|
@@ -2,11 +2,16 @@ package org.jeecg.modules.Index.service.impl;
|
|
|
|
|
|
import javassist.expr.NewArray;
|
|
|
import org.apache.commons.collections4.comparators.NullComparator;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.modules.Index.entity.kpi.IndexKpiCompletByDate;
|
|
|
import org.jeecg.modules.Index.entity.kpi.IndexKpiDataDepart;
|
|
|
import org.jeecg.modules.Index.entity.kpi.IndexKpiParamDto;
|
|
|
import org.jeecg.modules.Index.mapper.IndexKpiMapper;
|
|
|
import org.jeecg.modules.Index.service.IndexKpiService;
|
|
|
+import org.jeecg.modules.Index.util.AuthMark;
|
|
|
+import org.jeecg.modules.Index.util.CommonMethod;
|
|
|
+import org.jeecg.modules.dataSourceSwitch.annotation.TargetDataSource;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -29,11 +34,16 @@ import java.util.concurrent.CompletableFuture;
|
|
|
* @Version 1.0
|
|
|
*/
|
|
|
@Service
|
|
|
+@TargetDataSource
|
|
|
public class IndexKpiServiceImpl implements IndexKpiService {
|
|
|
@Autowired
|
|
|
@SuppressWarnings("all")
|
|
|
private IndexKpiMapper indexKpiMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private CommonMethod commonMethod;
|
|
|
+
|
|
|
/**
|
|
|
* 工具类
|
|
|
* 根据日期字符串求上一个月的字符串
|
|
@@ -53,246 +63,246 @@ public class IndexKpiServiceImpl implements IndexKpiService {
|
|
|
*
|
|
|
* @return IndexKpiDataDepart
|
|
|
*/
|
|
|
- public IndexKpiDataDepart getCompletRateByDate(IndexKpiParamDto indexKpiParamDto){
|
|
|
- //初始化
|
|
|
- IndexKpiDataDepart indexKpiDataDepart = new IndexKpiDataDepart();
|
|
|
- List<IndexKpiCompletByDate> kpiDataZrbmList = new ArrayList<>();//责任部门排行
|
|
|
- List<IndexKpiCompletByDate> kpiDataJycsList = new ArrayList<>();//下达部门排行
|
|
|
- indexKpiDataDepart.setZrbmCharts(kpiDataZrbmList);//初始化放入空列表
|
|
|
- indexKpiDataDepart.setJycsCharts(kpiDataJycsList);
|
|
|
- //查询所有部门 将所有部门的指标和完成度赋为空,合同额和已收款赋为0
|
|
|
- List<String> departList = indexKpiMapper.getDepartName();
|
|
|
- System.out.println(departList);
|
|
|
- //此处是否需要去重???
|
|
|
- if(departList.isEmpty()) return indexKpiDataDepart;
|
|
|
- for(String depart:departList){
|
|
|
- IndexKpiCompletByDate indexKpiCompletByDate = new IndexKpiCompletByDate();
|
|
|
- indexKpiCompletByDate.setDepart(depart);
|
|
|
- indexKpiCompletByDate.setDepartKpi(null);
|
|
|
- indexKpiCompletByDate.setContractAmount(new BigDecimal(0));
|
|
|
- indexKpiCompletByDate.setReceived(new BigDecimal(0));
|
|
|
- indexKpiCompletByDate.setKpiCompletRate(null);
|
|
|
- IndexKpiCompletByDate indexKpiCompletByDate2 = new IndexKpiCompletByDate();
|
|
|
- indexKpiCompletByDate2.setDepart(depart);
|
|
|
- indexKpiCompletByDate2.setDepartKpi(null);
|
|
|
- indexKpiCompletByDate2.setContractAmount(new BigDecimal(0));
|
|
|
- indexKpiCompletByDate2.setReceived(new BigDecimal(0));
|
|
|
- indexKpiCompletByDate2.setKpiCompletRate(null);
|
|
|
- kpiDataZrbmList.add(indexKpiCompletByDate);
|
|
|
- kpiDataJycsList.add(indexKpiCompletByDate2);
|
|
|
- }
|
|
|
-// System.out.println(kpiDataZrbmList);
|
|
|
-// System.out.println(kpiDataJycsList);
|
|
|
- // TODO: 初始化结束
|
|
|
-
|
|
|
- //目前是算某个月的指标,不涉及范围
|
|
|
- //年/月
|
|
|
- String timeType = indexKpiParamDto.getTime();
|
|
|
- //日期
|
|
|
- String dateString = indexKpiParamDto.getBeginDate();
|
|
|
- /*
|
|
|
- //起始时间
|
|
|
- String startString = indexKpiParamDto.getBeginDate();
|
|
|
- //结束时间
|
|
|
- String endString = indexKpiParamDto.getEndDate();
|
|
|
- */
|
|
|
- //获取当前时间的年月
|
|
|
- LocalDate currentDate = LocalDate.now();
|
|
|
- // 获取当前年份
|
|
|
- int currentDateYear = currentDate.getYear();
|
|
|
- // 获取当前年月
|
|
|
- String currentYm = String.format("%d-%d", currentDateYear, currentDate.getMonthValue());
|
|
|
- //用来存放要看的年末或月末的年月日期 上一年末或上一月末的日期
|
|
|
- String dateYm = "";
|
|
|
- String dateLastYm = "";
|
|
|
- boolean isCurrentDate = true;//是否是当年或当月,当年或当月要从项目成本表中获取数据
|
|
|
-
|
|
|
- List<IndexKpiCompletByDate> kpiList = new ArrayList<>(); //用来保存部门指标表中的部门和指标
|
|
|
- List<IndexKpiCompletByDate> htereceivedZrbmList = new ArrayList<>();//用来保存部门该月合计的合同额、已收款以及责任部门
|
|
|
- List<IndexKpiCompletByDate> htereceivedJycsList = new ArrayList<>();//用来保存部门该月合计的合同额、已收款以及下达部门
|
|
|
- List<IndexKpiCompletByDate> htereceivedZrbmLastList = new ArrayList<>();//用来保存部门上月合计的合同额、已收款以及责任部门
|
|
|
- List<IndexKpiCompletByDate> htereceivedJycsLastList = new ArrayList<>();//用来保存部门上月合计的合同额、已收款以及下达部门
|
|
|
- try{
|
|
|
- if(timeType.equals("year")){
|
|
|
- isCurrentDate = dateString.equals(String.valueOf(currentDateYear));
|
|
|
- dateYm = String.format("%s-%d", currentDateYear, 12);
|
|
|
- dateLastYm = String.format("%d-%d", Integer.parseInt(dateString)-1, 12);
|
|
|
- }else if(timeType.equals("month")){
|
|
|
- isCurrentDate = dateString.equals(currentYm);
|
|
|
- dateYm = dateString;
|
|
|
- dateLastYm = getLastMonthString(currentYm);
|
|
|
- }
|
|
|
- }catch (ParseException e){
|
|
|
- System.out.println("部门指标排行传送的日期字符串错误!!!");
|
|
|
- return indexKpiDataDepart;
|
|
|
- }
|
|
|
-
|
|
|
- //获取部门指标数据 kpi
|
|
|
- boolean finalIsCurrentDate = isCurrentDate;
|
|
|
- String finalDateYm = dateYm;
|
|
|
- String finalDateLastYm = dateLastYm;
|
|
|
- CompletableFuture<List<IndexKpiCompletByDate>> getKpiListFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
- if(timeType.equals("year")){
|
|
|
- return indexKpiMapper.getKpiYear(Integer.parseInt(dateString));
|
|
|
- }else{
|
|
|
- return indexKpiMapper.getKpiMonth(dateString);
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- //获取选择年月的数据 合同额、已收款
|
|
|
- CompletableFuture<List<IndexKpiCompletByDate>> getHtereceivedZrbmListFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
- //如果选择的日期是当年当月,则从项目成本表里取数据,否则从每月月底项目进度考核表中取
|
|
|
- if(finalIsCurrentDate){
|
|
|
- return indexKpiMapper.getHteReceivedZrbmCost();
|
|
|
- }else{
|
|
|
- return indexKpiMapper.getHteReceivedZrbmYm(finalDateYm);
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- CompletableFuture<List<IndexKpiCompletByDate>> getHtereceivedJycsListFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
- //如果选择的日期是当年当月,则从项目成本表里取数据,否则从每月月底项目进度考核表中取
|
|
|
- if(finalIsCurrentDate){
|
|
|
- return indexKpiMapper.getHteReceivedJycsCost();
|
|
|
- }else{
|
|
|
- return indexKpiMapper.getHteReceivedJycsYm(finalDateYm);
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- //获取选择年月上月的数据 合同额、已收款
|
|
|
- CompletableFuture<List<IndexKpiCompletByDate>> getHtereceivedZrbmLastListFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
- return indexKpiMapper.getHteReceivedZrbmYm(finalDateLastYm);
|
|
|
- });
|
|
|
- CompletableFuture<List<IndexKpiCompletByDate>> getHtereceivedJycsLastListFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
- return indexKpiMapper.getHteReceivedJycsYm(finalDateLastYm);
|
|
|
- });
|
|
|
- CompletableFuture<Void> future1 = CompletableFuture.allOf(getKpiListFuture, getHtereceivedZrbmListFuture, getHtereceivedJycsListFuture, getHtereceivedZrbmLastListFuture, getHtereceivedJycsLastListFuture);
|
|
|
- future1.join();
|
|
|
- kpiList = getKpiListFuture.join();
|
|
|
- htereceivedZrbmList = getHtereceivedZrbmListFuture.join();
|
|
|
- htereceivedJycsList = getHtereceivedJycsListFuture.join();
|
|
|
- htereceivedZrbmLastList = getHtereceivedZrbmLastListFuture.join();
|
|
|
- htereceivedJycsLastList = getHtereceivedJycsLastListFuture.join();
|
|
|
-
|
|
|
- System.out.println(kpiList);
|
|
|
- System.out.println(htereceivedZrbmList);
|
|
|
- System.out.println(htereceivedJycsList);
|
|
|
- System.out.println(htereceivedZrbmLastList);
|
|
|
- System.out.println(htereceivedJycsLastList);
|
|
|
-
|
|
|
-
|
|
|
- List<IndexKpiCompletByDate> finalHtereceivedZrbmList = htereceivedZrbmList;
|
|
|
- List<IndexKpiCompletByDate> finalHtereceivedZrbmLastList = htereceivedZrbmLastList;
|
|
|
- List<IndexKpiCompletByDate> finalKpiList = kpiList;
|
|
|
- List<IndexKpiCompletByDate> finalHtereceivedJycsList = htereceivedJycsList;
|
|
|
- List<IndexKpiCompletByDate> finalHtereceivedJycsLastList = htereceivedJycsLastList;
|
|
|
- CompletableFuture<Void> setKpiDataZrbmList = CompletableFuture.runAsync(() -> {
|
|
|
- //责任部门列表计算合同额和已收款差额得到选择月份的合同额和已收款
|
|
|
- for(IndexKpiCompletByDate htereceivedZrbm: finalHtereceivedZrbmList){
|
|
|
- BigDecimal hteLast = new BigDecimal(0);
|
|
|
- BigDecimal receivedLast = new BigDecimal(0);
|
|
|
- for(IndexKpiCompletByDate htereceivedZrbmLast: finalHtereceivedZrbmLastList){
|
|
|
- if(htereceivedZrbm.getDepart().equals(htereceivedZrbmLast.getDepart())){
|
|
|
- hteLast = htereceivedZrbmLast.getContractAmount();
|
|
|
- receivedLast = htereceivedZrbmLast.getReceived();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- htereceivedZrbm.setContractAmount(htereceivedZrbm.getContractAmount().subtract(hteLast));
|
|
|
- htereceivedZrbm.setReceived(htereceivedZrbm.getReceived().subtract(receivedLast));
|
|
|
- }
|
|
|
-// System.out.println(finalHtereceivedZrbmList);
|
|
|
- //责任部门列表填充kpi
|
|
|
- for(IndexKpiCompletByDate kpiDataZrbm:kpiDataZrbmList){
|
|
|
- //根据部门输入部门指标
|
|
|
- for(IndexKpiCompletByDate kpiDepart: finalKpiList){
|
|
|
- if(kpiDataZrbm.getDepart().equals(kpiDepart.getDepart())){
|
|
|
- kpiDataZrbm.setDepartKpi(kpiDepart.getDepartKpi());
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //责任部门列表填充合同额、已收款、完成度
|
|
|
- for(IndexKpiCompletByDate kpiDataZrbm2:kpiDataZrbmList){
|
|
|
- for(IndexKpiCompletByDate htereceivedZrbm: finalHtereceivedZrbmList){
|
|
|
- if(kpiDataZrbm2.getDepart().equals(htereceivedZrbm.getDepart())){
|
|
|
- kpiDataZrbm2.setContractAmount(htereceivedZrbm.getContractAmount());//合同额
|
|
|
- kpiDataZrbm2.setReceived(htereceivedZrbm.getReceived());//已收款
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //计算完成度 合同额(是计算的某个月或某个年的合同额 增量)/ 指标
|
|
|
- if(kpiDataZrbm2.getDepartKpi() != null){
|
|
|
- if(kpiDataZrbm2.getDepartKpi().equals(BigDecimal.valueOf(0))){
|
|
|
- kpiDataZrbm2.setKpiCompletRate(BigDecimal.valueOf(1));
|
|
|
- }else{
|
|
|
- kpiDataZrbm2.setKpiCompletRate(kpiDataZrbm2.getContractAmount().divide(kpiDataZrbm2.getDepartKpi(), 2, RoundingMode.HALF_UP));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-// System.out.println("kpiDataZrbmList");
|
|
|
- //责任部门指标完成度排序
|
|
|
- kpiDataZrbmList.sort(Comparator.comparing(IndexKpiCompletByDate::getKpiCompletRate, Comparator.nullsFirst(BigDecimal::compareTo)).reversed());
|
|
|
-// System.out.println(kpiDataZrbmList);
|
|
|
- });
|
|
|
- CompletableFuture<Void> setKpiDataJycsList = CompletableFuture.runAsync(() -> {
|
|
|
- //下达部门列表计算合同额和已收款差额得到选择月份的合同额和已收款
|
|
|
- for(IndexKpiCompletByDate htereceivedJycs: finalHtereceivedJycsList){
|
|
|
- BigDecimal hteLast = new BigDecimal(0);
|
|
|
- BigDecimal receivedLast = new BigDecimal(0);
|
|
|
- for(IndexKpiCompletByDate htereceivedJycsLast: finalHtereceivedJycsLastList){
|
|
|
- if(htereceivedJycs.getDepart().equals(htereceivedJycsLast.getDepart())){
|
|
|
- hteLast = htereceivedJycsLast.getContractAmount();
|
|
|
- receivedLast = htereceivedJycsLast.getReceived();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- htereceivedJycs.setContractAmount(htereceivedJycs.getContractAmount().subtract(hteLast));
|
|
|
- htereceivedJycs.setReceived(htereceivedJycs.getReceived().subtract(receivedLast));
|
|
|
- }
|
|
|
-// System.out.println(finalHtereceivedJycsList);
|
|
|
- //下达部门列表填充kpi
|
|
|
- for(IndexKpiCompletByDate kpiDataJycs:kpiDataJycsList){
|
|
|
- //根据部门输入部门指标
|
|
|
- for(IndexKpiCompletByDate kpiDepart: finalKpiList){
|
|
|
- if(kpiDataJycs.getDepart().equals(kpiDepart.getDepart())){
|
|
|
- kpiDataJycs.setDepartKpi(kpiDepart.getDepartKpi());
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //下达部门列表填充合同额、已收款、完成度
|
|
|
- for(IndexKpiCompletByDate kpiDataJycs2:kpiDataJycsList){
|
|
|
- for(IndexKpiCompletByDate htereceivedJycs: finalHtereceivedJycsList){
|
|
|
- if(kpiDataJycs2.getDepart().equals(htereceivedJycs.getDepart())){
|
|
|
- kpiDataJycs2.setContractAmount(htereceivedJycs.getContractAmount());//合同额
|
|
|
- kpiDataJycs2.setReceived(htereceivedJycs.getReceived());//已收款
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //计算完成度 合同额(是计算的某个月或某个年的合同额 增量)/ 指标
|
|
|
- if(kpiDataJycs2.getDepartKpi() != null){
|
|
|
- if(kpiDataJycs2.getDepartKpi().equals(BigDecimal.valueOf(0))){
|
|
|
- kpiDataJycs2.setKpiCompletRate(BigDecimal.valueOf(1));
|
|
|
- }else{
|
|
|
- kpiDataJycs2.setKpiCompletRate(kpiDataJycs2.getContractAmount().divide(kpiDataJycs2.getDepartKpi(), 2, RoundingMode.HALF_UP));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-// System.out.println(kpiDataJycsList);
|
|
|
- //下达部门指标完成度排序
|
|
|
- kpiDataJycsList.sort(Comparator.comparing(IndexKpiCompletByDate::getKpiCompletRate, Comparator.nullsFirst(BigDecimal::compareTo)).reversed());
|
|
|
-// System.out.println(kpiDataJycsList);
|
|
|
- });
|
|
|
- CompletableFuture<Void> future2 = CompletableFuture.allOf(setKpiDataZrbmList, setKpiDataJycsList);
|
|
|
- future2.join();
|
|
|
-// System.out.println(kpiDataZrbmList);
|
|
|
-// System.out.println(kpiDataJycsList);
|
|
|
- indexKpiDataDepart.setZrbmCharts(kpiDataZrbmList);
|
|
|
- indexKpiDataDepart.setJycsCharts(kpiDataJycsList);
|
|
|
-
|
|
|
- return indexKpiDataDepart;
|
|
|
- }
|
|
|
+// public IndexKpiDataDepart getCompletRateByDate(IndexKpiParamDto indexKpiParamDto){
|
|
|
+// //初始化
|
|
|
+// IndexKpiDataDepart indexKpiDataDepart = new IndexKpiDataDepart();
|
|
|
+// List<IndexKpiCompletByDate> kpiDataZrbmList = new ArrayList<>();//责任部门排行
|
|
|
+// List<IndexKpiCompletByDate> kpiDataJycsList = new ArrayList<>();//下达部门排行
|
|
|
+// indexKpiDataDepart.setZrbmCharts(kpiDataZrbmList);//初始化放入空列表
|
|
|
+// indexKpiDataDepart.setJycsCharts(kpiDataJycsList);
|
|
|
+// //查询所有部门 将所有部门的指标和完成度赋为空,合同额和已收款赋为0
|
|
|
+// List<String> departList = indexKpiMapper.getDepartName();
|
|
|
+// System.out.println(departList);
|
|
|
+// //此处是否需要去重???
|
|
|
+// if(departList.isEmpty()) return indexKpiDataDepart;
|
|
|
+// for(String depart:departList){
|
|
|
+// IndexKpiCompletByDate indexKpiCompletByDate = new IndexKpiCompletByDate();
|
|
|
+// indexKpiCompletByDate.setDepart(depart);
|
|
|
+// indexKpiCompletByDate.setDepartKpi(null);
|
|
|
+// indexKpiCompletByDate.setContractAmount(new BigDecimal(0));
|
|
|
+// indexKpiCompletByDate.setReceived(new BigDecimal(0));
|
|
|
+// indexKpiCompletByDate.setKpiCompletRate(null);
|
|
|
+// IndexKpiCompletByDate indexKpiCompletByDate2 = new IndexKpiCompletByDate();
|
|
|
+// indexKpiCompletByDate2.setDepart(depart);
|
|
|
+// indexKpiCompletByDate2.setDepartKpi(null);
|
|
|
+// indexKpiCompletByDate2.setContractAmount(new BigDecimal(0));
|
|
|
+// indexKpiCompletByDate2.setReceived(new BigDecimal(0));
|
|
|
+// indexKpiCompletByDate2.setKpiCompletRate(null);
|
|
|
+// kpiDataZrbmList.add(indexKpiCompletByDate);
|
|
|
+// kpiDataJycsList.add(indexKpiCompletByDate2);
|
|
|
+// }
|
|
|
+//// System.out.println(kpiDataZrbmList);
|
|
|
+//// System.out.println(kpiDataJycsList);
|
|
|
+// // TODO: 初始化结束
|
|
|
+//
|
|
|
+// //目前是算某个月的指标,不涉及范围
|
|
|
+// //年/月
|
|
|
+// String timeType = indexKpiParamDto.getTime();
|
|
|
+// //日期
|
|
|
+// String dateString = indexKpiParamDto.getBeginDate();
|
|
|
+// /*
|
|
|
+// //起始时间
|
|
|
+// String startString = indexKpiParamDto.getBeginDate();
|
|
|
+// //结束时间
|
|
|
+// String endString = indexKpiParamDto.getEndDate();
|
|
|
+// */
|
|
|
+// //获取当前时间的年月
|
|
|
+// LocalDate currentDate = LocalDate.now();
|
|
|
+// // 获取当前年份
|
|
|
+// int currentDateYear = currentDate.getYear();
|
|
|
+// // 获取当前年月
|
|
|
+// String currentYm = String.format("%d-%d", currentDateYear, currentDate.getMonthValue());
|
|
|
+// //用来存放要看的年末或月末的年月日期 上一年末或上一月末的日期
|
|
|
+// String dateYm = "";
|
|
|
+// String dateLastYm = "";
|
|
|
+// boolean isCurrentDate = true;//是否是当年或当月,当年或当月要从项目成本表中获取数据
|
|
|
+//
|
|
|
+// List<IndexKpiCompletByDate> kpiList = new ArrayList<>(); //用来保存部门指标表中的部门和指标
|
|
|
+// List<IndexKpiCompletByDate> htereceivedZrbmList = new ArrayList<>();//用来保存部门该月合计的合同额、已收款以及责任部门
|
|
|
+// List<IndexKpiCompletByDate> htereceivedJycsList = new ArrayList<>();//用来保存部门该月合计的合同额、已收款以及下达部门
|
|
|
+// List<IndexKpiCompletByDate> htereceivedZrbmLastList = new ArrayList<>();//用来保存部门上月合计的合同额、已收款以及责任部门
|
|
|
+// List<IndexKpiCompletByDate> htereceivedJycsLastList = new ArrayList<>();//用来保存部门上月合计的合同额、已收款以及下达部门
|
|
|
+// try{
|
|
|
+// if(timeType.equals("year")){
|
|
|
+// isCurrentDate = dateString.equals(String.valueOf(currentDateYear));
|
|
|
+// dateYm = String.format("%s-%d", currentDateYear, 12);
|
|
|
+// dateLastYm = String.format("%d-%d", Integer.parseInt(dateString)-1, 12);
|
|
|
+// }else if(timeType.equals("month")){
|
|
|
+// isCurrentDate = dateString.equals(currentYm);
|
|
|
+// dateYm = dateString;
|
|
|
+// dateLastYm = getLastMonthString(currentYm);
|
|
|
+// }
|
|
|
+// }catch (ParseException e){
|
|
|
+// System.out.println("部门指标排行传送的日期字符串错误!!!");
|
|
|
+// return indexKpiDataDepart;
|
|
|
+// }
|
|
|
+//
|
|
|
+// //获取部门指标数据 kpi
|
|
|
+// boolean finalIsCurrentDate = isCurrentDate;
|
|
|
+// String finalDateYm = dateYm;
|
|
|
+// String finalDateLastYm = dateLastYm;
|
|
|
+// CompletableFuture<List<IndexKpiCompletByDate>> getKpiListFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+// if(timeType.equals("year")){
|
|
|
+// return indexKpiMapper.getKpiYear(Integer.parseInt(dateString));
|
|
|
+// }else{
|
|
|
+// return indexKpiMapper.getKpiMonth(dateString);
|
|
|
+// }
|
|
|
+//
|
|
|
+// });
|
|
|
+// //获取选择年月的数据 合同额、已收款
|
|
|
+// CompletableFuture<List<IndexKpiCompletByDate>> getHtereceivedZrbmListFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+// //如果选择的日期是当年当月,则从项目成本表里取数据,否则从每月月底项目进度考核表中取
|
|
|
+// if(finalIsCurrentDate){
|
|
|
+// return indexKpiMapper.getHteReceivedZrbmCost();
|
|
|
+// }else{
|
|
|
+// return indexKpiMapper.getHteReceivedZrbmYm(finalDateYm);
|
|
|
+// }
|
|
|
+//
|
|
|
+// });
|
|
|
+// CompletableFuture<List<IndexKpiCompletByDate>> getHtereceivedJycsListFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+// //如果选择的日期是当年当月,则从项目成本表里取数据,否则从每月月底项目进度考核表中取
|
|
|
+// if(finalIsCurrentDate){
|
|
|
+// return indexKpiMapper.getHteReceivedJycsCost();
|
|
|
+// }else{
|
|
|
+// return indexKpiMapper.getHteReceivedJycsYm(finalDateYm);
|
|
|
+// }
|
|
|
+//
|
|
|
+// });
|
|
|
+// //获取选择年月上月的数据 合同额、已收款
|
|
|
+// CompletableFuture<List<IndexKpiCompletByDate>> getHtereceivedZrbmLastListFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+// return indexKpiMapper.getHteReceivedZrbmYm(finalDateLastYm);
|
|
|
+// });
|
|
|
+// CompletableFuture<List<IndexKpiCompletByDate>> getHtereceivedJycsLastListFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+// return indexKpiMapper.getHteReceivedJycsYm(finalDateLastYm);
|
|
|
+// });
|
|
|
+// CompletableFuture<Void> future1 = CompletableFuture.allOf(getKpiListFuture, getHtereceivedZrbmListFuture, getHtereceivedJycsListFuture, getHtereceivedZrbmLastListFuture, getHtereceivedJycsLastListFuture);
|
|
|
+// future1.join();
|
|
|
+// kpiList = getKpiListFuture.join();
|
|
|
+// htereceivedZrbmList = getHtereceivedZrbmListFuture.join();
|
|
|
+// htereceivedJycsList = getHtereceivedJycsListFuture.join();
|
|
|
+// htereceivedZrbmLastList = getHtereceivedZrbmLastListFuture.join();
|
|
|
+// htereceivedJycsLastList = getHtereceivedJycsLastListFuture.join();
|
|
|
+//
|
|
|
+// System.out.println(kpiList);
|
|
|
+// System.out.println(htereceivedZrbmList);
|
|
|
+// System.out.println(htereceivedJycsList);
|
|
|
+// System.out.println(htereceivedZrbmLastList);
|
|
|
+// System.out.println(htereceivedJycsLastList);
|
|
|
+//
|
|
|
+//
|
|
|
+// List<IndexKpiCompletByDate> finalHtereceivedZrbmList = htereceivedZrbmList;
|
|
|
+// List<IndexKpiCompletByDate> finalHtereceivedZrbmLastList = htereceivedZrbmLastList;
|
|
|
+// List<IndexKpiCompletByDate> finalKpiList = kpiList;
|
|
|
+// List<IndexKpiCompletByDate> finalHtereceivedJycsList = htereceivedJycsList;
|
|
|
+// List<IndexKpiCompletByDate> finalHtereceivedJycsLastList = htereceivedJycsLastList;
|
|
|
+// CompletableFuture<Void> setKpiDataZrbmList = CompletableFuture.runAsync(() -> {
|
|
|
+// //责任部门列表计算合同额和已收款差额得到选择月份的合同额和已收款
|
|
|
+// for(IndexKpiCompletByDate htereceivedZrbm: finalHtereceivedZrbmList){
|
|
|
+// BigDecimal hteLast = new BigDecimal(0);
|
|
|
+// BigDecimal receivedLast = new BigDecimal(0);
|
|
|
+// for(IndexKpiCompletByDate htereceivedZrbmLast: finalHtereceivedZrbmLastList){
|
|
|
+// if(htereceivedZrbm.getDepart().equals(htereceivedZrbmLast.getDepart())){
|
|
|
+// hteLast = htereceivedZrbmLast.getContractAmount();
|
|
|
+// receivedLast = htereceivedZrbmLast.getReceived();
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// htereceivedZrbm.setContractAmount(htereceivedZrbm.getContractAmount().subtract(hteLast));
|
|
|
+// htereceivedZrbm.setReceived(htereceivedZrbm.getReceived().subtract(receivedLast));
|
|
|
+// }
|
|
|
+//// System.out.println(finalHtereceivedZrbmList);
|
|
|
+// //责任部门列表填充kpi
|
|
|
+// for(IndexKpiCompletByDate kpiDataZrbm:kpiDataZrbmList){
|
|
|
+// //根据部门输入部门指标
|
|
|
+// for(IndexKpiCompletByDate kpiDepart: finalKpiList){
|
|
|
+// if(kpiDataZrbm.getDepart().equals(kpiDepart.getDepart())){
|
|
|
+// kpiDataZrbm.setDepartKpi(kpiDepart.getDepartKpi());
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //责任部门列表填充合同额、已收款、完成度
|
|
|
+// for(IndexKpiCompletByDate kpiDataZrbm2:kpiDataZrbmList){
|
|
|
+// for(IndexKpiCompletByDate htereceivedZrbm: finalHtereceivedZrbmList){
|
|
|
+// if(kpiDataZrbm2.getDepart().equals(htereceivedZrbm.getDepart())){
|
|
|
+// kpiDataZrbm2.setContractAmount(htereceivedZrbm.getContractAmount());//合同额
|
|
|
+// kpiDataZrbm2.setReceived(htereceivedZrbm.getReceived());//已收款
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //计算完成度 合同额(是计算的某个月或某个年的合同额 增量)/ 指标
|
|
|
+// if(kpiDataZrbm2.getDepartKpi() != null){
|
|
|
+// if(kpiDataZrbm2.getDepartKpi().equals(BigDecimal.valueOf(0))){
|
|
|
+// kpiDataZrbm2.setKpiCompletRate(BigDecimal.valueOf(1));
|
|
|
+// }else{
|
|
|
+// kpiDataZrbm2.setKpiCompletRate(kpiDataZrbm2.getContractAmount().divide(kpiDataZrbm2.getDepartKpi(), 2, RoundingMode.HALF_UP));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//// System.out.println("kpiDataZrbmList");
|
|
|
+// //责任部门指标完成度排序
|
|
|
+// kpiDataZrbmList.sort(Comparator.comparing(IndexKpiCompletByDate::getKpiCompletRate, Comparator.nullsFirst(BigDecimal::compareTo)).reversed());
|
|
|
+//// System.out.println(kpiDataZrbmList);
|
|
|
+// });
|
|
|
+// CompletableFuture<Void> setKpiDataJycsList = CompletableFuture.runAsync(() -> {
|
|
|
+// //下达部门列表计算合同额和已收款差额得到选择月份的合同额和已收款
|
|
|
+// for(IndexKpiCompletByDate htereceivedJycs: finalHtereceivedJycsList){
|
|
|
+// BigDecimal hteLast = new BigDecimal(0);
|
|
|
+// BigDecimal receivedLast = new BigDecimal(0);
|
|
|
+// for(IndexKpiCompletByDate htereceivedJycsLast: finalHtereceivedJycsLastList){
|
|
|
+// if(htereceivedJycs.getDepart().equals(htereceivedJycsLast.getDepart())){
|
|
|
+// hteLast = htereceivedJycsLast.getContractAmount();
|
|
|
+// receivedLast = htereceivedJycsLast.getReceived();
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// htereceivedJycs.setContractAmount(htereceivedJycs.getContractAmount().subtract(hteLast));
|
|
|
+// htereceivedJycs.setReceived(htereceivedJycs.getReceived().subtract(receivedLast));
|
|
|
+// }
|
|
|
+//// System.out.println(finalHtereceivedJycsList);
|
|
|
+// //下达部门列表填充kpi
|
|
|
+// for(IndexKpiCompletByDate kpiDataJycs:kpiDataJycsList){
|
|
|
+// //根据部门输入部门指标
|
|
|
+// for(IndexKpiCompletByDate kpiDepart: finalKpiList){
|
|
|
+// if(kpiDataJycs.getDepart().equals(kpiDepart.getDepart())){
|
|
|
+// kpiDataJycs.setDepartKpi(kpiDepart.getDepartKpi());
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //下达部门列表填充合同额、已收款、完成度
|
|
|
+// for(IndexKpiCompletByDate kpiDataJycs2:kpiDataJycsList){
|
|
|
+// for(IndexKpiCompletByDate htereceivedJycs: finalHtereceivedJycsList){
|
|
|
+// if(kpiDataJycs2.getDepart().equals(htereceivedJycs.getDepart())){
|
|
|
+// kpiDataJycs2.setContractAmount(htereceivedJycs.getContractAmount());//合同额
|
|
|
+// kpiDataJycs2.setReceived(htereceivedJycs.getReceived());//已收款
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //计算完成度 合同额(是计算的某个月或某个年的合同额 增量)/ 指标
|
|
|
+// if(kpiDataJycs2.getDepartKpi() != null){
|
|
|
+// if(kpiDataJycs2.getDepartKpi().equals(BigDecimal.valueOf(0))){
|
|
|
+// kpiDataJycs2.setKpiCompletRate(BigDecimal.valueOf(1));
|
|
|
+// }else{
|
|
|
+// kpiDataJycs2.setKpiCompletRate(kpiDataJycs2.getContractAmount().divide(kpiDataJycs2.getDepartKpi(), 2, RoundingMode.HALF_UP));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//// System.out.println(kpiDataJycsList);
|
|
|
+// //下达部门指标完成度排序
|
|
|
+// kpiDataJycsList.sort(Comparator.comparing(IndexKpiCompletByDate::getKpiCompletRate, Comparator.nullsFirst(BigDecimal::compareTo)).reversed());
|
|
|
+//// System.out.println(kpiDataJycsList);
|
|
|
+// });
|
|
|
+// CompletableFuture<Void> future2 = CompletableFuture.allOf(setKpiDataZrbmList, setKpiDataJycsList);
|
|
|
+// future2.join();
|
|
|
+//// System.out.println(kpiDataZrbmList);
|
|
|
+//// System.out.println(kpiDataJycsList);
|
|
|
+// indexKpiDataDepart.setZrbmCharts(kpiDataZrbmList);
|
|
|
+// indexKpiDataDepart.setJycsCharts(kpiDataJycsList);
|
|
|
+//
|
|
|
+// return indexKpiDataDepart;
|
|
|
+// }
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -303,210 +313,192 @@ public class IndexKpiServiceImpl implements IndexKpiService {
|
|
|
*/
|
|
|
public IndexKpiDataDepart getCompletRateByDate2(IndexKpiParamDto indexKpiParamDto){
|
|
|
//初始化
|
|
|
+ BigDecimal initDecimalNum = BigDecimal.valueOf(0);
|
|
|
IndexKpiDataDepart indexKpiDataDepart = new IndexKpiDataDepart();
|
|
|
List<IndexKpiCompletByDate> kpiDataZrbmList = new ArrayList<>();//责任部门排行
|
|
|
List<IndexKpiCompletByDate> kpiDataJycsList = new ArrayList<>();//下达部门排行
|
|
|
indexKpiDataDepart.setZrbmCharts(kpiDataZrbmList);//初始化放入空列表
|
|
|
indexKpiDataDepart.setJycsCharts(kpiDataJycsList);
|
|
|
- //查询所有部门 将所有部门的指标和完成度赋为空,合同额和已收款赋为0
|
|
|
- List<String> departList = indexKpiMapper.getDepartName();
|
|
|
- System.out.println(departList);
|
|
|
- //此处是否需要去重???
|
|
|
- if(departList.isEmpty()) return indexKpiDataDepart;
|
|
|
- for(String depart:departList){
|
|
|
- IndexKpiCompletByDate indexKpiCompletByDate = new IndexKpiCompletByDate();
|
|
|
- indexKpiCompletByDate.setDepart(depart);
|
|
|
- indexKpiCompletByDate.setDepartKpi(null);
|
|
|
- indexKpiCompletByDate.setContractAmount(new BigDecimal(0));
|
|
|
- indexKpiCompletByDate.setReceived(new BigDecimal(0));
|
|
|
- indexKpiCompletByDate.setKpiCompletRate(null);
|
|
|
- IndexKpiCompletByDate indexKpiCompletByDate2 = new IndexKpiCompletByDate();
|
|
|
- indexKpiCompletByDate2.setDepart(depart);
|
|
|
- indexKpiCompletByDate2.setDepartKpi(null);
|
|
|
- indexKpiCompletByDate2.setContractAmount(new BigDecimal(0));
|
|
|
- indexKpiCompletByDate2.setReceived(new BigDecimal(0));
|
|
|
- indexKpiCompletByDate2.setKpiCompletRate(null);
|
|
|
- kpiDataZrbmList.add(indexKpiCompletByDate);
|
|
|
- kpiDataJycsList.add(indexKpiCompletByDate2);
|
|
|
- }
|
|
|
-// System.out.println(kpiDataZrbmList);
|
|
|
-// System.out.println(kpiDataJycsList);
|
|
|
// TODO: 初始化结束
|
|
|
|
|
|
- //目前是算某个月的指标,不涉及范围
|
|
|
- //年/月
|
|
|
- String timeType = indexKpiParamDto.getTime();
|
|
|
- //日期
|
|
|
- String dateString = indexKpiParamDto.getBeginDate();
|
|
|
- /*
|
|
|
- //起始时间
|
|
|
- String startString = indexKpiParamDto.getBeginDate();
|
|
|
- //结束时间
|
|
|
- String endString = indexKpiParamDto.getEndDate();
|
|
|
- */
|
|
|
- //获取当前时间的年月
|
|
|
- LocalDate currentDate = LocalDate.now();
|
|
|
- // 获取当前年份
|
|
|
- int currentDateYear = currentDate.getYear();
|
|
|
- // 获取当前年月
|
|
|
- String currentYm = String.format("%d-%d", currentDateYear, currentDate.getMonthValue());
|
|
|
- //用来存放要看的年末或月末的年月日期 上一年末或上一月末的日期
|
|
|
- String dateYm = "";
|
|
|
- String dateLastYm = "";
|
|
|
- boolean isCurrentDate = true;//是否是当年或当月,当年或当月要从项目成本表中获取数据
|
|
|
- try{
|
|
|
- if(timeType.equals("year")){
|
|
|
- isCurrentDate = dateString.equals(String.valueOf(currentDateYear));
|
|
|
- dateYm = String.format("%s-%d", currentDateYear, 12);
|
|
|
- dateLastYm = String.format("%d-%d", Integer.parseInt(dateString)-1, 12);
|
|
|
- }else if(timeType.equals("month")){
|
|
|
- isCurrentDate = dateString.equals(currentYm);
|
|
|
- dateYm = dateString;
|
|
|
- dateLastYm = getLastMonthString(currentYm);
|
|
|
- }
|
|
|
- }catch (ParseException e){
|
|
|
- System.out.println("部门指标排行传送的日期字符串错误!!!");
|
|
|
+ //判断用户权限
|
|
|
+ // 获取登录人用户信息 V2.0版本:
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ String role = commonMethod.getRole(sysUser.getUsername());
|
|
|
+ if (role == null) {
|
|
|
return indexKpiDataDepart;
|
|
|
}
|
|
|
-
|
|
|
- boolean finalIsCurrentDate = isCurrentDate;
|
|
|
- String finalDateYm = dateYm;
|
|
|
- String finalDateLastYm = dateLastYm;
|
|
|
-
|
|
|
- //得到各数据列表,处理各个列表 转成map
|
|
|
- //获取部门指标数据 kpi
|
|
|
- CompletableFuture<Map<String, IndexKpiCompletByDate>> getKpiMapFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
- Map<String, IndexKpiCompletByDate> kpiMap = new TreeMap<>();//用来保存部门指标表中的部门和指标,根据部门查找对应数据
|
|
|
+ //所长权限,查看部门指标排行
|
|
|
+ if (role.equals(AuthMark.BOSS)) {
|
|
|
+ System.out.println("当前账户权限:所长,可以查看部门指标排行");
|
|
|
+ //目前是算某个月的指标,不涉及范围
|
|
|
+ String timeType = indexKpiParamDto.getTime();//年/月
|
|
|
+ String dateString = indexKpiParamDto.getBeginDate();//日期
|
|
|
+ /*
|
|
|
+ //起始时间
|
|
|
+ String startString = indexKpiParamDto.getBeginDate();
|
|
|
+ //结束时间
|
|
|
+ String endString = indexKpiParamDto.getEndDate();
|
|
|
+ */
|
|
|
+ //获取当前时间的年月
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ // 获取当前年份
|
|
|
+ int currentDateYear = currentDate.getYear();
|
|
|
+ // 获取当前年月
|
|
|
+ String currentYm = String.format("%d-%d", currentDateYear, currentDate.getMonthValue());
|
|
|
+ //用来存放要看的年末或月末的年月日期 上一年末或上一月末的日期
|
|
|
+ String dateYm = "";
|
|
|
+ String dateLastYm = "";
|
|
|
+ boolean isCurrentDate = true;//是否是当年或当月,当年或当月要从项目成本表中获取数据
|
|
|
+ try{
|
|
|
+ if(timeType.equals("year")){
|
|
|
+ isCurrentDate = dateString.equals(String.valueOf(currentDateYear));
|
|
|
+ dateYm = String.format("%s-%d", currentDateYear, 12);
|
|
|
+ dateLastYm = String.format("%d-%d", Integer.parseInt(dateString)-1, 12);
|
|
|
+ }else if(timeType.equals("month")){
|
|
|
+ isCurrentDate = dateString.equals(currentYm);
|
|
|
+ dateYm = dateString;
|
|
|
+ dateLastYm = getLastMonthString(currentYm);
|
|
|
+ }
|
|
|
+ }catch (ParseException e){
|
|
|
+ System.out.println("部门指标排行传送的日期字符串错误!!!");
|
|
|
+ return indexKpiDataDepart;
|
|
|
+ }
|
|
|
+ boolean finalIsCurrentDate = isCurrentDate;
|
|
|
+ String finalDateYm = dateYm;
|
|
|
+ String finalDateLastYm = dateLastYm;
|
|
|
+
|
|
|
+ //得到各数据列表,处理各个列表 转成map
|
|
|
+ //获取部门指标数据 kpi
|
|
|
+// Map<String, IndexKpiCompletByDate> kpiMap = new TreeMap<>();//用来保存部门指标表中的部门和指标,根据部门查找对应数据
|
|
|
+ List<String> departList = new ArrayList<>();//用来存放需要进行排行的部门
|
|
|
List<IndexKpiCompletByDate> kpiList;
|
|
|
if(timeType.equals("year")){
|
|
|
kpiList = indexKpiMapper.getKpiYear(Integer.parseInt(dateString));
|
|
|
}else{
|
|
|
kpiList = indexKpiMapper.getKpiMonth(dateString);
|
|
|
}
|
|
|
+ //根据年指标导入表中的部门进行指标完成度排行 将合同额和已收款赋以及完成度都置为0
|
|
|
for(IndexKpiCompletByDate kpiData:kpiList){
|
|
|
- kpiMap.put(kpiData.getDepart(), kpiData);
|
|
|
- }
|
|
|
- return kpiMap;
|
|
|
- });
|
|
|
- //获取选择年月的数据 合同额、已收款
|
|
|
- CompletableFuture<Map<String, IndexKpiCompletByDate>> getHtereceivedZrbmMapFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
- Map<String, IndexKpiCompletByDate> htereceivedZrbmMap = new TreeMap<>();//用来保存部门该月合计的合同额、已收款以及责任部门
|
|
|
- List<IndexKpiCompletByDate> htereceivedZrbmList;
|
|
|
- //如果选择的日期是当年当月,则从项目成本表里取数据,否则从每月月底项目进度考核表中取
|
|
|
- if(finalIsCurrentDate){
|
|
|
- htereceivedZrbmList = indexKpiMapper.getHteReceivedZrbmCost();
|
|
|
- }else{
|
|
|
- htereceivedZrbmList = indexKpiMapper.getHteReceivedZrbmYm(finalDateYm);
|
|
|
- }
|
|
|
- for(IndexKpiCompletByDate htereceivedZrbm:htereceivedZrbmList){
|
|
|
- htereceivedZrbmMap.put(htereceivedZrbm.getDepart(), htereceivedZrbm);
|
|
|
- }
|
|
|
- return htereceivedZrbmMap;
|
|
|
- });
|
|
|
- //获取选择年月上月的数据 合同额、已收款
|
|
|
- CompletableFuture<Map<String, IndexKpiCompletByDate>> getHtereceivedZrbmLastMapFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
- Map<String, IndexKpiCompletByDate> htereceivedZrbmLastMap = new TreeMap<>();//用来保存部门上月合计的合同额、已收款以及责任部门
|
|
|
- List<IndexKpiCompletByDate> htereceivedZrbmLastList = indexKpiMapper.getHteReceivedZrbmYm(finalDateLastYm);
|
|
|
- for(IndexKpiCompletByDate htereceivedZrbmLast:htereceivedZrbmLastList){
|
|
|
- htereceivedZrbmLastMap.put(htereceivedZrbmLast.getDepart(), htereceivedZrbmLast);
|
|
|
- }
|
|
|
- return htereceivedZrbmLastMap;
|
|
|
- });
|
|
|
- //获取选择年月的数据 合同额、已收款
|
|
|
- CompletableFuture<Map<String, IndexKpiCompletByDate>> getHtereceivedJycsMapFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
- Map<String, IndexKpiCompletByDate> htereceivedJycsMap = new TreeMap<>();//用来保存部门该月合计的合同额、已收款以及下达部门
|
|
|
- List<IndexKpiCompletByDate> htereceivedJycsList;
|
|
|
- //如果选择的日期是当年当月,则从项目成本表里取数据,否则从每月月底项目进度考核表中取
|
|
|
- if(finalIsCurrentDate){
|
|
|
- htereceivedJycsList = indexKpiMapper.getHteReceivedJycsCost();
|
|
|
- }else{
|
|
|
- htereceivedJycsList = indexKpiMapper.getHteReceivedJycsYm(finalDateYm);
|
|
|
- }
|
|
|
-
|
|
|
- for(IndexKpiCompletByDate htereceivedJycs:htereceivedJycsList){
|
|
|
- htereceivedJycsMap.put(htereceivedJycs.getDepart(), htereceivedJycs);
|
|
|
- }
|
|
|
- return htereceivedJycsMap;
|
|
|
- });
|
|
|
- //获取选择年月上月的数据 合同额、已收款
|
|
|
- CompletableFuture<Map<String, IndexKpiCompletByDate>> getHtereceivedJycsLastMapFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
- Map<String, IndexKpiCompletByDate> htereceivedJycsLastMap = new TreeMap<>();//用来保存部门上月合计的合同额、已收款以及下达部门
|
|
|
- List<IndexKpiCompletByDate> htereceivedJycsLastList = indexKpiMapper.getHteReceivedJycsYm(finalDateLastYm);
|
|
|
- for(IndexKpiCompletByDate htereceivedJycsLast:htereceivedJycsLastList){
|
|
|
- htereceivedJycsLastMap.put(htereceivedJycsLast.getDepart(), htereceivedJycsLast);
|
|
|
- }
|
|
|
- return htereceivedJycsLastMap;
|
|
|
- });
|
|
|
- CompletableFuture<Void> future1 = CompletableFuture.allOf(getKpiMapFuture, getHtereceivedZrbmMapFuture, getHtereceivedZrbmLastMapFuture, getHtereceivedJycsMapFuture, getHtereceivedJycsLastMapFuture);
|
|
|
- future1.join();
|
|
|
- Map<String, IndexKpiCompletByDate> kpiMap = getKpiMapFuture.join();
|
|
|
- Map<String, IndexKpiCompletByDate> htereceivedZrbmMap = getHtereceivedZrbmMapFuture.join();
|
|
|
- Map<String, IndexKpiCompletByDate> htereceivedZrbmLastMap = getHtereceivedZrbmLastMapFuture.join();
|
|
|
- Map<String, IndexKpiCompletByDate> htereceivedJycsMap = getHtereceivedJycsMapFuture.join();
|
|
|
- Map<String, IndexKpiCompletByDate> htereceivedJycsLastMap = getHtereceivedJycsLastMapFuture.join();
|
|
|
-
|
|
|
- CompletableFuture<Void> setKpiDataZrbmList = CompletableFuture.runAsync(() -> {
|
|
|
- //责任部门列表填充kpi
|
|
|
- for(IndexKpiCompletByDate kpiDataZrbm:kpiDataZrbmList){
|
|
|
- //根据部门输入部门指标
|
|
|
- kpiDataZrbm.setDepartKpi(kpiMap.getOrDefault(kpiDataZrbm.getDepart(), kpiDataZrbm).getDepartKpi());
|
|
|
+ kpiData.setContractAmount(initDecimalNum);
|
|
|
+ kpiData.setReceived(initDecimalNum);
|
|
|
+ kpiData.setKpiCompletRate(initDecimalNum);
|
|
|
+ kpiDataZrbmList.add(kpiData);
|
|
|
+ kpiDataJycsList.add((IndexKpiCompletByDate) kpiData.clone());
|
|
|
+ departList.add(kpiData.getDepart());
|
|
|
}
|
|
|
- //责任部门列表填充合同额、已收款、完成度
|
|
|
- for(IndexKpiCompletByDate kpiDataZrbm2:kpiDataZrbmList){
|
|
|
- //根据部门找到今年的合同额和已收款
|
|
|
- IndexKpiCompletByDate htereceivedZrbm = htereceivedZrbmMap.getOrDefault(kpiDataZrbm2.getDepart(), kpiDataZrbm2);
|
|
|
- IndexKpiCompletByDate htereceivedZrbmLast = htereceivedZrbmLastMap.getOrDefault(kpiDataZrbm2.getDepart(), kpiDataZrbm2);
|
|
|
- kpiDataZrbm2.setContractAmount(htereceivedZrbm.getContractAmount().subtract(htereceivedZrbmLast.getContractAmount()));//合同额
|
|
|
- kpiDataZrbm2.setReceived(htereceivedZrbm.getReceived().subtract(htereceivedZrbmLast.getReceived()));//已收款
|
|
|
+ if(departList.isEmpty()) return indexKpiDataDepart;
|
|
|
+
|
|
|
+ //获取选择年月的数据 合同额、已收款
|
|
|
+ CompletableFuture<Map<String, IndexKpiCompletByDate>> getHtereceivedZrbmMapFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+ Map<String, IndexKpiCompletByDate> htereceivedZrbmMap = new TreeMap<>();//用来保存部门该月合计的合同额、已收款以及责任部门
|
|
|
+ List<IndexKpiCompletByDate> htereceivedZrbmList;
|
|
|
+ //如果选择的日期是当年当月,则从项目成本表里取数据,否则从每月月底项目进度考核表中取
|
|
|
+ if(finalIsCurrentDate){
|
|
|
+ htereceivedZrbmList = indexKpiMapper.getHteReceivedZrbmCost(departList);
|
|
|
+ }else{
|
|
|
+ htereceivedZrbmList = indexKpiMapper.getHteReceivedZrbmYm(finalDateYm, departList);
|
|
|
+ }
|
|
|
+ for(IndexKpiCompletByDate htereceivedZrbm:htereceivedZrbmList){
|
|
|
+ htereceivedZrbmMap.put(htereceivedZrbm.getDepart(), htereceivedZrbm);
|
|
|
+ }
|
|
|
+ return htereceivedZrbmMap;
|
|
|
+ });
|
|
|
+ //获取选择年月上月的数据 合同额、已收款
|
|
|
+ CompletableFuture<Map<String, IndexKpiCompletByDate>> getHtereceivedZrbmLastMapFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+ Map<String, IndexKpiCompletByDate> htereceivedZrbmLastMap = new TreeMap<>();//用来保存部门上月合计的合同额、已收款以及责任部门
|
|
|
+ List<IndexKpiCompletByDate> htereceivedZrbmLastList = indexKpiMapper.getHteReceivedZrbmYm(finalDateLastYm, departList);
|
|
|
+ for(IndexKpiCompletByDate htereceivedZrbmLast:htereceivedZrbmLastList){
|
|
|
+ htereceivedZrbmLastMap.put(htereceivedZrbmLast.getDepart(), htereceivedZrbmLast);
|
|
|
+ }
|
|
|
+ return htereceivedZrbmLastMap;
|
|
|
+ });
|
|
|
+ //获取选择年月的数据 合同额、已收款
|
|
|
+ CompletableFuture<Map<String, IndexKpiCompletByDate>> getHtereceivedJycsMapFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+ Map<String, IndexKpiCompletByDate> htereceivedJycsMap = new TreeMap<>();//用来保存部门该月合计的合同额、已收款以及下达部门
|
|
|
+ List<IndexKpiCompletByDate> htereceivedJycsList;
|
|
|
+ //如果选择的日期是当年当月,则从项目成本表里取数据,否则从每月月底项目进度考核表中取
|
|
|
+ if(finalIsCurrentDate){
|
|
|
+ htereceivedJycsList = indexKpiMapper.getHteReceivedJycsCost(departList);
|
|
|
+ }else{
|
|
|
+ htereceivedJycsList = indexKpiMapper.getHteReceivedJycsYm(finalDateYm, departList);
|
|
|
+ }
|
|
|
|
|
|
- //计算完成度 合同额(是计算的某个月或某个年的合同额 增量)/ 指标
|
|
|
- if(kpiDataZrbm2.getDepartKpi() != null){
|
|
|
- if(kpiDataZrbm2.getDepartKpi().equals(BigDecimal.valueOf(0))){
|
|
|
- kpiDataZrbm2.setKpiCompletRate(BigDecimal.valueOf(1));
|
|
|
- }else{
|
|
|
- kpiDataZrbm2.setKpiCompletRate(kpiDataZrbm2.getContractAmount().divide(kpiDataZrbm2.getDepartKpi(), 2, RoundingMode.HALF_UP));
|
|
|
+ for(IndexKpiCompletByDate htereceivedJycs:htereceivedJycsList){
|
|
|
+ htereceivedJycsMap.put(htereceivedJycs.getDepart(), htereceivedJycs);
|
|
|
+ }
|
|
|
+ return htereceivedJycsMap;
|
|
|
+ });
|
|
|
+ //获取选择年月上月的数据 合同额、已收款
|
|
|
+ CompletableFuture<Map<String, IndexKpiCompletByDate>> getHtereceivedJycsLastMapFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+ Map<String, IndexKpiCompletByDate> htereceivedJycsLastMap = new TreeMap<>();//用来保存部门上月合计的合同额、已收款以及下达部门
|
|
|
+ List<IndexKpiCompletByDate> htereceivedJycsLastList = indexKpiMapper.getHteReceivedJycsYm(finalDateLastYm, departList);
|
|
|
+ for(IndexKpiCompletByDate htereceivedJycsLast:htereceivedJycsLastList){
|
|
|
+ htereceivedJycsLastMap.put(htereceivedJycsLast.getDepart(), htereceivedJycsLast);
|
|
|
+ }
|
|
|
+ return htereceivedJycsLastMap;
|
|
|
+ });
|
|
|
+ CompletableFuture<Void> future1 = CompletableFuture.allOf(getHtereceivedZrbmMapFuture, getHtereceivedZrbmLastMapFuture, getHtereceivedJycsMapFuture, getHtereceivedJycsLastMapFuture);
|
|
|
+ future1.join();
|
|
|
+ Map<String, IndexKpiCompletByDate> htereceivedZrbmMap = getHtereceivedZrbmMapFuture.join();
|
|
|
+ Map<String, IndexKpiCompletByDate> htereceivedZrbmLastMap = getHtereceivedZrbmLastMapFuture.join();
|
|
|
+ Map<String, IndexKpiCompletByDate> htereceivedJycsMap = getHtereceivedJycsMapFuture.join();
|
|
|
+ Map<String, IndexKpiCompletByDate> htereceivedJycsLastMap = getHtereceivedJycsLastMapFuture.join();
|
|
|
+
|
|
|
+ CompletableFuture<Void> setKpiDataZrbmList = CompletableFuture.runAsync(() -> {
|
|
|
+ //责任部门列表填充合同额、已收款、完成度
|
|
|
+ for(IndexKpiCompletByDate kpiDataZrbm:kpiDataZrbmList){
|
|
|
+ //根据部门找到今年的合同额和已收款
|
|
|
+ IndexKpiCompletByDate htereceivedZrbm = htereceivedZrbmMap.getOrDefault(kpiDataZrbm.getDepart(), kpiDataZrbm);
|
|
|
+ IndexKpiCompletByDate htereceivedZrbmLast = htereceivedZrbmLastMap.getOrDefault(kpiDataZrbm.getDepart(), kpiDataZrbm);
|
|
|
+ kpiDataZrbm.setContractAmount(htereceivedZrbm.getContractAmount().subtract(htereceivedZrbmLast.getContractAmount()).setScale(2, RoundingMode.HALF_UP));//合同额
|
|
|
+ kpiDataZrbm.setReceived(htereceivedZrbm.getReceived().subtract(htereceivedZrbmLast.getReceived()).setScale(2, RoundingMode.HALF_UP));//已收款
|
|
|
+
|
|
|
+ //计算完成度 合同额(是计算的某个月或某个年的合同额 增量)/ 指标
|
|
|
+ if(kpiDataZrbm.getDepartKpi() != null){
|
|
|
+ if(kpiDataZrbm.getDepartKpi().equals(BigDecimal.valueOf(0))){
|
|
|
+ kpiDataZrbm.setKpiCompletRate(BigDecimal.valueOf(1));
|
|
|
+ }else{
|
|
|
+ kpiDataZrbm.setKpiCompletRate(kpiDataZrbm.getContractAmount().divide(kpiDataZrbm.getDepartKpi(), 2, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
// System.out.println("kpiDataZrbmList");
|
|
|
- //责任部门指标完成度排序
|
|
|
- kpiDataZrbmList.sort(Comparator.comparing(IndexKpiCompletByDate::getKpiCompletRate, Comparator.nullsFirst(BigDecimal::compareTo)).reversed());
|
|
|
+ //责任部门指标完成度排序
|
|
|
+ kpiDataZrbmList.sort(Comparator.comparing(IndexKpiCompletByDate::getKpiCompletRate, Comparator.nullsFirst(BigDecimal::compareTo)).reversed());
|
|
|
// System.out.println(kpiDataZrbmList);
|
|
|
- });
|
|
|
- CompletableFuture<Void> setKpiDataJycsList = CompletableFuture.runAsync(() -> {
|
|
|
- //下达部门列表填充kpi
|
|
|
- for(IndexKpiCompletByDate kpiDataJycs:kpiDataJycsList){
|
|
|
- //根据部门输入部门指标
|
|
|
- kpiDataJycs.setDepartKpi(kpiMap.getOrDefault(kpiDataJycs.getDepart(), kpiDataJycs).getDepartKpi());
|
|
|
- }
|
|
|
- //下达部门列表填充合同额、已收款、完成度
|
|
|
- for(IndexKpiCompletByDate kpiDataJycs2:kpiDataJycsList){
|
|
|
- //根据部门找到今年的合同额和已收款
|
|
|
- IndexKpiCompletByDate htereceivedJycs = htereceivedJycsMap.getOrDefault(kpiDataJycs2.getDepart(), kpiDataJycs2);
|
|
|
- IndexKpiCompletByDate htereceivedJycsLast = htereceivedJycsLastMap.getOrDefault(kpiDataJycs2.getDepart(), kpiDataJycs2);
|
|
|
- kpiDataJycs2.setContractAmount(htereceivedJycs.getContractAmount().subtract(htereceivedJycsLast.getContractAmount()));//合同额
|
|
|
- kpiDataJycs2.setReceived(htereceivedJycs.getReceived().subtract(htereceivedJycsLast.getReceived()));//已收款
|
|
|
-
|
|
|
- //计算完成度 合同额(是计算的某个月或某个年的合同额 增量)/ 指标
|
|
|
- if(kpiDataJycs2.getDepartKpi() != null){
|
|
|
- if(kpiDataJycs2.getDepartKpi().equals(BigDecimal.valueOf(0))){
|
|
|
- kpiDataJycs2.setKpiCompletRate(BigDecimal.valueOf(1));
|
|
|
- }else{
|
|
|
- kpiDataJycs2.setKpiCompletRate(kpiDataJycs2.getContractAmount().divide(kpiDataJycs2.getDepartKpi(), 2, RoundingMode.HALF_UP));
|
|
|
+ });
|
|
|
+ CompletableFuture<Void> setKpiDataJycsList = CompletableFuture.runAsync(() -> {
|
|
|
+ //下达部门列表填充合同额、已收款、完成度
|
|
|
+ for(IndexKpiCompletByDate kpiDataJycs:kpiDataJycsList){
|
|
|
+ //根据部门找到今年的合同额和已收款
|
|
|
+ IndexKpiCompletByDate htereceivedJycs = htereceivedJycsMap.getOrDefault(kpiDataJycs.getDepart(), kpiDataJycs);
|
|
|
+ IndexKpiCompletByDate htereceivedJycsLast = htereceivedJycsLastMap.getOrDefault(kpiDataJycs.getDepart(), kpiDataJycs);
|
|
|
+ kpiDataJycs.setContractAmount(htereceivedJycs.getContractAmount().subtract(htereceivedJycsLast.getContractAmount()).setScale(2, RoundingMode.HALF_UP));//合同额
|
|
|
+ kpiDataJycs.setReceived(htereceivedJycs.getReceived().subtract(htereceivedJycsLast.getReceived()).setScale(2, RoundingMode.HALF_UP));//已收款
|
|
|
+
|
|
|
+ //计算完成度 合同额(是计算的某个月或某个年的合同额 增量)/ 指标
|
|
|
+ if(kpiDataJycs.getDepartKpi() != null){
|
|
|
+ if(kpiDataJycs.getDepartKpi().equals(BigDecimal.valueOf(0))){
|
|
|
+ kpiDataJycs.setKpiCompletRate(BigDecimal.valueOf(1));
|
|
|
+ }else{
|
|
|
+ kpiDataJycs.setKpiCompletRate(kpiDataJycs.getContractAmount().divide(kpiDataJycs.getDepartKpi(), 2, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
// System.out.println("kpiDataJycsList");
|
|
|
- //下达部门指标完成度排序
|
|
|
- kpiDataJycsList.sort(Comparator.comparing(IndexKpiCompletByDate::getKpiCompletRate, Comparator.nullsFirst(BigDecimal::compareTo)).reversed());
|
|
|
+ //下达部门指标完成度排序
|
|
|
+ kpiDataJycsList.sort(Comparator.comparing(IndexKpiCompletByDate::getKpiCompletRate, Comparator.nullsFirst(BigDecimal::compareTo)).reversed());
|
|
|
// System.out.println(kpiDataJycsList);
|
|
|
- });
|
|
|
- CompletableFuture<Void> future2 = CompletableFuture.allOf(setKpiDataZrbmList, setKpiDataJycsList);
|
|
|
- future2.join();
|
|
|
+ });
|
|
|
+ CompletableFuture<Void> future2 = CompletableFuture.allOf(setKpiDataZrbmList, setKpiDataJycsList);
|
|
|
+ future2.join();
|
|
|
// System.out.println(kpiDataZrbmList);
|
|
|
// System.out.println(kpiDataJycsList);
|
|
|
- indexKpiDataDepart.setZrbmCharts(kpiDataZrbmList);
|
|
|
- indexKpiDataDepart.setJycsCharts(kpiDataJycsList);
|
|
|
+ indexKpiDataDepart.setZrbmCharts(kpiDataZrbmList);
|
|
|
+ indexKpiDataDepart.setJycsCharts(kpiDataJycsList);
|
|
|
+ }
|
|
|
+ System.out.println(indexKpiDataDepart);
|
|
|
|
|
|
return indexKpiDataDepart;
|
|
|
}
|