|
@@ -29,6 +29,7 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.Year;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
@@ -85,12 +86,13 @@ 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 CONTRACT_CHART_INFO_DATA_REDIS_KEY = "ContractChartInfoVoDataRedisKey:";
|
|
|
|
|
|
private static final String YEAR = "year";
|
|
|
|
|
|
private static final String MONTH = "month";
|
|
|
|
|
|
+ /*合同额一层*/
|
|
|
@Override
|
|
|
public IncomeDataInfoVo getTotalIncome(HttpServletRequest request) {
|
|
|
//首页收入渲染对象
|
|
@@ -240,6 +242,8 @@ public class IndexServiceImpl implements IndexService {
|
|
|
return finalIncomeDataInfoVo;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /*合同数量一层*/
|
|
|
@Override
|
|
|
public ContractDataInfoVo getTotalContract(HttpServletRequest request) {
|
|
|
//首页合同渲染对象
|
|
@@ -388,6 +392,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /*已收款*/
|
|
|
@Override
|
|
|
public ReceivedDataInfoVo getTotalReceived(HttpServletRequest request) {
|
|
|
BigDecimal initValue = BigDecimal.valueOf(0);
|
|
@@ -553,16 +558,18 @@ public class IndexServiceImpl implements IndexService {
|
|
|
instance.set(Calendar.MILLISECOND, 0);
|
|
|
}
|
|
|
|
|
|
+ /*合同额和合同数量二层图表*/
|
|
|
@Override
|
|
|
- public String getContractAmountInfo(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
|
|
|
+ public ContractChartInfoVo getContractAmountInfo(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
|
|
|
|
|
|
- String resultl;
|
|
|
+ ContractChartInfoVo resultl;
|
|
|
switch (indexInfoParamDto.getTime()) {
|
|
|
case "year":
|
|
|
- resultl = getContractAmountInfoIfYear(request, indexInfoParamDto);
|
|
|
+ resultl = getContractAmountInfo(request, indexInfoParamDto,YEAR);
|
|
|
break;
|
|
|
case "month":
|
|
|
- resultl = getContractAmountInfoIfMonth(request, indexInfoParamDto);
|
|
|
+ resultl = getContractAmountInfo(request, indexInfoParamDto,MONTH);
|
|
|
+ break;
|
|
|
default:
|
|
|
resultl = null;
|
|
|
}
|
|
@@ -571,29 +578,52 @@ 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);
|
|
|
+ public ContractChartInfoVo getContractAmountInfo(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto,String Time) {
|
|
|
+ /*根据传进来年份或者月份初始化返回结果对象*/
|
|
|
+ ContractChartInfoVo resVo = new ContractChartInfoVo();
|
|
|
+ Date beginDate = dateFormat(indexInfoParamDto.getBeginDate(), Time);
|
|
|
+ Date endDate = dateFormat(indexInfoParamDto.getEndDate(), Time);
|
|
|
+ List<Date> pastDates = getPastDates(beginDate, endDate, Time);
|
|
|
+
|
|
|
+ List<BigDecimal> contractAmount = new ArrayList<>();
|
|
|
+ ArrayList<Long> contractTotal = new ArrayList<>();
|
|
|
+ ArrayList<String> xAxisData = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Date pastDate : pastDates) {
|
|
|
+ String parseDateString = getParseDateString(pastDate, Time);
|
|
|
+ xAxisData.add(parseDateString);
|
|
|
+ contractAmount.add(BigDecimal.valueOf(0.00));
|
|
|
+ contractTotal.add(0L);
|
|
|
+ }
|
|
|
+
|
|
|
+ Collections.reverse(contractAmount);
|
|
|
+ Collections.reverse(contractTotal);
|
|
|
+ Collections.reverse(xAxisData);
|
|
|
+
|
|
|
+ resVo.setContractAmount(contractAmount);
|
|
|
+ resVo.setContractTotal(contractTotal);
|
|
|
+ resVo.setXAxisData(xAxisData);
|
|
|
+
|
|
|
+
|
|
|
+ endDate = endDateProcess(endDate, Time);
|
|
|
|
|
|
String userNameByToken = JwtUtil.getUserNameByToken(request);
|
|
|
LoginUser sysUser = sysBaseApi.getUserByName(userNameByToken);
|
|
|
|
|
|
List<String> departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
|
|
|
- if (departNames.isEmpty()) return JSONObject.toJSONString(resVo);
|
|
|
+ if (departNames.isEmpty()) return 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>>() {
|
|
|
+ Object cacheObject = redisUtil.get(CONTRACT_CHART_INFO_DATA_REDIS_KEY + depart);
|
|
|
+ ContractChartInfoVo Object = JSONObject.parseObject(JSONObject.toJSONString(cacheObject), new TypeReference<ContractChartInfoVo>() {
|
|
|
});
|
|
|
if (ObjectUtils.isNotEmpty(cacheObject)) {
|
|
|
resVo = Object;
|
|
|
- return JSONObject.toJSONString(resVo);
|
|
|
+ return resVo;
|
|
|
}
|
|
|
|
|
|
ArrayList<String> tasknoList = new ArrayList<>();
|
|
@@ -601,38 +631,77 @@ public class IndexServiceImpl implements IndexService {
|
|
|
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);
|
|
|
-
|
|
|
-
|
|
|
+ if (tasknoList.isEmpty()) return resVo;
|
|
|
|
|
|
+ List<ContractAmount> contractAmountList = null;
|
|
|
+ if (YEAR.equals(Time)) {
|
|
|
+ contractAmountList = exchangeMapper.getContractAmountandNumByYear(tasknoList, beginDate, endDate);
|
|
|
+ }else {
|
|
|
+ contractAmountList = exchangeMapper.getContractAmountandNumByMonth(tasknoList, beginDate, endDate);
|
|
|
+ }
|
|
|
+ ContractChartInfoVo newResVo = new ContractChartInfoVo();
|
|
|
+ for (ContractAmount amount : contractAmountList) {
|
|
|
+ String dateResult = amount.getDate();
|
|
|
+ BigDecimal contractAmountResult = amount.getContractAmount();
|
|
|
+ Long contractTotalResult = amount.getContractTotal();
|
|
|
+
|
|
|
+ for (int i = 0; i < xAxisData.size(); i++) {
|
|
|
+ if (ObjectUtils.isNotEmpty(dateResult) && xAxisData.get(i).equals(dateResult)){
|
|
|
+ xAxisData.set(i,dateResult);
|
|
|
+ contractAmount.set(i,contractAmountResult);
|
|
|
+ contractTotal.set(i,contractTotalResult);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ newResVo.setXAxisData(xAxisData);
|
|
|
+ newResVo.setContractAmount(contractAmount);
|
|
|
+ newResVo.setContractTotal(contractTotal);
|
|
|
|
|
|
+ return newResVo;
|
|
|
+ }
|
|
|
|
|
|
+ public String getParseDateString(Date date, String time) {
|
|
|
+ if (YEAR.equals(time)) {
|
|
|
+ SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");
|
|
|
+ return yearFormat.format(date);
|
|
|
+ } else if (MONTH.equals(time)) {
|
|
|
+ SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
+ return monthFormat.format(date);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
+ public List<Date> getPastDates(Date beginDate, Date endDate, String time) {
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+ instance.setTime(endDate);
|
|
|
|
|
|
+ ArrayList<Date> dates = new ArrayList<>();
|
|
|
|
|
|
+ Date pastDate = endDate;
|
|
|
+ dates.add(endDate);
|
|
|
+ while (pastDate.compareTo(beginDate) > 0) {
|
|
|
+ if (YEAR.equals(time)) {
|
|
|
+ instance.add(Calendar.YEAR, -1);
|
|
|
+ } else if (MONTH.equals(time)) {
|
|
|
+ instance.add(Calendar.MONTH, -1);
|
|
|
+ }
|
|
|
+ pastDate = instance.getTime();
|
|
|
+ dates.add(pastDate);
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
+ return dates;
|
|
|
}
|
|
|
|
|
|
- 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");
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
public Date endDateProcess(Date endDate, String time) {
|
|
|
Calendar instance = Calendar.getInstance();
|
|
|
instance.setTime(endDate);
|
|
|
- if ("year".equals(time)) {
|
|
|
+ if (YEAR.equals(time)) {
|
|
|
instance.add(Calendar.YEAR, 1);
|
|
|
- } else if ("month".equals(time)) {
|
|
|
+ } else if (MONTH.equals(time)) {
|
|
|
instance.add(Calendar.MONTH, 1);
|
|
|
}
|
|
|
return instance.getTime();
|
|
@@ -640,14 +709,14 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
public Date dateFormat(String DateString, String time) {
|
|
|
switch (time) {
|
|
|
- case "year":
|
|
|
+ case YEAR:
|
|
|
SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");
|
|
|
try {
|
|
|
return yearFormat.parse(DateString);
|
|
|
} catch (ParseException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
- case "month":
|
|
|
+ case MONTH:
|
|
|
SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
try {
|
|
|
return monthFormat.parse(DateString);
|