Commit f8ac4804445847ef6a2a1ba49b49d6d83f7a8f83
1 parent
d4e26baaff
Exists in
master
and in
8 other branches
儿童查询
Showing 2 changed files with 260 additions and 73 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java
View file @
f8ac480
... | ... | @@ -13,6 +13,8 @@ |
13 | 13 | import com.lyms.platform.common.utils.*; |
14 | 14 | import com.lyms.platform.operate.web.request.*; |
15 | 15 | import com.lyms.platform.operate.web.result.*; |
16 | +import com.lyms.platform.operate.web.utils.BabyListTask; | |
17 | +import com.lyms.platform.operate.web.utils.HiskCountTask; | |
16 | 18 | import com.lyms.platform.operate.web.utils.MessageCenterService; |
17 | 19 | import com.lyms.platform.permission.model.Organization; |
18 | 20 | import com.lyms.platform.permission.model.OrganizationQuery; |
... | ... | @@ -30,6 +32,10 @@ |
30 | 32 | import java.io.IOException; |
31 | 33 | import java.io.OutputStream; |
32 | 34 | import java.util.*; |
35 | +import java.util.concurrent.Callable; | |
36 | +import java.util.concurrent.ExecutorService; | |
37 | +import java.util.concurrent.Executors; | |
38 | +import java.util.concurrent.Future; | |
33 | 39 | |
34 | 40 | /** |
35 | 41 | * |
... | ... | @@ -103,6 +109,9 @@ |
103 | 109 | private AutoMatchFacade autoMatchFacade; |
104 | 110 | |
105 | 111 | |
112 | + private static ExecutorService pool = Executors.newFixedThreadPool(4); | |
113 | + | |
114 | + | |
106 | 115 | public BaseResponse getBabyBase(String babyId) { |
107 | 116 | //查询儿童的基本信息 |
108 | 117 | BabyBasicResult base = new BabyBasicResult(); |
... | ... | @@ -1366,6 +1375,8 @@ |
1366 | 1375 | |
1367 | 1376 | List<String> hospitalIdList = new ArrayList<>(); |
1368 | 1377 | |
1378 | + String hospitalName = ""; | |
1379 | + | |
1369 | 1380 | if(String.valueOf("true").equals(request.getIsArea())){ |
1370 | 1381 | |
1371 | 1382 | OrganizationQuery organizationQuery = new OrganizationQuery(); |
1372 | 1383 | |
1373 | 1384 | |
1374 | 1385 | |
1375 | 1386 | |
1376 | 1387 | |
1377 | 1388 | |
1378 | 1389 | |
... | ... | @@ -1429,75 +1440,118 @@ |
1429 | 1440 | } |
1430 | 1441 | } |
1431 | 1442 | hospitalIdList.add(hospitalId); |
1443 | + | |
1444 | + hospitalName = organizationService.getOrganization(Integer.valueOf(hospitalId)).getName(); | |
1432 | 1445 | } |
1433 | 1446 | |
1434 | 1447 | |
1435 | - | |
1436 | - | |
1448 | + List<BabyManageListResult> list = new ArrayList<>(); | |
1437 | 1449 | BabyModelQuery babyQuery = new BabyModelQuery(); |
1438 | 1450 | babyQuery.setHospitalIdList(hospitalIdList); |
1439 | 1451 | List<BabyModel> models = getBabayListByCondition(request, true, babyQuery); |
1440 | - List<BabyManageListResult> list = new ArrayList<>(); | |
1441 | 1452 | if (CollectionUtils.isNotEmpty(models)) { |
1442 | - for (BabyModel model : models) { | |
1443 | - BabyManageListResult result = new BabyManageListResult(); | |
1444 | - result.setId(model.getId()); | |
1445 | - if (model.getLastHighRisk() == null || model.getLastHighRisk() == 0) { | |
1446 | - result.setHighRisk("健康"); | |
1447 | - } else { | |
1448 | - result.setHighRisk("高危"); | |
1453 | + int batchSize = 50; | |
1454 | + int end = 0; | |
1455 | + List<Future> futures = new ArrayList<>(); | |
1456 | + for (int i = 0; i < models.size(); i += batchSize) { | |
1457 | + end = (end + batchSize); | |
1458 | + if (end > models.size()) { | |
1459 | + end = models.size(); | |
1449 | 1460 | } |
1450 | - result.setSex(StringUtils.emptyDeal(SexEnum.getTextById(model.getSex()))); | |
1451 | - result.setBabyName(StringUtils.emptyDeal(model.getName())); | |
1452 | - result.setBirthday(StringUtils.emptyDeal(DateUtil.getyyyy_MM_dd(model.getBirth()))); | |
1453 | - result.setMommyName(StringUtils.emptyDeal(model.getMname())); | |
1454 | - result.setMommnyPhone(StringUtils.emptyDeal(model.getMphone())); | |
1455 | - result.setMommnyEncryptPhone(StringUtils.encryPhone(model.getMphone())); | |
1456 | - result.setServiceStatus(StringUtils.emptyDeal(model.getServiceStatus() == null ? "" : ServiceStatusEnums.getNameById(model.getServiceStatus()))); | |
1457 | - result.setServiceType(StringUtils.emptyDeal(model.getServiceType() == null ? "" : ServiceTypeEnums.getTitleById(model.getServiceType()))); | |
1458 | - result.setNextDate(StringUtils.emptyDeal(DateUtil.getyyyy_MM_dd(model.getNextDate()))); | |
1459 | - result.setMonthAge(StringUtils.emptyDeal(DateUtil.getBabyMonthAge(model.getBirth(), new Date()))); | |
1460 | - result.setPatientId(model.getParentId()); | |
1461 | - result.setBuildTime(DateUtil.getyyyy_MM_dd(model.getBuildDate())); | |
1462 | - result.setHospitalName(organizationService.getOrganization(Integer.valueOf(model.getHospitalId())).getName()); | |
1463 | - | |
1464 | - // 开始查询省市区街道 | |
1465 | - // 省 | |
1466 | - BasicConfig provinceName = basicConfigService.getOneBasicConfigById(model.getProvinceId()); | |
1467 | - // 市 | |
1468 | - BasicConfig cityName = basicConfigService.getOneBasicConfigById(model.getCityId()); | |
1469 | - // 区 | |
1470 | - BasicConfig areaName = basicConfigService.getOneBasicConfigById(model.getAreaId()); | |
1471 | - // 街道 | |
1472 | - BasicConfig streetName = basicConfigService.getOneBasicConfigById(model.getStreetId()); | |
1473 | - // 具体 | |
1474 | - String address = model.getAddress(); | |
1475 | - String completeAddress = ""; | |
1476 | - if(provinceName!=null){ | |
1477 | - completeAddress+=provinceName.getName(); | |
1461 | + List<BabyModel> ms = models.subList(i, end); | |
1462 | + Callable c = new BabyListTask( | |
1463 | + basicConfigService, | |
1464 | + organizationService, | |
1465 | + babyCheckFacade, | |
1466 | + ms,request.getIsArea(),hospitalName); | |
1467 | + Future f = pool.submit(c); | |
1468 | + futures.add(f); | |
1469 | + } | |
1470 | + if (CollectionUtils.isNotEmpty(futures)) | |
1471 | + { | |
1472 | + for (Future f : futures) | |
1473 | + { | |
1474 | + try { | |
1475 | + list.addAll((List<BabyManageListResult>) f.get()); | |
1476 | + } catch (Exception e) { | |
1477 | + ExceptionUtils.catchException(e, "baby list error."); | |
1478 | + } | |
1478 | 1479 | } |
1479 | - if(cityName!=null){ | |
1480 | - completeAddress+=cityName.getName(); | |
1481 | - } | |
1482 | - if(areaName!=null){ | |
1483 | - completeAddress+=areaName.getName(); | |
1484 | - } | |
1485 | - if(streetName!=null){ | |
1486 | - completeAddress+=streetName.getName(); | |
1487 | - } | |
1488 | - if(!StringUtils.isEmpty(address)) { | |
1489 | - completeAddress += address; | |
1490 | - } | |
1491 | - if(completeAddress.length()==0){ | |
1492 | - completeAddress = "-"; | |
1493 | - } | |
1494 | - result.setCompleteAddress(completeAddress); | |
1480 | + } | |
1481 | + } | |
1495 | 1482 | |
1496 | - String diagnose = ""; | |
1497 | -// if (!StringUtils.isEmpty(model.getDiagnose())) { | |
1498 | -// List diagList = JsonUtil.toList(model.getDiagnose(), List.class); | |
1483 | +// if (CollectionUtils.isNotEmpty(models)) { | |
1484 | +// for (BabyModel model : models) { | |
1485 | +// BabyManageListResult result = new BabyManageListResult(); | |
1486 | +// result.setId(model.getId()); | |
1487 | +// if (model.getLastHighRisk() == null || model.getLastHighRisk() == 0) { | |
1488 | +// result.setHighRisk("健康"); | |
1489 | +// } else { | |
1490 | +// result.setHighRisk("高危"); | |
1491 | +// } | |
1492 | +// result.setSex(StringUtils.emptyDeal(SexEnum.getTextById(model.getSex()))); | |
1493 | +// result.setBabyName(StringUtils.emptyDeal(model.getName())); | |
1494 | +// result.setBirthday(StringUtils.emptyDeal(DateUtil.getyyyy_MM_dd(model.getBirth()))); | |
1495 | +// result.setMommyName(StringUtils.emptyDeal(model.getMname())); | |
1496 | +// result.setMommnyPhone(StringUtils.emptyDeal(model.getMphone())); | |
1497 | +// result.setMommnyEncryptPhone(StringUtils.encryPhone(model.getMphone())); | |
1498 | +// result.setServiceStatus(StringUtils.emptyDeal(model.getServiceStatus() == null ? "" : ServiceStatusEnums.getNameById(model.getServiceStatus()))); | |
1499 | +// result.setServiceType(StringUtils.emptyDeal(model.getServiceType() == null ? "" : ServiceTypeEnums.getTitleById(model.getServiceType()))); | |
1500 | +// result.setNextDate(StringUtils.emptyDeal(DateUtil.getyyyy_MM_dd(model.getNextDate()))); | |
1501 | +// result.setMonthAge(StringUtils.emptyDeal(DateUtil.getBabyMonthAge(model.getBirth(), new Date()))); | |
1502 | +// result.setPatientId(model.getParentId()); | |
1503 | +// result.setBuildTime(DateUtil.getyyyy_MM_dd(model.getBuildDate())); | |
1504 | +// result.setHospitalName(organizationService.getOrganization(Integer.valueOf(model.getHospitalId())).getName()); | |
1505 | +// | |
1506 | +// if(String.valueOf("true").equals(request.getIsArea())) { | |
1507 | +// // 开始查询省市区街道 | |
1508 | +// // 省 | |
1509 | +// BasicConfig provinceName = basicConfigService.getOneBasicConfigById(model.getProvinceId()); | |
1510 | +// // 市 | |
1511 | +// BasicConfig cityName = basicConfigService.getOneBasicConfigById(model.getCityId()); | |
1512 | +// // 区 | |
1513 | +// BasicConfig areaName = basicConfigService.getOneBasicConfigById(model.getAreaId()); | |
1514 | +// // 街道 | |
1515 | +// BasicConfig streetName = basicConfigService.getOneBasicConfigById(model.getStreetId()); | |
1516 | +// // 具体 | |
1517 | +// String address = model.getAddress(); | |
1518 | +// String completeAddress = ""; | |
1519 | +// if (provinceName != null) { | |
1520 | +// completeAddress += provinceName.getName(); | |
1521 | +// } | |
1522 | +// if (cityName != null) { | |
1523 | +// completeAddress += cityName.getName(); | |
1524 | +// } | |
1525 | +// if (areaName != null) { | |
1526 | +// completeAddress += areaName.getName(); | |
1527 | +// } | |
1528 | +// if (streetName != null) { | |
1529 | +// completeAddress += streetName.getName(); | |
1530 | +// } | |
1531 | +// if (!StringUtils.isEmpty(address)) { | |
1532 | +// completeAddress += address; | |
1533 | +// } | |
1534 | +// if (completeAddress.length() == 0) { | |
1535 | +// completeAddress = "-"; | |
1536 | +// } | |
1537 | +// result.setCompleteAddress(completeAddress); | |
1538 | +// } | |
1539 | +// String diagnose = ""; | |
1540 | +//// if (!StringUtils.isEmpty(model.getDiagnose())) { | |
1541 | +//// List diagList = JsonUtil.toList(model.getDiagnose(), List.class); | |
1542 | +//// if (CollectionUtils.isNotEmpty(diagList)) { | |
1543 | +//// diagnose = ""; | |
1544 | +//// for (Object obj : diagList) { | |
1545 | +//// BasicConfig basicConfig = basicConfigService.getOneBasicConfigById((String) obj); | |
1546 | +//// if (basicConfig != null) { | |
1547 | +//// diagnose += basicConfig.getName() + " "; | |
1548 | +//// } | |
1549 | +//// } | |
1550 | +//// } | |
1551 | +//// } | |
1552 | +// if (StringUtils.isNotEmpty(model.getPid())) { | |
1553 | +// List diagList = babyCheckFacade.getBabyLastDiagnose(model.getPid()); | |
1499 | 1554 | // if (CollectionUtils.isNotEmpty(diagList)) { |
1500 | -// diagnose = ""; | |
1501 | 1555 | // for (Object obj : diagList) { |
1502 | 1556 | // BasicConfig basicConfig = basicConfigService.getOneBasicConfigById((String) obj); |
1503 | 1557 | // if (basicConfig != null) { |
... | ... | @@ -1506,21 +1560,10 @@ |
1506 | 1560 | // } |
1507 | 1561 | // } |
1508 | 1562 | // } |
1509 | - if (StringUtils.isNotEmpty(model.getPid())) { | |
1510 | - List diagList = babyCheckFacade.getBabyLastDiagnose(model.getPid()); | |
1511 | - if (CollectionUtils.isNotEmpty(diagList)) { | |
1512 | - for (Object obj : diagList) { | |
1513 | - BasicConfig basicConfig = basicConfigService.getOneBasicConfigById((String) obj); | |
1514 | - if (basicConfig != null) { | |
1515 | - diagnose += basicConfig.getName() + " "; | |
1516 | - } | |
1517 | - } | |
1518 | - } | |
1519 | - } | |
1520 | - result.setDiagnose(StringUtils.emptyDeal(diagnose)); | |
1521 | - list.add(result); | |
1522 | - } | |
1523 | - } | |
1563 | +// result.setDiagnose(StringUtils.emptyDeal(diagnose)); | |
1564 | +// list.add(result); | |
1565 | +// } | |
1566 | +// } | |
1524 | 1567 | |
1525 | 1568 | BaseListResponse objectResponse = new BaseListResponse(); |
1526 | 1569 | objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/BabyListTask.java
View file @
f8ac480
1 | +package com.lyms.platform.operate.web.utils; | |
2 | + | |
3 | +import com.lyms.platform.biz.service.BasicConfigService; | |
4 | +import com.lyms.platform.common.enums.*; | |
5 | +import com.lyms.platform.common.utils.DateUtil; | |
6 | +import com.lyms.platform.common.utils.StringUtils; | |
7 | +import com.lyms.platform.operate.web.facade.BabyCheckFacade; | |
8 | +import com.lyms.platform.operate.web.result.BabyManageListResult; | |
9 | +import com.lyms.platform.permission.service.OrganizationService; | |
10 | +import com.lyms.platform.pojo.BabyModel; | |
11 | +import com.lyms.platform.pojo.BasicConfig; | |
12 | +import org.apache.commons.collections.CollectionUtils; | |
13 | + | |
14 | +import java.util.*; | |
15 | +import java.util.concurrent.*; | |
16 | + | |
17 | +/** | |
18 | + * Created by lqy on 2016/11/30. | |
19 | + */ | |
20 | +public class BabyListTask implements Callable { | |
21 | + | |
22 | + private BasicConfigService basicConfigService; | |
23 | + | |
24 | + private OrganizationService organizationService; | |
25 | + | |
26 | + private BabyCheckFacade babyCheckFacade; | |
27 | + | |
28 | + private List<BabyModel> models; | |
29 | + | |
30 | + private String isArea; | |
31 | + private String hospitalName; | |
32 | + | |
33 | + public BabyListTask(BasicConfigService basicConfigService, | |
34 | + OrganizationService organizationService, | |
35 | + BabyCheckFacade babyCheckFacade, | |
36 | + List<BabyModel> models, | |
37 | + String isArea, | |
38 | + String hospitalName) | |
39 | + { | |
40 | + this.basicConfigService = basicConfigService; | |
41 | + this.organizationService = organizationService; | |
42 | + this.babyCheckFacade = babyCheckFacade; | |
43 | + this.models = models; | |
44 | + this.isArea = isArea; | |
45 | + this.hospitalName = hospitalName; | |
46 | + | |
47 | + } | |
48 | + @Override | |
49 | + public List<BabyManageListResult> call() throws Exception { | |
50 | + List<BabyManageListResult> list = new ArrayList<>(); | |
51 | + if (CollectionUtils.isNotEmpty(models)) { | |
52 | + for (BabyModel model : models) { | |
53 | + BabyManageListResult result = new BabyManageListResult(); | |
54 | + result.setId(model.getId()); | |
55 | + if (model.getLastHighRisk() == null || model.getLastHighRisk() == 0) { | |
56 | + result.setHighRisk("健康"); | |
57 | + } else { | |
58 | + result.setHighRisk("高危"); | |
59 | + } | |
60 | + result.setSex(StringUtils.emptyDeal(SexEnum.getTextById(model.getSex()))); | |
61 | + result.setBabyName(StringUtils.emptyDeal(model.getName())); | |
62 | + result.setBirthday(StringUtils.emptyDeal(DateUtil.getyyyy_MM_dd(model.getBirth()))); | |
63 | + result.setMommyName(StringUtils.emptyDeal(model.getMname())); | |
64 | + result.setMommnyPhone(StringUtils.emptyDeal(model.getMphone())); | |
65 | + result.setMommnyEncryptPhone(StringUtils.encryPhone(model.getMphone())); | |
66 | + result.setServiceStatus(StringUtils.emptyDeal(model.getServiceStatus() == null ? "" : ServiceStatusEnums.getNameById(model.getServiceStatus()))); | |
67 | + result.setServiceType(StringUtils.emptyDeal(model.getServiceType() == null ? "" : ServiceTypeEnums.getTitleById(model.getServiceType()))); | |
68 | + result.setNextDate(StringUtils.emptyDeal(DateUtil.getyyyy_MM_dd(model.getNextDate()))); | |
69 | + result.setMonthAge(StringUtils.emptyDeal(DateUtil.getBabyMonthAge(model.getBirth(), new Date()))); | |
70 | + result.setPatientId(model.getParentId()); | |
71 | + result.setBuildTime(DateUtil.getyyyy_MM_dd(model.getBuildDate())); | |
72 | + result.setHospitalName(hospitalName); | |
73 | + | |
74 | + if(String.valueOf("true").equals(isArea)) { | |
75 | + | |
76 | + result.setHospitalName(organizationService.getOrganization(Integer.valueOf(model.getHospitalId())).getName()); | |
77 | + // 开始查询省市区街道 | |
78 | + // 省 | |
79 | + BasicConfig provinceName = basicConfigService.getOneBasicConfigById(model.getProvinceId()); | |
80 | + // 市 | |
81 | + BasicConfig cityName = basicConfigService.getOneBasicConfigById(model.getCityId()); | |
82 | + // 区 | |
83 | + BasicConfig areaName = basicConfigService.getOneBasicConfigById(model.getAreaId()); | |
84 | + // 街道 | |
85 | + BasicConfig streetName = basicConfigService.getOneBasicConfigById(model.getStreetId()); | |
86 | + // 具体 | |
87 | + String address = model.getAddress(); | |
88 | + String completeAddress = ""; | |
89 | + if (provinceName != null) { | |
90 | + completeAddress += provinceName.getName(); | |
91 | + } | |
92 | + if (cityName != null) { | |
93 | + completeAddress += cityName.getName(); | |
94 | + } | |
95 | + if (areaName != null) { | |
96 | + completeAddress += areaName.getName(); | |
97 | + } | |
98 | + if (streetName != null) { | |
99 | + completeAddress += streetName.getName(); | |
100 | + } | |
101 | + if (!StringUtils.isEmpty(address)) { | |
102 | + completeAddress += address; | |
103 | + } | |
104 | + if (completeAddress.length() == 0) { | |
105 | + completeAddress = "-"; | |
106 | + } | |
107 | + result.setCompleteAddress(completeAddress); | |
108 | + } | |
109 | + String diagnose = ""; | |
110 | +// if (!StringUtils.isEmpty(model.getDiagnose())) { | |
111 | +// List diagList = JsonUtil.toList(model.getDiagnose(), List.class); | |
112 | +// if (CollectionUtils.isNotEmpty(diagList)) { | |
113 | +// diagnose = ""; | |
114 | +// for (Object obj : diagList) { | |
115 | +// BasicConfig basicConfig = basicConfigService.getOneBasicConfigById((String) obj); | |
116 | +// if (basicConfig != null) { | |
117 | +// diagnose += basicConfig.getName() + " "; | |
118 | +// } | |
119 | +// } | |
120 | +// } | |
121 | +// } | |
122 | + if (StringUtils.isNotEmpty(model.getPid())) { | |
123 | + List diagList = babyCheckFacade.getBabyLastDiagnose(model.getPid()); | |
124 | + if (CollectionUtils.isNotEmpty(diagList)) { | |
125 | + for (Object obj : diagList) { | |
126 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById((String) obj); | |
127 | + if (basicConfig != null) { | |
128 | + diagnose += basicConfig.getName() + " "; | |
129 | + } | |
130 | + } | |
131 | + } | |
132 | + } | |
133 | + result.setDiagnose(StringUtils.emptyDeal(diagnose)); | |
134 | + list.add(result); | |
135 | + } | |
136 | + } | |
137 | + | |
138 | + return list; | |
139 | + } | |
140 | + | |
141 | + | |
142 | +} |