Commit b5c7a8560d54ef8681180a884985e08faf397612
1 parent
f0009b5b0c
Exists in
master
and in
1 other branch
update code
Showing 1 changed file with 98 additions and 33 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
View file @
b5c7a85
| ... | ... | @@ -16,6 +16,8 @@ |
| 16 | 16 | import com.lyms.platform.operate.web.facade.SieveFacade; |
| 17 | 17 | import com.lyms.platform.operate.web.result.HighScoreResult; |
| 18 | 18 | import com.lyms.platform.operate.web.service.SyncDataTaskService; |
| 19 | +import com.lyms.platform.permission.model.Organization; | |
| 20 | +import com.lyms.platform.permission.model.OrganizationQuery; | |
| 19 | 21 | import com.lyms.platform.permission.service.OrganizationService; |
| 20 | 22 | import com.lyms.platform.pojo.*; |
| 21 | 23 | import com.lyms.platform.query.*; |
| 22 | 24 | |
| 23 | 25 | |
| 24 | 26 | |
| 25 | 27 | |
| 26 | 28 | |
| ... | ... | @@ -348,36 +350,70 @@ |
| 348 | 350 | */ |
| 349 | 351 | @RequestMapping(value = "/updatePostViewTimes", method = RequestMethod.GET) |
| 350 | 352 | @ResponseBody |
| 351 | - public String updatePostViewTimes(@RequestParam(required = true) String hospitalId,@RequestParam(required = false) String patientId) { | |
| 353 | + public String updatePostViewTimes(@RequestParam(required = false) String hospitalId,@RequestParam(required = false) String patientId) { | |
| 354 | + | |
| 355 | + OrganizationQuery organizationQuery = new OrganizationQuery(); | |
| 356 | + organizationQuery.setYn(YnEnums.YES.getId()); | |
| 357 | + if (StringUtils.isNotEmpty(hospitalId)) | |
| 358 | + { | |
| 359 | + organizationQuery.setId(Integer.parseInt(hospitalId)); | |
| 360 | + } | |
| 361 | + List<Organization> organizationList = organizationService.queryOrganization(organizationQuery); | |
| 362 | + | |
| 352 | 363 | PatientsQuery patientsQuery1 = new PatientsQuery(); |
| 353 | 364 | patientsQuery1.setYn(YnEnums.YES.getId()); |
| 354 | - patientsQuery1.setHospitalId(hospitalId); | |
| 365 | + | |
| 355 | 366 | patientsQuery1.setType(3); //查询产妇 |
| 356 | 367 | patientsQuery1.setExtEnable(false); |
| 357 | 368 | patientsQuery1.setId(patientId); |
| 358 | - List<Patients> pats = patientsService.queryPatient(patientsQuery1); | |
| 359 | - System.out.println("main=" + pats.size()); | |
| 360 | - if (CollectionUtils.isNotEmpty(pats)) { | |
| 361 | - for (Patients pat : pats) { | |
| 362 | - if (StringUtils.isNotEmpty(pat.getPid())) | |
| 363 | - { | |
| 364 | - PostReviewQuery postReviewQuery = new PostReviewQuery(); | |
| 365 | - postReviewQuery.setPid(pat.getPid()); | |
| 366 | - postReviewQuery.setYn(YnEnums.YES.getId()); | |
| 367 | - List<PostReviewModel> postReviewModels = postReviewService.findWithList(postReviewQuery); | |
| 368 | - if (CollectionUtils.isNotEmpty(postReviewModels)) | |
| 369 | - { | |
| 370 | - System.out.println("postReviewModels=" + postReviewModels.size() + ";patientid=" + pat.getId()); | |
| 371 | - for(PostReviewModel postReviewModel : postReviewModels) | |
| 372 | - { | |
| 373 | - Patients patients = patientsService.findOnePatientById(postReviewModel.getParentId()); | |
| 374 | - patients.setPostViewTimes(postReviewModels.size()); | |
| 375 | - patientsService.updatePatient(patients); | |
| 376 | - } | |
| 369 | + | |
| 370 | + if (CollectionUtils.isNotEmpty(organizationList)) | |
| 371 | + { | |
| 372 | + for (Organization organization : organizationList) { | |
| 373 | + | |
| 374 | + patientsQuery1.setHospitalId(organization.getId()+""); | |
| 375 | + List<Patients> pats = patientsService.queryPatient(patientsQuery1); | |
| 376 | + | |
| 377 | + int batchSize = 500; | |
| 378 | + int end = 0; | |
| 379 | + for (int i = 0; i < pats.size(); i += batchSize) { | |
| 380 | + end = (end + batchSize); | |
| 381 | + if (end > pats.size()) { | |
| 382 | + end = pats.size(); | |
| 377 | 383 | } |
| 384 | + System.out.println("start:" + i + ",end:" + end); | |
| 385 | + final List<Patients> tempList = pats.subList(i, end); | |
| 378 | 386 | |
| 379 | - } | |
| 387 | + new Thread(new Runnable() { | |
| 388 | + @Override | |
| 389 | + public void run() { | |
| 390 | + if (CollectionUtils.isNotEmpty(tempList)) { | |
| 391 | + for (Patients pat : tempList) { | |
| 392 | + if (StringUtils.isNotEmpty(pat.getPid())) | |
| 393 | + { | |
| 394 | + PostReviewQuery postReviewQuery = new PostReviewQuery(); | |
| 395 | + postReviewQuery.setPid(pat.getPid()); | |
| 396 | + postReviewQuery.setYn(YnEnums.YES.getId()); | |
| 397 | + List<PostReviewModel> postReviewModels = postReviewService.findWithList(postReviewQuery); | |
| 398 | + if (CollectionUtils.isNotEmpty(postReviewModels)) | |
| 399 | + { | |
| 400 | + System.out.println("postReviewModels=" + postReviewModels.size() + ";patientid=" + pat.getId()); | |
| 401 | + for(PostReviewModel postReviewModel : postReviewModels) | |
| 402 | + { | |
| 403 | + Patients patients = patientsService.findOnePatientById(postReviewModel.getParentId()); | |
| 404 | + patients.setPostViewTimes(postReviewModels.size()); | |
| 405 | + patientsService.updatePatient(patients); | |
| 406 | + } | |
| 407 | + } | |
| 380 | 408 | |
| 409 | + } | |
| 410 | + | |
| 411 | + } | |
| 412 | + } | |
| 413 | + } | |
| 414 | + }).start(); | |
| 415 | + | |
| 416 | + } | |
| 381 | 417 | } |
| 382 | 418 | } |
| 383 | 419 | return "updatePostViewTimes finish"; |
| 384 | 420 | |
| 385 | 421 | |
| 386 | 422 | |
| ... | ... | @@ -391,22 +427,51 @@ |
| 391 | 427 | */ |
| 392 | 428 | @RequestMapping(value = "/updatePatBuildDays", method = RequestMethod.GET) |
| 393 | 429 | @ResponseBody |
| 394 | - public String updatePatBuildDays(@RequestParam(required = true) String hospitalId) { | |
| 430 | + public String updatePatBuildDays(@RequestParam(required = false) String hospitalId) { | |
| 431 | + OrganizationQuery organizationQuery = new OrganizationQuery(); | |
| 432 | + organizationQuery.setYn(YnEnums.YES.getId()); | |
| 433 | + if (StringUtils.isNotEmpty(hospitalId)) | |
| 434 | + { | |
| 435 | + organizationQuery.setId(Integer.parseInt(hospitalId)); | |
| 436 | + } | |
| 437 | + List<Organization> organizationList = organizationService.queryOrganization(organizationQuery); | |
| 395 | 438 | PatientsQuery patientsQuery1 = new PatientsQuery(); |
| 396 | 439 | patientsQuery1.setYn(YnEnums.YES.getId()); |
| 397 | - patientsQuery1.setHospitalId(hospitalId); | |
| 398 | - List<Patients> pats = patientsService.queryPatient(patientsQuery1); | |
| 399 | - System.out.println("main="+pats.size()); | |
| 400 | - if (CollectionUtils.isNotEmpty(pats)) { | |
| 401 | - for (Patients pat : pats) { | |
| 402 | - if (StringUtils.isNotEmpty(pat.getPid())) | |
| 403 | - { | |
| 404 | - pat.setBuildDays(DateUtil.getDays(pat.getLastMenses(), pat.getBookbuildingDate())); | |
| 405 | - patientsService.updatePatient(pat); | |
| 406 | - } | |
| 440 | + if (CollectionUtils.isNotEmpty(organizationList)) { | |
| 441 | + for (Organization organization : organizationList) { | |
| 442 | + patientsQuery1.setHospitalId(organization.getId()+""); | |
| 443 | + List<Patients> pats = patientsService.queryPatient(patientsQuery1); | |
| 407 | 444 | |
| 445 | + int batchSize = 500; | |
| 446 | + int end = 0; | |
| 447 | + for (int i = 0; i < pats.size(); i += batchSize) { | |
| 448 | + end = (end + batchSize); | |
| 449 | + if (end > pats.size()) { | |
| 450 | + end = pats.size(); | |
| 451 | + } | |
| 452 | + System.out.println("start:" + i + ",end:" + end); | |
| 453 | + final List<Patients> tempList = pats.subList(i, end); | |
| 454 | + | |
| 455 | + new Thread(new Runnable() { | |
| 456 | + @Override | |
| 457 | + public void run() { | |
| 458 | + if (CollectionUtils.isNotEmpty(tempList)) { | |
| 459 | + for (Patients pat : tempList) { | |
| 460 | + if (StringUtils.isNotEmpty(pat.getPid())) | |
| 461 | + { | |
| 462 | + pat.setBuildDays(DateUtil.getDays(pat.getLastMenses(), pat.getBookbuildingDate())); | |
| 463 | + patientsService.updatePatient(pat); | |
| 464 | + } | |
| 465 | + | |
| 466 | + } | |
| 467 | + } | |
| 468 | + | |
| 469 | + } | |
| 470 | + }).start(); | |
| 471 | + } | |
| 408 | 472 | } |
| 409 | 473 | } |
| 474 | + | |
| 410 | 475 | return "updatePatBuildDays finish"; |
| 411 | 476 | } |
| 412 | 477 |