SiManageService.java 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. package thyyxxk.webserver.service.medicalinsurance;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5. import lombok.extern.slf4j.Slf4j;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Service;
  8. import thyyxxk.webserver.config.exception.ExceptionEnum;
  9. import thyyxxk.webserver.constants.Capacity;
  10. import thyyxxk.webserver.constants.YesOrNo;
  11. import thyyxxk.webserver.constants.sidicts.*;
  12. import thyyxxk.webserver.dao.his.medicalinsurance.SiLogDao;
  13. import thyyxxk.webserver.dao.his.medicalinsurance.SiManageDao;
  14. import thyyxxk.webserver.dao.his.medicalinsurance.SiSetlinfoDao;
  15. import thyyxxk.webserver.entity.ResultVo;
  16. import thyyxxk.webserver.entity.dictionary.PureCodeName;
  17. import thyyxxk.webserver.entity.medicalinsurance.log.SiLog;
  18. import thyyxxk.webserver.entity.medicalinsurance.manage.*;
  19. import thyyxxk.webserver.entity.medicalinsurance.manage.deptmanage.DeptInfo;
  20. import thyyxxk.webserver.entity.medicalinsurance.manage.deptmanage.DeptInfoQuery;
  21. import thyyxxk.webserver.entity.medicalinsurance.manage.deptmanage.DrInfoQuery;
  22. import thyyxxk.webserver.entity.medicalinsurance.manage.detailanalyse.MainPart;
  23. import thyyxxk.webserver.entity.medicalinsurance.manage.examination.BilgItemInfo;
  24. import thyyxxk.webserver.entity.medicalinsurance.manage.goods.*;
  25. import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
  26. import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SlctSetlPrm;
  27. import thyyxxk.webserver.utils.*;
  28. import java.io.IOException;
  29. import java.math.BigDecimal;
  30. import java.nio.file.Files;
  31. import java.nio.file.Paths;
  32. import java.util.*;
  33. /**
  34. * @description: 医保管理服务,包涵项目对照等
  35. * @author: DingJie
  36. * @create: 2021/6/2914:44
  37. */
  38. @Service
  39. @Slf4j
  40. public class SiManageService {
  41. private static final String RESULT_CODE = "infcode";
  42. private static final String ERROR_MESSAGE = "err_msg";
  43. private static final String OUTPUT = "output";
  44. private final ExecService exec;
  45. private final SiUploadService upldServcie;
  46. private final SiDownloadService dldService;
  47. private final SiManageDao dao;
  48. private final SiSetlinfoDao setlinfoDao;
  49. private final SiLogDao logDao;
  50. @Autowired
  51. public SiManageService(ExecService exec, SiUploadService upldServcie,
  52. SiDownloadService dldService, SiManageDao dao, SiSetlinfoDao setlinfoDao, SiLogDao logDao) {
  53. this.exec = exec;
  54. this.upldServcie = upldServcie;
  55. this.dldService = dldService;
  56. this.dao = dao;
  57. this.setlinfoDao = setlinfoDao;
  58. this.logDao = logDao;
  59. }
  60. public ResultVo<String> uploadCatalogueContrast(CatalogueContrast prm) {
  61. JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_CATALOGUE_CONTRAST);
  62. JSONArray data = new JSONArray();
  63. setListType(prm);
  64. List<String> codes = new ArrayList<>();
  65. prm.getList().forEach(item -> {
  66. codes.add(item.getCode());
  67. JSONObject catalogue = new JSONObject();
  68. catalogue.put("fixmedins_hilist_id", item.getCode());
  69. catalogue.put("fixmedins_hilist_name", item.getName());
  70. catalogue.put("list_type", prm.getListType());
  71. catalogue.put("med_list_codg", item.getNationalCode());
  72. catalogue.put("begndate", DateUtil.formatDatetime(prm.getBeginDate()));
  73. catalogue.put("enddate", DateUtil.formatDatetime(prm.getEndDate()));
  74. data.add(catalogue);
  75. });
  76. input.getJSONObject("input").put("data", data);
  77. JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_CATALOGUE_CONTRAST);
  78. log.info("【操作员:{}】,上传目录对照:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  79. if (null == result) {
  80. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  81. }
  82. Integer infcode = result.getInteger(RESULT_CODE);
  83. logDao.insert(new SiLog(input, result, null, null, null, infcode, null));
  84. if (null == infcode) {
  85. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  86. }
  87. if (infcode == 0) {
  88. dao.updateUploadedFlag(prm.getTable(), YesOrNo.YES.getCode(), codes);
  89. return ResultVoUtil.success("上传目录对照成功。");
  90. }
  91. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  92. }
  93. public ResultVo<String> revokeCatalogueContrast(CatalogueContrast prm) {
  94. setListType(prm);
  95. JSONObject input = exec.makeTradeHeader(SiFunction.REVOKE_CATALOGUE_CONTRAST);
  96. JSONObject data = new JSONObject();
  97. data.put("fixmedins_code", SiUtil.INSTITUTION_ID);
  98. data.put("fixmedins_hilist_id", prm.getChargeCode());
  99. data.put("list_type", prm.getListType());
  100. data.put("med_list_codg", prm.getNationalCode());
  101. input.getJSONObject("input").put("data", data);
  102. JSONObject result = exec.executeTrade(input, SiFunction.REVOKE_CATALOGUE_CONTRAST);
  103. log.info("【操作员:{}】,撤销目录:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  104. if (null == result) {
  105. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  106. }
  107. Integer infcode = result.getInteger(RESULT_CODE);
  108. logDao.insert(new SiLog(input, result, null, null, null, infcode, null));
  109. if (null == infcode) {
  110. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  111. }
  112. if (infcode == 0) {
  113. dao.updateUploadedFlag2(prm.getTable(), prm.getChargeCode());
  114. return ResultVoUtil.success("撤销目录对照成功。");
  115. }
  116. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  117. }
  118. private void setListType(CatalogueContrast prm) {
  119. String table = "yp_zd_dict";
  120. switch (prm.getType()) {
  121. case 1:
  122. prm.setListType(ListType.WEST_PATENT.getCode());
  123. break;
  124. case 2:
  125. prm.setListType(ListType.HERBAL.getCode());
  126. break;
  127. case 3:
  128. prm.setListType(ListType.SERVICE.getCode());
  129. table = "zd_charge_item";
  130. break;
  131. case 4:
  132. prm.setListType(ListType.SUPPLY.getCode());
  133. table = "zd_charge_item";
  134. break;
  135. }
  136. prm.setTable(table);
  137. }
  138. public ResultVo<String> autoRecoveryTrade(AtoRcvTrd atoRcvTrd) {
  139. Integer recoveryTradePermission = dao.recoveryTradePermission(TokenUtil.getTokenUserId());
  140. if (null == recoveryTradePermission || recoveryTradePermission == 0) {
  141. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您没有冲正交易的权限!");
  142. }
  143. JSONObject input = exec.makeTradeHeader(SiFunction.AUTO_RECOVERY_TRADE);
  144. String ref = JSONObject.toJSONString(atoRcvTrd);
  145. input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
  146. JSONObject result = exec.executeTrade(input, SiFunction.AUTO_RECOVERY_TRADE);
  147. log.info("【操作员:{}】,冲正交易:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  148. Integer infcode = result.getInteger(RESULT_CODE);
  149. logDao.insert(new SiLog(input, result, null, null, null, infcode, atoRcvTrd.getPsnNo()));
  150. return SiUtil.makeReturnWithoutOutput(result, "冲正成功。");
  151. }
  152. public ResultVo<String> institutionSettlementLedgerCheck(InstStlLdgChk instStlLdgChk) {
  153. String startdate = DateUtil.getDayStartTime(instStlLdgChk.getStmtBegndate());
  154. String enddate = DateUtil.getDayEndTime(instStlLdgChk.getStmtEnddate());
  155. List<InstSetlLdgChkBrf> brfs = dao.selectSetlChkBrfsWithInsutype(instStlLdgChk.getClrType(), instStlLdgChk.getInsutype(),
  156. instStlLdgChk.getSetlOptins(), startdate, enddate);
  157. BigDecimal medfeesum = new BigDecimal("0");
  158. BigDecimal acctpaysum = new BigDecimal("0");
  159. BigDecimal fundpaysum = new BigDecimal("0");
  160. for (InstSetlLdgChkBrf brf : brfs) {
  161. medfeesum = DecimalUtil.add(medfeesum, brf.getMedfeeSumamt());
  162. acctpaysum = DecimalUtil.add(acctpaysum, brf.getAcctPay());
  163. fundpaysum = DecimalUtil.add(fundpaysum, brf.getFundPaySumamt());
  164. if (null != brf.getHospPay()) {
  165. fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPay());
  166. }
  167. }
  168. instStlLdgChk.setMedfeeSumamt(medfeesum);
  169. instStlLdgChk.setAcctPay(acctpaysum);
  170. instStlLdgChk.setFundPaySumamt(fundpaysum);
  171. instStlLdgChk.setFixmedinsSetlCnt(brfs.size());
  172. JSONObject input = exec.makeTradeHeader(SiFunction.INSTITUTION_SETTLEMENT_LEDGER_CHECK);
  173. String ref = JSONObject.toJSONStringWithDateFormat(instStlLdgChk, "yyyy-MM-dd");
  174. input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
  175. JSONObject result = exec.executeTrade(input, SiFunction.INSTITUTION_SETTLEMENT_LEDGER_CHECK);
  176. log.info("【操作员:{}】,医药机构费用结算对总账:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  177. if (null == result) {
  178. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  179. }
  180. if (null == result.getInteger(RESULT_CODE)) {
  181. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  182. }
  183. if (result.getIntValue(RESULT_CODE) == 0) {
  184. JSONObject output = result.getJSONObject(OUTPUT);
  185. JSONObject info = output.getJSONObject("stmtinfo");
  186. String setlOptins = info.getString("setl_optins");
  187. Admdvs admdvs = Admdvs.get(setlOptins);
  188. String optins;
  189. if (null == admdvs) {
  190. optins = dao.selectRegion(setlOptins);
  191. } else {
  192. optins = admdvs.getName();
  193. }
  194. String rslt;
  195. if (info.getString("stmt_rslt").equals(StmtRslt.CORRECT.getCode())) {
  196. rslt = StmtRslt.CORRECT.getName();
  197. } else {
  198. rslt = StmtRslt.WRONG.getName();
  199. }
  200. String dscr = info.getString("stmt_rslt_dscr");
  201. if (StringUtil.isBlank(dscr)) {
  202. dscr = "结算笔数:" + brfs.size() +
  203. ",医疗费总额:" + medfeesum + ",基金支付总额:" + fundpaysum;
  204. }
  205. String data = "【清算机构:" + optins + "】对账结果:" + rslt + "。对账结果说明:" + dscr;
  206. if (rslt.equals(StmtRslt.CORRECT.getName())) {
  207. return ResultVoUtil.success(data);
  208. }
  209. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, data);
  210. }
  211. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  212. }
  213. public ResultVo<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(InsSetlDetlChk prm) {
  214. String snowId = SnowFlakeId.instance().nextId();
  215. String filename = snowId + ".txt";
  216. StringBuilder fsIn = new StringBuilder();
  217. String startdate = DateUtil.getDayStartTime(prm.getStmtBegndate());
  218. String enddate = DateUtil.getDayEndTime(prm.getStmtEnddate());
  219. List<InstSetlLdgChkBrf> brfs = dao.selectSetlChkBrfs(prm.getClrType(),
  220. prm.getSetlOptins(), startdate, enddate);
  221. BigDecimal medfeesum = new BigDecimal("0");
  222. BigDecimal psnCashPay = new BigDecimal("0");
  223. BigDecimal fundpaysum = new BigDecimal("0");
  224. for (InstSetlLdgChkBrf brf : brfs) {
  225. medfeesum = DecimalUtil.add(medfeesum, brf.getMedfeeSumamt());
  226. psnCashPay = DecimalUtil.add(psnCashPay, brf.getPsnCashPay());
  227. fundpaysum = DecimalUtil.add(fundpaysum, brf.getFundPaySumamt());
  228. if (null != brf.getHospPay()) {
  229. fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPay());
  230. brf.setFundPaySumamt(DecimalUtil.minus(brf.getFundPaySumamt(), brf.getHospPay()));
  231. }
  232. }
  233. prm.setMedfeeSumamt(medfeesum);
  234. prm.setCashPayamt(psnCashPay);
  235. prm.setFundPaySumamt(fundpaysum);
  236. prm.setFixmedinsSetlCnt(brfs.size());
  237. for (InstSetlLdgChkBrf item : brfs) {
  238. fsIn.append(item.getSetlId()).append("\t")
  239. .append(item.getMdtrtId()).append("\t")
  240. .append(item.getPsnNo()).append("\t")
  241. .append(item.getMedfeeSumamt()).append("\t")
  242. .append(item.getFundPaySumamt()).append("\t")
  243. .append(item.getAcctPay()).append("\t")
  244. .append(prm.getRefdSetlFlag()).append("\n");
  245. }
  246. try {
  247. Files.write(Paths.get(filename), fsIn.toString().getBytes());
  248. String zipFile = ZipUtil.zip(filename);
  249. ZipUtil.deleteFile(filename);
  250. String fsUploadIn = "{\"filename\": \"" + filename + ".zip\", \"fixmedins_code\": \"" +
  251. SiUtil.INSTITUTION_ID + "\", \"in\": " + Arrays.toString(ZipUtil.zipFileToBytes(zipFile)) + "}";
  252. ResultVo<String> uplRes = upldServcie.uploadFile(JSONObject.parseObject(fsUploadIn), filename);
  253. ZipUtil.deleteFile(zipFile);
  254. if (uplRes.getCode().equals(ExceptionEnum.SUCCESS.getCode())) {
  255. prm.setFileQuryNo(uplRes.getData());
  256. }
  257. } catch (IOException e) {
  258. log.error("医药机构费用结算对明细账出错", e);
  259. }
  260. JSONObject input = exec.makeTradeHeader(SiFunction.INSTITUTION_SETTLEMENT_DETAIL_CHECK);
  261. String ref = JSONObject.toJSONStringWithDateFormat(prm, "yyyy-MM-dd");
  262. input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
  263. JSONObject result = exec.executeTrade(input, SiFunction.INSTITUTION_SETTLEMENT_DETAIL_CHECK);
  264. log.info("【操作员:{}】,医药机构费用结算对明细账:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  265. if (null == result) {
  266. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  267. }
  268. if (null == result.getInteger(RESULT_CODE)) {
  269. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  270. }
  271. if (result.getIntValue(RESULT_CODE) == 0) {
  272. JSONObject output = result.getJSONObject(OUTPUT);
  273. JSONObject fileinfo = output.getJSONObject("fileinfo");
  274. String filePath = dldService.downloadFile(fileinfo.getString("file_qury_no"), fileinfo.getString("filename"));
  275. Queue<String> queue = SiUtil.readTxtFile(filePath);
  276. if (null == queue || queue.size() == 0) {
  277. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "未能成功获取到对账结果。");
  278. }
  279. List<InsSetlDetlChkRslt> list = new ArrayList<>();
  280. while (queue.size() > 0) {
  281. String item = queue.poll();
  282. String[] arr = item.split("\t");
  283. InsSetlDetlChkRslt rslt = new InsSetlDetlChkRslt(arr);
  284. list.add(rslt);
  285. }
  286. return ResultVoUtil.success(list);
  287. }
  288. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  289. }
  290. public ResultVo<Map<String, Object>> selectSetlinfos(SlctSetlPrm prm) {
  291. QueryWrapper<SiSetlinfo> wrapper = new QueryWrapper<>();
  292. if (StringUtil.notBlank(prm.getInsutype())) {
  293. wrapper.eq("insutype", prm.getInsutype());
  294. }
  295. String begndate = DateUtil.formatDatetime(prm.getStmtBegndate(), "yyyy-MM-dd") + " 00:00:00";
  296. String enddate = DateUtil.formatDatetime(prm.getStmtEnddate(), "yyyy-MM-dd") + " 23:59:59";
  297. wrapper.eq("setl_type", prm.getClrType());
  298. wrapper.eq("revoked", YesOrNo.NO.getCode());
  299. wrapper.apply("fund_pay_sumamt!=0");
  300. wrapper.apply("setl_time>='" + begndate + "'");
  301. wrapper.apply("setl_time<='" + enddate + "'");
  302. wrapper.apply("(insuplc_admdvs='439900' or insuplc_admdvs like '4301%') ");
  303. List<SiSetlinfo> list = setlinfoDao.selectList(wrapper);
  304. if (null == list || list.isEmpty()) {
  305. return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到符合条件的数据。");
  306. }
  307. Map<String, Object> map = new HashMap<>(Capacity.TWO);
  308. Map<String, String> optinsMap = new HashMap<>();
  309. List<PureCodeName> optinList = new ArrayList<>();
  310. list.forEach(item -> {
  311. Admdvs admdvs = Admdvs.get(item.getClrOptins());
  312. if (null == admdvs) {
  313. item.setClrOptinsName(dao.selectRegion(item.getClrOptins()));
  314. } else {
  315. item.setClrOptinsName(admdvs.getName());
  316. }
  317. if (!optinsMap.containsKey(item.getClrOptins())) {
  318. optinsMap.put(item.getClrOptins(), item.getClrOptinsName());
  319. }
  320. FilterUtil.filterCodeToName(item);
  321. });
  322. map.put("list", list);
  323. for (Map.Entry<String, String> entry : optinsMap.entrySet()) {
  324. optinList.add(new PureCodeName(entry.getKey(), entry.getValue()));
  325. }
  326. map.put("optins", optinList);
  327. return ResultVoUtil.success(map);
  328. }
  329. public ResultVo<String> detailAnalyse(String patNo, int times, int ledger, int type) {
  330. SiFunction function = type == 1 ? SiFunction.ITEMIZED_REVIEW_ANALYSIS_SERVICES_BEFORE
  331. : SiFunction.ITEMIZED_REVIEW_ANALYSIS_SERVICES_MIDDLE;
  332. String logpart = type == 1 ? "明细审核事前分析" : "明细审核事中分析";
  333. JSONObject input = exec.makeTradeHeader(function);
  334. MainPart mainPart = new MainPart();
  335. String ref = JSONObject.toJSONString(mainPart);
  336. input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
  337. JSONObject result = exec.executeTrade(input, function);
  338. log.info("【操作员:{}】,{}:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), logpart, input, result);
  339. Integer infcode = result.getInteger(RESULT_CODE);
  340. logDao.insert(new SiLog(input, result, patNo, times, ledger, infcode, "psn_no"));
  341. return SiUtil.makeReturnWithoutOutput(result, "分析结果。");
  342. }
  343. public ResultVo<String> deptInfoUpload(DeptInfo deptInfo) {
  344. JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_DEPARTMENT_INFO);
  345. String ref = JSONObject.toJSONStringWithDateFormat(deptInfo, "yyyy-MM-dd HH:mm:ss");
  346. input.getJSONObject("input").put("deptinfo", JSONObject.parseObject(ref));
  347. JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_DEPARTMENT_INFO);
  348. log.info("【操作员:{}】,科室信息上传:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  349. Integer infcode = result.getInteger(RESULT_CODE);
  350. logDao.insert(new SiLog(input, result, null, null, null, infcode, null));
  351. return SiUtil.makeReturnWithoutOutput(result, "科室信息上传成功。");
  352. }
  353. public ResultVo<String> deptInfoBatchUpload(List<DeptInfo> deptInfos) {
  354. JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_DEPARTMENT_INFO_IN_BATCH);
  355. String ref = JSONArray.toJSONStringWithDateFormat(deptInfos, "yyyy-MM-dd HH:mm:ss");
  356. input.getJSONObject("input").put("deptinfo", JSONObject.parseObject(ref));
  357. JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_DEPARTMENT_INFO_IN_BATCH);
  358. log.info("【操作员:{}】,科室信息批量上传:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  359. Integer infcode = result.getInteger(RESULT_CODE);
  360. logDao.insert(new SiLog(input, result, null, null, null, infcode, null));
  361. return SiUtil.makeReturnWithoutOutput(result, "科室信息批量上传成功。");
  362. }
  363. public ResultVo<String> deptInfoModify(DeptInfo deptInfo) {
  364. JSONObject input = exec.makeTradeHeader(SiFunction.MODIFY_DEPARTMENT_INFO);
  365. String ref = JSONObject.toJSONStringWithDateFormat(deptInfo, "yyyy-MM-dd HH:mm:ss");
  366. input.getJSONObject("input").put("deptinfo", JSONObject.parseObject(ref));
  367. JSONObject result = exec.executeTrade(input, SiFunction.MODIFY_DEPARTMENT_INFO);
  368. log.info("【操作员:{}】,科室信息变更:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  369. Integer infcode = result.getInteger(RESULT_CODE);
  370. logDao.insert(new SiLog(input, result, null, null, null, infcode, null));
  371. return SiUtil.makeReturnWithoutOutput(result, "科室信息变更成功。");
  372. }
  373. public ResultVo<String> deptInfoDelete(DeptInfo deptInfo) {
  374. JSONObject input = exec.makeTradeHeader(SiFunction.REVOKE_DEPARTMENT_INFO);
  375. JSONObject data = new JSONObject();
  376. data.put("hosp_dept_codg", deptInfo.getHospDeptCodg());
  377. data.put("hosp_dept_name", deptInfo.getHospDeptName());
  378. data.put("begntime", DateUtil.formatDatetime(deptInfo.getBegntime(), "yyyy-MM-dd"));
  379. input.getJSONObject("input").put("data", data);
  380. JSONObject result = exec.executeTrade(input, SiFunction.REVOKE_DEPARTMENT_INFO);
  381. log.info("【操作员:{}】,科室信息撤销:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  382. Integer infcode = result.getInteger(RESULT_CODE);
  383. logDao.insert(new SiLog(input, result, null, null, null, infcode, null));
  384. return SiUtil.makeReturnWithoutOutput(result, "科室信息撤销成功。");
  385. }
  386. public ResultVo<JSONObject> queryDeptInfo(DeptInfoQuery query) {
  387. String ref = JSONObject.toJSONString(query);
  388. JSONObject input = exec.makeTradeHeader(SiFunction.QUERY_DEPARTMENT_INFO);
  389. input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
  390. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_DEPARTMENT_INFO);
  391. log.info("【操作员:{}】,科室信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  392. Integer infcode = result.getInteger(RESULT_CODE);
  393. if (null == infcode) {
  394. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  395. }
  396. if (infcode == 0) {
  397. return ResultVoUtil.success(result.getJSONObject(OUTPUT));
  398. }
  399. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  400. }
  401. // 接口存在问题
  402. public ResultVo<JSONObject> queryDrInfo(DrInfoQuery query) {
  403. String ref = JSONObject.toJSONString(query);
  404. JSONObject input = exec.makeTradeHeader(SiFunction.QUERY_MEDICAL_STAFF_INFO);
  405. input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
  406. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_MEDICAL_STAFF_INFO);
  407. log.info("【操作员:{}】,医执人员信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  408. Integer infcode = result.getInteger(RESULT_CODE);
  409. if (null == infcode) {
  410. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  411. }
  412. if (infcode == 0) {
  413. return ResultVoUtil.success(result.getJSONObject(OUTPUT));
  414. }
  415. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  416. }
  417. public ResultVo<JSONObject> queryExaminationExInfo(BilgItemInfo bilgItemInfo) {
  418. String ref = JSONObject.toJSONString(bilgItemInfo);
  419. JSONObject input = exec.makeTradeHeader(SiFunction.QUERY_MUTUAL_ACCREDIT_INFO);
  420. input.getJSONObject("input").put("bilgiteminfo", JSONObject.parseObject(ref));
  421. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_MUTUAL_ACCREDIT_INFO);
  422. log.info("【操作员:{}】,项目互认信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  423. Integer infcode = result.getInteger(RESULT_CODE);
  424. if (null == infcode) {
  425. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  426. }
  427. if (infcode == 0) {
  428. return ResultVoUtil.success(result.getJSONObject(OUTPUT));
  429. }
  430. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  431. }
  432. public ResultVo<JSONObject> queryExaminationExInfo(String psnNo, String reportNo) {
  433. JSONObject input = exec.makeTradeHeader(SiFunction.QUERY_DIAGNOSIS_REPORT_DETAIL);
  434. JSONObject rptdetailinfo = new JSONObject();
  435. rptdetailinfo.put("psn_no", psnNo);
  436. rptdetailinfo.put("rpotc_no", reportNo);
  437. rptdetailinfo.put("fixmedins_code", SiUtil.INSTITUTION_ID);
  438. input.getJSONObject("input").put("rptdetailinfo", rptdetailinfo);
  439. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_DIAGNOSIS_REPORT_DETAIL);
  440. log.info("【操作员:{}】,报告明细信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  441. Integer infcode = result.getInteger(RESULT_CODE);
  442. if (null == infcode) {
  443. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  444. }
  445. if (infcode == 0) {
  446. return ResultVoUtil.success(result.getJSONObject(OUTPUT));
  447. }
  448. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  449. }
  450. public ResultVo<String> uploadInvinfo(InvinfoUpload invinfo) {
  451. String ref = JSONObject.toJSONStringWithDateFormat(invinfo, "yyyy-MM-dd");
  452. JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_COMMODITY_INVENTORY);
  453. input.getJSONObject("input").put("invinfo", JSONObject.parseObject(ref));
  454. JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_COMMODITY_INVENTORY);
  455. return SiUtil.makeReturnWithoutOutput(result, "商品盘存上传成功。");
  456. }
  457. public ResultVo<String> modifyInvinfo(InvinfoModify invinfo) {
  458. String ref = JSONObject.toJSONStringWithDateFormat(invinfo, "yyyy-MM-dd HH:mm:ss");
  459. JSONObject input = exec.makeTradeHeader(SiFunction.CHANGE_COMMODITY_INVENTORY);
  460. input.getJSONObject("input").put("invinfo", JSONObject.parseObject(ref));
  461. JSONObject result = exec.executeTrade(input, SiFunction.CHANGE_COMMODITY_INVENTORY);
  462. return SiUtil.makeReturnWithoutOutput(result, "商品盘存修改成功。");
  463. }
  464. public ResultVo<String> purchaseGoods(PurcinfoBought purcinfo) {
  465. String ref = JSONObject.toJSONString(purcinfo);
  466. JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_COMMODITY_PURCHASE);
  467. input.getJSONObject("input").put("purcinfo", JSONObject.parseObject(ref));
  468. JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_COMMODITY_PURCHASE);
  469. return SiUtil.makeReturnWithoutOutput(result, "商品采购上传成功。");
  470. }
  471. public ResultVo<String> returnGoods(PurcinfoBought purcinfo) {
  472. String ref = JSONObject.toJSONString(purcinfo);
  473. JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_COMMODITY_PURCHASE_RETURN);
  474. input.getJSONObject("input").put("purcinfo", JSONObject.parseObject(ref));
  475. JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_COMMODITY_PURCHASE_RETURN);
  476. return SiUtil.makeReturnWithoutOutput(result, "商品采购退货成功。");
  477. }
  478. public ResultVo<String> saleGoods(SelinfoSold selinfo) {
  479. String ref = JSONObject.toJSONString(selinfo);
  480. JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_COMMODITY_SALES);
  481. input.getJSONObject("input").put("selinfo", JSONObject.parseObject(ref));
  482. JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_COMMODITY_SALES);
  483. return SiUtil.makeReturnWithoutOutput(result, "商品销售上传成功。");
  484. }
  485. public ResultVo<String> returnSales(SelinfoReturn selinfo) {
  486. String ref = JSONObject.toJSONString(selinfo);
  487. JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_COMMODITY_SALES_RETURN);
  488. input.getJSONObject("input").put("selinfo", JSONObject.parseObject(ref));
  489. JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_COMMODITY_SALES_RETURN);
  490. return SiUtil.makeReturnWithoutOutput(result, "商品销售退货成功。");
  491. }
  492. public ResultVo<String> deleteGoods(String fixmedinsBchno, int type) {
  493. JSONObject input = exec.makeTradeHeader(SiFunction.DELETE_COMMODITY_INFO);
  494. JSONObject data = new JSONObject();
  495. data.put("fixmedins_bchno", fixmedinsBchno);
  496. data.put("inv_data_type", type); // 1-盘存信息;2-库存变更信息;3-采购信息;4-销售信息
  497. input.getJSONObject("input").put("data", data);
  498. JSONObject result = exec.executeTrade(input, SiFunction.DELETE_COMMODITY_INFO);
  499. return SiUtil.makeReturnWithoutOutput(result, "商品删除成功。");
  500. }
  501. public ResultVo<String> modifySetllistState(String psnNo, String setlId, int type) {
  502. JSONObject input = exec.makeTradeHeader(SiFunction.MODIFY_SI_SETTLE_STATE);
  503. JSONObject data = new JSONObject();
  504. data.put("psn_no", psnNo);
  505. data.put("setl_id", setlId);
  506. data.put("stas_type", type); // 0未提交,1已提交
  507. input.getJSONObject("input").put("data", data);
  508. JSONObject result = exec.executeTrade(input, SiFunction.MODIFY_SI_SETTLE_STATE);
  509. log.info("【操作员:{}】,结算清单状态修改:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  510. return SiUtil.makeReturnWithoutOutput(result, "结算清单状态修改成功。");
  511. }
  512. public ResultVo<JSONObject> querySetllistInfo(String psnNo, String setlId) {
  513. JSONObject input = exec.makeTradeHeader(SiFunction.QUERY_SI_SETTLE_INFO);
  514. JSONObject data = new JSONObject();
  515. data.put("psn_no", psnNo);
  516. data.put("setl_id", setlId);
  517. input.getJSONObject("input").put("data", data);
  518. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_SI_SETTLE_INFO);
  519. log.info("【操作员:{}】,结算清单信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  520. Integer infcode = result.getInteger(RESULT_CODE);
  521. if (null == infcode) {
  522. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  523. }
  524. if (infcode == 0) {
  525. return ResultVoUtil.success(result.getJSONObject(OUTPUT));
  526. }
  527. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  528. }
  529. }