From 512687903465293d48b6145db1df68b49742a71f Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Wed, 24 Jun 2020 12:11:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=AE=E9=A2=98=E6=95=B0=E6=8D=AE=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/issue/impl/IssueServiceImpl.java | 82 +++++++++++++------ .../main/resources/mapper/issue/IssueDao.xml | 2 +- .../java/com/epmet/DataStatsApplication.java | 2 + 3 files changed, 61 insertions(+), 25 deletions(-) diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/issue/impl/IssueServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/issue/impl/IssueServiceImpl.java index 4271cbe29e..207a7f9c30 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/issue/impl/IssueServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/issue/impl/IssueServiceImpl.java @@ -2,6 +2,7 @@ package com.epmet.service.issue.impl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.DateUtils; import com.epmet.dao.issue.IssueDao; import com.epmet.dto.form.LoginUserDetailsFormDTO; import com.epmet.dto.result.LoginUserDetailsResultDTO; @@ -17,6 +18,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -35,15 +37,29 @@ public class IssueServiceImpl implements IssueService { IssueSummaryInfoResultDTO result = new IssueSummaryInfoResultDTO(); String agencyId = getAgencyId(tokenDto); IssueDataDTO data = issueDao.selectAgencyInfo(agencyId); - result.setAgencyId(agencyId); - result.setDateName(data.getDateName()); - result.setIssueTotal(data.getIssueTotal()); - result.setVotingTotal(data.getVotingTotal()); - result.setShiftProjectTotal(data.getShiftProjectTotal()); - result.setClosedTotal(data.getClosedTotal()); - result.setVotingRatio(toRatio(data.getVotingPercent())); - result.setShiftProjectRatio(toRatio(data.getShiftProjectPercent())); - result.setClosedRatio(toRatio(data.getClosedPercent())); + if (null == data) { + //获取当前日期前一天 + Date date = DateUtils.getBeforeDay(new Date()); + result.setAgencyId(agencyId); + result.setDateName(DateUtils.format(date, "yyyy.MM.dd")); + result.setIssueTotal(NumConstant.ZERO); + result.setVotingTotal(NumConstant.ZERO); + result.setShiftProjectTotal(NumConstant.ZERO); + result.setClosedTotal(NumConstant.ZERO); + result.setVotingRatio("0%"); + result.setShiftProjectRatio("0%"); + result.setClosedRatio("0%"); + } else { + result.setAgencyId(agencyId); + result.setDateName(data.getDateName()); + result.setIssueTotal(data.getIssueTotal()); + result.setVotingTotal(data.getVotingTotal()); + result.setShiftProjectTotal(data.getShiftProjectTotal()); + result.setClosedTotal(data.getClosedTotal()); + result.setVotingRatio(toRatio(data.getVotingPercent())); + result.setShiftProjectRatio(toRatio(data.getShiftProjectPercent())); + result.setClosedRatio(toRatio(data.getClosedPercent())); + } return result; } @@ -52,21 +68,39 @@ public class IssueServiceImpl implements IssueService { List list = new ArrayList<>(); String agencyId = getAgencyId(tokenDto); IssueDataDTO data = issueDao.selectAgencyInfo(agencyId); - IssueSummaryPieResultDTO voting = new IssueSummaryPieResultDTO(); - voting.setName(IssueConstant.VOTING_NAME); - voting.setValue(data.getVotingTotal()); - voting.setRatio(toRatio(data.getVotingPercent())); - list.add(voting); - IssueSummaryPieResultDTO shift = new IssueSummaryPieResultDTO(); - shift.setName(IssueConstant.SHIFT_NAME); - shift.setValue(data.getShiftProjectTotal()); - shift.setRatio(toRatio(data.getShiftProjectPercent())); - list.add(shift); - IssueSummaryPieResultDTO closed = new IssueSummaryPieResultDTO(); - closed.setName(IssueConstant.CLOSED_NAME); - closed.setValue(data.getClosedTotal()); - closed.setRatio(toRatio(data.getClosedPercent())); - list.add(closed); + if (null == data) { + IssueSummaryPieResultDTO voting = new IssueSummaryPieResultDTO(); + voting.setName(IssueConstant.VOTING_NAME); + voting.setValue(NumConstant.ZERO); + voting.setRatio("0%"); + list.add(voting); + IssueSummaryPieResultDTO shift = new IssueSummaryPieResultDTO(); + shift.setName(IssueConstant.SHIFT_NAME); + shift.setValue(NumConstant.ZERO); + shift.setRatio("0%"); + list.add(shift); + IssueSummaryPieResultDTO closed = new IssueSummaryPieResultDTO(); + closed.setName(IssueConstant.CLOSED_NAME); + closed.setValue(NumConstant.ZERO); + closed.setRatio("0%"); + list.add(closed); + } else { + IssueSummaryPieResultDTO voting = new IssueSummaryPieResultDTO(); + voting.setName(IssueConstant.VOTING_NAME); + voting.setValue(data.getVotingTotal()); + voting.setRatio(toRatio(data.getVotingPercent())); + list.add(voting); + IssueSummaryPieResultDTO shift = new IssueSummaryPieResultDTO(); + shift.setName(IssueConstant.SHIFT_NAME); + shift.setValue(data.getShiftProjectTotal()); + shift.setRatio(toRatio(data.getShiftProjectPercent())); + list.add(shift); + IssueSummaryPieResultDTO closed = new IssueSummaryPieResultDTO(); + closed.setName(IssueConstant.CLOSED_NAME); + closed.setValue(data.getClosedTotal()); + closed.setRatio(toRatio(data.getClosedPercent())); + list.add(closed); + } return list; } diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/issue/IssueDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/issue/IssueDao.xml index bb9e3b4747..468f4c7a89 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/issue/IssueDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/issue/IssueDao.xml @@ -13,7 +13,7 @@ CLOSED_TOTAL, CLOSED_PERCENT, MAX(DATE_ID) AS DATE_ID, - DATE_FORMAT(DATE_ID, '%Y.%m.%d') AS DATE_NAME + DATE_FORMAT(MAX(DATE_ID), '%Y.%m.%d') AS DATE_NAME FROM fact_issue_agency_daily fiad WHERE DEL_FLAG = '0' diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java index 7da757a418..ad4e2110fa 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java @@ -3,8 +3,10 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.scheduling.annotation.EnableAsync; @SpringBootApplication (exclude = {DataSourceAutoConfiguration.class}) +@EnableAsync public class DataStatsApplication { public static void main(String[] args) {