From 84b06adb5ecc2fe9196fc908be2bfdcbf3c3f0e9 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 22 Sep 2020 16:44:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8C=87=E6=A0=87=E6=B7=BB=E5=8A=A0=20?= =?UTF-8?q?=E6=89=80=E6=9C=89=E6=8C=87=E6=A0=87=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/indexcal/GridSubScoreDTO.java | 52 +++++++++++++++++++ .../indexcal/GridSubScoreDao.java | 18 +++++-- .../evaluationindex/screen/IndexGroupDao.java | 2 + .../screen/IndexGroupDetailDao.java | 2 + .../screen/IndexGroupDetailEntity.java | 7 ++- .../IndexGroupDetailTemplateEntity.java | 7 ++- .../screen/IndexGroupEntity.java | 17 +++--- .../screen/IndexGroupTemplateEntity.java | 17 +++--- .../epmet/model/IndexExcelDataListener.java | 9 +++- .../main/java/com/epmet/model/IndexModel.java | 42 +++++++++++++++ .../impl/GridCorreLationServiceImpl.java | 17 ++++++ .../screen/impl/IndexGroupServiceImpl.java | 20 +++---- .../evaluationindex/indexcal/GridScoreDao.xml | 4 +- .../indexcal/GridSubScoreDao.xml | 32 ++++++++++++ .../evaluationindex/screen/IndexGroupDao.xml | 4 ++ .../screen/IndexGroupDetailDao.xml | 6 ++- .../screen/IndexGroupDetailTemplateDao.xml | 2 +- .../screen/IndexGroupTemplateDao.xml | 2 +- 18 files changed, 224 insertions(+), 36 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridSubScoreDTO.java diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridSubScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridSubScoreDTO.java new file mode 100644 index 0000000000..a1624409c2 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridSubScoreDTO.java @@ -0,0 +1,52 @@ +package com.epmet.dto.indexcal; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 网格相关分值 + * + * @author yinzuomei@elink-cn.com + * @date 2020/8/31 16:38 + */ +@Data +public class GridSubScoreDTO implements Serializable { + /** + * 网格Id + */ + private String gridId; + + /** + * 客户Id + */ + private String customerId; + + /** + * 网格所属的机关Id + */ + private String agencyId; + + /** + * 所有上级ID,用英文逗号分开 + */ + private String allParentIds; + + /** + * 季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4 + */ + private String quarterId; + + /** + * 年度ID: yyyy + */ + private String yearId; + + /** + * 月维度Id: yyyyMM + */ + private String monthId; + + private List detailList; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridSubScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridSubScoreDao.java index 1005fcf781..cae75ea905 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridSubScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridSubScoreDao.java @@ -18,6 +18,7 @@ package com.epmet.dao.evaluationindex.indexcal; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.indexcal.GridSubScoreDTO; import com.epmet.entity.evaluationindex.indexcal.GridSubScoreEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -52,7 +53,18 @@ public interface GridSubScoreDao extends BaseDao { * @Date 2020/9/10 13:36 **/ int deleteBatches(@Param("customerId") String customerId, - @Param("monthId") String monthId, - @Param("allParentIndexCode") String allParentIndexCode, - @Param("deleteSize") Integer deleteSize); + @Param("monthId") String monthId, + @Param("allParentIndexCode") String allParentIndexCode, + @Param("deleteSize") Integer deleteSize); + + /** + * desc:获取网格5级指标分数 明细 + * + * @param customerId + * @param monthId + * @param offset + * @param pageSize + * @return + */ + List selectSubListGroup(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("offset") int offset, @Param("pageSize") int pageSize); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/IndexGroupDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/IndexGroupDao.java index 26cb71f2ec..2a3e617b75 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/IndexGroupDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/IndexGroupDao.java @@ -31,4 +31,6 @@ import org.apache.ibatis.annotations.Mapper; public interface IndexGroupDao extends BaseDao { int inertGroupFromTable(String customerId); + + int deleteByCustomerId(String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/IndexGroupDetailDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/IndexGroupDetailDao.java index d67b86e887..85d05705ad 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/IndexGroupDetailDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/IndexGroupDetailDao.java @@ -36,4 +36,6 @@ public interface IndexGroupDetailDao extends BaseDao { List getDetailListByParentCode(@Param("customerId") String customerId, @Param("indexCode") String indexCode); List getAllIndexWeightList(String customerId); + + int deleteByCustomerId(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupDetailEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupDetailEntity.java index 8a1b94fb3c..8db661ce1b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupDetailEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupDetailEntity.java @@ -73,10 +73,15 @@ public class IndexGroupDetailEntity extends BaseEpmetEntity { private BigDecimal threshold; /** - * 所有指标code拼接的字符串 冒号隔开 + * 所有有权重的指标code拼接的字符串 冒号隔开 */ private String allParentIndexCode; + /** + * 所有指标code 冒号隔开 + */ + private String allIndexCodePath; + /** * 正相关:positive;负相关:negative */ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupDetailTemplateEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupDetailTemplateEntity.java index 0d06fe6955..e75d36927b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupDetailTemplateEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupDetailTemplateEntity.java @@ -68,10 +68,15 @@ public class IndexGroupDetailTemplateEntity extends BaseEpmetEntity { private BigDecimal threshold; /** - * 所有指标code拼接的字符串 冒号隔开 + * 所有有权重的指标code拼接的字符串 冒号隔开 */ private String allParentIndexCode; + /** + * 所有指标code 冒号隔开 + */ + private String allIndexCodePath; + /** * 正相关:positive;负相关:negative */ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupEntity.java index dfe57f7d8d..b25f4d1d82 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupEntity.java @@ -50,14 +50,19 @@ public class IndexGroupEntity extends BaseEpmetEntity { */ private String indexCode; - /** - * 是否启用:启用:enable 禁用:disabled - */ + /** + * 是否启用:启用:enable 禁用:disabled + */ private String status; - /** - * 当前指标关联的上一级指标分组,如果没有上一级,则为0 - */ + /** + * 当前指标关联的上一级指标分组,如果没有上一级,则为0 + */ private String parentIndexGroupId; + /** + * 所有指标code 冒号隔开 + */ + private String allIndexCodePath; + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupTemplateEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupTemplateEntity.java index e22f7e6f2f..f8cdc843c5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupTemplateEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/IndexGroupTemplateEntity.java @@ -45,14 +45,19 @@ public class IndexGroupTemplateEntity extends BaseEpmetEntity { */ private String indexCode; - /** - * 是否启用:启用:enable 禁用:disabled - */ + /** + * 是否启用:启用:enable 禁用:disabled + */ private String status; - /** - * 当前指标关联的上一级指标分组,如果没有上一级,则为0 - */ + /** + * 当前指标关联的上一级指标分组,如果没有上一级,则为0 + */ private String parentIndexGroupId; + /** + * 所有指标code 冒号隔开 + */ + private String allIndexCodePath; + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java index 57eead6c35..fc8ec41c57 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java @@ -139,6 +139,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { group1.setParentIndexGroupId("0"); group1.setId(UniqueIdGenerator.generate()); group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), true, 4)); + group1.setAllIndexCodePath(index.getAllIndexCodePath(0)); indexGroupMap.put(index.getLevel1Index(), group1); } StringBuilder allIndexCodeSb = new StringBuilder(group1.getIndexCode()); @@ -154,6 +155,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { group2.setParentIndexGroupId(group1.getId()); group2.setId(UniqueIdGenerator.generate()); group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); + group2.setAllIndexCodePath(index.getAllIndexCodePath(3)); indexGroupMap.put(level4IndexDetailKey, group2); //构建 分组明细 templateEntity = indexGroupDetailMap.get(index.getLevel1Index() + level4Index); @@ -164,6 +166,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); templateEntity.setId(UniqueIdGenerator.generate()); templateEntity.setCorrelation(index.getCorrelation()); + templateEntity.setAllIndexCodePath(index.getAllIndexCodePath(3)); buildIndexGroupDetail(templateEntity, indexDictEntity, index, 2); indexGroupDetailMap.put(index.getLevel1Index() + level4Index, templateEntity); } @@ -181,6 +184,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); templateEntity.setId(UniqueIdGenerator.generate()); templateEntity.setCorrelation(index.getCorrelation()); + templateEntity.setAllIndexCodePath(index.getAllIndexCodePath(4)); buildIndexGroupDetail(templateEntity, indexDictEntity, index, 5); indexGroupDetailMap.put(level5IndexDetailKey, templateEntity); } @@ -195,6 +199,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { group1.setParentIndexGroupId("0"); group1.setId(UniqueIdGenerator.generate()); group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); + group1.setAllIndexCodePath(index.getAllIndexCodePath(0)); indexGroupMap.put(index.getLevel1Index(), group1); } StringBuilder allIndexCodeSb = new StringBuilder(group1.getIndexCode()); @@ -209,7 +214,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { group2.setParentIndexGroupId(group1.getId()); group2.setId(UniqueIdGenerator.generate()); group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); - + group2.setAllIndexCodePath(index.getAllIndexCodePath(1)); indexGroupMap.put(level2IndexGroupKey, group2); //构建 分组明细 templateEntity = indexGroupDetailMap.get(level2IndexGroupKey); @@ -220,6 +225,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); templateEntity.setId(UniqueIdGenerator.generate()); templateEntity.setCorrelation(index.getCorrelation()); + templateEntity.setAllIndexCodePath(index.getAllIndexCodePath(1)); buildIndexGroupDetail(templateEntity, indexDictEntity, index, 2); indexGroupDetailMap.put(level2IndexGroupKey, templateEntity); } @@ -236,6 +242,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); templateEntity.setId(UniqueIdGenerator.generate()); templateEntity.setCorrelation(index.getCorrelation()); + templateEntity.setAllIndexCodePath(index.getAllIndexCodePath(4)); buildIndexGroupDetail(templateEntity, indexDictEntity, index, 5); indexGroupDetailMap.put(level5IndexGroupKey, templateEntity); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexModel.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexModel.java index 77a0fd3138..b2e124ff09 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexModel.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexModel.java @@ -1,6 +1,8 @@ package com.epmet.model; import com.alibaba.excel.annotation.ExcelProperty; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.util.Pinyin4jUtil; import lombok.Data; @Data @@ -29,4 +31,44 @@ public class IndexModel { */ @ExcelProperty(value = "相关性") private String correlation; + + /** + * desc:获取所有codepath 顶级为0 + * + * @param level + * @return + */ + public String getAllIndexCodePath(Integer level) { + StringBuilder result = new StringBuilder(); + switch (level) { + case 1: + result.append(Pinyin4jUtil.getSpellPinYin(level1Index, false, 4)); + break; + case 2: + result.append(Pinyin4jUtil.getSpellPinYin(level1Index, false, 4)) + .append(StrConstant.COLON).append(Pinyin4jUtil.getSpellPinYin(level2Index, false, 4)); + break; + case 3: + result.append(Pinyin4jUtil.getSpellPinYin(level1Index, false, 4)) + .append(StrConstant.COLON).append(Pinyin4jUtil.getSpellPinYin(level2Index, false, 4)) + .append(StrConstant.COLON).append(Pinyin4jUtil.getSpellPinYin(level3Index, false, 4)); + break; + case 4: + result.append(Pinyin4jUtil.getSpellPinYin(level1Index, false, 4)) + .append(StrConstant.COLON).append(Pinyin4jUtil.getSpellPinYin(level2Index, false, 4)) + .append(StrConstant.COLON).append(Pinyin4jUtil.getSpellPinYin(level3Index, false, 4)) + .append(StrConstant.COLON).append(Pinyin4jUtil.getSpellPinYin(level4Index, false, 4)); + break; + case 5: + result.append(Pinyin4jUtil.getSpellPinYin(level1Index, false, 4)) + .append(StrConstant.COLON).append(Pinyin4jUtil.getSpellPinYin(level2Index, false, 4)) + .append(StrConstant.COLON).append(Pinyin4jUtil.getSpellPinYin(level3Index, false, 4)) + .append(StrConstant.COLON).append(Pinyin4jUtil.getSpellPinYin(level4Index, false, 4)) + .append(StrConstant.COLON).append(Pinyin4jUtil.getSpellPinYin(level5Index, false, 4)); + break; + default: + return "0"; + } + return result.toString(); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java index a4d6f3579e..21e398445c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java @@ -90,9 +90,26 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { calculateGridFuWu(formDTO); //4、计算网格相关总分 calculateGridTotal(formDTO); + //4、计算自身和下级的分数 + calculateSelfSubScore(formDTO); return true; } + private void calculateSelfSubScore(CalculateCommonFormDTO formDTO) { + /* List gridIdList = gridScoreDao.selectListGridId(formDTO.getCustomerId(), formDTO.getMonthId()); + if (CollectionUtils.isEmpty(gridIdList)){ + log.warn("calculateSelfSubScore have not any record"); + return; + } + List> partGridIds = ListUtils.partition(gridIdList, NumConstant.ONE_HUNDRED); + partGridIds.forEach(gridIds->{ + int pageNo = NumConstant.ONE; + int pageSize = 2;//NumConstant.ONE_HUNDRED; + List list = gridSubScoreDao.selectSubListGroup(formDTO.getCustomerId(),formDTO.getMonthId(),(pageNo-NumConstant.ONE)*pageSize,pageSize); + });*/ + + } + /** * @param formDTO * @return void diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/IndexGroupServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/IndexGroupServiceImpl.java index e455120eef..50092d64db 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/IndexGroupServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/IndexGroupServiceImpl.java @@ -68,28 +68,22 @@ private IndexGroupTemplateDao indexGroupTemplateDao; public Boolean initCustomerIndexGroup(String customerId) { List groupTempList = indexGroupTemplateDao.selectAll(); List groupDetailTempList = indexGroupDetailTemplateDao.selectAll(); - if (CollectionUtils.isEmpty(groupTempList) || CollectionUtils.isEmpty(groupDetailTempList)){ + if (CollectionUtils.isEmpty(groupTempList) || CollectionUtils.isEmpty(groupDetailTempList)) { throw new RenException("没有需要初始化的数据"); } Map groupMap = groupTempList.stream().collect(Collectors.toMap(IndexGroupTemplateEntity::getId, o -> o)); - Map groupEntityMap = new HashMap<>(); - Map groupNewIdMap = new HashMap<>(); + Map groupNewIdMap = new HashMap<>(); + + indexGroupDetailDao.deleteByCustomerId(customerId); + baseDao.deleteByCustomerId(customerId); List insertGroupList = new ArrayList<>(); - groupMap.forEach((oldGroupTempId,o)->{ + groupMap.forEach((oldGroupTempId, o) -> { IndexGroupEntity newGroupEntity = ConvertUtils.sourceToTarget(o, IndexGroupEntity.class); String newGroupId = UniqueIdGenerator.generate(); newGroupEntity.setId(newGroupId); newGroupEntity.setCustomerId(customerId); - String oldPid = newGroupEntity.getParentIndexGroupId(); - String newPid = groupNewIdMap.get(oldPid); - /*if (StringUtils.isBlank(newPid)){ - newPid = UniqueIdGenerator.generate(); - groupNewIdMap.put(oldPid,newPid); - }*/ - //newGroupEntity.setParentIndexGroupId(newPid); - groupNewIdMap.put(oldGroupTempId,newGroupId); - //groupEntityMap.put(newGroupId,newGroupEntity); + groupNewIdMap.put(oldGroupTempId, newGroupId); insertGroupList.add(newGroupEntity); }); insertGroupList.forEach(o-> { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml index 499f3349f4..aab983a94f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml @@ -110,8 +110,8 @@ m.YEAR_ID, m.MONTH_ID, m.IS_TOTAL, - M.SCORE, - M.INDEX_CODE + m.SCORE, + m.INDEX_CODE FROM fact_index_grid_score m WHERE diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml index e0707ee17b..36305146f3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml @@ -65,4 +65,36 @@ limit #{deleteSize} + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDao.xml index 668ba89e2d..4f0c4d0c75 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDao.xml @@ -6,4 +6,8 @@ + + + delete from index_group where CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDetailDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDetailDao.xml index 76bec7b257..0fe297d9b0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDetailDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDetailDao.xml @@ -6,7 +6,7 @@ + + + delete from index_group_detail where CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDetailTemplateDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDetailTemplateDao.xml index a8e5f55a2e..5769bd5818 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDetailTemplateDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupDetailTemplateDao.xml @@ -7,7 +7,7 @@ delete from index_group_detail_template diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupTemplateDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupTemplateDao.xml index 92067e3247..e1fd380618 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupTemplateDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/IndexGroupTemplateDao.xml @@ -7,7 +7,7 @@ \ No newline at end of file From 025ef4209361b0a106ae19f6e512e6ab5963866e Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 22 Sep 2020 17:01:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=85=88=E8=BF=9B=E6=A8=A1=E8=8C=83?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8A=BD=E5=8F=96=E5=88=B0=E5=A4=A7=E5=B1=8F?= =?UTF-8?q?=E8=A1=A8screen=5Fpioneer=5FdataV0.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen/ScreenPioneerDataDao.java | 14 +++- .../impl/CalCpcIndexServiceImpl.java | 15 +---- .../impl/CalGridIndexServiceImpl.java | 27 +------- .../impl/PioneerDataExtractServiceImpl.java | 4 +- ...FactIndexPartyAblityCpcMonthlyService.java | 16 ++--- ...tIndexServiceAblityGridMonthlyService.java | 19 ++---- ...IndexPartyAblityCpcMonthlyServiceImpl.java | 34 +++++----- ...exServiceAblityGridMonthlyServiceImpl.java | 40 ++++------- .../screen/ScreenPioneerDataService.java | 13 ++++ .../impl/ScreenPioneerDataServiceImpl.java | 42 ++++++++++-- .../impl/ShiBeiScreenCollServiceImpl.java | 3 +- .../screen/ScreenPioneerDataDao.xml | 66 ++++++++++++++++++- 12 files changed, 176 insertions(+), 117 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenPioneerDataDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenPioneerDataDao.java index c9307411d5..becb9d1034 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenPioneerDataDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenPioneerDataDao.java @@ -43,7 +43,10 @@ public interface ScreenPioneerDataDao extends BaseDao { * @Author zhangyong * @Date 10:52 2020-08-18 **/ - Integer deletePioneerData(@Param("customerId") String customerId); + Integer deletePioneerData(@Param("customerId") String customerId, + @Param("orgType") String orgType, + @Param("dataEndTime")String dataEndTime, + @Param("deleteSize") Integer deleteSize); /** * 10、党建引领-先锋模范数据 @@ -74,4 +77,13 @@ public interface ScreenPioneerDataDao extends BaseDao { * @Date 2020/9/22 15:03 **/ List initAgencyPioneerDataList(@Param("customerId")String customerId, @Param("agencyLevel")String agencyLevel); + + /** + * @return void + * @param list + * @author yinzuomei + * @description 插入 entity + * @Date 2020/9/22 15:55 + **/ + void insertBatchEntity(@Param("list") List list); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java index 6eef7b395c..a837550337 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java @@ -2,7 +2,6 @@ package com.epmet.service.evaluationindex.extract.dataToIndex.impl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.constant.IndexCalConstant; import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; import com.epmet.service.evaluationindex.extract.dataToIndex.CalCpcIndexService; import com.epmet.service.evaluationindex.extract.todata.*; @@ -10,7 +9,6 @@ import com.epmet.service.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthl import com.epmet.service.stats.DimCustomerPartymemberService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.ListUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -63,9 +61,6 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { } String quarterId= DateUtils.getQuarterId(monthId); String yearId=DateUtils.getYearId(monthId); - //2、删除之前统计过的 - factIndexPartyAblityCpcMonthlyService.deleteFactIndexPartyAblityCpcMonthly(customerId, monthId); - //1、党员提出话题数 Map createTopicCountMap = calCreateTopicCount(customerId, monthId); @@ -88,7 +83,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { //9、自建群活跃度——议题转项目率 Map topicToIssueRatioMap = caltopicToIssueRatio(customerId, monthId, indexPartyAblityCpcList, userCreatedGroups); - //3、计算实际值,更新 + //2、计算实际值,更新 for (FactIndexPartyAblityCpcMonthlyEntity indexPartyAblityCpcEntity : indexPartyAblityCpcList) { indexPartyAblityCpcEntity.setMonthId(monthId); indexPartyAblityCpcEntity.setQuarterId(quarterId); @@ -127,12 +122,8 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { indexPartyAblityCpcEntity.setTopicToIssueRatio(topicToIssueRatioMap.get(indexPartyAblityCpcEntity.getUserId())); } } - //4、分批插入批量插入 - List> partition = ListUtils.partition(indexPartyAblityCpcList, IndexCalConstant.INSERT_SIZE); - partition.forEach(list -> { - factIndexPartyAblityCpcMonthlyService.saveFactIndexPartyAblityCpcMonthlyEntity(list); - }); - + //3、删除之前统计过的、批插入批量插入 + factIndexPartyAblityCpcMonthlyService.delAndSavePartyAblityCpcMonthly(customerId,monthId,indexPartyAblityCpcList); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalGridIndexServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalGridIndexServiceImpl.java index 1afad5f062..5e69ff1c2d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalGridIndexServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalGridIndexServiceImpl.java @@ -1,11 +1,8 @@ package com.epmet.service.evaluationindex.extract.dataToIndex.impl; -import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.constant.DataSourceConstant; import com.epmet.constant.ExtractConstant; -import com.epmet.constant.IndexCalConstant; import com.epmet.constant.ProjectEvaluateConstant; import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyDao; import com.epmet.dto.extract.form.GovernAbilityGridMonthlyFormDTO; @@ -72,8 +69,6 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { @Autowired private FactIndexServiceAblityGridMonthlyService factIndexServiceAbilityGridMonthlyService; @Autowired - private FactIndexServiceAblityGridMonthlyService factIndexServiceAblityGridMonthlyService; - @Autowired private ActInfoService actInfoService; @Autowired private UserService userService; @@ -459,13 +454,8 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { } } - //3、批量删 - factIndexServiceAblityGridMonthlyService.deleteBatchIndexServiceAblityGridMonthly(customerId,monthId); - //4、批量增 - List> partition = ListUtils.partition(entityList, IndexCalConstant.INSERT_SIZE); - partition.forEach(list -> { - this.saveFactIndexServiceAblityGridMonthlyEntity(list); - }); + //3、批量删、批量增 + factIndexServiceAbilityGridMonthlyService.delAndSaveServiceAbilityGridMonthly(customerId,monthId,entityList); return true; } @@ -479,19 +469,6 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { System.out.println(partyVolunteerRatio); }*/ - - /** - * @param list - * @return void - * @author yinzuomei - * @description 批量插入网格相关-服务能力指标表 - * @Date 2020/9/21 10:04 - **/ - @DataSource(DataSourceConstant.EVALUATION_INDEX) - private void saveFactIndexServiceAblityGridMonthlyEntity(List list) { - factIndexServiceAbilityGridMonthlyService.insertBatchEntity(list); - } - /** * @Description 小数四舍五入【保留六位小数】 * @param d diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PioneerDataExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PioneerDataExtractServiceImpl.java index b658ec71aa..f8230b191c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PioneerDataExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PioneerDataExtractServiceImpl.java @@ -1,6 +1,7 @@ package com.epmet.service.evaluationindex.extract.toscreen.impl; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.constant.IndexCalConstant; import com.epmet.entity.evaluationindex.screen.ScreenPioneerDataEntity; import com.epmet.service.evaluationindex.extract.toscreen.PioneerDataExtractService; import com.epmet.service.evaluationindex.screen.ScreenPioneerDataService; @@ -48,6 +49,7 @@ public class PioneerDataExtractServiceImpl implements PioneerDataExtractService **/ @Override public void extractGridPioneerData(String customerId, String dateId) { + //查询客户下所有的网格,初始数据值为0 List gridList=screenPioneerDataService.initPioneerDataList(customerId,"grid", StrConstant.EPMETY_STR); if(CollectionUtils.isEmpty(gridList)){ return; @@ -56,7 +58,7 @@ public class PioneerDataExtractServiceImpl implements PioneerDataExtractService entity.setDataEndTime(dateId); }); - + screenPioneerDataService.delAndSavePioneerData(customerId,"grid",dateId, IndexCalConstant.DELETE_SIZE,gridList); } @Override diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyService.java index 149ff64cab..5614ff29a3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyService.java @@ -34,18 +34,10 @@ public interface FactIndexPartyAblityCpcMonthlyService extends BaseService list); + void delAndSavePartyAblityCpcMonthly(String customerId, String monthId, List indexPartyAblityCpcList); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexServiceAblityGridMonthlyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexServiceAblityGridMonthlyService.java index 84b9862e9e..3249c1a7eb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexServiceAblityGridMonthlyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexServiceAblityGridMonthlyService.java @@ -31,15 +31,6 @@ import java.util.List; * @since v1.0.0 2020-09-21 */ public interface FactIndexServiceAblityGridMonthlyService extends BaseService { - /** - * @return void - * @param customerId - * @param monthId - * @author yinzuomei - * @description 批量删除网格相关-服务能力指标表 - * @Date 2020/9/21 16:38 - **/ - void deleteBatchIndexServiceAblityGridMonthly(String customerId, String monthId); /** * @return java.util.List @@ -52,10 +43,12 @@ public interface FactIndexServiceAblityGridMonthlyService extends BaseService list); + void delAndSaveServiceAbilityGridMonthly(String customerId, String monthId, List entityList); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexPartyAblityCpcMonthlyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexPartyAblityCpcMonthlyServiceImpl.java index 78072b7bed..33316c2eba 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexPartyAblityCpcMonthlyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexPartyAblityCpcMonthlyServiceImpl.java @@ -21,50 +21,46 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.constant.DataSourceConstant; +import com.epmet.constant.IndexCalConstant; import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyDao; import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; import com.epmet.service.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyService; +import org.apache.commons.collections4.ListUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; /** - * 党建能力-党员相关的事实表 + * 党建能力-党员相关的事实表 * * @author generator generator@elink-cn.com * @since v1.0.0 2020-09-21 */ @Service public class FactIndexPartyAblityCpcMonthlyServiceImpl extends BaseServiceImpl implements FactIndexPartyAblityCpcMonthlyService { + /** * @param customerId * @param monthId + * @param indexPartyAblityCpcList * @return void * @author yinzuomei - * @description 删除这个客户这个月 党员相关-党建能力的数据 - * @Date 2020/9/18 10:20 + * @description 先删后增 + * @Date 2020/9/22 16:30 **/ - @Override + @Transactional(rollbackFor = Exception.class) @DataSource(value = DataSourceConstant.EVALUATION_INDEX) - public void deleteFactIndexPartyAblityCpcMonthly(String customerId, String monthId) { + @Override + public void delAndSavePartyAblityCpcMonthly(String customerId, String monthId, List indexPartyAblityCpcList) { int deleteNum; do { deleteNum = baseDao.deleteFactIndexPartyAblityCpcMonthly(customerId, monthId); } while (deleteNum > NumConstant.ZERO); - } - - - /** - * @param list - * @return void - * @author yinzuomei - * @description 批量插入党员相关党建能力表 - * @Date 2020/9/18 10:27 - **/ - @Override - @DataSource(value = DataSourceConstant.EVALUATION_INDEX) - public void saveFactIndexPartyAblityCpcMonthlyEntity(List list) { - baseDao.insertBatchEntity(list); + List> partition = ListUtils.partition(indexPartyAblityCpcList, IndexCalConstant.INSERT_SIZE); + partition.forEach(list -> { + baseDao.insertBatchEntity(list); + }); } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexServiceAblityGridMonthlyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexServiceAblityGridMonthlyServiceImpl.java index a6683c5fd5..3d575b8958 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexServiceAblityGridMonthlyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexServiceAblityGridMonthlyServiceImpl.java @@ -21,10 +21,13 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.constant.DataSourceConstant; +import com.epmet.constant.IndexCalConstant; import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyDao; import com.epmet.entity.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyEntity; import com.epmet.service.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyService; +import org.apache.commons.collections4.ListUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -37,23 +40,6 @@ import java.util.List; @Service public class FactIndexServiceAblityGridMonthlyServiceImpl extends BaseServiceImpl implements FactIndexServiceAblityGridMonthlyService { - /** - * @return void - * @param customerId - * @param monthId - * @author yinzuomei - * @description 批量删除网格相关-服务能力指标表 - * @Date 2020/9/21 10:16 - **/ - @Override - @DataSource(DataSourceConstant.EVALUATION_INDEX) - public void deleteBatchIndexServiceAblityGridMonthly(String customerId, String monthId) { - int deleteNum; - do { - deleteNum = baseDao.deleteFactIndexServiceAblityGridMonthly(customerId, monthId); - } while (deleteNum > NumConstant.ZERO); - } - /** * @param customerId * @return java.util.List @@ -67,16 +53,18 @@ public class FactIndexServiceAblityGridMonthlyServiceImpl extends BaseServiceImp return baseDao.initAllGridList(customerId); } - /** - * @param list - * @return void - * @author yinzuomei - * @description 批量插入网格相关-服务能力指标表 - * @Date 2020/9/21 10:05 - **/ + @Transactional(rollbackFor = Exception.class) @Override @DataSource(DataSourceConstant.EVALUATION_INDEX) - public void insertBatchEntity(List list) { - baseDao.insertBatchEntity(list); + public void delAndSaveServiceAbilityGridMonthly(String customerId, String monthId, List entityList) { + int deleteNum; + do { + deleteNum = baseDao.deleteFactIndexServiceAblityGridMonthly(customerId, monthId); + } while (deleteNum > NumConstant.ZERO); + + List> partition = ListUtils.partition(entityList, IndexCalConstant.INSERT_SIZE); + partition.forEach(list -> { + baseDao.insertBatchEntity(list); + }); } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenPioneerDataService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenPioneerDataService.java index 1add697600..1e42747a4a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenPioneerDataService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenPioneerDataService.java @@ -40,4 +40,17 @@ public interface ScreenPioneerDataService extends BaseService initPioneerDataList(String customerId, String orgType,String agencyLevel); + + /** + * @return void + * @param customerId + * @param orgType grid, agency + * @param dataEndTime + * @param deleteSize + * @param entityList 待插入的数据 + * @author yinzuomei + * @description 保存抽取结果 + * @Date 2020/9/22 15:54 + **/ + void delAndSavePioneerData(String customerId, String orgType, String dataEndTime, Integer deleteSize, List entityList); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPioneerDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPioneerDataServiceImpl.java index f7299247ac..da031da750 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPioneerDataServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPioneerDataServiceImpl.java @@ -20,12 +20,16 @@ package com.epmet.service.evaluationindex.screen.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.constant.DataSourceConstant; +import com.epmet.constant.IndexCalConstant; import com.epmet.dao.evaluationindex.screen.ScreenPioneerDataDao; import com.epmet.entity.evaluationindex.screen.ScreenPioneerDataEntity; import com.epmet.service.evaluationindex.screen.ScreenPioneerDataService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -53,12 +57,40 @@ public class ScreenPioneerDataServiceImpl extends BaseServiceImpl initPioneerDataList(String customerId, String orgType, String agencyLevel) { - List list=new ArrayList<>(); - if("grid".equals(orgType)){ - list=baseDao.initGridPioneerDataList(customerId); - }else if("agency".equals(orgType)){ - list=baseDao.initAgencyPioneerDataList(customerId,agencyLevel); + List list = new ArrayList<>(); + if ("grid".equals(orgType)) { + list = baseDao.initGridPioneerDataList(customerId); + } else if ("agency".equals(orgType)) { + list = baseDao.initAgencyPioneerDataList(customerId, agencyLevel); } return list; } + + + /** + * @param customerId + * @param orgType grid, agency + * @param dataEndTime + * @param deleteSize + * @param entityList 待插入的数据 + * @return void + * @author yinzuomei + * @description 保存抽取结果 + * @Date 2020/9/22 15:54 + **/ + @Transactional(rollbackFor = Exception.class) + @DataSource(DataSourceConstant.EVALUATION_INDEX) + @Override + public void delAndSavePioneerData(String customerId, String orgType, String dataEndTime, Integer deleteSize, List entityList) { + int deleteNum; + do { + deleteNum = baseDao.deletePioneerData(customerId, orgType, dataEndTime, deleteSize); + } while (deleteNum != NumConstant.ZERO); + + List> partition = ListUtils.partition(entityList, IndexCalConstant.INSERT_SIZE); + partition.forEach(list -> { + baseDao.insertBatchEntity(list); + }); + } + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ShiBeiScreenCollServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ShiBeiScreenCollServiceImpl.java index bbb0585d44..3608048a66 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ShiBeiScreenCollServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ShiBeiScreenCollServiceImpl.java @@ -22,6 +22,7 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.CompareConstant; import com.epmet.constant.DataSourceConstant; +import com.epmet.constant.IndexCalConstant; import com.epmet.dao.evaluationindex.screen.*; import com.epmet.dto.screencoll.form.*; import com.epmet.entity.evaluationindex.screen.ScreenEventImgDataEntity; @@ -447,7 +448,7 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService { if (formDTO.getIsFirst()) { int deleteNum; do { - deleteNum = screenPioneerDataDao.deletePioneerData(customerId); + deleteNum = screenPioneerDataDao.deletePioneerData(customerId,null,null, IndexCalConstant.DELETE_SIZE); } while (deleteNum != NumConstant.ZERO); } if (!CollectionUtils.isEmpty(formDTO.getDataList())) { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPioneerDataDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPioneerDataDao.xml index 70e8170efb..64f19416a9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPioneerDataDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPioneerDataDao.xml @@ -3,10 +3,16 @@ - + delete from screen_pioneer_data where CUSTOMER_ID = #{customerId} - limit 1000; + + and ORG_TYPE=#{orgType} + + + and DATA_END_TIME=#{dataEndTime} + + limit #{deleteSize} @@ -117,4 +123,60 @@ and sca.`LEVEL`=#{agencyLevel} AND sca.CUSTOMER_ID = #{customerId} + + + insert into screen_pioneer_data + ( + ID, + CUSTOMER_ID, + ORG_TYPE, + ORG_ID, + PARENT_ID, + ORG_NAME, + PUBLISH_ISSUE_TOTAL, + ISSUE_TOTAL, + TOPIC_TOTAL, + SHIFT_PROJECT_TOTAL, + RESOLVED_PROJECT_TOTAL, + PUBLISH_ISSUE_RATIO, + ISSUE_RATIO, + TOPIC_RATIO, + SHIFT_PROJECT_RATIO, + RESOLVED_PROJECT_RATIO, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME, + DATA_END_TIME + ) values + + ( + (SELECT REPLACE(UUID(), '-', '') AS id), + #{item.customerId}, + #{item.orgType}, + #{item.orgId}, + #{item.parentId}, + #{item.orgName}, + #{item.publishIssueTotal}, + #{item.issueTotal}, + #{item.topicTotal}, + #{item.shiftProjectTotal}, + #{item.resolvedProjectTotal}, + #{item.publishIssueRatio}, + #{item.issueRatio}, + #{item.topicRatio}, + #{item.shiftProjectRatio}, + #{item.resolvedProjectRatio}, + 0, + 0, + 'APP_USER', + now(), + 'APP_USER', + now(), + #{item.dataEndTime} + ) + +