|
@@ -11,6 +11,7 @@ import org.jeecg.modules.Index.entity.dto.IndexInfoParamDto;
|
|
|
import org.jeecg.modules.Index.entity.vo.ContractDataInfoVo;
|
|
|
import org.jeecg.modules.Index.entity.vo.IncomeDataInfoVo;
|
|
|
import org.jeecg.modules.Index.entity.vo.LreDataInfoVo;
|
|
|
+import org.jeecg.modules.Index.entity.vo.ReceivedDataInfoVo;
|
|
|
import org.jeecg.modules.Index.service.IndexService;
|
|
|
import org.jeecg.modules.kyTaskInfo.service.IKyTaskInfoService;
|
|
|
import org.jeecg.modules.projectCost.entity.ProjectCost;
|
|
@@ -80,6 +81,9 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
private static final String CONTRACT_DATA_REDIS_KEY = "contractDataRedisKey:";
|
|
|
|
|
|
+ private static final String RECEIVED_DATA_REDIS_KEY = "receivedDataRedisKey:";
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public IncomeDataInfoVo getTotalIncome(HttpServletRequest request) {
|
|
|
//首页收入渲染对象
|
|
@@ -377,6 +381,154 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public ReceivedDataInfoVo getTotalReceived(HttpServletRequest request) {
|
|
|
+ BigDecimal initValue = BigDecimal.valueOf(0);
|
|
|
+ ReceivedDataInfoVo receivedDataInfoVo = new ReceivedDataInfoVo();
|
|
|
+ receivedDataInfoVo.setReceivedYearTotal(initValue);
|
|
|
+ receivedDataInfoVo.setReceivedYearTq(initValue);
|
|
|
+ receivedDataInfoVo.setReceivedYearTb(initValue);
|
|
|
+ receivedDataInfoVo.setReceivedMonthTotal(initValue);
|
|
|
+ receivedDataInfoVo.setReceivedMonthHb(initValue);
|
|
|
+ receivedDataInfoVo.setReceivedMonthTb(initValue);
|
|
|
+
|
|
|
+ String userNameByToken = JwtUtil.getUserNameByToken(request);
|
|
|
+ LoginUser sysUser = sysBaseApi.getUserByName(userNameByToken);
|
|
|
+
|
|
|
+ List<String> departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
|
|
|
+ if (departNames.isEmpty()) return receivedDataInfoVo;
|
|
|
+
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ for (String departName : departNames) {
|
|
|
+ stringBuilder.append(departName).append("|");
|
|
|
+ }
|
|
|
+ String depart = stringBuilder.toString();
|
|
|
+ ReceivedDataInfoVo cacheObject = (ReceivedDataInfoVo) redisUtil.get(RECEIVED_DATA_REDIS_KEY + depart);
|
|
|
+ if (ObjectUtils.isNotEmpty(cacheObject)) {
|
|
|
+ receivedDataInfoVo = cacheObject;
|
|
|
+ return receivedDataInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<String> tasknoList = new ArrayList<>();
|
|
|
+ List<String> ZrbmTasknoList = projectCostMapper.queryZrbmTasknoListbydepartNames(departNames);
|
|
|
+ List<String> XdbmTasknoList = projectCostMapper.queryXdbmTasknoListbydepartNames(departNames);
|
|
|
+ tasknoList.addAll(ZrbmTasknoList);
|
|
|
+ tasknoList.addAll(XdbmTasknoList);
|
|
|
+ if (tasknoList.isEmpty()) return receivedDataInfoVo;
|
|
|
+
|
|
|
+
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+
|
|
|
+ Date currentYearEndDate = instance.getTime();
|
|
|
+ setZeroYear(instance);
|
|
|
+ Date currentYearBeginDate = instance.getTime();
|
|
|
+
|
|
|
+ List<BigDecimal> currentYearIncomeList = new ArrayList<>();
|
|
|
+ ReceivedDataInfoVo finalIncomeDataInfoVo = receivedDataInfoVo;
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ //根据年份和当前部门对应的任务号查询,部门当前年的年收入
|
|
|
+ BigDecimal currentYearTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, currentYearBeginDate, currentYearEndDate);
|
|
|
+ if (ObjectUtils.isEmpty(currentYearTotal)) currentYearTotal = BigDecimal.valueOf(0);
|
|
|
+ finalIncomeDataInfoVo.setReceivedYearTotal(currentYearTotal);
|
|
|
+ currentYearIncomeList.add(currentYearTotal);
|
|
|
+ }).join();
|
|
|
+
|
|
|
+ instance.setTime(new Date());
|
|
|
+ instance.add(Calendar.YEAR, -1);
|
|
|
+ //去年的今日
|
|
|
+ Date LastTqEndDate = instance.getTime();
|
|
|
+ setZeroYear(instance);
|
|
|
+ Date LastYearBeginDate = instance.getTime();
|
|
|
+
|
|
|
+ ArrayList<BigDecimal> lastYearTqIncomeList = new ArrayList<>();
|
|
|
+ //根据年份和当前部门对应的任务号查询,部门去年同期年收入
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ BigDecimal lastYearTqTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, LastYearBeginDate, LastTqEndDate);
|
|
|
+ if (ObjectUtils.isEmpty(lastYearTqTotal)) lastYearTqTotal = BigDecimal.valueOf(0);
|
|
|
+ finalIncomeDataInfoVo.setReceivedYearTq(lastYearTqTotal);
|
|
|
+ lastYearTqIncomeList.add(lastYearTqTotal);
|
|
|
+ }).join();
|
|
|
+
|
|
|
+
|
|
|
+ instance.setTime(new Date());
|
|
|
+ Date currentMothEndDate = instance.getTime();
|
|
|
+ setZeroMonth(instance);
|
|
|
+ Date currentMothBginDate = instance.getTime();
|
|
|
+
|
|
|
+ ArrayList<BigDecimal> currentMonthTotalList = new ArrayList<>();
|
|
|
+
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ BigDecimal currentMonthTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, currentMothBginDate, currentMothEndDate);
|
|
|
+ if (ObjectUtils.isEmpty(currentMonthTotal)) currentMonthTotal = BigDecimal.valueOf(0);
|
|
|
+ finalIncomeDataInfoVo.setReceivedMonthTotal(currentMonthTotal);
|
|
|
+ currentMonthTotalList.add(currentMonthTotal);
|
|
|
+ }).join();
|
|
|
+
|
|
|
+
|
|
|
+ instance.setTime(new Date());
|
|
|
+ instance.add(Calendar.MONTH, -1);
|
|
|
+ Date LastMothTqEndDate = instance.getTime();
|
|
|
+ setZeroMonth(instance);
|
|
|
+ Date LastMothTqBeginDate = instance.getTime();
|
|
|
+
|
|
|
+ ArrayList<BigDecimal> lastMothTqTotalList = new ArrayList<>();
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ BigDecimal lastMothTqTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, LastMothTqBeginDate, LastMothTqEndDate);
|
|
|
+ if (ObjectUtils.isEmpty(lastMothTqTotal)) lastMothTqTotal = BigDecimal.valueOf(0);
|
|
|
+ lastMothTqTotalList.add(lastMothTqTotal);
|
|
|
+ }).join();
|
|
|
+
|
|
|
+
|
|
|
+ instance.setTime(new Date());
|
|
|
+ instance.add(Calendar.YEAR, -1);
|
|
|
+ Date lastYearMonthTqEndDate = instance.getTime();
|
|
|
+ setZeroMonth(instance);
|
|
|
+ Date lastYearMonthTqBeginDate = instance.getTime();
|
|
|
+
|
|
|
+ ArrayList<BigDecimal> lastYearMonthTqTotalList = new ArrayList<>();
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ BigDecimal lastYearMonthTqTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, lastYearMonthTqBeginDate, lastYearMonthTqEndDate);
|
|
|
+ if (ObjectUtils.isEmpty(lastYearMonthTqTotal)) lastYearMonthTqTotal = BigDecimal.valueOf(0);
|
|
|
+ lastYearMonthTqTotalList.add(lastYearMonthTqTotal);
|
|
|
+ }).join();
|
|
|
+
|
|
|
+
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ BigDecimal currentYearTotal = currentYearIncomeList.get(0);
|
|
|
+ BigDecimal lastYearTqTotal = lastYearTqIncomeList.get(0);
|
|
|
+ //去年同比
|
|
|
+ BigDecimal YearDifference = currentYearTotal.subtract(lastYearTqTotal);
|
|
|
+ BigDecimal incomeYearTb = BigDecimal.valueOf(1);
|
|
|
+ if (lastYearTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
|
|
|
+ incomeYearTb = YearDifference.divide(lastYearTqTotal, 2, RoundingMode.HALF_UP);
|
|
|
+ finalIncomeDataInfoVo.setReceivedYearTb(incomeYearTb);
|
|
|
+ }).join();
|
|
|
+
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ BigDecimal currentMonthTotal = currentMonthTotalList.get(0);
|
|
|
+ BigDecimal lastMothTqTotal = lastMothTqTotalList.get(0);
|
|
|
+ BigDecimal MothDifference = currentMonthTotal.subtract(lastMothTqTotal);
|
|
|
+ BigDecimal incomeMothHb = BigDecimal.valueOf(1);
|
|
|
+ if (lastMothTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
|
|
|
+ incomeMothHb = MothDifference.divide(lastMothTqTotal, 2, RoundingMode.HALF_UP);
|
|
|
+ finalIncomeDataInfoVo.setReceivedMonthHb(incomeMothHb);
|
|
|
+ }).join();
|
|
|
+
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ BigDecimal currentMonthTotal = currentMonthTotalList.get(0);
|
|
|
+ BigDecimal lastYearMonthTqTotal = lastYearMonthTqTotalList.get(0);
|
|
|
+ BigDecimal yearMothDifference = currentMonthTotal.subtract(lastYearMonthTqTotal);
|
|
|
+ BigDecimal incomeYearMothTb = BigDecimal.valueOf(1);
|
|
|
+ if (lastYearMonthTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
|
|
|
+ incomeYearMothTb = yearMothDifference.divide(lastYearMonthTqTotal, 2, RoundingMode.HALF_UP);
|
|
|
+ finalIncomeDataInfoVo.setReceivedMonthTb(incomeYearMothTb);
|
|
|
+ }).join();
|
|
|
+
|
|
|
+ redisUtil.set(RECEIVED_DATA_REDIS_KEY + depart, finalIncomeDataInfoVo, 1000L * 60 * 60 * 2);
|
|
|
+
|
|
|
+ return finalIncomeDataInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
public void setZeroYear(Calendar instance) {
|
|
|
instance.set(Calendar.MONTH, 0);
|
|
|
instance.set(Calendar.DAY_OF_MONTH, 0);
|
|
@@ -401,6 +553,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
switch (indexInfoParamDto.getTime()) {
|
|
|
case "year":
|
|
|
resultl = getContractAmountInfoIfYear(request, indexInfoParamDto);
|
|
|
+ break;
|
|
|
case "month":
|
|
|
resultl = getContractAmountInfoIfMonth(request, indexInfoParamDto);
|
|
|
case "day":
|
|
@@ -414,20 +567,25 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
|
|
|
public String getContractAmountInfoIfYear(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
|
|
|
+ Date beginDate = indexInfoParamDto.getBeginDate();
|
|
|
+ Date endDate = indexInfoParamDto.getEndDate();
|
|
|
+
|
|
|
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public String getContractAmountInfoIfMonth(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
|
|
|
-
|
|
|
+ Date beginDate = indexInfoParamDto.getBeginDate();
|
|
|
+ Date endDate = indexInfoParamDto.getEndDate();
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
public String getContractAmountInfoIfDay(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
|
|
|
-
|
|
|
+ Date beginDate = indexInfoParamDto.getBeginDate();
|
|
|
+ Date endDate = indexInfoParamDto.getEndDate();
|
|
|
|
|
|
return null;
|
|
|
}
|