yeguodong 3 周之前
父節點
當前提交
332337a62c

+ 6 - 0
pom.xml

@@ -250,6 +250,12 @@
             <version>3.2.4</version>
         </dependency>
         <!--丁捷的查询检验报告的代码需要的jar-->
+
+        <dependency>
+            <groupId>org.yaml</groupId>
+            <artifactId>snakeyaml</artifactId>
+            <version>1.33</version> <!-- 版本号可根据需要选择,最新稳定版可查询 Maven 中央仓库 -->
+        </dependency>
     </dependencies>
 
     <dependencyManagement>

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

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
+import java.util.Map;
 
 public interface SelinfoSoldMapper extends BaseMapper<SelinfoSold> {
 
@@ -16,4 +17,7 @@ public interface SelinfoSoldMapper extends BaseMapper<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);
+
+    @Select("select * from selinfo_sold_drugtrac where selinfo_sold_id=#{selinfoSoldId}")
+    List<Map<String, String>> getSelinfoSoldDrugtracById(String selinfoSoldId);
 }

+ 38 - 20
src/main/java/cn/hnthyy/thmz/service/yb/YbService.java

@@ -13,6 +13,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.yaml.snakeyaml.util.UriEncoder;
 
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -104,6 +105,10 @@ public class YbService {
         selInfo.setRtalDocno(rtalDocno + randomNumber);
         selInfo.setFixmedinsBchno(rtalDocno + randomNumber);
         selInfo.setSelRetnCnt(drugTracCodgList.size());
+        selInfo.setPsnName(UriEncoder.encode(selInfo.getPsnName()));
+        selInfo.setPrscDrName(UriEncoder.encode(selInfo.getPrscDrName()));
+        selInfo.setPharName(UriEncoder.encode(selInfo.getPharName()));
+        selInfo.setSelRetnOpterName(UriEncoder.encode(selInfo.getSelRetnOpterName()));
         String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
         selInfo.setSelRetnTime(now);
 
@@ -257,6 +262,7 @@ public class YbService {
         selinfoReturn.setManuDate(selinfoSold.getManuDate());
         selinfoReturn.setRxFlag(selinfoSold.getRxFlag());
         selinfoReturn.setTrdnFlag(selinfoSold.getTrdnFlag());
+        selinfoReturn.setSelRetnOpterName(UriEncoder.encode(selinfoReturn.getSelRetnOpterName()));
 
         String realUrl = siInventoryServiceUrl + "/returnGoodsItem";
         try {
@@ -295,31 +301,43 @@ public class YbService {
             return response;
         }
 
+        List<Object> datas = new ArrayList<>();
         SelinfoSold sold = selinfoSoldList.get(0);
-        Map<String, String> param = new HashMap<>();
-        param.put("med_list_codg", sold.getMedListCodg());
-
+        List<Map<String, String>> selinfoSoldDrugtracById = selinfoSoldMapper.getSelinfoSoldDrugtracById(sold.getId());
         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"));
+        for(Map<String, String> map : selinfoSoldDrugtracById) {
+            Map<String, String> param = new HashMap<>();
+            param.put("med_list_codg", sold.getMedListCodg());
 
-            // 记录医保接口调用结果
-            // 通过关联键可以快速定位具体的退药记录,便于问题排查和审计
-            log.info("医保退药接口调用结果 - 结果: {}", response);
+            param.put("drug_trac_codg", map.get("trac_codg"));
 
-        } catch (Exception e) {
-            e.printStackTrace();
-            response = new ResultVo(-1, "商品销售查询失败");
-            // 记录错误信息时包含关联键,便于快速定位问题
-            log.error("医保退药接口调用失败 - 错误: {}", e.getMessage());
+
+            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"), ybResultJson.get("data"));
+                JSONObject data = ybResultJson.getJSONObject("data");
+                JSONArray output = data.getJSONArray("output");
+                if(output != null && !output.isEmpty()) {
+                    datas.add(output.get(0));
+                }
+                // 记录医保接口调用结果
+                // 通过关联键可以快速定位具体的退药记录,便于问题排查和审计
+                log.info("医保退药接口调用结果 - 结果: {}", response);
+
+            } catch (Exception e) {
+                e.printStackTrace();
+                response = new ResultVo(-1, "商品销售查询失败");
+                // 记录错误信息时包含关联键,便于快速定位问题
+                log.error("医保退药接口调用失败 - 错误: {}", e.getMessage());
+            }
         }
+        response = new ResultVo(0, "查询成功", datas);
 
         return response;
     }