Commit d22af23c authored by zhangzhenbang's avatar zhangzhenbang

健康码

parent aa33fb71
...@@ -6,6 +6,7 @@ import com.yingxin.beijingvehicleflow.dto.ReservationInfoDTO; ...@@ -6,6 +6,7 @@ import com.yingxin.beijingvehicleflow.dto.ReservationInfoDTO;
import com.yingxin.beijingvehicleflow.dto.ReservationsDisplayDTO; import com.yingxin.beijingvehicleflow.dto.ReservationsDisplayDTO;
import com.yingxin.beijingvehicleflow.entity.IdentityInformation; import com.yingxin.beijingvehicleflow.entity.IdentityInformation;
import com.yingxin.beijingvehicleflow.entity.Reservation; import com.yingxin.beijingvehicleflow.entity.Reservation;
import com.yingxin.beijingvehicleflow.exception.SystemException;
import com.yingxin.beijingvehicleflow.response.Response; import com.yingxin.beijingvehicleflow.response.Response;
import com.yingxin.beijingvehicleflow.service.AuthService; import com.yingxin.beijingvehicleflow.service.AuthService;
import com.yingxin.beijingvehicleflow.service.IdentityInformationService; import com.yingxin.beijingvehicleflow.service.IdentityInformationService;
...@@ -127,7 +128,7 @@ public class IdentityInfoController { ...@@ -127,7 +128,7 @@ public class IdentityInfoController {
@Autowired @Autowired
private ReservationService reservationService; private ReservationService reservationService;
/** /**
* 认证接口,此处不用再次判断身份证号码 * 认证接口,此处不用再次判断身份证号码 【二维码生成-----一所健康码】
* *
* 1.图片压缩 * 1.图片压缩
* *
...@@ -154,11 +155,28 @@ public class IdentityInfoController { ...@@ -154,11 +155,28 @@ public class IdentityInfoController {
if (!reservationService.isUpdateAuthInfoSucc(reservation)) { if (!reservationService.isUpdateAuthInfoSucc(reservation)) {
return Response.fail("UPDATE-FAILED","更新预约单认证信息失败"); return Response.fail("UPDATE-FAILED","更新预约单认证信息失败");
} }
EncodeData encodeData = new EncodeData(reservationInfoDTO); EncodeData encodeData = new EncodeData(reservationInfoDTO).encodeData();
return new Response<EncodeData>(true,"","", encodeData.encodeData()); /*生成一所健康二维码*/
String qrCode;
try {
qrCode = identityInformationService.getFriQRCode(encodeData.getQrCodeData());
} catch (SystemException e) {
LOGGER.error(e.getCode()+"->"+e.getMsg(), e);
return Response.fail(e.getCode(), e.getMsg());
}
encodeData.setQrCodeData(qrCode);
return new Response<EncodeData>(true,"","", encodeData);
} }
/**
* 曾经的解密接口【二维码解密-----一所健康码】
*
* @date 2020/2/25
* @param json
* @return com.yingxin.beijingvehicleflow.response.Response
*/
@PostMapping("/identity/code") @PostMapping("/identity/code")
public Response selectOneByEncodedId(@RequestBody String json) { public Response selectOneByEncodedId(@RequestBody String json) {
IdentityInformation info; IdentityInformation info;
...@@ -167,7 +185,16 @@ public class IdentityInfoController { ...@@ -167,7 +185,16 @@ public class IdentityInfoController {
try { try {
JSONObject jsonObject = JSONObject.fromObject(json); JSONObject jsonObject = JSONObject.fromObject(json);
String encodedData = jsonObject.getString("encodedData"); String encodedData = jsonObject.getString("encodedData");
String datafterDecryptStr = DesUtil.decrypt(Const.KEY, encodedData);
/*解密一所健康二维码*/
String qrDate;
try {
qrDate = identityInformationService.validateFriQRCode(encodedData);
} catch (SystemException e) {
LOGGER.error(e.getCode()+"->"+e.getMsg(), e);
return Response.fail(e.getCode(), e.getMsg());
}
String datafterDecryptStr = DesUtil.decrypt(Const.KEY, qrDate);
datafterDecryptJson = JSONObject.fromObject(datafterDecryptStr); datafterDecryptJson = JSONObject.fromObject(datafterDecryptStr);
String authTime = datafterDecryptJson.getString("authTime"); String authTime = datafterDecryptJson.getString("authTime");
......
...@@ -19,7 +19,7 @@ import java.util.HashMap; ...@@ -19,7 +19,7 @@ import java.util.HashMap;
public class EncodeData { public class EncodeData {
private ReservationInfoDTO data; private ReservationInfoDTO data;
private String encodedData; private String qrCodeData;
public EncodeData(ReservationInfoDTO data) { public EncodeData(ReservationInfoDTO data) {
this.data = data; this.data = data;
...@@ -32,7 +32,7 @@ public class EncodeData { ...@@ -32,7 +32,7 @@ public class EncodeData {
map.put("id",data.getReservation().getId()); map.put("id",data.getReservation().getId());
JSONObject jsonObject = JSONObject.fromObject(map); JSONObject jsonObject = JSONObject.fromObject(map);
encodedData = DesUtil.encrypt(Const.KEY, jsonObject.toString()); qrCodeData = DesUtil.encrypt(Const.KEY, jsonObject.toString());
return this; return this;
} }
......
package com.yingxin.beijingvehicleflow.exception;
/**
* 异常基类
*
* @author zhangzhenbang
* @version 1.0
* @date 2019/11/23
*/
public class BasicException extends Throwable{
private String msg;
private String code;
public BasicException(String code, String msg) {
this.code = code;
this.msg = msg;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
package com.yingxin.beijingvehicleflow.exception;
/**
* 客户异常,需要向外吐出的异常信息
*
* @author zhangzhenbang
* @version 1.0
* @date 2019/11/23
*/
public class CustomerException extends BasicException {
public CustomerException(String code, String msg) {
super(code, msg);
}
}
package com.yingxin.beijingvehicleflow.exception;
/**
* 系统异常,最后需要统一口径的异常
*
* @author zhangzhenbang
* @version 1.0
* @date 2019/11/23
*/
public class SystemException extends BasicException {
public SystemException(String code, String msg) {
super(code, msg);
}
}
package com.yingxin.beijingvehicleflow.exception;
/**
* 一般为日志异常
*
* @author zhangzhenbang
* @version 1.0
* @date 2019/11/23
*/
public class UnimportantException extends BasicException {
public UnimportantException(String code, String msg) {
super(code, msg);
}
}
...@@ -3,6 +3,7 @@ package com.yingxin.beijingvehicleflow.service; ...@@ -3,6 +3,7 @@ package com.yingxin.beijingvehicleflow.service;
import com.yingxin.beijingvehicleflow.dto.ReservationsDisplayDTO; import com.yingxin.beijingvehicleflow.dto.ReservationsDisplayDTO;
import com.yingxin.beijingvehicleflow.entity.IdentityInformation; import com.yingxin.beijingvehicleflow.entity.IdentityInformation;
import com.yingxin.beijingvehicleflow.entity.Reservation; import com.yingxin.beijingvehicleflow.entity.Reservation;
import com.yingxin.beijingvehicleflow.exception.SystemException;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import java.util.List; import java.util.List;
...@@ -48,4 +49,7 @@ public interface IdentityInformationService { ...@@ -48,4 +49,7 @@ public interface IdentityInformationService {
IdentityInformation getAllIdentityInfoById(int id); IdentityInformation getAllIdentityInfoById(int id);
String getFriQRCode(String encodedDateStr) throws SystemException;
String validateFriQRCode(String qrCodeData) throws SystemException;
} }
...@@ -4,6 +4,7 @@ import com.yingxin.beijingvehicleflow.constant.Const; ...@@ -4,6 +4,7 @@ import com.yingxin.beijingvehicleflow.constant.Const;
import com.yingxin.beijingvehicleflow.dto.ReservationsDisplayDTO; import com.yingxin.beijingvehicleflow.dto.ReservationsDisplayDTO;
import com.yingxin.beijingvehicleflow.entity.IdentityInformation; import com.yingxin.beijingvehicleflow.entity.IdentityInformation;
import com.yingxin.beijingvehicleflow.entity.Reservation; import com.yingxin.beijingvehicleflow.entity.Reservation;
import com.yingxin.beijingvehicleflow.exception.SystemException;
import com.yingxin.beijingvehicleflow.mapper.IdentityInformationMapper; import com.yingxin.beijingvehicleflow.mapper.IdentityInformationMapper;
import com.yingxin.beijingvehicleflow.service.IdentityInformationService; import com.yingxin.beijingvehicleflow.service.IdentityInformationService;
import com.yingxin.beijingvehicleflow.util.PicUtils; import com.yingxin.beijingvehicleflow.util.PicUtils;
...@@ -13,6 +14,7 @@ import org.slf4j.LoggerFactory; ...@@ -13,6 +14,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
...@@ -23,6 +25,7 @@ import java.net.URLConnection; ...@@ -23,6 +25,7 @@ import java.net.URLConnection;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
...@@ -134,4 +137,54 @@ public class IdentityInformationServiceImpl implements IdentityInformationServic ...@@ -134,4 +137,54 @@ public class IdentityInformationServiceImpl implements IdentityInformationServic
public IdentityInformation getAllIdentityInfoById(int id) { public IdentityInformation getAllIdentityInfoById(int id) {
return identityInformationMapper.getAllIdentityInfoById(id); return identityInformationMapper.getAllIdentityInfoById(id);
} }
@Autowired
private RestTemplate restTemplate;
@Value("${create-QR-code-Fri-Url}")
private String friQrCodeGenerateUrl;
@Override
public String getFriQRCode(String encodedDateStr) throws SystemException{
HashMap<String,String> hashMap = new HashMap<>(4);
hashMap.put("bizExtData", encodedDateStr);
String response;
try {
response = restTemplate.postForObject(friQrCodeGenerateUrl,hashMap,String.class);
} catch (Exception e) {
LOGGER.error("一所二维码生成接口异常:" , e);
throw new SystemException("FRI_QR_CODE_GENERATE_FAILED", "一所二维码生成接口调用异常");
}
JSONObject responseJson = JSONObject.fromObject(response);
if (responseJson.getBoolean("success")) {
return responseJson.getString("qrCode");
}
throw new SystemException("FRI_QR_CODE_GENERATE_FAILED", responseJson.getString("errorDec"));
}
@Value("${validate-QR-code-Fri-Url}")
private String friQrCodeDecodeUrl;
@Override
public String validateFriQRCode(String qrCodeData) throws SystemException{
HashMap<String,String> hashMap = new HashMap<>(4);
hashMap.put("qrCode", qrCodeData);
String response;
try {
response = restTemplate.postForObject(friQrCodeDecodeUrl,hashMap,String.class);
} catch (Exception e) {
LOGGER.error("一所二维码校验接口异常:" , e);
throw new SystemException("FRI_QR_CODE_VALIDATE_FAILED", "一所二维码校验接口调用异常");
}
JSONObject responseJson = JSONObject.fromObject(response);
if (responseJson.getBoolean("success")) {
return responseJson.getString("bizExtData");
}
throw new SystemException("FRI_QR_CODE_GENERATE_FAILED", responseJson.getString("errorDec"));
}
} }
...@@ -33,6 +33,8 @@ restTemplate: ...@@ -33,6 +33,8 @@ restTemplate:
validateAfterInactivity: 30000 validateAfterInactivity: 30000
QR-code-validTime: 30 QR-code-validTime: 30
create-QR-code-Fri-Url: http://121.22.111.253:9000/api/code/create
validate-QR-code-Fri-Url: http://121.22.111.253:9000/api/code/validate
async-Config: async-Config:
MAX-POOL-SIZE: 50 MAX-POOL-SIZE: 50
......
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