123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608 |
- package com.diagbot.facade;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.Wrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
- import com.diagbot.biz.push.entity.Lis;
- import com.diagbot.dto.RespDTO;
- import com.diagbot.entity.*;
- import com.diagbot.enums.IsDeleteEnum;
- import com.diagbot.facade.data.*;
- import com.diagbot.util.DateUtil;
- import com.diagbot.util.EntityUtil;
- import com.diagbot.util.ReadProperties;
- import com.diagbot.util.TZDBConn;
- import com.diagbot.vo.OldInfoVo;
- import com.diagbot.vo.data.AHomePageIngVO;
- import com.diagbot.vo.data.AHomePageVO;
- import com.diagbot.vo.data.XyHomePageVo;
- import com.google.common.collect.Lists;
- import lombok.extern.log4j.Log4j;
- import org.apache.commons.httpclient.NameValuePair;
- import org.apache.commons.httpclient.methods.PostMethod;
- import org.apache.commons.lang.StringEscapeUtils;
- import org.apache.commons.httpclient.NameValuePair;
- import org.apache.commons.httpclient.methods.PostMethod;
- import org.apache.commons.lang.StringUtils;
- import org.apache.cxf.endpoint.Client;
- import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
- import org.apache.http.client.methods.CloseableHttpResponse;
- import org.apache.http.client.methods.HttpPost;
- import org.apache.http.entity.ContentType;
- import org.apache.http.entity.StringEntity;
- import org.apache.http.impl.client.CloseableHttpClient;
- import org.apache.http.impl.client.HttpClients;
- import org.apache.http.util.EntityUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.stereotype.Component;
- import org.springframework.web.bind.annotation.RequestParam;
- import java.text.ParsePosition;
- import java.text.SimpleDateFormat;
- import java.time.LocalDateTime;
- import java.time.temporal.ChronoUnit;
- import java.util.*;
- /**
- * 视图拉取(科室,医嘱,病案首页,检查检验信息结果)
- */
- @Component
- public class ViewFacade {
- @Autowired
- private ABasDeptInfoFacade aBasDeptInfoFacade;
- @Autowired
- private ADoctorAdviceFacade aDoctorAdviceFacade;
- @Autowired
- private AHomePageFacade aHomePageFacade;
- @Autowired
- private AHomeDiagnoseInfoFacade aHomeDiagnoseInfoFacade;
- @Autowired
- private AHomeOperationInfoFacade aHomeOperationInfoFacade;
- @Autowired
- private AMedLisResultFacade aMedLisResultFacade;
- @Autowired
- private AMedPacsResultFacade aMedPacsResultFacade;
- @Autowired
- private AMedPacsInfoFacade aMedPacsInfoFacade;
- @Autowired
- private AMedLisInfoFacade aMedLisInfoFacade;
- @Autowired
- private AMedAbnormalInfoFacade aMedAbnormalInfoFacade;
- @Autowired
- private ReadProperties readProperties;
- @Autowired
- private AMedicalRecordFacade aMedicalRecordFacade;
- @Autowired
- private AMedicalRecordContentFacade aMedicalRecordContentFacade;
- @Autowired
- private ABehospitalInfoFacade aBehospitalInfoFacade;
- @Autowired
- private ABasDoctorInfoFacade aBasDoctorInfoFacade;
- private TZDBConn tzDBConn = new TZDBConn();
- /**
- * 定时任务每天晚上11点拉取历史病例
- */
- public void executeOldData() {
- String deptSql = "select * from dept where deptType='临床' and station='住院' ";
- String doctorAdviceSql = "select * from doctor_order where daStartDate >= to_date('" + DateUtil.yesterdayFormate() + "','yyyy-MM-dd')";
- String lisSql = "select * from ASSAY_LIST where repDate >= '" + DateUtil.yesterdayFormate() + "' and behospitalNum is not null";
- String pacsSql = "select * from CHECK_LIST where repDate >= '" + DateUtil.yesterdayFormate() + "' and behospitalNum is not null";
- String infoSql = "select * from admission_pat_regist where leaveHospitalDate >= '" + DateUtil.yesterdayFormate() + "'";
- try {
- Long startTime = System.currentTimeMillis();
- //更新前一天出院的入院登记信息
- this.getInfo(infoSql);
- //得到全部的科室信息并添加修改
- this.getDeptInfo(deptSql);
- //获取医生信息并修改添加
- aBasDoctorInfoFacade.executeDoctorPast();
- //得到前一天的医嘱信息并添加修改
- this.getDoctorAdvice(doctorAdviceSql);
- //得到前一天的化验信息和相应的化验结果并添加修改
- this.getLisInfo(lisSql);
- //得到前一天的检查信息和相应的检查结果并添加修改
- this.getPacsInfo(pacsSql);
- Long startTime2 = System.currentTimeMillis();
- aMedAbnormalInfoFacade.saveAbnormalInfo("每天拉去历史数据成功", "", "所用时间" + (startTime2 - startTime), DateUtil.now().toString(), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("每天拉去历史数据失败", "", "", DateUtil.now().toString(), e.getMessage());
- }
- }
- /**
- * 根据出院时间来拉取历史数据
- *
- * @param startDate
- * @param stopDate
- */
- public void executeData(String startDate, String stopDate) {
- //获取入院登记表中的信息
- String infoSql = "select * from admission_pat_regist where leaveHospitalDate >= '" + startDate + "' and leaveHospitalDate <= '" + stopDate + "'";
- List<BehospitalInfo> behospitalInfoList = this.getInfo(infoSql);
- this.a(behospitalInfoList);
- }
- /**
- * 根据入院时间来拉取历史数据
- *
- * @param startDate
- * @param stopDate
- */
- public void executeOldData(String startDate, String stopDate) {
- //获取入院登记表中的信息
- String infoSql = "select * from admission_pat_regist where behospitalDate >= '" + startDate + "' and behospitalDate <= '" + stopDate + "'";
- List<BehospitalInfo> behospitalInfoList = this.getInfo(infoSql);
- this.a(behospitalInfoList);
- }
- /**
- * 根据住院号来拉取历史数据
- *
- * @param
- */
- public String executeOldDataOne(OldInfoVo oldInfoVo) {
- try{
- String behospitalCode=oldInfoVo.getBehospitalCode();
- //分割住院号与住院次数
- String hospitalCode = behospitalCode.substring(0, behospitalCode.indexOf("_"));
- String hospitalNum = behospitalCode.substring(hospitalCode.length() + 1, behospitalCode.length());
- //获取入院登记表中的信息
- String infoSql = "select * from admission_pat_regist where behospitalCode = '" + hospitalCode + "' and behospitalNum = '" + hospitalNum + "'";
- List<BehospitalInfo> behospitalInfoList = this.getInfo(infoSql);
- this.a(behospitalInfoList);
- return "true";
- }catch (Exception e){
- return e.getMessage();
- }
- }
- /**
- * 单独更新病案首页
- */
- public void executeHome() {
- List<BehospitalInfo> behospitalInfoList = aBehospitalInfoFacade.list();
- if (behospitalInfoList.size() > 0) {
- behospitalInfoList.forEach(s -> {
- //获取拼接前的behospitalCode和behospitalNum
- String behospitalCode = s.getBehospitalCode();
- String hospitalCode = behospitalCode.substring(0, behospitalCode.indexOf("_"));
- String hospitalNum = behospitalCode.substring(hospitalCode.length() + 1, behospitalCode.length());
- //获取病案首页
- XyHomePageVo xyHomePageVo = new XyHomePageVo();
- xyHomePageVo.setBehospitalCode(hospitalCode);
- xyHomePageVo.setHospitalId("35");
- xyHomePageVo.setFileCode(hospitalNum);
- xyHomePageVo.setDockModeType("0");
- this.getHomePageByView(xyHomePageVo);
- });
- }
- }
- /**
- * 获取病人信息
- *
- * @param behospitalInfoList
- */
- public void a(List<BehospitalInfo> behospitalInfoList) {
- //根据入院登记表的信息来查所需文书
- if (behospitalInfoList.size() > 0) {
- behospitalInfoList.forEach(s -> {
- //获取拼接前的behospitalCode和behospitalNum
- String behospitalCode = s.getBehospitalCode();
- String hospitalCode = behospitalCode.substring(0, behospitalCode.indexOf("_"));
- String hospitalNum = behospitalCode.substring(hospitalCode.length() + 1, behospitalCode.length());
- //获取文书信息和文书详情信息
- String recordSql = "select * from record_list where behospitalCode= '" + hospitalCode + "' and behospitalnum= '" + hospitalNum + "'";
- this.getRecord(recordSql);
- //获取病案首页
- XyHomePageVo xyHomePageVo = new XyHomePageVo();
- xyHomePageVo.setBehospitalCode(hospitalCode);
- xyHomePageVo.setHospitalId("35");
- xyHomePageVo.setFileCode(hospitalNum);
- xyHomePageVo.setDockModeType("0");
- this.getHomePageByView(xyHomePageVo);
- //获取病人医嘱
- String doctorAdviceSql = "select * from doctor_order where behospitalCode= '" + hospitalCode + "' and behospitalnum= '" + hospitalNum + "'";
- this.getDoctorAdvice(doctorAdviceSql);
- //获取化验信息和相应的化验结果并添加修改
- String lisSql = "select * from ASSAY_LIST where behospitalCode= '" + hospitalCode + "' and behospitalnum= '" + hospitalNum + "'";
- this.getLisInfo(lisSql);
- //获取检查信息和相应的检查结果并添加修改
- String pacsSql = "select * from CHECK_LIST where behospitalCode= '" + hospitalCode + "' and behospitalnum= '" + hospitalNum + "'";
- this.getPacsInfo(pacsSql);
- });
- aMedAbnormalInfoFacade.saveAbnormalInfo("历史数据拉取完成", "", "", JSON.toJSONString(behospitalInfoList), "");
- }
- }
- /**
- * 从试图获取病案首页(诊断和手术)
- */
- public RespDTO<Map<String, Object>> getHomePageByView(XyHomePageVo xyHomePageVo) {
- //保存入参
- aMedAbnormalInfoFacade.saveAbnormalInfo("病案首页入参", xyHomePageVo.getHomePageId(), xyHomePageVo.getBehospitalCode(), JSON.toJSONString(xyHomePageVo), "");
- Long modeId = Long.valueOf("6");//病案首页默认为6
- String behospitalCode = xyHomePageVo.getBehospitalCode() + "_" + xyHomePageVo.getFileCode();
- //从视图拉取数据
- String homepageSql = "select * from homePage where behospitalCode= '" + xyHomePageVo.getBehospitalCode() + "' and behospitalnum= '" + xyHomePageVo.getFileCode() + "'";
- String diagSql = "select * from homePage_diag where behospitalCode= '" + xyHomePageVo.getBehospitalCode() + "' and behospitalnum= '" + xyHomePageVo.getFileCode() + "'";
- String opsSql = "select * from homePage_operation where behospitalCode= '" + xyHomePageVo.getBehospitalCode() + "' and behospitalnum= '" + xyHomePageVo.getFileCode() + "'";
- this.getHomePage(homepageSql);
- this.getHomeDiagnose(diagSql);
- this.getHomeOperation(opsSql);
- //根据传过来的方案编码来判断是否返回评分(1:返回评分,其他只保存数据)
- if (xyHomePageVo.getDockModeType().equals("1")) {
- QueryWrapper<BehospitalInfo> wrapper = new QueryWrapper<>();
- wrapper.eq("behospital_code", behospitalCode)
- .eq("is_deleted", IsDeleteEnum.N);
- BehospitalInfo behospitalInfo = aBehospitalInfoFacade.getOne(wrapper);
- String url = "";
- if (behospitalInfo != null && behospitalInfo.getIsPlacefile().equals("1")) {
- url = readProperties.getProcessQcUrl() + "?behospitalCode=" + behospitalCode + "&hospitalId=" + xyHomePageVo.getHospitalId() + "&modeId=" + modeId;
- }
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("url", url);
- return RespDTO.onSuc(map);
- }
- return RespDTO.onSuc(true);
- }
- /**
- * 从视图获取科室信息
- *
- * @param sql
- */
- public void getDeptInfo(String sql) {
- List<BasDeptInfo> deptInfos = new ArrayList<>();
- try {
- deptInfos = tzDBConn.getDeptInfo(sql);
- aBasDeptInfoFacade.execute(deptInfos);
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取科室信息正常", "", sql, JSON.toJSONString(deptInfos), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取科室信息错误", "", sql, JSON.toJSONString(deptInfos), e.getMessage());
- }
- }
- /**
- * 从视图获取出院诊断信息
- *
- * @param sql
- */
- public void getHomeDiagnose(String sql) {
- List<HomeDiagnoseInfo> homeDiagnoseInfos = new ArrayList<>();
- try {
- homeDiagnoseInfos = tzDBConn.getHomeDiagnose(sql);
- aHomeDiagnoseInfoFacade.execute(homeDiagnoseInfos);
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取出院诊断信息正常", "", sql, JSON.toJSONString(homeDiagnoseInfos), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取出院诊断信息错误", "", sql, JSON.toJSONString(homeDiagnoseInfos), e.getMessage());
- }
- }
- /**
- * 从视图获取病案首页手术信息
- *
- * @param sql
- */
- public void getHomeOperation(String sql) {
- List<HomeOperationInfo> homeOperation = new ArrayList<>();
- try {
- homeOperation = tzDBConn.getHomeOperation(sql);
- aHomeOperationInfoFacade.execute(homeOperation);
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取病案首页手术信息正常", "", sql, JSON.toJSONString(homeOperation), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取病案首页手术信息错误", "", sql, JSON.toJSONString(homeOperation), e.getMessage());
- }
- }
- /**
- * 从视图获取病案首页信息
- *
- * @param sql
- */
- public void getHomePage(String sql) {
- List<HomePage> homePage = new ArrayList<>();
- try {
- homePage = tzDBConn.getHomePage(sql);
- aHomePageFacade.execute(homePage);
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取病案首页手术信息正常", "", sql, JSON.toJSONString(homePage), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取病案首页手术信息错误", "", sql, JSON.toJSONString(homePage), e.getMessage());
- }
- }
- /**
- * 从视图获取医嘱信息
- *
- * @param sql
- */
- public void getDoctorAdvice(String sql) {
- List<DoctorAdvice> doctorAdvice = new ArrayList<>();
- try {
- doctorAdvice = tzDBConn.getDoctorAdvice(sql);
- aDoctorAdviceFacade.execute(doctorAdvice);
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取医嘱信息正常", "", sql, JSON.toJSONString(doctorAdvice), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取医嘱信息错误", "", sql, JSON.toJSONString(doctorAdvice), e.getMessage());
- }
- }
- /**
- * 从视图获取化验信息
- *
- * @param sql
- */
- public void getLisInfo(String sql) {
- List<MedLisInfo> lisInfos = new ArrayList<>();
- try {
- lisInfos = tzDBConn.getLisInfo(sql);
- aMedLisInfoFacade.execute(lisInfos);
- if (lisInfos.size() > 0) {
- lisInfos.forEach(lis -> {
- this.getLisResult(lis.getRepNo());
- });
- }
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取化验信息正常", "", sql, JSON.toJSONString(lisInfos), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取化验信息错误", "", sql, JSON.toJSONString(lisInfos), e.getMessage());
- }
- }
- /**
- * 从视图获取化验结果信息
- *
- * @param repNo
- */
- public void getLisResult(String repNo) {
- List<MedLisResult> lisResults = new ArrayList<>();
- String sql = "select * from ASSAY_DETAILS where repNo='" + repNo + "'";
- try {
- lisResults = tzDBConn.getLisResult(sql);
- aMedLisResultFacade.execute(lisResults);
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取化验结果信息正常", "", sql, JSON.toJSONString(lisResults), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取化验结果信息错误", "", sql, JSON.toJSONString(lisResults), e.getMessage());
- }
- }
- /**
- * 从视图获取检查信息
- *
- * @param sql
- */
- public void getPacsInfo(String sql) {
- List<MedPacsInfo> pacsInfos = new ArrayList<>();
- try {
- pacsInfos = tzDBConn.getPacsInfo(sql);
- aMedPacsInfoFacade.execute(pacsInfos);
- if (pacsInfos.size() > 0) {
- pacsInfos.forEach(pacs -> {
- this.getPacsResult(pacs.getRepNo());
- });
- }
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取检查信息正常", "", sql, JSON.toJSONString(pacsInfos), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取检查信息错误", "", sql, JSON.toJSONString(pacsInfos), e.getMessage());
- }
- }
- /**
- * 从视图获取检查结果信息
- *
- * @param repNo
- */
- public void getPacsResult(String repNo) {
- List<MedPacsResult> pacsResults = new ArrayList<>();
- String sql = "select * from CHECK_DETAILS where repNo='" + repNo + "'";
- try {
- pacsResults = tzDBConn.getPacsResult(sql);
- aMedPacsResultFacade.execute(pacsResults);
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取检查结果信息正常", "", sql, JSON.toJSONString(pacsResults), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取检查结果信息错误", "", sql, JSON.toJSONString(pacsResults), e.getMessage());
- }
- }
- /**
- * 从视图获取入院登记信息
- *
- * @param sql
- */
- public List<BehospitalInfo> getInfo(String sql) {
- List<BehospitalInfo> behospitalInfoList = new ArrayList<>();
- try {
- behospitalInfoList = tzDBConn.getBehospitalInfo(sql);
- aBehospitalInfoFacade.execute(behospitalInfoList);
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取入院登记信息正常", "", sql, JSON.toJSONString(behospitalInfoList), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取入院登记信息错误", "", sql, JSON.toJSONString(behospitalInfoList), e.getMessage());
- }
- return behospitalInfoList;
- }
- /**
- * 从视图获取文书信息
- *
- * @param sql
- */
- public void getRecord(String sql) {
- List<MedicalRecord> medicalRecordList = new ArrayList<>();
- try {
- medicalRecordList = tzDBConn.getMedicalRecord(sql);
- if (medicalRecordList.size() > 0) {
- medicalRecordList.forEach(s -> {
- //获取文书详情
- String recId = s.getRecId();
- //截取rec_id後面的_次數跟接口相對潁上
- int inedx = s.getRecId().lastIndexOf("_");
- s.setRecId(s.getRecId().substring(0, inedx));
- this.getRecordContent(recId);
- });
- }
- aMedicalRecordFacade.execute(medicalRecordList);
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取文书信息正常", "", sql, JSON.toJSONString(medicalRecordList), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从试图拉取文书信息错误", "", sql, JSON.toJSONString(medicalRecordList), e.getMessage());
- }
- }
- /**
- * 从webService获取文书详情信息
- *
- * @param recId
- */
- public void getRecordContent(String recId) {
- List<MedicalRecordContent> medicalRecordContentList = new ArrayList<>();
- try {
- String html = this.getHtml(recId);
- if (StringUtils.isBlank(html) || html.equals("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
- "<string xmlns=\"http://www.healthcare.supcon.com/wsmeddoc/\" />")) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从webService获取文书详情信息为空", "", recId, JSON.toJSONString(html), "");
- return;
- }
- MedicalRecordContent medicalRecordContent = new MedicalRecordContent();
- medicalRecordContent.setRecId(recId);
- medicalRecordContent.setHospitalId(Long.valueOf("35"));
- System.out.println("返回数据:" + html);
- medicalRecordContent.setXmlText(html);
- //截取rec_id後面的_次數跟接口相對潁上
- int inedx = medicalRecordContent.getRecId().lastIndexOf("_");
- medicalRecordContent.setRecId(medicalRecordContent.getRecId().substring(0, inedx));
- medicalRecordContentList.add(medicalRecordContent);
- aMedicalRecordContentFacade.execute(medicalRecordContentList);
- aMedAbnormalInfoFacade.saveAbnormalInfo("从webService获取文书详情信息正常", "", recId, JSON.toJSONString(medicalRecordContentList), "");
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("从webService获取文书详情信息错误", "", recId, JSON.toJSONString(medicalRecordContentList), e.getMessage());
- }
- }
- public String getHtml(String recId) {
- String url = "http://132.147.254.142:8093/DocService.asmx/GetDocsHTML";
- try {
- PostMethod postMethod = null;
- postMethod = new PostMethod(url);
- postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
- NameValuePair[] data = {
- // new NameValuePair("startTime",""),
- new NameValuePair("szDocIDs", recId)
- };
- postMethod.setRequestBody(data);
- org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
- int response = httpClient.executeMethod(postMethod);
- String result = postMethod.getResponseBodyAsString();
- String html = this.decode(result);
- return html;
- } catch (Exception e) {
- // System.out.println("请求异常"+e.getMessage());
- throw new RuntimeException(e.getMessage());
- } finally {
- }
- }
- /**
- * 数值行代码转换成中文
- *
- * @param result
- * @return
- */
- public String decode(String result) {
- String html = StringEscapeUtils.unescapeXml(result);
- String[] tmp = html.split("&#|&#|;");
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < tmp.length; i++) {
- if (tmp[i].matches("\\d{5}")) {
- sb.append((char) Integer.parseInt(tmp[i]));
- } else {
- sb.append(tmp[i]);
- }
- }
- return sb.toString();
- }
- /**
- * 查看30天前的病人住院登记信息
- */
- public void execute(String date) {
- LocalDateTime now = LocalDateTime.now();
- now = now.minus(Integer.parseInt(date), ChronoUnit.DAYS);
- List<BehospitalInfo> list = aBehospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
- .le("leave_hospital_date", DateUtil.now())
- .ge("leave_hospital_date", now));
- if (list.size() > 0) {
- list.forEach(behospitalInfo -> {
- this.IfCoincide(behospitalInfo.getBehospitalCode());
- });
- }
- }
- /**
- * 判断文书量跟视图是否一致
- *
- * @param code
- */
- public void IfCoincide(String code) {
- try {
- Integer myCount = 0;
- myCount = aMedicalRecordFacade.count(new QueryWrapper<MedicalRecord>()
- .eq("behospital_code", code)
- .eq("hospital_id", Long.valueOf("35"))
- .eq("is_deleted", IsDeleteEnum.N.getKey()));
- String hospitalCode = code.substring(0, code.indexOf("_"));
- String hospitalNum = code.substring(hospitalCode.length() + 1, code.length());
- String sql = "select count(*) as count from record_list where behospitalCode= '" + hospitalCode + "' and behospitalnum= '" + hospitalNum + "'";
- Integer count = tzDBConn.getCount(sql);
- if (count != 0) {
- if (count != myCount) {
- aMedicalRecordFacade.remove(new QueryWrapper<MedicalRecord>()
- .eq("behospital_code", code)
- .eq("hospital_id", Long.valueOf("35")));
- OldInfoVo oldInfoV =new OldInfoVo();
- oldInfoV.setBehospitalCode(code);
- this.executeOldDataOne(oldInfoV);
- aMedAbnormalInfoFacade.saveAbnormalInfo("补传数据成功", code, "视图文书数量为" + count, "本地数量为" + myCount, "");
- }
- }
- } catch (Exception e) {
- aMedAbnormalInfoFacade.saveAbnormalInfo("补传数据失败", code, "", e.getMessage(), "");
- }
- }
- }
|