From 2c25ccd81f9bc39e8815452a5970299b8a5d2668 Mon Sep 17 00:00:00 2001 From: liquanyu Date: Wed, 30 Jan 2019 21:53:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=84=BF=E7=AB=A5=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lyms/platform/biz/BasicConfigServiceTest.java | 381 +++++++++++++- .../platform/pojo/BabyNutritionConfigModel.java | 161 ++++++ .../web/controller/BabyNutritionController.java | 15 +- .../operate/web/facade/BabyCheckFacade.java | 14 +- .../operate/web/facade/BabyNutritionFacade.java | 562 ++++++++++++++++++++- .../operate/web/result/FoodBaseResult.java | 36 ++ .../platform/operate/web/result/FoodResult.java | 15 +- .../operate/web/utils/BabyNutritionConstant.java | 9 - 8 files changed, 1162 insertions(+), 31 deletions(-) create mode 100644 platform-dal/src/main/java/com/lyms/platform/pojo/BabyNutritionConfigModel.java create mode 100644 platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/FoodBaseResult.java delete mode 100644 platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/BabyNutritionConstant.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 a7725d9..b86b889 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 @@ -1819,6 +1819,382 @@ public class BasicConfigServiceTest { } + + public static void babyNutritionConfig(String fileName) + { + + ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext_biz_patient1.xml"); + MongoTemplate mongoTemplate + = (MongoTemplate) applicationContext.getBean("mongoTemplate"); + mongoTemplate.getDb().authenticate("platform", "platform123".toCharArray()); + File file = new File(fileName); + Workbook wb = null; + try { + wb = Workbook.getWorkbook(file); + Sheet s = wb.getSheet(0); + System.out.println(s.getName() + " : "); + int rows = s.getRows(); + if(rows > 0){ + //遍历每行 + for(int i = 1 ;i < rows ; i++){ + System.out.println("rows="+i); + BabyNutritionConfigModel model = new BabyNutritionConfigModel(); + // 0 0-11月龄喂养 1 0-11月每月营养素需求 2 12-36各月龄饮食指南 3 12-36月龄热量计算 4 12-36喂养指南 5 0-36营养元素参考摄入量 + model.setType(0); + Cell[] cells = s.getRow(i); + if(cells.length > 0){ + //遍历每行中的每列 + for (int j = 0 ; j < cells.length ; j ++) + { + String str = cells[j].getContents().trim(); +// if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(str)) +// { +// continue; +// } + switch (j) + { + case 0: + model.setMonthAge(Integer.parseInt(str)); + continue; + case 1: + model.setFeedType(str); + continue; + case 2: + model.setStatus(str); + continue; + case 3: + List list3 = Arrays.asList(str.split("\n")); + model.setContentOne(list3); + continue; + + } + } + + } + mongoTemplate.save(model); + } + } + + Sheet s1 = wb.getSheet(1); + System.out.println(s1.getName() + " : "); + + int rows1 = s1.getRows(); + if(rows1 > 0){ + //遍历每行 + for(int i = 1 ;i < rows1 ; i++){ + System.out.println("rows="+i); + BabyNutritionConfigModel model = new BabyNutritionConfigModel(); + // 0 0-11月龄喂养 1 0-11月每月营养素需求 2 12-36各月龄饮食指南 3 12-36月龄热量计算 4 12-36喂养指南 5 0-36营养元素参考摄入量 + model.setType(1); + Cell[] cells = s1.getRow(i); + if(cells.length > 0){ + //遍历每行中的每列 + for (int j = 0 ; j < cells.length ; j ++) + { + String str = cells[j].getContents().trim(); + if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(str)) + { + continue; + } + switch (j) + { + case 0: + model.setMonthAge(Integer.parseInt(str)); + continue; + case 1: + List list1 = Arrays.asList(str.split("\n")); + model.setContentOne(list1); + continue; + } + } + + } + mongoTemplate.save(model); + } + } + + + + Sheet s2 = wb.getSheet(2); + System.out.println(s2.getName() + " : "); + + int rows2 = s2.getRows(); + if(rows2 > 0){ + //遍历每行 + for(int i = 1 ;i < rows2 ; i++){ + System.out.println("rows="+i); + BabyNutritionConfigModel model = new BabyNutritionConfigModel(); + // 0 0-11月龄喂养 1 0-11月每月营养素需求 2 12-36各月龄饮食指南 3 12-36月龄热量计算 4 12-36喂养指南 5 0-36营养元素参考摄入量 + model.setType(2); + Cell[] cells = s2.getRow(i); + if(cells.length > 0){ + //遍历每行中的每列 + for (int j = 0 ; j < cells.length ; j ++) + { + String str = cells[j].getContents().trim(); + if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(str)) + { + continue; + } + switch (j) + { + case 0: + model.setMonthAge(Integer.parseInt(str)); + continue; + case 1: + model.setTitle(str); + continue; + case 2: + List list1 = Arrays.asList(str.split("\n")); + model.setContentOne(list1); + continue; + } + } + + } + mongoTemplate.save(model); + } + } + + + Sheet s3 = wb.getSheet(3); + System.out.println(s3.getName() + " : "); + int rows3 = s3.getRows(); + if(rows3 > 0){ + //遍历每行 + for(int i = 1 ;i < rows3 ; i++){ + System.out.println("rows="+i); + BabyNutritionConfigModel model = new BabyNutritionConfigModel(); + // 0 0-11月龄喂养 1 0-11月每月营养素需求 2 12-36各月龄饮食指南 3 12-36月龄热量计算 4 12-36喂养指南 5 0-36营养元素参考摄入量 + model.setType(3); + Cell[] cells = s3.getRow(i); + if(cells.length > 0){ + //遍历每行中的每列 + for (int j = 0 ; j < cells.length ; j ++) + { + String str = cells[j].getContents().trim(); + if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(str)) + { + continue; + } + switch (j) + { + case 0: + model.setMonthAge(Integer.parseInt(str)); + continue; + case 1: + model.setMonthAgeEnd(Integer.parseInt(str)); + continue; + case 2: + model.setKcal(Double.parseDouble(str)); + continue; + case 3: + model.setTitle(str); + continue; + case 4: + List list2 = Arrays.asList(str.split("\n")); + model.setContentOne(list2); + continue; + case 5: + model.setStatus(str); + continue; + } + } + } + mongoTemplate.save(model); + } + } + + + Sheet s4 = wb.getSheet(4); + System.out.println(s4.getName() + " : "); + int rows4 = s4.getRows(); + if(rows3 > 0){ + //遍历每行 + for(int i = 1 ;i < rows4 ; i++){ + System.out.println("rows="+i); + BabyNutritionConfigModel model = new BabyNutritionConfigModel(); + // 0 0-11月龄喂养 1 0-11月每月营养素需求 2 12-36各月龄饮食指南 3 12-36月龄热量计算 4 12-36喂养指南 5 0-36营养元素参考摄入量 + model.setType(4); + Cell[] cells = s4.getRow(i); + if(cells.length > 0){ + //遍历每行中的每列 + for (int j = 0 ; j < cells.length ; j ++) + { + String str = cells[j].getContents().trim(); + if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(str)) + { + continue; + } + switch (j) + { + + case 0: + model.setMonthAge(Integer.parseInt(str)); + continue; + case 1: + model.setMonthAgeEnd(Integer.parseInt(str)); + continue; + case 2: + model.setTitle(str); + continue; + case 3: + List list2 = Arrays.asList(str.split("\n")); + model.setContentOne(list2); + continue; + case 4: + model.setStatus(str); + continue; + } + } + } + mongoTemplate.save(model); + } + } + + + + + Sheet s5 = wb.getSheet(5); + System.out.println(s5.getName() + " : "); + int rows5 = s5.getRows(); + if(rows5 > 0){ + //遍历每行 + for(int i = 1 ;i < rows5 ; i++){ + System.out.println("rows="+i); + BabyNutritionConfigModel model = new BabyNutritionConfigModel(); + // 0 0-11月龄喂养 1 0-11月每月营养素需求 2 12-36各月龄饮食指南 3 12-36月龄热量计算 4 12-36喂养指南 5 0-36营养元素参考摄入量 + model.setType(5); + Cell[] cells = s5.getRow(i); + if(cells.length > 0){ + //遍历每行中的每列 + for (int j = 0 ; j < cells.length ; j ++) + { + String str = cells[j].getContents().trim(); + switch (j) + { + case 0: + model.setMonthAge(Integer.parseInt(str)); + continue; + case 1: + model.setMonthAgeEnd(Integer.parseInt(str)); + continue; + case 2: + model.setTitle(str); + continue; + case 3: + model.setDownValue(str); + continue; + case 4: + model.setNormalValue(str); + continue; + case 5: + model.setUpValue(str); + continue; + case 6: + model.setUnit(str); + continue; + } + } + } + mongoTemplate.save(model); + } + } + + + + Sheet s6 = wb.getSheet(6); + System.out.println(s6.getName() + " : "); + int rows6 = s6.getRows(); + if(rows6 > 0){ + //遍历每行 + for(int i = 1 ;i < rows6 ; i++){ + System.out.println("rows="+i); + BabyNutritionConfigModel model = new BabyNutritionConfigModel(); + // 0 0-11月龄喂养 1 0-11月每月营养素需求 2 12-36各月龄饮食指南 3 12-36月龄热量计算 4 12-36喂养指南 5 0-36营养元素参考摄入量 6 6-11辅食添加 + model.setType(6); + Cell[] cells = s6.getRow(i); + if(cells.length > 0){ + //遍历每行中的每列 + for (int j = 0 ; j < cells.length ; j ++) + { + String str = cells[j].getContents().trim(); + switch (j) + { + case 0: + model.setMonthAge(Integer.parseInt(str)); + continue; + case 1: + model.setKcal(Double.parseDouble(str)); + continue; + case 2: + List list1 = Arrays.asList(str.split("\n")); + model.setContentOne(list1); + continue; + case 3: + List list2 = Arrays.asList(str.split("\n")); + model.setContentTwo(list2); + continue; + case 4: + List list3 = Arrays.asList(str.split("\n")); + model.setContentThree(list3); + continue; + } + } + } + mongoTemplate.save(model); + } + } + + + + + Sheet s7 = wb.getSheet(7); + System.out.println(s7.getName() + " : "); + int rows7 = s7.getRows(); + if(rows7 > 0){ + //遍历每行 + for(int i = 1 ;i < rows7 ; i++){ + System.out.println("rows="+i); + BabyNutritionConfigModel model = new BabyNutritionConfigModel(); + // 0 0-11月龄喂养 1 0-11月每月营养素需求 2 12-36各月龄饮食指南 3 12-36月龄热量计算 4 12-36喂养指南 5 0-36营养元素参考摄入量 6 6-11辅食添加 7 12-36元素文章 + model.setType(7); + Cell[] cells = s7.getRow(i); + if(cells.length > 0){ + //遍历每行中的每列 + for (int j = 0 ; j < cells.length ; j ++) + { + String str = cells[j].getContents().trim(); + switch (j) + { + case 0: + model.setTitle(str); + continue; + case 1: + List list1 = Arrays.asList(str.split("\n")); + model.setContentOne(list1); + continue; + case 2: + model.setStatus(str); + continue; + + } + } + } + mongoTemplate.save(model); + } + } + + + } catch (IOException e) { + e.printStackTrace(); + } catch (BiffException e) { + e.printStackTrace(); + } + + } + + public static void main(String[] args) { // weightWeek("F:\\体重与营养管理\\体重与营养管理第三版(北方)改标红“、冰淇淋”-晓萌.xls"); // weightMange("F:\\体重与营养管理\\体重与营养管理第三版(北方)改标红“、冰淇淋”-晓萌.xls"); @@ -1828,9 +2204,12 @@ public class BasicConfigServiceTest { // zcet("D:\\doc\\高血压报告20180813模板.xls"); // zcet("D:\\doc\\1.xls",false); - addBabyBmiHealthConfig("F:\\儿童营养报告\\婴幼儿bmi.xls"); +// addBabyBmiHealthConfig("F:\\儿童营养报告\\婴幼儿bmi.xls"); // babyConfig("F:\\儿童营养报告\\儿童营养报告模板.xls"); + + + babyNutritionConfig("F:\\儿童营养报告\\婴幼儿体重与营养管理报告内容及规则\\儿童膳食报告文章1.xls"); } } diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/BabyNutritionConfigModel.java b/platform-dal/src/main/java/com/lyms/platform/pojo/BabyNutritionConfigModel.java new file mode 100644 index 0000000..8558b3b --- /dev/null +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/BabyNutritionConfigModel.java @@ -0,0 +1,161 @@ +package com.lyms.platform.pojo; + +import org.springframework.data.mongodb.core.mapping.Document; + +import java.util.List; + +/** + * 儿童膳食营养报告 + * Created by Administrator on 2018-06-04. + */ +@Document(collection = "lyms_baby_Nutrition_config") +public class BabyNutritionConfigModel { + private String id; + private String title; + private Integer monthAge;//月龄 + private Integer monthAgeEnd;//月龄 + private String feedType; + private List contentOne;// + private List contentTwo;// + private List contentThree;// + private List contentFour;// + private Double kcal; //热量 + private Integer type; //0 0-11月龄喂养 1 0-11月每月营养素需求 2 12-36各月龄饮食指南 3 12-36月龄热量计算 4 12-36喂养指南 5 0-36营养元素参考摄入量 6 6-11辅食添加 7 12-36元素文章 + + private String status; // 消瘦、正常、超重 + + private String upValue; + private String normalValue; + private String downValue; + + private String unit; + + public Integer getMonthAge() { + return monthAge; + } + + public void setMonthAge(Integer monthAge) { + this.monthAge = monthAge; + } + + public Integer getMonthAgeEnd() { + return monthAgeEnd; + } + + public void setMonthAgeEnd(Integer monthAgeEnd) { + this.monthAgeEnd = monthAgeEnd; + } + + public String getFeedType() { + return feedType; + } + + public void setFeedType(String feedType) { + this.feedType = feedType; + } + + public String getUpValue() { + return upValue; + } + + public void setUpValue(String upValue) { + this.upValue = upValue; + } + + public String getNormalValue() { + return normalValue; + } + + public void setNormalValue(String normalValue) { + this.normalValue = normalValue; + } + + public String getDownValue() { + return downValue; + } + + public void setDownValue(String downValue) { + this.downValue = downValue; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + + public List getContentOne() { + return contentOne; + } + + public void setContentOne(List contentOne) { + this.contentOne = contentOne; + } + + public List getContentTwo() { + return contentTwo; + } + + public void setContentTwo(List contentTwo) { + this.contentTwo = contentTwo; + } + + public List getContentThree() { + return contentThree; + } + + public void setContentThree(List contentThree) { + this.contentThree = contentThree; + } + + public List getContentFour() { + return contentFour; + } + + public void setContentFour(List contentFour) { + this.contentFour = contentFour; + } + + public Double getKcal() { + return kcal; + } + + public void setKcal(Double kcal) { + this.kcal = kcal; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyNutritionController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyNutritionController.java index c1b59a6..17b34ba 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyNutritionController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyNutritionController.java @@ -63,7 +63,7 @@ public class BabyNutritionController extends BaseController{ @RequestParam(required = false)String babyName, @RequestParam(required = false)String recordTime, HttpServletRequest request){ - return babyNutritionFacade.queryBabyNutritionList(page, limit, queryNo, vcCardNo, babyName, getUserId(request),recordTime); + return babyNutritionFacade.queryBabyNutritionList(page, limit, queryNo, vcCardNo, babyName, getUserId(request), recordTime); } @@ -103,4 +103,17 @@ public class BabyNutritionController extends BaseController{ } + /** + * 儿童营养报告 + * @param id + * @return + */ + @RequestMapping(value = "/queryBabyNutritionReport/{id}", method = RequestMethod.GET) + @ResponseBody + @TokenRequired + public BaseObjectResponse queryBabyNutritionReport(@PathVariable("id")String id,HttpServletRequest request){ + return babyNutritionFacade.queryBabyNutritionReport(id,getUserId(request)); + } + + } \ No newline at end of file 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 5db5591..8e4563f 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 @@ -2238,19 +2238,7 @@ public class BabyCheckFacade { } } kcal = getKaul(kcal); - - if (month < 12) - { - if (kcal < 800) - { - kcal = 800; - } - else if (kcal > 2000) - { - kcal = 2000; - } - } - else if (month < 36) + if (month < 36) { if (kcal < 600 && "正常".equals(kaupEvaluate)) { diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyNutritionFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyNutritionFacade.java index c92d722..70a92c1 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyNutritionFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyNutritionFacade.java @@ -3,6 +3,7 @@ package com.lyms.platform.operate.web.facade; import com.lyms.platform.biz.service.*; import com.lyms.platform.common.constants.ErrorCodeConstants; import com.lyms.platform.common.enums.SexEnum; +import com.lyms.platform.common.enums.WyTypeEnums; import com.lyms.platform.common.enums.YnEnums; import com.lyms.platform.common.result.BaseListResponse; import com.lyms.platform.common.result.BaseObjectResponse; @@ -24,6 +25,9 @@ import org.apache.commons.lang.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Sort; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; import org.springframework.stereotype.Component; import java.util.*; @@ -59,6 +63,15 @@ public class BabyNutritionFacade { @Autowired private BasicConfigService basicConfigService; + @Autowired + private BabyCheckService babyCheckService; + + @Autowired + private MongoTemplate mongoTemplate; + + + @Autowired + private PatientWeightService patientWeightService; public BaseObjectResponse queryBabyNutritionRecord(String babyId) { Map resMap = new HashMap<>(); @@ -105,9 +118,9 @@ public class BabyNutritionFacade { if (CollectionUtils.isNotEmpty(models)) { MeasureBabyInfoModel model = models.get(0); - map.put("weight",model.getValueTwo()); - map.put("hegiht",model.getValueOne()); - map.put("lastTime",DateUtil.getyyyy_MM_dd(model.getModified())); + map.put("weight", model.getValueTwo()); + map.put("hegiht", model.getValueOne()); + map.put("lastTime", DateUtil.getyyyy_MM_dd(model.getModified())); } return map; } @@ -170,7 +183,8 @@ public class BabyNutritionFacade { Map map = new HashMap(); map.put("ids", ids); String data = HttpClientUtil.doGet(amsUrl + "/v1/getFoodsByIds", map, "utf-8", "3d19960bf3e81e7d816c4f26051c49ba"); - List results = JsonUtil.toList(data, FoodResult.class); + FoodBaseResult foodBaseResult = JsonUtil.jkstr2Obj(data, FoodBaseResult.class); + List results = foodBaseResult.getList(); return results; } @@ -274,4 +288,544 @@ public class BabyNutritionFacade { objectResponse.setErrormsg("成功"); return objectResponse; } + + public BaseObjectResponse queryBabyNutritionReport(String id,Integer userId) { + + + Map data = new HashMap(); + + BabyNutritionQuery babyQuery = new BabyNutritionQuery(); + String hospitalId = autoMatchFacade.getHospitalId(userId); + babyQuery.setHospitalId(hospitalId); + babyQuery.setId(id); + + List models = babyNutritionService.queryBabyNutritions(babyQuery); + if (CollectionUtils.isNotEmpty(models)) + { + BabyNutritionModel model = models.get(0); + BabyModel baby = babyBookbuildingService.queryBabyBuildById(model.getBabyId()); + + Map map = new HashMap(); + map.put("id",model.getId()); + map.put("babyId",model.getBabyId()); + map.put("babyName",baby.getName()); + map.put("babySex", SexEnum.getTextById(baby.getSex())); + map.put("monthAge",StringUtils.emptyDeal(DateUtil.getBabyMonthAge(baby.getBirth(), new Date()))); + map.put("motherName", baby.getMname()); + map.put("phone", baby.getMphone()); + map.put("vcCardNo", baby.getVcCardNo()); + map.put("weight", model.getWeight()); + map.put("height", model.getHeight()); + Organization org = organizationService.getOrganization(Integer.parseInt(hospitalId)); + map.put("hospitalName", org.getName()); + + + int month = DateUtil.getMonth(baby.getBirth(), model.getNutritiTime()); + + if (month == 0 || month > 36) + { + return new BaseObjectResponse().setData(data).setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("月龄范围没有报告"); + } + + String kaupEvaluate = getBabyStatus(month,baby.getSex(),model.getHeight(),model.getWeight()); + map.put("kaupEvaluate", kaupEvaluate); + map.put("month", month); + data.put("baseInfo", map); + + double kaul = getKal(month,model.getHeight(),model.getWeight(), baby.getSex(), kaupEvaluate); + + if (month < 12) + { + //根据喂养方式获取 合理喂养 + Criteria ca = Criteria.where("monthAge").is(month).and("type").is(0).and("status").is(kaupEvaluate); + if (month < 7) + { + String feedType = WyTypeEnums.getNameById(Integer.parseInt(model.getFeedType())); + ca.and("feedType").is(feedType); + } + BabyNutritionConfigModel babyNutritionConfig = mongoTemplate.findOne(Query.query(ca), + BabyNutritionConfigModel.class); + + //合理喂养 + data.put("hlFeed",babyNutritionConfig.getContentOne()); + + + BabyNutritionConfigModel babyNutritionConfig1 = mongoTemplate.findOne( + Query.query(Criteria.where("monthAge").is(month).and("type").is(1)), BabyNutritionConfigModel.class); + + //每月营养素需求 + data.put("yysxq",babyNutritionConfig1.getContentOne()); + + if (month > 5) + { + BabyNutritionConfigModel babyNutritionConfig2 = mongoTemplate.findOne( + Query.query(Criteria.where("monthAge").is(month).and("type").is(6)), BabyNutritionConfigModel.class); + + //食用须知 + data.put("syxz",babyNutritionConfig2.getContentOne()); + //辅食添加 + data.put("fstj",babyNutritionConfig2.getContentTwo()); + //辅食制作 + data.put("fszz",babyNutritionConfig2.getContentThree()); + } + + } + else + { + BabyNutritionConfigModel babyNutritionConfig1 = mongoTemplate.findOne( + Query.query(Criteria.where("monthAge").is(month).and("type").is(2)), BabyNutritionConfigModel.class); + //各月龄饮食指南 + data.put("yszl",babyNutritionConfig1.getContentOne()); + + + int tempMonth = month < 36 ? 12 : 36; + List configModels = mongoTemplate.find(Query.query( + Criteria.where("kcal").is(kaul).and("status").is(kaupEvaluate).and("type").is(3).and("monthAge").is(tempMonth)), BabyNutritionConfigModel.class); + if (CollectionUtils.isNotEmpty(configModels) && configModels.size() == 3) + { + List> list = new ArrayList<>(); + for (BabyNutritionConfigModel configModel : configModels) + { + Map map1 = new HashMap<>(); + map1.put("title",configModel.getTitle()); + map1.put("contents",configModel.getContentOne()); + list.add(map); + } + data.put("foods",list); + } + + //每日所需营养素 + List yys = getYys(month); + + data.put("yys",yys); + + } + + //元素计算 + List yysMapList = new ArrayList<>(); + + List wlysMapList = new ArrayList<>(); + + //能量计算 + double nl = getBasicKaul( month, model.getWeight(),model.getHeight(),baby.getSex()); + double nlCurrent = 0; + yysMapList.add(getNl(nl,nlCurrent)); + + double tsCurrent = 0;//碳素化合物 TODO + double dbzCurrent = 0;//蛋白质 TODO + double zfCurrent = 0;//脂肪 TODO + if (month < 5) + { + yysMapList.add(getYysItems( nl, tsCurrent, "碳水化合物",0.55,0.65)); + yysMapList.add(getYysItems( nl, dbzCurrent, "蛋白质",0.07,0.09)); + yysMapList.add(getYysItems( nl, zfCurrent, "脂肪",0.4,0.5)); + + } + else if (month < 12) + { + + yysMapList.add(getYysItems( nl, tsCurrent, "碳水化合物",0.55,0.65)); + + yysMapList.add(getYysItems( nl, dbzCurrent, "蛋白质",0.05,0.07)); + + yysMapList.add(getYysItems( nl, zfCurrent, "脂肪",0.4,0.5)); + } + else if (month < 36) + { + yysMapList.add(getYysItems( nl, tsCurrent, "碳水化合物",0.5,0.7)); + + yysMapList.add(getYysItems( nl, dbzCurrent, "蛋白质",0.07,0.2)); + + yysMapList.add(getYysItems( nl, zfCurrent, "脂肪",0.2,0.35)); + } + else + { + yysMapList.add(getYysItems( nl, tsCurrent, "碳水化合物",0.55,0.7)); + yysMapList.add(getYysItems( nl, dbzCurrent, "蛋白质",0.07,0.2)); + yysMapList.add(getYysItems( nl, zfCurrent, "脂肪",0.15,0.3)); + } + + Map elements = new HashMap(); + + List mainFoods = model.getMainFood(); + getFoodElements(elements,mainFoods); + + List vegYj = model.getVegYj(); + getFoodElements(elements,vegYj); + + List vegGj = model.getVegGj(); + getFoodElements(elements,vegGj); + + List vegGq = model.getVegGq(); + getFoodElements(elements,vegGq); + + List vegHc = model.getVegHc(); + getFoodElements(elements,vegHc); + + List vegJl = model.getVegJl(); + getFoodElements(elements,vegJl); + + List meatC = model.getMeatC(); + getFoodElements(elements,meatC); + + + List meatQ = model.getMeatQ(); + getFoodElements(elements,meatQ); + + List meatD = model.getMeatD(); + getFoodElements(elements,meatD); + + List meatX = model.getMeatX(); + getFoodElements(elements,meatX); + + List meatH = model.getMeatH(); + getFoodElements(elements,meatH); + + List meatY = model.getMeatY(); + getFoodElements(elements,meatY); + + + List meatYz = model.getMeatYz(); + getFoodElements(elements,meatYz); + + List milk = model.getMilk(); + getFoodElements(elements,milk); + + List oilGg = model.getOilGg(); + getFoodElements(elements,oilGg); + + + List beansGd = model.getBeansGd(); + getFoodElements(elements,beansGd); + + List beansDl = model.getBeansDl(); + getFoodElements(elements,beansDl); + + List fruits = model.getFruits(); + getFoodElements(elements,fruits); + + List vegXd = model.getVegXd(); + getFoodElements(elements,vegXd); + + if (elements.size() > 0) + { + for (String key : elements.keySet()) + { + BabyNutritionConfigModel babyNutritionConfig1 = mongoTemplate.findOne( + Query.query(Criteria.where("type").is(5).and("monthAge").is(6).and("title").is(key)), BabyNutritionConfigModel.class); + if (babyNutritionConfig1 == null) + { + continue; + } + Double value = elements.get(key); + String upValue = babyNutritionConfig1.getUpValue(); + String normalValue = babyNutritionConfig1.getNormalValue(); + String downValue = babyNutritionConfig1.getDownValue(); + + Map wly = new HashMap(); + wly.put("name",key); + wly.put("normalValue", normalValue); + wly.put("currentValue", value); + wly.put("status", -1); + wlysMapList.add(wly); + } + } + + + data.put("yysMapList",yysMapList); + data.put("wlysMapList", wlysMapList); + + List items = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(yysMapList)) + { + for (Map map1 : yysMapList) + { + Integer status = Integer.valueOf(String.valueOf(map1.get("status"))); + if (status != 0) + { + String str = status == -1 ? "摄入不足" : "摄入过量"; + BabyNutritionConfigModel babyNutritionConfig1 = mongoTemplate.findOne( + Query.query(Criteria.where("type").is(7).and("status").is(str).and("title").is(String.valueOf(map1.get("name")))), BabyNutritionConfigModel.class); + Map item = new HashMap(); + item.put("title",babyNutritionConfig1.getTitle()); + item.put("content",babyNutritionConfig1.getContentOne()); + items.add(item); + } + } + } + data.put("items", items); + + List wlysitems = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(wlysMapList)) + { + for (Map map1 : wlysMapList) + { + Integer status = Integer.valueOf(String.valueOf(map1.get("status"))); + if (status != 0) + { + String str = status == -1 ? "摄入不足" : "摄入过量"; + BabyNutritionConfigModel babyNutritionConfig1 = mongoTemplate.findOne( + Query.query(Criteria.where("type").is(7).and("status").is(str).and("title").is(String.valueOf(map1.get("name")))), BabyNutritionConfigModel.class); + Map item = new HashMap(); + item.put("title",babyNutritionConfig1.getTitle()); + item.put("content",babyNutritionConfig1.getContentOne()); + wlysitems.add(item); + } + } + } + + data.put("wlysitems", wlysitems); + + } + + BaseObjectResponse objectResponse = new BaseObjectResponse(); + objectResponse.setData(data); + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + objectResponse.setErrormsg("成功"); + return objectResponse; + } + + private void getFoodElements(Map elements,List foods) + { + if (CollectionUtils.isNotEmpty(foods)) + { + for (Map map1 : foods) + { + if (map1.get("val") == null || map1.get("ids") == null) + { + continue; + } + String ids = String.valueOf(map1.get("ids")); + String val = String.valueOf(map1.get("val")); + + if (StringUtils.isEmpty(ids) || StringUtils.isEmpty(val)) + { + continue; + } + + if (StringUtils.isNotEmpty(ids)) + { + List foodResults = getFoods(ids); + if (CollectionUtils.isNotEmpty(foodResults)) + { + for (FoodResult food : foodResults) + { + Double protein = (elements.get(food.getNutritionName()) == null ? 0 : elements.get(food.getNutritionName())) * Double.valueOf(val); + elements.put(food.getNutritionName(),protein == null ? 0+food.getProtein() : protein+food.getProtein()); + } + } + } + } + } + } + + private Map getYysItems(double nl,double current,String title,double down,double up) + { + Map map = new HashMap(); + map.put("name",title); + map.put("normalValue", (nl * down) + "-" + (nl * up)); + map.put("currentValue", current); + map.put("status", (nl * up) < current ? 1 : (nl * down > current ? -1 : 0)); + return map; + } + + private Map getNl(double nl,double current) + { + + Map nlMap = new HashMap(); + nlMap.put("name","能量"); + nlMap.put("normalValue",(nl-50)+"-" +(nl+50)); + nlMap.put("currentValue",current); + nlMap.put("status", nl + 50 < current ? 1 : (nl - 50 > current ? -1 : 0)); + return nlMap; + } + + + private List getYys(int month){ + List list = new ArrayList<>(); + + if (month < 36) + { + list.add("碳水化合物:总能量的50-70%"); + list.add("蛋白质:总能量的7-20%,平均每日约0.96g/kg"); + list.add("脂肪:总能量的20-35%"); + list.add("n-6:总能量的4-8%"); + list.add("N-3:总能量的1%"); + list.add("无机物:钙的推荐摄入量为500mg,磷的推荐摄入量为500mg,钠的充分摄入为0.7g,氯的充分摄入量为1.1g,钾的充分摄入量为1.7g,镁的推荐摄入量为75mg,铁的推荐摄入量为6mg,锌的推荐摄入量为3mg,铜的推荐摄入量为290 μg,氟的充分摄入量为0.6mg,猛的充分摄入量为1.4mg,碘的推荐摄入量为80 μg,硒的推荐摄入量为20 μg"); + list.add("维生素:维生素A的推荐摄入量为300 μgRE,维生素D的充分摄入量为5 μg,维生素E的充分摄入量为5mg α-TE,维生素K的充分摄入量为25μg,维生素C的推荐摄入量为40mg,维生素B1的推荐摄入量为0.5mg,维生素B2(核黄素)的0.6mg,维生素B3烟酸的推荐摄入量为6mgNE,尼克酸的上限摄入量为10mg,尼克酰胺的上限摄入量为180mg,维生素B6的推荐摄入量0.6mg,叶酸的推荐摄入量为150μg DFE,维生素B12的推荐摄入量为0.9μg,泛酸的充分摄入量为2mg,维生素H的充分摄入量9μg"); + list.add("水分:1岁120-135ml/kg/day;2岁115-125ml/kg/day"); + } + else + { + list.add("碳水化合物:总能量的55-70%"); + list.add("蛋白质:总能量的7-20%,平均每日约0.88g/kg"); + list.add("脂肪:总能量的15-30%"); + list.add("n-6:总能量的4-8%"); + list.add("n-3:总能量的1%"); + list.add("无机物:钙的推荐摄入量为600mg,磷的推荐摄入量为500mg,钠的充分摄入量为0.9g,氯的充分摄入量为1.4g,钾的充分摄入量为2.3g,镁的推荐摄入量为100mg,铁的推荐摄入量7mg,锌的推荐摄入量为4mg,铜的推荐摄入量为330 μg,氟的充分摄入量为0.8mg,猛的充分摄入量为2.0mg,碘的推荐摄入量为90 μg,硒的推荐摄入量为25 μg"); + list.add("维生素:维生素A的推荐摄入量为300 μgRE,维生素D的充分摄入量为5 μg,维生素E的充分摄入量为6mg α-TE,维生素K的充分摄入量为30μg,维生素C的推荐摄入量为40mg,维生素B1的推荐摄入量为0.5mg,维生素B2(核黄素)的0.7mg,维生素B3烟酸的推荐摄入量为7mgNE,尼克酸的上限摄入量为10mg,尼克酰胺的上限摄入量为250mg,维生素B6的推荐摄入量0.7mg,叶酸的推荐摄入量为180μg DFE,维生素B12的推荐摄入量为1.1μg,泛酸的充分摄入量为3mg,维生素H的充分摄入量11μg"); + list.add("水分:90-100ml/kg/day"); + } + + return list; + } + + /** + * 1-5 体重 * 90kcal/kg + * 6-11月龄热量计算:体重 * 80kcal/kg + * 12月龄-35月龄 [80×体重(kg)-100]+20kcal/day + * 36月龄 男童:88.5-61.9×年龄(岁)+PA[26.7×体重(kg)+903×身长(m)]+20kcal/day PA=1.26 + * 36月龄 女童:135.3-30.8×年龄(岁)+PA[10×体重(kg)+934×身长(m)]+20kcal/day PA=1.31 + * 获取热量 + * @return + */ + private double getBasicKaul(int month,Double weight,Double height,int sex) + { + double kaul = 0; + if (month < 12) + { + kaul = weight * (month < 6 ? 90 : 80); + } + else if (month < 36) + { + kaul = 89 * weight - 100 + 20; + } + else + { + if (sex == 1) + { + kaul = 88.5-61.9*3+1.26*(26.7*weight +903*(height/100))+20; + } + else { + kaul = 135.3-30.8*3+1.31*(10*weight +934*(height/100))+20; + } + } + return kaul; + } + + + + private double getKal(int month,Double weight,Double height,int sex,String kaupEvaluate) + { + double kaul = getBasicKaul(month, weight, height, sex); + kaul = getMathAbs(kaul); + if (month < 12) + { + if (kaul < 800) + { + kaul = 800; + } + else if (kaul > 2000) + { + kaul = 2000; + } + } + else if (month < 36) + { + if (kaul < 600 && "正常".equals(kaupEvaluate)) + { + kaul = 600; + } + else if (kaul > 1550 && "正常".equals(kaupEvaluate)) + { + kaul = 1550; + }else if (kaul < 500 && "消瘦".equals(kaupEvaluate)) + { + kaul = 500; + } + else if (kaul > 1100 && "消瘦".equals(kaupEvaluate)) + { + kaul = 1100; + } + else if (kaul < 800 && "超重".equals(kaupEvaluate)) + { + kaul = 800; + } + else if (kaul > 1750 && "超重".equals(kaupEvaluate)) + { + kaul = 1750; + } + } + else if (month == 36) + { + if (kaul < 1300 && "正常".equals(kaupEvaluate)) + { + kaul = 1300; + } + else if (kaul > 1750 && "正常".equals(kaupEvaluate)) + { + kaul = 1750; + }else if (kaul < 1200 && "消瘦".equals(kaupEvaluate)) + { + kaul = 1200; + } + else if (kaul > 1450 && "消瘦".equals(kaupEvaluate)) + { + kaul = 1450; + } + else if (kaul < 1500 && "超重".equals(kaupEvaluate)) + { + kaul = 1500; + } + else if (kaul > 1850 && "超重".equals(kaupEvaluate)) + { + kaul = 1850; + } + } + + return kaul; + + } + + + private Double getMathAbs(Double kcal) { + int k = (int)(kcal/100)*100; + Double d = Math.floor(k); + Double md = d + 50; + if (md > kcal) { + return d; + } else { + return md; + } + } + + + /** + * 0-11分为正常、消瘦、超重及以上三种情况:-2SD ≤ BMI ≤ 1SD正常;BMI<-2SD消瘦;BMI>+1SD超重 + * 12-26分为正常、消瘦、超重及以上三种情况:-2SD ≤ BMI ≤ 1SD正常;BMI<-2SD消瘦;BMI>+1SD超重 + * @return + */ + private String getBabyStatus(int month,int sex,Double weight,Double hegiht) + { + String kaupEvaluate = ""; + if (weight != null && hegiht != null) + { + String bmi = patientWeightService.getBmi(String.valueOf(weight),String.valueOf(hegiht)); + if (StringUtils.isNotEmpty(bmi)) + { + Double bbmi = Double.parseDouble(bmi); + //查询该月龄的年龄别体重值 + // 正常 :-2SD ≤ A ≤ +1SD + // 消瘦 : A < -2SD + //偏重 : A > +1SD + List list = babyCheckService.queryBabyHealthConfig(month, sex, 5); + if (CollectionUtils.isNotEmpty(list)) { + AwModel awModel = list.get(0); + if (awModel.getPoneDs() < bbmi) + { + kaupEvaluate = "超重"; + } + else if (awModel.getPoneDs() >= bbmi && awModel.getRtwoDs() <= bbmi) + { + kaupEvaluate = "正常"; + } + else if (awModel.getRtwoDs() > bbmi) + { + kaupEvaluate = "消瘦"; + } + } + } + } + return kaupEvaluate; + } } \ No newline at end of file diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/FoodBaseResult.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/FoodBaseResult.java new file mode 100644 index 0000000..3d5e457 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/FoodBaseResult.java @@ -0,0 +1,36 @@ +package com.lyms.platform.operate.web.result; + +import java.util.List; + +/** + * Created by Administrator on 2019-01-30. + */ +public class FoodBaseResult { + private int errorcode; + private String errormsg; + private List list; + + public int getErrorcode() { + return errorcode; + } + + public void setErrorcode(int errorcode) { + this.errorcode = errorcode; + } + + public String getErrormsg() { + return errormsg; + } + + public void setErrormsg(String errormsg) { + this.errormsg = errormsg; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/FoodResult.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/FoodResult.java index eef3f08..80fcf12 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/FoodResult.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/FoodResult.java @@ -6,10 +6,19 @@ package com.lyms.platform.operate.web.result; public class FoodResult { private Integer id; - private Integer protein; + private Double protein; private Integer categoryId; private Integer nutritionId; private Integer unitId; + private String nutritionName; + + public String getNutritionName() { + return nutritionName; + } + + public void setNutritionName(String nutritionName) { + this.nutritionName = nutritionName; + } public Integer getId() { return id; @@ -19,11 +28,11 @@ public class FoodResult { this.id = id; } - public Integer getProtein() { + public Double getProtein() { return protein; } - public void setProtein(Integer protein) { + public void setProtein(Double protein) { this.protein = protein; } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/BabyNutritionConstant.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/BabyNutritionConstant.java deleted file mode 100644 index e394149..0000000 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/BabyNutritionConstant.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.lyms.platform.operate.web.utils; - -/** - * Created by Administrator on 2019-01-30. - */ -public class BabyNutritionConstant { - - -} -- 1.8.3.1