yeguodong 2 周之前
父節點
當前提交
36815a688a

+ 5 - 0
src/main/java/cn/hnthyy/thmz/controller/yb/YbController.java

@@ -31,4 +31,9 @@ public class YbController {
         return ybService.returnGoodsItem(selinfoReturn);
     }
 
+    @RequestMapping(value = "/getGoods", method = {RequestMethod.POST})
+    public ResultVo getGoods(@RequestBody SelinfoSold selinfoSold) {
+        return ybService.getGoods(selinfoSold);
+    }
+
 }

+ 4 - 0
src/main/java/cn/hnthyy/thmz/entity/yb/SelinfoSelect.java

@@ -0,0 +1,4 @@
+package cn.hnthyy.thmz.entity.yb;
+
+public class SelinfoSelect {
+}

+ 2 - 2
src/main/java/cn/hnthyy/thmz/mapper/his/yb/SelinfoSoldMapper.java

@@ -14,6 +14,6 @@ public interface SelinfoSoldMapper extends BaseMapper<SelinfoSold> {
             " values(#{id,jdbcType=VARCHAR},#{selinfoSoldId,jdbcType=VARCHAR},#{tracCodg,jdbcType=VARCHAR})")
     int insertSelinfoSoldDrugtrac(String id, String selinfoSoldId,  String tracCodg);
 
-    @Select("select * from selinfo_sold_drugtrac where patientId=#{selinfoSold.patientId}")
-    List<SelinfoSold> getSelinfoSoldList(SelinfoSold selinfoSold);
+    @Select("select * from selinfo_sold where patient_id=#{patientId} and times=#{times} and order_no=#{orderNo} and charge_item_code=#{chargeItemCode} and real_no=#{realNo}")
+    List<SelinfoSold> getSelinfoSoldList(String patientId, Integer times, Integer orderNo, String chargeItemCode, Integer realNo);
 }

+ 62 - 2
src/main/java/cn/hnthyy/thmz/service/yb/YbService.java

@@ -190,6 +190,10 @@ public class YbService {
     public ResultVo returnGoodsItem(SelinfoReturn selinfoReturn) {
         ResultVo response = null;
         List<DrugTracCodg> drugTracCodgList = selinfoReturn.getDrugtracinfo();
+        if(drugTracCodgList == null || drugTracCodgList.size() == 0) {
+            response = new ResultVo(-1, "追溯码不能为空");
+            return response;
+        }
         
         // 记录关联字段信息(用于关联退药记录)
         // 这些字段用于后续查询退药记录,确保医保记录与退药记录的一一对应
@@ -231,11 +235,27 @@ public class YbService {
         } else {
             log.warn("退药操作没有追溯码信息,继续处理");
         }*/
-        
+
+        List<SelinfoSold> selinfoSoldList =
+                selinfoSoldMapper.getSelinfoSoldList(selinfoReturn.getPatientId(), selinfoReturn.getTimes(),
+                        selinfoReturn.getOrderNo(), selinfoReturn.getChargeItemCode(), selinfoReturn.getRealNo());
+        if(selinfoSoldList == null || selinfoSoldList.size() == 0) {
+            response = new ResultVo(-1, "关联追溯码上传失败");
+            return response;
+        }
+
+        SelinfoSold selinfoSold = selinfoSoldList.get(0);
+
         selinfoReturn.setSelRetnCnt(drugTracCodgList != null ? drugTracCodgList.size() : 0);
         String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+        selinfoReturn.setMedListCodg(selinfoSold.getMedListCodg());
         selinfoReturn.setSelRetnTime(now);
-        selinfoReturn.setMdtrtSn("MDTRT_ID");
+        selinfoReturn.setMdtrtSn(selinfoSold.getMdtrtSn());
+        selinfoReturn.setFixmedinsBchno(selinfoSold.getFixmedinsBchno());
+        selinfoReturn.setManuLotnum(selinfoSold.getManuLotnum());
+        selinfoReturn.setManuDate(selinfoSold.getManuDate());
+        selinfoReturn.setRxFlag(selinfoSold.getRxFlag());
+        selinfoReturn.setTrdnFlag(selinfoSold.getTrdnFlag());
 
         String realUrl = siInventoryServiceUrl + "/returnGoodsItem";
         try {
@@ -263,4 +283,44 @@ public class YbService {
 
     }
 
+    public ResultVo getGoods(SelinfoSold selinfoSold) {
+        ResultVo response = null;
+
+        List<SelinfoSold> selinfoSoldList =
+                selinfoSoldMapper.getSelinfoSoldList(selinfoSold.getPatientId(), selinfoSold.getTimes(),
+                        selinfoSold.getOrderNo(), selinfoSold.getChargeItemCode(), selinfoSold.getRealNo());
+        if(selinfoSoldList == null || selinfoSoldList.size() == 0) {
+            response = new ResultVo(-1, "关联追溯码上传失败");
+            return response;
+        }
+
+        SelinfoSold sold = selinfoSoldList.get(0);
+        Map<String, String> param = new HashMap<>();
+        param.put("med_list_codg", sold.getMedListCodg());
+
+        String realUrl = siInventoryServiceUrl + "/selectSalesGoodsItem";
+        try {
+            String jsonString = JSONObject.toJSONString(param, SerializerFeature.WriteNonStringKeyAsString);
+            String ybResult = HttpUtil.sendHttpPost(realUrl, jsonString, 8000);
+            JSONObject ybResultJson = JSONObject.parseObject(ybResult);
+            int responseCode = 0;
+            if(ybResultJson.getInteger("code") != 200) {
+                responseCode = ybResultJson.getInteger("code");
+            }
+            response = new ResultVo(responseCode, ybResultJson.getString("message"));
+
+            // 记录医保接口调用结果
+            // 通过关联键可以快速定位具体的退药记录,便于问题排查和审计
+            log.info("医保退药接口调用结果 - 结果: {}", response);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            response = new ResultVo(-1, "商品销售查询失败");
+            // 记录错误信息时包含关联键,便于快速定位问题
+            log.error("医保退药接口调用失败 - 错误: {}", e.getMessage());
+        }
+
+        return response;
+    }
+
 }

+ 1 - 1
src/main/resources/application-mhyy.yml

@@ -149,7 +149,7 @@ wxPayOrderServiceUrl: "http://130.150.161.72:8706"
 #特殊门诊生产地址
 tsmzServiceUrl: "http://130.150.161.72:8706/markMtFees"
 
-siInventoryServiceUrl: "http://localhost:8706/siInventory"
+siInventoryServiceUrl: "http://130.150.161.72:8706/siInventory"
 #流行病调查问卷生产地址
 lxbdcwjUrl: "http://tbd"