Commit bae47a3ff19ceb8e615e5a21b71a922f38452e11
1 parent
78ec251d8e
Exists in
master
and in
6 other branches
儿童营养报告
Showing 4 changed files with 53 additions and 16 deletions
- platform-common/src/main/java/com/lyms/platform/common/utils/HttpClientUtil.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyNutritionController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyNutritionFacade.java
- platform-operate-api/src/main/resources/config.properties
platform-common/src/main/java/com/lyms/platform/common/utils/HttpClientUtil.java
View file @
bae47a3
... | ... | @@ -226,14 +226,13 @@ |
226 | 226 | public static void main(String[] args) throws Exception { |
227 | 227 | |
228 | 228 | Map<String,String> map = new HashMap<String, String>(); |
229 | + map.put("categoryId","1"); | |
229 | 230 | map.put("page","1"); |
230 | - map.put("limit","10"); | |
231 | - map.put("patientIds", "5ab064e9e4b087666f0621d7"); | |
232 | - long start = System.currentTimeMillis(); | |
233 | - String s = doGet("https://area-weihai-api.healthbaby.com.cn:12356/getAppLis", map, "utf-8", "3d19960bf3e81e7d816c4f26051c49ba"); | |
234 | - System.out.println(s); | |
235 | - long end = System.currentTimeMillis(); | |
236 | - System.out.print(end -start); | |
231 | + map.put("limit","1000"); | |
232 | +// map.put("nutritionId",nutritionId); | |
233 | +// map.put("title", title); | |
234 | + String s = HttpClientUtil.doGet("http://ams.api.stage.healthbaby.com.cn/v1/foods", map, "utf-8", "3d19960bf3e81e7d816c4f26051c49ba"); | |
235 | + System.out.println(s ); | |
237 | 236 | } |
238 | 237 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyNutritionController.java
View file @
bae47a3
... | ... | @@ -3,17 +3,10 @@ |
3 | 3 | |
4 | 4 | import com.lyms.platform.common.annotation.TokenRequired; |
5 | 5 | import com.lyms.platform.common.base.BaseController; |
6 | -import com.lyms.platform.common.base.LoginContext; | |
7 | -import com.lyms.platform.common.constants.ErrorCodeConstants; | |
8 | 6 | import com.lyms.platform.common.result.BaseObjectResponse; |
9 | 7 | import com.lyms.platform.common.result.BaseResponse; |
10 | -import com.lyms.platform.common.utils.StringUtils; | |
11 | -import com.lyms.platform.operate.web.facade.AutoMatchFacade; | |
12 | -import com.lyms.platform.operate.web.facade.BabyCheckFacade; | |
13 | 8 | import com.lyms.platform.operate.web.facade.BabyNutritionFacade; |
14 | -import com.lyms.platform.operate.web.request.BabyCheckRequest; | |
15 | 9 | import com.lyms.platform.operate.web.request.BabyNutritionRequest; |
16 | -import com.lyms.platform.permission.service.CouponService; | |
17 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
18 | 11 | import org.springframework.stereotype.Controller; |
19 | 12 | import org.springframework.web.bind.annotation.*; |
... | ... | @@ -44,7 +37,7 @@ |
44 | 37 | public BaseResponse addOrUpBabyNutrition(@Valid @RequestBody BabyNutritionRequest request, |
45 | 38 | HttpServletRequest httpServletRequest) { |
46 | 39 | |
47 | - return babyNutritionFacade.addOrUpBabyNutrition(request); | |
40 | + return babyNutritionFacade.addOrUpBabyNutrition(request,getUserId(httpServletRequest)); | |
48 | 41 | } |
49 | 42 | |
50 | 43 | |
... | ... | @@ -71,6 +64,28 @@ |
71 | 64 | public BaseObjectResponse queryBabyNutritionById(@PathVariable("id")String id){ |
72 | 65 | return babyNutritionFacade.queryBabyNutritionById(id); |
73 | 66 | } |
67 | + | |
68 | + | |
69 | + /** | |
70 | + * 从ams获取儿童营养食谱 | |
71 | + * @param categoryId 食物类别 | |
72 | + * @param nutritionId 营养元素 | |
73 | + * @param title 食物名称 | |
74 | + * @param id 食物名称 | |
75 | + * @return | |
76 | + */ | |
77 | + @RequestMapping(value = "/queryBabyNutritionFood", method = RequestMethod.GET) | |
78 | + @ResponseBody | |
79 | + @TokenRequired | |
80 | + public BaseObjectResponse queryBabyNutritionFood(@RequestParam(required = false)String categoryId, | |
81 | + @RequestParam(required = false)String nutritionId, | |
82 | + @RequestParam(required = false)String id, | |
83 | + @RequestParam(required = false)String title){ | |
84 | + return babyNutritionFacade.queryBabyNutritionFood(categoryId,nutritionId,title,id); | |
85 | + } | |
86 | + | |
87 | + | |
88 | + | |
74 | 89 | |
75 | 90 | |
76 | 91 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyNutritionFacade.java
View file @
bae47a3
... | ... | @@ -27,6 +27,8 @@ |
27 | 27 | public class BabyNutritionFacade { |
28 | 28 | |
29 | 29 | |
30 | + public static final String amsUrl = PropertiesUtils.getPropertyValue("ams_url"); | |
31 | + | |
30 | 32 | @Autowired |
31 | 33 | private BabyCheckFacade babyCheckFacade; |
32 | 34 | |
33 | 35 | |
... | ... | @@ -37,7 +39,10 @@ |
37 | 39 | @Autowired |
38 | 40 | private MeasureDataInfoService mysqlMeasureDataInfoService; |
39 | 41 | |
42 | + @Autowired | |
43 | + private AutoMatchFacade autoMatchFacade; | |
40 | 44 | |
45 | + | |
41 | 46 | public BaseObjectResponse queryBabyNutritionRecord(String babyId) { |
42 | 47 | Map<String, Object> resMap = new HashMap<>(); |
43 | 48 | BabyBasicResult base = new BabyBasicResult(); |
... | ... | @@ -47,6 +52,7 @@ |
47 | 52 | List<Map<String, String>> list = new ArrayList<>(); |
48 | 53 | |
49 | 54 | BabyNutritionQuery babyQuery = new BabyNutritionQuery(); |
55 | + babyQuery.setBabyId(babyId); | |
50 | 56 | List<BabyNutritionModel> models = babyNutritionService.queryBabyNutritions(babyQuery); |
51 | 57 | if (CollectionUtils.isNotEmpty(models)) |
52 | 58 | { |
53 | 59 | |
... | ... | @@ -87,8 +93,10 @@ |
87 | 93 | return map; |
88 | 94 | } |
89 | 95 | |
90 | - public BaseResponse addOrUpBabyNutrition(BabyNutritionRequest request) { | |
96 | + public BaseResponse addOrUpBabyNutrition(BabyNutritionRequest request,Integer userId) { | |
91 | 97 | |
98 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
99 | + | |
92 | 100 | BabyNutritionModel model = request.convertToDataModel(); |
93 | 101 | if (StringUtils.isNotEmpty(model.getId())) |
94 | 102 | { |
... | ... | @@ -97,6 +105,7 @@ |
97 | 105 | } |
98 | 106 | else |
99 | 107 | { |
108 | + model.setHospitalId(hospitalId); | |
100 | 109 | model.setModified(new Date()); |
101 | 110 | model.setCreated(new Date()); |
102 | 111 | babyNutritionService.addBabyNutrition(model); |
... | ... | @@ -119,6 +128,17 @@ |
119 | 128 | objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); |
120 | 129 | objectResponse.setErrormsg("成功"); |
121 | 130 | return objectResponse; |
131 | + } | |
132 | + | |
133 | + public BaseObjectResponse queryBabyNutritionFood(String categoryId, String nutritionId, String title,String id) { | |
134 | + | |
135 | + Map<String,String> map = new HashMap<String, String>(); | |
136 | + map.put("categoryId",categoryId); | |
137 | + map.put("nutritionId",nutritionId); | |
138 | + map.put("title", title); | |
139 | + map.put("id", id == null ? null : String.valueOf(id)); | |
140 | + String s = HttpClientUtil.doGet(amsUrl+"/v1/foods", map, "utf-8", "3d19960bf3e81e7d816c4f26051c49ba"); | |
141 | + return null; | |
122 | 142 | } |
123 | 143 | } |
platform-operate-api/src/main/resources/config.properties
View file @
bae47a3