Commit dc84b903637f9952d4d47d3536f9816793be3312
1 parent
474fbfbd5f
Exists in
master
and in
6 other branches
update
Showing 3 changed files with 121 additions and 1 deletions
platform-dal/src/main/java/com/lyms/platform/pojo/BabyQhdfyDietSelect.java
View file @
dc84b90
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 | +/** | |
7 | + * Created by Administrator on 2021-01-14. | |
8 | + */ | |
9 | +@Document(collection = "lyms_qhdfy_baby_diet_select") | |
10 | +public class BabyQhdfyDietSelect extends BaseModel { | |
11 | + | |
12 | + private String id; | |
13 | + private String dietId;//膳食报告id | |
14 | + private String oid; | |
15 | + private String rid; | |
16 | + | |
17 | + public String getId() { | |
18 | + return id; | |
19 | + } | |
20 | + | |
21 | + public void setId(String id) { | |
22 | + this.id = id; | |
23 | + } | |
24 | + | |
25 | + public String getDietId() { | |
26 | + return dietId; | |
27 | + } | |
28 | + | |
29 | + public void setDietId(String dietId) { | |
30 | + this.dietId = dietId; | |
31 | + } | |
32 | + | |
33 | + public String getOid() { | |
34 | + return oid; | |
35 | + } | |
36 | + | |
37 | + public void setOid(String oid) { | |
38 | + this.oid = oid; | |
39 | + } | |
40 | + | |
41 | + public String getRid() { | |
42 | + return rid; | |
43 | + } | |
44 | + | |
45 | + public void setRid(String rid) { | |
46 | + this.rid = rid; | |
47 | + } | |
48 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyNutritionController.java
View file @
dc84b90
... | ... | @@ -163,13 +163,37 @@ |
163 | 163 | } |
164 | 164 | |
165 | 165 | |
166 | - | |
166 | + /** | |
167 | + * 查询选择 | |
168 | + * @param id | |
169 | + * @param request | |
170 | + * @return | |
171 | + */ | |
167 | 172 | @RequestMapping(value = "/queryQhdDeitSelect", method = RequestMethod.GET) |
168 | 173 | @ResponseBody |
169 | 174 | @TokenRequired |
170 | 175 | public BaseObjectResponse queryQhdDeitSelect(@RequestParam(required = true) String id, HttpServletRequest request |
171 | 176 | ) { |
172 | 177 | return babyNutritionFacade.queryQhdDeitSelect(id, getUserId(request)); |
178 | + } | |
179 | + | |
180 | + | |
181 | + /** | |
182 | + * 保存秦皇岛选择 | |
183 | + * @param dietId | |
184 | + * @param oid | |
185 | + * @param rid | |
186 | + * @param request | |
187 | + * @return | |
188 | + */ | |
189 | + @RequestMapping(value = "/saveQhdDeitSelect", method = RequestMethod.GET) | |
190 | + @ResponseBody | |
191 | + @TokenRequired | |
192 | + public BaseResponse saveQhdDeitSelect(@RequestParam(required = true) String dietId, | |
193 | + @RequestParam(required = false)String oid, | |
194 | + @RequestParam(required = false)String rid, HttpServletRequest request | |
195 | + ) { | |
196 | + return babyNutritionFacade.saveQhdDeitSelect(dietId, oid, rid, getUserId(request)); | |
173 | 197 | } |
174 | 198 | |
175 | 199 | /** |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyNutritionFacade.java
View file @
dc84b90
... | ... | @@ -27,6 +27,7 @@ |
27 | 27 | import org.springframework.data.mongodb.core.MongoTemplate; |
28 | 28 | import org.springframework.data.mongodb.core.query.Criteria; |
29 | 29 | import org.springframework.data.mongodb.core.query.Query; |
30 | +import org.springframework.data.mongodb.core.query.Update; | |
30 | 31 | import org.springframework.stereotype.Component; |
31 | 32 | import scala.reflect.generic.Trees; |
32 | 33 | |
... | ... | @@ -2090,6 +2091,22 @@ |
2090 | 2091 | List<BabyNutritionModel> models = babyNutritionService.queryBabyNutritions(babyQuery); |
2091 | 2092 | if (CollectionUtils.isNotEmpty(models)) { |
2092 | 2093 | BabyNutritionModel model = models.get(0); |
2094 | + data.put("dietId",model.getId()); | |
2095 | + | |
2096 | + BabyQhdfyDietSelect dbSelect = | |
2097 | + mongoTemplate.findOne(Query.query(Criteria.where("dietId").is(model.getId())), BabyQhdfyDietSelect.class); | |
2098 | + if (dbSelect == null) | |
2099 | + { | |
2100 | + data.put("oid",dbSelect.getOid()); | |
2101 | + data.put("rid",dbSelect.getRid()); | |
2102 | + } | |
2103 | + else | |
2104 | + { | |
2105 | + data.put("oid",null); | |
2106 | + data.put("rid",null); | |
2107 | + } | |
2108 | + | |
2109 | + | |
2093 | 2110 | BabyModel baby = babyBookbuildingService.queryBabyBuildById(model.getBabyId()); |
2094 | 2111 | |
2095 | 2112 | int month = DateUtil.getMonth(baby.getBirth(), model.getNutritiTime()); |
... | ... | @@ -2175,6 +2192,37 @@ |
2175 | 2192 | objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); |
2176 | 2193 | objectResponse.setErrormsg("成功"); |
2177 | 2194 | return objectResponse; |
2195 | + } | |
2196 | + | |
2197 | + public BaseResponse saveQhdDeitSelect(String dietId, String oid, String rid, Integer userId) { | |
2198 | + | |
2199 | + | |
2200 | + BabyQhdfyDietSelect dbSelect = | |
2201 | + mongoTemplate.findOne(Query.query(Criteria.where("dietId").is(dietId)), BabyQhdfyDietSelect.class); | |
2202 | + | |
2203 | + if (dbSelect != null) | |
2204 | + | |
2205 | + { | |
2206 | + dbSelect.setOid(oid); | |
2207 | + dbSelect.setRid(rid); | |
2208 | + Query query1 = Query.query(Criteria.where("id").is(dbSelect.getId())); | |
2209 | + Update update = MongoConvertHelper | |
2210 | + .convertToNativeUpdate(ReflectionUtils.getUpdateField(dbSelect)); | |
2211 | + mongoTemplate.updateFirst(query1, update, BabyQhdfyDietSelect.class); | |
2212 | + } | |
2213 | + else | |
2214 | + { | |
2215 | + BabyQhdfyDietSelect select = new BabyQhdfyDietSelect(); | |
2216 | + select.setDietId(dietId); | |
2217 | + select.setOid(oid); | |
2218 | + select.setRid(rid); | |
2219 | + mongoTemplate.save(select); | |
2220 | + } | |
2221 | + BaseResponse objectResponse = new BaseResponse(); | |
2222 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
2223 | + objectResponse.setErrormsg("成功"); | |
2224 | + return objectResponse; | |
2225 | + | |
2178 | 2226 | } |
2179 | 2227 | } |