Commit d9b8ca18f6f46e8b2bd359c84faa8d26f36d7642
1 parent
dfa663b8b0
Exists in
master
and in
6 other branches
优化产后访视功能
Showing 11 changed files with 215 additions and 11 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/MasterOrganizationMapper.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/OrganizationService.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/OrganizationServiceImpl.java
- platform-biz-service/src/main/resources/mainOrm/master/MasterOrganization.xml
- platform-dal/src/main/java/com/lyms/platform/query/MatDeliverQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MatDeliverController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PregnantBuildController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientServiceFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/BatchUpdateLymsPatient.java
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/MasterOrganizationMapper.java
View file @
d9b8ca1
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | |
3 | 3 | import com.lyms.platform.permission.model.Organization; |
4 | 4 | import com.lyms.platform.permission.model.OrganizationQuery; |
5 | +import org.apache.ibatis.annotations.Param; | |
5 | 6 | |
6 | 7 | import java.util.List; |
7 | 8 | import java.util.Map; |
... | ... | @@ -34,5 +35,10 @@ |
34 | 35 | */ |
35 | 36 | public String getOrganizationName(String id); |
36 | 37 | |
38 | + /** | |
39 | + * @param townOrgId | |
40 | + * @return | |
41 | + */ | |
42 | + List<Map<String, Object>> findIdByTownOrgId(@Param("townOrgId") String townOrgId); | |
37 | 43 | } |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/OrganizationService.java
View file @
d9b8ca1
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/OrganizationServiceImpl.java
View file @
d9b8ca1
platform-biz-service/src/main/resources/mainOrm/master/MasterOrganization.xml
View file @
d9b8ca1
... | ... | @@ -271,6 +271,10 @@ |
271 | 271 | SELECT name FROM organization WHERE id=#{id,jdbcType=VARCHAR} |
272 | 272 | </select> |
273 | 273 | |
274 | + <select id="findIdByTownOrgId" parameterType="string" resultType="java.util.Map"> | |
275 | + select o.id as "id" from organization o where o.townOrgId = #{townOrgId} | |
276 | + </select> | |
277 | + | |
274 | 278 | |
275 | 279 | </mapper> |
platform-dal/src/main/java/com/lyms/platform/query/MatDeliverQuery.java
View file @
d9b8ca1
... | ... | @@ -309,8 +309,9 @@ |
309 | 309 | } |
310 | 310 | if (CollectionUtils.isNotEmpty(fmHospitalList)) { |
311 | 311 | if (fsHospital != null) { |
312 | - condition.orCondition(MongoCondition.newInstance("fmHospital", fmHospitalList, MongoOper.IN), MongoCondition.newInstance("fsHospital", fsHospital, MongoOper.IS)); | |
313 | -// condition = condition.and("fmHospital", fmHospitalList, MongoOper.IN); | |
312 | + /*condition.orCondition(MongoCondition.newInstance("fmHospital", fmHospitalList, MongoOper.IN), MongoCondition.newInstance("fsHospital", fsHospital, MongoOper.IS), | |
313 | + MongoCondition.newInstance("fsHospital", false, MongoOper.EXISTS));*/ | |
314 | + condition = condition.and("fmHospital", fmHospitalList, MongoOper.IN); | |
314 | 315 | // condition = condition.and("fsHospital", fsHospital, MongoOper.IN); |
315 | 316 | } else { |
316 | 317 | condition = condition.and("fmHospital", fmHospitalList, MongoOper.IN); |
317 | 318 | |
... | ... | @@ -319,13 +320,16 @@ |
319 | 320 | |
320 | 321 | if (null != fmHospital) { |
321 | 322 | if (fsHospital != null) { |
322 | - condition.orCondition(MongoCondition.newInstance("fmHospital", fmHospital, MongoOper.IS), MongoCondition.newInstance("fsHospital", fsHospital, MongoOper.IS)); | |
323 | + //condition.orCondition(MongoCondition.newInstance("fmHospital", fmHospital, MongoOper.IS), MongoCondition.newInstance("fsHospital", fsHospital, MongoOper.IS)); | |
324 | + condition = condition.and("fmHospital", fmHospital, MongoOper.IS); | |
323 | 325 | } else { |
324 | 326 | condition = condition.and("fmHospital", fmHospital, MongoOper.IS); |
325 | 327 | } |
326 | 328 | } |
327 | 329 | if (null != fsHospitalId) { |
328 | - condition = condition.and("fmHospital", fsHospitalId, MongoOper.IS); | |
330 | + MongoCondition con1 = MongoCondition.newInstance("fsHospital", fsHospitalId, MongoOper.IS); | |
331 | + MongoCondition con2 = MongoCondition.newInstance("fsHospital", false, MongoOper.EXISTS); | |
332 | + condition.orCondition(con1, con2); | |
329 | 333 | } |
330 | 334 | |
331 | 335 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MatDeliverController.java
View file @
d9b8ca1
... | ... | @@ -111,6 +111,18 @@ |
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
114 | + * 更新分娩记录===> where 已分娩未进行产后访视并且小于28天 | |
115 | + * | |
116 | + * @return 返回 | |
117 | + */ | |
118 | + @RequestMapping(value = "/history/batch/update", method = RequestMethod.GET) | |
119 | + @ResponseBody | |
120 | + public BaseResponse historyBatchUpdate() { | |
121 | + BaseResponse baseResponse = matDeliverFacade.historyBatchUpdate(); | |
122 | + return baseResponse; | |
123 | + } | |
124 | + | |
125 | + /** | |
114 | 126 | * 删除一条删除记录 |
115 | 127 | * |
116 | 128 | * @param id 删除分娩记录 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PregnantBuildController.java
View file @
d9b8ca1
... | ... | @@ -602,15 +602,26 @@ |
602 | 602 | |
603 | 603 | /** |
604 | 604 | * 更新mysql 机构表的townOrgId |
605 | + * | |
605 | 606 | * @param request |
606 | 607 | * @return |
607 | 608 | */ |
608 | 609 | @RequestMapping(value="/batchUpdateOrg",method=RequestMethod.GET) |
609 | 610 | @ResponseBody |
610 | 611 | public BaseResponse batchUpdateOrg(HttpServletRequest request) { |
611 | - | |
612 | 612 | return bookbuildingFacade.batchUpdateOrg(request); |
613 | + } | |
613 | 614 | |
615 | + /** | |
616 | + * 更新mongDB 病人建档表 lyms_patient | |
617 | + * | |
618 | + * @param request | |
619 | + * @return | |
620 | + */ | |
621 | + @RequestMapping(value="/batchUpdateLymsPatient",method=RequestMethod.GET) | |
622 | + @ResponseBody | |
623 | + public BaseResponse batchUpdateLymsPatient(HttpServletRequest request) { | |
624 | + return bookbuildingFacade.batchUpdateLymsPatient(request); | |
614 | 625 | } |
615 | 626 | |
616 | 627 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java
View file @
d9b8ca1
... | ... | @@ -21,6 +21,7 @@ |
21 | 21 | import com.lyms.platform.operate.web.result.*; |
22 | 22 | import com.lyms.platform.operate.web.service.ITrackDownService; |
23 | 23 | import com.lyms.platform.operate.web.utils.JdbcUtil; |
24 | +import com.lyms.platform.operate.web.worker.BatchUpdateLymsPatient; | |
24 | 25 | import com.lyms.platform.operate.web.worker.CorrectDataWorker; |
25 | 26 | import com.lyms.platform.operate.web.worker.SyncV2HistoryWorkerx; |
26 | 27 | import com.lyms.platform.permission.dao.master.CouponMapper; |
... | ... | @@ -33,6 +34,7 @@ |
33 | 34 | import com.lyms.platform.permission.service.UsersService; |
34 | 35 | import com.lyms.platform.pojo.*; |
35 | 36 | import com.lyms.platform.query.*; |
37 | +import com.mongodb.WriteResult; | |
36 | 38 | import org.apache.commons.collections.CollectionUtils; |
37 | 39 | import org.apache.commons.dbutils.QueryRunner; |
38 | 40 | import org.apache.commons.dbutils.handlers.BeanListHandler; |
39 | 41 | |
... | ... | @@ -44,11 +46,13 @@ |
44 | 46 | import org.springframework.data.mongodb.core.MongoTemplate; |
45 | 47 | import org.springframework.data.mongodb.core.query.Criteria; |
46 | 48 | import org.springframework.data.mongodb.core.query.Query; |
49 | +import org.springframework.data.mongodb.core.query.Update; | |
47 | 50 | import org.springframework.http.HttpHeaders; |
48 | 51 | import org.springframework.http.MediaType; |
49 | 52 | import org.springframework.http.ResponseEntity; |
50 | 53 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
51 | 54 | import org.springframework.stereotype.Component; |
55 | +import org.springframework.transaction.annotation.Transactional; | |
52 | 56 | import org.springframework.web.client.RestTemplate; |
53 | 57 | import org.springframework.web.multipart.MultipartFile; |
54 | 58 | |
55 | 59 | |
56 | 60 | |
... | ... | @@ -61,8 +65,12 @@ |
61 | 65 | import java.text.SimpleDateFormat; |
62 | 66 | import java.util.*; |
63 | 67 | import java.util.Date; |
68 | +import java.util.concurrent.ExecutorService; | |
69 | +import java.util.concurrent.Executors; | |
64 | 70 | import java.util.concurrent.Future; |
71 | +import java.util.concurrent.TimeUnit; | |
65 | 72 | import java.util.concurrent.atomic.AtomicLong; |
73 | +import java.util.regex.Pattern; | |
66 | 74 | |
67 | 75 | /** |
68 | 76 | * |
69 | 77 | |
... | ... | @@ -2394,8 +2402,69 @@ |
2394 | 2402 | return connection; |
2395 | 2403 | } |
2396 | 2404 | |
2405 | + /** | |
2406 | + * 更新org 表 | |
2407 | + * | |
2408 | + * @param request | |
2409 | + * @return | |
2410 | + */ | |
2397 | 2411 | public BaseResponse batchUpdateOrg(HttpServletRequest request) { |
2398 | - return null; | |
2412 | + OrganizationQuery query = new OrganizationQuery(); | |
2413 | + Integer updateSize = 0; | |
2414 | + Integer errorSize = 0; | |
2415 | + List<Organization> organizations = organizationService.queryHospitals(query); | |
2416 | + for (Organization organization: organizations) { | |
2417 | + String name = organization.getName(); | |
2418 | + List<BasicConfig> basicConfigs = mongoTemplate.find(Query.query(Criteria.where("name").is(name)), BasicConfig.class); | |
2419 | + if (CollectionUtils.isNotEmpty(basicConfigs)) { | |
2420 | + BasicConfig basicConfig = basicConfigs.get(0); | |
2421 | + String basicConfigId = basicConfig.getId(); | |
2422 | + if (basicConfigId.equals(organization.getTownOrgId())) { | |
2423 | + continue; | |
2424 | + } | |
2425 | + Organization org = new Organization(); | |
2426 | + org.setId(organization.getId()); | |
2427 | + org.setTownOrgId(basicConfigId); | |
2428 | + organizationService.updateOrganization(org); | |
2429 | + updateSize ++; | |
2430 | + } else { | |
2431 | + System.out.println("暂无匹配数据, name===>" + name); | |
2432 | + errorSize ++; | |
2433 | + } | |
2434 | + } | |
2435 | + BaseResponse baseResponse = new BaseResponse(); | |
2436 | + HashMap<String, Object> objectObjectHashMap = new HashMap<>(); | |
2437 | + objectObjectHashMap.put("updateSize",updateSize); | |
2438 | + objectObjectHashMap.put("errorSize", errorSize); | |
2439 | + baseResponse.setObject(objectObjectHashMap); | |
2440 | + return baseResponse; | |
2441 | + } | |
2442 | + | |
2443 | + /** | |
2444 | + * 更新mongDB 病人建档表 lyms_patient | |
2445 | + * | |
2446 | + * @param request | |
2447 | + * @return | |
2448 | + */ | |
2449 | + public BaseResponse batchUpdateLymsPatient(HttpServletRequest request) { | |
2450 | + | |
2451 | + List<Patients> patients = mongoTemplate.find(Query.query(Criteria.where("fmDate").exists(false).and("yn").is(1)), Patients.class); | |
2452 | + ExecutorService service = Executors.newFixedThreadPool(5); | |
2453 | + for (Patients patient : patients) { | |
2454 | + /* if ("18328353220".equals(patient.getCardNo())) { | |
2455 | + System.out.println(patient); | |
2456 | + }*/ | |
2457 | + service.execute(new BatchUpdateLymsPatient(patient, organizationService, mongoTemplate)); | |
2458 | + } | |
2459 | + service.shutdown(); | |
2460 | + try { | |
2461 | + service.awaitTermination(1, TimeUnit.HOURS); | |
2462 | + } catch (InterruptedException e) { | |
2463 | + e.printStackTrace(); | |
2464 | + } | |
2465 | + BaseResponse baseResponse = new BaseResponse(); | |
2466 | + baseResponse.setObject(patients.size()); | |
2467 | + return baseResponse; | |
2399 | 2468 | } |
2400 | 2469 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java
View file @
d9b8ca1
... | ... | @@ -40,6 +40,7 @@ |
40 | 40 | import org.springframework.data.mongodb.core.MongoTemplate; |
41 | 41 | import org.springframework.data.mongodb.core.query.Criteria; |
42 | 42 | import org.springframework.data.mongodb.core.query.Query; |
43 | +import org.springframework.data.mongodb.core.query.Update; | |
43 | 44 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
44 | 45 | import org.springframework.stereotype.Component; |
45 | 46 | |
... | ... | @@ -235,7 +236,7 @@ |
235 | 236 | return new BaseResponse().setErrormsg("您已分娩").setErrorcode(ErrorCodeConstants.DATA_EXIST); |
236 | 237 | } |
237 | 238 | |
238 | - if (CollectionUtils.isNotEmpty(patients2.getChildExtAddrs())) { | |
239 | + /*if (CollectionUtils.isNotEmpty(patients2.getChildExtAddrs())) { | |
239 | 240 | List<String> childExts = patients2.getChildExtAddrs(); |
240 | 241 | String extId = childExts.get(childExts.size() - 1); |
241 | 242 | PostVisitHospitalModelQuery postQuery = new PostVisitHospitalModelQuery(); |
... | ... | @@ -258,6 +259,10 @@ |
258 | 259 | String postHosptial = postVisitHospitalModel.getPostHosptial(); |
259 | 260 | maternalDeliverModel.setFsHospital(postHosptial); |
260 | 261 | } |
262 | + }*/ | |
263 | + String townOrgId = patients2.getTownOrgId(); | |
264 | + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(townOrgId)) { | |
265 | + maternalDeliverModel.setFsHospital(townOrgId); | |
261 | 266 | } |
262 | 267 | |
263 | 268 | matDeliverQuery.setDueDate(deliverAddRequest.getDueDate()); |
... | ... | @@ -3060,6 +3065,39 @@ |
3060 | 3065 | v3Val = "3"; |
3061 | 3066 | } |
3062 | 3067 | return v3Val; |
3068 | + } | |
3069 | + | |
3070 | + /** | |
3071 | + * 更新分娩记录===> where 已分娩未进行产后访视并且小于28天 | |
3072 | + * | |
3073 | + * @return | |
3074 | + */ | |
3075 | + public BaseResponse historyBatchUpdate() { | |
3076 | + List<MatdeliverFollowModel> followModels = mongoTemplate.find(Query.query(new Criteria()), MatdeliverFollowModel.class); | |
3077 | + List<String> ids = new ArrayList<>(); | |
3078 | + if (CollectionUtils.isNotEmpty(followModels)) { | |
3079 | + for (MatdeliverFollowModel followModel : followModels) { | |
3080 | + ids.add(followModel.getParentid()); | |
3081 | + } | |
3082 | + } | |
3083 | + List<MaternalDeliverModel> deliverModels = mongoTemplate.find(Query.query(Criteria.where("id").nin(ids)), MaternalDeliverModel.class); | |
3084 | + Integer updateSize = 0; | |
3085 | + for (MaternalDeliverModel model : deliverModels) { | |
3086 | + String dueDate = model.getDueDate(); | |
3087 | + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(dueDate)) { | |
3088 | + Date date = DateUtil.parseYMD(dueDate); | |
3089 | + long dateTime = date.getTime(); | |
3090 | + long currentTime = System.currentTimeMillis(); | |
3091 | + long betweenDays = (long) ((currentTime - dateTime) / (1000 * 60 * 60 * 24)); | |
3092 | + if (betweenDays <= 28) { | |
3093 | + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(model.getId())), new Update().unset("fsHospital"), MaternalDeliverModel.class); | |
3094 | + updateSize++; | |
3095 | + } | |
3096 | + } | |
3097 | + } | |
3098 | + BaseResponse baseResponse = new BaseResponse(); | |
3099 | + baseResponse.setObject("updateSize:" + updateSize + ";" + "find size:" + deliverModels.size()); | |
3100 | + return baseResponse; | |
3063 | 3101 | } |
3064 | 3102 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientServiceFacade.java
View file @
d9b8ca1
... | ... | @@ -196,11 +196,12 @@ |
196 | 196 | |
197 | 197 | List<Map> towns = new ArrayList<>(); |
198 | 198 | |
199 | - //所有数据 | |
200 | - List<BasicConfig> basicConfigList = basicConfigService.queryBasicConfig(basicConfigQuery); | |
199 | + //所有数据 由原来的baseConfing ==> Organization | |
200 | + OrganizationQuery organizationQuery = new OrganizationQuery(); | |
201 | + List<Organization> organizations = organizationService.queryOrganization(organizationQuery); | |
201 | 202 | |
202 | - if (CollectionUtils.isNotEmpty(basicConfigList)) { | |
203 | - for (BasicConfig model : basicConfigList) { | |
203 | + if (CollectionUtils.isNotEmpty(organizations)) { | |
204 | + for (Organization model : organizations) { | |
204 | 205 | Map data = new HashMap(); |
205 | 206 | data.put("id", model.getId()); |
206 | 207 | data.put("name", model.getName()); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/BatchUpdateLymsPatient.java
View file @
d9b8ca1
1 | +package com.lyms.platform.operate.web.worker; | |
2 | + | |
3 | +import com.lyms.platform.common.utils.StringUtils; | |
4 | +import com.lyms.platform.permission.service.OrganizationService; | |
5 | +import com.lyms.platform.pojo.Patients; | |
6 | +import org.apache.commons.collections.CollectionUtils; | |
7 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
8 | +import org.springframework.data.mongodb.core.query.Criteria; | |
9 | +import org.springframework.data.mongodb.core.query.Query; | |
10 | +import org.springframework.data.mongodb.core.query.Update; | |
11 | + | |
12 | +import java.util.List; | |
13 | +import java.util.Map; | |
14 | +import java.util.regex.Pattern; | |
15 | + | |
16 | +/** | |
17 | + * | |
18 | + * @Author dongqin | |
19 | + * @Description | |
20 | + * @Date 11:41 2019/6/18 | |
21 | + */ | |
22 | + | |
23 | +public class BatchUpdateLymsPatient implements Runnable { | |
24 | + private Patients patient; | |
25 | + private OrganizationService organizationService; | |
26 | + private MongoTemplate mongoTemplate; | |
27 | + public static final String NUMBER_PATTERN = "^[-\\+]?[\\d]*$"; | |
28 | + | |
29 | + public BatchUpdateLymsPatient(final Patients patient, final OrganizationService organizationService, final MongoTemplate mongoTemplate) { | |
30 | + this.patient = patient; | |
31 | + this.organizationService = organizationService; | |
32 | + this.mongoTemplate = mongoTemplate; | |
33 | + } | |
34 | + | |
35 | + @Override | |
36 | + public void run() { | |
37 | + String townOrgId = patient.getTownOrgId(); | |
38 | + if (StringUtils.isNotEmpty(townOrgId)) { | |
39 | + Pattern pattern = Pattern.compile(NUMBER_PATTERN); | |
40 | + boolean isInteger = pattern.matcher(townOrgId).matches(); | |
41 | + if (!isInteger) { | |
42 | + List<Map<String, Object>> ids = organizationService.findIdByTownOrgId(townOrgId); | |
43 | + if (CollectionUtils.isNotEmpty(ids)) { | |
44 | + patient.setTownOrgId(ids.get(0).get("id").toString()); | |
45 | + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(patient.getId())), Update.update("townOrgId", patient.getTownOrgId()), Patients.class); | |
46 | + }else { | |
47 | + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(patient.getId())), new Update().unset("townOrgId"), Patients.class); | |
48 | + } | |
49 | + } | |
50 | + } | |
51 | + } | |
52 | +} |