Commit 75c8a9753946db3bc2c1646eb61ab8a3cd1eced2
1 parent
30c2995f8d
Exists in
master
and in
1 other branch
产检节点统计
Showing 4 changed files with 116 additions and 25 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/AntenatalExaminationDaoImpl.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/AntExRecordService.java
- platform-dal/src/main/java/com/lyms/platform/pojo/AntExRecordModel.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/AntenatalExaminationDaoImpl.java
View file @
75c8a97
| ... | ... | @@ -137,28 +137,17 @@ |
| 137 | 137 | |
| 138 | 138 | @Override |
| 139 | 139 | public int queryWeekPointCount(int startWeek, int endWeek, String hospitalId, Date startTime, Date endTime,Integer pointType) { |
| 140 | -// String map = "function(){ " + | |
| 141 | -// " if (this.hospitalId == '"+hospitalId+"' && this.checkTime != null && this.lastMenses != null) { " + | |
| 142 | -// " var start = this.lastMenses; " + | |
| 143 | -// " var end = this.checkTime; " + | |
| 144 | -// " var iDays = parseInt(Math.abs(end - start ) / 86400000); " + | |
| 145 | -// " var week = parseInt(iDays/7)+1; " + | |
| 146 | -// " if (week >= "+startWeek+" && week <= "+endWeek+")" + | |
| 147 | -// " { " + | |
| 148 | -// " emit(this._id,{checkTime:end,parentId:this.parentId}); " + | |
| 149 | -// " } " + | |
| 150 | -// " } " + | |
| 151 | -// "}"; | |
| 152 | - String map = "function(){ " + | |
| 153 | - " if (this.hospitalId == '"+hospitalId+"' && this.checkTime != null && this.lastMenses != null) { " + | |
| 154 | - " var end = this.checkTime; " + | |
| 155 | - " var week = parseInt(this.cDay/7); " + | |
| 156 | - " if (week >= "+startWeek+" && week <= "+endWeek+")" + | |
| 157 | - " { " + | |
| 158 | - " emit(this._id,{checkTime:end,parentId:this.parentId}); " + | |
| 159 | - " } " + | |
| 160 | - " } " + | |
| 161 | - "}"; | |
| 140 | + String map = "function(){ " + | |
| 141 | + " if (this.hospitalId == '"+hospitalId+"' && this.checkTime != null && this.lastMenses != null) { " + | |
| 142 | + " var end = this.checkTime; " + | |
| 143 | + " var week = parseInt(this.cDay/7); " + | |
| 144 | + " if (week >= "+startWeek+" && week <= "+endWeek+")" + | |
| 145 | + " { " + | |
| 146 | + " emit(this._id,{checkTime:end,parentId:this.parentId}); " + | |
| 147 | + " } " + | |
| 148 | + " } " + | |
| 149 | + "}"; | |
| 150 | + | |
| 162 | 151 | String reduce = "function(key, values) { return values.toString(); }"; |
| 163 | 152 | |
| 164 | 153 | DBCollection collections =this.mongoTemplate.getCollection("lyms_antexrecord"); |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/AntExRecordService.java
View file @
75c8a97
| ... | ... | @@ -58,13 +58,13 @@ |
| 58 | 58 | * @param antExRecordQuery |
| 59 | 59 | * @return |
| 60 | 60 | */ |
| 61 | - public List<AntExPRecordModel> queryAntExRecords1(AntExRecordQuery antExRecordQuery) { | |
| 61 | + public List<AntExPRecordModel> queryAntExRecords(AntExRecordQuery antExRecordQuery,String sortField) { | |
| 62 | 62 | MongoQuery query = antExRecordQuery.convertToQuery(); |
| 63 | 63 | if (StringUtils.isNotEmpty(antExRecordQuery.getNeed())) { |
| 64 | 64 | antExRecordQuery.mysqlBuild(iAntExRecordMDao.count(query)); |
| 65 | 65 | query.start(antExRecordQuery.getOffset()).end(antExRecordQuery.getLimit()); |
| 66 | 66 | } |
| 67 | - return iAntExRecordMDao.queryRecord(query.addOrder(Sort.Direction.DESC, "checkTime")); | |
| 67 | + return iAntExRecordMDao.queryRecord(query.addOrder(Sort.Direction.DESC, sortField)); | |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 |
platform-dal/src/main/java/com/lyms/platform/pojo/AntExRecordModel.java
View file @
75c8a97
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
View file @
75c8a97
| ... | ... | @@ -93,6 +93,10 @@ |
| 93 | 93 | @Autowired |
| 94 | 94 | private GenSequenceIdService genIdService; |
| 95 | 95 | |
| 96 | + | |
| 97 | + @Autowired | |
| 98 | + private AntExRecordService recordService; | |
| 99 | + | |
| 96 | 100 | /** |
| 97 | 101 | * 获取科室 |
| 98 | 102 | */ |
| ... | ... | @@ -341,6 +345,104 @@ |
| 341 | 345 | |
| 342 | 346 | return "update finish"; |
| 343 | 347 | } |
| 348 | + | |
| 349 | + | |
| 350 | + /** | |
| 351 | + * 计算产检是不是对应孕周断中的第一次 | |
| 352 | + * @param hospitalId | |
| 353 | + * @return | |
| 354 | + */ | |
| 355 | + @RequestMapping(value = "/updateCheckRecord", method = RequestMethod.GET) | |
| 356 | + @ResponseBody | |
| 357 | + public String updateCheckRecord(@RequestParam(required = false) String hospitalId | |
| 358 | + ) { | |
| 359 | + | |
| 360 | + OrganizationQuery organizationQuery = new OrganizationQuery(); | |
| 361 | + organizationQuery.setYn(YnEnums.YES.getId()); | |
| 362 | + if (StringUtils.isNotEmpty(hospitalId)) | |
| 363 | + { | |
| 364 | + organizationQuery.setId(Integer.parseInt(hospitalId)); | |
| 365 | + } | |
| 366 | + List<Organization> organizationList = organizationService.queryOrganization(organizationQuery); | |
| 367 | + | |
| 368 | + PatientsQuery patientsQuery1 = new PatientsQuery(); | |
| 369 | + patientsQuery1.setYn(YnEnums.YES.getId()); | |
| 370 | + | |
| 371 | + if (CollectionUtils.isNotEmpty(organizationList)) | |
| 372 | + { | |
| 373 | + for (Organization organization : organizationList) { | |
| 374 | + | |
| 375 | + patientsQuery1.setHospitalId(organization.getId()+""); | |
| 376 | + List<Patients> pats = patientsService.queryPatient(patientsQuery1); | |
| 377 | + | |
| 378 | + int batchSize = 1000; | |
| 379 | + int end = 0; | |
| 380 | + for (int i = 0; i < pats.size(); i += batchSize) { | |
| 381 | + end = (end + batchSize); | |
| 382 | + if (end > pats.size()) { | |
| 383 | + end = pats.size(); | |
| 384 | + } | |
| 385 | + System.out.println("start:" + i + ",end:" + end); | |
| 386 | + final List<Patients> tempList = pats.subList(i, end); | |
| 387 | + | |
| 388 | + new Thread(new Runnable() { | |
| 389 | + @Override | |
| 390 | + public void run() { | |
| 391 | + if (CollectionUtils.isNotEmpty(tempList)) { | |
| 392 | + AntExRecordQuery antExRecordQuery = new AntExRecordQuery(); | |
| 393 | + for (Patients pat : tempList) { | |
| 394 | + antExRecordQuery.setParentId(pat.getId()); | |
| 395 | + if (StringUtils.isNotEmpty(pat.getId())) | |
| 396 | + { | |
| 397 | + | |
| 398 | + for (int i = 0 ; i < 5 ; i++) | |
| 399 | + { | |
| 400 | + if (i == 0) | |
| 401 | + { | |
| 402 | + antExRecordQuery.setcDueWeekStart(0); | |
| 403 | + antExRecordQuery.setcDueWeekEnd((12 + 1) * 7 - 1); | |
| 404 | + } | |
| 405 | + else if (i == 1) | |
| 406 | + { | |
| 407 | + antExRecordQuery.setcDueWeekStart(16); | |
| 408 | + antExRecordQuery.setcDueWeekEnd((20 + 1) * 7 - 1); | |
| 409 | + } | |
| 410 | + else if (i == 2) | |
| 411 | + { | |
| 412 | + antExRecordQuery.setcDueWeekStart(21); | |
| 413 | + antExRecordQuery.setcDueWeekEnd((24 + 1) * 7 - 1); | |
| 414 | + } | |
| 415 | + else if (i == 3) | |
| 416 | + { | |
| 417 | + antExRecordQuery.setcDueWeekStart(28); | |
| 418 | + antExRecordQuery.setcDueWeekEnd((36 + 1) * 7 - 1); | |
| 419 | + } | |
| 420 | + else if (i == 4) | |
| 421 | + { | |
| 422 | + antExRecordQuery.setcDueWeekStart(37); | |
| 423 | + antExRecordQuery.setcDueWeekEnd((40 + 1) * 7 - 1); | |
| 424 | + } | |
| 425 | + } | |
| 426 | + List<AntExRecordModel> list = recordService.queryAntExRecords(antExRecordQuery); | |
| 427 | + if (CollectionUtils.isNotEmpty(list)) | |
| 428 | + { | |
| 429 | + AntExRecordModel m = list.get(list.size() - 1); | |
| 430 | + m.setIsFirst(1); | |
| 431 | + recordService.updateOne(m,m.getId()); | |
| 432 | + } | |
| 433 | + } | |
| 434 | + | |
| 435 | + } | |
| 436 | + } | |
| 437 | + } | |
| 438 | + }).start(); | |
| 439 | + | |
| 440 | + } | |
| 441 | + } | |
| 442 | + } | |
| 443 | + return "updateCheckRecord finish"; | |
| 444 | + } | |
| 445 | + | |
| 344 | 446 | |
| 345 | 447 | |
| 346 | 448 | /** |