Commit 2bfd7a372b3d2f24255ddcba8b858b8086214829
1 parent
632d26390d
Exists in
master
提交代码
Showing 6 changed files with 278 additions and 31 deletions
- mainData/src/main/java/com/lymsh/yimiao/main/data/model/MedKids.java
- mainData/src/main/resources/mainOrm/MedKids.xml
- webApi/src/main/java/com/lyms/yimiao/web/controller/v1/KidsController.java
- webApi/src/main/java/com/lyms/yimiao/web/controller/v1/NotificationsController.java
- webApi/src/main/java/com/lyms/yimiao/web/controller/v1/UserController.java
- webApi/src/main/java/com/lyms/yimiao/web/controller/v1/VaccineNamesController.java
mainData/src/main/java/com/lymsh/yimiao/main/data/model/MedKids.java
View file @
2bfd7a3
... | ... | @@ -13,6 +13,26 @@ |
13 | 13 | private String buildTime;//建档时间 |
14 | 14 | private String isDelete;//宝宝是否有效 |
15 | 15 | |
16 | + private String fatherName; | |
17 | + private String motherName; | |
18 | + | |
19 | + public String getMotherName() { | |
20 | + return motherName; | |
21 | + } | |
22 | + | |
23 | + public void setMotherName(String motherName) { | |
24 | + this.motherName = motherName; | |
25 | + } | |
26 | + | |
27 | + public String getFatherName() { | |
28 | + | |
29 | + return fatherName; | |
30 | + } | |
31 | + | |
32 | + public void setFatherName(String fatherName) { | |
33 | + this.fatherName = fatherName; | |
34 | + } | |
35 | + | |
16 | 36 | public String getIsDelete() { |
17 | 37 | return isDelete; |
18 | 38 | } |
... | ... | @@ -100,6 +120,30 @@ |
100 | 120 | |
101 | 121 | public void setCurrentOrganizationId(String currentOrganizationId) { |
102 | 122 | this.currentOrganizationId = currentOrganizationId; |
123 | + } | |
124 | + | |
125 | + @Override | |
126 | + public boolean equals(Object o) { | |
127 | + if (this == o) return true; | |
128 | + if (o == null || getClass() != o.getClass()) return false; | |
129 | + | |
130 | + MedKids medKids = (MedKids) o; | |
131 | + | |
132 | + if (!buildTime.equals(medKids.buildTime)) return false; | |
133 | + if (!fatherName.equals(medKids.fatherName)) return false; | |
134 | + if (!motherName.equals(medKids.motherName)) return false; | |
135 | + if (!phone.equals(medKids.phone)) return false; | |
136 | + | |
137 | + return true; | |
138 | + } | |
139 | + | |
140 | + @Override | |
141 | + public int hashCode() { | |
142 | + int result = phone.hashCode(); | |
143 | + result = 31 * result + buildTime.hashCode(); | |
144 | + result = 31 * result + fatherName.hashCode(); | |
145 | + result = 31 * result + motherName.hashCode(); | |
146 | + return result; | |
103 | 147 | } |
104 | 148 | } |
mainData/src/main/resources/mainOrm/MedKids.xml
View file @
2bfd7a3
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | </resultMap> |
18 | 18 | |
19 | 19 | <select id="getMedKids" resultMap="MedKidsResultMap" parameterType="java.lang.String"> |
20 | -select ki_id,ki_name,ki_sex,ki_birthday,ki_guardianid,ki_currentOrganizationid,ki_barCode,phone,ki_buildoper, ki_buildtime,isdelete | |
20 | +select ki_id,ki_name,ki_sex,ki_birthday,ki_guardianid,ki_currentOrganizationid,ki_barCode,phone,ki_buildoper, ki_buildtime,isdelete,fathername,mothername | |
21 | 21 | from med_kids |
22 | 22 | WHERE ki_id = #{id,jdbcType=VARCHAR} |
23 | 23 | </select> |
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | |
37 | 37 | <sql id="MedKidsCondition"> |
38 | 38 | <where> |
39 | - 1 = 1 | |
39 | + 1 = 1 | |
40 | 40 | <if test="id != null and id != ''"> |
41 | 41 | and ki_id = #{id,jdbcType=VARCHAR} |
42 | 42 | </if> |
... | ... | @@ -76,7 +76,7 @@ |
76 | 76 | |
77 | 77 | |
78 | 78 | <select id="queryMedKids" resultMap="MedKidsResultMap" parameterType="com.lymsh.yimiao.main.data.model.MedKidsQuery"> |
79 | -select ki_id,ki_name,ki_sex,ki_birthday,ki_guardianid,ki_currentOrganizationid,ki_barCode,phone,ki_buildoper, ki_buildtime,isdelete | |
79 | +select ki_id,ki_name,ki_sex,ki_birthday,ki_guardianid,ki_currentOrganizationid,ki_barCode,phone,ki_buildoper, ki_buildtime,isdelete,fathername,mothername | |
80 | 80 | from med_kids |
81 | 81 | <include refid="MedKidsCondition" /> |
82 | 82 | <include refid="orderAndLimit" /> |
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/KidsController.java
View file @
2bfd7a3
... | ... | @@ -4,8 +4,7 @@ |
4 | 4 | import com.lymsh.mommybaby.basecommon.base.TokenRequired; |
5 | 5 | import com.lymsh.mommybaby.basecommon.cache.redis.RedisUtils; |
6 | 6 | import com.lymsh.mommybaby.basecommon.constant.ConstantInterface; |
7 | -import com.lymsh.mommybaby.basecommon.context.MommyBobyContext; | |
8 | -import com.lymsh.mommybaby.basecommon.util.ContextHolder; | |
7 | +import com.lymsh.mommybaby.basecommon.util.DateUtil; | |
9 | 8 | import com.lymsh.mommybaby.basecommon.util.ResultUtils; |
10 | 9 | import com.lymsh.yimiao.main.data.enumdata.YnEnum; |
11 | 10 | import com.lymsh.yimiao.main.data.model.*; |
... | ... | @@ -140,7 +139,7 @@ |
140 | 139 | medKidsQuery.setBirthday(birthday); |
141 | 140 | medKidsQuery.setBarCode(barCode); |
142 | 141 | medKidsQuery.setPhone(phone); |
143 | - //medKidsQuery.setSort("");//时间排序 | |
142 | + medKidsQuery.setSort("ki_buildtime desc");//时间排序 | |
144 | 143 | medKidsQuery.setIsDelete("1"); |
145 | 144 | List<MedKids> medKidsList = medKidsService.queryMedKids(medKidsQuery); |
146 | 145 | |
147 | 146 | |
148 | 147 | |
149 | 148 | |
150 | 149 | |
... | ... | @@ -148,16 +147,125 @@ |
148 | 147 | |
149 | 148 | if (CollectionUtils.isNotEmpty(medKidsList)){ |
150 | 149 | //TODO 查出来的数据,可能会多条一样的和不一样的,有多条一样的情况下,取最新的一条,不一样的正常返回 |
150 | + | |
151 | + Set<MedKids> set = new HashSet<>(); | |
152 | + | |
153 | + Map<MedKids,MedKids> map = new HashMap<>(); | |
154 | + | |
151 | 155 | for (MedKids data :medKidsList){ |
152 | - Map<String,Object> map = new HashMap<>(); | |
153 | - map.put("id",data.getId()); | |
154 | - map.put("name",data.getName()); | |
155 | - list.add(map); | |
156 | + | |
157 | + if (map.containsKey(data)){ | |
158 | + MedKids kids = map.get(data); | |
159 | + Date mapDate = DateUtil.parseYMD(kids.getBuildTime()); | |
160 | + Date dataDate = DateUtil.parseYMD(data.getBuildTime()); | |
161 | + if(mapDate.after(dataDate)) { | |
162 | + map.put(data, data); | |
163 | + } | |
164 | + }else { | |
165 | + set.add(data); | |
166 | + map.put(data,data); | |
167 | + } | |
156 | 168 | } |
169 | + | |
170 | + | |
171 | + | |
172 | + | |
173 | + | |
157 | 174 | } |
175 | + | |
158 | 176 | ResultUtils.buildSuccessResultAndWrite(response,list); |
159 | 177 | } |
160 | 178 | |
179 | + | |
180 | + public static void main(String[] str) { | |
181 | + final Kids kids = new Kids(); | |
182 | + kids.setPhone("110"); | |
183 | + kids.setName("罗野"); | |
184 | + kids.setFatherName("罗芭"); | |
185 | + kids.setMotherName("罗马"); | |
186 | + kids.setCreated("2016-05-04"); | |
187 | + kids.setNumber(1); | |
188 | + | |
189 | + | |
190 | + Kids kids1 = new Kids(); | |
191 | + kids1.setPhone("110"); | |
192 | + kids1.setName("罗野"); | |
193 | + kids1.setFatherName("罗芭"); | |
194 | + kids1.setMotherName("罗马"); | |
195 | + kids1.setCreated("2016-05-11"); | |
196 | + kids1.setNumber(3); | |
197 | + | |
198 | + | |
199 | + Kids kids2 = new Kids(); | |
200 | + kids2.setPhone("110"); | |
201 | + kids2.setName("罗小野"); | |
202 | + kids2.setFatherName("罗芭"); | |
203 | + kids2.setMotherName("罗马"); | |
204 | + kids2.setCreated("2016-05-03"); | |
205 | + List<Kids> list = new ArrayList<>(); | |
206 | + list.add(kids); | |
207 | + list.add(kids1); | |
208 | + list.add(kids2); | |
209 | + Set<Kids> set = new HashSet<>(); | |
210 | + Map<Kids,Kids> map = new HashMap<>(); | |
211 | + | |
212 | + | |
213 | + List<Kids> list1 = new ArrayList<>(); | |
214 | + List<Kids> list2 = new ArrayList<>(); | |
215 | + | |
216 | + for (Kids data : list) { | |
217 | + | |
218 | + if (!list1.contains(data)){ | |
219 | + list1.add(data); | |
220 | + }else { | |
221 | + list2.add(data); | |
222 | + } | |
223 | + | |
224 | + | |
225 | +// if (map.containsKey(data)) { | |
226 | +// Kids k = map.get(data); | |
227 | +// Date mapDate = DateUtil.parseYMD(k.getCreated()); | |
228 | +// Date dataDate = DateUtil.parseYMD(data.getCreated()); | |
229 | +// if(mapDate.getTime()> dataDate.getTime()) { | |
230 | +// map.put(data, data); | |
231 | +// } | |
232 | +// } else{ | |
233 | +// set.add(data); | |
234 | +// map.put(data,data); | |
235 | +// } | |
236 | + } | |
237 | + | |
238 | + List<Kids> a = new ArrayList<>(set); | |
239 | + | |
240 | +// Collections.sort(a, new Comparator<Kids>() { | |
241 | +// | |
242 | +// private String key ="created"; | |
243 | +// | |
244 | +// @Override | |
245 | +// public int compare(Kids o1, Kids o2) { | |
246 | +// if (o1.getCreated()!=null && o2.getCreated()!=null){ | |
247 | +// if (o1.getCreated().getTime() ==o2.getCreated().getTime()) { | |
248 | +// return 0; | |
249 | +// } | |
250 | +// if (o1.getCreated().getTime() >o2.getCreated().getTime()){ | |
251 | +// return -1; | |
252 | +// }else { | |
253 | +// return 1; | |
254 | +// } | |
255 | +// } | |
256 | +// return 0; | |
257 | +// } | |
258 | +// }); | |
259 | + | |
260 | + for (Kids data :a){ | |
261 | + System.out.println(data.getName()); | |
262 | + System.out.println(data.getCreated()); | |
263 | + System.out.println(data.getNumber()); | |
264 | + } | |
265 | + | |
266 | + } | |
267 | + | |
268 | + | |
161 | 269 | /** |
162 | 270 | * 添加宝宝接口(当前登陆用户与小孩子进行关联 |
163 | 271 | * @param response |
164 | 272 | |
165 | 273 | |
166 | 274 | |
... | ... | @@ -218,23 +326,22 @@ |
218 | 326 | Map<String, Object> map = new HashMap<>(); |
219 | 327 | map.put("id", kids.getId()); |
220 | 328 | map.put("name", kids.getName()); |
221 | - //TODO 这里需要把这个字符串转换成时间戳 | |
222 | - map.put("birthday", kids.getBirthday()); | |
329 | + map.put("birthday", DateUtil.getSecond(DateUtil.parseYMD(kids.getBirthday()))); | |
223 | 330 | |
224 | 331 | MedInoculateOrderQuery inoculateorderQuery = new MedInoculateOrderQuery(); |
225 | 332 | inoculateorderQuery.setIoKidId(id); |
226 | 333 | //时间倒序 |
227 | - inoculateorderQuery.setIoInoculateTime("ioInoculateTime desc"); | |
334 | + inoculateorderQuery.setSort("io_inoculateDate desc"); | |
228 | 335 | List<MedInoculateOrder> inoculateorderList = medInoculateorderService.queryMedInoculateOrder(inoculateorderQuery); |
229 | 336 | if (CollectionUtils.isNotEmpty(inoculateorderList)) { |
230 | 337 | //取出离现在日期最近的一个预约接种 |
231 | 338 | MedInoculateOrder medInoculateorder = inoculateorderList.get(0); |
232 | 339 | //下次接种时间 |
233 | - map.put("ioInoculateTime", medInoculateorder.getIoInoculateTime()); | |
340 | + map.put("ioInoculateDate", DateUtil.getSecond(DateUtil.parseYMD(medInoculateorder.getIoInoculateDate()))); | |
234 | 341 | //下次接种疫苗 |
235 | 342 | map.put("vaccineId", medInoculateorder.getIoVaccineId()); |
236 | - MedVaccineInfo medVaccineinfo = medVaccineinfoService.getMedVaccineInfo(medInoculateorder.getIoVaccineId()); | |
237 | - map.put("vaccineName", medVaccineinfo == null ? "" : medVaccineinfo.getViName()); | |
343 | + MedVaccineName medVaccineName = medVaccineNameService.getMedVaccineName(medInoculateorder.getIoVaccineId()); | |
344 | + map.put("vaccineName", medVaccineName == null ? "" : medVaccineName.getVnName()); | |
238 | 345 | //接种地点 |
239 | 346 | map.put("organizationId", medInoculateorder.getIoOrganizationId()); |
240 | 347 | MedOrganization medOrganization = medOrganizationService.getMedOrganization(medInoculateorder.getIoOrganizationId()); |
241 | 348 | |
242 | 349 | |
... | ... | @@ -303,21 +410,18 @@ |
303 | 410 | } |
304 | 411 | } |
305 | 412 | |
306 | - | |
307 | - | |
308 | - | |
309 | - | |
310 | - | |
311 | - | |
312 | - | |
313 | - | |
314 | - | |
315 | - | |
316 | - | |
317 | 413 | } |
318 | 414 | |
415 | + /** | |
416 | + * 获取接种记录 | |
417 | + * @param response | |
418 | + * @param request | |
419 | + */ | |
420 | + @RequestMapping(value = "/inoculateRecord", method = RequestMethod.GET) | |
421 | + @TokenRequired | |
422 | + public void getKidVaccines(HttpServletResponse response,HttpServletRequest request){ | |
319 | 423 | |
320 | - | |
424 | + } | |
321 | 425 | |
322 | 426 | |
323 | 427 | } |
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/NotificationsController.java
View file @
2bfd7a3
1 | 1 | package com.lyms.yimiao.web.controller.v1; |
2 | 2 | |
3 | 3 | import com.lymsh.mommybaby.basecommon.base.BaseController; |
4 | +import com.lymsh.mommybaby.basecommon.base.TokenRequired; | |
5 | +import com.lymsh.mommybaby.basecommon.bean.CommonResult; | |
6 | +import com.lymsh.mommybaby.basecommon.util.DateUtil; | |
7 | +import com.lymsh.mommybaby.basecommon.util.ResultUtils; | |
8 | +import com.lymsh.yimiao.main.data.enumdata.YnEnum; | |
9 | +import com.lymsh.yimiao.main.data.model.YmNotifications; | |
10 | +import com.lymsh.yimiao.main.data.model.YmNotificationsQuery; | |
11 | +import com.lymsh.yimiao.main.data.service.YmNotificationsService; | |
12 | +import org.apache.commons.collections.CollectionUtils; | |
13 | +import org.springframework.beans.factory.annotation.Autowired; | |
4 | 14 | import org.springframework.stereotype.Controller; |
5 | 15 | import org.springframework.web.bind.annotation.RequestMapping; |
16 | +import org.springframework.web.bind.annotation.RequestMethod; | |
17 | +import org.springframework.web.bind.annotation.RequestParam; | |
6 | 18 | |
19 | +import javax.management.Notification; | |
20 | +import javax.servlet.http.HttpServletResponse; | |
21 | +import java.util.ArrayList; | |
22 | +import java.util.HashMap; | |
23 | +import java.util.List; | |
24 | +import java.util.Map; | |
25 | + | |
7 | 26 | /** |
8 | 27 | * |
9 | 28 | * 消息接口 |
10 | 29 | |
11 | 30 | |
... | ... | @@ -14,8 +33,43 @@ |
14 | 33 | @RequestMapping("/v1") |
15 | 34 | public class NotificationsController extends BaseController{ |
16 | 35 | |
36 | + @Autowired | |
37 | + private YmNotificationsService notificationsService; | |
38 | + | |
17 | 39 | //获取消息(1.系统消息2.接种消息) |
40 | + @RequestMapping(value = "/notifications", method = RequestMethod.GET) | |
41 | + @TokenRequired | |
42 | + public void getNotifications(HttpServletResponse response, | |
43 | + @RequestParam("page") int page, | |
44 | + @RequestParam("limit") int limit ){ | |
18 | 45 | |
46 | + YmNotificationsQuery notificationsQuery = new YmNotificationsQuery(); | |
47 | + notificationsQuery.setYn(YnEnum.yes.getId()); | |
48 | + | |
49 | + notificationsQuery.setPage(page); | |
50 | + notificationsQuery.setLimit(limit); | |
51 | + notificationsQuery.setSort("created desc"); | |
52 | + notificationsQuery.setNeed("y"); | |
53 | + | |
54 | + List<YmNotifications> notificationsList = notificationsService.queryYmNotifications(notificationsQuery); | |
55 | + | |
56 | + List<Map> list = new ArrayList<>(); | |
57 | + | |
58 | + if (CollectionUtils.isNotEmpty(notificationsList)){ | |
59 | + for (YmNotifications data : notificationsList){ | |
60 | + Map<String,Object> map = new HashMap<>(); | |
61 | + map.put("id",data.getId()); | |
62 | + map.put("created", DateUtil.getSecond(data.getCreated())); | |
63 | + map.put("type",data.getType()); | |
64 | + map.put("content",data.getContent()); | |
65 | + list.add(map); | |
66 | + } | |
67 | + } | |
68 | + CommonResult result = new CommonResult(); | |
69 | + result.setList(list); | |
70 | + result.setPageInfo(notificationsQuery.getPageInfo()); | |
71 | + ResultUtils.buildSuccessResultAndWrite(response,result); | |
72 | + } | |
19 | 73 | |
20 | 74 | //定时发送给当前登录用户接种通知 |
21 | 75 | /* |
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/UserController.java
View file @
2bfd7a3
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | import com.lymsh.yimiao.main.data.util.LoginContext; |
16 | 16 | import com.lymsh.yimiao.main.data.util.LoginUtil; |
17 | 17 | import com.lymsh.yimiao.main.data.util.PhoneUtil; |
18 | +import org.apache.commons.collections.CollectionUtils; | |
18 | 19 | import org.springframework.beans.factory.annotation.Autowired; |
19 | 20 | import org.springframework.beans.factory.annotation.Value; |
20 | 21 | import org.springframework.http.MediaType; |
... | ... | @@ -106,6 +107,30 @@ |
106 | 107 | writeJson(response, JsonUtil.obj2JsonString(map)); |
107 | 108 | }else { |
108 | 109 | ResultUtils.buildParameterErrorResultAndWrite(response,"登陆失败,异常"); |
110 | + } | |
111 | + } | |
112 | + | |
113 | + //暫時獲取token接口 | |
114 | + @RequestMapping(value = "/userlogin", method = RequestMethod.POST) | |
115 | + public void userLogin(HttpServletResponse response, | |
116 | + @RequestParam("phone") String phone){ | |
117 | + YmUsersQuery query = new YmUsersQuery(); | |
118 | + query.setPhone(phone); | |
119 | + query.setYn(YnEnum.yes.getId()); | |
120 | + List<YmUsers> usersList = usersService.queryYmUsers(query); | |
121 | + Map<String, Object> map = new HashMap<>(); | |
122 | + if (CollectionUtils.isNotEmpty(usersList)){ | |
123 | + YmUsers users = usersList.get(0); | |
124 | + String token = tokenService.createToken(users.getId()); | |
125 | + map.put("token", token); | |
126 | + map.put("id", users.getId()); | |
127 | + users.setLastLoginTime(new Date()); | |
128 | + usersService.updateYmUsers(users); | |
129 | + map.put("errorcode", 0); | |
130 | + map.put("errormsg", "成功"); | |
131 | + writeJson(response,JsonUtil.obj2JsonString(map)); | |
132 | + }else { | |
133 | + ResultUtils.buildParameterErrorResultAndWrite(response,"該手機不存在,請註冊"); | |
109 | 134 | } |
110 | 135 | } |
111 | 136 |
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/VaccineNamesController.java
View file @
2bfd7a3
... | ... | @@ -12,7 +12,9 @@ |
12 | 12 | import org.springframework.web.bind.annotation.RequestParam; |
13 | 13 | |
14 | 14 | import javax.servlet.http.HttpServletResponse; |
15 | +import java.util.ArrayList; | |
15 | 16 | import java.util.HashMap; |
17 | +import java.util.List; | |
16 | 18 | import java.util.Map; |
17 | 19 | |
18 | 20 | /** 疫苗信息接口 |
19 | 21 | |
... | ... | @@ -46,12 +48,30 @@ |
46 | 48 | map.put("title",medVaccineName.getVnName()); |
47 | 49 | //接种预防疾病 |
48 | 50 | map.put("preventDisease",medVaccineName.getVnPreventDisease()); |
49 | - //TODO 接种月龄 需要处理成 3月龄(1/2),6月龄(2/2) | |
50 | - map.put("mouthAge",medVaccineName.getVnMonthAge()); | |
51 | + // 接种月龄 需要处理成 3月龄(1/2),6月龄(2/2) | |
52 | + | |
53 | + String mouthAge = null; | |
54 | + | |
55 | + if (medVaccineName.getVnMonthAge()!=null){ | |
56 | + String[] ages = medVaccineName.getVnMonthAge().split(",");//1,2 | |
57 | + List<String> list = new ArrayList(); | |
58 | + for (int j = 0; j < ages.length ; j++) { | |
59 | + String q = ages[j]+"月齡"+"("+ (j+1) +"/"+ages.length+")"; | |
60 | + list.add(q); | |
61 | + } | |
62 | + StringBuffer q = new StringBuffer(); | |
63 | + for (String a : list){ | |
64 | + q = q.append(a).append(","); | |
65 | + } | |
66 | + q.deleteCharAt(q.length()-1); | |
67 | + | |
68 | + mouthAge = new String(q); | |
69 | + } | |
70 | + map.put("mouthAge",mouthAge); | |
51 | 71 | //接种部位 |
52 | 72 | map.put("position",medVaccineName.getVnPosition()); |
53 | 73 | //TODO 接种效果 |
54 | - | |
74 | + map.put("InoculateEffect",null); | |
55 | 75 | //接种禁忌 |
56 | 76 | map.put("taboo",medVaccineName.getVnTaboo()); |
57 | 77 | //不良反应 |