|
@@ -15,6 +15,7 @@ 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.jeecg.modules.Index.util.CommonMethod;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -53,6 +54,11 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
@SuppressWarnings("all")
|
|
|
private ISysBaseAPI iSysBaseAPI;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private CommonMethod commonMethod;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* author: dzc
|
|
|
* version: 1.0
|
|
@@ -74,7 +80,8 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
LoginUser loginUser = (LoginUser)subject.getPrincipal();
|
|
|
String username = loginUser.getUsername();
|
|
|
//获取当前用户的角色的集合 (一个用户可能会有多个角色)
|
|
|
- List<String> rolesList = iSysBaseAPI.getRoleIdsByUsername(username);
|
|
|
+ //List<String> rolesList = iSysBaseAPI.getRoleIdsByUsername(username);
|
|
|
+ String role = commonMethod.getRole(username);
|
|
|
// 根据用户名查询对应的部门
|
|
|
List<String> deptList = indexZcbMapper.getDepartByUsername(username);
|
|
|
//处理当前系统日期
|
|
@@ -106,7 +113,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
|
|
|
|
|
|
|
|
|
- if (rolesList.contains(AuthMark.BOSS)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
+ if (AuthMark.BOSS.equals(role)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
BigDecimal sumZcb = indexZcbMapper.getZcbByDate(String.valueOf(year), pcList);
|
|
|
if (ObjectUtil.isEmpty(sumZcb)){
|
|
|
sumZcb = BigDecimal.valueOf(0);
|
|
@@ -166,9 +173,8 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
projectZhiChusList.add(projectZhiChu);
|
|
|
|
|
|
}
|
|
|
- if (rolesList.contains(AuthMark.DEPT_LEADER)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
- //查询当前年份的总成本
|
|
|
- BigDecimal sumZcb = BigDecimal.valueOf(0);
|
|
|
+ if (AuthMark.DEPT_LEADER.equals(role)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
+ 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)){
|
|
@@ -286,7 +292,15 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
projectZhiChu.setYearTb(zcbYearTb); //同比增长率
|
|
|
projectZhiChusList.add(projectZhiChu);
|
|
|
}
|
|
|
-
|
|
|
+ if (role == null){ // 如果是空 就给0
|
|
|
+ projectZhiChu.setYearTotal(BigDecimal.valueOf(0));//当年总收入
|
|
|
+ projectZhiChu.setYearTq(BigDecimal.valueOf(0)); //去年同期
|
|
|
+ projectZhiChu.setMonthTotal(BigDecimal.valueOf(0)); //当月支出
|
|
|
+ projectZhiChu.setMonthTb(BigDecimal.valueOf(0)); //当月同比
|
|
|
+ projectZhiChu.setMonthHb(BigDecimal.valueOf(0)); //当月环比
|
|
|
+ projectZhiChu.setYearTb(BigDecimal.valueOf(0)); //同比增长率
|
|
|
+ projectZhiChusList.add(projectZhiChu);
|
|
|
+ }
|
|
|
|
|
|
return projectZhiChusList;
|
|
|
}
|
|
@@ -306,7 +320,8 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
LoginUser loginUser = (LoginUser)subject.getPrincipal();
|
|
|
String username = loginUser.getUsername();
|
|
|
//获取当前用户的角色的集合 (一个用户可能会有多个角色)
|
|
|
- List<String> rolesList = iSysBaseAPI.getRoleIdsByUsername(username);
|
|
|
+ //List<String> rolesList = iSysBaseAPI.getRoleIdsByUsername(username);
|
|
|
+ String role = commonMethod.getRole(username);
|
|
|
// 该用户的部门
|
|
|
List<String> deptList = indexZcbMapper.getDepartByUsername(username);
|
|
|
// 创建响应给前端的实体
|
|
@@ -336,13 +351,13 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
List<String> years = getYears(beginLocalDate, endLocalDate);
|
|
|
for (String year:years) {
|
|
|
BigDecimal zcbSumValue = BigDecimal.valueOf(0); // 默认值为0
|
|
|
- if (rolesList.contains(AuthMark.BOSS)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
+ if (AuthMark.BOSS.equals(role)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
zcbSumValue = indexZcbMapper.getZcbByDate(year,pcList);
|
|
|
if (ObjectUtil.isEmpty(zcbSumValue)) {
|
|
|
zcbSumValue = BigDecimal.valueOf(0);
|
|
|
}
|
|
|
}
|
|
|
- if (rolesList.contains(AuthMark.DEPT_LEADER)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
+ if (AuthMark.DEPT_LEADER.equals(role)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
BigDecimal b1 = indexZcbMapper.getZcbByXdDepartAndDate(deptList, year,pcList);
|
|
|
BigDecimal b2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, year,pcList);
|
|
|
if (!ObjectUtil.isEmpty(b1) && ObjectUtil.isEmpty(b2)){
|
|
@@ -358,6 +373,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
zcbSumValue = b1.add(b2);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
zcbSumValueList.add(zcbSumValue);
|
|
|
}
|
|
|
|
|
@@ -386,14 +402,14 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
String yearsMonthI = yearMonth.format(DateTimeFormatter.ofPattern("yyyy-MM"));
|
|
|
BigDecimal zcbSumValue = BigDecimal.valueOf(0); // 默认值为0
|
|
|
|
|
|
- if (rolesList.contains(AuthMark.BOSS)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
+ if (AuthMark.BOSS.equals(role)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
zcbSumValue = indexZcbMapper.getZcbByDate(yearsMonthI,pcList);
|
|
|
if (ObjectUtil.isEmpty(zcbSumValue)) {
|
|
|
zcbSumValue = BigDecimal.valueOf(0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (rolesList.contains(AuthMark.DEPT_LEADER)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
+ if (AuthMark.DEPT_LEADER.equals(role)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
BigDecimal b1 = indexZcbMapper.getZcbByXdDepartAndDate(deptList, yearsMonthI,pcList);
|
|
|
BigDecimal b2 = indexZcbMapper.getZcbByZrDepartAndDate(deptList, yearsMonthI,pcList);
|
|
|
if (!ObjectUtil.isEmpty(b1) && ObjectUtil.isEmpty(b2)){
|
|
@@ -435,7 +451,8 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
LoginUser loginUser = (LoginUser)subject.getPrincipal();
|
|
|
String username = loginUser.getUsername();
|
|
|
// 查询当前用户的角色id (一个用户可能对应多个角色)
|
|
|
- List<String> rolesList = iSysBaseAPI.getRoleIdsByUsername(username);
|
|
|
+ //List<String> rolesList = iSysBaseAPI.getRoleIdsByUsername(username);
|
|
|
+ String role = commonMethod.getRole(username);
|
|
|
// 该用户的部门
|
|
|
List<String> deptList = indexZcbMapper.getDepartByUsername(username);
|
|
|
// 创建响应给前端的实体
|
|
@@ -446,7 +463,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
if ("year".equals(indexInfoParamDto.getTime())){
|
|
|
String beginDate = getInitYear(beginDateStr);
|
|
|
String endDate = getInitYearAdd(endDateStr);
|
|
|
- if (rolesList.contains(AuthMark.BOSS)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
+ if (AuthMark.BOSS.equals(role)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
List<EightCosts> e1 = indexZcbMapper.getEightCostDepartByDate(beginDate, endDate, pcList);
|
|
|
if (!ObjectUtil.isEmpty(e1)){
|
|
|
HashMap<String, BigDecimal> m = new HashMap<>();
|
|
@@ -475,7 +492,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (rolesList.contains(AuthMark.DEPT_LEADER)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
+ if (AuthMark.DEPT_LEADER.equals(role)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
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){
|
|
@@ -570,12 +587,37 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (role == null){ // 如果是空 就给0
|
|
|
+ HashMap<String, BigDecimal> m = new HashMap<>();
|
|
|
+ m.put("clf",BigDecimal.valueOf(0));
|
|
|
+ m.put("zyf",BigDecimal.valueOf(0));
|
|
|
+ m.put("swf",BigDecimal.valueOf(0));
|
|
|
+ m.put("wxf",BigDecimal.valueOf(0));
|
|
|
+ m.put("rldlf",BigDecimal.valueOf(0));
|
|
|
+ m.put("gdzczj",BigDecimal.valueOf(0));
|
|
|
+ m.put("gzjlwf",BigDecimal.valueOf(0));
|
|
|
+ m.put("glf",BigDecimal.valueOf(0));
|
|
|
+
|
|
|
+ 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)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
+ if (AuthMark.BOSS.equals(role)){ // 如果当前用户角色是领导,则查询全部部门的总成本
|
|
|
List<EightCosts> e1 = indexZcbMapper.getEightCostDepartByDate(beginDate, endDate, pcList);
|
|
|
if (!ObjectUtil.isEmpty(e1)){
|
|
|
HashMap<String, BigDecimal> m = new HashMap<>();
|
|
@@ -603,7 +645,7 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (rolesList.contains(AuthMark.DEPT_LEADER)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
+ if (AuthMark.DEPT_LEADER.equals(role)){ // 如果当前用户角色是部门领导,则查询当前部门的总成本
|
|
|
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){
|
|
@@ -698,6 +740,31 @@ public class IndexZcbServiceImpl implements IndexZcbService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (role == null){ // 如果是空 就给0
|
|
|
+ HashMap<String, BigDecimal> m = new HashMap<>();
|
|
|
+ m.put("clf",BigDecimal.valueOf(0));
|
|
|
+ m.put("zyf",BigDecimal.valueOf(0));
|
|
|
+ m.put("swf",BigDecimal.valueOf(0));
|
|
|
+ m.put("wxf",BigDecimal.valueOf(0));
|
|
|
+ m.put("rldlf",BigDecimal.valueOf(0));
|
|
|
+ m.put("gdzczj",BigDecimal.valueOf(0));
|
|
|
+ m.put("gzjlwf",BigDecimal.valueOf(0));
|
|
|
+ m.put("glf",BigDecimal.valueOf(0));
|
|
|
+
|
|
|
+ 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;
|