Commit d687806aa5107f4f6bae02e47cb1ee68ffa1a758
1 parent
2bb4fd5fba
Exists in
master
and in
6 other branches
体重
Showing 2 changed files with 38 additions and 3 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TempController.java
View file @
d687806
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | import com.lyms.platform.operate.web.facade.TempFacade; |
| 8 | 8 | import com.lyms.platform.operate.web.request.TempAddRequest; |
| 9 | 9 | import com.lyms.platform.operate.web.request.TempQueryRequest; |
| 10 | +import com.lyms.platform.pojo.TempModel; | |
| 10 | 11 | import org.slf4j.Logger; |
| 11 | 12 | import org.slf4j.LoggerFactory; |
| 12 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -44,6 +45,16 @@ |
| 44 | 45 | |
| 45 | 46 | @Autowired |
| 46 | 47 | private TempFacade tempFacade; |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 增加一条体温记录(小程序) | |
| 51 | + */ | |
| 52 | + @TokenRequired | |
| 53 | + @RequestMapping(value = "/wx/add",method = RequestMethod.POST) | |
| 54 | + @ResponseBody | |
| 55 | + public BaseResponse addWxTemp(TempModel tempModel) { | |
| 56 | + return tempFacade.addWxTemp(tempModel); | |
| 57 | + } | |
| 47 | 58 | |
| 48 | 59 | |
| 49 | 60 | /** |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/TempFacade.java
View file @
d687806
| ... | ... | @@ -3,12 +3,11 @@ |
| 3 | 3 | import com.lyms.platform.biz.service.CommonService; |
| 4 | 4 | import com.lyms.platform.biz.service.PatientsService; |
| 5 | 5 | import com.lyms.platform.biz.service.TempService; |
| 6 | -import com.lyms.platform.common.base.ContextHolder; | |
| 7 | 6 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
| 8 | 7 | import com.lyms.platform.common.enums.YnEnums; |
| 9 | 8 | import com.lyms.platform.common.result.BaseListResponse; |
| 10 | -import com.lyms.platform.common.result.BaseObjectResponse; | |
| 11 | 9 | import com.lyms.platform.common.result.BaseResponse; |
| 10 | +import com.lyms.platform.common.result.RespBuilder; | |
| 12 | 11 | import com.lyms.platform.common.utils.Assert; |
| 13 | 12 | import com.lyms.platform.common.utils.DateUtil; |
| 14 | 13 | import com.lyms.platform.operate.web.request.TempAddRequest; |
| 15 | 14 | |
| ... | ... | @@ -20,10 +19,12 @@ |
| 20 | 19 | import com.lyms.platform.query.TempQuery; |
| 21 | 20 | import org.apache.commons.collections.CollectionUtils; |
| 22 | 21 | import org.apache.commons.lang.StringUtils; |
| 23 | -import org.apache.commons.lang.math.NumberUtils; | |
| 24 | 22 | import org.slf4j.Logger; |
| 25 | 23 | import org.slf4j.LoggerFactory; |
| 26 | 24 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
| 26 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 27 | +import org.springframework.data.mongodb.core.query.Query; | |
| 27 | 28 | import org.springframework.stereotype.Component; |
| 28 | 29 | |
| 29 | 30 | import java.util.*; |
| ... | ... | @@ -59,6 +60,9 @@ |
| 59 | 60 | @Autowired |
| 60 | 61 | private CommonService commonService; |
| 61 | 62 | |
| 63 | + @Autowired | |
| 64 | + private MongoTemplate mongoTemplate; | |
| 65 | + | |
| 62 | 66 | public BaseResponse addOrUpdateOneTemp(TempAddRequest addRequest, Integer userId) { |
| 63 | 67 | Assert.notNull(addRequest, "请求为空."); |
| 64 | 68 | String hospital = autoMatchFacade.getHospitalId(userId); |
| ... | ... | @@ -219,6 +223,26 @@ |
| 219 | 223 | temp.add(String.valueOf(data.get(t))); |
| 220 | 224 | } |
| 221 | 225 | return map; |
| 226 | + } | |
| 227 | + | |
| 228 | + public BaseResponse addWxTemp(TempModel tempModel) { | |
| 229 | + TempModel temp = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(tempModel.getParentId())), TempModel.class); | |
| 230 | + Date date = new Date(); | |
| 231 | + LinkedHashMap data = temp == null ? new LinkedHashMap<String, Double>() : temp.getTempList(); | |
| 232 | + data.put(DateUtil.getYyyyMmDd(new Date()), Double.valueOf(tempModel.getNow())); | |
| 233 | + tempModel.setTempList(data); | |
| 234 | + if(temp != null) { | |
| 235 | + temp.setNow(tempModel.getNow()); | |
| 236 | + temp.setTempList(data); | |
| 237 | + temp.setModified(date); | |
| 238 | + tempService.update(temp, temp.getId()); | |
| 239 | + } else { | |
| 240 | + tempModel.setYn(YnEnums.YES.getId()); | |
| 241 | + tempModel.setCreated(date); | |
| 242 | + tempModel.setCreatedTime(DateUtil.getyyyy_MM_dd(date)); | |
| 243 | + mongoTemplate.save(tempModel); | |
| 244 | + } | |
| 245 | + return RespBuilder.buildSuccess(); | |
| 222 | 246 | } |
| 223 | 247 | } |