Browse Source

领导驾驶舱一层统计+二层图表

丁治程 1 year ago
parent
commit
9fdae749fb

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

@@ -1,21 +1,25 @@
 package org.jeecg.modules.Index.controller;
 
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.poi.ss.formula.functions.T;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.Index.entity.vo.ProjectZhiChu;
 import org.jeecg.modules.Index.entity.dto.IndexInfoParamDto;
 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.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;
 
-@Api(tags = "首页")
+import java.util.List;
+
+@Api(tags="首页")
 @RestController
 @RequestMapping("/index")
 @Slf4j
@@ -23,6 +27,9 @@ public class IndexController {
     @Autowired
     private IndexService indexService;
 
+    @Autowired
+    private IndexZcbService indexZcbService;
+
     @GetMapping("getTotalIncome")
     public Result<IncomeDataInfoVo> getTotalIncome(HttpServletRequest request) {
         IncomeDataInfoVo reslut = indexService.getTotalIncome(request);
@@ -49,4 +56,22 @@ public class IndexController {
     }
 
 
+
+
+
+    @ApiOperation("领导驾驶舱---支出模块")
+    @GetMapping("/getZcb")
+    public List<ProjectZhiChu> getZhiChuTotalList(){
+        List<ProjectZhiChu> zhiChuTotalList = indexZcbService.getZhiChuTotalList();
+        return zhiChuTotalList;
+    }
+
+    @ApiOperation("领导驾驶舱---支出模块下的统计")
+    @GetMapping("/getEightCost")
+    public List<IndexChartInfoVo> getEightCost(IndexInfoParamDto indexInfoParamDto){
+        List<IndexChartInfoVo> resultList = indexZcbService.getEightCostsList(indexInfoParamDto);
+        return resultList;
+    }
+
+
 }

+ 39 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/entity/vo/EightCosts.java

@@ -0,0 +1,39 @@
+package org.jeecg.modules.Index.entity.vo;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author dzc
+ * @date 2023/9/22 14:54
+ * @package org.jeecg.modules.Index.entity
+ * @project yecai_server
+ * @des 八项成本
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+public class EightCosts implements Serializable {
+    private final static long serialVersionUID = 1L;
+
+    /** 材料费 */
+    private BigDecimal clf;
+    /** 专用费 */
+    private BigDecimal zyf;
+    /** 事务费 */
+    private BigDecimal swf;
+    /** 外协费 */
+    private BigDecimal wxf;
+    /** 燃料动力费 */
+    private BigDecimal rldlf;
+    /** 固定资产折旧费 */
+    private BigDecimal gdzczj;
+    /** 工资及劳务费 */
+    private BigDecimal gzjlwf;
+    /** 管理费 */
+    private BigDecimal glf;
+}

+ 38 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/entity/vo/ProjectZhiChu.java

@@ -0,0 +1,38 @@
+package org.jeecg.modules.Index.entity.vo;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author dzc
+ * @date 2023/9/21 10:30
+ * @package org.jeecg.modules.Index.entity
+ * @project yecai_server
+ * @des 领导驾驶舱支出模块实体
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+public class ProjectZhiChu implements Serializable {
+
+    private final static long serialVersionUID = 1L;
+
+    /** 年总支出 */
+    private BigDecimal ZhiChuYearTotal;
+    /** 上年同期总支出 */
+    private BigDecimal ZhiChuYearTq;
+    /** 同比增长率 */
+    private BigDecimal ZhiChuYearTb;
+    /** 当月支出 */
+    private BigDecimal ZhiChuMonthTotal;
+    /** 当月同比 */
+    private BigDecimal ZhiChuMonthTb;
+    /** 当月环比 */
+    private BigDecimal ZhiChuMonthHb;
+}

+ 77 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/mapper/IndexZcbMapper.java

@@ -0,0 +1,77 @@
+package org.jeecg.modules.Index.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.Index.entity.vo.EightCosts;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @author dzc
+ * @date 2023/9/22 8:36
+ * @package org.jeecg.modules.Index.mapper
+ * @project yecai_server
+ * @des 领导驾驶舱支出模块
+ */
+@Mapper
+public interface IndexZcbMapper {
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 统计总成本根据当前用户的部门和日期 部门根据下达部门
+     *   date: 2023/9/21
+     */
+    public BigDecimal getZcbByXdDepartAndDate(@Param("dep") List<String> dep, @Param("nowDate") String nowDate);
+
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 统计总成本根据当前用户的部门和日期 部门根据责任部门
+     *   date: 2023/9/21
+     */
+    public BigDecimal getZcbByZrDepartAndDate(@Param("dep") List<String> dep, @Param("nowDate") String nowDate);
+
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 根据用户名查询部门名称
+     *   date: 2023/9/21
+     */
+    public List<String> getDepartByUsername(String username);
+
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 查询去年同期总成本  部门根据下达部门
+     *   date: 2023/9/21
+     */
+    public BigDecimal getZcbByXdDepartAndUpDate(@Param("dep") List<String> dep,@Param("upDateFirst") String upDateFirst, @Param("upDate") String upDate);
+
+
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 查询去年同期总成本  部门根据责任部门
+     *   date: 2023/9/21
+     */
+    public BigDecimal getZcbByZrDepartAndUpDate(@Param("dep") List<String> dep,@Param("upDateFirst") String upDateFirst, @Param("upDate") String upDate);
+
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 查询指定时间段内的八项成本  部门根据下达部门
+    *   date: 2023/9/22
+    */
+    public List<EightCosts> getEightCostXdDepartByDate(@Param("dep") List<String> dep,@Param("startDate") String startDate,@Param("endDate") String endDate);
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 查询指定时间段内的八项成本 部门根据责任部门
+    *   date: 2023/9/22
+    */
+    public List<EightCosts> getEightCostZrDepartByDate(@Param("dep") List<String> dep,@Param("startDate") String startDate,@Param("endDate") String endDate);
+
+}

+ 114 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/mapper/xml/IndexZcbMapper.xml

@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.Index.mapper.IndexZcbMapper">
+
+
+
+    <!-- 统计总成本(支出) 部门根据下达部门 -->
+    <select id="getZcbByXdDepartAndDate" resultType="BigDecimal">
+        select sum(c.zcb)
+        from kzks_project_cost c
+        left join ky_task_info k
+        on c.taskno = k.taskno
+        where k.jycs in
+        <foreach collection="dep" item="item" index="index" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        and k.sjwcsj like concat('%', #{nowDate}, '%')
+<!--        and c.taskno not in-->
+<!--        <foreach collection="dep" item="item" index="index" separator="," open="(" close=")">-->
+</select>
+
+    <!-- 统计总成本(支出) 部门根据责任部门 -->
+    <select id="getZcbByZrDepartAndDate" resultType="BigDecimal">
+        select sum(c.zcb)
+        from kzks_project_cost c
+        left join ky_task_info k
+        on c.taskno = k.taskno
+        where k.zrbm in
+        <foreach collection="dep" item="item" index="index" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        and k.sjwcsj like concat('%', #{nowDate}, '%')
+    </select>
+
+    <resultMap id="DepartMap" type="String">
+        <result column="depart_name"></result>
+    </resultMap>
+    <!-- 根据登录时的用户名 查询该用户所属部门 -->
+    <select id="getDepartByUsername" resultMap="DepartMap">
+        SELECT depart_name
+        FROM sys_depart
+        WHERE id IN
+        (SELECT dep_id FROM sys_user_depart WHERE user_id IN
+            (SELECT id FROM sys_user WHERE username = #{username})
+        )
+    </select>
+
+    <!-- 查询去年同期总成本 部门根据下达部门 -->
+    <select id="getZcbByXdDepartAndUpDate" resultType="BigDecimal">
+        select sum(c.zcb)
+        from kzks_project_cost c
+        left join ky_task_info k
+        on c.taskno = k.taskno
+        where k.jycs in
+        <foreach collection="dep" item="item" index="index" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        and k.sjwcsj >= #{upDateFirst} and k.sjwcsj <![CDATA[ <= ]]> #{upDate}
+    </select>
+
+    <!-- 查询去年同期总成本 部门根据责任部门部门 -->
+    <select id="getZcbByZrDepartAndUpDate" resultType="BigDecimal">
+        SELECT sum(c.zcb)
+        FROM kzks_project_cost c
+        LEFT JOIN ky_task_info k
+        ON c.taskno = k.taskno
+        WHERE k.zrbm IN
+        <foreach collection="dep" item="item" index="index" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND k.sjwcsj >= #{upDateFirst} AND k.sjwcsj <![CDATA[ <= ]]> #{upDate}
+    </select>
+
+    <!-- 查询规定时间段内的 材料费、专用费、事务费、外协费、燃料动力费、固定资产折旧费、工资及劳务费、管理费 之和 部门根据下达部门 -->
+    <resultMap id="EigthCostList" type="org.jeecg.modules.Index.entity.vo.EightCosts">
+        <result property="clf" column="clf"/>
+        <result property="zyf" column="zyf"/>
+        <result property="swf" column="swf"/>
+        <result property="wxf" column="wxf"/>
+        <result property="rldlf" column="rldlf"/>
+        <result property="gdzczj" column="gdzczj"/>
+        <result property="gzjlwf" column="gzjlwf"/>
+        <result property="glf" column="glf"/>
+    </resultMap>
+    <select id="getEightCostXdDepartByDate" resultMap="EigthCostList">
+        SELECT
+            sum( c.clf ) as clf,sum(c.zyf) as zyf,sum(c.swf) as swf,sum(c.wxf) as wxf,
+            sum(c.rldlf) as rldlf,sum(c.gdzczj) as gdzczj,sum(c.gzjlwf) as gzjlwf,sum(c.glf) as glf
+        FROM
+            kzks_project_cost c
+        LEFT JOIN ky_task_info k
+        ON c.taskno = k.taskno
+        WHERE k.jycs IN
+        <foreach collection="dep" item="item" index="index" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND k.sjwcsj >= #{startDate} AND k.sjwcsj <![CDATA[ <= ]]> #{endDate}
+    </select>
+    <!-- 查询规定时间段内的 材料费、专用费、事务费、外协费、燃料动力费、固定资产折旧费、工资及劳务费、管理费 之和 部门根据责任部门 -->
+    <select id="getEightCostZrDepartByDate" resultMap="EigthCostList">
+        SELECT
+        sum( c.clf ) as clf,sum(c.zyf) as zyf,sum(c.swf) as swf,sum(c.wxf) as wxf,
+        sum(c.rldlf) as rldlf,sum(c.gdzczj) as gdzczj,sum(c.gzjlwf) as gzjlwf,sum(c.glf) as glf
+        FROM
+        kzks_project_cost c
+        LEFT JOIN ky_task_info k
+        ON c.taskno = k.taskno
+        WHERE k.zrbm IN
+        <foreach collection="dep" item="item" index="index" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND k.sjwcsj >= #{startDate} AND k.sjwcsj <![CDATA[ <= ]]> #{endDate}
+    </select>
+</mapper>

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

@@ -0,0 +1,77 @@
+package org.jeecg.modules.Index.service;
+
+import org.jeecg.modules.Index.entity.vo.EightCosts;
+import org.jeecg.modules.Index.entity.vo.ProjectZhiChu;
+import org.jeecg.modules.Index.entity.dto.IndexInfoParamDto;
+import org.jeecg.modules.Index.entity.vo.IndexChartInfoVo;
+
+import java.time.LocalDate;
+import java.time.YearMonth;
+import java.util.List;
+
+/**
+ * @author dzc
+ * @date 2023/9/22 8:31
+ * @package org.jeecg.modules.Index.service
+ * @project yecai_server
+ * @des 领导驾驶舱支出模块
+ */
+public interface IndexZcbService {
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 获取 支出相关信息(给前端的数据) 的service方法
+    *   date: 2023/9/22
+    */
+    public List<ProjectZhiChu> getZhiChuTotalList();
+
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 获取 八项成本相关信息 的service方法
+    *   date: 2023/9/22
+    */
+    public List<IndexChartInfoVo> getEightCostsList(IndexInfoParamDto indexInfoParamDto);
+
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 指定日期范围内 八项成本各自之和 并排序
+     *   date: 2023/9/23
+     */
+    public List<EightCosts> getSumEightCosts(IndexInfoParamDto indexInfoParamDto);
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 获取日期范围内 有哪几年
+    *   date: 2023/9/22
+    */
+    public List<String> getYears(LocalDate startDate, LocalDate endDate);
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 获取日期范围内 有哪几个月
+    *   date: 2023/9/23
+    */
+    public List<YearMonth> getYearMonths(LocalDate startDate, LocalDate endDate);
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 格式化 前端传入的年 日期范围  2023 ---> 2023-01-01 00:00:00
+    *   date: 2023/9/23
+    */
+    public String getInitYear(String str);
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 格式化 前端传入的年月 日期范围 2023-09 ---> 2023-09-01 00:00:00
+    *   date: 2023/9/23
+    */
+    public String getInitYearMonth(String str);
+}

+ 443 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/service/impl/IndexZcbServiceImpl.java

@@ -0,0 +1,443 @@
+package org.jeecg.modules.Index.service.impl;
+
+import cn.hutool.core.util.ObjectUtil;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.subject.Subject;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.Index.entity.vo.EightCosts;
+import org.jeecg.modules.Index.entity.vo.ProjectZhiChu;
+import org.jeecg.modules.Index.entity.dto.IndexInfoParamDto;
+import org.jeecg.modules.Index.entity.vo.IndexChartInfoVo;
+import org.jeecg.modules.Index.mapper.IndexZcbMapper;
+import org.jeecg.modules.Index.service.IndexZcbService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.*;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author dzc
+ * @date 2023/9/22 8:32
+ * @package org.jeecg.modules.Index.service.impl
+ * @project yecai_server
+ * @des 支出模块实现类
+ */
+@Service
+public class IndexZcbServiceImpl implements IndexZcbService {
+
+    @Autowired
+    @SuppressWarnings("all")
+    private IndexZcbMapper indexZcbMapper;
+
+    @Autowired
+    @SuppressWarnings("all")
+    private RedisTemplate<String,String> redisTemplate;
+
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 获取 支出相关信息(给前端的数据) 的service方法
+     *   date: 2023/9/22
+     */
+    @Override
+    public List<ProjectZhiChu> getZhiChuTotalList() {
+
+        /**
+         * todo : (未做)需要剔除掉 redis缓存中存储的 组批任务的相关金额,查询出组批任务的任务号的list集合 在sql上用not in来实现
+         * */
+
+        //redisTemplate.opsForList().range("getZuPiList",0,-1);
+        ArrayList<ProjectZhiChu> projectZhiChusList = new ArrayList<>();
+        ProjectZhiChu projectZhiChu = new ProjectZhiChu();
+        //获取当前登录的用户名,根据用户名查询对应的部门
+        Subject subject = SecurityUtils.getSubject();
+        LoginUser loginUser = (LoginUser)subject.getPrincipal();
+        String username = loginUser.getUsername();
+        List<String> deptList = indexZcbMapper.getDepartByUsername(username);
+        //处理当前系统日期
+        SimpleDateFormat simpl = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        SimpleDateFormat simpl1 = new SimpleDateFormat("yyyy-MM");
+        String nowDate = DateUtils.date2Str(DateUtils.getDate(), simpl);
+        String nowMonth = DateUtils.date2Str(DateUtils.getDate(), simpl1);
+        int year = DateUtils.getYear();  // 当前年份
+        Calendar calendar1 = Calendar.getInstance();
+        calendar1.setTime(DateUtils.getDate());
+        calendar1.add(Calendar.MONTH,-1);
+        Date month = calendar1.getTime();
+        String sgyMonth = DateUtils.date2Str(month, simpl1); // 上个月
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(DateUtils.getDate());  //设置当前日期
+        calendar.add(Calendar.YEAR,-1); //将年份减去1
+        Date upDate = calendar.getTime(); // 去年同期
+        String upYearDateTq = DateUtils.date2Str(upDate, simpl); // 去年同期
+        String upYearMonthTq = DateUtils.date2Str(upDate, simpl1); // 去年同期月份
+        Calendar calendar2 = Calendar.getInstance();
+        calendar2.setTime(upDate);
+        calendar2.set(Calendar.MONDAY,Calendar.JANUARY);  //去年一月
+        calendar2.set(Calendar.DAY_OF_MONTH,1);           // 一日
+        calendar2.set(Calendar.HOUR_OF_DAY,0);            //零时
+        calendar2.set(Calendar.MINUTE,0);                 //零分
+        calendar2.set(Calendar.SECOND,0);                 //零秒
+        Date upDateFirst = calendar2.getTime();
+        String upYearDateFirstTq = DateUtils.date2Str(upDateFirst, simpl);
+
+        //查询当前年份的总成本
+        BigDecimal sumZcb = BigDecimal.valueOf(0);
+        BigDecimal a1 = indexZcbMapper.getZcbByXdDepartAndDate(deptList, String.valueOf(year));
+        BigDecimal a2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, String.valueOf(year));
+        if (!ObjectUtil.isEmpty(a1) && ObjectUtil.isEmpty(a2)){
+            // 如果根据责任部门没有查出来值 但 根据下达部门查询有值
+            sumZcb = a1.add(BigDecimal.valueOf(0));
+        }
+        if (ObjectUtil.isEmpty(a1) && !ObjectUtil.isEmpty(a2)){
+            // 如果根据责任部门查询有值,但根据下达部门没有值
+            sumZcb = a2.add(BigDecimal.valueOf(0));
+        }
+        if (!ObjectUtil.isEmpty(a1) && !ObjectUtil.isEmpty(a2)){
+            // 如果下达部门跟责任部门都查询出值时,就进行累加(据沈工所说同一条任务的这两个字段的部门名称不会是相同的)
+            sumZcb = a1.add(a2);
+        }
+        //上年同期支出
+        BigDecimal sumZcbTq = BigDecimal.valueOf(0);
+        BigDecimal b1 = indexZcbMapper.getZcbByXdDepartAndUpDate(deptList, upYearDateFirstTq, upYearDateTq);
+        BigDecimal b2 = indexZcbMapper.getZcbByZrDepartAndUpDate(deptList, upYearDateFirstTq, upYearDateTq);
+        if (!ObjectUtil.isEmpty(b1) && ObjectUtil.isEmpty(b2)){
+            // 如果根据责任部门没有查出来值 但 根据下达部门查询有值
+            sumZcbTq = b1.add(BigDecimal.valueOf(0));
+        }
+        if (ObjectUtil.isEmpty(b1) && !ObjectUtil.isEmpty(b2)){
+            // 如果根据责任部门查询有值,但根据下达部门没有值
+            sumZcbTq = b2.add(BigDecimal.valueOf(0));
+        }
+        if (!ObjectUtil.isEmpty(b1) && !ObjectUtil.isEmpty(b2)){
+            // 如果下达部门跟责任部门都查询出值时,就进行累加(据沈工所说同一条任务的这两个字段的部门名称不会是相同的)
+            sumZcbTq = b1.add(b2);
+        }
+
+        //当月支出 (今年当月的总成本)
+        BigDecimal sumZcbMonth = BigDecimal.valueOf(0);
+        BigDecimal c1 = indexZcbMapper.getZcbByXdDepartAndDate(deptList, nowMonth);
+        BigDecimal c2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, nowMonth);
+        if (!ObjectUtil.isEmpty(c1) && ObjectUtil.isEmpty(c2)){
+            // 如果根据责任部门没有查出来值 但 根据下达部门查询有值
+            sumZcbMonth = c1.add(BigDecimal.valueOf(0));
+        }
+        if (ObjectUtil.isEmpty(c1) && !ObjectUtil.isEmpty(c2)){
+            // 如果根据责任部门查询有值,但根据下达部门没有值
+            sumZcbMonth = c2.add(BigDecimal.valueOf(0));
+        }
+        if (!ObjectUtil.isEmpty(c1) && !ObjectUtil.isEmpty(c2)){
+            // 如果下达部门跟责任部门都查询出值时,就进行累加(据沈工所说同一条任务的这两个字段的部门名称不会是相同的)
+            sumZcbMonth = c1.add(c2);
+        }
+        //去年同期 (去年当前月份的总成本)
+        BigDecimal upYearTq = BigDecimal.valueOf(0);
+        BigDecimal e1 = indexZcbMapper.getZcbByXdDepartAndDate(deptList, upYearMonthTq);
+        BigDecimal e2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, upYearMonthTq);
+        if (!ObjectUtil.isEmpty(e1) && ObjectUtil.isEmpty(e2)){
+            // 如果根据责任部门没有查出来值 但 根据下达部门查询有值
+            upYearTq = e1.add(BigDecimal.valueOf(0));
+        }
+        if (ObjectUtil.isEmpty(e1) && !ObjectUtil.isEmpty(e2)){
+            // 如果根据责任部门查询有值,但根据下达部门没有值
+            upYearTq = e2.add(BigDecimal.valueOf(0));
+        }
+        if (!ObjectUtil.isEmpty(e1) && !ObjectUtil.isEmpty(e2)){
+            // 如果下达部门跟责任部门都查询出值时,就进行累加(据沈工所说同一条任务的这两个字段的部门名称不会是相同的)
+            upYearTq = e1.add(e2);
+        }
+        //今年上个月份的总成本
+        BigDecimal sgyMonthHb = BigDecimal.valueOf(0);
+        BigDecimal f1 = indexZcbMapper.getZcbByXdDepartAndDate(deptList, sgyMonth);
+        BigDecimal f2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, sgyMonth);
+        if (!ObjectUtil.isEmpty(f1) && ObjectUtil.isEmpty(f2)){
+            // 如果根据责任部门没有查出来值 但 根据下达部门查询有值
+            upYearTq = f1.add(BigDecimal.valueOf(0));
+        }
+        if (ObjectUtil.isEmpty(f1) && !ObjectUtil.isEmpty(f2)){
+            // 如果根据责任部门查询有值,但根据下达部门没有值
+            upYearTq = f2.add(BigDecimal.valueOf(0));
+        }
+        if (!ObjectUtil.isEmpty(f1) && !ObjectUtil.isEmpty(f2)){
+            // 如果下达部门跟责任部门都查询出值时,就进行累加(据沈工所说同一条任务的这两个字段的部门名称不会是相同的)
+            upYearTq = f1.add(f2);
+        }
+
+
+        //当月同比
+        BigDecimal zcbMonthTb;
+        if(upYearTq.compareTo(BigDecimal.valueOf(0)) == 0){
+            zcbMonthTb = BigDecimal.valueOf(1);
+        }else {
+            BigDecimal x1 = sumZcbMonth.subtract(upYearTq);
+            zcbMonthTb = x1.divide(upYearTq, 2, BigDecimal.ROUND_HALF_UP);
+        }
+
+        //当月环比
+        BigDecimal zcbMonthHb;
+        if (sgyMonthHb.compareTo(BigDecimal.valueOf(0)) == 0){
+            zcbMonthHb = BigDecimal.valueOf(1);
+        }else {
+            BigDecimal x2 = sumZcbMonth.subtract(sgyMonthHb);
+            zcbMonthHb = x2.divide(sgyMonthHb, 2, BigDecimal.ROUND_HALF_UP);
+        }
+
+        //同比增长率
+        BigDecimal zcbYearTb;
+        if (sumZcbTq.compareTo(BigDecimal.valueOf(0)) == 0){
+            zcbYearTb = BigDecimal.valueOf(1);
+        }else {
+            BigDecimal x3 = sumZcb.subtract(sumZcbTq);
+            zcbYearTb = x3.divide(sumZcbTq,2,BigDecimal.ROUND_HALF_UP);
+        }
+
+
+        projectZhiChu.setZhiChuYearTotal(sumZcb);//当年总收入
+        projectZhiChu.setZhiChuYearTq(sumZcbTq); //去年同期
+        projectZhiChu.setZhiChuMonthTotal(sumZcbMonth); //当月支出
+        projectZhiChu.setZhiChuMonthTb(zcbMonthTb); //当月同比
+        projectZhiChu.setZhiChuMonthHb(zcbMonthHb); //当月环比
+        projectZhiChu.setZhiChuYearTb(zcbYearTb); //同比增长率
+        projectZhiChusList.add(projectZhiChu);
+        return projectZhiChusList;
+    }
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 获取 八项成本相关信息 的service方法
+    *   date: 2023/9/22
+    */
+    @Override
+    public List<IndexChartInfoVo> getEightCostsList(IndexInfoParamDto indexInfoParamDto) {
+        //获取当前登录的用户名,根据用户名查询对应的部门
+        Subject subject = SecurityUtils.getSubject();
+        LoginUser loginUser = (LoginUser)subject.getPrincipal();
+        String username = loginUser.getUsername();
+        // 该用户的部门
+        List<String> deptList = indexZcbMapper.getDepartByUsername(username);
+        // 创建响应给前端的实体
+        ArrayList<IndexChartInfoVo> resultList = new ArrayList<>();
+        // 获取前端传过来的 开始日期 和 结束日期
+        String beginDateStr = indexInfoParamDto.getBeginDate();
+        String endDateStr = indexInfoParamDto.getEndDate();
+        SimpleDateFormat simpleDateFormatYear = new SimpleDateFormat("yyyy");
+        SimpleDateFormat simpleDateFormatYearMonth = new SimpleDateFormat("yyyy-MM");
+
+        // 各个年、月的总成本之和的集合(结果集合)
+        ArrayList<BigDecimal> zcbSumValueList = new ArrayList<>();
+        IndexChartInfoVo indexChartInfoVo = new IndexChartInfoVo();
+        // 如果前端传递过来的标记是 按年统计 则获取日期范围内所有的年份,遍历集合 分别查询各个年份下的总成本的和
+        if ("year".equals(indexInfoParamDto.getTime())){
+            Date beginDate = null;
+            Date endDate = null;
+            try {
+                beginDate = simpleDateFormatYear.parse(beginDateStr);
+                endDate = simpleDateFormatYear.parse(endDateStr);
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+            // 将Date类型的数据转换成 LocalDate类型
+            LocalDate beginLocalDate = beginDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+            LocalDate endLocalDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+            List<String> years = getYears(beginLocalDate, endLocalDate);
+            for (String year:years) {
+                BigDecimal zcbSumValue = BigDecimal.valueOf(0); // 默认值为0
+                BigDecimal b1 = indexZcbMapper.getZcbByXdDepartAndDate(deptList, year);
+                BigDecimal b2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, year);
+                if (!ObjectUtil.isEmpty(b1) && ObjectUtil.isEmpty(b2)){
+                    // 如果根据责任部门没有查出来值 但 根据下达部门查询有值
+                    zcbSumValue = b1.add(BigDecimal.valueOf(0));
+                }
+                if (ObjectUtil.isEmpty(b1) && !ObjectUtil.isEmpty(b2)){
+                    // 如果根据责任部门查询有值,但根据下达部门没有值
+                    zcbSumValue = b2.add(BigDecimal.valueOf(0));
+                }
+                if (!ObjectUtil.isEmpty(b1) && !ObjectUtil.isEmpty(b2)){
+                    // 如果下达部门跟责任部门都查询出值时,就进行累加(据沈工所说同一条任务的这两个字段的部门名称不会是相同的)
+                    zcbSumValue = b1.add(b2);
+                }
+                zcbSumValueList.add(zcbSumValue);
+            }
+
+
+            indexChartInfoVo.setSeriesData(zcbSumValueList);
+            indexChartInfoVo.setXAxisData(years);
+            resultList.add(indexChartInfoVo);
+        }
+
+        // 如果前端传递过来的标记是 按月统计 则获取日期范围内所有的月份,遍历集合 分别查询各个月份下的总成本之和
+        if ("month".equals(indexInfoParamDto.getTime())){
+            Date beginDate = null;
+            Date endDate = null;
+            try {
+                beginDate = simpleDateFormatYearMonth.parse(beginDateStr);
+                endDate = simpleDateFormatYearMonth.parse(endDateStr);
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+            // 将Date类型的数据转换成 LocalDate类型
+            LocalDate beginLocalDate = beginDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+            LocalDate endLocalDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+            List<YearMonth> yearMonths = getYearMonths(beginLocalDate, endLocalDate);
+            ArrayList<String> yearMonthList = new ArrayList<>();
+            for (YearMonth yearMonth : yearMonths) {
+                String yearsMonthI = yearMonth.format(DateTimeFormatter.ofPattern("yyyy-MM"));
+                BigDecimal zcbSumValue = BigDecimal.valueOf(0); // 默认值为0
+                BigDecimal b1 = indexZcbMapper.getZcbByXdDepartAndDate(deptList, yearsMonthI);
+                BigDecimal b2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, yearsMonthI);
+                if (!ObjectUtil.isEmpty(b1) && ObjectUtil.isEmpty(b2)){
+                    // 如果根据责任部门没有查出来值 但 根据下达部门查询有值
+                    zcbSumValue = b1.add(BigDecimal.valueOf(0));
+                }
+                if (ObjectUtil.isEmpty(b1) && !ObjectUtil.isEmpty(b2)){
+                    // 如果根据责任部门查询有值,但根据下达部门没有值
+                    zcbSumValue = b2.add(BigDecimal.valueOf(0));
+                }
+                if (!ObjectUtil.isEmpty(b1) && !ObjectUtil.isEmpty(b2)){
+                    // 如果下达部门跟责任部门都查询出值时,就进行累加(据沈工所说同一条任务的这两个字段的部门名称不会是相同的)
+                    zcbSumValue = b1.add(b2);
+                }
+                zcbSumValueList.add(zcbSumValue);
+                yearMonthList.add(yearsMonthI);
+            }
+            indexChartInfoVo.setSeriesData(zcbSumValueList);
+            indexChartInfoVo.setXAxisData(yearMonthList);
+            resultList.add(indexChartInfoVo);
+        }
+        return resultList;
+    }
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 指定日期范围内 八项成本各自之和 并排序
+    *   date: 2023/9/23
+    */
+    @Override
+    public List<EightCosts> getSumEightCosts(IndexInfoParamDto indexInfoParamDto) {
+        //获取当前登录的用户名,根据用户名查询对应的部门
+        Subject subject = SecurityUtils.getSubject();
+        LoginUser loginUser = (LoginUser)subject.getPrincipal();
+        String username = loginUser.getUsername();
+        // 该用户的部门
+        List<String> deptList = indexZcbMapper.getDepartByUsername(username);
+        // 创建响应给前端的实体
+        ArrayList<EightCosts> resultList = new ArrayList<>();
+        // 获取前端传过来的 开始日期 和 结束日期
+        String beginDateStr = indexInfoParamDto.getBeginDate();
+        String endDateStr = indexInfoParamDto.getEndDate();
+        if ("year".equals(indexInfoParamDto.getTime())){
+            String beginDate = getInitYear(beginDateStr);
+            String endDate = getInitYear(endDateStr);
+            List<EightCosts> e1 = indexZcbMapper.getEightCostXdDepartByDate(deptList, beginDate, endDate);
+            List<EightCosts> e2 = indexZcbMapper.getEightCostZrDepartByDate(deptList, beginDate, endDate);
+            if (e1.size() > 0 && e2.size() == 0){
+                resultList.addAll(e1);
+            }
+            if (e1.size() == 0 && e2.size() > 0){
+                resultList.addAll(e2);
+            }
+            if (e1.size() > 0 && e2.size() > 0){
+                ArrayList<EightCosts> eightCostsList = new ArrayList<>();
+                EightCosts eightCosts = new EightCosts();
+                for (int i = 0; i < e1.size(); i++) {
+                    EightCosts e1Cost = e1.get(i);
+                    EightCosts e2Cost = e2.get(i);
+                    eightCosts.setClf(e1Cost.getClf().add(e2Cost.getClf()));
+                    eightCosts.setZyf(e1Cost.getZyf().add(e2Cost.getZyf()));
+                    eightCosts.setSwf(e1Cost.getSwf().add(e2Cost.getSwf()));
+                    eightCosts.setWxf(e1Cost.getWxf().add(e2Cost.getWxf()));
+                    eightCosts.setRldlf(e1Cost.getRldlf().add(e2Cost.getRldlf()));
+                    eightCosts.setGdzczj(e1Cost.getGdzczj().add(e2Cost.getGdzczj()));
+                    eightCosts.setGzjlwf(e1Cost.getGzjlwf().add(e2Cost.getGzjlwf()));
+                    eightCosts.setGlf(e1Cost.getGlf().add(e2Cost.getGlf()));
+                    eightCostsList.add(eightCosts);
+                }
+                resultList.addAll(eightCostsList);
+            }
+        }
+        if ("month".equals(indexInfoParamDto.getTime())){
+
+        }
+
+        return resultList;
+    }
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 获取日期范围内 有哪几年
+    *   date: 2023/9/23
+    */
+    @Override
+    public List<String> getYears(LocalDate startDate, LocalDate endDate) {
+        List<String> year = new ArrayList<>();
+        int years = Period.between(startDate, endDate).getYears();  // 相差的年数
+        int startYear = startDate.getYear();  // 起始年
+        int endYear = endDate.getYear();      // 结束年
+        for (int i = startYear; i <= endYear; i++) {
+            year.add(String.valueOf(i));
+        }
+        return year;
+    }
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 获取日期范围内 有哪几个月
+    *   date: 2023/9/23
+    */
+    @Override
+    public List<YearMonth> getYearMonths(LocalDate startDate, LocalDate endDate) {
+        List<YearMonth> yearMonths = new ArrayList<>();
+        int years = Period.between(startDate, endDate).getYears();  // 起始日期与结束日期相差几年
+        int months = Period.between(startDate, endDate).getMonths();
+        YearMonth currentYearMonth = YearMonth.from(startDate);
+        for (int i = 0; i <= years; i++) {
+            int startMonth = (i == 0) ? startDate.getMonthValue() : 1;
+            int endMonth = (i == years) ? endDate.getMonthValue() : 12;
+            for (int j = startMonth; j <= endMonth; j++) {
+                yearMonths.add(currentYearMonth);
+                currentYearMonth = currentYearMonth.plusMonths(1);
+            }
+        }
+        return yearMonths;
+    }
+
+    /**
+    *   author: dzc
+    *   version: 1.0
+    *   des: 格式化 前端传入的年 日期范围  2023 ---> 2023-01-01 00:00:00
+    *   date: 2023/9/23
+    */
+    @Override
+    public String getInitYear(String str) {
+        LocalDateTime dateTime = LocalDateTime.of(Integer.parseInt(str), Month.JANUARY, 1, 0, 0, 0);
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String strDateTime = dateTime.format(formatter);
+        return strDateTime;
+    }
+
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 格式化 前端传入的年月 日期范围 2023-09 ---> 2023-09-01 00:00:00
+     *   date: 2023/9/23
+     */
+    @Override
+    public String getInitYearMonth(String str) {
+        String newDateStr = str+"-01 00:00:00";
+        return newDateStr;
+    }
+}