Commit 843c660779a192705e599d796458ec08073f0142
1 parent
cec444de19
Exists in
master
and in
1 other branch
增加自动分配社区
Showing 7 changed files with 187 additions and 23 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/param/CommunityQuery.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CommunityConfigService.java
- platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java
- platform-data-api/src/main/java/com/lyms/platform/data/controller/TaskController.java
- platform-data-api/src/main/java/com/lyms/platform/data/service/DataImportTaskService.java
- platform-data-api/src/main/java/com/lyms/platform/data/service/impl/DataImportTaskServiceImpl.java
- platform-data-api/src/main/webapp/WEB-INF/vm/task/index.vm
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/param/CommunityQuery.java
View file @
843c660
... | ... | @@ -20,8 +20,24 @@ |
20 | 20 | |
21 | 21 | //管辖区域名字 |
22 | 22 | private String gxxq; |
23 | + private Boolean isGxxqNull; | |
24 | + private Boolean isAreasNull; | |
23 | 25 | |
26 | + public Boolean getIsAreasNull() { | |
27 | + return isAreasNull; | |
28 | + } | |
24 | 29 | |
30 | + public void setIsAreasNull(Boolean isAreasNull) { | |
31 | + this.isAreasNull = isAreasNull; | |
32 | + } | |
33 | + | |
34 | + public Boolean getIsGxxqNull() { | |
35 | + return isGxxqNull; | |
36 | + } | |
37 | + | |
38 | + public void setIsGxxqNull(Boolean isGxxqNull) { | |
39 | + this.isGxxqNull = isGxxqNull; | |
40 | + } | |
25 | 41 | |
26 | 42 | public String getOrgAreaId() { |
27 | 43 | return orgAreaId; |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CommunityConfigService.java
View file @
843c660
... | ... | @@ -52,6 +52,11 @@ |
52 | 52 | if(null != communityQuery.getKeyword()) { |
53 | 53 | mongoCondition = mongoCondition.orCondition(new MongoCondition[]{new MongoCondition("name", communityQuery.getKeyword(), MongoOper.LIKE), new MongoCondition("gxxq", communityQuery.getKeyword(), MongoOper.LIKE)}); |
54 | 54 | } |
55 | + | |
56 | + if(null!=communityQuery.getIsGxxqNull()){ | |
57 | + mongoCondition = new MongoCondition("gxxq","", MongoOper.NE); | |
58 | + } | |
59 | + | |
55 | 60 | mongoCondition.and("yn", YnEnums.YES.getId(), MongoOper.IS); |
56 | 61 | if(null != communityQuery.getId() ||null!=communityQuery.getOrgAreaId()) { |
57 | 62 | List<String> list = new ArrayList<>(); |
platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java
View file @
843c660
... | ... | @@ -25,8 +25,20 @@ |
25 | 25 | * 关键字 |
26 | 26 | */ |
27 | 27 | private String keyword; |
28 | - | |
29 | 28 | /** |
29 | + * 是否分配社区 | |
30 | + */ | |
31 | + private Boolean isNull; | |
32 | + | |
33 | + public Boolean getIsNull() { | |
34 | + return isNull; | |
35 | + } | |
36 | + | |
37 | + public void setIsNull(Boolean isNull) { | |
38 | + this.isNull = isNull; | |
39 | + } | |
40 | + | |
41 | + /** | |
30 | 42 | * 产妇名称 |
31 | 43 | */ |
32 | 44 | private String name; |
... | ... | @@ -40,6 +52,17 @@ |
40 | 52 | private int visitstatus=-1; |
41 | 53 | |
42 | 54 | private String areaId; |
55 | + //社区id | |
56 | + private String areaIdOrRestId; | |
57 | + | |
58 | + public String getAreaIdOrRestId() { | |
59 | + return areaIdOrRestId; | |
60 | + } | |
61 | + | |
62 | + public void setAreaIdOrRestId(String areaIdOrRestId) { | |
63 | + this.areaIdOrRestId = areaIdOrRestId; | |
64 | + } | |
65 | + | |
43 | 66 | /** |
44 | 67 | * 产妇手机号 |
45 | 68 | */ |
... | ... | @@ -193,6 +216,11 @@ |
193 | 216 | MongoCondition con = MongoCondition.newInstance("username", "^"+keyword, MongoOper.LIKE); |
194 | 217 | condition = condition.orCondition(new MongoCondition[]{con1,con}); |
195 | 218 | } |
219 | + if(null!=areaIdOrRestId){ | |
220 | + MongoCondition con1= MongoCondition.newInstance("areaId", areaIdOrRestId, MongoOper.IS); | |
221 | + MongoCondition con = MongoCondition.newInstance("areaPostRestId", areaIdOrRestId, MongoOper.IS); | |
222 | + condition=condition.orCondition(new MongoCondition[]{con1, con}); | |
223 | + } | |
196 | 224 | if(visitstatus!=-1){ |
197 | 225 | condition= condition.and("isVisit", visitstatus, MongoOper.IS); |
198 | 226 | } |
199 | 227 | |
... | ... | @@ -215,8 +243,12 @@ |
215 | 243 | if(null!=name){ |
216 | 244 | condition=condition.and("username", name, MongoOper.IS); |
217 | 245 | } |
246 | + | |
218 | 247 | if(-1!=yn){ |
219 | 248 | condition=condition.and("yn", yn, MongoOper.IS); |
249 | + } | |
250 | + if(null!=isNull){ | |
251 | + condition=condition.and("communityId", null, MongoOper.IS); | |
220 | 252 | } |
221 | 253 | //去掉type为3 的情况 |
222 | 254 | /* if(-1!=type){ |
platform-data-api/src/main/java/com/lyms/platform/data/controller/TaskController.java
View file @
843c660
... | ... | @@ -62,6 +62,9 @@ |
62 | 62 | } else if ("fullUpdatePatients".equals(sid)) { |
63 | 63 | dataImportTaskService.fullUpdatePatients(); |
64 | 64 | writeString(response, "success"); |
65 | + }else if("updateCommunity".equals(sid)){ | |
66 | + dataImportTaskService.updateCommunity(); | |
67 | + writeString(response, "success"); | |
65 | 68 | } else if ("codeinit111".equals(sid)) { |
66 | 69 | try { |
67 | 70 | List<String> list = FileUtils.readLines(new File("d:/streets.csv")); |
platform-data-api/src/main/java/com/lyms/platform/data/service/DataImportTaskService.java
View file @
843c660
platform-data-api/src/main/java/com/lyms/platform/data/service/impl/DataImportTaskServiceImpl.java
View file @
843c660
... | ... | @@ -9,7 +9,6 @@ |
9 | 9 | import com.lyms.platform.common.enums.UserTypeEnum; |
10 | 10 | import com.lyms.platform.common.enums.VisitStatusEnums; |
11 | 11 | import com.lyms.platform.common.enums.YnEnums; |
12 | -import com.lyms.platform.common.utils.Assert; | |
13 | 12 | import com.lyms.platform.common.utils.LogUtil; |
14 | 13 | import com.lyms.platform.common.utils.LoginUtil; |
15 | 14 | import com.lyms.platform.data.service.DataImportTaskService; |
... | ... | @@ -18,6 +17,7 @@ |
18 | 17 | import com.lyms.platform.pojo.BasicConfig; |
19 | 18 | import com.lyms.platform.pojo.CommunityConfig; |
20 | 19 | import com.lyms.platform.pojo.Patients; |
20 | +import com.lyms.platform.query.PatientsQuery; | |
21 | 21 | import com.lymsh.mommybaby.earlydata.dao.PlatMapper; |
22 | 22 | import com.lymsh.mommybaby.earlydata.model.PlatDataContent; |
23 | 23 | import com.lymsh.mommybaby.earlydata.model.PlatDataType; |
... | ... | @@ -446,8 +446,7 @@ |
446 | 446 | patients.setAreaRegisterId(map.get("P_HUSBANDMOBILEPHONE") == null ? null : map.get("P_HUSBANDMOBILEPHONE").toString()); |
447 | 447 | patients.setVcCardNo(map.get("VC_CARDNO") == null ? null : map.get("VC_CARDNO").toString()); |
448 | 448 | patients.setDeliverOrg(map.get("P_HOSPITALID") == null ? null : map.get("P_HOSPITALID").toString()); |
449 | - //分配社区 | |
450 | - updateCommunity(patients); | |
449 | + | |
451 | 450 | if (patientsService.queryPatientCount(patients.getId()) == 0) { |
452 | 451 | patients.setCreated(patients.getModified()); |
453 | 452 | patients.setIsVisit(VisitStatusEnums.UNVISIT.getId()); |
454 | 453 | |
455 | 454 | |
... | ... | @@ -470,26 +469,122 @@ |
470 | 469 | } |
471 | 470 | } |
472 | 471 | |
473 | - private void updateCommunity(Patients patients) { | |
474 | - Assert.notNull(patients, "patient must not null."); | |
472 | + private Map<String, List<SimpleCommunity>> convertToMap(List<CommunityConfig> configs) { | |
473 | + Map<String, List<SimpleCommunity>> listMap = new HashMap<>(); | |
474 | + for (CommunityConfig config : configs) { | |
475 | + if (StringUtils.isEmpty(config.getGxxq())) { | |
476 | + continue; | |
477 | + } | |
478 | + if (CollectionUtils.isNotEmpty(config.getAreas())) { | |
479 | + String areaId = config.getAreas().get(config.getAreas().size() - 1); | |
480 | + //查看map里面是否存在该区域 | |
481 | + if (listMap.containsKey(areaId)) { | |
482 | + List<SimpleCommunity> list = listMap.get(areaId); | |
483 | + list.add(buildCommunity(config)); | |
484 | + listMap.put(areaId, list); | |
485 | + } else { | |
486 | + List<SimpleCommunity> list = new ArrayList<>(); | |
487 | + list.add(buildCommunity(config)); | |
488 | + listMap.put(areaId, list); | |
489 | + } | |
490 | + } | |
491 | + } | |
492 | + return listMap; | |
493 | + } | |
475 | 494 | |
476 | - CommunityQuery communityQuery = null; | |
477 | - CommunityConfig communityConfig = null; | |
478 | - //优先产后修养地,然后现住地址 | |
479 | - if (StringUtils.isNotEmpty(patients.getAreaPostRestId()) && StringUtils.isNotEmpty(patients.getAddressPostRest())) { | |
480 | - communityQuery = new CommunityQuery(); | |
481 | - communityQuery.setOrgAreaId(patients.getAreaPostRestId()); | |
482 | - communityQuery.setGxxq(patients.getAddressPostRest()); | |
483 | - } else if (StringUtils.isNotEmpty(patients.getAddress()) && StringUtils.isNotEmpty(patients.getAreaId())) { | |
484 | - communityQuery = new CommunityQuery(); | |
485 | - communityQuery.setOrgAreaId(patients.getAreaId()); | |
486 | - communityQuery.setGxxq(patients.getAddress()); | |
495 | + private SimpleCommunity buildCommunity(CommunityConfig config) { | |
496 | + SimpleCommunity simpleCommunity = new SimpleCommunity(); | |
497 | + simpleCommunity.setId(config.getId()); | |
498 | + String[] a = config.getGxxq().split(","); | |
499 | + List<String> gxxqList = new ArrayList<>(); | |
500 | + for (String a1 : a) { | |
501 | + gxxqList.add(a1.trim()); | |
487 | 502 | } |
488 | - if (null != communityQuery) { | |
489 | - List<CommunityConfig> list = communityConfigService.queryCommunity(communityQuery); | |
490 | - if (CollectionUtils.isNotEmpty(list)) { | |
491 | - communityConfig = list.get(0); | |
492 | - patients.setCommunityId(communityConfig.getId()); | |
503 | + simpleCommunity.setGxxq(gxxqList); | |
504 | + return simpleCommunity; | |
505 | + } | |
506 | + | |
507 | + private class SimpleCommunity { | |
508 | + private String id; | |
509 | + private List<String> gxxq; | |
510 | + | |
511 | + public List<String> getGxxq() { | |
512 | + return gxxq; | |
513 | + } | |
514 | + | |
515 | + public void setGxxq(List<String> gxxq) { | |
516 | + this.gxxq = gxxq; | |
517 | + } | |
518 | + | |
519 | + public String getId() { | |
520 | + return id; | |
521 | + } | |
522 | + | |
523 | + public void setId(String id) { | |
524 | + this.id = id; | |
525 | + } | |
526 | + } | |
527 | + | |
528 | + public void updateCommunity() { | |
529 | + //先把所有的社区数据拿出来 | |
530 | + CommunityQuery communityQuery = new CommunityQuery(); | |
531 | + communityQuery.setIsAreasNull(true); | |
532 | + communityQuery.setIsGxxqNull(true); | |
533 | + List<CommunityConfig> list = communityConfigService.queryCommunity(communityQuery); | |
534 | + //把区域id分配成区域id和社区 | |
535 | + Map<String, List<SimpleCommunity>> map = convertToMap(list); | |
536 | + if (map.isEmpty()) { | |
537 | + return; | |
538 | + } | |
539 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
540 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
541 | + patientsQuery.setIsNull(true); | |
542 | + patientsQuery.setNeed("1"); | |
543 | + patientsQuery.setPage(1); | |
544 | + patientsQuery.setLimit(100); | |
545 | + //每次取50个产妇分配社区 | |
546 | + | |
547 | + Iterator<String> key = map.keySet().iterator(); | |
548 | + while (key.hasNext()) { | |
549 | + boolean isMatch = Boolean.FALSE; | |
550 | + String areaid = key.next(); | |
551 | + patientsQuery.setAreaIdOrRestId(areaid); | |
552 | + List<Patients> pat = patientsService.queryPatient(patientsQuery); | |
553 | + for (Patients patients : pat) { | |
554 | + //优先产后修养地,然后现住地址 | |
555 | + if (StringUtils.isNotBlank(patients.getAreaPostRestId()) && StringUtils.isNotBlank(patients.getAddressPostRest())) { | |
556 | + List<SimpleCommunity> communityList = map.get(patients.getAreaPostRestId()); | |
557 | + if (CollectionUtils.isNotEmpty(communityList)) { | |
558 | + for (SimpleCommunity community : communityList) { | |
559 | + for (String str : community.getGxxq()) { | |
560 | + if (patients.getAddressPostRest().indexOf(str) > -1) { | |
561 | + patients.setCommunityId(community.getId()); | |
562 | + isMatch = true; | |
563 | + break; | |
564 | + } | |
565 | + } | |
566 | + } | |
567 | + } | |
568 | + | |
569 | + } | |
570 | + if (!isMatch&&StringUtils.isNotBlank(patients.getAddress()) && StringUtils.isNotBlank(patients.getAreaId()) ) { | |
571 | + List<SimpleCommunity> communityList = map.get(patients.getAreaId()); | |
572 | + if (CollectionUtils.isNotEmpty(communityList)) { | |
573 | + for (SimpleCommunity community : communityList) { | |
574 | + for (String str : community.getGxxq()) { | |
575 | + if (patients.getAddress().indexOf(str) > -1) { | |
576 | + patients.setCommunityId(community.getId()); | |
577 | + isMatch = true; | |
578 | + break; | |
579 | + } | |
580 | + } | |
581 | + } | |
582 | + } | |
583 | + } | |
584 | + if (isMatch){ | |
585 | + patientsService.updatePatient(patients); | |
586 | + isMatch = Boolean.FALSE; | |
587 | + } | |
493 | 588 | } |
494 | 589 | } |
495 | 590 | } |
platform-data-api/src/main/webapp/WEB-INF/vm/task/index.vm
View file @
843c660
... | ... | @@ -41,6 +41,14 @@ |
41 | 41 | <button class="btn btn-sm btn-danger" onclick="execOne('fullUpdatePatients')">执行</button> |
42 | 42 | </td> |
43 | 43 | </tr> |
44 | + <tr> | |
45 | + <td>分配社区</td> | |
46 | + <td></td> | |
47 | + <td>无</td> | |
48 | + <td> | |
49 | + <button class="btn btn-sm btn-danger" onclick="execOne('updateCommunity')">执行</button> | |
50 | + </td> | |
51 | + </tr> | |
44 | 52 | </table> |
45 | 53 | |
46 | 54 | <script> |