From ebd7fb5c1f31b5ae4571baed0da17fc408ce33e2 Mon Sep 17 00:00:00 2001 From: liquanyu Date: Wed, 10 Nov 2021 10:35:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=BD=93=E9=87=8D=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=BB=BA=E6=A1=A3=E6=97=B6=E9=97=B4=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/lyms/platform/pojo/PatientWeight.java | 9 +++++ .../operate/web/controller/TestController.java | 43 ++++++++++++++++++++++ .../operate/web/facade/MeasureInfoFacade.java | 1 + .../platform/operate/web/facade/PatientFacade.java | 39 +++++++++++++++----- .../web/service/impl/PatientWeightServiceImpl.java | 1 + .../operate/web/worker/QuanWeightWorker.java | 28 ++------------ 6 files changed, 86 insertions(+), 35 deletions(-) diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/PatientWeight.java b/platform-dal/src/main/java/com/lyms/platform/pojo/PatientWeight.java index bd35056..e761a2f 100644 --- a/platform-dal/src/main/java/com/lyms/platform/pojo/PatientWeight.java +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/PatientWeight.java @@ -79,6 +79,8 @@ public class PatientWeight extends BaseModel { } private Date modified; + //建档时间 + private Date buildDate; public Date getModified() { return modified; @@ -145,6 +147,13 @@ public class PatientWeight extends BaseModel { private Integer type; private Integer isUp;//是否增长过快 1和空为正常 2 过快 + public Date getBuildDate() { + return buildDate; + } + + public void setBuildDate(Date buildDate) { + this.buildDate = buildDate; + } public Integer getIsUp() { return isUp; diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java index c2c238e..bf9f560 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java @@ -4053,6 +4053,49 @@ public class TestController extends BaseController { } + @ResponseBody + @RequestMapping(value = "/updateWeightBuildDate", method = RequestMethod.GET) + public String updateWeightBuildDate(@RequestParam(required = false) String hospitalId) { + List patientWeights = mongoTemplate.find(Query.query(Criteria.where("yn"). + is("1")), PatientWeight.class); + + System.out.println("本次读取了【" + patientWeights.size() + "】条数据"); + int batchSize = 1000; + int end = 0; + for (int i = 0; i < patientWeights.size(); i += batchSize) { + end = (end + batchSize); + if (end > patientWeights.size()) { + end = patientWeights.size(); + } + final List tempList = patientWeights.subList(i, end); + commonThreadPool.execute(new Runnable() { + @Override + public void run() { + if (CollectionUtils.isNotEmpty(tempList)) { + for (PatientWeight weight : tempList) { + try { + if (weight != null && StringUtils.isNotEmpty(weight.getPatientId())) + { + Patients patients = patientsService.findOnePatientById(weight.getPatientId()); + if (patients != null) + { + + weight.setBuildDate(patients.getBookbuildingDate()); + patientWeightService2.update(Query.query(Criteria.where("id").is(weight.getId())), weight); + } + } + }catch (Exception e) + { + continue; + } + } + } + } + }); + } + return "updateWeightBuildDate start......"; + } + @ResponseBody @RequestMapping(value = "/updateBabyAfterVisitStatisticsModel", method = RequestMethod.GET) diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MeasureInfoFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MeasureInfoFacade.java index 11c4d5b..a662113 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MeasureInfoFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MeasureInfoFacade.java @@ -1100,6 +1100,7 @@ public class MeasureInfoFacade { patientWeight.setIsNormal(isNormal); patientWeight.setIsUp(Integer.parseInt(isUp)); patientWeight.setType(patients.getType()); + patientWeight.setBuildDate(patients.getBookbuildingDate()); patientWeightService2.add(patientWeight); diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java index af565e0..fe9a8a4 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java @@ -783,6 +783,32 @@ public class PatientFacade extends BaseServiceImpl { criteria.and("type").is(Integer.parseInt(riskPatientsQueryRequest.getType())); } + //根据建档时间查询 + String bookbuildingDate=null; + if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getBookbuildingDate())) { + //根据建档时间查询整理传来的时间 + Date bookbuildingDateStart=null; + Date bookbuildingDateEnd=null; + if (StringUtils.isNotEmpty(bookbuildingDate)) { + String[] dates = bookbuildingDate.split(" - "); + bookbuildingDateStart=DateUtil.parseYMD(dates[0]); + if (dates.length == 2) { + bookbuildingDateEnd=new Date(DateUtil.parseYMD(dates[1]).getTime() + 24 * 60 * 60 * 1000 - 1); + } + } + //根据建档时间查询 拼查询语句 + if(null!=bookbuildingDateStart&&null!=bookbuildingDateEnd){ + criteria=criteria.and("buildDate").gte(bookbuildingDateStart).lte(bookbuildingDateEnd); + }else { + if(null!=bookbuildingDateStart){ + criteria=criteria.and("buildDate").gte(bookbuildingDateStart); + } + if(null!=bookbuildingDateEnd){ + criteria=criteria.and("buildDate").lte(bookbuildingDateEnd); + } + } + } + Query query = Query.query(criteria); String formatBmi = ""; if ("1".equals(riskPatientsQueryRequest.getBmi())) { @@ -801,16 +827,9 @@ public class PatientFacade extends BaseServiceImpl { query.addCriteria(Criteria.where("$where").is(formatBmi)); PageResult pageResult = findMongoPage(PatientWeight.class, query.with(new Sort(Sort.Direction.DESC, "modified")), riskPatientsQueryRequest.getPage(), riskPatientsQueryRequest.getLimit()); List patientWeightList = (List ) pageResult.getGrid(); - - //根据建档时间查询 - String bookbuildingDate=null; - if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getBookbuildingDate())) { - bookbuildingDate=riskPatientsQueryRequest.getBookbuildingDate(); - } - List data = new ArrayList <>(); if (CollectionUtils.isNotEmpty(patientWeightList)) { - data = convertToQuanWeight(patientWeightList,bookbuildingDate); + data = convertToQuanWeight(patientWeightList); } return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS) .setData(data).setPageInfo(new PageInfo(pageResult.getPage(), pageResult.getLastPage(), pageResult.getCount(), pageResult.getLimit())); @@ -1678,7 +1697,7 @@ public class PatientFacade extends BaseServiceImpl { return data; } - private List convertToQuanWeight(List patientWeightList,String bookbuildingDate) { + private List convertToQuanWeight(List patientWeightList) { List data = new ArrayList <>(); int batchSize = 4; int end = 0; @@ -1688,7 +1707,7 @@ public class PatientFacade extends BaseServiceImpl { if (end > patientWeightList.size()) { end = patientWeightList.size(); } - listFuture.add(commonThreadPool.submit(new QuanWeightWorker(patientWeightList.subList(i, end),bookbuildingDate, mongoTemplate, + listFuture.add(commonThreadPool.submit(new QuanWeightWorker(patientWeightList.subList(i, end), mongoTemplate, commonService, basicConfigService, trackDownRecordService,trackDownService,matDeliverService))); } for (Future f : listFuture) { diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java index 1dd8e7e..31d5d6d 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java @@ -258,6 +258,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient patientWeight.setIsNormal(result.get("isNormal")); patientWeight.setIsUp(Integer.parseInt(result.get("isUp"))); patientWeight.setType(1); + patientWeight.setBuildDate(patients.getBookbuildingDate()); patientWeightService2.add(patientWeight); operateLogFacade.addAddOptLog(userId, Integer.valueOf(hospitalId), patientWeight, OptActionEnums.ADD.getId(), "添加孕体重"); diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanWeightWorker.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanWeightWorker.java index f5a77df..a9750f0 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanWeightWorker.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanWeightWorker.java @@ -43,14 +43,12 @@ public class QuanWeightWorker implements Callable> { private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); private ITrackDownService trackDownService; private List patientWeightList; - private String bookbuildingDate; private MongoTemplate mongoTemplate; private CommonService commonService; private BasicConfigService basicConfigService; private TrackDownRecordService trackDownRecordService; private MatDeliverService matDeliverService; public QuanWeightWorker(List patientWeightList, - String bookbuildingDate, MongoTemplate mongoTemplate, CommonService commonService, BasicConfigService basicConfigService, @@ -59,7 +57,6 @@ public class QuanWeightWorker implements Callable> { MatDeliverService matDeliverService ) { this.patientWeightList = patientWeightList; - this.bookbuildingDate = bookbuildingDate; this.mongoTemplate = mongoTemplate; this.commonService = commonService; this.basicConfigService = basicConfigService; @@ -71,31 +68,12 @@ public class QuanWeightWorker implements Callable> { @Override public List call() throws Exception { - //根据建档时间查询整理传来的时间 - Date bookbuildingDateStart=null; - Date bookbuildingDateEnd=null; - if (StringUtils.isNotEmpty(bookbuildingDate)) { - String[] dates = bookbuildingDate.split(" - "); - bookbuildingDateStart=DateUtil.parseYMD(dates[0]); - if (dates.length == 2) { -// bookbuildingDateEnd=DateUtil.parseYMDHMS(dates[1]+" 23:59:59"); - bookbuildingDateEnd=new Date(DateUtil.parseYMD(dates[1]).getTime() + 24 * 60 * 60 * 1000 - 1); - } - } + + List data = new ArrayList<>(); for (PatientWeight patientWeight : patientWeightList){ Criteria criteriaPatients=Criteria.where("id").is(patientWeight.getPatientId()).and("yn").ne("0"); - //根据建档时间查询 拼查询语句 - if(null!=bookbuildingDateStart&&null!=bookbuildingDateEnd){ - criteriaPatients=criteriaPatients.and("bookbuildingDate").gte(bookbuildingDateStart).lte(bookbuildingDateEnd); - }else { - if(null!=bookbuildingDateStart){ - criteriaPatients=criteriaPatients.and("bookbuildingDate").gte(bookbuildingDateStart); - } - if(null!=bookbuildingDateEnd){ - criteriaPatients=criteriaPatients.and("bookbuildingDate").lte(bookbuildingDateEnd); - } - } + Query queryPatients=Query.query(criteriaPatients); List patientsList = mongoTemplate.find(queryPatients, Patients.class); -- 1.8.3.1