Browse Source

完成医技科室的医嘱确费优化和新功能。

xiaochan 3 years ago
parent
commit
ddc78b50c7

+ 6 - 7
src/main/java/thyyxxk/webserver/controller/zhuyuanyiji/QueRenYiZhuShouFeiController.java

@@ -1,7 +1,10 @@
 package thyyxxk.webserver.controller.zhuyuanyiji;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import org.springframework.web.bind.annotation.*;
+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.entity.ResultVo;
 import thyyxxk.webserver.entity.datamodify.YzActOrder;
 import thyyxxk.webserver.service.zhuyuanyiji.QueRenYiZhuShouFeiServer;
@@ -28,15 +31,11 @@ public class QueRenYiZhuShouFeiController {
         return server.getXuQueFeiYiZhu(yzActOrder);
     }
 
-    @GetMapping("/getXuQueFeiXiangXiXinXi")
-    public ResultVo<YzActOrder> getXuQueFeiXiangXiXinXi(@RequestParam("inpatientNo") String inpatientNo,
-                                                        @RequestParam("admissTimes") Integer admissTimes,
-                                                        @RequestParam("execUnit") String execUnit) {
-        return server.getXuQueFeiXiangXiXinXi(inpatientNo, admissTimes, execUnit);
-    }
 
     @PostMapping("/baoCunYiZhuQueFeiShuJu")
     public ResultVo<String> baoCunYiZhuQueFeiShuJu(@RequestBody YzActOrder param) {
         return server.baoCunYiZhuQueFeiShuJu(param);
     }
+
+   
 }

+ 143 - 63
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyiji/QueRenYiZhuShouFeiDao.java

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 import thyyxxk.webserver.entity.datamodify.YzActOrder;
+import thyyxxk.webserver.entity.yibao.patient.Patient;
 
 import java.util.List;
 
@@ -24,34 +25,49 @@ public interface QueRenYiZhuShouFeiDao {
     List<String> getKeShiLieBiao(String deptCode);
 
     @Select("<script>" +
-            "SELECT a.inpatient_no, " +
-            "       a.admiss_times, " +
-            "       bed_no   =b.bed_no, " +
-            "       b.name, " +
-            "       a.ward_code , " +
-            "       ward_name = (select name from zd_unit_code where code = ward_code) " +
-            "FROM yz_zy_patient_fee a ,zy_actpatient b " +
-            "where    a.charge_status='3' and " +
-            "         a.exec_unit    in" +
+            "select  " +
+            "rtrim(a.inpatient_no) inpatient_no, a.admiss_times, bed_no =b.bed_no,rtrim(b.name) name, a.ward_code ,b.sex,b.admiss_date,  " +
+            "ledger_sn = (select max(ledger_sn) from zy_ledger_file where zy_ledger_file.inpatient_no = b.inpatient_no  " +
+            "and zy_ledger_file.admiss_times = b.admiss_times),b.total_charge,  " +
+            "responce_type_name = (select rtrim(name) from zy_zd_responce_type where zy_zd_responce_type.code = b.responce_type),  " +
+            "ward_name = (select name from zd_unit_code where code = ward_code),  " +
+            "shi_fou_you_chu_yuan_yi_zhu =  " +
+            "case when (select count(1) from yz_act_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times  " +
+            "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')) > 0  " +
+            "then 1  " +
+            "when (select count(1) from yz_inact_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times  " +
+            "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')) > 0  " +
+            "then 1 else 0 end  " +
+            "FROM yz_zy_patient_fee a  left join  zy_actpatient b on (a.inpatient_no = b.inpatient_no and a.admiss_times = b.admiss_times)  " +
+            "where a.charge_status ${liShi}'3' and a.exec_unit in " +
             "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
             "    #{item}  " +
             "</foreach>" +
-            "      and   a.inpatient_no=b.inpatient_no and " +
             "<if test=\"inpatientNo !=null and inpatientNo != '' \">" +
-            " a.inpatient_no = #{inpatientNo} and " +
+            " and a.inpatient_no = #{inpatientNo}  " +
             "</if>" +
             "<if test=\"wardCode !=null and wardCode != '' \">" +
-            " a.ward_code = #{wardCode} and " +
+            " and a.ward_code = #{wardCode}  " +
             "</if>" +
-            "         a.admiss_times=b.admiss_times " +
-            "         and convert(varchar(20),a.occ_time,23)&lt;=convert(varchar(20),getdate(),23) " +
-            "group by a.inpatient_no, a.admiss_times, b.bed_no, b.name, a.ward_code " +
-            "order by ward_code" +
+            "<choose>" +
+            "<when  test=\"startTime != null and startTime != '' \">" +
+            " and a.occ_time &gt;= #{startTime} and a.occ_time &lt;= #{endTime} " +
+            "</when >" +
+            "<otherwise>" +
+            " and convert(varchar(20),a.occ_time,23)&lt;=convert(varchar(20),getdate(),23) " +
+            "</otherwise>" +
+            "</choose>" +
+            "group by a.inpatient_no, a.admiss_times, b.bed_no, b.name, a.ward_code, b.total_charge, b.sex, b.admiss_date,b.inpatient_no,b.admiss_times,b.responce_type " +
+            "order by ${fenLei}" +
             "</script>")
     IPage<YzActOrder> getXuQueFeiYiZhu(IPage<YzActOrder> page,
                                        @Param("inpatientNo") String inpatientNo,
                                        @Param("wardCode") String wardCode,
-                                       @Param("list") List<String> list);
+                                       @Param("list") List<String> list,
+                                       @Param("startTime") String startTime,
+                                       @Param("endTime") String endTime,
+                                       @Param("fenLei") String fenLei,
+                                       @Param("liShi") String liShi);
 
 
     /**
@@ -62,64 +78,85 @@ public interface QueRenYiZhuShouFeiDao {
      */
     @Select("<script>" +
             "select count(*) from (" +
-            "SELECT a.inpatient_no, " +
-            "       a.admiss_times, " +
-            "       bed_no   =b.bed_no, " +
-            "       b.name, " +
-            "       a.ward_code , " +
-            "       ward_name = (select name from zd_unit_code where code = ward_code) " +
-            "FROM yz_zy_patient_fee a ,zy_actpatient b " +
-            "where    a.charge_status='3' and " +
-            "         a.exec_unit    in" +
+            "select  " +
+            "a.inpatient_no, a.admiss_times, bed_no =b.bed_no, b.name, a.ward_code ,b.sex,b.admiss_date,  " +
+            "ledger_sn = (select max(ledger_sn) from zy_ledger_file where zy_ledger_file.inpatient_no = b.inpatient_no  " +
+            "and zy_ledger_file.admiss_times = b.admiss_times),b.total_charge,  " +
+            "responce_type_name = (select rtrim(name) from zy_zd_responce_type where zy_zd_responce_type.code = b.responce_type),  " +
+            "ward_name = (select name from zd_unit_code where code = ward_code),  " +
+            "shi_fou_you_chu_yuan_yi_zhu =  " +
+            "case when (select count(1) from yz_act_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times  " +
+            "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')) > 0  " +
+            "then 1  " +
+            "when (select count(1) from yz_inact_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times  " +
+            "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')) > 0  " +
+            "then 1 else 0 end  " +
+            "FROM yz_zy_patient_fee a  left join  zy_actpatient b on (a.inpatient_no = b.inpatient_no and a.admiss_times = b.admiss_times)  " +
+            "where a.charge_status ${liShi} '3' and a.exec_unit in " +
             "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
             "    #{item}  " +
             "</foreach>" +
-
-            "      and   a.inpatient_no=b.inpatient_no and " +
             "<if test=\"inpatientNo !=null and inpatientNo != '' \">" +
-            " a.inpatient_no = #{inpatientNo} and " +
+            " and a.inpatient_no = #{inpatientNo}  " +
             "</if>" +
             "<if test=\"wardCode !=null and wardCode != '' \">" +
-            " a.ward_code = #{wardCode} and " +
+            " and a.ward_code = #{wardCode}  " +
             "</if>" +
-            "         a.admiss_times=b.admiss_times " +
-            "         and convert(varchar(20),a.occ_time,23)&lt;=convert(varchar(20),getdate(),23) " +
-            "group by a.inpatient_no, a.admiss_times, b.bed_no, b.name, a.ward_code" +
-            ") temp" +
+            "<choose>" +
+            "<when  test=\"startTime != null and startTime != '' \">" +
+            " and a.occ_time &gt;= #{startTime} and a.occ_time &lt;= #{endTime} " +
+            "</when >" +
+            "<otherwise>" +
+            " and convert(varchar(20),a.occ_time,23)&lt;=convert(varchar(20),getdate(),23) " +
+            "</otherwise>" +
+            "</choose>" +
+            "group by a.inpatient_no, a.admiss_times, b.bed_no, b.name, a.ward_code, b.total_charge, b.sex, b.admiss_date,b.inpatient_no," +
+            "b.admiss_times,b.responce_type" +
+            ") temp " +
             "</script>")
     long getXuQueFeiYiZhuTotal(@Param("inpatientNo") String inpatientNo,
                                @Param("wardCode") String wardCode,
-                               @Param("list") List<String> list);
-
-
-    @Select("select inpatient_no,admiss_times,bed_no,sex,admiss_date,responce_type, " +
-            "ledger_sn = (select max(ledger_sn) from zy_ledger_file where zy_ledger_file.inpatient_no = zy_actpatient.inpatient_no " +
-            "and zy_ledger_file.admiss_times = zy_actpatient.admiss_times), " +
-            "responce_type_name = (select rtrim(name) from zy_zd_responce_type where code = responce_type),  " +
-            "total_charge from zy_actpatient where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} ")
-    YzActOrder huoQuGeRenXinXi(@Param("inpatientNo") String inpatientNo,
-                               @Param("admissTimes") Integer admissTimes);
+                               @Param("list") List<String> list,
+                               @Param("startTime") String startTime,
+                               @Param("endTime") String endTime,
+                               @Param("liShi") String liShi);
 
     @Select("<script>" +
-            "select a.charge_status,e.name docotr_name,a.act_order_no,c.name order_name,a.charge_code,a.charge_fee,a.order_count,occ_time " +
-            "from yz_zy_patient_fee a ,zd_charge_item c,yz_act_order d,a_employee_mi e " +
-            "where a.inpatient_no = #{inpatientNo} and a.admiss_times = #{admissTimes} and " +
-            "a.charge_status = '3' and " +
-            "a.charge_code=c.code  and " +
-            "a.inpatient_no=d.inpatient_no and " +
-            "a.admiss_times=d.admiss_times  and " +
-            "a.act_order_no=d.act_order_no  and " +
-            "d.physician*=e.code  and " +
-            "convert(varchar(20),a.occ_time,23)&lt;=convert(varchar(20),getdate(),23) and " +
-            "a.exec_unit in " +
+            "select a.charge_status,e.name docotr_name,a.act_order_no,c.name charge_name,a.charge_code,a.charge_fee," +
+            "a.order_count,occ_time,rtrim(a.inpatient_no) inpatient_no,op_id,a.op_date, " +
+            "a.admiss_times" +
+            "<if test=\"startTime != null and startTime != '' \"> " +
+            ",op_id_name = (select rtrim(name) name from a_employee_mi where a_employee_mi.code = a.op_id)," +
+            "a.op_date" +
+            "</if>" +
+            "from yz_zy_patient_fee a  left join  zd_charge_item c on (a.charge_code=c.code)\n" +
+            "left join yz_act_order d on (a.inpatient_no=d.inpatient_no and a.admiss_times=d.admiss_times and a.act_order_no=d.act_order_no )\n" +
+            "left join a_employee_mi e on (d.physician=e.code)" +
+            "where  " +
+            "a.charge_status ${liShi} '3' " +
+            "<choose>" +
+            "<when  test=\"startTime != null and startTime != '' \">" +
+            " and a.occ_time &gt;= #{startTime} and a.occ_time &lt;= #{endTime} " +
+            "</when >" +
+            "<otherwise>" +
+            " and convert(varchar(20),a.occ_time,23)&lt;=convert(varchar(20),getdate(),23) " +
+            "</otherwise>" +
+            "</choose>" +
+            "and a.exec_unit in " +
             "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
             "    #{item}  " +
             "</foreach>" +
+            "and a.inpatient_no in " +
+            "<foreach collection='inpatientNoList' item='item' index='index' open='(' close=')' separator=','>" +
+            "    #{item.inpatientNo}  " +
+            "</foreach>" +
             "</script>")
-    List<YzActOrder> getXuQueFeiXiangXiXinXi(@Param("inpatientNo") String inpatientNo,
-                                             @Param("admissTimes") Integer admissTimes,
-                                             @Param("execUnit") String execUnit,
-                                             @Param("list") List<String> list);
+    List<YzActOrder> getXuQueFeiXiangXiXinXi(@Param("list") List<String> list,
+                                             @Param("inpatientNoList") List<YzActOrder> inpatientNoList,
+                                             @Param("startTime") String startTime,
+                                             @Param("endTime") String endTime,
+                                             @Param("liShi") String liShi);
+
 
     @Update("<script>" +
             "<foreach collection='list' item='item' separator=';'>" +
@@ -128,11 +165,54 @@ public interface QueRenYiZhuShouFeiDao {
             " charge_status = #{item.chargeStatus}, op_id = #{code}, op_date = GETDATE() " +
             "</set>" +
             "WHERE act_order_no = #{item.actOrderNo} " +
-            "AND inpatient_no = #{inpatientNo} AND admiss_times = #{admissTimes} and occ_time = #{item.occTime} " +
+            "AND inpatient_no = #{item.inpatientNo} AND admiss_times = #{item.admissTimes} and occ_time = #{item.occTime} " +
             "</foreach>" +
             "</script>")
-    void baoCunYiZhuQueFei(@Param("inpatientNo") String inpatientNo,
-                           @Param("admissTimes") Integer admissTimes,
-                           @Param("list") List<YzActOrder> list,
+    void baoCunYiZhuQueFei(@Param("list") List<YzActOrder> list,
                            @Param("code") String code);
+
+
+    @Select("<script>" +
+            "select rtrim(a.inpatient_no) inpatient_no,a.admiss_times,rtrim(e.name) patient_name,  " +
+            "a.charge_status,docotr_name = (select rtrim(name) name from a_employee_mi where a_employee_mi.code = d.physician),  " +
+            "a.act_order_no,c.name order_name,a.charge_code,a.charge_fee,a.order_count,occ_time, " +
+            "op_id_name = (select rtrim(name) name from a_employee_mi where a_employee_mi.code = a.op_id),  " +
+            "a.op_date,rtrim(f.name) ward_name  " +
+            "from yz_zy_patient_fee a  " +
+            "left join  zd_charge_item c on (a.charge_code=c.code)  " +
+            "left join yz_act_order d on (a.inpatient_no=d.inpatient_no and a.admiss_times=d.admiss_times and a.act_order_no=d.act_order_no)  " +
+            "left join zy_actpatient e on (a.inpatient_no = e.inpatient_no)  " +
+            "left join zd_unit_code f on (a.ward_code = f.code)  " +
+            "where a.charge_status &lt;&gt; '3' " +
+            "<choose>" +
+            "<when  test=\"startTime != null and startTime != '' \">" +
+            " and charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} " +
+            "</when >" +
+            "<otherwise>" +
+            " and convert(varchar(20),a.occ_time,23)&lt;=convert(varchar(20),getdate(),23) " +
+            "</otherwise>" +
+            "</choose>" +
+            " and a.exec_unit in " +
+            "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
+            "    #{item}  " +
+            "</foreach>" +
+            "<if test=\"wardCode !=null and wardCode != '' \">" +
+            " and a.ward_code = #{wardCode}" +
+            "</if>" +
+            "<if test=\"yiQueFeiShuJu != null and yiQueFeiShuJu.size > 0 \">" +
+            " and a.inpatient_no in " +
+            "<foreach collection='yiQueFeiShuJu' item='item' index='index' open='(' close=')' separator=','>" +
+            "    #{item.inpatientNo}  " +
+            "</foreach>" +
+            "</if>" +
+            "order by a.ward_code" +
+            "</script>")
+    List<YzActOrder> huoQuLiShiQueFeiXinXi(
+            @Param("startTime") String startTime,
+            @Param("endTime") String endTime,
+            @Param("list") List<String> execUnitList,
+            @Param("wardCode") String wardCode,
+            @Param("yiQueFeiShuJu") List<Patient> yiQueFeiShuJu);
+
+
 }

+ 20 - 0
src/main/java/thyyxxk/webserver/entity/datamodify/YzActOrder.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.entity.datamodify;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import io.swagger.annotations.ApiModel;
 import lombok.Data;
@@ -56,6 +57,10 @@ public class YzActOrder implements Serializable {
 
     private Date endTime;
 
+    private String startTimeString;
+
+    private String endTimeString;
+
     private String modifier;
 
     private String modifierName;
@@ -226,7 +231,9 @@ public class YzActOrder implements Serializable {
     private Integer comfirmFlag;
     private String wardName;
     private String chargeCode;
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private BigDecimal chargeFee;
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private BigDecimal orderCount;
     private Integer sex;
     private Date admissDate;
@@ -235,8 +242,21 @@ public class YzActOrder implements Serializable {
     private String responceTypeName;
     private Date occTime;
     private String occTimeString;
+    private String chargeName;
     private String billItemCode;
     private List<YzActOrder> list;
+    private long total;
+    private String opIdName;
+    private Date opDate;
+
+    private Integer fenLei;
+    private Integer shiFouYouChuYuanYiZhu;
+    private Integer liShi;
+
+    private Integer yiQueRen;
+    private Integer quXiao;
+    private Integer weiQueRen;
+    private Integer yiChanShenFeiYong;
 
 
     public String getDrugFlagName() {

+ 101 - 53
src/main/java/thyyxxk/webserver/service/zhuyuanyiji/QueRenYiZhuShouFeiServer.java

@@ -1,6 +1,7 @@
 package thyyxxk.webserver.service.zhuyuanyiji;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
@@ -8,18 +9,20 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.constants.GetDateFormat;
-import thyyxxk.webserver.dao.his.yibao.XiangMuLuRuDao;
 import thyyxxk.webserver.dao.his.zhuyuanyiji.QueRenYiZhuShouFeiDao;
 import thyyxxk.webserver.entity.ResultVo;
-import thyyxxk.webserver.entity.datamodify.FeiYongLeiXin;
 import thyyxxk.webserver.entity.datamodify.YzActOrder;
-import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
+import thyyxxk.webserver.entity.yibao.patient.Patient;
 import thyyxxk.webserver.service.PublicServer;
+import thyyxxk.webserver.service.yibao.PatientService;
 import thyyxxk.webserver.utils.*;
+import thyyxxk.webserver.websocket.WebSocketServer;
 
-import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -34,14 +37,14 @@ import java.util.List;
 public class QueRenYiZhuShouFeiServer {
     private final QueRenYiZhuShouFeiDao dao;
 
-    private final XiangMuLuRuDao xiangMuLuRuDao;
-
     private final PublicServer publicServer;
 
-    public QueRenYiZhuShouFeiServer(QueRenYiZhuShouFeiDao dao, XiangMuLuRuDao xiangMuLuRuDao, PublicServer server) {
+    private final PatientService patientService;
+
+    public QueRenYiZhuShouFeiServer(QueRenYiZhuShouFeiDao dao, PublicServer server, PatientService patientService) {
         this.dao = dao;
-        this.xiangMuLuRuDao = xiangMuLuRuDao;
         this.publicServer = server;
+        this.patientService = patientService;
     }
 
     /**
@@ -50,73 +53,118 @@ public class QueRenYiZhuShouFeiServer {
      */
     public ResultVo<IPage<YzActOrder>> getXuQueFeiYiZhu(YzActOrder yzActOrder) {
         IPage<YzActOrder> page = new Page<>(yzActOrder.getCurrentPage(), yzActOrder.getPageSize(), false);
+
+        List<String> execUnitList = publicServer.getKeShiLieBiaoList(yzActOrder.getExecUnit());
         if (StringUtil.isBlank(yzActOrder.getExecUnit())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "科室信息为空 [・_・?]");
         }
+
+        String liShi = "=";
+
+        if (yzActOrder.getLiShi() == 1) {
+            if (StringUtil.isBlank(yzActOrder.getStartTimeString()) || StringUtil.isBlank(yzActOrder.getEndTimeString())) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "查看历史数据时需要携带医嘱时间");
+            }
+            liShi = "<>";
+        }
         log.info("查询需确费医嘱:数据:{}", JSON.toJSONString(yzActOrder));
-        page.setTotal(dao.getXuQueFeiYiZhuTotal(yzActOrder.getInpatientNo(), yzActOrder.getWardCode(), publicServer.getKeShiLieBiaoList(yzActOrder.getExecUnit())));
-        dao.getXuQueFeiYiZhu(page, yzActOrder.getInpatientNo(), yzActOrder.getWardCode(), publicServer.getKeShiLieBiaoList(yzActOrder.getExecUnit()));
+        String fenLei = "a.ward_code";
+        if (yzActOrder.getFenLei() != null && yzActOrder.getFenLei().equals(1)) {
+            fenLei = "(select count(*) from yz_zy_patient_fee " +
+                    "where op_id = '" + TokenUtil.getTokenUserId() + "' and inpatient_no = a.inpatient_no and admiss_times = a.admiss_times and charge_status <> 3)";
+        }
+        page.setTotal(dao.getXuQueFeiYiZhuTotal(yzActOrder.getInpatientNo(), yzActOrder.getWardCode(), execUnitList, yzActOrder.getStartTimeString(), yzActOrder.getEndTimeString(), liShi));
+        dao.getXuQueFeiYiZhu(page, yzActOrder.getInpatientNo(), yzActOrder.getWardCode(), execUnitList, yzActOrder.getStartTimeString(), yzActOrder.getEndTimeString(),
+                fenLei, liShi);
         if (page.getRecords().isEmpty()) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
         }
+
+        List<YzActOrder> ziJieDian = dao.getXuQueFeiXiangXiXinXi(execUnitList, page.getRecords(), yzActOrder.getStartTimeString(), yzActOrder.getEndTimeString(), liShi);
+
+        Map<String, List<YzActOrder>> ziJieDianMap = ziJieDian.stream().collect(
+                Collectors.groupingBy(item -> item.getInpatientNo() + item.getAdmissTimes())
+        );
+
+        for (int i = 0; i < page.getRecords().size(); i++) {
+            YzActOrder yz = page.getRecords().get(i);
+            String key = yz.getInpatientNo() + yz.getAdmissTimes();
+            if (yz.getList() == null) {
+                yz.setList(new ArrayList<>());
+            }
+            if (ziJieDianMap.containsKey(key)) {
+                yz.getList().addAll(ziJieDianMap.get(key));
+            }
+        }
         return ResultVoUtil.success(page);
     }
 
+
     /**
-     * 这里是查询 患者的具体医嘱确认信息
-     *
-     * @param inpatientNo 住院号
-     * @param admissTimes 住院次数
-     * @param execUnit    执行科室
-     * @return 返回
+     * @param param
+     * @return
      */
-    public ResultVo<YzActOrder> getXuQueFeiXiangXiXinXi(String inpatientNo, Integer admissTimes, String execUnit) {
-        YzActOrder yzActOrder = dao.huoQuGeRenXinXi(inpatientNo, admissTimes);
-        log.info("查询确认医嘱费用明细 ==> 住院号:{},住院次数:{},执行科室:{}", inpatientNo, admissTimes, execUnit);
-        yzActOrder.setList(dao.getXuQueFeiXiangXiXinXi(inpatientNo, admissTimes, execUnit, publicServer.getKeShiLieBiaoList(execUnit)));
-        if (yzActOrder.getList() == null || yzActOrder.getList().isEmpty()) {
-            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有数据 ヽ(゜Q。)ノ?");
-        }
-        return ResultVoUtil.success(yzActOrder);
-    }
-
     @Transactional(rollbackFor = Exception.class)
     public ResultVo<String> baoCunYiZhuQueFeiShuJu(YzActOrder param) {
-        List<ZyDetailCharge> zyDetailCharges = new ArrayList<>();
-        List<YzActOrder> shangChuanList = new ArrayList<>();
-        BigDecimal sum = new BigDecimal(0);
+        List<Patient> xuYaoFeiYongJieShou = new ArrayList<>();
+        List<YzActOrder> xuYaoQueFei = new ArrayList<>();
         if (ListUtil.isBlank(param.getList())) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者没有需要确认的医嘱费用 ∑(っ°Д°;)っ。");
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请选择需要确费的数据 ヽ(ー_ー)ノ");
+        }
+        if (StringUtil.isBlank(param.getExecUnit())) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "科室信息为空 ∑(っ°Д°;)っ卧槽,不见了");
         }
         for (YzActOrder yzActOrder : param.getList()) {
-            if (StringUtil.isBlank(yzActOrder.getChargeStatus())) {
-                return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER);
-            }
-            if (yzActOrder.getChargeStatus().equals("1")) {
-                ZyDetailCharge zy = new ZyDetailCharge();
-                zy.setChargeAmount(yzActOrder.getOrderCount());
-                zy.setChargeFee(yzActOrder.getChargeFee());
-                zy.setBillItemCode(yzActOrder.getBillItemCode());
-                zyDetailCharges.add(zy);
-                sum = sum.add(zy.getChargeAmount().multiply(zy.getChargeFee()));
-                shangChuanList.add(yzActOrder);
-            } else if (yzActOrder.getChargeStatus().equals("2")) {
-                yzActOrder.setOccTimeString(DateUtil.formatDatetime(yzActOrder.getOccTime()));
-                shangChuanList.add(yzActOrder);
+            if (yzActOrder.getList() != null && !yzActOrder.getList().isEmpty()) {
+                for (YzActOrder actOrder : yzActOrder.getList()) {
+                    if (actOrder.getChargeStatus().equals("1")) {
+                        xuYaoQueFei.add(actOrder);
+                        Patient xuQueFei = new Patient();
+                        xuQueFei.setInpatientNo(yzActOrder.getInpatientNo());
+                        xuQueFei.setAdmissTimes(yzActOrder.getAdmissTimes());
+                        xuQueFei.setName(yzActOrder.getName());
+                        xuQueFei.setLedgerSn(yzActOrder.getLedgerSn());
+                        if (!xuYaoFeiYongJieShou.contains(xuQueFei)) {
+                            xuYaoFeiYongJieShou.add(xuQueFei);
+                        }
+                    } else if (actOrder.getChargeStatus().equals("2")) {
+                        xuYaoQueFei.add(actOrder);
+                    }
+                }
             }
         }
-        if (shangChuanList.isEmpty()) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有选择任何操作 !!!∑(゚Д゚ノ)ノ");
+        if (xuYaoFeiYongJieShou.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有进行确认操作请勿点击。 ψ(*`ー´)ψ");
         } else {
-            dao.baoCunYiZhuQueFei(param.getInpatientNo(), param.getAdmissTimes(), shangChuanList, TokenUtil.getTokenUserId());
+            List<YzActOrder> yiQueFei = dao.huoQuLiShiQueFeiXinXi("", "",
+                    publicServer.getKeShiLieBiaoList(param.getExecUnit()), "", xuYaoFeiYongJieShou);
+            Map<String, YzActOrder> yiQueFeiMap = yiQueFei.stream().collect(
+                    Collectors.toMap(L -> L.getInpatientNo() + L.getAdmissTimes() + DateUtil.formatDatetime(L.getOccTime()) + L.getChargeCode() + L.getChargeFee() + L.getOrderCount(), Function.identity()));
+
+            for (YzActOrder yzActOrder : xuYaoQueFei) {
+                String key = yzActOrder.getInpatientNo() + yzActOrder.getAdmissTimes() + DateUtil.formatDatetime(yzActOrder.getOccTime()) +
+                        yzActOrder.getChargeCode() + yzActOrder.getChargeFee() + yzActOrder.getOrderCount();
+                if (yiQueFeiMap.containsKey(key)) {
+                    YzActOrder queRenTiShi = yiQueFeiMap.get(key);
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("存在已被确费的项目,请对该项目选择不操作或刷新数据重新加载。 !!!∑(゚Д゚ノ)ノ <br>患者姓名:【%s】<br>项目:【%s】<br> 医嘱号:【%s】<br> 医嘱时间:【%s】<br>执行人:【%s】<br> 操作时间:【%s】", queRenTiShi.getPatientName(),
+                            queRenTiShi.getOrderName(), queRenTiShi.getActOrderNo(), DateUtil.formatDatetime(queRenTiShi.getOccTime()), queRenTiShi.getOpIdName(), DateUtil.formatDatetime(queRenTiShi.getOpDate())));
+                }
+            }
         }
-        if (!zyDetailCharges.isEmpty()) {
-            FeiYongLeiXin fy = JiSuanFeiYong.jiSuan(zyDetailCharges, true);
-            fy.setTotalCharge(sum);
-            xiangMuLuRuDao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_ledger_file");
-            xiangMuLuRuDao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
+        dao.baoCunYiZhuQueFei(xuYaoQueFei, TokenUtil.getTokenUserId());
+        for (Patient patient : xuYaoFeiYongJieShou) {
+            try {
+                patientService.receiveAndRecalculateCost(patient);
+            } catch (Exception e) {
+                JSONObject obj = new JSONObject();
+                obj.put("name", "systemNotification");
+                obj.put("message", String.format("患者名字为:【%s】,医嘱确认成功但接受费用失败,请护士重新接受费用", patient.getName()));
+                String message = obj.toJSONString();
+                WebSocketServer.sendMessageByUserCode(TokenUtil.getTokenUserId(), message);
+            }
         }
-        log.info("医嘱确费保存==》操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONStringWithDateFormat(param.getList(), GetDateFormat.DATE_TIME));
+        log.info("医嘱确费保存==》操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONStringWithDateFormat(xuYaoQueFei, GetDateFormat.DATE_TIME));
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "操作成功 (๑*◡*๑)");
     }
+
 }