Browse Source

添加人数树状图

hsh 3 years ago
parent
commit
617d81585b

+ 6 - 0
src/main/java/thyyxxk/webserver/controller/ybkf/YbStatController.java

@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
+import thyyxxk.webserver.entity.ybkf.TreeNodesResult;
 import thyyxxk.webserver.entity.ybkf.YbStatDto;
 import thyyxxk.webserver.entity.ybkf.YbStatResult;
 import thyyxxk.webserver.service.ybkf.YbStatService;
@@ -64,4 +65,9 @@ public class YbStatController {
         return service.selectBarChangeData(dto);
     }
 
+    @PostMapping("/selectTreeData")
+    public ResultVo<TreeNodesResult> selectTreeData(@RequestBody @Validated YbStatDto dto){
+        return service.selectTreeData(dto);
+    }
+
 }

+ 73 - 0
src/main/java/thyyxxk/webserver/dao/his/ybkf/YbStatDao.java

@@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
+import thyyxxk.webserver.entity.ybkf.TreeNodesResult;
 import thyyxxk.webserver.entity.ybkf.YbStatResult;
 
 import java.util.List;
@@ -25,6 +26,7 @@ public interface YbStatDao {
             "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.setl_id) as decimal(10,2)),2) as decimal(10,2)), " +
             "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(10,2)), " +
             "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(10,2)), " +
+            "acctPay=cast(round(sum(a.acct_pay),2) as decimal(10,2)), " +
             "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(10,2)), " +
             "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(10,2)), " +
             "otherFunds=cast(round(sum(isnull(a.fund_pay_sumamt,0)-isnull(a.hifp_pay,0)-isnull(a.cvlserv_pay,0)-isnull(a.hifmi_pay,0)),2) as decimal(10,2)), " +
@@ -64,6 +66,7 @@ public interface YbStatDao {
             "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
             "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.setl_id) as decimal(10,2)),2) as decimal(10,2)), " +
             "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(10,2)), " +
+            "acctPay=cast(round(sum(a.acct_pay),2) as decimal(10,2)), " +
             "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(10,2)), " +
             "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(10,2)), " +
             "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(10,2)), " +
@@ -85,6 +88,7 @@ public interface YbStatDao {
             "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
             "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.setl_id) as decimal(10,2)),2) as decimal(10,2)), " +
             "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(10,2)), " +
+            "acctPay=cast(round(sum(a.acct_pay),2) as decimal(10,2)), " +
             "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(10,2)), " +
             "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(10,2)), " +
             "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(10,2)), " +
@@ -106,6 +110,7 @@ public interface YbStatDao {
             "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
             "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.setl_id) as decimal(10,2)),2) as decimal(10,2)), " +
             "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(10,2)), " +
+            "acctPay=cast(round(sum(a.acct_pay),2) as decimal(10,2)), " +
             "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(10,2)), " +
             "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(10,2)), " +
             "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(10,2)), " +
@@ -222,4 +227,72 @@ public interface YbStatDao {
             "</script>")
     List<Map<String, Object>> selectBarChangeData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
 
+    @Select("select count(a.setl_id) value, 0 id, '医保病人数' name " +
+            "from t_si_setlinfo a " +
+            "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time>=#{beginTime} and a.setl_time<=#{endTime} ")
+    TreeNodesResult getTreeRootResult(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
+
+    @Select("<script> " +
+            "select count(t.setl_id) value, 0 pid, rtrim(t.id) as id, rtrim(isnull(d.name, '其他')) name from " +
+            "(select a.setl_id, isnull(zy.small_dept, zya.small_dept) id " +
+            "from t_si_setlinfo a " +
+            "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
+            "left join zy_actpatient zya on (zya.inpatient_no = a.pat_no and zya.admiss_times = a.times) " +
+            "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
+            " ) t " +
+            "left join zy_dept_code d on d.code = t.id " +
+            "group by t.id, d.name " +
+            "order by count(t.setl_id) desc " +
+            "</script>")
+    List<TreeNodesResult> selectTreeSecondData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType, @Param("insurType") String insurType);
+
+    @Select("<script> " +
+            "select count(t.setl_id) as value, rtrim(t.pid) as pid, rtrim(t.id) as id, rtrim(isnull(e.name, '其他')) as name from " +
+            "(select a.setl_id, isnull(zy.small_dept, zya.small_dept) pid, isnull(isnull(zy.refer_physician, zya.refer_physician), 9999) id " +
+            "from t_si_setlinfo a " +
+            "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
+            "left join zy_actpatient zya on (zya.inpatient_no = a.pat_no and zya.admiss_times = a.times) " +
+            "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
+            " ) t " +
+            "left join a_employee_mi e on e.code = t.id " +
+            "group by t.pid, t.id, e.name " +
+            "order by count(t.setl_id) desc " +
+            "</script>")
+    List<TreeNodesResult> selectTreeThirdData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType, @Param("insurType") String insurType);
+
+    @Select("<script> " +
+            "select count(t.setl_id) as value, rtrim(t.uid) as uid, rtrim(t.pid) as pid, rtrim(isnull(t.medins_type, '其他')) as name  from " +
+            "(select a.setl_id, a.medins_type, isnull(isnull(zy.refer_physician, zya.refer_physician), 9999) pid, " +
+            "isnull(isnull(zy.small_dept, zya.small_dept), 999) uid " +
+            "from t_si_setlinfo a " +
+            "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
+            "left join zy_actpatient zya on (zya.inpatient_no = a.pat_no and zya.admiss_times = a.times) " +
+            "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
+            " ) t " +
+            "group by t.uid, t.pid, t.medins_type " +
+            "order by count(t.setl_id) desc " +
+            "</script>")
+    List<TreeNodesResult> selectTreeFourthData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType, @Param("insurType") String insurType);
+
+    @Select("<script> " +
+            "select count(t.setl_id) as value, rtrim(t.pid) as pid, rtrim(t.id) as id, rtrim(isnull(t.medins_type, '其他')) as insurName, rtrim(isnull(e.name, '其他')) as doctorName, rtrim(d.name) as deptName  from " +
+            "(select a.setl_id, a.medins_type, isnull(zy.small_dept, zya.small_dept) pid, isnull(isnull(zy.refer_physician, zya.refer_physician), 9999) id " +
+            "from t_si_setlinfo a " +
+            "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
+            "left join zy_actpatient zya on (zya.inpatient_no = a.pat_no and zya.admiss_times = a.times) " +
+            "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
+            "<if test=\"deptCode != null and deptCode != '' \">" +
+            " and (zy.small_dept=#{deptCode} or zya.small_dept=#{deptCode})  " +
+            "</if> " +
+            "<if test=\"doctorId != null and doctorId != '' \">" +
+            " and (zy.refer_physician=#{doctorId} or zya.refer_physician=#{doctorId}) " +
+            "</if> ) t " +
+            "left join zy_dept_code d on d.code = t.pid " +
+            "left join a_employee_mi e on e.code = t.id " +
+            "group by t.pid, t.id, t.medins_type, d.name, e.name " +
+            "order by count(t.setl_id) desc " +
+            "</script>")
+    List<TreeNodesResult> selectTreeAllData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType,
+                                              @Param("deptCode") String deptCode, @Param("doctorId") String doctorId, @Param("insurType") String insurType);
+
 }

+ 26 - 0
src/main/java/thyyxxk/webserver/entity/ybkf/TreeNodesResult.java

@@ -0,0 +1,26 @@
+package thyyxxk.webserver.entity.ybkf;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @ClassName TreeNodesResult
+ * @Description 树
+ * @Author hsh
+ * @Date 2022/7/27 16:16
+ **/
+@Data
+public class TreeNodesResult {
+
+    private String id;
+    private String pid;
+    private String uid;
+    private String name;
+    private Integer value;
+    //控制节点打开与关闭: false为节点展开,true为节点关闭,默认为false展开
+    private boolean collapsed;
+    //子节点集合
+    private List<TreeNodesResult> children;
+
+}

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/ybkf/YbStatDto.java

@@ -22,5 +22,7 @@ public class YbStatDto {
     private String setlType;
     private String selectType;
     private String exportName;
+    private String dept;
+    private String doctor;
 
 }

+ 1 - 0
src/main/java/thyyxxk/webserver/entity/ybkf/YbStatResult.java

@@ -27,5 +27,6 @@ public class YbStatResult {
     private String otherFunds;
     private String allFunds;
     private String yf;
+    private String acctPay;
 
 }

+ 65 - 0
src/main/java/thyyxxk/webserver/service/ybkf/YbStatService.java

@@ -8,6 +8,7 @@ import thyyxxk.webserver.dao.his.ybkf.YbStatDao;
 import thyyxxk.webserver.entity.HeadInfo;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
+import thyyxxk.webserver.entity.ybkf.TreeNodesResult;
 import thyyxxk.webserver.entity.ybkf.YbStatDto;
 import thyyxxk.webserver.entity.ybkf.YbStatResult;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
@@ -16,6 +17,7 @@ import thyyxxk.webserver.utils.DecimalUtil;
 import thyyxxk.webserver.utils.ExcelUtil;
 import thyyxxk.webserver.utils.FilterUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.StringUtil;
 
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
@@ -1376,4 +1378,67 @@ public class YbStatService {
         return ResultVoUtil.success(result);
     }
 
+
+
+    public ResultVo<TreeNodesResult> selectTreeData(YbStatDto dto){
+        String beginTime = dto.getStartTime();
+        String endTime = DateUtil.getMonthEndtime(dto.getEndTime());
+        String setlType = dto.getSetlType();
+        String dept = dto.getDept();
+        String doctor = dto.getDoctor();
+        String insurType = dto.getInsurType();
+
+        // 存放根节点数据集合
+        TreeNodesResult root = dao.getTreeRootResult(beginTime,endTime,setlType);
+        // 根节点默认打开
+        root.setCollapsed(false);
+        // 查询第一子节点数据
+        List<TreeNodesResult> secondTreeList = dao.selectTreeSecondData(beginTime,endTime,setlType,insurType);
+        // 查询第二子节点数据
+        List<TreeNodesResult> thirdTreeList = dao.selectTreeThirdData(beginTime,endTime,setlType,insurType);
+        // 查询第三子节点数据
+        List<TreeNodesResult> fourthTreeList = dao.selectTreeFourthData(beginTime,endTime,setlType,insurType);
+
+        for (Integer i = 0; i < secondTreeList.size(); i++) {
+            if(StringUtil.notBlank(dept)){
+                if(secondTreeList.get(i).getName().contains(dept)){
+                    secondTreeList.get(i).setCollapsed(false);
+                } else {
+                    secondTreeList.get(i).setCollapsed(true);
+                }
+            } else {
+                // 子节点默认关闭
+                secondTreeList.get(i).setCollapsed(true);
+            }
+        }
+
+        for (Integer i = 0; i < thirdTreeList.size(); i++) {
+            if(StringUtil.notBlank(doctor)){
+                if(thirdTreeList.get(i).getName().contains(doctor)){
+                    thirdTreeList.get(i).setCollapsed(false);
+                } else {
+                    thirdTreeList.get(i).setCollapsed(true);
+                }
+            } else {
+                // 子节点默认关闭
+                thirdTreeList.get(i).setCollapsed(true);
+            }
+        }
+
+        Map<String, List<TreeNodesResult>> m11 = fourthTreeList.stream().collect(Collectors.groupingBy(item ->item.getPid()+"_"+item.getUid()));
+        for (TreeNodesResult result : thirdTreeList) {
+            String id = result.getId();
+            String pid = result.getPid();
+            List<TreeNodesResult> l1 = m11.get(id+"_"+pid);
+            result.setChildren(l1);
+        }
+        Map<String, List<TreeNodesResult>> m2 = thirdTreeList.stream().collect(Collectors.groupingBy(item ->item.getPid()));
+        for(TreeNodesResult result : secondTreeList){
+            String id = result.getId();
+            List<TreeNodesResult> l1 =  m2.get(id);
+            result.setChildren(l1);
+        }
+        root.setChildren(secondTreeList);
+        return ResultVoUtil.success(root);
+    }
 }