From 4f278d6bb07a89e617da96d91a626509a249f011 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Wed, 23 Sep 2020 17:52:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=BD=E5=8A=9B=E6=8C=87=E6=A0=87=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen/dto/form/AblityIndexFormDTO.java | 8 +++ .../dao/fact/FactIndexAgencyScoreDao.java | 11 ++++ .../dao/fact/FactIndexCommunityScoreDao.java | 41 +++++++++++++ .../dao/fact/FactIndexGridScoreDao.java | 31 ++++++++++ .../dao/fact/FactIndexGridSubScoreDao.java | 31 ++++++++++ .../fact/impl/FactIndexServiceImpl.java | 58 ++++++++++++++++--- .../mapper/fact/FactIndexAgencyScoreDao.xml | 23 ++++++++ .../fact/FactIndexCommunityScoreDao.xml | 29 ++++++++++ .../mapper/fact/FactIndexGridScoreDao.xml | 7 +++ .../mapper/fact/FactIndexGridSubScoreDao.xml | 7 +++ 10 files changed, 238 insertions(+), 8 deletions(-) create mode 100644 epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexCommunityScoreDao.java create mode 100644 epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexGridScoreDao.java create mode 100644 epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexGridSubScoreDao.java create mode 100644 epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml create mode 100644 epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml create mode 100644 epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridSubScoreDao.xml diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AblityIndexFormDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AblityIndexFormDTO.java index 66da4e0e9e..bdf6aa34c5 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AblityIndexFormDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AblityIndexFormDTO.java @@ -14,6 +14,10 @@ import java.io.Serializable; @Data public class AblityIndexFormDTO implements Serializable { private static final long serialVersionUID = -2880432640584616651L; + /** + * 查询月份的前12个月对应的monthId + */ + private String startMonthId; /** * 组织Id */ @@ -29,6 +33,10 @@ public class AblityIndexFormDTO implements Serializable { */ @NotBlank(message = "月份ID不能为空",groups = {AblityIndexFormDTO.AddUserInternalGroup.class}) private String monthId; + /** + * 类型(党建能力:dangjiannengli;治理能力:zhilinengli;服务能力:fuwunengli;) + */ + private String indexCode; public interface AddUserInternalGroup {} } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexAgencyScoreDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexAgencyScoreDao.java index 0ca569e995..b57cb76571 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexAgencyScoreDao.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexAgencyScoreDao.java @@ -17,10 +17,14 @@ package com.epmet.datareport.dao.fact; +import com.epmet.evaluationindex.screen.dto.form.AblityIndexFormDTO; import com.epmet.evaluationindex.screen.dto.form.ScoreListFormDTO; +import com.epmet.evaluationindex.screen.dto.result.AblityIndexResultDTO; import com.epmet.evaluationindex.screen.dto.result.ScoreListResultDTO; import org.apache.ibatis.annotations.Mapper; +import java.util.LinkedList; + /** * 区/街道相关分数表 * @@ -36,4 +40,11 @@ public interface FactIndexAgencyScoreDao { * @author sun */ ScoreListResultDTO selectScore(ScoreListFormDTO formDTO); + + /** + * @param formDTO + * @Description 分别查询区县、乡镇街道过去12个月党建能力、治理能力、服务能力每月总分、本级得分、下级得分数据 + * @author sun + */ + LinkedList selectAblityIndex(AblityIndexFormDTO formDTO); } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexCommunityScoreDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexCommunityScoreDao.java new file mode 100644 index 0000000000..ed9be12d6d --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexCommunityScoreDao.java @@ -0,0 +1,41 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.datareport.dao.fact; + +import com.epmet.evaluationindex.screen.dto.form.AblityIndexFormDTO; +import com.epmet.evaluationindex.screen.dto.result.AblityIndexResultDTO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.LinkedList; + +/** + * 社区相关分数表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-02 + */ +@Mapper +public interface FactIndexCommunityScoreDao { + + /** + * @param formDTO + * @Description 分别查询社区过去12个月党建能力、治理能力、服务能力每月总分、本级得分、下级得分数据 + * @author sun + */ + LinkedList selectCommunityAblityIndex(AblityIndexFormDTO formDTO); +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexGridScoreDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexGridScoreDao.java new file mode 100644 index 0000000000..7944793f56 --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexGridScoreDao.java @@ -0,0 +1,31 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.datareport.dao.fact; + +import org.apache.ibatis.annotations.Mapper; + +/** + * 网格相关分值记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-02 + */ +@Mapper +public interface FactIndexGridScoreDao { + +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexGridSubScoreDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexGridSubScoreDao.java new file mode 100644 index 0000000000..2edc0a1965 --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/FactIndexGridSubScoreDao.java @@ -0,0 +1,31 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.datareport.dao.fact; + +import org.apache.ibatis.annotations.Mapper; + +/** + * 网格相关分值记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-02 + */ +@Mapper +public interface FactIndexGridSubScoreDao { + +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java index 52a9fe1d7a..0ee79681fb 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java @@ -2,7 +2,6 @@ package com.epmet.datareport.service.fact.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.exception.ErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.constant.DataSourceConstant; import com.epmet.datareport.constant.FactConstant; @@ -10,6 +9,7 @@ import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerAgencyDao; import com.epmet.datareport.dao.evaluationindex.screen.ScreenIndexDataMonthlyDao; import com.epmet.datareport.dao.fact.FactIndexAgencyScoreDao; import com.epmet.datareport.dao.fact.FactIndexAgencySubScoreDao; +import com.epmet.datareport.dao.fact.FactIndexCommunityScoreDao; import com.epmet.datareport.dao.fact.FactIndexCommunitySubScoreDao; import com.epmet.datareport.service.fact.FactIndexService; import com.epmet.evaluationindex.screen.dto.form.*; @@ -19,7 +19,10 @@ import org.springframework.stereotype.Service; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.List; /** * 数据改版api @@ -39,6 +42,8 @@ public class FactIndexServiceImpl implements FactIndexService { @Autowired private FactIndexAgencySubScoreDao factIndexAgencySubScoreDao; @Autowired + private FactIndexCommunityScoreDao factIndexCommunityScoreDao; + @Autowired private FactIndexCommunitySubScoreDao factIndexCommunitySubScoreDao; /** @@ -49,15 +54,47 @@ public class FactIndexServiceImpl implements FactIndexService { @Override public List ablityIndex(AblityIndexFormDTO formDTO) { LinkedList resultDTO = new LinkedList<>(); - //分别查询过去12个月党建能力、治理能力、服务能力各自总分乘权重后的分值,每个月份三个分值的加和就是当月的能力指数的分值 fact_index_agency_score 按月份升序 - //1.查询组织过去12个月党建能力指标 - //LinkedList djList = factIndexAgencyScoreDao.; LinkedList djList = null; - //2.查询组织过去12个月治理能力指标 LinkedList zlList = null; - //3.查询组织过去12个月服务能力指标 LinkedList fwList = null; - //4.遍历计算每个月能力指数 + //分别查询过去12个月党建能力、治理能力、服务能力各自总分乘权重后的分值,每个月份三个分值的加和就是当月的能力指数的分值 fact_index_agency_score 按月份升序 + //1.计算所查月份前12个月的monthId + formDTO.setStartMonthId(getDate(formDTO.getMonthId())); + //2.根据组织Id查询组织信息 + CompartmentResultDTO agency = screenCustomerAgencyDao.getAgencyAreaInfo(formDTO.getAgencyId()); + if (null == agency) { + throw new RenException(String.format("根据组织Id未查询到组织信息,组织Id:%s", formDTO.getAgencyId())); + } + //1.根据组织级别判断查询哪类数据表 + //区县级、乡镇街道级 + if ("district".equals(agency.getLevel()) || "street".equals(agency.getLevel())) { + //2-1.查询过去12个月党建能力每月总分、本级得分、下级得分数据(不想写union) + formDTO.setIndexCode(FactConstant.DJNL); + djList = factIndexAgencyScoreDao.selectAblityIndex(formDTO); + //2-2.查询过去12个月治理能力每月总分、本级得分、下级得分数据 + formDTO.setIndexCode(FactConstant.ZLNL); + zlList = factIndexAgencyScoreDao.selectAblityIndex(formDTO); + //2-3.查询过去12个月服务能力每月总分、本级得分、下级得分数据 + formDTO.setIndexCode(FactConstant.FWNL); + fwList = factIndexAgencyScoreDao.selectAblityIndex(formDTO); + + //社区级 + } else if ("community".equals(agency.getLevel())) { + //2-1.查询过去12个月党建能力每月总分、本级得分、下级得分数据 + formDTO.setIndexCode(FactConstant.DJNL); + djList = factIndexCommunityScoreDao.selectCommunityAblityIndex(formDTO); + //2-2.查询过去12个月治理能力每月总分、本级得分、下级得分数据 + formDTO.setIndexCode(FactConstant.ZLNL); + zlList = factIndexCommunityScoreDao.selectCommunityAblityIndex(formDTO); + //2-3.查询过去12个月服务能力每月总分、本级得分、下级得分数据 + formDTO.setIndexCode(FactConstant.FWNL); + fwList = factIndexCommunityScoreDao.selectCommunityAblityIndex(formDTO); + + } else { + throw new RenException(String.format("根据组织Id查询到的组织级别信息错误,组织Id:%s", formDTO.getAgencyId())); + } + + //3.遍历计算每个月能力指数 LinkedList nlList = new LinkedList<>(); for (int i = 0; i < djList.size(); i++) { AblityIndexResultDTO.ScoreListResultDTO nldto = new AblityIndexResultDTO.ScoreListResultDTO(); @@ -180,6 +217,11 @@ public class FactIndexServiceImpl implements FactIndexService { return resultList; } + /** + * @param newDate + * @Description 计算monthId对应一年前的monthId + * @author sun + */ public String getDate(String newDate) { String date = ""; SimpleDateFormat sdf = new SimpleDateFormat("yyyymm"); diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml index 4ecea63f0a..87a08ed389 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml @@ -7,4 +7,27 @@ + + diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml new file mode 100644 index 0000000000..10756a9e75 --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml new file mode 100644 index 0000000000..4ff2a2b66c --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridSubScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridSubScoreDao.xml new file mode 100644 index 0000000000..ff7c0031c7 --- /dev/null +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridSubScoreDao.xml @@ -0,0 +1,7 @@ + + + + + + +