Sfoglia il codice sorgente

Merge branch 'master' into 'master'

新增门诊发药增加变更追溯码功能

See merge request lighter/web-server!168
huangshuhua 1 mese fa
parent
commit
e04695215b

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

@@ -61,4 +61,16 @@ public class YpCodgMatchController {
         return service.selectMzDrugTracCodgData(vo);
     }
 
+    /**
+     * @Description 变更门诊病人追溯码信息
+     * @Author hsh
+     * @param list 门诊病人追溯码信息
+     * @return map
+     * @Date 2025/8/22 0022 14:44
+     */
+    @PostMapping("/updateMzDrugCodgDataNew")
+    public ResultVo<Map<String, Object>> updateMzDrugCodgDataNew(@RequestBody @Validated List<MzDrugTracCodg> list){
+        return service.updateMzDrugCodgDataNew(list);
+    }
+
 }

+ 3 - 0
src/main/java/thyyxxk/webserver/dao/his/medicine/YpSelinfoSoldDao.java

@@ -103,4 +103,7 @@ public interface YpSelinfoSoldDao extends BaseMapper<YpSelinfoSold> {
             "</script>")
     List<YpSelinfoSold> selectYpSelinfoSoldTkResult(@Param("dto") YpCodgUpload dto);
 
+    @Select(" select * from yp_selinfo_sold where pat_no = #{patNo} and times = #{times} and upload_flag = '1' ")
+    List<YpSelinfoSold> selectYpSelinfoSoldByCode(@Param("patNo") String patNo, @Param("times") Integer times);
+
 }

+ 65 - 1
src/main/java/thyyxxk/webserver/service/medicine/YpCodgMatchService.java

@@ -13,6 +13,7 @@ import thyyxxk.webserver.dao.his.medicine.MzDrugTracCodgDao;
 import thyyxxk.webserver.dao.his.medicine.YpCodgLineDao;
 import thyyxxk.webserver.dao.his.medicine.YpCodgMatchDao;
 import thyyxxk.webserver.dao.his.medicine.YpInDetlDao;
+import thyyxxk.webserver.dao.his.medicine.YpSelinfoSoldDao;
 import thyyxxk.webserver.dao.his.medicine.YpTracCodgDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.login.UserInfo;
@@ -58,7 +59,11 @@ public class YpCodgMatchService {
 
     private final YpTracCodgDao codgDao;
 
-    public YpCodgMatchService(YpCodgMatchDao matchDao, YpCodgLineDao lineDao, YpTaoBaoService taoBaoService, YpInDetlDao inDao, MzDrugTracCodgDao mzDrugTracCodgDao, UserCache userCache, YpTracCodgDao codgDao) {
+    private final YpSelinfoSoldDao soldDao;
+
+    public YpCodgMatchService(YpCodgMatchDao matchDao, YpCodgLineDao lineDao, YpTaoBaoService taoBaoService,
+                              YpInDetlDao inDao, MzDrugTracCodgDao mzDrugTracCodgDao, UserCache userCache,
+                              YpTracCodgDao codgDao, YpSelinfoSoldDao soldDao) {
         this.matchDao = matchDao;
         this.lineDao = lineDao;
         this.taoBaoService = taoBaoService;
@@ -66,6 +71,7 @@ public class YpCodgMatchService {
         this.mzDrugTracCodgDao = mzDrugTracCodgDao;
         this.userCache = userCache;
         this.codgDao = codgDao;
+        this.soldDao = soldDao;
     }
 
     /**
@@ -529,4 +535,62 @@ public class YpCodgMatchService {
         return ResultVoUtil.success(map);
     }
 
+    /**
+     * @Description 变更门诊病人追溯码信息
+     * @Author hsh
+     * @param list 门诊病人追溯码信息
+     * @return map
+     * @Date 2025/8/22 0022 14:45
+     */
+    public ResultVo<Map<String, Object>> updateMzDrugCodgDataNew(List<MzDrugTracCodg> list){
+        Map<String, Object> resultMap = new HashMap<>();
+        if(null == list || list.isEmpty()){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "药品扫码的追溯码信息不存在,请检查!");
+        }
+        String patNo = list.get(0).getPatientId();
+        Integer times = list.get(0).getTimes();
+        Integer orderNo = list.get(0).getOrderNo();
+        String groupNo = list.get(0).getGroupNo();
+        if(StringUtils.isBlank(patNo)){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "病人门诊号信息不存在,请检查!");
+        }
+        if(null == times){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "病人门诊次数信息不存在,请检查!");
+        }
+        if(null == orderNo){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "病人门诊处方号信息不存在,请检查!");
+        }
+        if(StringUtils.isBlank(groupNo)){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "病人药房信息不存在,请检查!");
+        }
+        List<MzDrugTracCodg> mzCodgList = mzDrugTracCodgDao.selectMzDrugTracCodgByCode(list.get(0));
+        int c = 0;
+        if(null == mzCodgList || mzCodgList.isEmpty()){
+            List<List<MzDrugTracCodg>> rl = ListUtils.partition(list, 30);
+            for (List<MzDrugTracCodg> al : rl) {
+                c = c + mzDrugTracCodgDao.insertMzDrugTracCodgBatch(al);
+            }
+        } else {
+            // 查询看是否有存在已经上传追溯码情况
+            List<YpSelinfoSold> soldList = soldDao.selectYpSelinfoSoldByCode(patNo, times);
+            if(null != soldList && !soldList.isEmpty()){
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "存在已经上传的追溯码,请核对并取消上传再更新!");
+            }
+            mzDrugTracCodgDao.deleteMzDrugTracCodgByCode(list.get(0));
+            List<List<MzDrugTracCodg>> rl = ListUtils.partition(list, 30);
+            for (List<MzDrugTracCodg> al : rl) {
+                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);
+    }
+
 }