Commit 55e3e63b by 牟邦恺

添加驾驶证图片反面查看

parent 41c57542
...@@ -5,6 +5,7 @@ import com.hikcreate.common.sdk.exception.BusinessException; ...@@ -5,6 +5,7 @@ import com.hikcreate.common.sdk.exception.BusinessException;
import com.hikcreate.common.sdk.response.apiparam.Response; import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.common.sdk.response.apiparam.ResponseGenerator; import com.hikcreate.common.sdk.response.apiparam.ResponseGenerator;
import com.hikcreate.common.sdk.response.statuscode.StatusCode; import com.hikcreate.common.sdk.response.statuscode.StatusCode;
import com.hikcreate.edl.common.image.builder.domain.DlBackImageDO;
import com.hikcreate.edl.common.image.builder.domain.DlImageDO; import com.hikcreate.edl.common.image.builder.domain.DlImageDO;
import com.hikcreate.edl.pub.web.mobile.domain.CredentialsImageService; import com.hikcreate.edl.pub.web.mobile.domain.CredentialsImageService;
import com.hikcreate.edl.pub.web.mobile.domain.DrivingLicenseService; import com.hikcreate.edl.pub.web.mobile.domain.DrivingLicenseService;
...@@ -34,6 +35,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -34,6 +35,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Objects;
/** /**
* 驾驶证图片接口 * 驾驶证图片接口
...@@ -84,12 +86,15 @@ public class DrivingLicenseController { ...@@ -84,12 +86,15 @@ public class DrivingLicenseController {
} }
@GetMapping("/image") @GetMapping("/image")
public void image(@RequestParam("userId") String userId, @RequestParam("idCard") String idCard, HttpServletResponse response) { public void image(@RequestParam("userId") String userId, @RequestParam("idCard") String idCard, @RequestParam("type") Integer type, HttpServletResponse response) {
// 验证是否有查看权限 // 验证是否有查看权限
if (!drivingLicenseService.checkValid(userId, idCard) && !iBindService.checkValid(userId,idCard)) { if (!drivingLicenseService.checkValid(userId, idCard) && !iBindService.checkValid(userId,idCard)) {
throw new BusinessException(StatusCode.PARAM_ERROR); throw new BusinessException(StatusCode.PARAM_ERROR);
} }
DrivingLicenseMicRes drivingLicenseMicRes = drivingLicenseFeign.getByIdCard(new CreditIdCardMicReq().setIdCard(idCard)).fallback().getData(); DrivingLicenseMicRes drivingLicenseMicRes = drivingLicenseFeign.getByIdCard(new CreditIdCardMicReq().setIdCard(idCard)).fallback().getData();
ByteArrayOutputStream outputStream;
if(type == null || Objects.equals(type, 1)) {
DlImageDO dlImageDO = new DlImageDO(); DlImageDO dlImageDO = new DlImageDO();
dlImageDO.setAddress(drivingLicenseMicRes.getAddress()); dlImageDO.setAddress(drivingLicenseMicRes.getAddress());
dlImageDO.setBelowLicenseNumber(drivingLicenseMicRes.getIdCard()); dlImageDO.setBelowLicenseNumber(drivingLicenseMicRes.getIdCard());
...@@ -105,8 +110,13 @@ public class DrivingLicenseController { ...@@ -105,8 +110,13 @@ public class DrivingLicenseController {
dlImageDO.setValidityPeriod(drivingLicenseMicRes.getEffectiveDate() + "至" + drivingLicenseMicRes.getExpiryDate()); dlImageDO.setValidityPeriod(drivingLicenseMicRes.getEffectiveDate() + "至" + drivingLicenseMicRes.getExpiryDate());
dlImageDO.setRecord(""); dlImageDO.setRecord("");
dlImageDO.setFileNumber(drivingLicenseMicRes.getFileNum()); dlImageDO.setFileNumber(drivingLicenseMicRes.getFileNum());
ByteArrayOutputStream outputStream = (ByteArrayOutputStream) credentialsImageService.genDlImage(dlImageDO); outputStream = (ByteArrayOutputStream) credentialsImageService.genDlImage(dlImageDO);
} else {
DlBackImageDO dlBackImageDO = new DlBackImageDO();
dlBackImageDO.setRecordContents("");
dlBackImageDO.setSerialNum("");
outputStream = (ByteArrayOutputStream) credentialsImageService.genDlBackImage(dlBackImageDO);
}
try { try {
setHeader(response, drivingLicenseMicRes.getIdCard() + ".jpg"); setHeader(response, drivingLicenseMicRes.getIdCard() + ".jpg");
response.getOutputStream().write(outputStream.toByteArray()); response.getOutputStream().write(outputStream.toByteArray());
......
package com.hikcreate.edl.pub.web.mobile.domain; package com.hikcreate.edl.pub.web.mobile.domain;
import com.hikcreate.edl.common.image.builder.domain.DlBackImageDO;
import com.hikcreate.edl.common.image.builder.domain.DlImageDO; import com.hikcreate.edl.common.image.builder.domain.DlImageDO;
import java.io.OutputStream; import java.io.OutputStream;
...@@ -17,4 +18,13 @@ public interface CredentialsImageService { ...@@ -17,4 +18,13 @@ public interface CredentialsImageService {
* @return * @return
*/ */
OutputStream genDlImage(DlImageDO params); OutputStream genDlImage(DlImageDO params);
/**
* 生成驾驶证背面图片
*
* @param params 参数
* @return
*/
OutputStream genDlBackImage(DlBackImageDO params);
} }
...@@ -2,6 +2,7 @@ package com.hikcreate.edl.pub.web.mobile.domain.impl; ...@@ -2,6 +2,7 @@ package com.hikcreate.edl.pub.web.mobile.domain.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hikcreate.common.sdk.exception.BusinessException; import com.hikcreate.common.sdk.exception.BusinessException;
import com.hikcreate.edl.common.image.builder.domain.DlBackImageDO;
import com.hikcreate.edl.common.image.builder.domain.DlImageDO; import com.hikcreate.edl.common.image.builder.domain.DlImageDO;
import com.hikcreate.edl.common.image.builder.refactor.DrawDispatcher; import com.hikcreate.edl.common.image.builder.refactor.DrawDispatcher;
import com.hikcreate.edl.pub.web.mobile.domain.CredentialsImageService; import com.hikcreate.edl.pub.web.mobile.domain.CredentialsImageService;
...@@ -18,6 +19,7 @@ import java.io.OutputStream; ...@@ -18,6 +19,7 @@ import java.io.OutputStream;
@Slf4j @Slf4j
@Service @Service
public class CredentialsImageServiceImpl implements CredentialsImageService { public class CredentialsImageServiceImpl implements CredentialsImageService {
@Autowired @Autowired
private DrawDispatcher drawDispatcher; private DrawDispatcher drawDispatcher;
...@@ -32,4 +34,23 @@ public class CredentialsImageServiceImpl implements CredentialsImageService { ...@@ -32,4 +34,23 @@ public class CredentialsImageServiceImpl implements CredentialsImageService {
} }
return outputStream; return outputStream;
} }
/**
* 生成驾驶证背面图片
*
* @param params 参数
* @return
*/
@Override
public OutputStream genDlBackImage(DlBackImageDO params) {
OutputStream outputStream;
try {
outputStream = drawDispatcher.drawDlBack(params);
} catch (Exception e) {
log.error("Gen DrivingLicense back Image Error, param={}, msg={}", JSONObject.toJSONString(params), e);
throw new BusinessException("获取驾驶证图片失败");
}
return outputStream;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment