Commit 2d90526d3c14f57c4e751b04fdf5c4322623c182
1 parent
8b8dfb45cd
Exists in
master
and in
6 other branches
复查管理
Showing 5 changed files with 101 additions and 12 deletions
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PostReviewController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IBaseService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IPostReviewService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BaseServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PostReviewServiceImpl.java
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PostReviewController.java
View file @
2d90526
| ... | ... | @@ -119,14 +119,18 @@ |
| 119 | 119 | * 复查管理 |
| 120 | 120 | * @param startDate |
| 121 | 121 | * @param endDate |
| 122 | - * @param doctorName | |
| 122 | + * @param doctorId | |
| 123 | 123 | * @param key 姓名/联系方式/就诊卡 |
| 124 | + * @param limit | |
| 125 | + * @param page | |
| 124 | 126 | * @return |
| 125 | 127 | */ |
| 126 | 128 | @RequestMapping(method = RequestMethod.GET, value = "/postpartum/review") |
| 127 | - public BaseObjectResponse postpartumReview(Date startDate, Date endDate, String doctorName, String key | |
| 128 | - ,Integer page, Integer limit) { | |
| 129 | - return postReviewService.postpartumReview(startDate, endDate, doctorName, key); | |
| 129 | + @TokenRequired | |
| 130 | + @ResponseBody | |
| 131 | + public BaseObjectResponse postpartumReview(Date startDate, Date endDate, String doctorId, | |
| 132 | + String key, Integer page, Integer limit, HttpServletRequest request) { | |
| 133 | + return postReviewService.postpartumReview(getUserId(request), startDate, endDate, doctorId, key, page, limit); | |
| 130 | 134 | } |
| 131 | 135 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IBaseService.java
View file @
2d90526
| ... | ... | @@ -2,6 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | import com.lyms.platform.common.result.PageResult; |
| 4 | 4 | |
| 5 | +import org.springframework.data.mongodb.core.query.Query; | |
| 6 | + | |
| 5 | 7 | import java.util.List; |
| 6 | 8 | |
| 7 | 9 | /** |
| ... | ... | @@ -18,6 +20,8 @@ |
| 18 | 20 | * @param params |
| 19 | 21 | * @return |
| 20 | 22 | */ |
| 21 | - public PageResult findPage(String sql, Integer currentPage, Integer pageSize, List<Object> params); | |
| 23 | + PageResult findPage(String sql, Integer currentPage, Integer pageSize, List<Object> params); | |
| 24 | + | |
| 25 | + <T> PageResult findMongoPage (Class<T> entity, Query query, Integer page, Integer limit); | |
| 22 | 26 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IPostReviewService.java
View file @
2d90526
| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | /** |
| 8 | 8 | * Created by litao on 2017/7/3 0003 |
| 9 | 9 | */ |
| 10 | -public interface IPostReviewService { | |
| 11 | - BaseObjectResponse postpartumReview(Date startDate, Date endDate, String doctorName, String key); | |
| 10 | +public interface IPostReviewService extends IBaseService { | |
| 11 | + BaseObjectResponse postpartumReview(Integer userId, Date startDate, Date endDate, String doctorId, String key, Integer page, Integer limit); | |
| 12 | 12 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BaseServiceImpl.java
View file @
2d90526
| ... | ... | @@ -5,8 +5,9 @@ |
| 5 | 5 | import com.lyms.platform.operate.web.service.IBaseService; |
| 6 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | 7 | import org.springframework.beans.factory.annotation.Qualifier; |
| 8 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
| 8 | 9 | import org.springframework.stereotype.Service; |
| 9 | - | |
| 10 | +import org.springframework.data.mongodb.core.query.Query; | |
| 10 | 11 | import java.util.List; |
| 11 | 12 | import java.util.Map; |
| 12 | 13 | |
| ... | ... | @@ -21,6 +22,9 @@ |
| 21 | 22 | @Qualifier("baseDaoImpl") |
| 22 | 23 | private IBaseDao baseDao; |
| 23 | 24 | |
| 25 | + @Autowired | |
| 26 | + private MongoTemplate mongoTemplate; | |
| 27 | + | |
| 24 | 28 | @Override |
| 25 | 29 | public PageResult findPage(String sql, Integer currentPage, Integer pageSize, List<Object> params) { |
| 26 | 30 | pageSize = pageSize == null ? 10 : pageSize; |
| ... | ... | @@ -29,6 +33,15 @@ |
| 29 | 33 | Integer count = baseDao.findCount(sql, params); |
| 30 | 34 | List<Map<String, Object>> rows = baseDao.findList(sql, currentPage, pageSize, params); |
| 31 | 35 | return new PageResult(count, currentPage, pageSize, rows); |
| 36 | + } | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + public <T> PageResult findMongoPage(Class<T> entity, Query query, Integer page, Integer limit) { | |
| 40 | + Long count = mongoTemplate.count(query, entity); | |
| 41 | + query.skip((page - 1) * limit); | |
| 42 | + query.limit(limit); | |
| 43 | + List<T> rows = mongoTemplate.find(query, entity); | |
| 44 | + return new PageResult(count.intValue(), page, limit, rows); | |
| 32 | 45 | } |
| 33 | 46 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PostReviewServiceImpl.java
View file @
2d90526
| 1 | 1 | package com.lyms.platform.operate.web.service.impl; |
| 2 | 2 | |
| 3 | 3 | import com.lyms.platform.common.result.BaseObjectResponse; |
| 4 | +import com.lyms.platform.common.result.PageResult; | |
| 4 | 5 | import com.lyms.platform.common.result.RespBuilder; |
| 6 | +import com.lyms.platform.common.utils.DateUtil; | |
| 7 | +import com.lyms.platform.common.utils.StringUtils; | |
| 8 | +import com.lyms.platform.operate.web.facade.AutoMatchFacade; | |
| 5 | 9 | import com.lyms.platform.operate.web.service.IPostReviewService; |
| 10 | +import com.lyms.platform.operate.web.utils.MongoUtil; | |
| 11 | +import com.lyms.platform.permission.dao.master.MasterUsersMapper; | |
| 12 | +import com.lyms.platform.permission.model.Users; | |
| 13 | +import com.lyms.platform.pojo.Patients; | |
| 6 | 14 | import com.lyms.platform.pojo.PostReviewModel; |
| 15 | +import org.apache.commons.collections.CollectionUtils; | |
| 7 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | +import org.springframework.data.domain.Sort; | |
| 8 | 18 | import org.springframework.data.mongodb.core.MongoTemplate; |
| 9 | 19 | import org.springframework.data.mongodb.core.query.Criteria; |
| 10 | 20 | import org.springframework.data.mongodb.core.query.Query; |
| 11 | 21 | import org.springframework.stereotype.Service; |
| 12 | 22 | |
| 13 | -import java.util.Date; | |
| 23 | +import java.util.*; | |
| 14 | 24 | |
| 15 | 25 | /** |
| 16 | 26 | * Created by litao on 2017/7/3 0003 |
| 17 | 27 | */ |
| 18 | 28 | @Service |
| 19 | -public class PostReviewServiceImpl implements IPostReviewService { | |
| 29 | +public class PostReviewServiceImpl extends BaseServiceImpl implements IPostReviewService { | |
| 20 | 30 | |
| 21 | 31 | @Autowired |
| 22 | 32 | private MongoTemplate mongoTemplate; |
| 23 | 33 | |
| 34 | + @Autowired | |
| 35 | + private AutoMatchFacade autoMatchFacade; | |
| 36 | + | |
| 37 | + @Autowired | |
| 38 | + private MasterUsersMapper usersMapper; | |
| 39 | + | |
| 40 | + @Autowired | |
| 41 | + private MongoUtil mongoUtil; | |
| 42 | + | |
| 24 | 43 | @Override |
| 25 | - public BaseObjectResponse postpartumReview(Date startDate, Date endDate, String doctorName, String key) { | |
| 26 | - return RespBuilder.buildSuccess(mongoTemplate.findOne(Query.query(Criteria.where("id").is("57c7e2fb28b66ec7a1bef00b")), PostReviewModel.class)); | |
| 44 | + public BaseObjectResponse postpartumReview(Integer userId, Date startDate, Date endDate, String doctorId, String key, Integer page, Integer limit) { | |
| 45 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 46 | + Query query = Query.query(Criteria.where("hospitalId").is(hospitalId).and("yn").is(1)); | |
| 47 | + if(startDate != null && endDate != null) { | |
| 48 | + query.addCriteria(Criteria.where("checkTime").gte(startDate).lt(DateUtil.addDay(endDate, 1))); | |
| 49 | + } | |
| 50 | + if(StringUtils.isNotEmpty(doctorId)) { | |
| 51 | + query.addCriteria(Criteria.where("prodDoctor").is(doctorId)); | |
| 52 | + } | |
| 53 | + | |
| 54 | + if(StringUtils.isNotEmpty(key)) { | |
| 55 | + Criteria criteria = new Criteria(); | |
| 56 | + criteria.orOperator(Criteria.where("username").is(key), Criteria.where("vcCardNo").is(key), Criteria.where("phone").is(key)); | |
| 57 | + List<Patients> patients = mongoUtil.findField(Patients.class, criteria, "id"); | |
| 58 | + if(CollectionUtils.isEmpty(patients)) { | |
| 59 | + return RespBuilder.buildSuccess(new PageResult(0, page, limit, null)); | |
| 60 | + } | |
| 61 | + List<String> ids = new ArrayList<>(); | |
| 62 | + for (Patients patient : patients) { | |
| 63 | + ids.add(patient.getId()); | |
| 64 | + } | |
| 65 | + query.addCriteria(Criteria.where("parentId").in(ids)); | |
| 66 | + } | |
| 67 | + | |
| 68 | + PageResult pageResult = findMongoPage(PostReviewModel.class, query, page, limit); | |
| 69 | + List<PostReviewModel> grid = (List<PostReviewModel>) pageResult.getGrid(); | |
| 70 | + | |
| 71 | + List<Map<String, Object>> rest = new ArrayList<>(); | |
| 72 | + for (PostReviewModel model : grid) { | |
| 73 | + Map<String, Object> tempMap = new HashMap<>(); | |
| 74 | + Patients p = mongoTemplate.findById(model.getParentId(), Patients.class); | |
| 75 | + tempMap.put("checkTime", model.getCheckTime()); /** 复查日期 */ | |
| 76 | + tempMap.put("hcertificateNum", p == null ? null : p.getHcertificateNum()); /** 证件号 */ | |
| 77 | + tempMap.put("username", p == null ? null : p.getUsername()); /** 姓名 */ | |
| 78 | + tempMap.put("age", p == null ? null : DateUtil.getAge(p.getBirth())); /** 年龄 */ | |
| 79 | + tempMap.put("day", p == null ? null : model.getDay()); /** 产后天数 */ | |
| 80 | + tempMap.put("reviewCount", mongoTemplate.count(Query.query(Criteria.where("parentId").is(model.getParentId())), PostReviewModel.class)); /** 复查次数 */ | |
| 81 | + tempMap.put("reviewHospitalCount", mongoTemplate.count(Query.query(Criteria.where("parentId").is(model.getParentId()) | |
| 82 | + .and("hospitalId").is(model.getHospitalId())), PostReviewModel.class)); /** 本院复查次数 */ | |
| 83 | + String prodDoctor = model.getProdDoctor(); | |
| 84 | + if(StringUtils.isNotEmpty(prodDoctor)) { | |
| 85 | + Users users = usersMapper.getUsers(Integer.parseInt(prodDoctor)); | |
| 86 | + tempMap.put("doctorName", users == null ? null : users.getName()); /** 检查医生 */ | |
| 87 | + } else { | |
| 88 | + tempMap.put("doctorName", null); | |
| 89 | + } | |
| 90 | + tempMap.put("phone", p == null ? null : p.getPhone()); | |
| 91 | + rest.add(tempMap); | |
| 92 | + } | |
| 93 | + pageResult.setGrid(rest); | |
| 94 | + return RespBuilder.buildSuccess(pageResult); | |
| 27 | 95 | } |
| 28 | 96 | } |