Selaa lähdekoodia

Merge branch 'master' into 'master'

新增退药追溯码回调使用,优化科室核算汇总报表统计

See merge request lighter/web-server!171
huangshuhua 2 kuukautta sitten
vanhempi
commit
7e7c20fb24

+ 23 - 0
src/main/java/thyyxxk/webserver/controller/medicine/YpCodgMatchController.java

@@ -73,4 +73,27 @@ public class YpCodgMatchController {
         return service.updateMzDrugCodgDataNew(list);
     }
 
+    /**
+     * @Description 查询病人退药追溯码信息
+     * @Author hsh
+     * @param vo 查询条件
+     * @return List 病人退药追溯码信息
+     * @Date 2025/9/8 0008 10:29
+     */
+    @PostMapping("/selectMzMatchCodgReturn")
+    public ResultVo<List<MzDrugTracCodg>> selectMzMatchCodgReturn(@RequestBody @Validated YpCodgVo vo){
+        return service.selectMzMatchCodgReturn(vo);
+    }
+
+    /**
+     * @Description 根据上次退药追溯码匹配并成为本次处方发药匹配的追溯码并保存
+     * @Author hsh
+     * @param list 匹配的追溯码list
+     * @return map
+     * @Date 2025/9/9 0009 10:35
+     */
+    @PostMapping("/updateMzDrugCodgTyFyData")
+    public ResultVo<Map<String, Object>> updateMzDrugCodgTyFyData(@RequestBody @Validated List<MzDrugTracCodg> list){
+        return service.updateMzDrugCodgTyFyData(list);
+    }
 }

+ 19 - 14
src/main/java/thyyxxk/webserver/dao/his/highreport/AllStatisticsDao.java

@@ -120,18 +120,20 @@ public interface AllStatisticsDao {
             "        z.code as ksid, " +
             "        max(d.parent_code) as flm, " +
             "        max(e.name) as flmc, " +
-            "        isnull(sum(round(convert(decimal(18,3),((convert(decimal(18,3),unit_price)) * (quantity * isnull(drug_win,1)))),2)),0) as totalCharge, " +
+            "        isnull(sum(round(convert(decimal(18,4),((convert(decimal(18,4),unit_price)) * (quantity * isnull(drug_win,1)))),2)),0) as totalCharge, " +
             "        max(d.name) as hsmc, " +
             "        c.audit_code as hsm " +
             "   from mz_charge_detail a(nolock) " +
-            "   join (select distinct patient_id,times,receipt_no, serial_no,receipt_sn from mz_receipt_serial " +
+            "   join (select distinct patient_id,times,receipt_no from mz_receipt_serial " +
             "         where charge_date >= #{startTime} " +
-            "           and charge_date <= #{endTime}) as b " +
+            "           and charge_date <= #{endTime} " +
+            "           and tf_flag != '1' " +
+            "           and receipt_no > 0 " +
+            "           and isnull(warn_code,'')!='' " +
+            "           and isnull(doctor_code,'')!='') as b " +
             "     on a.patient_id = b.patient_id " +
             "    and a.times = b.times " +
             "    and a.receipt_no = b.receipt_no " +
-            "    and a.real_no = b.receipt_sn " +
-            "    and a.serial_no = b.serial_no " +
             "   left join zd_charge_item c " +
             "     on case a.charge_bill_code " +
             "          when 'BILL10' then 'BILL01' " +
@@ -150,6 +152,8 @@ public interface AllStatisticsDao {
             "        end = z.code " +
             "  where a.bill_item_code <> 'TC' " +
             "    and a.exec_dept <> '0000000' " +
+            "    and a.pay_mark = '0' " +
+            "    and a.tf_flag != '1' " +
             "  group by z.name, z.code, c.audit_code")
     List<Map<String, Object>> selectInpatientDeptAccountingReportMzExecDept(
             @Param("startTime") String startTime, @Param("endTime") String endTime);
@@ -158,18 +162,20 @@ public interface AllStatisticsDao {
             "        z.code as ksid, " +
             "        max(d.parent_code) as flm, " +
             "        max(e.name) as flmc, " +
-            "        isnull(sum(round(convert(decimal(18,3),((convert(decimal(18,3),unit_price)) * (quantity * isnull(drug_win,1)))),2)),0) as totalCharge, " +
+            "        isnull(sum(round(convert(decimal(18,4),((convert(decimal(18,4),unit_price)) * (quantity * isnull(drug_win,1)))),2)),0) as totalCharge, " +
             "        max(d.name) as hsmc, " +
             "        c.audit_code as hsm " +
             "   from mz_charge_detail a(nolock) " +
-            "   join (select distinct patient_id,times,receipt_no, serial_no,receipt_sn from mz_receipt_serial " +
+            "   join (select distinct patient_id,times,receipt_no,warn_code from mz_receipt_serial " +
             "         where charge_date >= #{startTime} " +
-            "           and charge_date <= #{endTime}) as b " +
+            "           and charge_date <= #{endTime}" +
+            "           and tf_flag != '1' " +
+            "           and receipt_no > 0 " +
+            "           and isnull(warn_code,'')!='' " +
+            "           and isnull(doctor_code,'')!='') as b " +
             "     on a.patient_id = b.patient_id " +
             "    and a.times = b.times " +
             "    and a.receipt_no = b.receipt_no " +
-            "    and a.real_no = b.receipt_sn " +
-            "    and a.serial_no = b.serial_no " +
             "   left join zd_charge_item c " +
             "     on case a.charge_bill_code " +
             "          when 'BILL10' then 'BILL01' " +
@@ -182,12 +188,11 @@ public interface AllStatisticsDao {
             "   join zy_zd_audit_report e " +
             "     on d.parent_code = e.code " +
             "   left join zd_unit_code z " +
-            "     on case when isnull(a.warn_dept,'') = '' or a.warn_dept = 'null' " +
-            "             then a.exec_dept " +
-            "             else a.warn_dept " +
-            "        end = z.code " +
+            "     on b.warn_code = z.code " +
             "  where a.bill_item_code <> 'TC' " +
             "    and a.exec_dept <> '0000000' " +
+            "    and a.pay_mark = '0' " +
+            "    and a.tf_flag != '1' " +
             "  group by z.name, z.code, c.audit_code")
     List<Map<String, Object>> selectInpatientDeptAccountingReportMzWardDept(
             @Param("startTime") String startTime, @Param("endTime") String endTime);

+ 14 - 0
src/main/java/thyyxxk/webserver/dao/his/medicine/MzDrugTracCodgDao.java

@@ -48,4 +48,18 @@ public interface MzDrugTracCodgDao {
     void updateMzChargeDetailConfirmFlag(@Param("patNo") String patNo, @Param("times") Integer times,
                                         @Param("orderNo") Integer orderNo, @Param("groupNo") String groupNo);
 
+    @Select(" select ty.* from yp_mz_fytj as fy, mz_drug_trac_codg_ty as ty " +
+            " where fy.patient_id = #{patNo} and fy.times = #{times} " +
+            " and fy.patient_id = ty.patient_id " +
+            " and fy.charge_item_code = ty.charge_item_code " +
+            " and not exists (select 1 from mz_drug_trac_codg as tr where tr.drug_trac_codg = ty.drug_trac_codg) ")
+    List<MzDrugTracCodg> selectMzMatchCodgReturn(@Param("patNo") String patNo, @Param("times") Integer times);
+
+    @Delete("<script> " +
+            " delete from mz_drug_trac_codg_ty where drug_trac_codg in " +
+            " <foreach collection='list' item='item' open='(' separator=',' close=')'> " +
+            " #{item.drugTracCodg} " +
+            " </foreach> " +
+            " </script>")
+    void deleteMzDrugTracCodgTyBatchByCode(List<MzDrugTracCodg> list);
 }

+ 4 - 0
src/main/java/thyyxxk/webserver/dao/his/medicine/YpCodgMatchDao.java

@@ -26,8 +26,12 @@ public interface YpCodgMatchDao {
             " and mz.serial_no &gt; 0 " +
             " and isnull(mz.confirm_zs, '') &lt;&gt; '1' " +
             " and mz.group_no = #{vo.groupNo} " +
+            "<if test=\" vo.startTime != null and vo.startTime != '' \">" +
             " and mz.charge_date &gt;= #{vo.startTime} " +
+            "</if>" +
+            "<if test=\" vo.endTime != null and vo.endTime != '' \">" +
             " and mz.charge_date &lt;= #{vo.endTime} " +
+            "</if>" +
             "<if test=\" vo.patName != null and vo.patName != '' \">" +
             " and mz.name like ('%' + #{vo.patName} + '%') " +
             "</if>" +

+ 54 - 5
src/main/java/thyyxxk/webserver/service/medicine/YpCodgMatchService.java

@@ -87,6 +87,10 @@ public class YpCodgMatchService {
     public ResultVo<List<Map<String, Object>>> selectMzChargePrescription(YpCodgVo vo){
         // 查询血透室的科室编码(特殊需求: 血透室的发药是批量发的,不再这里显示)
         // String deptCode = matchDao.selectXtsDeptCode();
+        if(StringUtils.isNotEmpty(vo.getPatNo())){
+            vo.setStartTime(null);
+            vo.setEndTime(null);
+        }
         List<Map<String, Object>> cfList = matchDao.selectMzChargePrescription(vo);
         // 增加移动支付的医保信息收集
         for(Map<String, Object> map : cfList){
@@ -349,12 +353,15 @@ public class YpCodgMatchService {
             codg.setConfirmId(StringUtils.trim(us.getCode()));
             codg.setConfirmName(StringUtils.trim(us.getName()));
             codg.setConfirmTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
-            // 根据传票号和生产批号查询入库记录(2025.08.29 需要处理前后缀问题)
+            // 根据传票号和生产批号查询入库记录(2025.08.29 需要处理前后缀问题 09.09 优化取消前后缀影响匹配问题
             YpZdSupply supply = codgDao.selectSupplyTypeBySupplyCode(line.getDelventpUscc());
-            String cph = line.getDelvBchno().replaceAll(
-                    Convert.toStr(supply.getStartWith(), ""), "").replaceAll(
+            YpInDetlVo detlVo = inDao.selectYpInDetlListByNo(line.getDelvBchno(), line.getManuBchno());
+            if(null == detlVo){
+                String cph = line.getDelvBchno().replaceAll(
+                        Convert.toStr(supply.getStartWith(), ""), "").replaceAll(
                         Convert.toStr(supply.getEndWith(), ""), "");
-            YpInDetlVo detlVo = inDao.selectYpInDetlListByNo(cph, line.getManuBchno());
+                detlVo = inDao.selectYpInDetlListByNo(cph, line.getManuBchno());
+            }
             if(null == detlVo){
                 codg.setFlag("-1");
                 codg.setMatchFlag("-1");
@@ -364,7 +371,7 @@ public class YpCodgMatchService {
                 codg.setManuDate(line.getManuDate());
                 codg.setAbbrName(line.getProdentpName());
                 codg.setExpyEnd(line.getExpyEnd());
-                codg.setMatchMessage("未匹配到入库信息:扫码药品【" + line.getDrugProdname() + "】,请核对!");
+                codg.setMatchMessage("未匹配到入库信息:扫码药品【" + line.getDrugProdname() + "】, 生产批号【" + line.getManuBchno() + "】,请核对!");
             } else {
                 List<Map<String, Object>> l = m.get(StringUtils.trim(detlVo.getChargeCode()));
                 if(null != l && !l.isEmpty()){
@@ -631,4 +638,46 @@ public class YpCodgMatchService {
         return ResultVoUtil.success(resultMap);
     }
 
+    /**
+     * @Description 查询病人退药追溯码信息
+     * @Author hsh
+     * @param vo 查询条件
+     * @return List 病人退药追溯码信息
+     * @Date 2025/9/8 0008 11:01
+     */
+    public ResultVo<List<MzDrugTracCodg>> selectMzMatchCodgReturn(YpCodgVo vo){
+        return ResultVoUtil.success(mzDrugTracCodgDao.selectMzMatchCodgReturn(vo.getPatNo(), vo.getTimes()));
+    }
+
+    /**
+     * @Description 根据上次退药追溯码匹配并成为本次处方发药匹配的追溯码并保存
+     * @Author hsh
+     * @param list 匹配的追溯码list
+     * @return map
+     * @Date 2025/9/9 0009 10:40
+     */
+    public ResultVo<Map<String, Object>> updateMzDrugCodgTyFyData(List<MzDrugTracCodg> list){
+        if(null == list || list.isEmpty()){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "药品扫码的追溯码信息不存在,请检查!");
+        }
+        Map<String, Object> resultMap = new HashMap<>();
+        int c = 0;
+        List<List<MzDrugTracCodg>> rl = ListUtils.partition(list, 30);
+        for (List<MzDrugTracCodg> al : rl) {
+            // 删除退药追溯码记录
+            mzDrugTracCodgDao.deleteMzDrugTracCodgTyBatchByCode(al);
+            // 保存追溯码
+            c = c + mzDrugTracCodgDao.insertMzDrugTracCodgBatch(al);
+        }
+        if(c > 0){
+            resultMap.put("code", 0);
+            resultMap.put("message", "更新追溯码信息成功!");
+        } else {
+            resultMap.put("code", -1);
+            resultMap.put("message", "更新追溯码信息失败!");
+        }
+        resultMap.put("data", list);
+        return ResultVoUtil.success(resultMap);
+    }
+
 }

+ 7 - 7
src/main/java/thyyxxk/webserver/service/medicine/YpTracCodgService.java

@@ -160,7 +160,7 @@ public class YpTracCodgService {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, str.getMessage());
         }
         resultMap.put("sucMsg", str.getMessage());
-        resultMap.put("msg", "根据批次流水号【"  + dto.getFixmedinsBchno() + "】查询药品销售信息成功!");
+        resultMap.put("msg", "根据批次流水号【" + dto.getFixmedinsBchno() + "】或者医保就诊id【"  + dto.getMdtrtId() + "】查询药品销售信息成功!");
         resultMap.put("invinfoList", str.getData());
         return ResultVoUtil.success(resultMap);
     }
@@ -675,16 +675,16 @@ public class YpTracCodgService {
     }
 
     /**
-     * @Description 批量上传药品销售退货信息
+     * @Description 批量撤销药品销售或者销售退货信息
      * @Author hsh
-     * @param list 药品销售退货信息
+     * @param list 药品销售或者销售退货信息
      * @return map
      * @Date 2025/5/30 0030 9:23
      */
     public ResultVo<Map<String, Object>> uploadYpSelinfoReturnBatch(List<YpSelinfoSold> list) {
         Map<String, Object> resultMap = new HashMap<>();
         if(null == list || list.isEmpty()){
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有销售退货数量,请检查!");
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有批量撤销的药品销售或者销售退货数量,请检查!");
         }
         String type = list.get(0).getType();
         List<SelinfoReturn> selinfoS = new ArrayList<>();
@@ -697,7 +697,7 @@ public class YpTracCodgService {
         }
         ResultVo<JSONObject> str = sv.returnSales(selinfoS);
         if(YpDictConstant.ERROR_STATUS == str.getCode()){
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "批量上传药品销售退货信息失败:" + str.getMessage());
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "批量撤销药品销售或者销售退货信息失败:" + str.getMessage());
         }
         JSONObject result = str.getData();
         JSONObject output = result.getJSONObject("output");
@@ -705,7 +705,7 @@ public class YpTracCodgService {
         if(null != errDetail){
             List<Map> errList = errDetail.toJavaList(Map.class);
             String msg = String.valueOf(errList.get(0).get("msgRslt"));
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "批量上传药品销售退货信息失败:" + msg);
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "批量撤销药品销售或者销售退货信息失败:" + msg);
         }
         for(YpSelinfoSold in : list){
             in.setUploadFlag("-2");
@@ -713,7 +713,7 @@ public class YpTracCodgService {
             in.setCreateTime(DateUtil.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
         }
         soldService.updateYpSelinfoSoldBatch(list);
-        resultMap.put("msg", "批量上传药品销售退货信息全部成功!");
+        resultMap.put("msg", "批量撤销药品销售或者销售退货信息成功!");
         return ResultVoUtil.success(resultMap);
     }