release
gaorl 2 years ago
commit 3e9f8fef78
  1. 26
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/controller/CommodityController.java
  2. 30
      order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/taxcodematch/controller/SdenergyTaxCodeMatchController.java
  3. 134
      order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/service/impl/SDEnregyServiceImpl.java

@ -5,16 +5,6 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; 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.common.ExcelReadContext;
import com.dxhy.base.file.exception.ExcelReadException; import com.dxhy.base.file.exception.ExcelReadException;
import com.dxhy.base.file.handle.ExcelReadHandle; 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.constant.CommodityEnum;
import com.dxhy.order.baseservice.module.commodity.model.CommodityCodeEntity; 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.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.CommodityService;
import com.dxhy.order.baseservice.module.commodity.service.VerifyCommodityCodeService; 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.DeptEntity;
import com.dxhy.order.baseservice.module.thirdservice.user.model.UserEntity; 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.module.thirdservice.user.service.UserInfoService;
import com.dxhy.order.baseservice.openapi.protocol.qd.PageSpxxReq; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -162,7 +161,6 @@ public class CommodityController {
if (StringUtils.isBlank(commodityCodeEntity.getYcbz())) { if (StringUtils.isBlank(commodityCodeEntity.getYcbz())) {
commodityCodeEntity.setYcbz(ConfigureConstant.STRING_0); commodityCodeEntity.setYcbz(ConfigureConstant.STRING_0);
} }
/** /**
* 添加校验 * 添加校验
*/ */
@ -447,7 +445,7 @@ public class CommodityController {
/** /**
* excel 导入数据转换为表格数据 * excel 导入数据转换为表格数据
*/ */
List<CommodityCodeEntity> commodityCodeEntities = transCommodityCodeEntityList(commodityExcelList, String.valueOf(userEntity.getUserId())); List<CommodityCodeEntity> commodityCodeEntities = transCommodityCodeEntityList(commodityExcelList, String.valueOf(userEntity.getUserId()),userEntity.getDept().getDeptId());
return commodityService.uploadCommodityCode(commodityCodeEntities); return commodityService.uploadCommodityCode(commodityCodeEntities);
@ -459,7 +457,7 @@ public class CommodityController {
* @param commodityExcelList * @param commodityExcelList
* @return * @return
*/ */
public List<CommodityCodeEntity> transCommodityCodeEntityList(List<CommodityExcel> commodityExcelList, String userId) { public List<CommodityCodeEntity> transCommodityCodeEntityList(List<CommodityExcel> commodityExcelList, String userId, String deptId) {
List<CommodityCodeEntity> commodityCodeEntityList = new ArrayList<>(); List<CommodityCodeEntity> commodityCodeEntityList = new ArrayList<>();
if (ObjectUtil.isNotEmpty(commodityExcelList)) { if (ObjectUtil.isNotEmpty(commodityExcelList)) {
for (CommodityExcel commodityExcel : commodityExcelList) { for (CommodityExcel commodityExcel : commodityExcelList) {
@ -503,7 +501,7 @@ public class CommodityController {
commodityCodeEntity.setCpy(""); commodityCodeEntity.setCpy("");
commodityCodeEntity.setJdc(""); commodityCodeEntity.setJdc("");
commodityCodeEntity.setBmbBbh(""); commodityCodeEntity.setBmbBbh("");
commodityCodeEntity.setEntId(deptId);
commodityCodeEntity.setUserId(userId); commodityCodeEntity.setUserId(userId);
if (StringUtils.isNotEmpty(commodityCodeEntity.getHsbz())) { if (StringUtils.isNotEmpty(commodityCodeEntity.getHsbz())) {

@ -6,14 +6,18 @@ import com.dxhy.base.file.exception.ExcelReadException;
import com.dxhy.base.file.handle.ExcelReadHandle; import com.dxhy.base.file.handle.ExcelReadHandle;
import com.dxhy.order.baseservice.module.taxclass.model.TaxClassCodeEntity; import com.dxhy.order.baseservice.module.taxclass.model.TaxClassCodeEntity;
import com.dxhy.order.baseservice.module.taxclass.service.TaxClassCodeService; 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.emum.SdenergyTaxCodeMatchEnum;
import com.dxhy.order.consumer.modules.taxcodematch.entity.SdenergyTaxCodeMatch; 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.SdenergyTaxCodeMatchDTO;
import com.dxhy.order.consumer.modules.taxcodematch.model.dto.SdenergyTaxCodeMatchDeleteDTO; import com.dxhy.order.consumer.modules.taxcodematch.model.dto.SdenergyTaxCodeMatchDeleteDTO;
import com.dxhy.order.consumer.modules.taxcodematch.service.SdenergyTaxCodeMatchService; 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.PageUtils;
import com.dxhy.order.model.R; import com.dxhy.order.model.R;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -149,39 +153,49 @@ public class SdenergyTaxCodeMatchController {
if(ObjectUtil.isEmpty(uploadList) ){ if(ObjectUtil.isEmpty(uploadList) ){
return R.error("数据解析为空"); return R.error("数据解析为空");
} }
List<String> errorMsgList = Lists.newArrayList(); List<Map<String,String>> errorMsgList = Lists.newArrayList();
int resultIndex = 3; int resultIndex = 2;
for (SdenergyTaxCodeMatch taxCodeMatch : uploadList) { for (SdenergyTaxCodeMatch taxCodeMatch : uploadList) {
resultIndex++;
String wlflbm = taxCodeMatch.getWlflbm(); String wlflbm = taxCodeMatch.getWlflbm();
if(StringUtils.isNotBlank(wlflbm)){ if(StringUtils.isNotBlank(wlflbm)){
SdenergyTaxCodeMatch codeMatch = sdenergyTaxCodeMatchService.queryByWlflbm(taxCodeMatch.getWlflbm()); SdenergyTaxCodeMatch codeMatch = sdenergyTaxCodeMatchService.queryByWlflbm(taxCodeMatch.getWlflbm());
if(codeMatch != null){ if(codeMatch != null){
errorMsgList.add("第" + resultIndex + "行,物料分类编码已存在"); errorMsgList.add(buildEMsgMap("第" + resultIndex + "行,物料分类编码已存在"));
continue; continue;
} }
}else { }else {
errorMsgList.add("第" + resultIndex + "行,物料分类编码不能为空"); errorMsgList.add(buildEMsgMap("第" + resultIndex + "行,物料分类编码不能为空"));
continue; continue;
} }
String ssflbm = taxCodeMatch.getSsflbm(); String ssflbm = taxCodeMatch.getSsflbm();
if(StringUtils.isBlank(ssflbm)){ if(StringUtils.isBlank(ssflbm)){
errorMsgList.add("第" + resultIndex + "行,税收分类编码不能为空"); errorMsgList.add(buildEMsgMap("第" + resultIndex + "行,税收分类编码不能为空"));
continue; continue;
}else { }else {
TaxClassCodeEntity entity = taxClassCodeService.queryTaxClassCodeEntityBySpbm(ssflbm); TaxClassCodeEntity entity = taxClassCodeService.queryTaxClassCodeEntityBySpbm(ssflbm);
if(entity != null){ if(entity != null){
taxCodeMatch.setSsflmc(entity.getSpjc()); taxCodeMatch.setSsflmc(entity.getSpjc());
}else { }else {
errorMsgList.add("第" + resultIndex + "行,税收分类编码有误"); errorMsgList.add(buildEMsgMap("第" + resultIndex + "行,税收分类编码有误"));
continue; continue;
} }
} }
} }
if (ObjectUtil.isNotEmpty(errorMsgList)) { 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<String,String> buildEMsgMap(String errorMsg){
Map<String, String> map = Maps.newHashMap();
map.put("errorMsg",errorMsg);
return map;
}
} }

@ -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)

Loading…
Cancel
Save