Jelajahi Sumber

医保目录先行自付比例入库

lighter 2 tahun lalu
induk
melakukan
390ae50ade

+ 19 - 4
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiDownloadDao.java

@@ -1,10 +1,7 @@
 package thyyxxk.webserver.dao.his.medicalinsurance;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import org.apache.ibatis.annotations.Insert;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Select;
-import org.apache.ibatis.annotations.Update;
+import org.apache.ibatis.annotations.*;
 import thyyxxk.webserver.entity.medicalinsurance.download.*;
 
 import java.util.List;
@@ -364,6 +361,24 @@ public interface SiDownloadDao {
             "</script>")
     void insertTrdtnlChnsDssBatch(List<SiDlTrdtnlChnsDss> list);
 
+    @Update("truncate table t_si_selfpay_first_catalogue")
+    void truncateSelfPayCatalogue();
+
+    @Insert("<script>" +
+            "insert into t_si_selfpay_first_catalogue (hilist_code, selfpay_prop_psn_type, selfpay_prop_type, " +
+            "insu_admdvs, begndate, enddate, selfpay_prop, vali_flag, rid, updt_time, crter_id, crter_name, crte_time, " +
+            "crte_optins_no, opter_id, opter_name, opt_time, optins_no, tabname, poolarea_no) " +
+            "values " +
+            "<foreach collection='list' item='item' open='' separator=',' close=''>" +
+            "(#{item.hilistCode},#{item.selfpayPropPsnType},#{item.selfpayPropType},#{item.insuAdmdvs},#{item.begndate}," +
+            "#{item.enddate},#{item.selfpayProp},#{item.valiFlag},#{item.rid},#{item.updtTime},#{item.crterId}," +
+            "#{item.crterName},#{item.crteTime},#{item.crteOptinsNo},#{item.opterId},#{item.opterName},#{item.optTime}," +
+            "#{item.optinsNo},#{item.tabname},#{item.poolareaNo}) " +
+            "</foreach>" +
+            "</script>")
+    void insertSelfPayCatalogue(List<SelfPayFirstCatalogue> list);
+
     @Select("select * from t_si_dl_trdtnl_chns_dss with(nolock)")
     IPage<SiDlTrdtnlChnsDss> selectSiDlTrdtnlChnsDssPage(IPage<SiDlTrdtnlChnsDss> iPage);
+
 }

+ 69 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/download/SelfPayFirstCatalogue.java

@@ -0,0 +1,69 @@
+package thyyxxk.webserver.entity.medicalinsurance.download;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+
+@Data
+public class SelfPayFirstCatalogue {
+    private Integer id;
+
+    @JSONField(name = "insu_admdvs")
+    private String insuAdmdvs;
+
+    @JSONField(name = "poolarea_no")
+    private String poolareaNo;
+
+    @JSONField(name = "opt_time")
+    private String optTime;
+
+    @JSONField(name = "hilist_code")
+    private String hilistCode;
+
+    @JSONField(name = "opter_id")
+    private String opterId;
+
+    @JSONField(name = "crter_name")
+    private String crterName;
+
+    @JSONField(name = "rid")
+    private String rid;
+
+    @JSONField(name = "crte_optins_no")
+    private String crteOptinsNo;
+
+    @JSONField(name = "begndate")
+    private String begndate;
+
+    @JSONField(name = "tabname")
+    private String tabname;
+
+    @JSONField(name = "enddate")
+    private String enddate;
+
+    @JSONField(name = "selfpay_prop_type")
+    private String selfpayPropType;
+
+    @JSONField(name = "crte_time")
+    private String crteTime;
+
+    @JSONField(name = "opter_name")
+    private String opterName;
+
+    @JSONField(name = "optins_no")
+    private String optinsNo;
+
+    @JSONField(name = "vali_flag")
+    private String valiFlag;
+
+    @JSONField(name = "selfpay_prop")
+    private String selfpayProp;
+
+    @JSONField(name = "selfpay_prop_psn_type")
+    private String selfpayPropPsnType;
+
+    @JSONField(name = "crter_id")
+    private String crterId;
+
+    @JSONField(name = "updt_time")
+    private String updtTime;
+}

+ 71 - 0
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiDownloadService.java

@@ -93,6 +93,8 @@ public class SiDownloadService {
                 return downloadMedicalInsurancePriceLimitCatalogue(prm);
             case "1319":
                 return downloadMedicalInsurancePayFirstCatalogue(prm);
+            case "1319_save":
+                return saveMedicalInsurancePayFirstCatalogue(prm);
             case "1901":
                 return downloadDictionaryList(prm);
         }
@@ -933,6 +935,75 @@ public class SiDownloadService {
         return getMapResultVo(result);
     }
 
+    public ResultVo<Map<String, Object>> saveMedicalInsurancePayFirstCatalogue(DwnldPrm prm) {
+        int pageNum = 1;
+        int recordPages = 0;
+        JSONObject input = exec.makeTradeHeader(SiFunction.DOWNLOAD_MEDICAL_INSURANCE_PAY_FIRST_CATALOGUE);
+        JSONObject data = new JSONObject();
+        data.put("updt_time", DateUtil.formatDatetime(prm.getUpdtTime()));
+        data.put("page_num", pageNum);
+        data.put("page_size", 3000);
+        input.getJSONObject("input").put("data", data);
+        JSONObject result = exec.executeTrade(input, SiFunction.DOWNLOAD_MEDICAL_INSURANCE_PAY_FIRST_CATALOGUE);
+        if (null == result) {
+            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+        }
+        if (null == result.getInteger(RESULT_CODE)) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
+        }
+        if (result.getIntValue(RESULT_CODE) == 0) {
+            JSONObject output = result.getJSONObject(OUTPUT);
+            recordPages = output.getInteger("pages");
+            List<SelfPayFirstCatalogue> list = JSONArray.parseArray(output.getJSONArray("data").toJSONString(), SelfPayFirstCatalogue.class);
+            List<SelfPayFirstCatalogue> tempList = new ArrayList<>();
+            log.info("下载医保目录先自付比例信息并入库:第 {} 页,共 {} 页。", pageNum, recordPages);
+            if (pageNum == 1) {
+                dnlddao.truncateSelfPayCatalogue();
+            }
+            for (SelfPayFirstCatalogue item : list) {
+                tempList.add(item);
+                if (tempList.size() == 100) {
+                    dnlddao.insertSelfPayCatalogue(tempList);
+                    tempList.clear();
+                }
+            }
+            if (tempList.size() > 0) {
+                dnlddao.insertSelfPayCatalogue(tempList);
+            }
+        }
+        while (pageNum < recordPages) {
+            pageNum += 1;
+            data.replace("page_num", pageNum);
+            input.getJSONObject("input").replace("data", data);
+            result = exec.executeTrade(input, SiFunction.DOWNLOAD_MEDICAL_INSURANCE_PAY_FIRST_CATALOGUE);
+            if (null == result) {
+                return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+            }
+            if (null == result.getInteger(RESULT_CODE)) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
+            }
+            if (result.getIntValue(RESULT_CODE) == 0) {
+                JSONObject output = result.getJSONObject(OUTPUT);
+                List<SelfPayFirstCatalogue> list = JSONArray.parseArray(output.getJSONArray("data").toJSONString(), SelfPayFirstCatalogue.class);
+                List<SelfPayFirstCatalogue> tempList = new ArrayList<>();
+                log.info("下载医保目录先自付比例信息并入库:第 {} 页,共 {} 页。", pageNum, recordPages);
+                for (SelfPayFirstCatalogue item : list) {
+                    tempList.add(item);
+                    if (tempList.size() == 100) {
+                        dnlddao.insertSelfPayCatalogue(tempList);
+                        tempList.clear();
+                    }
+                }
+                if (tempList.size() > 0) {
+                    dnlddao.insertSelfPayCatalogue(tempList);
+                }
+            }
+        }
+        prm.setPageNum(1);
+        prm.setPageSize(30);
+        return downloadMedicalInsurancePayFirstCatalogue(prm);
+    }
+
     public ResultVo<Map<String, Object>> downloadDictionaryList(DwnldPrm prm) {
         JSONObject input = exec.makeTradeHeader(SiFunction.DOWNLOAD_DICTIONARY_LIST);
         DldDictList data = new DldDictList();