| 
					
				 | 
			
			
				@@ -20,6 +20,7 @@ import thyyxxk.webserver.entity.highreport.TableDisplayInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.highreport.TableGroupInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.highreport.ZbReportCycle; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.highreport.ZbReportCycleScore; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import thyyxxk.webserver.entity.highreport.ZbReportMonthScore; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.highreport.ZbReportResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.highreport.ZbReportScoreDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.highreport.ZdReportType; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -37,6 +38,8 @@ import thyyxxk.webserver.utils.TargetDictTreeUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.utils.TokenUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.LocalDate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.YearMonth; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Comparator; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.HashMap; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -118,7 +121,7 @@ public class TargetManagementService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public ResultVo<List<TargetDictTree>> selectTargetDictTree(TargetManagement dto) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<TargetDictTree> zbList = zbZdDao.selectTargetDictTree(dto); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 组装指标树 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<TargetDictTree> list = assemblyTargetDictTree(zbList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TargetDictTree> list = assemblyTargetDictTree(zbList, dto.getDept()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ResultVoUtil.success(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -129,9 +132,9 @@ public class TargetManagementService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param: [list, zbList] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return: void 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      **/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private List<TargetDictTree> assemblyTargetDictTree(@NotNull List<TargetDictTree> zbList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private List<TargetDictTree> assemblyTargetDictTree(@NotNull List<TargetDictTree> zbList, String dept) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 创建树形结构(数据集合作为参数) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        TargetDictTreeUtil treeBuild = new TargetDictTreeUtil(zbList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        TargetDictTreeUtil treeBuild = new TargetDictTreeUtil(zbList, dept); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 原查询结果转换树形结构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return treeBuild.buildTree(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1103,4 +1106,146 @@ public class TargetManagementService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ResultVoUtil.success(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @Description 根据月份查询指标得分想详细情况 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @Author hsh 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param dto 指标参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return map 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @Date 2024/11/20 11:02 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ResultVo<Map<String, Object>> targetSqlExecuteMonthById(TargetManagement dto) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ReportBaseInfo reportChild = dao.selectReportBaseInfoByCalcId(dto.getChildId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ReportBaseInfo reportMom = dao.selectReportBaseInfoByCalcId(dto.getMomId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(null ==  reportChild && null == reportMom){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【" + dto.getName() + "】指标-分子或分母指标都不存在,请联系管理员!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(null ==  dto.getStartTime() || null == dto.getEndTime()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【" + dto.getName() + "】查询时间不存在,请检查!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Object> resultMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        resultMap.put("id", dto.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        resultMap.put("pid", dto.getPid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        resultMap.put("name", dto.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        resultMap.put("childId", dto.getChildId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        resultMap.put("momId", dto.getMomId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 数据统计来源(1:sql统计;2:手动填写输入。) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        resultMap.put("dataType", "1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 统计年月 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        resultMap.put("month", dto.getStartTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String d1 = dto.getStartTime().substring(0,4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String d2 = dto.getStartTime().substring(4,6); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int year = Integer.parseInt(d1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int month = Integer.parseInt(d2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        YearMonth ym = YearMonth.of(year, month); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LocalDate js = ym.atEndOfMonth(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        dto.setStartTime(ym + "-01 23:59:59"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        dto.setEndTime(js + " 23:59:59"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HighReportDto vo = ReportUtil.TargetManagementConvertHighReportDto(dto); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 计算结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String child = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String mom = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(null != reportChild){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String childSql = ReportUtil.callSqlFormat(vo, reportChild.getBaseSql(), reportChild.getGatherSql(), null, null, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            child = dao.targetSqlExecute(childSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            child = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(null != reportMom){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String momSql = ReportUtil.callSqlFormat(vo, reportMom.getBaseSql(), reportMom.getGatherSql(), null, null, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            mom = dao.targetSqlExecute(momSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            mom = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (StringUtil.notBlank(child)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            resultMap.put("childResult", child); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            resultMap.put("childResult", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (StringUtil.notBlank(mom)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            resultMap.put("momResult", mom); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(StringUtil.notBlank(child)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("calcResult", DecimalUtil.divide(new BigDecimal(child), new BigDecimal(mom), 4)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("calcResult", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            resultMap.put("momResult", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (StringUtil.notBlank(child)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("calcResult", child); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("calcResult", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return ResultVoUtil.success(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @Description 根据月份查询指标月度结果以及得分情况 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @Author hsh 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param dto 指标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return score 指标月度结果以及得分情况 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @Date 2024/11/20 17:15 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ResultVo<ZbReportMonthScore> selectTargetReportResultByMonth(ZbReportMonthScore dto) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ZbReportMonthScore score = reportDao.selectReportResultByMonth(dto.getId(), dto.getPid(), dto.getMonth()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return ResultVoUtil.success(score); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @Description 保存指标计算结果以及得分情况 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @Author hsh 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param monthScore 指标计算结果以及得分情况 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return  map 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @Date 2024/11/20 17:16 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ResultVo<Map<String, Object>> saveTargetReportMonthResult(ZbReportMonthScore monthScore){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Object> resultMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(monthScore == null || null == monthScore.getId()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "指标id不存在,请检查!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        UserInfo user = redis.getUserInfoByCode(TokenUtil.getInstance().getTokenUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        monthScore.setAuthorName(user.getName() != null ? user.getName().trim() : null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        monthScore.setAuthorId(user.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        monthScore.setDeptId(user.getDeptCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        monthScore.setDeptName(user.getDeptName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        monthScore.setCreateTime(DateUtil.now()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 入库或更新操作 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int n = updateAndSaveTargetReportMonthResult(monthScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (n <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存指标计算结果以及得分情况失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        resultMap.put("cg", "保存指标计算结果以及得分情况成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return ResultVoUtil.success(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private int updateAndSaveTargetReportMonthResult(ZbReportMonthScore monthScore) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(monthScore == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ZbReportMonthScore r = reportDao.selectReportResultByMonth(monthScore.getId(), monthScore.getPid(), monthScore.getMonth()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(r != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            reportDao.deleteReportResultMonthById(monthScore.getId(), monthScore.getPid(), monthScore.getMonth()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return reportDao.saveTargetReportMonthResult(monthScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @Description 根据月份,指标id查询指标得分详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @Author hsh 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param dto 月份,指标id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return list 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @Date 2024/11/21 11:01 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ResultVo<List<ZbReportMonthScore>> selectTargetReportMonthScore(TargetManagement dto) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<ZbReportMonthScore> score = reportDao.selectTargetReportMonthResultById(dto.getId(), dto.getPid(), dto.getStartTime(), dto.getEndTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return ResultVoUtil.success(score); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |