feature:订单导入客户信息,存在则跳过

release
gaorl 2 years ago
parent 30c0634989
commit bbf1177dc4
  1. 96
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/buyer/service/impl/BuyerServiceImpl.java

@ -137,6 +137,7 @@ public class BuyerServiceImpl implements BuyerService {
List<Map<String, String>> checkResultMapList = new ArrayList<>();
int k = 1;
Map<String, Object> repeatMap = new HashMap<>(10);
List<BuyerEntity> buyerEntitys = new ArrayList<>();
for (BuyerEntity buyerEntity : buyerEntityList) {
k++;
String preStr = "第" + k + "行,";
@ -168,6 +169,7 @@ public class BuyerServiceImpl implements BuyerService {
List<Map<String, String>> checkResultMap = verifyBuyerManageInfoService.checkSyncBuyerRequestParam(gmfxxtbReqBo, preStr);
if (ObjectUtil.isNotEmpty(checkResultMap)) {
checkResultMapList.addAll(checkResultMap);
continue;
}
if (StringUtils.isNotEmpty(buyerEntity.getTaxpayerCode())) {
@ -178,6 +180,7 @@ public class BuyerServiceImpl implements BuyerService {
checkResultMap1.put(OrderManagementConstant.ERRORCODE, ConfigureConstant.STRING_9999);
checkResultMap1.put(OrderManagementConstant.ERRORMESSAGE, preStr + "税号:" + buyerEntity.getTaxpayerCode() + ",已经存在");
checkResultMapList.add(checkResultMap1);
continue;
}
}
//查找根据销方税号 deptid
@ -190,12 +193,14 @@ public class BuyerServiceImpl implements BuyerService {
checkResultMap1.put(OrderManagementConstant.ERRORCODE, ConfigureConstant.STRING_9999);
checkResultMap1.put(OrderManagementConstant.ERRORMESSAGE, preStr + "购方名称:" + buyerEntity.getPurchaseName() + ",已经存在");
checkResultMapList.add(checkResultMap1);
continue;
}
}else{
Map<String, String> checkResultMap1 = new HashMap<>(2);
checkResultMap1.put(OrderManagementConstant.ERRORCODE, ConfigureConstant.STRING_9999);
checkResultMap1.put(OrderManagementConstant.ERRORMESSAGE, preStr + "购方名称不允许为空");
checkResultMapList.add(checkResultMap1);
continue;
}
if (StringUtils.isNotEmpty(buyerEntity.getEntId())&&StringUtils.isNotEmpty(buyerEntity.getBuyerCode())) {
param = new HashMap<>(5);
@ -207,13 +212,16 @@ public class BuyerServiceImpl implements BuyerService {
checkResultMap1.put(OrderManagementConstant.ERRORCODE, ConfigureConstant.STRING_9999);
checkResultMap1.put(OrderManagementConstant.ERRORMESSAGE, preStr + "销方组织:" + buyerEntity.getXhfMc() + ",购方编码:" + buyerEntity.getBuyerCode() + ",已经存在");
checkResultMapList.add(checkResultMap1);
continue;
}
}else{
Map<String, String> checkResultMap1 = new HashMap<>(2);
checkResultMap1.put(OrderManagementConstant.ERRORCODE, ConfigureConstant.STRING_9999);
checkResultMap1.put(OrderManagementConstant.ERRORMESSAGE, preStr + "销方组织或购方编码不允许为空");
checkResultMapList.add(checkResultMap1);
continue;
}
buyerEntitys.add(buyerEntity);
}
if (ObjectUtil.isNotEmpty(checkResultMapList)) {
@ -228,58 +236,58 @@ public class BuyerServiceImpl implements BuyerService {
int importSuccessCount = 0;
Map<String, Object> resultMap = new HashMap<>(10);
R result = R.ok();
if (ObjectUtil.isNotEmpty(list)) {
resultMap.put("list", list);
result.put(OrderManagementConstant.CODE, ConfigureConstant.STRING_9999)
.put(OrderManagementConstant.MESSAGE, "上传失败");
} else {
importSuccessCount = buyerEntityList.size();
for (BuyerEntity buyerEntity : buyerEntityList) {
//数据重复性校验
buyerEntity.setId(baseService.getGenerateShotKey());
if (StringUtils.isBlank(buyerEntity.getBuyerCode())) {
buyerEntity.setBuyerCode(baseService.getGenerateShotKey());
}
List<BuyerEntityDetail> buyerEntityDetail = new ArrayList<>();
BuyerEntityDetail buyerEntityDetail1 = new BuyerEntityDetail();
buyerEntityDetail1.setBuyerManageId(buyerEntity.getId());
buyerEntityDetail1.setBankAccount(buyerEntity.getBankNumber());
buyerEntityDetail1.setBankName(buyerEntity.getBankOfDeposit());
buyerEntityDetail1.setAddress(buyerEntity.getAddress());
buyerEntityDetail1.setPhone(buyerEntity.getPhone());
buyerEntityDetail1.setCreateTime(new Date());
buyerEntityDetail1.setDefaultMark("0");
try {
buyerEntityDetail1.setCreateUser(userInfoService.getUser().getUserId().toString());
} catch (Exception e) {
buyerEntityDetail1.setCreateUser("");
}
buyerEntityDetail.add(buyerEntityDetail1);
buyerMapper.batchInsertBuyerDetail(buyerEntityDetail);
// if (ObjectUtil.isNotEmpty(list)) {
// resultMap.put("list", list);
// result.put(OrderManagementConstant.CODE, ConfigureConstant.STRING_9999)
// .put(OrderManagementConstant.MESSAGE, "上传失败");
// } else {
importSuccessCount = buyerEntitys.size();
for (BuyerEntity buyerEntity : buyerEntitys) {
//数据重复性校验
buyerEntity.setId(baseService.getGenerateShotKey());
if (StringUtils.isBlank(buyerEntity.getBuyerCode())) {
buyerEntity.setBuyerCode(baseService.getGenerateShotKey());
}
if (buyerEntityList.size() < ConfigureConstant.BATCH_INSERT) {
buyerMapper.insertBuyerByList(buyerEntityList);
} else {
List<BuyerEntity> insertBuyerList = new ArrayList<>();
int i = 0;
for (BuyerEntity buyerEntity : buyerEntityList) {
if (i != 0 && i % ConfigureConstant.BATCH_INSERT == 0) {
buyerMapper.insertBuyerByList(insertBuyerList);
insertBuyerList = new ArrayList<>();
}
insertBuyerList.add(buyerEntity);
i++;
}
if (insertBuyerList.size() > 0) {
List<BuyerEntityDetail> buyerEntityDetail = new ArrayList<>();
BuyerEntityDetail buyerEntityDetail1 = new BuyerEntityDetail();
buyerEntityDetail1.setBuyerManageId(buyerEntity.getId());
buyerEntityDetail1.setBankAccount(buyerEntity.getBankNumber());
buyerEntityDetail1.setBankName(buyerEntity.getBankOfDeposit());
buyerEntityDetail1.setAddress(buyerEntity.getAddress());
buyerEntityDetail1.setPhone(buyerEntity.getPhone());
buyerEntityDetail1.setCreateTime(new Date());
buyerEntityDetail1.setDefaultMark("0");
try {
buyerEntityDetail1.setCreateUser(userInfoService.getUser().getUserId().toString());
} catch (Exception e) {
buyerEntityDetail1.setCreateUser("");
}
buyerEntityDetail.add(buyerEntityDetail1);
buyerMapper.batchInsertBuyerDetail(buyerEntityDetail);
}
if (buyerEntitys.size() < ConfigureConstant.BATCH_INSERT) {
buyerMapper.insertBuyerByList(buyerEntitys);
} else {
List<BuyerEntity> insertBuyerList = new ArrayList<>();
int i = 0;
for (BuyerEntity buyerEntity : buyerEntitys) {
if (i != 0 && i % ConfigureConstant.BATCH_INSERT == 0) {
buyerMapper.insertBuyerByList(insertBuyerList);
insertBuyerList = new ArrayList<>();
}
insertBuyerList.add(buyerEntity);
i++;
}
if (buyerEntitys.size() > 0) {
buyerMapper.insertBuyerByList(buyerEntitys);
}
resultMap.put("list", list);
}
resultMap.put("list", list);
// }
log.info("{}数据库插入耗时:{}", LOGGER_MSG, (System.currentTimeMillis() - t3));
return result.put(OrderManagementConstant.DATA, resultMap).put("count", importSuccessCount)
.put("importResult", "导入数据共" + buyerEntityList.size() + "条,成功" + importSuccessCount + "条");
.put("importResult", "导入数据共" + buyerEntitys.size() + "条,成功" + importSuccessCount + "条");
}
@Override

Loading…
Cancel
Save