Commit 0c7aaf2cd8520be488ad13fc0934038936f7434c
1 parent
0da9175754
Exists in
master
and in
6 other branches
优化代码
Showing 7 changed files with 64 additions and 138 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/PatientServiceMapper.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/PatientServiceService.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/PatientServiceServiceImpl.java
- platform-biz-service/src/main/resources/mainOrm/master/PatientService.xml
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AreaCountFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/ServiceListBySerStatusWorker.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/ServiceListWorker.java
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/PatientServiceMapper.java
View file @
0c7aaf2
| ... | ... | @@ -38,7 +38,7 @@ |
| 38 | 38 | * @param query |
| 39 | 39 | * @return |
| 40 | 40 | */ |
| 41 | - Map<String, Object> getServiceList(@Param("query") ServiceListQuery query); | |
| 41 | + Map<String, Object> getServiceList(@Param("query") ServiceListQuery query, @Param("id") String id); | |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | /** |
| ... | ... | @@ -47,7 +47,7 @@ |
| 47 | 47 | * @param param |
| 48 | 48 | * @return |
| 49 | 49 | */ |
| 50 | - int countStatusInfo(@Param("param") ServiceListQuery param); | |
| 50 | + int countStatusInfo(@Param("param") ServiceListQuery param, @Param("ids") List<String> ids, @Param("serStatus") String serStatus); | |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * 所有增值服务详情list的总数 |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/PatientServiceService.java
View file @
0c7aaf2
| ... | ... | @@ -23,9 +23,9 @@ |
| 23 | 23 | |
| 24 | 24 | List<Map> selectOnlyBzService(PatientServiceQuery query); |
| 25 | 25 | |
| 26 | - Map<String, Object> getServiceList(ServiceListQuery param); | |
| 26 | + Map<String, Object> getServiceList(ServiceListQuery param, String id); | |
| 27 | 27 | |
| 28 | - int countStatusInfo(ServiceListQuery param); | |
| 28 | + int countStatusInfo(ServiceListQuery param, List<String> ids, String setStatus); | |
| 29 | 29 | |
| 30 | 30 | List<Map<String, Object>> getServeDetailList(ServiceListQuery param); |
| 31 | 31 |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/PatientServiceServiceImpl.java
View file @
0c7aaf2
| ... | ... | @@ -59,13 +59,13 @@ |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | @Override |
| 62 | - public Map<String, Object> getServiceList(ServiceListQuery query) { | |
| 63 | - return patientServiceMapper.getServiceList(query); | |
| 62 | + public Map<String, Object> getServiceList(ServiceListQuery query, String id) { | |
| 63 | + return patientServiceMapper.getServiceList(query, id); | |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | @Override |
| 67 | - public int countStatusInfo(ServiceListQuery param) { | |
| 68 | - return patientServiceMapper.countStatusInfo(param); | |
| 67 | + public int countStatusInfo(ServiceListQuery param, List<String> ids, String serStatus) { | |
| 68 | + return patientServiceMapper.countStatusInfo(param, ids, serStatus); | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | @Override |
platform-biz-service/src/main/resources/mainOrm/master/PatientService.xml
View file @
0c7aaf2
| ... | ... | @@ -393,101 +393,17 @@ |
| 393 | 393 | select count(1) from patient_service |
| 394 | 394 | <include refid="PatientServiceCondition"/> |
| 395 | 395 | </select> |
| 396 | - <select id="getServiceList" parameterType="com.lyms.platform.permission.model.ServiceListQuery" resultType="java.util.Map" fetchSize="10000"> | |
| 396 | + <select id="getServiceList" resultType="java.util.Map"> | |
| 397 | 397 | SELECT |
| 398 | 398 | o.name as "name", |
| 399 | 399 | o.province_id as "provinceId", |
| 400 | 400 | o.city_id as "cityId", |
| 401 | 401 | o.area_id as "areaId", |
| 402 | - o.id as "hospitalId", | |
| 403 | - (SELECT Count(1) | |
| 404 | - FROM patient_service ps | |
| 405 | - join organization o ON o.id = ps.hospital_id | |
| 406 | - WHERE ps.hospital_id = #{query.hospitalId} | |
| 407 | - AND ps.ser_status = 1 | |
| 408 | - <if test="query.startTime != null "> | |
| 409 | - AND ps.create_date >= #{query.startTime} | |
| 410 | - </if> | |
| 411 | - <if test="query.endTime != null "> | |
| 412 | - AND ps.create_date <= #{query.endTime} | |
| 413 | - </if> | |
| 414 | - <if test="query.provinceId != null and query.provinceId != '' "> | |
| 415 | - and o.province_id = #{query.provinceId} | |
| 416 | - </if> | |
| 417 | - <if test="query.cityId != null and query.cityId != ''"> | |
| 418 | - and o.city_id = #{query.cityId} | |
| 419 | - </if> | |
| 420 | - <if test="query.areaId != null and query.areaId != ''"> | |
| 421 | - and o.area_id = #{query.areaId} | |
| 422 | - </if> | |
| 423 | - ) as "open", | |
| 424 | - (SELECT Count(1) | |
| 425 | - FROM patient_service ps | |
| 426 | - join organization o ON o.id = ps.hospital_id | |
| 427 | - WHERE ps.hospital_id = #{query.hospitalId} | |
| 428 | - AND ps.ser_status = 2 | |
| 429 | - <if test="query.startTime != null "> | |
| 430 | - AND ps.create_date >= #{query.startTime} | |
| 431 | - </if> | |
| 432 | - <if test="query.endTime != null "> | |
| 433 | - AND ps.create_date <= #{query.endTime} | |
| 434 | - </if> | |
| 435 | - <if test="query.provinceId != null and query.provinceId != '' "> | |
| 436 | - and o.province_id = #{query.provinceId} | |
| 437 | - </if> | |
| 438 | - <if test="query.cityId != null and query.cityId != ''"> | |
| 439 | - and o.city_id = #{query.cityId} | |
| 440 | - </if> | |
| 441 | - <if test="query.areaId != null and query.areaId != ''"> | |
| 442 | - and o.area_id = #{query.areaId} | |
| 443 | - </if> | |
| 444 | - ) as "unsubscribe", | |
| 445 | - (SELECT Count(1) | |
| 446 | - FROM patient_service ps | |
| 447 | - join organization o ON o.id = ps.hospital_id | |
| 448 | - WHERE ps.hospital_id = #{query.hospitalId} | |
| 449 | - AND ps.ser_status = 3 | |
| 450 | - <if test="query.startTime != null "> | |
| 451 | - AND ps.create_date >= #{query.startTime} | |
| 452 | - </if> | |
| 453 | - <if test="query.endTime != null "> | |
| 454 | - AND ps.create_date <= #{query.endTime} | |
| 455 | - </if> | |
| 456 | - <if test="query.provinceId != null and query.provinceId != '' "> | |
| 457 | - and o.province_id = #{query.provinceId} | |
| 458 | - </if> | |
| 459 | - <if test="query.cityId != null and query.cityId != ''"> | |
| 460 | - and o.city_id = #{query.cityId} | |
| 461 | - </if> | |
| 462 | - <if test="query.areaId != null and query.areaId != ''"> | |
| 463 | - and o.area_id = #{query.areaId} | |
| 464 | - </if> | |
| 465 | - ) as "expire", | |
| 466 | - (SELECT Count(1) | |
| 467 | - FROM patient_service ps | |
| 468 | - join organization o ON o.id = ps.hospital_id | |
| 469 | - WHERE ps.hospital_id = #{query.hospitalId} | |
| 470 | - AND ps.ser_status = 4 | |
| 471 | - <if test="query.startTime != null "> | |
| 472 | - AND ps.create_date >= #{query.startTime} | |
| 473 | - </if> | |
| 474 | - <if test="query.endTime != null "> | |
| 475 | - AND ps.create_date <= #{query.endTime} | |
| 476 | - </if> | |
| 477 | - <if test="query.provinceId != null and query.provinceId != '' "> | |
| 478 | - and o.province_id = #{query.provinceId} | |
| 479 | - </if> | |
| 480 | - <if test="query.cityId != null and query.cityId != ''"> | |
| 481 | - and o.city_id = #{query.cityId} | |
| 482 | - </if> | |
| 483 | - <if test="query.areaId != null and query.areaId != ''"> | |
| 484 | - and o.area_id = #{query.areaId} | |
| 485 | - </if> | |
| 486 | - ) as "suspend" | |
| 402 | + o.id as "hospitalId" | |
| 487 | 403 | FROM patient_service ps |
| 488 | 404 | JOIN organization o |
| 489 | 405 | ON o.id = ps.hospital_id |
| 490 | - WHERE ps.hospital_id = #{query.hospitalId} | |
| 406 | + WHERE ps.hospital_id = #{id} | |
| 491 | 407 | <if test="query.startTime != null "> |
| 492 | 408 | AND ps.create_date >= #{query.startTime} |
| 493 | 409 | </if> |
| 494 | 410 | |
| ... | ... | @@ -507,14 +423,14 @@ |
| 507 | 423 | o.city_id, |
| 508 | 424 | o.area_id |
| 509 | 425 | </select> |
| 510 | - <select id="countStatusInfo" parameterType="com.lyms.platform.permission.model.ServiceListQuery" resultType="int"> | |
| 426 | + <select id="countStatusInfo" resultType="int"> | |
| 511 | 427 | select count(1) |
| 512 | 428 | from patient_service ps |
| 513 | 429 | join organization o on o.id = ps.hospital_id |
| 514 | 430 | where 1=1 |
| 515 | 431 | and ps.create_date >= #{param.startTime} |
| 516 | 432 | AND ps.create_date <= #{param.endTime} |
| 517 | - and ps.ser_status = #{param.serStatus} | |
| 433 | + and ps.ser_status = #{serStatus} | |
| 518 | 434 | <if test="param.provinceId != null and param.provinceId != ''"> |
| 519 | 435 | and o.province_id = #{param.provinceId} |
| 520 | 436 | </if> |
| 521 | 437 | |
| ... | ... | @@ -524,9 +440,9 @@ |
| 524 | 440 | <if test="param.areaId != null and param.areaId != ''"> |
| 525 | 441 | and o.area_id = #{param.areaId} |
| 526 | 442 | </if> |
| 527 | - <if test="param.hospitalIds.size() > 0"> | |
| 443 | + <if test="ids.size() > 0"> | |
| 528 | 444 | and ps.hospital_id in |
| 529 | - <foreach collection="param.hospitalIds" item="item" open="(" close=")" separator=","> | |
| 445 | + <foreach collection="ids" item="item" open="(" close=")" separator=","> | |
| 530 | 446 | #{item} |
| 531 | 447 | </foreach> |
| 532 | 448 | </if> |
| 533 | 449 | |
| 534 | 450 | |
| ... | ... | @@ -607,22 +523,15 @@ |
| 607 | 523 | AND ps.create_date <= #{param.endTime} |
| 608 | 524 | </select> |
| 609 | 525 | <select id="getHospitalIds" resultType="string"> |
| 610 | - | |
| 611 | - SELECT | |
| 526 | + select | |
| 612 | 527 | o.id as "hospitalId" |
| 613 | - FROM patient_service ps | |
| 614 | - JOIN organization o | |
| 615 | - ON o.id = ps.hospital_id | |
| 616 | - WHERE ps.hospital_id in | |
| 528 | + from organization o | |
| 529 | + join (select ps.hospital_id from patient_service ps where ps.create_date >= #{param.startTime} and ps.create_date <= #{param.endTime} group by ps.hospital_id) | |
| 530 | + t on t.hospital_id = o.id | |
| 531 | + where t.hospital_id in | |
| 617 | 532 | <foreach collection="ids" item="item" open="(" close=")" separator=","> |
| 618 | 533 | #{item} |
| 619 | 534 | </foreach> |
| 620 | - <if test="param.startTime != null "> | |
| 621 | - AND ps.create_date >= #{param.startTime} | |
| 622 | - </if> | |
| 623 | - <if test="param.endTime != null "> | |
| 624 | - AND ps.create_date <= #{param.endTime} | |
| 625 | - </if> | |
| 626 | 535 | <if test="param.provinceId != null and param.provinceId != ''"> |
| 627 | 536 | and o.province_id = #{param.provinceId} |
| 628 | 537 | </if> |
| ... | ... | @@ -635,13 +544,13 @@ |
| 635 | 544 | |
| 636 | 545 | </select> |
| 637 | 546 | <select id="getServiceListByParentId" resultType="com.lyms.platform.permission.model.PatientService"> |
| 638 | -SELECT | |
| 639 | - id as id, | |
| 640 | - parentid as parentid, | |
| 641 | - ser_type as serType | |
| 642 | -FROM | |
| 643 | - patient_service | |
| 644 | -where parentid = #{patientsId} and ser_status = 1 and per_type = #{patientType} | |
| 547 | + SELECT | |
| 548 | + id as id, | |
| 549 | + parentid as parentid, | |
| 550 | + ser_type as serType | |
| 551 | + FROM | |
| 552 | + patient_service | |
| 553 | + where parentid = #{patientsId} and ser_status = 1 and per_type = #{patientType} | |
| 645 | 554 | </select> |
| 646 | 555 | |
| 647 | 556 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AreaCountFacade.java
View file @
0c7aaf2
| ... | ... | @@ -1059,7 +1059,7 @@ |
| 1059 | 1059 | } |
| 1060 | 1060 | ExecutorService threadPool = Executors.newFixedThreadPool(5); |
| 1061 | 1061 | //param.setHospitalIds(hospitalIds); |
| 1062 | - //List<String> ids = patientServiceService.getHospitalIds(param, hospitalIds); | |
| 1062 | + hospitalIds = patientServiceService.getHospitalIds(param, hospitalIds); | |
| 1063 | 1063 | int size = hospitalIds.size(); |
| 1064 | 1064 | int batchSize = 2; |
| 1065 | 1065 | int end = 0; |
| 1066 | 1066 | |
| 1067 | 1067 | |
| ... | ... | @@ -1070,18 +1070,19 @@ |
| 1070 | 1070 | if (end > hospitalIds.size()) { |
| 1071 | 1071 | end = hospitalIds.size(); |
| 1072 | 1072 | } |
| 1073 | - Future<List<Map<String, Object>>> listFuture = threadPool.submit(new ServiceListWorker(hospitalIds.subList(i, end), param, patientServiceService, basicConfigService)); | |
| 1073 | + Future<List<Map<String, Object>>> listFuture = threadPool.submit(new ServiceListWorker( hospitalIds.subList(i, end), param, patientServiceService, basicConfigService)); | |
| 1074 | 1074 | futureArrayList.add(listFuture); |
| 1075 | 1075 | } |
| 1076 | - threadPool.shutdown(); | |
| 1077 | - while (true){ | |
| 1078 | - if (threadPool.isTerminated()){ | |
| 1079 | - for (Future future : futureArrayList){ | |
| 1080 | - mapList.addAll((List)future.get()); | |
| 1081 | - } | |
| 1082 | - break; | |
| 1076 | + for (Future future : futureArrayList){ | |
| 1077 | + if (future != null){ | |
| 1078 | + Object o = future.get(); | |
| 1079 | + if (o instanceof Collection){ | |
| 1080 | + Collection collection = (Collection) o; | |
| 1081 | + if (CollectionUtils.isNotEmpty(collection)){ | |
| 1082 | + mapList.addAll(collection); | |
| 1083 | + } | |
| 1084 | + } | |
| 1083 | 1085 | } |
| 1084 | - Thread.sleep(1000); | |
| 1085 | 1086 | } |
| 1086 | 1087 | ArrayList<Object> statusNameList = new ArrayList<>(); |
| 1087 | 1088 | statusNameList.add("开通"); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/ServiceListBySerStatusWorker.java
View file @
0c7aaf2
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | import com.lyms.platform.permission.model.ServiceListQuery; |
| 4 | 4 | import com.lyms.platform.permission.service.PatientServiceService; |
| 5 | 5 | |
| 6 | +import java.util.List; | |
| 6 | 7 | import java.util.concurrent.CopyOnWriteArrayList; |
| 7 | 8 | import java.util.concurrent.CountDownLatch; |
| 8 | 9 | |
| ... | ... | @@ -29,9 +30,9 @@ |
| 29 | 30 | public void run() { |
| 30 | 31 | try { |
| 31 | 32 | int number = 0; |
| 32 | - if (!param.getHospitalIds().isEmpty()){ | |
| 33 | - param.setSerStatus(serStatus); | |
| 34 | - number = patientServiceService.countStatusInfo(param); | |
| 33 | + List<String> hospitalIds = param.getHospitalIds(); | |
| 34 | + if (!hospitalIds.isEmpty()){ | |
| 35 | + number = patientServiceService.countStatusInfo(param, hospitalIds, serStatus ); | |
| 35 | 36 | } |
| 36 | 37 | statusValList.add(number); |
| 37 | 38 | }finally { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/ServiceListWorker.java
View file @
0c7aaf2
| ... | ... | @@ -9,9 +9,7 @@ |
| 9 | 9 | import java.util.HashMap; |
| 10 | 10 | import java.util.List; |
| 11 | 11 | import java.util.Map; |
| 12 | -import java.util.concurrent.BlockingQueue; | |
| 13 | 12 | import java.util.concurrent.Callable; |
| 14 | -import java.util.concurrent.CopyOnWriteArrayList; | |
| 15 | 13 | |
| 16 | 14 | /** |
| 17 | 15 | * |
| 18 | 16 | |
| 19 | 17 | |
| ... | ... | @@ -21,13 +19,13 @@ |
| 21 | 19 | **/ |
| 22 | 20 | |
| 23 | 21 | public class ServiceListWorker implements Callable< List<Map<String, Object>>> { |
| 24 | - private List<String> hospitals; | |
| 25 | 22 | private ServiceListQuery param; |
| 26 | 23 | private PatientServiceService patientServiceService; |
| 27 | 24 | private BasicConfigService basicConfigService; |
| 25 | + private List<String> hospitals; | |
| 28 | 26 | |
| 29 | - public ServiceListWorker(List<String> hospitals, ServiceListQuery param, | |
| 30 | - PatientServiceService patientServiceService, BasicConfigService basicConfigService) { | |
| 27 | + public ServiceListWorker(List<String> hospitals, ServiceListQuery param, | |
| 28 | + PatientServiceService patientServiceService, BasicConfigService basicConfigService) { | |
| 31 | 29 | this.hospitals = hospitals; |
| 32 | 30 | this.param = param; |
| 33 | 31 | this.patientServiceService = patientServiceService; |
| 34 | 32 | |
| 35 | 33 | |
| ... | ... | @@ -38,10 +36,25 @@ |
| 38 | 36 | public List<Map<String, Object>> call() throws Exception { |
| 39 | 37 | List<Map<String, Object>> mapList = new ArrayList<>(); |
| 40 | 38 | for (String hospital : hospitals){ |
| 39 | + | |
| 41 | 40 | param.setHospitalId(hospital); |
| 42 | 41 | |
| 43 | - Map<String, Object> map = patientServiceService.getServiceList(param); | |
| 42 | + Map<String, Object> map = patientServiceService.getServiceList(param, hospital); | |
| 44 | 43 | if (map != null){ |
| 44 | + ArrayList<String> strings = new ArrayList<>(); | |
| 45 | + strings.add(hospital); | |
| 46 | + int openSize = patientServiceService.countStatusInfo(param, strings, "1"); | |
| 47 | + map.put("open", openSize); | |
| 48 | + | |
| 49 | + int unsubscribeSize = patientServiceService.countStatusInfo(param, strings, "2"); | |
| 50 | + map.put("unsubscribe", unsubscribeSize); | |
| 51 | + | |
| 52 | + int expireSize = patientServiceService.countStatusInfo(param, strings, "3"); | |
| 53 | + map.put("expire", expireSize); | |
| 54 | + | |
| 55 | + int suspendSize = patientServiceService.countStatusInfo(param, strings, "4"); | |
| 56 | + map.put("suspend", suspendSize); | |
| 57 | + | |
| 45 | 58 | HashMap<String, Object> hashMap = new HashMap<>(16); |
| 46 | 59 | String id = map.get("provinceId").toString(); |
| 47 | 60 | BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(id); |
| 48 | 61 | |
| 49 | 62 | |
| ... | ... | @@ -60,10 +73,12 @@ |
| 60 | 73 | + Integer.parseInt(map.get("suspend").toString())); |
| 61 | 74 | |
| 62 | 75 | hashMap.putAll(map); |
| 76 | + | |
| 63 | 77 | mapList.add(hashMap); |
| 78 | + | |
| 64 | 79 | } |
| 65 | 80 | } |
| 66 | - return mapList; | |
| 81 | + return mapList; | |
| 67 | 82 | } |
| 68 | 83 | |
| 69 | 84 | } |