Commit f6de5e68df0c8cd216d9af9339f1bbabb2255155
1 parent
25dc5cefcc
Exists in
master
and in
6 other branches
修改产筛
Showing 2 changed files with 121 additions and 1 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SieveFacade.java
View file @
f6de5e6
| ... | ... | @@ -21,6 +21,8 @@ |
| 21 | 21 | import com.lyms.platform.operate.web.result.SieveDetailResult; |
| 22 | 22 | import com.lyms.platform.operate.web.result.SieveListResult; |
| 23 | 23 | import com.lyms.platform.operate.web.result.SieveResult; |
| 24 | +import com.lyms.platform.operate.web.worker.SieveWorker; | |
| 25 | +import com.lyms.platform.operate.web.worker.WorkHR; | |
| 24 | 26 | import com.lyms.platform.permission.model.Organization; |
| 25 | 27 | import com.lyms.platform.permission.service.OrganizationService; |
| 26 | 28 | import com.lyms.platform.pojo.*; |
| 27 | 29 | |
| 28 | 30 | |
| ... | ... | @@ -29,12 +31,16 @@ |
| 29 | 31 | import org.apache.commons.lang.StringUtils; |
| 30 | 32 | import org.apache.commons.lang.math.NumberUtils; |
| 31 | 33 | import org.springframework.beans.factory.annotation.Autowired; |
| 34 | +import org.springframework.beans.factory.annotation.Qualifier; | |
| 32 | 35 | import org.springframework.data.domain.Sort; |
| 36 | +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | |
| 33 | 37 | import org.springframework.stereotype.Component; |
| 34 | 38 | |
| 35 | 39 | import javax.servlet.http.HttpServletResponse; |
| 36 | 40 | import java.io.OutputStream; |
| 37 | 41 | import java.util.*; |
| 42 | +import java.util.concurrent.Future; | |
| 43 | +import java.util.concurrent.TimeUnit; | |
| 38 | 44 | |
| 39 | 45 | /** |
| 40 | 46 | * 产筛门面 |
| ... | ... | @@ -57,6 +63,10 @@ |
| 57 | 63 | @Autowired |
| 58 | 64 | private PatientsService patientsService; |
| 59 | 65 | |
| 66 | + @Autowired | |
| 67 | + @Qualifier("commonThreadPool") | |
| 68 | + private ThreadPoolTaskExecutor commonThreadPool; | |
| 69 | + | |
| 60 | 70 | /** |
| 61 | 71 | * 增加一条产筛结果记录 |
| 62 | 72 | * |
| ... | ... | @@ -214,6 +224,29 @@ |
| 214 | 224 | //查询产筛list |
| 215 | 225 | List<SieveModel> list = sieveService.queryList1(sieveQuery, "order"); |
| 216 | 226 | List<SieveListResult> data = new ArrayList<>(); |
| 227 | + | |
| 228 | + | |
| 229 | + int batchSize = 4; | |
| 230 | + int end = 0; | |
| 231 | + List<Future> listFuture = new ArrayList<>(); | |
| 232 | + for (int i = 0; i < list.size(); i += batchSize) { | |
| 233 | + end = (end + batchSize); | |
| 234 | + if (end > list.size()) { | |
| 235 | + end = list.size(); | |
| 236 | + } | |
| 237 | + listFuture.add(commonThreadPool.submit(new SieveWorker(hospitalId, list.subList(i, end), antenatalExaminationService, patientsService))); | |
| 238 | + } | |
| 239 | + for (Future f : listFuture) { | |
| 240 | + try { | |
| 241 | + data.addAll((List) f.get(30, TimeUnit.SECONDS)); | |
| 242 | + } catch (Exception e) { | |
| 243 | + ExceptionUtils.catchException(e, "cqSieve list get result Future error."); | |
| 244 | + } | |
| 245 | + } | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | +/* | |
| 217 | 250 | if (CollectionUtils.isNotEmpty(list)) { |
| 218 | 251 | for (SieveModel sieveModel : list) { |
| 219 | 252 | SieveListResult sieveListResult = new SieveListResult(); |
| ... | ... | @@ -252,7 +285,7 @@ |
| 252 | 285 | } |
| 253 | 286 | data.add(sieveListResult); |
| 254 | 287 | } |
| 255 | - } | |
| 288 | + }*/ | |
| 256 | 289 | return new BaseListResponse().setData(data).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setPageInfo(sieveQuery.getPageInfo()); |
| 257 | 290 | } |
| 258 | 291 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/SieveWorker.java
View file @
f6de5e6
| 1 | +package com.lyms.platform.operate.web.worker; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.AntenatalExaminationService; | |
| 4 | +import com.lyms.platform.biz.service.PatientsService; | |
| 5 | +import com.lyms.platform.common.enums.YnEnums; | |
| 6 | +import com.lyms.platform.common.utils.DateUtil; | |
| 7 | +import com.lyms.platform.operate.web.result.SieveListResult; | |
| 8 | +import com.lyms.platform.pojo.AntExChuModel; | |
| 9 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 10 | +import com.lyms.platform.pojo.Patients; | |
| 11 | +import com.lyms.platform.pojo.SieveModel; | |
| 12 | +import com.lyms.platform.query.AntExChuQuery; | |
| 13 | +import com.lyms.platform.query.AntExQuery; | |
| 14 | +import org.apache.commons.collections.CollectionUtils; | |
| 15 | +import org.apache.commons.lang.StringUtils; | |
| 16 | +import org.apache.commons.lang.math.NumberUtils; | |
| 17 | +import org.springframework.data.domain.Sort; | |
| 18 | + | |
| 19 | +import java.util.ArrayList; | |
| 20 | +import java.util.List; | |
| 21 | +import java.util.concurrent.Callable; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * 产筛列表处理 | |
| 25 | + * <p/> | |
| 26 | + * Created by Administrator on 2017/3/10 0010. | |
| 27 | + */ | |
| 28 | +public class SieveWorker implements Callable<List<SieveListResult>> { | |
| 29 | + | |
| 30 | + private String hospitalId; | |
| 31 | + | |
| 32 | + private List<SieveModel> list; | |
| 33 | + | |
| 34 | + private AntenatalExaminationService antService; | |
| 35 | + | |
| 36 | + private PatientsService patientsService; | |
| 37 | + | |
| 38 | + public SieveWorker(String hospitalId, List<SieveModel> list, AntenatalExaminationService antService, PatientsService patientsService) { | |
| 39 | + this.hospitalId = hospitalId; | |
| 40 | + this.list = list; | |
| 41 | + this.antService = antService; | |
| 42 | + this.patientsService = patientsService; | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + public List<SieveListResult> call() throws Exception { | |
| 47 | + List<SieveListResult> results = new ArrayList<>(); | |
| 48 | + for (SieveModel sieveModel : list) { | |
| 49 | + SieveListResult sieveListResult = new SieveListResult(); | |
| 50 | + AntExQuery antExQuery = new AntExQuery(); | |
| 51 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 52 | + antExQuery.setHospitalId(hospitalId); | |
| 53 | + antExQuery.setParentId(sieveModel.getParentId()); | |
| 54 | + List<AntenatalExaminationModel> list1 = antService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); | |
| 55 | + if (CollectionUtils.isNotEmpty(list1)) { | |
| 56 | + if (StringUtils.isNotEmpty(list1.get(0).getTireNumber())) { | |
| 57 | + sieveModel.setTireNumber(NumberUtils.toInt(list1.get(0).getTireNumber())); | |
| 58 | + } | |
| 59 | + } else { | |
| 60 | + AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
| 61 | + antExChuQuery.setYn(YnEnums.YES.getId()); | |
| 62 | + antExChuQuery.setParentId(sieveModel.getParentId()); | |
| 63 | + antExChuQuery.setHospitalId(hospitalId); | |
| 64 | + List<AntExChuModel> antExChuModels = antService.queryAntExChu(antExChuQuery); | |
| 65 | + if (CollectionUtils.isNotEmpty(antExChuModels)) { | |
| 66 | + if (StringUtils.isNotEmpty(antExChuModels.get(0).getTireNumber())) { | |
| 67 | + sieveModel.setTireNumber(NumberUtils.toInt(antExChuModels.get(0).getTireNumber())); | |
| 68 | + } | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + sieveListResult.convertToResult(sieveModel); | |
| 73 | + Patients patients = patientsService.findOnePatientById(sieveModel.getParentId()); | |
| 74 | + if (null != patients) { | |
| 75 | + sieveListResult.setIsGravida((patients.getType() == 3 && patients.getFmDate() != null) ? "0" : "1"); | |
| 76 | + if (null != patients.getDueStatus() && 1 == patients.getDueStatus()) | |
| 77 | + sieveListResult.setcDueWeek("终止妊娠"); | |
| 78 | + else if (patients.getType() == 3) { | |
| 79 | + sieveListResult.setcDueWeek("已分娩"); | |
| 80 | + } | |
| 81 | + sieveListResult.setAge(DateUtil.getAge(patients.getBirth()) + "岁"); | |
| 82 | + } | |
| 83 | + results.add(sieveListResult); | |
| 84 | + } | |
| 85 | + return results; | |
| 86 | + } | |
| 87 | +} |