Commit add66cd4587974e3677b9fb0127ace6fb6d6e699
1 parent
b743b51ec1
Exists in
master
and in
6 other branches
小程序展示项bug修改
Showing 11 changed files with 500 additions and 11 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/ITemporaryWeightDao.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/TemporaryWeightDaoImpl.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CheckItemManageServiceImpl.java
- platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java
- platform-dal/src/main/java/com/lyms/platform/pojo/TemporaryWeightModel.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TemporaryWeightController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/TemporaryWeightService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/TemporaryWeightServiceImpl.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/ITemporaryWeightDao.java
View file @
add66cd
| 1 | +package com.lyms.platform.biz.dal; | |
| 2 | + | |
| 3 | +import com.lyms.platform.pojo.TemporaryWeightModel; | |
| 4 | +import org.springframework.data.mongodb.core.query.Query; | |
| 5 | + | |
| 6 | +public interface ITemporaryWeightDao { | |
| 7 | + public void addTemporaryWeight(TemporaryWeightModel weightModel); | |
| 8 | + | |
| 9 | + void updateTemporaryWeight(Query query, TemporaryWeightModel weightModel); | |
| 10 | + | |
| 11 | + void deleteTemporaryWeight(Query query); | |
| 12 | +} |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/TemporaryWeightDaoImpl.java
View file @
add66cd
| 1 | +package com.lyms.platform.biz.dal.impl; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.dal.ITemporaryWeightDao; | |
| 4 | +import com.lyms.platform.common.dao.BaseMongoDAOImpl; | |
| 5 | +import com.lyms.platform.pojo.TemporaryWeightModel; | |
| 6 | +import org.springframework.data.mongodb.core.query.Query; | |
| 7 | +import org.springframework.stereotype.Repository; | |
| 8 | + | |
| 9 | + | |
| 10 | +@Repository("temporaryWeightDao") | |
| 11 | +public class TemporaryWeightDaoImpl extends BaseMongoDAOImpl<TemporaryWeightModel> implements ITemporaryWeightDao { | |
| 12 | + @Override | |
| 13 | + public void addTemporaryWeight(TemporaryWeightModel weightModel) { | |
| 14 | + save(weightModel); | |
| 15 | + } | |
| 16 | + | |
| 17 | + @Override | |
| 18 | + public void updateTemporaryWeight(Query query, TemporaryWeightModel weightModel) { | |
| 19 | + update(query, weightModel); | |
| 20 | + } | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + public void deleteTemporaryWeight(Query query) { | |
| 24 | + delete(query); | |
| 25 | + } | |
| 26 | +} |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/CheckItemManageServiceImpl.java
View file @
add66cd
| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | import com.lyms.platform.biz.AntExChuModelTemp; |
| 4 | 4 | import com.lyms.platform.common.utils.DateUtil; |
| 5 | +import com.lyms.platform.common.utils.StringUtils; | |
| 5 | 6 | import com.lyms.platform.permission.dao.master.MasterCheckItemManageMapper; |
| 6 | 7 | import com.lyms.platform.permission.dao.master.MasterCheckItemMapper; |
| 7 | 8 | import com.lyms.platform.permission.model.CheckItem; |
| ... | ... | @@ -91,9 +92,7 @@ |
| 91 | 92 | }); |
| 92 | 93 | //获取排序后对象中的第一条数据 |
| 93 | 94 | AntenatalExaminationModel examinationModels = antenatalExaminationModels.get(0); |
| 94 | - if (examinationModels != null && examinationModels.getConfigItemId() != null) { | |
| 95 | - System.out.println("=======>复诊" + examinationModels.getConfigItemId()); | |
| 96 | - System.out.println("=====>时间" + DateUtil.getyyyy_MM_dd_hms(examinationModels.getModified())); | |
| 95 | + if (examinationModels != null && StringUtils.isNotEmpty(examinationModels.getConfigItemId())) { | |
| 97 | 96 | String strCept = examinationModels.getConfigItemId(); |
| 98 | 97 | String[] string = strCept.split(","); |
| 99 | 98 | for (String s1 : string) { |
| ... | ... | @@ -114,7 +113,6 @@ |
| 114 | 113 | //获取初诊 |
| 115 | 114 | AntExChuModelTemp antExChuModelTemps = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(parentId)), AntExChuModelTemp.class); |
| 116 | 115 | if (antExChuModelTemps != null && antExChuModelTemps.getConfigItemId() != null) { |
| 117 | - System.out.println("========初诊:" + antExChuModelTemps.getConfigItemId()); | |
| 118 | 116 | String[] str = antExChuModelTemps.getConfigItemId().split(","); |
| 119 | 117 | for (String s2 : str) { |
| 120 | 118 | List<CheckItem> list1 = checkItemMapper.xcxGetCheckItemList(Integer.valueOf(s2).intValue()); |
platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java
View file @
add66cd
| ... | ... | @@ -80,10 +80,13 @@ |
| 80 | 80 | BabySieveModel("BabySieveModel", 97531049991L), |
| 81 | 81 | PostpartumRecords("PostpartumRecords", 97521049991L), |
| 82 | 82 | QuestionModel("QuestionModel", 97521049991L), |
| 83 | + TemporaryWeightModel("TemporaryWeightModel", 97531049591L), | |
| 83 | 84 | BabyEyeCheck("BabyEyeCheck", 97521039591L); |
| 84 | 85 | |
| 86 | + | |
| 85 | 87 | private String cname; |
| 86 | 88 | private Long cid; |
| 89 | + | |
| 87 | 90 | private SerialIdEnum(String cname, Long cid) { |
| 88 | 91 | this.cid = cid; |
| 89 | 92 | this.cname = cname; |
platform-dal/src/main/java/com/lyms/platform/pojo/TemporaryWeightModel.java
View file @
add66cd
| 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 | +import java.util.List; | |
| 9 | +import java.util.Map; | |
| 10 | + | |
| 11 | +@Document(collection = "lyms_temporary_weigh") | |
| 12 | +public class TemporaryWeightModel extends BaseModel { | |
| 13 | + private static final long serialVersionUID = SerialIdEnum.TemporaryWeightModel.getCid(); | |
| 14 | + | |
| 15 | + private String id; | |
| 16 | + private String userName; | |
| 17 | + private Integer age; | |
| 18 | + private Integer yn; | |
| 19 | + private String weeks; | |
| 20 | + // 孕前体重 | |
| 21 | + private String beforeWeight; | |
| 22 | + | |
| 23 | + // 孕前身高 | |
| 24 | + private String beforeHeight; | |
| 25 | + | |
| 26 | + // 当前体重 | |
| 27 | + private String nowWeight; | |
| 28 | + | |
| 29 | + // 前囟 单胎/双胎/多胎 | |
| 30 | + private String bregmatic; | |
| 31 | + | |
| 32 | + | |
| 33 | + private Date created; | |
| 34 | + | |
| 35 | + private Date modified; | |
| 36 | + //记录次数 | |
| 37 | + private Integer number; | |
| 38 | + | |
| 39 | + private String phone; | |
| 40 | + //高危因素 | |
| 41 | + private List riskFactorId; | |
| 42 | + //末次月经 | |
| 43 | + private Date lastMenses; | |
| 44 | + | |
| 45 | + private String bmi; | |
| 46 | + | |
| 47 | + private String cardID; | |
| 48 | + | |
| 49 | + public String getCardID() { | |
| 50 | + return cardID; | |
| 51 | + } | |
| 52 | + | |
| 53 | + public void setCardID(String cardID) { | |
| 54 | + this.cardID = cardID; | |
| 55 | + } | |
| 56 | + | |
| 57 | + // 存储 年月日 = xxKG | |
| 58 | + private Map<String, String> dayWeights; | |
| 59 | + | |
| 60 | + public Map<String, String> getDayWeights() { | |
| 61 | + return dayWeights; | |
| 62 | + } | |
| 63 | + | |
| 64 | + | |
| 65 | + public Date getLastMenses() { | |
| 66 | + return lastMenses; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public void setLastMenses(Date lastMenses) { | |
| 70 | + this.lastMenses = lastMenses; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public void setDayWeights(Map<String, String> dayWeights) { | |
| 74 | + this.dayWeights = dayWeights; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public String getBmi() { | |
| 78 | + return bmi; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public void setBmi(String bmi) { | |
| 82 | + this.bmi = bmi; | |
| 83 | + } | |
| 84 | + | |
| 85 | + public List getRiskFactorId() { | |
| 86 | + return riskFactorId; | |
| 87 | + } | |
| 88 | + | |
| 89 | + public Integer getYn() { | |
| 90 | + return yn; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public void setYn(Integer yn) { | |
| 94 | + this.yn = yn; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void setRiskFactorId(List riskFactorId) { | |
| 98 | + this.riskFactorId = riskFactorId; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public String getPhone() { | |
| 102 | + return phone; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void setPhone(String phone) { | |
| 106 | + this.phone = phone; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public static long getSerialVersionUID() { | |
| 110 | + return serialVersionUID; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public String getId() { | |
| 114 | + return id; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public void setId(String id) { | |
| 118 | + this.id = id; | |
| 119 | + } | |
| 120 | + | |
| 121 | + public String getUserName() { | |
| 122 | + return userName; | |
| 123 | + } | |
| 124 | + | |
| 125 | + public void setUserName(String userName) { | |
| 126 | + this.userName = userName; | |
| 127 | + } | |
| 128 | + | |
| 129 | + public Integer getAge() { | |
| 130 | + return age; | |
| 131 | + } | |
| 132 | + | |
| 133 | + public void setAge(Integer age) { | |
| 134 | + this.age = age; | |
| 135 | + } | |
| 136 | + | |
| 137 | + public String getWeeks() { | |
| 138 | + return weeks; | |
| 139 | + } | |
| 140 | + | |
| 141 | + public void setWeeks(String weeks) { | |
| 142 | + this.weeks = weeks; | |
| 143 | + } | |
| 144 | + | |
| 145 | + public String getBeforeWeight() { | |
| 146 | + return beforeWeight; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public void setBeforeWeight(String beforeWeight) { | |
| 150 | + this.beforeWeight = beforeWeight; | |
| 151 | + } | |
| 152 | + | |
| 153 | + public String getBeforeHeight() { | |
| 154 | + return beforeHeight; | |
| 155 | + } | |
| 156 | + | |
| 157 | + public void setBeforeHeight(String beforeHeight) { | |
| 158 | + this.beforeHeight = beforeHeight; | |
| 159 | + } | |
| 160 | + | |
| 161 | + public String getNowWeight() { | |
| 162 | + return nowWeight; | |
| 163 | + } | |
| 164 | + | |
| 165 | + public void setNowWeight(String nowWeight) { | |
| 166 | + this.nowWeight = nowWeight; | |
| 167 | + } | |
| 168 | + | |
| 169 | + public String getBregmatic() { | |
| 170 | + return bregmatic; | |
| 171 | + } | |
| 172 | + | |
| 173 | + public void setBregmatic(String bregmatic) { | |
| 174 | + this.bregmatic = bregmatic; | |
| 175 | + } | |
| 176 | + | |
| 177 | + public Date getCreated() { | |
| 178 | + return created; | |
| 179 | + } | |
| 180 | + | |
| 181 | + public void setCreated(Date created) { | |
| 182 | + this.created = created; | |
| 183 | + } | |
| 184 | + | |
| 185 | + public Date getModified() { | |
| 186 | + return modified; | |
| 187 | + } | |
| 188 | + | |
| 189 | + public void setModified(Date modified) { | |
| 190 | + this.modified = modified; | |
| 191 | + } | |
| 192 | + | |
| 193 | + public Integer getNumber() { | |
| 194 | + return number; | |
| 195 | + } | |
| 196 | + | |
| 197 | + public void setNumber(Integer number) { | |
| 198 | + this.number = number; | |
| 199 | + } | |
| 200 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java
View file @
add66cd
| ... | ... | @@ -32,6 +32,12 @@ |
| 32 | 32 | |
| 33 | 33 | @ResponseBody |
| 34 | 34 | @RequestMapping(method = RequestMethod.POST) |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 35 | 41 | @TokenRequired |
| 36 | 42 | public BaseResponse addOrUpdate(PatientWeight patientWeight, HttpServletRequest request) { |
| 37 | 43 | return patientWeightService.addOrUpdate(getUserId(request), patientWeight); |
| ... | ... | @@ -256,12 +262,6 @@ |
| 256 | 262 | * @param pid |
| 257 | 263 | * @return |
| 258 | 264 | */ |
| 259 | -/* | |
| 260 | - public BaseResponse report(@PathVariable String id, | |
| 261 | - HttpServletRequest request, | |
| 262 | - @RequestParam(value = "rid", required = false) String rid) { | |
| 263 | - return patientWeightService.report(id, getUserId(request), rid); | |
| 264 | - }*/ | |
| 265 | 265 | @ResponseBody |
| 266 | 266 | @RequestMapping(value = "/getWeightsReport/{pid}", method = RequestMethod.GET) |
| 267 | 267 | @TokenRequired |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TemporaryWeightController.java
View file @
add66cd
| 1 | +package com.lyms.platform.operate.web.controller; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.lyms.platform.common.annotation.TokenRequired; | |
| 5 | +import com.lyms.platform.common.base.LoginContext; | |
| 6 | +import com.lyms.platform.common.result.BaseResponse; | |
| 7 | +import com.lyms.platform.operate.web.service.TemporaryWeightService; | |
| 8 | +import com.lyms.platform.pojo.TemporaryWeightModel; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.stereotype.Controller; | |
| 11 | +import org.springframework.web.bind.annotation.*; | |
| 12 | + | |
| 13 | +import javax.servlet.http.HttpServletRequest; | |
| 14 | + | |
| 15 | +@Controller | |
| 16 | +@RequestMapping("/temporary/weight") | |
| 17 | +public class TemporaryWeightController { | |
| 18 | + | |
| 19 | + @Autowired | |
| 20 | + private TemporaryWeightService temporaryWeightService; | |
| 21 | + | |
| 22 | + @RequestMapping(value = "/addOrUpdate", method = RequestMethod.POST) | |
| 23 | + @TokenRequired | |
| 24 | + @ResponseBody | |
| 25 | + public BaseResponse addTemporaryWeight(TemporaryWeightModel temporaryWeightModel, HttpServletRequest request) { | |
| 26 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 27 | + return temporaryWeightService.addTemporaryWeight(temporaryWeightModel); | |
| 28 | + } | |
| 29 | + | |
| 30 | + @RequestMapping(value = "/update", method = RequestMethod.PUT) | |
| 31 | + @TokenRequired | |
| 32 | + public BaseResponse udateTemporaryWeight() { | |
| 33 | + return new BaseResponse(); | |
| 34 | + } | |
| 35 | + | |
| 36 | + @RequestMapping(value = "/delete", method = RequestMethod.DELETE) | |
| 37 | + @TokenRequired | |
| 38 | + @ResponseBody | |
| 39 | + public BaseResponse delete(@RequestParam(value = "phone") String phone) { | |
| 40 | + return temporaryWeightService.deleteTemporaryWeight(phone); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @RequestMapping(value = "/queryOne", method = RequestMethod.GET) | |
| 44 | + @TokenRequired | |
| 45 | + @ResponseBody | |
| 46 | + public BaseResponse queryOne(String phone) { | |
| 47 | + return temporaryWeightService.queryOne(phone); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @RequestMapping(value = "/queryAll", method = RequestMethod.GET) | |
| 51 | + @TokenRequired | |
| 52 | + @ResponseBody | |
| 53 | + public BaseResponse queryAll(Integer page, Integer limit) { | |
| 54 | + return temporaryWeightService.queryAll(page, limit); | |
| 55 | + } | |
| 56 | + | |
| 57 | + @ResponseBody | |
| 58 | + @TokenRequired | |
| 59 | + @RequestMapping(value = "/info/{phone}", method = RequestMethod.GET) | |
| 60 | + public BaseResponse info(@PathVariable String phone) { | |
| 61 | + return temporaryWeightService.info(phone); | |
| 62 | + } | |
| 63 | + | |
| 64 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java
View file @
add66cd
| ... | ... | @@ -56,5 +56,8 @@ |
| 56 | 56 | public void getSeries(Map<String, Object> series, String bmiStr, String bregmatic); |
| 57 | 57 | |
| 58 | 58 | BaseResponse getWeightsReport(String pid, Integer userId, String rid); |
| 59 | + | |
| 60 | + public void setReport(Map<String, Object> restMap, Map<Integer, String> weights, String beforeWeight, | |
| 61 | + String bmi, Map<String, String> dayWeights, String bregmatic); | |
| 59 | 62 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/TemporaryWeightService.java
View file @
add66cd
| 1 | +package com.lyms.platform.operate.web.service; | |
| 2 | + | |
| 3 | +import com.lyms.platform.common.result.BaseResponse; | |
| 4 | +import com.lyms.platform.pojo.TemporaryWeightModel; | |
| 5 | +import org.springframework.data.mongodb.core.query.Query; | |
| 6 | + | |
| 7 | +public interface TemporaryWeightService extends IBaseService { | |
| 8 | + | |
| 9 | + BaseResponse addTemporaryWeight(TemporaryWeightModel weightModel); | |
| 10 | + | |
| 11 | + void updateTemporaryWeight(Query query, TemporaryWeightModel weightModel); | |
| 12 | + | |
| 13 | + BaseResponse deleteTemporaryWeight(String Phone); | |
| 14 | + | |
| 15 | + BaseResponse queryOne(String phone); | |
| 16 | + | |
| 17 | + BaseResponse queryAll(Integer page, Integer limit); | |
| 18 | + | |
| 19 | + BaseResponse info(String phone); | |
| 20 | + | |
| 21 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
add66cd
| ... | ... | @@ -1315,6 +1315,7 @@ |
| 1315 | 1315 | return restList; |
| 1316 | 1316 | } |
| 1317 | 1317 | |
| 1318 | + @Override | |
| 1318 | 1319 | public void setReport(Map<String, Object> restMap, Map<Integer, String> weights, String beforeWeight, |
| 1319 | 1320 | String bmi, Map<String, String> dayWeights, String bregmatic) { |
| 1320 | 1321 | List<Map<String, Object>> restList = new ArrayList<>(); |
| ... | ... | @@ -2322,7 +2323,6 @@ |
| 2322 | 2323 | } |
| 2323 | 2324 | return 0.0; |
| 2324 | 2325 | } |
| 2325 | - | |
| 2326 | 2326 | |
| 2327 | 2327 | public double getDiabetes(double height, Integer weeks) { |
| 2328 | 2328 | if (weeks > 0 && weeks <= 12) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/TemporaryWeightServiceImpl.java
View file @
add66cd
| 1 | +package com.lyms.platform.operate.web.service.impl; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.dal.ITemporaryWeightDao; | |
| 4 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 5 | +import com.lyms.platform.common.enums.BregmaticEnums2; | |
| 6 | +import com.lyms.platform.common.result.BaseObjectResponse; | |
| 7 | +import com.lyms.platform.common.result.BaseResponse; | |
| 8 | +import com.lyms.platform.common.result.PageResult; | |
| 9 | +import com.lyms.platform.common.result.RespBuilder; | |
| 10 | +import com.lyms.platform.common.utils.DateUtil; | |
| 11 | +import com.lyms.platform.common.utils.ReflectionUtils; | |
| 12 | +import com.lyms.platform.common.utils.StringUtils; | |
| 13 | +import com.lyms.platform.operate.web.service.PatientWeightService; | |
| 14 | +import com.lyms.platform.operate.web.service.TemporaryWeightService; | |
| 15 | +import com.lyms.platform.operate.web.utils.CollectionUtils; | |
| 16 | +import com.lyms.platform.pojo.TemporaryWeightModel; | |
| 17 | +import org.apache.commons.collections.MapUtils; | |
| 18 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 19 | +import org.springframework.data.domain.Sort; | |
| 20 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
| 21 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 22 | +import org.springframework.data.mongodb.core.query.Query; | |
| 23 | +import org.springframework.data.mongodb.core.query.Update; | |
| 24 | +import org.springframework.stereotype.Service; | |
| 25 | + | |
| 26 | +import java.util.*; | |
| 27 | + | |
| 28 | +@Service | |
| 29 | +public class TemporaryWeightServiceImpl extends BaseServiceImpl implements TemporaryWeightService { | |
| 30 | + | |
| 31 | + @Autowired | |
| 32 | + private ITemporaryWeightDao temporaryWeightDao; | |
| 33 | + | |
| 34 | + @Autowired | |
| 35 | + private MongoTemplate mongoTemplate; | |
| 36 | + | |
| 37 | + @Autowired | |
| 38 | + private PatientWeightService patientWeightService; | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public BaseResponse addTemporaryWeight(TemporaryWeightModel weightModel) { | |
| 42 | + if (StringUtils.isNotEmpty(weightModel.getPhone())) { | |
| 43 | + TemporaryWeightModel temporaryWeightModel = mongoTemplate.findOne(Query.query(Criteria.where("phone").is(weightModel.getPhone())), TemporaryWeightModel.class); | |
| 44 | + if (temporaryWeightModel != null) { | |
| 45 | + if (StringUtils.isNotEmpty(temporaryWeightModel.getPhone())) { | |
| 46 | + weightModel.setModified(new Date()); | |
| 47 | + temporaryWeightDao.updateTemporaryWeight(Query.query(Criteria.where("phone").is(temporaryWeightModel.getPhone())), weightModel); | |
| 48 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("修改成功"); | |
| 49 | + } | |
| 50 | + } else { | |
| 51 | + weightModel.setYn(1); | |
| 52 | + weightModel.setModified(new Date()); | |
| 53 | + weightModel.setCreated(new Date()); | |
| 54 | + Map<String, String> dayWeights = new LinkedHashMap<>(); | |
| 55 | + List<Map<String, Object>> dayWeights2 = new ArrayList<>(); | |
| 56 | + /* if (MapUtils.isNotEmpty(temporaryWeightModel.getDayWeights())) { | |
| 57 | + dayWeights = temporaryWeightModel.getDayWeights(); | |
| 58 | + }*/ | |
| 59 | + dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), weightModel.getNowWeight()); | |
| 60 | + weightModel.setDayWeights(dayWeights); | |
| 61 | + weightModel.setBmi(patientWeightService.getBmi(weightModel.getBeforeWeight(), weightModel.getBeforeHeight())); | |
| 62 | + temporaryWeightDao.addTemporaryWeight(weightModel); | |
| 63 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("添加成功"); | |
| 64 | + | |
| 65 | + } | |
| 66 | + } | |
| 67 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("请填写电话号码"); | |
| 68 | + } | |
| 69 | + | |
| 70 | + @Override | |
| 71 | + public void updateTemporaryWeight(Query query, TemporaryWeightModel weightModel) { | |
| 72 | + | |
| 73 | + } | |
| 74 | + | |
| 75 | + @Override | |
| 76 | + public BaseResponse deleteTemporaryWeight(String phone) { | |
| 77 | + mongoTemplate.updateFirst(Query.query(Criteria.where("phone").is(phone)), Update.update("yn", 1), TemporaryWeightModel.class); | |
| 78 | + return RespBuilder.buildSuccess(); | |
| 79 | + } | |
| 80 | + | |
| 81 | + @Override | |
| 82 | + public BaseResponse queryOne(String phone) { | |
| 83 | + if (StringUtils.isNotEmpty(phone)) { | |
| 84 | + TemporaryWeightModel temporaryWeightModel = mongoTemplate.findOne(Query.query(Criteria.where("phone").is(phone)), TemporaryWeightModel.class); | |
| 85 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(temporaryWeightModel); | |
| 86 | + } | |
| 87 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("请选择一条记录"); | |
| 88 | + } | |
| 89 | + | |
| 90 | + @Override | |
| 91 | + public BaseResponse queryAll(Integer page, Integer limit) { | |
| 92 | + Criteria criteria = Criteria.where("yn").ne(0); | |
| 93 | + PageResult pageResult = findMongoPage(TemporaryWeightModel.class, new Query(criteria).with(new Sort(Sort.Direction.DESC, "modified")), page, limit); | |
| 94 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(pageResult); | |
| 95 | + } | |
| 96 | + | |
| 97 | + | |
| 98 | + @Override | |
| 99 | + public BaseResponse info(String phone) { | |
| 100 | + TemporaryWeightModel template = mongoTemplate.findOne(Query.query(Criteria.where("phone").is(phone)), TemporaryWeightModel.class); | |
| 101 | + if (template != null) { | |
| 102 | + /* Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); | |
| 103 | + if (patients == null) { | |
| 104 | + return RespBuilder.buildSuccess("建档数据未找到"); | |
| 105 | + }*/ | |
| 106 | + Map<String, Object> map = ReflectionUtils.beanToMap(template); | |
| 107 | + //http://jira.healthbaby.com.cn/browse/WEB-2744 | |
| 108 | + String bregmatic = ""; | |
| 109 | + try { | |
| 110 | + if (org.apache.commons.lang.StringUtils.isEmpty(template.getBregmatic()) || "null".equals(template.getBregmatic())) { | |
| 111 | + bregmatic = "未知"; | |
| 112 | + } else { | |
| 113 | + bregmatic = BregmaticEnums2.getName(template.getBregmatic()); | |
| 114 | + } | |
| 115 | + } catch (Exception e) { | |
| 116 | + bregmatic = "未知"; | |
| 117 | + } | |
| 118 | + | |
| 119 | + map.put("bregmatic", bregmatic); | |
| 120 | + map.put("bim", template.getBmi()); // 体质指数(BMI)=体重(kg)÷身高^2(m) | |
| 121 | + | |
| 122 | + Map<String, String> dayWeights = template.getDayWeights(); | |
| 123 | + dayWeights = sortMapByKey(dayWeights); | |
| 124 | + Map<Integer, String> weights = new LinkedHashMap<>(); | |
| 125 | + if (MapUtils.isNotEmpty(dayWeights)) { | |
| 126 | + Set<Map.Entry<String, String>> entries = dayWeights.entrySet(); | |
| 127 | + for (Map.Entry<String, String> entry : entries) { | |
| 128 | + weights.put(DateUtil.getWeek2(template.getLastMenses(), DateUtil.parseYMD(entry.getKey())), entry.getValue()); | |
| 129 | + } | |
| 130 | + } | |
| 131 | + | |
| 132 | + if (dayWeights != null && dayWeights.size() > 0 && org.apache.commons.lang.StringUtils.isNotEmpty(dayWeights.get(DateUtil.getyyyy_MM_dd(new Date())))) { | |
| 133 | + map.put("isShow", true); | |
| 134 | + } else { | |
| 135 | + map.put("isShow", false); | |
| 136 | + } | |
| 137 | + patientWeightService.setReport(map, weights, template.getBeforeWeight(), template.getBmi(), template.getDayWeights(), template.getBregmatic()); | |
| 138 | + | |
| 139 | + CollectionUtils.removeNullValue(map); | |
| 140 | + return RespBuilder.buildSuccess(map); | |
| 141 | + } | |
| 142 | + return RespBuilder.buildSuccess(); | |
| 143 | + } | |
| 144 | + | |
| 145 | + private Map<String, String> sortMapByKey(Map<String, String> dayWeights) { | |
| 146 | + if (MapUtils.isNotEmpty(dayWeights)) { | |
| 147 | + Map<String, String> temp = new TreeMap<>(new Comparator<String>() { | |
| 148 | + @Override | |
| 149 | + public int compare(String o1, String o2) { | |
| 150 | + return o1.compareTo(o2); | |
| 151 | + } | |
| 152 | + }); | |
| 153 | + for (Map.Entry<String, String> entry : dayWeights.entrySet()) { | |
| 154 | + temp.put(entry.getKey(), entry.getValue()); | |
| 155 | + } | |
| 156 | + return temp; | |
| 157 | + } | |
| 158 | + return dayWeights; | |
| 159 | + } | |
| 160 | + | |
| 161 | + | |
| 162 | +} |