From a28e3bdb7de59b35c8d58bbcff89a41dd7d7888a Mon Sep 17 00:00:00 2001 From: "zhenghaiyang@ele-cloud.com" Date: Fri, 14 Apr 2023 13:57:16 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feature=201.=E5=85=AC=E5=8F=B8=E7=89=A9?= =?UTF-8?q?=E6=96=99=E5=AF=BC=E5=85=A5=E8=A1=A5=E5=85=A8entId=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CommodityController.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/controller/CommodityController.java b/order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/controller/CommodityController.java index f898a28b..eb40e5f1 100644 --- a/order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/controller/CommodityController.java +++ b/order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/controller/CommodityController.java @@ -5,16 +5,6 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.dxhy.order.baseservice.module.commodity.model.CommodityCodeModifyLog; -import com.dxhy.order.baseservice.module.commodity.model.dto.QueryModifyLogDTO; -import com.dxhy.order.baseservice.module.commodity.model.dto.QueryModifyLogResultDTO; -import com.dxhy.order.baseservice.module.commodity.service.CommodityCodeModifyLogService; -import com.dxhy.order.constant.*; -import com.dxhy.order.model.CommodityCodeCheckQuery; -import com.dxhy.order.model.CommodityTaxClassCodeReq; -import com.dxhy.order.model.PageUtils; -import com.dxhy.order.model.R; -import com.dxhy.order.utils.*; import com.dxhy.base.file.common.ExcelReadContext; import com.dxhy.base.file.exception.ExcelReadException; import com.dxhy.base.file.handle.ExcelReadHandle; @@ -23,12 +13,21 @@ import com.dxhy.order.baseservice.module.base.service.BaseService; import com.dxhy.order.baseservice.module.commodity.constant.CommodityEnum; import com.dxhy.order.baseservice.module.commodity.model.CommodityCodeEntity; import com.dxhy.order.baseservice.module.commodity.model.CommodityExcel; +import com.dxhy.order.baseservice.module.commodity.model.dto.QueryModifyLogDTO; +import com.dxhy.order.baseservice.module.commodity.model.dto.QueryModifyLogResultDTO; +import com.dxhy.order.baseservice.module.commodity.service.CommodityCodeModifyLogService; import com.dxhy.order.baseservice.module.commodity.service.CommodityService; import com.dxhy.order.baseservice.module.commodity.service.VerifyCommodityCodeService; import com.dxhy.order.baseservice.module.thirdservice.user.model.DeptEntity; import com.dxhy.order.baseservice.module.thirdservice.user.model.UserEntity; import com.dxhy.order.baseservice.module.thirdservice.user.service.UserInfoService; import com.dxhy.order.baseservice.openapi.protocol.qd.PageSpxxReq; +import com.dxhy.order.constant.*; +import com.dxhy.order.model.CommodityCodeCheckQuery; +import com.dxhy.order.model.CommodityTaxClassCodeReq; +import com.dxhy.order.model.PageUtils; +import com.dxhy.order.model.R; +import com.dxhy.order.utils.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -162,7 +161,6 @@ public class CommodityController { if (StringUtils.isBlank(commodityCodeEntity.getYcbz())) { commodityCodeEntity.setYcbz(ConfigureConstant.STRING_0); } - /** * 添加校验 */ @@ -447,7 +445,7 @@ public class CommodityController { /** * excel 导入数据转换为表格数据 */ - List commodityCodeEntities = transCommodityCodeEntityList(commodityExcelList, String.valueOf(userEntity.getUserId())); + List commodityCodeEntities = transCommodityCodeEntityList(commodityExcelList, String.valueOf(userEntity.getUserId()),userEntity.getDept().getDeptId()); return commodityService.uploadCommodityCode(commodityCodeEntities); @@ -459,7 +457,7 @@ public class CommodityController { * @param commodityExcelList * @return */ - public List transCommodityCodeEntityList(List commodityExcelList, String userId) { + public List transCommodityCodeEntityList(List commodityExcelList, String userId, String deptId) { List commodityCodeEntityList = new ArrayList<>(); if (ObjectUtil.isNotEmpty(commodityExcelList)) { for (CommodityExcel commodityExcel : commodityExcelList) { @@ -503,7 +501,7 @@ public class CommodityController { commodityCodeEntity.setCpy(""); commodityCodeEntity.setJdc(""); commodityCodeEntity.setBmbBbh(""); - + commodityCodeEntity.setEntId(deptId); commodityCodeEntity.setUserId(userId); if (StringUtils.isNotEmpty(commodityCodeEntity.getHsbz())) { From 803f415541739d69d581a98954de73c17bbd4d5d Mon Sep 17 00:00:00 2001 From: "zhenghaiyang@ele-cloud.com" Date: Fri, 14 Apr 2023 14:16:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feature=201.=E7=BB=9F=E4=B8=80=E5=85=AC?= =?UTF-8?q?=E5=8F=B8=E7=89=A9=E6=96=99=E5=AF=BC=E5=85=A5=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SdenergyTaxCodeMatchController.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/taxcodematch/controller/SdenergyTaxCodeMatchController.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/taxcodematch/controller/SdenergyTaxCodeMatchController.java index 8d321508..15994c75 100644 --- a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/taxcodematch/controller/SdenergyTaxCodeMatchController.java +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/taxcodematch/controller/SdenergyTaxCodeMatchController.java @@ -6,14 +6,18 @@ import com.dxhy.base.file.exception.ExcelReadException; import com.dxhy.base.file.handle.ExcelReadHandle; import com.dxhy.order.baseservice.module.taxclass.model.TaxClassCodeEntity; import com.dxhy.order.baseservice.module.taxclass.service.TaxClassCodeService; +import com.dxhy.order.constant.OrderInfoContentEnum; +import com.dxhy.order.constant.OrderManagementConstant; import com.dxhy.order.consumer.modules.taxcodematch.emum.SdenergyTaxCodeMatchEnum; import com.dxhy.order.consumer.modules.taxcodematch.entity.SdenergyTaxCodeMatch; import com.dxhy.order.consumer.modules.taxcodematch.model.dto.SdenergyTaxCodeMatchDTO; import com.dxhy.order.consumer.modules.taxcodematch.model.dto.SdenergyTaxCodeMatchDeleteDTO; import com.dxhy.order.consumer.modules.taxcodematch.service.SdenergyTaxCodeMatchService; +import com.dxhy.order.consumer.utils.InterfaceResponseUtils; import com.dxhy.order.model.PageUtils; import com.dxhy.order.model.R; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import lombok.extern.slf4j.Slf4j; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.lang3.StringUtils; @@ -149,39 +153,49 @@ public class SdenergyTaxCodeMatchController { if(ObjectUtil.isEmpty(uploadList) ){ return R.error("数据解析为空"); } - List errorMsgList = Lists.newArrayList(); - int resultIndex = 3; + List> errorMsgList = Lists.newArrayList(); + int resultIndex = 2; for (SdenergyTaxCodeMatch taxCodeMatch : uploadList) { + resultIndex++; String wlflbm = taxCodeMatch.getWlflbm(); if(StringUtils.isNotBlank(wlflbm)){ SdenergyTaxCodeMatch codeMatch = sdenergyTaxCodeMatchService.queryByWlflbm(taxCodeMatch.getWlflbm()); if(codeMatch != null){ - errorMsgList.add("第" + resultIndex + "行,物料分类编码已存在"); + errorMsgList.add(buildEMsgMap("第" + resultIndex + "行,物料分类编码已存在")); continue; } }else { - errorMsgList.add("第" + resultIndex + "行,物料分类编码不能为空"); + errorMsgList.add(buildEMsgMap("第" + resultIndex + "行,物料分类编码不能为空")); continue; } String ssflbm = taxCodeMatch.getSsflbm(); if(StringUtils.isBlank(ssflbm)){ - errorMsgList.add("第" + resultIndex + "行,税收分类编码不能为空"); + errorMsgList.add(buildEMsgMap("第" + resultIndex + "行,税收分类编码不能为空")); continue; }else { TaxClassCodeEntity entity = taxClassCodeService.queryTaxClassCodeEntityBySpbm(ssflbm); if(entity != null){ taxCodeMatch.setSsflmc(entity.getSpjc()); }else { - errorMsgList.add("第" + resultIndex + "行,税收分类编码有误"); + errorMsgList.add(buildEMsgMap("第" + resultIndex + "行,税收分类编码有误")); continue; } } } if (ObjectUtil.isNotEmpty(errorMsgList)) { - return R.error(errorMsgList); + return R.error("9999","导入失败").put(OrderManagementConstant.DATA, errorMsgList).put("isPass", false).put("count", errorMsgList.size()); } - return sdenergyTaxCodeMatchService.upload(uploadList) > 0 ? R.ok() : R.error(); + if(sdenergyTaxCodeMatchService.upload(uploadList) > 0){ + return InterfaceResponseUtils.buildReturnInfo(OrderInfoContentEnum.SUCCESS, null).put("count", uploadList.size()); + } + return R.error("9999","导入失败").put(OrderManagementConstant.DATA, errorMsgList).put("isPass", false).put("count", errorMsgList.size()); } + public Map buildEMsgMap(String errorMsg){ + Map map = Maps.newHashMap(); + map.put("errorMsg",errorMsg); + return map; + } + } \ No newline at end of file From 395ec52c894848b9f0e72e1ead5a7c3733c2c2e2 Mon Sep 17 00:00:00 2001 From: "zhenghaiyang@ele-cloud.com" Date: Fri, 14 Apr 2023 14:45:27 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feature=201.=E5=90=8C=E6=AD=A5MDM=E7=9A=84?= =?UTF-8?q?=E5=AE=A2=E5=95=86=E4=BF=A1=E6=81=AF=E5=81=9A=E5=94=AF=E4=B8=80?= =?UTF-8?q?=E5=80=BC=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SDEnregyServiceImpl.java | 134 ++++++++++-------- 1 file changed, 73 insertions(+), 61 deletions(-) diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/service/impl/SDEnregyServiceImpl.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/service/impl/SDEnregyServiceImpl.java index 12161508..0b3bddcc 100644 --- a/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/service/impl/SDEnregyServiceImpl.java +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/service/impl/SDEnregyServiceImpl.java @@ -114,75 +114,82 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { public AjaxResult syncBuyerMessage(List mdmGmfxxtbReqBOS, String requestBody) { // 存表 List list = new ArrayList<>(); - for (int i = 0; i < mdmGmfxxtbReqBOS.size(); i++) { MdmGmfxxtbReqBO tempMdmGmfxxtbReqBO = mdmGmfxxtbReqBOS.get(i); BuyerEntity entity = new BuyerEntity(); - 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 valuelistBOS = tempMdmGmfxxtbReqBO.getMULTICODE().getVALUELIST(); - MdmGmfxxtbMulticodeValuelistBO firstValueList = valuelistBOS.get(0); - if (firstValueList != null) { - entity.setBankOfDeposit(firstValueList.getDESC3()); - entity.setBankNumber(firstValueList.getDESC4()); + BuyerEntity buyerEntity = buyerMapper.selectBuyerByCodeOrNameAndNsrsbh(tempMdmGmfxxtbReqBO.getCODE(), "", "-1"); + if(buyerEntity == null){ + log.info("MDM编码数据已存在;{}",tempMdmGmfxxtbReqBO.getCODE()); + entity.setSuccess(false); + if(mdmGmfxxtbReqBOS.size() == 1){ + return AjaxResult.success("9999", "MDM数据已存在,请勿重复同步"); } + } 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 valuelistBOS = tempMdmGmfxxtbReqBO.getMULTICODE().getVALUELIST(); + MdmGmfxxtbMulticodeValuelistBO firstValueList = valuelistBOS.get(0); + if (firstValueList != null) { + entity.setBankOfDeposit(firstValueList.getDESC3()); + entity.setBankNumber(firstValueList.getDESC4()); + } - List mdmBankListBOS = new ArrayList<>(); - String finalBuyerAddress = buyerAddress; - valuelistBOS.forEach(j -> { - MdmBankListBO temp = new MdmBankListBO(j, finalBuyerAddress, tempMdmGmfxxtbReqBO.getDESC27()); - mdmBankListBOS.add(temp); - }); + List mdmBankListBOS = new ArrayList<>(); + String finalBuyerAddress = buyerAddress; + valuelistBOS.forEach(j -> { + MdmBankListBO temp = new MdmBankListBO(j, finalBuyerAddress, tempMdmGmfxxtbReqBO.getDESC27()); + mdmBankListBOS.add(temp); + }); - bankList = JsonUtils.getInstance().toJsonStringNullToEmpty(mdmBankListBOS); - entity.setMdmMulticodeJson(bankList); - } + bankList = JsonUtils.getInstance().toJsonStringNullToEmpty(mdmBankListBOS); + entity.setMdmMulticodeJson(bankList); + } - entity.setSjh(tempMdmGmfxxtbReqBO.getDESC27()); - entity.setEmail(tempMdmGmfxxtbReqBO.getDESC29()); - // entity.setRemarks(); - entity.setCreateTime(new Date()); // TODO 记得修改Mapper - entity.setModifyTime(new Date()); - entity.setModifyUserId(null); // TODO - entity.setCreateUserId(null); // TODO - String idCardRegex = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)"; - // 税号正则表达式 - String taxNoRegex = "^[a-zA-Z0-9]{15,20}$"; - entity.setGhfQylx(""); - if (StringUtils.isNotEmpty(tempMdmGmfxxtbReqBO.getDESC14())) { - if (tempMdmGmfxxtbReqBO.getDESC14().matches(idCardRegex)) { - entity.setGhfQylx("03"); // 有可能出现个人 + entity.setSjh(tempMdmGmfxxtbReqBO.getDESC27()); + entity.setEmail(tempMdmGmfxxtbReqBO.getDESC29()); + // entity.setRemarks(); + entity.setCreateTime(new Date()); // TODO 记得修改Mapper + entity.setModifyTime(new Date()); + entity.setModifyUserId(null); // TODO + entity.setCreateUserId(null); // TODO + String idCardRegex = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)"; + // 税号正则表达式 + String taxNoRegex = "^[a-zA-Z0-9]{15,20}$"; + entity.setGhfQylx(""); + if (StringUtils.isNotEmpty(tempMdmGmfxxtbReqBO.getDESC14())) { + if (tempMdmGmfxxtbReqBO.getDESC14().matches(idCardRegex)) { + entity.setGhfQylx("03"); // 有可能出现个人 + } + if (tempMdmGmfxxtbReqBO.getDESC14().matches(taxNoRegex)) { + entity.setGhfQylx("01"); + } } - if (tempMdmGmfxxtbReqBO.getDESC14().matches(taxNoRegex)) { - entity.setGhfQylx("01"); + 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); } } - 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); } String respStr = ""; @@ -429,7 +436,7 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { "}"; // 发送POST请求 - log.info("[MDM主动同步物料]请求地址:{},请求参数:{}", buyerUrl, requestBody); + log.info("[MDM主动同步物料]请求地址:{},请求参数:{}", groupTaxCodeUrl, requestBody); HttpResponse response = HttpRequest.post(groupTaxCodeUrl) .timeout(20000) // 设置请求超时时间 .header("Content-Type", "application/json") @@ -439,8 +446,13 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { .execute(); String resp = response.body(); log.info("[MDM主动同步物料]响应结果:{}", resp); - + if(StringUtils.isBlank(resp)){ + return R.error("未查询到数据!"); + } SDEnergyMdmBaseBO baseBO = JSONObject.parseObject(resp, SDEnergyMdmBaseBO.class); + if(baseBO == null || baseBO.getESB() == null || "S".equals(baseBO.getESB().getRESULT())){ + return R.error("未查询到数据!"); + } List mdmGmfxxtbReqBOS = (List) Optional.of(baseBO) .map(SDEnergyMdmBaseBO::getESB) .map(ESBBO::getDATA)