diff --git a/pom.xml b/pom.xml index e07fdae..aa6d89d 100644 --- a/pom.xml +++ b/pom.xml @@ -53,10 +53,22 @@ 1.16.14 - com.spring4all - swagger-spring-boot-starter - 1.9.0.RELEASE + io.springfox + springfox-swagger2 + 2.9.2 + + + io.springfox + springfox-swagger-ui + 2.9.2 + + + com.github.xiaoymin + swagger-bootstrap-ui + 1.9.6 + + org.apache.commons diff --git a/src/main/java/com/docus/bgts/config/MyScheduling.java b/src/main/java/com/docus/bgts/config/MyScheduling.java index 5599fff..48357af 100644 --- a/src/main/java/com/docus/bgts/config/MyScheduling.java +++ b/src/main/java/com/docus/bgts/config/MyScheduling.java @@ -74,15 +74,15 @@ public class MyScheduling { * 手麻/重症采集器 * 10分钟执行一次 */ -// @Scheduled(fixedRate = 1000 * 60 * 10) -// public void collect() { -// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); -// if ((!collectorid.equals(Codes.SMCODE.getCode())) && (!collectorid.equals(Codes.ZZCODE.getCode()))) { -// return; -// } -// bgtsService.timerCollect(); -// } - + @Scheduled(fixedRate = 1000 * 60 * 10) + public void collect() { + String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); + if ((!collectorid.equals(Codes.SMCODE.getCode())) && (!collectorid.equals(Codes.ZZCODE.getCode()))) { + return; + } + bgtsService.timerCollect(); + } +// // // 时间 // private static List date = new ArrayList<>(); // // 上次任务执行时间 @@ -95,9 +95,9 @@ public class MyScheduling { // myScheduling.collectByExamNo(); // TimeUnit.MILLISECONDS.sleep(500); // } -// -//// System.out.println(date); -//// System.out.println(currentIndex); + +// System.out.println(date); +// System.out.println(currentIndex); // } // private static void initDate() throws Exception { // String configStart = String.valueOf(FileUtils.getJsonByName("collectStartDate")); @@ -113,7 +113,7 @@ public class MyScheduling { // localDate = localDate.plusDays(1); // } // } - +// /** @@ -160,24 +160,24 @@ public class MyScheduling { // } // // } - - @Scheduled(cron ="0 0 0 * * ?") - public void collect(){ - String intervalDayOpen = String.valueOf(FileUtils.getJsonByName("intervalDayOpen")); - if (intervalDayOpen.equals("1")){ - try{ - String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); - int day = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("intervalDay"))); - logger.info("0点采集前"+day+"天出院数据"); - Map dateCollectionTime = getDateCollectionTime(new Date(), day); - logger.info("采集"+dateCollectionTime.get("startDate")+"至-------"+dateCollectionTime.get("endDate")+"数据"); - bgtsService.collectByDate(dateCollectionTime.get("startDate"),dateCollectionTime.get("endDate"),collectorid,String.valueOf(0)); - }catch (Exception e) { - logger.error("pacs二次采集出错!---"+e.getMessage()); - } - - } - } +// +// @Scheduled(cron ="0 0 0 * * ?") +// public void collect(){ +// String intervalDayOpen = String.valueOf(FileUtils.getJsonByName("intervalDayOpen")); +// if (intervalDayOpen.equals("1")){ +// try{ +// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); +// int day = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("intervalDay"))); +// logger.info("0点采集前"+day+"天出院数据"); +// Map dateCollectionTime = getDateCollectionTime(new Date(), day); +// logger.info("采集"+dateCollectionTime.get("startDate")+"至-------"+dateCollectionTime.get("endDate")+"数据"); +// bgtsService.collectByDate(dateCollectionTime.get("startDate"),dateCollectionTime.get("endDate"),collectorid,String.valueOf(0)); +// }catch (Exception e) { +// logger.error("pacs二次采集出错!---"+e.getMessage()); +// } +// +// } +// } /** diff --git a/src/main/java/com/docus/bgts/config/SwaggerConfig.java b/src/main/java/com/docus/bgts/config/SwaggerConfig.java new file mode 100644 index 0000000..18350dd --- /dev/null +++ b/src/main/java/com/docus/bgts/config/SwaggerConfig.java @@ -0,0 +1,42 @@ +package com.docus.bgts.config; + + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + + /* + * 1.配置生成的文档信息 + * 2.配置生成规则 + * */ + + //Docket封装接口文档信息 + @Bean + public Docket getDocket(){ + + //创建封面信息对象 + ApiInfoBuilder apiInfoBuilder = new ApiInfoBuilder(); + apiInfoBuilder.title("查询采集接口说明") + .description("") + .version("v 1.0.0"); + ApiInfo apiInfo = apiInfoBuilder.build(); + + Docket docket = new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo) + .select() + .apis(RequestHandlerSelectors.basePackage("com.docus.bgts.controller")) + .build(); + + return docket; + } +} + diff --git a/src/main/java/com/docus/bgts/controller/BgtsController.java b/src/main/java/com/docus/bgts/controller/BgtsController.java index 84e52bf..91421e1 100644 --- a/src/main/java/com/docus/bgts/controller/BgtsController.java +++ b/src/main/java/com/docus/bgts/controller/BgtsController.java @@ -18,6 +18,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.Date; + @Api(value = "采集接口", tags = "采集接口") @RestController @@ -34,120 +36,202 @@ public class BgtsController { @Autowired IAfCollectTaskService afCollectTaskService; - @ApiOperation("完整性同步程序开关0:关闭 1:开启") - @GetMapping("/onOffSync") - public void onOffSync(@RequestParam(value = "flag",defaultValue = "0") String flag){ - MyScheduling.syncFlag=flag; - } +// @ApiOperation("完整性同步程序开关0:关闭 1:开启") +// @GetMapping("/onOffSync") +// public void onOffSync(@RequestParam(value = "flag",defaultValue = "0") String flag){ +// MyScheduling.syncFlag=flag; +// } +// +// @GetMapping("/addSyncIntegrality") +// public void addSyncIntegrality(@RequestParam("startDate")String startDate,String endDate){ +// checkIntegrityService.addSyncIntegrality(startDate,endDate); +// } +// +// @GetMapping("/addSyncIntegralityByJzhs") +// public CommonResult addSyncIntegrality(@RequestParam("jzhs")String jzhs){ +// if(jzhs.split(",").length > 100){ +// return CommonResult.failed("jzh个数不能超过100个"); +// } +// checkIntegrityService.addSyncIntegralityByJzhs(jzhs); +// return CommonResult.success("完成"); +// } - @GetMapping("/addSyncIntegrality") - public void addSyncIntegrality(@RequestParam("startDate")String startDate,String endDate){ - checkIntegrityService.addSyncIntegrality(startDate,endDate); - } +// @ApiOperation("采集接口") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "empId",value = "患者主索引号",required = true,dataTypeClass = String.class), +// @ApiImplicitParam(name = "collectSubId",value = "af_interface_collect_sub表id",required = true) +// }) +// @GetMapping("/collect") +// public CommonResult collect(@RequestParam("collectSubId") String collectSubId, +// @RequestParam("empId") String empId) { +// try { +// logger.info("采集接口接收到参数:\nempId--"+empId+"\ncollectSubId--"+collectSubId); +// bgtsService.collect(empId); +// 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(); +// }catch (Throwable t){ +// t.printStackTrace(); +// logger.error("throwable,{}", t.getMessage()); +// } +// 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"); +// } +// - @GetMapping("/addSyncIntegralityByJzhs") - public CommonResult addSyncIntegrality(@RequestParam("jzhs")String jzhs){ - if(jzhs.split(",").length > 100){ - return CommonResult.failed("jzh个数不能超过100个"); - } - checkIntegrityService.addSyncIntegralityByJzhs(jzhs); - return CommonResult.success("完成"); - } +// @ApiOperation("动态心电采集接口") +// @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("/collectEcg") +// public CommonResult collectEcg(@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.collectEcg(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"); +// } - @ApiOperation("采集接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "empId",value = "患者主索引号",required = true,dataTypeClass = String.class), - @ApiImplicitParam(name = "collectSubId",value = "af_interface_collect_sub表id",required = true) - }) - @GetMapping("/collect") - public CommonResult collect(@RequestParam("collectSubId") String collectSubId, - @RequestParam("empId") String empId) { - try { - logger.info("采集接口接收到参数:\nempId--"+empId+"\ncollectSubId--"+collectSubId); - bgtsService.collect(empId); - 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(); - }catch (Throwable t){ - t.printStackTrace(); - logger.error("throwable,{}", t.getMessage()); - } - return CommonResult.success("ok"); - } +// /** +// * 按需采集 +// * @param emamNo +// * @return +// */ +// @ApiOperation("按需采集接口") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "emamNo",value = "报告单号",required = true,dataTypeClass = String.class), +// @ApiImplicitParam(name = "empId",value = "患者主索引号",required = true,dataTypeClass = String.class) +// }) +// @GetMapping("/collectByExamNo") +// public CommonResult collectByExamNo(@RequestParam("emamNo") String emamNo, +// @RequestParam("empId") String empId){ +// try { +// logger.info("按需采集接口接受参数:\nempId--"+empId+"\nemamNo--"+emamNo); +// bgtsService.collectByExamNo(emamNo,empId); +//// afCollectTaskService.updateInterfaceCollect(collectSubId, 1); +// }catch (RuntimeException e) { +// e.printStackTrace(); +// return CommonResult.failed(e.getMessage()); +// } +// catch (Exception e) { +// e.printStackTrace(); +// } +// 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"); - } +// /** +// * 按需采集 +// */ +// @GetMapping("/collectByEx") +// public CommonResult collectByEx(@RequestParam("empId") String empId){ +// try{ +// bgtsService.collect(empId); +// }catch (Exception e){ +// e.printStackTrace(); +// return CommonResult.failed(e.getMessage()); +// } +// return CommonResult.success("ok"); +// } +// /** +// * pacs按需采集 +// */ +// @ApiOperation("pacs按需采集接口") +// @GetMapping("/collectByPacs") +// public CommonResult collectByPacs(){ +// try{ +// bgtsService.collectPacss(); +// }catch (Exception e){ +// e.printStackTrace(); +// return CommonResult.failed(e.getMessage()); +// } +// return CommonResult.success("ok"); +// } - @ApiOperation("动态心电采集接口") + @ApiOperation("手麻根据出院时间区间补偿采集接口") @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) + @ApiImplicitParam(name = "startDate",value = "开始时间",required = true), + @ApiImplicitParam(name = "endDate",value = "结束时间",required = true) }) - @GetMapping("/collectEcg") - public CommonResult collectEcg(@RequestParam("collectSubId") String collectSubId, - @RequestParam("empId") String empId, - @RequestParam("admissDate") String admissDate, - @RequestParam("disDate") String disDate, - @RequestParam("times") String times){ + @GetMapping("/collectPacsCompensate") + public CommonResult collectSm( + @RequestParam("startDate") String startDate, + @RequestParam("endDate") String endDate){ try { - logger.info("采集接口接收到参数:\nempId--"+empId+"\ncollectSubId--"+collectSubId); - bgtsService.collectEcg(empId,admissDate,disDate,times); - logger.info("采集完成"); - afCollectTaskService.updateInterfaceCollect(collectSubId, 1); - logger.info("------------采集结束-----------"); + bgtsService.collectSmByDate(startDate,endDate); } catch (RuntimeException e) { e.printStackTrace(); try { - afCollectTaskService.updateInterfaceCollect(collectSubId, 0); }catch (Exception e1) { logger.info(e1.getMessage()); return CommonResult.failed(e1.getMessage()); @@ -159,62 +243,68 @@ public class BgtsController { } return CommonResult.success("ok"); } - - /** - * 按需采集 - * @param emamNo - * @return - */ - @ApiOperation("按需采集接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "emamNo",value = "报告单号",required = true,dataTypeClass = String.class), - @ApiImplicitParam(name = "empId",value = "患者主索引号",required = true,dataTypeClass = String.class) - }) - @GetMapping("/collectByExamNo") - public CommonResult collectByExamNo(@RequestParam("emamNo") String emamNo, - @RequestParam("empId") String empId){ - try { - logger.info("按需采集接口接受参数:\nempId--"+empId+"\nemamNo--"+emamNo); - bgtsService.collectByExamNo(emamNo,empId); -// afCollectTaskService.updateInterfaceCollect(collectSubId, 1); - }catch (RuntimeException e) { - e.printStackTrace(); - return CommonResult.failed(e.getMessage()); - } - catch (Exception e) { - e.printStackTrace(); - } - return CommonResult.success("ok"); - } - - /** - * 按需采集 - */ - @GetMapping("/collectByEx") - public CommonResult collectByEx(@RequestParam("empId") String empId){ - try{ - bgtsService.collect(empId); - }catch (Exception e){ - e.printStackTrace(); - return CommonResult.failed(e.getMessage()); - } - return CommonResult.success("ok"); - } - - /** - * pacs按需采集 - */ - @ApiOperation("pacs按需采集接口") - @GetMapping("/collectByPacs") - public CommonResult collectByPacs(){ - try{ - bgtsService.collectPacss(); - }catch (Exception e){ - e.printStackTrace(); - return CommonResult.failed(e.getMessage()); - } - return CommonResult.success("ok"); - } +// +// @ApiOperation("Pacs补偿采集接口") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "empId",value = "住院号",required = true,dataTypeClass = String.class), +// @ApiImplicitParam(name = "admissDate",value = "入院时间",required = true), +// @ApiImplicitParam(name = "disDate",value = "出院时间",required = true), +// @ApiImplicitParam(name = "times",value = "住院次数",required = true) +// }) +// @GetMapping("/collectPacsCompensate") +// public CommonResult collectPacs( +// @RequestParam("empId") String empId, +// @RequestParam("admissDate") String admissDate, +// @RequestParam("disDate") String disDate, +// @RequestParam("times") String times){ +// try { +// logger.info("采集接口接收到参数:\nempId--"+empId); +// bgtsService.collectPacs(empId,admissDate,disDate,times); +// logger.info("采集完成"); +// logger.info("------------采集结束-----------"); +// } catch (RuntimeException e) { +// e.printStackTrace(); +// try { +// }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"); +// } +// +// @ApiOperation("Pacs根据出院时间区间补偿采集接口") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "startDate",value = "开始时间",required = true), +// @ApiImplicitParam(name = "endDate",value = "结束时间",required = true) +// }) +// @GetMapping("/collectPacsByDate") +// public CommonResult collectPacsByDate( +// @RequestParam("startDate") String startDate, +// @RequestParam("endDate") String endDate){ +// try { +// logger.info("根据出院时间区间补偿采集接口收到参数:\n"+startDate+"\t"+endDate); +// bgtsService.collectPacsByDate(startDate,endDate); +// logger.info("采集完成"); +// logger.info("------------采集结束-----------"); +// } catch (RuntimeException e) { +// e.printStackTrace(); +// try { +// }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"); +// } diff --git a/src/main/java/com/docus/bgts/facade/IBgtsService.java b/src/main/java/com/docus/bgts/facade/IBgtsService.java index 6bc2e54..ef2b7d5 100644 --- a/src/main/java/com/docus/bgts/facade/IBgtsService.java +++ b/src/main/java/com/docus/bgts/facade/IBgtsService.java @@ -1,4 +1,7 @@ package com.docus.bgts.facade; + +import java.util.Date; + public interface IBgtsService { /** * 根据封存id进行封存病案的重症病历采集 @@ -50,7 +53,17 @@ public interface IBgtsService { */ void collectSealEcg(String sealId) throws Exception; + /** + * @date 2024/9/26 18:00 + * + * @param startDate + * @param endDate + */ + void collectSmByDate(String startDate, String endDate); + void collectPacss(); + + void collectPacsByDate(String startDate, String endDate); /** * 按需采集 * @param emamNo diff --git a/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java b/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java index 877af99..e04d57f 100644 --- a/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java +++ b/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java @@ -274,25 +274,29 @@ public class BgtsServiceImpl implements IBgtsService { } @Override - public void collectPacs(String empId, String admissDate, String disDate, String times) throws Exception { - SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd"); - Date ad = sim.parse(admissDate); - Date di = sim.parse(disDate); - String admiss = sim.format(ad); - String dis = sim.format(di); - //通过empId获取报告单号集合 - List exams = getExamNoByInpNo(empId, admiss, dis); - String jzh = afCollectTaskService.getJzhByInpatientNo(empId,times); - if (null == jzh) { - logger.info("通过住院号与住院次数未匹配到患者"); - return; + public void collectPacs(String empId, String admissDate, String disDate, String times) { + try { + SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd"); + Date ad = sim.parse(admissDate); + Date di = sim.parse(disDate); + String admiss = sim.format(ad); + String dis = sim.format(di); + //通过empId获取报告单号集合 + List exams = getExamNoByInpNo(empId, admiss, dis); + String jzh = afCollectTaskService.getJzhByInpatientNo(empId, times); + if (null == jzh) { + logger.info("通过住院号与住院次数未匹配到患者"); + return; + } + //获取插入表数据 + ReportDownDto reportDownDto = getUrlCreateReportDto(exams, jzh); + //插入文件af_collect_task表数据 + afCollectTaskService.insert(reportDownDto); + //通过报告单号集合采集 + collectExams(exams, empId, reportDownDto); + }catch (Exception e) { + logger.info(empId,":采集出错!",e.getMessage()); } - //获取插入表数据 - ReportDownDto reportDownDto = getUrlCreateReportDto(exams, jzh); - //插入文件af_collect_task表数据 - afCollectTaskService.insert(reportDownDto); - //通过报告单号集合采集 - collectExams(exams, empId, reportDownDto); } @Override @@ -417,6 +421,13 @@ public class BgtsServiceImpl implements IBgtsService { logger.info("--------------全量采集结束------------------"); } + @Override + public void collectSmByDate(String startDate, String endDate) { + logger.info("----------手麻采集开始时间:"+startDate+" 结束时间:"+endDate+"------"); + collectByDates(startDate, endDate); + logger.info("----------手麻采集结束-"); + } + @Override public void collectPacss(){ logger.info("按需采集任务执行----"); @@ -458,6 +469,47 @@ public class BgtsServiceImpl implements IBgtsService { } + @Override + public void collectPacsByDate(String startDate, String endDate) { + logger.info("按需采集任务执行----"); +// if (CollUtil.isEmpty(date)) { +// try { +// initDate(); +// } catch (Exception e) { +// logger.error(e.getMessage()); +// return; +// } +// } +// if (currentIndex >= date.size()) { +// currentIndex = 0; +// } +// logger.info("index:{},Thread {}", currentIndex, Thread.currentThread().getName()); +// String collectStartDate = date.get(currentIndex); +// String collectEndDate = collectStartDate + "\t23:59:59"; + String collectStartDate = String.valueOf(startDate)+"\t00:00:00"; + String collectEndDate = String.valueOf(endDate)+"\t23:59:59"; + String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); + String isDead = String.valueOf(FileUtils.getJsonByName("isDead")); + CountDownLatch countDownLatch = new CountDownLatch(1); + threadPoolExecutor.execute(() -> { + try { + collectByDate(collectStartDate, collectEndDate, collectorid,isDead); + }catch (Exception e) { + logger.info("按需采集出错{}",e.getMessage()); + } + countDownLatch.countDown(); + }); + try { + countDownLatch.await(); + } catch (Exception e) { + logger.error("JUC countDownLatch error {}", e.getMessage()); + } + logger.info("{},采集结束----", collectStartDate); + // currentIndex++; + System.gc(); + } + + @Override public void timerCollect() { logger.info("------采集器开始采集---------"); @@ -484,46 +536,84 @@ public class BgtsServiceImpl implements IBgtsService { public void collectByDate(String startDate, String endDate, String collectorId,String isDead) { logger.info("按需采集开始----------开始时间---" + startDate + "------结束时间---" + endDate); //页码 - int startrow; - //每页10条数据 - int endrow = 10; - //2.获取第一页10条数据开始采集 +// int startrow; +// //每页10条数据 +// int endrow = 10; +// //2.获取第一页10条数据开始采集 try{ - List patientIds; - for (startrow = 0; ; startrow += 10) { - if (("1").equals(isDead)){ - patientIds=afCollectTaskService.getjzhByDateAndIsDead(startDate, endDate, startrow, endrow); +// List patientIds; +// for (startrow = 0; ; startrow += 10) { +// if (("1").equals(isDead)){ +// patientIds=afCollectTaskService.getjzhByDateAndIsDead(startDate, endDate, startrow, endrow); +// logger.info("按需采集死亡患者----"); +// }else { +// patientIds = afCollectTaskService.getjzhByDate(startDate, endDate, startrow, endrow); +// } +// +// if (null == patientIds || patientIds.size() <= 0) { +// logger.info("未查询到按需采集患者!"); +// break; +// } +// for (Map patientId : patientIds) { +// if (patientId != null) { +// try { +// logger.info("按需采集------患者" + patientId.get("inpatient_no")); +// logger.info("处理按需采集第" + startrow + "条数据----"); +// if (collectorId.equals("3")) { +// collectPacs(String.valueOf(patientId.get("inpatient_no")), String.valueOf(patientId.get("admiss_date")) +// , String.valueOf(patientId.get("dis_date")), String.valueOf(patientId.get("admiss_times"))); +// } else if (collectorId.equals("4") || collectorId.equals("23")) { +// collectEcg(String.valueOf(patientId.get("jzh")), String.valueOf(patientId.get("admiss_date")) +// , String.valueOf(patientId.get("dis_date")), String.valueOf(patientId.get("admiss_times"))); +// } else { +// collect(String.valueOf(patientId.get("jzh"))); +// } +// +// } catch (Exception e) { +// logger.error("按需采集-患者inpatient_no:{},collectPacs() Error:{}", patientId.get("inpatient_no"), e.getMessage()); +// } +// } +// } +// patientIds.clear(); +// } + int startrow = 0; + int endrow = 10; + boolean hasMoreData = true; + + while (hasMoreData) { + List patientIds; + if ("1".equals(isDead)) { + patientIds = afCollectTaskService.getjzhByDateAndIsDead(startDate, endDate, startrow, endrow); logger.info("按需采集死亡患者----"); - }else { + } else { patientIds = afCollectTaskService.getjzhByDate(startDate, endDate, startrow, endrow); } - if (null == patientIds || patientIds.size() <= 0) { + if (patientIds == null || patientIds.isEmpty()) { logger.info("未查询到按需采集患者!"); - break; - } - for (Map patientId : patientIds) { - if (patientId != null) { - try { - logger.info("按需采集------患者" + patientId.get("inpatient_no")); - logger.info("处理按需采集第" + startrow + "条数据----"); - if (collectorId.equals("3")) { - collectPacs(String.valueOf(patientId.get("inpatient_no")), String.valueOf(patientId.get("admiss_date")) - , String.valueOf(patientId.get("dis_date")), String.valueOf(patientId.get("admiss_times"))); - } else if (collectorId.equals("4") || collectorId.equals("23")) { - collectEcg(String.valueOf(patientId.get("jzh")), String.valueOf(patientId.get("admiss_date")) - , String.valueOf(patientId.get("dis_date")), String.valueOf(patientId.get("admiss_times"))); - } else { - collect(String.valueOf(patientId.get("jzh"))); + hasMoreData = false; + } else { + for (Map patientId : patientIds) { + if (patientId != null) { + try { + logger.info("按需采集------患者" + patientId.get("inpatient_no")); + logger.info("处理按需采集第" + startrow + "条数据----"); + if (collectorId.equals("3")) { + collectPacs(String.valueOf(patientId.get("inpatient_no")), String.valueOf(patientId.get("admiss_date")), String.valueOf(patientId.get("dis_date")), String.valueOf(patientId.get("admiss_times"))); + } else if (collectorId.equals("4") || collectorId.equals("23")) { + collectEcg(String.valueOf(patientId.get("jzh")), String.valueOf(patientId.get("admiss_date")), String.valueOf(patientId.get("dis_date")), String.valueOf(patientId.get("admiss_times"))); + } else { + collect(String.valueOf(patientId.get("jzh"))); + } + } catch (Exception e) { + logger.error("按需采集-患者inpatient_no:{},collectPacs() Error:{}", patientId.get("inpatient_no"), e.getMessage()); } - - } catch (Exception e) { - logger.error("按需采集-患者inpatient_no:{},collectPacs() Error:{}", patientId.get("inpatient_no"), e.getMessage()); } } + startrow += 10; } - patientIds.clear(); } + }catch (Exception e){ logger.error(e.getMessage()); }catch (Throwable t) { diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 0b28482..0aa3cdc 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -21,8 +21,8 @@ log/demo.%d.%i.log - - 30 + + 180 10MB