ソースを参照

报表保存优化

hsh 2 年 前
コミット
37b447af65

+ 6 - 1
src/main/java/thyyxxk/webserver/controller/targetmanagement/TargetManagementController.java

@@ -99,7 +99,7 @@ public class TargetManagementController {
     }
 
     @PostMapping("/deleteReportDictById")
-    public ResultVo<Map<String, Object>> deleteReportDictById(@RequestBody @Validated HighReportDto dto){
+    public ResultVo<Map<String, Object>> deleteReportDictById(@RequestBody @Validated TargetManagement dto){
         return service.deleteReportDictById(dto);
     }
 
@@ -134,4 +134,9 @@ public class TargetManagementController {
         return service.selectTargetReportResult(dto);
     }
 
+    @PostMapping("/saveReportBaseInfo")
+    public ResultVo<Map<String, Object>> saveReportBaseInfo(@RequestBody @Validated ReportBaseInfo info){
+        return service.saveReportBaseInfo(info);
+    }
+
 }

+ 24 - 1
src/main/java/thyyxxk/webserver/dao/his/highreport/HighReportDao.java

@@ -107,8 +107,14 @@ public interface HighReportDao {
             " select * from zb_report_result zb " +
             " where zb.id = #{id} " +
             " and 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> selectReportResultById(@Param("id") String id, @Param("pid") String pid);
+    List<ZbReportResult> selectReportResultById(@Param("id") String id, @Param("pid") String pid, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
     @Delete("<script>" +
             " delete zb from zb_report_result zb " +
@@ -127,4 +133,21 @@ public interface HighReportDao {
     "</script>")
     int saveTargetReportResult(ZbReportResult result);
 
+    @Delete("<script>" +
+            " delete from report_base_info " +
+            " where report_id = #{reportId} " +
+            "</script>")
+    int deleteReportBaseInfoById(@Param("reportId") String reportId);
+
+    @Insert("<script>" +
+            " insert into report_base_info " +
+            " (report_id, report_name, report_type, unit, level, gather_sql, base_sql, display_type, flag, " +
+            "  menu_id, sort, report_sort, is_cw, is_yj, calc_child, calc_mom) values " +
+            " (#{reportId},#{reportName},#{reportType},#{unit},#{level}, " +
+            " #{gatherSql},#{baseSql},#{displayType},#{flag},#{menuId} " +
+            " #{sort},#{reportSort},#{isCw},#{isYj},#{calcChild},#{calcMom} " +
+            " ) " +
+            "</script>")
+    int saveReportBaseInfo(ReportBaseInfo info);
+
 }

+ 1 - 0
src/main/java/thyyxxk/webserver/entity/highreport/TableGroupInfo.java

@@ -23,6 +23,7 @@ public class TableGroupInfo {
     private String trdName;
     private String fthGroup;
     private String fthName;
+    private String reportId;
     private String flag;
     private String levelType;
 

+ 34 - 6
src/main/java/thyyxxk/webserver/service/targetmanagement/TargetManagementService.java

@@ -129,7 +129,7 @@ public class TargetManagementService {
         target.setId(dto.getId());
         target.setPid(dto.getPid());
         ZbZdBaseInfo zdBaseInfo = zbZdDao.selectZbZdBaseInfoById(target);
-        int num = 0;
+        int num;
         if(zdBaseInfo != null){
             num = zbZdDao.updateZbZdBaseInfo(dto);
         } else {
@@ -522,7 +522,7 @@ public class TargetManagementService {
             typeMap.put(zdReport.getReportType(), zdReport);
         }
 
-        Map<String, List<ReportBaseInfo>> reportMap = list.stream().collect(Collectors.groupingBy(reportBaseInfo -> reportBaseInfo.getReportType()));
+        Map<String, List<ReportBaseInfo>> reportMap = list.stream().collect(Collectors.groupingBy(ReportBaseInfo::getReportType));
         List<Map<String, Object>> resultList = new ArrayList<>();
         Map<String, Object> rootMap = new HashMap<>();
         rootMap.put("id", "zbJc");
@@ -580,12 +580,12 @@ public class TargetManagementService {
      * @param: [dto]
      * @return: ResultVo<Map<String,Object>>
      **/
-    public ResultVo<Map<String, Object>> deleteReportDictById(HighReportDto dto) {
-        if (StringUtil.isBlank(dto.getReportId())) {
+    public ResultVo<Map<String, Object>> deleteReportDictById(TargetManagement dto) {
+        if (StringUtil.isBlank(dto.getId())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "id不存在,请检查!");
         }
         Map<String, Object> resultMap = new HashMap<>();
-        int num = reportDao.updateReportDictById(dto.getReportId());
+        int num = reportDao.updateReportDictById(dto.getId());
         if (num == 0) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "作废指标报表失败!");
         }
@@ -720,8 +720,36 @@ public class TargetManagementService {
      * @return: ResultVo<List<ZbReportResult>>
      **/
     public ResultVo<List<ZbReportResult>> selectTargetReportResult(TargetManagement dto) {
-        List<ZbReportResult> list = reportDao.selectReportResultById(dto.getId(), dto.getPid());
+        List<ZbReportResult> list = reportDao.selectReportResultById(dto.getId(), dto.getPid(), dto.getStartTime(), dto.getEndTime());
         return ResultVoUtil.success(list);
     }
 
+    /**
+     * @description: 保存/更新指标报表基本信息
+     * @author: hsh
+     * @date: 2023/7/27 9:55
+     * @param: [info]
+     * @return: ResultVo<Map<String,Object>>
+     **/
+    public ResultVo<Map<String, Object>> saveReportBaseInfo(ReportBaseInfo info) {
+        Map<String, Object> resultMap = new HashMap<>();
+
+        if(info == null || StringUtil.isBlank(info.getReportId())){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "报表详情为空,保存指标详情失败!");
+        }
+
+        ReportBaseInfo report = reportDao.selectReportPortalMenu(info.getReportId(), null, null);
+        if (report != null) {
+            reportDao.deleteReportBaseInfoById(info.getReportId());
+        }
+
+        int n = dao.insert(info);
+        if (n <= 0) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存指标详情失败!");
+        }
+
+        resultMap.put("cg", "保存指标详情成功!");
+        return ResultVoUtil.success(resultMap);
+    }
+
 }