| 
					
				 | 
			
			
				@@ -5,11 +5,13 @@ import org.jetbrains.annotations.NotNull; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.config.exception.ExceptionEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import thyyxxk.webserver.dao.his.highreport.HighReportDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.dao.his.targetmanagement.TargetManagementDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.dao.his.targetmanagement.ZbZdBaseInfoDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.ResultVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.highreport.HighReportDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.highreport.ReportBaseInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import thyyxxk.webserver.entity.highreport.ReportType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.targetmanagement.TargetDictTree; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.targetmanagement.TargetManagement; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.targetmanagement.ZbZdBaseInfo; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -20,9 +22,11 @@ import thyyxxk.webserver.utils.StringUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.utils.TargetDictTreeUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @Description: 指标管理 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -38,10 +42,13 @@ public class TargetManagementService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private final ZbZdBaseInfoDao zbZdDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private final HighReportDao reportDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public TargetManagementService(TargetManagementDao dao, ZbZdBaseInfoDao zbZdDao) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public TargetManagementService(TargetManagementDao dao, ZbZdBaseInfoDao zbZdDao, HighReportDao reportDao) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.dao = dao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.zbZdDao = zbZdDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.reportDao = reportDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -261,7 +268,11 @@ public class TargetManagementService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (StringUtil.notBlank(mom)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             resultMap.put("r2", mom); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            resultMap.put("r3", DecimalUtil.divide(new BigDecimal(child), new BigDecimal(mom), 2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(StringUtil.notBlank(child)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("r3", DecimalUtil.divide(new BigDecimal(child), new BigDecimal(mom), 4)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultMap.put("r3", "无"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             resultMap.put("r2", "无"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (StringUtil.notBlank(child)) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -458,4 +469,95 @@ public class TargetManagementService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ResultVoUtil.success(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @description: 查询指标报表数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @author: hsh 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @date: 2023/7/7 10:19 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param: [dto] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return: ResultVo<List<Map<String, Object>>> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     **/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ResultVo<List<Map<String, Object>>> selectReportDictTree(HighReportDto dto){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 查询所有使用的指标报表数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<ReportBaseInfo> list = reportDao.selectReportDictTree(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, List<ReportBaseInfo>> reportMap = list.stream().collect(Collectors.groupingBy(reportBaseInfo -> reportBaseInfo.getReportType())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String, Object>> resultList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Object> rootMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        rootMap.put("id", "zbJc"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        rootMap.put("pid", "0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        rootMap.put("label", "指标监测"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String, Object>> rootChildList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(Map.Entry<String, List<ReportBaseInfo>> entry: reportMap.entrySet()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, Object> map = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<ReportBaseInfo> l = entry.getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String type = entry.getKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String reportName = ReportType.find(type + "_jc"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(StringUtil.notBlank(reportName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put("id", type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put("pid", "zbJc"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put("label", reportName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put("id", type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put("label", ReportType.QT.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put("pid", "zbJc"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Map<String, Object>> child = AssertReportTree(l, type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put("children", child); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            rootChildList.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        rootMap.put("children", rootChildList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        resultList.add(rootMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return ResultVoUtil.success(resultList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @description: 组装指标报表树数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @author: hsh 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @date: 2023/7/7 11:34 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param: [list, type] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return: List<Map<String, Object>> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     **/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private List<Map<String, Object>> AssertReportTree(List<ReportBaseInfo> list, String type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String, Object>> resultList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(ReportBaseInfo info : list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, Object> map = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put("id", info.getReportId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put("pid", type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put("label", info.getReportName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            resultList.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return resultList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @description: 根据报表id作废指标报表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @author: hsh 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @date: 2023/7/7 16:13 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param: [dto] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return: ResultVo<Map<String,Object>> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     **/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ResultVo<Map<String, Object>> deleteReportDictById(HighReportDto dto) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (StringUtil.isBlank(dto.getReportId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "id不存在,请检查!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Object> resultMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int num = reportDao.updateReportDictById(dto.getReportId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (num == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "作废指标报表失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        resultMap.put("cg", "作废指标报表成功!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return ResultVoUtil.success(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @description: 查询指标报表信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @author: hsh 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @date: 2023/7/7 16:52 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param: [dto] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return: ResultVo<List<ReportBaseInfo>> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     **/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ResultVo<List<ReportBaseInfo>> selectReportDict(HighReportDto dto) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<ReportBaseInfo> list = reportDao.selectReportDict(dto); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return ResultVoUtil.success(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |