|
@ -842,6 +842,360 @@ public class BmsSupplierController { |
|
|
// @SysLog(module = SystemModule.BASE, title = "供应商", biz = BizType.INSERT)
|
|
|
// @SysLog(module = SystemModule.BASE, title = "供应商", biz = BizType.INSERT)
|
|
|
@PreAuthorize("hasRole('bms:supplier:insert')") |
|
|
@PreAuthorize("hasRole('bms:supplier:insert')") |
|
|
public R<?> importExcel(@RequestBody List<BmsSupplierExcelBo> param){ |
|
|
public R<?> importExcel(@RequestBody List<BmsSupplierExcelBo> param){ |
|
|
|
|
|
param.forEach(a->{ |
|
|
|
|
|
a.setErrorInfo(""); |
|
|
|
|
|
if(a.getType().equals("4")){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if(!StringUtils.hasText(a.getCustomerCode())){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"客户编号不能为空;"); |
|
|
|
|
|
} |
|
|
|
|
|
if(!StringUtils.hasText(a.getCustomerName())){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"客户名称不能为空;"); |
|
|
|
|
|
} |
|
|
|
|
|
if(!StringUtils.hasText(a.getSalesRegionName())){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"销售区域不能为空;"); |
|
|
|
|
|
} |
|
|
|
|
|
if(!StringUtils.hasText(a.getFirstLevelAdministrativeRegionName())){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"省不能为空;"); |
|
|
|
|
|
} |
|
|
|
|
|
if(!StringUtils.hasText(a.getSecondaryLevelAdministrativeRegionName())){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"市不能为空;"); |
|
|
|
|
|
} |
|
|
|
|
|
if(!StringUtils.hasText(a.getAdministrativeRegionName())){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"行政区域不能为空;"); |
|
|
|
|
|
} |
|
|
|
|
|
if(a.getIsSupplier()==null){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"是否供应商字段不能为空;"); |
|
|
|
|
|
} |
|
|
|
|
|
if(!StringUtils.hasText(a.getMinorHeadCodes()) && !StringUtils.hasText(a.getMainHeadCode())){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"负责人不能为空;"); |
|
|
|
|
|
} |
|
|
|
|
|
if(a.getIsExpendableExpense()==null){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"是否投放费用字段不能为空;"); |
|
|
|
|
|
} |
|
|
|
|
|
// if(a.getCloseAccountStatus()==null){
|
|
|
|
|
|
// a.setErrorInfo(a.getErrorInfo()+"闭户状态不能为空;");
|
|
|
|
|
|
// }
|
|
|
|
|
|
}); |
|
|
|
|
|
List<BmsSupplierExcelBo> saveList = param.stream().filter(a->a.getType().equals("1")).collect(Collectors.toList()); |
|
|
|
|
|
List<BmsSupplierExcelBo> updateList = param.stream().filter(a->a.getType().equals("2")).collect(Collectors.toList()); |
|
|
|
|
|
List<BmsSupplierExcelBo> deleteList = param.stream().filter(a->a.getType().equals("3")).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
/** --------------------------------------------------------------------------- **/ |
|
|
|
|
|
List<String> bmsRegionNames = new ArrayList<>(); |
|
|
|
|
|
bmsRegionNames.addAll( |
|
|
|
|
|
saveList.stream().filter(a->a.getSalesRegionName()!=null) |
|
|
|
|
|
.map(a->a.getSalesRegionName()).collect(Collectors.toList()) |
|
|
|
|
|
); |
|
|
|
|
|
bmsRegionNames.addAll( |
|
|
|
|
|
updateList.stream().filter(a->a.getSalesRegionName()!=null) |
|
|
|
|
|
.map(a->a.getSalesRegionName()).collect(Collectors.toList()) |
|
|
|
|
|
); |
|
|
|
|
|
bmsRegionNames = bmsRegionNames.stream().distinct().collect(Collectors.toList()); |
|
|
|
|
|
List<BmsRegion> regionList = new ArrayList<>(); |
|
|
|
|
|
if(bmsRegionNames.size()>0){ |
|
|
|
|
|
LambdaQueryWrapper<BmsRegion> bmsRegionLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
bmsRegionLambdaQueryWrapper.in(BmsRegion::getName,bmsRegionNames); |
|
|
|
|
|
regionList = bmsRegionService.list(bmsRegionLambdaQueryWrapper); |
|
|
|
|
|
List<String> existBmsRegionName = regionList.stream().map(a->a.getName()).collect(Collectors.toList()); |
|
|
|
|
|
if(regionList.size()<bmsRegionNames.size()){ |
|
|
|
|
|
param.forEach(a->{ |
|
|
|
|
|
if(a.getType().equals("4")){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if(!existBmsRegionName.contains(a.getSalesRegionName())){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"不存在销售区域"+a.getSalesRegionName()+";"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<String> bmsBizRegionNames = new ArrayList<>(); |
|
|
|
|
|
List<BmsRegion2> bizRegionList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
bmsBizRegionNames.addAll( |
|
|
|
|
|
saveList.stream().filter(a->a.getSecondaryLevelAdministrativeRegionName()!=null |
|
|
|
|
|
&& a.getFirstLevelAdministrativeRegionName()!=null && a.getAdministrativeRegionName()!=null) |
|
|
|
|
|
.map(a->a.getFirstLevelAdministrativeRegionName()+"_"+a.getSecondaryLevelAdministrativeRegionName()+"_"+a.getAdministrativeRegionName()).collect(Collectors.toList()) |
|
|
|
|
|
); |
|
|
|
|
|
bmsBizRegionNames.addAll( |
|
|
|
|
|
updateList.stream().filter(a->a.getSecondaryLevelAdministrativeRegionName()!=null |
|
|
|
|
|
&& a.getFirstLevelAdministrativeRegionName()!=null && a.getAdministrativeRegionName()!=null) |
|
|
|
|
|
.map(a->a.getFirstLevelAdministrativeRegionName()+"_"+a.getSecondaryLevelAdministrativeRegionName()+"_"+a.getAdministrativeRegionName()).collect(Collectors.toList()) |
|
|
|
|
|
); |
|
|
|
|
|
bmsBizRegionNames = bmsBizRegionNames.stream().distinct().collect(Collectors.toList()); |
|
|
|
|
|
if(bmsBizRegionNames.size()>0){ |
|
|
|
|
|
LambdaQueryWrapper<BmsRegion2> bmsRegion2LambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
bmsRegion2LambdaQueryWrapper.in(BmsRegion2::getPathNames,bmsBizRegionNames); |
|
|
|
|
|
bizRegionList = bmsRegion2Service.list(bmsRegion2LambdaQueryWrapper); |
|
|
|
|
|
List<String> exsitBizRegeionName = bizRegionList.stream().map(a->a.getName()).collect(Collectors.toList()); |
|
|
|
|
|
if(bizRegionList.size()<bmsBizRegionNames.size()){ |
|
|
|
|
|
param.forEach(a->{ |
|
|
|
|
|
if(a.getType().equals("4")){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if(!exsitBizRegeionName.contains( |
|
|
|
|
|
a.getFirstLevelAdministrativeRegionName()+"_"+a.getSecondaryLevelAdministrativeRegionName()+"_"+a.getAdministrativeRegionName()) |
|
|
|
|
|
){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"不存在行政区域"+a.getFirstLevelAdministrativeRegionName()+"_"+a.getSecondaryLevelAdministrativeRegionName()+"_"+a.getAdministrativeRegionName()+";"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
/** ------------------------------- 校验负责人 ------------------------------------------------ */ |
|
|
|
|
|
List<String> userCodes = new ArrayList<>(); |
|
|
|
|
|
userCodes.addAll( |
|
|
|
|
|
saveList.stream().filter(a->StringUtils.hasText(a.getMainHeadCode())) |
|
|
|
|
|
.map(a->Arrays.asList(a.getMainHeadCode().split(","))) |
|
|
|
|
|
.flatMap(List::stream).collect(Collectors.toList()) |
|
|
|
|
|
); |
|
|
|
|
|
userCodes.addAll( |
|
|
|
|
|
saveList.stream().filter(a->StringUtils.hasText(a.getMinorHeadCodes())) |
|
|
|
|
|
.map(a->Arrays.asList(a.getMinorHeadCodes().split(","))) |
|
|
|
|
|
.flatMap(List::stream).collect(Collectors.toList()) |
|
|
|
|
|
); |
|
|
|
|
|
List<SysUser> userList = new ArrayList<>(); |
|
|
|
|
|
if(userCodes.size()>0){ |
|
|
|
|
|
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
sysUserLambdaQueryWrapper.in(SysUser::getCode,userCodes); |
|
|
|
|
|
userList = sysUserService.list(sysUserLambdaQueryWrapper); |
|
|
|
|
|
List<String> exsitUserCodes = userList.stream().map(a->a.getCode()).collect(Collectors.toList()); |
|
|
|
|
|
if(userList.size()<userCodes.size()){ |
|
|
|
|
|
param.forEach(a->{ |
|
|
|
|
|
if(a.getType().equals("4")){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if(a.getType().equals("3")){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
List<String> userCodeTemp = new ArrayList<>(); |
|
|
|
|
|
if(StringUtils.hasText(a.getMainHeadCode())){ |
|
|
|
|
|
userCodeTemp.addAll(Arrays.asList(a.getMainHeadCode().split(","))); |
|
|
|
|
|
} |
|
|
|
|
|
if(StringUtils.hasText(a.getMinorHeadCodes())){ |
|
|
|
|
|
userCodeTemp.addAll(Arrays.asList(a.getMinorHeadCodes().split(","))); |
|
|
|
|
|
} |
|
|
|
|
|
List<String> noExistUserCode = userCodeTemp.stream().filter(b->!exsitUserCodes.contains(b)).collect(Collectors.toList()); |
|
|
|
|
|
if(noExistUserCode.size()>0){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"不存在人员"+noExistUserCode.stream().collect(Collectors.joining(","))); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
/** --------------------------------------------------------------------------- **/ |
|
|
|
|
|
|
|
|
|
|
|
/** --------------------------------------------------------------------------- **/ |
|
|
|
|
|
/** ------------------------------- 校验新增 ------------------------------------------------ */ |
|
|
|
|
|
if(saveList.size()>0){ |
|
|
|
|
|
List<String> saveCodes = saveList.stream().filter(a->StringUtils.hasText(a.getCustomerCode())).map(a->a.getCustomerCode()).distinct().collect(Collectors.toList()); |
|
|
|
|
|
if(saveCodes.size()>0){ |
|
|
|
|
|
LambdaQueryWrapper<BmsSupplier> checkSave = new LambdaQueryWrapper<>(); |
|
|
|
|
|
checkSave.in(BmsSupplier::getCode,saveCodes); |
|
|
|
|
|
List<BmsSupplier> checkSaveSupplier = bmsSupplierService.list(checkSave); |
|
|
|
|
|
if(checkSaveSupplier.size()>0){ |
|
|
|
|
|
List<String> existSaveCodes = checkSaveSupplier.stream().map(a->a.getCode()).collect(Collectors.toList()); |
|
|
|
|
|
param.forEach(a->{ |
|
|
|
|
|
if(a.getType().equals("1")){ |
|
|
|
|
|
if(existSaveCodes.contains(a.getCustomerCode())){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"已存在客户编码"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** --------------------------------------------------------------------------- **/ |
|
|
|
|
|
|
|
|
|
|
|
/** ------------------------------- 校验更新 ------------------------------------------------ */ |
|
|
|
|
|
if(updateList.size()>0){ |
|
|
|
|
|
List<String> updateCheckCodes = updateList.stream().filter(a->StringUtils.hasText(a.getCustomerCode())).map(a->a.getCustomerCode()).distinct().collect(Collectors.toList()); |
|
|
|
|
|
if(updateCheckCodes.size()==0){ |
|
|
|
|
|
param.forEach(a->{ |
|
|
|
|
|
if(a.getType().equals("2")){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"更新不存在客户编码;"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
LambdaQueryWrapper<BmsSupplier> checkUpdateCustomerCode = new LambdaQueryWrapper<>(); |
|
|
|
|
|
checkUpdateCustomerCode.in(BmsSupplier::getCode,updateCheckCodes); |
|
|
|
|
|
List<BmsSupplier> checkUpdateSupplierList = bmsSupplierService.list(checkUpdateCustomerCode); |
|
|
|
|
|
List<String> existUpdateCodes = checkUpdateSupplierList.stream().map(a->a.getCode()).collect(Collectors.toList()); |
|
|
|
|
|
param.forEach(a->{ |
|
|
|
|
|
if(a.getType().equals("2")){ |
|
|
|
|
|
if(!existUpdateCodes.contains(a.getCustomerCode())){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"更新不存在客户编码;"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
/** ----------------------------------------------------------------------------------- */ |
|
|
|
|
|
|
|
|
|
|
|
/** ------------------------------- 删除更新 ------------------------------------------------ */ |
|
|
|
|
|
if(deleteList.size()>0){ |
|
|
|
|
|
List<String> deleteCheckCodes = deleteList.stream().map(a->a.getCustomerCode()).collect(Collectors.toList()); |
|
|
|
|
|
if(deleteCheckCodes.size()==0){ |
|
|
|
|
|
param.forEach(a->{ |
|
|
|
|
|
if(a.getType().equals("3")){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"删除不存在客户编码"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}else{ |
|
|
|
|
|
LambdaQueryWrapper<BmsSupplier> checkDeleteCustomerCode = new LambdaQueryWrapper<>(); |
|
|
|
|
|
checkDeleteCustomerCode.in(BmsSupplier::getCode,deleteCheckCodes); |
|
|
|
|
|
List<BmsSupplier> checkDeleteSupplierList = bmsSupplierService.list(checkDeleteCustomerCode); |
|
|
|
|
|
List<String> existDeleteCodes = checkDeleteSupplierList.stream().map(a->a.getCode()).collect(Collectors.toList()); |
|
|
|
|
|
param.forEach(a->{ |
|
|
|
|
|
if(a.getType().equals("3")){ |
|
|
|
|
|
if(!existDeleteCodes.contains(a.getCustomerCode())){ |
|
|
|
|
|
a.setErrorInfo(a.getErrorInfo()+"删除不存在客户编码;"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
/** ----------------------------------------------------------------------------------- */ |
|
|
|
|
|
|
|
|
|
|
|
/** ------------------------------- 返回错误 ------------------------------------------- */ |
|
|
|
|
|
if(param.stream().filter(a->a.getErrorInfo().length()>0).count()>0) { |
|
|
|
|
|
return R.ok(param, "导入失败,请打开EXCEL查询错误详情!"); |
|
|
|
|
|
} |
|
|
|
|
|
/** ----------------------------------------------------------------------------------- */ |
|
|
|
|
|
|
|
|
|
|
|
Map<String,BmsRegion2> bizRegionMap = bizRegionList.stream().collect(Collectors.toMap(BmsRegion2::getPathNames, a->a)); |
|
|
|
|
|
Map<String,BmsRegion> saleRegionMap = regionList.stream().collect(Collectors.toMap(BmsRegion::getName, a->a)); |
|
|
|
|
|
Map<String,SysUser> sysUserMap = userList.stream().collect(Collectors.toMap(SysUser::getCode, a->a)); |
|
|
|
|
|
|
|
|
|
|
|
/** ------------------------------- 保存新增 ------------------------------------------------ */ |
|
|
|
|
|
if(saveList.size()>0) { |
|
|
|
|
|
List<BmsSupplier> saveBmsSuppliers = saveList.stream().map(a->{ |
|
|
|
|
|
BmsSupplier supplier = new BmsSupplier(); |
|
|
|
|
|
supplier.setName(a.getCustomerName()); |
|
|
|
|
|
supplier.setCode(a.getCustomerCode()); |
|
|
|
|
|
supplier.setStopFlag(a.getCloseAccountStatus()); |
|
|
|
|
|
supplier.setStopFlagDate(a.getCloseAccountDate()); |
|
|
|
|
|
supplier.setCooperatePauseFlag(a.getSuspendCooperationStatus()); |
|
|
|
|
|
supplier.setCooperatePauseFlagDate(a.getSuspendCooperationDate()); |
|
|
|
|
|
if(StringUtils.hasText(a.getMainHeadCode())){ |
|
|
|
|
|
SysUser sysUser = sysUserMap.get(a.getMainHeadCode()); |
|
|
|
|
|
supplier.setUserId(sysUser.getId()); |
|
|
|
|
|
supplier.setUserCode(sysUser.getCode()); |
|
|
|
|
|
supplier.setUserName(sysUser.getName()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.hasText(a.getMinorHeadCodes())){ |
|
|
|
|
|
List<String> otherUserCodes = Arrays.asList(a.getMinorHeadCodes().split(",")); |
|
|
|
|
|
List<String> otherUserNames = new ArrayList<>(); |
|
|
|
|
|
List<String> otherUserIds = new ArrayList<>(); |
|
|
|
|
|
otherUserCodes.forEach(b->{ |
|
|
|
|
|
SysUser sysUser = sysUserMap.get(b); |
|
|
|
|
|
otherUserNames.add(sysUser.getName()); |
|
|
|
|
|
otherUserIds.add(sysUser.getId()); |
|
|
|
|
|
}); |
|
|
|
|
|
supplier.setOtherUserCodes(otherUserCodes.stream().collect(Collectors.joining(","))); |
|
|
|
|
|
supplier.setOtherUserNames(otherUserNames.stream().collect(Collectors.joining(","))); |
|
|
|
|
|
supplier.setOtherUserIds(otherUserIds.toArray(new String[otherUserIds.size()])); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.hasText(a.getSalesRegionName())){ |
|
|
|
|
|
BmsRegion saleRegion = saleRegionMap.get(a.getSalesRegionName()); |
|
|
|
|
|
supplier.setRegionLast(saleRegion.getId()); |
|
|
|
|
|
supplier.setRegionSecond(saleRegion.getId()); |
|
|
|
|
|
supplier.setRegionFirst(saleRegion.getPid()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.hasText(a.getSecondaryLevelAdministrativeRegionName()) |
|
|
|
|
|
&& StringUtils.hasText(a.getFirstLevelAdministrativeRegionName()) |
|
|
|
|
|
&& StringUtils.hasText(a.getAdministrativeRegionName())){ |
|
|
|
|
|
BmsRegion2 bizRegion = bizRegionMap.get(a.getFirstLevelAdministrativeRegionName()+"_"+a.getSecondaryLevelAdministrativeRegionName()+"_"+a.getAdministrativeRegionName()); |
|
|
|
|
|
supplier.setRegion2Third(bizRegion.getId()); |
|
|
|
|
|
supplier.setRegion2Second(bizRegion.getPid()); |
|
|
|
|
|
String firstRegion2Id = bizRegion.getPathIds().split("_")[0]; |
|
|
|
|
|
supplier.setRegion2First(firstRegion2Id); |
|
|
|
|
|
supplier.setRegion2Last(bizRegion.getId()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return supplier; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
bmsSupplierService.saveBatch(saveBmsSuppliers); |
|
|
|
|
|
} |
|
|
|
|
|
/** ----------------------------------------------------------------------------------- */ |
|
|
|
|
|
/** ------------------------------- 保存更新 ------------------------------------------------ */ |
|
|
|
|
|
if(updateList.size()>0) { |
|
|
|
|
|
LambdaQueryWrapper<BmsSupplier> oriBmsLqw = new LambdaQueryWrapper<>(); |
|
|
|
|
|
oriBmsLqw.in(BmsSupplier::getCode,updateList.stream().map(b->b.getCustomerCode()).collect(Collectors.toList())); |
|
|
|
|
|
List<BmsSupplier> oriBmsSuppliers = bmsSupplierService.list(oriBmsLqw); |
|
|
|
|
|
Map<String, String> codeToSupplierId = oriBmsSuppliers.stream().collect(Collectors.toMap(BmsSupplier::getCode, BmsSupplier::getId)); |
|
|
|
|
|
|
|
|
|
|
|
List<BmsSupplier> updateBmsSuppliers = updateList.stream().map(a->{ |
|
|
|
|
|
BmsSupplier supplier = new BmsSupplier(); |
|
|
|
|
|
|
|
|
|
|
|
supplier.setId(codeToSupplierId.get(a.getCustomerCode())); |
|
|
|
|
|
supplier.setName(a.getCustomerName()); |
|
|
|
|
|
supplier.setCode(a.getCustomerCode()); |
|
|
|
|
|
supplier.setStopFlag(a.getCloseAccountStatus()); |
|
|
|
|
|
supplier.setStopFlagDate(a.getCloseAccountDate()); |
|
|
|
|
|
supplier.setCooperatePauseFlag(a.getSuspendCooperationStatus()); |
|
|
|
|
|
supplier.setCooperatePauseFlagDate(a.getSuspendCooperationDate()); |
|
|
|
|
|
if(StringUtils.hasText(a.getMainHeadCode())){ |
|
|
|
|
|
SysUser sysUser = sysUserMap.get(a.getMainHeadCode()); |
|
|
|
|
|
supplier.setUserId(sysUser.getId()); |
|
|
|
|
|
supplier.setUserCode(sysUser.getCode()); |
|
|
|
|
|
supplier.setUserName(sysUser.getName()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.hasText(a.getMinorHeadCodes())){ |
|
|
|
|
|
List<String> otherUserCodes = Arrays.asList(a.getMinorHeadCodes().split(",")); |
|
|
|
|
|
List<String> otherUserNames = new ArrayList<>(); |
|
|
|
|
|
List<String> otherUserIds = new ArrayList<>(); |
|
|
|
|
|
otherUserCodes.forEach(b->{ |
|
|
|
|
|
SysUser sysUser = sysUserMap.get(b); |
|
|
|
|
|
otherUserNames.add(sysUser.getName()); |
|
|
|
|
|
otherUserIds.add(sysUser.getId()); |
|
|
|
|
|
}); |
|
|
|
|
|
supplier.setOtherUserCodes(otherUserCodes.stream().collect(Collectors.joining(","))); |
|
|
|
|
|
supplier.setOtherUserNames(otherUserNames.stream().collect(Collectors.joining(","))); |
|
|
|
|
|
supplier.setOtherUserIds(otherUserIds.toArray(new String[otherUserIds.size()])); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.hasText(a.getSalesRegionName())){ |
|
|
|
|
|
BmsRegion saleRegion = saleRegionMap.get(a.getSalesRegionName()); |
|
|
|
|
|
supplier.setRegionLast(saleRegion.getId()); |
|
|
|
|
|
supplier.setRegionSecond(saleRegion.getId()); |
|
|
|
|
|
supplier.setRegionFirst(saleRegion.getPid()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.hasText(a.getSecondaryLevelAdministrativeRegionName()) |
|
|
|
|
|
&& StringUtils.hasText(a.getFirstLevelAdministrativeRegionName()) |
|
|
|
|
|
&& StringUtils.hasText(a.getAdministrativeRegionName())){ |
|
|
|
|
|
BmsRegion2 bizRegion = bizRegionMap.get(a.getFirstLevelAdministrativeRegionName()+"_"+a.getSecondaryLevelAdministrativeRegionName()+"_"+a.getAdministrativeRegionName()); |
|
|
|
|
|
supplier.setRegion2Third(bizRegion.getId()); |
|
|
|
|
|
supplier.setRegion2Second(bizRegion.getPid()); |
|
|
|
|
|
String firstRegion2Id = bizRegion.getPathIds().split("_")[0]; |
|
|
|
|
|
supplier.setRegion2First(firstRegion2Id); |
|
|
|
|
|
supplier.setRegion2Last(bizRegion.getId()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return supplier; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
bmsSupplierService.updateBatchById(updateBmsSuppliers); |
|
|
|
|
|
} |
|
|
|
|
|
/** ----------------------------------------------------------------------------------- */ |
|
|
|
|
|
/** ------------------------------- 删除数据 ------------------------------------------------ */ |
|
|
|
|
|
if(deleteList.size()>0) { |
|
|
|
|
|
LambdaQueryWrapper<BmsSupplier> oriBmsLqw = new LambdaQueryWrapper<>(); |
|
|
|
|
|
oriBmsLqw.in(BmsSupplier::getCode,deleteList.stream().map(b->b.getCustomerCode()).collect(Collectors.toList())); |
|
|
|
|
|
List<BmsSupplier> oriBmsSuppliers = bmsSupplierService.list(oriBmsLqw); |
|
|
|
|
|
// Map<String, String> codeToSupplierId = oriBmsSuppliers.stream().collect(Collectors.toMap(BmsSupplier::getCode, BmsSupplier::getId));
|
|
|
|
|
|
List<String> deleteIds = oriBmsSuppliers.stream().map(a->a.getId()).collect(Collectors.toList()); |
|
|
|
|
|
bmsSupplierService.removeBatchByIds(deleteIds); |
|
|
|
|
|
} |
|
|
|
|
|
/** ----------------------------------------------------------------------------------- */ |
|
|
|
|
|
|
|
|
return R.ok(); |
|
|
return R.ok(); |
|
|
} |
|
|
} |
|
|