Commit c92ec50a31e5a48f8f47a319ca326eb16c02643b
1 parent
34418ab04d
Exists in
master
and in
1 other branch
commit
Showing 4 changed files with 535 additions and 312 deletions
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanChanPatientWorker.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanPatientWorker.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/WorkHR.java
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
View file @
c92ec50
| ... | ... | @@ -11,6 +11,9 @@ |
| 11 | 11 | import com.lyms.platform.operate.web.result.*; |
| 12 | 12 | import com.lyms.platform.operate.web.utils.CommonsHelper; |
| 13 | 13 | import com.lyms.platform.operate.web.utils.MessageCenterService; |
| 14 | +import com.lyms.platform.operate.web.worker.QuanChanPatientWorker; | |
| 15 | +import com.lyms.platform.operate.web.worker.QuanPatientWorker; | |
| 16 | +import com.lyms.platform.operate.web.worker.WorkHR; | |
| 14 | 17 | import com.lyms.platform.permission.model.Users; |
| 15 | 18 | import com.lyms.platform.permission.service.UsersService; |
| 16 | 19 | import com.lyms.platform.pojo.*; |
| ... | ... | @@ -63,7 +66,7 @@ |
| 63 | 66 | @Autowired |
| 64 | 67 | private MatDeliverService matDeliverService; |
| 65 | 68 | |
| 66 | - private ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 10, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>()); | |
| 69 | + private ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(15, 20, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>(5000)); | |
| 67 | 70 | |
| 68 | 71 | /** |
| 69 | 72 | * 修改产妇的社区 |
| 70 | 73 | |
| 71 | 74 | |
| 72 | 75 | |
| 73 | 76 | |
| 74 | 77 | |
| 75 | 78 | |
| 76 | 79 | |
| 77 | 80 | |
| ... | ... | @@ -337,324 +340,50 @@ |
| 337 | 340 | */ |
| 338 | 341 | private List convertToQuanCPatient(List<Patients> patientses, Integer userId, String hospital) { |
| 339 | 342 | List data = new ArrayList<>(); |
| 340 | - AntExQuery antExQuery = new AntExQuery(); | |
| 341 | -// String hospital = autoMatchFacade.getHospitalId(userId); | |
| 342 | - for (Patients patients : patientses) { | |
| 343 | - QuanChanResult chanResult = new QuanChanResult(); | |
| 344 | - chanResult.convertToResult(patients); | |
| 345 | - antExQuery.setParentId(patients.getId()); | |
| 346 | - antExQuery.setYn(YnEnums.YES.getId()); | |
| 347 | - if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 348 | - if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 349 | - Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 350 | - if (null != users) { | |
| 351 | - chanResult.setlName(users.getName()); | |
| 352 | - } else { | |
| 353 | - chanResult.setlName(patients.getBookbuildingDoctor()); | |
| 354 | - } | |
| 355 | 343 | |
| 356 | - } else { | |
| 357 | - chanResult.setlName(patients.getBookbuildingDoctor()); | |
| 358 | - } | |
| 344 | + int batchSize = 4; | |
| 345 | + int end = 0; | |
| 346 | + List<Future> listFuture = new ArrayList<>(); | |
| 347 | + for (int i = 0; i < patientses.size(); i += batchSize) { | |
| 348 | + end = (end + batchSize); | |
| 349 | + if (end > patientses.size()) { | |
| 350 | + end = patientses.size(); | |
| 359 | 351 | } |
| 360 | - MatDeliverQuery matDeliverQuery = new MatDeliverQuery(); | |
| 361 | - matDeliverQuery.setPid(patients.getPid()); | |
| 362 | - matDeliverQuery.setCreatedStart(patients.getLastMenses()); | |
| 363 | - matDeliverQuery.setYn(YnEnums.YES.getId()); | |
| 364 | - List<MaternalDeliverModel> maternalDeliverModels = matDeliverService.query(matDeliverQuery); | |
| 365 | - if (CollectionUtils.isNotEmpty(maternalDeliverModels)) { | |
| 366 | - chanResult.setDueWeek(maternalDeliverModels.get(0).getDueDate()); | |
| 352 | + listFuture.add(threadPoolExecutor.submit(new QuanChanPatientWorker(patientses.subList(i, end), hospital, usersService, postReviewService, matDeliverService))); | |
| 353 | + } | |
| 354 | + for (Future f : listFuture) { | |
| 355 | + try { | |
| 356 | + data.addAll((List) f.get(30, TimeUnit.SECONDS)); | |
| 357 | + } catch (Exception e) { | |
| 358 | + ExceptionUtils.catchException(e, "convertToQuanCPatient get result Future error."); | |
| 367 | 359 | } |
| 368 | - /*if (StringUtils.isNotEmpty(patients.getLastCheckEmployeeId())) { | |
| 369 | - if (NumberUtils.isNumber(patients.getLastCheckEmployeeId())) { | |
| 370 | - Users users = usersService.getUsers(NumberUtils.toInt(patients.getLastCheckEmployeeId())); | |
| 371 | - if (null != users) { | |
| 372 | - chanResult.setCheckDoctor(users.getName()); | |
| 373 | - } else { | |
| 374 | - chanResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 375 | - } | |
| 376 | - } else { | |
| 377 | - chanResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 378 | - } | |
| 379 | - }*/ | |
| 380 | - //复查次数 | |
| 381 | - PostReviewQuery postReviewQuery = new PostReviewQuery(); | |
| 382 | - postReviewQuery.setPid(patients.getPid()); | |
| 383 | - postReviewQuery.setYn(YnEnums.YES.getId()); | |
| 384 | - List<PostReviewModel> withList = postReviewService.findWithList(postReviewQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); | |
| 385 | - | |
| 386 | - String nextCheckTime = ""; | |
| 387 | - if (CollectionUtils.isNotEmpty(withList)) { | |
| 388 | - chanResult.setcTimes(withList.size()); | |
| 389 | - if (null != withList.get(0).getNextCheckTime()) { | |
| 390 | - nextCheckTime = DateUtil.getyyyy_MM_dd(withList.get(0).getNextCheckTime()); | |
| 391 | - } | |
| 392 | - postReviewQuery.setHospitalId(hospital); | |
| 393 | - | |
| 394 | - withList = postReviewService.findWithList(postReviewQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); | |
| 395 | - if (CollectionUtils.isNotEmpty(withList)) { | |
| 396 | - chanResult.setcHTimes(withList.size()); | |
| 397 | - if (StringUtils.isNotEmpty(withList.get(0).getProdDoctor())) { | |
| 398 | - Users users = usersService.getUsers(NumberUtils.toInt(withList.get(0).getProdDoctor())); | |
| 399 | - if (null != users) { | |
| 400 | - chanResult.setCheckDoctor(users.getName()); | |
| 401 | - } | |
| 402 | - } | |
| 403 | - } | |
| 404 | - } | |
| 405 | - | |
| 406 | - chanResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 407 | - chanResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 408 | - chanResult.setNextCheckTime(nextCheckTime); | |
| 409 | - data.add(chanResult); | |
| 410 | 360 | } |
| 411 | 361 | return data; |
| 412 | 362 | } |
| 413 | 363 | |
| 414 | 364 | |
| 415 | 365 | private List convertToQuanPatient(List<Patients> patientses, Integer userId, String hospital) { |
| 416 | - AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
| 417 | - AntExQuery antExQuery = new AntExQuery(); | |
| 418 | 366 | List data = new ArrayList<>(); |
| 419 | -// String hospital = autoMatchFacade.getHospitalId(userId); | |
| 420 | - for (Patients patients : patientses) { | |
| 421 | - QuanPatientsResult quanPatientsResult = new QuanPatientsResult(); | |
| 422 | - quanPatientsResult.convertToResult(patients); | |
| 423 | - antExQuery.setPid(patients.getPid()); | |
| 424 | - antExQuery.setYn(YnEnums.YES.getId()); | |
| 425 | - if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 426 | - if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 427 | - Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 428 | - if (null != users) { | |
| 429 | - quanPatientsResult.setlName(users.getName()); | |
| 430 | - } else { | |
| 431 | - quanPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 432 | - } | |
| 433 | - | |
| 434 | - } else { | |
| 435 | - quanPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 436 | - } | |
| 367 | + int batchSize = 4; | |
| 368 | + int end = 0; | |
| 369 | + List<Future> listFuture = new ArrayList<>(); | |
| 370 | + for (int i = 0; i < patientses.size(); i += batchSize) { | |
| 371 | + end = (end + batchSize); | |
| 372 | + if (end > patientses.size()) { | |
| 373 | + end = patientses.size(); | |
| 437 | 374 | } |
| 438 | - | |
| 439 | - antExQuery.setHospitalId(null); | |
| 440 | - //复诊次数 | |
| 441 | - int i = antExService.queryAntenatalExaminationCount(antExQuery.convertToQuery()); | |
| 442 | - antExChuQuery.setPid(patients.getPid()); | |
| 443 | - antExChuQuery.setYn(YnEnums.YES.getId()); | |
| 444 | - antExChuQuery.setHospitalId(null); | |
| 445 | - //初诊次数 | |
| 446 | - int b = antExService.queryAntExChuCount(antExChuQuery.convertToQuery()); | |
| 447 | - quanPatientsResult.setcTimes(i + b); | |
| 448 | - | |
| 449 | - | |
| 450 | - antExChuQuery.setHospitalId(hospital); | |
| 451 | - | |
| 452 | - antExQuery.setHospitalId(hospital); | |
| 453 | - //本院初诊 | |
| 454 | - int chi = antExService.queryAntExChuCount(antExChuQuery.convertToQuery()); | |
| 455 | - | |
| 456 | - //本院复诊 | |
| 457 | - int chb = antExService.queryAntenatalExaminationCount(antExQuery.convertToQuery()); | |
| 458 | - quanPatientsResult.setcHTimes(chi + chb); | |
| 459 | - | |
| 460 | - String nextCheckTime = ""; | |
| 461 | - List<AntenatalExaminationModel> examinationModels = antExService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); | |
| 462 | - if (CollectionUtils.isNotEmpty(examinationModels)) { | |
| 463 | - nextCheckTime = DateUtil.getyyyy_MM_dd(examinationModels.get(0).getNextCheckTime()); | |
| 464 | - | |
| 465 | - if (StringUtils.isNotEmpty(examinationModels.get(0).getCheckDoctor())) { | |
| 466 | - if (NumberUtils.isNumber(examinationModels.get(0).getCheckDoctor())) { | |
| 467 | - Users users = usersService.getUsers(NumberUtils.toInt(examinationModels.get(0).getCheckDoctor())); | |
| 468 | - if (null != users) { | |
| 469 | - quanPatientsResult.setCheckDoctor(users.getName()); | |
| 470 | - } else { | |
| 471 | - quanPatientsResult.setCheckDoctor(examinationModels.get(0).getCheckDoctor()); | |
| 472 | - } | |
| 473 | - } else { | |
| 474 | - quanPatientsResult.setCheckDoctor(examinationModels.get(0).getCheckDoctor()); | |
| 475 | - } | |
| 476 | - } | |
| 477 | - | |
| 478 | - } else { | |
| 479 | - List<AntExChuModel> list = antExService.queryAntExChu(antExChuQuery); | |
| 480 | - if (CollectionUtils.isNotEmpty(list)) { | |
| 481 | - nextCheckTime = DateUtil.getyyyy_MM_dd(list.get(0).getNextCheckTime()); | |
| 482 | - if (StringUtils.isNotEmpty(list.get(0).getProdDoctor())) { | |
| 483 | - if (NumberUtils.isNumber(list.get(0).getProdDoctor())) { | |
| 484 | - Users users = usersService.getUsers(NumberUtils.toInt(list.get(0).getProdDoctor())); | |
| 485 | - if (null != users) { | |
| 486 | - quanPatientsResult.setCheckDoctor(users.getName()); | |
| 487 | - } else { | |
| 488 | - quanPatientsResult.setCheckDoctor(list.get(0).getProdDoctor()); | |
| 489 | - } | |
| 490 | - } else { | |
| 491 | - quanPatientsResult.setCheckDoctor(list.get(0).getProdDoctor()); | |
| 492 | - } | |
| 493 | - } | |
| 494 | - } | |
| 375 | + listFuture.add(threadPoolExecutor.submit(new QuanPatientWorker(patientses.subList(i, end), usersService, hospital, antExService, basicConfigService))); | |
| 376 | + } | |
| 377 | + for (Future f : listFuture) { | |
| 378 | + try { | |
| 379 | + data.addAll((List) f.get(30, TimeUnit.SECONDS)); | |
| 380 | + } catch (Exception e) { | |
| 381 | + ExceptionUtils.catchException(e, "convertToQuanPatient get result Future error."); | |
| 495 | 382 | } |
| 496 | - | |
| 497 | - quanPatientsResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 498 | - quanPatientsResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 499 | - HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), true); | |
| 500 | - quanPatientsResult.setcTime(nextCheckTime); | |
| 501 | - quanPatientsResult.setrLevel(highScoreResult.filter(highScoreResult.getLevel())); | |
| 502 | - data.add(quanPatientsResult); | |
| 503 | 383 | } |
| 504 | 384 | return data; |
| 505 | 385 | } |
| 506 | 386 | |
| 507 | - private static class WorkHR implements Callable<List<RiskPatientsResult>> { | |
| 508 | - private List<Patients> patientses; | |
| 509 | - | |
| 510 | - private BasicConfigService basicConfigService; | |
| 511 | - private AntenatalExaminationService antExService; | |
| 512 | - private UsersService usersService; | |
| 513 | - private String hospital; | |
| 514 | - | |
| 515 | - public WorkHR(List<Patients> patientses, UsersService usersService, String hospital, | |
| 516 | - BasicConfigService basicConfigService, | |
| 517 | - AntenatalExaminationService antExService) { | |
| 518 | - this.patientses = patientses; | |
| 519 | - this.usersService = usersService; | |
| 520 | - this.hospital = hospital; | |
| 521 | - this.basicConfigService=basicConfigService; | |
| 522 | - this.antExService=antExService; | |
| 523 | - } | |
| 524 | - | |
| 525 | - public List<RiskPatientsResult> call() { | |
| 526 | - List<RiskPatientsResult> dataList = new ArrayList<>(); | |
| 527 | - for (Patients patients : patientses) { | |
| 528 | - StopWatch stopWatch = new StopWatch("convert -" + patients.getId()); | |
| 529 | - RiskPatientsResult riskPatientsResult = new RiskPatientsResult(); | |
| 530 | - riskPatientsResult.convertToResult(patients); | |
| 531 | - if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 532 | - if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 533 | - Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 534 | - if (null != users) { | |
| 535 | - riskPatientsResult.setlName(users.getName()); | |
| 536 | - } else { | |
| 537 | - riskPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 538 | - } | |
| 539 | - } else { | |
| 540 | - riskPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 541 | - } | |
| 542 | - } | |
| 543 | - | |
| 544 | - AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
| 545 | - AntExQuery antExQuery = new AntExQuery(); | |
| 546 | - | |
| 547 | - antExQuery.setPid(patients.getPid()); | |
| 548 | - antExQuery.setYn(YnEnums.YES.getId()); | |
| 549 | - antExQuery.setHospitalId(null); | |
| 550 | - stopWatch.start("cap antex count"); | |
| 551 | - //复诊次数 | |
| 552 | - int i = antExService.queryAntenatalExaminationCount(antExQuery.convertToQuery()); | |
| 553 | - antExChuQuery.setPid(patients.getPid()); | |
| 554 | - antExChuQuery.setYn(YnEnums.YES.getId()); | |
| 555 | - //初诊次数 | |
| 556 | - antExChuQuery.setHospitalId(null); | |
| 557 | - int b = antExService.queryAntExChuCount(antExChuQuery.convertToQuery()); | |
| 558 | - antExQuery.setHospitalId(hospital); | |
| 559 | - //本院的复诊记录 | |
| 560 | - int chi = antExService.queryAntenatalExaminationCount(antExQuery.convertToQuery()); | |
| 561 | - antExChuQuery.setHospitalId(hospital); | |
| 562 | - //本院的初诊记录 | |
| 563 | - int chb = antExService.queryAntExChuCount(antExChuQuery.convertToQuery()); | |
| 564 | - riskPatientsResult.setcTimes(i + b); | |
| 565 | - riskPatientsResult.setcHTimes(chi + chb); | |
| 566 | - String nextCheckTime = ""; | |
| 567 | - stopWatch.stop(); | |
| 568 | - stopWatch.start("query antex count"); | |
| 569 | - | |
| 570 | - List<AntenatalExaminationModel> examinationModels = antExService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); | |
| 571 | - if (CollectionUtils.isNotEmpty(examinationModels)) { | |
| 572 | - if (NumberUtils.isNumber(examinationModels.get(0).getCheckDoctor())) { | |
| 573 | - Users users = usersService.getUsers(NumberUtils.toInt(examinationModels.get(0).getCheckDoctor())); | |
| 574 | - if (null != users) { | |
| 575 | - riskPatientsResult.setCheckDoctor(users.getName()); | |
| 576 | - } else { | |
| 577 | - riskPatientsResult.setCheckDoctor(examinationModels.get(0).getCheckDoctor()); | |
| 578 | - } | |
| 579 | - } | |
| 580 | - nextCheckTime = DateUtil.getyyyy_MM_dd(examinationModels.get(0).getNextCheckTime()); | |
| 581 | - } else { | |
| 582 | - List<AntExChuModel> list = antExService.queryAntExChu(antExChuQuery); | |
| 583 | - if (CollectionUtils.isNotEmpty(list)) { | |
| 584 | - nextCheckTime = DateUtil.getyyyy_MM_dd(list.get(0).getNextCheckTime()); | |
| 585 | - if (NumberUtils.isNumber(list.get(0).getProdDoctor())) { | |
| 586 | - Users users = usersService.getUsers(NumberUtils.toInt(list.get(0).getProdDoctor())); | |
| 587 | - if (null != users) { | |
| 588 | - riskPatientsResult.setCheckDoctor(users.getName()); | |
| 589 | - } else { | |
| 590 | - riskPatientsResult.setCheckDoctor(list.get(0).getProdDoctor()); | |
| 591 | - } | |
| 592 | - } | |
| 593 | - } | |
| 594 | - } | |
| 595 | - stopWatch.stop(); | |
| 596 | - | |
| 597 | - riskPatientsResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 598 | - riskPatientsResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 599 | - riskPatientsResult.setcTime(nextCheckTime); | |
| 600 | - stopWatch.start("query findLastRisk"); | |
| 601 | - /* HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), true); | |
| 602 | - riskPatientsResult.setrFactor(highScoreResult.gethighRiskStr()); | |
| 603 | - riskPatientsResult.setrLevel(highScoreResult.filter(highScoreResult.getLevel())); | |
| 604 | - riskPatientsResult.sethScore(highScoreResult.getScore());*/ | |
| 605 | - HighScoreResult highScoreResult = new HighScoreResult(); | |
| 606 | - | |
| 607 | - | |
| 608 | - //高危因素 | |
| 609 | - List<String> factor = patients.getRiskFactorId(); | |
| 610 | - | |
| 611 | - if (CollectionUtils.isNotEmpty(factor)) { | |
| 612 | - StringBuilder sb = new StringBuilder(56); | |
| 613 | - for (String srt : factor) { | |
| 614 | - if (StringUtils.isNotEmpty(srt)) { | |
| 615 | - BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(srt); | |
| 616 | - if (null != basicConfig && sb.indexOf(basicConfig.getName()) == -1) { | |
| 617 | - sb.append(basicConfig.getName()).append(','); | |
| 618 | - } | |
| 619 | - } | |
| 620 | - } | |
| 621 | - if (sb.toString().endsWith(",")) { | |
| 622 | - riskPatientsResult.setrFactor(sb.substring(0, sb.length() - 1)); | |
| 623 | - } else { | |
| 624 | - riskPatientsResult.setrFactor(sb.toString()); | |
| 625 | - } | |
| 626 | - } | |
| 627 | - List level = new ArrayList(); | |
| 628 | - if (StringUtils.isNotEmpty(patients.getRiskLevelId())) { | |
| 629 | - try { | |
| 630 | - List<String> list = JsonUtil.jkstr2Obj(patients.getRiskLevelId(), List.class); | |
| 631 | - for (String str : list) { | |
| 632 | - BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str); | |
| 633 | - if (null != basicConfig) { | |
| 634 | - Map map = new HashMap(); | |
| 635 | - String name = basicConfig.getName(); | |
| 636 | - if (name.indexOf("预警") > -1) { | |
| 637 | - name = name.replace("预警", ""); | |
| 638 | - } | |
| 639 | - map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
| 640 | - level.add(map); | |
| 641 | - } | |
| 642 | - } | |
| 643 | - } catch (Exception e) { | |
| 644 | - ExceptionUtils.catchException(e,"patients.getRiskLevelId error."); | |
| 645 | - } | |
| 646 | - riskPatientsResult.setrLevel(level); | |
| 647 | - } | |
| 648 | - | |
| 649 | - riskPatientsResult.sethScore(patients.getRiskScore()); | |
| 650 | - dataList.add(riskPatientsResult); | |
| 651 | - stopWatch.stop(); | |
| 652 | - logger.info(stopWatch.toString()); | |
| 653 | - } | |
| 654 | - return dataList; | |
| 655 | - } | |
| 656 | - } | |
| 657 | - | |
| 658 | 387 | /** |
| 659 | 388 | * 转换成高危产妇的返回对象 |
| 660 | 389 | * |
| 661 | 390 | |
| 662 | 391 | |
| 663 | 392 | |
| ... | ... | @@ -662,27 +391,22 @@ |
| 662 | 391 | * @return |
| 663 | 392 | */ |
| 664 | 393 | private List convertToHighRisk(List<Patients> patientses, Integer userId, String hospital) { |
| 665 | - AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
| 666 | - AntExQuery antExQuery = new AntExQuery(); | |
| 667 | 394 | List data = new ArrayList<>(); |
| 668 | - //String hospital = autoMatchFacade.getHospitalId(userId); | |
| 669 | - | |
| 670 | - int batchSize = 5; | |
| 671 | - int start = 0, end = 0; | |
| 395 | + int batchSize = 4; | |
| 396 | + int end = 0; | |
| 672 | 397 | List<Future> listFuture = new ArrayList<>(); |
| 673 | 398 | for (int i = 0; i < patientses.size(); i += batchSize) { |
| 674 | 399 | end = (end + batchSize); |
| 675 | 400 | if (end > patientses.size()) { |
| 676 | 401 | end = patientses.size(); |
| 677 | 402 | } |
| 678 | - System.out.println("start:" + i + ",end:" + end); | |
| 679 | - listFuture.add(threadPoolExecutor.submit(new WorkHR(patientses.subList(i, end), usersService, hospital,basicConfigService,antExService))); | |
| 403 | + listFuture.add(threadPoolExecutor.submit(new WorkHR(patientses.subList(i, end), usersService, hospital, basicConfigService, antExService))); | |
| 680 | 404 | } |
| 681 | 405 | for (Future f : listFuture) { |
| 682 | 406 | try { |
| 683 | 407 | data.addAll((List) f.get(30, TimeUnit.SECONDS)); |
| 684 | 408 | } catch (Exception e) { |
| 685 | - ExceptionUtils.catchException(e, "get result Future error."); | |
| 409 | + ExceptionUtils.catchException(e, "convertToHighRisk get result Future error."); | |
| 686 | 410 | } |
| 687 | 411 | } |
| 688 | 412 | return data; |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanChanPatientWorker.java
View file @
c92ec50
| 1 | +package com.lyms.platform.operate.web.worker; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.AntenatalExaminationService; | |
| 4 | +import com.lyms.platform.biz.service.BasicConfigService; | |
| 5 | +import com.lyms.platform.biz.service.MatDeliverService; | |
| 6 | +import com.lyms.platform.biz.service.PostReviewService; | |
| 7 | +import com.lyms.platform.common.enums.ServiceStatusEnums; | |
| 8 | +import com.lyms.platform.common.enums.ServiceTypeEnums; | |
| 9 | +import com.lyms.platform.common.enums.YnEnums; | |
| 10 | +import com.lyms.platform.common.utils.DateUtil; | |
| 11 | +import com.lyms.platform.operate.web.facade.PatientFacade; | |
| 12 | +import com.lyms.platform.operate.web.facade.SmsConfigFacade; | |
| 13 | +import com.lyms.platform.operate.web.result.QuanChanResult; | |
| 14 | +import com.lyms.platform.permission.model.Users; | |
| 15 | +import com.lyms.platform.permission.service.UsersService; | |
| 16 | +import com.lyms.platform.pojo.MaternalDeliverModel; | |
| 17 | +import com.lyms.platform.pojo.Patients; | |
| 18 | +import com.lyms.platform.pojo.PostReviewModel; | |
| 19 | +import com.lyms.platform.query.AntExQuery; | |
| 20 | +import com.lyms.platform.query.MatDeliverQuery; | |
| 21 | +import com.lyms.platform.query.PostReviewQuery; | |
| 22 | +import org.apache.commons.collections.CollectionUtils; | |
| 23 | +import org.apache.commons.lang.StringUtils; | |
| 24 | +import org.apache.commons.lang.math.NumberUtils; | |
| 25 | +import org.slf4j.Logger; | |
| 26 | +import org.slf4j.LoggerFactory; | |
| 27 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 28 | +import org.springframework.data.domain.Sort; | |
| 29 | +import org.springframework.util.StopWatch; | |
| 30 | + | |
| 31 | +import java.util.ArrayList; | |
| 32 | +import java.util.List; | |
| 33 | +import java.util.concurrent.Callable; | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * 全部产妇列表 | |
| 37 | + * <p/> | |
| 38 | + * Created by Administrator on 2016/10/13 0013. | |
| 39 | + */ | |
| 40 | +public class QuanChanPatientWorker implements Callable<List<QuanChanResult>> { | |
| 41 | + | |
| 42 | + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); | |
| 43 | + private List<Patients> patientses; | |
| 44 | + | |
| 45 | + private UsersService usersService; | |
| 46 | + private PostReviewService postReviewService; | |
| 47 | + | |
| 48 | + private MatDeliverService matDeliverService; | |
| 49 | + private String hospital; | |
| 50 | + | |
| 51 | + public QuanChanPatientWorker(List<Patients> patientses, | |
| 52 | + String hospital, | |
| 53 | + UsersService usersService, | |
| 54 | + PostReviewService postReviewService, | |
| 55 | + MatDeliverService matDeliverService) { | |
| 56 | + this.patientses = patientses; | |
| 57 | + this.matDeliverService = matDeliverService; | |
| 58 | + this.postReviewService = postReviewService; | |
| 59 | + this.hospital = hospital; | |
| 60 | + this.usersService = usersService; | |
| 61 | + } | |
| 62 | + | |
| 63 | + | |
| 64 | + @Override | |
| 65 | + public List<QuanChanResult> call() throws Exception { | |
| 66 | + List data = new ArrayList<>(); | |
| 67 | + AntExQuery antExQuery = new AntExQuery(); | |
| 68 | + for (Patients patients : patientses) { | |
| 69 | + StopWatch stopWatch = new StopWatch("QuanChanPatientWorker -" + patients.getId()); | |
| 70 | + QuanChanResult chanResult = new QuanChanResult(); | |
| 71 | + chanResult.convertToResult(patients); | |
| 72 | + antExQuery.setParentId(patients.getId()); | |
| 73 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 74 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 75 | + if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 76 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 77 | + if (null != users) { | |
| 78 | + chanResult.setlName(users.getName()); | |
| 79 | + } else { | |
| 80 | + chanResult.setlName(patients.getBookbuildingDoctor()); | |
| 81 | + } | |
| 82 | + } else { | |
| 83 | + chanResult.setlName(patients.getBookbuildingDoctor()); | |
| 84 | + } | |
| 85 | + } | |
| 86 | + MatDeliverQuery matDeliverQuery = new MatDeliverQuery(); | |
| 87 | + matDeliverQuery.setPid(patients.getPid()); | |
| 88 | + matDeliverQuery.setCreatedStart(patients.getLastMenses()); | |
| 89 | + matDeliverQuery.setYn(YnEnums.YES.getId()); | |
| 90 | + stopWatch.start("query matdeliver"); | |
| 91 | + List<MaternalDeliverModel> maternalDeliverModels = matDeliverService.query(matDeliverQuery); | |
| 92 | + if (CollectionUtils.isNotEmpty(maternalDeliverModels)) { | |
| 93 | + chanResult.setDueWeek(maternalDeliverModels.get(0).getDueDate()); | |
| 94 | + } | |
| 95 | + stopWatch.stop(); | |
| 96 | + //复查次数 | |
| 97 | + PostReviewQuery postReviewQuery = new PostReviewQuery(); | |
| 98 | + postReviewQuery.setPid(patients.getPid()); | |
| 99 | + postReviewQuery.setYn(YnEnums.YES.getId()); | |
| 100 | + stopWatch.start("query postreview list"); | |
| 101 | + List<PostReviewModel> withList = postReviewService.findWithList(postReviewQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); | |
| 102 | + | |
| 103 | + String nextCheckTime = ""; | |
| 104 | + if (CollectionUtils.isNotEmpty(withList)) { | |
| 105 | + chanResult.setcTimes(withList.size()); | |
| 106 | + if (null != withList.get(0).getNextCheckTime()) { | |
| 107 | + nextCheckTime = DateUtil.getyyyy_MM_dd(withList.get(0).getNextCheckTime()); | |
| 108 | + } | |
| 109 | + postReviewQuery.setHospitalId(hospital); | |
| 110 | + | |
| 111 | + withList = postReviewService.findWithList(postReviewQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); | |
| 112 | + if (CollectionUtils.isNotEmpty(withList)) { | |
| 113 | + chanResult.setcHTimes(withList.size()); | |
| 114 | + if (StringUtils.isNotEmpty(withList.get(0).getProdDoctor())) { | |
| 115 | + Users users = usersService.getUsers(NumberUtils.toInt(withList.get(0).getProdDoctor())); | |
| 116 | + if (null != users) { | |
| 117 | + chanResult.setCheckDoctor(users.getName()); | |
| 118 | + } | |
| 119 | + } | |
| 120 | + } | |
| 121 | + } | |
| 122 | + stopWatch.stop(); | |
| 123 | + chanResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 124 | + chanResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 125 | + chanResult.setNextCheckTime(nextCheckTime); | |
| 126 | + data.add(chanResult); | |
| 127 | + logger.debug(stopWatch.toString()); | |
| 128 | + } | |
| 129 | + return data; | |
| 130 | + } | |
| 131 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanPatientWorker.java
View file @
c92ec50
| 1 | +package com.lyms.platform.operate.web.worker; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.AntenatalExaminationService; | |
| 4 | +import com.lyms.platform.biz.service.BasicConfigService; | |
| 5 | +import com.lyms.platform.common.enums.RiskDefaultTypeEnum; | |
| 6 | +import com.lyms.platform.common.enums.ServiceStatusEnums; | |
| 7 | +import com.lyms.platform.common.enums.ServiceTypeEnums; | |
| 8 | +import com.lyms.platform.common.enums.YnEnums; | |
| 9 | +import com.lyms.platform.common.utils.DateUtil; | |
| 10 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
| 11 | +import com.lyms.platform.common.utils.JsonUtil; | |
| 12 | +import com.lyms.platform.operate.web.facade.PatientFacade; | |
| 13 | +import com.lyms.platform.operate.web.result.HighScoreResult; | |
| 14 | +import com.lyms.platform.operate.web.result.QuanPatientsResult; | |
| 15 | +import com.lyms.platform.permission.model.Users; | |
| 16 | +import com.lyms.platform.permission.service.UsersService; | |
| 17 | +import com.lyms.platform.pojo.AntExChuModel; | |
| 18 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 19 | +import com.lyms.platform.pojo.BasicConfig; | |
| 20 | +import com.lyms.platform.pojo.Patients; | |
| 21 | +import com.lyms.platform.query.AntExChuQuery; | |
| 22 | +import com.lyms.platform.query.AntExQuery; | |
| 23 | +import org.apache.commons.collections.CollectionUtils; | |
| 24 | +import org.apache.commons.lang.StringUtils; | |
| 25 | +import org.apache.commons.lang.math.NumberUtils; | |
| 26 | +import org.slf4j.Logger; | |
| 27 | +import org.slf4j.LoggerFactory; | |
| 28 | +import org.springframework.data.domain.Sort; | |
| 29 | +import org.springframework.util.StopWatch; | |
| 30 | + | |
| 31 | +import java.util.ArrayList; | |
| 32 | +import java.util.HashMap; | |
| 33 | +import java.util.List; | |
| 34 | +import java.util.Map; | |
| 35 | +import java.util.concurrent.Callable; | |
| 36 | + | |
| 37 | +/** | |
| 38 | + * 全部孕妇列表 | |
| 39 | + */ | |
| 40 | +public class QuanPatientWorker implements Callable<List<QuanPatientsResult>> { | |
| 41 | + | |
| 42 | + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); | |
| 43 | + | |
| 44 | + private List<Patients> patientses; | |
| 45 | + | |
| 46 | + private String hospital; | |
| 47 | + private UsersService usersService; | |
| 48 | + private AntenatalExaminationService antExService; | |
| 49 | + private BasicConfigService basicConfigService; | |
| 50 | + | |
| 51 | + public QuanPatientWorker(List<Patients> patientses, | |
| 52 | + UsersService usersService, | |
| 53 | + String hospital, | |
| 54 | + AntenatalExaminationService antExService, | |
| 55 | + BasicConfigService basicConfigService) { | |
| 56 | + this.patientses = patientses; | |
| 57 | + this.usersService = usersService; | |
| 58 | + this.antExService = antExService; | |
| 59 | + this.hospital = hospital; | |
| 60 | + this.basicConfigService = basicConfigService; | |
| 61 | + } | |
| 62 | + | |
| 63 | + @Override | |
| 64 | + public List<QuanPatientsResult> call() throws Exception { | |
| 65 | + List data = new ArrayList<>(); | |
| 66 | + AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
| 67 | + AntExQuery antExQuery = new AntExQuery(); | |
| 68 | + for (Patients patients : patientses) { | |
| 69 | + StopWatch stopWatch = new StopWatch("QuanPatientWorker -" + patients.getId()); | |
| 70 | + QuanPatientsResult quanPatientsResult = new QuanPatientsResult(); | |
| 71 | + quanPatientsResult.convertToResult(patients); | |
| 72 | + antExQuery.setPid(patients.getPid()); | |
| 73 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 74 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 75 | + if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 76 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 77 | + if (null != users) { | |
| 78 | + quanPatientsResult.setlName(users.getName()); | |
| 79 | + } else { | |
| 80 | + quanPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 81 | + } | |
| 82 | + } else { | |
| 83 | + quanPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 84 | + } | |
| 85 | + } | |
| 86 | + | |
| 87 | + antExQuery.setHospitalId(null); | |
| 88 | + stopWatch.start("query ant count"); | |
| 89 | + //复诊次数 | |
| 90 | + int i = antExService.queryAntenatalExaminationCount(antExQuery.convertToQuery()); | |
| 91 | + antExChuQuery.setPid(patients.getPid()); | |
| 92 | + antExChuQuery.setYn(YnEnums.YES.getId()); | |
| 93 | + antExChuQuery.setHospitalId(null); | |
| 94 | + //初诊次数 | |
| 95 | + int b = antExService.queryAntExChuCount(antExChuQuery.convertToQuery()); | |
| 96 | + quanPatientsResult.setcTimes(i + b); | |
| 97 | + | |
| 98 | + | |
| 99 | + antExChuQuery.setHospitalId(hospital); | |
| 100 | + | |
| 101 | + antExQuery.setHospitalId(hospital); | |
| 102 | + //本院初诊 | |
| 103 | + int chi = antExService.queryAntExChuCount(antExChuQuery.convertToQuery()); | |
| 104 | + | |
| 105 | + //本院复诊 | |
| 106 | + int chb = antExService.queryAntenatalExaminationCount(antExQuery.convertToQuery()); | |
| 107 | + quanPatientsResult.setcHTimes(chi + chb); | |
| 108 | + stopWatch.stop(); | |
| 109 | + String nextCheckTime = ""; | |
| 110 | + stopWatch.start("query antex list"); | |
| 111 | + List<AntenatalExaminationModel> examinationModels = antExService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); | |
| 112 | + if (CollectionUtils.isNotEmpty(examinationModels)) { | |
| 113 | + nextCheckTime = DateUtil.getyyyy_MM_dd(examinationModels.get(0).getNextCheckTime()); | |
| 114 | + | |
| 115 | + if (StringUtils.isNotEmpty(examinationModels.get(0).getCheckDoctor())) { | |
| 116 | + if (NumberUtils.isNumber(examinationModels.get(0).getCheckDoctor())) { | |
| 117 | + Users users = usersService.getUsers(NumberUtils.toInt(examinationModels.get(0).getCheckDoctor())); | |
| 118 | + if (null != users) { | |
| 119 | + quanPatientsResult.setCheckDoctor(users.getName()); | |
| 120 | + } else { | |
| 121 | + quanPatientsResult.setCheckDoctor(examinationModels.get(0).getCheckDoctor()); | |
| 122 | + } | |
| 123 | + } else { | |
| 124 | + quanPatientsResult.setCheckDoctor(examinationModels.get(0).getCheckDoctor()); | |
| 125 | + } | |
| 126 | + } | |
| 127 | + | |
| 128 | + } else { | |
| 129 | + List<AntExChuModel> list = antExService.queryAntExChu(antExChuQuery); | |
| 130 | + if (CollectionUtils.isNotEmpty(list)) { | |
| 131 | + nextCheckTime = DateUtil.getyyyy_MM_dd(list.get(0).getNextCheckTime()); | |
| 132 | + if (StringUtils.isNotEmpty(list.get(0).getProdDoctor())) { | |
| 133 | + if (NumberUtils.isNumber(list.get(0).getProdDoctor())) { | |
| 134 | + Users users = usersService.getUsers(NumberUtils.toInt(list.get(0).getProdDoctor())); | |
| 135 | + if (null != users) { | |
| 136 | + quanPatientsResult.setCheckDoctor(users.getName()); | |
| 137 | + } else { | |
| 138 | + quanPatientsResult.setCheckDoctor(list.get(0).getProdDoctor()); | |
| 139 | + } | |
| 140 | + } else { | |
| 141 | + quanPatientsResult.setCheckDoctor(list.get(0).getProdDoctor()); | |
| 142 | + } | |
| 143 | + } | |
| 144 | + } | |
| 145 | + } | |
| 146 | + stopWatch.stop(); | |
| 147 | + quanPatientsResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 148 | + quanPatientsResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 149 | + //修改获取建档里面的高危等级不用在重新去算 | |
| 150 | +// HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), true); | |
| 151 | +// quanPatientsResult.setrLevel(highScoreResult.filter(highScoreResult.getLevel())); | |
| 152 | + quanPatientsResult.setcTime(nextCheckTime); | |
| 153 | + List level = new ArrayList(); | |
| 154 | + if (StringUtils.isNotEmpty(patients.getRiskLevelId())) { | |
| 155 | + try { | |
| 156 | + List<String> list = JsonUtil.jkstr2Obj(patients.getRiskLevelId(), List.class); | |
| 157 | + for (String str : list) { | |
| 158 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str); | |
| 159 | + if (null != basicConfig) { | |
| 160 | + Map map = new HashMap(); | |
| 161 | + String name = basicConfig.getName(); | |
| 162 | + if (name.indexOf("预警") > -1) { | |
| 163 | + name = name.replace("预警", ""); | |
| 164 | + } | |
| 165 | + map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
| 166 | + level.add(map); | |
| 167 | + } | |
| 168 | + } | |
| 169 | + } catch (Exception e) { | |
| 170 | + ExceptionUtils.catchException(e, "patients.getRiskLevelId error."); | |
| 171 | + } | |
| 172 | + quanPatientsResult.setrLevel(level); | |
| 173 | + } | |
| 174 | + data.add(quanPatientsResult); | |
| 175 | + logger.debug(stopWatch.toString()); | |
| 176 | + } | |
| 177 | + return data; | |
| 178 | + } | |
| 179 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/WorkHR.java
View file @
c92ec50
| 1 | +package com.lyms.platform.operate.web.worker; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.AntenatalExaminationService; | |
| 4 | +import com.lyms.platform.biz.service.BasicConfigService; | |
| 5 | +import com.lyms.platform.common.enums.RiskDefaultTypeEnum; | |
| 6 | +import com.lyms.platform.common.enums.ServiceStatusEnums; | |
| 7 | +import com.lyms.platform.common.enums.ServiceTypeEnums; | |
| 8 | +import com.lyms.platform.common.enums.YnEnums; | |
| 9 | +import com.lyms.platform.common.utils.DateUtil; | |
| 10 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
| 11 | +import com.lyms.platform.common.utils.JsonUtil; | |
| 12 | +import com.lyms.platform.operate.web.facade.PatientFacade; | |
| 13 | +import com.lyms.platform.operate.web.result.RiskPatientsResult; | |
| 14 | +import com.lyms.platform.permission.model.Users; | |
| 15 | +import com.lyms.platform.permission.service.UsersService; | |
| 16 | +import com.lyms.platform.pojo.AntExChuModel; | |
| 17 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 18 | +import com.lyms.platform.pojo.BasicConfig; | |
| 19 | +import com.lyms.platform.pojo.Patients; | |
| 20 | +import com.lyms.platform.query.AntExChuQuery; | |
| 21 | +import com.lyms.platform.query.AntExQuery; | |
| 22 | +import org.apache.commons.collections.CollectionUtils; | |
| 23 | +import org.apache.commons.lang.StringUtils; | |
| 24 | +import org.apache.commons.lang.math.NumberUtils; | |
| 25 | +import org.slf4j.Logger; | |
| 26 | +import org.slf4j.LoggerFactory; | |
| 27 | +import org.springframework.data.domain.Sort; | |
| 28 | +import org.springframework.util.StopWatch; | |
| 29 | + | |
| 30 | +import java.util.ArrayList; | |
| 31 | +import java.util.HashMap; | |
| 32 | +import java.util.List; | |
| 33 | +import java.util.Map; | |
| 34 | +import java.util.concurrent.Callable; | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * | |
| 38 | + * 高危孕妇列表线程处理 | |
| 39 | + * | |
| 40 | + */ | |
| 41 | +public class WorkHR implements Callable<List<RiskPatientsResult>> { | |
| 42 | + | |
| 43 | + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); | |
| 44 | + private List<Patients> patientses; | |
| 45 | + | |
| 46 | + private BasicConfigService basicConfigService; | |
| 47 | + private AntenatalExaminationService antExService; | |
| 48 | + private UsersService usersService; | |
| 49 | + private String hospital; | |
| 50 | + | |
| 51 | + public WorkHR(List<Patients> patientses, UsersService usersService, String hospital, | |
| 52 | + BasicConfigService basicConfigService, | |
| 53 | + AntenatalExaminationService antExService) { | |
| 54 | + this.patientses = patientses; | |
| 55 | + this.usersService = usersService; | |
| 56 | + this.hospital = hospital; | |
| 57 | + this.basicConfigService = basicConfigService; | |
| 58 | + this.antExService = antExService; | |
| 59 | + } | |
| 60 | + | |
| 61 | + public List<RiskPatientsResult> call() { | |
| 62 | + List<RiskPatientsResult> dataList = new ArrayList<>(); | |
| 63 | + for (Patients patients : patientses) { | |
| 64 | + StopWatch stopWatch = new StopWatch("WorkHR -" + patients.getId()); | |
| 65 | + RiskPatientsResult riskPatientsResult = new RiskPatientsResult(); | |
| 66 | + riskPatientsResult.convertToResult(patients); | |
| 67 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 68 | + if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 69 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 70 | + if (null != users) { | |
| 71 | + riskPatientsResult.setlName(users.getName()); | |
| 72 | + } else { | |
| 73 | + riskPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 74 | + } | |
| 75 | + } else { | |
| 76 | + riskPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 77 | + } | |
| 78 | + } | |
| 79 | + | |
| 80 | + AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
| 81 | + AntExQuery antExQuery = new AntExQuery(); | |
| 82 | + | |
| 83 | + antExQuery.setPid(patients.getPid()); | |
| 84 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 85 | + antExQuery.setHospitalId(null); | |
| 86 | + stopWatch.start("cap antex count"); | |
| 87 | + //复诊次数 | |
| 88 | + int i = antExService.queryAntenatalExaminationCount(antExQuery.convertToQuery()); | |
| 89 | + antExChuQuery.setPid(patients.getPid()); | |
| 90 | + antExChuQuery.setYn(YnEnums.YES.getId()); | |
| 91 | + //初诊次数 | |
| 92 | + antExChuQuery.setHospitalId(null); | |
| 93 | + int b = antExService.queryAntExChuCount(antExChuQuery.convertToQuery()); | |
| 94 | + antExQuery.setHospitalId(hospital); | |
| 95 | + //本院的复诊记录 | |
| 96 | + int chi = antExService.queryAntenatalExaminationCount(antExQuery.convertToQuery()); | |
| 97 | + antExChuQuery.setHospitalId(hospital); | |
| 98 | + //本院的初诊记录 | |
| 99 | + int chb = antExService.queryAntExChuCount(antExChuQuery.convertToQuery()); | |
| 100 | + riskPatientsResult.setcTimes(i + b); | |
| 101 | + riskPatientsResult.setcHTimes(chi + chb); | |
| 102 | + String nextCheckTime = ""; | |
| 103 | + stopWatch.stop(); | |
| 104 | + stopWatch.start("query antex count"); | |
| 105 | + | |
| 106 | + List<AntenatalExaminationModel> examinationModels = antExService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); | |
| 107 | + if (CollectionUtils.isNotEmpty(examinationModels)) { | |
| 108 | + if (NumberUtils.isNumber(examinationModels.get(0).getCheckDoctor())) { | |
| 109 | + Users users = usersService.getUsers(NumberUtils.toInt(examinationModels.get(0).getCheckDoctor())); | |
| 110 | + if (null != users) { | |
| 111 | + riskPatientsResult.setCheckDoctor(users.getName()); | |
| 112 | + } else { | |
| 113 | + riskPatientsResult.setCheckDoctor(examinationModels.get(0).getCheckDoctor()); | |
| 114 | + } | |
| 115 | + } | |
| 116 | + nextCheckTime = DateUtil.getyyyy_MM_dd(examinationModels.get(0).getNextCheckTime()); | |
| 117 | + } else { | |
| 118 | + List<AntExChuModel> list = antExService.queryAntExChu(antExChuQuery); | |
| 119 | + if (CollectionUtils.isNotEmpty(list)) { | |
| 120 | + nextCheckTime = DateUtil.getyyyy_MM_dd(list.get(0).getNextCheckTime()); | |
| 121 | + if (NumberUtils.isNumber(list.get(0).getProdDoctor())) { | |
| 122 | + Users users = usersService.getUsers(NumberUtils.toInt(list.get(0).getProdDoctor())); | |
| 123 | + if (null != users) { | |
| 124 | + riskPatientsResult.setCheckDoctor(users.getName()); | |
| 125 | + } else { | |
| 126 | + riskPatientsResult.setCheckDoctor(list.get(0).getProdDoctor()); | |
| 127 | + } | |
| 128 | + } | |
| 129 | + } | |
| 130 | + } | |
| 131 | + stopWatch.stop(); | |
| 132 | + | |
| 133 | + riskPatientsResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 134 | + riskPatientsResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 135 | + riskPatientsResult.setcTime(nextCheckTime); | |
| 136 | + stopWatch.start("query findLastRisk"); | |
| 137 | + /*HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), true); | |
| 138 | + riskPatientsResult.setrFactor(highScoreResult.gethighRiskStr()); | |
| 139 | + riskPatientsResult.setrLevel(highScoreResult.filter(highScoreResult.getLevel())); | |
| 140 | + riskPatientsResult.sethScore(highScoreResult.getScore());*/ | |
| 141 | + //高危因素 | |
| 142 | + List<String> factor = patients.getRiskFactorId(); | |
| 143 | + | |
| 144 | + if (CollectionUtils.isNotEmpty(factor)) { | |
| 145 | + StringBuilder sb = new StringBuilder(56); | |
| 146 | + for (String srt : factor) { | |
| 147 | + if (StringUtils.isNotEmpty(srt)) { | |
| 148 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(srt); | |
| 149 | + if (null != basicConfig && sb.indexOf(basicConfig.getName()) == -1) { | |
| 150 | + sb.append(basicConfig.getName()).append(','); | |
| 151 | + } | |
| 152 | + } | |
| 153 | + } | |
| 154 | + if (sb.toString().endsWith(",")) { | |
| 155 | + riskPatientsResult.setrFactor(sb.substring(0, sb.length() - 1)); | |
| 156 | + } else { | |
| 157 | + riskPatientsResult.setrFactor(sb.toString()); | |
| 158 | + } | |
| 159 | + } | |
| 160 | + List level = new ArrayList(); | |
| 161 | + if (StringUtils.isNotEmpty(patients.getRiskLevelId())) { | |
| 162 | + try { | |
| 163 | + List<String> list = JsonUtil.jkstr2Obj(patients.getRiskLevelId(), List.class); | |
| 164 | + for (String str : list) { | |
| 165 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str); | |
| 166 | + if (null != basicConfig) { | |
| 167 | + Map map = new HashMap(); | |
| 168 | + String name = basicConfig.getName(); | |
| 169 | + if (name.indexOf("预警") > -1) { | |
| 170 | + name = name.replace("预警", ""); | |
| 171 | + } | |
| 172 | + map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
| 173 | + level.add(map); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + } catch (Exception e) { | |
| 177 | + ExceptionUtils.catchException(e, "patients.getRiskLevelId error."); | |
| 178 | + } | |
| 179 | + riskPatientsResult.setrLevel(level); | |
| 180 | + } | |
| 181 | + | |
| 182 | + riskPatientsResult.sethScore(patients.getRiskScore()); | |
| 183 | + dataList.add(riskPatientsResult); | |
| 184 | + stopWatch.stop(); | |
| 185 | + logger.debug(stopWatch.toString()); | |
| 186 | + } | |
| 187 | + return dataList; | |
| 188 | + } | |
| 189 | +} |