Browse Source

利润二层修改(解决多次查询部门的问题)

sl 1 year ago
parent
commit
1fef5006fd

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

@@ -102,12 +102,11 @@ public class IndexController {
      * @param indexInfoParamDto
      * @return IndexChartInfoVo<BigDecimal>
      */
-    @ApiOperation(value="首页二层利润额显示", notes="首页二层利润额显示")
-    @GetMapping(value = "/countLreByDate")
-    public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(IndexInfoParamDto indexInfoParamDto) {
-        return indexService.countLreByDate(indexInfoParamDto);
+    @ApiOperation(value="首页二层已收款显示", notes="首页二层已收款显示")
+    @GetMapping("countTotalReceivedByDate")
+    public Result<IndexChartInfoVo<BigDecimal>> countTotalReceivedByDate(IndexInfoParamDto indexInfoParamDto) {
+        return indexService.countTotalReceivedByDate(indexInfoParamDto);
     }
-
     /**
      * 首页二层:前端传送IndexInfoParamDto  有三个参数,都是string类型  time 年/月 beginDate 开始日期  endDate结束日期
      * 跟据time来按月查或按年查
@@ -115,9 +114,9 @@ public class IndexController {
      * @param indexInfoParamDto
      * @return IndexChartInfoVo<BigDecimal>
      */
-    @ApiOperation(value="首页二层已收款显示", notes="首页二层已收款显示")
-    @GetMapping("countTotalReceivedByDate")
-    public Result<IndexChartInfoVo<BigDecimal>> countTotalReceivedByDate(IndexInfoParamDto indexInfoParamDto) {
-        return indexService.countTotalReceivedByDate(indexInfoParamDto);
+    @ApiOperation(value="首页二层利润额显示", notes="首页二层利润额显示")
+    @GetMapping(value = "/countLreByDate")
+    public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(IndexInfoParamDto indexInfoParamDto) {
+        return indexService.countLreByDate(indexInfoParamDto);
     }
 }

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

@@ -52,17 +52,17 @@ public interface IndexService {
      * 首页二层:前端传送IndexInfoParamDto  有三个参数,都是string类型  time 年/月 beginDate 开始日期  endDate结束日期
      * 跟据time来按月查或按年查
      *
-     * @return
+     * @param indexInfoParamDto
+     * @return IndexChartInfoVo<BigDecimal>
      */
-    public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(IndexInfoParamDto indexInfoParamDto);
+    public Result<IndexChartInfoVo<BigDecimal>> countTotalReceivedByDate(IndexInfoParamDto indexInfoParamDto);
 
     /**
      * 首页二层:前端传送IndexInfoParamDto  有三个参数,都是string类型  time 年/月 beginDate 开始日期  endDate结束日期
      * 跟据time来按月查或按年查
      *
-     * @param indexInfoParamDto
-     * @return IndexChartInfoVo<BigDecimal>
+     * @return
      */
-    public Result<IndexChartInfoVo<BigDecimal>> countTotalReceivedByDate(IndexInfoParamDto indexInfoParamDto);
+    public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(IndexInfoParamDto indexInfoParamDto);
 
 }

+ 72 - 73
module_kzks/src/main/java/org/jeecg/modules/Index/service/impl/IndexServiceImpl.java

@@ -1055,25 +1055,24 @@ public class IndexServiceImpl implements IndexService {
         return timeRangeList;
     }
 
-
     /**
-     * 首页二层:前端传送一个时间段,即开始时间和结束时间 Date类型
-     * 如果>31天,则返回按月的利润额
-     * 如果<=31天,则返回按天的利润额
+     * 首页二层:前端传送IndexInfoParamDto  有三个参数,都是string类型  time 年/月 beginDate 开始日期  endDate结束日期
+     * 跟据time来按月查或按年查
      *
-     * @return
+     * @param indexInfoParamDto
+     * @return IndexChartInfoVo<BigDecimal>
      */
-    public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(IndexInfoParamDto indexInfoParamDto){
+    public Result<IndexChartInfoVo<BigDecimal>> countTotalReceivedByDate(IndexInfoParamDto indexInfoParamDto){
         //1.创建一个IndexChartInfoVo实例用来存储最后返回前端的信息
         IndexChartInfoVo<BigDecimal> indexChartInfoVo = new IndexChartInfoVo<>();
-        BigDecimal initValue = BigDecimal.valueOf(0); //某年或某月没有任务,利润额为0
+        BigDecimal initValue = BigDecimal.valueOf(0); //某年或某月没有任务,已收款为0
         //创建一个String列表用来存储横坐标日期
         List<String> timeRangeList = new ArrayList<>();
         //创建一个BigDecimal列表用来存储纵坐标利润
         List<BigDecimal> seriesDataList = new ArrayList<>();
+        //初始化传一个空列表
         indexChartInfoVo.setXAxisData(timeRangeList);
         indexChartInfoVo.setSeriesData(seriesDataList);
-
         //2.计算时间列表 横坐标时间string列表
         //年/月
         String timeType = indexInfoParamDto.getTime();
@@ -1081,75 +1080,88 @@ public class IndexServiceImpl implements IndexService {
         String startString = indexInfoParamDto.getBeginDate();
         //结束时间
         String endString = indexInfoParamDto.getEndDate();
-
         if(timeType.equals("year")){
             timeRangeList = getDateList(timeRangeList, startString, endString, "yyyy", timeType);
         }
         else if (timeType.equals("month")){
             timeRangeList = getDateList(timeRangeList, startString, endString, "yyyy-MM", timeType);
         }
-        System.out.println("获取的日期列表为:");
-        System.out.println(timeRangeList);
-        if(timeRangeList.size() != 0){
-            //添加横坐标列表
-            indexChartInfoVo.setXAxisData(timeRangeList);
-            //3.通过登录的用户找到相应的部门,可能一个或两个
-            List<String> sysDepartNames = getDepNameBySysUser();
-            //4.计算该时间列表中某年或某月对应的总利润额
-            for(String timeRange:timeRangeList){
-                //根据时间和部门去查找任务号
-                List<String> taskNoListNew = getTaskNoListFDepTime2(sysDepartNames, timeType, timeRange);
-                System.out.println(timeRange + "的任务号列表:");
-                System.out.println(taskNoListNew);
-                if(taskNoListNew.size() != 0){
-                    BigDecimal sumLreYear = countLre(taskNoListNew);
-                    System.out.println(timeRange + "的利润额为:");
-                    System.out.println(sumLreYear);
-                    seriesDataList.add(sumLreYear);
-                    System.out.println("----------------------------------------------------");
+//        System.out.println("获取的日期列表为:");
+//        System.out.println(timeRangeList);
+        if (timeRangeList.isEmpty()) return Result.OK(indexChartInfoVo);//日期为空,直接传回两个空list
+        //根据日期长度初始化纵坐标值 0
+        for(String timeRange:timeRangeList){
+            seriesDataList.add(initValue);
+        }
+        //添加横坐标列表
+        indexChartInfoVo.setXAxisData(timeRangeList);
+        //添加纵坐标列表
+        indexChartInfoVo.setSeriesData(seriesDataList);
+
+        //3.通过登录的用户找到相应的部门,可能一个或两个
+        List<String> sysDepartNames = getDepNameBySysUser();
+        if (sysDepartNames.isEmpty()) return Result.OK(indexChartInfoVo);
+
+        ArrayList<String> tasknoList = new ArrayList<>();
+        List<String> ZrbmTasknoList = projectCostMapper.queryZrbmTasknoListbydepartNames(sysDepartNames);
+        List<String> XdbmTasknoList = projectCostMapper.queryXdbmTasknoListbydepartNames(sysDepartNames);
+        tasknoList.addAll(ZrbmTasknoList);
+        tasknoList.addAll(XdbmTasknoList);
+        System.out.println("查到的所有部门对应的任务号列表:");
+        System.out.println(tasknoList);
+        if (tasknoList.isEmpty()) return Result.OK(indexChartInfoVo);
+//        System.out.println(indexChartInfoVo);
+
+        //4.计算该时间列表中某年或某月对应的总利润额
+        List<BigDecimal> seriesDataList2 = new ArrayList<>();
+        for(String timeRange2:timeRangeList){
+            //根据日期和当前部门对应的任务号查询,部门某年或某月的年收入
+            if(timeType.equals("year")){
+                BigDecimal yearTotal = exchangeMapper.getReceivedByYear(tasknoList, timeRange2);
+                if(yearTotal == null){
+                    yearTotal = initValue;
                 }
-                else{
-                    System.out.println(timeRange + "的利润额为:" + initValue);
-                    seriesDataList.add(initValue);
+                seriesDataList2.add(yearTotal);
+            }
+            else if(timeType.equals("month")){
+                BigDecimal yearTotal = exchangeMapper.getReceivedByYMonth(tasknoList, timeRange2);
+                if(yearTotal == null){
+                    yearTotal = initValue;
                 }
-
+                seriesDataList2.add(yearTotal);
             }
-            //添加纵坐标列表
-            indexChartInfoVo.setSeriesData(seriesDataList);
-
         }
+        //添加纵坐标列表
+        indexChartInfoVo.setSeriesData(seriesDataList2);
         return Result.OK(indexChartInfoVo);
-
     }
 
+
     /**
      * 首页二层:前端传送IndexInfoParamDto  有三个参数,都是string类型  time 年/月 beginDate 开始日期  endDate结束日期
      * 跟据time来按月查或按年查
      *
-     * @param indexInfoParamDto
-     * @return IndexChartInfoVo<BigDecimal>
+     * @return
      */
-    public Result<IndexChartInfoVo<BigDecimal>> countTotalReceivedByDate(IndexInfoParamDto indexInfoParamDto){
+    public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(IndexInfoParamDto indexInfoParamDto){
         //1.创建一个IndexChartInfoVo实例用来存储最后返回前端的信息
         IndexChartInfoVo<BigDecimal> indexChartInfoVo = new IndexChartInfoVo<>();
-        BigDecimal initValue = BigDecimal.valueOf(0); //某年或某月没有任务,已收款为0
+        BigDecimal initValue = BigDecimal.valueOf(0); //某年或某月没有任务,利润额为0
         //创建一个String列表用来存储横坐标日期
         List<String> timeRangeList = new ArrayList<>();
         //创建一个BigDecimal列表用来存储纵坐标利润
         List<BigDecimal> seriesDataList = new ArrayList<>();
-        //初始化一个空列表
+        //初始化横纵列表都是一个空列表
         indexChartInfoVo.setXAxisData(timeRangeList);
         indexChartInfoVo.setSeriesData(seriesDataList);
+
         //2.计算时间列表 横坐标时间string列表
         //年/月
         String timeType = indexInfoParamDto.getTime();
-        System.out.println(timeType);
         //起始时间
         String startString = indexInfoParamDto.getBeginDate();
-        System.out.println(startString);
         //结束时间
         String endString = indexInfoParamDto.getEndDate();
-        System.out.println(endString);
 
         if(timeType.equals("year")){
             timeRangeList = getDateList(timeRangeList, startString, endString, "yyyy", timeType);
@@ -1159,11 +1171,13 @@ public class IndexServiceImpl implements IndexService {
         }
         System.out.println("获取的日期列表为:");
         System.out.println(timeRangeList);
+
         if (timeRangeList.isEmpty()) return Result.OK(indexChartInfoVo);//日期为空,直接传回两个空list
         //根据日期长度初始化纵坐标值 0
         for(String timeRange:timeRangeList){
             seriesDataList.add(initValue);
         }
+        //初始化横坐标有日期时,相应的纵坐标先赋一个0
         //添加横坐标列表
         indexChartInfoVo.setXAxisData(timeRangeList);
         //添加纵坐标列表
@@ -1172,41 +1186,26 @@ public class IndexServiceImpl implements IndexService {
         //3.通过登录的用户找到相应的部门,可能一个或两个
         List<String> sysDepartNames = getDepNameBySysUser();
         if (sysDepartNames.isEmpty()) return Result.OK(indexChartInfoVo);
-
-        ArrayList<String> tasknoList = new ArrayList<>();
-        List<String> ZrbmTasknoList = projectCostMapper.queryZrbmTasknoListbydepartNames(sysDepartNames);
-        List<String> XdbmTasknoList = projectCostMapper.queryXdbmTasknoListbydepartNames(sysDepartNames);
-        tasknoList.addAll(ZrbmTasknoList);
-        tasknoList.addAll(XdbmTasknoList);
-        System.out.println("查到的所有部门对应的任务号列表:");
-        System.out.println(tasknoList);
-        if (tasknoList.isEmpty()) return Result.OK(indexChartInfoVo);
-
-        System.out.println(indexChartInfoVo);
-
         //4.计算该时间列表中某年或某月对应的总利润额
         List<BigDecimal> seriesDataList2 = new ArrayList<>();
-        for(String timeRange2:timeRangeList){
-            //根据日期和当前部门对应的任务号查询,部门某年或某月的年收入
-            if(timeType.equals("year")){
-                BigDecimal yearTotal = exchangeMapper.getReceivedByYear(tasknoList, timeRange2);
-                if(yearTotal == null){
-                    yearTotal = initValue;
-                }
-                seriesDataList2.add(yearTotal);
-            }
-            else if(timeType.equals("month")){
-                BigDecimal yearTotal = exchangeMapper.getReceivedByYMonth(tasknoList, timeRange2);
-                if(yearTotal == null){
-                    yearTotal = initValue;
-                }
-                seriesDataList2.add(yearTotal);
+        for(String timeRange:timeRangeList) {
+            //根据时间和部门去查找任务号
+            List<String> taskNoListNew = getTaskNoListFDepTime2(sysDepartNames, timeType, timeRange);
+            System.out.println(timeRange + "的任务号列表:");
+            System.out.println(taskNoListNew);
+            if (taskNoListNew.size() != 0) {
+                BigDecimal sumLreYear = countLre(taskNoListNew);
+                System.out.println(timeRange + "的利润额为:");
+                System.out.println(sumLreYear);
+                seriesDataList2.add(sumLreYear);
+                System.out.println("----------------------------------------------------");
+            } else {
+                System.out.println(timeRange + "的利润额为:" + initValue);
+                seriesDataList2.add(initValue);
             }
         }
         //添加纵坐标列表
         indexChartInfoVo.setSeriesData(seriesDataList2);
         return Result.OK(indexChartInfoVo);
-
     }
-
 }