|
@@ -5,7 +5,8 @@ import org.jeecg.common.system.api.ISysBaseAPI;
|
|
|
import org.jeecg.common.system.util.JwtUtil;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.common.util.RedisUtil;
|
|
|
-import org.jeecg.modules.Index.entity.IncomeDataInfoVO;
|
|
|
+import org.jeecg.modules.Index.entity.ContractDataInfoVo;
|
|
|
+import org.jeecg.modules.Index.entity.IncomeDataInfoVo;
|
|
|
import org.jeecg.modules.Index.service.IndexService;
|
|
|
import org.jeecg.modules.projectCost.mapper.ProjectCostMapper;
|
|
|
import org.jeecg.modules.system.mapper.SysDepartMapper;
|
|
@@ -39,11 +40,13 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
private static final String INCOME_DATA_REDIS_KEY = "incomeDataRedisKey:";
|
|
|
|
|
|
+ private static final String CONTRACT_DATA_REDIS_KEY = "contractDataRedisKey:";
|
|
|
+
|
|
|
@Override
|
|
|
- public IncomeDataInfoVO getTotalIncome(HttpServletRequest request) {
|
|
|
+ public IncomeDataInfoVo getTotalIncome(HttpServletRequest request) {
|
|
|
//首页收入渲染对象
|
|
|
BigDecimal initValue = BigDecimal.valueOf(0);
|
|
|
- IncomeDataInfoVO incomeDataInfoVO = new IncomeDataInfoVO();
|
|
|
+ IncomeDataInfoVo incomeDataInfoVO = new IncomeDataInfoVo();
|
|
|
incomeDataInfoVO.setIncomeYearTotal(initValue);
|
|
|
incomeDataInfoVO.setIncomeYearTq(initValue);
|
|
|
incomeDataInfoVO.setIncomeYearTb(initValue);
|
|
@@ -62,7 +65,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
stringBuilder.append(departName).append("|");
|
|
|
}
|
|
|
String depart = stringBuilder.toString();
|
|
|
- IncomeDataInfoVO cacheObject = (IncomeDataInfoVO)redisUtil.get(INCOME_DATA_REDIS_KEY + depart);
|
|
|
+ IncomeDataInfoVo cacheObject = (IncomeDataInfoVo) redisUtil.get(INCOME_DATA_REDIS_KEY + depart);
|
|
|
if (ObjectUtils.isNotEmpty(cacheObject)) {
|
|
|
incomeDataInfoVO = cacheObject;
|
|
|
return incomeDataInfoVO;
|
|
@@ -83,12 +86,12 @@ public class IndexServiceImpl implements IndexService {
|
|
|
Date currentYearBeginDate = instance.getTime();
|
|
|
|
|
|
List<BigDecimal> currentYearIncomeList = new ArrayList<>();
|
|
|
- IncomeDataInfoVO finalIncomeDataInfoVO = incomeDataInfoVO;
|
|
|
+ IncomeDataInfoVo finalIncomeDataInfoVo = incomeDataInfoVO;
|
|
|
CompletableFuture.runAsync(() -> {
|
|
|
//根据年份和当前部门对应的任务号查询,部门当前年的年收入
|
|
|
BigDecimal currentYearTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRange(tasknoList, currentYearBeginDate, currentYearEndDate);
|
|
|
if (ObjectUtils.isEmpty(currentYearTotal)) currentYearTotal = BigDecimal.valueOf(0);
|
|
|
- finalIncomeDataInfoVO.setIncomeYearTotal(currentYearTotal);
|
|
|
+ finalIncomeDataInfoVo.setIncomeYearTotal(currentYearTotal);
|
|
|
currentYearIncomeList.add(currentYearTotal);
|
|
|
}).join();
|
|
|
|
|
@@ -104,7 +107,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
CompletableFuture.runAsync(() -> {
|
|
|
BigDecimal lastYearTqTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRange(tasknoList, LastYearBeginDate, LastTqEndDate);
|
|
|
if (ObjectUtils.isEmpty(lastYearTqTotal)) lastYearTqTotal = BigDecimal.valueOf(0);
|
|
|
- finalIncomeDataInfoVO.setIncomeYearTq(lastYearTqTotal);
|
|
|
+ finalIncomeDataInfoVo.setIncomeYearTq(lastYearTqTotal);
|
|
|
lastYearTqIncomeList.add(lastYearTqTotal);
|
|
|
}).join();
|
|
|
|
|
@@ -119,7 +122,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
CompletableFuture.runAsync(() -> {
|
|
|
BigDecimal currentMonthTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRange(tasknoList, currentMothBginDate, currentMothEndDate);
|
|
|
if (ObjectUtils.isEmpty(currentMonthTotal)) currentMonthTotal = BigDecimal.valueOf(0);
|
|
|
- finalIncomeDataInfoVO.setIncomeMonthTotal(currentMonthTotal);
|
|
|
+ finalIncomeDataInfoVo.setIncomeMonthTotal(currentMonthTotal);
|
|
|
currentMonthTotalList.add(currentMonthTotal);
|
|
|
}).join();
|
|
|
|
|
@@ -160,7 +163,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
BigDecimal incomeYearTb = BigDecimal.valueOf(1);
|
|
|
if (lastYearTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
|
|
|
incomeYearTb = YearDifference.divide(lastYearTqTotal, 2, RoundingMode.HALF_UP);
|
|
|
- finalIncomeDataInfoVO.setIncomeYearTb(incomeYearTb);
|
|
|
+ finalIncomeDataInfoVo.setIncomeYearTb(incomeYearTb);
|
|
|
}).join();
|
|
|
|
|
|
CompletableFuture.runAsync(() -> {
|
|
@@ -170,7 +173,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
BigDecimal incomeMothHb = BigDecimal.valueOf(1);
|
|
|
if (lastMothTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
|
|
|
incomeMothHb = MothDifference.divide(lastMothTqTotal, 2, RoundingMode.HALF_UP);
|
|
|
- finalIncomeDataInfoVO.setIncomeMonthHb(incomeMothHb);
|
|
|
+ finalIncomeDataInfoVo.setIncomeMonthHb(incomeMothHb);
|
|
|
}).join();
|
|
|
|
|
|
CompletableFuture.runAsync(() -> {
|
|
@@ -180,12 +183,159 @@ public class IndexServiceImpl implements IndexService {
|
|
|
BigDecimal incomeYearMothTb = BigDecimal.valueOf(1);
|
|
|
if (lastYearMonthTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
|
|
|
incomeYearMothTb = yearMothDifference.divide(lastYearMonthTqTotal, 2, RoundingMode.HALF_UP);
|
|
|
- finalIncomeDataInfoVO.setIncomeMonthTb(incomeYearMothTb);
|
|
|
+ finalIncomeDataInfoVo.setIncomeMonthTb(incomeYearMothTb);
|
|
|
+ }).join();
|
|
|
+
|
|
|
+ redisUtil.set(INCOME_DATA_REDIS_KEY + depart, finalIncomeDataInfoVo, 1000L * 60 * 60 * 2);
|
|
|
+
|
|
|
+ return finalIncomeDataInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ContractDataInfoVo getTotalContract(HttpServletRequest request) {
|
|
|
+ //首页收入渲染对象
|
|
|
+ BigDecimal initValue = BigDecimal.valueOf(0);
|
|
|
+ ContractDataInfoVo contractDataInfoVo = new ContractDataInfoVo();
|
|
|
+ contractDataInfoVo.setContractYearTotal(initValue);
|
|
|
+ contractDataInfoVo.setContractYearTq(initValue);
|
|
|
+ contractDataInfoVo.setContractYearTb(initValue);
|
|
|
+ contractDataInfoVo.setContractMonthTotal(initValue);
|
|
|
+ contractDataInfoVo.setContractMonthHb(initValue);
|
|
|
+ contractDataInfoVo.setContractMonthTb(initValue);
|
|
|
+
|
|
|
+ String userNameByToken = JwtUtil.getUserNameByToken(request);
|
|
|
+ LoginUser sysUser = sysBaseApi.getUserByName(userNameByToken);
|
|
|
+
|
|
|
+ List<String> departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
|
|
|
+ if (departNames.isEmpty()) return contractDataInfoVo;
|
|
|
+
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ for (String departName : departNames) {
|
|
|
+ stringBuilder.append(departName).append("|");
|
|
|
+ }
|
|
|
+ String depart = stringBuilder.toString();
|
|
|
+ ContractDataInfoVo cacheObject = (ContractDataInfoVo) redisUtil.get(CONTRACT_DATA_REDIS_KEY + depart);
|
|
|
+ if (ObjectUtils.isNotEmpty(cacheObject)) {
|
|
|
+ contractDataInfoVo = cacheObject;
|
|
|
+ return contractDataInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 contractDataInfoVo;
|
|
|
+
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+
|
|
|
+ Date currentYearEndDate = instance.getTime();
|
|
|
+ setZeroYear(instance);
|
|
|
+ Date currentYearBeginDate = instance.getTime();
|
|
|
+
|
|
|
+ List<BigDecimal> currentYearIncomeList = new ArrayList<>();
|
|
|
+ ContractDataInfoVo finalContractDataInfoVo = contractDataInfoVo;
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ //根据年份和当前部门对应的任务号查询,部门当前年的年收入
|
|
|
+ BigDecimal currentYearTotal = exchangeMapper.getContractNumYearTotalByTasknoListAndByQsrqRange(tasknoList, currentYearBeginDate, currentYearEndDate);
|
|
|
+ if (ObjectUtils.isEmpty(currentYearTotal)) currentYearTotal = BigDecimal.valueOf(0);
|
|
|
+ finalContractDataInfoVo.setContractYearTotal(currentYearTotal);
|
|
|
+ currentYearIncomeList.add(currentYearTotal);
|
|
|
}).join();
|
|
|
|
|
|
- redisUtil.set(INCOME_DATA_REDIS_KEY + depart, finalIncomeDataInfoVO, 1000L * 60 * 60 * 2);
|
|
|
+ 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.getContractNumYearTotalByTasknoListAndByQsrqRange(tasknoList, LastYearBeginDate, LastTqEndDate);
|
|
|
+ if (ObjectUtils.isEmpty(lastYearTqTotal)) lastYearTqTotal = BigDecimal.valueOf(0);
|
|
|
+ finalContractDataInfoVo.setContractYearTq(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.getContractNumYearTotalByTasknoListAndByQsrqRange(tasknoList, currentMothBginDate, currentMothEndDate);
|
|
|
+ if (ObjectUtils.isEmpty(currentMonthTotal)) currentMonthTotal = BigDecimal.valueOf(0);
|
|
|
+ finalContractDataInfoVo.setContractMonthTotal(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.getContractNumYearTotalByTasknoListAndByQsrqRange(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.getContractNumYearTotalByTasknoListAndByQsrqRange(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 contractYearTb = BigDecimal.valueOf(1);
|
|
|
+ if (lastYearTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
|
|
|
+ contractYearTb = YearDifference.divide(lastYearTqTotal, 2, RoundingMode.HALF_UP);
|
|
|
+ finalContractDataInfoVo.setContractYearTb(contractYearTb);
|
|
|
+ }).join();
|
|
|
+
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ BigDecimal currentMonthTotal = currentMonthTotalList.get(0);
|
|
|
+ BigDecimal lastMothTqTotal = lastMothTqTotalList.get(0);
|
|
|
+ BigDecimal MothDifference = currentMonthTotal.subtract(lastMothTqTotal);
|
|
|
+ BigDecimal contractMothHb = BigDecimal.valueOf(1);
|
|
|
+ if (lastMothTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
|
|
|
+ contractMothHb = MothDifference.divide(lastMothTqTotal, 2, RoundingMode.HALF_UP);
|
|
|
+ finalContractDataInfoVo.setContractMonthHb(contractMothHb);
|
|
|
+ }).join();
|
|
|
+
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ BigDecimal currentMonthTotal = currentMonthTotalList.get(0);
|
|
|
+ BigDecimal lastYearMonthTqTotal = lastYearMonthTqTotalList.get(0);
|
|
|
+ BigDecimal yearMothDifference = currentMonthTotal.subtract(lastYearMonthTqTotal);
|
|
|
+ BigDecimal contractYearMothTb = BigDecimal.valueOf(1);
|
|
|
+ if (lastYearMonthTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
|
|
|
+ contractYearMothTb = yearMothDifference.divide(lastYearMonthTqTotal, 2, RoundingMode.HALF_UP);
|
|
|
+ finalContractDataInfoVo.setContractMonthTb(contractYearMothTb);
|
|
|
+ }).join();
|
|
|
+
|
|
|
+ redisUtil.set(CONTRACT_DATA_REDIS_KEY + depart, finalContractDataInfoVo, 1000L * 60 * 60 * 2);
|
|
|
+
|
|
|
|
|
|
- return finalIncomeDataInfoVO;
|
|
|
+ return finalContractDataInfoVo;
|
|
|
}
|
|
|
|
|
|
public void setZeroYear(Calendar instance) {
|