Bladeren bron

新增长浏宁次均

hsh 2 jaren geleden
bovenliggende
commit
c1c40b9909

+ 52 - 0
src/main/java/thyyxxk/webserver/controller/ybkf/YbClnTimesAvgController.java

@@ -0,0 +1,52 @@
+package thyyxxk.webserver.controller.ybkf;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+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.RestController;
+import thyyxxk.webserver.config.auth.PassToken;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.ybkf.YbkfShareDto;
+import thyyxxk.webserver.service.ybkf.YbClnTimesAvgService;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 长浏宁次均控费
+ * @Author: hsh
+ * @CreateTime: 2022-10-26  10:44
+ * @Version: 1.0
+ */
+@RestController
+@RequestMapping("/clnTimesAvg")
+public class YbClnTimesAvgController {
+
+    private final YbClnTimesAvgService service;
+
+    @Autowired
+    public YbClnTimesAvgController(YbClnTimesAvgService service) {
+        this.service = service;
+    }
+
+    @PassToken
+    @PostMapping("/selectClnTimesAvg")
+    public ResultVo<Map<String, Object>> selectClnTimesAvg(@RequestBody @Validated YbkfShareDto dto){
+        return service.selectClnTimesAvg(dto);
+    }
+
+    @PassToken
+    @PostMapping("/selectClnAvgFeeDoctor")
+    public ResultVo<List<Map<String, Object>>> selectClnAvgFeeDoctor(@RequestBody @Validated YbkfShareDto dto){
+        return service.selectClnAvgFeeDoctor(dto);
+    }
+
+    @PassToken
+    @PostMapping("/selectClnAvgFeePatient")
+    public ResultVo<List<Map<String, Object>>> selectClnAvgFeePatient(@RequestBody @Validated YbkfShareDto dto){
+        return service.selectClnAvgFeePatient(dto);
+    }
+
+}

+ 1 - 1
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiManageDao.java

@@ -246,7 +246,7 @@ public interface SiManageDao {
             " tentative_diagnosis as tentativeDiagnosis, " +
             " rtrim(isnull(e.name, '其他')) as doctorName, rtrim(isnull(z.name, '其他')) as deptName " +
             " from mz_bl_record " +
-            " left join zy_dept_code z on dept_code = z.code" +
+            " left join zd_unit_code z on dept_code = z.code" +
             " left join a_employee_mi e on doctor_code = e.code " +
             " where patient_id = #{patNo} and times = #{times} ")
     Map<String, Object> selectMzBl(@Param("patNo") String patNo, @Param("times") int times);

+ 69 - 0
src/main/java/thyyxxk/webserver/dao/his/ybkf/YbClnTimesAvgDao.java

@@ -0,0 +1,69 @@
+package thyyxxk.webserver.dao.his.ybkf;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import thyyxxk.webserver.entity.ybkf.YbClnAvgParam;
+import thyyxxk.webserver.entity.ybkf.YbSetlInfo;
+
+import java.util.List;
+
+/**
+ * @description: 长浏宁次均控费
+ * @author: hsh
+ * @date: 2022/10/26 15:02
+ * @param:
+ * @return: null
+ **/
+@Mapper
+public interface YbClnTimesAvgDao {
+
+    @Select(" select top 1 * from yb_cln_avg_param where year = #{year} and insur_name = #{insurName} ")
+    YbClnAvgParam selectClnAvgParam(@Param("year") String year, @Param("insurName") String insurName);
+
+    @Select("<script> " +
+            " select t.*, datediff(day, isnull(zy.admiss_date, zya.admiss_date), isnull(zy.dis_date, zya.dis_date)) inDays, " +
+            " rtrim(isnull(zy.small_dept, zya.small_dept)) as deptId, rtrim(isnull(z.name, d.name)) as deptName," +
+            " rtrim(isnull(zy.refer_physician, zya.refer_physician)) as doctorId, rtrim(isnull(e.name, f.name)) as doctor " +
+            " from t_si_setlinfo t " +
+            " left join zy_inactpatient zy on (zy.inpatient_no = t.pat_no and zy.admiss_times = t.times) " +
+            " left join zy_actpatient zya on (zya.inpatient_no = t.pat_no and zya.admiss_times = t.times) " +
+            " left join zd_unit_code z on zy.small_dept = z.code " +
+            " left join zd_unit_code d on zya.small_dept = d.code " +
+            " left join a_employee_mi e on zy.refer_physician = e.code " +
+            " left join a_employee_mi f on zya.refer_physician = f.code " +
+            " where t.revoked = '0' and t.setl_type = '21' " +
+            " and t.setl_time &gt;= #{beginTime} " +
+            " and t.setl_time &lt;= #{endTime} " +
+            " and t.medins_type = #{insurName} " +
+            " <if test=\"dept != null and dept != '' \"> " +
+            " and rtrim(isnull(z.name, d.name)) = #{dept} " +
+            " </if> " +
+            " </script> ")
+    List<YbSetlInfo> selectClnSetlData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("insurName") String insurName, @Param("dept") String dept);
+
+    @Select("<script> " +
+            " select t.*, datediff(day, isnull(zy.admiss_date, zya.admiss_date), isnull(zy.dis_date, zya.dis_date)) inDays, " +
+            " rtrim(isnull(zy.small_dept, zya.small_dept)) as deptId, rtrim(isnull(z.name, d.name)) as deptName," +
+            " rtrim(isnull(zy.refer_physician, zya.refer_physician)) as doctorId, rtrim(isnull(e.name, f.name)) as doctor, " +
+            " zd.dis_diag_comment as mainDiagnosis, ss.ssmc as mainOperation " +
+            " from t_si_setlinfo t " +
+            " left join zy_inactpatient zy on (zy.inpatient_no = t.pat_no and zy.admiss_times = t.times) " +
+            " left join zy_actpatient zya on (zya.inpatient_no = t.pat_no and zya.admiss_times = t.times) " +
+            " left join zd_unit_code z on zy.small_dept = z.code " +
+            " left join zd_unit_code d on zya.small_dept = d.code " +
+            " left join a_employee_mi e on zy.refer_physician = e.code " +
+            " left join a_employee_mi f on zya.refer_physician = f.code " +
+            " left join zy_dis_diag_yb zd on (zd.inpatient_no = t.pat_no and zd.admiss_times = t.times and zd.dis_diag_no = '1') " +
+            " left join batj_ba4 ss on (ss.bah = t.pat_no and ss.zycs = t.times and ss.ssxh = '1') " +
+            " where t.revoked = '0' and t.setl_type = '21' " +
+            " and t.setl_time &gt;= #{beginTime} " +
+            " and t.setl_time &lt;= #{endTime} " +
+            " and t.medins_type = #{insurName} " +
+            " and rtrim(isnull(z.name, d.name)) = #{dept} " +
+            " and rtrim(isnull(e.name, f.name)) = #{doctor} " +
+            " </script> ")
+    List<YbSetlInfo> selectClnAvgFeePatient(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("insurName") String insurName,
+                                       @Param("dept") String dept, @Param("doctor") String doctor);
+
+}

+ 4 - 4
src/main/java/thyyxxk/webserver/dao/his/ybkf/YbCssTjDao.java

@@ -278,7 +278,7 @@ public interface YbCssTjDao {
             " (select sum(a.charge_fee) as charge_fee, a.ward_code, a.refer_physician, rtrim(a.inpatient_no) as inpatient_no, a.admiss_times, a.ledger_sn, " +
             " rtrim(z.name) as execUnitName, rtrim(e.name) as consultPhysician " +
             " from zy_detail_charge a " +
-            " left join zy_dept_code z on a.ward_code = z.code " +
+            " left join zd_unit_code z on a.ward_code = z.code " +
             " left join a_employee_mi e on a.refer_physician = e.code " +
             " where a.inpatient_no = #{item.patNo} and a.admiss_times = #{item.times} " +
             " group by a.ward_code, a.refer_physician, z.name, e.name, a.inpatient_no, a.admiss_times, a.ledger_sn) t " +
@@ -349,7 +349,7 @@ public interface YbCssTjDao {
             " rtrim(a.refer_physician) as doctorId, rtrim(e.name) as doctor " +
             " from t_si_setlinfo t " +
             " left join zy_inactpatient a on t.pat_no = a.inpatient_no and t.times = a.admiss_times " +
-            " left join zy_dept_code z on a.zk_ward = z.code " +
+            " left join zd_unit_code z on a.zk_ward = z.code " +
             " left join a_employee_mi e on a.refer_physician = e.code " +
             " where t.revoked = '0' and t.setl_id in " +
             " <foreach collection='list' item='item' open='(' close=')' separator=','> " +
@@ -417,8 +417,8 @@ public interface YbCssTjDao {
             " round(t.fund_pay_sumamt/t.medfee_sumamt * 100, 2) bxbl, " +
             " zy.operation as zlfs, zy.dec_type as sblx " +
             " from t_si_setlinfo t, zy_inactpatient zy " +
-            " left join zy_dept_code a on zy.small_dept = a.code " +
-            " left join zy_dept_code b on zy.zk_ward = b.code " +
+            " left join zd_unit_code a on zy.small_dept = a.code " +
+            " left join zd_unit_code b on zy.zk_ward = b.code " +
             " left join a_employee_mi e on e.code = zy.refer_physician " +
             " where t.revoked = '0' and t.setl_type = '21' " +
             " and t.pat_no = zy.inpatient_no " +

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

@@ -156,7 +156,7 @@ public interface YbStatDao {
             "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
             "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_dept_code z on zy.small_dept = z.code " +
+            "left join zd_unit_code z on zy.small_dept = z.code " +
             "left join zy_dis_diag_yb zd1 on (zd1.inpatient_no = a.pat_no and zd1.admiss_times = a.times and zd1.dis_diag_no = '1') " +
             "left join zy_dis_diag_yb_modify zd2 on (zd2.inpatient_no = a.pat_no and zd2.admiss_times = a.times and zd2.dis_diag_no = '1') " +
             "left join batj_ba4 ss1 on (ss1.zyh = a.pat_no and ss1.zycs = a.times and ss1.ssxh = '1') " +
@@ -190,7 +190,7 @@ public interface YbStatDao {
             "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
             "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_dept_code z on zy.small_dept = z.code " +
+            "left join zd_unit_code z on zy.small_dept = z.code " +
             "left join zy_dis_diag_yb zd1 on (zd1.inpatient_no = a.pat_no and zd1.admiss_times = a.times and zd1.dis_diag_no = '1') " +
             "left join zy_dis_diag_yb_modify zd2 on (zd2.inpatient_no = a.pat_no and zd2.admiss_times = a.times and zd2.dis_diag_no = '1') " +
             "left join batj_ba4 ss1 on (ss1.zyh = a.pat_no and ss1.zycs = a.times and ss1.ssxh = '1') " +
@@ -206,7 +206,7 @@ public interface YbStatDao {
             "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
             "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_dept_code z on zy.small_dept = z.code " +
+            "left join zd_unit_code z on zy.small_dept = z.code " +
             "left join zy_dis_diag_yb zd1 on (zd1.inpatient_no = a.pat_no and zd1.admiss_times = a.times and zd1.dis_diag_no = '1') " +
             "left join zy_dis_diag_yb_modify zd2 on (zd2.inpatient_no = a.pat_no and zd2.admiss_times = a.times and zd2.dis_diag_no = '1') " +
             "left join batj_ba4 ss1 on (ss1.zyh = a.pat_no and ss1.zycs = a.times and ss1.ssxh = '1') " +
@@ -222,7 +222,7 @@ public interface YbStatDao {
             "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
             "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_dept_code z on zy.small_dept = z.code " +
+            "left join zd_unit_code z on zy.small_dept = z.code " +
             "left join zy_dis_diag_yb zd1 on (zd1.inpatient_no = a.pat_no and zd1.admiss_times = a.times and zd1.dis_diag_no = '1') " +
             "left join zy_dis_diag_yb_modify zd2 on (zd2.inpatient_no = a.pat_no and zd2.admiss_times = a.times and zd2.dis_diag_no = '1') " +
             "left join batj_ba4 ss1 on (ss1.zyh = a.pat_no and ss1.zycs = a.times and ss1.ssxh = '1') " +
@@ -264,7 +264,7 @@ public interface YbStatDao {
             "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 " +
+            "left join zd_unit_code d on d.code = t.id " +
             "group by t.id, d.name " +
             "order by count(t.setl_id) desc " +
             "</script>")
@@ -309,7 +309,7 @@ public interface YbStatDao {
             " and a.medins_type=#{insurType}  " +
             "</if> " +
             ") t " +
-            "left join zy_dept_code d on d.code = t.pid " +
+            "left join zd_unit_code d on d.code = t.pid " +
             "left join a_employee_mi e on e.code = t.id " +
             "where 1=1 " +
             "<if test=\"dept != null and dept != '' \"> " +

+ 25 - 0
src/main/java/thyyxxk/webserver/entity/ybkf/YbClnAvgParam.java

@@ -0,0 +1,25 @@
+package thyyxxk.webserver.entity.ybkf;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @Description: 长浏宁次均费用标准参数
+ * @Author: hsh
+ * @CreateTime: 2022-10-26  11:31
+ * @Version: 1.0
+ */
+@Data
+@TableName(value = "yb_cln_avg_param")
+public class YbClnAvgParam {
+
+    private String year;
+    private String insurType;
+    private String insurName;
+    private BigDecimal avgStandard;
+    private BigDecimal rates;
+    private String remark;
+
+}

+ 4 - 0
src/main/java/thyyxxk/webserver/entity/ybkf/YbSetlInfo.java

@@ -30,5 +30,9 @@ public class YbSetlInfo extends SiSetlinfo {
      * 医生
      **/
     private String doctor;
+    /**
+     * 住院天数
+     **/
+    private Integer inDays;
 
 }

+ 305 - 0
src/main/java/thyyxxk/webserver/service/ybkf/YbClnTimesAvgService.java

@@ -0,0 +1,305 @@
+package thyyxxk.webserver.service.ybkf;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.dao.his.ybkf.YbClnTimesAvgDao;
+import thyyxxk.webserver.dao.his.ybkf.YbUtilDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
+import thyyxxk.webserver.entity.ybkf.YbClnAvgParam;
+import thyyxxk.webserver.entity.ybkf.YbSetlInfo;
+import thyyxxk.webserver.entity.ybkf.YbkfShareDto;
+import thyyxxk.webserver.utils.DecimalUtil;
+import thyyxxk.webserver.utils.ResultVoUtil;
+
+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: 长浏宁次均控费
+ * @Author: hsh
+ * @CreateTime: 2022-10-26  10:47
+ * @Version: 1.0
+ */
+@Service
+public class YbClnTimesAvgService {
+
+    private final YbClnTimesAvgDao dao;
+
+    private final YbUtilDao utilDao;
+
+    @Autowired
+    public YbClnTimesAvgService(YbClnTimesAvgDao dao, YbUtilDao utilDao) {
+        this.dao = dao;
+        this.utilDao = utilDao;
+    }
+
+    public ResultVo<Map<String, Object>> selectClnTimesAvg(YbkfShareDto dto) {
+        String beginTime = dto.getStartTime();
+        String endTime = dto.getEndTime();
+        String insurName = dto.getInsurName();
+        String dept = dto.getDept();
+        String year = beginTime.substring(0,4);
+
+        Map<String, Object> resultMap = new HashMap<>();
+        YbClnAvgParam clnAvgParam = callClnAvgParam(year, insurName);
+        if(null == clnAvgParam){
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+
+        List<YbSetlInfo> list = dao.selectClnSetlData(beginTime, endTime, insurName, dept);
+        Map<String, List<YbSetlInfo>> setlMap = list.stream().collect(
+                Collectors.groupingBy(YbSetlInfo::getDeptId, Collectors.toList()));
+
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        for(Map.Entry<String, List<YbSetlInfo>> entry : setlMap.entrySet()){
+
+            List<YbSetlInfo> infoList = entry.getValue();
+            if(infoList.size() == 0){
+                continue;
+            }
+            Map<String, Object> map = new HashMap<>();
+            int rs = 0;
+            int inDays = 0;
+            int dlRs = 0;
+            BigDecimal zfy = BigDecimal.ZERO;
+            BigDecimal ypf = BigDecimal.ZERO;
+            BigDecimal zf = BigDecimal.ZERO;
+            BigDecimal dlf = BigDecimal.ZERO;
+            BigDecimal bal = BigDecimal.ZERO;
+            map.put("deptId", entry.getKey());
+            map.put("deptName", infoList.get(0).getDeptName());
+            map.put("insurName", insurName);
+            for(YbSetlInfo info : infoList){
+                ++rs;
+                inDays += info.getInDays();
+                zfy = DecimalUtil.add(zfy, BigDecimal.valueOf(info.getMedfeeSumamt()));
+                ypf = DecimalUtil.add(ypf, DecimalUtil.add(DecimalUtil.add(info.getChargeWesternMedicine(), info.getChargePatentMedicine()), info.getChargeHerbal()));
+                zf = DecimalUtil.add(zf, BigDecimal.valueOf(info.getPsnPartAmt()));
+                // false表示列为单列:盈亏额为0,无需计算
+                boolean flag = true;
+                if(BigDecimal.valueOf(info.getMedfeeSumamt()).compareTo(
+                        (DecimalUtil.multiply(clnAvgParam.getAvgStandard(), clnAvgParam.getRates()))) >= 0){
+                    ++dlRs;
+                    dlf = DecimalUtil.add(dlf, BigDecimal.valueOf(info.getMedfeeSumamt()));
+                    flag = false;
+                }
+                // 长沙县城职/居普通住院病人做了介入手术且手术+化疗同时进行病人也纳入单列
+                if("长沙县城职普通住院".equals(insurName) || "长沙县城居普通住院".equals(insurName)){
+                    // 是否用了介入手术材料并且是否同时做了化疗
+                    if(isInterventionalProject(info.getPatNo(), info.getTimes(), info.getLedgerSn()) && isChemotherapy(info.getPatNo(), info.getTimes(), info.getLedgerSn())){
+                        flag = false;
+                    }
+                }
+                if(flag){
+                    bal = DecimalUtil.add(bal, DecimalUtil.minus(clnAvgParam.getAvgStandard(), BigDecimal.valueOf(info.getMedfeeSumamt())));
+                }
+            }
+            map.put("zfy", zfy);
+            map.put("rs", rs);
+            map.put("ypf", ypf);
+            map.put("zf", zf);
+            map.put("inDays", inDays);
+            map.put("dlRs", dlRs);
+            map.put("dlf", dlf);
+            map.put("bal", bal);
+            // 次均费用
+            map.put("cjfy", DecimalUtil.divide(zfy, BigDecimal.valueOf(Long.parseLong(String.valueOf(rs))), 2));
+            // 平均住院天数
+            map.put("avgDays", inDays/rs);
+            // 床日费用
+            map.put("crf", DecimalUtil.divide(zfy, BigDecimal.valueOf(Long.parseLong(String.valueOf(inDays))), 2));
+            // 药品比
+            map.put("ypbl", DecimalUtil.multiply(DecimalUtil.divide(ypf, zfy, 4), BigDecimal.valueOf(100)));
+            // 自付比
+            map.put("zfbl", DecimalUtil.multiply(DecimalUtil.divide(zf, zfy, 4), BigDecimal.valueOf(100)));
+            resultList.add(map);
+        }
+        resultMap.put("insurName", insurName);
+        resultMap.put("avgFee", clnAvgParam.getAvgStandard());
+        resultMap.put("avgRates", clnAvgParam.getRates());
+        resultMap.put("dlFee", DecimalUtil.multiply(clnAvgParam.getAvgStandard(), clnAvgParam.getRates()));
+        resultMap.put("returnData", resultList);
+        return ResultVoUtil.success(resultMap);
+    }
+
+    private boolean isChemotherapy(String patNo, Integer times, Integer ledgerSn) {
+        // 待定
+        System.out.println("------------------" + patNo + "||" + times + "||" + ledgerSn + "------------------");
+        return false;
+    }
+
+    private boolean isInterventionalProject(String patNo, Integer times, Integer ledgerSn) {
+        List<ZyDetailCharge> feeList = utilDao.selectInterventionalProject(patNo, times, ledgerSn, "0032%");
+        return feeList.size() != 0;
+    }
+
+    /**
+     * @description: 根据年份查询次均费用标准(今年查不到就差上一年的标准)
+     * @author: hsh
+     * @date: 2022/10/26 15:11
+     * @param: [year, insurName]
+     * @return: YbClnAvgParam
+     **/
+    private YbClnAvgParam callClnAvgParam(String year, String insurName) {
+        YbClnAvgParam clnAvgParam = dao.selectClnAvgParam(year, insurName);
+        if(null == clnAvgParam){
+            year = String.valueOf(Integer.parseInt(year) - 1);
+            clnAvgParam = dao.selectClnAvgParam(year, insurName);
+        }
+        return clnAvgParam;
+    }
+
+    public ResultVo<List<Map<String, Object>>> selectClnAvgFeeDoctor(YbkfShareDto dto) {
+        String beginTime = dto.getStartTime();
+        String endTime = dto.getEndTime();
+        String insurName = dto.getInsurName();
+        String year = beginTime.substring(0, 4);
+        String dept = dto.getDept();
+
+        YbClnAvgParam clnAvgParam = callClnAvgParam(year, insurName);
+        if(null == clnAvgParam){
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+
+        List<YbSetlInfo> list = dao.selectClnSetlData(beginTime, endTime, insurName, dept);
+        Map<String, List<YbSetlInfo>> setlMap = list.stream().collect(
+                Collectors.groupingBy(YbSetlInfo::getDoctorId, Collectors.toList()));
+
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        for(Map.Entry<String, List<YbSetlInfo>> entry : setlMap.entrySet()){
+
+            List<YbSetlInfo> infoList = entry.getValue();
+            if(infoList.size() == 0){
+                continue;
+            }
+            Map<String, Object> map = new HashMap<>();
+            int rs = 0;
+            int inDays = 0;
+            int dlRs = 0;
+            BigDecimal zfy = BigDecimal.ZERO;
+            BigDecimal ypf = BigDecimal.ZERO;
+            BigDecimal zf = BigDecimal.ZERO;
+            BigDecimal dlf = BigDecimal.ZERO;
+            BigDecimal bal = BigDecimal.ZERO;
+            map.put("deptId", infoList.get(0).getDeptId());
+            map.put("deptName", infoList.get(0).getDeptName());
+            map.put("doctorId", entry.getKey());
+            map.put("doctor", infoList.get(0).getDoctor());
+            map.put("insurName", insurName);
+            for(YbSetlInfo info : infoList){
+                ++rs;
+                inDays += info.getInDays();
+                zfy = DecimalUtil.add(zfy, BigDecimal.valueOf(info.getMedfeeSumamt()));
+                ypf = DecimalUtil.add(ypf, DecimalUtil.add(DecimalUtil.add(info.getChargeWesternMedicine(), info.getChargePatentMedicine()), info.getChargeHerbal()));
+                zf = DecimalUtil.add(zf, BigDecimal.valueOf(info.getPsnPartAmt()));
+                // 计算单列
+                boolean flag = true;
+                if(BigDecimal.valueOf(info.getMedfeeSumamt()).compareTo(
+                        (DecimalUtil.multiply(clnAvgParam.getAvgStandard(), clnAvgParam.getRates()))) >= 0){
+                    ++dlRs;
+                    dlf = DecimalUtil.add(dlf, BigDecimal.valueOf(info.getMedfeeSumamt()));
+                    flag = false;
+                }
+                // 长沙县城职/居普通住院病人做了介入手术且手术+化疗同时进行病人也纳入单列
+                if("长沙县城职普通住院".equals(insurName) || "长沙县城居普通住院".equals(insurName)){
+                    // 是否用了介入手术材料并且是否同时做了化疗
+                    if(isInterventionalProject(info.getPatNo(), info.getTimes(), info.getLedgerSn()) && isChemotherapy(info.getPatNo(), info.getTimes(), info.getLedgerSn())){
+                        flag = false;
+                    }
+                }
+                if(flag){
+                    bal = DecimalUtil.add(bal, DecimalUtil.minus(clnAvgParam.getAvgStandard(), BigDecimal.valueOf(info.getMedfeeSumamt())));
+                }
+            }
+            map.put("zfy", zfy);
+            map.put("rs", rs);
+            map.put("ypf", ypf);
+            map.put("zf", zf);
+            map.put("inDays", inDays);
+            map.put("dlRs", dlRs);
+            map.put("dlf", dlf);
+            map.put("bal", bal);
+            // 次均费用
+            map.put("cjfy", DecimalUtil.divide(zfy, BigDecimal.valueOf(Long.parseLong(String.valueOf(rs))), 2));
+            // 平均住院天数
+            map.put("avgDays", inDays/rs);
+            // 床日费用
+            map.put("crf", DecimalUtil.divide(zfy, BigDecimal.valueOf(Long.parseLong(String.valueOf(inDays))), 2));
+            // 药品比
+            map.put("ypbl", DecimalUtil.multiply(DecimalUtil.divide(ypf, zfy, 4), BigDecimal.valueOf(100)));
+            // 自付比
+            map.put("zfbl", DecimalUtil.multiply(DecimalUtil.divide(zf, zfy, 4), BigDecimal.valueOf(100)));
+            resultList.add(map);
+        }
+        return ResultVoUtil.success(resultList);
+    }
+
+    public ResultVo<List<Map<String, Object>>> selectClnAvgFeePatient(YbkfShareDto dto) {
+
+        String beginTime = dto.getStartTime();
+        String endTime = dto.getEndTime();
+        String insurName = dto.getInsurName();
+        String year = beginTime.substring(0, 4);
+        String dept = dto.getDept();
+        String doctor = dto.getDoctor();
+
+        YbClnAvgParam clnAvgParam = callClnAvgParam(year, insurName);
+        if (null == clnAvgParam) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+
+        List<YbSetlInfo> list = dao.selectClnAvgFeePatient(beginTime, endTime, insurName, dept, doctor);
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        for(YbSetlInfo info : list){
+            Map<String, Object> map = new HashMap<>();
+            map.put("deptId", info.getDeptId());
+            map.put("deptName", info.getDeptName());
+            map.put("doctorId", info.getDoctorId());
+            map.put("doctor", info.getDoctor());
+            map.put("insurName", insurName);
+            map.put("xm", info.getPsnName());
+            map.put("zyh", info.getPatNo());
+            map.put("zfy", info.getMedfeeSumamt());
+            map.put("inDays", info.getInDays());
+            map.put("zyzd", info.getMainDiagnosis());
+            map.put("zyss", info.getMainOperation());
+            BigDecimal ypf = DecimalUtil.add(DecimalUtil.add(info.getChargeWesternMedicine(), info.getChargePatentMedicine()), info.getChargeHerbal());
+            map.put("ypf", ypf);
+            map.put("zf", info.getPsnPartAmt());
+            // 床日费用
+            map.put("crf", DecimalUtil.divide(BigDecimal.valueOf(info.getMedfeeSumamt()), BigDecimal.valueOf(Long.parseLong(String.valueOf(info.getInDays()))), 2));
+            // 药品比
+            map.put("ypbl", DecimalUtil.multiply(DecimalUtil.divide(ypf, BigDecimal.valueOf(info.getMedfeeSumamt()), 4), BigDecimal.valueOf(100)));
+            // 自付比
+            map.put("zfbl", DecimalUtil.multiply(DecimalUtil.divide(BigDecimal.valueOf(info.getPsnPartAmt()), BigDecimal.valueOf(info.getMedfeeSumamt()), 4), BigDecimal.valueOf(100)));
+            // 计算单列
+            boolean flag = BigDecimal.valueOf(info.getMedfeeSumamt()).compareTo(
+                    (DecimalUtil.multiply(clnAvgParam.getAvgStandard(), clnAvgParam.getRates()))) < 0;
+            // 长沙县城职/居普通住院病人做了介入手术且手术+化疗同时进行病人也纳入单列
+            if("长沙县城职普通住院".equals(insurName) || "长沙县城居普通住院".equals(insurName)){
+                // 是否用了介入手术材料并且是否同时做了化疗
+                if(isInterventionalProject(info.getPatNo(), info.getTimes(), info.getLedgerSn()) && isChemotherapy(info.getPatNo(), info.getTimes(), info.getLedgerSn())){
+                    flag = false;
+                }
+            }
+            if(flag){
+                BigDecimal bal = DecimalUtil.minus(clnAvgParam.getAvgStandard(), BigDecimal.valueOf(info.getMedfeeSumamt()));
+                map.put("bal", bal);
+                map.put("jslx", "普通病");
+            } else {
+                map.put("bal", 0);
+                map.put("jslx", "单列");
+            }
+            resultList.add(map);
+        }
+
+        return ResultVoUtil.success(resultList);
+    }
+
+}

+ 0 - 6
src/main/java/thyyxxk/webserver/service/ybkf/YbCssTjService.java

@@ -1327,23 +1327,17 @@ public class YbCssTjService {
         String dept = dto.getDept();
         String insurName = dto.getInsurName();
         String zyh = dto.getZyh();
-        long start_times1 = System.currentTimeMillis();
         List<Map<String, Object>> result = dao.selectCssYbCsTj(beginTime, endTime, dept, insurName, zyh);
-        long end_times1 = System.currentTimeMillis();
-        System.out.println((end_times1-start_times1)/3600);
 
         // 获取当年长沙市分值测算标准(setl_cc: 决算; test_cc: 测算)
         String year = endTime.substring(0,4);
         List<YbParamInfo> testParams = dao.selectYbParamInfoByYear(year, "test_cc");
         List<YbParamInfo> setlParams = dao.selectYbParamInfoByYear(year, "setl_cc");
 
-        long start_times = System.currentTimeMillis();
         // 补充主诊断、主手术、分值、预计支付,计算预计的盈亏额
         for(Map<String, Object> map : result){
             AddDaginAndBal(testParams, setlParams, map);
         }
-        long end_times = System.currentTimeMillis();
-        System.out.println((end_times-start_times)/3600);
         return ResultVoUtil.success(result);
     }