Explorar el Código

Merge branch 'master' into 'master'

增加科室经营分析报表

See merge request lighter/web-server!130
huangshuhua hace 4 meses
padre
commit
bdce024a39

+ 45 - 0
src/main/java/thyyxxk/webserver/controller/highreport/DeptBusinessController.java

@@ -0,0 +1,45 @@
+package thyyxxk.webserver.controller.highreport;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.highreport.HighReportDto;
+import thyyxxk.webserver.service.highreport.DeptBusinessService;
+
+import java.util.Map;
+
+/**
+ * @ClassName DeptBusinessController
+ * @Author hsh
+ * @Date 2025/4/2 15:35
+ * @Version 1.0
+ * @Description 科室经营报表
+ **/
+@RestController
+@RequestMapping("/deptBusiness")
+public class DeptBusinessController {
+
+    private final DeptBusinessService service;
+
+    @Autowired
+    public DeptBusinessController(DeptBusinessService service) {
+        this.service = service;
+    }
+
+    @GetMapping("/selectReportTypeList")
+    public ResultVo<Map<String, Object>> selectReportTypeList(@RequestParam("flag") String flag){
+        return service.selectReportTypeList(flag);
+    }
+
+    @PostMapping("/selectDeptReportList")
+    public ResultVo<Map<String, Object>> selectDeptReportList(@RequestBody @Validated HighReportDto dto){
+        return service.selectDeptReportList(dto);
+    }
+
+}

+ 5 - 0
src/main/java/thyyxxk/webserver/controller/medicalinsurance/costcontrol/YbUtilController.java

@@ -59,4 +59,9 @@ public class YbUtilController {
         return service.selectAllRegLevel(map);
     }
 
+    @PostMapping("/selectQxSmallDept")
+    public ResultVo<List<Map<String, Object>>> selectQxSmallDept(@RequestBody @Validated Map<String, String> map){
+        return service.selectQxSmallDept(map);
+    }
+
 }

+ 30 - 0
src/main/java/thyyxxk/webserver/dao/his/highreport/DeptBusinessDao.java

@@ -0,0 +1,30 @@
+package thyyxxk.webserver.dao.his.highreport;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import thyyxxk.webserver.entity.highreport.DeptReportResult;
+import thyyxxk.webserver.entity.highreport.ReportBaseInfo;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface DeptBusinessDao {
+
+    @Select(" select report_type as reportType, report_label as reportLabel, report_code as reportCode, ybb_flag as layoutFlag from zd_report_type where flag = #{flag} order by sort ")
+    List<Map<String, Object>> selectReportTypeList(@Param("flag") String flag);
+
+    @Select(" select * from report_base_info where flag = 'Y' and report_type in (select report_type from zd_report_type where flag = #{flag}) order by sort ")
+    List<ReportBaseInfo> selectReportList(@Param("flag") String flag);
+
+    @Select("<script> ${sql} </script>")
+    List<DeptReportResult> selectDeptBusinessReportData(@Param("sql")String sql);
+
+    @Select(" select * from report_base_info where flag = 'Y' and report_type in (select report_type from zd_report_type where flag = #{flag} and report_type in (${codes})) order by sort ")
+    List<ReportBaseInfo> selectReportListByCodes(@Param("flag") String flag, @Param("codes") String codes);
+
+    @Select(" select report_type as reportType, report_label as reportLabel, report_code as reportCode, ybb_flag as layoutFlag from zd_report_type where flag = #{flag} and report_type in (${codes}) order by sort ")
+    List<Map<String, Object>> selectReportTypeListByCodes(@Param("flag") String flag, @Param("codes") String codes);
+
+}

+ 15 - 0
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/costcontrol/YbUtilDao.java

@@ -99,4 +99,19 @@ public interface YbUtilDao {
             "</script> ")
     List<Map<String, Object>> selectAllRegLevel(@Param("str") String str);
 
+    @Select(" select name from sys_parameters where code = #{code} ")
+    String selectDeptYbbQxByRole(@Param("code") String code);
+
+    @Select("<script> " +
+            "select rtrim(name) as name, rtrim(code) as code from zd_unit_code with(nolock) where code not like '8%' and del_flag = 0 " +
+            "<if test=\"codeList != null \"> " +
+            " and code in " +
+            "<foreach collection='codeList' item='code' separator=',' open='(' close=')'>" +
+            "#{code}" +
+            "</foreach> " +
+            "</if> " +
+            "order by code " +
+            "</script> ")
+    List<Map<String, Object>> selectSmallDeptByCode(@Param("codeList") List<String> codeList);
+
 }

+ 40 - 0
src/main/java/thyyxxk/webserver/entity/highreport/DeptReportResult.java

@@ -0,0 +1,40 @@
+package thyyxxk.webserver.entity.highreport;
+
+import lombok.Data;
+
+/**
+ * @ClassName DeptReportResult
+ * @Author hsh
+ * @Date 2025/4/10 0010 16:50
+ * @Version 1.0
+ * @Description 科室经营分析月报结果dto
+ **/
+@Data
+public class DeptReportResult {
+
+    // 指标类型所属名称
+    private String name;
+    // 指标类型所属编码
+    private String code;
+    // 指标id
+    private String reportId;
+    // 指标名称
+    private String reportName;
+    // 指标类型
+    private String reportType;
+    // 年月(本月)
+    private String yf;
+    // 本月
+    private String baseMonth;
+    // 去年同期
+    private String fastMonth;
+    // 上月
+    private String lastMonth;
+    // 同比:(本月-去年同期)/去年同期*100%
+    private String tb;
+    // 环比:(本月-上月)/上月*100%
+    private String hb;
+    // 计算时间
+    private String createTime;
+
+}

+ 5 - 0
src/main/java/thyyxxk/webserver/entity/highreport/HighReportDto.java

@@ -2,6 +2,7 @@ package thyyxxk.webserver.entity.highreport;
 
 import lombok.Data;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -69,4 +70,8 @@ public class HighReportDto {
      **/
     private Map<String, Object> total;
 
+    // 表示zd_report_type中flag的值(1: 是科室经营分析月报表的指标;Y: 是运营监测的指标)
+    private String ybbFlag;
+    // 科室经营分析月报表的报表类型集合
+    private List<String> reportTypeList;
 }

+ 192 - 0
src/main/java/thyyxxk/webserver/service/highreport/DeptBusinessService.java

@@ -0,0 +1,192 @@
+package thyyxxk.webserver.service.highreport;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.dao.his.highreport.DeptBusinessDao;
+import thyyxxk.webserver.dao.his.medicalinsurance.costcontrol.YbUtilDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.highreport.DeptReportResult;
+import thyyxxk.webserver.entity.highreport.HighReportDto;
+import thyyxxk.webserver.entity.highreport.ReportBaseInfo;
+import thyyxxk.webserver.entity.login.UserInfo;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.utils.ReportUtil;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.TokenUtil;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @ClassName DeptBusinessService
+ * @Author hsh
+ * @Date 2025/4/2 15:41
+ * @Version 1.0
+ * @Description 科室经营报表
+ **/
+@Service
+@Slf4j
+public class DeptBusinessService {
+
+    private final DeptBusinessDao dao;
+
+    private final RedisLikeService redis;
+
+    private final YbUtilDao ybDao;
+
+    @Autowired
+    public DeptBusinessService(DeptBusinessDao dao, RedisLikeService redis, YbUtilDao ybDao) {
+        this.dao = dao;
+        this.redis = redis;
+        this.ybDao = ybDao;
+    }
+
+    /**
+     * @Description 查询报表范围以及权限
+     * @Author hsh
+     * @param flag 报表类型分类(1: 科室经营分析月报表)
+     * @return map
+     * @Date 2025/4/16 0016 12:53
+     */
+    public ResultVo<Map<String, Object>> selectReportTypeList(String flag){
+        Map<String, Object> map = new HashMap<>();
+        // 获取指标类型
+        List<Map<String, Object>> reportTypeList = dao.selectReportTypeList(flag);
+        // 获取需要计算的指标
+        List<ReportBaseInfo> reportList = dao.selectReportList(flag);
+        UserInfo user = redis.getUserInfoByCode(TokenUtil.getInstance().getTokenUserId());
+        String s = ybDao.selectDeptYbbQxByRole("ybbQx");
+        boolean index = true;
+        if(null != s){
+            List<Integer> roles = user.getRoles();
+            for(Integer role : roles){
+                String[] st = s.split(",");
+                for(String qx : st){
+                    String bs = String.valueOf(role);
+                    if(qx.equals(bs)){
+                        index = false;
+                        break;
+                    }
+                }
+                if(!index){
+                    break;
+                }
+            }
+        }
+        if(index){
+            // 有科室权限控制,只能查询一个科室的数据
+            map.put("qx", 0);
+        } else {
+            // 不限制科室,可以查询全院数据
+            map.put("qx", 1);
+        }
+        map.put("reportTypeList", reportTypeList);
+        map.put("reportList", reportList);
+        return ResultVoUtil.success(map);
+    }
+
+    /**
+     * @param dto 查询条件
+     * @return list 科室分析报表数据
+     * @Description 根据科室分析报表类型查询报表数据
+     * @Author hsh
+     * @Date 2025/4/11 0011 16:00
+     */
+    private List<DeptReportResult> callReportResultData(Map<String, Object> m, HighReportDto dto, List<ReportBaseInfo> rl) {
+        List<DeptReportResult> list = new ArrayList<>();
+        String name = (String) m.get("reportLabel");
+        String code = (String) m.get("reportCode");
+        for(ReportBaseInfo report : rl){
+            String sql = ReportUtil.callSqlFormat(dto, report.getBaseSql(), report.getGatherSql(), null, null, null);
+            List<DeptReportResult> dl = dao.selectDeptBusinessReportData(sql);
+            if(null == dl || dl.isEmpty()){
+                continue;
+            }
+            boolean r_f = false;
+            for(DeptReportResult result : dl){
+                if(null == result) {
+                    continue;
+                }
+                if(!r_f){
+                    r_f = true;
+                }
+                result.setName(name);
+                result.setCode(code);
+                result.setReportId(report.getReportId());
+                result.setReportName(report.getReportName());
+                result.setReportType(report.getReportType());
+            }
+            if(r_f){
+                list.addAll(dl);
+            }
+        }
+        return list;
+    }
+
+    public ResultVo<Map<String, Object>> selectDeptReportList(HighReportDto dto){
+        Map<String, Object> map = new HashMap<>();
+        String flag = dto.getYbbFlag();
+        List<String> codeList = dto.getReportTypeList();
+        // 获取指标类型
+        List<Map<String, Object>> reportTypeList;
+        StringBuilder codes = new StringBuilder("'");
+        if(null == codeList || codeList.isEmpty()){
+            reportTypeList = dao.selectReportTypeList(flag);
+        } else {
+            if(codeList.size() == 1){
+                codes.append(codeList.get(0)).append("'");
+            } else {
+                for(int i = 0; i < codeList.size(); i++ ){
+                    if(i == codeList.size() - 1){
+                        codes.append(codeList.get(i)).append("'");
+                    } else {
+                        codes.append(codeList.get(i)).append("','");
+                    }
+                }
+            }
+            // 获取指标类型
+            reportTypeList = dao.selectReportTypeListByCodes(flag, codes.toString());
+        }
+        // 获取需要计算的指标
+        List<ReportBaseInfo> reportList;
+        if(null == codeList || codeList.isEmpty()){
+            reportList = dao.selectReportList(flag);
+        } else {
+            reportList = dao.selectReportListByCodes(flag, codes.toString());
+        }
+        // 按照指标类型分组
+        Map<String, List<ReportBaseInfo>> m1 = reportList.stream().collect(Collectors.groupingBy(ReportBaseInfo::getReportType));
+        List<DeptReportResult> deptLeft = new ArrayList<>();
+        List<DeptReportResult> deptRight = new ArrayList<>();
+//        UserInfo user = redis.getUserInfoByCode(TokenUtil.getInstance().getTokenUserId());
+//        dto.setDept(user.getDeptCode());
+        for(Map<String, Object> m : reportTypeList){
+            String reportType = (String) m.get("reportType");
+            String layoutFlag = (String) m.get("layoutFlag");
+            List<ReportBaseInfo> rl = m1.get(reportType);
+            if(null == rl || rl.isEmpty()){
+                continue;
+            }
+            m.put("reportCount", rl.size());
+            m.put("layoutFlag", layoutFlag);
+            List<DeptReportResult> s = callReportResultData(m, dto, rl);
+            if(!s.isEmpty()){
+                if("0".equals(layoutFlag)){
+                    deptLeft.addAll(s);
+                } else {
+                    deptRight.addAll(s);
+                }
+            }
+        }
+        map.put("reportTypeList", reportTypeList);
+        map.put("reportList", reportList);
+        map.put("deptLeft", deptLeft);
+        map.put("deptRight", deptRight);
+        return ResultVoUtil.success(map);
+    }
+
+}

+ 43 - 1
src/main/java/thyyxxk/webserver/service/medicalinsurance/costcontrol/YbUtilService.java

@@ -4,8 +4,12 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import thyyxxk.webserver.dao.his.medicalinsurance.costcontrol.YbUtilDao;
 import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.login.UserInfo;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
 import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.TokenUtil;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -20,9 +24,12 @@ public class YbUtilService {
 
     private final YbUtilDao dao;
 
+    private final RedisLikeService redis;
+
     @Autowired
-    public YbUtilService(YbUtilDao dao) {
+    public YbUtilService(YbUtilDao dao, RedisLikeService redis) {
         this.dao = dao;
+        this.redis = redis;
     }
 
     public ResultVo<List<Map<String, Object>>> selectSmallDept(Map<String, String> map) {
@@ -76,4 +83,39 @@ public class YbUtilService {
         return ResultVoUtil.success(list);
     }
 
+    public ResultVo<List<Map<String, Object>>> selectQxSmallDept(Map<String, String> map) {
+        String str = map.get("str");
+        String code = map.get("code");
+        List<Map<String, Object>> list;
+        List<String> deptQx = new ArrayList<>();
+        UserInfo user = redis.getUserInfoByCode(TokenUtil.getInstance().getTokenUserId());
+        String s = dao.selectDeptYbbQxByRole(code);
+        List<Integer> roles = user.getRoles();
+        boolean index = true;
+        for(Integer role : roles){
+            String[] st = s.split(",");
+            for(String qx : st){
+                String bs = String.valueOf(role);
+                if(qx.equals(bs)){
+                    index = false;
+                    break;
+                }
+            }
+            if(!index){
+                break;
+            }
+        }
+        if(index){
+            // 需要增加科室权限限制
+            deptQx.add(user.getDeptCode());
+            if(null != user.getPartTimeDept() && !user.getPartTimeDept().isEmpty()){
+                deptQx.addAll(user.getPartTimeDept());
+            }
+            list = dao.selectSmallDeptByCode(deptQx);
+        } else {
+            list = dao.selectSmallDept(str);
+        }
+        return ResultVoUtil.success(list);
+    }
+
 }