ViewFacade.java 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. package com.diagbot.facade;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.baomidou.mybatisplus.core.conditions.Wrapper;
  5. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  6. import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
  7. import com.diagbot.biz.push.entity.Lis;
  8. import com.diagbot.dto.RespDTO;
  9. import com.diagbot.entity.*;
  10. import com.diagbot.enums.IsDeleteEnum;
  11. import com.diagbot.facade.data.*;
  12. import com.diagbot.util.DateUtil;
  13. import com.diagbot.util.EntityUtil;
  14. import com.diagbot.util.ReadProperties;
  15. import com.diagbot.util.TZDBConn;
  16. import com.diagbot.vo.OldInfoVo;
  17. import com.diagbot.vo.data.AHomePageIngVO;
  18. import com.diagbot.vo.data.AHomePageVO;
  19. import com.diagbot.vo.data.XyHomePageVo;
  20. import com.google.common.collect.Lists;
  21. import lombok.extern.log4j.Log4j;
  22. import org.apache.commons.httpclient.NameValuePair;
  23. import org.apache.commons.httpclient.methods.PostMethod;
  24. import org.apache.commons.lang.StringEscapeUtils;
  25. import org.apache.commons.httpclient.NameValuePair;
  26. import org.apache.commons.httpclient.methods.PostMethod;
  27. import org.apache.commons.lang.StringUtils;
  28. import org.apache.cxf.endpoint.Client;
  29. import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
  30. import org.apache.http.client.methods.CloseableHttpResponse;
  31. import org.apache.http.client.methods.HttpPost;
  32. import org.apache.http.entity.ContentType;
  33. import org.apache.http.entity.StringEntity;
  34. import org.apache.http.impl.client.CloseableHttpClient;
  35. import org.apache.http.impl.client.HttpClients;
  36. import org.apache.http.util.EntityUtils;
  37. import org.springframework.beans.BeanUtils;
  38. import org.springframework.beans.factory.annotation.Autowired;
  39. import org.springframework.scheduling.annotation.Scheduled;
  40. import org.springframework.stereotype.Component;
  41. import org.springframework.web.bind.annotation.RequestParam;
  42. import java.text.ParsePosition;
  43. import java.text.SimpleDateFormat;
  44. import java.time.LocalDateTime;
  45. import java.time.temporal.ChronoUnit;
  46. import java.util.*;
  47. /**
  48. * 视图拉取(科室,医嘱,病案首页,检查检验信息结果)
  49. */
  50. @Component
  51. public class ViewFacade {
  52. @Autowired
  53. private ABasDeptInfoFacade aBasDeptInfoFacade;
  54. @Autowired
  55. private ADoctorAdviceFacade aDoctorAdviceFacade;
  56. @Autowired
  57. private AHomePageFacade aHomePageFacade;
  58. @Autowired
  59. private AHomeDiagnoseInfoFacade aHomeDiagnoseInfoFacade;
  60. @Autowired
  61. private AHomeOperationInfoFacade aHomeOperationInfoFacade;
  62. @Autowired
  63. private AMedLisResultFacade aMedLisResultFacade;
  64. @Autowired
  65. private AMedPacsResultFacade aMedPacsResultFacade;
  66. @Autowired
  67. private AMedPacsInfoFacade aMedPacsInfoFacade;
  68. @Autowired
  69. private AMedLisInfoFacade aMedLisInfoFacade;
  70. @Autowired
  71. private AMedAbnormalInfoFacade aMedAbnormalInfoFacade;
  72. @Autowired
  73. private ReadProperties readProperties;
  74. @Autowired
  75. private AMedicalRecordFacade aMedicalRecordFacade;
  76. @Autowired
  77. private AMedicalRecordContentFacade aMedicalRecordContentFacade;
  78. @Autowired
  79. private ABehospitalInfoFacade aBehospitalInfoFacade;
  80. @Autowired
  81. private ABasDoctorInfoFacade aBasDoctorInfoFacade;
  82. private TZDBConn tzDBConn = new TZDBConn();
  83. /**
  84. * 定时任务每天晚上11点拉取历史病例
  85. */
  86. public void executeOldData() {
  87. String deptSql = "select * from dept where deptType='临床' and station='住院' ";
  88. String doctorAdviceSql = "select * from doctor_order where daStartDate >= to_date('" + DateUtil.yesterdayFormate() + "','yyyy-MM-dd')";
  89. String lisSql = "select * from ASSAY_LIST where repDate >= '" + DateUtil.yesterdayFormate() + "' and behospitalNum is not null";
  90. String pacsSql = "select * from CHECK_LIST where repDate >= '" + DateUtil.yesterdayFormate() + "' and behospitalNum is not null";
  91. String infoSql = "select * from admission_pat_regist where leaveHospitalDate >= '" + DateUtil.yesterdayFormate() + "'";
  92. try {
  93. Long startTime = System.currentTimeMillis();
  94. //更新前一天出院的入院登记信息
  95. this.getInfo(infoSql);
  96. //得到全部的科室信息并添加修改
  97. this.getDeptInfo(deptSql);
  98. //获取医生信息并修改添加
  99. aBasDoctorInfoFacade.executeDoctorPast();
  100. //得到前一天的医嘱信息并添加修改
  101. this.getDoctorAdvice(doctorAdviceSql);
  102. //得到前一天的化验信息和相应的化验结果并添加修改
  103. this.getLisInfo(lisSql);
  104. //得到前一天的检查信息和相应的检查结果并添加修改
  105. this.getPacsInfo(pacsSql);
  106. Long startTime2 = System.currentTimeMillis();
  107. aMedAbnormalInfoFacade.saveAbnormalInfo("每天拉去历史数据成功", "", "所用时间" + (startTime2 - startTime), DateUtil.now().toString(), "");
  108. } catch (Exception e) {
  109. aMedAbnormalInfoFacade.saveAbnormalInfo("每天拉去历史数据失败", "", "", DateUtil.now().toString(), e.getMessage());
  110. }
  111. }
  112. /**
  113. * 根据出院时间来拉取历史数据
  114. *
  115. * @param startDate
  116. * @param stopDate
  117. */
  118. public void executeData(String startDate, String stopDate) {
  119. //获取入院登记表中的信息
  120. String infoSql = "select * from admission_pat_regist where leaveHospitalDate >= '" + startDate + "' and leaveHospitalDate <= '" + stopDate + "'";
  121. List<BehospitalInfo> behospitalInfoList = this.getInfo(infoSql);
  122. this.a(behospitalInfoList);
  123. }
  124. /**
  125. * 根据入院时间来拉取历史数据
  126. *
  127. * @param startDate
  128. * @param stopDate
  129. */
  130. public void executeOldData(String startDate, String stopDate) {
  131. //获取入院登记表中的信息
  132. String infoSql = "select * from admission_pat_regist where behospitalDate >= '" + startDate + "' and behospitalDate <= '" + stopDate + "'";
  133. List<BehospitalInfo> behospitalInfoList = this.getInfo(infoSql);
  134. this.a(behospitalInfoList);
  135. }
  136. /**
  137. * 根据住院号来拉取历史数据
  138. *
  139. * @param
  140. */
  141. public String executeOldDataOne(OldInfoVo oldInfoVo) {
  142. try{
  143. String behospitalCode=oldInfoVo.getBehospitalCode();
  144. //分割住院号与住院次数
  145. String hospitalCode = behospitalCode.substring(0, behospitalCode.indexOf("_"));
  146. String hospitalNum = behospitalCode.substring(hospitalCode.length() + 1, behospitalCode.length());
  147. //获取入院登记表中的信息
  148. String infoSql = "select * from admission_pat_regist where behospitalCode = '" + hospitalCode + "' and behospitalNum = '" + hospitalNum + "'";
  149. List<BehospitalInfo> behospitalInfoList = this.getInfo(infoSql);
  150. this.a(behospitalInfoList);
  151. return "true";
  152. }catch (Exception e){
  153. return e.getMessage();
  154. }
  155. }
  156. /**
  157. * 单独更新病案首页
  158. */
  159. public void executeHome() {
  160. List<BehospitalInfo> behospitalInfoList = aBehospitalInfoFacade.list();
  161. if (behospitalInfoList.size() > 0) {
  162. behospitalInfoList.forEach(s -> {
  163. //获取拼接前的behospitalCode和behospitalNum
  164. String behospitalCode = s.getBehospitalCode();
  165. String hospitalCode = behospitalCode.substring(0, behospitalCode.indexOf("_"));
  166. String hospitalNum = behospitalCode.substring(hospitalCode.length() + 1, behospitalCode.length());
  167. //获取病案首页
  168. XyHomePageVo xyHomePageVo = new XyHomePageVo();
  169. xyHomePageVo.setBehospitalCode(hospitalCode);
  170. xyHomePageVo.setHospitalId("35");
  171. xyHomePageVo.setFileCode(hospitalNum);
  172. xyHomePageVo.setDockModeType("0");
  173. this.getHomePageByView(xyHomePageVo);
  174. });
  175. }
  176. }
  177. /**
  178. * 获取病人信息
  179. *
  180. * @param behospitalInfoList
  181. */
  182. public void a(List<BehospitalInfo> behospitalInfoList) {
  183. //根据入院登记表的信息来查所需文书
  184. if (behospitalInfoList.size() > 0) {
  185. behospitalInfoList.forEach(s -> {
  186. //获取拼接前的behospitalCode和behospitalNum
  187. String behospitalCode = s.getBehospitalCode();
  188. String hospitalCode = behospitalCode.substring(0, behospitalCode.indexOf("_"));
  189. String hospitalNum = behospitalCode.substring(hospitalCode.length() + 1, behospitalCode.length());
  190. //获取文书信息和文书详情信息
  191. String recordSql = "select * from record_list where behospitalCode= '" + hospitalCode + "' and behospitalnum= '" + hospitalNum + "'";
  192. this.getRecord(recordSql);
  193. //获取病案首页
  194. XyHomePageVo xyHomePageVo = new XyHomePageVo();
  195. xyHomePageVo.setBehospitalCode(hospitalCode);
  196. xyHomePageVo.setHospitalId("35");
  197. xyHomePageVo.setFileCode(hospitalNum);
  198. xyHomePageVo.setDockModeType("0");
  199. this.getHomePageByView(xyHomePageVo);
  200. //获取病人医嘱
  201. String doctorAdviceSql = "select * from doctor_order where behospitalCode= '" + hospitalCode + "' and behospitalnum= '" + hospitalNum + "'";
  202. this.getDoctorAdvice(doctorAdviceSql);
  203. //获取化验信息和相应的化验结果并添加修改
  204. String lisSql = "select * from ASSAY_LIST where behospitalCode= '" + hospitalCode + "' and behospitalnum= '" + hospitalNum + "'";
  205. this.getLisInfo(lisSql);
  206. //获取检查信息和相应的检查结果并添加修改
  207. String pacsSql = "select * from CHECK_LIST where behospitalCode= '" + hospitalCode + "' and behospitalnum= '" + hospitalNum + "'";
  208. this.getPacsInfo(pacsSql);
  209. });
  210. aMedAbnormalInfoFacade.saveAbnormalInfo("历史数据拉取完成", "", "", JSON.toJSONString(behospitalInfoList), "");
  211. }
  212. }
  213. /**
  214. * 从试图获取病案首页(诊断和手术)
  215. */
  216. public RespDTO<Map<String, Object>> getHomePageByView(XyHomePageVo xyHomePageVo) {
  217. //保存入参
  218. aMedAbnormalInfoFacade.saveAbnormalInfo("病案首页入参", xyHomePageVo.getHomePageId(), xyHomePageVo.getBehospitalCode(), JSON.toJSONString(xyHomePageVo), "");
  219. Long modeId = Long.valueOf("6");//病案首页默认为6
  220. String behospitalCode = xyHomePageVo.getBehospitalCode() + "_" + xyHomePageVo.getFileCode();
  221. //从视图拉取数据
  222. String homepageSql = "select * from homePage where behospitalCode= '" + xyHomePageVo.getBehospitalCode() + "' and behospitalnum= '" + xyHomePageVo.getFileCode() + "'";
  223. String diagSql = "select * from homePage_diag where behospitalCode= '" + xyHomePageVo.getBehospitalCode() + "' and behospitalnum= '" + xyHomePageVo.getFileCode() + "'";
  224. String opsSql = "select * from homePage_operation where behospitalCode= '" + xyHomePageVo.getBehospitalCode() + "' and behospitalnum= '" + xyHomePageVo.getFileCode() + "'";
  225. this.getHomePage(homepageSql);
  226. this.getHomeDiagnose(diagSql);
  227. this.getHomeOperation(opsSql);
  228. //根据传过来的方案编码来判断是否返回评分(1:返回评分,其他只保存数据)
  229. if (xyHomePageVo.getDockModeType().equals("1")) {
  230. QueryWrapper<BehospitalInfo> wrapper = new QueryWrapper<>();
  231. wrapper.eq("behospital_code", behospitalCode)
  232. .eq("is_deleted", IsDeleteEnum.N);
  233. BehospitalInfo behospitalInfo = aBehospitalInfoFacade.getOne(wrapper);
  234. String url = "";
  235. if (behospitalInfo != null && behospitalInfo.getIsPlacefile().equals("1")) {
  236. url = readProperties.getProcessQcUrl() + "?behospitalCode=" + behospitalCode + "&hospitalId=" + xyHomePageVo.getHospitalId() + "&modeId=" + modeId;
  237. }
  238. Map<String, Object> map = new HashMap<String, Object>();
  239. map.put("url", url);
  240. return RespDTO.onSuc(map);
  241. }
  242. return RespDTO.onSuc(true);
  243. }
  244. /**
  245. * 从视图获取科室信息
  246. *
  247. * @param sql
  248. */
  249. public void getDeptInfo(String sql) {
  250. List<BasDeptInfo> deptInfos = new ArrayList<>();
  251. try {
  252. deptInfos = tzDBConn.getDeptInfo(sql);
  253. aBasDeptInfoFacade.execute(deptInfos);
  254. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取科室信息正常", "", sql, JSON.toJSONString(deptInfos), "");
  255. } catch (Exception e) {
  256. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取科室信息错误", "", sql, JSON.toJSONString(deptInfos), e.getMessage());
  257. }
  258. }
  259. /**
  260. * 从视图获取出院诊断信息
  261. *
  262. * @param sql
  263. */
  264. public void getHomeDiagnose(String sql) {
  265. List<HomeDiagnoseInfo> homeDiagnoseInfos = new ArrayList<>();
  266. try {
  267. homeDiagnoseInfos = tzDBConn.getHomeDiagnose(sql);
  268. aHomeDiagnoseInfoFacade.execute(homeDiagnoseInfos);
  269. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取出院诊断信息正常", "", sql, JSON.toJSONString(homeDiagnoseInfos), "");
  270. } catch (Exception e) {
  271. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取出院诊断信息错误", "", sql, JSON.toJSONString(homeDiagnoseInfos), e.getMessage());
  272. }
  273. }
  274. /**
  275. * 从视图获取病案首页手术信息
  276. *
  277. * @param sql
  278. */
  279. public void getHomeOperation(String sql) {
  280. List<HomeOperationInfo> homeOperation = new ArrayList<>();
  281. try {
  282. homeOperation = tzDBConn.getHomeOperation(sql);
  283. aHomeOperationInfoFacade.execute(homeOperation);
  284. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取病案首页手术信息正常", "", sql, JSON.toJSONString(homeOperation), "");
  285. } catch (Exception e) {
  286. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取病案首页手术信息错误", "", sql, JSON.toJSONString(homeOperation), e.getMessage());
  287. }
  288. }
  289. /**
  290. * 从视图获取病案首页信息
  291. *
  292. * @param sql
  293. */
  294. public void getHomePage(String sql) {
  295. List<HomePage> homePage = new ArrayList<>();
  296. try {
  297. homePage = tzDBConn.getHomePage(sql);
  298. aHomePageFacade.execute(homePage);
  299. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取病案首页手术信息正常", "", sql, JSON.toJSONString(homePage), "");
  300. } catch (Exception e) {
  301. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取病案首页手术信息错误", "", sql, JSON.toJSONString(homePage), e.getMessage());
  302. }
  303. }
  304. /**
  305. * 从视图获取医嘱信息
  306. *
  307. * @param sql
  308. */
  309. public void getDoctorAdvice(String sql) {
  310. List<DoctorAdvice> doctorAdvice = new ArrayList<>();
  311. try {
  312. doctorAdvice = tzDBConn.getDoctorAdvice(sql);
  313. aDoctorAdviceFacade.execute(doctorAdvice);
  314. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取医嘱信息正常", "", sql, JSON.toJSONString(doctorAdvice), "");
  315. } catch (Exception e) {
  316. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取医嘱信息错误", "", sql, JSON.toJSONString(doctorAdvice), e.getMessage());
  317. }
  318. }
  319. /**
  320. * 从视图获取化验信息
  321. *
  322. * @param sql
  323. */
  324. public void getLisInfo(String sql) {
  325. List<MedLisInfo> lisInfos = new ArrayList<>();
  326. try {
  327. lisInfos = tzDBConn.getLisInfo(sql);
  328. aMedLisInfoFacade.execute(lisInfos);
  329. if (lisInfos.size() > 0) {
  330. lisInfos.forEach(lis -> {
  331. this.getLisResult(lis.getRepNo());
  332. });
  333. }
  334. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取化验信息正常", "", sql, JSON.toJSONString(lisInfos), "");
  335. } catch (Exception e) {
  336. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取化验信息错误", "", sql, JSON.toJSONString(lisInfos), e.getMessage());
  337. }
  338. }
  339. /**
  340. * 从视图获取化验结果信息
  341. *
  342. * @param repNo
  343. */
  344. public void getLisResult(String repNo) {
  345. List<MedLisResult> lisResults = new ArrayList<>();
  346. String sql = "select * from ASSAY_DETAILS where repNo='" + repNo + "'";
  347. try {
  348. lisResults = tzDBConn.getLisResult(sql);
  349. aMedLisResultFacade.execute(lisResults);
  350. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取化验结果信息正常", "", sql, JSON.toJSONString(lisResults), "");
  351. } catch (Exception e) {
  352. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取化验结果信息错误", "", sql, JSON.toJSONString(lisResults), e.getMessage());
  353. }
  354. }
  355. /**
  356. * 从视图获取检查信息
  357. *
  358. * @param sql
  359. */
  360. public void getPacsInfo(String sql) {
  361. List<MedPacsInfo> pacsInfos = new ArrayList<>();
  362. try {
  363. pacsInfos = tzDBConn.getPacsInfo(sql);
  364. aMedPacsInfoFacade.execute(pacsInfos);
  365. if (pacsInfos.size() > 0) {
  366. pacsInfos.forEach(pacs -> {
  367. this.getPacsResult(pacs.getRepNo());
  368. });
  369. }
  370. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取检查信息正常", "", sql, JSON.toJSONString(pacsInfos), "");
  371. } catch (Exception e) {
  372. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取检查信息错误", "", sql, JSON.toJSONString(pacsInfos), e.getMessage());
  373. }
  374. }
  375. /**
  376. * 从视图获取检查结果信息
  377. *
  378. * @param repNo
  379. */
  380. public void getPacsResult(String repNo) {
  381. List<MedPacsResult> pacsResults = new ArrayList<>();
  382. String sql = "select * from CHECK_DETAILS where repNo='" + repNo + "'";
  383. try {
  384. pacsResults = tzDBConn.getPacsResult(sql);
  385. aMedPacsResultFacade.execute(pacsResults);
  386. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取检查结果信息正常", "", sql, JSON.toJSONString(pacsResults), "");
  387. } catch (Exception e) {
  388. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取检查结果信息错误", "", sql, JSON.toJSONString(pacsResults), e.getMessage());
  389. }
  390. }
  391. /**
  392. * 从视图获取入院登记信息
  393. *
  394. * @param sql
  395. */
  396. public List<BehospitalInfo> getInfo(String sql) {
  397. List<BehospitalInfo> behospitalInfoList = new ArrayList<>();
  398. try {
  399. behospitalInfoList = tzDBConn.getBehospitalInfo(sql);
  400. aBehospitalInfoFacade.execute(behospitalInfoList);
  401. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取入院登记信息正常", "", sql, JSON.toJSONString(behospitalInfoList), "");
  402. } catch (Exception e) {
  403. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取入院登记信息错误", "", sql, JSON.toJSONString(behospitalInfoList), e.getMessage());
  404. }
  405. return behospitalInfoList;
  406. }
  407. /**
  408. * 从视图获取文书信息
  409. *
  410. * @param sql
  411. */
  412. public void getRecord(String sql) {
  413. List<MedicalRecord> medicalRecordList = new ArrayList<>();
  414. try {
  415. medicalRecordList = tzDBConn.getMedicalRecord(sql);
  416. if (medicalRecordList.size() > 0) {
  417. medicalRecordList.forEach(s -> {
  418. //获取文书详情
  419. String recId = s.getRecId();
  420. //截取rec_id後面的_次數跟接口相對潁上
  421. int inedx = s.getRecId().lastIndexOf("_");
  422. s.setRecId(s.getRecId().substring(0, inedx));
  423. this.getRecordContent(recId);
  424. });
  425. }
  426. aMedicalRecordFacade.execute(medicalRecordList);
  427. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取文书信息正常", "", sql, JSON.toJSONString(medicalRecordList), "");
  428. } catch (Exception e) {
  429. aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取文书信息错误", "", sql, JSON.toJSONString(medicalRecordList), e.getMessage());
  430. }
  431. }
  432. /**
  433. * 从webService获取文书详情信息
  434. *
  435. * @param recId
  436. */
  437. public void getRecordContent(String recId) {
  438. List<MedicalRecordContent> medicalRecordContentList = new ArrayList<>();
  439. try {
  440. String html = this.getHtml(recId);
  441. if (StringUtils.isBlank(html) || html.equals("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
  442. "<string xmlns=\"http://www.healthcare.supcon.com/wsmeddoc/\" />")) {
  443. aMedAbnormalInfoFacade.saveAbnormalInfo("从webService获取文书详情信息为空", "", recId, JSON.toJSONString(html), "");
  444. return;
  445. }
  446. MedicalRecordContent medicalRecordContent = new MedicalRecordContent();
  447. medicalRecordContent.setRecId(recId);
  448. medicalRecordContent.setHospitalId(Long.valueOf("35"));
  449. System.out.println("返回数据:" + html);
  450. medicalRecordContent.setXmlText(html);
  451. //截取rec_id後面的_次數跟接口相對潁上
  452. int inedx = medicalRecordContent.getRecId().lastIndexOf("_");
  453. medicalRecordContent.setRecId(medicalRecordContent.getRecId().substring(0, inedx));
  454. medicalRecordContentList.add(medicalRecordContent);
  455. aMedicalRecordContentFacade.execute(medicalRecordContentList);
  456. aMedAbnormalInfoFacade.saveAbnormalInfo("从webService获取文书详情信息正常", "", recId, JSON.toJSONString(medicalRecordContentList), "");
  457. } catch (Exception e) {
  458. aMedAbnormalInfoFacade.saveAbnormalInfo("从webService获取文书详情信息错误", "", recId, JSON.toJSONString(medicalRecordContentList), e.getMessage());
  459. }
  460. }
  461. public String getHtml(String recId) {
  462. String url = "http://132.147.254.142:8093/DocService.asmx/GetDocsHTML";
  463. try {
  464. PostMethod postMethod = null;
  465. postMethod = new PostMethod(url);
  466. postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
  467. NameValuePair[] data = {
  468. // new NameValuePair("startTime",""),
  469. new NameValuePair("szDocIDs", recId)
  470. };
  471. postMethod.setRequestBody(data);
  472. org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
  473. int response = httpClient.executeMethod(postMethod);
  474. String result = postMethod.getResponseBodyAsString();
  475. String html = this.decode(result);
  476. return html;
  477. } catch (Exception e) {
  478. // System.out.println("请求异常"+e.getMessage());
  479. throw new RuntimeException(e.getMessage());
  480. } finally {
  481. }
  482. }
  483. /**
  484. * 数值行代码转换成中文
  485. *
  486. * @param result
  487. * @return
  488. */
  489. public String decode(String result) {
  490. String html = StringEscapeUtils.unescapeXml(result);
  491. String[] tmp = html.split("&#|&#|;");
  492. StringBuilder sb = new StringBuilder();
  493. for (int i = 0; i < tmp.length; i++) {
  494. if (tmp[i].matches("\\d{5}")) {
  495. sb.append((char) Integer.parseInt(tmp[i]));
  496. } else {
  497. sb.append(tmp[i]);
  498. }
  499. }
  500. return sb.toString();
  501. }
  502. /**
  503. * 查看30天前的病人住院登记信息
  504. */
  505. public void execute(String date) {
  506. LocalDateTime now = LocalDateTime.now();
  507. now = now.minus(Integer.parseInt(date), ChronoUnit.DAYS);
  508. List<BehospitalInfo> list = aBehospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
  509. .le("leave_hospital_date", DateUtil.now())
  510. .ge("leave_hospital_date", now));
  511. if (list.size() > 0) {
  512. list.forEach(behospitalInfo -> {
  513. this.IfCoincide(behospitalInfo.getBehospitalCode());
  514. });
  515. }
  516. }
  517. /**
  518. * 判断文书量跟视图是否一致
  519. *
  520. * @param code
  521. */
  522. public void IfCoincide(String code) {
  523. try {
  524. Integer myCount = 0;
  525. myCount = aMedicalRecordFacade.count(new QueryWrapper<MedicalRecord>()
  526. .eq("behospital_code", code)
  527. .eq("hospital_id", Long.valueOf("35"))
  528. .eq("is_deleted", IsDeleteEnum.N.getKey()));
  529. String hospitalCode = code.substring(0, code.indexOf("_"));
  530. String hospitalNum = code.substring(hospitalCode.length() + 1, code.length());
  531. String sql = "select count(*) as count from record_list where behospitalCode= '" + hospitalCode + "' and behospitalnum= '" + hospitalNum + "'";
  532. Integer count = tzDBConn.getCount(sql);
  533. if (count != 0) {
  534. if (count != myCount) {
  535. aMedicalRecordFacade.remove(new QueryWrapper<MedicalRecord>()
  536. .eq("behospital_code", code)
  537. .eq("hospital_id", Long.valueOf("35")));
  538. OldInfoVo oldInfoV =new OldInfoVo();
  539. oldInfoV.setBehospitalCode(code);
  540. this.executeOldDataOne(oldInfoV);
  541. aMedAbnormalInfoFacade.saveAbnormalInfo("补传数据成功", code, "视图文书数量为" + count, "本地数量为" + myCount, "");
  542. }
  543. }
  544. } catch (Exception e) {
  545. aMedAbnormalInfoFacade.saveAbnormalInfo("补传数据失败", code, "", e.getMessage(), "");
  546. }
  547. }
  548. }