From 07ea90dfdbb6538f249e55dbcb78a0e36bd1c266 Mon Sep 17 00:00:00 2001 From: liquanyu Date: Fri, 9 Sep 2016 13:55:08 +0800 Subject: [PATCH] code update --- .../lyms/platform/biz/BasicConfigServiceTest.java | 38 +++++++++++++++- .../platform/biz/service/BabyCheckService.java | 3 +- .../platform/common/enums/BaybHealthTabEnums.java | 39 +++++++++++++++++ .../main/java/com/lyms/platform/pojo/AwModel.java | 2 +- .../web/controller/BabyCheckController.java | 22 +++++++++- .../operate/web/facade/BabyCheckFacade.java | 50 +++++++++++++++++++++- 6 files changed, 149 insertions(+), 5 deletions(-) create mode 100644 platform-common/src/main/java/com/lyms/platform/common/enums/BaybHealthTabEnums.java diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java index db98743..bb289eb 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java @@ -82,7 +82,7 @@ public class BasicConfigServiceTest { // addaw(applicationContext, "0-83月龄体重标准差数值表(男、女).csv", 0); // addZhenduan(applicationContext); - addMingzu(applicationContext); + addHealthConfig(applicationContext); } public static void addZhenduan(ApplicationContext applicationContext) { @@ -382,6 +382,42 @@ public class BasicConfigServiceTest { } } + + public static void addHealthConfig(ApplicationContext applicationContext) { + MongoTemplate mongoTemplate + =(MongoTemplate)applicationContext.getBean("mongoTemplate"); + mongoTemplate.getDb().authenticate("platform", "platform123".toCharArray()); + + try { + List list = FileUtils.readLines(new File("F:\\temp\\touwei.txt"),"gbk"); + for (String line:list) { + if (line != null) { + + String[] array = line.split(","); + + AwModel awModel2 = new AwModel(); + awModel2.setType(2); + awModel2.setSex(0); + awModel2.setAge(Integer.valueOf(array[0])); + awModel2.setRthreeDs(Double.valueOf(array[1])); + awModel2.setRtwoDs(Double.valueOf(array[2])); + awModel2.setRoneDs(Double.valueOf(array[3])); + awModel2.setMiddleDs(Double.valueOf(array[4])); + awModel2.setPoneDs(Double.valueOf(array[5])); + awModel2.setPtwoDs(Double.valueOf(array[6])); + awModel2.setPthreeDs(Double.valueOf(array[7])); + + System.out.println(" == " + JsonUtil.obj2JsonString(awModel2)); + mongoTemplate.save(awModel2); + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void addVisit(ApplicationContext applicationContext){ VisitModel visitModel = new VisitModel(); diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/BabyCheckService.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/BabyCheckService.java index d417645..768ef65 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/BabyCheckService.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/BabyCheckService.java @@ -61,10 +61,11 @@ public class BabyCheckService { return babyHwDao.queryHWByHeight(condition.toMongoQuery()); } - public List queryAwByHeight(Integer age, Integer sex) { + public List queryBabyHealthConfig(Integer age, Integer sex,Integer type) { MongoCondition condition = MongoCondition.newInstance(); condition = condition.and("age", age, MongoOper.IS); condition = condition.and("sex", sex, MongoOper.IS); + condition = condition.and("type", type, MongoOper.IS); return babyAwDao.queryAwByHeight(condition.toMongoQuery()); } diff --git a/platform-common/src/main/java/com/lyms/platform/common/enums/BaybHealthTabEnums.java b/platform-common/src/main/java/com/lyms/platform/common/enums/BaybHealthTabEnums.java new file mode 100644 index 0000000..ca27e8b --- /dev/null +++ b/platform-common/src/main/java/com/lyms/platform/common/enums/BaybHealthTabEnums.java @@ -0,0 +1,39 @@ +package com.lyms.platform.common.enums; + + + +/** + * Created by lqy on 2016/3/29 0029. + */ +public enum BaybHealthTabEnums { + + + TZ(0,"体重"), + + SC(1,"身长"), + + TW(2,"头围"); + + private BaybHealthTabEnums(int id, String name){ + this.name=name; + this.id =id; + } + private String name; + private int id; + + public int getId() { + return id; + } + + public String getName() { + return name; + } + public static String getNameById(int id){ + for(BaybHealthTabEnums enums:values()){ + if(id==enums.getId()){ + return enums.getName(); + } + } + return null; + } +} diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/AwModel.java b/platform-dal/src/main/java/com/lyms/platform/pojo/AwModel.java index cb5d9a9..bed71a8 100644 --- a/platform-dal/src/main/java/com/lyms/platform/pojo/AwModel.java +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/AwModel.java @@ -18,7 +18,7 @@ public class AwModel { private Double poneDs; private Double ptwoDs; private Double pthreeDs; - //0 体重标准差数值表 1 身长/身高标准差数值表 + //0 体重标准差数值表 1 身长/身高标准差数值表 2 头围标准差数值表 private Integer type; public Integer getType() { diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyCheckController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyCheckController.java index 6cb119a..c816e6e 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyCheckController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyCheckController.java @@ -120,11 +120,31 @@ public class BabyCheckController extends BaseController{ */ @RequestMapping(value = "/queryHWByHeight", method = RequestMethod.GET) @ResponseBody - public BaseObjectResponse queryHWByHeight(@RequestParam(required = true) Double height,@RequestParam(required = true) Integer sex){ + public BaseObjectResponse queryHWByHeight( + @RequestParam(required = true) Double height, + @RequestParam(required = true) Integer sex){ return babyCheckFacade.queryHWByHeight(height, sex); } + + /** + * 查询儿童的健康状态 + * @param value + * @param sex + * @return + */ + @RequestMapping(value = "/queryBabyHealthStatus", method = RequestMethod.GET) + @ResponseBody + public BaseObjectResponse queryBabyHealthStatus(@RequestParam(required = true) Double value, + @RequestParam(required = true) Integer sex, + @RequestParam(required = true) Integer type, + @RequestParam(required = true) String birth){ + return babyCheckFacade.queryBabyHealthStatus(birth,value, sex, type); + + } + + /** * 计算体格发育评价 * @param height 身长 diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java index 7e87dbc..32b5e1f 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java @@ -939,7 +939,7 @@ public class BabyCheckFacade { //查询该月龄的年龄别体重值 - List aws = babyCheckService.queryAwByHeight(monthAge, sex); + List aws = babyCheckService.queryBabyHealthConfig(monthAge, sex,0); if (CollectionUtils.isNotEmpty(aws) && aws.size() > 1) { AwModel model = aws.get(0); @@ -1033,4 +1033,52 @@ public class BabyCheckFacade { return objectResponse; } + + public BaseObjectResponse queryBabyHealthStatus(String birth,Double value, Integer sex, Integer type) { + + //计算儿童的月龄 + int monthAge = DateUtil.getBabyAgeMonth(DateUtil.parseYMD(birth), new Date()); + + + //查询该月龄的年龄别体重值 + List list = babyCheckService.queryBabyHealthConfig(monthAge, sex,type); + String res = ""; + if (CollectionUtils.isNotEmpty(list)) { + AwModel model = list.get(0); + + if (model.getPthreeDs() < value) + { + res = "上"; + } + else if (model.getPthreeDs() >=value && value > model.getPtwoDs()) + { + res = "中上"; + } + else if (model.getPtwoDs() >=value && value > model.getPoneDs()) + { + res = "中+"; + } + else if (model.getPoneDs() >=value && value >= model.getRoneDs()) + { + res = "中"; + } + else if (model.getRoneDs() >value && value >= model.getRtwoDs()) + { + res = "中-"; + } + else if (model.getRtwoDs() >value && value >= model.getRthreeDs()) + { + res = "中下"; + } + else if (model.getRtwoDs() >value) + { + res = "下"; + } + } + BaseObjectResponse objectResponse = new BaseObjectResponse(); + objectResponse.setData(res); + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + objectResponse.setErrormsg("成功"); + return objectResponse; + } } -- 1.8.3.1