From f5990b0c6bbbb2aa5527d7e890e6ead277dc4de0 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 1 Sep 2020 21:55:16 +0800 Subject: [PATCH] =?UTF-8?q?1=E5=A4=9A=E9=9F=B3=E5=AD=97=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=9B2=EF=BC=9A=E6=8C=87=E6=A0=87=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=88=86=E7=BB=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IndexCalculateController.java | 36 +++++++++++-------- .../epmet/model/IndexExcelDataListener.java | 25 +++++++------ .../impl/IndexCalculateServiceImpl.java | 12 ++++--- .../java/com/epmet/util/Pinyin4jUtil.java | 2 ++ 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java index 9dab47c148..de9f746130 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java @@ -1,6 +1,5 @@ package com.epmet.controller; -import com.epmet.commons.extappauth.bean.ExternalAppRequestParam; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.screen.form.IndexCalculateForm; @@ -23,33 +22,40 @@ import org.springframework.web.bind.annotation.RestController; public class IndexCalculateController { @Autowired - private IndexCalculateService indexCalculateService; - + private IndexCalculateService indexCalculateService; + @Autowired private CpcIndexCalculateService cpcIndexCalculateService; /** - * 1、按照客户计算指标(按照月份) + * 按照客户计算所有指标(按照月份) * - * @param externalAppRequestParam * @param formDTO * @return com.epmet.commons.tools.utils.Result * @Author zhangyong * @Date 10:52 2020-08-20 **/ - @PostMapping("cpc") - public Result cpcIndexCalculate(ExternalAppRequestParam externalAppRequestParam, @RequestBody IndexCalculateForm formDTO) { - indexCalculateService.indexCalculate(formDTO); - return new Result(); + @PostMapping("all") + public Result indexCalculate(@RequestBody IndexCalculateForm formDTO) { + Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); + if (aBoolean){ + return new Result().ok(true); + } + return new Result().error("指标计算失败"); } - @PostMapping("getMax") - public Result getMax(){ - CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO("b09527201c4409e19d1dbc5e3c3429a1","202008"); - cpcIndexCalculateService.cpcIndexCalculate(calculateCommonFormDTO); - return new Result(); + + /** + * desc:计算党员指标分数 + * + * @return + */ + @PostMapping("cpc") + public Result cpc(CalculateCommonFormDTO formDTO) { + + return new Result().ok(cpcIndexCalculateService.cpcIndexCalculate(formDTO)); } - /* *//** + /* *//** * 2、党建能力-网格相关指标上报(按照月份) * * @param externalAppRequestParam 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 9267d562a8..9c41161089 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 @@ -130,7 +130,8 @@ public class IndexExcelDataListener extends AnalysisEventListener { String level4Index = index.getLevel4Index(); indexDictEntity = indexDicMap.get(level4Index); - IndexGroupTemplateEntity group2 = indexGroupMap.get(index.getLevel1Index() + level4Index); + String level4IndexDetailKey = index.getLevel1Index() + index.getLevel2Index() + level4Index; + IndexGroupTemplateEntity group2 = indexGroupMap.get(level4IndexDetailKey); IndexGroupDetailTemplateEntity templateEntity = null; if (group2 == null) { group2 = new IndexGroupTemplateEntity(); @@ -138,7 +139,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { group2.setParentIndexGroupId(group1.getId()); group2.setId(UniqueIdGenerator.generate()); group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); - indexGroupMap.put(index.getLevel1Index() + level4Index, group2); + indexGroupMap.put(level4IndexDetailKey, group2); //构建 分组明细 templateEntity = indexGroupDetailMap.get(index.getLevel1Index() + level4Index); if (templateEntity == null) { @@ -154,9 +155,10 @@ public class IndexExcelDataListener extends AnalysisEventListener { } indexDictEntity = indexDicMap.get(index.getLevel5Index()); + String level5IndexDetailKey = index.getLevel1Index() + index.getLevel2Index() + index.getLevel5Index(); allIndexCodeSb.append(StrConstant.COLON); allIndexCodeSb.append(group2.getIndexCode()); - templateEntity = indexGroupDetailMap.get(index.getLevel1Index() + index.getLevel5Index()); + templateEntity = indexGroupDetailMap.get(level5IndexDetailKey); if (templateEntity == null) { templateEntity = new IndexGroupDetailTemplateEntity(); templateEntity.setIndexGroupId(group2.getId()); @@ -165,7 +167,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { templateEntity.setId(UniqueIdGenerator.generate()); templateEntity.setCorrelation(index.getCorrelation()); buildIndexGroupDetail(templateEntity, indexDictEntity, index, 5); - indexGroupDetailMap.put(index.getLevel1Index() + index.getLevel5Index(), templateEntity); + indexGroupDetailMap.put(level5IndexDetailKey, templateEntity); } } else { //todo 测试完去掉 @@ -183,8 +185,8 @@ public class IndexExcelDataListener extends AnalysisEventListener { StringBuilder allIndexCodeSb = new StringBuilder(group1.getIndexCode()); String level2Index = index.getLevel2Index(); indexDictEntity = indexDicMap.get(level2Index); - String groupMapKey = index.getLevel1Index() + level2Index; - IndexGroupTemplateEntity group2 = indexGroupMap.get(groupMapKey); + String level2IndexGroupKey = index.getLevel1Index() + level2Index; + IndexGroupTemplateEntity group2 = indexGroupMap.get(level2IndexGroupKey); IndexGroupDetailTemplateEntity templateEntity = null; if (group2 == null) { group2 = new IndexGroupTemplateEntity(); @@ -193,9 +195,9 @@ public class IndexExcelDataListener extends AnalysisEventListener { group2.setId(UniqueIdGenerator.generate()); group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); - indexGroupMap.put(groupMapKey, group2); + indexGroupMap.put(level2IndexGroupKey, group2); //构建 分组明细 - templateEntity = indexGroupDetailMap.get(level2Index); + templateEntity = indexGroupDetailMap.get(level2IndexGroupKey); if (templateEntity == null) { templateEntity = new IndexGroupDetailTemplateEntity(); templateEntity.setIndexGroupId(group2.getId()); @@ -204,13 +206,14 @@ public class IndexExcelDataListener extends AnalysisEventListener { templateEntity.setId(UniqueIdGenerator.generate()); templateEntity.setCorrelation(index.getCorrelation()); buildIndexGroupDetail(templateEntity, indexDictEntity, index, 2); - indexGroupDetailMap.put(groupMapKey, templateEntity); + indexGroupDetailMap.put(level2IndexGroupKey, templateEntity); } } indexDictEntity = indexDicMap.get(index.getLevel5Index()); allIndexCodeSb.append(StrConstant.COLON); allIndexCodeSb.append(group2.getIndexCode()); - templateEntity = indexGroupDetailMap.get(index.getLevel1Index() + index.getLevel5Index()); + String level5IndexGroupKey = index.getLevel1Index() + index.getLevel2Index() + index.getLevel5Index(); + templateEntity = indexGroupDetailMap.get(level5IndexGroupKey); if (templateEntity == null) { templateEntity = new IndexGroupDetailTemplateEntity(); templateEntity.setIndexGroupId(group2.getId()); @@ -219,7 +222,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { templateEntity.setId(UniqueIdGenerator.generate()); templateEntity.setCorrelation(index.getCorrelation()); buildIndexGroupDetail(templateEntity, indexDictEntity, index, 5); - indexGroupDetailMap.put(index.getLevel1Index() + index.getLevel5Index(), templateEntity); + indexGroupDetailMap.put(level5IndexGroupKey, templateEntity); } } //} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java index dde54c76f2..a7100121f7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java @@ -54,16 +54,17 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { } formDTO.setCustomerIds(externalCustomerIdsResult.getData()); } - formDTO.getCustomerIds().forEach(customerId -> { + Boolean flag = false; + for (String customerId : formDTO.getCustomerIds()) { CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO(customerId, formDTO.getMonthId()); //计算党员相关的 - Boolean flag = false; try { CalculateCommonFormDTO param = new CalculateCommonFormDTO(customerId, formDTO.getMonthId()); flag = cpcIndexCalculateService.cpcIndexCalculate(param); log.info("indexCalculate cpcIndexCalculate return result:{}", flag); } catch (Exception e) { log.error("indexCalculate cpcIndexCalculate exception", e); + break; } //计算网格 @@ -72,6 +73,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { log.info("indexCalculate calculateGridCorreLation return result:{}", flag); } catch (Exception e) { log.error("indexCalculate calculateGridCorreLation exception", e); + break; } //计算社区 try { @@ -79,10 +81,10 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { log.info("indexCalculate calAll return result:{}", flag); } catch (Exception e) { log.error("indexCalculate calAll exception", e); + break; } - }); - indexCodeFieldReRedis.deleteIndexCodeFromRedis(); - return true; + } + return flag; } catch (Exception e) { log.error("indexCalculate exception,param:{}", JSON.toJSONString(formDTO)); } finally { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/Pinyin4jUtil.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/Pinyin4jUtil.java index bedaf09f1b..727de4bbeb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/Pinyin4jUtil.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/Pinyin4jUtil.java @@ -27,6 +27,8 @@ public class Pinyin4jUtil { duoyinMap.put('提',new String[]{"ti"}); duoyinMap.put('被',new String[]{"bei"}); duoyinMap.put('期',new String[]{"qi"}); + duoyinMap.put('参',new String[]{"can"}); + duoyinMap.put('均',new String[]{"jun"}); } /**