瀏覽代碼

追溯码

yeguodong 3 周之前
父節點
當前提交
de6bfcf623

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

@@ -11,9 +11,9 @@ import java.util.Map;
 
 public interface SelinfoSoldMapper extends BaseMapper<SelinfoSold> {
 
-    @Insert("insert into selinfo_sold_drugtrac(id,selinfo_sold_id,trac_codg)" +
-            " values(#{id,jdbcType=VARCHAR},#{selinfoSoldId,jdbcType=VARCHAR},#{tracCodg,jdbcType=VARCHAR})")
-    int insertSelinfoSoldDrugtrac(String id, String selinfoSoldId,  String tracCodg);
+    @Insert("insert into selinfo_sold_drugtrac(id,selinfo_sold_id,trac_codg,success_flag)" +
+            " values(#{id,jdbcType=VARCHAR},#{selinfoSoldId,jdbcType=VARCHAR},#{tracCodg,jdbcType=VARCHAR},,#{successFlag,jdbcType=VARCHAR})")
+    int insertSelinfoSoldDrugtrac(String id, String selinfoSoldId, String tracCodg, String successFlag);
 
     @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);

+ 26 - 6
src/main/java/cn/hnthyy/thmz/service/yb/YbService.java

@@ -1,9 +1,11 @@
 package cn.hnthyy.thmz.service.yb;
 
 import cn.hnthyy.thmz.Utils.HttpUtil;
+import cn.hnthyy.thmz.entity.his.zy.ZyActpatient;
 import cn.hnthyy.thmz.entity.jy.ResultVo;
 import cn.hnthyy.thmz.entity.yb.*;
 import cn.hnthyy.thmz.mapper.his.yb.SelinfoSoldMapper;
+import cn.hnthyy.thmz.mapper.his.zy.ZyActpatientMapper;
 import cn.hnthyy.thmz.service.taobao.TaobaoService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -31,6 +33,9 @@ public class YbService {
     @Autowired
     private SelinfoSoldMapper selinfoSoldMapper;
 
+    @Autowired
+    private ZyActpatientMapper zyActpatientMapper;
+
     /**
      * 医保商品销售接口
      * 功能说明:将发药信息上报给医保系统,实现医保结算
@@ -98,7 +103,7 @@ public class YbService {
         int randomNumber = new Random().nextInt(90) + 10;
         String rtalDocno = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
         if("1".equals(selInfo.getMdtrtSetlType())) {
-            selInfo.setMdtrtSn("MDTRT_ID");
+            selInfo.setMdtrtSn(zyActpatientMapper.selectMdtrtId(selInfo.getPatientId(), selInfo.getTimes()));
         } else {
             selInfo.setMdtrtSn(rtalDocno + randomNumber);
         }
@@ -120,11 +125,6 @@ public class YbService {
             selinfoSoldMapper.insert(selInfo);
         }
 
-        for(DrugTracCodg codg : drugTracCodgList) {
-            String itemId = UUID.randomUUID().toString().replaceAll("-", "");
-            selinfoSoldMapper.insertSelinfoSoldDrugtrac(itemId, id, codg.getDrugTracCodg());
-        }
-
         selInfo.setPsnName(UriEncoder.encode(selInfo.getPsnName()));
         selInfo.setPrscDrName(UriEncoder.encode(selInfo.getPrscDrName()));
         selInfo.setPharName(UriEncoder.encode(selInfo.getPharName()));
@@ -152,6 +152,26 @@ public class YbService {
                 responseCode = ybResultJson.getInteger("code");
             }
             response = new ResultVo(responseCode, ybResultJson.getString("message"));
+            for(DrugTracCodg codg : drugTracCodgList) {
+                String itemId = UUID.randomUUID().toString().replaceAll("-", "");
+                String successFlag = "0";
+                Map<String, String> param = new HashMap<>();
+                param.put("med_list_codg", selInfo.getMedListCodg());
+                param.put("trac_codg", codg.getDrugTracCodg());
+                try {
+                    JSONObject selinfoResult = getGoodsItemByCode(param);
+                    JSONObject data = selinfoResult.getJSONObject("data");
+                    if(selinfoResult.getInteger("code") == 200) {
+                        JSONArray output = data.getJSONArray("output");
+                        if(output != null && !output.isEmpty()) {
+                            successFlag = "1";
+                        }
+                    }
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+                selinfoSoldMapper.insertSelinfoSoldDrugtrac(itemId, id, codg.getDrugTracCodg(), successFlag);
+            }
             
             // 记录医保接口调用结果
             // 通过关联键可以快速定位具体的发药记录,便于问题排查和审计