|
@@ -3,14 +3,18 @@ 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.api.ISysBaseAPI;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
+import org.jeecg.common.util.RedisUtil;
|
|
|
+import org.jeecg.modules.Index.entity.vo.ResultEightCost;
|
|
|
import org.jeecg.modules.Index.entity.vo.EightCosts;
|
|
|
import org.jeecg.modules.Index.entity.vo.IndexTotalVo;
|
|
|
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.jeecg.modules.Index.util.AuthMark;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -20,10 +24,8 @@ 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;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author dzc
|
|
@@ -39,9 +41,17 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
@SuppressWarnings("all")
|
|
|
private IndexZcbMapper indexZcbMapper;
|
|
|
|
|
|
+ //@Autowired
|
|
|
+ //@SuppressWarnings("all")
|
|
|
+ //private RedisTemplate<String,String> redisTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private RedisUtil redisUtil;
|
|
|
+
|
|
|
@Autowired
|
|
|
@SuppressWarnings("all")
|
|
|
- private RedisTemplate<String,String> redisTemplate;
|
|
|
+ private ISysBaseAPI iSysBaseAPI;
|
|
|
|
|
|
/**
|
|
|
* author: dzc
|
|
@@ -53,16 +63,19 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
public List<IndexTotalVo> getZhiChuTotalList() {
|
|
|
|
|
|
/**
|
|
|
- * todo : (未做)需要剔除掉 redis缓存中存储的 组批任务的相关金额,查询出组批任务的任务号的list集合 在sql上用not in来实现
|
|
|
+ * todo : (已做)需要剔除掉 redis缓存中存储的 组批任务的相关金额,查询出组批任务的任务号的list集合 在sql上用not in来实现
|
|
|
* */
|
|
|
-
|
|
|
- //redisTemplate.opsForList().range("getZuPiList",0,-1);
|
|
|
ArrayList<IndexTotalVo> projectZhiChusList = new ArrayList<>();
|
|
|
IndexTotalVo projectZhiChu = new IndexTotalVo();
|
|
|
- //获取当前登录的用户名,根据用户名查询对应的部门
|
|
|
+ //从redis中取到所有的组批相关的任务号
|
|
|
+ List<String> pcList = (List<String>)redisUtil.get("pcList");
|
|
|
+ // 获取当前登录的用户名
|
|
|
Subject subject = SecurityUtils.getSubject();
|
|
|
LoginUser loginUser = (LoginUser)subject.getPrincipal();
|
|
|
String username = loginUser.getUsername();
|
|
|
+ //获取当前用户的角色的集合 (一个用户可能会有多个角色)
|
|
|
+ List<String> rolesList = iSysBaseAPI.getRoleIdsByUsername(username);
|
|
|
+ // 根据用户名查询对应的部门
|
|
|
List<String> deptList = indexZcbMapper.getDepartByUsername(username);
|
|
|
//处理当前系统日期
|
|
|
SimpleDateFormat simpl = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
@@ -89,126 +102,192 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
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);
|
|
|
- }
|
|
|
+ String upYearDateFirstTq = DateUtils.date2Str(upDateFirst, simpl); // 去年第一天零时零分零秒
|
|
|
|
|
|
- //当月支出 (今年当月的总成本)
|
|
|
- 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);
|
|
|
- }
|
|
|
+ if (rolesList.contains(AuthMark.BOSS)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
+ BigDecimal sumZcb = indexZcbMapper.getZcbByDate(String.valueOf(year), pcList);
|
|
|
+ if (ObjectUtil.isEmpty(sumZcb)){
|
|
|
+ sumZcb = BigDecimal.valueOf(0);
|
|
|
+ }
|
|
|
+ BigDecimal sumZcbTq = indexZcbMapper.getZcbByUpdate(upYearDateFirstTq, upYearDateTq, pcList);
|
|
|
+ if (ObjectUtil.isEmpty(sumZcbTq)){
|
|
|
+ sumZcbTq = BigDecimal.valueOf(0);
|
|
|
+ }
|
|
|
+ BigDecimal sumZcbMonth = indexZcbMapper.getZcbByDate(nowMonth, pcList);
|
|
|
+ if (ObjectUtil.isEmpty(sumZcbMonth)){
|
|
|
+ sumZcbMonth = BigDecimal.valueOf(0);
|
|
|
+ }
|
|
|
+ BigDecimal upYearTq = indexZcbMapper.getZcbByDate(upYearMonthTq, pcList);
|
|
|
+ if (ObjectUtil.isEmpty(upYearTq)){
|
|
|
+ upYearTq = BigDecimal.valueOf(0);
|
|
|
+ }
|
|
|
+ BigDecimal sgyMonthHb = indexZcbMapper.getZcbByDate(sgyMonth, pcList);
|
|
|
+ if (ObjectUtil.isEmpty(sgyMonthHb)){
|
|
|
+ sgyMonthHb = BigDecimal.valueOf(0);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //当月同比
|
|
|
+ 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.setYearTotal(sumZcb);//当年总收入
|
|
|
+ projectZhiChu.setYearTq(sumZcbTq); //去年同期
|
|
|
+ projectZhiChu.setMonthTotal(sumZcbMonth); //当月支出
|
|
|
+ projectZhiChu.setMonthTb(zcbMonthTb); //当月同比
|
|
|
+ projectZhiChu.setMonthHb(zcbMonthHb); //当月环比
|
|
|
+ projectZhiChu.setYearTb(zcbYearTb); //同比增长率
|
|
|
+ projectZhiChusList.add(projectZhiChu);
|
|
|
|
|
|
- //当月环比
|
|
|
- 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);
|
|
|
}
|
|
|
+ if (rolesList.contains(AuthMark.DEPT_LEADER)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
+ //查询当前年份的总成本
|
|
|
+ BigDecimal sumZcb = BigDecimal.valueOf(0);
|
|
|
+ BigDecimal a1 = indexZcbMapper.getZcbByXdDepartAndDate(deptList, String.valueOf(year),pcList);
|
|
|
+ BigDecimal a2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, String.valueOf(year),pcList);
|
|
|
+ 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,pcList);
|
|
|
+ BigDecimal b2 = indexZcbMapper.getZcbByZrDepartAndUpDate(deptList, upYearDateFirstTq, upYearDateTq,pcList);
|
|
|
+ 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,pcList);
|
|
|
+ BigDecimal c2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, nowMonth,pcList);
|
|
|
+ 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,pcList);
|
|
|
+ BigDecimal e2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, upYearMonthTq,pcList);
|
|
|
+ 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,pcList);
|
|
|
+ BigDecimal f2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, sgyMonth,pcList);
|
|
|
+ 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);
|
|
|
+ //同比增长率
|
|
|
+ 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.setYearTotal(sumZcb);//当年总收入
|
|
|
+ projectZhiChu.setYearTq(sumZcbTq); //去年同期
|
|
|
+ projectZhiChu.setMonthTotal(sumZcbMonth); //当月支出
|
|
|
+ projectZhiChu.setMonthTb(zcbMonthTb); //当月同比
|
|
|
+ projectZhiChu.setMonthHb(zcbMonthHb); //当月环比
|
|
|
+ projectZhiChu.setYearTb(zcbYearTb); //同比增长率
|
|
|
+ projectZhiChusList.add(projectZhiChu);
|
|
|
}
|
|
|
|
|
|
|
|
|
- projectZhiChu.setYearTotal(sumZcb);//当年总收入
|
|
|
- projectZhiChu.setYearTq(sumZcbTq); //去年同期
|
|
|
- projectZhiChu.setMonthTotal(sumZcbMonth); //当月支出
|
|
|
- projectZhiChu.setMonthTb(zcbMonthTb); //当月同比
|
|
|
- projectZhiChu.setMonthHb(zcbMonthHb); //当月环比
|
|
|
- projectZhiChu.setYearTb(zcbYearTb); //同比增长率
|
|
|
- projectZhiChusList.add(projectZhiChu);
|
|
|
return projectZhiChusList;
|
|
|
}
|
|
|
|
|
@@ -220,10 +299,14 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
*/
|
|
|
@Override
|
|
|
public List<IndexChartInfoVo> getEightCostsList(IndexInfoParamDto indexInfoParamDto) {
|
|
|
+ //获取redis中的组批任务号
|
|
|
+ List<String> pcList = (List<String>)redisUtil.get("pcList");
|
|
|
//获取当前登录的用户名,根据用户名查询对应的部门
|
|
|
Subject subject = SecurityUtils.getSubject();
|
|
|
LoginUser loginUser = (LoginUser)subject.getPrincipal();
|
|
|
String username = loginUser.getUsername();
|
|
|
+ //获取当前用户的角色的集合 (一个用户可能会有多个角色)
|
|
|
+ List<String> rolesList = iSysBaseAPI.getRoleIdsByUsername(username);
|
|
|
// 该用户的部门
|
|
|
List<String> deptList = indexZcbMapper.getDepartByUsername(username);
|
|
|
// 创建响应给前端的实体
|
|
@@ -253,19 +336,27 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
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 (rolesList.contains(AuthMark.BOSS)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
+ zcbSumValue = indexZcbMapper.getZcbByDate(year,pcList);
|
|
|
+ if (ObjectUtil.isEmpty(zcbSumValue)) {
|
|
|
+ zcbSumValue = BigDecimal.valueOf(0);
|
|
|
+ }
|
|
|
}
|
|
|
- if (!ObjectUtil.isEmpty(b1) && !ObjectUtil.isEmpty(b2)){
|
|
|
- // 如果下达部门跟责任部门都查询出值时,就进行累加(据沈工所说同一条任务的这两个字段的部门名称不会是相同的)
|
|
|
- zcbSumValue = b1.add(b2);
|
|
|
+ if (rolesList.contains(AuthMark.DEPT_LEADER)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
+ BigDecimal b1 = indexZcbMapper.getZcbByXdDepartAndDate(deptList, year,pcList);
|
|
|
+ BigDecimal b2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, year,pcList);
|
|
|
+ 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);
|
|
|
}
|
|
@@ -294,20 +385,31 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
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 (rolesList.contains(AuthMark.BOSS)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
+ zcbSumValue = indexZcbMapper.getZcbByDate(yearsMonthI,pcList);
|
|
|
+ if (ObjectUtil.isEmpty(zcbSumValue)) {
|
|
|
+ zcbSumValue = BigDecimal.valueOf(0);
|
|
|
+ }
|
|
|
}
|
|
|
- if (!ObjectUtil.isEmpty(b1) && !ObjectUtil.isEmpty(b2)){
|
|
|
- // 如果下达部门跟责任部门都查询出值时,就进行累加(据沈工所说同一条任务的这两个字段的部门名称不会是相同的)
|
|
|
- zcbSumValue = b1.add(b2);
|
|
|
+
|
|
|
+ if (rolesList.contains(AuthMark.DEPT_LEADER)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
+ BigDecimal b1 = indexZcbMapper.getZcbByXdDepartAndDate(deptList, yearsMonthI,pcList);
|
|
|
+ BigDecimal b2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, yearsMonthI,pcList);
|
|
|
+ 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);
|
|
|
}
|
|
@@ -325,52 +427,279 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
* date: 2023/9/23
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<EightCosts> getSumEightCosts(IndexInfoParamDto indexInfoParamDto) {
|
|
|
+ public List<ResultEightCost> getSumEightCosts(IndexInfoParamDto indexInfoParamDto) {
|
|
|
+ //获取redis中的组批任务号
|
|
|
+ List<String> pcList = (List<String>)redisUtil.get("pcList");
|
|
|
//获取当前登录的用户名,根据用户名查询对应的部门
|
|
|
Subject subject = SecurityUtils.getSubject();
|
|
|
LoginUser loginUser = (LoginUser)subject.getPrincipal();
|
|
|
String username = loginUser.getUsername();
|
|
|
+ // 查询当前用户的角色id (一个用户可能对应多个角色)
|
|
|
+ List<String> rolesList = iSysBaseAPI.getRoleIdsByUsername(username);
|
|
|
// 该用户的部门
|
|
|
List<String> deptList = indexZcbMapper.getDepartByUsername(username);
|
|
|
// 创建响应给前端的实体
|
|
|
- ArrayList<EightCosts> resultList = new ArrayList<>();
|
|
|
+ ArrayList<ResultEightCost> 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);
|
|
|
+ String endDate = getInitYearAdd(endDateStr);
|
|
|
+ if (rolesList.contains(AuthMark.BOSS)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
+ List<EightCosts> e1 = indexZcbMapper.getEightCostDepartByDate(beginDate, endDate, pcList);
|
|
|
+ if (!ObjectUtil.isEmpty(e1)){
|
|
|
+ HashMap<String, BigDecimal> m = new HashMap<>();
|
|
|
+ for (EightCosts e:e1) {
|
|
|
+ m.put("clf",e.getClf());
|
|
|
+ m.put("zyf",e.getZyf());
|
|
|
+ m.put("swf",e.getSwf());
|
|
|
+ m.put("wxf",e.getWxf());
|
|
|
+ m.put("rldlf",e.getRldlf());
|
|
|
+ m.put("gdzczj",e.getGdzczj());
|
|
|
+ m.put("gzjlwf",e.getGzjlwf());
|
|
|
+ m.put("glf",e.getGlf());
|
|
|
+ }
|
|
|
+ Map<String, BigDecimal> sortedMap = m.entrySet()
|
|
|
+ .stream()
|
|
|
+ .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
|
|
+ (oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
|
|
+
|
|
|
+ for (Map.Entry<String, BigDecimal> entry : sortedMap.entrySet()) {
|
|
|
+ ResultEightCost resultEightCost = new ResultEightCost();
|
|
|
+ resultEightCost.setName(entry.getKey());
|
|
|
+ resultEightCost.setValue(entry.getValue());
|
|
|
+ resultList.add(resultEightCost);
|
|
|
+ }
|
|
|
}
|
|
|
- resultList.addAll(eightCostsList);
|
|
|
}
|
|
|
+
|
|
|
+ if (rolesList.contains(AuthMark.DEPT_LEADER)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
+ List<EightCosts> e1 = indexZcbMapper.getEightCostXdDepartByDate(deptList, beginDate, endDate,pcList);
|
|
|
+ List<EightCosts> e2 = indexZcbMapper.getEightCostZrDepartByDate(deptList, beginDate, endDate,pcList);
|
|
|
+ if (e1.size() > 0 && e2.size() == 0){
|
|
|
+ HashMap<String, BigDecimal> m = new HashMap<>();
|
|
|
+ for (EightCosts e:e1) {
|
|
|
+ m.put("clf",e.getClf());
|
|
|
+ m.put("zyf",e.getZyf());
|
|
|
+ m.put("swf",e.getSwf());
|
|
|
+ m.put("wxf",e.getWxf());
|
|
|
+ m.put("rldlf",e.getRldlf());
|
|
|
+ m.put("gdzczj",e.getGdzczj());
|
|
|
+ m.put("gzjlwf",e.getGzjlwf());
|
|
|
+ m.put("glf",e.getGlf());
|
|
|
+ }
|
|
|
+ Map<String, BigDecimal> sortedMap = m.entrySet()
|
|
|
+ .stream()
|
|
|
+ .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
|
|
+ (oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
|
|
+
|
|
|
+ for (Map.Entry<String, BigDecimal> entry : sortedMap.entrySet()) {
|
|
|
+ ResultEightCost resultEightCost = new ResultEightCost();
|
|
|
+ resultEightCost.setName(entry.getKey());
|
|
|
+ resultEightCost.setValue(entry.getValue());
|
|
|
+ resultList.add(resultEightCost);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (e1.size() == 0 && e2.size() > 0){
|
|
|
+ HashMap<String, BigDecimal> m = new HashMap<>();
|
|
|
+ for (EightCosts e:e2) {
|
|
|
+ m.put("clf",e.getClf());
|
|
|
+ m.put("zyf",e.getZyf());
|
|
|
+ m.put("swf",e.getSwf());
|
|
|
+ m.put("wxf",e.getWxf());
|
|
|
+ m.put("rldlf",e.getRldlf());
|
|
|
+ m.put("gdzczj",e.getGdzczj());
|
|
|
+ m.put("gzjlwf",e.getGzjlwf());
|
|
|
+ m.put("glf",e.getGlf());
|
|
|
+ }
|
|
|
+ Map<String, BigDecimal> sortedMap = m.entrySet()
|
|
|
+ .stream()
|
|
|
+ .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
|
|
+ (oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
|
|
+
|
|
|
+ for (Map.Entry<String, BigDecimal> entry : sortedMap.entrySet()) {
|
|
|
+ ResultEightCost resultEightCost = new ResultEightCost();
|
|
|
+ resultEightCost.setName(entry.getKey());
|
|
|
+ resultEightCost.setValue(entry.getValue());
|
|
|
+ resultList.add(resultEightCost);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ HashMap<String, BigDecimal> m = new HashMap<>();
|
|
|
+ for (EightCosts e:eightCostsList) {
|
|
|
+ m.put("clf",e.getClf());
|
|
|
+ m.put("zyf",e.getZyf());
|
|
|
+ m.put("swf",e.getSwf());
|
|
|
+ m.put("wxf",e.getWxf());
|
|
|
+ m.put("rldlf",e.getRldlf());
|
|
|
+ m.put("gdzczj",e.getGdzczj());
|
|
|
+ m.put("gzjlwf",e.getGzjlwf());
|
|
|
+ m.put("glf",e.getGlf());
|
|
|
+ }
|
|
|
+ Map<String, BigDecimal> sortedMap = m.entrySet()
|
|
|
+ .stream()
|
|
|
+ .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
|
|
+ (oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
|
|
+
|
|
|
+ for (Map.Entry<String, BigDecimal> entry : sortedMap.entrySet()) {
|
|
|
+ ResultEightCost resultEightCost = new ResultEightCost();
|
|
|
+ resultEightCost.setName(entry.getKey());
|
|
|
+ resultEightCost.setValue(entry.getValue());
|
|
|
+ resultList.add(resultEightCost);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
if ("month".equals(indexInfoParamDto.getTime())){
|
|
|
+ String beginDate = getInitYearMonth(beginDateStr);
|
|
|
+ String endDate = getInitYearMonthAdd(endDateStr);
|
|
|
|
|
|
- }
|
|
|
+ if (rolesList.contains(AuthMark.BOSS)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
+ List<EightCosts> e1 = indexZcbMapper.getEightCostDepartByDate(beginDate, endDate, pcList);
|
|
|
+ if (!ObjectUtil.isEmpty(e1)){
|
|
|
+ HashMap<String, BigDecimal> m = new HashMap<>();
|
|
|
+ for (EightCosts e:e1) {
|
|
|
+ m.put("clf",e.getClf());
|
|
|
+ m.put("zyf",e.getZyf());
|
|
|
+ m.put("swf",e.getSwf());
|
|
|
+ m.put("wxf",e.getWxf());
|
|
|
+ m.put("rldlf",e.getRldlf());
|
|
|
+ m.put("gdzczj",e.getGdzczj());
|
|
|
+ m.put("gzjlwf",e.getGzjlwf());
|
|
|
+ m.put("glf",e.getGlf());
|
|
|
+ }
|
|
|
+ Map<String, BigDecimal> sortedMap = m.entrySet()
|
|
|
+ .stream()
|
|
|
+ .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
|
|
+ (oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
|
|
+
|
|
|
+ for (Map.Entry<String, BigDecimal> entry : sortedMap.entrySet()) {
|
|
|
+ ResultEightCost resultEightCost = new ResultEightCost();
|
|
|
+ resultEightCost.setName(entry.getKey());
|
|
|
+ resultEightCost.setValue(entry.getValue());
|
|
|
+ resultList.add(resultEightCost);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (rolesList.contains(AuthMark.DEPT_LEADER)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
+ List<EightCosts> e1 = indexZcbMapper.getEightCostXdDepartByDate(deptList, beginDate, endDate,pcList);
|
|
|
+ List<EightCosts> e2 = indexZcbMapper.getEightCostZrDepartByDate(deptList, beginDate, endDate,pcList);
|
|
|
+ if (e1.size() > 0 && e2.size() == 0){
|
|
|
+ HashMap<String, BigDecimal> m = new HashMap<>();
|
|
|
+ for (EightCosts e:e1) {
|
|
|
+ m.put("clf",e.getClf());
|
|
|
+ m.put("zyf",e.getZyf());
|
|
|
+ m.put("swf",e.getSwf());
|
|
|
+ m.put("wxf",e.getWxf());
|
|
|
+ m.put("rldlf",e.getRldlf());
|
|
|
+ m.put("gdzczj",e.getGdzczj());
|
|
|
+ m.put("gzjlwf",e.getGzjlwf());
|
|
|
+ m.put("glf",e.getGlf());
|
|
|
+ }
|
|
|
+ Map<String, BigDecimal> sortedMap = m.entrySet()
|
|
|
+ .stream()
|
|
|
+ .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
|
|
+ (oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
|
|
+
|
|
|
+ for (Map.Entry<String, BigDecimal> entry : sortedMap.entrySet()) {
|
|
|
+ ResultEightCost resultEightCost = new ResultEightCost();
|
|
|
+ resultEightCost.setName(entry.getKey());
|
|
|
+ resultEightCost.setValue(entry.getValue());
|
|
|
+ resultList.add(resultEightCost);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (e1.size() == 0 && e2.size() > 0){
|
|
|
+ HashMap<String, BigDecimal> m = new HashMap<>();
|
|
|
+ for (EightCosts e:e2) {
|
|
|
+ m.put("clf",e.getClf());
|
|
|
+ m.put("zyf",e.getZyf());
|
|
|
+ m.put("swf",e.getSwf());
|
|
|
+ m.put("wxf",e.getWxf());
|
|
|
+ m.put("rldlf",e.getRldlf());
|
|
|
+ m.put("gdzczj",e.getGdzczj());
|
|
|
+ m.put("gzjlwf",e.getGzjlwf());
|
|
|
+ m.put("glf",e.getGlf());
|
|
|
+ }
|
|
|
+ Map<String, BigDecimal> sortedMap = m.entrySet()
|
|
|
+ .stream()
|
|
|
+ .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
|
|
+ (oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
|
|
+
|
|
|
+ for (Map.Entry<String, BigDecimal> entry : sortedMap.entrySet()) {
|
|
|
+ ResultEightCost resultEightCost = new ResultEightCost();
|
|
|
+ resultEightCost.setName(entry.getKey());
|
|
|
+ resultEightCost.setValue(entry.getValue());
|
|
|
+ resultList.add(resultEightCost);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ HashMap<String, BigDecimal> m = new HashMap<>();
|
|
|
+ for (EightCosts e:eightCostsList) {
|
|
|
+ m.put("clf",e.getClf());
|
|
|
+ m.put("zyf",e.getZyf());
|
|
|
+ m.put("swf",e.getSwf());
|
|
|
+ m.put("wxf",e.getWxf());
|
|
|
+ m.put("rldlf",e.getRldlf());
|
|
|
+ m.put("gdzczj",e.getGdzczj());
|
|
|
+ m.put("gzjlwf",e.getGzjlwf());
|
|
|
+ m.put("glf",e.getGlf());
|
|
|
+ }
|
|
|
+ Map<String, BigDecimal> sortedMap = m.entrySet()
|
|
|
+ .stream()
|
|
|
+ .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
|
|
+ (oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
|
|
+
|
|
|
+ for (Map.Entry<String, BigDecimal> entry : sortedMap.entrySet()) {
|
|
|
+ ResultEightCost resultEightCost = new ResultEightCost();
|
|
|
+ resultEightCost.setName(entry.getKey());
|
|
|
+ resultEightCost.setValue(entry.getValue());
|
|
|
+ resultList.add(resultEightCost);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ }
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
@@ -432,6 +761,20 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
/**
|
|
|
* author: dzc
|
|
|
* version: 1.0
|
|
|
+ * des: 格式化 前端传入的年 日期范围 2023 ---> 2024-01-01 00:00:00
|
|
|
+ * date: 2023/9/23
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String getInitYearAdd(String str) {
|
|
|
+ LocalDateTime dateTime = LocalDateTime.of(Integer.parseInt(str)+1, 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
|
|
|
*/
|
|
@@ -440,4 +783,35 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
String newDateStr = str+"-01 00:00:00";
|
|
|
return newDateStr;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * author: dzc
|
|
|
+ * version: 1.0
|
|
|
+ * des: 格式化 前端传入的年月 日期范围 2023-09 ---> 2023-10-01 00:00:00
|
|
|
+ * date: 2023/9/23
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String getInitYearMonthAdd(String str) {
|
|
|
+ YearMonth yearMonth = YearMonth.parse(str, DateTimeFormatter.ofPattern("yyyy-MM"));
|
|
|
+ LocalDateTime dateTime = yearMonth.atDay(1).atStartOfDay();
|
|
|
+ dateTime = dateTime.plusMonths(1);
|
|
|
+ String outputDateTime = dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ return outputDateTime;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * author: dzc
|
|
|
+ * version: 1.0
|
|
|
+ * des: 获取项目成本表中的组批任务及其子任务的任务号
|
|
|
+ * date: 2023/9/24
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void getPcTasknoList() {
|
|
|
+ List<String> pcTasknoList = indexZcbMapper.getPcTasknoList();
|
|
|
+ List<String> pcTasknoSonList = indexZcbMapper.getPcTasknoSonList();
|
|
|
+ ArrayList<String> pcList = new ArrayList<>();
|
|
|
+ pcList.addAll(pcTasknoList);
|
|
|
+ pcList.addAll(pcTasknoSonList);
|
|
|
+ redisUtil.set("pcList",pcList,1000L * 60 * 60 * 2);
|
|
|
+ }
|
|
|
}
|