Browse Source

首页一层利润额以及二层显示

sl 1 year ago
parent
commit
3418e9b162

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

@@ -10,12 +10,14 @@ import org.jeecg.modules.Index.entity.vo.ContractDataInfoVo;
 import org.jeecg.modules.Index.entity.vo.IncomeDataInfoVo;
 import org.jeecg.modules.Index.entity.vo.IndexChartInfoVo;
 import org.jeecg.modules.Index.entity.vo.ReceivedDataInfoVo;
+import org.jeecg.modules.Index.entity.vo.*;
 import org.jeecg.modules.Index.service.IndexService;
 import org.jeecg.modules.Index.service.IndexZcbService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
 
 import java.util.List;
 
@@ -30,35 +32,34 @@ public class IndexController {
     @Autowired
     private IndexZcbService indexZcbService;
 
+    @ApiOperation(value="计算合同额", notes="计算合同额")
     @GetMapping("getTotalIncome")
     public Result<IncomeDataInfoVo> getTotalIncome(HttpServletRequest request) {
         IncomeDataInfoVo reslut = indexService.getTotalIncome(request);
         return Result.ok(reslut);
     }
 
-
+    @ApiOperation(value="计算合同数量", notes="计算合同数量")
     @GetMapping("getTotalContract")
     public Result<ContractDataInfoVo> getTotalContract(HttpServletRequest request) {
         ContractDataInfoVo reslut = indexService.getTotalContract(request);
         return Result.ok(reslut);
     }
 
+    @ApiOperation(value="计算已收款", notes="计算已收款")
     @GetMapping("getTotalReceived")
     public Result<ReceivedDataInfoVo> getTotalReceived(HttpServletRequest request) {
         ReceivedDataInfoVo reslut = indexService.getTotalReceived(request);
         return Result.ok(reslut);
     }
 
-
+    @ApiOperation(value="首页二层合同额显示", notes="首页二层合同额显示")
     @PostMapping("getContractAmountInfo")
     public Result<String> getContractAmountInfo(HttpServletRequest request, @RequestBody IndexInfoParamDto indexInfoParamDto) {
         return Result.ok(indexService.getContractAmountInfo(request,indexInfoParamDto));
     }
 
 
-
-
-
     @ApiOperation("领导驾驶舱---支出模块")
     @GetMapping("/getZcb")
     public List<ProjectZhiChu> getZhiChuTotalList(){
@@ -73,5 +74,27 @@ public class IndexController {
         return resultList;
     }
 
+    /**
+     * 计算当年的年总利润额、上一年同期总利润额、年同比增长、当月总利润额、当月同比、当月环比
+     *
+     * @return
+     */
+    @ApiOperation(value="计算总利润额以及同比环比", notes="计算总利润额以及同比环比")
+    @GetMapping(value = "/countLre")
+    public Result<LreDataInfoVo> countLre() {
+        return indexService.countLre();
+    }
 
+    /**
+     * 首页二层:前端传送IndexInfoParamDto  有三个参数,都是string类型  time 年/月 beginDate 开始日期  endDate结束日期
+     * 跟据time来按月查或按年查
+     *
+     * @param indexInfoParamDto
+     * @return IndexChartInfoVo<BigDecimal>
+     */
+    @ApiOperation(value="首页二层利润额显示", notes="首页二层利润额显示")
+    @GetMapping(value = "/countLreByDate")
+    public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(IndexInfoParamDto indexInfoParamDto) {
+        return indexService.countLreByDate(indexInfoParamDto);
+    }
 }

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

@@ -7,6 +7,8 @@ import org.jeecg.modules.Index.entity.vo.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 
 public interface IndexService {
@@ -46,5 +48,14 @@ public interface IndexService {
      */
     Result<LreDataInfoVo> countLre();
 
+    /**
+     * 首页二层:前端传送IndexInfoParamDto  有三个参数,都是string类型  time 年/月 beginDate 开始日期  endDate结束日期
+     * 跟据time来按月查或按年查
+     *
+     * @return
+     */
+    public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(IndexInfoParamDto indexInfoParamDto);
+
+
 
 }

+ 139 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/service/impl/IndexServiceImpl.java

@@ -792,6 +792,43 @@ public class IndexServiceImpl implements IndexService {
     }
 
     /**
+     * 根据部门和需要的日期(某年某月)来取任务号tasknolist
+     *
+     * @return
+     */
+    public List<String> getTaskNoListFDepTime2(List<String> sysDepartNames, String timeType, String timeRange){
+        //2.根据部门名称(zrbm、jycs)和实际完成时间查询taskno
+        List<String> taskNoList = new ArrayList<>();
+        for (String sysDepartName : sysDepartNames) {
+            List<String> taskNoList1 = new ArrayList<>();
+            switch (timeType) {
+                case "年"://某年的所有任务
+                    taskNoList1 = kyTaskInfoService.getKyTaskNoByYear(sysDepartName, timeRange);
+                    break;
+                case "月"://某月的所有任务
+                    taskNoList1 = kyTaskInfoService.getKyTaskNoByMonth(sysDepartName, timeRange);
+                    break;
+                default:
+                    System.out.println("默认没有任务");
+                    break;
+            }
+
+//            List<String> taskNoList1 = kyTaskInfoService.getKyTaskNoByNameCurrYear(sysDepartName);
+            System.out.println(taskNoList1);
+            taskNoList.addAll(taskNoList1);
+            System.out.println(taskNoList);
+        }
+        //新建一个list来给list中的数据去重   防止责任部门和下达部门都为一个部门,可能会信息重复
+        List<String> taskNoListNew = new ArrayList<>();
+        for (String taskNo : taskNoList) {
+            if (!taskNoListNew.contains(taskNo)) {
+                taskNoListNew.add(taskNo);
+            }
+        }
+        return taskNoListNew;
+    }
+
+    /**
      * 计算当年的年总利润额、上一年同期总利润额、年同比增长、当月总利润额、当月同比、当月环比
      *
      * @return
@@ -914,4 +951,106 @@ public class IndexServiceImpl implements IndexService {
         System.out.println(sysDepartNames);
         return sysDepartNames;
     }
+
+    /**
+    * 获取年月列表
+    * @Param dateFormat 日期格式  timeType 日期增加的格式(年/月)
+    *
+    */
+    public List<String> getDateList(List<String> timeRangeList, String startString, String endString, String dateFormat, String timeType){
+        //用Calendar 进行日期比较判断
+        Calendar calendar = Calendar.getInstance();
+        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
+        try {
+            // 转化成日期类型
+            Date startDate = sdf.parse(startString);
+            Date endDate = sdf.parse(endString);
+            while (startDate.getTime()<=endDate.getTime()){
+                // 把日期添加到集合
+                timeRangeList.add(sdf.format(startDate));
+                // 设置日期
+                calendar.setTime(startDate);
+                //把日期增加一天
+                if(timeType.equals("年")){
+                    calendar.add(Calendar.YEAR, 1);
+                }
+                else if(timeType.equals("月")){
+                    calendar.add(Calendar.MONTH, 1);
+                }
+                // 获取增加后的日期
+                startDate=calendar.getTime();
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return timeRangeList;
+    }
+
+
+    /**
+     * 首页二层:前端传送一个时间段,即开始时间和结束时间 Date类型
+     * 如果>31天,则返回按月的利润额
+     * 如果<=31天,则返回按天的利润额
+     *
+     * @return
+     */
+    public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(IndexInfoParamDto indexInfoParamDto){
+        //1.创建一个IndexChartInfoVo实例用来存储最后返回前端的信息
+        IndexChartInfoVo<BigDecimal> indexChartInfoVo = new IndexChartInfoVo<>();
+        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();
+        //起始时间
+        String startString = indexInfoParamDto.getBeginDate();
+        //结束时间
+        String endString = indexInfoParamDto.getEndDate();
+
+        if(timeType.equals("年")){
+            timeRangeList = getDateList(timeRangeList, startString, endString, "yyyy", timeType);
+        }
+        else if (timeType.equals("月")){
+            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("----------------------------------------------------");
+                }
+                else{
+                    System.out.println(timeRange + "的利润额为:" + initValue);
+                    seriesDataList.add(initValue);
+                }
+
+            }
+            //添加纵坐标列表
+            indexChartInfoVo.setSeriesData(seriesDataList);
+
+        }
+        return Result.OK(indexChartInfoVo);
+
+    }
+
 }

+ 6 - 0
module_kzks/src/main/java/org/jeecg/modules/kyTaskInfo/mapper/KyTaskInfoMapper.java

@@ -36,4 +36,10 @@ public interface KyTaskInfoMapper extends BaseMapper<KyTaskInfo> {
     /**根据部门名称和实际完成时间查询任务号  @param depName 部门名称  此处按去年同期月份查询*/
     public List<String> getKyTaskNoByNameTqMonth(String depName);
 
+    /**根据部门名称和实际完成时间查询任务号  @param depName 部门名称  按年查询(随便某一年的数据)*/
+    public List<String> getKyTaskNoByYear(String depName, String year);
+    /**根据部门名称和实际完成时间查询任务号  @param depName 部门名称  按月查询(随便某一年某个月的数据) ym形式如2023-09*/
+    public List<String> getKyTaskNoByMonth(String depName, String ym);
+
+
 }

+ 24 - 1
module_kzks/src/main/java/org/jeecg/modules/kyTaskInfo/mapper/xml/KyTaskInfoMapper.xml

@@ -46,7 +46,30 @@
             </if>
         </where>
     </select>
-
+    <!--根据部门和实际完成时间  按年查询(随便某一年)-->
+    <select id="getKyTaskNoByYear" parameterType="String" resultType="String">
+        select taskno from ky_task_info
+        <where>
+            <if test="depName!=null and depName!=''">
+                and (zrbm=#{depName} or jycs=#{depName})
+            </if>
+            <if test="year!=null and year!=''">
+                and (YEAR(sjwcsj)=#{year})
+            </if>
+        </where>
+    </select>
+    <!--根据部门和实际完成时间  按年月查询(随便某一年的某个月)-->
+    <select id="getKyTaskNoByMonth" parameterType="String" resultType="String">
+        select taskno from ky_task_info
+        <where>
+            <if test="depName!=null and depName!=''">
+                and (zrbm=#{depName} or jycs=#{depName})
+            </if>
+            <if test="ym!=null and ym!=''">
+                and (DATE_FORMAT(sjwcsj,"%Y-%m")=#{ym})
+            </if>
+        </where>
+    </select>
 
 
 </mapper>

+ 5 - 0
module_kzks/src/main/java/org/jeecg/modules/kyTaskInfo/service/IKyTaskInfoService.java

@@ -27,4 +27,9 @@ public interface IKyTaskInfoService extends IService<KyTaskInfo> {
     public List<String> getKyTaskNoByNameLastMonth(String depName);
     /**根据部门名称和实际完成时间查询任务号  @param depName 部门名称  此处按去年同期月份查询*/
     public List<String> getKyTaskNoByNameTqMonth(String depName);
+
+    /**根据部门名称和实际完成时间查询任务号  @param depName 部门名称  按年查询(随便某一年的数据)*/
+    public List<String> getKyTaskNoByYear(String depName, String year);
+    /**根据部门名称和实际完成时间查询任务号  @param depName 部门名称  按月查询(随便某一年某个月的数据) ym形式如2023-09*/
+    public List<String> getKyTaskNoByMonth(String depName, String ym);
 }

+ 9 - 0
module_kzks/src/main/java/org/jeecg/modules/kyTaskInfo/service/impl/KyTaskInfoServiceImpl.java

@@ -52,5 +52,14 @@ public class KyTaskInfoServiceImpl extends ServiceImpl<KyTaskInfoMapper, KyTaskI
         return kyTaskInfoMapper.getKyTaskNoByNameTqMonth(depName);
     }
 
+    /**根据部门名称和实际完成时间查询任务号  @param depName 部门名称  按年查询(随便某一年的数据)*/
+    public List<String> getKyTaskNoByYear(String depName, String year){
+        return kyTaskInfoMapper.getKyTaskNoByYear(depName, year);
+    }
+    /**根据部门名称和实际完成时间查询任务号  @param depName 部门名称  按月查询(随便某一年某个月的数据) ym形式如2023-09*/
+    public List<String> getKyTaskNoByMonth(String depName, String ym){
+        return  kyTaskInfoMapper.getKyTaskNoByMonth(depName, ym);
+    }
+
 
 }