|
@ -18,11 +18,13 @@ import com.qs.serve.modules.bms.entity.vo.BmsRegionTreeVo; |
|
|
import com.qs.serve.modules.bms.service.*; |
|
|
import com.qs.serve.modules.bms.service.*; |
|
|
import com.qs.serve.modules.his.entity.HisUserSupplier; |
|
|
import com.qs.serve.modules.his.entity.HisUserSupplier; |
|
|
import com.qs.serve.modules.his.service.HisUserSupplierService; |
|
|
import com.qs.serve.modules.his.service.HisUserSupplierService; |
|
|
|
|
|
import com.qs.serve.modules.sys.service.SysPostUserService; |
|
|
import com.qs.serve.modules.tbs.common.TbsCenterType; |
|
|
import com.qs.serve.modules.tbs.common.TbsCenterType; |
|
|
import com.qs.serve.modules.tbs.entity.TbsBudget; |
|
|
import com.qs.serve.modules.tbs.entity.TbsBudget; |
|
|
import com.qs.serve.modules.tbs.service.TbsBudgetService; |
|
|
import com.qs.serve.modules.tbs.service.TbsBudgetService; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.jetbrains.annotations.Nullable; |
|
|
import org.springframework.cache.annotation.Cacheable; |
|
|
import org.springframework.cache.annotation.Cacheable; |
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
@ -55,6 +57,7 @@ public class BmsRegionController { |
|
|
private TbsBudgetService tbsBudgetService; |
|
|
private TbsBudgetService tbsBudgetService; |
|
|
private BmsCostCenterService bmsCostCenterService; |
|
|
private BmsCostCenterService bmsCostCenterService; |
|
|
private BirBudgetTargetService birBudgetTargetService; |
|
|
private BirBudgetTargetService birBudgetTargetService; |
|
|
|
|
|
private SysPostUserService postUserService; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 列表 |
|
|
* 列表 |
|
@ -115,13 +118,24 @@ public class BmsRegionController { |
|
|
if(so.getStopFlag()==null){ |
|
|
if(so.getStopFlag()==null){ |
|
|
so.setStopFlag(0); |
|
|
so.setStopFlag(0); |
|
|
} |
|
|
} |
|
|
|
|
|
// 当前负责人
|
|
|
if(so.getLoadByCurrent()!=null&&so.getLoadByCurrent().equals(1)){ |
|
|
if(so.getLoadByCurrent()!=null&&so.getLoadByCurrent().equals(1)){ |
|
|
return R.ok(treeByCurrentUser(so.getSupplierId(),so.getStopFlag())); |
|
|
return R.ok(treeByCurrentUser(so.getSupplierId(),so.getStopFlag())); |
|
|
} |
|
|
} |
|
|
|
|
|
// 当前负责人及下属负责人
|
|
|
|
|
|
if(so.getLoadByCurrent()!=null&&so.getLoadByCurrent().equals(3)){ |
|
|
|
|
|
return R.ok(treeByCurrentUserAndChildUser(so.getSupplierId(),so.getStopFlag())); |
|
|
|
|
|
} |
|
|
return R.ok(bmsRegionService.getTree(so.getListUserFlag()!=null&&so.getListUserFlag().equals(1), so.getStopFlag())); |
|
|
return R.ok(bmsRegionService.getTree(so.getListUserFlag()!=null&&so.getListUserFlag().equals(1), so.getStopFlag())); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 加载当前负责人的 |
|
|
|
|
|
* @param supplierId |
|
|
|
|
|
* @param stopFlag |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
public List<BmsRegionTreeVo> treeByCurrentUser(String supplierId,Integer stopFlag){ |
|
|
public List<BmsRegionTreeVo> treeByCurrentUser(String supplierId,Integer stopFlag){ |
|
|
String userId = AuthContextUtils.getSysUserId(); |
|
|
String userId = AuthContextUtils.getSysUserId(); |
|
|
LambdaQueryWrapper<BmsRegionUser> lqw = new LambdaQueryWrapper<>(); |
|
|
LambdaQueryWrapper<BmsRegionUser> lqw = new LambdaQueryWrapper<>(); |
|
@ -133,8 +147,33 @@ public class BmsRegionController { |
|
|
BmsSupplier supplier = bmsSupplierService.getById(supplierId); |
|
|
BmsSupplier supplier = bmsSupplierService.getById(supplierId); |
|
|
regionIds.addAll(supplier.listSaleRegionIds()); |
|
|
regionIds.addAll(supplier.listSaleRegionIds()); |
|
|
} |
|
|
} |
|
|
//List<HisUserSupplier> hisUserSuppliers = hisUserSupplierService.selectHisSupplier(null,false);
|
|
|
return buildRegionTreeByRegionIds(stopFlag, regionIds); |
|
|
//List<Long> supplierIds = hisUserSuppliers.stream().map(HisUserSupplier::getSupplierId).collect(Collectors.toList());
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 加载当前负责人和下属的 |
|
|
|
|
|
* @param supplierId |
|
|
|
|
|
* @param stopFlag |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public List<BmsRegionTreeVo> treeByCurrentUserAndChildUser(String supplierId,Integer stopFlag){ |
|
|
|
|
|
String userId = AuthContextUtils.getSysUserId(); |
|
|
|
|
|
List<String> userIds = postUserService.listByChildIds(userId); |
|
|
|
|
|
userIds.add(userId); |
|
|
|
|
|
LambdaQueryWrapper<BmsRegionUser> lqw = new LambdaQueryWrapper<>(); |
|
|
|
|
|
lqw.eq(BmsRegionUser::getType,0); |
|
|
|
|
|
lqw.in(BmsRegionUser::getUserId,userIds); |
|
|
|
|
|
List<BmsRegionUser> regionUsers = bmsRegionUserService.list(lqw); |
|
|
|
|
|
List<String> regionIds = regionUsers.stream().map(BmsRegionUser::getRegionId).collect(Collectors.toList()); |
|
|
|
|
|
if(StringUtils.hasText(supplierId)){ |
|
|
|
|
|
BmsSupplier supplier = bmsSupplierService.getById(supplierId); |
|
|
|
|
|
regionIds.addAll(supplier.listSaleRegionIds()); |
|
|
|
|
|
} |
|
|
|
|
|
return buildRegionTreeByRegionIds(stopFlag, regionIds); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
|
private List<BmsRegionTreeVo> buildRegionTreeByRegionIds(Integer stopFlag, List<String> regionIds) { |
|
|
List<Long> supplierIds = hisUserSupplierService.selectHisSupplier(null,false); |
|
|
List<Long> supplierIds = hisUserSupplierService.selectHisSupplier(null,false); |
|
|
supplierIds.add(0L); |
|
|
supplierIds.add(0L); |
|
|
List<BmsSupplier> supplierList = bmsSupplierService.listByIds(supplierIds); |
|
|
List<BmsSupplier> supplierList = bmsSupplierService.listByIds(supplierIds); |
|
@ -153,7 +192,7 @@ public class BmsRegionController { |
|
|
|
|
|
|
|
|
List<BmsRegion> regionList = bmsRegionService.listByIds(regionIds); |
|
|
List<BmsRegion> regionList = bmsRegionService.listByIds(regionIds); |
|
|
if(regionList.size()==0){ |
|
|
if(regionList.size()==0){ |
|
|
return toTreeNodeList2(allSelectList,stopFlag); |
|
|
return toTreeNodeList2(allSelectList, stopFlag); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
List<String> pathIds = regionList.stream().filter(b->b.getPathIds()!=null) |
|
|
List<String> pathIds = regionList.stream().filter(b->b.getPathIds()!=null) |
|
@ -162,7 +201,7 @@ public class BmsRegionController { |
|
|
.flatMap(pathId -> Arrays.stream(pathId.split("_"))) |
|
|
.flatMap(pathId -> Arrays.stream(pathId.split("_"))) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
regionList = bmsRegionService.listByIds(idList); |
|
|
regionList = bmsRegionService.listByIds(idList); |
|
|
return toTreeNodeList2(regionList,stopFlag); |
|
|
return toTreeNodeList2(regionList, stopFlag); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return null; |
|
|
return null; |
|
|