|
@@ -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;
|
|
|
+ }
|
|
|
+}
|