diff --git a/dataConfig/RequestParams.xml b/dataConfig/RequestParams.xml index 20aaaed..f99acf7 100644 --- a/dataConfig/RequestParams.xml +++ b/dataConfig/RequestParams.xml @@ -30,7 +30,7 @@ - 1123 + 20211213 20211222 diff --git a/dataConfig/homeQualitySet.json b/dataConfig/homeQualitySet.json index abb59b1..0b1bdaf 100644 --- a/dataConfig/homeQualitySet.json +++ b/dataConfig/homeQualitySet.json @@ -1,72 +1,23 @@ { - //唯一键目录结构数组,最高层为前面,最后一层为数据采集层,根节点不填 - "directory":["Msg","ReportInfo"], - //患者主索引号 - "indexFlag":"就诊号", - //采集流水号 - "serialnum":"手术申请单号", - //文件标题 - "filetitle":"文书名", - //下载地址 - "downurl":"WEB_ADDRESS", //分类id - "assortid":"15E7FE7803F545CB81390BC88E725240", - //过滤报告单,多个用逗号隔开 - "filterReport":"病理送检标签,处方笺,麻醉处方精二-1,麻醉处方精二-2,术后镇痛", + "assortid":"e3625e059eb74ad88772edb03abf3bf7", //系统id - "collectorid":"14", + "collectorid":"24", //采集类型(文件来源 1:采集器;2:扫描生产软件) "filesource":1, //下载类型(1:服务器本地;2:ftp服务器;3:共享文件夹) "filestoragetype":1, + "filetype": 4, //上传接口 "uploadConnector":"http://127.0.0.1:9291/api/downplatform/report", - //基本数据存放处,根节点不填,最后一层为基本信息存放标签与doubleBasic配合 - "basicDirectory":["Msg","ReportInfo"], - //可能存在存储基本数据不同情况的标签 - "doubleBasic":["TestItemInfo","BioTestInfo"], - //检查报告列表入参路径 - "bgtsParam":["Request","Msg","EMPI_ID"], - //检查报告列表响应信息根路径 - "bgtsRespon":["MsgInfo","Msg"], - //检查报告key - "examNo":"EXAM_NO", - //文件标题key - "examItemName":"EXAM_ITEM_NAME", - //文件路径 - "pdfUrl":"PDF_URL", - //检查报告明細列表响应信息根路径 - "bgtsDetailParam":["Request","Msg","EXAM_NO"], - //检查报告明細列表响应信息根路径 - "bgtsDetailRespon":["MsgInfo","Msg","ReportInfo"], - //采集日期 - "startCollectTime":"2016-04-11", + //采集开始日期 + "startCollectTime":"2022-08-01", + //采集结束日期 + "endCollectTime":"2022-08-01", //是否开启全量采集 1:是 0 :否 - "isStartCollect":"0", - //oracle命名空间 - "namespace":"DOCUS", - //oracle表名 - "tableName":"V_DOCUMENT_PDF", - //oracle时间配置 - "collectTimeName":"ARCHIVE_DATE_TIME", - //批量按需采集开始时间 - "collectStartDate": "2021-01-01", - //批量按需采集结束时间 - "collectEndDate": "2022-04-01", - //批量按需采集开关 1:开启 0:关闭 - "collectOpen": "1", - //校验完整性方式 1:根据af_collect_task完成情况 2:梅州根据信息科提供任务视图 - "checkIntegrityType": "1", - - //----以下是梅州完整性检验同步配置------ - //开关0:关闭 1:开启 - "syncFlag":"0", - "pageSize":"1000", - //同步开始时间 - "newSyncTime":"", - //数据表名 - "syncTableName":"CIS_EMR_DOCUMENT", - "syncTableNamespaces":"CDR", - //url需要过滤掉的字符串 - "replaceUrl": ["","","","","","",""] + "isStartCollect":"1", + //采集增量采集 1:是 0 :否 + "isCollect":"0", + //采集每日扫描 1:是 0 :否 + "isStartCollectDay":"0" } \ No newline at end of file diff --git a/pom.xml b/pom.xml index e07fdae..4811023 100644 --- a/pom.xml +++ b/pom.xml @@ -137,6 +137,7 @@ ojdbc6 11.2.0.4 + org.apache.cxf cxf-rt-frontend-jaxws @@ -163,6 +164,18 @@ commons-collections4 4.4 + + + com.microsoft.sqlserver + mssql-jdbc + 8.2.2.jre8 + + + com.microsoft.sqlserver + sqljdbc4 + 4.0 + + diff --git a/src/main/java/com/docus/bgts/config/MyConstruct.java b/src/main/java/com/docus/bgts/config/MyConstruct.java index fa0b11f..9ccdbd2 100644 --- a/src/main/java/com/docus/bgts/config/MyConstruct.java +++ b/src/main/java/com/docus/bgts/config/MyConstruct.java @@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; +import java.util.List; +import java.util.Map; @Component public class MyConstruct { @@ -20,17 +22,34 @@ public class MyConstruct { private Logger logger = LogManager.getLogger(MyConstruct.class); /** - * 开启手麻全量采集 + * 开启扫描全量采集 */ + @PostConstruct + public void startCollectAll(){ + String startCollectTime = String.valueOf(FileUtils.getJsonByName("startCollectTime")); + String isStartCollect = String.valueOf(FileUtils.getJsonByName("isStartCollect")); + if(StringUtils.isNotBlank(startCollectTime)&&isStartCollect!=null&&isStartCollect.equals("1")){ + bgtsService.collectAll(); + } + } + // @PostConstruct -// public void startCollectAll(){ -// logger.info("全量采集开始------"); -// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); -// String startCollectTime = String.valueOf(FileUtils.getJsonByName("startCollectTime")); -// String isStartCollect = String.valueOf(FileUtils.getJsonByName("isStartCollect")); -// if(collectorid.equals(Codes.SMCODE.getCode())&& StringUtils.isNotBlank(startCollectTime)&&isStartCollect!=null&&isStartCollect.equals("1")){ -// bgtsService.collectAll(); +// public void tests(){ +// //页码 +// int startrow; +// //每页10条数据 +// int endrow; +// a: for (startrow=1;;startrow+=10){ +// endrow = 10 +startrow; +// List maps = bgtsService.test(startrow,endrow-1); +// System.err.println(startrow+"---------------"+(endrow-1)); +// System.err.println("处理数据---"+maps); +// if (null == maps || maps.size() <= 0) { +// break; +// } // } +// +// // } /** @@ -46,7 +65,7 @@ public class MyConstruct { // bgtsService.collectAll(); // } // } - +// diff --git a/src/main/java/com/docus/bgts/config/MyScheduling.java b/src/main/java/com/docus/bgts/config/MyScheduling.java index ffd383b..2da0115 100644 --- a/src/main/java/com/docus/bgts/config/MyScheduling.java +++ b/src/main/java/com/docus/bgts/config/MyScheduling.java @@ -43,17 +43,17 @@ public class MyScheduling { private Logger logger = LogManager.getLogger(MyScheduling.class); //5分钟执行一次心跳 - @Scheduled(fixedRate = 1000 * 60 * 5) - public void beat() { - Map params = new HashMap<>(); - params.put("code", String.valueOf(FileUtils.getJsonByName("collectorid"))); - try { - HttpUtils.get(beatUrl, params); - } catch (Exception e) { - e.printStackTrace(); - logger.info("心跳推送出错,可能是住院服务没有开启"); - } - } +// @Scheduled(fixedRate = 1000 * 60 * 5) +// public void beat() { +// Map params = new HashMap<>(); +// params.put("code", String.valueOf(FileUtils.getJsonByName("collectorid"))); +// try { +// HttpUtils.get(beatUrl, params); +// } catch (Exception e) { +// e.printStackTrace(); +// logger.info("心跳推送出错,可能是住院服务没有开启"); +// } +// } @@ -68,24 +68,63 @@ public class MyScheduling { // return; // } // bgtsService.timerCollect(); +// } + /** + * 急诊就诊信息采集 + */ +// @Scheduled(fixedRate = 1000*10) +// public void collectJzone(){ +// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); +// if (!collectorid.equals("24")){ +// return; +// } +//bgtsService.timerCollectJz(); // } /** - * 批量按需采集 - * 10分钟执行一次 + * 扫描增量采集 + */ + @Scheduled(fixedDelay = 1000 * 60 * 10) + public void collectIncrement(){ + String isCollect = String.valueOf(FileUtils.getJsonByName("isCollect")); + if (isCollect.equals("1")){ + bgtsService.timerCollectSmIncrement(); + } + + + + } + + /** + * 扫描每日采集 */ - @Scheduled(fixedRate = 1000 * 60 *10 ) - public void collectByExamNo(){ - String collectOpen = String.valueOf(FileUtils.getJsonByName("collectOpen")); - if (collectOpen.equals("1")){ - logger.info("按需采集开始----------"); - String collectStartDate = String.valueOf(FileUtils.getJsonByName("collectStartDate")); - String collectEndDate = String.valueOf(FileUtils.getJsonByName("collectEndDate")); - String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); - bgtsService.collectByDate(collectStartDate,collectEndDate,collectorid); + @Scheduled(cron ="0 0 0 * * ?") + public void collectSm(){ + String isStartCollectDay = String.valueOf(FileUtils.getJsonByName("isStartCollectDay")); + if (isStartCollectDay.equals("1")){ + bgtsService.timerCollectSmDay(); } + } + + + /** + * 批量按需采集 + * 10分钟执行一次 + */ +// @Scheduled(fixedRate = 1000 * 60 *10 ) +// public void collectByExamNo(){ +// String collectOpen = String.valueOf(FileUtils.getJsonByName("collectOpen")); +// if (collectOpen.equals("1")){ +// logger.info("按需采集开始----------"); +// String collectStartDate = String.valueOf(FileUtils.getJsonByName("collectStartDate")); +// String collectEndDate = String.valueOf(FileUtils.getJsonByName("collectEndDate")); +// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); +// bgtsService.collectByDate(collectStartDate,collectEndDate,collectorid); +// } +// } + /** * 完整性校验 */ diff --git a/src/main/java/com/docus/bgts/controller/BgtsController.java b/src/main/java/com/docus/bgts/controller/BgtsController.java index 5566988..a6f172a 100644 --- a/src/main/java/com/docus/bgts/controller/BgtsController.java +++ b/src/main/java/com/docus/bgts/controller/BgtsController.java @@ -84,6 +84,43 @@ public class BgtsController { return CommonResult.success("ok"); } + @ApiOperation("Pacs采集接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "empId",value = "患者主索引号",required = true,dataTypeClass = String.class), + @ApiImplicitParam(name = "collectSubId",value = "af_interface_collect_sub表id",required = true), + @ApiImplicitParam(name = "admissDate",value = "入院时间",required = true), + @ApiImplicitParam(name = "disDate",value = "出院时间",required = true), + @ApiImplicitParam(name = "times",value = "住院次数",required = true) + }) + @GetMapping("/collectPacs") + public CommonResult collect(@RequestParam("collectSubId") String collectSubId, + @RequestParam("empId") String empId, + @RequestParam("admissDate") String admissDate, + @RequestParam("disDate") String disDate, + @RequestParam("times") String times){ + try { + logger.info("采集接口接收到参数:\nempId--"+empId+"\ncollectSubId--"+collectSubId); + bgtsService.collectPacs(empId,admissDate,disDate,times); + logger.info("采集完成"); + afCollectTaskService.updateInterfaceCollect(collectSubId, 1); + logger.info("------------采集结束-----------"); + } catch (RuntimeException e) { + e.printStackTrace(); + try { + afCollectTaskService.updateInterfaceCollect(collectSubId, 0); + }catch (Exception e1) { + logger.info(e1.getMessage()); + return CommonResult.failed(e1.getMessage()); + } + return CommonResult.failed(e.getMessage()); + } + catch (Exception e) { + e.printStackTrace(); + } + return CommonResult.success("ok"); + } + + /** * 按需采集 * @param emamNo @@ -125,5 +162,19 @@ public class BgtsController { return CommonResult.success("ok"); } + @GetMapping("/xx") + public void collectxx(){ + bgtsService.collectAll(); + } + @GetMapping("/collectById") + public CommonResult collectById(@RequestParam("inPatientId") String inPatientId,@RequestParam("vistId") String vistId){ + try{ +bgtsService.SmCollect(inPatientId,vistId); + }catch (Exception e){ + e.printStackTrace(); + return CommonResult.failed(e.getMessage()); + } + return CommonResult.success("ok"); + } } diff --git a/src/main/java/com/docus/bgts/entity/ReportDownPatientDto.java b/src/main/java/com/docus/bgts/entity/ReportDownPatientDto.java index 8509d86..e336590 100644 --- a/src/main/java/com/docus/bgts/entity/ReportDownPatientDto.java +++ b/src/main/java/com/docus/bgts/entity/ReportDownPatientDto.java @@ -7,4 +7,10 @@ import lombok.Data; public class ReportDownPatientDto { @ApiModelProperty(value = "记帐号") private String jzh; + @ApiModelProperty(value = "住院号") + private String inPatientNo; + @ApiModelProperty(value = "住院次数") + private String visitId; + @ApiModelProperty(value = "主键") + private String patientid; } diff --git a/src/main/java/com/docus/bgts/entity/ReportDownScanFileDto.java b/src/main/java/com/docus/bgts/entity/ReportDownScanFileDto.java index 7712d14..d4270ff 100644 --- a/src/main/java/com/docus/bgts/entity/ReportDownScanFileDto.java +++ b/src/main/java/com/docus/bgts/entity/ReportDownScanFileDto.java @@ -11,6 +11,8 @@ public class ReportDownScanFileDto { private int filesource; @ApiModelProperty(value = "下载类型(1:服务器本地;2:ftp服务器;3:共享文件夹)") private int filestoragetype; + @ApiModelProperty(value = "文件类型(1:url;2:base64;3:url base64;4:共享文件夹)") + private int filetype; @ApiModelProperty(value = "下载地址") private String downurl; @ApiModelProperty(value = "档案信息") diff --git a/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java b/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java index 258e369..538e0e2 100644 --- a/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java +++ b/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java @@ -25,6 +25,10 @@ public interface IAfCollectTaskService extends IService { void insert(ReportDownDto reportDownDto); + String getJzhByInpatientNo(String inPatientNo,String visitId); + + void insertServer(ReportDownDto reportDownDto); + void updateInterfaceCollect(String collectSubId, int state); /** @@ -56,10 +60,24 @@ public interface IAfCollectTaskService extends IService { */ List getJzhByPatientId(List patientIds); + /** + * 通过住院号和住院次数获取patient_id + */ + String getPatientIdByInpatientNo(String inPatientNo,String visitId); + + /** + * 通过住院号和出院时间获取patient_id + */ + String getPatientIdByInpatientNoAndDate(String inPatientNo,String disDate); + + + /** * 根据jzh集合查询文件采集任务情况 * @param jzhs * @return */ List getCompleteIntegrity(List jzhs); + + } diff --git a/src/main/java/com/docus/bgts/facade/IBgtsService.java b/src/main/java/com/docus/bgts/facade/IBgtsService.java index e8343b7..89b20be 100644 --- a/src/main/java/com/docus/bgts/facade/IBgtsService.java +++ b/src/main/java/com/docus/bgts/facade/IBgtsService.java @@ -1,4 +1,8 @@ package com.docus.bgts.facade; + +import java.util.List; +import java.util.Map; + public interface IBgtsService { /** * 采集 @@ -6,6 +10,8 @@ public interface IBgtsService { */ void collect(String empId) throws Exception; + void collectPacs(String empId,String admissDate,String disDate,String times) throws Exception; + /** * 按需采集 * @param emamNo @@ -25,8 +31,21 @@ public interface IBgtsService { */ void collectAll(); + void collectxx(); + /** * 定时采集 */ void timerCollect(); + + /** + * 急诊就诊信息增量采集 + */ + void timerCollectSmIncrement(); + + void timerCollectSmDay(); + + void SmCollect(String inPatientId,String vistId); + + List test(int size,int current); } diff --git a/src/main/java/com/docus/bgts/mapper/dbmysql/AfCollectAddMapper.java b/src/main/java/com/docus/bgts/mapper/dbmysql/AfCollectAddMapper.java index b65cc76..94a99ed 100644 --- a/src/main/java/com/docus/bgts/mapper/dbmysql/AfCollectAddMapper.java +++ b/src/main/java/com/docus/bgts/mapper/dbmysql/AfCollectAddMapper.java @@ -24,6 +24,12 @@ public interface AfCollectAddMapper extends BaseMapper { */ List listJzh(@Param("pageNumber") int pageNumber,@Param("pageSize") Integer pageSize); + /** + * 根据jzh查询出入院时间 + * @param jzh + * @return + */ + Map selectDate(@Param("jzh") String jzh); /** * 数据完整性校验 * @param mzSyncs diff --git a/src/main/java/com/docus/bgts/mapper/dbmysql/AfCollectTaskMapper.java b/src/main/java/com/docus/bgts/mapper/dbmysql/AfCollectTaskMapper.java index ab0c11e..17217f9 100644 --- a/src/main/java/com/docus/bgts/mapper/dbmysql/AfCollectTaskMapper.java +++ b/src/main/java/com/docus/bgts/mapper/dbmysql/AfCollectTaskMapper.java @@ -19,12 +19,22 @@ import java.util.List; public interface AfCollectTaskMapper extends BaseMapper { /** * 获取病案id通过报告唯一单号 - * @param empId + * @param jzh * @return */ - String getpatientIdByEmpId(@Param("jzh") String empId); + String getpatientIdByEmpId(@Param("jzh") String jzh); + String getPatientIdByInpatientNo(@Param("inPatientNo") String inPatientNo,@Param("visitId") String visitId); + /** + * 根据住院号与出院时间获取patient_id + * @param inPatientNo + * @param disDate + * @return + */ + String getPatientIdByInpatientNoAndDate(@Param("inPatientNo") String inPatientNo,@Param("disDate") String disDate); + + String getJzhByInpatientNo(@Param("inPatientNo") String inPatientNo,@Param("visitId") String visitId); /** * 通过出院日期获取患者jzh * @param startDate 开始日期 @@ -60,4 +70,6 @@ public interface AfCollectTaskMapper extends BaseMapper { * @return */ List selectListByJzhs(@Param("jzhs") List jzhs); + + } diff --git a/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java b/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java index 3f5c85d..af06fcf 100644 --- a/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java +++ b/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java @@ -52,8 +52,8 @@ public class AfCollectTaskServiceImpl extends ServiceImpl scanfiles = reportDownDto.getScanfiles(); + for (ReportDownScanFileDto scanfile : scanfiles) { + // 判断任务是否已存在 + afCollectTask = afCollectTaskMapper.selectOne(new QueryWrapper().eq("C1", scanfile.getSerialnum()).eq("sysflag", reportDownDto.getCollectorid())); + if (afCollectTask == null) { + //不存在 新增 + afCollectTask = new AfCollectTask(); + afCollectTask.setPatientId(reportDownDto.getPatient().getPatientid()); + afCollectTask.setSysflag(reportDownDto.getCollectorid()); + afCollectTask.setState("0"); + afCollectTask.setSyncTime(date); + afCollectTask.setC1(scanfile.getSerialnum()); + afCollectTask.setC2(scanfile.getFiletitle()); + afCollectTask.setC3(reportDownDto.getPatient().getJzh()); + save = afCollectTaskMapper.insert(afCollectTask); + if (save <= 0) { + throw new RuntimeException("插入病案任务表数据出错"); + }else { + log.warn("插入病案成功"); + } + + } else { + //存在就修改 + afCollectTask.setPatientId(reportDownDto.getPatient().getPatientid()); + afCollectTask.setSysflag(reportDownDto.getCollectorid()); + afCollectTask.setState("0"); + afCollectTask.setSyncTime(date); + afCollectTask.setC1(scanfile.getSerialnum()); + afCollectTask.setC2(scanfile.getFiletitle()); + save = afCollectTaskMapper.updateById(afCollectTask); + log.warn(reportDownDto.getPatient().getPatientid()+"----修改病案成功"+scanfile.getSerialnum()); + } + scanfile.setTaskid(afCollectTask.getId()); + } + reportDownDto.setScanfiles(scanfiles); + } + @Override public void updateInterfaceCollect(String collectSubId, int state) { log.warn("开始记录采集"); @@ -174,6 +226,17 @@ public class AfCollectTaskServiceImpl extends ServiceImpl exams = getExamNo(empId, admissDate, disDate); + String jzh = afCollectTaskService.getJzhByInpatientNo(empId, times); + if (null == jzh) { + throw new RuntimeException("通过住院号与住院次数未匹配到患者"); + } + //获取插入表数据 + ReportDownDto reportDownDto = getUrlCreateReportDto(exams, jzh); + //插入文件af_collect_task表数据 + afCollectTaskService.insert(reportDownDto); + //通过报告单号集合采集 + collectExams(exams, empId, reportDownDto); + } + @Override public void collectByExamNo(String emamNo, String empId) throws Exception { String[] strings = new String[2]; @@ -100,111 +141,36 @@ public class BgtsServiceImpl implements IBgtsService { //当前日期 Date date = new Date(); String dateStr = simpleDateFormat.format(date); - collectByDates(startCollectTime, dateStr); + collectByDateJz(startCollectTime, dateStr); //更新采集时间 - addAfCollectAdd(date); + // addAfCollectAdd(date); logger.info("--------------全量采集结束------------------"); } - /** - * 根据时间到采集任务 手麻 - * - * @param startDate - * @param endDate - */ - private void collectByDates(String startDate, String endDate) { - //页码 - int current; - //每页10条数据 - int size; - String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); - String assortid = String.valueOf(FileUtils.getJsonByName("assortid")); - int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource"))); - int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype"))); - Map headMap = new HashMap<>(); - headMap.put("Content-Type", "application/json"); - SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0); - String indexFlag = String.valueOf(FileUtils.getJsonByName("indexFlag")); - String serialnum = String.valueOf(FileUtils.getJsonByName("serialnum")); - String filetitle = String.valueOf(FileUtils.getJsonByName("filetitle")); - String downurl = String.valueOf(FileUtils.getJsonByName("downurl")); - List fieldArr = new ArrayList<>(); - fieldArr.add(indexFlag); - fieldArr.add(serialnum); - if (StringUtils.isNotBlank(filetitle)) { - fieldArr.add(filetitle); - } - fieldArr.add(downurl); - String namespace = String.valueOf(FileUtils.getJsonByName("namespace")); - String tableName = String.valueOf(FileUtils.getJsonByName("tableName")); - String collectTimeName = String.valueOf(FileUtils.getJsonByName("collectTimeName")); - List maps; - //2.获取第一页10条数据开始采集 - for (current = 1; ; current++) { - size = 10 * current; - maps = vDocumentPdfMapper.listCollectPage(size - 10, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName); - logger.info("处理采集数据:" + maps); - if (null == maps || maps.size() <= 0) { - break; - } - maps: - for (Map map : maps) { - //获取过滤报告单 - String[] filterReports = String.valueOf(FileUtils.getJsonByName("filterReport")).split(","); - if (filterReports.length > 0) { - for (String filterReport : filterReports) { - //需要过滤的报告单存在则不采集 - if (String.valueOf(map.get(filetitle)).equals(filterReport)) { - continue maps; - } - } - } - ReportDownDto reportDownDto = new ReportDownDto(); - reportDownDto.setCollectorid(collectorid); - reportDownDto.setAssortid(assortid); - ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(); - reportDownPatientDto.setJzh(String.valueOf(map.get(indexFlag))); - reportDownDto.setPatient(reportDownPatientDto); + @Override + public void collectxx() { + logger.info("----------全量采集开始-----------"); + //1.获取最早采集日期 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String startCollectTime = null; + startCollectTime = String.valueOf(FileUtils.getJsonByName("startCollectTime")); - List reportDownScanFileDtos = new ArrayList<>(); - ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); - reportDownScanFileDto.setDownurl(String.valueOf(map.get(downurl))); - reportDownScanFileDto.setFilestoragetype(filestoragetype); - reportDownScanFileDto.setFilesource(filesource); - reportDownScanFileDto.setFiletitle(map.get(filetitle) == null ? "重症" + (System.currentTimeMillis()) : String.valueOf(map.get(filetitle))); - reportDownScanFileDto.setSerialnum(StringUtils.isNotBlank(String.valueOf(map.get(serialnum))) ? String.valueOf(map.get(serialnum)) : String.valueOf(idWorker.nextId())); - reportDownScanFileDtos.add(reportDownScanFileDto); - reportDownDto.setScanfiles(reportDownScanFileDtos); - String post; - try { - afCollectTaskService.insert(reportDownDto); - //String uploadConnector = String.valueOf(FileUtils.getJsonByName("uploadConnector")); - //调用下载接口 - post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class)); - Map resMap = JSON.parseObject(post, Map.class); - logger.info(reportDownDto); - if (String.valueOf(resMap.get("code")).equals("500")) { - throw new RuntimeException(String.valueOf(resMap.get("msg"))); - } - } catch (Exception e) { - //打印错误日志 - logger.info("采集出错:" + reportDownDto); - logger.info(e); - String stackTrace = ExceptionUtils.getStackTrace(e); - logger.info("错误信息----------" + stackTrace); - addMrReportErrorLog(reportDownDto); - e.printStackTrace(); - } - } - } + logger.info("----------采集初始时间:" + startCollectTime + " -------------------"); + //当前日期 + Date date = new Date(); + String dateStr = simpleDateFormat.format(date); + collectByDateTest(startCollectTime, dateStr); + //更新采集时间 + // addAfCollectAdd(date); + logger.info("--------------全量采集结束------------------"); } - /** - * 根据时间到采集任务 重症 - * - * @param startDate - * @param endDate - */ +// /** +// * 根据时间到采集任务 手麻 +// * +// * @param startDate +// * @param endDate +// */ // private void collectByDates(String startDate, String endDate) { // //页码 // int current; @@ -219,33 +185,42 @@ public class BgtsServiceImpl implements IBgtsService { // SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0); // String indexFlag = String.valueOf(FileUtils.getJsonByName("indexFlag")); // String serialnum = String.valueOf(FileUtils.getJsonByName("serialnum")); -// //String filetitle = String.valueOf(FileUtils.getJsonByName("filetitle")); +// String filetitle = String.valueOf(FileUtils.getJsonByName("filetitle")); // String downurl = String.valueOf(FileUtils.getJsonByName("downurl")); -// List fieldArr=new ArrayList<>(); +// List fieldArr = new ArrayList<>(); // fieldArr.add(indexFlag); // fieldArr.add(serialnum); -//// if(StringUtils.isNotBlank(filetitle)){ -//// fieldArr.add(filetitle); -//// } +// if (StringUtils.isNotBlank(filetitle)) { +// fieldArr.add(filetitle); +// } // fieldArr.add(downurl); // String namespace = String.valueOf(FileUtils.getJsonByName("namespace")); // String tableName = String.valueOf(FileUtils.getJsonByName("tableName")); // String collectTimeName = String.valueOf(FileUtils.getJsonByName("collectTimeName")); // List maps; // //2.获取第一页10条数据开始采集 -// logger.info("开始时间-----"+startDate+"结束时间-----"+"\n"+endDate); // for (current = 1; ; current++) { // size = 10 * current; -// maps = vDocumentPdfMapper.listCollectPage(size-10, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName); -// logger.info("处理采集数据:"+maps); +// maps = vDocumentPdfMapper.listCollectPage(size - 10, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName); +// logger.info("处理采集数据:" + maps); // if (null == maps || maps.size() <= 0) { // break; // } -// maps.stream().forEach(map -> { +// maps: +// for (Map map : maps) { +// //获取过滤报告单 +// String[] filterReports = String.valueOf(FileUtils.getJsonByName("filterReport")).split(","); +// if (filterReports.length > 0) { +// for (String filterReport : filterReports) { +// //需要过滤的报告单存在则不采集 +// if (String.valueOf(map.get(filetitle)).equals(filterReport)) { +// continue maps; +// } +// } +// } // ReportDownDto reportDownDto = new ReportDownDto(); // reportDownDto.setCollectorid(collectorid); // reportDownDto.setAssortid(assortid); -// // ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(); // reportDownPatientDto.setJzh(String.valueOf(map.get(indexFlag))); // reportDownDto.setPatient(reportDownPatientDto); @@ -255,15 +230,15 @@ public class BgtsServiceImpl implements IBgtsService { // reportDownScanFileDto.setDownurl(String.valueOf(map.get(downurl))); // reportDownScanFileDto.setFilestoragetype(filestoragetype); // reportDownScanFileDto.setFilesource(filesource); -// //reportDownScanFileDto.setFiletitle(map.get(filetitle)==null?"重症"+(System.currentTimeMillis()):String.valueOf(map.get(filetitle))); -// reportDownScanFileDto.setFiletitle(StringUtils.isNotBlank(String.valueOf(map.get(serialnum)))?String.valueOf(map.get(serialnum)):String.valueOf(idWorker.nextId())); -// reportDownScanFileDto.setSerialnum(StringUtils.isNotBlank(String.valueOf(map.get(serialnum)))?String.valueOf(map.get(serialnum)):String.valueOf(idWorker.nextId())); +// reportDownScanFileDto.setFiletitle(map.get(filetitle) == null ? "重症" + (System.currentTimeMillis()) : String.valueOf(map.get(filetitle))); +// reportDownScanFileDto.setSerialnum(StringUtils.isNotBlank(String.valueOf(map.get(serialnum))) ? String.valueOf(map.get(serialnum)) : String.valueOf(idWorker.nextId())); // reportDownScanFileDtos.add(reportDownScanFileDto); // reportDownDto.setScanfiles(reportDownScanFileDtos); // String post; // try { // afCollectTaskService.insert(reportDownDto); // //String uploadConnector = String.valueOf(FileUtils.getJsonByName("uploadConnector")); +// //调用下载接口 // post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class)); // Map resMap = JSON.parseObject(post, Map.class); // logger.info(reportDownDto); @@ -272,16 +247,182 @@ public class BgtsServiceImpl implements IBgtsService { // } // } catch (Exception e) { // //打印错误日志 -// logger.info("采集出错:"+reportDownDto); +// logger.info("采集出错:" + reportDownDto); // logger.info(e); // String stackTrace = ExceptionUtils.getStackTrace(e); -// logger.info("错误信息----------"+stackTrace); +// logger.info("错误信息----------" + stackTrace); // addMrReportErrorLog(reportDownDto); // e.printStackTrace(); // } -// }); +// } // } // } + + /** + * 根据时间到采集任务 重症 + * + * @param startDate + * @param endDate + */ + private void collectByDates(String startDate, String endDate) { + //页码 + int current; + //每页10条数据 + int size; + String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); + String assortid = String.valueOf(FileUtils.getJsonByName("assortid")); + int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource"))); + int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype"))); + Map headMap = new HashMap<>(); + headMap.put("Content-Type", "application/json"); + SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0); + String indexFlag = String.valueOf(FileUtils.getJsonByName("indexFlag")); + String serialnum = String.valueOf(FileUtils.getJsonByName("serialnum")); + //String filetitle = String.valueOf(FileUtils.getJsonByName("filetitle")); + String downurl = String.valueOf(FileUtils.getJsonByName("downurl")); + String inPatientNo = String.valueOf(FileUtils.getJsonByName("inPatientNo")); + String visitId = String.valueOf(FileUtils.getJsonByName("visitId")); + + List fieldArr = new ArrayList<>(); + fieldArr.add(indexFlag); + fieldArr.add(serialnum); + fieldArr.add(inPatientNo); + fieldArr.add(visitId); +// if(StringUtils.isNotBlank(filetitle)){ +// fieldArr.add(filetitle); +// } + fieldArr.add(downurl); + String namespace = String.valueOf(FileUtils.getJsonByName("namespace")); + String tableName = String.valueOf(FileUtils.getJsonByName("tableName")); + String collectTimeName = String.valueOf(FileUtils.getJsonByName("collectTimeName")); + List maps; + //2.获取第一页10条数据开始采集 + logger.info("开始时间-----" + startDate + "结束时间-----" + "\n" + endDate); + for (current = 1; ; current++) { + size = 10 * current; + maps = vDocumentPdfMapper.listCollectPage(size - 10, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName); + logger.info("处理采集数据:" + maps); + if (null == maps || maps.size() <= 0) { + break; + } + maps.stream().forEach(map -> { + ReportDownDto reportDownDto = new ReportDownDto(); + reportDownDto.setCollectorid(collectorid); + reportDownDto.setAssortid(assortid); + ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(); + reportDownPatientDto.setInPatientNo(String.valueOf(map.get(inPatientNo))); + reportDownPatientDto.setVisitId(String.valueOf(map.get(visitId))); + reportDownDto.setPatient(reportDownPatientDto); + // reportDownPatientDto.setJzh(String.valueOf(map.get(indexFlag))); + List reportDownScanFileDtos = new ArrayList<>(); + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setDownurl(String.valueOf(map.get(downurl))); + reportDownScanFileDto.setFilestoragetype(filestoragetype); + reportDownScanFileDto.setFilesource(filesource); + //reportDownScanFileDto.setFiletitle(map.get(filetitle)==null?"重症"+(System.currentTimeMillis()):String.valueOf(map.get(filetitle))); + reportDownScanFileDto.setFiletitle(StringUtils.isNotBlank(String.valueOf(map.get(serialnum))) ? String.valueOf(map.get(serialnum)) : String.valueOf(idWorker.nextId())); + reportDownScanFileDto.setSerialnum(StringUtils.isNotBlank(String.valueOf(map.get(serialnum))) ? String.valueOf(map.get(serialnum)) : String.valueOf(idWorker.nextId())); + reportDownScanFileDtos.add(reportDownScanFileDto); + reportDownDto.setScanfiles(reportDownScanFileDtos); + String post; + try { + afCollectTaskService.insertServer(reportDownDto); + //String uploadConnector = String.valueOf(FileUtils.getJsonByName("uploadConnector")); + String jzh = afCollectTaskService.getJzhByInpatientNo(reportDownDto.getPatient().getInPatientNo(), reportDownDto.getPatient().getVisitId()); + if (null != jzh && !("").equals(jzh)) { + reportDownPatientDto.setJzh(jzh); + reportDownDto.setPatient(reportDownPatientDto); + post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class)); + Map resMap = JSON.parseObject(post, Map.class); + logger.info(reportDownDto); + if (String.valueOf(resMap.get("code")).equals("500")) { + throw new RuntimeException(String.valueOf(resMap.get("msg"))); + } + } + + } catch (Exception e) { + //打印错误日志 + logger.info("采集出错:" + reportDownDto); + logger.info(e); + // String stackTrace = ExceptionUtils.getStackTrace(e); + // logger.info("错误信息----------"+stackTrace); + addMrReportErrorLog(reportDownDto); + e.printStackTrace(); + } + }); + } + } + + @Override + public void timerCollectSmDay() { + logger.info("------采集器开始采集---------"); + //获取前一天开始结束时间 + Map time = getSmCollectionTime(new Date()); + collectByDateSm(time.get("startDate"), time.get("endDate")); + //更新采集时间 + logger.info("--------采集器结束采集------"); + } + + @Override + public void SmCollect(String inPatientId,String vistId) { + List maps = scanningMapper.selectByInPatientId(inPatientId,vistId); + int i = scanningMapper.selectRow(inPatientId,vistId); + logger.info(inPatientId+"患者扫描病历共"+i+"条----"); + Map headMap = new HashMap<>(); + headMap.put("Content-Type", "application/json"); + int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource"))); + int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype"))); + String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); + int filetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filetype"))); + String assortid = String.valueOf(FileUtils.getJsonByName("assortid")); + int i1 =0; + for (Map map : maps) { + try { + i1++; + logger.info("当前第"+i1+"条------"); + ReportDownDto reportDownDto = new ReportDownDto(); + reportDownDto.setCollectorid(collectorid); + reportDownDto.setAssortid(String.valueOf(map.get("分类id"))); + ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(); +// reportDownPatientDto.setInPatientNo(String.valueOf(map.get("住院号"))); +// reportDownPatientDto.setVisitId(String.valueOf(map.get("次数"))); + String patientId = afCollectTaskService.getPatientIdByInpatientNo(String.valueOf(map.get("住院号")), String.valueOf(map.get("次数"))); + if (null != patientId) { + reportDownPatientDto.setPatientid(patientId); + reportDownDto.setPatient(reportDownPatientDto); + List reportDownScanFileDtos = new ArrayList<>(); + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setFiletype(filetype); + reportDownScanFileDto.setDownurl(String.valueOf(map.get("图像路径")) + "/" + String.valueOf(map.get("文件名"))); + reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")).substring(0,map.get("文件名").toString().indexOf("."))); + //处理下载地址为唯一值 + String ser = String.valueOf(map.get("主键")) + String.valueOf(map.get("分段名称")) + String.valueOf(map.get("文件名")); + reportDownScanFileDto.setSerialnum(ser); + reportDownScanFileDto.setFilestoragetype(filestoragetype); + reportDownScanFileDto.setFilesource(filesource); + reportDownScanFileDtos.add(reportDownScanFileDto); + reportDownDto.setScanfiles(reportDownScanFileDtos); + afCollectTaskService.insertServer(reportDownDto); + String post; + logger.info("上传下载参数-----" + reportDownDto); + post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class)); + Map resMap = JSON.parseObject(post, Map.class); + if (String.valueOf(resMap.get("code")).equals("500")) { + logger.info("下载服务-------" + String.valueOf(resMap.get("msg"))); + } + + } else { + logger.info(String.valueOf(map.get("住院号")) + "患者基础信息不存在!"); + } + + } catch (Exception e) { + logger.error(String.valueOf(map.get("住院号")) + e.getMessage()); + } + } + } + + + @Override public void timerCollect() { logger.info("------采集器开始采集---------"); @@ -289,9 +430,11 @@ public class BgtsServiceImpl implements IBgtsService { //1.获取上次采集时间 Date time; if (collectorid.equals("5")) { - time = afCollectAddMapper.getTimeByAdd(5); - }else { + time = afCollectAddMapper.getTimeByAdd(5); + } else if (collectorid.equals("15")) { time = afCollectAddMapper.getTimeByAdd(15); + } else { + time = afCollectAddMapper.getTimeByAdd(24); } SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String startDate = simpleDateFormat.format(time); @@ -304,6 +447,308 @@ public class BgtsServiceImpl implements IBgtsService { logger.info("--------采集器结束采集------"); } + @Override + public void timerCollectSmIncrement() { + logger.info("------采集器开始采集---------"); + String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); + //1.获取上次采集时间 + Date time; + time = afCollectAddMapper.getTimeByAdd(25); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String startDate = simpleDateFormat.format(time); + //当前日期 + Date date = new Date(); + String endDate = simpleDateFormat.format(date); + logger.info("增量采集开始----采集扫描日期区间为"+startDate+"-----"+endDate); + collectByDateSm(startDate, endDate); + //更新采集时间 + addAfCollectAdd(date); + logger.info("--------采集器结束采集------"); + } + + /** + * 获取前一天开始与结束时间 + * + * @param date + * @return + */ + + public static Map getSmCollectionTime(Date date) { + Date dBefore; + Calendar calendar = Calendar.getInstance(); //得到日历 + calendar.setTime(date);//把当前时间赋给日历 + calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天 + dBefore = calendar.getTime(); //得到前一天的时间 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //设置时间格式 + String defaultStartDate = sdf.format(dBefore); //格式化前一天 + defaultStartDate = defaultStartDate + " 00:00:00"; + String defaultEndDate = defaultStartDate.substring(0, 10) + " 23:59:59"; + Map map = new HashMap<>(); + map.put("startDate", defaultStartDate); + map.put("endDate", defaultEndDate); + return map; + } + + + /** + * 根据时间采集扫描电子病历 + */ + private void collectByDateJz(String startDate, String endDate) { + //页码 + int startrow; + //每页10条数据 + int endrow; + //2.获取第一页10条数据开始采集 + logger.info("开始时间-----" + startDate + "结束时间-----" + "\n" + endDate); + Map headMap = new HashMap<>(); + headMap.put("Content-Type", "application/json"); + int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource"))); + int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype"))); + String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); + int filetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filetype"))); + String assortid = String.valueOf(FileUtils.getJsonByName("assortid")); + List maps; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String format; + for (startrow = 1; ; startrow += 10) { + endrow = 10 + startrow; + maps = scanningMapper.selectAllByDisDate(startrow, endrow - 1, startDate, endDate); + logger.info("处理采集数据" + maps); + // List maps = patientBRMapper.selectAll(1,1,startDate,endDate); + if (null == maps || maps.size() <= 0) { + break; + } + try { + for (Map map : maps) { + try { + ReportDownDto reportDownDto = new ReportDownDto(); + reportDownDto.setCollectorid(collectorid); + reportDownDto.setAssortid(String.valueOf(map.get("分类id"))); + ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(); +// reportDownPatientDto.setInPatientNo(String.valueOf(map.get("住院号"))); +// reportDownPatientDto.setVisitId(String.valueOf(map.get("次数"))); + Date parse = simpleDateFormat.parse(String.valueOf(map.get("出院日期"))); + format = simpleDateFormat.format(parse); + String patientId = afCollectTaskService.getPatientIdByInpatientNoAndDate(String.valueOf(map.get("住院号")),format); + if (null != patientId) { + reportDownPatientDto.setPatientid(patientId); + reportDownDto.setPatient(reportDownPatientDto); + List reportDownScanFileDtos = new ArrayList<>(); + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setFiletype(filetype); + reportDownScanFileDto.setDownurl(String.valueOf(map.get("图像路径")) + "/" + String.valueOf(map.get("文件名"))); + reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")).substring(0,map.get("文件名").toString().indexOf("."))); + //处理下载地址为唯一值 + String ser = String.valueOf(map.get("主键")) + String.valueOf(map.get("分段名称")) + String.valueOf(map.get("文件名")); + logger.info("唯一值++++++" + ser); + reportDownScanFileDto.setSerialnum(ser); + reportDownScanFileDto.setFilestoragetype(filestoragetype); + reportDownScanFileDto.setFilesource(filesource); + reportDownScanFileDtos.add(reportDownScanFileDto); + reportDownDto.setScanfiles(reportDownScanFileDtos); + afCollectTaskService.insertServer(reportDownDto); + String post; + logger.info("上传下载参数-----" + reportDownDto); + post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class)); + Map resMap = JSON.parseObject(post, Map.class); + if (String.valueOf(resMap.get("code")).equals("500")) { + logger.info("下载服务-------" + String.valueOf(resMap.get("msg"))); + } + + } else { + logger.info(String.valueOf(map.get("住院号")) + "患者基础信息不存在!"); + } + + } catch (Exception e) { + logger.error(String.valueOf(map.get("住院号")) + e.getMessage()); + } + } + } catch (Exception e) { + e.printStackTrace(); + logger.error(e.getMessage()); + } catch (Throwable e) { + logger.error("throwable{}", e.getMessage()); + } +// System.err.println(startrow+"---------------"+(endrow-1)); +// System.err.println("处理数据---"+maps); + maps.clear(); + } + } + + + /** + * 根据时间采集扫描电子病历 + */ + private void collectByDateTest(String startDate, String endDate) { + //页码 + int startrow; + //每页10条数据 + int endrow; + //2.获取第一页10条数据开始采集 + logger.info("开始时间-----" + startDate + "结束时间-----" + "\n" + endDate); + Map headMap = new HashMap<>(); + headMap.put("Content-Type", "application/json"); + int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource"))); + int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype"))); + String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); + int filetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filetype"))); + String assortid = String.valueOf(FileUtils.getJsonByName("assortid")); + List maps; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String format; + for (startrow = 1; ; startrow += 10) { + endrow = 10 + startrow; + maps = scanningMapper.selectAllByDisDate(startrow, endrow - 1, startDate, endDate); + logger.info("处理采集数据" + maps); + // List maps = patientBRMapper.selectAll(1,1,startDate,endDate); + if (null == maps || maps.size() <= 0) { + break; + } + + try { + + for (Map map : maps) { + try { + ReportDownDto reportDownDto = new ReportDownDto(); + + reportDownDto.setCollectorid(collectorid); + reportDownDto.setAssortid(String.valueOf(map.get("分类id"))); + ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(); +// reportDownPatientDto.setInPatientNo(String.valueOf(map.get("住院号"))); +// reportDownPatientDto.setVisitId(String.valueOf(map.get("次数"))); + Date parse = simpleDateFormat.parse(String.valueOf(map.get("出院日期"))); + format = simpleDateFormat.format(parse); + String patientId = afCollectTaskService.getPatientIdByInpatientNoAndDate(String.valueOf(map.get("住院号")), format); + if (null != patientId) { + reportDownPatientDto.setPatientid(patientId); + reportDownDto.setPatient(reportDownPatientDto); + List reportDownScanFileDtos = new ArrayList<>(); + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setFiletype(filetype); + reportDownScanFileDto.setDownurl(String.valueOf(map.get("图像路径")) + "/" + String.valueOf(map.get("文件名"))); + reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名"))); + //处理下载地址为唯一值 + String ser = String.valueOf(map.get("图像路径").hashCode()) + "/" + String.valueOf(map.get("文件名").hashCode()); + int i1 = MurmurHash2.hash32(ser); + reportDownScanFileDto.setSerialnum(Integer.toBinaryString(i1).toString()); + reportDownScanFileDto.setFilestoragetype(filestoragetype); + reportDownScanFileDto.setFilesource(filesource); + reportDownScanFileDtos.add(reportDownScanFileDto); + reportDownDto.setScanfiles(reportDownScanFileDtos); + afCollectTaskService.insertServer(reportDownDto); + String post; + logger.info("上传下载参数-----" + reportDownDto); + post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class)); + Map resMap = JSON.parseObject(post, Map.class); + if (String.valueOf(resMap.get("code")).equals("500")) { + logger.info("下载服务-------" + String.valueOf(resMap.get("msg"))); + } + + } else { + logger.info(String.valueOf(map.get("住院号")) + "患者基础信息不存在!"); + } + + } catch (Exception e) { + logger.error(String.valueOf(map.get("住院号")) + e.getMessage()); + } + } + } catch (Exception e) { + e.printStackTrace(); + logger.error(e.getMessage()); + } catch (Throwable e) { + logger.error("throwable{}", e.getMessage()); + } +// System.err.println(startrow+"---------------"+(endrow-1)); +// System.err.println("处理数据---"+maps); + maps.clear(); + } + } + + + /** + * 根据时间采集扫描电子病历 + */ + private void collectByDateSm(String startDate, String endDate) { + //页码 + int startrow; + //每页10条数据 + int endrow; + //2.获取第一页10条数据开始采集 + logger.info("开始时间-----" + startDate + "结束时间-----" + "\n" + endDate); + Map headMap = new HashMap<>(); + headMap.put("Content-Type", "application/json"); + int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource"))); + int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype"))); + int filetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filetype"))); + String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); + String assortid = String.valueOf(FileUtils.getJsonByName("assortid")); + List maps; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String format; + for (startrow = 1; ; startrow += 10) { + endrow = 10 + startrow; + maps = scanningMapper.selectAll(startrow, endrow - 1, startDate, endDate); + // List maps = patientBRMapper.selectAll(1,1,startDate,endDate); + if (null == maps || maps.size() <= 0) { + break; + } + + try { + logger.info("处理采集数据" + maps); + + for (Map map : maps) { + try { + ReportDownDto reportDownDto = new ReportDownDto(); + + reportDownDto.setCollectorid(collectorid); + reportDownDto.setAssortid(String.valueOf(map.get("分类id"))); + ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(); + +// reportDownPatientDto.setInPatientNo(String.valueOf(map.get("住院号"))); +// reportDownPatientDto.setVisitId(String.valueOf(map.get("次数"))); + Date parse = simpleDateFormat.parse(String.valueOf(map.get("出院日期"))); + format = simpleDateFormat.format(parse); + String patientId = afCollectTaskService.getPatientIdByInpatientNoAndDate(String.valueOf(map.get("住院号")), format); + reportDownPatientDto.setPatientid(patientId); + reportDownDto.setPatient(reportDownPatientDto); + List reportDownScanFileDtos = new ArrayList<>(); + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setFiletype(filetype); + reportDownScanFileDto.setDownurl(String.valueOf(map.get("图像路径")) + "/" + String.valueOf(map.get("文件名"))); + reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")).substring(0,map.get("文件名").toString().indexOf("."))); + //处理下载地址为唯一值 + String ser = String.valueOf(map.get("主键")) + String.valueOf(map.get("分段名称")) + String.valueOf(map.get("文件名")); + reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名"))); + reportDownScanFileDto.setSerialnum(ser); + reportDownScanFileDto.setFilestoragetype(filestoragetype); + reportDownScanFileDto.setFilesource(filesource); + reportDownScanFileDtos.add(reportDownScanFileDto); + reportDownDto.setScanfiles(reportDownScanFileDtos); + afCollectTaskService.insertServer(reportDownDto); + String post; + logger.info("上传下载参数-----" + reportDownDto); + post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class)); + Map resMap = JSON.parseObject(post, Map.class); + if (String.valueOf(resMap.get("code")).equals("500")) { + logger.info("下载服务{}", String.valueOf(resMap.get("msg"))); + } + } catch (Exception e) { + logger.error(String.valueOf(map.get("住院号") + "错误信息" + e.getMessage())); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } catch (Throwable t) { + logger.error("throwable,{}", t.getMessage()); + } + maps.clear(); + } + + } + + + /** * 更新采集时间 */ @@ -376,6 +821,7 @@ public class BgtsServiceImpl implements IBgtsService { return reportDownDto; } + /** * 创建ReportDownScanFileDto对象 通过报告单号 * @@ -416,7 +862,62 @@ public class BgtsServiceImpl implements IBgtsService { XmlUtils reqXmlUtils = new XmlUtils(FileUtils.getXmlPath()); Element reqElement = reqXmlUtils.getMsgElement(); + Map map = afCollectAddMapper.selectDate(empId); reqElement.element("INHOSP_NO").setText(empId); + reqElement.element("BEGIN_DATE").setText(new SimpleDateFormat(FileUtils.getJsonByName("dateFormat").toString()).format(map.get("admiss_date"))); + reqElement.element("END_DATE").setText(new SimpleDateFormat(FileUtils.getJsonByName("dateFormat").toString()).format(map.get("dis_date"))); + logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------"); + String xml = reqXmlUtils.getDocument().asXML(); + logger.info("---------------------------"); + logger.info(xml); + logger.info("----------------------------"); + String resXml = invokeWs(xml); + logger.info("---------返回值-------------"); + logger.info(resXml); + logger.info("-----------------------------"); + //解析XML + XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8"))); + String success = xmlUtils.isSuccess(); + if (!success.equals("ok")) { + logger.info("发送错误:" + success); + throw new RuntimeException(success); + } + List dis = (List) FileUtils.getJsonByName("bgtsRespon"); + //数据所在节点 + Element element = xmlUtils.getElement(dis); + List examInfos = element.elements("ExamInfo"); + Element examNo; + String[] key; + for (Element examInfo : examInfos) { + key = new String[2]; + examNo = examInfo.element(String.valueOf(FileUtils.getJsonByName("examNo"))); + if (examNo != null) { + key[0] = examNo.getText(); + } + Element examItemInfo = examInfo.element("ExamItemInfo"); + if (examItemInfo != null) { + key[1] = examItemInfo.element(String.valueOf(FileUtils.getJsonByName("examItemName"))).getText(); + } + exams.add(key); + } + return exams; + } + + /** + * 通过empId获取报告单号集合 pacs + * + * @param empId + * @return + */ + private List getExamNo(String empId, String admissDate, String disDate) throws Exception { + List exams = new ArrayList<>(); + + XmlUtils reqXmlUtils = new XmlUtils(FileUtils.getXmlPath()); + Element reqElement = reqXmlUtils.getMsgElement(); + Map map = afCollectAddMapper.selectDate(empId); + reqElement.element("INHOSP_INDEX_NO").setText(empId); + reqElement.element("BEGIN_DATE").setText(admissDate); + reqElement.element("END_DATE").setText(disDate); logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------"); String xml = reqXmlUtils.getDocument().asXML(); logger.info("---------------------------"); @@ -489,8 +990,8 @@ public class BgtsServiceImpl implements IBgtsService { // } try { for (String patientId : patientIds) { - if (patientId!=null){ - logger.info("按需采集------患者"+patientId); + if (patientId != null) { + logger.info("按需采集------患者" + patientId); collect(patientId); } } @@ -506,6 +1007,10 @@ public class BgtsServiceImpl implements IBgtsService { } + public List test(int size, int current) { + return testMapper.selectAll(size, current); + } + /** * 调用web service * @@ -524,5 +1029,6 @@ public class BgtsServiceImpl implements IBgtsService { return str; } + } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f4b45a1..57adfdf 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -25,10 +25,15 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver username: docus password: docus702 - url: jdbc:mysql://db.docus.cn:3306/docus_archivefile?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true&allowMultiQueries=true + url: jdbc:mysql://localhost:3306/docus_archivefile?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true&allowMultiQueries=true oracle-docus: driver-class-name: oracle.jdbc.driver.OracleDriver # url: jdbc:oracle:thin:@localhost:1521:ORCL url: jdbc:oracle:thin:@192.168.117.100:1521:helowin username: docus password: docus702 + sqlserver-docus: + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + username: sa + password: 123456 + url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=jizhen diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 8d89969..0b28482 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -21,8 +21,8 @@ log/demo.%d.%i.log - - 15 + + 30 10MB diff --git a/src/main/resources/mapper/dbmysql/AfCollectAddMapper.xml b/src/main/resources/mapper/dbmysql/AfCollectAddMapper.xml index ad1f222..bf495ea 100644 --- a/src/main/resources/mapper/dbmysql/AfCollectAddMapper.xml +++ b/src/main/resources/mapper/dbmysql/AfCollectAddMapper.xml @@ -15,6 +15,12 @@ limit ${pageNumber},${pageSize} + + select patient_id - from docus_medicalrecord.t_basic + from docus_medicalrecord.t_basic_out where jzh = #{jzh} + + + + +