diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java index c873ffdb0b..5458720940 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDao.java @@ -21,8 +21,6 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.entity.screen.IndexGroupEntity; import org.apache.ibatis.annotations.Mapper; -import java.util.List; - /** * 客户指标分组 * @@ -33,6 +31,4 @@ import java.util.List; public interface IndexGroupDao extends BaseDao { int inertGroupFromTable(String customerId); - - List getDetailByCode(String indexCode, Integer offset); } \ No newline at end of file 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 6e747b0766..a4993cf00b 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 @@ -112,85 +112,109 @@ public class IndexExcelDataListener extends AnalysisEventListener { List collect = indexModelList.stream().sorted(Comparator.comparing(IndexModel::getLevel1Index)).collect(Collectors.toList()); collect.forEach(index -> { if (index.getLevel1Index().equals("党员相关")) { + IndexDictEntity indexDictEntity = indexDicMap.get(index.getLevel1Index()); - String level1GroupId = UniqueIdGenerator.generate(); IndexGroupTemplateEntity group1 = indexGroupMap.get(index.getLevel1Index()); if (group1 == null) { group1 = new IndexGroupTemplateEntity(); group1.setIndexId(indexDictEntity.getId()); group1.setParentIndexGroupId("0"); - group1.setId(level1GroupId); - group1.setIndexCode(Pinyin4jUtil.getFirstSpellPinYin(indexDictEntity.getIndexName(),true)); + group1.setId(UniqueIdGenerator.generate()); + group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),true,4)); indexGroupMap.put(index.getLevel1Index(), group1); } StringBuilder allIndexCodeSb = new StringBuilder(group1.getIndexCode()); String level4Index = index.getLevel4Index(); indexDictEntity = indexDicMap.get(level4Index); - String level2GroupId = UniqueIdGenerator.generate(); - IndexGroupTemplateEntity group2 = indexGroupMap.get(level4Index); + IndexGroupTemplateEntity group2 = indexGroupMap.get(index.getLevel1Index()+level4Index); IndexGroupDetailTemplateEntity templateEntity = null; if (group2 == null) { group2 = new IndexGroupTemplateEntity(); group2.setIndexId(indexDictEntity.getId()); - group2.setParentIndexGroupId(level1GroupId); - group2.setId(level2GroupId); - group2.setIndexCode(Pinyin4jUtil.getFirstSpellPinYin(indexDictEntity.getIndexName(),true)); - indexGroupMap.put(level4Index, group2); + group2.setParentIndexGroupId(group1.getId()); + group2.setId(UniqueIdGenerator.generate()); + group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),false,4 )); + indexGroupMap.put(index.getLevel1Index()+level4Index, group2); //构建 分组明细 - templateEntity = indexGroupDetailMap.get(level4Index); + templateEntity = indexGroupDetailMap.get(index.getLevel1Index()+level4Index); if (templateEntity == null) { - buildIndexGroupDetail(indexDictEntity, index, group1, allIndexCodeSb.toString(), 2); + templateEntity = new IndexGroupDetailTemplateEntity(); + templateEntity.setIndexGroupId(group1.getId()); + templateEntity.setIndexId(indexDictEntity.getId()); + templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); + templateEntity.setId(UniqueIdGenerator.generate()); + buildIndexGroupDetail(templateEntity,indexDictEntity, index, group1, 2); + indexGroupDetailMap.put(index.getLevel1Index()+level4Index,templateEntity); } } indexDictEntity = indexDicMap.get(index.getLevel5Index()); allIndexCodeSb.append(StrConstant.COLON); allIndexCodeSb.append(group2.getIndexCode()); - templateEntity = indexGroupDetailMap.get(index.getLevel5Index()); + templateEntity = indexGroupDetailMap.get(index.getLevel1Index()+index.getLevel5Index()); if (templateEntity == null) { - buildIndexGroupDetail(indexDictEntity, index, group2, allIndexCodeSb.toString(), 5); + templateEntity = new IndexGroupDetailTemplateEntity(); + templateEntity.setIndexGroupId(group2.getId()); + System.out.println("=========="+group2.getId()); + templateEntity.setIndexId(indexDictEntity.getId()); + templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); + templateEntity.setId(UniqueIdGenerator.generate()); + buildIndexGroupDetail(templateEntity,indexDictEntity, index, group2, 5); + indexGroupDetailMap.put(index.getLevel1Index()+index.getLevel5Index(),templateEntity); } } else { //todo 测试完去掉 //if ("街道相关".equals(index.getLevel1Index())) { IndexDictEntity indexDictEntity = indexDicMap.get(index.getLevel1Index()); - String level1GroupId = UniqueIdGenerator.generate(); IndexGroupTemplateEntity group1 = indexGroupMap.get(index.getLevel1Index()); if (group1 == null) { group1 = new IndexGroupTemplateEntity(); group1.setIndexId(indexDictEntity.getId()); group1.setParentIndexGroupId("0"); - group1.setId(level1GroupId); - group1.setIndexCode(Pinyin4jUtil.getFirstSpellPinYin(indexDictEntity.getIndexName(),true)); + group1.setId(UniqueIdGenerator.generate()); + group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),false,4 )); indexGroupMap.put(index.getLevel1Index(), group1); } StringBuilder allIndexCodeSb = new StringBuilder(group1.getIndexCode()); String level2Index = index.getLevel2Index(); indexDictEntity = indexDicMap.get(level2Index); - String level2GroupId = UniqueIdGenerator.generate(); - - IndexGroupTemplateEntity group2 = indexGroupMap.get(level2Index); + String groupMapKey = index.getLevel1Index() + level2Index; + IndexGroupTemplateEntity group2 = indexGroupMap.get(groupMapKey); IndexGroupDetailTemplateEntity templateEntity = null; if (group2 == null) { group2 = new IndexGroupTemplateEntity(); group2.setIndexId(indexDictEntity.getId()); - group2.setParentIndexGroupId(level1GroupId); - group2.setId(level2GroupId); - group2.setIndexCode(Pinyin4jUtil.getFirstSpellPinYin(indexDictEntity.getIndexName(),true)); - indexGroupMap.put(level2Index, group2); + group2.setParentIndexGroupId(group1.getId()); + group2.setId(UniqueIdGenerator.generate()); + group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),false,4 )); + + indexGroupMap.put(groupMapKey, group2); //构建 分组明细 templateEntity = indexGroupDetailMap.get(level2Index); if (templateEntity == null) { - buildIndexGroupDetail(indexDictEntity, index, group1, allIndexCodeSb.toString(), 2); + templateEntity = new IndexGroupDetailTemplateEntity(); + templateEntity.setIndexGroupId(group2.getId()); + templateEntity.setIndexId(indexDictEntity.getId()); + templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); + templateEntity.setId(UniqueIdGenerator.generate()); + buildIndexGroupDetail(templateEntity,indexDictEntity, index, group1, 2); + indexGroupDetailMap.put(level2Index,templateEntity); } } indexDictEntity = indexDicMap.get(index.getLevel5Index()); allIndexCodeSb.append(StrConstant.COLON); allIndexCodeSb.append(group2.getIndexCode()); - templateEntity = indexGroupDetailMap.get(index.getLevel5Index()); + templateEntity = indexGroupDetailMap.get(index.getLevel1Index()+index.getLevel5Index()); if (templateEntity == null) { - buildIndexGroupDetail(indexDictEntity, index, group2, allIndexCodeSb.toString(), 5); + templateEntity = new IndexGroupDetailTemplateEntity(); + templateEntity.setIndexGroupId(group2.getId()); + templateEntity.setIndexId(indexDictEntity.getId()); + templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); + templateEntity.setId(UniqueIdGenerator.generate()); + + buildIndexGroupDetail(templateEntity, indexDictEntity, index, group2, 5); + indexGroupDetailMap.put(index.getLevel1Index()+index.getLevel5Index(),templateEntity); } } //} @@ -199,24 +223,16 @@ public class IndexExcelDataListener extends AnalysisEventListener { LOGGER.info("所有指标分组明细数据解析完成:{}", JSON.toJSONString(indexGroupDetailMap.values())); } - private void buildIndexGroupDetail(IndexDictEntity indexDictEntity, IndexModel index, IndexGroupTemplateEntity parentGroup, String allIndexCode, Integer level) { - IndexGroupDetailTemplateEntity templateEntity; - templateEntity = new IndexGroupDetailTemplateEntity(); - templateEntity.setIndexGroupId(parentGroup.getId()); - templateEntity.setAllParentIndexCode(allIndexCode); - templateEntity.setIndexId(indexDictEntity.getId()); - + private void buildIndexGroupDetail( IndexGroupDetailTemplateEntity templateEntity,IndexDictEntity indexDictEntity, IndexModel index, IndexGroupTemplateEntity parentGroup, Integer level) { if (level == 5) { - templateEntity.setIndexCode(Pinyin4jUtil.getFirstSpellPinYin(index.getLevel5Index(),true)); + templateEntity.setIndexCode(Pinyin4jUtil.getSpellPinYin(index.getLevel5Index(),false,4 )); String level5WeightStr = index.getLevel5Weight().replace("%", ""); templateEntity.setWeight(new BigDecimal(level5WeightStr).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP)); - indexGroupDetailMap.put(index.getLevel5Index(), templateEntity); } else { - templateEntity.setIndexCode(Pinyin4jUtil.getFirstSpellPinYin(indexDictEntity.getIndexName(),true)); - indexGroupDetailMap.put(indexDictEntity.getIndexName(), templateEntity); + templateEntity.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),false,4 )); templateEntity.setWeight(new BigDecimal(index.getWeight()).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP)); } - templateEntity.setId(UniqueIdGenerator.generate()); + if (StringUtils.isNotBlank(index.getThreshold())) { String thresholdStr = index.getThreshold().replace("%", ""); templateEntity.setThreshold(new BigDecimal(thresholdStr).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP)); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/CpcIndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/CpcIndexCalculateServiceImpl.java index 63a0105f28..4b26ff128c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/CpcIndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/CpcIndexCalculateServiceImpl.java @@ -2,8 +2,12 @@ package com.epmet.service.screen.impl; import com.alibaba.fastjson.JSON; import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao; +import com.epmet.dao.screen.IndexCodeFieldReDao; +import com.epmet.dao.screen.IndexGroupDetailDao; import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.entity.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; +import com.epmet.entity.screen.IndexGroupDetailEntity; +import com.epmet.eum.IndexCodeEnum; import com.epmet.service.screen.CpcIndexCalculateService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -19,14 +23,25 @@ import java.util.Map; public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { @Autowired private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao; + @Autowired + private IndexCodeFieldReDao indexCodeFieldReDao; + @Autowired + private IndexGroupDetailDao indexGroupDetailDao; @Override public Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO) { //计算最大最小值 Map minAndMaxList = factIndexPartyAblityCpcMonthlyDao.getExtremeValue(formDTO.getCustomerId()); if (CollectionUtils.isEmpty(minAndMaxList)){ - log.warn("customerId:{} have not any record",formDTO.getCustomerId()); + log.warn("customerId:{} have not any fact record",formDTO.getCustomerId()); return false; } + //获取指标权重信息 + List indexDetails = indexGroupDetailDao.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); + if (CollectionUtils.isEmpty(indexDetails)){ + log.warn("customerId:{} have not any indexGroupDetail",formDTO.getCustomerId()); + return false; + } + log.info(JSON.toJSONString(minAndMaxList)); List list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId()); return null; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java index 6c22b360d6..0225c956c5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java @@ -46,7 +46,6 @@ public class IndexGroupDetailServiceImpl extends BaseServiceImpl groupEntityList = groupTempList.stream().map(groupTemp -> { + Map groupMap = groupTempList.stream().collect(Collectors.toMap(IndexGroupTemplateEntity::getId, o -> o)); + Map groupEntityMap = new HashMap<>(); + + groupDetailTempList.forEach(groupDetailTemp->{ + String indexGroupId = groupDetailTemp.getIndexGroupId(); + IndexGroupTemplateEntity group = groupMap.get(indexGroupId); + if (group == null){ + System.out.println(JSON.toJSONString(groupDetailTemp)); + } + + IndexGroupEntity groupEntity = groupEntityMap.get(indexGroupId); + if (groupEntity == null){ + groupEntity = ConvertUtils.sourceToTarget(group, IndexGroupEntity.class); + String groupId = UniqueIdGenerator.generate(); + groupEntity.setId(groupId); + groupEntity.setCustomerId(customerId); + groupEntityMap.put(indexGroupId,groupEntity); + } + + IndexGroupDetailEntity entity = ConvertUtils.sourceToTarget(groupDetailTemp, IndexGroupDetailEntity.class); + entity.setId(UniqueIdGenerator.generate()); + entity.setIndexGroupId(groupEntity.getId()); + entity.setCustomerId(customerId); + indexGroupDetailDao.insert(entity); + }); + this.insertBatch(groupEntityMap.values(),10); + + + /* List groupEntityList = groupTempList.stream().map(groupTemp -> { IndexGroupEntity entity = ConvertUtils.sourceToTarget(groupTemp, IndexGroupEntity.class); entity.setId(UniqueIdGenerator.generate()); entity.setCustomerId(customerId); return entity; }).collect(Collectors.toList()); - this.insertBatch(groupEntityList,10); + + groupEntityList.forEach(group->{ + + }); List groupTempEntityList = groupDetailTempList.stream().map(groupTemp -> { IndexGroupDetailEntity entity = ConvertUtils.sourceToTarget(groupTemp, IndexGroupDetailEntity.class); @@ -78,7 +112,7 @@ private IndexGroupTemplateDao indexGroupTemplateDao; }).collect(Collectors.toList()); groupTempEntityList.forEach(o->{ indexGroupDetailDao.insert(o); - }); + });*/ return true; } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/ScreenCollServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/ScreenCollServiceImpl.java index 1411cd9c00..c7650aa185 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/ScreenCollServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/ScreenCollServiceImpl.java @@ -410,6 +410,9 @@ public class ScreenCollServiceImpl implements ScreenCollService { * @Date 15:38 2020-08-21 **/ private BigDecimal calculateGrowthRateNumber(Integer old, Integer now){ + if (NumConstant.ZERO == old){ + return new BigDecimal(now * NumConstant.ONE_HUNDRED); + } BigDecimal bignum1 = new BigDecimal((now - old) * NumConstant.ONE_HUNDRED); BigDecimal bignum2 = bignum1.divide(new BigDecimal(old),2,BigDecimal.ROUND_HALF_UP); return bignum2; 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 5ea9d4b828..c6e61ffb01 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 @@ -22,6 +22,9 @@ public class Pinyin4jUtil { duoyinMap = new HashMap<>(); duoyinMap.put('区',new String[]{"qu"}); duoyinMap.put('系',new String[]{"xi"}); + duoyinMap.put('率',new String[]{"lv"}); + duoyinMap.put('员',new String[]{"yuan"}); + duoyinMap.put('提',new String[]{"ti"}); } /** @@ -32,7 +35,24 @@ public class Pinyin4jUtil { * @return 第一个拼音 */ public static String getFirstSpellPinYin(String src, boolean isFullSpell) { - String targetStr = Pinyin4jUtil.makeStringByStringSet(Pinyin4jUtil.getPinyin(src, isFullSpell)); + String targetStr = Pinyin4jUtil.makeStringByStringSet(Pinyin4jUtil.getPinyin(src, isFullSpell, 1)); + System.out.println(targetStr); + String[] split = targetStr.split(","); + if (split.length > 1) { + targetStr = split[0]; + } + return targetStr; + } + + /** + * getFirstSpellPinYin:(多音字的时候获取第一个).
+ * + * @param src 传入的拼音字符串,以逗号隔开 + * @param isFullSpell 是否全拼,true:全拼,false:第一个汉字全拼(其它汉字取首字母) + * @return 第一个拼音 + */ + public static String getSpellPinYin(String src, boolean isFullSpell,Integer preFont) { + String targetStr = Pinyin4jUtil.makeStringByStringSet(Pinyin4jUtil.getPinyin(src, isFullSpell, preFont)); System.out.println(targetStr); String[] split = targetStr.split(","); if (split.length > 1) { @@ -68,9 +88,10 @@ public class Pinyin4jUtil { * * @param src 汉字 * @param isFullSpell 是否全拼,如果为true:全拼,false:首字全拼 + * @param preFont isFullSpell =true时,前几个字全拼 * @return */ - public static Set getPinyin(String src, boolean isFullSpell) { + public static Set getPinyin(String src, boolean isFullSpell, int preFont) { if (src != null && !src.trim().equalsIgnoreCase("")) { char[] srcChar; srcChar = src.toCharArray(); @@ -95,7 +116,7 @@ public class Pinyin4jUtil { } if (!isFullSpell) { - if (i == 0) { + if (i < preFont) { temp[i] = temp[i]; } else { String[] tTemps = new String[temp[i].length]; @@ -167,4 +188,9 @@ public class Pinyin4jUtil { return strJaggedArray; } } + + public static void main(String[] args) { + System.out.println(getFirstSpellPinYin("区直部门",false)); + System.out.println(getSpellPinYin("党员提出话题数",false,4)); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml index 115e0ae4e3..a1694d1104 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml @@ -114,24 +114,24 @@ - select ID, INDEX_GROUP_ID, INDEX_ID, INDEX_CODE, WEIGHT, THRESHOLD FROM index_group_detail - where STATUS = 'enable' and DEL_FLAG = '0' + select + ID, INDEX_GROUP_ID, INDEX_ID, INDEX_CODE, WEIGHT, THRESHOLD + FROM index_group_detail + WHERE + CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and STATUS = 'enable' and DEL_FLAG = '0' + and ALL_PARENT_INDEX_CODE = #{indexCode,jdbcType=VARCHAR} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml index 8ec562b386..5aacdd4b1b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailTemplateDao.xml @@ -7,7 +7,7 @@ delete from index_group_detail_template