Commit 1867b4a0ad6a34fb9f174fb15e00c301eeda2621

Authored by litao@lymsh.com
1 parent d687806aa5

体温

Showing 2 changed files with 30 additions and 1 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TempController.java View file @ 1867b4a
... ... @@ -19,6 +19,7 @@
19 19  
20 20 import javax.servlet.http.HttpServletRequest;
21 21 import javax.validation.Valid;
  22 +import java.util.List;
22 23 import java.util.Map;
23 24  
24 25  
25 26  
... ... @@ -47,9 +48,17 @@
47 48 private TempFacade tempFacade;
48 49  
49 50 /**
  51 + * 获取体温记录(小程序)
  52 + */
  53 + @RequestMapping(value = "/wx/get/{parentId}",method = RequestMethod.POST)
  54 + @ResponseBody
  55 + public List<Map<String, Object>> getTemp(@PathVariable String parentId) {
  56 + return tempFacade.getTemp(parentId);
  57 + }
  58 +
  59 + /**
50 60 * 增加一条体温记录(小程序)
51 61 */
52   - @TokenRequired
53 62 @RequestMapping(value = "/wx/add",method = RequestMethod.POST)
54 63 @ResponseBody
55 64 public BaseResponse addWxTemp(TempModel tempModel) {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/TempFacade.java View file @ 1867b4a
... ... @@ -18,6 +18,7 @@
18 18 import com.lyms.platform.query.PatientsQuery;
19 19 import com.lyms.platform.query.TempQuery;
20 20 import org.apache.commons.collections.CollectionUtils;
  21 +import org.apache.commons.collections.MapUtils;
21 22 import org.apache.commons.lang.StringUtils;
22 23 import org.slf4j.Logger;
23 24 import org.slf4j.LoggerFactory;
24 25  
... ... @@ -240,9 +241,28 @@
240 241 tempModel.setYn(YnEnums.YES.getId());
241 242 tempModel.setCreated(date);
242 243 tempModel.setCreatedTime(DateUtil.getyyyy_MM_dd(date));
  244 + Patients patients = mongoTemplate.findById(tempModel.getParentId(), Patients.class);
  245 + if(patients != null) {
  246 + tempModel.setPid(patients.getPid());
  247 + }
243 248 mongoTemplate.save(tempModel);
244 249 }
245 250 return RespBuilder.buildSuccess();
  251 + }
  252 +
  253 + public List<Map<String,Object>> getTemp(String parentId) {
  254 + List<Map<String, Object>> restList = new ArrayList<>();
  255 + TempModel temp = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(parentId)), TempModel.class);
  256 + if(temp != null && MapUtils.isNotEmpty(temp.getTempList())) {
  257 + LinkedHashMap<String, Double> tempList = temp.getTempList();
  258 + for (Map.Entry<String, Double> entry : tempList.entrySet()) {
  259 + Map<String, Object> map = new HashMap<>();
  260 + map.put("date", entry.getKey());
  261 + map.put("temp", entry.getValue());
  262 + restList.add(map);
  263 + }
  264 + }
  265 + return restList;
246 266 }
247 267 }