Browse Source

更新指标管理首页

hsh 1 year ago
parent
commit
4dffce90c2

+ 11 - 0
src/main/java/thyyxxk/webserver/controller/targetmanagement/TargetManagementController.java

@@ -16,6 +16,7 @@ import thyyxxk.webserver.entity.highreport.TableGroupInfo;
 import thyyxxk.webserver.entity.highreport.ZbReportCycle;
 import thyyxxk.webserver.entity.highreport.ZbReportCycleScore;
 import thyyxxk.webserver.entity.highreport.ZbReportResult;
+import thyyxxk.webserver.entity.highreport.ZbReportScoreDto;
 import thyyxxk.webserver.entity.highreport.ZdReportType;
 import thyyxxk.webserver.entity.targetmanagement.TargetDictTree;
 import thyyxxk.webserver.entity.targetmanagement.TargetManagement;
@@ -195,4 +196,14 @@ public class TargetManagementController {
         return service.selectScoreCyclePermissions();
     }
 
+    @PostMapping("/selectTargetDictScoreById")
+    public ResultVo<List<Map<String, Object>>> selectTargetDictScoreById(@RequestBody @Validated ZbReportScoreDto dto){
+        return service.selectTargetDictScoreById(dto);
+    }
+
+    @PostMapping("/selectTargetTotalScoreInfo")
+    public ResultVo<Map<String, Object>> selectTargetTotalScoreInfo(@RequestBody @Validated ZbReportScoreDto dto){
+        return service.selectTargetTotalScoreInfo(dto);
+    }
+
 }

+ 12 - 0
src/main/java/thyyxxk/webserver/dao/his/highreport/HighReportDao.java

@@ -163,4 +163,16 @@ public interface HighReportDao {
             "</script>")
     void deleteTableGroupInfoById(@Param("reportId") String reportId);
 
+    @Select("<script>" +
+            " select * from zb_report_result zb " +
+            " where zb.pid = #{pid} " +
+            " <if test=\"startTime != null and startTime != '' \"> " +
+            " and zb.year &gt;= #{startTime} " +
+            " </if> " +
+            " <if test=\"endTime != null and endTime != '' \"> " +
+            " and zb.year &lt;= #{endTime} " +
+            " </if> " +
+            "</script>")
+    List<ZbReportResult> selectReportResultByPid(@Param("pid") String pid, @Param("startTime") String startTime, @Param("endTime") String endTime);
+
 }

+ 14 - 0
src/main/java/thyyxxk/webserver/dao/his/targetmanagement/ZbReportCycleScoreDao.java

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 import thyyxxk.webserver.entity.highreport.ZbReportCycleScore;
 
+import java.util.List;
 import java.util.Map;
 
 @Mapper
@@ -47,4 +48,17 @@ public interface ZbReportCycleScoreDao extends BaseMapper<ZbReportCycleScore> {
     @Select(" select name from sys_parameters where code = 'targetScore' ")
     String selectScoreCyclePermissions();
 
+    @Select("<script> " +
+            "select zb.id, zb.pid, zb.name as t_name, zb.score, zb.method as t_method, " +
+            "   zb.score_rule as t_rule, zb.op as t_manager, zb.op_id, " +
+            "   isnull(s.report_score, '') + '/' + cast(cast(zb.score as float) as varchar) as t_score " +
+            "from zb_zd_base_info zb left join zb_report_cycle_score s " +
+            "on zb.id = s.id and zb.pid = s.pid and s.report_cycle = #{reportCycle} " +
+            "where zb.pid = #{pid} " +
+            "</script>")
+    List<Map<String, Object>> selectTargetDictScoreByPid(@Param("pid") String pid, @Param("reportCycle") String reportCycle);
+
+    @Select(" select * from zb_report_cycle_score where report_cycle = #{reportCycle} ")
+    List<ZbReportCycleScore> selectTargetDictScoreByReportCycle(@Param("reportCycle") String reportCycle);
+
 }

+ 5 - 1
src/main/java/thyyxxk/webserver/dao/his/targetmanagement/ZbZdBaseInfoDao.java

@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
+import thyyxxk.webserver.entity.highreport.ZbReportCycleScore;
 import thyyxxk.webserver.entity.targetmanagement.TargetDictTree;
 import thyyxxk.webserver.entity.targetmanagement.TargetManagement;
 import thyyxxk.webserver.entity.targetmanagement.ZbZdBaseInfo;
@@ -135,7 +136,6 @@ public interface ZbZdBaseInfoDao {
             "</script>")
     int deleteTargetDictById(@Param("id") String id, @Param("pid") String pid);
 
-
     @Update("<script> " +
             " update zb_zd_base_info " +
             "<trim prefix=\"set\" suffixOverrides=\",\">" +
@@ -149,4 +149,8 @@ public interface ZbZdBaseInfoDao {
             " where id = #{id} and pid = #{pid} and state = 'Y' " +
             "</script>")
     void updateZbZdBaseInfoCalcId(@Param("id") String id, @Param("pid") String pid, @Param("childId") String calcId, @Param("momId") String momId);
+
+    @Select(" select * from zb_zd_base_info where pid = #{pid} order by id ")
+    List<ZbZdBaseInfo> selectTargetDictScoreBySecond(@Param("pid") String pid);
+
 }

+ 47 - 0
src/main/java/thyyxxk/webserver/entity/highreport/ZbReportScoreDto.java

@@ -0,0 +1,47 @@
+package thyyxxk.webserver.entity.highreport;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @ClassName ZbReportScoreDao
+ * @Author hsh
+ * @Date 2024/8/27 9:53
+ * @Version 1.0
+ * @Description 分数查询Dto
+ **/
+@Data
+public class ZbReportScoreDto {
+
+    private String id;
+    /**
+     * 指标父id
+     */
+    private String pid;
+    /**
+     * 指标(年度)周期
+     */
+    private String reportCycle;
+    /**
+     * 开始年份
+     */
+    private String startTime;
+    /**
+     * 结束年份
+     */
+    private String endTime;
+    /**
+     * 指标信息
+     */
+    private List<String> dataInfo;
+    /**
+     *
+     */
+    private String targetType;
+    /**
+     * 根目录id
+     */
+    private String bigId;
+
+}

+ 118 - 0
src/main/java/thyyxxk/webserver/service/targetmanagement/TargetManagementService.java

@@ -21,6 +21,7 @@ import thyyxxk.webserver.entity.highreport.TableGroupInfo;
 import thyyxxk.webserver.entity.highreport.ZbReportCycle;
 import thyyxxk.webserver.entity.highreport.ZbReportCycleScore;
 import thyyxxk.webserver.entity.highreport.ZbReportResult;
+import thyyxxk.webserver.entity.highreport.ZbReportScoreDto;
 import thyyxxk.webserver.entity.highreport.ZdReportType;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.entity.targetmanagement.TargetDictTree;
@@ -985,4 +986,121 @@ public class TargetManagementService {
         return ResultVoUtil.success(resultMap);
     }
 
+    /**
+     * @Description 查询指标得分情况
+     * @Author hsh
+     * @param dto 指标信息
+     * @return list
+     * @Date 2024/8/27 16:12
+     */
+    public ResultVo<List<Map<String, Object>>> selectTargetDictScoreById(ZbReportScoreDto dto){
+        String pid = dto.getPid();
+        String reportCycle = dto.getReportCycle();
+        if(StringUtil.isBlank(pid) || StringUtil.isBlank(reportCycle)){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "指标pid或年度周期信息不全,请检查!");
+        }
+        List<Map<String, Object>> list = scoreDao.selectTargetDictScoreByPid(pid, reportCycle);
+        // 根据pid以及时间查询报表结果
+        List<ZbReportResult> resultList = reportDao.selectReportResultByPid(pid, dto.getStartTime(), dto.getEndTime());
+        Map<String, List<ZbReportResult>> resultMap = resultList.stream().collect(Collectors.groupingBy(ZbReportResult::getId, Collectors.toList()));
+
+        for (Map<String, Object> map : list){
+            String id = String.valueOf(map.get("id"));
+            List<ZbReportResult> results = resultMap.get(id);
+            if(null != results && !results.isEmpty()){
+                for(ZbReportResult r : results){
+                    map.put("t_" + r.getYear(), r.getCalcResult());
+                }
+            } else {
+                String s = dto.getStartTime();
+                int year = Integer.parseInt(s);
+                for(int j = 0; j < 4; j++){
+                    int f = year + j;
+                    map.put("t_" + f, "");
+                }
+            }
+        }
+        return ResultVoUtil.success(list);
+    }
+
+    /**
+     * @Description 根据指标年度周期查询指标章节总分以及得分
+     * @Author hsh
+     * @param dto 指标年度周期
+     * @return list
+     * @Date 2024/8/30 8:58
+     */
+    public ResultVo<Map<String, Object>> selectTargetTotalScoreInfo(ZbReportScoreDto dto){
+        String reportCycle = dto.getReportCycle();
+        if(StringUtil.isBlank(reportCycle)){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有年度周期,请检查!");
+        }
+        Map<String, Object> resultMap = new HashMap<>();
+        // 查询第二级指标(pid是B)
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        List<ZbZdBaseInfo> ls = zbZdDao.selectTargetDictScoreBySecond("B");
+        // 拼接总分
+        Map<String, Object> m1 = new HashMap<>();
+        // 拼接名字
+        List<Map<String, Object>> mc = new ArrayList<>();
+        m1.put("name", "总分");
+        List<BigDecimal> zf = new ArrayList<>();
+        for (ZbZdBaseInfo zb : ls){
+            Map<String, Object> m2 = new HashMap<>();
+            zf.add(zb.getScore());
+            m2.put(zb.getId(), zb.getName());
+            mc.add(m2);
+        }
+        m1.put("data", zf);
+        resultList.add(m1);
+        resultMap.put("mc", mc);
+        // 查询得分
+        List<ZbReportCycleScore> list = scoreDao.selectTargetDictScoreByReportCycle(reportCycle);
+        if(null == list || list.isEmpty()){
+            // 没有得分就只显示总分
+            Map<String, Object> m3 = new HashMap<>();
+            m3.put("name", "得分");
+            m3.put("data", new int[]{0, 0, 0, 0, 0});
+            resultList.add(m3);
+            resultMap.put("infoData", resultList);
+            return ResultVoUtil.success(resultMap);
+        }
+        BigDecimal B1 = BigDecimal.ZERO;
+        BigDecimal B2 = BigDecimal.ZERO;
+        BigDecimal B3 = BigDecimal.ZERO;
+        BigDecimal B4 = BigDecimal.ZERO;
+        BigDecimal B5 = BigDecimal.ZERO;
+        for (ZbReportCycleScore score : list){
+            String pid = score.getPid();
+            String s = score.getReportScore();
+            if(StringUtil.isBlank(s)){
+                s = "0";
+            }
+            if(pid.startsWith("B1")){
+                B1 = DecimalUtil.add(B1, new BigDecimal(s));
+            } else if(pid.startsWith("B2")){
+                B2 = DecimalUtil.add(B2, new BigDecimal(s));
+            } else if(pid.startsWith("B3")){
+                B3 = DecimalUtil.add(B3, new BigDecimal(s));
+            } else if(pid.startsWith("B4")){
+                B4 = DecimalUtil.add(B4, new BigDecimal(s));
+            } else if(pid.startsWith("B5")){
+                B5 = DecimalUtil.add(B5, new BigDecimal(s));
+            }
+        }
+        // 拼接得分
+        Map<String, Object> m3 = new HashMap<>();
+        m3.put("name", "得分");
+        List<BigDecimal> df = new ArrayList<>();
+        df.add(B1);
+        df.add(B2);
+        df.add(B3);
+        df.add(B4);
+        df.add(B5);
+        m3.put("data", df);
+        resultList.add(m3);
+        resultMap.put("infoData", resultList);
+        return ResultVoUtil.success(resultMap);
+    }
+
 }