|
|
@ -73,27 +73,108 @@ public class BmsSupplierController { |
|
|
|
* @param param |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@GetMapping("/list") |
|
|
|
@PostMapping("/list") |
|
|
|
@PreAuthorize("hasRole('bms:supplier:query')") |
|
|
|
public R<List<BmsSupplier>> getList(BmsSupplier param){ |
|
|
|
String userId = param.getUserId(); |
|
|
|
if(param.getLoadByCurrent()!=null&¶m.getLoadByCurrent().equals(1)){ |
|
|
|
List<String> userIds = sysPostUserService.listByChildIds(userId); |
|
|
|
userIds.add(userId); |
|
|
|
param.setSelectUserIds(userIds); |
|
|
|
}else { |
|
|
|
param.setCurrUserId(userId); |
|
|
|
public R<List<BmsSupplier>> getList(@RequestBody BmsSupplier param){ |
|
|
|
|
|
|
|
if(param.getSupplierName()!=null){ |
|
|
|
param.setName(param.getSupplierName()); |
|
|
|
} |
|
|
|
if(param.getSupplierCode()!=null){ |
|
|
|
param.setCode(param.getSupplierCode()); |
|
|
|
} |
|
|
|
|
|
|
|
// String userId = param.getUserId();
|
|
|
|
// if(param.getLoadByCurrent()!=null&¶m.getLoadByCurrent().equals(1)){
|
|
|
|
// List<String> userIds = sysPostUserService.listByChildIds(userId);
|
|
|
|
// userIds.add(userId);
|
|
|
|
// param.setSelectUserIds(userIds);
|
|
|
|
// }else {
|
|
|
|
// param.setCurrUserId(userId);
|
|
|
|
// }
|
|
|
|
|
|
|
|
if(StringUtils.hasText(param.getRegion2Label())){ |
|
|
|
LambdaQueryWrapper<BmsRegion2> region2LambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
region2LambdaQueryWrapper.like(BmsRegion2::getPathNames,param.getRegion2Label()); |
|
|
|
List<BmsRegion2> region2List = bmsRegion2Service.list(region2LambdaQueryWrapper); |
|
|
|
if(region2List.size()>0) { |
|
|
|
param.setRegion2Ids(region2List.stream().map(a -> a.getId()).collect(Collectors.toList())); |
|
|
|
}else{ |
|
|
|
param.setRegion2Ids(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.hasText(param.getSearchRegion2FirstName())){ |
|
|
|
LambdaQueryWrapper<BmsRegion2> region2LambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
region2LambdaQueryWrapper.like(BmsRegion2::getName,param.getSearchRegion2FirstName()); |
|
|
|
List<BmsRegion2> region2List = bmsRegion2Service.list(region2LambdaQueryWrapper); |
|
|
|
if(region2List.size()>0) { |
|
|
|
param.setSearchRegion2First(region2List.stream().map(a -> a.getId()).collect(Collectors.toList())); |
|
|
|
}else{ |
|
|
|
param.setSearchRegion2First(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.hasText(param.getSearchRegion2SecondName())){ |
|
|
|
LambdaQueryWrapper<BmsRegion2> region2LambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
region2LambdaQueryWrapper.like(BmsRegion2::getName,param.getSearchRegion2SecondName()); |
|
|
|
List<BmsRegion2> region2List = bmsRegion2Service.list(region2LambdaQueryWrapper); |
|
|
|
if(region2List.size()>0) { |
|
|
|
param.setSearchRegion2Second(region2List.stream().map(a -> a.getId()).collect(Collectors.toList())); |
|
|
|
}else{ |
|
|
|
param.setSearchRegion2Second(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.hasText(param.getSearchRegion2ThirdName())){ |
|
|
|
LambdaQueryWrapper<BmsRegion2> region2LambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
region2LambdaQueryWrapper.like(BmsRegion2::getName,param.getSearchRegion2ThirdName()); |
|
|
|
List<BmsRegion2> region2List = bmsRegion2Service.list(region2LambdaQueryWrapper); |
|
|
|
if(region2List.size()>0) { |
|
|
|
param.setSearchRegion2Third(region2List.stream().map(a -> a.getId()).collect(Collectors.toList())); |
|
|
|
}else{ |
|
|
|
param.setSearchRegion2Third(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(StringUtils.hasText(param.getRegionLabel())){ |
|
|
|
LambdaQueryWrapper<BmsRegion> regionLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
regionLambdaQueryWrapper.like(BmsRegion::getPathNames,param.getRegionLabel()); |
|
|
|
List<BmsRegion> regionList = bmsRegionService.list(regionLambdaQueryWrapper); |
|
|
|
if(regionList.size()>0) { |
|
|
|
param.setRegionIds(regionList.stream().map(a -> a.getId()).collect(Collectors.toList())); |
|
|
|
}else{ |
|
|
|
param.setRegion2Ids(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.hasText(param.getSearchRegionFirstName())){ |
|
|
|
LambdaQueryWrapper<BmsRegion> regionLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
regionLambdaQueryWrapper.like(BmsRegion::getName,param.getSearchRegionFirstName()); |
|
|
|
List<BmsRegion> regionList = bmsRegionService.list(regionLambdaQueryWrapper); |
|
|
|
if(regionList.size()>0) { |
|
|
|
param.setSearchRegionFirst(regionList.stream().map(a -> a.getId()).collect(Collectors.toList())); |
|
|
|
}else{ |
|
|
|
param.setSearchRegionFirst(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.hasText(param.getSearchRegionSecondName())){ |
|
|
|
LambdaQueryWrapper<BmsRegion> regionLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
regionLambdaQueryWrapper.like(BmsRegion::getName,param.getSearchRegionSecondName()); |
|
|
|
List<BmsRegion> regionList = bmsRegionService.list(regionLambdaQueryWrapper); |
|
|
|
if(regionList.size()>0) { |
|
|
|
param.setSearchRegionSecond(regionList.stream().map(a -> a.getId()).collect(Collectors.toList())); |
|
|
|
}else{ |
|
|
|
param.setSearchRegionSecond(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<BmsSupplier> list = bmsSupplierService.selectSupplierList(param); |
|
|
|
initSupplierList(list); |
|
|
|
initParentList(list); |
|
|
|
for (BmsSupplier supplier : list) { |
|
|
|
supplier.setMasterFlag(0); |
|
|
|
if(supplier.getUserId()!=null&&supplier.getUserId().equals(userId)){ |
|
|
|
supplier.setMasterFlag(1); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
// for (BmsSupplier supplier : list) {
|
|
|
|
// supplier.setMasterFlag(0);
|
|
|
|
// if(supplier.getUserId()!=null&&supplier.getUserId().equals(userId)){
|
|
|
|
// supplier.setMasterFlag(1);
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
return R.ok(list); |
|
|
|
} |
|
|
|
|
|
|
@ -114,11 +195,7 @@ public class BmsSupplierController { |
|
|
|
param.setCode(param.getSupplierCode()); |
|
|
|
} |
|
|
|
|
|
|
|
if(param.getLoadByCurrent()!=null&¶m.getLoadByCurrent().equals(1)){ |
|
|
|
PageUtil.setPageSize(param.getPageSize()+""); |
|
|
|
PageUtil.setPageNum(param.getPageNum()+""); |
|
|
|
return supplierMyController.getUnderlingAndMinePage(param); |
|
|
|
} |
|
|
|
|
|
|
|
if(StringUtils.hasText(param.getRegion2Label())){ |
|
|
|
LambdaQueryWrapper<BmsRegion2> region2LambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
region2LambdaQueryWrapper.like(BmsRegion2::getPathNames,param.getRegion2Label()); |
|
|
@ -129,6 +206,36 @@ public class BmsSupplierController { |
|
|
|
param.setRegion2Ids(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.hasText(param.getSearchRegion2FirstName())){ |
|
|
|
LambdaQueryWrapper<BmsRegion2> region2LambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
region2LambdaQueryWrapper.like(BmsRegion2::getName,param.getSearchRegion2FirstName()); |
|
|
|
List<BmsRegion2> region2List = bmsRegion2Service.list(region2LambdaQueryWrapper); |
|
|
|
if(region2List.size()>0) { |
|
|
|
param.setSearchRegion2First(region2List.stream().map(a -> a.getId()).collect(Collectors.toList())); |
|
|
|
}else{ |
|
|
|
param.setSearchRegion2First(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.hasText(param.getSearchRegion2SecondName())){ |
|
|
|
LambdaQueryWrapper<BmsRegion2> region2LambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
region2LambdaQueryWrapper.like(BmsRegion2::getName,param.getSearchRegion2SecondName()); |
|
|
|
List<BmsRegion2> region2List = bmsRegion2Service.list(region2LambdaQueryWrapper); |
|
|
|
if(region2List.size()>0) { |
|
|
|
param.setSearchRegion2Second(region2List.stream().map(a -> a.getId()).collect(Collectors.toList())); |
|
|
|
}else{ |
|
|
|
param.setSearchRegion2Second(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.hasText(param.getSearchRegion2ThirdName())){ |
|
|
|
LambdaQueryWrapper<BmsRegion2> region2LambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
region2LambdaQueryWrapper.like(BmsRegion2::getName,param.getSearchRegion2ThirdName()); |
|
|
|
List<BmsRegion2> region2List = bmsRegion2Service.list(region2LambdaQueryWrapper); |
|
|
|
if(region2List.size()>0) { |
|
|
|
param.setSearchRegion2Third(region2List.stream().map(a -> a.getId()).collect(Collectors.toList())); |
|
|
|
}else{ |
|
|
|
param.setSearchRegion2Third(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(StringUtils.hasText(param.getRegionLabel())){ |
|
|
|
LambdaQueryWrapper<BmsRegion> regionLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
@ -140,7 +247,34 @@ public class BmsSupplierController { |
|
|
|
param.setRegion2Ids(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.hasText(param.getSearchRegionFirstName())){ |
|
|
|
LambdaQueryWrapper<BmsRegion> regionLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
regionLambdaQueryWrapper.like(BmsRegion::getName,param.getSearchRegionFirstName()); |
|
|
|
List<BmsRegion> regionList = bmsRegionService.list(regionLambdaQueryWrapper); |
|
|
|
if(regionList.size()>0) { |
|
|
|
param.setSearchRegionFirst(regionList.stream().map(a -> a.getId()).collect(Collectors.toList())); |
|
|
|
}else{ |
|
|
|
param.setSearchRegionFirst(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.hasText(param.getSearchRegionSecondName())){ |
|
|
|
LambdaQueryWrapper<BmsRegion> regionLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
regionLambdaQueryWrapper.like(BmsRegion::getName,param.getSearchRegionSecondName()); |
|
|
|
List<BmsRegion> regionList = bmsRegionService.list(regionLambdaQueryWrapper); |
|
|
|
if(regionList.size()>0) { |
|
|
|
param.setSearchRegionSecond(regionList.stream().map(a -> a.getId()).collect(Collectors.toList())); |
|
|
|
}else{ |
|
|
|
param.setSearchRegionSecond(Arrays.asList("#")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(param.getLoadByCurrent()!=null&¶m.getLoadByCurrent().equals(1)){ |
|
|
|
List<BmsSupplier> list = bmsSupplierService.selectSupplierList(param); |
|
|
|
param.setSearchInIds(list.stream().map(a->a.getId()).collect(Collectors.toList())); |
|
|
|
PageUtil.setPageSize(param.getPageSize()+""); |
|
|
|
PageUtil.setPageNum(param.getPageNum()+""); |
|
|
|
return supplierMyController.getUnderlingAndMinePage(param); |
|
|
|
} |
|
|
|
|
|
|
|
PageHelper.startPage(param.getPageNum(),param.getPageSize()); |
|
|
|
List<BmsSupplier> list = bmsSupplierService.selectSupplierList(param); |
|
|
@ -615,22 +749,51 @@ public class BmsSupplierController { |
|
|
|
* 显示关联 |
|
|
|
* @param list |
|
|
|
*/ |
|
|
|
private void initSupplierList(List<BmsSupplier> list){ |
|
|
|
private void initSupplierList(List<BmsSupplier> list) { |
|
|
|
//设置销售区域
|
|
|
|
List<String> regionIds = list.stream() |
|
|
|
.filter(sup->sup.getRegionLast()!=null&&!sup.getRegionLast().equals("0")) |
|
|
|
.filter(sup -> sup.getRegionLast() != null && !sup.getRegionLast().equals("0")) |
|
|
|
.map(BmsSupplier::getRegionLast).collect(Collectors.toList()); |
|
|
|
regionIds.addAll(list.stream() |
|
|
|
.filter(sup -> sup.getRegionFirst() != null && !sup.getRegionFirst().equals("0")) |
|
|
|
.map(BmsSupplier::getRegionFirst).collect(Collectors.toList())); |
|
|
|
regionIds.addAll(list.stream() |
|
|
|
.filter(sup -> sup.getRegionSecond() != null && !sup.getRegionSecond().equals("0")) |
|
|
|
.map(BmsSupplier::getRegionSecond).collect(Collectors.toList())); |
|
|
|
regionIds.addAll(list.stream() |
|
|
|
.filter(sup -> sup.getRegionThird() != null && !sup.getRegionThird().equals("0")) |
|
|
|
.map(BmsSupplier::getRegionThird).collect(Collectors.toList())); |
|
|
|
regionIds.addAll(list.stream() |
|
|
|
.filter(sup -> sup.getRegionFourthly() != null && !sup.getRegionFourthly().equals("0")) |
|
|
|
.map(BmsSupplier::getRegionFourthly).collect(Collectors.toList())); |
|
|
|
|
|
|
|
List<BmsRegion> regionList = null; |
|
|
|
if(CollectionUtil.isNotEmpty(regionIds)){ |
|
|
|
if (CollectionUtil.isNotEmpty(regionIds)) { |
|
|
|
regionList = bmsRegionService.listByIds(regionIds); |
|
|
|
} |
|
|
|
for (BmsSupplier supplier : list) { |
|
|
|
String regionId = supplier.getRegionLast(); |
|
|
|
if(regionId!=null&&CollectionUtil.isNotEmpty(regionList)){ |
|
|
|
if (CollectionUtil.isNotEmpty(regionList)){ |
|
|
|
for (BmsSupplier supplier : list) { |
|
|
|
String regionId = supplier.getRegionLast(); |
|
|
|
String regionFirst = supplier.getRegionFirst(); |
|
|
|
String regionSecond = supplier.getRegionSecond(); |
|
|
|
String regionThird = supplier.getRegionThird(); |
|
|
|
String regionFourthly = supplier.getRegionFourthly(); |
|
|
|
|
|
|
|
for (BmsRegion region : regionList) { |
|
|
|
if(region.getId().equals(regionId)){ |
|
|
|
if (region.getId().equals(regionId)) { |
|
|
|
supplier.setRegionLabel(region.getName()); |
|
|
|
break; |
|
|
|
} |
|
|
|
if (region.getId().equals(regionFirst)) { |
|
|
|
supplier.setRegionFirstInfo(region); |
|
|
|
} |
|
|
|
if (region.getId().equals(regionSecond)) { |
|
|
|
supplier.setRegionSecondInfo(region); |
|
|
|
} |
|
|
|
if (region.getId().equals(regionThird)) { |
|
|
|
supplier.setRegionThirdInfo(region); |
|
|
|
} |
|
|
|
if (region.getId().equals(regionFourthly)) { |
|
|
|
supplier.setRegionFourthlyInfo(region); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -639,18 +802,48 @@ public class BmsSupplierController { |
|
|
|
List<String> region2Ids = list.stream() |
|
|
|
.filter(sup->sup.getRegion2Last()!=null&&!sup.getRegion2Last().equals("0")) |
|
|
|
.map(BmsSupplier::getRegion2Last).collect(Collectors.toList()); |
|
|
|
region2Ids.addAll(list.stream() |
|
|
|
.filter(sup -> sup.getRegion2First() != null && !sup.getRegion2First().equals("0")) |
|
|
|
.map(BmsSupplier::getRegion2First).collect(Collectors.toList())); |
|
|
|
region2Ids.addAll(list.stream() |
|
|
|
.filter(sup -> sup.getRegion2Second() != null && !sup.getRegion2Second().equals("0")) |
|
|
|
.map(BmsSupplier::getRegion2Second).collect(Collectors.toList())); |
|
|
|
region2Ids.addAll(list.stream() |
|
|
|
.filter(sup -> sup.getRegion2Third() != null && !sup.getRegion2Third().equals("0")) |
|
|
|
.map(BmsSupplier::getRegion2Third).collect(Collectors.toList())); |
|
|
|
region2Ids.addAll(list.stream() |
|
|
|
.filter(sup -> sup.getRegion2Fourthly() != null && !sup.getRegion2Fourthly().equals("0")) |
|
|
|
.map(BmsSupplier::getRegion2Fourthly).collect(Collectors.toList())); |
|
|
|
|
|
|
|
List<BmsRegion2> region2List = null; |
|
|
|
if(CollectionUtil.isNotEmpty(region2Ids)){ |
|
|
|
region2List = bmsRegion2Service.listByIds(region2Ids); |
|
|
|
} |
|
|
|
for (BmsSupplier supplier : list) { |
|
|
|
String region2Id = supplier.getRegion2Last(); |
|
|
|
if(region2Id!=null&&CollectionUtil.isNotEmpty(region2List)){ |
|
|
|
if(CollectionUtil.isNotEmpty(region2List)){ |
|
|
|
for (BmsSupplier supplier : list) { |
|
|
|
String region2Id = supplier.getRegion2Last(); |
|
|
|
String regionFirst = supplier.getRegion2First(); |
|
|
|
String regionSecond = supplier.getRegion2Second(); |
|
|
|
String regionThird = supplier.getRegion2Third(); |
|
|
|
String regionFourthly = supplier.getRegion2Fourthly(); |
|
|
|
|
|
|
|
for (BmsRegion2 region : region2List) { |
|
|
|
String regionId = region.getId(); |
|
|
|
if(regionId.equals(region2Id)){ |
|
|
|
|
|
|
|
if (regionId.equals(region2Id)) { |
|
|
|
supplier.setRegion2Label(region.getName()); |
|
|
|
break; |
|
|
|
} |
|
|
|
if (region.getId().equals(regionFirst)) { |
|
|
|
supplier.setRegion2FirstInfo(region); |
|
|
|
} |
|
|
|
if (region.getId().equals(regionSecond)) { |
|
|
|
supplier.setRegion2SecondInfo(region); |
|
|
|
} |
|
|
|
if (region.getId().equals(regionThird)) { |
|
|
|
supplier.setRegion2ThirdInfo(region); |
|
|
|
} |
|
|
|
if (region.getId().equals(regionFourthly)) { |
|
|
|
supplier.setRegion2FourthlyInfo(region); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|