From 63669ff304f3dcafceb0486d06500deff39e8763 Mon Sep 17 00:00:00 2001 From: V26772074 Date: Fri, 16 Aug 2024 09:49:31 +0800 Subject: [PATCH] update --- .../impl/IndicatorStatisticsServiceImpl.java | 71 ++++++++++++++++++- .../mapper/BiddingProjectSubscribeMapper.xml | 6 +- 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/jnpf-tendering-biz/src/main/java/jnpf/service/impl/IndicatorStatisticsServiceImpl.java b/jnpf-tendering-biz/src/main/java/jnpf/service/impl/IndicatorStatisticsServiceImpl.java index eee1325..e94a99a 100644 --- a/jnpf-tendering-biz/src/main/java/jnpf/service/impl/IndicatorStatisticsServiceImpl.java +++ b/jnpf-tendering-biz/src/main/java/jnpf/service/impl/IndicatorStatisticsServiceImpl.java @@ -7,6 +7,8 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import jnpf.base.DictionaryDataApi; +import jnpf.base.entity.DictionaryDataEntity; import jnpf.entity.Bidding_project_statisticsEntity; import jnpf.exception.DataException; import jnpf.model.dto.IndicatorStatisticsDto; @@ -27,6 +29,7 @@ import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; @Service @AllArgsConstructor @@ -35,6 +38,7 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic private final BiddingProjectSubscribeService biddingProjectSubscribeService; private final CustomAuthService customAuthService; private final UserProvider userProvider; + private final DictionaryDataApi dictionaryDataApi; @Override @@ -100,7 +104,11 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic } LocalDateTime month = LocalDateTimeUtil.parse(param.getCorresponding(), "yyyy-MM"); YearMonth yearMonth = YearMonth.from(month); - for (int day = 1; day <= yearMonth.lengthOfMonth(); day++) { + int i = yearMonth.lengthOfMonth(); + if (LocalDateTimeUtil.parse(LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM"), "yyyy-MM").isEqual(LocalDateTimeUtil.parse(param.getCorresponding(), "yyyy-MM"))){ + i=LocalDateTime.now().getDayOfMonth(); + } + for (int day = 1; day <= i; day++) { IndicatorStatisticsDto.Indicator indicator = new IndicatorStatisticsDto.Indicator(); indicator.setYData("0"); // 创建代表该日期的LocalDate对象 @@ -112,6 +120,7 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic } break; case "2": + int value = LocalDateTime.now().getMonth().getValue(); if (StrUtil.isBlank(param.getCorresponding())) { String yyyy = LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy"); param.setCorresponding(yyyy); @@ -120,11 +129,14 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic //校验时间格式 try { response.setCorresponding(LocalDateTimeUtil.parse(param.getCorresponding(), "yyyy")); + if (LocalDateTime.now().getYear()>LocalDateTimeUtil.parse(param.getCorresponding(), "yyyy").getYear()){ + value = 12; + } } catch (Exception e) { throw new DataException("dataTime parse error, must be yyyy"); } } - for (int monthCount = 1; monthCount <= 12; monthCount++) { + for (int monthCount = 1; monthCount <= value; monthCount++) { IndicatorStatisticsDto.Indicator indicator = new IndicatorStatisticsDto.Indicator(); indicator.setYData("0"); String monthString = String.format("%02d", monthCount); @@ -149,10 +161,65 @@ public class IndicatorStatisticsServiceImpl implements IndicatorStatisticsServic } assert queryWhere != null; List dataList = biddingProjectSubscribeService.moneyAndProjectsNumber(param, queryWhere.getParamNameValuePairs(), queryWhere.getSqlSegment().replace("paramNameValuePairs.", "")); + checkMoneyAndProjectsNumberResult(param,dataList); response.setDataList(dataList); return response; } + private void checkMoneyAndProjectsNumberResult(IndicatorStatisticsDto.MoneyAndProjectsNumberParam param, List dataList) { +// +// count(organizational_form) projectsNumber, +// (select f_full_name from base_dictionary_data where f_dictionary_type_id='539393647729185989' and f_en_code=main.organizational_form limit 1) yName +// +// +// count(Item_classification) projectsNumber, +// (select f_full_name from base_dictionary_data where f_dictionary_type_id='539390743437907141' and f_en_code=main.item_classification limit 1) yName +// +// +// count(bidding_method) projectsNumber, +// (select f_full_name from base_dictionary_data where f_dictionary_type_id='539394095383057605' and f_en_code=main.bidding_method limit 1) yName +// + String classificationType = param.getClassificationType(); + List oldNameList = dataList.stream().map(IndicatorStatisticsDto.MoneyAndProjectsNumberChild::getYName).collect(Collectors.toList()); + List newNameList=new ArrayList<>(); + switch (classificationType){ + case "1": + break; + case "2": + newNameList = dictionaryDataApi.getList("539393647729185989") + .stream() + .map(DictionaryDataEntity::getFullName) + .filter(fullName -> !oldNameList.contains(fullName)) + .collect(Collectors.toList()); + break; + case "3": + newNameList = dictionaryDataApi.getList("539390743437907141") + .stream() + .map(DictionaryDataEntity::getFullName) + .filter(fullName -> !oldNameList.contains(fullName)) + .collect(Collectors.toList()); + break; + case "4": + newNameList = dictionaryDataApi.getList("539394095383057605") + .stream() + .map(DictionaryDataEntity::getFullName) + .filter(fullName -> !oldNameList.contains(fullName)) + .collect(Collectors.toList()); + break; + + } + if (CollectionUtil.isEmpty(newNameList)){ + return; + } + for (String name : newNameList) { + IndicatorStatisticsDto.MoneyAndProjectsNumberChild data = new IndicatorStatisticsDto.MoneyAndProjectsNumberChild(); + data.setYName(name); + data.setProjectsNumber("0"); + data.setMoney("0.0"); + dataList.add(data); + } + } + private IndicatorStatisticsDto.MoneyAndProjectsNumberResponse checkMoneyAndProjectsNumberParam(IndicatorStatisticsDto.MoneyAndProjectsNumberParam param) { IndicatorStatisticsDto.MoneyAndProjectsNumberResponse response = new IndicatorStatisticsDto.MoneyAndProjectsNumberResponse(); if (StrUtil.isBlank(param.getMenuId())) { diff --git a/jnpf-tendering-biz/src/main/resources/mapper/BiddingProjectSubscribeMapper.xml b/jnpf-tendering-biz/src/main/resources/mapper/BiddingProjectSubscribeMapper.xml index 2b55986..8946044 100644 --- a/jnpf-tendering-biz/src/main/resources/mapper/BiddingProjectSubscribeMapper.xml +++ b/jnpf-tendering-biz/src/main/resources/mapper/BiddingProjectSubscribeMapper.xml @@ -227,13 +227,13 @@ and ${sql}) - group by organizational_form + group by organizational_form order by count(organizational_form) desc - group by Item_classification + group by Item_classification order by count(Item_classification) desc - group by bidding_method + group by bidding_method order by count(bidding_method) desc