|
|
@ -114,75 +114,82 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { |
|
|
|
public AjaxResult syncBuyerMessage(List<MdmGmfxxtbReqBO> mdmGmfxxtbReqBOS, String requestBody) { |
|
|
|
public AjaxResult syncBuyerMessage(List<MdmGmfxxtbReqBO> mdmGmfxxtbReqBOS, String requestBody) { |
|
|
|
// 存表
|
|
|
|
// 存表
|
|
|
|
List<BuyerEntity> list = new ArrayList<>(); |
|
|
|
List<BuyerEntity> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < mdmGmfxxtbReqBOS.size(); i++) { |
|
|
|
for (int i = 0; i < mdmGmfxxtbReqBOS.size(); i++) { |
|
|
|
MdmGmfxxtbReqBO tempMdmGmfxxtbReqBO = mdmGmfxxtbReqBOS.get(i); |
|
|
|
MdmGmfxxtbReqBO tempMdmGmfxxtbReqBO = mdmGmfxxtbReqBOS.get(i); |
|
|
|
BuyerEntity entity = new BuyerEntity(); |
|
|
|
BuyerEntity entity = new BuyerEntity(); |
|
|
|
entity.setId(DistributedKeyMaker.generateShotKey()); |
|
|
|
BuyerEntity buyerEntity = buyerMapper.selectBuyerByCodeOrNameAndNsrsbh(tempMdmGmfxxtbReqBO.getCODE(), "", "-1"); |
|
|
|
entity.setTaxpayerCode(tempMdmGmfxxtbReqBO.getDESC14()); |
|
|
|
if(buyerEntity == null){ |
|
|
|
entity.setPurchaseName(tempMdmGmfxxtbReqBO.getDESC1()); |
|
|
|
log.info("MDM编码数据已存在;{}",tempMdmGmfxxtbReqBO.getCODE()); |
|
|
|
String buyerAddress = ""; |
|
|
|
entity.setSuccess(false); |
|
|
|
buyerAddress = buyerAddress.concat(StringUtils.isEmpty(tempMdmGmfxxtbReqBO.getDESC22()) ? "" : tempMdmGmfxxtbReqBO.getDESC22()); |
|
|
|
if(mdmGmfxxtbReqBOS.size() == 1){ |
|
|
|
buyerAddress = buyerAddress.concat(StringUtils.isEmpty(tempMdmGmfxxtbReqBO.getDESC23()) ? "" : tempMdmGmfxxtbReqBO.getDESC23()); |
|
|
|
return AjaxResult.success("9999", "MDM数据已存在,请勿重复同步"); |
|
|
|
buyerAddress = buyerAddress.concat(StringUtils.isEmpty(tempMdmGmfxxtbReqBO.getDESC24()) ? "" : tempMdmGmfxxtbReqBO.getDESC24()); |
|
|
|
|
|
|
|
entity.setAddress(buyerAddress); |
|
|
|
|
|
|
|
entity.setPhone(tempMdmGmfxxtbReqBO.getDESC27()); |
|
|
|
|
|
|
|
String bankList = "[]"; // 银行列表
|
|
|
|
|
|
|
|
entity.setMdmMulticodeJson(bankList); |
|
|
|
|
|
|
|
if (tempMdmGmfxxtbReqBO.getMULTICODE() != null && !CollectionUtils.isEmpty(tempMdmGmfxxtbReqBO.getMULTICODE().getVALUELIST())) { |
|
|
|
|
|
|
|
// 处理开户行银行
|
|
|
|
|
|
|
|
List<MdmGmfxxtbMulticodeValuelistBO> valuelistBOS = tempMdmGmfxxtbReqBO.getMULTICODE().getVALUELIST(); |
|
|
|
|
|
|
|
MdmGmfxxtbMulticodeValuelistBO firstValueList = valuelistBOS.get(0); |
|
|
|
|
|
|
|
if (firstValueList != null) { |
|
|
|
|
|
|
|
entity.setBankOfDeposit(firstValueList.getDESC3()); |
|
|
|
|
|
|
|
entity.setBankNumber(firstValueList.getDESC4()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
entity.setId(DistributedKeyMaker.generateShotKey()); |
|
|
|
|
|
|
|
entity.setTaxpayerCode(tempMdmGmfxxtbReqBO.getDESC14()); |
|
|
|
|
|
|
|
entity.setPurchaseName(tempMdmGmfxxtbReqBO.getDESC1()); |
|
|
|
|
|
|
|
String buyerAddress = ""; |
|
|
|
|
|
|
|
buyerAddress = buyerAddress.concat(StringUtils.isEmpty(tempMdmGmfxxtbReqBO.getDESC22()) ? "" : tempMdmGmfxxtbReqBO.getDESC22()); |
|
|
|
|
|
|
|
buyerAddress = buyerAddress.concat(StringUtils.isEmpty(tempMdmGmfxxtbReqBO.getDESC23()) ? "" : tempMdmGmfxxtbReqBO.getDESC23()); |
|
|
|
|
|
|
|
buyerAddress = buyerAddress.concat(StringUtils.isEmpty(tempMdmGmfxxtbReqBO.getDESC24()) ? "" : tempMdmGmfxxtbReqBO.getDESC24()); |
|
|
|
|
|
|
|
entity.setAddress(buyerAddress); |
|
|
|
|
|
|
|
entity.setPhone(tempMdmGmfxxtbReqBO.getDESC27()); |
|
|
|
|
|
|
|
String bankList = "[]"; // 银行列表
|
|
|
|
|
|
|
|
entity.setMdmMulticodeJson(bankList); |
|
|
|
|
|
|
|
if (tempMdmGmfxxtbReqBO.getMULTICODE() != null && !CollectionUtils.isEmpty(tempMdmGmfxxtbReqBO.getMULTICODE().getVALUELIST())) { |
|
|
|
|
|
|
|
// 处理开户行银行
|
|
|
|
|
|
|
|
List<MdmGmfxxtbMulticodeValuelistBO> valuelistBOS = tempMdmGmfxxtbReqBO.getMULTICODE().getVALUELIST(); |
|
|
|
|
|
|
|
MdmGmfxxtbMulticodeValuelistBO firstValueList = valuelistBOS.get(0); |
|
|
|
|
|
|
|
if (firstValueList != null) { |
|
|
|
|
|
|
|
entity.setBankOfDeposit(firstValueList.getDESC3()); |
|
|
|
|
|
|
|
entity.setBankNumber(firstValueList.getDESC4()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<MdmBankListBO> mdmBankListBOS = new ArrayList<>(); |
|
|
|
List<MdmBankListBO> mdmBankListBOS = new ArrayList<>(); |
|
|
|
String finalBuyerAddress = buyerAddress; |
|
|
|
String finalBuyerAddress = buyerAddress; |
|
|
|
valuelistBOS.forEach(j -> { |
|
|
|
valuelistBOS.forEach(j -> { |
|
|
|
MdmBankListBO temp = new MdmBankListBO(j, finalBuyerAddress, tempMdmGmfxxtbReqBO.getDESC27()); |
|
|
|
MdmBankListBO temp = new MdmBankListBO(j, finalBuyerAddress, tempMdmGmfxxtbReqBO.getDESC27()); |
|
|
|
mdmBankListBOS.add(temp); |
|
|
|
mdmBankListBOS.add(temp); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
bankList = JsonUtils.getInstance().toJsonStringNullToEmpty(mdmBankListBOS); |
|
|
|
bankList = JsonUtils.getInstance().toJsonStringNullToEmpty(mdmBankListBOS); |
|
|
|
entity.setMdmMulticodeJson(bankList); |
|
|
|
entity.setMdmMulticodeJson(bankList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
entity.setSjh(tempMdmGmfxxtbReqBO.getDESC27()); |
|
|
|
entity.setSjh(tempMdmGmfxxtbReqBO.getDESC27()); |
|
|
|
entity.setEmail(tempMdmGmfxxtbReqBO.getDESC29()); |
|
|
|
entity.setEmail(tempMdmGmfxxtbReqBO.getDESC29()); |
|
|
|
// entity.setRemarks();
|
|
|
|
// entity.setRemarks();
|
|
|
|
entity.setCreateTime(new Date()); // TODO 记得修改Mapper
|
|
|
|
entity.setCreateTime(new Date()); // TODO 记得修改Mapper
|
|
|
|
entity.setModifyTime(new Date()); |
|
|
|
entity.setModifyTime(new Date()); |
|
|
|
entity.setModifyUserId(null); // TODO
|
|
|
|
entity.setModifyUserId(null); // TODO
|
|
|
|
entity.setCreateUserId(null); // TODO
|
|
|
|
entity.setCreateUserId(null); // TODO
|
|
|
|
String idCardRegex = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)"; |
|
|
|
String idCardRegex = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)"; |
|
|
|
// 税号正则表达式
|
|
|
|
// 税号正则表达式
|
|
|
|
String taxNoRegex = "^[a-zA-Z0-9]{15,20}$"; |
|
|
|
String taxNoRegex = "^[a-zA-Z0-9]{15,20}$"; |
|
|
|
entity.setGhfQylx(""); |
|
|
|
entity.setGhfQylx(""); |
|
|
|
if (StringUtils.isNotEmpty(tempMdmGmfxxtbReqBO.getDESC14())) { |
|
|
|
if (StringUtils.isNotEmpty(tempMdmGmfxxtbReqBO.getDESC14())) { |
|
|
|
if (tempMdmGmfxxtbReqBO.getDESC14().matches(idCardRegex)) { |
|
|
|
if (tempMdmGmfxxtbReqBO.getDESC14().matches(idCardRegex)) { |
|
|
|
entity.setGhfQylx("03"); // 有可能出现个人
|
|
|
|
entity.setGhfQylx("03"); // 有可能出现个人
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (tempMdmGmfxxtbReqBO.getDESC14().matches(taxNoRegex)) { |
|
|
|
|
|
|
|
entity.setGhfQylx("01"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (tempMdmGmfxxtbReqBO.getDESC14().matches(taxNoRegex)) { |
|
|
|
entity.setXhfNsrsbh("-1"); // 如果为-1,代表总表
|
|
|
|
entity.setGhfQylx("01"); |
|
|
|
entity.setXhfMc(null); |
|
|
|
|
|
|
|
entity.setBuyerCode(tempMdmGmfxxtbReqBO.getCODE()); |
|
|
|
|
|
|
|
entity.setInvoiceName(tempMdmGmfxxtbReqBO.getDESC48()); |
|
|
|
|
|
|
|
entity.setInvoiceTaxno(tempMdmGmfxxtbReqBO.getDESC49()); |
|
|
|
|
|
|
|
// entity.setMdmMulticodeJson(JsonUtils.getInstance().toJsonStringNullToEmpty());
|
|
|
|
|
|
|
|
entity.setUUID(tempMdmGmfxxtbReqBO.getUUID()); |
|
|
|
|
|
|
|
entity.setStatus("0"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (buyerMapper.insertBuyerOnDuplicateKey(entity) > 0) { |
|
|
|
|
|
|
|
entity.setSuccess(true); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
entity.setSuccess(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
entity.setXhfNsrsbh("-1"); // 如果为-1,代表总表
|
|
|
|
|
|
|
|
entity.setXhfMc(null); |
|
|
|
|
|
|
|
entity.setBuyerCode(tempMdmGmfxxtbReqBO.getCODE()); |
|
|
|
|
|
|
|
entity.setInvoiceName(tempMdmGmfxxtbReqBO.getDESC48()); |
|
|
|
|
|
|
|
entity.setInvoiceTaxno(tempMdmGmfxxtbReqBO.getDESC49()); |
|
|
|
|
|
|
|
// entity.setMdmMulticodeJson(JsonUtils.getInstance().toJsonStringNullToEmpty());
|
|
|
|
|
|
|
|
entity.setUUID(tempMdmGmfxxtbReqBO.getUUID()); |
|
|
|
|
|
|
|
entity.setStatus("0"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (buyerMapper.insertBuyerOnDuplicateKey(entity) > 0) { |
|
|
|
|
|
|
|
entity.setSuccess(true); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
entity.setSuccess(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list.add(entity); |
|
|
|
list.add(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
String respStr = ""; |
|
|
|
String respStr = ""; |
|
|
@ -429,7 +436,7 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { |
|
|
|
"}"; |
|
|
|
"}"; |
|
|
|
|
|
|
|
|
|
|
|
// 发送POST请求
|
|
|
|
// 发送POST请求
|
|
|
|
log.info("[MDM主动同步物料]请求地址:{},请求参数:{}", buyerUrl, requestBody); |
|
|
|
log.info("[MDM主动同步物料]请求地址:{},请求参数:{}", groupTaxCodeUrl, requestBody); |
|
|
|
HttpResponse response = HttpRequest.post(groupTaxCodeUrl) |
|
|
|
HttpResponse response = HttpRequest.post(groupTaxCodeUrl) |
|
|
|
.timeout(20000) // 设置请求超时时间
|
|
|
|
.timeout(20000) // 设置请求超时时间
|
|
|
|
.header("Content-Type", "application/json") |
|
|
|
.header("Content-Type", "application/json") |
|
|
@ -439,8 +446,13 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { |
|
|
|
.execute(); |
|
|
|
.execute(); |
|
|
|
String resp = response.body(); |
|
|
|
String resp = response.body(); |
|
|
|
log.info("[MDM主动同步物料]响应结果:{}", resp); |
|
|
|
log.info("[MDM主动同步物料]响应结果:{}", resp); |
|
|
|
|
|
|
|
if(StringUtils.isBlank(resp)){ |
|
|
|
|
|
|
|
return R.error("未查询到数据!"); |
|
|
|
|
|
|
|
} |
|
|
|
SDEnergyMdmBaseBO baseBO = JSONObject.parseObject(resp, SDEnergyMdmBaseBO.class); |
|
|
|
SDEnergyMdmBaseBO baseBO = JSONObject.parseObject(resp, SDEnergyMdmBaseBO.class); |
|
|
|
|
|
|
|
if(baseBO == null || baseBO.getESB() == null || "S".equals(baseBO.getESB().getRESULT())){ |
|
|
|
|
|
|
|
return R.error("未查询到数据!"); |
|
|
|
|
|
|
|
} |
|
|
|
List<MdmSyncGroupTaxCodeReqBO> mdmGmfxxtbReqBOS = (List<MdmSyncGroupTaxCodeReqBO>) Optional.of(baseBO) |
|
|
|
List<MdmSyncGroupTaxCodeReqBO> mdmGmfxxtbReqBOS = (List<MdmSyncGroupTaxCodeReqBO>) Optional.of(baseBO) |
|
|
|
.map(SDEnergyMdmBaseBO::getESB) |
|
|
|
.map(SDEnergyMdmBaseBO::getESB) |
|
|
|
.map(ESBBO::getDATA) |
|
|
|
.map(ESBBO::getDATA) |
|
|
|