From 7e4b117651c047a13c0efae991f9b91508cb1c70 Mon Sep 17 00:00:00 2001 From: jiangjiazhi Date: Mon, 27 Aug 2018 16:20:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=93=E9=87=8D=E8=90=A5?= =?UTF-8?q?=E5=85=BB=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/PatientWeightController.java | 99 +++- .../operate/web/service/PatientWeightService.java | 6 +- .../web/service/impl/PatientWeightServiceImpl.java | 570 +++++++++++---------- 3 files changed, 399 insertions(+), 276 deletions(-) diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java index 8b30f6b..ec6e354 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java @@ -34,12 +34,11 @@ public class PatientWeightController extends BaseController { } /** - * - * @param key 姓名/证件号/联系方式 - * @param vcCardNo 就诊卡号 + * @param key 姓名/证件号/联系方式 + * @param vcCardNo 就诊卡号 * @param currentWeekStart 当前孕周开始 - * @param currentWeekEnd 当前孕周结束 - * @param age 年龄 + * @param currentWeekEnd 当前孕周结束 + * @param age 年龄 * @param page * @param limit * @param request @@ -54,6 +53,7 @@ public class PatientWeightController extends BaseController { /** * 保存之后查看的数据 + * * @param id * @return */ @@ -80,14 +80,15 @@ public class PatientWeightController extends BaseController { /** * 体重报告 + * * @param id * @return */ @ResponseBody @RequestMapping(value = "report/{id}", method = RequestMethod.GET) @TokenRequired - public BaseResponse report(@PathVariable String id,HttpServletRequest request) { - return patientWeightService.report(id,getUserId(request)); + public BaseResponse report(@PathVariable String id, HttpServletRequest request) { + return patientWeightService.report(id, getUserId(request)); } /** @@ -101,6 +102,7 @@ public class PatientWeightController extends BaseController { /** * 保存修改体重报告(小程序使用) + * * @return */ @ResponseBody @@ -111,6 +113,7 @@ public class PatientWeightController extends BaseController { /** * 保存修改体重报告(小程序使用) + * * @return */ @ResponseBody @@ -131,4 +134,86 @@ public class PatientWeightController extends BaseController { public BaseResponse syncUpdate(String id, String beforeWeight, String beforeHeight, String date, String nowWeight, Integer userId, String bregmatic, String bregmaticOther) { return patientWeightService.update(userId, id, beforeWeight, beforeHeight, date, nowWeight, bregmatic, bregmaticOther, false); } + + /** + * 孕妇基本信息接口 + * + * @param pid + * @return + */ + @ResponseBody + @RequestMapping(value = "/base/info", method = RequestMethod.GET) + public BaseResponse patientBasicInfo(String pid) { + return patientWeightService.patientBaseInfo(pid); + } + + /** + * 孕妇基本信息接口 + * + * @param pid + * @return + */ + @ResponseBody + @RequestMapping(value = "/last/check", method = RequestMethod.GET) + public String patientLastCheck(String pid) { + return patientWeightService.lastCheckTime(pid); + } + + /** + * 孕期体重管理曲线 + * + * @param pid + * @return + */ + public BaseResponse patientReportInfo(String pid) { + return null; + } + + /** + * 孕期食谱 + * + * @param pid + * @return + */ + @ResponseBody + @RequestMapping(value = "/recipe/info", method = RequestMethod.GET) + public BaseResponse patientRecipeInfo(String pid) { + return patientWeightService.patientRecipeInfo(pid, 2); + } + + /** + * 膳食摄入量推荐 + * + * @param pid + * @return + */ + @ResponseBody + @RequestMapping(value = "/suggest/info", method = RequestMethod.GET) + public BaseResponse patientSuggestInfo(String pid) { + return patientWeightService.patientRecipeInfo(pid, 3); + } + + /** + * 孕期营养指南 + * + * @param pid + * @return + */ + @ResponseBody + @RequestMapping(value = "/guide/info", method = RequestMethod.GET) + public BaseResponse patientGuideInfo(String pid) { + return patientWeightService.patientRecipeInfo(pid, 1); + } + + /** + * 孕期推荐菜谱 + * + * @param pid + * @return + */ + @ResponseBody + @RequestMapping(value = "/cookbook/info", method = RequestMethod.GET) + public BaseResponse patientCookbookInfo(String pid) { + return patientWeightService.patientRecipeInfo(pid, 4); + } } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java index 8c59305..7d7e776 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java @@ -7,8 +7,10 @@ import com.lyms.platform.pojo.PatientWeight; * Created by lt on 2017/9/6 0006 */ public interface PatientWeightService extends IBaseService { - BaseResponse init(); + String lastCheckTime(String pid); + BaseResponse init(); + BaseResponse patientRecipeInfo(String pid,Integer type); BaseResponse addOrUpdate(Integer userId, PatientWeight patientWeight); BaseResponse list(String key, String vcCardNo, Integer currentWeekStart, Integer currentWeekEnd, Integer age, Integer page, Integer limit, Integer userId); @@ -28,6 +30,6 @@ public interface PatientWeightService extends IBaseService { BaseResponse wxAddOrUpdateSync(PatientWeight patientWeight); String getBmi(String weight, String height); - + BaseResponse patientBaseInfo(String pid); BaseResponse update(Integer userId, String id, String beforeWeight, String beforeHeight, String date, String nowWeight, String bregmatic, String bregmaticOther, boolean sync); } 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 402f109..c1f0675 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 @@ -4,13 +4,11 @@ import com.lyms.platform.biz.service.BasicConfigService; import com.lyms.platform.biz.service.DoctorUserMapService; import com.lyms.platform.biz.service.PatientWeightService2; import com.lyms.platform.biz.service.PatientsService; +import com.lyms.platform.common.constants.ErrorCodeConstants; import com.lyms.platform.common.enums.BregmaticEnums2; import com.lyms.platform.common.enums.OptActionEnums; import com.lyms.platform.common.enums.RemoteServerEnmus; -import com.lyms.platform.common.result.BaseResponse; -import com.lyms.platform.common.result.PageResult; -import com.lyms.platform.common.result.RespBuilder; -import com.lyms.platform.common.result.ResponseCode; +import com.lyms.platform.common.result.*; import com.lyms.platform.common.utils.*; import com.lyms.platform.operate.web.facade.AutoMatchFacade; import com.lyms.platform.operate.web.facade.OperateLogFacade; @@ -76,12 +74,9 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient private DoctorUserMapService doctorUserMapService; - - - /** * 最低:0~13 : 0~1.9 13~40 1.9~11.9 - * 最高: 0~2.2 2.2~15.9 + * 最高: 0~2.2 2.2~15.9 */ @Override @@ -98,9 +93,9 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); // PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId()).and("hospitalId").is(hospitalId)), PatientWeight.class); PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId())), PatientWeight.class); - if(pw == null && StringUtils.isEmpty(patientWeight.getBeforeWeight())) { + if (pw == null && StringUtils.isEmpty(patientWeight.getBeforeWeight())) { patients = mongoTemplate.findOne(Query.query(Criteria.where("source").is(patientWeight.getPatientId()).and("hospitalId").is(hospitalId).and("enable").is("2")), Patients.class); - if(patients == null) { + if (patients == null) { return RespBuilder.buildErro(ResponseCode.NEED_ADD_PATIENT_WEIGHT); } patientWeight.setPatientId(patients.getId()); @@ -124,7 +119,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient return RespBuilder.buildErro(ResponseCode.PATIENT_WEIGHT_IS_EXIST); }*/ - if(patients != null && !hospitalId.equals(patients.getHospitalId())) {// 隐藏建档 + if (patients != null && !hospitalId.equals(patients.getHospitalId())) {// 隐藏建档 patients.setId(null); patients.setHospitalId(hospitalId); patients.setEnable("2"); @@ -137,8 +132,8 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } Map dayWeights = new LinkedHashMap<>(); List> dayWeights2 = new ArrayList<>(); - if(pw != null) { - if(MapUtils.isNotEmpty(pw.getDayWeights())) { + if (pw != null) { + if (MapUtils.isNotEmpty(pw.getDayWeights())) { dayWeights = pw.getDayWeights(); } dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight); @@ -147,11 +142,11 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient String ymdDate = DateUtil.getyyyy_MM_dd(new Date()); boolean flag = true; - if(CollectionUtils.isNotEmpty(pw.getDayWeights2())) { + if (CollectionUtils.isNotEmpty(pw.getDayWeights2())) { dayWeights2 = pw.getDayWeights2(); } for (Map map : dayWeights2) { - if(map.get("date").equals(ymdDate)) { + if (map.get("date").equals(ymdDate)) { flag = false; map.put("hospitalId", hospitalId); map.put("hospitalName", couponMapper.getHospitalName(hospitalId)); @@ -159,7 +154,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient map.put("nowWeight", nowWeight); } } - if(flag) { + if (flag) { Map m = new HashMap<>(); m.put("hospitalId", hospitalId); m.put("hospitalName", couponMapper.getHospitalName(hospitalId)); @@ -173,7 +168,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient return RespBuilder.buildSuccess(pw.getId()); } - if(StringUtils.isEmpty(patientWeight.getId()) && patients != null) { + if (StringUtils.isEmpty(patientWeight.getId()) && patients != null) { // antenatalExaminationFacade.handHideBuild(patients.getPid(), patients.getId(), userId, 1); dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight); @@ -182,7 +177,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient patientWeight.setHospitalId(hospitalId); patientWeight.setOperaterId(userId.toString()); patientWeight.setCreated(new Date()); - if(StringUtils.isNotBlank(patientWeight.getNowWeight()) && patientWeight.getBeforeHeight() != null) { + if (StringUtils.isNotBlank(patientWeight.getNowWeight()) && patientWeight.getBeforeHeight() != null) { patientWeight.setBmi(getBmi(patientWeight.getBeforeWeight(), patientWeight.getBeforeHeight())); } patientWeight.setYn("1"); @@ -224,33 +219,33 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient @Override public BaseResponse list(String key, String vcCardNo, Integer currentWeekStart, Integer currentWeekEnd, Integer age, Integer page, Integer limit, Integer userId) { boolean flag = false; - List hospital = groupsFacade.findGroupHospital(userId, false) ; + List hospital = groupsFacade.findGroupHospital(userId, false); Criteria criteria = Criteria.where("yn").ne("0").and("hospitalId").in(hospital); Criteria pCriteria = Criteria.where("yn").ne("0").and("hospitalId").in(hospital); - if(StringUtils.isNotBlank(key)) { + if (StringUtils.isNotBlank(key)) { pCriteria.orOperator(Criteria.where("phone").regex(key), Criteria.where("username").regex(key), Criteria.where("cardNo").is(key)); flag = true; } - if(StringUtils.isNotBlank(vcCardNo)) { + if (StringUtils.isNotBlank(vcCardNo)) { pCriteria.and("vcCardNo").is(vcCardNo); flag = true; } - if(currentWeekStart != null && currentWeekEnd != null) { + if (currentWeekStart != null && currentWeekEnd != null) { Date start = DateUtil.getWeekStart(currentWeekEnd); Date end = DateUtil.getWeekEnd(currentWeekStart); pCriteria.and("lastMenses").gt(start).lte(end); flag = true; } - if(age != null) { + if (age != null) { Date start = DateUtil.getBeforeAge(age); Date end = DateUtil.getBeforeAge(age + 1); pCriteria.and("birth").gt(end).lte(start); flag = true; } - if(flag) { + if (flag) { List patients = mongoTemplate.find(Query.query(pCriteria), Patients.class); List ids = new ArrayList<>(); - if(CollectionUtils.isNotEmpty(patients)) { + if (CollectionUtils.isNotEmpty(patients)) { for (Patients patient : patients) { ids.add(patient.getId()); } @@ -261,10 +256,10 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient PageResult pageResult = findMongoPage(PatientWeight.class, new Query(criteria).with(new Sort(Sort.Direction.DESC, "modified")), page, limit); List patientWeights = (List) pageResult.getGrid(); List> restMap = new ArrayList<>(); - if(CollectionUtils.isNotEmpty(patientWeights)) { + if (CollectionUtils.isNotEmpty(patientWeights)) { for (PatientWeight patientWeight : patientWeights) { Patients p = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); - if(p != null) { + if (p != null) { Map temp = new LinkedHashMap<>(); temp.put("id", patientWeight.getId()); temp.put("username", p.getUsername()); @@ -289,12 +284,12 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient // 体质指数(BMI)=孕前体重(kg)÷孕前身高^2(m) @Override - public String getBmi(String weight, String height) { - if(StringUtils.isNotBlank(weight) && StringUtils.isNotEmpty(height)) { + public String getBmi(String weight, String height) { + if (StringUtils.isNotBlank(weight) && StringUtils.isNotEmpty(height)) { java.text.DecimalFormat df = new java.text.DecimalFormat("#.#"); df.setRoundingMode(RoundingMode.FLOOR); double db = Math.pow(Double.parseDouble(height) / 100, 2); - db = Double.valueOf(String.format("%.2f",db)); + db = Double.valueOf(String.format("%.2f", db)); double tzzs = Double.parseDouble(weight) / db; return df.format(tzzs); } @@ -304,29 +299,25 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient @Override public BaseResponse info(String id) { PatientWeight patientWeight = mongoTemplate.findById(id, PatientWeight.class); - if(patientWeight != null) { + if (patientWeight != null) { Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); - if(patients == null) { + if (patients == null) { return RespBuilder.buildSuccess("建档数据未找到"); } Map map = ReflectionUtils.beanToMap(patientWeight); //http://jira.healthbaby.com.cn/browse/WEB-2744 String bregmatic = ""; try { - if (StringUtils.isEmpty(patientWeight.getBregmatic()) || "null".equals(patientWeight.getBregmatic())) - { + if (StringUtils.isEmpty(patientWeight.getBregmatic()) || "null".equals(patientWeight.getBregmatic())) { bregmatic = "未知"; - } - else - { + } else { bregmatic = BregmaticEnums2.getName(patientWeight.getBregmatic()); } - }catch (Exception e) - { + } catch (Exception e) { bregmatic = "未知"; } - map.put("bregmatic",bregmatic); + map.put("bregmatic", bregmatic); map.put("bim", patientWeight.getBmi()); // 体质指数(BMI)=体重(kg)÷身高^2(m) Map dayWeights = patientWeight.getDayWeights(); @@ -339,16 +330,13 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } } - if (dayWeights != null && dayWeights.size() > 0 && StringUtils.isNotEmpty(dayWeights.get(DateUtil.getyyyy_MM_dd(new Date())))) - { - map.put("isShow",true); - } - else - { - map.put("isShow",false); + if (dayWeights != null && dayWeights.size() > 0 && StringUtils.isNotEmpty(dayWeights.get(DateUtil.getyyyy_MM_dd(new Date())))) { + map.put("isShow", true); + } else { + map.put("isShow", false); } - setReport(map, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights(),patientWeight.getBregmatic()); + setReport(map, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights(), patientWeight.getBregmatic()); CollectionUtils.removeNullValue(map); return RespBuilder.buildSuccess(map); @@ -357,7 +345,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } private Map sortMapByKey(Map dayWeights) { - if(MapUtils.isNotEmpty(dayWeights)) { + if (MapUtils.isNotEmpty(dayWeights)) { Map temp = new TreeMap<>(new Comparator() { @Override public int compare(String o1, String o2) { @@ -373,7 +361,6 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } - @Override public BaseResponse edit(String id) { PatientWeight patientWeight = mongoTemplate.findById(id, PatientWeight.class); @@ -385,24 +372,21 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient weightInfo.add(temp); temp.put("id", date); for (Map map : patientWeight.getDayWeights2()) { - if(date.equals(map.get("date").toString())) { + if (date.equals(map.get("date").toString())) { temp.put("name", map.get("nowWeight")); break; } } - if(!temp.containsKey("name")) { + if (!temp.containsKey("name")) { temp.put("name", "--"); } } patientWeight.setWeightInfo(weightInfo); Map dayWeights = patientWeight.getDayWeights(); - if (dayWeights != null && dayWeights.size() > 0 && StringUtils.isNotEmpty(dayWeights.get(DateUtil.getyyyy_MM_dd(new Date())))) - { + if (dayWeights != null && dayWeights.size() > 0 && StringUtils.isNotEmpty(dayWeights.get(DateUtil.getyyyy_MM_dd(new Date())))) { patientWeight.setIsShow(true); - } - else - { + } else { patientWeight.setIsShow(false); } @@ -415,8 +399,113 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient return RespBuilder.buildSuccess(); } + /** + * 查询这个孕妇最新的一次体重数据 + * + * @param pid + * @return + */ + private PatientWeight queryPatientWeight(String pid) { + Query query = new Query(); + query.addCriteria(Criteria.where("pid").is(pid)); + query.with(new Sort(Sort.Direction.DESC, "modified")); + + List patientWeightList = mongoTemplate.find(query, PatientWeight.class); + PatientWeight patientWeight = null; + if (CollectionUtils.isNotEmpty(patientWeightList)) { + patientWeight = patientWeightList.get(0); + } + return patientWeight; + } + + public String lastCheckTime(String pid) { + PatientWeight patientWeight = queryPatientWeight(pid); + Integer week = 0; + if (null != patientWeight) { + Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); + if (patients != null) { + week = DateUtil.getWeek2(patients.getLastMenses(), patientWeight.getModified()); + + } + } + return "孕" + String.valueOf(week) + "期"; + } + + public BaseResponse patientRecipeInfo(String pid, Integer type) { + PatientWeight patientWeight = queryPatientWeight(pid); + Map map = new LinkedHashMap<>(); + if (null != patientWeight) { + Organization org = organizationService.getOrganization(Integer.parseInt(patientWeight.getHospitalId())); + Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); + Integer week = null; + + if (patients != null) { + week = DateUtil.getWeek2(patients.getLastMenses(), new Date()); + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(org.getProvinceId()); + if (week != null && StringUtils.isNotEmpty(patientWeight.getBmi())) { + + //setInfo(week, map); // 设置孕期相关营养信息 + if (week > 5 && week < 41) { + double bmi = Double.parseDouble(patientWeight.getBmi()); + Map kmap = getComputeKul(Double.parseDouble(patientWeight.getBeforeWeight()), + Double.parseDouble(patientWeight.getNowWeight()), week, bmi, patientWeight.getBregmatic()); + if (map == null || map.size() == 0) { + return null; + } + if (1 == type) { + setGuide(week, map); // 设置指南 + } + + WeightConfigModel configModel = getWeightConfigBykcal(kmap, ReportConfig.getNSArea(basicConfig.getName())); + if (configModel != null) { + if (2 == type) { + setRecipe(map, configModel, week, kmap); // 设置食谱 + } else if (3 == type) { + setSuggest(map, configModel, week); // 设置建议 + } else if (4 == type) { + setCookbook(map, configModel); // 设置菜谱 + } + } + } + } + } + } + return new BaseObjectResponse().setData(map).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + } + + + public BaseResponse patientBaseInfo(String pid) { + PatientWeight patientWeight = queryPatientWeight(pid); + Map map = new LinkedHashMap<>(); + if (patientWeight != null) { + Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); + Integer week = null; + + if (patients != null) { + map.put("vcCard", patients.getVcCardNo()); + map.put("username", patients.getUsername()); + map.put("phone", patients.getPhone()); + map.put("dueDate", DateUtil.getyyyy_MM_dd(patients.getDueDate())); + map.put("age", DateUtil.getAge(patients.getBirth()) + " 岁"); + week = DateUtil.getWeek2(patients.getLastMenses(), new Date()); + String yunqi = "孕" + String.valueOf(week) + "期"; + map.put("yunqi", yunqi); + } + map.put("height", patientWeight.getBeforeHeight() == null ? "" : MathUtil.doubleFormat(Double.parseDouble(patientWeight.getBeforeHeight()) / 100) + " 米"); + map.put("beforeWeight", patientWeight.getBeforeWeight() == null ? "" : patientWeight.getBeforeWeight() + " 公斤"); + map.put("bmi", patientWeight.getBmi()); + map.put("nowWeight", patientWeight.getNowWeight() + " 公斤"); + String pregnancy = DateUtil.getWeekDesc(patients.getLastMenses(), new Date()); + if (StringUtils.isNotEmpty(pregnancy) && pregnancy.endsWith("0天")) { + pregnancy.replaceAll("\\+0天", ""); + } + map.put("pregnancy", pregnancy); + } + return new BaseObjectResponse().setData(map).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + } + @Override - public BaseResponse report(String id,Integer userId) { + public BaseResponse report(String id, Integer userId) { String hospitalId = autoMatchFacade.getHospitalId(userId); Organization org = organizationService.getOrganization(Integer.parseInt(hospitalId)); @@ -424,49 +513,46 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(org.getProvinceId()); PatientWeight patientWeight = mongoTemplate.findById(id, PatientWeight.class); - if(patientWeight != null) { + if (patientWeight != null) { Map map = new LinkedHashMap<>(); Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); Integer week = null; - if(patients != null) { + if (patients != null) { map.put("vcCard", patients.getVcCardNo()); map.put("username", patients.getUsername()); map.put("phone", patients.getPhone()); map.put("dueDate", DateUtil.getyyyy_MM_dd(patients.getDueDate())); map.put("age", DateUtil.getAge(patients.getBirth()) + " 岁"); week = DateUtil.getWeek2(patients.getLastMenses(), new Date()); - String yunqi = "孕"+String.valueOf(week)+"期"; + String yunqi = "孕" + String.valueOf(week) + "期"; map.put("yunqi", yunqi); } - map.put("height", patientWeight.getBeforeHeight() == null ? "" : MathUtil.doubleFormat(Double.parseDouble(patientWeight.getBeforeHeight())/100) + " 米"); + map.put("height", patientWeight.getBeforeHeight() == null ? "" : MathUtil.doubleFormat(Double.parseDouble(patientWeight.getBeforeHeight()) / 100) + " 米"); map.put("beforeWeight", patientWeight.getBeforeWeight() == null ? "" : patientWeight.getBeforeWeight() + " 公斤"); map.put("bmi", patientWeight.getBmi()); map.put("nowWeight", patientWeight.getNowWeight() + " 公斤"); String pregnancy = DateUtil.getWeekDesc(patients.getLastMenses(), new Date()); - if(StringUtils.isNotEmpty(pregnancy) && pregnancy.endsWith("0天")) { + if (StringUtils.isNotEmpty(pregnancy) && pregnancy.endsWith("0天")) { pregnancy.replaceAll("\\+0天", ""); } map.put("pregnancy", pregnancy); - if(week != null && StringUtils.isNotEmpty(patientWeight.getBmi())) { + if (week != null && StringUtils.isNotEmpty(patientWeight.getBmi())) { //setInfo(week, map); // 设置孕期相关营养信息 - if (week > 5 && week < 41) - { + if (week > 5 && week < 41) { double bmi = Double.parseDouble(patientWeight.getBmi()); - Map kmap = getComputeKul(Double.parseDouble(patientWeight.getBeforeWeight()), - Double.parseDouble(patientWeight.getNowWeight()), week, bmi,patientWeight.getBregmatic()); - if (map == null || map.size() == 0) - { + Map kmap = getComputeKul(Double.parseDouble(patientWeight.getBeforeWeight()), + Double.parseDouble(patientWeight.getNowWeight()), week, bmi, patientWeight.getBregmatic()); + if (map == null || map.size() == 0) { return null; } setGuide(week, map); // 设置指南 - WeightConfigModel configModel = getWeightConfigBykcal(kmap,ReportConfig.getNSArea(basicConfig.getName())); - if (configModel != null) - { - setRecipe(map, configModel,week,kmap); // 设置食谱 - setSuggest(map, configModel,week); // 设置建议 + WeightConfigModel configModel = getWeightConfigBykcal(kmap, ReportConfig.getNSArea(basicConfig.getName())); + if (configModel != null) { + setRecipe(map, configModel, week, kmap); // 设置食谱 + setSuggest(map, configModel, week); // 设置建议 setCookbook(map, configModel); // 设置菜谱 } } @@ -480,7 +566,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient weights.put(DateUtil.getWeek2(patients.getLastMenses(), DateUtil.parseYMD(entry.getKey())), entry.getValue()); } } - setReport(map, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights(),patientWeight.getBregmatic()); + setReport(map, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights(), patientWeight.getBregmatic()); CollectionUtils.removeNullValue(map); return RespBuilder.buildSuccess(map); } @@ -490,7 +576,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient @Override public BaseResponse wxReport(String pid) { PatientWeight patientWeight = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(pid).and("yn").ne("0")), PatientWeight.class); - if(patientWeight != null) { + if (patientWeight != null) { Map map = new LinkedHashMap<>(); map.put("beforeWeight", patientWeight.getBeforeWeight()); Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); @@ -519,42 +605,42 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient String ymdDate = DateUtil.getyyyy_MM_dd(new Date()); String hospitalId = patientWeight.getHospitalId(); - if(pw == null && StringUtils.isEmpty(patientWeight.getBeforeWeight())) { + if (pw == null && StringUtils.isEmpty(patientWeight.getBeforeWeight())) { return RespBuilder.buildErro(ResponseCode.NEED_ADD_PATIENT_WEIGHT); } - if(pw != null && StringUtils.isNotEmpty(patientWeight.getBeforeWeight())) { + if (pw != null && StringUtils.isNotEmpty(patientWeight.getBeforeWeight())) { return RespBuilder.buildErro(ResponseCode.PATIENT_WEIGHT_IS_EXIST); } - if(patients == null) { + if (patients == null) { return RespBuilder.buildSuccess("patients未找到,patientWeight>>> " + patientWeight); } - if(pw != null) { // 修改 - if(MapUtils.isNotEmpty(pw.getDayWeights())) { + if (pw != null) { // 修改 + if (MapUtils.isNotEmpty(pw.getDayWeights())) { dayWeights = pw.getDayWeights(); } dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight); pw.setNowWeight(nowWeight); pw.setDayWeights(dayWeights); - if(CollectionUtils.isNotEmpty(pw.getDayWeights2())) { + if (CollectionUtils.isNotEmpty(pw.getDayWeights2())) { dayWeights2 = pw.getDayWeights2(); } boolean flag = true; for (Map map : dayWeights2) { - if(map.get("date").equals(ymdDate)) { + if (map.get("date").equals(ymdDate)) { flag = false; - if(hospitalId.equals(map.get("hospitalId") + "")) { + if (hospitalId.equals(map.get("hospitalId") + "")) { map.put("hospitalId", hospitalId); map.put("hospitalName", couponMapper.getHospitalName(hospitalId)); map.put("date", ymdDate); map.put("nowWeight", nowWeight); - } else { + } else { map.put("hospitalId2", hospitalId); map.put("nowWeight2", nowWeight); } } } - if(flag) { + if (flag) { Map m = new HashMap<>(); m.put("hospitalId", hospitalId); m.put("hospitalName", couponMapper.getHospitalName(hospitalId)); @@ -568,7 +654,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient return RespBuilder.buildSuccess(pw); } - if(StringUtils.isNotEmpty(nowWeight)) { + if (StringUtils.isNotEmpty(nowWeight)) { Map m = new HashMap<>(); m.put("hospitalId", hospitalId); m.put("hospitalName", couponMapper.getHospitalName(hospitalId)); @@ -581,7 +667,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient patientWeight.setCreated(new Date()); patientWeight.setHospitalId(patients.getHospitalId()); - if(StringUtils.isNotBlank(patientWeight.getBeforeWeight()) && patientWeight.getBeforeHeight() != null) { + if (StringUtils.isNotBlank(patientWeight.getBeforeWeight()) && patientWeight.getBeforeHeight() != null) { patientWeight.setBmi(getBmi(patientWeight.getBeforeWeight(), patientWeight.getBeforeHeight())); } patientWeight.setYn("1"); @@ -626,12 +712,12 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient patientWeight.setCreated2(null); PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(patientWeight.getPid())), PatientWeight.class); - if(pw != null) { + if (pw != null) { patientWeight.setId(pw.getId()); Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(patientWeight)); mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class); } else { - if(StringUtils.isNotEmpty(patientWeight.getId())) { + if (StringUtils.isNotEmpty(patientWeight.getId())) { mongoTemplate.save(patientWeight); } } @@ -644,14 +730,14 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient public BaseResponse update(final Integer userId, final String id, final String beforeWeight, final String beforeHeight, final String date, final String nowWeight, final String bregmatic, final String bregmaticOther, boolean sync) { PatientWeight patientWeight = mongoTemplate.findById(id, PatientWeight.class); - if(patientWeight == null) { + if (patientWeight == null) { return RespBuilder.buildSuccess("该体重未找到"); } String hospitalId = autoMatchFacade.getHospitalId(userId); PatientWeight beforePatientWeight = mongoTemplate.findById(id, PatientWeight.class); - operateLogFacade.addModifyOptLog(userId, Integer.valueOf(hospitalId), beforePatientWeight, patientWeight,OptActionEnums.UPDATE.getId(), "修改孕体重"); + operateLogFacade.addModifyOptLog(userId, Integer.valueOf(hospitalId), beforePatientWeight, patientWeight, OptActionEnums.UPDATE.getId(), "修改孕体重"); // 绑定医生和患者的关系 /* String patSerSyncUrl = Config.getItem("patSer_sync_url", "0"); @@ -666,25 +752,25 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient DoctorUserMap doctorUserMap = new DoctorUserMap(patientWeight.getPatientId(), couponMapper.findUserName(userId + ""), couponMapper.findHospitalNameById(hospitalId), userId + ""); doctorUserMapService.add(doctorUserMap); - if(StringUtils.isNotEmpty(beforeWeight)) { + if (StringUtils.isNotEmpty(beforeWeight)) { patientWeight.setBeforeWeight(beforeWeight); } - if(StringUtils.isNotEmpty(beforeHeight)) { + if (StringUtils.isNotEmpty(beforeHeight)) { patientWeight.setBeforeHeight(beforeHeight); } - if(StringUtils.isNotEmpty(nowWeight)) { + if (StringUtils.isNotEmpty(nowWeight)) { patientWeight.setNowWeight(nowWeight); } - if(StringUtils.isNotEmpty(bregmatic)) { + if (StringUtils.isNotEmpty(bregmatic)) { patientWeight.setBregmatic(bregmatic); } - if(StringUtils.isNotEmpty(bregmaticOther)) { + if (StringUtils.isNotEmpty(bregmaticOther)) { patientWeight.setBregmaticOther(bregmaticOther); } - if(StringUtils.isNotEmpty(date)) { + if (StringUtils.isNotEmpty(date)) { List> dayWeights2 = patientWeight.getDayWeights2(); for (Map map : dayWeights2) { - if(date.equals(map.get("date"))) { + if (date.equals(map.get("date"))) { map.put("hospitalId", hospitalId); map.put("hospitalName", couponMapper.getHospitalName(hospitalId)); map.put("nowWeight", nowWeight); @@ -695,14 +781,14 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient patientWeight.setDayWeights2(dayWeights2); patientWeight.setDayWeights(dayWeights); - if(StringUtils.isNotEmpty(beforeWeight) && StringUtils.isNotEmpty(beforeHeight)) { + if (StringUtils.isNotEmpty(beforeWeight) && StringUtils.isNotEmpty(beforeHeight)) { patientWeight.setBmi(getBmi(beforeWeight, beforeHeight)); } } patientWeight.setModified(new Date()); patientWeightService2.update(Query.query(Criteria.where("id").is(id)), patientWeight); - if(sync) { + if (sync) { // 同步修改数据 RemoteServerEnmus[] values = RemoteServerEnmus.values(); for (final RemoteServerEnmus server : values) { @@ -741,10 +827,10 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient WeightConfigModel configModel = getWeightConfigByWeek(week); Map map9 = setData2("本周需注意", configModel != null ? configModel.getWeekContent() : ""); map.put("guide", Arrays.asList(map1, map2, map3, map4, map5, map6, map7, map8, map9)); - map.put("guideTitle", "孕"+week+"周营养指南"); + map.put("guideTitle", "孕" + week + "周营养指南"); } - private void setRecipe(Map map,WeightConfigModel configModel,int week,Map kmap) { + private void setRecipe(Map map, WeightConfigModel configModel, int week, Map kmap) { Map breakfast = new LinkedHashMap<>(); // 早餐 Map breakfast2 = new LinkedHashMap<>(); // 上午加餐 Map lunch = new LinkedHashMap<>(); // 午餐 @@ -753,40 +839,35 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient Map dinner2 = new LinkedHashMap<>(); // 晚加餐 String status = kmap.get("status"); - String kcal = Math.round(Double.parseDouble(kmap.get("kulStart")))+"-"+Math.round(Double.parseDouble(kmap.get("kulEnd"))); + String kcal = Math.round(Double.parseDouble(kmap.get("kulStart"))) + "-" + Math.round(Double.parseDouble(kmap.get("kulEnd"))); - setData(breakfast, "早餐",configModel.getBreakfast()); + 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 = "孕"+week+"周"; + String recipeTitle1 = "孕" + week + "周"; map.put("recipeTitle1", recipeTitle1); - map.put("recipeTitle2", "基于您的身高、孕前体重、当前体重及所在孕周,您的累计增重数"+status+"适宜增重范围,为了您与胎儿的健康,本周您每日应摄入的热量为:"+kcal+"kcal。以下为特别向您推荐的对应热量食谱,请参照指导日常饮食。"); + map.put("recipeTitle2", "基于您的身高、孕前体重、当前体重及所在孕周,您的累计增重数" + status + "适宜增重范围,为了您与胎儿的健康,本周您每日应摄入的热量为:" + kcal + "kcal。以下为特别向您推荐的对应热量食谱,请参照指导日常饮食。"); map.put("food", Arrays.asList(breakfast, breakfast2, lunch, lunch2, dinner, dinner2)); } - private void setSuggest(Map map,WeightConfigModel configModel,int week) { + private void setSuggest(Map map, WeightConfigModel configModel, int week) { List suggests = null; - if (week < 12) - { + if (week < 12) { suggests = configModel.getEarlySuggests(); - } - else if (week <= 28) - { + } else if (week <= 28) { suggests = configModel.getMiddleSuggests(); - } - else - { + } else { suggests = configModel.getLaterSuggests(); } map.put("suggest", suggests); } - private void setCookbook(Map map,WeightConfigModel configModel) { - List cookbooks = configModel.getCookbooks(); + private void setCookbook(Map map, WeightConfigModel configModel) { + List cookbooks = configModel.getCookbooks(); map.put("cookbooks", cookbooks); map.put("cookbookTitle", "推荐菜谱"); } @@ -796,7 +877,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient map.put("name", value); } - private Map setData2(String ... values) { + private Map setData2(String... values) { Map map = new LinkedHashMap<>(); map.put("id", values[0]); List value = new ArrayList<>(); @@ -809,25 +890,25 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient /** - BMI指数: - 低体重(<18.5) 0-13周 13-40周 - 最低 0-1.2 1.2-11.9 - 最高 0-3.8 3.8-18.1 - 标准 (18.5-24.9) 0-13周 13-40周 - 最低 0-1.4 1.4-11.9 - 最高 0-3.2 3.2-15.9 - - 超重(25.0-29.9) 0-13周 13-40周 - 最低 0-1.1 1.1-7.1 - 最高 0-3.1 3.2-11.6 - 肥胖 (>=30.0) 0-13周 13-40周 - 最低 0-0.8 0.9-4.9 - 最高 0-2.1 2.1-8.9 + * BMI指数: + * 低体重(<18.5) 0-13周 13-40周 + * 最低 0-1.2 1.2-11.9 + * 最高 0-3.8 3.8-18.1 + * 标准 (18.5-24.9) 0-13周 13-40周 + * 最低 0-1.4 1.4-11.9 + * 最高 0-3.2 3.2-15.9 + *

+ * 超重(25.0-29.9) 0-13周 13-40周 + * 最低 0-1.1 1.1-7.1 + * 最高 0-3.1 3.2-11.6 + * 肥胖 (>=30.0) 0-13周 13-40周 + * 最低 0-0.8 0.9-4.9 + * 最高 0-2.1 2.1-8.9 */ public void setAppReport(Map restMap, Map weights, String beforeWeight, String bmi, Map dayWeights) { List> restList = new ArrayList<>(); dayWeights = sortMapByKey(dayWeights); - if(MapUtils.isNotEmpty(dayWeights)) { + if (MapUtils.isNotEmpty(dayWeights)) { for (String key : dayWeights.keySet()) { Map temp = new LinkedHashMap<>(); temp.put("nowWeight", dayWeights.get(key)); @@ -838,7 +919,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient // 小程序和app可能没有bmi 默认返回标准 Double bmiD = 20D; - if(StringUtils.isNotEmpty(bmi)) { + if (StringUtils.isNotEmpty(bmi)) { bmiD = Double.parseDouble(bmi); } double low = 0D; @@ -846,26 +927,26 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient double high = 0D; double high2 = 0D; String color = ""; - if(bmiD <= 18.5) { + if (bmiD <= 18.5) { low = 1.2; low2 = 11.9; high = 3.8; high2 = 18.1; color = "#00CD00"; - } else if(bmiD > 18.5 && bmiD <= 24.9){ + } else if (bmiD > 18.5 && bmiD <= 24.9) { low = 1.4; low2 = 11.9; high = 3.2; high2 = 15.9; color = "#7EC0EE"; - } else if(bmiD > 24.9 && bmiD < 30){ - low = 1.1 ; + } else if (bmiD > 24.9 && bmiD < 30) { + low = 1.1; low2 = 7.1; high = 3.1; high2 = 11.6; color = "#CD3333"; - } else if(bmiD >= 30){ - low = 0.8 ; + } else if (bmiD >= 30) { + low = 0.8; low2 = 4.9; high = 2.1; high2 = 8.9; @@ -925,7 +1006,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } series.put("portData", list);*/ List> list = new ArrayList<>(); - if(MapUtils.isNotEmpty(weights)) { + if (MapUtils.isNotEmpty(weights)) { Iterator> iterator = weights.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry next = iterator.next(); @@ -944,11 +1025,11 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient */ public static List delOtherPort(List list) { List restList = new ArrayList<>(); - if(CollectionUtils.isNotEmpty(list)) { + if (CollectionUtils.isNotEmpty(list)) { for (int i = 0; i < list.size(); i++) { - if(i == 0) { + if (i == 0) { restList.add(0.1D); - } else if(i == 13 || i == 40) { + } else if (i == 13 || i == 40) { restList.add(MathUtil.doubleFormat2(list.get(i))); } else { restList.add(0D); @@ -959,9 +1040,9 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } public void setReport(Map restMap, Map weights, String beforeWeight, - String bmi, Map dayWeights,String bregmatic) { + String bmi, Map dayWeights, String bregmatic) { List> restList = new ArrayList<>(); - if(MapUtils.isNotEmpty(dayWeights)) { + if (MapUtils.isNotEmpty(dayWeights)) { for (String key : dayWeights.keySet()) { Map temp = new LinkedHashMap<>(); temp.put("nowWeight", dayWeights.get(key)); @@ -972,7 +1053,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient // 小程序和app可能没有bmi 默认返回标准 Double bmiD = 20D; - if(StringUtils.isNotEmpty(bmi)) { + if (StringUtils.isNotEmpty(bmi)) { bmiD = Double.parseDouble(bmi); } String title = ""; @@ -982,37 +1063,34 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient String bmiStr = ""; //空和1表示单胎 - if (!StringUtils.isNotEmpty(bregmatic) || "1".equals(bregmatic)) - { - if(bmiD < 18.5) { + if (!StringUtils.isNotEmpty(bregmatic) || "1".equals(bregmatic)) { + if (bmiD < 18.5) { title = "低体重推荐增重均值"; color = "#00CD00"; bmiStr = "BMI<18.5"; - } else if(bmiD >= 18.5 && bmiD <= 24.9){ + } else if (bmiD >= 18.5 && bmiD <= 24.9) { title = "标准体重推荐增重均值"; color = "#7EC0EE"; bmiStr = "BMI=18.5-24.9"; - } else if(bmiD > 24.9 && bmiD < 30){ + } else if (bmiD > 24.9 && bmiD < 30) { title = "超重体重推荐增重均值"; color = "#CD3333"; bmiStr = "BMI=25-29.9"; - } else if(bmiD >= 30){ + } else if (bmiD >= 30) { title = "肥胖体重推荐增重均值"; color = "#CD00CD"; bmiStr = "BMI≥30"; } - } - else - { - if(bmiD <= 24.9) { + } else { + if (bmiD <= 24.9) { title = "标准体重推荐增重均值"; color = "#7EC0EE"; bmiStr = "BMI≤24.9"; - } else if(bmiD >= 25 && bmiD <= 29.9){ + } else if (bmiD >= 25 && bmiD <= 29.9) { title = "超重体重推荐增重均值"; color = "#CD3333"; bmiStr = "BMI=25-29.9"; - } else if(bmiD >= 30){ + } else if (bmiD >= 30) { title = "肥胖体重推荐增重均值"; color = "#CD00CD"; bmiStr = "BMI≥30"; @@ -1027,29 +1105,25 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient double avg = Double.valueOf(String.format("%.2f", low / 12)); for (int i = 1; i <= 12; i++) { - lowMap.put(i, Double.valueOf(String.format("%.2f",i * avg))); + lowMap.put(i, Double.valueOf(String.format("%.2f", i * avg))); } - double highAvg = Double.valueOf(String.format("%.2f",high / 12)); + double highAvg = Double.valueOf(String.format("%.2f", high / 12)); for (int i = 1; i <= 12; i++) { - highMap.put(i, Double.valueOf(String.format("%.2f",i * highAvg))); + highMap.put(i, Double.valueOf(String.format("%.2f", i * highAvg))); } for (int i = 13; i <= 40; i++) { String range = ""; //空和1表示单胎 - if (!StringUtils.isNotEmpty(bregmatic) || "1".equals(bregmatic)) - { - range = ReportConfig.getWeightRange(bmiStr + "孕" + i + "周"); - } - else - { + if (!StringUtils.isNotEmpty(bregmatic) || "1".equals(bregmatic)) { + range = ReportConfig.getWeightRange(bmiStr + "孕" + i + "周"); + } else { range = ReportConfig.getDWeightRange(bmiStr + "孕" + i + "周"); } - if (StringUtils.isNotEmpty(range)) - { + if (StringUtils.isNotEmpty(range)) { String[] array = range.split("-"); lowMap.put(i, Double.valueOf(String.format("%.2f", Double.valueOf(array[0])))); highMap.put(i, Double.valueOf(String.format("%.2f", Double.valueOf(array[1])))); @@ -1057,7 +1131,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } for (int i = 1; i <= 40; i++) { - normalMap.put(i, Double.valueOf(String.format("%.2f", (highMap.get(i) + lowMap.get(i)) / 2)) ); + normalMap.put(i, Double.valueOf(String.format("%.2f", (highMap.get(i) + lowMap.get(i)) / 2))); } Map reportModel = new LinkedHashMap<>(); @@ -1079,7 +1153,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient reportModel.put("xAxis", xAxis); List list = new ArrayList<>(); - if(MapUtils.isNotEmpty(weights)) { + if (MapUtils.isNotEmpty(weights)) { Iterator> iterator = weights.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry next = iterator.next(); @@ -1094,7 +1168,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient * 获取两个体重之间相差的数值 */ private Double getDiff(String before, String now) { - if(StringUtils.isEmpty(before) || StringUtils.isEmpty(now)) { + if (StringUtils.isEmpty(before) || StringUtils.isEmpty(now)) { return 0D; } Double b = Double.parseDouble(before); @@ -1103,26 +1177,20 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } - private WeightConfigModel getWeightConfigBykcal(Map map,String northSouth) - { - if (map.get("kulStart") == null) - { + private WeightConfigModel getWeightConfigBykcal(Map map, String northSouth) { + if (map.get("kulStart") == null) { return null; } double kulStart = Double.valueOf(map.get("kulStart")); - int k1 = ((int)kulStart/100)*100; + int k1 = ((int) kulStart / 100) * 100; double k2 = kulStart - k1; - if (k2 > 50) - { - k1+=100; + if (k2 > 50) { + k1 += 100; } - if (k1 < 1000) - { + if (k1 < 1000) { k1 = 1000; - } - else if (k1 > 3300) - { + } else if (k1 > 3300) { k1 = 3300; } WeightConfigModel weightConfigModel = mongoTemplate.findOne(Query.query(Criteria.where("northSouth").is(northSouth).and("kcal").is(k1)), @@ -1131,8 +1199,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } - private WeightConfigModel getWeightConfigByWeek(int week) - { + private WeightConfigModel getWeightConfigByWeek(int week) { WeightConfigModel weightConfigModel = mongoTemplate.findOne(Query.query(Criteria.where("week").is(String.valueOf(week))), WeightConfigModel.class); return weightConfigModel; @@ -1141,130 +1208,99 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient /** * 孕妇期所需卡里计算 + * * @param currentWeight 孕前体重 - * @param beforeWeight 当前体重 + * @param beforeWeight 当前体重 * @return */ - private Map getComputeKul(double beforeWeight,double currentWeight,int week,double bmi,String bregmatic) - { - Map map = new HashMap<>(); + private Map getComputeKul(double beforeWeight, double currentWeight, int week, double bmi, String bregmatic) { + Map map = new HashMap<>(); double kulStart = 0; double kulEnd = 0; - String status = ""; + String status = ""; - double add = Double.valueOf(String.format("%.2f",currentWeight - beforeWeight)); + double add = Double.valueOf(String.format("%.2f", currentWeight - beforeWeight)); //孕早期 - if (week <= 12) - { - if (add < 1 && (1 - add >= 0.5)) - { + if (week <= 12) { + if (add < 1 && (1 - add >= 0.5)) { status = "低于"; - kulStart = currentWeight * 25+500; - } - else if (add > 1.5 && (add - 1.5 >= 0.5)) - { + kulStart = currentWeight * 25 + 500; + } else if (add > 1.5 && (add - 1.5 >= 0.5)) { status = "高于"; - kulStart = currentWeight * 25-500; - } - else - { + kulStart = currentWeight * 25 - 500; + } else { status = "处于"; kulStart = currentWeight * 25; } kulEnd = kulStart; } //孕中期 //孕晚期 - else if (week > 12) - { + else if (week > 12) { //基础kcal值 - int basekul = (week > 12 && week <= 27) ? 340 : 450; + int basekul = (week > 12 && week <= 27) ? 340 : 450; - String bmiStr = ""; + String bmiStr = ""; - if (StringUtils.isEmpty(bregmatic) || "1".equals(bregmatic)) - { - if (bmi < 18.5) - { - bmiStr = "BMI<18.5孕"+week+"周"; + if (StringUtils.isEmpty(bregmatic) || "1".equals(bregmatic)) { + if (bmi < 18.5) { + bmiStr = "BMI<18.5孕" + week + "周"; + } else if (bmi <= 24.9 && bmi >= 18.5) { + bmiStr = "BMI=18.5-24.9孕" + week + "周"; + } else if (bmi <= 29.9 && bmi >= 25) { + bmiStr = "BMI=25-29.9孕" + week + "周"; + } else if (bmi >= 30) { + bmiStr = "BMI≥30孕" + week + "周"; } - else if (bmi <= 24.9 && bmi >= 18.5) - { - bmiStr = "BMI=18.5-24.9孕"+week+"周"; - } - else if (bmi <= 29.9 && bmi >= 25) - { - bmiStr = "BMI=25-29.9孕"+week+"周"; - } - else if (bmi >= 30) - { - bmiStr = "BMI≥30孕"+week+"周"; + } else { + if (bmi <= 24.9) { + bmiStr = "BMI≤24.9孕" + week + "周"; + } else if (bmi <= 29.9 && bmi >= 25) { + bmiStr = "BMI=25-29.9孕" + week + "周"; + } else if (bmi >= 30) { + bmiStr = "BMI≥30孕" + week + "周"; } } - else - { - if (bmi <= 24.9) - { - bmiStr = "BMI≤24.9孕"+week+"周"; - } - else if (bmi <= 29.9 && bmi >= 25) - { - bmiStr = "BMI=25-29.9孕"+week+"周"; - } - else if (bmi >= 30) - { - bmiStr = "BMI≥30孕"+week+"周"; - } - } - - if (StringUtils.isEmpty(bmiStr)) - { + if (StringUtils.isEmpty(bmiStr)) { return map; } String[] rangeWeight = null; - if (StringUtils.isEmpty(bregmatic) || "1".equals(bregmatic)) - { + if (StringUtils.isEmpty(bregmatic) || "1".equals(bregmatic)) { rangeWeight = ReportConfig.getWeightRange(bmiStr).split("-"); - } - else - { + } else { rangeWeight = ReportConfig.getDWeightRange(bmiStr).split("-"); } - if (rangeWeight == null || rangeWeight.length != 2) - { + if (rangeWeight == null || rangeWeight.length != 2) { return map; } double addWeightStart = Double.parseDouble(rangeWeight[0]); - double addWeightEnd = Double.parseDouble(rangeWeight[1]); + double addWeightEnd = Double.parseDouble(rangeWeight[1]); - BigDecimal b1 = new BigDecimal(Double.toString(addWeightStart)); - BigDecimal b2 = new BigDecimal(Double.toString(addWeightEnd)); - BigDecimal bw = new BigDecimal(Double.toString(beforeWeight)); + BigDecimal b1 = new BigDecimal(Double.toString(addWeightStart)); + BigDecimal b2 = new BigDecimal(Double.toString(addWeightEnd)); + BigDecimal bw = new BigDecimal(Double.toString(beforeWeight)); double kstart = (bw.add(b1)).multiply(new BigDecimal(25)).doubleValue() + basekul; - double kend = (bw.add(b2)).multiply(new BigDecimal(25)).doubleValue() + basekul; + double kend = (bw.add(b2)).multiply(new BigDecimal(25)).doubleValue() + basekul; // double kstart = (beforeWeight + addWeightStart) * 25 + basekul; // double kend = (beforeWeight + addWeightEnd) * 25 + basekul; status = "处于"; - if (addWeightEnd < add && (Double.valueOf(String.format("%.2f",add - addWeightEnd))) >= 0.5) - { + if (addWeightEnd < add && (Double.valueOf(String.format("%.2f", add - addWeightEnd))) >= 0.5) { status = "高于"; kstart -= 500; kend -= 500; - } - else if (addWeightStart > add && (Double.valueOf(String.format("%.2f",addWeightStart - add))) >= 0.5) - { + } else if (addWeightStart > add && (Double.valueOf(String.format("%.2f", addWeightStart - add))) >= 0.5) { status = "低于"; kstart += 500; kend += 500; @@ -1273,9 +1309,9 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient kulEnd = kend; } - map.put("kulStart",String.valueOf(kulStart)); - map.put("kulEnd",String.valueOf(kulEnd)); - map.put("status",status); + map.put("kulStart", String.valueOf(kulStart)); + map.put("kulEnd", String.valueOf(kulEnd)); + map.put("status", status); return map; } @@ -1283,7 +1319,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient public static void main(String[] args) { PatientWeightServiceImpl patientWeightService = new PatientWeightServiceImpl(); String bmi = patientWeightService.getBmi("68.07", "165"); - Map map = patientWeightService.getComputeKul(50 , 70.43, 18, Double.parseDouble(bmi),"2"); + Map map = patientWeightService.getComputeKul(50, 70.43, 18, Double.parseDouble(bmi), "2"); System.out.println(map); } } -- 1.8.3.1