Quellcode durchsuchen

医保接口切换成https;分解一些存储过程。

lighter vor 1 Jahr
Ursprung
Commit
5b12e74cba

+ 91 - 0
src/main/java/thyyxxk/webserver/dao/his/inpatient/dismiss/ReceiveDrugDao.java

@@ -0,0 +1,91 @@
+package thyyxxk.webserver.dao.his.inpatient.dismiss;
+
+import org.apache.ibatis.annotations.*;
+import thyyxxk.webserver.entity.inpatient.dismiss.SnAndResponce;
+import thyyxxk.webserver.entity.inpatient.dismiss.ZyInit;
+import thyyxxk.webserver.entity.inpatient.dismiss.ZyTmpReceiveData;
+
+import java.util.Date;
+import java.util.List;
+
+@Mapper
+public interface ReceiveDrugDao {
+    @Select("select west_drug_code,chn_drug_code,inNo=#{inNo},times=#{times} from zy_init")
+    ZyInit getZyInit(String inNo, int times);
+
+    @Select("select count(1) from zy_actpatient where " +
+            "inpatient_no=#{vNo} and admiss_times=#{times}")
+    int getInHospitalState(String vNo, int times);
+
+    @Select("select sn=times_billed,resType=responce_type from ${tableName} " +
+            "where inpatient_no=#{vNo} and admiss_times=#{times}")
+    SnAndResponce getSnAndResponce(String vNo, int times, String tableName);
+
+    @Select("select account_date from zy_ledger_file where " +
+            "inpatient_no=#{vNo} and admiss_times=#{times} and ledger_sn=#{sn}")
+    Date getAccountDate(String vNo, int times, int sn);
+
+    @Select("select isnull(max(detail_sn),0)+1 from zy_detail_charge where " +
+            "inpatient_no=#{vNo} and admiss_times=#{times} and ledger_sn=#{sn}")
+    int getMaxDetailSn(String vNo, int times, int sn);
+
+    @Select("select chargeDate=order_date,opIdCode=drawer,patNo=#{inNo},times=#{times}," +
+            "chargeCode=case when charge_code>'00000' and charge_code<'30000' " +
+            "then #{westDrugCode} when charge_code>'30000' and charge_code<'40000' " +
+            "then #{chnDrugCode} else #{westDrugCode} end," +
+            "a.infant_flag,chargeStatus=#{chgStatus},retprice as chargeFee,self_flag," +
+            "separate_flag,suprice_flag,order_date as occTime, " +
+            "actOrderNo=cast(cast(b.act_order_no as decimal) as varchar), " +
+            "b.dept_code,b.ward_code,amount as orderCount," +
+            "execUnit=isnull(b.exec_unit,c.exec_unit), " +
+            "ybSelfFlag=isnull(b.yb_self_flag,c.yb_self_flag)," +
+            "doctorCode=isnull(b.physician,c.physician)," +
+            "referPhysician=isnull(b.refer_physician,c.refer_physician), " +
+            "consultPhysician=isnull(b.consult_physician,c.consult_physician), " +
+            "billItemCode='xxx',p1=1,p2=1,p3=1,p4=1,p5=1, " +
+            "a.serial,a.group_no,a.supply_code,charge_code as chargeItemCode " +
+            "from yp_zy_patient a, yz_act_order b left join yz_erase_order c on " +
+            "b.act_order_no=c.act_order_no " +
+            "where a.inpatient_no=#{inNo} and a.admiss_times=#{times} " +
+            "and a.acct_sign='0' and a.pay_self!='2' " +
+            "and a.act_order_no=b.act_order_no")
+    List<ZyTmpReceiveData> getTmpReceiveData(ZyInit zyInit);
+
+    @Update("update yp_zy_patient set acct_sign='2' " +
+            "where inpatient_no=#{inNo} and admiss_times=#{times} " +
+            "and acct_sign='0' and pay_self!='2'")
+    void updateYpZyPatient(String inNo, int times);
+
+    @Insert({"<script>" +
+            "insert into zy_detail_charge(inpatient_no,admiss_times,ledger_sn,detail_sn, " +
+            "charge_date,op_id_code,charge_code,infant_flag,charge_status,charge_fee," +
+            "self_flag,separate_flag,suppress_flag,ward_code,dept_code,order_no,ope_flag," +
+            "exec_unit,charge_amount,charge_code_mx,serial,doctor_code,refer_physician," +
+            "consult_physician,yb_self_flag) values " +
+            "<foreach collection='list' item='item' separator=','>" +
+            "(#{item.vNo},#{item.times},#{item.ledgerSn},#{item.detailSn}, " +
+            "#{item.chargeDate},#{item.opIdCode},#{item.chargeCode},#{item.infantFlag}, " +
+            "#{item.chargeStatus},#{item.chargeFee},#{item.selfFlag},#{item.separateFlag}, " +
+            "#{item.suppressFlag},#{item.wardCode},#{item.deptCode},#{item.actOrderNo},'0', " +
+            "#{item.execUnit},#{item.orderCount},#{item.chargeItemCode},#{item.serial}, " +
+            "#{item.doctorCode},#{item.referPhysician},#{item.consultPhysician}, " +
+            "#{item.ybSelfFlag})" +
+            "</foreach>" +
+            "</script>"})
+    void insertZyChargeFee(List<ZyTmpReceiveData> list);
+
+    @Select("select a.balance+isnull(a.max_ledger,0)+isnull(b.owe_limit,0) " +
+            "from zy_actpatient a,zy_adtward b where a.ward=b.ward_code and " +
+            "a.dept=b.dept_code and a.inpatient_no=#{inNo} and a.admiss_times=#{times}")
+    int getOweLimit(String inNo, int times);
+
+    @Update("update zy_actpatient set intern_code='9' " +
+            "where inpatient_no=#{inNo} and admiss_times=#{times} and " +
+            "isnull(intern_code,'0')!='1'")
+    void updateInterCode9(String inNo, int times);
+
+    @Update("update zy_actpatient set intern_code='0' " +
+            "where inpatient_no=#{inNo} and admiss_times=#{times} and " +
+            "isnull(intern_code,'0')='9'")
+    void updateInterCode0(String inNo, int times);
+}

+ 11 - 1
src/main/java/thyyxxk/webserver/dao/his/reports/InfantFeeReportDao.java

@@ -9,6 +9,16 @@ import java.util.List;
 
 @Mapper
 public interface InfantFeeReportDao {
-    @Select("exec infant_zy #{start},#{end}")
+    @Select("select a.inpatient_no as inpatient_no, " +
+            "c.name as name,a.admiss_times as admiss_times, " +
+            "sum(a.charge_fee) as charge " +
+            "from zy_detail_charge a,zy_ledger_file b,a_patient_mi c " +
+            "where a.infant_flag='1' " +
+            "and b.inpatient_no=a.inpatient_no " +
+            "and b.admiss_times=a.admiss_times " +
+            "and b.account_date>=#{start} " +
+            "and b.account_date<#{end} " +
+            "and a.inpatient_no=c.inpatient_no " +
+            "group by a.inpatient_no,c.name,a.admiss_times")
     List<InfantFee> getInfantCharge(GetInfantFeeParam param);
 }

+ 9 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/dismiss/SnAndResponce.java

@@ -0,0 +1,9 @@
+package thyyxxk.webserver.entity.inpatient.dismiss;
+
+import lombok.Data;
+
+@Data
+public class SnAndResponce {
+    private Integer sn;
+    private String responce;
+}

+ 12 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/dismiss/ZyInit.java

@@ -0,0 +1,12 @@
+package thyyxxk.webserver.entity.inpatient.dismiss;
+
+import lombok.Data;
+
+@Data
+public class ZyInit {
+    private String inNo;
+    private Integer times;
+    private String westDrugCode;
+    private String chnDrugCode;
+    private String chgStatus;
+}

+ 43 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/dismiss/ZyTmpReceiveData.java

@@ -0,0 +1,43 @@
+package thyyxxk.webserver.entity.inpatient.dismiss;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class ZyTmpReceiveData {
+    private String patNo;
+    private Integer times;
+    private Integer ledgerSn;
+    private Integer detailSn;
+    private Date chargeDate;
+    private String opIdCode;
+    private String chargeCode;
+    private String infantFlag;
+    private String chargeStatus;
+    private BigDecimal chargeFee;
+    private String selfFlag;
+    private String separateFlag;
+    private String suppressFlag;
+    private Date occTime;
+    private String actOrderNo;
+    private String execUnit;
+    private String deptCode;
+    private String wardCode;
+    private BigDecimal orderCount;
+    private String billItemCode;
+    private String ybSelfFlag;
+    private Integer p1;
+    private Integer p2;
+    private Integer p3;
+    private Integer p4;
+    private Integer p5;
+    private String serial;
+    private String groupNo;
+    private String supplyCode;
+    private String chargeItemCode;
+    private String doctorCode;
+    private String referPhysician;
+    private String consultPhysician;
+}

+ 1 - 1
src/main/java/thyyxxk/webserver/service/externalhttp/SiExecSrvc.java

@@ -9,7 +9,7 @@ import com.dtflys.forest.http.ForestResponse;
 
 import java.util.Map;
 
-@BaseRequest(baseURL = "http://dms.hun.hsip.gov.cn/isp-api/powercsb/1101")
+@BaseRequest(baseURL = "http://webhis.thyy.cn:8077/ybjkdz")
 public interface SiExecSrvc {
     @Post
     ForestResponse<byte[]> download(@Header Map<String, String> headerMap, @JSONBody JSONObject input);

+ 81 - 0
src/main/java/thyyxxk/webserver/service/inpatient/dismiss/ReceiveDrugService.java

@@ -0,0 +1,81 @@
+package thyyxxk.webserver.service.inpatient.dismiss;
+
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.config.exception.BizException;
+import thyyxxk.webserver.dao.his.inpatient.dismiss.ReceiveDrugDao;
+import thyyxxk.webserver.entity.inpatient.dismiss.SnAndResponce;
+import thyyxxk.webserver.entity.inpatient.dismiss.ZyInit;
+import thyyxxk.webserver.entity.inpatient.dismiss.ZyTmpReceiveData;
+import thyyxxk.webserver.utils.StringUtil;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class ReceiveDrugService {
+    private final ReceiveDrugDao dao;
+
+    public ReceiveDrugService(ReceiveDrugDao dao) {
+        this.dao = dao;
+    }
+
+    public void execute(String inNo, int times) {
+        String vNo = inNo.startsWith("$") ? inNo.replace("$", "") : inNo;
+        int inHospitalState = dao.getInHospitalState(vNo, times);
+        String actTable = inHospitalState == 1 ? "zy_actpatient" : "zy_inactpatient";
+        SnAndResponce snAndResponce = dao.getSnAndResponce(vNo, times, actTable);
+        if (null == snAndResponce || null == snAndResponce.getSn()) {
+            throw new BizException("获取患者账页失败,请联系管理员。");
+        }
+        int sn = snAndResponce.getSn();
+        Date accountDate = dao.getAccountDate(vNo, times, sn);
+        String chgStatus = null == accountDate ? "2" : "1";
+        ZyInit zyInit = dao.getZyInit(inNo, times);
+        zyInit.setChgStatus(chgStatus);
+        List<ZyTmpReceiveData> zyTmpReceiveDataList = dao.getTmpReceiveData(zyInit);
+        dao.updateYpZyPatient(inNo, times);
+        if (zyTmpReceiveDataList.isEmpty()) {
+            checkInpatientOweLimit(inNo, times, accountDate);
+            return;
+        }
+        int maxDetailSn = dao.getMaxDetailSn(vNo, times, sn) + 1;
+        for (int i = 0; i < zyTmpReceiveDataList.size(); i++) {
+            ZyTmpReceiveData item = zyTmpReceiveDataList.get(i);
+            item.setLedgerSn(sn);
+            item.setDetailSn(maxDetailSn + i);
+            if (StringUtil.isBlank(item.getInfantFlag())) {
+                item.setInfantFlag("0");
+            }
+            if (StringUtil.isBlank(item.getSelfFlag())) {
+                item.setSelfFlag("0");
+            }
+            if (StringUtil.isBlank(item.getSeparateFlag())) {
+                item.setSeparateFlag("0");
+            }
+            if (StringUtil.isBlank(item.getSuppressFlag())) {
+                item.setSuppressFlag("0");
+            }
+            BigDecimal price = item.getChargeFee().setScale(2, RoundingMode.HALF_UP);
+            if (price.compareTo(new BigDecimal("0.01")) < 0) {
+                price = new BigDecimal("0.01");
+            }
+            item.setChargeFee(price.multiply(item.getOrderCount()).setScale(2, RoundingMode.HALF_UP));
+        }
+        dao.insertZyChargeFee(zyTmpReceiveDataList);
+        checkInpatientOweLimit(inNo, times, accountDate);
+    }
+
+    private void checkInpatientOweLimit(String inNo, int times, Date accountDate) {
+        if (null != accountDate) {
+            return;
+        }
+        int oweLimit = dao.getOweLimit(inNo, times);
+        if (oweLimit <= 0) {
+            dao.updateInterCode9(inNo, times);
+        } else {
+            dao.updateInterCode0(inNo, times);
+        }
+    }
+}

+ 3 - 2
src/main/java/thyyxxk/webserver/service/medicalinsurance/ExecService.java

@@ -134,9 +134,9 @@ public class ExecService {
     }
 
     public JSONObject executeTrade(JSONObject input, SiFunction function) {
-        RestTemplate template = new RestTemplate();
         try {
-            String result = template.postForObject(siApiUrl,
+            RestTemplate restTemplate = new RestTemplate();
+            String result = restTemplate.postForObject(siApiUrl,
                     new HttpEntity<>(input, SiUtil.getHttpHeaders(function)), String.class);
             return JSONObject.parseObject(result);
         } catch (Exception e) {
@@ -151,4 +151,5 @@ public class ExecService {
             return object;
         }
     }
+
 }

+ 0 - 81
src/main/java/thyyxxk/webserver/utils/EncryptUtil.java

@@ -1,81 +0,0 @@
-package thyyxxk.webserver.utils;
-
-import cn.hutool.crypto.asymmetric.SM2;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-import org.bouncycastle.asn1.x9.X9ECParameters;
-import org.bouncycastle.util.encoders.Hex;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.*;
-
-public class EncryptUtil {
-
-    public static void main(String[] args) {
-        sign(new JSONObject());
-    }
-
-    public static void sign(JSONObject jsonObject) {
-
-        jsonObject = JSONObject.parseObject("{\"appId\":\"43AF047BBA47FC8A1AE8EFB2XXXXXXXX\", " +
-                "\"data\":{\"appId\":\"43AF047BBA47FC8A1AE8EFB2XXXXXXXX\",\"userName\":\"测试\",\"appUserId\":\"o8z4C5avQXqC0aWFPf1Mzu6D7WC\n" +
-                "Q_bd\",\"idNo\":\"350181199011193519\",\"idType\":\"01\",\"phoneNumber\":\"13763873033\"}, \"encType\":\"SM4\", \"signData\":\"URVQNdVNn5mz2EhKZhLTlXNwAWTSncFoSe8Ilx7jhn81eABJ46sdRRN1ZiAiQjPUTixG9bwqEhiJupH\n" +
-                "RGmyO5w==\", \"signType\":\"SM2\", \"timestamp\":\"20200207175759\", \"version\":\"2.0.1\"\n" +
-                "}");
-
-        // 生成原始签名串
-        SortedMap<String, Object> treeMap = new TreeMap<>(jsonObject);
-        String rawStr = getParamsFromMap(treeMap) + "key=4117E877F5FA0A0188891283E4B617D5";
-
-        System.out.println(SM2Sign(rawStr));
-    }
-
-    private static String SM2Sign(String raw) {
-        byte[] message = Hex.decode(raw);
-        return raw;
-    }
-
-    private static String getParamsFromMap(SortedMap<String, Object> map) {
-        // sign不参与签名
-        map.remove("signData");
-        map.remove("encData");
-        map.remove("extra");
-        StringBuilder sb = new StringBuilder();
-        Set<Map.Entry<String, Object>> es = map.entrySet();
-        Iterator<Map.Entry<String, Object>> it = es.iterator();
-        while (it.hasNext()) {
-            Map.Entry<String, Object> entry = it.next();
-            String k = entry.getKey();
-            Object objVal = entry.getValue();
-            if (objVal == null) { //值为空的参数不参与签名
-                continue;
-            }
-            String v;
-            if (isBaseDataType(objVal.getClass())) {
-                v = objVal.toString();
-            } else {
-                v = JSON.toJSONString(objVal, SerializerFeature.MapSortField);
-            }
-            if (!v.equals("")) {
-                if (it.hasNext()) {
-                    sb.append(k).append("=").append(v).append("&");
-                } else {
-                    sb.append(k).append("=").append(v);
-                }
-            }
-        }
-        return sb.toString();
-    }
-
-    private static boolean isBaseDataType(Class clazz) {
-        return (clazz.equals(String.class) || clazz.equals(Integer.class) || clazz.equals(Byte.class)
-                || clazz.equals(Long.class) || clazz.equals(Double.class) || clazz.equals(Float.class)
-                || clazz.equals(Character.class) || clazz.equals(Short.class) || clazz.equals(BigDecimal.class)
-                || clazz.equals(BigInteger.class) || clazz.equals(Boolean.class) || clazz.equals(Date.class) || clazz.isPrimitive());
-    }
-}

+ 27 - 13
src/main/java/thyyxxk/webserver/utils/SiUtil.java

@@ -58,26 +58,40 @@ public class SiUtil {
     }
 
     public static Map<String, String> getSiHeaderMap(SiFunction function) {
-        String timestamp = String.valueOf(System.currentTimeMillis());
         Map<String, String> headers = new HashMap<>();
-        headers.put("_api_access_key", apiAccessKey);
-        headers.put("_api_secreKey", apiSecretKey);
-        headers.put("_api_name", function.getCode());
-        headers.put("_api_version", API_VERSION);
-        headers.put("_api_timestamp", timestamp);
-        headers.put("_api_signature", getSignature(timestamp, function.getCode()));
+        String timestamp = String.valueOf(System.currentTimeMillis());
+        String signature = getSignature(timestamp, function.getCode());
+//        headers.put("_api_access_key", apiAccessKey);
+//        headers.put("_api_secreKey", apiSecretKey);
+//        headers.put("_api_name", function.getCode());
+//        headers.put("_api_version", API_VERSION);
+//        headers.put("_api_timestamp", timestamp);
+//        headers.put("_api_signature", signature);
+        headers.put("apiAccessKey", apiAccessKey);
+        headers.put("apiSecreKey", apiSecretKey);
+        headers.put("apiName", function.getCode());
+        headers.put("apiVersion", API_VERSION);
+        headers.put("apiTimestamp", timestamp);
+        headers.put("apiSignature", signature);
         return headers;
     }
 
     public static HttpHeaders getHttpHeaders(SiFunction function) {
         String timestamp = String.valueOf(System.currentTimeMillis());
+        String signature = getSignature(timestamp, function.getCode());
         HttpHeaders headers = new HttpHeaders();
-        headers.add("_api_access_key", apiAccessKey);
-        headers.add("_api_secreKey", apiSecretKey);
-        headers.add("_api_name", function.getCode());
-        headers.add("_api_version", API_VERSION);
-        headers.add("_api_timestamp", timestamp);
-        headers.add("_api_signature", getSignature(timestamp, function.getCode()));
+//        headers.add("_api_access_key", apiAccessKey);
+//        headers.add("_api_secreKey", apiSecretKey);
+//        headers.add("_api_name", function.getCode());
+//        headers.add("_api_version", API_VERSION);
+//        headers.add("_api_timestamp", timestamp);
+//        headers.add("_api_signature", signature);
+        headers.add("apiAccessKey", apiAccessKey);
+        headers.add("apiSecreKey", apiSecretKey);
+        headers.add("apiName", function.getCode());
+        headers.add("apiVersion", API_VERSION);
+        headers.add("apiTimestamp", timestamp);
+        headers.add("apiSignature", signature);
         return headers;
     }
 

+ 2 - 1
src/main/resources/application-prod.yml

@@ -140,7 +140,8 @@ is-prod: true
 
 triage-notify-url: http://172.16.32.160:8082/triage/roomScreen/pushMsg
 si-tj-url: http://jkglcsx.server.zhongmeihealth.com/openInter
-si-api-url: http://dms.hun.hsip.gov.cn/isp-api/powercsb/1101
+#si-api-url: https://dhs.hun.hsip.gov.cn/isp-api/powercsb/1101
+si-api-url: http://webhis.thyy.cn:8077/ybjkdz
 si-access-key: 04eMGRg7beAO6vqwrZiLacV8Uy3jNn7QGDUcBO
 si-secret-key: SK3Oip3a2R3NLz2xm58Mpmi69oFu96KrdKNRKglN
 si-zy-fee-url: http://172.16.32.166:1000