diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index ca81ce0ba7..a25e563a07 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java @@ -50,6 +50,7 @@ import com.epmet.service.org.CustomerGridService; import com.epmet.service.stats.DimAgencyService; import com.epmet.service.stats.DimCustomerPartymemberService; import com.epmet.service.stats.DimCustomerService; +import com.epmet.util.DimIdGenerator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -59,6 +60,8 @@ import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -695,10 +698,22 @@ public class DemoController { @PostMapping("governRankDaily") public Result governRankDaily(@RequestBody CustomerIdAndDateIdFormDTO formDTO){ - governRankDataExtractService.extractGridDataDaily(formDTO.getCustomerId(), formDTO.getDateId()); - governRankDataExtractService.extractCommunityDataDaily(formDTO.getCustomerId(), formDTO.getDateId()); - governRankDataExtractService.extractStreetDataDaily(formDTO.getCustomerId(), formDTO.getDateId()); - governRankDataExtractService.extractDistrictDataDaily(formDTO.getCustomerId(), formDTO.getDateId()); + List dateIds = new ArrayList<>(); + if ((StringUtils.isBlank(formDTO.getStartDate()) && StringUtils.isBlank(formDTO.getEndDate()))){ + if (StringUtils.isNotBlank(formDTO.getDateId())){ + dateIds.add(formDTO.getDateId()); + }else { + dateIds.add(DimIdGenerator.getDateDimId(DateUtils.addDateDays(new Date(), -1))); + } + }else { + dateIds = DateUtils.getDaysBetween(formDTO.getStartDate(), formDTO.getEndDate()); + } + dateIds.forEach(dateId -> { + governRankDataExtractService.extractGridDataDaily(formDTO.getCustomerId(), dateId); + governRankDataExtractService.extractCommunityDataDaily(formDTO.getCustomerId(), dateId); + governRankDataExtractService.extractStreetDataDaily(formDTO.getCustomerId(), dateId); + governRankDataExtractService.extractDistrictDataDaily(formDTO.getCustomerId(), dateId); + }); return new Result(); }