1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117 |
- package thyyxxk.webserver.service.medicalinsurance;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.dtflys.forest.http.ForestResponse;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import thyyxxk.webserver.config.exception.ExceptionEnum;
- import thyyxxk.webserver.constants.Capacity;
- import thyyxxk.webserver.constants.sidicts.SiFunction;
- import thyyxxk.webserver.dao.his.medicalinsurance.SiDownloadDao;
- import thyyxxk.webserver.entity.ResultVo;
- import thyyxxk.webserver.entity.medicalinsurance.download.DldDictList;
- import thyyxxk.webserver.entity.medicalinsurance.download.*;
- import thyyxxk.webserver.service.externalhttp.SiExecSrvc;
- import thyyxxk.webserver.utils.*;
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import java.util.*;
- /**
- * @description: 医保目录下载服务
- * @author: DingJie
- * @create: 2021-06-23 15:17:03
- **/
- @Service
- @Slf4j
- public class SiDownloadService {
- private static final String RESULT_CODE = "infcode";
- private static final String ERROR_MESSAGE = "err_msg";
- private static final String OUTPUT = "output";
- private static final String BEGIN_VERSION = "V00";
- private final ExecService exec;
- private final SiDownloadDao dnlddao;
- private final SiExecSrvc execSrvc;
- @Autowired
- public SiDownloadService(ExecService exec, SiDownloadDao dnlddao, SiExecSrvc execSrvc) {
- this.exec = exec;
- this.dnlddao = dnlddao;
- this.execSrvc = execSrvc;
- }
- public ResultVo<Map<String, Object>> executeDownload(DwnldPrm prm) {
- switch (prm.getCode()) {
- case "1301":
- return downloadPatentAndWesternMedicineCatalogue();
- case "1302":
- return downloadChineseHerbalCatalogue();
- case "1303":
- return downloadHospitalDosage();
- case "1304":
- return downloadEthnicMedicine(prm);
- case "1305":
- return downloadMedicalServiceItemsCatalogue();
- case "1306":
- return downloadMedicalSuppliesCatalogue();
- case "1307":
- return downloadDiseasesAndDiagnosisCatalogue();
- case "1308":
- return downloadOperationCatalogue();
- case "1309":
- return downloadOutpatientSpecialChronicDiseasesCatalogue();
- case "1310":
- return downloadPayByDiseaseCatalogue();
- case "1311":
- return downloadDaytimeSurgeryDiseasesCatalogue();
- case "1312":
- return downloadMedicalInsuranceCatalogue(prm);
- case "1313":
- return downloadTumorMorphologyCatalogue();
- case "1314":
- return downloadTraditionalChineseDiseasesCatalogue();
- case "1315":
- return downloadTcmSyndromeCatalogue();
- case "1316":
- return downloadMedicalInsuranceMatchCatalogue(prm);
- case "1317":
- return downloadMedicalInstitutionMatchCatalogue(prm);
- case "1318":
- return downloadMedicalInsurancePriceLimitCatalogue(prm);
- case "1319":
- return downloadMedicalInsurancePayFirstCatalogue(prm);
- case "1319_save":
- return saveMedicalInsurancePayFirstCatalogue(prm);
- case "1901":
- return downloadDictionaryList(prm);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此目录下载的功能号。");
- }
- public ResultVo<Map<String, Object>> queryFromHis(DwnldPrm prm) {
- Map<String, Object> map = new HashMap<>(Capacity.TWO);
- IPage iPage;
- switch (prm.getCode()) {
- case "1301":
- iPage = new Page<SiDlPtntWstnMdcn>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlPtntWstnMdcnPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- case "1302":
- iPage = new Page<SiDlChnsHbl>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlChnsHblPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- case "1303":
- iPage = new Page<SiDlInstPrptn>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlInstPrptnPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- case "1305":
- iPage = new Page<SiDlMdcnSrvc>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlMdcnSrvcPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- case "1306":
- iPage = new Page<SiDlMdcnSply>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlMdcnSplyPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- case "1307":
- iPage = new Page<SiDlDssDns>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlDssDnsPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- case "1308":
- iPage = new Page<SiDlOprtn>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlOprtnPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- case "1309":
- iPage = new Page<SiDlSlwSpcChr>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlSlwSpcChrPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- case "1310":
- iPage = new Page<SiDlPayByDss>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlPayByDssPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- case "1311":
- iPage = new Page<SiDlDytmSrgyDss>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlDytmSrgyDssPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- case "1313":
- iPage = new Page<SiDlTmrMrphlgy>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlTmrMrphlgyPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- case "1314":
- iPage = new Page<SiDlTrdtnlChnsDss>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlTrdtnlChnsDssPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- case "1315":
- iPage = new Page<SiDlTcmSyndr>(prm.getPageNum(), prm.getPageSize());
- iPage = dnlddao.selectSiDlTcmSyndrPage(iPage);
- map.put("totalSize", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此目录下载的功能号。");
- }
- public ResultVo<Map<String, Object>> downloadPatentAndWesternMedicineCatalogue() {
- ResultVo<String> dwnldrslt = dwnldPtntWstnMdcnCtlg(BEGIN_VERSION);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = dwnldPtntWstnMdcnCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<String> dwnldPtntWstnMdcnCtlg(String version) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_PATENT_AND_WESTERN_MEDICINE_CATALOGUE, version);
- log.info("【操作员:{}】,西药中成药目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), version, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- if (null == result.getInteger(RESULT_CODE)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
- }
- String versionName = null;
- if (result.getIntValue(RESULT_CODE) == 0) {
- JSONObject output = result.getJSONObject(OUTPUT);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Queue<String> queue = SiUtil.readTxtFile(filePath);
- if (version.equals(BEGIN_VERSION)) {
- dnlddao.truncatePtntWstnMdcnTable();
- }
- List<SiDlPtntWstnMdcn> list = new ArrayList<>();
- while (!queue.isEmpty()) {
- String tempstr = queue.poll();
- list.add(new SiDlPtntWstnMdcn(tempstr));
- if (null == versionName) {
- versionName = list.get(0).getVersionName();
- }
- if (list.size() == 20) {
- dnlddao.insertPtntWstnMdcnBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dnlddao.insertPtntWstnMdcnBatch(list);
- }
- if (StringUtil.notBlank(versionName)) {
- return ResultVoUtil.success(versionName);
- }
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadChineseHerbalCatalogue() {
- ResultVo<String> dwnldrslt = execDwnldChnsHrblCtlg(BEGIN_VERSION);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = execDwnldChnsHrblCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<Map<String, Object>> downloadHospitalDosage() {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_INSTITUTIONS_PREPARATIONS_CATALOGUE, BEGIN_VERSION);
- log.info("【操作员:{}】,医院制剂目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), BEGIN_VERSION, result);
- 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);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Map<String, Object> obj = new HashMap<>();
- obj.put("message", "下载成功");
- obj.put("path", filePath);
- return ResultVoUtil.success(obj);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<String> execDwnldChnsHrblCtlg(String version) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_CHINESE_HERBAL_CATALOGUE, version);
- log.info("【操作员:{}】,中药饮片目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), version, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- if (null == result.getInteger(RESULT_CODE)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
- }
- String versionName = null;
- if (result.getIntValue(RESULT_CODE) == 0) {
- JSONObject output = result.getJSONObject(OUTPUT);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Queue<String> queue = SiUtil.readTxtFile(filePath);
- if (version.equals(BEGIN_VERSION)) {
- dnlddao.truncateChnsHblTable();
- }
- List<SiDlChnsHbl> list = new ArrayList<>();
- while (!queue.isEmpty()) {
- String tempstr = queue.poll();
- list.add(new SiDlChnsHbl(tempstr));
- if (null == versionName) {
- versionName = list.get(0).getVersionName();
- }
- if (list.size() == 20) {
- dnlddao.insertChnsHblBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dnlddao.insertChnsHblBatch(list);
- }
- if (StringUtil.notBlank(versionName)) {
- return ResultVoUtil.success(versionName);
- }
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadEthnicMedicine(DwnldPrm prm) {
- JSONObject input = exec.makeTradeHeader(SiFunction.DOWNLOAD_ETHNIC_MEDICINE);
- JSONObject data = new JSONObject();
- data.put("updt_time", DateUtil.formatDatetime(prm.getUpdtTime()));
- data.put("page_num", prm.getPageNum());
- data.put("page_size", prm.getPageSize());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.DOWNLOAD_ETHNIC_MEDICINE);
- log.info("【操作员:{}】,民族药品目录下载:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
- return getMapResultVo(result);
- }
- public ResultVo<Map<String, Object>> downloadMedicalServiceItemsCatalogue() {
- ResultVo<String> dwnldrslt = execDwnldMdclSrvcItmsCtlg(BEGIN_VERSION);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = execDwnldMdclSrvcItmsCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<String> execDwnldMdclSrvcItmsCtlg(String version) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_MEDICAL_SERVICE_ITEMS_CATALOGUE, version);
- log.info("【操作员:{}】,医疗服务项目目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), version, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- if (null == result.getInteger(RESULT_CODE)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
- }
- String versionName = null;
- if (result.getIntValue(RESULT_CODE) == 0) {
- JSONObject output = result.getJSONObject(OUTPUT);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Queue<String> queue = SiUtil.readTxtFile(filePath);
- if (version.equals(BEGIN_VERSION)) {
- dnlddao.truncateMdcnSrvcTable();
- }
- List<SiDlMdcnSrvc> list = new ArrayList<>();
- while (!queue.isEmpty()) {
- String tempstr = queue.poll();
- list.add(new SiDlMdcnSrvc(tempstr));
- if (null == versionName) {
- versionName = list.get(0).getVersionName();
- }
- if (list.size() == 20) {
- dnlddao.insertMdcnSrvcBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dnlddao.insertMdcnSrvcBatch(list);
- }
- if (StringUtil.notBlank(versionName)) {
- return ResultVoUtil.success(versionName);
- }
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadMedicalSuppliesCatalogue() {
- ResultVo<String> dwnldrslt = execDwnldMdclSpplsCtlg(BEGIN_VERSION);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = execDwnldMdclSpplsCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<String> execDwnldMdclSpplsCtlg(String version) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_MEDICAL_SUPPLIES_CATALOGUE, version);
- log.info("【操作员:{}】,医用耗材目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), version, result);
- 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);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Queue<String> queue = SiUtil.readTxtFile(filePath);
- if (version.equals(BEGIN_VERSION)) {
- dnlddao.truncateMdcnSplyTable();
- }
- List<SiDlMdcnSply> list = new ArrayList<>();
- String versionName = null;
- while (!queue.isEmpty()) {
- String tempstr = queue.poll();
- list.add(new SiDlMdcnSply(tempstr));
- if (null == versionName) {
- versionName = list.get(0).getVersionName();
- }
- if (list.size() == 20) {
- dnlddao.insertMdcnSplyBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dnlddao.insertMdcnSplyBatch(list);
- }
- if (StringUtil.notBlank(versionName)) {
- return ResultVoUtil.success(versionName);
- }
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadDiseasesAndDiagnosisCatalogue() {
- ResultVo<String> dwnldrslt = execDwnldDssDgnssCtlg(BEGIN_VERSION);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = execDwnldDssDgnssCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<String> execDwnldDssDgnssCtlg(String version) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_DISEASES_AND_DIAGNOSIS_CATALOGUE, version);
- log.info("【操作员:{}】,疾病与诊断目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), version, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- if (null == result.getInteger(RESULT_CODE)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
- }
- String versionName = null;
- if (result.getIntValue(RESULT_CODE) == 0) {
- JSONObject output = result.getJSONObject(OUTPUT);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Queue<String> queue = SiUtil.readTxtFile(filePath);
- if (version.equals(BEGIN_VERSION)) {
- dnlddao.truncateDssDnsTable();
- }
- List<SiDlDssDns> list = new ArrayList<>();
- while (!queue.isEmpty()) {
- String tempstr = queue.poll();
- list.add(new SiDlDssDns(tempstr));
- if (null == versionName) {
- versionName = list.get(0).getVersionName();
- }
- if (list.size() == 20) {
- dnlddao.insertDssDnsBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dnlddao.insertDssDnsBatch(list);
- }
- if (StringUtil.notBlank(versionName)) {
- return ResultVoUtil.success(versionName);
- }
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadOperationCatalogue() {
- ResultVo<String> dwnldrslt = execDwnldOprtnCtlg(BEGIN_VERSION);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = execDwnldOprtnCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<String> execDwnldOprtnCtlg(String version) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_OPERATION_CATALOGUE, version);
- log.info("【操作员:{}】,手术操作目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), version, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- if (null == result.getInteger(RESULT_CODE)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
- }
- String versionName = null;
- if (result.getIntValue(RESULT_CODE) == 0) {
- JSONObject output = result.getJSONObject(OUTPUT);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Queue<String> queue = SiUtil.readTxtFile(filePath);
- if (version.equals(BEGIN_VERSION)) {
- dnlddao.truncateOprtnTable();
- }
- List<SiDlOprtn> list = new ArrayList<>();
- while (!queue.isEmpty()) {
- String tempstr = queue.poll();
- String[] arr = tempstr.split("\t");
- if (StringUtil.isBlank(arr[10])) {
- continue;
- }
- list.add(new SiDlOprtn(arr));
- if (null == versionName) {
- versionName = list.get(0).getVersionName();
- }
- if (list.size() == 20) {
- dnlddao.insertOprtnBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dnlddao.insertOprtnBatch(list);
- }
- if (StringUtil.notBlank(versionName)) {
- return ResultVoUtil.success(versionName);
- }
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadOutpatientSpecialChronicDiseasesCatalogue() {
- ResultVo<String> dwnldrslt = execDwnldOutptntSpclChrncDssCtlg(BEGIN_VERSION);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = execDwnldOutptntSpclChrncDssCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<String> execDwnldOutptntSpclChrncDssCtlg(String version) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_OUTPATIENT_SPECIAL_CHRONIC_DISEASES_CATALOGUE, version);
- log.info("【操作员:{}】,门诊慢特病种目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), version, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- if (null == result.getInteger(RESULT_CODE)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
- }
- String versionName = null;
- if (result.getIntValue(RESULT_CODE) == 0) {
- JSONObject output = result.getJSONObject(OUTPUT);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Queue<String> queue = SiUtil.readTxtFile(filePath);
- if (version.equals(BEGIN_VERSION)) {
- dnlddao.truncateSlwSpcChrTable();
- }
- List<SiDlSlwSpcChr> list = new ArrayList<>();
- while (!queue.isEmpty()) {
- String tempstr = queue.poll();
- list.add(new SiDlSlwSpcChr(tempstr));
- if (null == versionName) {
- versionName = list.get(0).getVersionName();
- }
- if (list.size() == 20) {
- dnlddao.insertSlwSpcChrBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dnlddao.insertSlwSpcChrBatch(list);
- }
- if (StringUtil.notBlank(versionName)) {
- return ResultVoUtil.success(versionName);
- }
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadPayByDiseaseCatalogue() {
- ResultVo<String> dwnldrslt = execDwnldPayByDssCtlg(BEGIN_VERSION);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = execDwnldPayByDssCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<String> execDwnldPayByDssCtlg(String version) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_PAY_BY_DISEASE_CATALOGUE, version);
- log.info("【操作员:{}】,按病种付费病种目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), version, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- if (null == result.getInteger(RESULT_CODE)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
- }
- String versionName = null;
- if (result.getIntValue(RESULT_CODE) == 0) {
- JSONObject output = result.getJSONObject(OUTPUT);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Queue<String> queue = SiUtil.readTxtFile(filePath);
- if (version.equals(BEGIN_VERSION)) {
- dnlddao.truncatePayByDssTable();
- }
- List<SiDlPayByDss> list = new ArrayList<>();
- while (!queue.isEmpty()) {
- String tempstr = queue.poll();
- list.add(new SiDlPayByDss(tempstr));
- if (null == versionName) {
- versionName = list.get(0).getVersionName();
- }
- if (list.size() == 20) {
- dnlddao.insertPayByDssBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dnlddao.insertPayByDssBatch(list);
- }
- if (StringUtil.notBlank(versionName)) {
- return ResultVoUtil.success(versionName);
- }
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadDaytimeSurgeryDiseasesCatalogue() {
- ResultVo<String> dwnldrslt = execDwnldDytmSrgryDssCtlg(BEGIN_VERSION);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = execDwnldDytmSrgryDssCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<String> execDwnldDytmSrgryDssCtlg(String version) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_DAYTIME_SURGERY_DISEASES_CATALOGUE, version);
- log.info("【操作员:{}】,日间手术治疗病种目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), version, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- if (null == result.getInteger(RESULT_CODE)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
- }
- String versionName = null;
- if (result.getIntValue(RESULT_CODE) == 0) {
- JSONObject output = result.getJSONObject(OUTPUT);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Queue<String> queue = SiUtil.readTxtFile(filePath);
- if (version.equals(BEGIN_VERSION)) {
- dnlddao.truncateDytmSrgyDssTable();
- }
- List<SiDlDytmSrgyDss> list = new ArrayList<>();
- while (!queue.isEmpty()) {
- String tempstr = queue.poll();
- list.add(new SiDlDytmSrgyDss(tempstr));
- if (null == versionName) {
- versionName = list.get(0).getVersionName();
- }
- if (list.size() == 20) {
- dnlddao.insertDytmSrgyDssBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dnlddao.insertDytmSrgyDssBatch(list);
- }
- if (StringUtil.notBlank(versionName)) {
- return ResultVoUtil.success(versionName);
- }
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadMedicalInsuranceCatalogue(DwnldPrm prm) {
- JSONObject input = exec.makeTradeHeader(SiFunction.DOWNLOAD_MEDICAL_INSURANCE_CATALOGUE);
- JSONObject data = new JSONObject();
- data.put("updt_time", DateUtil.formatDatetime(prm.getUpdtTime()));
- data.put("page_num", prm.getPageNum());
- data.put("page_size", prm.getPageSize());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.DOWNLOAD_MEDICAL_INSURANCE_CATALOGUE);
- log.info("【操作员:{}】,医保目录信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
- return getMapResultVo(result);
- }
- private ResultVo<Map<String, Object>> getMapResultVo(JSONObject result) {
- 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);
- Map<String, Object> map = new HashMap<>(Capacity.TWO);
- map.put("totalSize", output.getIntValue("recordCounts"));
- map.put("list", output.getJSONArray("data"));
- return ResultVoUtil.success(map);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadTumorMorphologyCatalogue() {
- ResultVo<String> dwnldrslt = execDwnldTmrMrphlgyCtlg(BEGIN_VERSION);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = execDwnldTmrMrphlgyCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<String> execDwnldTmrMrphlgyCtlg(String version) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_TUMOR_MORPHOLOGY_CATALOGUE, version);
- log.info("【操作员:{}】,肿瘤形态学目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), version, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- if (null == result.getInteger(RESULT_CODE)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
- }
- String versionName = null;
- if (result.getIntValue(RESULT_CODE) == 0) {
- JSONObject output = result.getJSONObject(OUTPUT);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Queue<String> queue = SiUtil.readTxtFile(filePath);
- if (version.equals(BEGIN_VERSION)) {
- dnlddao.truncateTmrMrphlgyTable();
- }
- List<SiDlTmrMrphlgy> list = new ArrayList<>();
- while (!queue.isEmpty()) {
- String tempstr = queue.poll();
- list.add(new SiDlTmrMrphlgy(tempstr));
- if (null == versionName) {
- versionName = list.get(0).getVersionName();
- }
- if (list.size() == 20) {
- dnlddao.insertTmrMrphlgyBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dnlddao.insertTmrMrphlgyBatch(list);
- }
- if (StringUtil.notBlank(versionName)) {
- return ResultVoUtil.success(versionName);
- }
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadTraditionalChineseDiseasesCatalogue() {
- ResultVo<String> dwnldrslt = execDwnldTrdtnlChnDssCtlg(BEGIN_VERSION);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = execDwnldTrdtnlChnDssCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<String> execDwnldTrdtnlChnDssCtlg(String version) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_TRADITIONAL_CHINESE_DISEASES_CATALOGUE, version);
- log.info("【操作员:{}】,中医疾病目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), version, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- if (null == result.getInteger(RESULT_CODE)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
- }
- String versionName = null;
- if (result.getIntValue(RESULT_CODE) == 0) {
- JSONObject output = result.getJSONObject(OUTPUT);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Queue<String> queue = SiUtil.readTxtFile(filePath);
- if (version.equals(BEGIN_VERSION)) {
- dnlddao.truncateTrdtnlChnsDssTable();
- }
- List<SiDlTrdtnlChnsDss> list = new ArrayList<>();
- while (!queue.isEmpty()) {
- String tempstr = queue.poll();
- list.add(new SiDlTrdtnlChnsDss(tempstr));
- if (null == versionName) {
- versionName = list.get(0).getVersionName();
- }
- if (list.size() == 20) {
- dnlddao.insertTrdtnlChnsDssBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dnlddao.insertTrdtnlChnsDssBatch(list);
- }
- if (StringUtil.notBlank(versionName)) {
- return ResultVoUtil.success(versionName);
- }
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadTcmSyndromeCatalogue() {
- ResultVo<String> dwnldrslt = execDwnldTcmSyndrmCtlg(BEGIN_VERSION);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = execDwnldTcmSyndrmCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<String> execDwnldTcmSyndrmCtlg(String version) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_TCM_SYNDROME_CATALOGUE, version);
- log.info("【操作员:{}】,中医证候目录下载:版本号:{},结果:{}", TokenUtil.getTokenUserId(), version, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- if (null == result.getInteger(RESULT_CODE)) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
- }
- String versionName = null;
- if (result.getIntValue(RESULT_CODE) == 0) {
- JSONObject output = result.getJSONObject(OUTPUT);
- String fileQuryNo = output.getString("file_qury_no");
- String filename = output.getString("filename");
- String filePath = downloadFile(fileQuryNo, filename);
- if (null == filePath) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR, "网络异常,下载失败!");
- }
- Queue<String> queue = SiUtil.readTxtFile(filePath);
- if (version.equals(BEGIN_VERSION)) {
- dnlddao.truncateTcmSyndrTable();
- }
- List<SiDlTcmSyndr> list = new ArrayList<>();
- while (!queue.isEmpty()) {
- String tempstr = queue.poll();
- list.add(new SiDlTcmSyndr(tempstr));
- if (null == versionName) {
- versionName = list.get(0).getVersionName();
- }
- if (list.size() == 20) {
- dnlddao.insertTcmSyndrBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dnlddao.insertTcmSyndrBatch(list);
- }
- if (StringUtil.notBlank(versionName)) {
- return ResultVoUtil.success(versionName);
- }
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> downloadMedicalInsuranceMatchCatalogue(DwnldPrm prm) {
- JSONObject input = exec.makeTradeHeader(SiFunction.DOWNLOAD_MEDICAL_INSURANCE_MATCH_CATALOGUE);
- JSONObject data = new JSONObject();
- data.put("updt_time", DateUtil.formatDatetime(prm.getUpdtTime()));
- data.put("page_num", prm.getPageNum());
- data.put("page_size", prm.getPageSize());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.DOWNLOAD_MEDICAL_INSURANCE_MATCH_CATALOGUE);
- log.info("【操作员:{}】,医疗目录与医保目录匹配信息下载:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
- return getMapResultVo(result);
- }
- public ResultVo<Map<String, Object>> downloadMedicalInstitutionMatchCatalogue(DwnldPrm prm) {
- JSONObject input = exec.makeTradeHeader(SiFunction.DOWNLOAD_MEDICAL_INSTITUTION_MATCH_CATALOGUE);
- JSONObject data = new JSONObject();
- data.put("updt_time", DateUtil.formatDatetime(prm.getUpdtTime()));
- data.put("page_num", prm.getPageNum());
- data.put("page_size", prm.getPageSize());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.DOWNLOAD_MEDICAL_INSTITUTION_MATCH_CATALOGUE);
- log.info("【操作员:{}】,医药机构目录匹配信息下载:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
- return getMapResultVo(result);
- }
- public ResultVo<Map<String, Object>> downloadMedicalInsurancePriceLimitCatalogue(DwnldPrm prm) {
- JSONObject input = exec.makeTradeHeader(SiFunction.DOWNLOAD_MEDICAL_INSURANCE_PRICE_LIMIT_CATALOGUE);
- JSONObject data = new JSONObject();
- data.put("updt_time", DateUtil.formatDatetime(prm.getUpdtTime()));
- data.put("page_num", prm.getPageNum());
- data.put("page_size", prm.getPageSize());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.DOWNLOAD_MEDICAL_INSURANCE_PRICE_LIMIT_CATALOGUE);
- log.info("【操作员:{}】,医保目录限价信息下载:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
- return getMapResultVo(result);
- }
- public ResultVo<Map<String, Object>> downloadMedicalInsurancePayFirstCatalogue(DwnldPrm prm) {
- JSONObject input = exec.makeTradeHeader(SiFunction.DOWNLOAD_MEDICAL_INSURANCE_PAY_FIRST_CATALOGUE);
- JSONObject data = new JSONObject();
- if (StringUtil.notBlank(prm.getMedinsCode())) {
- data.put("hilist_code", prm.getMedinsCode());
- }
- if (StringUtil.notBlank(prm.getInsutype())) {
- data.put("selfpay_prop_psn_type", prm.getInsutype());
- }
- data.put("updt_time", DateUtil.formatDatetime(prm.getUpdtTime()));
- data.put("page_num", prm.getPageNum());
- data.put("page_size", prm.getPageSize());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.DOWNLOAD_MEDICAL_INSURANCE_PAY_FIRST_CATALOGUE);
- log.info("【操作员:{}】,医保目录先自付比例信息下载:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
- return getMapResultVo(result);
- }
- public ResultVo<Map<String, Object>> saveMedicalInsurancePayFirstCatalogue(DwnldPrm prm) {
- int pageNum = prm.getPageNum();
- 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", prm.getPageSize());
- 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();
- data.setDate(DateUtil.formatDatetime(new Date(), "yyyy-MM-dd"));
- data.setAdmdvs(SiUtil.INSTITUTION_AREA);
- data.setParentValue(prm.getParentValue());
- data.setType(prm.getType());
- data.setValiFlag(prm.getValiFlag());
- input.getJSONObject("input").put("data", JSONObject.parseObject(JSONObject.toJSONString(data)));
- JSONObject result = exec.executeTrade(input, SiFunction.DOWNLOAD_DICTIONARY_LIST);
- log.info("【操作员:{}】,字典表下载:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
- 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);
- JSONArray list = output.getJSONArray("list");
- Map<String, Object> map = new HashMap<>(Capacity.TWO);
- map.put("totalSize", list.size());
- map.put("list", list);
- return ResultVoUtil.success(map);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public String downloadFile(String fileQuryNo, String filename) {
- JSONObject input = exec.makeTradeHeader(SiFunction.DOWNLOAD_FILE);
- JSONObject fsDownloadIn = new JSONObject();
- fsDownloadIn.put("file_qury_no", fileQuryNo);
- fsDownloadIn.put("filename", filename);
- fsDownloadIn.put("fixmedins_code", SiUtil.INSTITUTION_ID);
- input.getJSONObject("input").put("fsDownloadIn", fsDownloadIn);
- String targetPath = "D:\\" + filename;
- ForestResponse<byte[]> rsp = execSrvc.download(SiUtil.getSiHeaderMap(SiFunction.DOWNLOAD_FILE), input);
- try {
- Files.write(Paths.get(targetPath), Objects.requireNonNull(rsp.getByteArray(),
- "未获取到下载文件"));
- String unZip = ZipUtil.unZip(targetPath);
- log.info("解压缩成功:{}", unZip);
- ZipUtil.deleteFile(targetPath);
- return unZip;
- } catch (Exception e) {
- log.error("从医保中心下载文件出错", e);
- }
- return null;
- }
- private JSONObject getOrdinaryDownloadResult(SiFunction function, String version) {
- JSONObject input = exec.makeTradeHeader(function);
- JSONObject data = new JSONObject();
- data.put("ver", version);
- input.getJSONObject("input").put("data", data);
- return exec.executeTrade(input, function);
- }
- public ResultVo<String> fillPsnPayProp() {
- int countYp = 0;
- List<String> ypList = dnlddao.selectHospitalItems("yp_zd_dict");
- for (String item : ypList) {
- countYp += queryPsnPayProp(item, "yp_zd_dict");
- }
- int countXm = 0;
- List<String> xmList = dnlddao.selectHospitalItems("zd_charge_item");
- for (String item : xmList) {
- countXm += queryPsnPayProp(item, "zd_charge_item");
- }
- String result = String.format("药品共 %d 项,补充 %d 项;项目共 %d 项,补充 %d 项。",
- ypList.size(), countYp, xmList.size(), countXm);
- log.info(result);
- return ResultVoUtil.success(result);
- }
- private int queryPsnPayProp(String hilistCode, String table) {
- JSONObject input = exec.makeTradeHeader(SiFunction.DOWNLOAD_MEDICAL_INSURANCE_PAY_FIRST_CATALOGUE);
- JSONObject data = new JSONObject();
- data.put("hilist_code", hilistCode);
- data.put("selfpay_prop_psn_type", "310");
- data.put("updt_time", "2000-01-01 00:00:00");
- data.put("page_num", 1);
- data.put("page_size", 100);
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.DOWNLOAD_MEDICAL_INSURANCE_PAY_FIRST_CATALOGUE);
- if (null == result || null == result.getInteger(RESULT_CODE)) {
- return 0;
- }
- String psnPayProp = null;
- String nowdate = "2022-10-20 00:00:00";
- if (result.getIntValue(RESULT_CODE) == 0) {
- JSONObject output = result.getJSONObject(OUTPUT);
- JSONArray array = output.getJSONArray("data");
- int recordCounts = output.getIntValue("recordCounts");
- if (recordCounts == 1) {
- JSONObject target = array.getJSONObject(0);
- psnPayProp = target.getString("selfpay_prop");
- } else {
- for (int i = 0; i < recordCounts; i++) {
- JSONObject target = array.getJSONObject(i);
- String enddate = target.getString("enddate");
- if (DateUtil.shiJianDaXiao(nowdate, enddate, "<")) {
- nowdate = enddate;
- psnPayProp = target.getString("selfpay_prop");
- }
- }
- }
- }
- if (StringUtil.notBlank(psnPayProp)) {
- dnlddao.updatePsnpayProp(table, hilistCode, psnPayProp);
- log.info("补充自费比例:{},{}", hilistCode, psnPayProp);
- return 1;
- }
- return 0;
- }
- }
|