diff --git a/platform-dal/src/main/java/com/lyms/platform/query/BabyNutritionQuery.java b/platform-dal/src/main/java/com/lyms/platform/query/BabyNutritionQuery.java index d5339e9..2171066 100644 --- a/platform-dal/src/main/java/com/lyms/platform/query/BabyNutritionQuery.java +++ b/platform-dal/src/main/java/com/lyms/platform/query/BabyNutritionQuery.java @@ -24,13 +24,17 @@ public class BabyNutritionQuery extends BaseQuery implements IConvertToNativeQue private String babyId; + private List babyIds; private String hospitalId; private String doctorId; private Date createdStart; - private Date modifiedEnd; + private Date createdEnd; + + private Date nutritiTimeStart; + private Date nutritiTimeEnd; @Override @@ -45,6 +49,9 @@ public class BabyNutritionQuery extends BaseQuery implements IConvertToNativeQue if (null != babyId) { condition = condition.and("babyId", babyId, MongoOper.IS); } + if (null != babyIds && babyIds.size() > 0) { + condition = condition.and("babyId", babyIds, MongoOper.IN); + } if (null != hospitalId) { condition = condition.and("hospitalId", hospitalId, MongoOper.IS); } @@ -54,11 +61,18 @@ public class BabyNutritionQuery extends BaseQuery implements IConvertToNativeQue } Criteria c = null; - if(null != createdStart && createdStart != null){ + if(null != createdStart && createdEnd != null){ + if(c != null){ + c = c.where("created").gte(createdStart).lte(createdEnd); + }else{ + c = Criteria.where("created").gte(createdStart).lte(createdEnd); + } + } + if(null != nutritiTimeStart && nutritiTimeEnd != null){ if(c != null){ - c = c.where("created").gte(createdStart).lte(createdStart); + c = c.where("nutritiTime").gte(nutritiTimeStart).lte(nutritiTimeEnd); }else{ - c = Criteria.where("created").gte(createdStart).lte(createdStart); + c = Criteria.where("nutritiTime").gte(nutritiTimeStart).lte(nutritiTimeEnd); } } @@ -69,6 +83,38 @@ public class BabyNutritionQuery extends BaseQuery implements IConvertToNativeQue } + public Date getCreatedEnd() { + return createdEnd; + } + + public void setCreatedEnd(Date createdEnd) { + this.createdEnd = createdEnd; + } + + public Date getNutritiTimeStart() { + return nutritiTimeStart; + } + + public void setNutritiTimeStart(Date nutritiTimeStart) { + this.nutritiTimeStart = nutritiTimeStart; + } + + public Date getNutritiTimeEnd() { + return nutritiTimeEnd; + } + + public void setNutritiTimeEnd(Date nutritiTimeEnd) { + this.nutritiTimeEnd = nutritiTimeEnd; + } + + public List getBabyIds() { + return babyIds; + } + + public void setBabyIds(List babyIds) { + this.babyIds = babyIds; + } + public String getId() { return id; } @@ -125,11 +171,5 @@ public class BabyNutritionQuery extends BaseQuery implements IConvertToNativeQue this.createdStart = createdStart; } - public Date getModifiedEnd() { - return modifiedEnd; - } - public void setModifiedEnd(Date modifiedEnd) { - this.modifiedEnd = modifiedEnd; - } } \ No newline at end of file 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 5fb9a59..c1b59a6 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 @@ -44,6 +44,30 @@ public class BabyNutritionController extends BaseController{ /** + * 膳食列表 + * @param page + * @param limit + * @param queryNo + * @param vcCardNo + * @param babyName + * @param request + * @return + */ + @RequestMapping(value = "/queryBabyNutritionList", method = RequestMethod.GET) + @ResponseBody + @TokenRequired + public BaseResponse queryBabyNutritionList( @RequestParam("page") Integer page, + @RequestParam("limit") Integer limit, + @RequestParam(required = false)String queryNo, + @RequestParam(required = false)String vcCardNo, + @RequestParam(required = false)String babyName, + @RequestParam(required = false)String recordTime, + HttpServletRequest request){ + return babyNutritionFacade.queryBabyNutritionList(page, limit, queryNo, vcCardNo, babyName, getUserId(request),recordTime); + } + + + /** * 查询营养记录 * @param babyId * @return 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 9aadf38..c92d722 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 @@ -2,6 +2,9 @@ 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.YnEnums; +import com.lyms.platform.common.result.BaseListResponse; import com.lyms.platform.common.result.BaseObjectResponse; import com.lyms.platform.common.result.BaseResponse; import com.lyms.platform.common.utils.*; @@ -20,6 +23,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.*; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Component; import java.util.*; @@ -38,6 +42,9 @@ public class BabyNutritionFacade { private BabyNutritionService babyNutritionService; @Autowired + private BasicConfigFacade basicConfigFacade; + + @Autowired private MeasureDataInfoService mysqlMeasureDataInfoService; @Autowired @@ -46,6 +53,12 @@ public class BabyNutritionFacade { @Autowired private OrganizationService organizationService; + @Autowired + private BabyBookbuildingService babyBookbuildingService; + + @Autowired + private BasicConfigService basicConfigService; + public BaseObjectResponse queryBabyNutritionRecord(String babyId) { Map resMap = new HashMap<>(); @@ -155,9 +168,110 @@ public class BabyNutritionFacade { public List getFoods(String ids) { Map map = new HashMap(); - map.put("ids",ids); + map.put("ids", ids); String data = HttpClientUtil.doGet(amsUrl + "/v1/getFoodsByIds", map, "utf-8", "3d19960bf3e81e7d816c4f26051c49ba"); List results = JsonUtil.toList(data, FoodResult.class); return results; } + + public BaseResponse queryBabyNutritionList(Integer page, Integer limit, String queryNo, String vcCardNo, String babyName,Integer userId,String recordTime) { + String hospitalId = autoMatchFacade.getHospitalId(userId); + List list = new ArrayList<>(); + List babyIds = new ArrayList<>(); + BaseListResponse objectResponse = new BaseListResponse(); + + if (StringUtils.isNotEmpty(queryNo) || StringUtils.isNotEmpty(vcCardNo) || StringUtils.isNotEmpty(babyName)) + { + BabyModelQuery babyQuery = new BabyModelQuery(); + babyQuery.setName(babyName); + babyQuery.setQueryNo(queryNo); + babyQuery.setVcCardNo(vcCardNo); + babyQuery.setYn(YnEnums.YES.getId()); + List babies = babyBookbuildingService.queryBabyBuildByCond(babyQuery); + if (CollectionUtils.isNotEmpty(babies)) + { + for (BabyModel babyModel : babies) + { + babyIds.add(babyModel.getId()); + } + } + + if (CollectionUtils.isEmpty(babyIds)) + { + objectResponse.setData(list); + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + objectResponse.setErrormsg("成功"); + return objectResponse; + } + } + + BabyNutritionQuery babyQuery = new BabyNutritionQuery(); + babyQuery.setHospitalId(hospitalId); + babyQuery.setBabyIds(babyIds); + babyQuery.setLimit(limit); + babyQuery.setPage(page); + + if (StringUtils.isNotEmpty(recordTime)) { + String[] dates = recordTime.split(" - "); + babyQuery.setNutritiTimeStart(DateUtil.parseYMD(dates[0])); + if (dates.length == 2) { + babyQuery.setNutritiTimeEnd(DateUtil.addDay(DateUtil.parseYMD(dates[1]), 1)); + } + } + + babyQuery.setNeed("true"); + babyQuery.setSort(" nutritiTime desc "); + List models = babyNutritionService.queryBabyNutritions(babyQuery); + + if (CollectionUtils.isNotEmpty(models)) + { + for (BabyNutritionModel model : models) + { + Map map = new HashMap(); + + map.put("id",model.getId()); + map.put("babyId",model.getBabyId()); + + BabyModel baby = babyBookbuildingService.queryBabyBuildById(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()); + + String highRiskInfos = basicConfigFacade.queryBaseInfoByStr(baby.getHighRiskInfo()); + map.put("highRiskInfos",highRiskInfos); + + String diagnose = ""; + if (StringUtils.isNotEmpty(baby.getPid())) { + List diagList = babyCheckFacade.getBabyLastDiagnose(baby.getPid()); + if (CollectionUtils.isNotEmpty(diagList)) { + for (Object obj : diagList) { + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById((String) obj); + if (basicConfig != null) { + diagnose += basicConfig.getName() + " "; + } + } + } + } + + map.put("diagnose", StringUtils.emptyDeal(diagnose)); + + map.put("weight", model.getWeight()); + map.put("height", model.getHeight()); + map.put("recordTime", DateUtil.getyyyy_MM_dd(model.getNutritiTime())); + + list.add(map); + } + } + + + + objectResponse.setData(list); + objectResponse.setPageInfo(babyQuery.getPageInfo()); + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + objectResponse.setErrormsg("成功"); + return objectResponse; + } } \ No newline at end of file