Commit 3464e02990c6e622338384f06a3f90b4f2fed413

Authored by liquanyu
1 parent 48e3ed3ea0

update

Showing 5 changed files with 186 additions and 0 deletions

platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java View file @ 3464e02
... ... @@ -27,6 +27,7 @@
27 27 BabyFirstCheckModel("BabyHighRiskBabyModel", -6200631186554568668L),
28 28 BabyStuntingModel("BabyStuntingModel", 6185807286762682531L),
29 29 BabyModel("BabyModel", 97531000080L),
  30 + BabyRecordModel("BabyModel", 97531050080L),
30 31 Records("records", 97531000081L),
31 32 Baby("Baby", 97531000081L),
32 33 Microelement("Microelement", 97531020081L),
platform-dal/src/main/java/com/lyms/platform/pojo/BabyRecordModel.java View file @ 3464e02
  1 +package com.lyms.platform.pojo;
  2 +
  3 +import com.lyms.platform.beans.SerialIdEnum;
  4 +import com.lyms.platform.common.result.BaseModel;
  5 +import org.springframework.data.mongodb.core.mapping.Document;
  6 +
  7 +import java.util.Date;
  8 +
  9 +/**
  10 + * Created by Administrator on 2021-01-05.
  11 + */
  12 +@Document(collection = "lyms_baby_record")
  13 +public class BabyRecordModel extends BaseModel {
  14 +
  15 + private static final long serialVersionUID = SerialIdEnum.BabyModel.getCid();
  16 + private String id;
  17 + private String doctorId;
  18 + private String hospitalId;
  19 + private Date recordTime;
  20 + private Date nextCheckTime;
  21 + private String content;
  22 + private String babyId;
  23 + private Date created;
  24 + private Date modified;
  25 +
  26 + public String getHospitalId() {
  27 + return hospitalId;
  28 + }
  29 +
  30 + public void setHospitalId(String hospitalId) {
  31 + this.hospitalId = hospitalId;
  32 + }
  33 +
  34 + public String getId() {
  35 + return id;
  36 + }
  37 +
  38 + public void setId(String id) {
  39 + this.id = id;
  40 + }
  41 +
  42 + public String getDoctorId() {
  43 + return doctorId;
  44 + }
  45 +
  46 + public void setDoctorId(String doctorId) {
  47 + this.doctorId = doctorId;
  48 + }
  49 +
  50 + public Date getRecordTime() {
  51 + return recordTime;
  52 + }
  53 +
  54 + public void setRecordTime(Date recordTime) {
  55 + this.recordTime = recordTime;
  56 + }
  57 +
  58 + public Date getNextCheckTime() {
  59 + return nextCheckTime;
  60 + }
  61 +
  62 + public void setNextCheckTime(Date nextCheckTime) {
  63 + this.nextCheckTime = nextCheckTime;
  64 + }
  65 +
  66 + public String getContent() {
  67 + return content;
  68 + }
  69 +
  70 + public void setContent(String content) {
  71 + this.content = content;
  72 + }
  73 +
  74 + public String getBabyId() {
  75 + return babyId;
  76 + }
  77 +
  78 + public void setBabyId(String babyId) {
  79 + this.babyId = babyId;
  80 + }
  81 +
  82 + public Date getCreated() {
  83 + return created;
  84 + }
  85 +
  86 + public void setCreated(Date created) {
  87 + this.created = created;
  88 + }
  89 +
  90 + public Date getModified() {
  91 + return modified;
  92 + }
  93 +
  94 + public void setModified(Date modified) {
  95 + this.modified = modified;
  96 + }
  97 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyBuildController.java View file @ 3464e02
... ... @@ -874,6 +874,13 @@
874 874 }
875 875  
876 876  
  877 + @RequestMapping(method = RequestMethod.POST, value = "/addBabyRecord")
  878 + @ResponseBody
  879 + @TokenRequired
  880 + public BaseResponse addBabyRecord(@Valid @RequestBody BabyRecordRequest request, HttpServletRequest httpServletRequest) {
  881 + LoginContext loginState = (LoginContext) httpServletRequest.getAttribute("loginContext");
877 882  
  883 + return babyBookbuildingFacade.addBabyRecord(request, loginState.getId());
  884 + }
878 885 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java View file @ 3464e02
... ... @@ -35,8 +35,10 @@
35 35 import org.springframework.data.mongodb.core.MongoTemplate;
36 36 import org.springframework.data.mongodb.core.query.Criteria;
37 37 import org.springframework.data.mongodb.core.query.Query;
  38 +import org.springframework.data.mongodb.core.query.Update;
38 39 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
39 40 import org.springframework.stereotype.Component;
  41 +import org.springframework.web.bind.annotation.ResponseBody;
40 42  
41 43 import javax.servlet.http.HttpServletResponse;
42 44 import java.io.IOException;
43 45  
... ... @@ -5334,6 +5336,32 @@
5334 5336 }
5335 5337  
5336 5338  
  5339 + public BaseResponse addBabyRecord(BabyRecordRequest request, Integer userId) {
  5340 + BabyRecordModel model = new BabyRecordModel();
  5341 + model.setBabyId(request.getBabyId());
  5342 + model.setDoctorId(request.getDoctorId());
  5343 + model.setContent(request.getContent());
  5344 + model.setNextCheckTime(DateUtil.parseYMD(request.getNextCheckTime()));
5337 5345  
  5346 + if (StringUtils.isNotEmpty(request.getId()))
  5347 + {
  5348 + model.setModified(new Date());
  5349 + Query query = Query.query(Criteria.where("id").is(request.getId()));
  5350 + Update update = MongoConvertHelper
  5351 + .convertToNativeUpdate(ReflectionUtils.getUpdateField(model));
  5352 + mongoTemplate.updateFirst(query, update, BabyRecordModel.class);
  5353 + }
  5354 + else {
  5355 + model.setRecordTime(new Date());
  5356 + model.setCreated(new Date());
  5357 + model.setModified(new Date());
  5358 + model.setHospitalId(autoMatchFacade.getHospitalId(userId));
  5359 + mongoTemplate.insert(model);
  5360 + }
  5361 + BabyModel babyModelDb = babyService.getOneBabyById(request.getBabyId());
  5362 + babyModelDb.setNextCheckTime(model.getNextCheckTime());
  5363 + babyService.updateOneBaby(babyModelDb, babyModelDb.getId());
  5364 + return new BaseResponse();
  5365 + }
5338 5366 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyRecordRequest.java View file @ 3464e02
  1 +package com.lyms.platform.operate.web.request;
  2 +
  3 +
  4 +/**
  5 + * Created by Administrator on 2021-01-05.
  6 + */
  7 +public class BabyRecordRequest {
  8 + private String id;
  9 + private String doctorId;
  10 + private String nextCheckTime;
  11 + private String content;
  12 + private String babyId;
  13 +
  14 + public String getBabyId() {
  15 + return babyId;
  16 + }
  17 +
  18 + public void setBabyId(String babyId) {
  19 + this.babyId = babyId;
  20 + }
  21 +
  22 + public String getId() {
  23 + return id;
  24 + }
  25 +
  26 + public void setId(String id) {
  27 + this.id = id;
  28 + }
  29 +
  30 + public String getDoctorId() {
  31 + return doctorId;
  32 + }
  33 +
  34 + public void setDoctorId(String doctorId) {
  35 + this.doctorId = doctorId;
  36 + }
  37 +
  38 + public String getNextCheckTime() {
  39 + return nextCheckTime;
  40 + }
  41 +
  42 + public void setNextCheckTime(String nextCheckTime) {
  43 + this.nextCheckTime = nextCheckTime;
  44 + }
  45 +
  46 + public String getContent() {
  47 + return content;
  48 + }
  49 +
  50 + public void setContent(String content) {
  51 + this.content = content;
  52 + }
  53 +}