|
@@ -0,0 +1,479 @@
|
|
|
|
+package info.aspirecn.iov.yysj.product.check.common;
|
|
|
|
+
|
|
|
|
+import java.io.BufferedReader;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStreamReader;
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.*;
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+
|
|
|
|
+import info.aspirecn.cloud.yysj.commons.lang.BillItemResult;
|
|
|
|
+import info.aspirecn.cloud.yysj.commons.lang.Constants;
|
|
|
|
+import info.aspirecn.cloud.yysj.commons.lang.OtherCommonResult;
|
|
|
|
+import info.aspirecn.iov.yysj.product.check.entity.*;
|
|
|
|
+import org.apache.commons.lang.ArrayUtils;
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
+import com.google.gson.Gson;
|
|
|
|
+import com.netflix.zuul.context.RequestContext;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+@Component
|
|
|
|
+@Slf4j
|
|
|
|
+public class ZuulHelper {
|
|
|
|
+ @Autowired
|
|
|
|
+ private ObjectMapper mapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ Gson gson;
|
|
|
|
+ @Autowired
|
|
|
|
+ StringRedisTemplate stringTemplate;
|
|
|
|
+ @Autowired
|
|
|
|
+ private Property property;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ChannelRibbonHandle channelRibbonHandle;
|
|
|
|
+ @Value("#{'${common.errorCode}'.split(',')}")
|
|
|
|
+ List<String> errorCode;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ZuulHelper helper;
|
|
|
|
+ public Boolean hasProcessFlag(RequestContext requestContext) {
|
|
|
|
+
|
|
|
|
+ Boolean ret = (Boolean)requestContext.get("process");
|
|
|
|
+ if( ret != null )
|
|
|
|
+ {
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return Boolean.FALSE;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void responseHandle(BillItemResult responseObject, RequestContext requestContext) throws JsonProcessingException{
|
|
|
|
+ String json = mapper.writeValueAsString(responseObject);
|
|
|
|
+ requestContext.set("process", Boolean.TRUE);
|
|
|
|
+ requestContext.setResponseBody(json);
|
|
|
|
+ requestContext.getResponse().setCharacterEncoding("utf-8");
|
|
|
|
+ requestContext.getResponse().setContentType("application/json");
|
|
|
|
+ requestContext.setSendZuulResponse(false);
|
|
|
|
+ requestContext.setResponseStatusCode(HttpServletResponse.SC_OK);// 返回码
|
|
|
|
+ }
|
|
|
|
+ public void responseHandleCommon(Object object, RequestContext requestContext) throws JsonProcessingException{
|
|
|
|
+ String json = mapper.writeValueAsString(object);
|
|
|
|
+ requestContext.set("process", Boolean.TRUE);
|
|
|
|
+ requestContext.setResponseBody(json);
|
|
|
|
+ requestContext.getResponse().setCharacterEncoding("utf-8");
|
|
|
|
+ requestContext.getResponse().setContentType("application/json");
|
|
|
|
+ requestContext.setSendZuulResponse(false);
|
|
|
|
+ requestContext.setResponseStatusCode(HttpServletResponse.SC_OK);// 返回码
|
|
|
|
+ }
|
|
|
|
+ //获取请求参数
|
|
|
|
+ public String getCustomBody(HttpServletRequest request) throws UnsupportedEncodingException, IOException{
|
|
|
|
+ StringBuilder body = new StringBuilder();
|
|
|
|
+ BufferedReader bufferedReader = new BufferedReader(
|
|
|
|
+ new InputStreamReader(request.getInputStream(), "utf-8")); // 读取参数流
|
|
|
|
+ String nextLine = bufferedReader.readLine();
|
|
|
|
+ while (nextLine != null) {
|
|
|
|
+ body.append(nextLine);
|
|
|
|
+ nextLine = bufferedReader.readLine();
|
|
|
|
+ }
|
|
|
|
+ String bodyStr = body.toString();
|
|
|
|
+
|
|
|
|
+ return bodyStr;
|
|
|
|
+ }
|
|
|
|
+ //根据响应参数,判断结果
|
|
|
|
+ public void handleResult(String productId,ResponseObject responseObject,Map<String,Object> requestParams,BillItemResult billItemResult){
|
|
|
|
+ Set<String> inconsistentList = new HashSet<String>();//不一致项列表
|
|
|
|
+ Set<String> emptyList = new HashSet<String>();
|
|
|
|
+ String result =Constants.consistent_code;
|
|
|
|
+ BillItemResult.ErrorResponse errorResponse =new BillItemResult.ErrorResponse();
|
|
|
|
+ try {
|
|
|
|
+ String resultBody = "";
|
|
|
|
+ if (responseObject.getResultBody() instanceof String) {
|
|
|
|
+ resultBody = (String) responseObject.getResultBody();
|
|
|
|
+ } else {
|
|
|
|
+ resultBody = mapper.writeValueAsString(responseObject.getResultBody());
|
|
|
|
+ }
|
|
|
|
+ if(errorCode.contains(responseObject.getResultCode())){
|
|
|
|
+ errorResponse.setCode(Constants.ErrorCode.Exception.getErrorCode());
|
|
|
|
+ billItemResult.setResult(Constants.inconsistent_code);
|
|
|
|
+ billItemResult.setExceptionInformation(errorResponse);
|
|
|
|
+ return ;
|
|
|
|
+ }
|
|
|
|
+ Map<String, String> productMap = property.getProductMap();
|
|
|
|
+ if (productMap.get("clxszyz").equals(productId)) {//行驶证
|
|
|
|
+
|
|
|
|
+ if ("128".equals(responseObject.getResultCode())||"1000".equals(responseObject.getResultCode())) {
|
|
|
|
+
|
|
|
|
+ Map<String, String> responseParams = mapper.readValue(resultBody, Map.class);
|
|
|
|
+ //使用性质、车辆识别代号、发证机关、注册日期、发证日期
|
|
|
|
+ if ("不一致".equals(responseParams.get("isOwner"))) {
|
|
|
|
+
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ inconsistentList.add(Constants.car_owner);
|
|
|
|
+ }
|
|
|
|
+ String resp_vin=responseParams.get(Constants.clxszyz_vin);
|
|
|
|
+ if (StringUtils.isEmpty(resp_vin)) {
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ emptyList.add(Constants.car_vin);
|
|
|
|
+
|
|
|
|
+ } else if (!requestParams.get(Constants.car_vin).equals(resp_vin)) {
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ inconsistentList.add(Constants.car_vin);
|
|
|
|
+ }
|
|
|
|
+ String resp_register_date=responseParams.get(Constants.clxszyz_register_date);
|
|
|
|
+ if (StringUtils.isEmpty(resp_register_date)) {
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ emptyList.add(Constants.car_registerDate);
|
|
|
|
+ } else {
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ SimpleDateFormat ymdSdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
+ String resigerDate = ymdSdf.format(sdf.parse(resp_register_date));
|
|
|
|
+ if (!resigerDate.equals(requestParams.get(Constants.car_registerDate))) {
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ inconsistentList.add(Constants.car_registerDate);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else if("129".equals(responseObject.getResultCode()) ||"1099".equals(responseObject.getResultCode())){
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ emptyList.add(Constants.car_vehicleNumber);
|
|
|
|
+ emptyList.add(Constants.car_vehicleType);
|
|
|
|
+ emptyList.add(Constants.car_owner);
|
|
|
|
+ }else {
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ inconsistentList.add(Constants.car_vehicleNumber);
|
|
|
|
+ inconsistentList.add(Constants.car_vehicleType);
|
|
|
|
+ inconsistentList.add(Constants.car_owner);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (emptyList.size() != 0) {
|
|
|
|
+
|
|
|
|
+ errorResponse.setCode(Constants.ErrorCode.NULL.getErrorCode());
|
|
|
|
+ errorResponse.setResultList(emptyList);
|
|
|
|
+ } else if (inconsistentList.size() != 0) {
|
|
|
|
+ errorResponse.setCode(Constants.ErrorCode.INCONSISTENT_DETAIL.getErrorCode());
|
|
|
|
+ errorResponse.setResultList(inconsistentList);
|
|
|
|
+ //errorInfo = "数据源" + StringUtils.join(emptyList.toArray(), ",") + "为不一致";
|
|
|
|
+ }
|
|
|
|
+ } else if (productMap.get("ryjszyz").equals(productId)) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if ("124".equals(responseObject.getResultCode())||"1000".equals(responseObject.getResultCode())) {
|
|
|
|
+ Map<String, String> responseParams = mapper.readValue(resultBody, Map.class);
|
|
|
|
+ //准驾车型、有效期自、有效期至
|
|
|
|
+ String zjcx = responseParams.get("ZJCX");
|
|
|
|
+ if (StringUtils.isEmpty(zjcx)) {
|
|
|
|
+ emptyList.add(Constants.driver_vehicleClass);
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ } else if (!requestParams.get(Constants.driver_vehicleClass).equals(zjcx)) {
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ inconsistentList.add(Constants.driver_vehicleClass);
|
|
|
|
+ }
|
|
|
|
+ String qsyxqStr=responseParams.get("QSYXQ");
|
|
|
|
+ String jsyxqStr=responseParams.get("JSYXQ");
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ SimpleDateFormat ymdSdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
+ if (qsyxqStr == null || qsyxqStr.length() < 10) {
|
|
|
|
+ emptyList.add(Constants.driver_validPeriodFrom);
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ } else {
|
|
|
|
+ String qsyxq = qsyxqStr.substring(0, 10);
|
|
|
|
+ if (!requestParams.get(Constants.driver_validPeriodFrom).equals(ymdSdf.format(sdf.parse(qsyxq)))) {
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ inconsistentList.add(Constants.driver_validPeriodFrom);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (jsyxqStr == null || jsyxqStr.length() < 10) {
|
|
|
|
+ emptyList.add(Constants.driver_validPeriodTo);
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ } else {
|
|
|
|
+ String jsyxq = jsyxqStr.substring(0, 10);
|
|
|
|
+ if (!requestParams.get(Constants.driver_validPeriodTo).equals(ymdSdf.format(sdf.parse(jsyxq)))) {
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ inconsistentList.add(Constants.driver_validPeriodTo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else if("125".equals(responseObject.getResultCode())||"1099".equals(responseObject.getResultCode())){
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ emptyList.add(Constants.driver_driverNamer);
|
|
|
|
+ emptyList.add(Constants.driver_driverLicenseNumber);
|
|
|
|
+ }else {
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ inconsistentList.add(Constants.driver_driverNamer);
|
|
|
|
+ inconsistentList.add(Constants.driver_driverLicenseNumber);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (emptyList.size() != 0) {
|
|
|
|
+
|
|
|
|
+ errorResponse.setCode(Constants.ErrorCode.NULL.getErrorCode());
|
|
|
|
+ errorResponse.setResultList(emptyList);
|
|
|
|
+ } else if (inconsistentList.size() != 0) {
|
|
|
|
+ errorResponse.setCode(Constants.ErrorCode.INCONSISTENT_DETAIL.getErrorCode());
|
|
|
|
+ errorResponse.setResultList(inconsistentList);
|
|
|
|
+ //errorInfo = "数据源" + StringUtils.join(emptyList.toArray(), ",") + "为不一致";
|
|
|
|
+ }
|
|
|
|
+ } else if(productMap.get("czyz").equals(productId)){
|
|
|
|
+ if (!"1".equals(responseObject.getResultCode())) {
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ if ("2".equals(responseObject.getResultCode())) {
|
|
|
|
+ errorResponse.setCode(Constants.ErrorCode.WEIGTHOVER.getErrorCode());
|
|
|
|
+ }else{
|
|
|
|
+ errorResponse = mapper.readValue(resultBody, BillItemResult.ErrorResponse.class);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if(productMap.get("sfzyz").equals(productId)){
|
|
|
|
+ if (!"114".equals(responseObject.getResultCode()) && !"1174".equals(responseObject.getResultCode())) {
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ inconsistentList.add(Constants.persontyr_name);
|
|
|
|
+ inconsistentList.add(Constants.persontyr_idCode);
|
|
|
|
+ errorResponse.setCode(Constants.ErrorCode.INCONSISTENT_DETAIL.getErrorCode());
|
|
|
|
+ errorResponse.setResultList(inconsistentList);
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ if (!"1".equals(responseObject.getResultCode())) {
|
|
|
|
+ /*if("3".equals(responseObject.getResultCode())){
|
|
|
|
+ errorResponse.setCode(Constants.ErrorCode.Exception.getErrorCode());
|
|
|
|
+ billItemResult.setResult(Constants.inconsistent_code);
|
|
|
|
+ billItemResult.setExceptionInformation(errorResponse);
|
|
|
|
+ return ;
|
|
|
|
+ }*/
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ errorResponse = mapper.readValue(resultBody, BillItemResult.ErrorResponse.class);
|
|
|
|
+
|
|
|
|
+ /*Object resultObj = map.get("resultList");
|
|
|
|
+ List list = null;
|
|
|
|
+ if (resultObj instanceof LinkedList) {
|
|
|
|
+ list = (List) resultObj;
|
|
|
|
+ transferParam(productMap, productId, list);
|
|
|
|
+ }
|
|
|
|
+ if ("1".equals(map.get("code"))) {
|
|
|
|
+
|
|
|
|
+ errorInfo = "数据源" + StringUtils.join(list.toArray(), ",") + "为空";
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ errorInfo = "数据源" + StringUtils.join(list.toArray(), ",") + "为空";
|
|
|
|
+
|
|
|
|
+ }*/
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }catch(Exception ex){
|
|
|
|
+ log.error("解析参数异常,Exception:{}",ex);
|
|
|
|
+ result = Constants.inconsistent_code;
|
|
|
|
+ errorResponse.setCode(Constants.ErrorCode.Exception.getErrorCode());
|
|
|
|
+ }
|
|
|
|
+ billItemResult.setResult(result);
|
|
|
|
+ billItemResult.setExceptionInformation(errorResponse);
|
|
|
|
+ }
|
|
|
|
+ public void transferParam(Map<String,String> productMap,String productId,List<String> list){
|
|
|
|
+ List<String> removeList = new ArrayList<String>();
|
|
|
|
+ if (productMap.get("rycyzgyz").equals(productId)) {//人员从业资格验证
|
|
|
|
+ for(String param : list){
|
|
|
|
+ removeList.add(param);
|
|
|
|
+ if(Constants.rycyzgyz_nameOfPerson.equals(param)){
|
|
|
|
+ list.add(Constants.driver_driverNamer);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.rycyzgyz_qualificationCertificateNumber.equals(param)){
|
|
|
|
+ list.add(Constants.driver_qualificationCertificate);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.rycyzgyz_provinceCode.equals(param)){
|
|
|
|
+ list.add(Constants.driver_provinceCode);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.rycyzgyz_periodStartDate.equals(param)){
|
|
|
|
+ list.add(Constants.driver_qualificationCertificateFrom);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.rycyzgyz_periodEndDate.equals(param)){
|
|
|
|
+ list.add(Constants.driver_qualificationCertificateTo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }if (productMap.get("clyyyz").equals(productId)) {//车辆营运验证
|
|
|
|
+
|
|
|
|
+ for(String param : list){
|
|
|
|
+ removeList.add(param);
|
|
|
|
+ if(Constants.clyyyz_vehicleNumber.equals(param)){
|
|
|
|
+ list.add(Constants.car_vehicleNumber);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.clyyyz_licensePlateTypeCode.equals(param)){
|
|
|
|
+ list.add(Constants.car_vehiclePlateColorCode);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.clyyyz_roadTransportCertificateNumber.equals(param)){
|
|
|
|
+ list.add(Constants.car_roadTransport);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.clyyyz_periodStartDate.equals(param)){
|
|
|
|
+ list.add(Constants.car_roadTransportCertificateValidPeriodFrom);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.clyyyz_periodEndDate.equals(param)){
|
|
|
|
+ list.add(Constants.car_roadTransportCertificateValidPeriodTo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }if (productMap.get("qyyyxkyz_jyxkzh").equals(productId)) {//企业经营许可验证 经营许可证号
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for(String param : list){
|
|
|
|
+ removeList.add(param);
|
|
|
|
+ if(Constants.qyyyxkz_carrier.equals(param)){
|
|
|
|
+ list.add(Constants.bill_carrier);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.qyyyxkz_permitNumber.equals(param)){
|
|
|
|
+ list.add(Constants.bill_permitNumber);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.qyyyxkz_provinceCode.equals(param)){
|
|
|
|
+ list.add(Constants.bill_carrier);
|
|
|
|
+ list.add(Constants.bill_unifiedSocialCreditIdentifier);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }if (productMap.get("qyyyxkyz_tyshdm").equals(productId)) {//企业经营许可验证 统一社会代码
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for(String param : list){
|
|
|
|
+ removeList.add(param);
|
|
|
|
+ if(Constants.qyyyxkz_name.equals(param)){
|
|
|
|
+ list.add(Constants.bill_carrier);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.qyyyxkz_creditCode.equals(param)){
|
|
|
|
+ list.add(Constants.bill_unifiedSocialCreditIdentifier);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }if (productMap.get("clrwyz").equals(productId)) {//车辆入网验证
|
|
|
|
+
|
|
|
|
+ for(String param : list){
|
|
|
|
+ removeList.add(param);
|
|
|
|
+ if(Constants.clrw_vehicleNumber.equals(param)){
|
|
|
|
+ list.add(Constants.car_vehicleNumber);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.clrw_licensePlateTypeCode.equals(param)){
|
|
|
|
+ list.add(Constants.car_vehiclePlateColorCode);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }if (productMap.get("tyrsfyz_person").equals(productId)) {//托运人身份验证(个人)
|
|
|
|
+ for(String param : list){
|
|
|
|
+ removeList.add(param);
|
|
|
|
+ if(Constants.persontyr_name.equals(param)){
|
|
|
|
+ list.add(Constants.bill_consignor);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.persontyr_idCode.equals(param)){
|
|
|
|
+ list.add(Constants.bill_ConsignorID);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }if (productMap.get("tyrsfyz_enterprise").equals(productId)) {//托运人身份验证(企业)
|
|
|
|
+ for(String param : list){
|
|
|
|
+ removeList.add(param);
|
|
|
|
+ if(Constants.enterpricetyr_name.equals(param)){
|
|
|
|
+ list.add(Constants.bill_consignor);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.enterpricetyr_creditCode.equals(param)){
|
|
|
|
+ list.add(Constants.bill_ConsignorID);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }if (productMap.get("zhdwyz").equals(productId)) {//托运人身份验证(企业)
|
|
|
|
+ for(String param : list){
|
|
|
|
+ removeList.add(param);
|
|
|
|
+ if(Constants.enterpricetyr_name.equals(param)){
|
|
|
|
+ list.add(Constants.bill_consignor);
|
|
|
|
+ }
|
|
|
|
+ if(Constants.enterpricetyr_creditCode.equals(param)){
|
|
|
|
+ list.add(Constants.bill_ConsignorID);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ public ResponseObject getResult(SjjhTransferReq sjjhTransferReq,BillItemResult billItemResult) throws IOException {
|
|
|
|
+ BillItemResult.ErrorResponse errorResponse = new BillItemResult.ErrorResponse();
|
|
|
|
+
|
|
|
|
+ billItemResult.setResult(Constants.consistent_code);
|
|
|
|
+ RequestBody requestBody = new RequestBody();
|
|
|
|
+ requestBody.setAccessId(sjjhTransferReq.getAccessId());
|
|
|
|
+ requestBody.setProductId(sjjhTransferReq.getSjjhProductId());
|
|
|
|
+ requestBody.setCustomBody(sjjhTransferReq.getCustomBody());
|
|
|
|
+ String requestBodyStr = mapper.writeValueAsString(requestBody);
|
|
|
|
+ log.info("requestBodyStr:{}", requestBodyStr);
|
|
|
|
+ requestBodyStr = new String(requestBodyStr.getBytes(), "utf-8");
|
|
|
|
+ ResponseObject responseObject = channelRibbonHandle.channelRibbonHandle(sjjhTransferReq.getToken(), requestBodyStr);
|
|
|
|
+ if (responseObject == null) {//系统错误
|
|
|
|
+ billItemResult.setResult(Constants.inconsistent_code);
|
|
|
|
+ errorResponse.setCode(Constants.ErrorCode.Exception.getErrorCode());
|
|
|
|
+ billItemResult.setExceptionInformation(errorResponse);
|
|
|
|
+ } else {
|
|
|
|
+ helper.handleResult(sjjhTransferReq.getSjjhProductId(), responseObject, sjjhTransferReq.getOriginCustomBody(),billItemResult);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return responseObject;
|
|
|
|
+ }
|
|
|
|
+ public OtherCommonResult getOtherResult(SjjhTransferReq sjjhTransferReq) throws IOException {
|
|
|
|
+ OtherCommonResult otherCommonResult = new OtherCommonResult();
|
|
|
|
+ otherCommonResult.setResultCode(Constants.inconsistent_code);
|
|
|
|
+ RequestBody requestBody = new RequestBody();
|
|
|
|
+ requestBody.setAccessId(sjjhTransferReq.getAccessId());
|
|
|
|
+ requestBody.setProductId(sjjhTransferReq.getSjjhProductId());
|
|
|
|
+ requestBody.setCustomBody(sjjhTransferReq.getCustomBody());
|
|
|
|
+ String requestBodyStr = mapper.writeValueAsString(requestBody);
|
|
|
|
+ log.info("requestBodyStr:{}", requestBodyStr);
|
|
|
|
+ requestBodyStr = new String(requestBodyStr.getBytes(), "utf-8");
|
|
|
|
+ ResponseObject responseObject = channelRibbonHandle.channelRibbonHandle(sjjhTransferReq.getToken(), requestBodyStr);
|
|
|
|
+ if(responseObject!=null ){
|
|
|
|
+ if("1".equals(responseObject.getResultCode())) {
|
|
|
|
+
|
|
|
|
+ String resultBody = "";
|
|
|
|
+ if (responseObject.getResultBody() instanceof String) {
|
|
|
|
+ resultBody = (String) responseObject.getResultBody();
|
|
|
|
+ } else {
|
|
|
|
+ resultBody = mapper.writeValueAsString(responseObject.getResultBody());
|
|
|
|
+ }
|
|
|
|
+ Map<String,String> resultMap = mapper.readValue(resultBody,Map.class);
|
|
|
|
+ String url = RequestContext.getCurrentContext().getRequest().getHeader(Constants.Url);
|
|
|
|
+ if(Constants.OtherRquestUrl.LIVINGURL.getValue().equals(url)){
|
|
|
|
+ String similarity = resultMap.get("similarity");
|
|
|
|
+ double similarityDouble = Double.parseDouble(similarity);
|
|
|
|
+ if(similarityDouble>=85){
|
|
|
|
+ otherCommonResult.setResultCode(Constants.consistent_code);
|
|
|
|
+ }else{
|
|
|
|
+ otherCommonResult.setResultCode(Constants.inconsistent_code);
|
|
|
|
+ }
|
|
|
|
+ resultMap.clear();
|
|
|
|
+ resultMap.put("similarity",similarity);
|
|
|
|
+ }else if(Constants.OtherRquestUrl.IDLENTITYVERIFICATION.getValue().equals(url)){
|
|
|
|
+ String similarity = resultMap.get("similarity");
|
|
|
|
+ String appeidcode = resultMap.get("appeidcode");
|
|
|
|
+ String eIDvoucher = resultMap.get("eidvoucher");
|
|
|
|
+ String h1 = resultMap.get("h1");
|
|
|
|
+ /*String name = resultMap.get("name");
|
|
|
|
+ String idNumber = resultMap.get("idNumber");*/
|
|
|
|
+ double similarityDouble = Double.parseDouble(similarity);
|
|
|
|
+ if(similarityDouble>=85){
|
|
|
|
+ otherCommonResult.setResultCode(Constants.consistent_code);
|
|
|
|
+ }else{
|
|
|
|
+ otherCommonResult.setResultCode(Constants.inconsistent_code);
|
|
|
|
+ }
|
|
|
|
+ resultMap.clear();
|
|
|
|
+ resultMap.put("similarity",similarity);
|
|
|
|
+ resultMap.put("appeIdCode",appeidcode);
|
|
|
|
+ resultMap.put("eidVoucher",eIDvoucher);
|
|
|
|
+ resultMap.put("H1",h1);
|
|
|
|
+ //resultMap.put("idNumber",idNumber);
|
|
|
|
+ }
|
|
|
|
+ otherCommonResult.setResultBody(resultMap);
|
|
|
|
+ }else if(errorCode.contains(responseObject.getResultCode())){
|
|
|
|
+ otherCommonResult.setResultCode(Constants.xysj_error);
|
|
|
|
+ }else if("8".equals(responseObject.getResultCode())){
|
|
|
|
+ otherCommonResult.setResultCode(Constants.param_error);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ otherCommonResult.setResultCode(Constants.xysj_error);
|
|
|
|
+ }
|
|
|
|
+ return otherCommonResult;
|
|
|
|
+ }
|
|
|
|
+}
|