Commit 6216b6dd authored by 张庆's avatar 张庆

新增MQ

parent 6c881827
......@@ -47,18 +47,6 @@ public class CreditSubmitCommand extends AbstractCommand {
@Autowired
private CreditComponent creditComponent;
@Autowired
private OssUtils ossUtils;
@Autowired
private OssProperties ossProperties;
@Autowired
private IClientFeignService iClientFeignService;
@Autowired
private IWakandaFeignService iWakandaFeignService;
@Autowired
private WindowsProducer windowsProducer;
......@@ -71,127 +59,17 @@ public class CreditSubmitCommand extends AbstractCommand {
if (ObjectUtil.isNotNull(order)) {
return JsonResult.success();
}
CreditModel creditModel = new CreditModel();
creditModel.setOrderNo(request.getOrderNo());
this.convert(request, creditModel);
ClientInfoModel infoModel = this.convertCredit(request, creditModel);
JsonResult result = iWakandaFeignService.clientCredit(infoModel);
result.apiCheck();
creditComponent.insert(creditModel);
JSONObject thirdDataReq=new JSONObject();
thirdDataReq.put("orderNo",request.getOrderNo());
windowsProducer.pullCreditThirdData(thirdDataReq);
windowsProducer.pullCrditDate(request);
// CreditModel creditModel = new CreditModel();
// creditModel.setOrderNo(request.getOrderNo());
// this.convert(request, creditModel);
// ClientInfoModel infoModel = this.convertCredit(request, creditModel);
// JsonResult result = iWakandaFeignService.clientCredit(infoModel);
// result.apiCheck();
// creditComponent.insert(creditModel);
// JSONObject thirdDataReq=new JSONObject();
// thirdDataReq.put("orderNo",request.getOrderNo());
// windowsProducer.pullCreditThirdData(thirdDataReq);
return JsonResult.success();
}
private ClientInfoModel convertCredit(CreditSubmitRequest request, CreditModel model) {
ClientInfoModel clientInfoModel = new ClientInfoModel();
CreditInformationModel infoModel = request.getCreditData();
clientInfoModel.setCertNo(infoModel.getBasicInfo().getIdCard());
clientInfoModel.setClientName(infoModel.getBasicInfo().getName());
clientInfoModel.setClientNo(model.getClientNo());
clientInfoModel.setClientCell(infoModel.getBasicInfo().getPhone());
clientInfoModel.setOrderNo(request.getOrderNo());
clientInfoModel.setMobileEncrypt(LoanMobileAESUtil.encrypt(model.getClientCell()));
clientInfoModel.setProductName("ZN_DAI");
clientInfoModel.setChannelSign("ZN");
clientInfoModel.setCreditPath(model.getCreditDetailUrl());
clientInfoModel.setBizType(ProductNameEnum.getByCode(clientInfoModel.getProductName()).getBiz());
return clientInfoModel;
}
private CreditModel convert(CreditSubmitRequest request, CreditModel model) {
StringBuilder filePath = new StringBuilder("ZN/");
filePath.append("CREDIT_DATA").append("/").append(DateUtil.format(new Date(), "yyyyMMdd")).append("/").append(request.getOrderNo()).append(".json");
model.setCreditDetailUrl(filePath.toString());
CreditInformationModel infoModel = request.getCreditData();
IdentifyInfoModel idModel = infoModel.getIdentifyInfo();
BasicInfoModel basicModel = infoModel.getBasicInfo();
String marry = basicModel.getMarriage();
basicModel.setBirthday(IdcardUtil.getBirth(basicModel.getIdCard()));
//basicModel.setSex(IdcardUtil.getGenderByIdCard(basicModel.getIdCard())==1?);
basicModel.setDuty("9");
basicModel.setMarriage("99");
basicModel.setHaveCar(0);
basicModel.setHaveHouse(0);
DeviceInfoModel deviceInfoModel = infoModel.getDeviceInfo();
if ("02".equals(deviceInfoModel.getDeviceType())) {
deviceInfoModel.setDeviceType("ios");
} else {
deviceInfoModel.setDeviceType("android");
}
if (StringUtils.isNotBlank(marry)) {
basicModel.setMarriage(ZNMarryEnum.getByCode(marry).getMsg());
}
String first = basicModel.getFirstRelation();
basicModel.setFirstRelation("其他");
if (StringUtils.isNotBlank(first)) {
basicModel.setFirstRelation(ZNRelationEnum.getByCode(first).getMsg());
}
String second = basicModel.getSecondRelation();
basicModel.setSecondRelation("其他");
if (StringUtils.isNotBlank(second)) {
basicModel.setSecondRelation(ZNRelationEnum.getByCode(second).getMsg());
}
String eduCode = basicModel.getEducationCode();
basicModel.setEducationCode("40");
if (StringUtils.isNotBlank(eduCode)) {
basicModel.setEducationCode(ZNEduEnum.getByCode(eduCode).getMsg());
//basicModel.setEducation(ZNEduEnum.getByCode(eduCode).getMsg());
}
String income = basicModel.getFamilyMonthlyIncome();
basicModel.setFamilyMonthlyIncome("8000");
if (StringUtils.isNotBlank(income)) {
basicModel.setFamilyMonthlyIncome(ZNInComeEnum.getByCode(income).getMsg());
}
StringBuilder frontUrl = new StringBuilder();
frontUrl.append("USERCREDIT").append("/").append(DateUtil.format(new Date(), "yyyyMMdd")).append("/front_").append(request.getOrderNo()).append(".jpg");
HttpResponse frontResponse = HttpRequest.get(idModel.getFrontFile()).setConnectionTimeout(5000).execute();
ossUtils.ossUpload(frontUrl.toString(), frontResponse.bodyStream());
idModel.setFrontFile(ossProperties.getPrivateDomain() + frontUrl);
StringBuilder backUrl = new StringBuilder();
backUrl.append("USERCREDIT").append("/").append(DateUtil.format(new Date(), "yyyyMMdd")).append("/back_").append(request.getOrderNo()).append(".jpg");
HttpResponse backResponse = HttpRequest.get(idModel.getBackFile()).setConnectionTimeout(5000).execute();
ossUtils.ossUpload(backUrl.toString(), backResponse.bodyStream());
idModel.setBackFile(ossProperties.getPrivateDomain() + backUrl);
StringBuilder bestUrl = new StringBuilder();
bestUrl.append("USERCREDIT").append("/").append(DateUtil.format(new Date(), "yyyyMMdd")).append("/nature_").append(request.getOrderNo()).append(".jpg");
HttpResponse natureResponse = HttpRequest.get(idModel.getNatureFile()).setConnectionTimeout(5000).execute();
ossUtils.ossUpload(bestUrl.toString(), natureResponse.bodyStream());
idModel.setNatureFile(ossProperties.getPrivateDomain() + bestUrl);
String startDate = DateUtil.format(DateUtil.parseDate(infoModel.getIdentifyInfo().getStartDate()), "yyyy.MM.dd");
String endDate = "";
if ("长期".equals(infoModel.getIdentifyInfo().getEndDate())) {
endDate = "长期";
} else {
endDate = DateUtil.format(DateUtil.parseDate(infoModel.getIdentifyInfo().getEndDate()), "yyyy.MM.dd");
}
idModel.setValidDate(startDate + "-" + endDate);
infoModel.setDeviceInfo(deviceInfoModel);
infoModel.setIdentifyInfo(idModel);
infoModel.setBasicInfo(basicModel);
infoModel.setContinuedLoan(false);
// ClientFeignModel clientFeignModel = new ClientFeignModel(infoModel.getBasicInfo().getIdCard(), infoModel.getBasicInfo().getName());
// JsonResult<String> clientResult = iClientFeignService.getClientNo(clientFeignModel);
// if (!clientResult.isSuccess()) {
// throw new BizException(ExceptionCodeEnum.SYSTEM_REMOTE_ERROR);
// }
String clientId = IdUtil.simpleUUID().toString();
infoModel.setClientNo(clientId);
infoModel.setOrderNo(request.getOrderNo());
model.setClientNo(clientId);
model.setOrderNo(request.getOrderNo());
ossUtils.upStringObject(model.getCreditDetailUrl(), JSON.toJSONString(infoModel));
model.setClientCell(basicModel.getPhone());
model.setCertNo(basicModel.getIdCard());
model.setClientName(basicModel.getName());
return model;
}
}
package com.jqtx.windows.common.mq;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jqtx.infrastructure.mq.starter.annotation.MQConsumerComponent;
import com.jqtx.infrastructure.oss.starter.config.OssUtils;
import com.jqtx.infrastructure.oss.starter.properties.OssProperties;
import com.jqtx.infrastructure.util.LoanMobileAESUtil;
import com.jqtx.windows.component.CreditComponent;
import com.jqtx.windows.component.enums.ZNEduEnum;
import com.jqtx.windows.component.enums.ZNInComeEnum;
import com.jqtx.windows.component.enums.ZNMarryEnum;
import com.jqtx.windows.component.enums.ZNRelationEnum;
import com.jqtx.windows.component.model.CreditModel;
import com.jqtx.windows.infrastructure.feign.IClientFeignService;
import com.jqtx.windows.infrastructure.feign.IWakandaFeignService;
import com.jqtx.windows.infrastructure.feign.enums.ProductNameEnum;
import com.jqtx.windows.infrastructure.feign.model.wakanda.*;
import com.jqtx.windows.web.request.CreditSubmitRequest;
import com.jqtx.windows.web.response.JsonResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
@MQConsumerComponent(tags = "goCredit", topic = "$mq.creditTopic")
public class CreditListener extends AbstractMQConsumerHandler<CreditSubmitRequest> {
@Autowired
private CreditComponent creditComponent;
@Autowired
private OssUtils ossUtils;
@Autowired
private OssProperties ossProperties;
@Autowired
private IClientFeignService iClientFeignService;
@Autowired
private IWakandaFeignService iWakandaFeignService;
@Autowired
private WindowsProducer windowsProducer;
@Override
public void run(CreditSubmitRequest request) throws Exception {
CreditModel order = creditComponent.getByOrderNo(request.getOrderNo());
if (ObjectUtil.isNotNull(order)) {
return;
}
CreditModel creditModel = new CreditModel();
creditModel.setOrderNo(request.getOrderNo());
this.convert(request, creditModel);
ClientInfoModel infoModel = this.convertCredit(request, creditModel);
JsonResult result = iWakandaFeignService.clientCredit(infoModel);
result.apiCheck();
creditComponent.insert(creditModel);
JSONObject thirdDataReq=new JSONObject();
thirdDataReq.put("orderNo",request.getOrderNo());
windowsProducer.pullCreditThirdData(thirdDataReq);
}
@Override
public Class<CreditSubmitRequest> getClazz() {
return CreditSubmitRequest.class;
}
private ClientInfoModel convertCredit(CreditSubmitRequest request, CreditModel model) {
ClientInfoModel clientInfoModel = new ClientInfoModel();
CreditInformationModel infoModel = request.getCreditData();
clientInfoModel.setCertNo(infoModel.getBasicInfo().getIdCard());
clientInfoModel.setClientName(infoModel.getBasicInfo().getName());
clientInfoModel.setClientNo(model.getClientNo());
clientInfoModel.setClientCell(infoModel.getBasicInfo().getPhone());
clientInfoModel.setOrderNo(request.getOrderNo());
clientInfoModel.setMobileEncrypt(LoanMobileAESUtil.encrypt(model.getClientCell()));
clientInfoModel.setProductName("ZN_DAI");
clientInfoModel.setChannelSign("ZN");
clientInfoModel.setCreditPath(model.getCreditDetailUrl());
clientInfoModel.setBizType(ProductNameEnum.getByCode(clientInfoModel.getProductName()).getBiz());
return clientInfoModel;
}
private CreditModel convert(CreditSubmitRequest request, CreditModel model) {
StringBuilder filePath = new StringBuilder("ZN/");
filePath.append("CREDIT_DATA").append("/").append(DateUtil.format(new Date(), "yyyyMMdd")).append("/").append(request.getOrderNo()).append(".json");
model.setCreditDetailUrl(filePath.toString());
CreditInformationModel infoModel = request.getCreditData();
IdentifyInfoModel idModel = infoModel.getIdentifyInfo();
BasicInfoModel basicModel = infoModel.getBasicInfo();
String marry = basicModel.getMarriage();
basicModel.setBirthday(IdcardUtil.getBirth(basicModel.getIdCard()));
//basicModel.setSex(IdcardUtil.getGenderByIdCard(basicModel.getIdCard())==1?);
basicModel.setDuty("9");
basicModel.setMarriage("99");
basicModel.setHaveCar(0);
basicModel.setHaveHouse(0);
DeviceInfoModel deviceInfoModel = infoModel.getDeviceInfo();
if ("02".equals(deviceInfoModel.getDeviceType())) {
deviceInfoModel.setDeviceType("ios");
} else {
deviceInfoModel.setDeviceType("android");
}
if (StringUtils.isNotBlank(marry)) {
basicModel.setMarriage(ZNMarryEnum.getByCode(marry).getMsg());
}
String first = basicModel.getFirstRelation();
basicModel.setFirstRelation("其他");
if (StringUtils.isNotBlank(first)) {
basicModel.setFirstRelation(ZNRelationEnum.getByCode(first).getMsg());
}
String second = basicModel.getSecondRelation();
basicModel.setSecondRelation("其他");
if (StringUtils.isNotBlank(second)) {
basicModel.setSecondRelation(ZNRelationEnum.getByCode(second).getMsg());
}
String eduCode = basicModel.getEducationCode();
basicModel.setEducationCode("40");
if (StringUtils.isNotBlank(eduCode)) {
basicModel.setEducationCode(ZNEduEnum.getByCode(eduCode).getMsg());
//basicModel.setEducation(ZNEduEnum.getByCode(eduCode).getMsg());
}
String income = basicModel.getFamilyMonthlyIncome();
basicModel.setFamilyMonthlyIncome("8000");
if (StringUtils.isNotBlank(income)) {
basicModel.setFamilyMonthlyIncome(ZNInComeEnum.getByCode(income).getMsg());
}
StringBuilder frontUrl = new StringBuilder();
frontUrl.append("USERCREDIT").append("/").append(DateUtil.format(new Date(), "yyyyMMdd")).append("/front_").append(request.getOrderNo()).append(".jpg");
HttpResponse frontResponse = HttpRequest.get(idModel.getFrontFile()).setConnectionTimeout(5000).execute();
ossUtils.ossUpload(frontUrl.toString(), frontResponse.bodyStream());
idModel.setFrontFile(ossProperties.getPrivateDomain() + frontUrl);
StringBuilder backUrl = new StringBuilder();
backUrl.append("USERCREDIT").append("/").append(DateUtil.format(new Date(), "yyyyMMdd")).append("/back_").append(request.getOrderNo()).append(".jpg");
HttpResponse backResponse = HttpRequest.get(idModel.getBackFile()).setConnectionTimeout(5000).execute();
ossUtils.ossUpload(backUrl.toString(), backResponse.bodyStream());
idModel.setBackFile(ossProperties.getPrivateDomain() + backUrl);
StringBuilder bestUrl = new StringBuilder();
bestUrl.append("USERCREDIT").append("/").append(DateUtil.format(new Date(), "yyyyMMdd")).append("/nature_").append(request.getOrderNo()).append(".jpg");
HttpResponse natureResponse = HttpRequest.get(idModel.getNatureFile()).setConnectionTimeout(5000).execute();
ossUtils.ossUpload(bestUrl.toString(), natureResponse.bodyStream());
idModel.setNatureFile(ossProperties.getPrivateDomain() + bestUrl);
String startDate = DateUtil.format(DateUtil.parseDate(infoModel.getIdentifyInfo().getStartDate()), "yyyy.MM.dd");
String endDate = "";
if ("长期".equals(infoModel.getIdentifyInfo().getEndDate())) {
endDate = "长期";
} else {
endDate = DateUtil.format(DateUtil.parseDate(infoModel.getIdentifyInfo().getEndDate()), "yyyy.MM.dd");
}
idModel.setValidDate(startDate + "-" + endDate);
infoModel.setDeviceInfo(deviceInfoModel);
infoModel.setIdentifyInfo(idModel);
infoModel.setBasicInfo(basicModel);
infoModel.setContinuedLoan(false);
// ClientFeignModel clientFeignModel = new ClientFeignModel(infoModel.getBasicInfo().getIdCard(), infoModel.getBasicInfo().getName());
// JsonResult<String> clientResult = iClientFeignService.getClientNo(clientFeignModel);
// if (!clientResult.isSuccess()) {
// throw new BizException(ExceptionCodeEnum.SYSTEM_REMOTE_ERROR);
// }
String clientId = IdUtil.simpleUUID().toString();
infoModel.setClientNo(clientId);
infoModel.setOrderNo(request.getOrderNo());
model.setClientNo(clientId);
model.setOrderNo(request.getOrderNo());
ossUtils.upStringObject(model.getCreditDetailUrl(), JSON.toJSONString(infoModel));
model.setClientCell(basicModel.getPhone());
model.setCertNo(basicModel.getIdCard());
model.setClientName(basicModel.getName());
return model;
}
}
package com.jqtx.windows.common.mq;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jqtx.infrastructure.mq.starter.mq.MQProducer;
import lombok.Data;
......@@ -30,10 +31,15 @@ public class WindowsProducer {
}
public void pullCreditThirdData(JSONObject json) {
log.info("json:[{}]",json.toJSONString());
log.info("json:[{}]", json.toJSONString());
publishData(null, json.toJSONString(), creditTopic, "creditThirdData");
}
public <T> void pullCrditDate(T obj) {
log.info("pullCrditDate:[{}]", JSON.toJSONString(obj));
publishData(null, JSON.toJSONString(obj), creditTopic, "goCredit");
}
private void publishData(String id, String body, String topic, String tag) {
try {
......
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