Explorar o código

追溯码上传

yeguodong hai 2 meses
pai
achega
dab086570e

+ 41 - 20
src/main/java/cn/hnthyy/thmz/controller/taobao/TaobaoController.java

@@ -2,10 +2,12 @@ package cn.hnthyy.thmz.controller.taobao;
 
 import cn.hnthyy.thmz.Utils.HttpUtil;
 import cn.hnthyy.thmz.comment.UserLoginToken;
+import cn.hnthyy.thmz.service.taobao.TaobaoService;
 import cn.hnthyy.thmz.vo.MzPrescriptionVo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.json.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
@@ -19,32 +21,51 @@ import java.util.Map;
 @RequestMapping("/Taobao")
 public class TaobaoController {
 
-    private String url = "http://130.150.161.113:7001/pay/ypTaobao/";
+    @Autowired
+    private TaobaoService taobaoService;
 
     @RequestMapping(value = "/getCodeByParent", method = {RequestMethod.GET})
     public ResponseEntity<String> getCodeByParent(@RequestParam String parentCode) {
+        String result = taobaoService.sendGet("/getCodeByParent?parentCode=" + parentCode);
+        if (StringUtils.isBlank(result)) {
+            return ResponseEntity.noContent().build();
+        }
+
+        // 将外部系统返回的 code 从 200 改为 0,以符合前端 request 函数的期望
         try {
-            String result = HttpUtil.sendHttpGet(url + "/getCodeByParent?parentCode=" + parentCode, "utf-8", 40000);
-            if (StringUtils.isBlank(result)) {
-                return ResponseEntity.noContent().build();
+            JSONObject jsonObject = new JSONObject(result);
+            if (jsonObject.has("code") && jsonObject.getInt("code") == 200) {
+                jsonObject.put("code", 0);
+                result = jsonObject.toString();
             }
-            
-            // 将外部系统返回的 code 从 200 改为 0,以符合前端 request 函数的期望
-            try {
-                JSONObject jsonObject = new JSONObject(result);
-                if (jsonObject.has("code") && jsonObject.getInt("code") == 200) {
-                    jsonObject.put("code", 0);
-                    result = jsonObject.toString();
-                }
-            } catch (Exception e) {
-                log.warn("解析外部系统响应JSON失败,使用原始响应: {}", e.getMessage());
+        } catch (Exception e) {
+            log.warn("解析外部系统响应JSON失败,使用原始响应: {}", e.getMessage());
+        }
+
+        return ResponseEntity.ok()
+                .contentType(MediaType.APPLICATION_JSON)
+                .body(result);
+    }
+
+    @RequestMapping(value = "/queryCodeDetail", method = {RequestMethod.GET})
+    public ResponseEntity<String> queryCodeDetail(@RequestParam String codes) {
+        String result = taobaoService.sendGet("/queryCodeDetail?codes=" + codes);
+        if (StringUtils.isBlank(result)) {
+            return ResponseEntity.noContent().build();
+        }
+        // 将外部系统返回的 code 从 200 改为 0,以符合前端 request 函数的期望
+        try {
+            JSONObject jsonObject = new JSONObject(result);
+            if (jsonObject.has("code") && jsonObject.getInt("code") == 200) {
+                jsonObject.put("code", 0);
+                result = jsonObject.toString();
             }
-            
-            return ResponseEntity.ok()
-                    .contentType(MediaType.APPLICATION_JSON)
-                    .body(result);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
+        } catch (Exception e) {
+            log.warn("解析外部系统响应JSON失败,使用原始响应: {}", e.getMessage());
         }
+
+        return ResponseEntity.ok()
+                .contentType(MediaType.APPLICATION_JSON)
+                .body(result);
     }
 }

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

@@ -0,0 +1,28 @@
+package cn.hnthyy.thmz.controller.yb;
+
+import cn.hnthyy.thmz.comment.UserLoginToken;
+import cn.hnthyy.thmz.entity.jy.ResultVo;
+import cn.hnthyy.thmz.entity.yb.SelinfoSold;
+import cn.hnthyy.thmz.service.yb.YbService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@RestController
+@RequestMapping("/Yb")
+public class YbController {
+
+    @Autowired
+    private YbService ybService;
+
+    @UserLoginToken
+    @RequestMapping(value = "/saleGoodsItem", method = {RequestMethod.POST})
+    public ResultVo saleGoodsItem(@RequestBody SelinfoSold selInfo) {
+        return ybService.saleGoodsItem(selInfo);
+    }
+
+}

+ 13 - 0
src/main/java/cn/hnthyy/thmz/entity/yb/DrugTracCodg.java

@@ -0,0 +1,13 @@
+package cn.hnthyy.thmz.entity.yb;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+
+@Data
+public class DrugTracCodg {
+
+    @JSONField(name = "drug_trac_codg")
+    private String drugTracCodg;
+
+
+}

+ 163 - 0
src/main/java/cn/hnthyy/thmz/entity/yb/SelinfoReturn.java

@@ -0,0 +1,163 @@
+package cn.hnthyy.thmz.entity.yb;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class SelinfoReturn {
+    /**
+     * 医疗目录编码(如果没有就填默认值NMLC999)
+     * */
+    @JSONField(name = "med_list_codg")
+    private String medListCodg;
+
+    
+    /**
+     * 定点医药机构目录编号
+     * */
+    @JSONField(name = "fixmedins_hilist_id")
+    private String fixmedinsHilistId;
+
+    
+    /**
+     * 定点医药机构目录名称
+     * */
+    @JSONField(name = "fixmedins_hilist_name")
+    private String fixmedinsHilistName;
+
+    
+    /**
+     * 定点医药机构批次流水号
+     * */
+    @JSONField(name = "fixmedins_bchno")
+    private String fixmedinsBchno;
+
+    
+    /**
+     * 结算ID
+     * */
+    @JSONField(name = "setl_id")
+    private String setlId;
+
+    
+    /**
+     * 人员编号
+     * */
+    @JSONField(name = "psn_no")
+    private String psnNo;
+
+    
+    /**
+     * 人员证件类型
+     * */
+    @JSONField(name = "psn_cert_type")
+    private String psnCertType;
+
+    
+    /**
+     * 证件号码
+     * */
+    @JSONField(name = "certno")
+    private String certno;
+
+    
+    /**
+     * 人员姓名
+     * */
+    @JSONField(name = "psn_name")
+    private String psnName;
+
+    
+    /**
+     * 生产批号
+     * */
+    @JSONField(name = "manu_lotnum")
+    private String manuLotnum;
+
+    
+    /**
+     * 生产日期
+     * */
+    @JSONField(name = "manu_date")
+    private String manuDate;
+
+    
+    /**
+     * 有效期止
+     * */
+    @JSONField(name = "expy_end")
+    private String expyEnd;
+
+    
+    /**
+     * 处方药标志
+     * */
+    @JSONField(name = "rx_flag")
+    private String rxFlag;
+
+    
+    /**
+     * 拆零标志
+     * */
+    @JSONField(name = "trdn_flag")
+    private String trdnFlag;
+
+    
+    /**
+     * 最终成交单价
+     * */
+    @JSONField(name = "finl_trns_pric")
+    private BigDecimal finlTrnsPric;
+
+    
+    /**
+     * 销售/退货数量
+     * */
+    @JSONField(name = "sel_retn_cnt")
+    private BigDecimal selRetnCnt;
+
+    
+    /**
+     * 销售/退货时间
+     * */
+    @JSONField(name = "sel_retn_time")
+    private String selRetnTime;
+
+    
+    /**
+     * 销售/退货经办人姓名
+     * */
+    @JSONField(name = "sel_retn_opter_name")
+    private String selRetnOpterName;
+
+    
+    /**
+     * 备注
+     * */
+    @JSONField(name = "memo")
+    private String memo;
+
+    
+    /**
+     * 商品销售流水号
+     * */
+    @JSONField(name = "medins_prod_sel_no")
+    private String medinsProdSelNo;
+
+
+    /**
+     * 就医流水号(医保结算时为MDTRT_ID,自费结算时为医疗机构内就诊流水号)
+     * */
+    @JSONField(name = "mdtrt_sn")
+    private String mdtrtSn;
+
+    /**
+     * 商品销售流水号
+     * */
+    @JSONField(name = "drug_trac_codg")
+    private String drugTracCodg;
+
+}

+ 280 - 0
src/main/java/cn/hnthyy/thmz/entity/yb/SelinfoSold.java

@@ -0,0 +1,280 @@
+package cn.hnthyy.thmz.entity.yb;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class SelinfoSold {
+
+    /**
+     * 医疗目录编码(如果没有就填默认值NMLC999)
+     * */
+    @JSONField(name = "med_list_codg")
+    private String medListCodg;
+
+
+    /**
+     * 定点医药机构目录编号
+     * */
+    @JSONField(name = "fixmedins_hilist_id")
+    private String fixmedinsHilistId;
+
+
+    /**
+     * 定点医药机构目录名称
+     * */
+    @JSONField(name = "fixmedins_hilist_name")
+    private String fixmedinsHilistName;
+
+
+    /**
+     * 定点医药机构批次流水号
+     * */
+    @JSONField(name = "fixmedins_bchno")
+    private String fixmedinsBchno;
+
+
+    /**
+     * 开方医师证件类型
+     * */
+    @JSONField(name = "prsc_dr_cert_type")
+    private String prscDrCertType;
+
+
+    /**
+     * 开方医师证件号码
+     * */
+    @JSONField(name = "prsc_dr_certno")
+    private String prscDrCertno;
+
+
+    /**
+     * 开方医师姓名
+     * */
+    @JSONField(name = "prsc_dr_name")
+    private String prscDrName;
+
+
+    /**
+     * 药师证件类型
+     * */
+    @JSONField(name = "phar_cert_type")
+    private String pharCertType;
+
+
+    /**
+     * 药师证件号码
+     * */
+    @JSONField(name = "phar_certno")
+    private String pharCertno;
+
+
+    /**
+     * 药师姓名
+     * */
+    @JSONField(name = "phar_name")
+    private String pharName;
+
+
+    /**
+     * 药师执业资格证号
+     * */
+    @JSONField(name = "phar_prac_cert_no")
+    private String pharPracCertNo;
+
+
+    /**
+     * 医保费用结算类型
+     * */
+    @JSONField(name = "hi_feesetl_type")
+    private String hiFeesetlType;
+
+
+    /**
+     * 结算ID
+     * */
+    @JSONField(name = "setl_id")
+    private String setlId;
+
+
+    /**
+     * 就医流水号
+     * */
+    @JSONField(name = "mdtrt_sn")
+    private String mdtrtSn;
+
+
+    /**
+     * 人员编号
+     * */
+    @JSONField(name = "psn_no")
+    private String psnNo;
+
+
+    /**
+     * 人员证件类型
+     * */
+    @JSONField(name = "psn_cert_type")
+    private String psnCertType;
+
+
+    /**
+     * 证件号码
+     * */
+    @JSONField(name = "certno")
+    private String certno;
+
+
+    /**
+     * 人员姓名
+     * */
+    @JSONField(name = "psn_name")
+    private String psnName;
+
+
+    /**
+     * 生产批号
+     * */
+    @JSONField(name = "manu_lotnum")
+    private String manuLotnum;
+
+
+    /**
+     * 生产日期
+     * */
+    @JSONField(name = "manu_date")
+    private String manuDate;
+
+
+    /**
+     * 有效期止
+     * */
+    @JSONField(name = "expy_end")
+    private String expyEnd;
+
+
+    /**
+     * 处方药标志
+     * */
+    @JSONField(name = "rx_flag")
+    private String rxFlag;
+
+
+    /**
+     * 拆零标志
+     * */
+    @JSONField(name = "trdn_flag")
+    private String trdnFlag;
+
+
+    /**
+     * 最终成交单价
+     * */
+    @JSONField(name = "finl_trns_pric")
+    private String finlTrnsPric;
+
+
+    /**
+     * 处方号
+     * */
+    @JSONField(name = "rxno")
+    private String rxno;
+
+
+    /**
+     * 外购处方标志
+     * */
+    @JSONField(name = "rx_circ_flag")
+    private String rxCircFlag;
+
+
+    /**
+     * 零售单据号
+     * */
+    @JSONField(name = "rtal_docno")
+    private String rtalDocno;
+
+
+    /**
+     * 销售出库单据号
+     * */
+    @JSONField(name = "stoout_no")
+    private String stooutNo;
+
+
+    /**
+     * 批次号
+     * */
+    @JSONField(name = "bchno")
+    private String bchno;
+
+
+    /**
+     * 药品条形码
+     * */
+    @JSONField(name = "drug_prod_barc")
+    private String drugProdBarc;
+
+
+    /**
+     * 货架位
+     * */
+    @JSONField(name = "shelf_posi")
+    private String shelfPosi;
+
+
+    /**
+     * 销售/退货数量
+     * */
+    @JSONField(name = "sel_retn_cnt")
+    private int selRetnCnt;
+
+
+    /**
+     * 销售/退货时间
+     * */
+    @JSONField(name = "sel_retn_time")
+    private String selRetnTime;
+
+
+    /**
+     * 销售/退货经办人姓名
+     * */
+    @JSONField(name = "sel_retn_opter_name")
+    private String selRetnOpterName;
+
+
+    /**
+     * 备注
+     * */
+    @JSONField(name = "memo")
+    private String memo;
+
+    /**
+     * 开方医师编号(医保结算必填,非电子处方不校验)
+     * */
+    @JSONField(name = "prsc_dr_no")
+    private String prscDrNo;
+
+    /**
+     * 医保药师编号(医保结算必填)
+     * */
+    @JSONField(name = "phar_no")
+    private String pharNo;
+
+    /**
+     * 就诊结算类型(1-医保结算 2-自费结算)
+     * */
+    @JSONField(name = "MDTRT_SETL_TYPE")
+    private String mdtrtSetlType;
+
+    /**
+     * 溯源码节点信息
+     * */
+    @JSONField(name = "drugtracinfo")
+    private List<DrugTracCodg> drugtracinfo;
+
+}

+ 27 - 0
src/main/java/cn/hnthyy/thmz/service/taobao/TaobaoService.java

@@ -0,0 +1,27 @@
+package cn.hnthyy.thmz.service.taobao;
+
+import cn.hnthyy.thmz.Utils.HttpUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.json.JSONObject;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.io.IOException;
+
+@Slf4j
+@Service
+public class TaobaoService {
+
+    private String url = "http://130.150.161.113:7001/pay/ypTaobao/";
+
+    public String sendGet(String getUrl) {
+        try {
+            return HttpUtil.sendHttpGet(url + getUrl, "utf-8", 40000);
+        } catch (IOException e) {
+            return null;
+        }
+    }
+}

+ 93 - 0
src/main/java/cn/hnthyy/thmz/service/yb/YbService.java

@@ -0,0 +1,93 @@
+package cn.hnthyy.thmz.service.yb;
+
+import cn.hnthyy.thmz.Utils.HttpUtil;
+import cn.hnthyy.thmz.entity.jy.ResultVo;
+import cn.hnthyy.thmz.entity.yb.DrugTracCodg;
+import cn.hnthyy.thmz.entity.yb.SelinfoSold;
+import cn.hnthyy.thmz.entity.yb.SelinfoReturn;
+import cn.hnthyy.thmz.service.taobao.TaobaoService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+
+@Slf4j
+@Service
+public class YbService {
+
+    @Value("${siInventoryServiceUrl}")
+    private String siInventoryServiceUrl;
+
+    @Autowired
+    private TaobaoService taobaoService;
+
+    public ResultVo saleGoodsItem(SelinfoSold selInfo) {
+        ResultVo response = null;
+        selInfo.setMdtrtSn("MDTRT_ID");
+        List<DrugTracCodg> drugTracCodgList = selInfo.getDrugtracinfo();
+        if(drugTracCodgList == null || drugTracCodgList.isEmpty()) {
+            response = new ResultVo(-1, "追溯码不能为空");
+            return response;
+        }
+        String result = taobaoService.sendGet("/queryCodeDetail?codes=" + drugTracCodgList.get(0));
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        if (code == 200) {
+            JSONObject data = resultJson.getJSONObject("data");
+            Integer dataCode = data.getInteger("code");
+            if (dataCode == 0) {
+                JSONArray content = data.getJSONArray("data");
+                if(content != null && content.size() > 0) {
+                    JSONObject item = content.getJSONObject(0);
+                    JSONArray produceInfoList = item.getJSONObject("codeProduceInfoDTO").getJSONArray("produceInfoList");
+                    if(produceInfoList != null && produceInfoList.size() > 0) {
+                        JSONObject produceInfo = produceInfoList.getJSONObject(0);
+                        selInfo.setManuLotnum(produceInfo.getString("batchNo"));
+                        selInfo.setManuDate(produceInfo.getString("produceDateStr"));
+                    }
+                }
+            }
+        }
+        int randomNumber = new Random().nextInt(90) + 10;
+        String rtalDocno = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+        selInfo.setRtalDocno(rtalDocno + randomNumber);
+        selInfo.setFixmedinsBchno(rtalDocno + randomNumber);
+        selInfo.setSelRetnCnt(drugTracCodgList.size());
+        String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+        selInfo.setSelRetnTime(now);
+        selInfo.setSelRetnOpterName("");
+        selInfo.setMdtrtSetlType("1");
+
+
+        String realUrl = siInventoryServiceUrl + "/saleGoodsItem";
+        try {
+            String ybResult = HttpUtil.sendHttpPost(realUrl, JSONObject.toJSONString(selInfo), 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"));
+        } catch (Exception e) {
+            e.printStackTrace();
+            response = new ResultVo(-1, "商品销售失败");
+        }
+
+        return response;
+    }
+
+    public ResultVo returnGoodsItem(SelinfoReturn selinfoReturn) {
+        ResultVo response = null;
+        selinfoReturn.setMdtrtSn("MDTRT_ID");
+        return response;
+
+    }
+
+}

+ 2 - 0
src/main/resources/application-mhyy.yml

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