Commit 34ba2fb593a7d63e83785f10b0c7f13dc2634398

Authored by yangfei

Merge remote-tracking branch 'origin/master'

Showing 8 changed files

platform-common/src/main/java/com/lyms/platform/common/enums/NextVisitTimeEnums.java View file @ 34ba2fb
1 1 package com.lyms.platform.common.enums;
2 2  
  3 +import com.lyms.platform.common.utils.StringUtils;
  4 +
3 5 /**
4 6 * 下次访视时间 :出生0-42天
5 7 * Created by lt on 2017/7/18 0018
... ... @@ -52,9 +54,22 @@
52 54 private Integer id;
53 55 private String name;
54 56  
55   - public static FeedTypeEnums get(Integer id) {
56   - FeedTypeEnums[] values = FeedTypeEnums.values();
57   - for (FeedTypeEnums value : values) {
  57 + public static NextVisitTimeEnums getName(String id) {
  58 + if(StringUtils.isNotEmpty(id)) {
  59 + NextVisitTimeEnums[] values = NextVisitTimeEnums.values();
  60 + for (NextVisitTimeEnums value : values) {
  61 + if (value.getId() == Integer.parseInt(id)) {
  62 + return value;
  63 + }
  64 + }
  65 + }
  66 + return null;
  67 + }
  68 +
  69 +
  70 + public static NextVisitTimeEnums get(Integer id) {
  71 + NextVisitTimeEnums[] values = NextVisitTimeEnums.values();
  72 + for (NextVisitTimeEnums value : values) {
58 73 if (value.getId() == id) {
59 74 return value;
60 75 }
platform-common/src/main/java/com/lyms/platform/common/utils/ReflectionUtils.java View file @ 34ba2fb
1 1 package com.lyms.platform.common.utils;
2 2  
  3 +import java.beans.BeanInfo;
  4 +import java.beans.Introspector;
  5 +import java.beans.PropertyDescriptor;
3 6 import java.lang.reflect.Field;
4 7 import java.lang.reflect.InvocationTargetException;
5 8 import java.lang.reflect.Method;
... ... @@ -34,6 +37,32 @@
34 37 String getterMethodName = "get" + StringUtils.capitalize(propertyName);
35 38 return invokeMethod(obj, getterMethodName, new Class[] {},
36 39 new Object[] {});
  40 + }
  41 +
  42 + public static Map<String, Object> beanToMap(Object obj) {
  43 + if(obj == null){
  44 + return null;
  45 + }
  46 + Map<String, Object> map = new HashMap<String, Object>();
  47 + try {
  48 + BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
  49 + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
  50 + for (PropertyDescriptor property : propertyDescriptors) {
  51 + String key = property.getName();
  52 + // 过滤class属性
  53 + if (!key.equals("class")) {
  54 + // 得到property对应的getter方法
  55 + Method getter = property.getReadMethod();
  56 + Object value = getter.invoke(obj);
  57 +
  58 + map.put(key, value);
  59 + }
  60 + }
  61 + } catch (Exception e) {
  62 + e.printStackTrace();
  63 + }
  64 + return map;
  65 +
37 66 }
38 67  
39 68 /**
platform-dal/src/main/java/com/lyms/platform/pojo/NewbornVisit.java View file @ 34ba2fb
... ... @@ -149,10 +149,10 @@
149 149 private String visitLocation;
150 150  
151 151 // 下次访视时间 前端是枚举:出生0-42天
152   - private Date nextVisitTime;
  152 + private String nextVisitTime;
153 153  
154   - // 下次访视时间说明
155   - private String nextVisitTimeDesc;
  154 + // 下次访视时间
  155 + private Date nextVisitTimeDesc;
156 156  
157 157 public String getId() {
158 158 return id;
159 159  
160 160  
161 161  
... ... @@ -514,19 +514,19 @@
514 514 this.visitLocation = visitLocation;
515 515 }
516 516  
517   - public Date getNextVisitTime() {
  517 + public String getNextVisitTime() {
518 518 return nextVisitTime;
519 519 }
520 520  
521   - public void setNextVisitTime(Date nextVisitTime) {
  521 + public void setNextVisitTime(String nextVisitTime) {
522 522 this.nextVisitTime = nextVisitTime;
523 523 }
524 524  
525   - public String getNextVisitTimeDesc() {
  525 + public Date getNextVisitTimeDesc() {
526 526 return nextVisitTimeDesc;
527 527 }
528 528  
529   - public void setNextVisitTimeDesc(String nextVisitTimeDesc) {
  529 + public void setNextVisitTimeDesc(Date nextVisitTimeDesc) {
530 530 this.nextVisitTimeDesc = nextVisitTimeDesc;
531 531 }
532 532  
platform-msg-generate/src/main/java/com/lyms/platform/msg/remote/AmsMessageService.java View file @ 34ba2fb
... ... @@ -154,7 +154,7 @@
154 154 }
155 155  
156 156 public static void main(String[] args) {
157   - Map<String,List<MessageContent>> list = getMessageTemplateMap("202",
  157 + Map<String,List<MessageContent>> list = getMessageTemplateMap("216",
158 158 AmsServiceTypeEnum.YUN_GUIDE);
159 159 List<MessageContent> msgs = list.get("年龄≥35岁");
160 160 System.out.println(msgs);
platform-msg-generate/src/main/java/com/lyms/platform/msg/utils/DateUtils.java View file @ 34ba2fb
... ... @@ -245,5 +245,30 @@
245 245 return 0;
246 246 }
247 247  
  248 +
  249 + /**
  250 + * 获取两个日期相差几个月
  251 + * @param start
  252 + * @param end
  253 + * @return
  254 + */
  255 + public static int getBetweenMonths(Date start, Date end) {
  256 + int result = 0;
  257 + try {
  258 + Calendar c1 = Calendar.getInstance();
  259 + Calendar c2 = Calendar.getInstance();
  260 + c1.setTime(start);
  261 + c2.setTime(end);
  262 + result = c2.get(Calendar.MONTH) - c1.get(Calendar.MONTH);
  263 + result += 12 * (c2.get(Calendar.YEAR) - c1.get(Calendar.YEAR));
  264 + if(c2.get(Calendar.DAY_OF_MONTH) - c1.get(Calendar.DAY_OF_MONTH) < 0 && result > 0) {
  265 + result -= 1;
  266 + }
  267 + } catch (Exception e) {
  268 + e.printStackTrace();
  269 + }
  270 + return Math.abs(result);
  271 + }
  272 +
248 273 }
platform-msg-generate/src/main/java/com/lyms/platform/msg/utils/HelperUtils.java View file @ 34ba2fb
... ... @@ -15,6 +15,7 @@
15 15 import org.slf4j.Logger;
16 16 import org.slf4j.LoggerFactory;
17 17  
  18 +import java.util.Calendar;
18 19 import java.util.Date;
19 20 import java.util.List;
20 21 import java.util.Map;
21 22  
... ... @@ -336,8 +337,11 @@
336 337 * @return
337 338 */
338 339 public static String getMonthYear(Date birth, Date currentDate) {
339   - int month = DateUtils.daysBetween(birth,currentDate);
  340 + int month = DateUtils.getBetweenMonths(birth, currentDate);
340 341 return month+"月龄";
341 342 }
  343 +
  344 +
  345 +
342 346 }
platform-msg-generate/src/main/resources/config.properties View file @ 34ba2fb
... ... @@ -7,7 +7,7 @@
7 7  
8 8 #AMS地址 线上:http://data.api.healthbaby.com.cn/v1/messages 测试:http://data.api.stage.healthbaby.com.cn/v1/messages
9 9 #演示地址 https://stage-rp-data-api.healthbaby.com.cn/v1/messages
10   -ams_sms=http://data.api.stage.healthbaby.com.cn/v1/messages
  10 +ams_sms=http://data.api.healthbaby.com.cn/v1/messages
11 11  
12 12 #短信当天发送时间 如16:00
13 13 send_time=16:00
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/NewbornServiceImpl.java View file @ 34ba2fb
... ... @@ -13,6 +13,7 @@
13 13 import com.lyms.platform.operate.web.facade.AutoMatchFacade;
14 14 import com.lyms.platform.operate.web.service.INewbornVisitService;
15 15 import com.lyms.platform.operate.web.utils.CollectionUtils;
  16 +import com.lyms.platform.operate.web.utils.FunvCommonUtil;
16 17 import com.lyms.platform.operate.web.utils.MongoUtil;
17 18 import com.lyms.platform.operate.web.utils.ResponseUtil;
18 19 import com.lyms.platform.permission.dao.master.CouponMapper;
... ... @@ -22,6 +23,7 @@
22 23 import com.lyms.platform.pojo.*;
23 24 import com.lyms.platform.query.DataPermissionsModelQuery;
24 25 import com.mongodb.WriteResult;
  26 +import org.apache.commons.collections.map.HashedMap;
25 27 import org.apache.commons.lang.StringUtils;
26 28 import org.springframework.beans.factory.annotation.Autowired;
27 29 import org.springframework.data.domain.Sort;
28 30  
... ... @@ -73,12 +75,7 @@
73 75  
74 76 @Override
75 77 public BaseObjectResponse addOrUpdate(Integer userId, NewbornVisit newbornVisit) {
76   - newbornVisit.setFeedType(newbornVisit.getFeedType() == null ? null : FeedTypeEnums.get(Integer.parseInt(newbornVisit.getFeedType())).getName());
77   - newbornVisit.setSkin(newbornVisit.getSkin() == null ? null : SkinEnums.get(Integer.parseInt(newbornVisit.getSkin())).getName());
78   - newbornVisit.setComplexion(newbornVisit.getComplexion() == null ? null : ComplexionEnums.get(Integer.parseInt(newbornVisit.getComplexion())).getName());
79   - newbornVisit.setUmbilicalCord(newbornVisit.getUmbilicalCord() == null ? null : UmbilicalCordEnums.get(Integer.parseInt(newbornVisit.getUmbilicalCord())).getName());
80 78 newbornVisit.setHospitalId(autoMatchFacade.getHospitalId(userId));
81   - // newbornVisit.setNextVisitTime(newbornVisit.getUmbilicalCord() == null ? null : UmbilicalCordEnums.get(Integer.parseInt(newbornVisit.getUmbilicalCord())).getName());
82 79 if(StringUtils.isEmpty(newbornVisit.getId())) {
83 80 if(!buildArchive(userId, newbornVisit.getPid(), newbornVisit.getBabyId())) {
84 81 return RespBuilder.buildSuccess(ResponseCode.NEED_BUILD);
85 82  
86 83  
... ... @@ -90,13 +87,9 @@
90 87 mongoTemplate.save(newbornVisit);
91 88 return RespBuilder.buildSuccess(newbornVisit.getId());
92 89 } else {
93   - newbornVisit.setId(UUID.randomUUID().toString().replace("-", ""));
94 90 newbornVisit.setOperationId(userId.toString());
95   - newbornVisit.setCreated(new Date());
96   - newbornVisit.setYn("1");
97 91 Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(newbornVisit));
98 92 mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(newbornVisit.getId())), update, NewbornVisit.class);
99   -
100 93 }
101 94 return RespBuilder.buildSuccess();
102 95 }
... ... @@ -245,7 +238,20 @@
245 238  
246 239 @Override
247 240 public BaseObjectResponse get(String id) {
248   - return RespBuilder.buildSuccess(mongoTemplate.findById(id, NewbornVisit.class));
  241 + NewbornVisit newbornVisit = mongoTemplate.findById(id, NewbornVisit.class);
  242 + Map<String, Object> map = ReflectionUtils.beanToMap(newbornVisit);
  243 + List<Map<String, Object>> diagnosisList = new ArrayList<>();
  244 + List<String> diagnosis = newbornVisit.getDiagnosis();
  245 + if(CollectionUtils.isNotEmpty(diagnosis)) {
  246 + for (String s : diagnosis) {
  247 + Map<String, Object> tempMap = new HashedMap();
  248 + tempMap.put("id", s);
  249 + tempMap.put("name", mongoUtil.findName(s));
  250 + diagnosisList.add(tempMap);
  251 + }
  252 + map.put("diagnosis", diagnosisList);
  253 + }
  254 + return RespBuilder.buildSuccess(map);
249 255 }
250 256  
251 257 @Override
252 258  
253 259  
254 260  
... ... @@ -259,20 +265,21 @@
259 265 NewbornVisit newbornVisit = mongoTemplate.findById(id, NewbornVisit.class);
260 266 if(newbornVisit != null) {
261 267 Map<String, Object> restMap = new HashMap<>();
  268 + restMap.put("id", newbornVisit.getId()); /** id */
262 269 /** 访视信息 */
263 270 restMap.put("checkTimeDesc", newbornVisit.getCheckTimeDesc()); /** 产后天数 */
264 271 restMap.put("visitHospitalId", mapper.getHospitalName(newbornVisit.getVisitHospitalId())); /** 访视机构 */
265 272 restMap.put("doctor", mapper.getUserName(newbornVisit.getDoctor())); /** 访视医生 */
266 273 restMap.put("checkTime", DateUtil.getYyyyMmDd(newbornVisit.getCheckTime())); /** 访视时间 */
267 274 restMap.put("visitLocation", newbornVisit.getVisitLocation()); /** 访视地点 */
268   - restMap.put("nextVisitTime", DateUtil.getYyyyMmDd(newbornVisit.getNextVisitTime())); /** 预约下次访视时间 */
  275 + restMap.put("nextVisitTime", NextVisitTimeEnums.getName(newbornVisit.getNextVisitTime())); /** 预约下次访视时间 */
269 276 /** 问诊 */
270   - restMap.put("feedType", newbornVisit.getFeedType()); /** 喂养方式 */
  277 + restMap.put("feedType", FeedTypeEnums.getName(newbornVisit.getFeedType())); /** 喂养方式 */
271 278 restMap.put("feedNumber", newbornVisit.getFeedNumber()); /** 喂奶量 */
272 279 restMap.put("nurseNumber", newbornVisit.getNurseNumber()); /** 吃奶次数 */
273 280 restMap.put("weight", newbornVisit.getWeight()); /** 新生儿体重 */
274 281 restMap.put("height", newbornVisit.getHeight()); /** 出生身长 */
275   - restMap.put("vomit", newbornVisit.getVomit()); /** 呕吐 */
  282 + restMap.put("vomit", VomitEnums.getName(newbornVisit.getVomit())); /** 呕吐 */
276 283 restMap.put("shit", newbornVisit.getShit()); /** 大便 */
277 284 restMap.put("shitNumber", newbornVisit.getShitNumber()); /** 大便次数 */
278 285 /** 体格测量 */
279 286  
... ... @@ -281,10 +288,10 @@
281 288 /** 体格检查 */
282 289 restMap.put("heartRate", newbornVisit.getHeartRate()); /** 心率 */
283 290 restMap.put("respiratoryRate", newbornVisit.getRespiratoryRate()); /** 呼吸频率 */
284   - restMap.put("skin", newbornVisit.getSkin()); /** 皮肤 */
285   - restMap.put("complexion", newbornVisit.getComplexion()); /** 面色 */
  291 + restMap.put("skin", SkinEnums.getName(newbornVisit.getSkin())); /** 皮肤 */
  292 + restMap.put("complexion", ComplexionEnums.getName(newbornVisit.getComplexion())); /** 面色 */
286 293 restMap.put("ictericPart", newbornVisit.getIctericPart()); /** 黄染部位 */
287   - restMap.put("bregmatic", newbornVisit.getBregmatic()); /** 前囟 */
  294 + restMap.put("bregmatic", BregmaticEnums.getName(newbornVisit.getBregmatic())); /** 前囟 */
288 295 restMap.put("eye", newbornVisit.getEye()); /** 眼外观 */
289 296 restMap.put("limb", newbornVisit.getLimb()); /** 四肢活动 */
290 297 restMap.put("ear", newbornVisit.getEar()); /** 耳外观 */
... ... @@ -293,7 +300,7 @@
293 300 restMap.put("mouth", newbornVisit.getMouth()); /** 口腔 */
294 301 restMap.put("gangmen", newbornVisit.getGangmen()); /** 肛门 */
295 302 restMap.put("heartLung", newbornVisit.getHeartLung()); /** 心肺听诊 */
296   - restMap.put("umbilicalCord", newbornVisit.getUmbilicalCord()); /** 脐带 */
  303 + restMap.put("umbilicalCord", UmbilicalCordEnums.getName(newbornVisit.getUmbilicalCord())); /** 脐带 */
297 304 restMap.put("abdomen", newbornVisit.getAbdomen()); /** 腹部 */
298 305 restMap.put("spine", newbornVisit.getSpine()); /** 脊柱 */
299 306 restMap.put("extGenitalia", newbornVisit.getExtGenitalia()); /** 外生殖器 */
... ... @@ -301,6 +308,11 @@
301 308 restMap.put("diagnosis", mongoUtil.findNames(newbornVisit.getDiagnosis())); /** 诊断 */
302 309 restMap.put("handleOpinions", newbornVisit.getHandleOpinions()); /** 处理意见 */
303 310 restMap.put("guidanceOpinion", newbornVisit.getGuidanceOpinion()); /** 指导意见 */
  311 +
  312 + /** 其他 */
  313 + restMap.put("skinOther", newbornVisit.getSkinOther());
  314 + restMap.put("complexionOther", newbornVisit.getComplexionOther());
  315 + restMap.put("umbilicalCordOther", newbornVisit.getUmbilicalCordOther());
304 316 return RespBuilder.buildSuccess(restMap);
305 317 }
306 318 return RespBuilder.buildSuccess();