Explorar o código

门诊项目确认。

xiaochan %!s(int64=3) %!d(string=hai) anos
pai
achega
2564422630

+ 15 - 8
src/main/java/thyyxxk/webserver/controller/zhuyuanyiji/MenZhengXiangMuController.java

@@ -24,6 +24,14 @@ public class MenZhengXiangMuController {
         this.server = server;
     }
 
+
+    @GetMapping("/kuaiSuChaZhao")
+    public ResultVo<List<MzChargeDetail>> kuaiSuChaZhao(@RequestParam("startTime") String startTime,
+                                                        @RequestParam("endTime") String endTime,
+                                                        @RequestParam("execDept") String execDept) {
+        return server.kuaiSuChaZhao(startTime, endTime, execDept);
+    }
+
     @GetMapping("/getMzPatient")
     public ResultVo<MzChargeDetail> getMzPatient(@RequestParam("patientId") String patientId,
                                                  @RequestParam("xiangMuZhuangTai") Integer xiangMuZhuangTai,
@@ -34,17 +42,16 @@ public class MenZhengXiangMuController {
     }
 
     @GetMapping("/getFeiYongXinXi")
-    public ResultVo<List<MzChargeDetail>> getFeiYongXinXi(@RequestParam("serialNo") Integer serialNo,
+    public ResultVo<List<MzChargeDetail>> getFeiYongXinXi(@RequestParam("realNo") Integer realNo,
                                                           @RequestParam("patientId") String patientId,
-                                                          @RequestParam("times") Integer times) {
-        return server.getFeiYongXinXi(serialNo, patientId, times);
+                                                          @RequestParam("times") Integer times,
+                                                          @RequestParam("xiangMuZhuangTai") Integer xiangMuZhuangTai) {
+        return server.getFeiYongXinXi(realNo, patientId, times, xiangMuZhuangTai);
     }
 
-    @GetMapping("/getMingXi")
-    public ResultVo<List<MzChargeDetail>> getMingXi(@RequestParam("patientId") String patientId,
-                                                    @RequestParam("times") Integer times,
-                                                    @RequestParam("reqNo") Integer reqNo) {
-        return server.getMingXi(patientId, times, reqNo);
+    @PostMapping("/getMingXi")
+    public ResultVo<List<MzChargeDetail>> getMingXi(@RequestBody MzChargeDetail mzChargeDetail) {
+        return server.getMingXi(mzChargeDetail);
     }
 
     @PostMapping("/queRenOrQuXiao")

+ 58 - 157
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyiji/MenZhengXiangMuDao.java

@@ -19,9 +19,19 @@ import java.util.List;
 @Mapper
 public interface MenZhengXiangMuDao {
 
+
+    @Select("select rtrim(patient_id) patient_id,rtrim(name) name from mz_charge_detail " +
+            "where charge_date >= #{startTime} and charge_date <= #{endTime} " +
+            "and exec_dept = #{execDept} and group_no = '00' and confirm_flag = 0 " +
+            "and charge_item_code  <>  'BILL99' " +
+            "group by patient_id ,name")
+    List<MzChargeDetail> kuaiSuChaZhao(@Param("startTime") String startTime,
+                                       @Param("endTime") String endTime,
+                                       @Param("execDept") String execDept);
+
     @Select("SELECT mz_patient_mi.name, " +
             "       mz_patient_mi.sex, " +
-            "       mz_patient_mi.patient_id, " +
+            "       rtrim(mz_patient_mi.patient_id) patient_id, " +
             "       ic_card_no = cast(mz_patient_mi.ic_card_no as varchar(50)), " +
             "       mz_patient_mi.birth_day, " +
             "       mz_patient_mi.phone_no, " +
@@ -40,126 +50,50 @@ public interface MenZhengXiangMuDao {
     MzChargeDetail getMzPatient(String patientId);
 
 
-    @Select("SELECT patient_id =max(a.patient_id), " +
-            "       times      =max(a.times), " +
-            "       serial_no  =a.serial_no, " +
-            "       charge_date=max(a.charge_date) " +
-            "FROM mz_receipt_serial a " +
-            "where    patient_id=#{patientId} and " +
-            "        charge_date >= #{startTime} and " +
-            "        charge_date <= #{endTime} and " +
-            "        isnull(tf_flag,'') <> '1' " +
-            "group by serial_no " +
-            "having sum(total_charge) - sum(charge10 + charge11 + charge12) > 0")
-    List<MzChargeDetail> getFeiYong(@Param("patientId") String patientId,
-                                    @Param("startTime") String startTime,
-                                    @Param("endTime") String endTime);
-
-    @Select("SELECT patient_id =max(a.patient_id),  " +
-            "       times      =max(a.times),  " +
-            "       serial_no  =a.serial_no,  " +
-            "       charge_date=max(a.charge_date),  " +
-            "       confirm_date=max(a.confirm_time)  " +
-            "FROM mz_charge_detail a ,zd_unit_code d  " +
-            "where    a.exec_dept=d.code and  " +
-            "        patient_id=#{patientId} and  " +
-            "        charge_date >= #{startTime} and  " +
-            "        charge_date <= #{endTime} and  " +
-            "        isnull(a.confirm_flag,'') in ('1','3') and  " +
-            "    (a.exec_dept=#{dept} or d.parent_code_hs=#{dept}) and  " +
-            "        a.pay_mark='0' and  " +
-            "        a.group_no='00'  " +
-            "group by serial_no")
-    List<MzChargeDetail> getYiQueRenFeiYong(@Param("patientId") String patientId,
-                                            @Param("startTime") String startTime,
-                                            @Param("endTime") String endTime,
-                                            @Param("dept") String dept);
-
-    @Select("SELECT patient_id=rtrim(a.patient_id),  " +
-            "       times=a.times,  " +
-            "       receipt_no=a.receipt_no,  " +
-            "       order_no=a.order_no,  " +
-            "       item_no=a.item_no,  " +
-            "       charge_code=a.charge_item_code,  " +
-            "       charge_name=b.name,  " +
-            "       je         =round(quantity * unit_price,2),  " +
-            "       serial_no=a.serial_no,  " +
-            "       confirm_time=a.confirm_time,  " +
-            "       confirm_id=a.confirm_id,  " +
-            "       confirm_id_name = (select rtrim(name) name from a_employee_mi where a_employee_mi.code = confirm_id)," +
-            "       exec_dept=a.exec_dept,  " +
-            "       exec_dept_name = (select rtrim(name) name from zd_unit_code where zd_unit_code.code = a.exec_dept),  " +
-            "       confirm_flag=isnull(a.confirm_flag,'0'),  " +
-            "       req_no      =a.req_no  " +
-            "FROM mz_charge_detail a ,zd_charge_item b  " +
-            "where    a.serial_no       =#{serialNo} and  " +
-            "        a.pay_mark='0'    and  " +
-            "        a.charge_item_code=b.code   and  " +
-            "        isnull(a.req_no,0)=0  " +
-            "  " +
-            "union  " +
-            "  " +
-            "SELECT patient_id=rtrim(a.patient_id),  " +
-            "       times     =a.times,  " +
-            "       receipt_no=a.receipt_no,  " +
-            "       order_no=a.order_no,  " +
-            "       item_no=a.item_no,  " +
-            "       charge_code=a.order_code,  " +
-            "       charge_name=b.name,  " +
-            "       je          =0.00,  " +
-            "       serial_no   =a.serial_no,  " +
-            "       confirm_time=a.confirm_time,  " +
-            "       confirm_id  =a.confirm_id, " +
-            "       confirm_id_name = (select rtrim(name) name from a_employee_mi where a_employee_mi.code = confirm_id), " +
-            "       exec_dept   =a.exec_dept,  " +
-            "       exec_dept_name = (select rtrim(name) name from zd_unit_code where zd_unit_code.code = a.exec_dept),  " +
-            "       confirm_flag=isnull(a.confirm_flag,'0'),  " +
-            "       req_no      =a.req_no  " +
-            "FROM mz_yj_req a ,jy_zd_item b  " +
-            "where    a.patient_id    =#{patientId} and  " +
-            "        a.times         =#{times} and  " +
-            "        a.pay_mark='0'    and  " +
-            "        a.order_code      =b.code   and  " +
-            "        isnull(a.req_no,0) > 0  " +
-            "union  " +
-            "  " +
-            "SELECT patient_id=rtrim(a.patient_id),  " +
-            "       times     =a.times,  " +
-            "       receipt_no=a.receipt_no,  " +
-            "       order_no=a.order_no,  " +
-            "       item_no=a.item_no,  " +
-            "       charge_code=a.order_code, " +
-            "       charge_name=b.name,  " +
-            "       je          =0.00,  " +
-            "       serial_no   =a.serial_no,  " +
-            "       confirm_time=a.confirm_time,  " +
-            "       confirm_id  =a.confirm_id,  " +
-            "       confirm_id_name = (select rtrim(name) name from a_employee_mi where a_employee_mi.code = confirm_id)," +
-            "       exec_dept   =a.exec_dept,  " +
-            "       exec_dept_name = (select rtrim(name) name from zd_unit_code where zd_unit_code.code = a.exec_dept),  " +
-            "       confirm_flag=isnull(a.confirm_flag,'0'),  " +
-            "       req_no      =a.req_no  " +
-            "FROM mz_yj_req a ,jc_zd_item b  " +
-            "where    a.patient_id    =#{patientId} and  " +
-            "        a.times         =#{times} and  " +
-            "        a.pay_mark='0'    and  " +
-            "        a.order_code      =b.code   and  " +
-            "        isnull(a.req_no,0) > 0")
-    List<MzChargeDetail> getFeiYongXiangXi(@Param("serialNo") Integer serialNo,
-                                           @Param("patientId") String patientId,
-                                           @Param("times") Integer times);
+    @Select("<script>" +
+            "select charge_date,real_no,rtrim(patient_id) patient_id,times  " +
+            "from mz_charge_detail where  charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} and " +
+            "patient_id = #{patientId} and pay_mark = '0' " +
+            "<if test=\"confirmFlag == 0 \">" +
+            "and (confirm_flag = 0 or confirm_flag = 3) " +
+            "</if>" +
+            "<if test=\"confirmFlag != 0 \">" +
+            "and confirm_flag = 1" +
+            "</if>" +
+            "and group_no = '00' and charge_item_code  &lt;&gt; 'BILL99' " +
+            "group by charge_date,real_no,patient_id,times " +
+            "</script>")
+    List<MzChargeDetail> huoQuMenZhenQueRenShuJu(@Param("patientId") String patientId,
+                                                 @Param("startTime") String startTime,
+                                                 @Param("endTime") String endTime,
+                                                 @Param("confirmFlag") Integer confirmFlag);
 
+    //   父节点 根据  patient_id times receipt_no order_no charge_item_code
+    //   子节点 根据  patient_id times receipt_no order_no tc_no
+    @Select("<script>" +
+            "select confirm_flag,rtrim(patient_id) patient_id ,times,item_no,receipt_no,order_no,req_no, " +
+            "       rtrim(charge_item_code) charge_item_code,rtrim(tc_no) tc_no,rtrim(tc_name) tc_name," +
+            "       rtrim(bill_item_code) bill_item_code,exec_dept," +
+            "       charge_name = (select rtrim(name) from zd_charge_item where charge_item_code = code)," +
+            "       quantity,drug_win,unit_price, " +
+            "       exec_dept_name= (select rtrim(name) from zd_unit_code where code = exec_dept), " +
+            "       confirm_id,confirm_id_name = (select rtrim(name) from a_employee_mi where code = confirm_id), " +
+            "       confirm_time " +
+            "       from mz_charge_detail " +
+            "where  real_no = #{realNo} and patient_id = #{patientNo} and times = #{times} " +
+            "and pay_mark = '0' and group_no = '00' and charge_item_code  &lt;&gt; 'BILL99' " +
+            "<if test=\"xiangMuZhuangTai != null and xiangMuZhuangTai == 0 \">" +
+            "and (confirm_flag = 0 or confirm_flag = 3) " +
+            "</if>" +
+            "<if test=\"xiangMuZhuangTai !=null and xiangMuZhuangTai == 1 \">" +
+            "and confirm_flag = 1" +
+            "</if>" +
+            "</script>")
+    List<MzChargeDetail> feiYongXinXi(@Param("realNo") Integer realNo,
+                                      @Param("patientNo") String patientNo,
+                                      @Param("times") Integer times,
+                                      @Param("xiangMuZhuangTai") Integer xiangMuZhuangTai);
 
-    @Select("SELECT req_no     =a.req_no,   " +
-            "       je         =sum(round(quantity * unit_price,2)),   " +
-            "       charge_date=max(a.charge_date) " +
-            "FROM mz_charge_detail a ,zd_charge_item b   " +
-            "where    a.serial_no       =#{serialNo} and   " +
-            "        a.pay_mark='0'    and   " +
-            "        a.charge_item_code=b.code  and   " +
-            "        a.req_no > 0   " +
-            "group by a.req_no")
-    List<MzChargeDetail> piPiJingEr(@Param("serialNo") Integer serialNo);
 
     /**
      * @param patientId 门诊号
@@ -167,48 +101,15 @@ public interface MenZhengXiangMuDao {
      * @param reqNo     申请号
      * @return 缴费的详细信息
      */
-    @Select("SELECT patient_id=a.patient_id, " +
-            "       times=a.times, " +
-            "       receipt_no=a.receipt_no, " +
-            "       order_no=a.order_no, " +
-            "       item_no=a.item_no, " +
-            "       charge_code=a.charge_item_code, " +
-            "       charge_name=b.name, " +
-            "       je         =round(quantity * unit_price,2), " +
-            "       serial_no=a.serial_no, " +
-            "       confirm_time=a.confirm_time, " +
-            "       confirm_id=a.confirm_id, " +
-            "       exec_dept=a.exec_dept, " +
-            "       confirm_flag=a.confirm_flag, " +
-            "       req_no      =a.req_no " +
-            "FROM mz_charge_detail a ,zd_charge_item b " +
-            "where    a.patient_id     =#{patientId} and " +
-            "        a.times           =#{times} and " +
-            "        a.req_no=#{reqNo} and " +
-            "        a.pay_mark='0'    and " +
-            "        a.charge_item_code=b.code")
+    @Select("select (unit_price * quantity * drug_win) charge_fee,quantity charge_amount, " +
+            "(select rtrim(name) from zd_charge_item where code = charge_item_code) " +
+            "from mz_charge_detail where " +
+            "req_no = #{reqNo} and unit_price <> 0 and patient_id = #{patientId} and times = #{times} " +
+            "and group_no = 00 and charge_item_code  <> 'BILL99' ")
     List<MzChargeDetail> getMingXi(@Param("patientId") String patientId,
                                    @Param("times") Integer times,
                                    @Param("reqNo") Integer reqNo);
 
-    @Select("<script>" +
-            "select req_no,confirm_flag,charge_item_code,bill_item_code,rtrim(patient_id) patient_id,times,charge_date,item_no,receipt_no,order_no from mz_charge_detail " +
-            "where req_no in" +
-            "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
-            "#{item}" +
-            "</foreach>" +
-            "<if test=\"patientId != null and patientId != '' \">" +
-            " and patient_id = #{patientId} " +
-            "</if>" +
-            "<if test=\"times !=null and times != '' \">" +
-            " and times = #{times}" +
-            "</if>" +
-            "</script>")
-    List<MzChargeDetail> genJuShenQingHuoQuMingXi(@Param("patientId") String patientId,
-                                                  @Param("times") Integer times,
-                                                  @Param("list") List<Integer> reqNos);
-
-
     @Update("<script>" +
             "<foreach collection='list' item='item' separator=';'> " +
             "update mz_charge_detail " +

+ 4 - 4
src/main/java/thyyxxk/webserver/entity/datamodify/MzChargeDetail.java

@@ -68,12 +68,12 @@ public class MzChargeDetail implements Serializable {
     /**
      * quantity
      */
-    private Double quantity;
+    private BigDecimal quantity;
 
     /**
      * unitPrice
      */
-    private String unitPrice;
+    private BigDecimal unitPrice;
 
     /**
      * payMark
@@ -134,7 +134,7 @@ public class MzChargeDetail implements Serializable {
     /**
      * drugWin
      */
-    private Integer drugWin;
+    private BigDecimal drugWin;
 
     /**
      * inputId
@@ -242,7 +242,7 @@ public class MzChargeDetail implements Serializable {
     /**
      * drugQuan
      */
-    private Double drugQuan;
+    private BigDecimal drugQuan;
 
     /**
      * drugUnit

+ 97 - 85
src/main/java/thyyxxk/webserver/service/zhuyuanyiji/MenZhengXiangMuServer.java

@@ -8,16 +8,12 @@ import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.dao.his.zhuyuanyiji.MenZhengXiangMuDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.datamodify.MzChargeDetail;
-import thyyxxk.webserver.utils.ListUtil;
-import thyyxxk.webserver.utils.ResultVoUtil;
-import thyyxxk.webserver.utils.StringUtil;
-import thyyxxk.webserver.utils.TokenUtil;
+import thyyxxk.webserver.utils.*;
 
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -37,122 +33,138 @@ public class MenZhengXiangMuServer {
         this.dao = dao;
     }
 
+
+    public ResultVo<List<MzChargeDetail>> kuaiSuChaZhao(String startTime, String endTime, String execDept) {
+        if (StringUtil.isBlank(startTime) || StringUtil.isBlank(endTime) || StringUtil.isBlank(execDept)) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请选择日期范围。");
+        }
+        log.info("快速查找:开始:{},结束:{},科室:{}", startTime, endTime, execDept);
+        return ResultVoUtil.success(dao.kuaiSuChaZhao(startTime, endTime, execDept));
+    }
+
+    // 0 - 未确认 1 - 确认 3 -  取消
     public ResultVo<MzChargeDetail> getMzPatient(String patientId, Integer xiangMuZhuangTai, String startTime, String endTime, String dept) {
         if (StringUtil.isBlank(patientId)) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "门诊号不能为空 <( ̄ ﹌  ̄)>  ");
         }
+        if (StringUtil.isBlank(startTime) || StringUtil.isBlank(endTime)) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请选择日期范围。");
+        }
         MzChargeDetail mz = dao.getMzPatient(patientId);
         log.info("查询门诊项目确认 门诊id:{},项目状态:{},开始时间:{},结束时间:{}", patientId, xiangMuZhuangTai, startTime, endTime);
         if (mz == null) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
         }
-        if (xiangMuZhuangTai.equals(0)) {
-            mz.setList(dao.getFeiYong(patientId, startTime, endTime));
-        } else {
-            mz.setList(dao.getYiQueRenFeiYong(patientId, startTime, endTime, dept));
-        }
+        mz.setList(dao.huoQuMenZhenQueRenShuJu(patientId, startTime, endTime, xiangMuZhuangTai));
         return ResultVoUtil.success(mz);
     }
 
-    public ResultVo<List<MzChargeDetail>> getFeiYongXinXi(Integer serialNo, String patientId, Integer times) {
-        if (StringUtil.isBlank(patientId) || serialNo == null || times == null) {
+    public ResultVo<List<MzChargeDetail>> getFeiYongXinXi(Integer realNo, String patientId, Integer times, Integer xiangMuZhuangTai) {
+        log.info("流水号:{},门诊号:{},次数:{} ", realNo, patientId, times);
+        if (realNo == null || StringUtil.isBlank(patientId) || times == null) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER);
         }
-        List<MzChargeDetail> feiYong = dao.getFeiYongXiangXi(serialNo, patientId, times);
-        List<MzChargeDetail> piPei = dao.piPiJingEr(serialNo);
-        Map<Integer, MzChargeDetail> map = piPei.stream().collect(Collectors.toMap(MzChargeDetail::getReqNo, Function.identity()));
-        feiYong.forEach(item -> {
-            if (map.containsKey(item.getReqNo())) {
-                item.setJe(map.get(item.getReqNo()).getJe());
-            }
-            item.setXiangMuZhuangTai(item.getConfirmFlag());
-        });
-        if (feiYong.isEmpty()) {
+        List<MzChargeDetail> feiYongXinXi = dao.feiYongXinXi(realNo, patientId, times, xiangMuZhuangTai);
+        //   父节点 根据  patient_id times receipt_no order_no charge_item_code
+        //   子节点 根据  patient_id times receipt_no order_no tc_no
+        if (ListUtil.isBlank(feiYongXinXi)) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
         }
-        return ResultVoUtil.success(feiYong);
+        return ResultVoUtil.success(tcTree(feiYongXinXi));
+    }
+
+    public List<MzChargeDetail> tcTree(List<MzChargeDetail> tempList) {
+        List<MzChargeDetail> resultList = new ArrayList<>();
+        Map<String, MzChargeDetail> treeMap = new HashMap<>(tempList.size());
+        for (MzChargeDetail item : tempList) {
+            String key = item.getPatientId() + item.getTimes() + item.getReceiptNo() + item.getOrderNo() + item.getChargeItemCode();
+            treeMap.put(key, item);
+            if (item.getBillItemCode().equals("TC") || BigUtils.dengYu(item.getUnitPrice(), 0) || item.getChargeItemCode().length() > 3) {
+                if (item.getChargeItemCode().length() > 3) {
+                    item.setChargeFee(item.getUnitPrice().multiply(item.getQuantity()).multiply(item.getDrugWin()));
+                } else {
+                    item.setChargeName(item.getTcName() + "(套餐)");
+                }
+                resultList.add(item);
+            }
+        }
+
+        for (MzChargeDetail item : tempList) {
+            String key = item.getPatientId() + item.getTimes() + item.getReceiptNo() + item.getOrderNo() + item.getTcNo();
+            MzChargeDetail template = treeMap.get(key);
+            if (template != null) {
+                if (template.getList() == null) {
+                    template.setList(new ArrayList<>());
+                }
+                template.setChargeFee(item.getUnitPrice().multiply(item.getQuantity()).multiply(item.getDrugWin()));
+                template.getList().add(item);
+            }
+        }
+        return resultList;
     }
 
 
-    public ResultVo<List<MzChargeDetail>> getMingXi(String patientId, Integer times, Integer reqNo) {
-        return ResultVoUtil.success(dao.getMingXi(patientId, times, reqNo));
+    public ResultVo<List<MzChargeDetail>> getMingXi(MzChargeDetail param) {
+        log.info("门诊信息:{}", JSON.toJSONString(param));
+        List<MzChargeDetail> list = new ArrayList<>();
+        if (param.getReqNo() > 0) {
+            list.addAll(dao.getMingXi(param.getPatientId(), param.getTimes(), param.getReqNo()));
+        }
+        return ResultVoUtil.success(list);
     }
 
     /**
      * -- 0 不操作 1 确认 3 取消
      *
-     * @param mzChargeDetail 需要执行的数据
+     * @param mz 需要执行的数据
      * @return 返回提示
      */
     @Transactional(rollbackFor = Exception.class)
-    public ResultVo<String> menZhenXiangMuQueXiaoHuoQueRen(MzChargeDetail mzChargeDetail) {
-        if (ListUtil.notBlank(mzChargeDetail.getList()) && mzChargeDetail.getList().size() > 100) {
+    public ResultVo<String> menZhenXiangMuQueXiaoHuoQueRen(MzChargeDetail mz) {
+        if (ListUtil.notBlank(mz.getList()) && mz.getList().size() > 100) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "一次性操作不能大于 100 条,且不能为空。");
         }
-        List<MzChargeDetail> mz = new ArrayList<>();
-        MzChargeDetail mzcd = new MzChargeDetail();
-        Map<Integer, String> cuoWuXinXi = new HashMap<>();
-        String confirmId = mzChargeDetail.getConfirmId() == null ? TokenUtil.getTokenUserId() : mzChargeDetail.getConfirmId();
-        for (MzChargeDetail item : mzChargeDetail.getList()) {
-            if (item.getConfirmFlag() != 0) {
-                if (mzChargeDetail.getSource().equals("接口")) {
-                    if (item.getReqNo() <= 0) {
-                        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "申请号必须大于 0 且非空");
-                    }
-                }
-                mzcd.setPatientId(item.getPatientId());
-                mzcd.setTimes(item.getTimes());
-                if (mzcd.getReqNos() == null) {
-                    mzcd.setReqNos(new ArrayList<>());
+        Map<String, MzChargeDetail> map = dao.feiYongXinXi(mz.getRealNo(), mz.getPatientId(), mz.getTimes(), null).stream().collect(
+                Collectors.toMap(item -> item.getPatientId() + item.getTimes() + item.getReceiptNo() + item.getOrderNo() + item.getItemNo() +
+                                item.getChargeItemCode(),
+                        a -> a, (k1, k2) -> k1
+                ));
+        log.info("map:{}", JSON.toJSONString(map));
+        List<MzChargeDetail> xuYaoBaoCunDeShuJu = new ArrayList<>();
+        for (MzChargeDetail item : mz.getList()) {
+            String key = item.getPatientId() + item.getTimes() + item.getReceiptNo() + item.getOrderNo() + item.getItemNo() +
+                    item.getChargeItemCode();
+            log.info("父节点:{}", key);
+            MzChargeDetail mzChargeDetail = map.get(key);
+            if (mzChargeDetail != null) {
+                if (!item.getConfirmFlag().equals(mzChargeDetail.getConfirmFlag()) && item.getConfirmFlag() != 0) {
+                    xuYaoBaoCunDeShuJu.add(item);
                 }
-                mzcd.getReqNos().add(item.getReqNo());
-            }
-        }
-        if (ListUtil.isBlank(mzcd.getReqNos())) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请选择需要操作的数据。");
-        }
-        Map<String, List<MzChargeDetail>> buYaoChongFuChaoZuo = dao.genJuShenQingHuoQuMingXi(mzcd.getPatientId(), mzcd.getTimes(), mzcd.getReqNos()).stream()
-                .collect(Collectors.groupingBy(item -> item.getPatientId() + "_" + item.getTimes() + "_" + item.getReceiptNo() + "_" + item.getOrderNo() + "_"
-                        + item.getItemNo() + "_" + item.getChargeItemCode() + "_" + item.getReqNo()));
-
-        log.info("huoqu :{}", JSON.toJSONString(buYaoChongFuChaoZuo));
-
-        if (buYaoChongFuChaoZuo.isEmpty()) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有查询到对应的申请号信息");
-        }
-        // 这个是 判断操作的是 已确认的 还是未确认的
-        mzChargeDetail.getList().forEach(item -> {
-            String key = item.getPatientId().trim() + "_" + item.getTimes() + "_" + item.getReceiptNo() + "_" + item.getOrderNo() + "_"
-                    + item.getItemNo() + "_" + item.getChargeCode() + "_" + item.getReqNo();
-            log.info("key:{}", key);
-            // 不能改成为确认
-            if (buYaoChongFuChaoZuo.containsKey(key)) {
-                for (MzChargeDetail chargeDetail : buYaoChongFuChaoZuo.get(key)) {
-                    // 这里判断不要重复操作
-                    if (!chargeDetail.getConfirmFlag().equals(item.getConfirmFlag())) {
-                        if (item.getConfirmFlag() == 1 || item.getConfirmFlag() == 3) {
-                            chargeDetail.setConfirmFlag(item.getConfirmFlag());
-                            mz.add(chargeDetail);
+                if (item.getList() != null) {
+                    for (MzChargeDetail chargeDetail : item.getList()) {
+                        chargeDetail.setConfirmFlag(item.getConfirmFlag());
+                        String templateKey = chargeDetail.getPatientId() + chargeDetail.getTimes() + chargeDetail.getReceiptNo() + chargeDetail.getOrderNo()
+                                + chargeDetail.getItemNo() + chargeDetail.getChargeItemCode();
+                        log.info("子节点:{}", templateKey);
+                        MzChargeDetail template = map.get(templateKey);
+                        if (template != null) {
+                            if (!chargeDetail.getConfirmFlag().equals(mzChargeDetail.getConfirmFlag()) && chargeDetail.getConfirmFlag() != 0) {
+                                xuYaoBaoCunDeShuJu.add(chargeDetail);
+                            }
                         }
-                    } else if (item.getConfirmFlag() != 0 && mzChargeDetail.getSource().equals("接口")) {
-                        cuoWuXinXi.put(item.getReqNo(), String.format("申请号为:【%s】,请勿重复操作。", key));
                     }
+                    item.setList(null);
                 }
-            } else if (item.getConfirmFlag() != 0) {
-                cuoWuXinXi.put(item.getReqNo(), String.format("申请号为:【%s】,在数据库中没有查询到对应信息。", key));
             }
-        });
-        if (mz.isEmpty()) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请勿重复操作。");
-        } else {
-            log.info("门诊项目确认或取消 操作人:{},数据:{}", confirmId, JSON.toJSONString(mz));
-            dao.xiangMuQueRenHuoQuXiao(mz, confirmId, mzChargeDetail.getExecDept());
-            dao.xiangMuQueRenYjReq(mz, confirmId, mzChargeDetail.getExecDept());
         }
-        if (!cuoWuXinXi.isEmpty()) {
-            return ResultVoUtil.success(ExceptionEnum.LOGICAL_ERROR, cuoWuXinXi.toString());
+        if (ListUtil.notBlank(xuYaoBaoCunDeShuJu)) {
+            dao.xiangMuQueRenHuoQuXiao(xuYaoBaoCunDeShuJu, TokenUtil.getTokenUserId(), mz.getExecDept());
+            dao.xiangMuQueRenYjReq(xuYaoBaoCunDeShuJu, TokenUtil.getTokenUserId(), mz.getExecDept());
+            log.info("需要保存的数据:{}", JSON.toJSONString(xuYaoBaoCunDeShuJu));
+            return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "操作成功 L('ω')┘三└('ω')」");
         }
-        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "操作成功 L('ω')┘三└('ω')」");
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请选择需要操作的数据");
+
     }
 
 }