Browse Source

首页领导驾驶舱所领导查看指定部门数据

lw 1 year ago
parent
commit
a7dd9a3897

+ 28 - 28
module_kzks/src/main/java/org/jeecg/modules/Index/controller/IndexController.java

@@ -49,8 +49,8 @@ public class IndexController {
     private CommonMethod commonMethod;
 
     @ApiOperation(value = "首页一层汇总", notes = "首页一层汇总")
-    @GetMapping("getCollect")
-    public Result<Map<String, Object>> getCollect(HttpServletRequest request) {
+    @PostMapping("getCollect")
+    public Result<Map<String, Object>> getCollect(@RequestBody(required = false) List<String> departNameList,HttpServletRequest request) {
         String userNameByToken = JwtUtil.getUserNameByToken(request);
         LoginUser sysUser = sysBaseApi.getUserByName(userNameByToken);
 
@@ -61,19 +61,19 @@ public class IndexController {
         if (role != null && (!role.isEmpty() && !role.equals(AuthMark.STAFF))) {
             CompletableFuture<IndexTotalVo> hteFuture = CompletableFuture.supplyAsync(() -> {
                 // 合同额
-                return indexService.getTotalIncome(request);
+                return indexService.getTotalIncome(request,departNameList);
             });
             CompletableFuture<IndexTotalVo> skeFuture = CompletableFuture.supplyAsync(() -> {
                 // 收款额
-                return indexService.getTotalReceived(request);
+                return indexService.getTotalReceived(request,departNameList);
             });
             CompletableFuture<IndexTotalVo> lreFuture = CompletableFuture.supplyAsync(() -> {
                 // 利润额
-                return indexService.getLreByRole(request);
+                return indexService.getLreByRole(request,departNameList);
             });
             CompletableFuture<IndexTotalVo> zceFuture = CompletableFuture.supplyAsync(() -> {
                 // 支出额
-                return indexZcbService.getZhiChuTotalList(request).get(0);
+                return indexZcbService.getZhiChuTotalList(request,departNameList).get(0);
             });
             CompletableFuture<Void> allFutures = CompletableFuture.allOf(hteFuture, skeFuture, lreFuture, zceFuture);
             allFutures.join();
@@ -106,29 +106,29 @@ public class IndexController {
 
     @ApiOperation(value = "计算已收款", notes = "计算已收款")
     @GetMapping("getTotalReceived")
-    public Result<IndexTotalVo> getTotalReceived(HttpServletRequest request) {
-        IndexTotalVo reslut = indexService.getTotalReceived(request);
+    public Result<IndexTotalVo> getTotalReceived(HttpServletRequest request,List<String> departNameList) {
+        IndexTotalVo reslut = indexService.getTotalReceived(request,departNameList);
         return Result.ok(reslut);
     }
 
     @ApiOperation(value = "首页二层合同额显示", notes = "首页二层合同额显示")
     @PostMapping("getContractAmountInfo")
-    public Result<ContractChartInfoVo> getContractAmountInfo(HttpServletRequest request, @RequestBody IndexInfoParamDto indexInfoParamDto) {
-        return Result.ok(indexService.getContractAmountInfo(request, indexInfoParamDto));
+    public Result<ContractChartInfoVo> getContractAmountInfo(HttpServletRequest request, @RequestBody() IndexInfoParamDto indexInfoParamDto) {
+            return Result.ok(indexService.getContractAmountInfo(request, indexInfoParamDto,indexInfoParamDto.getDepartNameList()));
     }
 
 
     @ApiOperation("领导驾驶舱---支出模块")
-    @GetMapping("/getZcb")
-    public List<IndexTotalVo> getZhiChuTotalList(HttpServletRequest request) {
-        List<IndexTotalVo> zhiChuTotalList = indexZcbService.getZhiChuTotalList(request);
+    @PostMapping("/getZcb")
+    public List<IndexTotalVo> getZhiChuTotalList(HttpServletRequest request,@RequestBody(required = false) List<String> departNameList) {
+        List<IndexTotalVo> zhiChuTotalList = indexZcbService.getZhiChuTotalList(request,departNameList);
         return zhiChuTotalList;
     }
 
     @ApiOperation("领导驾驶舱---支出模块下的统计")
-    @GetMapping("/getEightCost")
-    public List<EightCostChartInfoVo> getEightCost(IndexInfoParamDto indexInfoParamDto,HttpServletRequest request) {
-        List<EightCostChartInfoVo> resultList = indexZcbService.getEightCostsList(indexInfoParamDto,request);
+    @PostMapping("/getEightCost")
+    public List<EightCostChartInfoVo> getEightCost(@RequestBody(required = false) IndexInfoParamDto indexInfoParamDto,HttpServletRequest request) {
+        List<EightCostChartInfoVo> resultList = indexZcbService.getEightCostsList(indexInfoParamDto,request,indexInfoParamDto.getDepartNameList());
         return resultList;
     }
 
@@ -152,9 +152,9 @@ public class IndexController {
      * @return IndexChartInfoVo<BigDecimal>
      */
     @ApiOperation(value = "首页二层已收款显示", notes = "首页二层已收款显示")
-    @GetMapping("countTotalReceivedByDate")
-    public Result<IndexChartInfoVo<BigDecimal>> countTotalReceivedByDate(IndexInfoParamDto indexInfoParamDto) {
-        return Result.OK(indexService.getReceivedDetailByRoleDate(indexInfoParamDto));//加入角色,判断查看权限
+    @PostMapping ("/countTotalReceivedByDate")
+    public Result<IndexChartInfoVo<BigDecimal>> countTotalReceivedByDate(@RequestBody IndexInfoParamDto indexInfoParamDto) {
+        return Result.OK(indexService.getReceivedDetailByRoleDate(indexInfoParamDto,indexInfoParamDto.getDepartNameList()));//加入角色,判断查看权限
 //        return Result.OK(indexService.countTotalReceivedByDate(indexInfoParamDto));
     }
 
@@ -167,23 +167,23 @@ public class IndexController {
      * @return IndexChartInfoVo<BigDecimal>
      */
     @ApiOperation(value = "首页二层利润额显示", notes = "首页二层利润额显示")
-    @GetMapping(value = "/countLreByDate")
-    public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
-        return Result.OK(indexService.getLreDetailByRole(request, indexInfoParamDto));//加入角色,判断查看权限
+    @PostMapping (value = "/countLreByDate")
+    public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(HttpServletRequest request, @RequestBody IndexInfoParamDto indexInfoParamDto) {
+        return Result.OK(indexService.getLreDetailByRole(request, indexInfoParamDto,indexInfoParamDto.getDepartNameList()));//加入角色,判断查看权限
 //        return Result.OK(indexService.countLreByDate(indexInfoParamDto));
     }
 
     @ApiOperation("领导驾驶舱---支出模块下的八项成本排行统计")
-    @GetMapping("/getSumEightCosts")
-    public List<ResultEightCost> getSumEightCosts(IndexInfoParamDto indexInfoParamDto,HttpServletRequest request){
-        List<ResultEightCost> sumEightCostsList = indexZcbService.getSumEightCosts(indexInfoParamDto,request);
+    @PostMapping ("/getSumEightCosts")
+    public List<ResultEightCost> getSumEightCosts(@RequestBody IndexInfoParamDto indexInfoParamDto,HttpServletRequest request){
+        List<ResultEightCost> sumEightCostsList = indexZcbService.getSumEightCosts(indexInfoParamDto,request,indexInfoParamDto.getDepartNameList());
         return sumEightCostsList;
     }
 
     @ApiOperation("领导驾驶舱---支出模块下二级汇总")
-    @GetMapping("/getEightCostsInfo")
-    public Result<List<ZhiChuCost>> getEightCostsInfo(IndexInfoParamDto indexInfoParamDto,HttpServletRequest request){
-        List<ZhiChuCost> list = indexZcbService.getEightCostsInfo(indexInfoParamDto,request);
+    @PostMapping("/getEightCostsInfo")
+    public Result<List<ZhiChuCost>> getEightCostsInfo(@RequestBody IndexInfoParamDto indexInfoParamDto,HttpServletRequest request){
+        List<ZhiChuCost> list = indexZcbService.getEightCostsInfo(indexInfoParamDto,request,indexInfoParamDto.getDepartNameList());
         return Result.ok(list);
     }
 

+ 3 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/entity/dto/IndexInfoParamDto.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.Index.entity.dto;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.List;
 
 @Data
 public class IndexInfoParamDto implements Serializable {
@@ -16,4 +17,6 @@ public class IndexInfoParamDto implements Serializable {
 
     /*截止时间*/
     private String endDate;
+
+    private List<String> departNameList;
 }

+ 7 - 6
module_kzks/src/main/java/org/jeecg/modules/Index/service/IndexService.java

@@ -6,19 +6,20 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.Index.entity.dto.IndexInfoParamDto;
 import org.jeecg.modules.Index.entity.vo.*;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
 import java.util.List;
 
 public interface IndexService {
-    IndexTotalVo getTotalIncome(HttpServletRequest request);
+    IndexTotalVo getTotalIncome(HttpServletRequest request,List<String> departNameList);
 
     IndexTotalVo getTotalContractNum(HttpServletRequest request);
 
-    IndexTotalVo getTotalReceived(HttpServletRequest request);
+    IndexTotalVo getTotalReceived(HttpServletRequest request,List<String> departNameList);
 
-    ContractChartInfoVo getContractAmountInfo(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto);
+    ContractChartInfoVo getContractAmountInfo(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto,List<String> departNameList);
 
     /**
      * 通过登录的用户找到相应的部门,可能一个或两个
@@ -82,14 +83,14 @@ public interface IndexService {
      *
      * @return
      */
-    public IndexTotalVo getLreByRole(HttpServletRequest request);
+    public IndexTotalVo getLreByRole(HttpServletRequest request,List<String> departNameList);
     /**
      * 首页二层 利润额
      * 通过登录的用户找到角色,根据角色来判断部门,根据部门和实际完成时间选择任务列表,根据任务列表计算利润额
      *
      * @return
      */
-    public IndexChartInfoVo<BigDecimal> getLreDetailByRole(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto);
+    public IndexChartInfoVo<BigDecimal> getLreDetailByRole(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto,List<String> departNameList);
 
     /**
      * 首页二层: 已收款
@@ -100,7 +101,7 @@ public interface IndexService {
      * @param indexInfoParamDto
      * @return IndexChartInfoVo<BigDecimal>
      */
-    public IndexChartInfoVo<BigDecimal> getReceivedDetailByRoleDate(IndexInfoParamDto indexInfoParamDto);
+    public IndexChartInfoVo<BigDecimal> getReceivedDetailByRoleDate(IndexInfoParamDto indexInfoParamDto,List<String> departNameList);
 
     /**
      * 测试sl

+ 4 - 4
module_kzks/src/main/java/org/jeecg/modules/Index/service/IndexZcbService.java

@@ -23,7 +23,7 @@ public interface IndexZcbService {
      *   des: 获取 支出相关信息(给前端的数据) 的service方法
      *   date: 2023/9/22
      */
-    public List<IndexTotalVo> getZhiChuTotalList(HttpServletRequest request);
+    public List<IndexTotalVo> getZhiChuTotalList(HttpServletRequest request,List<String> departNameList);
 
 
     /**
@@ -32,7 +32,7 @@ public interface IndexZcbService {
      *   des: 获取 八项成本相关信息 的service方法
      *   date: 2023/9/22
      */
-    public List<EightCostChartInfoVo> getEightCostsList(IndexInfoParamDto indexInfoParamDto,HttpServletRequest request);
+    public List<EightCostChartInfoVo> getEightCostsList(IndexInfoParamDto indexInfoParamDto,HttpServletRequest request,List<String> departNameList);
 
     /**
      *   author: dzc
@@ -40,7 +40,7 @@ public interface IndexZcbService {
      *   des: 指定日期范围内 八项成本各自之和 并排序
      *   date: 2023/9/23
      */
-    public List<ResultEightCost> getSumEightCosts(IndexInfoParamDto indexInfoParamDto,HttpServletRequest request);
+    public List<ResultEightCost> getSumEightCosts(IndexInfoParamDto indexInfoParamDto,HttpServletRequest request,List<String> departNameList);
 
     /**
      *   author: dzc
@@ -104,5 +104,5 @@ public interface IndexZcbService {
      *   des: 支出统计二级汇总
      *   date: 2023/9/24
      */
-    public List<ZhiChuCost> getEightCostsInfo(IndexInfoParamDto indexInfoParamDto, HttpServletRequest request);
+    public List<ZhiChuCost> getEightCostsInfo(IndexInfoParamDto indexInfoParamDto, HttpServletRequest request,List<String> departNameList);
 }

+ 105 - 62
module_kzks/src/main/java/org/jeecg/modules/Index/service/impl/IndexServiceImpl.java

@@ -29,6 +29,7 @@ import org.jeecg.modules.system.service.ISysUserDepartService;
 import org.jeecg.modules.xmcbDetail.mapper.ComContractInfoExchangeMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestBody;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
@@ -111,11 +112,12 @@ public class IndexServiceImpl implements IndexService {
 
     /*合同额一层*/
     @Override
-    public IndexTotalVo getTotalIncome(HttpServletRequest request) {
+    public IndexTotalVo getTotalIncome(HttpServletRequest request, List<String> departNameList) {
         String userNameByToken = JwtUtil.getUserNameByToken(request);
         LoginUser sysUser = sysBaseApi.getUserByName(userNameByToken);
         String role = commonMethod.getRole(userNameByToken);
-
+        if (departNameList != null && !departNameList.isEmpty() && AuthMark.BOSS.equals(role))
+            role = AuthMark.DEPT_LEADER;
         //首页收入渲染对象
         BigDecimal initValue = BigDecimal.valueOf(0);
         IndexTotalVo incomeDataInfoVO = new IndexTotalVo();
@@ -133,7 +135,12 @@ public class IndexServiceImpl implements IndexService {
         String depart = null;
         ArrayList<String> tasknoList = new ArrayList<>();
         if (AuthMark.DEPT_LEADER.equals(role)) {
-            List<String> departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
+            List<String> departNames = null;
+            if (departNameList != null && !departNameList.isEmpty()) {
+                departNames = departNameList;
+            } else {
+                departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
+            }
             if (departNames.isEmpty()) return incomeDataInfoVO;
 
             StringBuilder stringBuilder = new StringBuilder();
@@ -165,19 +172,20 @@ public class IndexServiceImpl implements IndexService {
 
         Calendar instance = Calendar.getInstance();
         setZeroMonth(instance);
-        instance.add(Calendar.MONTH,1);
-        instance.add(Calendar.DAY_OF_MONTH,1);
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DAY_OF_MONTH, 1);
         Date currentYearEndDate = instance.getTime(); //加一天
         setZeroYear(instance);
         Date currentYearBeginDate = instance.getTime();
 
 
+        String finalRole = role;
         CompletableFuture<BigDecimal> currentYearTotalFuture = CompletableFuture.supplyAsync(() -> {
             //根据年份和当前部门对应的任务号查询,部门当前年的年收入
             BigDecimal currentYearTotal = null;
-            if (AuthMark.DEPT_LEADER.equals(role)) {
+            if (AuthMark.DEPT_LEADER.equals(finalRole)) {
                 currentYearTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRange(tasknoList, currentYearBeginDate, currentYearEndDate);
-            } else if (AuthMark.BOSS.equals(role)) {
+            } else if (AuthMark.BOSS.equals(finalRole)) {
                 currentYearTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRangeIfBoss(tasknoList, currentYearBeginDate, currentYearEndDate);
             }
             if (ObjectUtils.isEmpty(currentYearTotal)) currentYearTotal = BigDecimal.valueOf(0);
@@ -188,8 +196,8 @@ public class IndexServiceImpl implements IndexService {
         instance.add(Calendar.YEAR, -1);
         //去年的今日
         setZeroMonth(instance);
-        instance.add(Calendar.MONTH,1);
-        instance.add(Calendar.DAY_OF_MONTH,1);
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DAY_OF_MONTH, 1);
         Date LastTqEndDate = instance.getTime();
 
         setZeroYear(instance);
@@ -198,9 +206,9 @@ public class IndexServiceImpl implements IndexService {
         //根据年份和当前部门对应的任务号查询,部门去年同期年收入
         CompletableFuture<BigDecimal> lastYearTqTotalFuture = CompletableFuture.supplyAsync(() -> {
             BigDecimal lastYearTqTotal = null;
-            if (AuthMark.DEPT_LEADER.equals(role)) {
+            if (AuthMark.DEPT_LEADER.equals(finalRole)) {
                 lastYearTqTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRange(tasknoList, LastYearBeginDate, LastTqEndDate);
-            } else if (AuthMark.BOSS.equals(role)) {
+            } else if (AuthMark.BOSS.equals(finalRole)) {
                 lastYearTqTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRangeIfBoss(tasknoList, LastYearBeginDate, LastTqEndDate);
             }
             if (ObjectUtils.isEmpty(lastYearTqTotal)) lastYearTqTotal = BigDecimal.valueOf(0);
@@ -220,9 +228,9 @@ public class IndexServiceImpl implements IndexService {
 
         CompletableFuture<BigDecimal> currentMonthTotalFuture = CompletableFuture.supplyAsync(() -> {
             BigDecimal currentMonthTotal = null;
-            if (AuthMark.DEPT_LEADER.equals(role)) {
+            if (AuthMark.DEPT_LEADER.equals(finalRole)) {
                 currentMonthTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRange(tasknoList, currentMothBginDate, currentMothEndDate);
-            } else if (AuthMark.BOSS.equals(role)) {
+            } else if (AuthMark.BOSS.equals(finalRole)) {
                 currentMonthTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRangeIfBoss(tasknoList, currentMothBginDate, currentMothEndDate);
             }
             if (ObjectUtils.isEmpty(currentMonthTotal)) currentMonthTotal = BigDecimal.valueOf(0);
@@ -233,8 +241,8 @@ public class IndexServiceImpl implements IndexService {
         instance.setTime(new Date());
         instance.add(Calendar.MONTH, -1);
         setZeroMonth(instance);
-        instance.add(Calendar.MONTH,1);
-        instance.add(Calendar.DAY_OF_MONTH,1);
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DAY_OF_MONTH, 1);
         Date LastMothTqEndDate = instance.getTime();
         setZeroMonth(instance);
         Date LastMothTqBeginDate = instance.getTime();
@@ -242,9 +250,9 @@ public class IndexServiceImpl implements IndexService {
 
         CompletableFuture<BigDecimal> lastMothTqTotalFuture = CompletableFuture.supplyAsync(() -> {
             BigDecimal lastMothTqTotal = null;
-            if (AuthMark.DEPT_LEADER.equals(role)) {
+            if (AuthMark.DEPT_LEADER.equals(finalRole)) {
                 lastMothTqTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRange(tasknoList, LastMothTqBeginDate, LastMothTqEndDate);
-            } else if (AuthMark.BOSS.equals(role)) {
+            } else if (AuthMark.BOSS.equals(finalRole)) {
                 lastMothTqTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRangeIfBoss(tasknoList, LastMothTqBeginDate, LastMothTqEndDate);
             }
             if (ObjectUtils.isEmpty(lastMothTqTotal)) lastMothTqTotal = BigDecimal.valueOf(0);
@@ -255,17 +263,17 @@ public class IndexServiceImpl implements IndexService {
         instance.setTime(new Date());
         instance.add(Calendar.YEAR, -1);
         setZeroMonth(instance);
-        instance.add(Calendar.MONTH,1);
-        instance.add(Calendar.DAY_OF_MONTH,1);
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DAY_OF_MONTH, 1);
         Date lastYearMonthTqEndDate = instance.getTime();
         setZeroMonth(instance);
         Date lastYearMonthTqBeginDate = instance.getTime();
 
         CompletableFuture<BigDecimal> lastYearMonthTqTotalFuture = CompletableFuture.supplyAsync(() -> {
             BigDecimal lastYearMonthTqTotal = null;
-            if (AuthMark.DEPT_LEADER.equals(role)) {
+            if (AuthMark.DEPT_LEADER.equals(finalRole)) {
                 lastYearMonthTqTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRange(tasknoList, lastYearMonthTqBeginDate, lastYearMonthTqEndDate);
-            } else if (AuthMark.BOSS.equals(role)) {
+            } else if (AuthMark.BOSS.equals(finalRole)) {
                 lastYearMonthTqTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRangeIfBoss(tasknoList, lastYearMonthTqBeginDate, lastYearMonthTqEndDate);
             }
             if (ObjectUtils.isEmpty(lastYearMonthTqTotal)) lastYearMonthTqTotal = BigDecimal.valueOf(0);
@@ -380,7 +388,9 @@ public class IndexServiceImpl implements IndexService {
         }
 
         Calendar instance = Calendar.getInstance();
-
+        setZeroMonth(instance);
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DAY_OF_MONTH, 1);
         Date currentYearEndDate = instance.getTime();
         setZeroYear(instance);
         Date currentYearBeginDate = instance.getTime();
@@ -400,6 +410,9 @@ public class IndexServiceImpl implements IndexService {
 
         instance.setTime(new Date());
         instance.add(Calendar.YEAR, -1);
+        setZeroMonth(instance);
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DAY_OF_MONTH, 1);
         //去年的今日
         Date LastTqEndDate = instance.getTime();
         setZeroYear(instance);
@@ -418,9 +431,11 @@ public class IndexServiceImpl implements IndexService {
         });
 
         instance.setTime(new Date());
-        Date currentMothEndDate = instance.getTime();
         setZeroMonth(instance);
         Date currentMothBginDate = instance.getTime();
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DATE, 1);
+        Date currentMothEndDate = instance.getTime();
 
         CompletableFuture<BigDecimal> currentMonthTotalFuture = CompletableFuture.supplyAsync(() -> {
             BigDecimal currentMonthTotal = null;
@@ -436,6 +451,9 @@ public class IndexServiceImpl implements IndexService {
 
         instance.setTime(new Date());
         instance.add(Calendar.MONTH, -1);
+        setZeroMonth(instance);
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DAY_OF_MONTH, 1);
         Date LastMothTqEndDate = instance.getTime();
         setZeroMonth(instance);
         Date LastMothTqBeginDate = instance.getTime();
@@ -455,6 +473,9 @@ public class IndexServiceImpl implements IndexService {
 
         instance.setTime(new Date());
         instance.add(Calendar.YEAR, -1);
+        setZeroMonth(instance);
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DAY_OF_MONTH, 1);
         Date lastYearMonthTqEndDate = instance.getTime();
         setZeroMonth(instance);
         Date lastYearMonthTqBeginDate = instance.getTime();
@@ -525,7 +546,7 @@ public class IndexServiceImpl implements IndexService {
 
     /*已收款一层*/
     @Override
-    public IndexTotalVo getTotalReceived(HttpServletRequest request) {
+    public IndexTotalVo getTotalReceived(HttpServletRequest request, List<String> departNameList) {
         //首页已收款渲染对象
         BigDecimal initValue = BigDecimal.valueOf(0);
         IndexTotalVo indexTotalVo = new IndexTotalVo();
@@ -539,12 +560,18 @@ public class IndexServiceImpl implements IndexService {
         String userNameByToken = JwtUtil.getUserNameByToken(request);
         LoginUser sysUser = sysBaseApi.getUserByName(userNameByToken);
         String role = commonMethod.getRole(userNameByToken);
-
+        if (departNameList != null && !departNameList.isEmpty() && AuthMark.BOSS.equals(role))
+            role = AuthMark.DEPT_LEADER;
         String depart = null;
         ArrayList<String> tasknoList = new ArrayList<>();
 
         if (AuthMark.DEPT_LEADER.equals(role)) {
-            List<String> departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
+            List<String> departNames = null;
+            if (departNameList != null && !departNameList.isEmpty()) {
+                departNames = departNameList;
+            } else {
+                departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
+            }
             if (departNames.isEmpty()) return indexTotalVo;
 
             StringBuilder stringBuilder = new StringBuilder();
@@ -576,19 +603,20 @@ public class IndexServiceImpl implements IndexService {
 
         Calendar instance = Calendar.getInstance();
         setZeroMonth(instance);
-        instance.add(Calendar.MONTH,1);
-        instance.add(Calendar.DAY_OF_MONTH,1);
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DAY_OF_MONTH, 1);
         Date currentYearEndDate = instance.getTime();
         setZeroYear(instance);
         Date currentYearBeginDate = instance.getTime();
 
 
+        String finalRole = role;
         CompletableFuture<BigDecimal> currentYearTotalFuture = CompletableFuture.supplyAsync(() -> {
 
             BigDecimal currentYearTotal = null;
-            if (AuthMark.DEPT_LEADER.equals(role)) {
+            if (AuthMark.DEPT_LEADER.equals(finalRole)) {
                 currentYearTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, currentYearBeginDate, currentYearEndDate);
-            } else if (AuthMark.BOSS.equals(role)) {
+            } else if (AuthMark.BOSS.equals(finalRole)) {
                 currentYearTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRangeIfBoss(tasknoList, currentYearBeginDate, currentYearEndDate);
             }
             if (ObjectUtils.isEmpty(currentYearTotal)) currentYearTotal = BigDecimal.valueOf(0);
@@ -598,8 +626,8 @@ public class IndexServiceImpl implements IndexService {
         instance.setTime(new Date());
         instance.add(Calendar.YEAR, -1);
         setZeroMonth(instance);
-        instance.add(Calendar.MONTH,1);
-        instance.add(Calendar.DAY_OF_MONTH,1);
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DAY_OF_MONTH, 1);
         //去年的今日
         Date LastTqEndDate = instance.getTime();
         setZeroYear(instance);
@@ -607,9 +635,9 @@ public class IndexServiceImpl implements IndexService {
 
         CompletableFuture<BigDecimal> lastYearTqTotalFuture = CompletableFuture.supplyAsync(() -> {
             BigDecimal lastYearTqTotal = null;
-            if (AuthMark.DEPT_LEADER.equals(role)) {
+            if (AuthMark.DEPT_LEADER.equals(finalRole)) {
                 lastYearTqTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, LastYearBeginDate, LastTqEndDate);
-            } else if (AuthMark.BOSS.equals(role)) {
+            } else if (AuthMark.BOSS.equals(finalRole)) {
                 lastYearTqTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRangeIfBoss(tasknoList, LastYearBeginDate, LastTqEndDate);
             }
             if (ObjectUtils.isEmpty(lastYearTqTotal)) lastYearTqTotal = BigDecimal.valueOf(0);
@@ -625,9 +653,9 @@ public class IndexServiceImpl implements IndexService {
 
         CompletableFuture<BigDecimal> currentMonthTotalFuture = CompletableFuture.supplyAsync(() -> {
             BigDecimal currentMonthTotal = null;
-            if (AuthMark.DEPT_LEADER.equals(role)) {
+            if (AuthMark.DEPT_LEADER.equals(finalRole)) {
                 currentMonthTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, currentMothBginDate, currentMothEndDate);
-            } else if (AuthMark.BOSS.equals(role)) {
+            } else if (AuthMark.BOSS.equals(finalRole)) {
                 currentMonthTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRangeIfBoss(tasknoList, currentMothBginDate, currentMothEndDate);
             }
             if (ObjectUtils.isEmpty(currentMonthTotal)) currentMonthTotal = BigDecimal.valueOf(0);
@@ -638,8 +666,8 @@ public class IndexServiceImpl implements IndexService {
         instance.setTime(new Date());
         instance.add(Calendar.MONTH, -1);
         setZeroMonth(instance);
-        instance.add(Calendar.MONTH,1);
-        instance.add(Calendar.DAY_OF_MONTH,1);
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DAY_OF_MONTH, 1);
         Date LastMothTqEndDate = instance.getTime();
         setZeroMonth(instance);
         Date LastMothTqBeginDate = instance.getTime();
@@ -647,9 +675,9 @@ public class IndexServiceImpl implements IndexService {
 
         CompletableFuture<BigDecimal> lastMothTqTotalFuture = CompletableFuture.supplyAsync(() -> {
             BigDecimal lastMothTqTotal = null;
-            if (AuthMark.DEPT_LEADER.equals(role)) {
+            if (AuthMark.DEPT_LEADER.equals(finalRole)) {
                 lastMothTqTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, LastMothTqBeginDate, LastMothTqEndDate);
-            } else if (AuthMark.BOSS.equals(role)) {
+            } else if (AuthMark.BOSS.equals(finalRole)) {
                 lastMothTqTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRangeIfBoss(tasknoList, LastMothTqBeginDate, LastMothTqEndDate);
             }
             if (ObjectUtils.isEmpty(lastMothTqTotal)) lastMothTqTotal = BigDecimal.valueOf(0);
@@ -660,17 +688,17 @@ public class IndexServiceImpl implements IndexService {
         instance.setTime(new Date());
         instance.add(Calendar.YEAR, -1);
         setZeroMonth(instance);
-        instance.add(Calendar.MONTH,1);
-        instance.add(Calendar.DAY_OF_MONTH,1);
+        instance.add(Calendar.MONTH, 1);
+        instance.add(Calendar.DAY_OF_MONTH, 1);
         Date lastYearMonthTqEndDate = instance.getTime();
         setZeroMonth(instance);
         Date lastYearMonthTqBeginDate = instance.getTime();
 
         CompletableFuture<BigDecimal> lastYearMonthTqTotalFuture = CompletableFuture.supplyAsync(() -> {
             BigDecimal lastYearMonthTqTotal = null;
-            if (AuthMark.DEPT_LEADER.equals(role)) {
+            if (AuthMark.DEPT_LEADER.equals(finalRole)) {
                 lastYearMonthTqTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, lastYearMonthTqBeginDate, lastYearMonthTqEndDate);
-            } else if (AuthMark.BOSS.equals(role)) {
+            } else if (AuthMark.BOSS.equals(finalRole)) {
                 lastYearMonthTqTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRangeIfBoss(tasknoList, lastYearMonthTqBeginDate, lastYearMonthTqEndDate);
             }
             if (ObjectUtils.isEmpty(lastYearMonthTqTotal)) lastYearMonthTqTotal = BigDecimal.valueOf(0);
@@ -748,15 +776,15 @@ public class IndexServiceImpl implements IndexService {
 
     /*合同额和合同数量二层图表*/
     @Override
-    public ContractChartInfoVo getContractAmountInfo(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
+    public ContractChartInfoVo getContractAmountInfo(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto, List<String> departNameList) {
 
         ContractChartInfoVo result;
         switch (indexInfoParamDto.getTime()) {
             case "year":
-                result = getContractAmountInfo(request, indexInfoParamDto, YEAR);
+                result = getContractAmountInfo(request, indexInfoParamDto, YEAR, departNameList);
                 break;
             case "month":
-                result = getContractAmountInfo(request, indexInfoParamDto, MONTH);
+                result = getContractAmountInfo(request, indexInfoParamDto, MONTH, departNameList);
                 break;
             default:
                 result = null;
@@ -765,7 +793,7 @@ public class IndexServiceImpl implements IndexService {
         return result;
     }
 
-    public ContractChartInfoVo getContractAmountInfo(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto, String Time) {
+    public ContractChartInfoVo getContractAmountInfo(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto, String Time, List<String> departNameList) {
         /*根据传进来年份或者月份初始化返回结果对象*/
         ContractChartInfoVo resVo = new ContractChartInfoVo();
         Date beginDate = dateFormat(indexInfoParamDto.getBeginDate(), Time);
@@ -800,6 +828,8 @@ public class IndexServiceImpl implements IndexService {
         LoginUser sysUser = sysBaseApi.getUserByName(userNameByToken);
 
         String role = commonMethod.getRole(userNameByToken);
+        if (AuthMark.BOSS.equals(role) && departNameList != null && !departNameList.isEmpty())
+            role = AuthMark.DEPT_LEADER;
         if (role == null) return resVo;
 
 
@@ -807,7 +837,13 @@ public class IndexServiceImpl implements IndexService {
         String depart = null;
         if (AuthMark.DEPT_LEADER.equals(role)) {
 
-            List<String> departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
+            List<String> departNames = null;
+            if (departNameList != null && !departNameList.isEmpty()) {
+                departNames = departNameList;
+            } else {
+                departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
+            }
+
             if (departNames.isEmpty()) return resVo;
 
             StringBuilder stringBuilder = new StringBuilder();
@@ -2415,7 +2451,7 @@ public class IndexServiceImpl implements IndexService {
      * @param indexInfoParamDto
      * @return IndexChartInfoVo<BigDecimal>
      */
-    public IndexChartInfoVo<BigDecimal> getTotalReceivedByDate(IndexInfoParamDto indexInfoParamDto, String userId) {
+    public IndexChartInfoVo<BigDecimal> getTotalReceivedByDate(IndexInfoParamDto indexInfoParamDto, String userId,List<String> departNameList) {
         //1.创建一个IndexChartInfoVo实例用来存储最后返回前端的信息
         IndexChartInfoVo<BigDecimal> indexChartInfoVo = new IndexChartInfoVo<>();
         BigDecimal initValue = BigDecimal.valueOf(0); //某年或某月没有任务,已收款为0
@@ -2452,7 +2488,13 @@ public class IndexServiceImpl implements IndexService {
 
         //3.通过登录的用户找到相应的部门,可能一个或两个
         //获取部门名称列表
-        List<String> sysDepartNames = sysDepartMapper.getSysUserOfDepartNameList(userId);
+        List<String> sysDepartNames = null;
+        if (departNameList!=null && !departNameList.isEmpty()){
+            sysDepartNames = departNameList;
+        }else {
+            sysDepartNames =  sysDepartMapper.getSysUserOfDepartNameList(userId);
+        }
+
         System.out.println("查出的部门列表:");
         System.out.println(sysDepartNames);
         if (sysDepartNames.isEmpty()) return indexChartInfoVo;
@@ -2561,19 +2603,19 @@ public class IndexServiceImpl implements IndexService {
      *
      * @return
      */
-    public IndexTotalVo getLreByRole(HttpServletRequest request) {
+    public IndexTotalVo getLreByRole(HttpServletRequest request, List<String> departNameList) {
         //初始化
         IndexTotalVo lrIndexTotalVo = indexTotalVoInit();
 
         //获取一层已收款
         CompletableFuture<IndexTotalVo> getYskFuture = CompletableFuture.supplyAsync(() -> {
-            return getTotalReceived(request);
+            return getTotalReceived(request, departNameList);
 //            return getTotalIncome(request);
         });
 //        IndexTotalVo hteindexTotalVo = getTotalIncome(request);
         //获取一层支出成本额
         CompletableFuture<IndexTotalVo> getZcbFuture = CompletableFuture.supplyAsync(() -> {
-            return indexZcbService.getZhiChuTotalList(request).get(0);
+            return indexZcbService.getZhiChuTotalList(request, departNameList).get(0);
         });
 //        IndexTotalVo zceindexTotalVo = indexZcbService.getZhiChuTotalList(request).get(0);
         CompletableFuture<Void> future1 = CompletableFuture.allOf(getYskFuture, getZcbFuture);
@@ -2672,7 +2714,7 @@ public class IndexServiceImpl implements IndexService {
      *
      * @return
      */
-    public IndexChartInfoVo<BigDecimal> getLreDetailByRole(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
+    public IndexChartInfoVo<BigDecimal> getLreDetailByRole(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto,List<String> departNameList) {
         //初始化
         IndexChartInfoVo<BigDecimal> indexChartInfoVo = indexChartInfoVoInit();
         List<String> xAxisDataList = new ArrayList<>();
@@ -2683,13 +2725,13 @@ public class IndexServiceImpl implements IndexService {
         //获取二层合同额
         CompletableFuture<IndexChartInfoVo> getHteFuture = CompletableFuture.supplyAsync(() -> {
 //            return getContractAmountInfo(request, indexInfoParamDto);
-            return getReceivedDetailByRoleDate(indexInfoParamDto);
+            return getReceivedDetailByRoleDate(indexInfoParamDto,departNameList);
         });
 //        ContractChartInfoVo contractChartInfoVo = getContractAmountInfo(request, indexInfoParamDto);
 
         //获取二层支出成本额 八项成本
         CompletableFuture<List<EightCostChartInfoVo>> getZcbFuture = CompletableFuture.supplyAsync(() -> {
-            return indexZcbService.getEightCostsList(indexInfoParamDto, request);
+            return indexZcbService.getEightCostsList(indexInfoParamDto, request,departNameList);
         });
 //        List<EightCostChartInfoVo> resultList = indexZcbService.getEightCostsList(indexInfoParamDto, request);
         CompletableFuture<Void> future1 = CompletableFuture.allOf(getHteFuture, getZcbFuture);
@@ -2762,7 +2804,7 @@ public class IndexServiceImpl implements IndexService {
      * @param indexInfoParamDto
      * @return IndexChartInfoVo<BigDecimal>
      */
-    public IndexChartInfoVo<BigDecimal> getReceivedDetailByRoleDate(IndexInfoParamDto indexInfoParamDto) {
+    public IndexChartInfoVo<BigDecimal> getReceivedDetailByRoleDate(IndexInfoParamDto indexInfoParamDto, List<String> departNameList) {
         //1.创建一个IndexChartInfoVo实例用来存储最后返回前端的信息
         IndexChartInfoVo<BigDecimal> indexChartInfoVo = new IndexChartInfoVo<>();
         BigDecimal initValue = BigDecimal.valueOf(0); //某年或某月没有任务,已收款为0
@@ -2777,9 +2819,10 @@ public class IndexServiceImpl implements IndexService {
         // 获取登录人用户信息 V2.0版本:
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String role = commonMethod.getRole(sysUser.getUsername());
-        if (role == null) {
-            return indexChartInfoVo;
-        }
+        if (AuthMark.BOSS.equals(role) && departNameList != null && !departNameList.isEmpty()) role = AuthMark.DEPT_LEADER;
+            if (role == null) {
+                return indexChartInfoVo;
+            }
         //如果是所长,查看所有 部门领导查看本部门  员工后期增加
         if (role.equals(AuthMark.BOSS)) {
             System.out.println("当前账户权限:所长");
@@ -2787,7 +2830,7 @@ public class IndexServiceImpl implements IndexService {
 //            indexChartInfoVo = getTotalReceivedByDate(indexInfoParamDto, sysUser.getId());
         } else if (role.equals(AuthMark.DEPT_LEADER)) {
             System.out.println("当前账户权限:部门领导");
-            indexChartInfoVo = getTotalReceivedByDate(indexInfoParamDto, sysUser.getId());
+            indexChartInfoVo = getTotalReceivedByDate(indexInfoParamDto, sysUser.getId(),departNameList);
         }
         return indexChartInfoVo;
     }

+ 44 - 20
module_kzks/src/main/java/org/jeecg/modules/Index/service/impl/IndexZcbServiceImpl.java

@@ -67,7 +67,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
      *   date: 2023/9/22
      */
     @Override
-    public List<IndexTotalVo> getZhiChuTotalList(HttpServletRequest request) {
+    public List<IndexTotalVo> getZhiChuTotalList(HttpServletRequest request,List<String> departNameList) {
 
         ArrayList<IndexTotalVo> projectZhiChusList = new ArrayList<>();
         IndexTotalVo projectZhiChu = new IndexTotalVo();
@@ -78,8 +78,15 @@ public class IndexZcbServiceImpl implements IndexZcbService {
         String username = JwtUtil.getUserNameByToken(request);
         //获取当前用户的角色的集合 (一个用户可能会有多个角色)
         String role = commonMethod.getRole(username);
+        List<String> deptList = null;
+        if (AuthMark.BOSS.equals(role) && departNameList != null && !departNameList.isEmpty()){
+            role = AuthMark.DEPT_LEADER;
+            deptList = departNameList;
+        }else {
+            deptList = sysUserDepartMapper.getDepartByUsername(username);
+        }
         // 根据用户名查询对应的部门
-        List<String> deptList = sysUserDepartMapper.getDepartByUsername(username);
+
         //处理当前系统日期
         SimpleDateFormat simpl = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         SimpleDateFormat simpl1 = new SimpleDateFormat("yyyy-MM");
@@ -202,9 +209,10 @@ public class IndexZcbServiceImpl implements IndexZcbService {
         }
         if (AuthMark.DEPT_LEADER.equals(role)){  // 如果当前用户角色是部门领导,则查询当前部门的总成本
             // 今年总收入
+            List<String> finalDeptList = deptList;
             CompletableFuture<BigDecimal> currentYearTotalFuture = CompletableFuture.supplyAsync(() -> {
                 BigDecimal sumZcb = BigDecimal.valueOf(0); //查询当前年份的总成本
-                BigDecimal a1 = indexZcbMapper.getZcbByDepartAndYear(deptList, String.valueOf(year));
+                BigDecimal a1 = indexZcbMapper.getZcbByDepartAndYear(finalDeptList, String.valueOf(year));
                 if (!ObjectUtil.isEmpty(a1)){
                     sumZcb = a1;
                 }
@@ -214,7 +222,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
             //上年同期支出
             CompletableFuture<BigDecimal> lastYearTqTotalFuture = CompletableFuture.supplyAsync(() -> {
                 BigDecimal sumZcbTq = BigDecimal.valueOf(0);
-                BigDecimal b1 = indexZcbMapper.getZcbByDepartAndUpDate(deptList, upYearDateFirstTq, upYearMonthTq);
+                BigDecimal b1 = indexZcbMapper.getZcbByDepartAndUpDate(finalDeptList, upYearDateFirstTq, upYearMonthTq);
                 if (!ObjectUtil.isEmpty(b1)){
                     sumZcbTq = b1;
                 }
@@ -225,7 +233,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
             //当月支出 (今年当月的总成本)
             CompletableFuture<BigDecimal> MonthTotalFuture = CompletableFuture.supplyAsync(() -> {
                 BigDecimal sumZcbMonth = BigDecimal.valueOf(0);
-                BigDecimal c1 = indexZcbMapper.getZcbByDepartAndYearMonth(deptList, nowMonth);
+                BigDecimal c1 = indexZcbMapper.getZcbByDepartAndYearMonth(finalDeptList, nowMonth);
                 if (!ObjectUtil.isEmpty(c1)){
                     sumZcbMonth = c1;
                 }
@@ -235,7 +243,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
             //去年同期 (去年当前月份的总成本)
             CompletableFuture<BigDecimal> upYearTotalFuture = CompletableFuture.supplyAsync(() -> {
                 BigDecimal upYearTq = BigDecimal.valueOf(0);
-                BigDecimal e1 = indexZcbMapper.getZcbByDepartAndYearMonth(deptList, upYearMonthTq);
+                BigDecimal e1 = indexZcbMapper.getZcbByDepartAndYearMonth(finalDeptList, upYearMonthTq);
                 if (!ObjectUtil.isEmpty(e1)){
                     upYearTq = e1;
                 }
@@ -245,7 +253,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
             //今年上个月份的总成本
             CompletableFuture<BigDecimal> sgyMonthTotalFuture = CompletableFuture.supplyAsync(() -> {
                 BigDecimal sgyMonthHb = BigDecimal.valueOf(0);
-                BigDecimal f1 = indexZcbMapper.getZcbByDepartAndYearMonth(deptList, sgyMonth);
+                BigDecimal f1 = indexZcbMapper.getZcbByDepartAndYearMonth(finalDeptList, sgyMonth);
                 if (!ObjectUtil.isEmpty(f1)){
                     sgyMonthHb = f1;
                 }
@@ -316,7 +324,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
      *   date: 2023/9/22
      */
     @Override
-    public List<EightCostChartInfoVo> getEightCostsList(IndexInfoParamDto indexInfoParamDto,HttpServletRequest request) {
+    public List<EightCostChartInfoVo> getEightCostsList(IndexInfoParamDto indexInfoParamDto,HttpServletRequest request,List<String> departNameList) {
         //获取当前登录的用户名,根据用户名查询对应的部门
         //Subject subject = SecurityUtils.getSubject();
         //LoginUser loginUser = (LoginUser)subject.getPrincipal();
@@ -324,8 +332,15 @@ public class IndexZcbServiceImpl implements IndexZcbService {
         String username = JwtUtil.getUserNameByToken(request);
         //获取当前用户的角色的集合 (一个用户可能会有多个角色)
         String role = commonMethod.getRole(username);
+        List<String> deptList = null;
+        if (AuthMark.BOSS.equals(role) && departNameList!=null && !departNameList.isEmpty()) {
+            role = AuthMark.DEPT_LEADER;
+            deptList = departNameList;
+        }else {
+            deptList  = sysUserDepartMapper.getDepartByUsername(username);
+        }
         // 该用户的部门
-        List<String> deptList = sysUserDepartMapper.getDepartByUsername(username);
+
         // 创建响应给前端的实体
         //ArrayList<IndexChartInfoVo> resultList = new ArrayList<>();
         ArrayList<EightCostChartInfoVo> resultList = new ArrayList<>();
@@ -428,8 +443,9 @@ public class IndexZcbServiceImpl implements IndexZcbService {
 
             if (AuthMark.DEPT_LEADER.equals(role)){ // 如果当前用户角色是部门领导,则查询当前部门的八项成本
                 // 查询前端指定的日期范围内和当前登录用户所在部门,在数据库中存在哪些日期
+                List<String> finalDeptList = deptList;
                 CompletableFuture<List<String>> getYearListSqlFuture = CompletableFuture.supplyAsync(() -> {
-                    List<String> yearListSql = indexZcbMapper.getYearByBm(beginDateStr, endDateStr, deptList);
+                    List<String> yearListSql = indexZcbMapper.getYearByBm(beginDateStr, endDateStr, finalDeptList);
                     return yearListSql;
                 });
                 //// 根据责任部门查询出日期集合
@@ -444,7 +460,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
                 //Collections.sort(yearListSql);  // 进行排序
                 // 根据部门查询出八项成本
                 CompletableFuture<List<EightCosts>> getCostListFuture = CompletableFuture.supplyAsync(() -> {
-                    List<EightCosts> costList = indexZcbMapper.getDepartEightCostByYear(beginDateStr, endDateStr, deptList);
+                    List<EightCosts> costList = indexZcbMapper.getDepartEightCostByYear(beginDateStr, endDateStr, finalDeptList);
                     return costList;
                 });
                 CompletableFuture<Void> future1 = CompletableFuture.allOf(getYearListSqlFuture,getCostListFuture);
@@ -585,8 +601,9 @@ public class IndexZcbServiceImpl implements IndexZcbService {
 
             if (AuthMark.DEPT_LEADER.equals(role)){   // 如果当前用户角色是部门领导,则查询当前部门的八项成本
                 // 查询前端指定的日期范围内和当前登录用户所在部门,在数据库中存在哪些日期
+                List<String> finalDeptList1 = deptList;
                 CompletableFuture<List<String>> getYearMonthListSqlFuture = CompletableFuture.supplyAsync(() -> {
-                    List<String> yearMonthListSql = indexZcbMapper.getDepartYearMonth(beginDateStr, endDateStr, deptList);
+                    List<String> yearMonthListSql = indexZcbMapper.getDepartYearMonth(beginDateStr, endDateStr, finalDeptList1);
                     return yearMonthListSql;
                 });
                 //List<String> zrbmYearMonthListSql = indexZcbMapper.getZrbmYearMonth(beginDateStr, endDateStr, deptList);
@@ -599,7 +616,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
                 //Collections.sort(yearMonthListSql);
                 // 根据部门查询出八项成本
                 CompletableFuture<List<EightCosts>> getCostListFuture = CompletableFuture.supplyAsync(() -> {
-                    List<EightCosts> costList = indexZcbMapper.getDepartEightCostByYearMonth(beginDateStr, endDateStr, deptList);
+                    List<EightCosts> costList = indexZcbMapper.getDepartEightCostByYearMonth(beginDateStr, endDateStr, finalDeptList1);
                     return costList;
                 });
                 CompletableFuture<Void> future1 = CompletableFuture.allOf(getYearMonthListSqlFuture,getCostListFuture);
@@ -689,7 +706,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
      *   date: 2023/9/23
      */
     @Override
-    public List<ResultEightCost> getSumEightCosts(IndexInfoParamDto indexInfoParamDto,HttpServletRequest request) {
+    public List<ResultEightCost> getSumEightCosts(IndexInfoParamDto indexInfoParamDto,HttpServletRequest request,List<String> departNameList) {
 
         //获取当前登录的用户名,根据用户名查询对应的部门
         //Subject subject = SecurityUtils.getSubject();
@@ -698,8 +715,14 @@ public class IndexZcbServiceImpl implements IndexZcbService {
         String username = JwtUtil.getUserNameByToken(request);
         // 查询当前用户的角色id (一个用户可能对应多个角色)
         String role = commonMethod.getRole(username);
-        // 该用户的部门
-        List<String> deptList = sysUserDepartMapper.getDepartByUsername(username);
+        List<String> deptList = null;
+        if (AuthMark.BOSS.equals(role) && departNameList != null && !departNameList.isEmpty()){
+            role = AuthMark.DEPT_LEADER;
+            deptList = departNameList;
+        }else {
+            // 该用户的部门
+            deptList = sysUserDepartMapper.getDepartByUsername(username);
+        }
         // 创建响应给前端的实体
         ArrayList<ResultEightCost> resultList = new ArrayList<>();
         // 获取前端传过来的 开始日期 和 结束日期
@@ -841,9 +864,10 @@ public class IndexZcbServiceImpl implements IndexZcbService {
             }
 
             if (AuthMark.DEPT_LEADER.equals(role)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
+                List<String> finalDeptList = deptList;
                 CompletableFuture<ArrayList<ResultEightCost>> getEightCostFuture = CompletableFuture.supplyAsync(() -> {
                     ArrayList<ResultEightCost> resultL = new ArrayList<>();
-                    List<EightCosts> e1 = indexZcbMapper.getDepartSumEightCostByYear(beginDateStr, endDateStr,deptList);
+                    List<EightCosts> e1 = indexZcbMapper.getDepartSumEightCostByYear(beginDateStr, endDateStr, finalDeptList);
                     if (e1.get(0) == null){
                         e1.clear();
                     }
@@ -1400,14 +1424,14 @@ public class IndexZcbServiceImpl implements IndexZcbService {
      *   date: 2023/9/24
      */
     @Override
-    public List<ZhiChuCost> getEightCostsInfo(IndexInfoParamDto indexInfoParamDto, HttpServletRequest request) {
+    public List<ZhiChuCost> getEightCostsInfo(IndexInfoParamDto indexInfoParamDto, HttpServletRequest request,List<String> departNameList) {
         ArrayList<ZhiChuCost> zhiChuCostsList = new ArrayList<>();
         CompletableFuture<List<EightCostChartInfoVo>> getChartInfoFuture = CompletableFuture.supplyAsync(() -> {
-            List<EightCostChartInfoVo> chartInfoList = getEightCostsList(indexInfoParamDto,request);
+            List<EightCostChartInfoVo> chartInfoList = getEightCostsList(indexInfoParamDto,request,departNameList);
             return chartInfoList;
         });
         CompletableFuture<List<ResultEightCost>> getSumEightCostsFuture = CompletableFuture.supplyAsync(() -> {
-            List<ResultEightCost> sumEightCosts = getSumEightCosts(indexInfoParamDto,request);
+            List<ResultEightCost> sumEightCosts = getSumEightCosts(indexInfoParamDto,request,departNameList);
             return sumEightCosts;
         });
         CompletableFuture<Void> future1 = CompletableFuture.allOf(getChartInfoFuture, getSumEightCostsFuture);

+ 1 - 1
module_kzks/src/main/java/org/jeecg/modules/Index/threadPool/SingletonThreadPool.java

@@ -14,7 +14,7 @@ public class SingletonThreadPool {
         int maxPoolSize = 16; // 最大线程池大小
         long keepAliveTime = 60L; // 线程空闲时间
         TimeUnit unit = TimeUnit.SECONDS; // 线程空闲时间单位
-        BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<>(2000); // 任务队列
+        BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<>(1000); // 任务队列
         executor = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, unit, workQueue);
     }
     public static SingletonThreadPool getInstance() {

+ 2 - 2
module_kzks/src/main/java/org/jeecg/modules/wzOutboundOrder/mapper/xml/WzOutboundOrderHMapper.xml

@@ -23,7 +23,7 @@
         FROM (SELECT a.wlbm,
                      a.wlmc,
                      a.ggxh,
-                     SUM(sfzsl * cgdj) AS totalAmount,
+                     SUM(case when cgdj = 0 or cgdj is null then nbdj * sfzsl else cgdj*sfzsl end) AS totalAmount,
                      sum(sfzsl)        AS totalCount
               FROM (SELECT wlbm,
                            wlmc,
@@ -79,7 +79,7 @@
         FROM (SELECT a.wlbm,
         a.wlmc,
         a.ggxh,
-        SUM(sfzsl * cgdj) AS totalAmount,
+        SUM(case when cgdj = 0 or cgdj is null then nbdj * sfzsl else cgdj*sfzsl end) AS totalAmount,
         sum(sfzsl) AS totalCount
         FROM (SELECT wlbm,
         wlmc,