|  |  | @ -22,6 +22,7 @@ import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.enums.OrgLevelEnum; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.DateUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.DataSourceConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.datareport.constant.FactConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.datareport.constant.IndexConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.datareport.dao.evaluationindex.index.IndexExplainDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.datareport.dao.evaluationindex.index.IndexGroupDetailDao; | 
			
		
	
	
		
			
				
					|  |  | @ -99,6 +100,16 @@ public class IndexExplainServiceImpl implements IndexExplainService { | 
			
		
	
		
			
				
					|  |  |  |             results.add(result); | 
			
		
	
		
			
				
					|  |  |  |             result.setTitle(explainDTO.getTitle()); | 
			
		
	
		
			
				
					|  |  |  |             result.setMeaning(explainDTO.getMeaning()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             //全区相关的服务能力的含义中 有权重 所以特殊处理下
 | 
			
		
	
		
			
				
					|  |  |  |             if (explainDTO.getOrgLevel().equals(OrgLevelEnum.DISTRICT.getCode()) && IndexConstant.ZLZS_CN.equals(explainDTO.getTitle())) { | 
			
		
	
		
			
				
					|  |  |  |                 List<IndexGroupDetailResult> detailResults = detailEntityMap.get(IndexConstant.QUAN_QU_ZHI_LI_INDEX_CODE); | 
			
		
	
		
			
				
					|  |  |  |                 detailResults.forEach(index -> { | 
			
		
	
		
			
				
					|  |  |  |                     String newMeaning = result.getMeaning().replaceFirst(IndexConstant.PATTERN_D, | 
			
		
	
		
			
				
					|  |  |  |                             index.getWeight().multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(NumConstant.ZERO, BigDecimal.ROUND_HALF_UP).toString()); | 
			
		
	
		
			
				
					|  |  |  |                     result.setMeaning(newMeaning); | 
			
		
	
		
			
				
					|  |  |  |                 }); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             //设置表格数据
 | 
			
		
	
		
			
				
					|  |  |  |             setTableData(formDTO, detailEntityMap, explainDTO, result); | 
			
		
	
		
			
				
					|  |  |  |             //子节点
 | 
			
		
	
	
		
			
				
					|  |  | @ -162,7 +173,6 @@ public class IndexExplainServiceImpl implements IndexExplainService { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                         List<IndexGroupDetailResult> indexGroupDetailEntities = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |                         for (IndexGroupDetailResult index : detailResults) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                             if (IndexConstant.INDEX_DISTRINCT_TABLE1_INDEX_CODE.equals(index.getIndexCode())) { | 
			
		
	
		
			
				
					|  |  |  |                                 indexGroupDetailEntities.add(index); | 
			
		
	
		
			
				
					|  |  |  |                                 setDefaultTableData(orgLevel, type, detailEntityMap, result, allIndexCodePath, indexGroupDetailEntities); | 
			
		
	
	
		
			
				
					|  |  | @ -184,10 +194,10 @@ public class IndexExplainServiceImpl implements IndexExplainService { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                     break; | 
			
		
	
		
			
				
					|  |  |  |                 default: | 
			
		
	
		
			
				
					|  |  |  |                     log.error("暂不支持更高级别的查询,level:{}",orgLevel); | 
			
		
	
		
			
				
					|  |  |  |                     log.error("暂不支持更高级别的查询,level:{}", orgLevel); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             setRealValue(result.getTableDataList(), realScoreList); | 
			
		
	
		
			
				
					|  |  |  |             setRealValue(result.getTableDataList(), realScoreList, tableHeaders); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -196,11 +206,12 @@ public class IndexExplainServiceImpl implements IndexExplainService { | 
			
		
	
		
			
				
					|  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |      * @param tableList | 
			
		
	
		
			
				
					|  |  |  |      * @param scoreList | 
			
		
	
		
			
				
					|  |  |  |      * @param tableHeaders | 
			
		
	
		
			
				
					|  |  |  |      * @return void | 
			
		
	
		
			
				
					|  |  |  |      * @author LiuJanJun | 
			
		
	
		
			
				
					|  |  |  |      * @date 2021/5/19 2:07 下午 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     private void setRealValue(List<IndexScoreDetailResult> tableList, List<IndexScoreResult> scoreList) { | 
			
		
	
		
			
				
					|  |  |  |     private void setRealValue(List<IndexScoreDetailResult> tableList, List<IndexScoreResult> scoreList, List<String> tableHeaders) { | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(tableList) || CollectionUtils.isEmpty(scoreList)) { | 
			
		
	
		
			
				
					|  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  | @ -209,19 +220,39 @@ public class IndexExplainServiceImpl implements IndexExplainService { | 
			
		
	
		
			
				
					|  |  |  |                 if (!tb.getIndexCode().equals(score.getIndexCode())) { | 
			
		
	
		
			
				
					|  |  |  |                     continue; | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 tb.setOriginValue(score.getOriginValue()); | 
			
		
	
		
			
				
					|  |  |  |                 tb.setScore(String.valueOf(score.getScore())); | 
			
		
	
		
			
				
					|  |  |  |                 if (StringUtils.isNotBlank(score.getQuantity())) { | 
			
		
	
		
			
				
					|  |  |  |                     tb.setQuantity(score.getQuantity()); | 
			
		
	
		
			
				
					|  |  |  |                 tb.setWeight(score.getWeight().multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(0, BigDecimal.ROUND_HALF_UP) + "%"); | 
			
		
	
		
			
				
					|  |  |  |                 if (tableHeaders.contains("平均值")) { | 
			
		
	
		
			
				
					|  |  |  |                     if (StringUtils.isNotBlank(score.getSampleCount())) { | 
			
		
	
		
			
				
					|  |  |  |                         tb.setOriginValue(score.getSampleCount()); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |                     tb.setOriginValue(score.getOriginValue()); | 
			
		
	
		
			
				
					|  |  |  |                     formatOriginValue(score, tb); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 tb.setWeight(score.getWeight().multiply(new BigDecimal(NumConstant.ONE_HUNDRED)) + "%"); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private void formatOriginValue(IndexScoreResult score, IndexScoreDetailResult index) { | 
			
		
	
		
			
				
					|  |  |  |         //小数类型,四舍五入保留小数点后一位
 | 
			
		
	
		
			
				
					|  |  |  |         if (FactConstant.INTEGER.equals(score.getValueType())) { | 
			
		
	
		
			
				
					|  |  |  |             BigDecimal num = new BigDecimal(index.getOriginValue()).setScale(0, BigDecimal.ROUND_HALF_UP); | 
			
		
	
		
			
				
					|  |  |  |             index.setOriginValue(num.toString()); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         if (FactConstant.DECIMAL.equals(score.getValueType())) { | 
			
		
	
		
			
				
					|  |  |  |             BigDecimal num = new BigDecimal(index.getOriginValue()).setScale(1, BigDecimal.ROUND_HALF_UP); | 
			
		
	
		
			
				
					|  |  |  |             index.setOriginValue(num.toString()); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         //百分数类型,四舍五入保留小数点后一位并转成百分比
 | 
			
		
	
		
			
				
					|  |  |  |         if (FactConstant.PERCENT.equals(score.getValueType())) { | 
			
		
	
		
			
				
					|  |  |  |             BigDecimal num = new BigDecimal(index.getOriginValue()).setScale(1, BigDecimal.ROUND_HALF_UP); | 
			
		
	
		
			
				
					|  |  |  |             index.setOriginValue(num + "%"); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private List<IndexScoreDetailResult> setDefaultTableData(String orgLevel, String type, Map<String, List<IndexGroupDetailResult>> detailEntityMap, | 
			
		
	
		
			
				
					|  |  |  |                                                              IndexExplainResult result, String allIndexCodePath, List<IndexGroupDetailResult> indexGroupDetailEntities) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if (indexGroupDetailEntities == null) { | 
			
		
	
		
			
				
					|  |  |  |             indexGroupDetailEntities = detailEntityMap.get(allIndexCodePath); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  | @ -233,18 +264,21 @@ public class IndexExplainServiceImpl implements IndexExplainService { | 
			
		
	
		
			
				
					|  |  |  |         List<String> threlodList = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |         indexGroupDetailEntities.forEach(index -> { | 
			
		
	
		
			
				
					|  |  |  |             IndexScoreDetailResult table = new IndexScoreDetailResult(); | 
			
		
	
		
			
				
					|  |  |  |             if ("grid".equals(orgLevel) && IndexConstant.ZI_SHEN.equals(type) && index.getAllIndexCodePath().contains(IndexConstant.XIA_JI)) { | 
			
		
	
		
			
				
					|  |  |  |             if (OrgLevelEnum.GRID.getCode().equals(orgLevel) && IndexConstant.ZI_SHEN.equals(type) && index.getAllIndexCodePath().contains(IndexConstant.XIA_JI)) { | 
			
		
	
		
			
				
					|  |  |  |                 return; | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             if (OrgLevelEnum.DISTRICT.getCode().equals(orgLevel) && !index.getAllIndexCodePath().contains(type) && !index.getAllIndexCodePath().contains(IndexConstant.ZHI_LI_NENG_LI)) { | 
			
		
	
		
			
				
					|  |  |  |                 return; | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             if ((!"grid".equals(orgLevel) && !"district".equals(orgLevel)) && !index.getAllIndexCodePath().contains(type)) { | 
			
		
	
		
			
				
					|  |  |  |             if (!OrgLevelEnum.GRID.getCode().equals(orgLevel) && !OrgLevelEnum.DISTRICT.getCode().equals(orgLevel) && !index.getAllIndexCodePath().contains(type)) { | 
			
		
	
		
			
				
					|  |  |  |                 return; | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             table.setIndexCode(index.getIndexCode()); | 
			
		
	
		
			
				
					|  |  |  |             table.setIndexName(index.getIndexName()); | 
			
		
	
		
			
				
					|  |  |  |             table.setOriginValue(NumConstant.ZERO_STR); | 
			
		
	
		
			
				
					|  |  |  |             table.setScore(NumConstant.ZERO_STR); | 
			
		
	
		
			
				
					|  |  |  |             table.setWeight(index.getWeight().multiply(new BigDecimal(100)).setScale(NumConstant.TWO, BigDecimal.ROUND_HALF_UP) + "%"); | 
			
		
	
		
			
				
					|  |  |  |             table.setQuantity(NumConstant.ZERO_STR); | 
			
		
	
		
			
				
					|  |  |  |             table.setWeight(index.getWeight().multiply(new BigDecimal(100)).setScale(0, BigDecimal.ROUND_HALF_UP) + "%"); | 
			
		
	
		
			
				
					|  |  |  |             table.setType(type); | 
			
		
	
		
			
				
					|  |  |  |             tableList.add(table); | 
			
		
	
		
			
				
					|  |  |  |             if (new BigDecimal(-1).compareTo(index.getThreshold()) != 0) { | 
			
		
	
		
			
				
					|  |  |  |                 threlodList.add(index.getIndexName().concat(String.format(IndexConstant.THRESHOLD_TEXT, index.getThreshold().intValue()))); | 
			
		
	
	
		
			
				
					|  |  | @ -277,13 +311,14 @@ public class IndexExplainServiceImpl implements IndexExplainService { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private List<String> getTableHeaders(String type, String allIndexCode, String orgLevel) { | 
			
		
	
		
			
				
					|  |  |  |         List<String> headers = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |         switch (orgLevel) { | 
			
		
	
		
			
				
					|  |  |  |             case "grid": | 
			
		
	
		
			
				
					|  |  |  |         OrgLevelEnum anEnum = OrgLevelEnum.getEnum(orgLevel); | 
			
		
	
		
			
				
					|  |  |  |         switch (anEnum) { | 
			
		
	
		
			
				
					|  |  |  |             case GRID: | 
			
		
	
		
			
				
					|  |  |  |                 //还没确定怎么搞
 | 
			
		
	
		
			
				
					|  |  |  |                 if ("zishen".equals(type)) { | 
			
		
	
		
			
				
					|  |  |  |                 if (IndexConstant.ZI_SHEN.equals(type)) { | 
			
		
	
		
			
				
					|  |  |  |                     headers = IndexConstant.getStandardSelfHeaders(allIndexCode); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 } else if ("xiaji".equals(type)) { | 
			
		
	
		
			
				
					|  |  |  |                 } else if (IndexConstant.XIA_JI.equals(type)) { | 
			
		
	
		
			
				
					|  |  |  |                     headers = new ArrayList<>(IndexConstant.QuantityLastHeader); | 
			
		
	
		
			
				
					|  |  |  |                     if (allIndexCode.contains("canyuyishi")) { | 
			
		
	
		
			
				
					|  |  |  |                         headers.add(0, "组织内党员的参与议事指数考评分(平均值)"); | 
			
		
	
	
		
			
				
					|  |  | @ -292,11 +327,11 @@ public class IndexExplainServiceImpl implements IndexExplainService { | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                     break; | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             case "district": | 
			
		
	
		
			
				
					|  |  |  |                 if ("zishen".equals(type)) { | 
			
		
	
		
			
				
					|  |  |  |             case DISTRICT: | 
			
		
	
		
			
				
					|  |  |  |                 if (IndexConstant.ZI_SHEN.equals(type)) { | 
			
		
	
		
			
				
					|  |  |  |                     headers = IndexConstant.getStandardSelfHeaders(allIndexCode); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 } else if ("xiaji".equals(type)) { | 
			
		
	
		
			
				
					|  |  |  |                 } else if (IndexConstant.XIA_JI.equals(type)) { | 
			
		
	
		
			
				
					|  |  |  |                     headers = new ArrayList<>(IndexConstant.QuantityLastHeader); | 
			
		
	
		
			
				
					|  |  |  |                     if (allIndexCode.contains("quzhibumen")) { | 
			
		
	
		
			
				
					|  |  |  |                         headers.add(0, "区直部门各项治理指数指标"); | 
			
		
	
	
		
			
				
					|  |  | @ -306,10 +341,10 @@ public class IndexExplainServiceImpl implements IndexExplainService { | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 break; | 
			
		
	
		
			
				
					|  |  |  |             default: | 
			
		
	
		
			
				
					|  |  |  |                 if ("zishen".equals(type)) { | 
			
		
	
		
			
				
					|  |  |  |                 if (IndexConstant.ZI_SHEN.equals(type)) { | 
			
		
	
		
			
				
					|  |  |  |                     headers = IndexConstant.getStandardSelfHeaders(allIndexCode); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                 } else if ("xiaji".equals(type)) { | 
			
		
	
		
			
				
					|  |  |  |                 } else if (IndexConstant.XIA_JI.equals(type)) { | 
			
		
	
		
			
				
					|  |  |  |                     headers = IndexConstant.getStandardSubHeaders(allIndexCode); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  | 
 |