Commit ca15880f82f1b22fe3965265c47e51a656a8ef1f
1 parent
6bff9d20a5
Exists in
master
and in
6 other branches
自测bug提交
Showing 4 changed files with 53 additions and 8 deletions
- platform-dal/src/main/java/com/lyms/platform/pojo/TemporaryWeightModel.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/TemporaryWeightService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/TemporaryWeightServiceImpl.java
platform-dal/src/main/java/com/lyms/platform/pojo/TemporaryWeightModel.java
View file @
ca15880
... | ... | @@ -51,6 +51,15 @@ |
51 | 51 | //高危补充说明 |
52 | 52 | private List otherRisk; |
53 | 53 | |
54 | + private String doctorName; | |
55 | + | |
56 | + public String getDoctorName() { | |
57 | + return doctorName; | |
58 | + } | |
59 | + | |
60 | + public void setDoctorName(String doctorName) { | |
61 | + this.doctorName = doctorName; | |
62 | + } | |
54 | 63 | |
55 | 64 | public String getHighriskDesc() { |
56 | 65 | return highriskDesc; |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TemporaryWeightController.java
View file @
ca15880
... | ... | @@ -3,6 +3,7 @@ |
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; | |
6 | 7 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
7 | 8 | import com.lyms.platform.common.result.BaseObjectResponse; |
8 | 9 | import com.lyms.platform.common.result.BaseResponse; |
... | ... | @@ -10,6 +11,7 @@ |
10 | 11 | import com.lyms.platform.pojo.TemporaryWeightModel; |
11 | 12 | import org.springframework.beans.factory.annotation.Autowired; |
12 | 13 | import org.springframework.stereotype.Controller; |
14 | +import org.springframework.util.Assert; | |
13 | 15 | import org.springframework.web.bind.annotation.*; |
14 | 16 | |
15 | 17 | import javax.servlet.http.HttpServletRequest; |
... | ... | @@ -26,7 +28,7 @@ |
26 | 28 | @TokenRequired |
27 | 29 | @ResponseBody |
28 | 30 | public BaseResponse addTemporaryWeight(@Valid @RequestBody TemporaryWeightModel temporaryWeightModel, HttpServletRequest request) { |
29 | - return temporaryWeightService.addTemporaryWeight(temporaryWeightModel); | |
31 | + return temporaryWeightService.addTemporaryWeight(temporaryWeightModel, getUserId(request)); | |
30 | 32 | } |
31 | 33 | |
32 | 34 | @RequestMapping(value = "/update", method = RequestMethod.PUT) |
... | ... | @@ -52,8 +54,8 @@ |
52 | 54 | @RequestMapping(value = "/queryAll", method = RequestMethod.GET) |
53 | 55 | @TokenRequired |
54 | 56 | @ResponseBody |
55 | - public BaseResponse queryAll(String key, Integer stateWeek, Integer endWeek, Integer age, Integer page, Integer limit) { | |
56 | - return temporaryWeightService.queryAll(key, stateWeek, endWeek, age, page, limit); | |
57 | + public BaseResponse queryAll(String key, Integer stateWeek, Integer endWeek, Integer age, Integer page, Integer limit, HttpServletRequest request) { | |
58 | + return temporaryWeightService.queryAll(key, stateWeek, endWeek, age, page, limit, getUserId(request)); | |
57 | 59 | } |
58 | 60 | |
59 | 61 | @ResponseBody |
... | ... | @@ -98,5 +100,10 @@ |
98 | 100 | return temporaryWeightService.report(id, getUserId(request), rid); |
99 | 101 | } |
100 | 102 | |
103 | + protected Integer getUserId(HttpServletRequest request) { | |
104 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
105 | + Assert.notNull(loginState, "未登录"); | |
106 | + return loginState.getId(); | |
107 | + } | |
101 | 108 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/TemporaryWeightService.java
View file @
ca15880
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | |
7 | 7 | public interface TemporaryWeightService extends IBaseService { |
8 | 8 | |
9 | - BaseResponse addTemporaryWeight(TemporaryWeightModel weightModel); | |
9 | + BaseResponse addTemporaryWeight(TemporaryWeightModel weightModel, Integer userId); | |
10 | 10 | |
11 | 11 | void updateTemporaryWeight(Query query, TemporaryWeightModel weightModel); |
12 | 12 | |
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | |
15 | 15 | BaseResponse queryOne(String phone); |
16 | 16 | |
17 | - BaseResponse queryAll(String key, Integer stateWeek, Integer endWeek, Integer age, Integer page, Integer limit); | |
17 | + BaseResponse queryAll(String key, Integer stateWeek, Integer endWeek, Integer age, Integer page, Integer limit, Integer userId); | |
18 | 18 | |
19 | 19 | BaseResponse info(String phone); |
20 | 20 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/TemporaryWeightServiceImpl.java
View file @
ca15880
... | ... | @@ -18,7 +18,9 @@ |
18 | 18 | import com.lyms.platform.operate.web.utils.MathUtil; |
19 | 19 | import com.lyms.platform.operate.web.utils.ReportConfig; |
20 | 20 | import com.lyms.platform.permission.model.Organization; |
21 | +import com.lyms.platform.permission.model.Users; | |
21 | 22 | import com.lyms.platform.permission.service.OrganizationService; |
23 | +import com.lyms.platform.permission.service.UsersService; | |
22 | 24 | import com.lyms.platform.pojo.*; |
23 | 25 | import org.apache.commons.collections.MapUtils; |
24 | 26 | import org.springframework.beans.factory.annotation.Autowired; |
25 | 27 | |
... | ... | @@ -55,9 +57,11 @@ |
55 | 57 | @Autowired |
56 | 58 | private BasicConfigService basicConfigService; |
57 | 59 | |
60 | + @Autowired | |
61 | + private UsersService usersService; | |
58 | 62 | |
59 | 63 | @Override |
60 | - public BaseResponse addTemporaryWeight(TemporaryWeightModel weightModel) { | |
64 | + public BaseResponse addTemporaryWeight(TemporaryWeightModel weightModel, Integer userId) { | |
61 | 65 | if (StringUtils.isNotEmpty(weightModel.getPhone())) { |
62 | 66 | TemporaryWeightModel temporaryWeightModel = mongoTemplate.findOne(Query.query(Criteria.where("phone").is(weightModel.getPhone())), TemporaryWeightModel.class); |
63 | 67 | if (temporaryWeightModel != null) { |
... | ... | @@ -70,6 +74,8 @@ |
70 | 74 | weightModel.setYn(1); |
71 | 75 | weightModel.setModified(new Date()); |
72 | 76 | weightModel.setCreated(new Date()); |
77 | + Users users = usersService.getUsers(userId); | |
78 | + weightModel.setDoctorName(users.getAccount()); | |
73 | 79 | Map<String, String> dayWeights = new LinkedHashMap<>(); |
74 | 80 | List<Map<String, Object>> dayWeights2 = new ArrayList<>(); |
75 | 81 | /* if (MapUtils.isNotEmpty(temporaryWeightModel.getDayWeights())) { |
... | ... | @@ -107,7 +113,7 @@ |
107 | 113 | } |
108 | 114 | |
109 | 115 | @Override |
110 | - public BaseResponse queryAll(String key, Integer stateWeek, Integer endWeek, Integer age, Integer page, Integer limit) { | |
116 | + public BaseResponse queryAll(String key, Integer stateWeek, Integer endWeek, Integer age, Integer page, Integer limit, Integer userId) { | |
111 | 117 | boolean flag = false; |
112 | 118 | Criteria pCriteria = Criteria.where("yn").ne(0); |
113 | 119 | Criteria criteria = Criteria.where("yn").ne(0); |
114 | 120 | |
... | ... | @@ -135,8 +141,31 @@ |
135 | 141 | } |
136 | 142 | criteria.and("_id").in(ids); |
137 | 143 | } |
144 | + Users users = usersService.getUsers(userId); | |
145 | + System.out.println("=========>" + users.getAccount()); | |
146 | + | |
138 | 147 | PageResult pageResult = findMongoPage(TemporaryWeightModel.class, new Query(criteria).with(new Sort(Sort.Direction.DESC, "modified")), page, limit); |
139 | - return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(pageResult); | |
148 | + List<TemporaryWeightModel> patientWeights = (List<TemporaryWeightModel>) pageResult.getGrid(); | |
149 | + List<Map<String, Object>> restMap = new ArrayList<>(); | |
150 | + if (CollectionUtils.isNotEmpty(patientWeights)) { | |
151 | + for (TemporaryWeightModel patientWeight : patientWeights) { | |
152 | + // Patients p = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); | |
153 | + Map<String, Object> temp = new LinkedHashMap<>(); | |
154 | + temp.put("id", patientWeight.getId()); | |
155 | + temp.put("username", patientWeight.getUserName()); | |
156 | + temp.put("age", patientWeight.getAge()); | |
157 | + temp.put("week", DateUtil.getWeekDesc(patientWeight.getLastMenses(), new Date())); | |
158 | + temp.put("beforeWeight", patientWeight.getBeforeWeight()); | |
159 | + temp.put("beforeHeight", patientWeight.getBeforeHeight()); | |
160 | + temp.put("bim", patientWeight.getBmi()); // 体质指数(BMI)=体重(kg)÷身高^2(m) | |
161 | + temp.put("nowWeight", patientWeight.getNowWeight()); | |
162 | + temp.put("time", DateUtil.getyyyy_MM_dd(patientWeight.getModified())); | |
163 | + temp.put("doctorName", patientWeight.getDoctorName()); | |
164 | + restMap.add(temp); | |
165 | + } | |
166 | + } | |
167 | + pageResult.setGrid(restMap); | |
168 | + return RespBuilder.buildSuccess(pageResult); | |
140 | 169 | } |
141 | 170 | |
142 | 171 |