12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127 |
- 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) {
- String v = StringUtil.nullIf(prm.getVersion(), BEGIN_VERSION);
- switch (prm.getCode()) {
- case "1301":
- return downloadPatentAndWesternMedicineCatalogue(v);
- case "1302":
- return downloadChineseHerbalCatalogue(v);
- case "1303":
- return downloadHospitalDosage(v);
- case "1304":
- return downloadEthnicMedicine(prm);
- case "1305":
- return downloadMedicalServiceItemsCatalogue(v);
- case "1306":
- return downloadMedicalSuppliesCatalogue(v);
- case "1307":
- return downloadDiseasesAndDiagnosisCatalogue(v);
- case "1308":
- return downloadOperationCatalogue(v);
- case "1309":
- return downloadOutpatientSpecialChronicDiseasesCatalogue(v);
- case "1310":
- return downloadPayByDiseaseCatalogue(v);
- case "1311":
- return downloadDaytimeSurgeryDiseasesCatalogue(v);
- case "1312":
- return downloadMedicalInsuranceCatalogue(prm);
- case "1313":
- return downloadTumorMorphologyCatalogue(v);
- case "1314":
- return downloadTraditionalChineseDiseasesCatalogue(v);
- case "1315":
- return downloadTcmSyndromeCatalogue(v);
- 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(String v) {
- ResultVo<String> dwnldrslt = dwnldPtntWstnMdcnCtlg(v);
- 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.getInstance().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(String v) {
- ResultVo<String> dwnldrslt = execDwnldChnsHrblCtlg(v);
- while (dwnldrslt.getCode() == ExceptionEnum.SUCCESS.getCode()) {
- dwnldrslt = execDwnldChnsHrblCtlg(dwnldrslt.getData());
- }
- return ResultVoUtil.success();
- }
- public ResultVo<Map<String, Object>> downloadHospitalDosage(String v) {
- JSONObject result = getOrdinaryDownloadResult(SiFunction.DOWNLOAD_INSTITUTIONS_PREPARATIONS_CATALOGUE, v);
- log.info("【操作员:{}】,医院制剂目录下载:版本号:{},结果:{}", TokenUtil.getInstance().getTokenUserId(), v, 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.getInstance().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) {
- try {
- dnlddao.insertChnsHblBatch(list);
- list.clear();
- } catch (Exception e) {
- log.info("{}", JSONArray.toJSON(list));
- throw e;
- }
- }
- }
- if (!list.isEmpty()) {
- try {
- dnlddao.insertChnsHblBatch(list);
- } catch (Exception e) {
- log.info("{}", JSONArray.toJSON(list));
- throw e;
- }
- }
- 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.getInstance().getTokenUserId(), input, result);
- return getMapResultVo(result);
- }
- public ResultVo<Map<String, Object>> downloadMedicalServiceItemsCatalogue(String v) {
- ResultVo<String> dwnldrslt = execDwnldMdclSrvcItmsCtlg(v);
- 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.getInstance().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(String v) {
- ResultVo<String> dwnldrslt = execDwnldMdclSpplsCtlg(v);
- 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.getInstance().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(String v) {
- ResultVo<String> dwnldrslt = execDwnldDssDgnssCtlg(v);
- 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.getInstance().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(String v) {
- ResultVo<String> dwnldrslt = execDwnldOprtnCtlg(v);
- 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.getInstance().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(String v) {
- ResultVo<String> dwnldrslt = execDwnldOutptntSpclChrncDssCtlg(v);
- 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.getInstance().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(String v) {
- ResultVo<String> dwnldrslt = execDwnldPayByDssCtlg(v);
- 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.getInstance().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(String v) {
- ResultVo<String> dwnldrslt = execDwnldDytmSrgryDssCtlg(v);
- 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.getInstance().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.getInstance().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(String v) {
- ResultVo<String> dwnldrslt = execDwnldTmrMrphlgyCtlg(v);
- 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.getInstance().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(String v) {
- ResultVo<String> dwnldrslt = execDwnldTrdtnlChnDssCtlg(v);
- 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.getInstance().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(String v) {
- ResultVo<String> dwnldrslt = execDwnldTcmSyndrmCtlg(v);
- 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.getInstance().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.isEmpty()) {
- 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.getInstance().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.getInstance().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.getInstance().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.getInstance().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.getInstance().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 = ZipUtil.DIRECTORY + 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 = DateUtil.formatDatetime(new Date());
- 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;
- }
- }
|