|
|
@@ -3,10 +3,13 @@ package cn.com.taiji.ias.manager.valid; |
|
|
|
import cn.com.taiji.common.manager.AbstractManager; |
|
|
|
import cn.com.taiji.common.manager.net.http.ServiceHandleException; |
|
|
|
import cn.com.taiji.common.pub.BeanTools; |
|
|
|
import cn.com.taiji.core.entity.log.IasInterfaceLog; |
|
|
|
import cn.com.taiji.core.entity.ygz.DaspOfflineHasSend; |
|
|
|
import cn.com.taiji.core.manager.comm.LogManager; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckRequest; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckResponse; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError; |
|
|
|
import cn.com.taiji.core.repo.jpa.log.IasInterfaceLogRepo; |
|
|
|
import cn.com.taiji.core.repo.jpa.ygz.DaspOfflineHasSendRepo; |
|
|
|
import cn.com.taiji.sdk2.comm.BspClientHelper; |
|
|
|
import cn.com.taiji.sdk2.model.comm.protocol.iss.offLine.issue.IssuePCOFLRequest; |
|
|
@@ -21,42 +24,49 @@ import java.time.LocalDateTime; |
|
|
|
import java.util.Random; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class VehiclePlateCheckManager extends AbstractManager { |
|
|
|
public class VehiclePlateCheckManager extends AbstractManager implements LogManager<VehiclePlateCheckRequest, VehiclePlateCheckResponse, IasInterfaceLog> { |
|
|
|
|
|
|
|
public static final int MAX = 9999; |
|
|
|
private final Random random = new Random(); |
|
|
|
@Autowired |
|
|
|
private DaspOfflineHasSendRepo sendRepo; |
|
|
|
@Autowired |
|
|
|
private IasInterfaceLogRepo logRepo; |
|
|
|
|
|
|
|
public VehiclePlateCheckResponse serviceHandle(VehiclePlateCheckRequest req) throws ServiceHandleException { |
|
|
|
|
|
|
|
if (hasText(req.getCustomerId())) { |
|
|
|
DaspOfflineHasSend po = sendRepo.findInfoById(req.getCustomerId()); |
|
|
|
if (po == null || po.getOfflineOpenId() == null) |
|
|
|
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("该用户没有成功上传,请确认用户上传情况"); |
|
|
|
|
|
|
|
} |
|
|
|
int rowNum = random.nextInt(MAX) % MAX + 1; |
|
|
|
DaspOfflineHasSend userHasSend = sendRepo.findOneByRowNum(String.valueOf(rowNum)); |
|
|
|
refreshToken(userHasSend); |
|
|
|
IssuePCOFLRequest issuePCOFLRequest = new IssuePCOFLRequest(); |
|
|
|
issuePCOFLRequest.setAccessToken(userHasSend.getOfflineToken()); |
|
|
|
issuePCOFLRequest.setOpenId(userHasSend.getOfflineOpenId()); |
|
|
|
issuePCOFLRequest.setAccountId(userHasSend.getOfflineTransId()); |
|
|
|
issuePCOFLRequest.setPlateNum(req.getVehiclePlate()); |
|
|
|
issuePCOFLRequest.setPlateColor(req.getVehiclePlateColor()); |
|
|
|
// 校验结果 1-发行方已办理 2-统一平台办理 3-未关联 4-未办理 5办理中 |
|
|
|
IssuePCOFLResponse response = null; |
|
|
|
try { |
|
|
|
response = BspClientHelper.binPostUrl(issuePCOFLRequest); |
|
|
|
} catch (IOException e) { |
|
|
|
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("BRZ接口请求异常"); |
|
|
|
long begin = System.currentTimeMillis(); |
|
|
|
if (hasText(req.getCustomerId())) { |
|
|
|
DaspOfflineHasSend po = sendRepo.findInfoById(req.getCustomerId()); |
|
|
|
if (po == null || po.getOfflineOpenId() == null) |
|
|
|
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("该用户没有成功上传,请确认用户上传情况"); |
|
|
|
|
|
|
|
} |
|
|
|
int rowNum = random.nextInt(MAX) % MAX + 1; |
|
|
|
DaspOfflineHasSend userHasSend = sendRepo.findOneByRowNum(String.valueOf(rowNum)); |
|
|
|
refreshToken(userHasSend); |
|
|
|
IssuePCOFLRequest issuePCOFLRequest = new IssuePCOFLRequest(); |
|
|
|
issuePCOFLRequest.setAccessToken(userHasSend.getOfflineToken()); |
|
|
|
issuePCOFLRequest.setOpenId(userHasSend.getOfflineOpenId()); |
|
|
|
issuePCOFLRequest.setAccountId(userHasSend.getOfflineTransId()); |
|
|
|
issuePCOFLRequest.setPlateNum(req.getVehiclePlate()); |
|
|
|
issuePCOFLRequest.setPlateColor(req.getVehiclePlateColor()); |
|
|
|
// 校验结果 1-发行方已办理 2-统一平台办理 3-未关联 4-未办理 5办理中 |
|
|
|
IssuePCOFLResponse response = null; |
|
|
|
try { |
|
|
|
response = BspClientHelper.binPostUrl(issuePCOFLRequest); |
|
|
|
} catch (IOException e) { |
|
|
|
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("BRZ接口请求异常"); |
|
|
|
} |
|
|
|
if (response == null) |
|
|
|
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("调用部中心校验车牌接口失败"); |
|
|
|
VehiclePlateCheckResponse res = new VehiclePlateCheckResponse(); |
|
|
|
BeanTools.copyProperties(response, res); |
|
|
|
return onSuccess(req, res, IasInterfaceLog.class, System.currentTimeMillis() - begin); |
|
|
|
} catch (ServiceHandleException e) { |
|
|
|
logger.error("车牌校验接口请求异常", e); |
|
|
|
throw exception(req, IasInterfaceLog.class, e.getMessage()); |
|
|
|
} |
|
|
|
if (response == null) |
|
|
|
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("调用部中心校验车牌接口失败"); |
|
|
|
VehiclePlateCheckResponse res = new VehiclePlateCheckResponse(); |
|
|
|
BeanTools.copyProperties(response, res); |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
private void refreshToken(DaspOfflineHasSend userHasSend) throws ServiceHandleException { |
|
|
@@ -71,7 +81,7 @@ public class VehiclePlateCheckManager extends AbstractManager { |
|
|
|
try { |
|
|
|
res = BspClientHelper.binPostUrl(req); |
|
|
|
} catch (IOException e) { |
|
|
|
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("BRZ接口请求异常"); |
|
|
|
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("BRZ1接口请求异常"); |
|
|
|
} |
|
|
|
if (res != null && res.getInfo().contains("成功")) { |
|
|
|
userHasSend.setOfflineToken(res.getAccessToken()); |
|
|
@@ -81,4 +91,9 @@ public class VehiclePlateCheckManager extends AbstractManager { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void doSaveLog(VehiclePlateCheckRequest request, VehiclePlateCheckResponse response, IasInterfaceLog log) { |
|
|
|
logRepo.persist(log); |
|
|
|
} |
|
|
|
|
|
|
|
} |