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 84d8c73..79e2bd4 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 @@ -38,6 +38,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; 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.data.mongodb.core.query.Update; @@ -797,9 +798,7 @@ public class BasicConfigServiceTest { Workbook wb = null; try { wb = Workbook.getWorkbook(file); - Sheet[] sheets = wb.getSheets(); - - for(Sheet s : sheets){ + Sheet s = wb.getSheet(0); System.out.println(s.getName() + " : "); int rows = s.getRows(); if(rows > 0){ @@ -830,15 +829,8 @@ public class BasicConfigServiceTest { case 7: model.setDinnerAdd(str); case 8: - model.setVegetable(str); - case 9 : - model.setFoodMaterial(str); - case 10: - List list = Arrays.asList(str.split("\n")); - model.setMakeMethod(list); - case 11: model.setWeightType(str); - case 12: + case 9: List list1 = Arrays.asList(str.split("\n")); model.setSuggests(list1); } @@ -847,14 +839,13 @@ public class BasicConfigServiceTest { } } } - } ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext_biz_patient1.xml"); MongoTemplate mongoTemplate = (MongoTemplate) applicationContext.getBean("mongoTemplate"); mongoTemplate.getDb().authenticate("platform", "platform123".toCharArray()); mongoTemplate.save(model); - System.out.println(model); + } catch (IOException e) { e.printStackTrace(); } catch (BiffException e) { @@ -863,8 +854,83 @@ public class BasicConfigServiceTest { } + + public static void weightFood(String fileName) + { + File file = new File(fileName); + Workbook wb = null; + try { + wb = Workbook.getWorkbook(file); + ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext_biz_patient1.xml"); + MongoTemplate mongoTemplate + = (MongoTemplate) applicationContext.getBean("mongoTemplate"); + mongoTemplate.getDb().authenticate("platform", "platform123".toCharArray()); + + Sheet s1 = wb.getSheet(1); + int rows1 = s1.getRows(); + if(rows1 > 0){ + //遍历每行 + for(int i = 1 ;i < rows1 ; i++){ + WeightManageConfigModel.Cookbook cookbook = new WeightManageConfigModel.Cookbook(); + Cell[] cells = s1.getRow(i); + if(cells.length > 0){ + //遍历每行中的每列 + for (int j = 0 ; j < cells.length ; j ++) + { + + String str = cells[j].getContents().trim(); + switch (j) + { + case 0: + cookbook.setWeek(str); + case 1: + cookbook.setVegetable(str); + case 2: + cookbook.setFoodMaterial(str); + case 3: + List list1 = Arrays.asList(str.split("\n")); + cookbook.setMakeMethod(list1); + case 4: + cookbook.setWeightType(str); + + } + + + } + + WeightManageConfigModel weightManageConfigModel = mongoTemplate.findOne(Query.query(Criteria.where("week").is(cookbook.getWeek()).and("weightType").is(cookbook.getWeightType())), + WeightManageConfigModel.class); + + List cookbooks = weightManageConfigModel.getCookbooks(); + if (cookbooks == null) + { + cookbooks = new ArrayList<>(); + } + cookbooks.add(cookbook); + weightManageConfigModel.setCookbooks(cookbooks); + + Update update = MongoConvertHelper + .convertToNativeUpdate(ReflectionUtils.getUpdateField(weightManageConfigModel)); + + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(weightManageConfigModel.getId())),update, + WeightManageConfigModel.class); + + } + } + } + + } catch (IOException e) { + e.printStackTrace(); + } catch (BiffException e) { + e.printStackTrace(); + } + + } + + public static void main(String[] args) { - weightMange("F:\\1.xls"); + weightMange("F:\\体重营养配置模板.xls"); + weightFood("F:\\体重营养配置模板.xls"); } public static void addBaby(ApplicationContext applicationContext) { diff --git a/platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java b/platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java index 8252621..8e97b00 100644 --- a/platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java +++ b/platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java @@ -15,6 +15,7 @@ public enum SerialIdEnum { BabyCheckModel("BabyCheckModel", 97531000070L), BabyModel("BabyModel", 97531000080L), Baby("Baby", 97531000081L), + Cookbook("Cookbook", 97231020081L), BabyVisitModel("BabyVisitModel", 97531000090L), BasicConfig("BasicConfig", 97531000100L), BCInventoryModel("BCInventoryModel", 97531000110L), diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/WeightManageConfigModel.java b/platform-dal/src/main/java/com/lyms/platform/pojo/WeightManageConfigModel.java index 78eb430..c69f657 100644 --- a/platform-dal/src/main/java/com/lyms/platform/pojo/WeightManageConfigModel.java +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/WeightManageConfigModel.java @@ -4,6 +4,7 @@ import com.lyms.platform.beans.SerialIdEnum; import com.lyms.platform.common.result.BaseModel; import org.springframework.data.mongodb.core.mapping.Document; +import java.io.Serializable; import java.util.Date; import java.util.LinkedHashMap; import java.util.List; @@ -27,9 +28,9 @@ public class WeightManageConfigModel extends BaseModel { private String dinner;//晚餐 private String dinnerAdd;//晚加餐 - private String vegetable;//菜名称 - private String foodMaterial; //食材 - private List makeMethod;//制作方法 + //食谱 + private List cookbooks; + private String weightType;//体重类型 private List suggests;//建议 @@ -81,6 +82,14 @@ public class WeightManageConfigModel extends BaseModel { this.lunch = lunch; } + public List getCookbooks() { + return cookbooks; + } + + public void setCookbooks(List cookbooks) { + this.cookbooks = cookbooks; + } + public String getLunchAdd() { return lunchAdd; } @@ -105,29 +114,6 @@ public class WeightManageConfigModel extends BaseModel { this.dinnerAdd = dinnerAdd; } - public String getVegetable() { - return vegetable; - } - - public void setVegetable(String vegetable) { - this.vegetable = vegetable; - } - - public String getFoodMaterial() { - return foodMaterial; - } - - public void setFoodMaterial(String foodMaterial) { - this.foodMaterial = foodMaterial; - } - - public List getMakeMethod() { - return makeMethod; - } - - public void setMakeMethod(List makeMethod) { - this.makeMethod = makeMethod; - } public String getWeightType() { return weightType; @@ -145,6 +131,8 @@ public class WeightManageConfigModel extends BaseModel { this.suggests = suggests; } + + @Override public String toString() { return "WeightManageConfigModel{" + @@ -157,11 +145,59 @@ public class WeightManageConfigModel extends BaseModel { ", lunchAdd='" + lunchAdd + '\'' + ", dinner='" + dinner + '\'' + ", dinnerAdd='" + dinnerAdd + '\'' + - ", vegetable='" + vegetable + '\'' + - ", foodMaterial=" + foodMaterial + - ", makeMethod=" + makeMethod + ", weightType='" + weightType + '\'' + ", suggests='" + suggests + '\'' + '}'; } + + public static class Cookbook implements Serializable { + private static final long serialVersionUID = SerialIdEnum.Cookbook.getCid(); + private String vegetable;//菜名称 + private String foodMaterial; //食材 + private List makeMethod;//制作方法 + private String weightType;//体重类型 + private String week; + + public String getWeightType() { + return weightType; + } + + public void setWeightType(String weightType) { + this.weightType = weightType; + } + + public String getWeek() { + return week; + } + + public void setWeek(String week) { + this.week = week; + } + + public String getVegetable() { + return vegetable; + } + + public void setVegetable(String vegetable) { + this.vegetable = vegetable; + } + + public String getFoodMaterial() { + return foodMaterial; + } + + public void setFoodMaterial(String foodMaterial) { + this.foodMaterial = foodMaterial; + } + + public List getMakeMethod() { + return makeMethod; + } + + public void setMakeMethod(List makeMethod) { + this.makeMethod = makeMethod; + } + } } + + diff --git a/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdfyFmService.java b/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdfyFmService.java index 7b5bf50..40c19e5 100644 --- a/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdfyFmService.java +++ b/platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdfyFmService.java @@ -861,17 +861,17 @@ public class QhdfyFmService { try { FmPatInfo patInfo = null; - List list = queryRunner.query(conn, "SELECT syxh,hzxm as name,sfzh as cardNo,sex as sex,birth,lxrdh as phone, blh FROM THIS4_BASY WHERE lxrdh <> '' and hzxm is not null and hzxm <> '' and len(lxrdh) = 11 and syxh = '"+syxh+"'", new BeanListHandler(FmPatInfo.class)); + List list = queryRunner.query(conn, "SELECT syxh,hzxm as name,sfzh as cardNo,sex as sex,birth,lxrdh as phone, blh FROM THIS4_BASY WHERE syxh = '"+syxh+"'", new BeanListHandler(FmPatInfo.class)); if (CollectionUtils.isNotEmpty(list)) { patInfo = list.get(0); } - else - { - List list1 = queryRunner.query(conn, "SELECT SYXH as syxh, BRXM as name,'' as cardNo,BRXB as sex,'' as birth,LXDH as phone,ZYHM as blh FROM JHMK_BASY WHERE len(LXDH) = 11 and SYXH = '"+syxh+"'", new BeanListHandler(FmPatInfo.class)); - if (CollectionUtils.isNotEmpty(list1)) { - patInfo = list1.get(0); - } - } +// else +// { +// List list1 = queryRunner.query(conn, "SELECT SYXH as syxh, BRXM as name,'' as cardNo,BRXB as sex,'' as birth,LXDH as phone,ZYHM as blh FROM JHMK_BASY WHERE len(LXDH) = 11 and SYXH = '"+syxh+"'", new BeanListHandler(FmPatInfo.class)); +// if (CollectionUtils.isNotEmpty(list1)) { +// patInfo = list1.get(0); +// } +// } return patInfo; }catch (SQLException e) { @@ -895,7 +895,7 @@ public class QhdfyFmService { try { FmPatInfo patInfo = null; - List list = queryRunner.query(conn, "SELECT syxh,hzxm as name,sfzh as cardNo,sex as sex,birth,lxrdh as phone, blh FROM THIS4_BASY WHERE hzxm is not null and hzxm <> '' and sfzh = '"+cardNo+"'", new BeanListHandler(FmPatInfo.class)); + List list = queryRunner.query(conn, "SELECT syxh,hzxm as name,sfzh as cardNo,sex as sex,birth,lxrdh as phone, blh FROM THIS4_BASY WHERE sfzh = '"+cardNo+"'", new BeanListHandler(FmPatInfo.class)); if (CollectionUtils.isNotEmpty(list)) { patInfo = list.get(0); } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java index ac21115..975e5e9 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java @@ -22,6 +22,7 @@ import com.lyms.platform.permission.dao.master.CouponMapper; import com.lyms.platform.pojo.DoctorUserMap; import com.lyms.platform.pojo.PatientWeight; import com.lyms.platform.pojo.Patients; +import com.lyms.platform.pojo.WeightManageConfigModel; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.collections.MapUtils; @@ -170,8 +171,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient patientWeight.setOperaterId(userId.toString()); patientWeight.setCreated(new Date()); if(StringUtils.isNotBlank(patientWeight.getNowWeight()) && patientWeight.getBeforeHeight() != null) { - patientWeight.setBmi(getBmi(patientWeight.getNowWeight(), patientWeight.getBeforeHeight())); - //patientWeight.setBmi(getBmi(patientWeight.getBeforeWeight(), patientWeight.getBeforeHeight())); + patientWeight.setBmi(getBmi(patientWeight.getBeforeWeight(), patientWeight.getBeforeHeight())); } patientWeight.setYn("1"); // mongoTemplate.save(patientWeight); @@ -404,10 +404,35 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient pregnancy.replaceAll("\\+0天", ""); } map.put("pregnancy", pregnancy); - if(week != null) { + if(week != null && StringUtils.isNotEmpty(patientWeight.getBmi())) { + String weightType = ""; + + //体重正常 过轻 过重 是依据孕妇BMI指数来的。 + //BMI计算方式:BMI=孕前体重(kg)/【身高(m)×身高(m)】 + //对应范围:BMI<18.5对应体重过轻 BMI=18.5-24.9对应正常体重 BMI>25对应体重过重 + + double bmi = Double.parseDouble(patientWeight.getBmi()); + if (bmi < 18.5) + { + weightType = "过轻"; + } + else if (bmi >= 18.5 && bmi <= 24.9) + { + weightType = "正常"; + } + else if (bmi > 25) + { + weightType = "过重"; + } + week = 12; + weightType = "正常"; + + WeightManageConfigModel configModel = getWeightConfig(String.valueOf(week),weightType); setInfo(week, map); // 设置孕期相关营养信息 - setRecipe(week, map); // 设置食谱 + setRecipe(map, configModel); // 设置食谱 setGuide(week, map); // 设置指南 + setSuggest(map, configModel); // 设置建议 + setCookbook(map, configModel); // 设置菜谱 } Map dayWeights = patientWeight.getDayWeights(); @@ -696,97 +721,39 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } } - private void setRecipe(Integer week, Map map) { - String recipeTitle1 = ""; - String recipeTitle2 = ""; + private void setRecipe(Map map,WeightManageConfigModel configModel) { Map breakfast = new LinkedHashMap<>(); // 早餐 Map breakfast2 = new LinkedHashMap<>(); // 上午加餐 Map lunch = new LinkedHashMap<>(); // 午餐 Map lunch2 = new LinkedHashMap<>(); // 下午加餐 Map dinner = new LinkedHashMap<>(); // 晚餐 Map dinner2 = new LinkedHashMap<>(); // 晚加餐 - if(week <= 12) { - setData(breakfast, "早餐", "(谷类80克,蔬菜70克,蛋类50克,坚果18克,油脂5克)\n" + - "面包(30克);小米绿豆粥(小米25克,绿豆25克);\n" + - "水煮鸡蛋(白皮鸡蛋50克);\n" + - "芝麻拌海带(黑芝麻18克,水发海带70克,芝麻油5克)。"); - setData(breakfast2, "上午加餐", "(水果100克)\n" + - "苹果(100克)"); - setData(lunch, "午餐", "(谷类125克,蔬菜245克,畜禽肉25克,鱼虾类100克,油脂7克)\n" + - "米饭(粳米125克);\n" + - "清蒸鲤鱼(鲤鱼100克,葱25克、姜15克,花生油2克);\n" + - "清炒荷兰豆(荷兰豆50克,花生油2克);\n" + - "鲜蘑炒肉(鲜蘑菇55克,瘦畜肉20克,花生油2克);\n" + - "菠菜炖肝汤(菠菜100克,畜禽肝5克,花生油1克)。"); - setData(lunch2, "下午加餐", "(水果110克)\n" + - "葡萄(110克)"); - setData(dinner, "晚餐", "(谷类100克,蔬菜158克,畜禽肉25克,鱼虾类50克,大豆制品70克,油脂7克)\n" + - "肉包子(面粉100克,瘦畜肉25克,芸豆30克,大葱18克,花生油3克);\n" + - "芹菜炒香干(豆腐干70克,嫩芹菜茎55克,花生油2克);\n" + - "虾仁汤(虾仁50克,黄瓜55克,花生油2克)。"); - setData(dinner2, "晚加餐", "(乳制品250克)\n" + - "牛奶(250克)"); - - recipeTitle1 = "孕早期营养食谱举例"; - recipeTitle2 = "以身高1.60m轻度体力劳动、中等身材的女性为例,孕早期一天所需能量约为1925千卡"; - } else if(week <= 28) { - setData(breakfast, "早餐", "(谷类75克,蔬菜70克,蛋类50克,坚果15克,油脂5克)\n" + - "全麦面包(全麦粉25克);小米粥(小米25克,大米25克);\n" + - "煮鸡蛋(鸡蛋50克);\n" + - "莴笋拌花生米(莴笋70克,花生米15克,芝麻油5克)。"); - setData(breakfast2, "上午加餐", "(水果110克,乳制品125克)\n" + - "水蜜桃(110克);\n" + - "酸奶(125克)。"); - setData(lunch, "午餐", "(谷类125克,蔬菜220克,畜禽肉25克,鱼虾类56克,油脂7克)\n" + - "米饭(粳米125克);\n" + - "青椒肉丝(鸡胸脯肉25克,青甜椒55克,花生油2克);\n" + - "芹菜鱿鱼(芹菜茎55克,鲜鱿鱼40克,花生油2克);\n" + - "清炒木耳菜(木耳菜55克,花生油2克);\n" + - "西红柿菠菜汤(西红柿30克,菠菜25克,虾仁16克,芝麻油1克)。"); - setData(lunch2, "下午加餐", "(水果100克,乳制品125克)\n" + - "桔子(100克);\n" + - "酸奶(125克)。"); - setData(dinner, "晚餐", "(谷类125克,蔬菜165克,畜禽肉25克,鱼虾类44克,大豆制品180克,油脂8克)\n" + - "米饭(大米125克);\n" + - "红烧鲅鱼(鲜鲅鱼44克,花生油4克);\n" + - "豆腐烩多蔬(南豆腐180克,鲜蘑菇30克,胡萝卜20克,竹笋30克,芸豆25克,花生油3克);\n" + - "海带肉丝汤(水发海带35克,瘦畜肉25克,菠菜25克,花生油1克)。"); - setData(dinner2, "晚加餐", "(水果100克,乳制品250克)\n" + - "苹果(100克);\n" + - "酸奶(250克)。"); - recipeTitle1 = "孕中期营养食谱举例"; - recipeTitle2 = "以身高1.60m轻度体力劳动、中等身材的女性为例,孕中期一天所需能量约为2125千卡"; - } else { - setData(breakfast, "早餐", "(谷类75克,蔬菜55克,蛋类50克,坚果15克,油脂5克)\n" + - "鸡蛋发糕(面粉50克,鸡蛋50克,花生油2克);麦片粥(麦片25克);\n" + - "芹菜拌花生米(芹菜茎55克,花生米15克,芝麻油3克)。"); - setData(breakfast2, "上午加餐", "(水果100克,乳制品125克)\n" + - "苹果(100克);\n" + - "酸奶(125克)。"); - setData(lunch, "午餐", "(谷类125克,蔬菜245克,畜禽肉50克,鱼虾类100克,油脂7克)\n" + - "青菜面(挂面125克,嫩油菜50克,花生油1克);\n" + - "木耳炒鸡片(鸡胸脯肉50克,水发木耳55克,花生油2克);\n" + - "清蒸鲤鱼(鲤鱼100克,葱25克、姜15克,花生油2克);\n" + - "清炒菠菜(菠菜100克,花生油2克)。"); - setData(lunch2, "下午加餐", "(水果110克,乳制品125克)\n" + - "葡萄(110克);\n" + - "酸奶(125克)。"); - setData(dinner, "晚餐", "(谷类128克,蔬菜106克,畜禽肉50克,鱼虾类15克,大豆制品70克,油脂8克)\n" + - "红豆饭(红豆28克,大米100克);\n" + - "四季豆炒肉丝(芸豆/四季豆50克,瘦畜肉50克,花生油3克);\n" + - "韭菜炒香干(香干70克,韭菜50克,花生油3克);\n" + - "紫菜虾皮汤(干紫菜6克,干虾皮15克,花生油2克)。"); - setData(dinner2, "晚加餐", "(水果60克,乳制品250克)\n" + - "鲜枣(60克);\n" + - "酸奶(250克)。"); - recipeTitle1 = "孕晚期营养食谱举例"; - recipeTitle2 = "以身高1.60m轻度体力劳动、中等身材的女性为例,孕晚期一天所需能量约为2125千卡"; - } + + setData(breakfast, "早餐",configModel.getBreakfast()); + setData(breakfast2, "上午加餐", configModel.getBreakfastAdd()); + setData(lunch, "午餐", configModel.getLunch()); + setData(lunch2, "下午加餐", configModel.getLunchAdd()); + setData(dinner, "晚餐", configModel.getDinner()); + setData(dinner2, "晚加餐", configModel.getDinnerAdd()); + String recipeTitle1 = "孕晚期营养食谱举例"; + String recipeTitle2 = configModel.getExample(); map.put("recipeTitle1", recipeTitle1); map.put("recipeTitle2", recipeTitle2); map.put("food", Arrays.asList(breakfast, breakfast2, lunch, lunch2, dinner, dinner2)); } + + private void setSuggest(Map map,WeightManageConfigModel configModel) { + List suggests = configModel.getSuggests(); + map.put("suggest", suggests); + } + + private void setCookbook(Map map,WeightManageConfigModel configModel) { + List cookbooks = configModel.getCookbooks(); + map.put("cookbooks", cookbooks); + map.put("cookbookTitle", "推荐菜谱"); + } + private void setData(Map map, String key, String value) { map.put("id", key); map.put("name", value); @@ -1243,4 +1210,18 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient Double n = Double.parseDouble(now); return MathUtil.doubleFormat2(n - b); } + + + /** + * 获取体重配置 + * @param week 孕周 + * @param weightType + * @return + */ + private WeightManageConfigModel getWeightConfig(String week,String weightType) + { + WeightManageConfigModel weightManageConfigModel = mongoTemplate.findOne(Query.query(Criteria.where("week").is(week).and("weightType").is(weightType)), + WeightManageConfigModel.class); + return weightManageConfigModel; + } }