Commit 9a75391dffadb98209da0d939e36888369af83d2

Authored by liquanyu
1 parent 49c2a3f028

update

Showing 5 changed files with 442 additions and 8 deletions

platform-dal/src/main/java/com/lyms/platform/pojo/PostkfModel.java View file @ 9a75391
... ... @@ -8,6 +8,7 @@
8 8 import java.util.Map;
9 9  
10 10 /**
  11 + * 产后康复评估记录
11 12 * Created by Administrator on 2021-05-18.
12 13 */
13 14 @Document(collection = "lyms_postkf")
platform-dal/src/main/java/com/lyms/platform/pojo/PostkfPgModel.java View file @ 9a75391
  1 +package com.lyms.platform.pojo;
  2 +
  3 +import com.lyms.platform.common.result.BaseModel;
  4 +import org.springframework.data.mongodb.core.mapping.Document;
  5 +
  6 +import java.util.Date;
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +
  10 +/**
  11 + * 产后康复上一评估的医生和这次医生的对比不一样的记录
  12 + *
  13 + * Created by Administrator on 2021-05-18.
  14 + */
  15 +@Document(collection = "lyms_postkfpg")
  16 +public class PostkfPgModel extends BaseModel {
  17 + private String id;
  18 + //PostkfModel的主键
  19 + private String pgId;
  20 + //分娩id
  21 + private String mid;
  22 + private String pid;
  23 + private String patientId;
  24 + private String upDoctorId;//上一次医生
  25 + private String currentDoctorId;//本次医生
  26 + private String hospitalId;
  27 + private Date created;
  28 +
  29 + public String getId() {
  30 + return id;
  31 + }
  32 +
  33 + public void setId(String id) {
  34 + this.id = id;
  35 + }
  36 +
  37 + public String getMid() {
  38 + return mid;
  39 + }
  40 +
  41 + public void setMid(String mid) {
  42 + this.mid = mid;
  43 + }
  44 +
  45 + public String getPid() {
  46 + return pid;
  47 + }
  48 +
  49 + public void setPid(String pid) {
  50 + this.pid = pid;
  51 + }
  52 +
  53 + public String getPatientId() {
  54 + return patientId;
  55 + }
  56 +
  57 + public void setPatientId(String patientId) {
  58 + this.patientId = patientId;
  59 + }
  60 +
  61 + public String getPgId() {
  62 + return pgId;
  63 + }
  64 +
  65 + public void setPgId(String pgId) {
  66 + this.pgId = pgId;
  67 + }
  68 +
  69 + public String getUpDoctorId() {
  70 + return upDoctorId;
  71 + }
  72 +
  73 + public void setUpDoctorId(String upDoctorId) {
  74 + this.upDoctorId = upDoctorId;
  75 + }
  76 +
  77 + public String getCurrentDoctorId() {
  78 + return currentDoctorId;
  79 + }
  80 +
  81 + public void setCurrentDoctorId(String currentDoctorId) {
  82 + this.currentDoctorId = currentDoctorId;
  83 + }
  84 +
  85 + public String getHospitalId() {
  86 + return hospitalId;
  87 + }
  88 +
  89 + public void setHospitalId(String hospitalId) {
  90 + this.hospitalId = hospitalId;
  91 + }
  92 +
  93 + public Date getCreated() {
  94 + return created;
  95 + }
  96 +
  97 + public void setCreated(Date created) {
  98 + this.created = created;
  99 + }
  100 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PostkfController.java View file @ 9a75391
... ... @@ -4,6 +4,7 @@
4 4 import com.lyms.platform.common.base.BaseController;
5 5 import com.lyms.platform.common.result.BaseResponse;
6 6 import com.lyms.platform.operate.web.facade.PostkfFaccade;
  7 +import com.lyms.platform.operate.web.request.PostKfRequest;
7 8 import com.lyms.platform.pojo.BabyAssessModel;
8 9 import com.lyms.platform.pojo.PostkfModel;
9 10 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -50,6 +51,20 @@
50 51  
51 52  
52 53 /**
  54 + * 产后康复列表
  55 + * @param request
  56 + * @param postKfRequest
  57 + * @return
  58 + */
  59 + @TokenRequired
  60 + @ResponseBody
  61 + @RequestMapping(value = "/getPostKfList", method = RequestMethod.POST)
  62 + public BaseResponse getPostKfList(HttpServletRequest request,@RequestBody PostKfRequest postKfRequest) {
  63 + return postkfFaccade.getPostKfList(postKfRequest, getUserId(request));
  64 + }
  65 +
  66 +
  67 + /**
53 68 * 添加儿童评估表
54 69 * @param request
55 70 * @param babyAssessModel
... ... @@ -74,6 +89,19 @@
74 89 @RequestMapping(value = "/getBabyAssess", method = RequestMethod.GET)
75 90 public BaseResponse getBabyAssess(HttpServletRequest request,@RequestParam(required = true) String babyId) {
76 91 return postkfFaccade.getBabyAssess(babyId, getUserId(request));
  92 + }
  93 +
  94 +
  95 + /**
  96 + * 产后康复上一评估的医生和这次医生的对比不一样的记录
  97 + * @param request
  98 + * @return
  99 + */
  100 + @TokenRequired
  101 + @ResponseBody
  102 + @RequestMapping(value = "/getPostPgRecord", method = RequestMethod.GET)
  103 + public BaseResponse getPostPgRecord(HttpServletRequest request,@RequestParam(required = true) Integer page,@RequestParam(required = true) Integer limit) {
  104 + return postkfFaccade.getPostPgRecord(getUserId(request),page,limit);
77 105 }
78 106 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PostkfFaccade.java View file @ 9a75391
1 1 package com.lyms.platform.operate.web.facade;
2 2  
  3 +import com.lyms.platform.biz.service.BabyService;
3 4 import com.lyms.platform.biz.service.MatDeliverService;
  5 +import com.lyms.platform.biz.service.PatientsService;
4 6 import com.lyms.platform.common.constants.ErrorCodeConstants;
  7 +import com.lyms.platform.common.dao.BaseQuery;
  8 +import com.lyms.platform.common.enums.CfEnums;
  9 +import com.lyms.platform.common.enums.FmTypeEnums;
  10 +import com.lyms.platform.common.enums.RenShenJieJuEnums;
5 11 import com.lyms.platform.common.enums.YnEnums;
  12 +import com.lyms.platform.common.result.BaseListResponse;
6 13 import com.lyms.platform.common.result.BaseObjectResponse;
7 14 import com.lyms.platform.common.result.BaseResponse;
8   -import com.lyms.platform.common.utils.MongoConvertHelper;
9   -import com.lyms.platform.common.utils.ReflectionUtils;
10   -import com.lyms.platform.common.utils.StringUtils;
11   -import com.lyms.platform.pojo.BabyAssessModel;
12   -import com.lyms.platform.pojo.MaternalDeliverModel;
13   -import com.lyms.platform.pojo.PostkfModel;
  15 +import com.lyms.platform.common.utils.*;
  16 +import com.lyms.platform.operate.web.request.PostKfRequest;
  17 +import com.lyms.platform.operate.web.result.ChildbirthManagerQueryModel;
  18 +import com.lyms.platform.operate.web.result.DefectiveChildModelResult;
  19 +import com.lyms.platform.operate.web.worker.MaterDeliverWorker;
  20 +import com.lyms.platform.permission.service.UsersService;
  21 +import com.lyms.platform.pojo.*;
  22 +import com.lyms.platform.query.BabyModelQuery;
14 23 import com.lyms.platform.query.MatDeliverQuery;
  24 +import com.lyms.platform.query.PatientsQuery;
15 25 import org.apache.commons.collections.CollectionUtils;
  26 +import org.apache.commons.collections.MapUtils;
16 27 import org.springframework.beans.factory.annotation.Autowired;
  28 +import org.springframework.beans.factory.annotation.Qualifier;
  29 +import org.springframework.data.domain.Sort;
17 30 import org.springframework.data.mongodb.core.MongoTemplate;
18 31 import org.springframework.data.mongodb.core.query.Criteria;
19 32 import org.springframework.data.mongodb.core.query.Query;
20 33 import org.springframework.data.mongodb.core.query.Update;
  34 +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
21 35 import org.springframework.stereotype.Component;
22 36  
23   -import java.util.Date;
24   -import java.util.List;
  37 +import java.util.*;
  38 +import java.util.concurrent.Callable;
  39 +import java.util.concurrent.Future;
25 40  
26 41 /**
27 42 * Created by Administrator on 2021-05-18.
... ... @@ -30,6 +45,16 @@
30 45 public class PostkfFaccade {
31 46  
32 47 @Autowired
  48 + @Qualifier("commonThreadPool")
  49 + private ThreadPoolTaskExecutor commonThreadPool;
  50 +
  51 + @Autowired
  52 + private PatientsService patientsService;
  53 + @Autowired
  54 + private BabyService babyService;
  55 + @Autowired
  56 + private UsersService usersService;
  57 + @Autowired
33 58 private MongoTemplate mongoTemplate;
34 59 @Autowired
35 60 private AutoMatchFacade autoMatchFacade;
... ... @@ -98,6 +123,214 @@
98 123 is(babyId)), BabyAssessModel.class);
99 124 return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(CollectionUtils.isNotEmpty(babyAssessModels)
100 125 ? babyAssessModels.get(0) : null);
  126 + }
  127 +
  128 + public BaseResponse getPostKfList(PostKfRequest postKfRequest, Integer userId) {
  129 +
  130 +
  131 + String hospitalId = autoMatchFacade.getHospitalId(userId);
  132 + Query query = new Query();
  133 + Integer status = postKfRequest.getStatus();
  134 + if (status != null) {
  135 + query.addCriteria(Criteria.where("status").in(status));
  136 + }
  137 + if (StringUtils.isNotEmpty(postKfRequest.getItem()) && StringUtils.isNotEmpty(postKfRequest.getType()) && postKfRequest.getResult() != null)
  138 + {
  139 + query.addCriteria(Criteria.where(postKfRequest.getItem()+"."+postKfRequest.getType()).is(String.valueOf(postKfRequest.getResult())));
  140 + if (StringUtils.isNotEmpty(postKfRequest.getDoctorId()))
  141 + {
  142 + query.addCriteria(Criteria.where(postKfRequest.getItem()+"."+postKfRequest.getType()+"doctor").is(postKfRequest.getDoctorId()));
  143 + }
  144 + }
  145 +
  146 + if (StringUtils.isNotEmpty(postKfRequest.getQueryNo()))
  147 + {
  148 + PatientsQuery query1 = new PatientsQuery();
  149 + query1.setQueryNo(postKfRequest.getQueryNo());
  150 + List<Patients> patientses = patientsService.queryPatient(query1);
  151 + if (CollectionUtils.isNotEmpty(patientses))
  152 + {
  153 + List<String> patientIds = new ArrayList<>();
  154 + for (Patients pat : patientses)
  155 + {
  156 + patientIds.add(pat.getId());
  157 + }
  158 + query.addCriteria(Criteria.where("patientId").in(patientIds));
  159 + }
  160 + }
  161 +
  162 + query.addCriteria(Criteria.where("hospitalId").is(hospitalId));
  163 +
  164 + query.with(new Sort(Sort.Direction.DESC, "created"));
  165 + long count = mongoTemplate.count(query, DefectiveChildModel.class);
  166 + postKfRequest.mysqlBuild((int) count);
  167 + query.skip(postKfRequest.getOffset()).limit(postKfRequest.getLimit());
  168 + List<ChildbirthManagerQueryModel> datas = new LinkedList<>();
  169 +
  170 + List<PostkfModel> models = mongoTemplate.find(query, PostkfModel.class);
  171 +
  172 + int batchSize = 5;
  173 + int end = 0;
  174 + List <Future> futures = new ArrayList <>();
  175 + for (int i = 0; i < models.size(); i += batchSize) {
  176 + end = (end + batchSize);
  177 + if (end > models.size()) {
  178 + end = models.size();
  179 + }
  180 + final List <PostkfModel> postkfModels = models.subList(i, end);
  181 + Future f = commonThreadPool.submit(new Callable() {
  182 + @Override
  183 + public Object call() throws Exception {
  184 + List<ChildbirthManagerQueryModel> results = new LinkedList<ChildbirthManagerQueryModel>();
  185 + if (CollectionUtils.isNotEmpty(postkfModels))
  186 + {
  187 + for (PostkfModel model : postkfModels){
  188 + ChildbirthManagerQueryModel childbirthManagerQueryModel = new ChildbirthManagerQueryModel();
  189 +
  190 + MatDeliverQuery matDeliverQuery = new MatDeliverQuery();
  191 + matDeliverQuery.setId(model.getMid());
  192 + matDeliverQuery.setYn(YnEnums.YES.getId());
  193 + List<MaternalDeliverModel> list2 = matDeliverService.query(matDeliverQuery);
  194 + if (CollectionUtils.isNotEmpty(list2))
  195 + {
  196 + MaternalDeliverModel maternalDeliverModel = list2.get(0);
  197 +
  198 + Patients patients = patientsService.findOnePatientById(maternalDeliverModel.getParentId());
  199 + if (patients == null)
  200 + {
  201 + continue;
  202 + }
  203 +
  204 + childbirthManagerQueryModel.setPid(patients.getPid());
  205 + childbirthManagerQueryModel.setPatientId(patients.getId());
  206 + childbirthManagerQueryModel.setMaternalDeliverId(maternalDeliverModel.getId());
  207 + childbirthManagerQueryModel.setTireNumber(maternalDeliverModel.getTireNumber());
  208 +
  209 + // 分娩日期
  210 + childbirthManagerQueryModel.setDueDate(DateUtil.getyyyy_MM_dd(maternalDeliverModel.getDueDate1()));
  211 + childbirthManagerQueryModel.setAge(DateUtil.getAge(patients.getBirth()));
  212 + // name
  213 + childbirthManagerQueryModel.setName(patients.getUsername());
  214 + childbirthManagerQueryModel.setCardNo(patients.getCardNo());
  215 +
  216 + String week = (patients.getFmWeek() / 7) + "";
  217 + int day = (patients.getFmWeek() % 7);
  218 + childbirthManagerQueryModel.setDueWeek("孕" + week + "周" + (day > 0 ? "+" + day + "天" : ""));
  219 +
  220 + String handDueWeek = "";
  221 + Map<String, Object> handDueWeekMap = maternalDeliverModel.getHandDueWeek();
  222 + if (handDueWeekMap != null && handDueWeekMap.size() > 0 && handDueWeekMap.get("week") != null && StringUtils.isNotEmpty(String.valueOf(handDueWeekMap.get("week"))))
  223 + {
  224 + handDueWeek = "孕"+String.valueOf(handDueWeekMap.get("week"))+"周"+((handDueWeekMap.get("day") == null
  225 + || String.valueOf(handDueWeekMap.get("day")).equals("0") || String.valueOf(handDueWeekMap.get("day")).equals("")) ? "" : "+"+String.valueOf(handDueWeekMap.get("day"))+"天" );
  226 + }
  227 + childbirthManagerQueryModel.setHandDueWeek(handDueWeek);
  228 +
  229 + String deliveryModeJson = maternalDeliverModel.getDeliveryMode();
  230 + Map<String, String> deliveryModeMap = JsonUtil.getMap(deliveryModeJson);
  231 + if (MapUtils.isNotEmpty(deliveryModeMap) && org.apache.commons.lang.StringUtils.isNotEmpty(deliveryModeMap.get("fmfs"))) {
  232 + for (FmTypeEnums fmTypeEnums : FmTypeEnums.values()) {
  233 + if (fmTypeEnums.getId().equals(deliveryModeMap.get("fmfs"))) {
  234 + childbirthManagerQueryModel.setDeliveryMode(fmTypeEnums.getName());
  235 + break;
  236 + }
  237 + }
  238 + if(deliveryModeMap.get("scfs") != null){
  239 + String scfs = deliveryModeMap.get("scfs").toString();
  240 + childbirthManagerQueryModel.setDeliveryMode1(FmTypeEnums.getFmScNameById(scfs));
  241 + }
  242 + } else {
  243 + childbirthManagerQueryModel.setDeliveryMode("");
  244 + }
  245 +
  246 + childbirthManagerQueryModel.setRhloseBloodL(maternalDeliverModel.getrHloseBloodL());
  247 +
  248 + if (org.apache.commons.lang.StringUtils.isNotBlank(maternalDeliverModel.getMaternalInfo())) {
  249 + for (CfEnums cfEnums : CfEnums.values()) {
  250 + if (cfEnums.getId().equals(maternalDeliverModel.getMaternalInfo())) {
  251 + childbirthManagerQueryModel.setMaternalInfo(cfEnums.getName());
  252 + break;
  253 + }
  254 + }
  255 + }
  256 +
  257 + BabyModelQuery babyModelQuery = new BabyModelQuery();
  258 + babyModelQuery.setParentId(patients.getId());
  259 + babyModelQuery.setDataStatus(false);
  260 + babyModelQuery.setPregnancyOut(RenShenJieJuEnums.O.getId());
  261 + List<BabyModel> babyModelList = babyService.queryBabyWithQuery(babyModelQuery);
  262 + if (CollectionUtils.isNotEmpty(babyModelList)) {
  263 + childbirthManagerQueryModel.setLivingNumber(babyModelList.size());
  264 + } else {
  265 + if (childbirthManagerQueryModel.getTireNumber() == null) {
  266 + childbirthManagerQueryModel.setLivingNumber(null);
  267 + } else {
  268 + childbirthManagerQueryModel.setLivingNumber(0);
  269 + }
  270 + }
  271 + childbirthManagerQueryModel.setDeliverDoctor(usersService.getUsers(Integer.valueOf(maternalDeliverModel.getDeliverDoctor())).getName());
  272 + childbirthManagerQueryModel.setPhone(patients.getPhone());
  273 + }
  274 +
  275 + results.add(childbirthManagerQueryModel);
  276 + }
  277 + }
  278 + return results;
  279 + }
  280 + });
  281 + if (f != null) {
  282 + futures.add(f);
  283 + }
  284 + }
  285 +
  286 + if (CollectionUtils.isNotEmpty(futures)) {
  287 + for (Future f : futures) {
  288 + try {
  289 + datas.addAll((List<ChildbirthManagerQueryModel>) f.get());
  290 + } catch (Exception e) {
  291 + ExceptionUtils.catchException(e, "fm list error.");
  292 + }
  293 + }
  294 + }
  295 + BaseListResponse baseListResponse = new BaseListResponse();
  296 + baseListResponse.setData(datas);
  297 + baseListResponse.setPageInfo(postKfRequest.getPageInfo());
  298 + return baseListResponse;
  299 + }
  300 +
  301 + public BaseResponse getPostPgRecord(Integer userId,Integer page,Integer limit) {
  302 + String hospitalId = autoMatchFacade.getHospitalId(userId);
  303 + Query query = new Query();
  304 + BaseQuery baseQuery = new BaseQuery();
  305 + baseQuery.setPage(page);
  306 + baseQuery.setLimit(limit);
  307 + query.addCriteria(Criteria.where("hospitalId").is(hospitalId));
  308 + query.addCriteria(Criteria.where("upDoctorId").is(String.valueOf(userId)));
  309 +
  310 + query.with(new Sort(Sort.Direction.DESC, "created"));
  311 + long count = mongoTemplate.count(query, DefectiveChildModel.class);
  312 + baseQuery.mysqlBuild((int) count);
  313 + query.skip(baseQuery.getOffset()).limit(limit);
  314 + List<Map> datas = new LinkedList<>();
  315 +
  316 + List<PostkfPgModel> models = mongoTemplate.find(query, PostkfPgModel.class);
  317 + if (CollectionUtils.isNotEmpty(models))
  318 + {
  319 + for (PostkfPgModel model : models)
  320 + {
  321 + Map data = new HashMap();
  322 + data.put("created",DateUtil.getyyyy_MM_dd(model.getCreated()));
  323 + data.put("mid",model.getMid());
  324 + data.put("upDoctor",usersService.getUsers(Integer.valueOf(model.getUpDoctorId())).getName());
  325 + data.put("currentDoctor",usersService.getUsers(Integer.valueOf(model.getCurrentDoctorId())).getName());
  326 + data.put("id",model.getId());
  327 + datas.add(data);
  328 + }
  329 + }
  330 + BaseListResponse baseListResponse = new BaseListResponse();
  331 + baseListResponse.setData(datas);
  332 + baseListResponse.setPageInfo(baseQuery.getPageInfo());
  333 + return baseListResponse;
101 334 }
102 335 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/PostKfRequest.java View file @ 9a75391
  1 +package com.lyms.platform.operate.web.request;
  2 +
  3 +import com.lyms.platform.common.dao.BaseQuery;
  4 +
  5 +/**
  6 + * Created by Administrator on 2021-05-20.
  7 + */
  8 +public class PostKfRequest extends BaseQuery {
  9 +
  10 + private String doctorId;
  11 + //产后复查评估 状态 1 出院前评估 2 产后7天评估 3 产后14天评估 4 产后28天评估 5 产后42天评估
  12 + private Integer status;
  13 +
  14 + //评估项目
  15 + private String item;
  16 +
  17 + //评估类型
  18 + private String type;
  19 +
  20 + //评估的结果
  21 + private Integer result;
  22 +
  23 + private String queryNo;
  24 +
  25 + public String getDoctorId() {
  26 + return doctorId;
  27 + }
  28 +
  29 + public void setDoctorId(String doctorId) {
  30 + this.doctorId = doctorId;
  31 + }
  32 +
  33 + public Integer getStatus() {
  34 + return status;
  35 + }
  36 +
  37 + public void setStatus(Integer status) {
  38 + this.status = status;
  39 + }
  40 +
  41 + public String getItem() {
  42 + return item;
  43 + }
  44 +
  45 + public void setItem(String item) {
  46 + this.item = item;
  47 + }
  48 +
  49 + public String getType() {
  50 + return type;
  51 + }
  52 +
  53 + public void setType(String type) {
  54 + this.type = type;
  55 + }
  56 +
  57 + public Integer getResult() {
  58 + return result;
  59 + }
  60 +
  61 + public void setResult(Integer result) {
  62 + this.result = result;
  63 + }
  64 +
  65 + public String getQueryNo() {
  66 + return queryNo;
  67 + }
  68 +
  69 + public void setQueryNo(String queryNo) {
  70 + this.queryNo = queryNo;
  71 + }
  72 +}