123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799 |
- package info.aspirecn.iov.sjjh.supplier10000034.service;
- import java.io.IOException;
- import java.net.SocketTimeoutException;
- import java.util.ArrayList;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import org.apache.commons.lang.math.NumberUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Service;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
- import info.aspirecn.iov.sjjh.commons.lang.ChannelTypeHandleResponseObject;
- import info.aspirecn.iov.sjjh.commons.lang.Constant;
- import info.aspirecn.iov.sjjh.commons.lang.PatternTools;
- import info.aspirecn.iov.sjjh.supplier10000034.SjjhConstants;
- import info.aspirecn.iov.sjjh.supplier10000034.gjwl.Response;
- import info.aspirecn.iov.sjjh.supplier10000034.gjwl.util.PostUtil;
- import info.aspirecn.iov.sjjh.supplier10000034.vo.EnterprisePermitRequestObject;
- import info.aspirecn.iov.sjjh.supplier10000034.vo.EnterprisePermitResponseObject;
- import info.aspirecn.iov.sjjh.supplier10000034.vo.PersonQualificationRequestObject;
- import info.aspirecn.iov.sjjh.supplier10000034.vo.PersonQualificationResponseObject;
- import info.aspirecn.iov.sjjh.supplier10000034.vo.PersonQualificationResponseObject.QualificationCertificateInfo;
- import info.aspirecn.iov.sjjh.supplier10000034.vo.ResultBody;
- import info.aspirecn.iov.sjjh.supplier10000034.vo.VehiclePermitSecondJsonResolveObject;
- import info.aspirecn.iov.sjjh.supplier10000034.vo.VehiclePermitSjxyRequstObject;
- import info.aspirecn.iov.sjjh.supplier10000034.vo.VehicleRoadTransportResponseObject;
- import info.aspirecn.rdc.aspirecloud.node.except.utils.ErrorUtils;
- import lombok.extern.slf4j.Slf4j;
- /**
- *
- * @author bzh
- *
- */
- @Slf4j
- @Service
- public class Supplier10000034SecondServiceImpl implements Supplier10000034SecondService {
- @Value("${custom.appKey}")
- private String appKey;
- @Value("${custom.appSecret}")
- private String appSecret;
- @Value("${custom.enterpriseUrl}")
- private String enterpriseUrl;
- @Value("${custom.personUrl}")
- private String personUrl;
- @Value("${custom.checkVehicleRoadTransportUrl}")
- private String checkVehicleRoadTransportUrl;
- @Value("${custom.urlCheckVehicleExist}")
- private String urlCheckVehicleExist;
-
- @Value("${custom.enterpriseV2Url}")
- private String enterpriseV2Url;
- @Value("${custom.personV2Url}")
- private String personV2Url;
-
- @Value("${custom.sleepTime}")
- private String sleepTime;
- @Autowired
- private ObjectMapper objectMapper;
- /**
- *企业道路运输经营许可证核查
- */
- @Override
- public ChannelTypeHandleResponseObject checkEnterprisePermit(HttpServletRequest request, String customBody,
- int outTime) {
- ChannelTypeHandleResponseObject ret = new ChannelTypeHandleResponseObject();
- ret.setCode(Constant.SUCCESS);
- ret.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
- String upstreamCode = Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
- request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
- String returnType = request.getHeader(Constant.CUSTOMER_RETURN_TYPE_PARA);
- if(StringUtils.isBlank(returnType)) {
- returnType = Constant.CUSTOMER_RETURN_ZW;
- }
-
- try {
- if (outTime <= SjjhConstants.PARA_ZERO) {
- outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
- }
- log.info("supplier10000034.checkEnterprisePermit---customBody={},outTime={}", customBody, outTime);
- ObjectMapper mapper = new ObjectMapper();
- EnterprisePermitRequestObject jsonResolveObject = mapper.readValue(customBody,
- EnterprisePermitRequestObject.class);
- String entName = jsonResolveObject.getEntName();
- String permitNumber = jsonResolveObject.getPermitNumber();
- String provinceCode = jsonResolveObject.getProvinceCode();
- //参数校验
- log.info("supplier10000034.checkEnterprisePermit---requestObject={},请求url:{}", JSON.toJSON(jsonResolveObject),enterpriseV2Url);
- List<String> paramErrorResultList = new ArrayList<>();
- if (StringUtils.isBlank(permitNumber)) {
- paramErrorResultList.add(SjjhConstants.ERROR_RETURN_PERMITNUMBER);
- }
- if (StringUtils.isBlank(provinceCode)&&provinceCode.length()!=6) {
- paramErrorResultList.add(SjjhConstants.ERROR_RETURN_PROVINCECODE);
- }
-
- if (!paramErrorResultList.isEmpty()) {
- if (Constant.CUSTOMER_RETURN_ZW.equals(returnType)) {
- ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
- } else {
- ret.setResultCode(Constant.JK_RETURN_CODE_INVALID_PARAMETER);
- }
- ret.setResultDesc(Constant.INVALID_PARAMETER);
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_THREE);
- resultBody.setResultList(paramErrorResultList);
- ret.setResultBody(resultBody);
- return ret;
- }
- JSONObject jsonObject = new JSONObject();
- jsonObject.put(SjjhConstants.ERROR_RETURN_PERMITNUMBER, permitNumber);
- jsonObject.put(SjjhConstants.ERROR_RETURN_PROVINCECODE, provinceCode);
- String body = jsonObject.toJSONString();
- Response responseContext = PostUtil.postString(enterpriseV2Url, body, appKey, appSecret,outTime);
- log.info("supplier10000034.checkEnterprisePermit接口responseContext={}", responseContext.getBody());
- EnterprisePermitResponseObject responseObject = objectMapper.readValue(
- responseContext.getBody(), EnterprisePermitResponseObject.class);
- log.info("supplier10000034.checkEnterprisePermit接口responseObject={}", responseObject);
- ret = setCheckEnterprisePermit(ret, returnType, entName, permitNumber, responseObject);
- if(responseObject != null) {
- upstreamCode = responseObject.getResultCode();
- }
- } catch (SocketTimeoutException ste) {
- ErrorUtils.captureException(ste);
- log.info("supplier10000034.checkEnterprisePermit接口SocketTimeoutException={}", ste);
- ret.setCode(Constant.REQUEST_TIMEOUT);
- } catch (UnrecognizedPropertyException upe) {
- log.info("supplier10000034.checkEnterprisePermit-UnrecognizedPropertyException:{}", upe);
- ErrorUtils.captureException(upe);
- ret.setCode(Constant.SUCCESS);
- ret.setIsCharge(Constant.IS_NOT_CHARGE);
- /**参数错误*/
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)){
- ret.setResultCode(Constant.JK_RETURN_CODE_INVALID_PARAMETER);
- } else {
- ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
- }
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_THREE);
- List<String> resultList = new ArrayList<>();
- resultList.add(SjjhConstants.ERROR_RETURN_ENTNAME);
- resultList.add(SjjhConstants.ERROR_RETURN_PERMITNUMBER);
- resultList.add(SjjhConstants.ERROR_RETURN_PROVINCECODE);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- ret.setResultDesc(Constant.PARAMETER_NAME_ERROR);
- return ret;
- } catch (Exception ioe) {
- log.info("supplier10000034.checkVehicleRoadTransport接口-Exception:{}", ioe);
- ErrorUtils.captureException(ioe);
- ret.setCode(Constant.FAIL);
- }
-
- request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
- return ret;
- }
-
- /**
- * 填充企业道路运输经营许可证核查接口的返回对象
- * @param ret
- * @param returnType
- * @param responseObject
- * @return
- */
- public ChannelTypeHandleResponseObject setCheckEnterprisePermit(ChannelTypeHandleResponseObject ret,
- String returnType,String entName,String permitNumber,EnterprisePermitResponseObject responseObject) {
- String resultCode = responseObject.getResultCode();
- if (SjjhConstants.RESULT_CODE_0.equals(resultCode)) {
- // 查询成功,返回结果
- ret.setIsCharge(Constant.INTERFACE_QUERY_FEE);
-
- //1、源数据是否为空
- List<String> resultList = new ArrayList<>();
- if(StringUtils.isBlank(responseObject.getData().getEnterpriseName())){
- resultList.add(SjjhConstants.ERROR_RETURN_ENTNAME);
- }
- if(StringUtils.isBlank(responseObject.getData().getPermitNumber())){
- resultList.add(SjjhConstants.ERROR_RETURN_PERMITNUMBER);
- }
- if(!resultList.isEmpty()){
- //数据源为空响应
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_NO_MATCH);
- } else {
- ret.setResultCode(Constant.UN_MATCH_CODE);
- }
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_ONE);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- } else {
- //2、数据是否一致
- if(StringUtils.isNotBlank(entName)&&!entName.equalsIgnoreCase(responseObject.getData().getEnterpriseName())){
- resultList.add(SjjhConstants.ERROR_RETURN_ENTNAME);
- } else if(StringUtils.isNotBlank(permitNumber)&&!permitNumber.equalsIgnoreCase(responseObject.getData().getPermitNumber())){
- resultList.add(SjjhConstants.ERROR_RETURN_PERMITNUMBER);
- }
- if(!resultList.isEmpty()){
- //数据不一致响应
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_NO_MATCH);
- } else {
- ret.setResultCode(Constant.UN_MATCH_CODE);
- }
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_TWO);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- } else {
- //数据一致响应
- if (Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_MATCH);
- } else {
- ret.setResultCode(Constant.MATCH_CODE);
- }
- ret.setResultBody(responseObject.getData());
- }
- }
- } else if(SjjhConstants.INTERFACE_CODE_110000.equals(resultCode)) {
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)){
- ret.setResultCode(Constant.JK_RETURN_CODE_NO_INFO);
- } else {
- ret.setResultCode(Constant.UN_FIND_NUM_CODE);
- }
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_THREE);
- List<String> resultList = new ArrayList<>();
- resultList.add(SjjhConstants.ERROR_RETURN_PERMITNUMBER);
- resultList.add(SjjhConstants.ERROR_RETURN_PROVINCECODE);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- ret.setResultDesc(Constant.PARAMETER_NAME_ERROR);
- }else if(SjjhConstants.INTERFACE_CODE_140002.equals(resultCode)){
- /**参数错误*/
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)){
- ret.setResultCode(Constant.JK_RETURN_CODE_INVALID_PARAMETER);
- } else {
- ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
- }
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_THREE);
- List<String> resultList = new ArrayList<>();
- resultList.add(SjjhConstants.ERROR_RETURN_PERMITNUMBER);
- resultList.add(SjjhConstants.ERROR_RETURN_PROVINCECODE);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- ret.setResultDesc(Constant.PARAMETER_NAME_ERROR);
- }else {
- // 其他错误
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_OTHER_ERROR);
- } else {
- ret.setResultCode(Constant.OTHER_ERROR_CODE);
- }
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_THREE);
- List<String> resultList = new ArrayList<>();
- resultList.add(SjjhConstants.ERROR_RETURN_PERMITNUMBER);
- resultList.add(SjjhConstants.ERROR_RETURN_PROVINCECODE);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- }
-
- return ret;
- }
- /**
- *人员从业资格证核查
- */
- @Override
- public ChannelTypeHandleResponseObject checkPersonQualification(HttpServletRequest request, String customBody,
- int outTime) {
- ChannelTypeHandleResponseObject ret = new ChannelTypeHandleResponseObject();
- ret.setCode(Constant.SUCCESS);
- ret.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
- String upstreamCode = Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
- request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
- String returnType = request.getHeader(Constant.CUSTOMER_RETURN_TYPE_PARA);
- if(StringUtils.isBlank(returnType)) {
- returnType = Constant.CUSTOMER_RETURN_ZW;
- }
- try {
- if (outTime <= SjjhConstants.PARA_ZERO) {
- outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
- }
- log.info("supplier10000034.checkPersonQualification---customBody={},outTime={}", customBody, outTime);
- ObjectMapper mapper = new ObjectMapper();
- PersonQualificationRequestObject jsonResolveObject = mapper.readValue(customBody,
- PersonQualificationRequestObject.class);
- String name = jsonResolveObject.getNameOfPerson();
- String idCode = jsonResolveObject.getIdentityDocumentNumber();
- String qualificationCertificateNumber = jsonResolveObject.getQualificationCertificateNumber();
- String provinceCode = jsonResolveObject.getProvinceCode();
- //参数校验
- log.info("supplier10000034.checkPersonQualification---requestObject={},请求url:{}", JSON.toJSON(jsonResolveObject),personV2Url);
- List<String> paramErrorResultList = new ArrayList<>();
- if (StringUtils.isBlank(name)&&!PatternTools.checkResult(Constant.PATTERN_CN_NAME_REGEX,name)) {
- paramErrorResultList.add(SjjhConstants.ERROR_RETURN_NAMEOFPERSON);
- }
- if (StringUtils.isBlank(provinceCode)&&provinceCode.length()!=6) {
- paramErrorResultList.add(SjjhConstants.ERROR_RETURN_PROVINCECODE);
- }
- if (StringUtils.isBlank(idCode)&&StringUtils.isBlank(qualificationCertificateNumber)) {
- paramErrorResultList.add(SjjhConstants.ERROR_RETURN_QUALIFICATIONCERTIFICATENUMBER);
- paramErrorResultList.add(SjjhConstants.ERROR_RETURN_IDENTITYDOCUMENTNUMBER);
- }
- if(StringUtils.isNotEmpty(idCode) && !PatternTools.checkResult(Constant.PATTERN_ID_NUMBER_REGEX,idCode)){
- paramErrorResultList.add(SjjhConstants.ERROR_RETURN_IDENTITYDOCUMENTNUMBER);
- }
- if (!paramErrorResultList.isEmpty()) {
- if (Constant.CUSTOMER_RETURN_ZW.equals(returnType)) {
- ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
- } else {
- ret.setResultCode(Constant.JK_RETURN_CODE_INVALID_PARAMETER);
- }
- ret.setResultDesc(Constant.INVALID_PARAMETER);
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_THREE);
- resultBody.setResultList(paramErrorResultList);
- ret.setResultBody(resultBody);
- return ret;
- }
- String body = objectMapper.writeValueAsString(jsonResolveObject);
- Response responseContext = PostUtil.postString(personV2Url, body, appKey, appSecret,outTime);
- log.info("supplier10000034.checkPersonQualification接口responseContext={}", responseContext.getBody());
- PersonQualificationResponseObject responseObject = objectMapper.readValue(
- responseContext.getBody(), PersonQualificationResponseObject.class);
- log.info("supplier10000034.checkPersonQualification接口responseObject={}", responseObject);
- ret = setCheckPersonQualification(ret, returnType, name, idCode, provinceCode,
- qualificationCertificateNumber, responseObject);
- if(responseObject != null) {
- upstreamCode = responseObject.getResultCode();
- }
- } catch (SocketTimeoutException ste) {
- ErrorUtils.captureException(ste);
- log.info("supplier10000034.checkPersonQualification接口SocketTimeoutException={}", ste);
- ret.setCode(Constant.REQUEST_TIMEOUT);
- } catch (UnrecognizedPropertyException upe) {
- log.info("supplier10000034.checkPersonQualification-UnrecognizedPropertyException:{}", upe);
- ErrorUtils.captureException(upe);
- ret.setCode(Constant.SUCCESS);
- ret.setIsCharge(Constant.IS_NOT_CHARGE);
- /**参数错误*/
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)){
- ret.setResultCode(Constant.JK_RETURN_CODE_INVALID_PARAMETER);
- } else {
- ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
- }
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_THREE);
- List<String> resultList = new ArrayList<>();
- resultList.add(SjjhConstants.ERROR_RETURN_NAMEOFPERSON);
- resultList.add(SjjhConstants.ERROR_RETURN_IDENTITYDOCUMENTNUMBER);
- resultList.add(SjjhConstants.ERROR_RETURN_QUALIFICATIONCERTIFICATENUMBER);
- resultList.add(SjjhConstants.ERROR_RETURN_PROVINCECODE);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- ret.setResultDesc(Constant.PARAMETER_NAME_ERROR);
- return ret;
- } catch (Exception ioe) {
- log.info("supplier10000034.checkPersonQualification接口-Exception:{}", ioe);
- ErrorUtils.captureException(ioe);
- ret.setCode(Constant.FAIL);
- }
-
- request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
- return ret;
- }
-
- /**
- * 填充人员从业资格证核查接口的返回对象
- * @param ret
- * @param returnType
- * @param name
- * @param idCode
- * @return
- */
- public ChannelTypeHandleResponseObject setCheckPersonQualification(ChannelTypeHandleResponseObject ret,
- String returnType,String name,String idCode,String provinceCode,
- String qualificationCertificateNumber,PersonQualificationResponseObject responseObject) {
- String resultCode = responseObject.getResultCode();
- if (SjjhConstants.RESULT_CODE_0.equals(resultCode)) {
- // 查询成功,返回结果
- ret.setIsCharge(Constant.INTERFACE_QUERY_FEE);
-
- //1、源数据是否为空
- List<String> resultList = new ArrayList<>();
- if (StringUtils.isNotBlank(name) && StringUtils.isBlank(responseObject.getData().getNameOfPerson())) {
- resultList.add(SjjhConstants.ERROR_RETURN_NAMEOFPERSON);
- }
- if (StringUtils.isNotBlank(idCode) && StringUtils.isBlank(responseObject.getData().getIdentityDocumentNumber())) {
- resultList.add(SjjhConstants.ERROR_RETURN_IDENTITYDOCUMENTNUMBER);
- }
- if (StringUtils.isNotBlank(qualificationCertificateNumber)) {
- for (QualificationCertificateInfo qualificationCertificateInfo : responseObject.getData().getQualificationCertificateInfo()) {
- if(StringUtils.isBlank(qualificationCertificateInfo.getQualificationCertificateNumber())){
- resultList.add(SjjhConstants.ERROR_RETURN_QUALIFICATIONCERTIFICATENUMBER);
- }
- }
- }
-
- if(!resultList.isEmpty()){
- //数据源为空响应
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_NO_MATCH);
- } else {
- ret.setResultCode(Constant.UN_MATCH_CODE);
- }
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_ONE);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- } else {
- //2、数据是否一致
- if (StringUtils.isNotBlank(name)
- && !name.equalsIgnoreCase(responseObject.getData().getNameOfPerson())) {
- resultList.add(SjjhConstants.ERROR_RETURN_NAMEOFPERSON);
- }
- if(StringUtils.isNotBlank(idCode)
- && !idCode.equalsIgnoreCase(responseObject.getData().getIdentityDocumentNumber())){
- resultList.add(SjjhConstants.ERROR_RETURN_IDENTITYDOCUMENTNUMBER);
- }
- if(StringUtils.isNotBlank(provinceCode)
- && !provinceCode.equalsIgnoreCase(responseObject.getData().getProvinceCode())){
- resultList.add(SjjhConstants.ERROR_RETURN_PROVINCECODE);
- }
- if (StringUtils.isNotBlank(qualificationCertificateNumber)) {
- for (QualificationCertificateInfo qualificationCertificateInfo : responseObject.getData().getQualificationCertificateInfo()) {
- if(StringUtils.isNotBlank(qualificationCertificateInfo.getQualificationCertificateNumber())
- && !qualificationCertificateNumber.equalsIgnoreCase(qualificationCertificateInfo.getQualificationCertificateNumber())){
- resultList.add(SjjhConstants.ERROR_RETURN_QUALIFICATIONCERTIFICATENUMBER);
- }
- }
- }
- if(!resultList.isEmpty()){
- //数据不一致响应
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_NO_MATCH);
- } else {
- ret.setResultCode(Constant.UN_MATCH_CODE);
- }
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_TWO);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- } else {
- //数据一致响应
- if (Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_MATCH);
- } else {
- ret.setResultCode(Constant.MATCH_CODE);
- }
- ret.setResultBody(responseObject.getData());
- }
- }
- } else if(SjjhConstants.INTERFACE_CODE_110000.equals(resultCode)) {
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)){
- ret.setResultCode(Constant.JK_RETURN_CODE_NO_INFO);
- } else {
- ret.setResultCode(Constant.UN_FIND_NUM_CODE);
- }
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_ONE);
- List<String> resultList = new ArrayList<>();
- resultList.add(SjjhConstants.ERROR_RETURN_NAMEOFPERSON);
- if (StringUtils.isNotBlank(idCode)) {
- resultList.add(SjjhConstants.ERROR_RETURN_IDENTITYDOCUMENTNUMBER);
- }
- if (StringUtils.isNotBlank(qualificationCertificateNumber)) {
- resultList.add(SjjhConstants.ERROR_RETURN_QUALIFICATIONCERTIFICATENUMBER);
- }
- resultList.add(SjjhConstants.ERROR_RETURN_PROVINCECODE);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- ret.setResultDesc(Constant.PARAMETER_NAME_ERROR);
- } else if(SjjhConstants.INTERFACE_CODE_140002.equals(resultCode)){
- /**参数错误*/
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)){
- ret.setResultCode(Constant.JK_RETURN_CODE_INVALID_PARAMETER);
- } else {
- ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
- }
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_THREE);
- List<String> resultList = new ArrayList<>();
- resultList.add(SjjhConstants.ERROR_RETURN_NAMEOFPERSON);
- if (StringUtils.isNotBlank(idCode)) {
- resultList.add(SjjhConstants.ERROR_RETURN_IDENTITYDOCUMENTNUMBER);
- }
- if (StringUtils.isNotBlank(qualificationCertificateNumber)) {
- resultList.add(SjjhConstants.ERROR_RETURN_QUALIFICATIONCERTIFICATENUMBER);
- }
- resultList.add(SjjhConstants.ERROR_RETURN_PROVINCECODE);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- ret.setResultDesc(Constant.PARAMETER_NAME_ERROR);
- } else {
- // 其他错误
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_OTHER_ERROR);
- } else {
- ret.setResultCode(Constant.OTHER_ERROR_CODE);
- }
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_THREE);
- List<String> resultList = new ArrayList<>();
- resultList.add(SjjhConstants.ERROR_RETURN_NAMEOFPERSON);
- if (StringUtils.isNotBlank(idCode)) {
- resultList.add(SjjhConstants.ERROR_RETURN_IDENTITYDOCUMENTNUMBER);
- }
- if (StringUtils.isNotBlank(qualificationCertificateNumber)) {
- resultList.add(SjjhConstants.ERROR_RETURN_QUALIFICATIONCERTIFICATENUMBER);
- }
- resultList.add(SjjhConstants.ERROR_RETURN_PROVINCECODE);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- }
- return ret;
- }
- @Override
- public ChannelTypeHandleResponseObject checkVehicleRoadTransport(HttpServletRequest request, String customBody, int outTime) {
- ChannelTypeHandleResponseObject ret = new ChannelTypeHandleResponseObject();
- ret.setCode(Constant.SUCCESS);
- ret.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
- String upstreamCode = Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
- request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
- String returnType = request.getHeader(Constant.CUSTOMER_RETURN_TYPE_PARA);
- if(StringUtils.isBlank(returnType)) {
- returnType = Constant.CUSTOMER_RETURN_ZW;
- }
-
- try {
- if (outTime <= SjjhConstants.PARA_ZERO) {
- outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
- }
- log.info("supplier10000034.checkVehicleRoadTransport---customBody={},outTime={}", customBody, outTime);
- ObjectMapper mapper = new ObjectMapper();
- VehiclePermitSecondJsonResolveObject jsonResolveObject = mapper.readValue(customBody,
- VehiclePermitSecondJsonResolveObject.class);
- String carNumber = jsonResolveObject.getVehicleNumber();
- String colorType = jsonResolveObject.getVehiclePlateColorCode();
- String vin = jsonResolveObject.getVin();
- String roadNumber = jsonResolveObject.getRoadTransportCertificateNumber();
- //参数校验
- log.info("supplier10000034.checkVehicleRoadTransport---requestObject={}", jsonResolveObject);
- List<String> paramErrorResultList = new ArrayList<>();
- //车牌号校验
- if (StringUtils.isBlank(carNumber) || !PatternTools.checkResult(SjjhConstants.PARA_THREE, carNumber)) {
- paramErrorResultList.add(SjjhConstants.ERROR_RETURN_VEHICLENUMBER);
- }
- //车颜色校验
- if (StringUtils.isBlank(colorType) || (!SjjhConstants.PARA_COLOR_ONE.equals(colorType)
- && !SjjhConstants.PARA_COLOR_TWO.equals(colorType))) {
- paramErrorResultList.add(SjjhConstants.ERROR_RETURN_COLOR_CODE);
- }
- //VIN和道路运输证号非空校验
- if (StringUtils.isBlank(vin) && StringUtils.isBlank(roadNumber)) {
- paramErrorResultList.add(SjjhConstants.ERROR_RETURN_VIN);
- paramErrorResultList.add(SjjhConstants.ERROR_RETURN_ROADNUMBER);
- }
- //道路运输证号不为空且全是数字
- if (StringUtils.isNotBlank(roadNumber)
- && !NumberUtils.isNumber(roadNumber)) {
- paramErrorResultList.add(SjjhConstants.ERROR_RETURN_ROADNUMBER);
- }
-
- if (!paramErrorResultList.isEmpty()) {
- if (Constant.CUSTOMER_RETURN_ZW.equals(returnType)) {
- ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
- } else {
- ret.setResultCode(Constant.JK_RETURN_CODE_INVALID_PARAMETER);
- }
- ret.setResultDesc(Constant.INVALID_PARAMETER);
- ResultBody resultBody = new ResultBody();
- resultBody.setCode(SjjhConstants.PARA_THREE);
- resultBody.setResultList(paramErrorResultList);
- ret.setResultBody(resultBody);
- return ret;
- }
- //请求的body,json格式
- VehiclePermitSjxyRequstObject requestObject = new VehiclePermitSjxyRequstObject();
- requestObject.setLicensePlateTypeCode(colorType);
- requestObject.setVehicleNumber(carNumber);
- String body = objectMapper.writeValueAsString(requestObject);
- log.info("supplier10000034.checkVehicleRoadTransport接口body={},url={}", body, checkVehicleRoadTransportUrl);
- info.aspirecn.iov.sjjh.supplier10000034.gjwl.Response response = PostUtil.postString(
- checkVehicleRoadTransportUrl, body, appKey, appSecret, outTime);
- String responseContext = response.getBody();
- log.info("supplier10000034.checkVehicleRoadTransport接口responseContext={}", responseContext);
- VehicleRoadTransportResponseObject responseObject = mapper.readValue(
- responseContext, VehicleRoadTransportResponseObject.class);
- String resultCode = "";
- if(responseObject != null) {
- upstreamCode = responseObject.getResultCode();
- resultCode = responseObject.getResultCode();
- }
-
- ret = setCheckVehicleRoadTransport(ret, returnType, vin, roadNumber, resultCode, responseObject);
- } catch (SocketTimeoutException ste) {
- ErrorUtils.captureException(ste);
- log.info("supplier10000034.checkVehicleRoadTransport接口SocketTimeoutException={}", ste);
- ret.setCode(Constant.REQUEST_TIMEOUT);
- } catch (UnrecognizedPropertyException upe) {
- log.info("supplier10000034.checkVehicleRoadTransport-UnrecognizedPropertyException:{}", upe);
- ErrorUtils.captureException(upe);
- ret.setCode(Constant.SUCCESS);
- ret.setIsCharge(Constant.IS_NOT_CHARGE);
- /**参数错误*/
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)){
- ret.setResultCode(Constant.JK_RETURN_CODE_9909);
- } else {
- ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
- }
- ret.setResultBody(Constant.PARAMETER_NAME_ERROR);
- ret.setResultDesc(Constant.PARAMETER_NAME_ERROR);
- return ret;
- } catch (Exception ioe) {
- log.info("supplier10000034.checkVehicleRoadTransport接口-Exception:{}", ioe);
- ErrorUtils.captureException(ioe);
- ret.setCode(Constant.FAIL);
- }
-
- request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
- return ret;
- }
- /**
- * 填充核车辆道路运输许可证信息接口的返回对象
- * @param ret
- * @param returnType
- * @param vin
- * @param roadNumber
- * @param responseObject
- * @return
- */
- public ChannelTypeHandleResponseObject setCheckVehicleRoadTransport(ChannelTypeHandleResponseObject ret,
- String returnType,String vin,String roadNumber,String resultCode,
- VehicleRoadTransportResponseObject responseObject) {
- ResultBody resultBody = new ResultBody();
-
- if (responseObject != null && responseObject.getData() != null
- && SjjhConstants.RESULT_CODE_0.equals(resultCode)) {
- // 查询成功,返回结果
- ret.setIsCharge(Constant.INTERFACE_QUERY_FEE);
-
- //1、源数据是否为空
- List<String> resultList = new ArrayList<>();
- if(StringUtils.isBlank(responseObject.getData().getVehicleNumber())){
- resultList.add(SjjhConstants.ERROR_RETURN_VEHICLENUMBER);
- }
- if(StringUtils.isBlank(responseObject.getData().getLicensePlateTypeCode())){
- resultList.add(SjjhConstants.ERROR_RETURN_COLOR_CODE);
- }
- if(StringUtils.isNotBlank(roadNumber) && StringUtils.isBlank(responseObject.getData().getRoadTransportCertificateNumber())){
- resultList.add(SjjhConstants.ERROR_RETURN_ROADNUMBER);
- }
- if(StringUtils.isNotBlank(vin) && StringUtils.isBlank(responseObject.getData().getVinNo())){
- resultList.add(SjjhConstants.ERROR_RETURN_VIN);
- }
- if(!resultList.isEmpty()){
- //数据源为空响应
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_NO_MATCH);
- } else {
- ret.setResultCode(Constant.UN_MATCH_CODE);
- }
- resultBody.setCode(SjjhConstants.PARA_ONE);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- } else {
- //2、数据是否一致
- if(StringUtils.isNotBlank(roadNumber) && StringUtils.isBlank(vin)){
- if(!roadNumber.equalsIgnoreCase(responseObject.getData().getRoadTransportCertificateNumber())) {
- resultList.add(SjjhConstants.ERROR_RETURN_ROADNUMBER);
- }
- } else if(StringUtils.isBlank(roadNumber) && StringUtils.isNotBlank(vin)){
- if(!vin.equalsIgnoreCase(responseObject.getData().getVinNo())) {
- resultList.add(SjjhConstants.ERROR_RETURN_VIN);
- }
- } else if(!vin.equalsIgnoreCase(responseObject.getData().getVinNo())) {
- resultList.add(SjjhConstants.ERROR_RETURN_VIN);
- }
- if(!resultList.isEmpty()){
- //数据不一致响应
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_NO_MATCH);
- } else {
- ret.setResultCode(Constant.UN_MATCH_CODE);
- }
- resultBody.setCode(SjjhConstants.PARA_TWO);
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- } else {
- //数据一致响应
- if (Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_MATCH);
- } else {
- ret.setResultCode(Constant.MATCH_CODE);
- }
- ret.setResultBody(responseObject.getData());
- }
- }
- } else if(SjjhConstants.INTERFACE_CODE_110000.equals(resultCode)) {
- // 查询结果为空
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_NO_INFO);
- } else {
- ret.setResultCode(Constant.UN_FIND_NUM_CODE);
- }
- resultBody.setCode(SjjhConstants.PARA_ONE);
- List<String> resultList = getErrorParamList();
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- } else if(SjjhConstants.INTERFACE_CODE_140002.equals(resultCode)) {
- // 参数错误
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_INVALID_PARAMETER);
- } else {
- ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
- }
- resultBody.setCode(SjjhConstants.PARA_THREE);
- List<String> resultList = getErrorParamList();
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- } else {
- // 其他错误
- if(Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
- ret.setResultCode(Constant.JK_RETURN_CODE_OTHER_ERROR);
- } else {
- ret.setResultCode(Constant.OTHER_ERROR_CODE);
- }
- resultBody.setCode(SjjhConstants.PARA_THREE);
- List<String> resultList = getErrorParamList();
- resultBody.setResultList(resultList);
- ret.setResultBody(resultBody);
- }
-
- return ret;
- }
-
- /**
- * 获取错误返回中相关参数LIST
- * @return
- */
- private List<String> getErrorParamList() {
- List<String> resultList = new ArrayList<>();
- resultList.add(SjjhConstants.ERROR_RETURN_VEHICLENUMBER);
- resultList.add(SjjhConstants.ERROR_RETURN_COLOR_CODE);
- resultList.add(SjjhConstants.ERROR_RETURN_ROADNUMBER);
- resultList.add(SjjhConstants.ERROR_RETURN_VIN);
-
- return resultList;
- }
- }
|