From a31072036e2e8c6bf63ae81c4efe068c8e156d27 Mon Sep 17 00:00:00 2001 From: tan <11033394+tanzr@user.noreply.gitee.com> Date: Thu, 9 Jun 2022 08:36:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E9=9C=80=E9=87=87=E9=9B=86=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Conflicts: # src/main/java/com/docus/bgts/config/MyScheduling.java # src/main/java/com/docus/bgts/controller/BgtsController.java # src/main/java/com/docus/bgts/facade/IMzSyncService.java --- .../com/docus/bgts/config/MyConstruct.java | 23 ++- .../com/docus/bgts/config/MyScheduling.java | 2 +- .../docus/bgts/controller/BgtsController.java | 29 ++-- .../docus/bgts/service/BgtsServiceImpl.java | 135 +++++++++++++++--- .../mapper/dboracle/VDocumentPdfMapper.xml | 37 ++--- 5 files changed, 174 insertions(+), 52 deletions(-) diff --git a/src/main/java/com/docus/bgts/config/MyConstruct.java b/src/main/java/com/docus/bgts/config/MyConstruct.java index f4f35cf..12ee26d 100644 --- a/src/main/java/com/docus/bgts/config/MyConstruct.java +++ b/src/main/java/com/docus/bgts/config/MyConstruct.java @@ -4,6 +4,8 @@ import com.docus.bgts.enums.Codes; import com.docus.bgts.facade.IBgtsService; import com.docus.bgts.utils.FileUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; @@ -15,20 +17,37 @@ public class MyConstruct { @Autowired IBgtsService bgtsService; + + /** + * 开启手麻全量采集 + */ +// @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(); +// } +// } + /** - * 开启全量采集 + * 开启重症全量采集 */ @PostConstruct public void startCollectAll(){ 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")){ + if(collectorid.equals(Codes.ZZCODE.getCode())&& StringUtils.isNotBlank(startCollectTime)&&isStartCollect!=null&&isStartCollect.equals("1")){ bgtsService.collectAll(); } } + + //在spring容器关闭时,释放 @PreDestroy public void destroy() { diff --git a/src/main/java/com/docus/bgts/config/MyScheduling.java b/src/main/java/com/docus/bgts/config/MyScheduling.java index 2477958..bed86c5 100644 --- a/src/main/java/com/docus/bgts/config/MyScheduling.java +++ b/src/main/java/com/docus/bgts/config/MyScheduling.java @@ -56,7 +56,7 @@ public class MyScheduling { /** - * 手麻采集器 + * 手麻/重症采集器 * 10分钟执行一次 */ // @Scheduled(fixedRate = 1000 * 60 * 10) diff --git a/src/main/java/com/docus/bgts/controller/BgtsController.java b/src/main/java/com/docus/bgts/controller/BgtsController.java index 0c6dae7..082104e 100644 --- a/src/main/java/com/docus/bgts/controller/BgtsController.java +++ b/src/main/java/com/docus/bgts/controller/BgtsController.java @@ -5,7 +5,7 @@ import com.docus.bgts.config.MyScheduling; import com.docus.bgts.entity.CommonResult; import com.docus.bgts.facade.IAfCollectTaskService; import com.docus.bgts.facade.IBgtsService; -import com.docus.bgts.service.CheckIntegrityService; +import com.docus.bgts.facade.IMzSyncService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -25,7 +25,7 @@ public class BgtsController { private final Logger logger = LoggerFactory.getLogger(getClass()); @Autowired - CheckIntegrityService checkIntegrityService; + IMzSyncService mzSyncService; @Autowired IBgtsService bgtsService; @@ -44,13 +44,9 @@ public class BgtsController { 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("/syncIntegrality") + public void syncIntegrality(){ + mzSyncService.syncIntegrality(); } @@ -111,4 +107,19 @@ public class BgtsController { 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"); + } + + } diff --git a/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java b/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java index 2a4d9d7..b290cf6 100644 --- a/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java +++ b/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java @@ -107,12 +107,12 @@ public class BgtsServiceImpl implements IBgtsService { } /** - * 根据时间到采集任务 + * 根据时间到采集任务 手麻 * * @param startDate * @param endDate */ - private void collectByDates(String startDate, String endDate) { + /* private void collectByDates(String startDate, String endDate) { //页码 int current; //每页10条数据 @@ -142,7 +142,7 @@ public class BgtsServiceImpl implements IBgtsService { //2.获取第一页10条数据开始采集 for (current = 1; ; current++) { size = 10 * current; - maps = vDocumentPdfMapper.listCollectPage(current, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName); + maps = vDocumentPdfMapper.listCollectPage(size-10, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName); logger.info("处理采集数据:"+maps); if (null == maps || maps.size() <= 0) { break; @@ -186,6 +186,89 @@ public class BgtsServiceImpl implements IBgtsService { } }); } + }*/ + /** + * 根据时间到采集任务 重症 + * + * @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条数据开始采集 + 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.setJzh(String.valueOf(map.get(indexFlag))); + reportDownDto.setPatient(reportDownPatientDto); + + 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.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(); + } + }); + } } @Override @@ -290,6 +373,7 @@ public class BgtsServiceImpl implements IBgtsService { Element esbEntry = reqXmlUtils.getMsgElement(); esbEntry.element("EXAM_NO").setText(exam[0]); String resXml = invokeWs(reqXmlUtils.getDocument().asXML()); + logger.info("明细入参------------"+reqXmlUtils.getDocument().asXML()); //解析XML XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8"))); String success = xmlUtils.isSuccess(); @@ -364,29 +448,34 @@ public class BgtsServiceImpl implements IBgtsService { //通过日期查询patientId集合 List patientIds = afCollectTaskService.getjzhByDate(startDate,endDate); //通过patientId集合与采集器编号查询报告单号 - //List c1s = afCollectTaskMapper.getC1ByPatientId(patientIds,collectorId); - List c1s = afCollectTaskService.getC1ByPatientId(patientIds, collectorId); + //List c1s = afCollectTaskService.getC1ByPatientId(patientIds, collectorId); //通过唯一报告单号查询patient_id - List patientIdByC1 = afCollectTaskService.getPatientIdByC1(c1s); + //List patientIdByC1 = afCollectTaskService.getPatientIdByC1(c1s); //通过patientId集合查询jzh - //List jzhs = afCollectTaskMapper.getJzhByPatientId(patientIds); - List jzhs = afCollectTaskService.getJzhByPatientId(patientIdByC1); - int i = -1; + List jzhs = afCollectTaskService.getJzhByPatientId(patientIds); + //int i = -1; //循环jzh与报告单号c1调用按需采集 - for (String c1 : c1s) { - try { - if (i \ No newline at end of file