|
@@ -1,5 +1,7 @@
|
|
|
package org.jeecg.modules.Index.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.alibaba.fastjson2.TypeReference;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
@@ -8,10 +10,8 @@ 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.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.entity.pojo.ContractAmount;
|
|
|
+import org.jeecg.modules.Index.entity.vo.*;
|
|
|
import org.jeecg.modules.Index.service.IndexService;
|
|
|
import org.jeecg.modules.kyTaskInfo.service.IKyTaskInfoService;
|
|
|
import org.jeecg.modules.projectCost.entity.ProjectCost;
|
|
@@ -27,6 +27,8 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
@@ -83,6 +85,11 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
private static final String RECEIVED_DATA_REDIS_KEY = "receivedDataRedisKey:";
|
|
|
|
|
|
+ private static final String CONTRACT_AMOUNT_VO_DATA_REDIS_KEY = "ContractAmountVoDataRedisKey:";
|
|
|
+
|
|
|
+ private static final String YEAR = "year";
|
|
|
+
|
|
|
+ private static final String MONTH = "month";
|
|
|
|
|
|
@Override
|
|
|
public IncomeDataInfoVo getTotalIncome(HttpServletRequest request) {
|
|
@@ -556,8 +563,6 @@ public class IndexServiceImpl implements IndexService {
|
|
|
break;
|
|
|
case "month":
|
|
|
resultl = getContractAmountInfoIfMonth(request, indexInfoParamDto);
|
|
|
- case "day":
|
|
|
- resultl = getContractAmountInfoIfDay(request, indexInfoParamDto);
|
|
|
default:
|
|
|
resultl = null;
|
|
|
}
|
|
@@ -567,22 +572,89 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
|
|
|
public String getContractAmountInfoIfYear(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
|
|
|
+ IndexChartInfoVo<ContractAmountVo> resVo = new IndexChartInfoVo<>();
|
|
|
+ Date beginDate = dateFormat(indexInfoParamDto.getBeginDate(), YEAR);
|
|
|
+ Date endDate = dateFormat(indexInfoParamDto.getEndDate(), YEAR);
|
|
|
+ endDate = endDateProcess(endDate, YEAR);
|
|
|
+
|
|
|
+ String userNameByToken = JwtUtil.getUserNameByToken(request);
|
|
|
+ LoginUser sysUser = sysBaseApi.getUserByName(userNameByToken);
|
|
|
+
|
|
|
+ List<String> departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
|
|
|
+ if (departNames.isEmpty()) return JSONObject.toJSONString(resVo);
|
|
|
+
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ for (String departName : departNames) {
|
|
|
+ stringBuilder.append(departName).append("|");
|
|
|
+ }
|
|
|
+ String depart = stringBuilder.toString();
|
|
|
+ Object cacheObject = redisUtil.get(RECEIVED_DATA_REDIS_KEY + depart);
|
|
|
+ IndexChartInfoVo<ContractAmountVo> Object = JSONObject.parseObject(JSONObject.toJSONString(cacheObject), new TypeReference<IndexChartInfoVo<ContractAmountVo>>() {
|
|
|
+ });
|
|
|
+ if (ObjectUtils.isNotEmpty(cacheObject)) {
|
|
|
+ resVo = Object;
|
|
|
+ return JSONObject.toJSONString(resVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 JSONObject.toJSONString(resVo);
|
|
|
+
|
|
|
+ List<ContractAmount> contractAmount = exchangeMapper.getContractAmountandNumByYear(tasknoList,beginDate,endDate);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
- public String getContractAmountInfoIfMonth(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
|
|
|
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ public String getContractAmountInfoIfMonth(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
|
|
|
+ IndexChartInfoVo<ContractAmountVo> resVo = new IndexChartInfoVo<>();
|
|
|
+ Date beginDate = dateFormat(indexInfoParamDto.getBeginDate(), "month");
|
|
|
+ Date endDate = dateFormat(indexInfoParamDto.getEndDate(), "month");
|
|
|
+ endDate = endDateProcess(endDate, "month");
|
|
|
|
|
|
- public String getContractAmountInfoIfDay(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
+ public Date endDateProcess(Date endDate, String time) {
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+ instance.setTime(endDate);
|
|
|
+ if ("year".equals(time)) {
|
|
|
+ instance.add(Calendar.YEAR, 1);
|
|
|
+ } else if ("month".equals(time)) {
|
|
|
+ instance.add(Calendar.MONTH, 1);
|
|
|
+ }
|
|
|
+ return instance.getTime();
|
|
|
+ }
|
|
|
|
|
|
+ public Date dateFormat(String DateString, String time) {
|
|
|
+ switch (time) {
|
|
|
+ case "year":
|
|
|
+ SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");
|
|
|
+ try {
|
|
|
+ return yearFormat.parse(DateString);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ case "month":
|
|
|
+ SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
+ try {
|
|
|
+ return monthFormat.parse(DateString);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|