diff --git a/running/pdf/healthyReport.pdf b/running/pdf/healthyReport.pdf new file mode 100644 index 000000000..bd2295f14 Binary files /dev/null and b/running/pdf/healthyReport.pdf differ diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerHealthyController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerHealthyController.java index b23ec1bab..1d9c91beb 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerHealthyController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerHealthyController.java @@ -3,6 +3,7 @@ package com.stdiet.custom.controller; import java.util.List; import com.stdiet.common.utils.StringUtils; +import com.stdiet.custom.dto.request.HealthyDetailRequest; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -109,4 +110,14 @@ public class SysCustomerHealthyController extends BaseController { return toAjax(sysCustomerHealthyService.deleteSysCustomerHealthyByIds(ids)); } + + /** + * 生成健康体征报告 + */ + @Log(title = "健康体征报告", businessType = BusinessType.INSERT) + @PostMapping("/generateHealthyReport") + public AjaxResult generateHealthyReport(@RequestBody HealthyDetailRequest healthyDetailRequest) + { + return sysCustomerHealthyService.generateHealthyReport(healthyDetailRequest); + } } \ No newline at end of file diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesPlanController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesPlanController.java index b7de225f6..88f35a1f4 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesPlanController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesPlanController.java @@ -57,6 +57,12 @@ public class SysRecipesPlanController extends BaseController return getDataTable(list); } + @PreAuthorize("@ss.hasPermi('recipes:recipesPlan:list')") + @GetMapping(value = "/list/{cusId}") + public AjaxResult getAllPlanByCusId(@PathVariable Long cusId) { + return AjaxResult.success(sysRecipesPlanService.selectPlanListByCusId(cusId)); + } + /** * 获取食谱计划详细信息 */ diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesPlanModelController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesPlanModelController.java new file mode 100644 index 000000000..6ade85a44 --- /dev/null +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysRecipesPlanModelController.java @@ -0,0 +1,68 @@ +package com.stdiet.web.controller.custom; + +import com.stdiet.common.core.controller.BaseController; +import com.stdiet.common.core.domain.AjaxResult; +import com.stdiet.common.core.page.TableDataInfo; +import com.stdiet.custom.domain.SysRecipesPlanModel; +import com.stdiet.custom.service.ISysRecipesPlanModelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 食谱模板 + * + * @author wonder + * @date 2021-02-27 + */ +@RestController +@RequestMapping("/recipes/model") +public class SysRecipesPlanModelController extends BaseController { + @Autowired + private ISysRecipesPlanModelService iSysRecipesPlanModelService; + + /** + * 查询 + */ + @PreAuthorize("@ss.hasPermi('recipes:recipesModel:list')") + @GetMapping("/list") + public TableDataInfo list(SysRecipesPlanModel sysRecipesPlanModel) { + startPage(); + List list = iSysRecipesPlanModelService.selectRecipesModelListByCondition(sysRecipesPlanModel); + return getDataTable(list); + } + + /** + * 添加 + */ + @PreAuthorize("@ss.hasPermi('recipes:recipesModel:edit')") + @PostMapping("/add") + public AjaxResult add(SysRecipesPlanModel sysRecipesPlanModel) { + return toAjax(iSysRecipesPlanModelService.insertRecipsesModel(sysRecipesPlanModel)); + } + + /** + * 更新 + * + * @param sysRecipesPlanModel + * @return + */ + @PreAuthorize("@ss.hasPermi('recipes:recipesPlan:list')") + @PutMapping(value = "/update") + public AjaxResult update(SysRecipesPlanModel sysRecipesPlanModel) { + return toAjax(iSysRecipesPlanModelService.updateRecipesModel(sysRecipesPlanModel)); + } + + /** + * 删除 + */ + @PreAuthorize("@ss.hasPermi('recipes:recipesPlan:query')") + @DeleteMapping(value = "/delete/{id}") + public AjaxResult delete(@PathVariable("id") Long id) { + return AjaxResult.success(iSysRecipesPlanModelService.removeRecipesModel(id)); + } + + +} \ No newline at end of file diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java index 45cb7f108..bb4236852 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java @@ -34,16 +34,31 @@ public class SysWapController extends BaseController { return AjaxResult.success(iSysWapServices.getRecipesPlanListInfo(outId)); } + /** + * 获取用户信息 + * @param outId + * @return + */ @GetMapping(value = "/healthyInfo/{outId}") public AjaxResult healthy(@PathVariable String outId) { return AjaxResult.success(iSysWapServices.getHealthyDataByOutId(outId)); } + /** + * 获取某天食谱菜品 + * @param id + * @return + */ @GetMapping(value = "/recipes/menu/{id}") public AjaxResult dayilyMenu(@PathVariable Long id) { return AjaxResult.success(iSysRecipesService.selectDishesByMenuId(id)); } + /** + * 系统字典 + * @param dictType + * @return + */ @GetMapping(value = "/dict/{dictType}") public AjaxResult sysDict(@PathVariable String dictType) { return AjaxResult.success(iSysDictTypeService.selectDictDataByType(dictType)); diff --git a/stdiet-common/src/main/java/com/stdiet/common/core/domain/entity/SysDictData.java b/stdiet-common/src/main/java/com/stdiet/common/core/domain/entity/SysDictData.java index 891da5078..87fdda38f 100644 --- a/stdiet-common/src/main/java/com/stdiet/common/core/domain/entity/SysDictData.java +++ b/stdiet-common/src/main/java/com/stdiet/common/core/domain/entity/SysDictData.java @@ -9,6 +9,8 @@ import com.stdiet.common.annotation.Excel.ColumnType; import com.stdiet.common.constant.UserConstants; import com.stdiet.common.core.domain.BaseEntity; +import java.util.List; + /** * 字典数据表 sys_dict_data * @@ -34,8 +36,10 @@ public class SysDictData extends BaseEntity @Excel(name = "字典键值") private String dictValue; - /** 字典类型 */ - @Excel(name = "字典类型") + private List dictValueList; + + /** 字典类型 */ + @Excel(name = "字典类型") private String dictType; /** 样式属性(其他样式扩展) */ @@ -153,7 +157,15 @@ public class SysDictData extends BaseEntity { this.status = status; } - + + public List getDictValueList() { + return dictValueList; + } + + public void setDictValueList(List dictValueList) { + this.dictValueList = dictValueList; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/stdiet-common/src/main/java/com/stdiet/common/utils/HealthyUtils.java b/stdiet-common/src/main/java/com/stdiet/common/utils/HealthyUtils.java index 9f19c3fbe..3f18008a0 100644 --- a/stdiet-common/src/main/java/com/stdiet/common/utils/HealthyUtils.java +++ b/stdiet-common/src/main/java/com/stdiet/common/utils/HealthyUtils.java @@ -16,6 +16,9 @@ public class HealthyUtils { //营养成分比例 public static final Integer[] nutritionRate = {30, 20, 50}; + //默认活动因子 + public static final double activityFactor = 0.3; + /** * 计算减脂每天最大摄入量(千卡) * @param age 年龄 @@ -148,7 +151,7 @@ public class HealthyUtils { * @param weight 体重 * @return */ - public static final Double[] calculateNutritionEveryWeight(Integer[] nutritionQuality, double weight){ + public static Double[] calculateNutritionEveryWeight(Integer[] nutritionQuality, double weight){ Double[] nutritionEveryWeight = new Double[3]; nutritionEveryWeight[0] = NumberUtils.getNumberByRoundHalfUp(nutritionQuality[0]/weight*2,2).doubleValue(); nutritionEveryWeight[1] = NumberUtils.getNumberByRoundHalfUp(nutritionQuality[1]/weight*2,2).doubleValue(); @@ -156,5 +159,19 @@ public class HealthyUtils { return nutritionEveryWeight; } + /** + * 计算不运动热量、运动热量 + * @param metabolizeHeat + * @return + */ + public static Long[] calculateWithoutExerciseHeat(Integer metabolizeHeat){ + Long[] array = new Long[2]; + //不运动热量 + array[0] = Math.round(metabolizeHeat * (1 + activityFactor)); + //运动热量 + array[1] = Math.round(metabolizeHeat * (1 + 0.8)); + return array; + } + } diff --git a/stdiet-common/src/main/java/com/stdiet/common/utils/reflect/ReflectUtils.java b/stdiet-common/src/main/java/com/stdiet/common/utils/reflect/ReflectUtils.java index 57559f1c1..b8cd10e16 100644 --- a/stdiet-common/src/main/java/com/stdiet/common/utils/reflect/ReflectUtils.java +++ b/stdiet-common/src/main/java/com/stdiet/common/utils/reflect/ReflectUtils.java @@ -403,4 +403,22 @@ public class ReflectUtils } return new RuntimeException(msg, e); } + + /** + * 根据属性名获取属性值 + * + * @param fieldName + * @param object + * @return + */ + public static String getFieldValueByFieldName(String fieldName, Object object) { + try { + Field field = object.getClass().getDeclaredField(fieldName); + //设置对象的访问权限,保证对private的属性的访问 + field.setAccessible(true); + return field.get(object) == null ? "" : field.get(object).toString(); + } catch (Exception e) { + return ""; + } + } } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomerHealthy.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomerHealthy.java index 21052d9f8..1b2bb182e 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomerHealthy.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomerHealthy.java @@ -433,6 +433,9 @@ public class SysCustomerHealthy extends BaseEntity //备注 private String remark; + /** 减脂指导 */ + private String guidance; + /** 湿气数据 */ @Excel(name = "湿气数据") private String moistureDate; diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlan.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlan.java index 3251d3bc7..d9e435ead 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlan.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlan.java @@ -28,6 +28,11 @@ public class SysRecipesPlan { private Long cusId; + /** + * 对外的用户id + */ + private String outId; + //客户ID // private Long customerId; @@ -132,4 +137,7 @@ public class SysRecipesPlan { */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date updateTime; + + // 0-普通 1-模板 + private Integer type; } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanModel.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanModel.java new file mode 100644 index 000000000..f491891cd --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanModel.java @@ -0,0 +1,28 @@ +package com.stdiet.custom.domain; + +import lombok.Data; + +import java.util.Date; + +@Data +public class SysRecipesPlanModel { + Long id; + + Long nutritionistId; + + Long nutriAssisId; + + Long planId; + + String remark; + + Date updateTime; + + Date createTime; + + String updateBy; + + String createBy; + + Long recipesId; +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/dto/request/HealthyDetailRequest.java b/stdiet-custom/src/main/java/com/stdiet/custom/dto/request/HealthyDetailRequest.java new file mode 100644 index 000000000..afab4aba9 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/dto/request/HealthyDetailRequest.java @@ -0,0 +1,396 @@ +package com.stdiet.custom.dto.request; + +import com.stdiet.common.annotation.Excel; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class HealthyDetailRequest implements Serializable { + + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 客户ID */ + private Long customerId; + + /** 加密的客户ID,非持久化字段 **/ + private String customerEncId; + + /** 客户姓名,非持久化字段 */ + @Excel(name = "客户姓名") + private String name; + + /** 客户手机号,非持久化字段 */ + @Excel(name = "客户手机号") + private String phone; + + /** 调理项目id */ + //@Excel(name = "调理项目id") + private String conditioningProjectId; + + /** 调理项目名称 ,非持久化字段*/ + @Excel(name = "调理项目") + private String conditioningProject; + + /** 0男 1女 2未知,默认2 */ + @Excel(name = "0男 1女 2未知,默认2") + private String sex; + + /** 年龄 */ + @Excel(name = "年龄") + private String age; + + /** 身高 */ + @Excel(name = "身高") + private String tall; + + /** 体重 */ + @Excel(name = "体重") + private String weight; + + /** 调味品种类,使用 , 隔开 */ + @Excel(name = "调味品种类,使用 , 隔开") + private String condiment; + + /** 其他调味品种类 */ + @Excel(name = "其他调味品种类") + private String otherCondiment; + + /** 喜好的烹调方式,使用 , 隔开 */ + @Excel(name = "喜好的烹调方式,使用 , 隔开") + private String cookingStyle; + + /** 烹调方式对应频次,每周几次,使用 , 隔开 */ + @Excel(name = "烹调方式对应频次,每周几次,使用 , 隔开") + private String cookingStyleRate; + + /** 洗菜方式,使用 , 隔开 */ + @Excel(name = "洗菜方式,使用 , 隔开") + private String washVegetablesStyle; + + /** 其他洗菜方式 */ + @Excel(name = "其他洗菜方式") + private String otherWashVegetablesStyle; + + /** 早餐习惯 */ + @Excel(name = "早餐习惯") + private String breakfastType; + + /** 早餐吃的食物 */ + @Excel(name = "早餐吃的食物") + private String breakfastFood; + + /** 午餐习惯,使用 , 隔开 */ + @Excel(name = "午餐习惯,使用 , 隔开") + private String lunchType; + + /** 晚餐习惯,使用 , 隔开 */ + @Excel(name = "晚餐习惯,使用 , 隔开") + private String dinner; + + /** 早餐当中素菜占比 */ + @Excel(name = "早餐当中素菜占比") + private String vegetableRate; + + /** 最常吃的肉类 */ + @Excel(name = "最常吃的肉类") + private String commonMeat; + + /** 晚餐时间(24小时制) */ + @Excel(name = "晚餐时间", readConverterExp = "2=4小时制") + private String dinnerTime; + + /** 每周吃夜宵次数,默认0 */ + @Excel(name = "每周吃夜宵次数,默认0") + private String supperNum; + + /** 夜宵通常吃的食物 */ + @Excel(name = "夜宵通常吃的食物") + private String supperFood; + + /** 食物的冷热偏好 */ + @Excel(name = "食物的冷热偏好") + private String dietHotAndCold; + + /** 食物的口味偏好,使用 , 隔开 */ + @Excel(name = "食物的口味偏好,使用 , 隔开") + private String dietFlavor; + + /** 平均每周吃生菜几次 */ + @Excel(name = "平均每周吃生菜几次") + private String vegetablesNum; + + /** 每周吃生菜的频次类型 */ + @Excel(name = "每周吃生菜的频次类型") + private String vegetablesRateType; + + /** 平均每天吃水果次数,默认0 */ + @Excel(name = "平均每天吃水果次数,默认0") + private String fruitsNum; + + /** 吃水果的时间段 */ + @Excel(name = "吃水果的时间段") + private String fruitsTime; + + /** 平时吃水果的频次 */ + @Excel(name = "平时吃水果的频次") + private String fruitsRate; + + /** 一餐吃几碗饭 */ + @Excel(name = "一餐吃几碗饭") + private String riceNum; + + /** 吃几成饱 */ + @Excel(name = "吃几成饱") + private String riceFull; + + /** 吃饭速度 */ + @Excel(name = "吃饭速度") + private String eatingSpeed; + + /** 常吃的零食,使用 , 隔开 */ + @Excel(name = "常吃的零食,使用 , 隔开") + private String snacks; + + /** 其他零食 */ + @Excel(name = "其他零食") + private String otherSnacks; + + /** 有无服用营养保健品,0无 1有 */ + @Excel(name = "有无服用营养保健品,0无 1有") + private String healthProductsFlag; + + /** 营养保健品品牌名 */ + @Excel(name = "营养保健品品牌名") + private String healthProductsBrand; + + /** 营养保健品产品名 */ + @Excel(name = "营养保健品产品名") + private String healthProductsName; + + /** 服用营养保健品频次,每周几次 */ + @Excel(name = "服用营养保健品频次,每周几次") + private String healthProductsWeekRate; + + /** 服用营养保健品频次,每天几次 */ + @Excel(name = "服用营养保健品频次,每天几次") + private String healthProductsDayRate; + + /** 每天的饮水量,单位:毫升 */ + @Excel(name = "每天的饮水量,单位:毫升") + private String waterNum; + + /** 喜欢喝什么水,使用 , 隔开 */ + @Excel(name = "喜欢喝什么水,使用 , 隔开") + private String waterType; + + /** 喝水习惯,使用 , 隔开 */ + @Excel(name = "喝水习惯,使用 , 隔开") + private String waterHabit; + + /** 常喝的饮品的每周频次,使用,隔开 */ + @Excel(name = "常喝的饮品的每周频次,使用,隔开") + private String drinksNum; + + /** 是否喝酒 */ + @Excel(name = "是否喝酒") + private String drinkWineFlag; + + /** 喝酒种类,使用,隔开 */ + @Excel(name = "喝酒种类,使用,隔开") + private String drinkWineClassify; + + /** 其他酒种类 */ + @Excel(name = "其他酒种类") + private String otherWineClassify; + + /** 对应酒的量 */ + @Excel(name = "对应酒的量") + private String drinkWineAmount; + + /** 是否抽烟,0否 1是,默认0 */ + @Excel(name = "是否抽烟,0否 1是,默认0") + private String smokeFlag; + + /** 抽烟频次和烟龄,戒烟几年,使用,隔开 */ + @Excel(name = "抽烟频次和烟龄,戒烟几年,使用,隔开") + private String smokeRate; + + /** 是否经常抽二手烟 0否 1是,默认0 */ + @Excel(name = "是否经常抽二手烟 0否 1是,默认0") + private String secondSmoke; + + /** 工作行业 */ + @Excel(name = "工作行业") + private String workIndustry; + + /** 工作性质,使用,隔开 */ + @Excel(name = "工作性质,使用,隔开") + private String workType; + + /** 排便次数 */ + @Excel(name = "排便次数") + private String defecationNum; + + /** 其他手动输入的排便次数 */ + @Excel(name = "其他手动输入的排便次数") + private String otherDefecationNum; + + /** 排便时间段,使用,隔开 */ + @Excel(name = "排便时间段,使用,隔开") + private String defecationTime; + + /** 排便的形状 */ + @Excel(name = "排便的形状") + private String defecationShape; + + /** 排便的气味 */ + @Excel(name = "排便的气味") + private String defecationSmell; + + /** 排便的速度 */ + @Excel(name = "排便的速度") + private String defecationSpeed; + + /** 排便的颜色 */ + @Excel(name = "排便的颜色") + private String defecationColor; + + /** 每周运动次数 */ + @Excel(name = "每周运动次数") + private String motionNum; + + /** 每次运动的时长,分钟 */ + private String motionDuration; + + /** 每天运动的时间,24小时制 */ + private String motionTime; + + /** 有氧运动项目,使用,隔开 */ + private String aerobicMotionClassify; + + /** 无氧运动项目,使用,隔开 */ + private String anaerobicMotionClassify; + + /** 无氧有氧项目,使用,隔开 */ + private String anaerobicAerobicMotionClassify; + + /** 其他运动项目,使用,隔开 */ + private String otherMotionClassify; + + private String motion; + + /** 运动场地,使用,隔开 */ + private String motionField; + + /** 其他运动场地 */ + private String otherMotionField; + + /** 睡觉时间,24小时制 */ + private String sleepTime; + + /** 睡眠质量 */ + private String sleepQuality; + + /** 是否有辅助入睡药物,0否 1是,默认0 */ + private String sleepDrugFlag; + + /** 辅助睡眠类药物名称 */ + private String sleepDrug; + + /** 是否经常熬夜(超过11点)0否 1是,默认0 */ + private String stayupLateFlag; + + /** 熬夜频次,每周几次 */ + private String stayupLateWeekNum; + + /** 家族疾病史,使用,隔开 */ + private String familyIllnessHistory; + + /** 其他家族病史 */ + private String otherFamilyIllnessHistory; + + /** 手术史,使用,隔开 */ + private String operationHistory; + + /** 其他手术史 */ + private String otherOperationHistory; + + /** 近期是否做过手术,0否 1是,默认0 */ + private String nearOperationFlag; + + /** 手术恢复情况 */ + private String recoveryeSituation; + + /** 是否长期服用药物,0否 1是,默认0 */ + private String longEatDrugFlag; + + /** 长期服用的药物,使用,隔开 */ + private String longEatDrugClassify; + + /** 其他长期服用的药物 */ + private String otherLongEatDrugClassify; + + /** 是否出现过过敏症状,0否 1是,默认0 */ + private String allergyFlag; + + /** 过敏症状 */ + private String allergySituation; + + /** 过敏源,使用,隔开 */ + private String allergen; + + /** 其他过敏源 */ + private String otherAllergen; + + /** 体检报告 */ + private String medicalReport; + + /** 体检报告名称 */ + private String medicalReportName; + + /** 南方人北方人,0南方 1北方 */ + private String position; + + /** 减脂经历方法 */ + @Excel(name = "减脂经历方法") + private String experience; + + /** 是否减脂反弹,0否 1是 */ + private String rebound; + + /** 减脂遇到的困难 */ + private String difficulty; + + /** 是否意识到生活习惯是减脂关键 0否 1是 */ + private String crux; + + /** 忌口或饮食食物 */ + private String dishesIngredient; + + /** 饮食习惯 */ + private String makeFoodType; + + /** 客户病史体征,使用,隔开 */ + private String physicalSigns; + + /** 其他病史体征 **/ + private String otherPhysicalSigns; + + /** 气血数据 */ + private String bloodData; + + //备注 + private String remark; + + /** 湿气数据 */ + private String moistureDate; + + + /** 减脂指导 **/ + private String guidance; + +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/NutritionalCalories.java b/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/NutritionalCalories.java index fc23e08bc..99f4d91e9 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/NutritionalCalories.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/NutritionalCalories.java @@ -69,4 +69,23 @@ public class NutritionalCalories implements Serializable { //蛋白质、脂肪、碳水剩余可摄入热量 public Integer[] surplusNutritionalHeat; + + private String nutritionalHeat_one; + + private String nutritionalHeat_two; + + private String nutritionalHeat_three; + + private String nutritionalQuality_one; + + private String nutritionalQuality_two; + + private String nutritionalQuality_three; + + private String weightNutritionalRate_one; + + private String weightNutritionalRate_two; + + private String weightNutritionalRate_three; + } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCustomerHealthyMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCustomerHealthyMapper.java index c60456991..29acf80b2 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCustomerHealthyMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCustomerHealthyMapper.java @@ -2,6 +2,7 @@ package com.stdiet.custom.mapper; import java.util.List; +import com.stdiet.common.core.domain.entity.SysDictData; import com.stdiet.custom.domain.SysCustomer; import com.stdiet.custom.domain.SysCustomerHealthy; import org.apache.ibatis.annotations.Param; @@ -79,4 +80,12 @@ public interface SysCustomerHealthyMapper * @return */ int deleteCustomerHealthyByCustomerId(@Param("customerId")Long customerId); + + + /** + * 根据类型、键值集合查询字典类型 + * @param sysDictData + * @return + */ + public List selectDictDataByTypeAndValue(SysDictData sysDictData); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanMapper.java index 9cdcd751f..6c383c955 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanMapper.java @@ -3,6 +3,7 @@ package com.stdiet.custom.mapper; import java.util.List; import com.stdiet.custom.domain.SysRecipesPlan; import com.stdiet.custom.domain.SysRecipesPlanListInfo; +import org.apache.ibatis.annotations.Param; /** * 食谱计划Mapper接口 @@ -81,6 +82,13 @@ public interface SysRecipesPlanMapper */ List selectPlanListByCondition(SysRecipesPlan sysRecipesPlan); + /** + * 根据客户ID查询最后一天食谱计划 + * @param customerId + * @return + */ + SysRecipesPlan getLastDayRecipesPlan(@Param("customerId")Long customerId); + /** * 根据订单ID查询食谱计划 * @param sysRecipesPlan @@ -88,9 +96,18 @@ public interface SysRecipesPlanMapper */ List selectPlanListByOrderId(SysRecipesPlan sysRecipesPlan); - List selectPlanListByOutId(String outId); - Long getCusIdByOutId(String outId); List selectRecipesPlanListInfo(String outId); + + List selectPlanListByCusId(Long cusId); + + List selectRecipesModelList(SysRecipesPlan sysRecipesPlan); + + /** + * 批量更新食谱计划的开始时间、结束时间 + * @param list + * @return + */ + int updateMuchRecipesPlanDate(SysRecipesPlan sysRecipesPlan); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanModelMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanModelMapper.java new file mode 100644 index 000000000..12909be6c --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanModelMapper.java @@ -0,0 +1,24 @@ +package com.stdiet.custom.mapper; + +import com.stdiet.custom.domain.SysRecipesPlan; +import com.stdiet.custom.domain.SysRecipesPlanListInfo; +import com.stdiet.custom.domain.SysRecipesPlanModel; + +import java.util.List; + +/** + * 食谱计划Mapper接口 + * + * @author wonder + * @date 2021-02-27 + */ +public interface SysRecipesPlanModelMapper +{ + List selectRecipesModelListByCondition(SysRecipesPlanModel sysRecipesPlanModel); + + int insertRecipsesModel(SysRecipesPlanModel sysRecipesPlanModel); + + int updateRecipesModel(SysRecipesPlanModel sysRecipesPlanModel); + + int removeRecipesModel(Long id); +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCustomerHealthyService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCustomerHealthyService.java index 16ddda9cb..65ded44e9 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCustomerHealthyService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCustomerHealthyService.java @@ -3,7 +3,9 @@ package com.stdiet.custom.service; import java.util.List; import com.stdiet.common.core.domain.AjaxResult; +import com.stdiet.common.core.domain.entity.SysDictData; import com.stdiet.custom.domain.SysCustomerHealthy; +import com.stdiet.custom.dto.request.HealthyDetailRequest; import org.apache.ibatis.annotations.Param; /** @@ -78,4 +80,18 @@ public interface ISysCustomerHealthyService * @return */ int deleteCustomerHealthyByCustomerId(Long customerId); + + /** + * 生成健康评估报告 + * @return + */ + AjaxResult generateHealthyReport(HealthyDetailRequest healthyDetailRequest); + + + /** + * 根据类型、键值集合查询字典类型 + * @param sysDictData + * @return + */ + public List selectDictDataByTypeAndValue(SysDictData sysDictData); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanModelService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanModelService.java new file mode 100644 index 000000000..f227cc3ce --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanModelService.java @@ -0,0 +1,25 @@ +package com.stdiet.custom.service; + +import com.stdiet.custom.domain.SysRecipesPlan; +import com.stdiet.custom.domain.SysRecipesPlanListInfo; +import com.stdiet.custom.domain.SysRecipesPlanModel; + +import java.util.List; + +/** + * 食谱计划Service接口 + * + * @author wonder + * @date 2021-02-27 + */ +public interface ISysRecipesPlanModelService +{ + + List selectRecipesModelListByCondition(SysRecipesPlanModel sysRecipesPlanModel); + + int insertRecipsesModel(SysRecipesPlanModel sysRecipesPlanModel); + + int updateRecipesModel(SysRecipesPlanModel sysRecipesPlanModel); + + int removeRecipesModel(Long id); +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanService.java index 0f333c918..cffc8b111 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanService.java @@ -91,10 +91,33 @@ public interface ISysRecipesPlanService */ List selectPlanListByOrderId(SysRecipesPlan sysRecipesPlan); - List selectPlanListByOutId(String outId); + /** + * 通过outId查询cusId + * @param outId + * @return + */ Long getCusIdByOutId(String outId); + /** + * 根据客户ID查询最后一天食谱计划 + * @param customerId + * @return + */ + SysRecipesPlan getLastDayRecipesPlan(Long customerId); + + /** + * 通过outId查询食谱计划简要 + * @param outId + * @return + */ List selectRecipesPlanListInfo(String outId); + /** + * 通过客户id查询食谱计划 + * @param cusId + * @return + */ + List selectPlanListByCusId(Long cusId); + } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerHealthyServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerHealthyServiceImpl.java index a3f1ea3c0..05d21b6d5 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerHealthyServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerHealthyServiceImpl.java @@ -1,14 +1,22 @@ package com.stdiet.custom.service.impl; -import java.util.List; +import java.util.*; +import com.stdiet.common.config.RuoYiConfig; import com.stdiet.common.core.domain.AjaxResult; +import com.stdiet.common.core.domain.entity.SysDictData; +import com.stdiet.common.utils.DateUtils; import com.stdiet.common.utils.StringUtils; import com.stdiet.common.utils.bean.ObjectUtils; +import com.stdiet.common.utils.reflect.ReflectUtils; import com.stdiet.common.utils.sign.AesUtils; import com.stdiet.custom.domain.SysCustomer; import com.stdiet.custom.domain.SysCustomerPhysicalSigns; +import com.stdiet.custom.dto.request.HealthyDetailRequest; +import com.stdiet.custom.dto.response.NutritionalCalories; import com.stdiet.custom.service.ISysCustomerService; +import com.stdiet.custom.utils.NutritionalUtils; +import com.stdiet.custom.utils.PdfUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.stdiet.custom.mapper.SysCustomerHealthyMapper; @@ -141,4 +149,111 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService public int deleteCustomerHealthyByCustomerId(Long customerId){ return sysCustomerHealthyMapper.deleteCustomerHealthyByCustomerId(customerId); } + + /** + * 生成健康评估报告 + * @return + */ + @Override + public AjaxResult generateHealthyReport(HealthyDetailRequest healthyDetailRequest){ + AjaxResult ajaxResult = AjaxResult.error(); + String templatePath = "/home/workspace/ShengTangManage/running/pdf/healthyReport.pdf"; + //String templatePath = "D:\\contract\\healthyReport.pdf"; + String fileName = "healthyReport" + healthyDetailRequest.getCustomerId() + System.currentTimeMillis() + ".pdf"; + String filePath = RuoYiConfig.getDownloadPath() + fileName; + //查询客户健康信息 + SysCustomerHealthy sysCustomerHealthy = selectSysCustomerHealthyById(healthyDetailRequest.getId()); + if(sysCustomerHealthy != null){ + ajaxResult = PdfUtils.generatePdfFile(templatePath, filePath, getReportData(sysCustomerHealthy, healthyDetailRequest)); + ajaxResult.put("path", fileName); + } + return ajaxResult; + } + + public static final String[] healthyAttrNameAray = {"createTime","name","phone","conditioningProject","sex","age","tall","weight","position", + "experience","difficulty","rebound","crux","condiment","cookingStyle","cookingStyleRate","washVegetablesStyle", + "breakfastType","breakfastFood","lunchType","dinner","vegetableRate","commonMeat","dinnerTime","supperNum","supperFood", + "dietHotAndCold","dietFlavor","vegetablesNum","vegetablesRateType","fruitsNum","fruitsTime","fruitsRate","riceNum","riceFull", + "eatingSpeed","makeFoodType","snacks","healthProductsFlag","healthProductsBrand","healthProductsName", + "healthProductsWeekRate","dishesIngredient","waterNum","waterType","waterHabit", + "drinksNum","drinkWineFlag","drinkWineClassify","drinkWineAmount","smokeFlag","smokeRate", + "secondSmoke","workIndustry","workType","defecationNum","defecationTime","defecationShape", + "defecationSmell","defecationSpeed","defecationColor","motionNum","motionDuration","motionTime", + "motion","motionField","sleepTime","sleepQuality","sleepDrugFlag","sleepDrug","stayupLateFlag","stayupLateWeekNum", + "physicalSigns","moistureDate","bloodData","familyIllnessHistory","operationHistory","nearOperationFlag", + "recoveryeSituation","longEatDrugFlag","longEatDrugClassify","allergyFlag","allergySituation","allergen" + }; + + public static final String[] nutriAttrNameArray = {"standardWeight","overWeight","metabolizeHeat","activityFactor","withoutExerciseHeat", + "exerciseHeat","targetEveryWeightHeat","standardEveryWeightHeat","nutritionalHeat_one","nutritionalHeat_two","nutritionalHeat_three", + "nutritionalQuality_one","nutritionalQuality_two","nutritionalQuality_three", + "weightNutritionalRate_one","weightNutritionalRate_two","weightNutritionalRate_three" + }; + + private Map getReportData(SysCustomerHealthy sysCustomerHealthy, HealthyDetailRequest healthyDetailRequest){ + if(StringUtils.isNotEmpty(sysCustomerHealthy.getBloodData())){ + SysDictData param = new SysDictData(); + param.setDictType("sys_moisture_data"); + param.setDictValueList(Arrays.asList(sysCustomerHealthy.getBloodData().split(","))); + List bloodData = selectDictDataByTypeAndValue(param); + String bloodString = ""; + for (SysDictData blood : bloodData) { + bloodString += blood.getDictValue() + "、" +blood.getDictLabel() + "\n"; + } + healthyDetailRequest.setBloodData(bloodString); + } + if(StringUtils.isNotEmpty(sysCustomerHealthy.getMoistureDate())){ + SysDictData param = new SysDictData(); + param.setDictType("sys_blood_data"); + param.setDictValueList(Arrays.asList(sysCustomerHealthy.getBloodData().split(","))); + List moistureData = selectDictDataByTypeAndValue(param); + String moistureString = ""; + for (SysDictData moisture : moistureData) { + moistureString += moisture.getDictValue() + "、" + moisture.getDictLabel() + "\n"; + } + healthyDetailRequest.setMoistureDate(moistureString); + } + Map data = new HashMap<>(); + for (String key : healthyAttrNameAray) { + data.put(key, ReflectUtils.getFieldValueByFieldName(key, healthyDetailRequest)); + } + //减脂指导 + data.put("guidance", sysCustomerHealthy.getGuidance()); + //营养热量分析数据 + NutritionalCalories nutritionalCalories = NutritionalUtils.getNutritionalCaloriesData(sysCustomerHealthy); + nutritionalCalories.setNutritionalHeat_one(nutritionalCalories.getNutritionalHeat()[0].toString()); + nutritionalCalories.setNutritionalHeat_two(nutritionalCalories.getNutritionalHeat()[1].toString()); + nutritionalCalories.setNutritionalHeat_three(nutritionalCalories.getNutritionalHeat()[2].toString()); + nutritionalCalories.setNutritionalQuality_one(nutritionalCalories.getNutritionalQuality()[0].toString()); + nutritionalCalories.setNutritionalQuality_two(nutritionalCalories.getNutritionalQuality()[1].toString()); + nutritionalCalories.setNutritionalQuality_three(nutritionalCalories.getNutritionalQuality()[2].toString()); + nutritionalCalories.setWeightNutritionalRate_one(nutritionalCalories.getWeightNutritionalRate()[0].toString()); + nutritionalCalories.setWeightNutritionalRate_two(nutritionalCalories.getWeightNutritionalRate()[1].toString()); + nutritionalCalories.setWeightNutritionalRate_three(nutritionalCalories.getWeightNutritionalRate()[2].toString()); + for (String key : nutriAttrNameArray) { + if("targetEveryWeightHeat".equals(key)){ + data.put(key, nutritionalCalories.getTargetEveryWeightHeat()[0].intValue()+"-"+nutritionalCalories.getTargetEveryWeightHeat()[1].intValue()); + continue; + } + if("standardEveryWeightHeat".equals(key)){ + data.put(key, nutritionalCalories.getStandardEveryWeightHeat()[0].intValue()+"-"+nutritionalCalories.getStandardEveryWeightHeat()[1].intValue()); + continue; + } + data.put(key, ReflectUtils.getFieldValueByFieldName(key, nutritionalCalories)); + } + data.put("company","深圳胜唐体控有限公司"); + data.put("date", DateUtils.getDate()); + return data; + } + + + /** + * 根据类型、键值集合查询字典类型 + * @param sysDictData + * @return + */ + @Override + public List selectDictDataByTypeAndValue(SysDictData sysDictData){ + return sysCustomerHealthyMapper.selectDictDataByTypeAndValue(sysDictData); + } } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderServiceImpl.java index 70d942f57..c822e243c 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysOrderServiceImpl.java @@ -188,18 +188,27 @@ public class SysOrderServiceImpl implements ISysOrderService { sysOrder.setUpdateBy(SecurityUtils.getUsername()); sysOrder.setUpdateTime(DateUtils.getNowDate()); //体验单 - /*if("2".equals(sysOrder.getOrderType())){ - - }*/ - + if("2".equals(sysOrder.getOrderType())){ + sysOrder.setAfterSaleId(null); + sysOrder.setNutritionistId(null); + sysOrder.setNutriAssisId(null); + } + //提成单 + if(sysOrder.getAfterSaleCommissOrder().intValue() == 1){ + sysOrder.setAfterSaleId(null); + sysOrder.setNutritionistId(null); + sysOrder.setNutriAssisId(null); + sysOrder.setPlannerId(null); + sysOrder.setPlannerAssisId(null); + sysOrder.setOperatorId(null); + sysOrder.setOperatorAssisId(null); + } //更新订单 int row = sysOrderMapper.updateSysOrder(sysOrder); // 审核后的订单才生成食谱 - if (row > 0 && oldSysOrder.getReviewStatus().equals("no") && sysOrder.getReviewStatus().equals("yes")) { + if (row > 0 && isNeedRegenerateRecipesPlan(oldSysOrder, sysOrder)) { //异步更新食谱计划 - if (isNeedRegenerateRecipesPlan(oldSysOrder, sysOrder)) { - sysRecipesPlanService.regenerateRecipesPlan(sysOrder.getOrderId()); - } + sysRecipesPlanService.regenerateRecipesPlan(sysOrder.getOrderId()); } return row; } @@ -212,6 +221,9 @@ public class SysOrderServiceImpl implements ISysOrderService { * @return */ private boolean isNeedRegenerateRecipesPlan(SysOrder oldSysOrder, SysOrder newSysOrder) { + if(oldSysOrder.getReviewStatus().equals("no") && newSysOrder.getReviewStatus().equals("yes")){ + return true; + } if (oldSysOrder.getServeTimeId() != null && newSysOrder.getServeTimeId() != null && oldSysOrder.getServeTimeId().intValue() != newSysOrder.getServeTimeId().intValue()) { return true; } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanModelServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanModelServiceImpl.java new file mode 100644 index 000000000..f2e5876da --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanModelServiceImpl.java @@ -0,0 +1,67 @@ +package com.stdiet.custom.service.impl; + +import com.stdiet.common.utils.DateUtils; +import com.stdiet.common.utils.SecurityUtils; +import com.stdiet.custom.domain.SysRecipesPlan; +import com.stdiet.custom.domain.SysRecipesPlanModel; +import com.stdiet.custom.mapper.SysRecipesPlanMapper; +import com.stdiet.custom.mapper.SysRecipesPlanModelMapper; +import com.stdiet.custom.service.ISysRecipesPlanModelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + +/** + * 食谱计划Service业务层处理 + * + * @author wonder + * @date 2021-02-27 + */ +@Service("sysRecipesPlanModelService") +@Transactional +public class SysRecipesPlanModelServiceImpl implements ISysRecipesPlanModelService { + + @Autowired + SysRecipesPlanModelMapper sysRecipesPlanModelMapper; + + @Autowired + SysRecipesPlanMapper sysRecipesPlanMapper; + + @Override + public List selectRecipesModelListByCondition(SysRecipesPlanModel sysRecipesPlanModel) { + return sysRecipesPlanModelMapper.selectRecipesModelListByCondition(sysRecipesPlanModel); + } + + @Override + public int insertRecipsesModel(SysRecipesPlanModel sysRecipesPlanModel) { + SysRecipesPlan sysRecipesPlan = new SysRecipesPlan(); + sysRecipesPlan.setStartNumDay(1); + sysRecipesPlan.setEndNumDay(7); + sysRecipesPlan.setType(1); + int rows = sysRecipesPlanMapper.insertSysRecipesPlan(sysRecipesPlan); + if (rows > 0) { + sysRecipesPlanModel.setCreateBy(SecurityUtils.getUsername()); + sysRecipesPlanModel.setCreateTime(DateUtils.getNowDate()); + sysRecipesPlanModel.setPlanId(sysRecipesPlan.getId()); + return sysRecipesPlanModelMapper.insertRecipsesModel(sysRecipesPlanModel); + } + return 0; + } + + @Override + public int updateRecipesModel(SysRecipesPlanModel sysRecipesPlanModel) { + sysRecipesPlanModel.setUpdateBy(SecurityUtils.getUsername()); + sysRecipesPlanModel.setUpdateTime(DateUtils.getNowDate()); + return sysRecipesPlanModelMapper.updateRecipesModel(sysRecipesPlanModel); + } + + @Override + public int removeRecipesModel(Long id) { + return sysRecipesPlanModelMapper.removeRecipesModel(id); + } + + +} \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java index 49df25d1c..29ba4025d 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java @@ -2,6 +2,7 @@ package com.stdiet.custom.service.impl; import com.stdiet.common.utils.DateUtils; import com.stdiet.common.utils.SynchrolockUtil; +import com.stdiet.common.utils.sign.Md5Utils; import com.stdiet.custom.domain.SysOrder; import com.stdiet.custom.domain.SysOrderPause; import com.stdiet.custom.domain.SysRecipesPlan; @@ -30,6 +31,7 @@ import java.util.List; @Service("sysRecipesPlanService") @Transactional public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService { + public static final String generateRecipesPlanLockKey = "generateRecipesPlanLock::%s"; @Autowired private SysRecipesPlanMapper sysRecipesPlanMapper; @@ -121,45 +123,45 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService { @Override @Async public void regenerateRecipesPlan(Long orderId) { + try{ + Thread.sleep(5000); + }catch (Exception e){ + e.printStackTrace(); + } if (orderId == null || orderId <= 0) { return; } SysOrder sysOrder = sysOrderService.selectSysOrderById(orderId); - //订单为空、金额小于0不进行食谱生成、更新,只对2021年开始的订单进行食谱计划生成,判断订单金额、开始时间、结束时间,为空则直接返回,不重新生成食谱计划 - if (sysOrder == null && DateUtils.dateToLocalDate(sysOrder.getOrderTime()).getYear() < 2021 + //订单为空、金额小于0、订单未审核不进行食谱生成、更新,只对2021年开始的订单进行食谱计划生成,判断订单金额、开始时间、结束时间,为空则直接返回,不重新生成食谱计划 + if (sysOrder == null || !sysOrder.getReviewStatus().equals("yes") || DateUtils.dateToLocalDate(sysOrder.getOrderTime()).getYear() < 2021 || sysOrder.getAmount().floatValue() <= 0 || sysOrder.getStartTime() == null || sysOrder.getServerEndTime() == null) { return; } -// System.out.println(DateUtils.dateToLocalDate(sysOrder.getOrderTime()).getYear()); + //判断是否提成单,拆分单中的副单,体验单 + if(sysOrder.getAfterSaleCommissOrder().intValue() == 1 || ("1".equals(sysOrder.getOrderType()) && sysOrder.getMainOrderId().intValue() == 1) || + "2".equals(sysOrder.getOrderType())){ + System.out.println("---------------------不生成食谱------------------------"); + return; + } try { //获取redis中该订单对应的锁 if (synchrolockUtil.lock(String.format(generateRecipesPlanLockKey, orderId))) { + //判断是否已存在食谱计划 SysRecipesPlan queryParam = new SysRecipesPlan(); queryParam.setOrderId(orderId); List oldRecipesPlanList = sysRecipesPlanMapper.selectSysRecipesPlanList(queryParam); - //判断是否已存在食谱 - if (oldRecipesPlanList != null && oldRecipesPlanList.size() > 0) { - Long[] orderIdArray = new Long[1]; - orderIdArray[0] = orderId; - //删除该订单对于食谱 - delRecipesPlanByOrderId(orderIdArray); - } -// //判断订单金额、开始时间、结束时间,为空则直接返回,不重新生成食谱计划 -// if (sysOrder.getAmount().floatValue() <= 0 || sysOrder.getStartTime() == null || sysOrder.getServerEndTime() == null) { -// return; -// } SysOrderPause pauseParam = new SysOrderPause(); pauseParam.setOrderId(sysOrder.getOrderId()); //暂停记录列表 List pauseList = sysOrderPauseService.selectSysOrderPauseList(pauseParam); - List planList = generatePlan(sysOrder, oldRecipesPlanList, - DateUtils.dateToLocalDate(sysOrder.getStartTime()), DateUtils.dateToLocalDate(sysOrder.getServerEndTime()), pauseList); - if (planList != null && planList.size() > 0) { - sysRecipesPlanMapper.insertBatch(planList); + List planList = generatePlan(sysOrder, oldRecipesPlanList, DateUtils.dateToLocalDate(sysOrder.getStartTime()), DateUtils.dateToLocalDate(sysOrder.getServerEndTime()), pauseList); + if(oldRecipesPlanList != null && oldRecipesPlanList.size() > 0){ + updateOrAddRecipesPlan(oldRecipesPlanList, planList); + }else{ + if (planList != null && planList.size() > 0) { + sysRecipesPlanMapper.insertBatch(planList); + } } - /*for (SysRecipesPlan sysRecipesPlan : planList) { - getTestDate(sysRecipesPlan.getStartDate(), sysRecipesPlan.getEndDate()); - }*/ } } catch (Exception e) { e.printStackTrace(); @@ -169,26 +171,64 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService { } } - public void getTestDate(Date date, Date date2) { - LocalDate d = DateUtils.dateToLocalDate(date); - LocalDate d2 = DateUtils.dateToLocalDate(date2); - String s1 = d.getYear() + "-" + d.getMonthValue() + "-" + d.getDayOfMonth(); - String s2 = d2.getYear() + "-" + d2.getMonthValue() + "-" + d2.getDayOfMonth(); - System.out.println(s1 + " " + s2); + /** + * 更新食谱计划,删除旧食谱中多余的,添加新食谱中多的 + * @param oldRecipesPlanList + * @param newRecipesPlanList + */ + private void updateOrAddRecipesPlan(List oldRecipesPlanList, List newRecipesPlanList){ + int newSize = newRecipesPlanList.size(); + int index = 0; + List addList = new ArrayList<>(); + List updateList = new ArrayList<>(); + List delList = new ArrayList<>(); + for (SysRecipesPlan plan : oldRecipesPlanList) { + if(index < newSize){ + plan.setStartDate(newRecipesPlanList.get(index).getStartDate()); + plan.setEndDate(newRecipesPlanList.get(index).getEndDate()); + updateList.add(plan); + }else{ + delList.add(plan.getId()); + } + index++; + } + if(newSize > oldRecipesPlanList.size()){ + addList = newRecipesPlanList.subList(oldRecipesPlanList.size(),newSize); + } + //更新 + if(updateList.size() > 0){ + for (SysRecipesPlan plan : updateList) { + sysRecipesPlanMapper.updateSysRecipesPlan(plan); + } + } + //删除多余的食谱计划 + if(delList.size() > 0){ + sysRecipesPlanMapper.deleteSysRecipesPlanByIds(delList.toArray(new Long[delList.size()])); + } + //添加新的 + if(addList.size() > 0){ + sysRecipesPlanMapper.insertBatch(addList); + } } /** * 根据订单ID、订单开始服务时间、结束时间、暂停列表生成食谱计划列表 * * @param sysOrder 订单对象 - * @param oldRecipesPlanList 旧的食谱计划 * @param serverStartDate 服务开始时间 * @param serverEndDate 服务结束时间 * @param pauseList 暂停列表 * @return */ - public List generatePlan(SysOrder sysOrder, List oldRecipesPlanList, - LocalDate serverStartDate, LocalDate serverEndDate, List pauseList) { + private List generatePlan(SysOrder sysOrder, List oldRecipesPlanList, LocalDate serverStartDate, LocalDate serverEndDate, List pauseList) { + //查询该客户最后一次食谱计划对应天数 + int oldStartNumDay = 0; + if(oldRecipesPlanList.size() == 0){ + SysRecipesPlan lastSysRecipesPlan = getLastDayRecipesPlan(sysOrder.getCusId()); + oldStartNumDay = lastSysRecipesPlan == null || lastSysRecipesPlan.getEndNumDay() == null ? 0 : lastSysRecipesPlan.getEndNumDay().intValue(); + }else{ + oldStartNumDay = oldRecipesPlanList.get(0).getStartNumDay() - 1; + } List planList = new ArrayList<>(); boolean breakFlag = false; LocalDate planStartDate = serverStartDate; @@ -207,17 +247,11 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService { sysRecipesPlan.setEndDate(DateUtils.localDateToDate(planEndDate)); sysRecipesPlan.setOrderId(sysOrder.getOrderId()); sysRecipesPlan.setCusId(sysOrder.getCusId()); - /*//当开始时间小于等于当前时间,默认为已发送,发送时间为前一天 - if(ChronoUnit.DAYS.between(planStartDate, LocalDate.now()) >= 0){ - sysRecipesPlan.setSendFlag(1); - sysRecipesPlan.setSendTime(DateUtils.localDateToDate(LocalDate.now().minusDays(1))); - }*/ - //将旧食谱计划中的发送状态、发送时间、食谱复制到新食谱计划中 - boolean existFlag = oldRecipesPlanList.size() >= planList.size() + 1; - sysRecipesPlan.setSendFlag(existFlag ? oldRecipesPlanList.get(planList.size()).getSendFlag() : 0); - sysRecipesPlan.setSendTime(existFlag ? oldRecipesPlanList.get(planList.size()).getSendTime() : null); - sysRecipesPlan.setRecipesId(existFlag ? oldRecipesPlanList.get(planList.size()).getRecipesId() : null); - + sysRecipesPlan.setOutId(Md5Utils.hash(String.valueOf(sysOrder.getCusId()))); + oldStartNumDay += 1; + sysRecipesPlan.setStartNumDay(oldStartNumDay); + oldStartNumDay += 6; + sysRecipesPlan.setEndNumDay(oldStartNumDay); planList.add(sysRecipesPlan); planStartDate = planEndDate.plusDays(1); @@ -238,7 +272,7 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService { * @param pauseList 暂停列表 * @return */ - public long getPauseDayeCount(LocalDate planStartDate, LocalDate planEndDate, List pauseList) { + private long getPauseDayeCount(LocalDate planStartDate, LocalDate planEndDate, List pauseList) { long pauseDay = 0; //判断这个时间内是否存在暂停 if (pauseList != null && pauseList.size() > 0) { @@ -293,9 +327,13 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService { return sysRecipesPlanMapper.selectPlanListByOrderId(sysRecipesPlan); } - @Override - public List selectPlanListByOutId(String outId) { - return sysRecipesPlanMapper.selectPlanListByOutId(outId); + /** + * 根据客户ID查询最后一天食谱计划 + * @param customerId + * @return + */ + public SysRecipesPlan getLastDayRecipesPlan(Long customerId){ + return sysRecipesPlanMapper.getLastDayRecipesPlan(customerId); } @Override @@ -308,4 +346,13 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService { return sysRecipesPlanMapper.selectRecipesPlanListInfo(outId); } + @Override + public List selectPlanListByCusId(Long cusId) { + return sysRecipesPlanMapper.selectPlanListByCusId(cusId); + } + + public List selectRecipesModelList(SysRecipesPlan sysRecipesPlan) { + return sysRecipesPlanMapper.selectRecipesModelList(sysRecipesPlan); + } + } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesServiceImpl.java index 34e0ddb24..9c38d2f2a 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesServiceImpl.java @@ -54,6 +54,7 @@ public class SysRecipesServiceImpl implements ISysRecipesService { SysRecipesPlan sysRecipesPlan = new SysRecipesPlan(); sysRecipesPlan.setId(sysRecipes.getPlanId()); sysRecipesPlan.setRecipesId(sysRecipes.getId()); + sysRecipesPlan.setReviewStatus(1); sysRecipesPlanMapper.updateSysRecipesPlan(sysRecipesPlan); } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/utils/NutritionalUtils.java b/stdiet-custom/src/main/java/com/stdiet/custom/utils/NutritionalUtils.java index e1a89986b..b253bcf45 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/utils/NutritionalUtils.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/utils/NutritionalUtils.java @@ -32,6 +32,13 @@ public class NutritionalUtils { nutritionalCalories.setNutritionalHeat(nutritionalHeatAndQuality[0]); nutritionalCalories.setNutritionalQuality(nutritionalHeatAndQuality[1]); nutritionalCalories.setWeightNutritionalRate(HealthyUtils.calculateNutritionEveryWeight(nutritionalHeatAndQuality[1], nutritionalCalories.getWeight())); + //活动因子 + nutritionalCalories.setActivityFactor(HealthyUtils.activityFactor); + Long[] heatArray = HealthyUtils.calculateWithoutExerciseHeat(nutritionalCalories.getMetabolizeHeat()); + //不运动热量 + nutritionalCalories.setWithoutExerciseHeat(heatArray[0].intValue()); + //运动热量 + nutritionalCalories.setExerciseHeat(heatArray[1].intValue()); } return nutritionalCalories; } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/utils/PdfUtils.java b/stdiet-custom/src/main/java/com/stdiet/custom/utils/PdfUtils.java new file mode 100644 index 000000000..41c96e36a --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/utils/PdfUtils.java @@ -0,0 +1,70 @@ +package com.stdiet.custom.utils; + +import com.itextpdf.text.DocumentException; +import com.itextpdf.text.pdf.*; +import com.itextpdf.text.Document; +import com.stdiet.common.core.domain.AjaxResult; + +import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Map; + +public class PdfUtils { + + /** + * 生成PDF + * @param templatePath PDF模板文件路径 + * @param filePath 目标文件路径 + * @param data 数据 + * @return + */ + public static AjaxResult generatePdfFile(String templatePath, String filePath, Map data){ + AjaxResult ajaxResult = AjaxResult.success(); + + PdfReader reader; + FileOutputStream out; + ByteArrayOutputStream bos; + PdfStamper stamper; + + try { + out = new FileOutputStream(filePath);// 输出流到新的pdf,没有b2.pdf时会创建 + reader = new PdfReader(templatePath);// 读取pdf模板 + bos = new ByteArrayOutputStream(); + stamper = new PdfStamper(reader, bos); + AcroFields form = stamper.getAcroFields(); + + form.addSubstitutionFont(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED)); + for(String key : data.keySet()){ + form.setField(key, data.get(key), true); + } + stamper.setFormFlattening(true);// 如果为false那么生成的PDF文件还能编辑,一定要设为true + stamper.close(); + + Document doc = new Document(); + + PdfCopy copy = new PdfCopy(doc, out); + doc.open(); + PdfImportedPage importPage = null; + for (int i = 1; i <= reader.getNumberOfPages(); i++) { + importPage = copy + .getImportedPage(new PdfReader(bos.toByteArray()), i); + copy.addPage(importPage); + } + doc.close(); + + //Runtime.getRuntime().exec("chmod 644 " + filePath); + } catch (FileNotFoundException e) { + e.printStackTrace(); + ajaxResult = AjaxResult.error(); + } catch (IOException e) { + e.printStackTrace(); + ajaxResult = AjaxResult.error(); + } catch (DocumentException e) { + e.printStackTrace(); + ajaxResult = AjaxResult.error(); + } + return ajaxResult; + } +} diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerHealthyMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerHealthyMapper.xml index 7f32de28e..437aedd3f 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerHealthyMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerHealthyMapper.xml @@ -112,6 +112,7 @@ + @@ -123,7 +124,7 @@ select sch.id, customer_id, conditioning_project_id, sex, age, weight, tall, condiment, other_condiment, cooking_style, cooking_style_rate, wash_vegetables_style, other_wash_vegetables_style, breakfast_type, breakfast_food, lunch_type, dinner, vegetable_rate, common_meat, dinner_time, supper_num, supper_food, diet_hot_and_cold, diet_flavor, vegetables_num, vegetables_rate_type, fruits_num, fruits_time, fruits_rate, rice_num, rice_full, eating_speed, snacks, other_snacks, health_products_flag, health_products_brand, health_products_name, health_products_week_rate, health_products_day_rate, water_num, water_type, water_habit, drinks_num, drink_wine_flag, drink_wine_classify, other_wine_classify, drink_wine_amount, smoke_flag, smoke_rate, second_smoke, work_industry, work_type, defecation_num, other_defecation_num, defecation_time, defecation_shape, defecation_smell, defecation_speed, defecation_color, motion_num, motion_duration, motion_time, aerobic_motion_classify, anaerobic_motion_classify, anaerobic_aerobic_motion_classify, other_motion_classify, motion_field, other_motion_field, sleep_time, sleep_quality, sleep_drug_flag, sleep_drug, stayup_late_flag, stayup_late_week_num, family_illness_history, other_family_illness_history, operation_history, other_operation_history, near_operation_flag, recoverye_situation, long_eat_drug_flag, long_eat_drug_classify, other_long_eat_drug_classify, allergy_flag, allergy_situation, allergen, other_allergen, medical_report, medical_report_name, - position,experience,rebound,difficulty,crux,dishes_ingredient,make_food_type,physical_signs_id,other_physical_signs,blood_data,moisture_date,sch.remark, + position,experience,rebound,difficulty,crux,dishes_ingredient,make_food_type,physical_signs_id,other_physical_signs,blood_data,moisture_date,sch.remark,sch.guidance, sch.create_time, sch.create_by,sch. update_time, sch.update_by, sch.del_flag @@ -261,6 +262,7 @@ blood_data, moisture_date, remark, + guidance, create_time, create_by, update_time, @@ -369,6 +371,7 @@ #{bloodData}, #{moistureDate}, #{remark}, + #{guidance}, #{createTime}, #{createBy}, #{updateTime}, @@ -480,6 +483,7 @@ blood_data = #{bloodData}, moisture_date = #{moistureDate}, remark = #{remark}, + guidance = #{guidance}, create_time = #{createTime}, create_by = #{createBy}, update_time = #{updateTime}, @@ -517,4 +521,20 @@ update sys_customer_healthy set del_flag = 1 where customer_id = #{customerId} + + + + + + + + + + \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml index ce4ece5b7..49e4a3da7 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml @@ -5,52 +5,55 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - select id, order_id, cus_id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, send_time, create_time, create_by, update_time, update_by, del_flag, review_status from sys_recipes_plan + + + insert into sys_recipes_plan order_id, cus_id, + out_id, start_date, end_date, start_num_day, @@ -80,6 +90,7 @@ #{orderId}, #{cusId}, + #{outId}, #{startDate}, #{endDate}, #{startNumDay}, @@ -101,6 +112,7 @@ order_id = #{orderId}, cus_id = #{cusId}, + out_id = #{outId}, start_date = #{startDate}, end_date = #{endDate}, start_num_day = #{startNumDay}, @@ -132,39 +144,45 @@ INSERT INTO sys_recipes_plan - (order_id, cus_id, start_date, end_date, start_num_day, end_num_day, send_flag, send_time, recipes_id) + (order_id, cus_id, out_id, start_date, end_date, start_num_day, end_num_day, send_flag, send_time, recipes_id) VALUES - - (#{plan.orderId}, #{plan.cusId}, #{plan.startDate}, #{plan.endDate}, #{plan.startNumDay}, #{plan.endNumDay}, #{plan.sendFlag}, #{plan.sendTime}, #{plan.recipesId}) - + + (#{plan.orderId}, #{plan.cusId}, #{plan.outId}, #{plan.startDate}, #{plan.endDate}, #{plan.startNumDay}, #{plan.endNumDay}, + #{plan.sendFlag}, #{plan.sendTime}, #{plan.recipesId}) + - delete from sys_recipes_plan where order_id in - + delete from sys_recipes_plan where order_id in + #{orderId} - + - - + select id, out_id, start_date, end_date, start_num_day, end_num_day, recipes_id, review_status from sys_recipes_plan + where cus_id=#{cusId} order by create_time desc - - - - - + + + + + + @@ -224,4 +244,12 @@ + + +   + + update sys_recipes_plan set start_date = #{startDate},end_date = #{endDate} where id = #{id} + \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanModelMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanModelMapper.xml new file mode 100644 index 000000000..33f906e92 --- /dev/null +++ b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanModelMapper.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + insert into sys_recipes_plan_model + + nutri_assis_id, + nutritionist_id, + create_time, + create_by, + update_time, + update_by, + remark, + review_status, + + + #{nutriAssisId}, + #{nutritionistId}, + #{createTime}, + #{createBy}, + #{updateTime}, + #{updateBy}, + #{remark}, + #{reviewStatus}, + + + + + update sys_recipes_plan_model + + nutri_assis_id = #{nutriAssisId}, + nutritionist_id = #{nutritionistId}, + create_time = #{createTime}, + create_by = #{createBy}, + update_time = #{updateTime}, + update_by = #{updateBy}, + remark = #{remark}, + review_status = #{reviewStatus}, + + where id = #{id} + + + + update sys_recipes_plan_model set del_flag=1 where id = #{id} + + + \ No newline at end of file diff --git a/stdiet-ui/src/api/custom/healthy.js b/stdiet-ui/src/api/custom/healthy.js index 473401e9c..f4b718818 100644 --- a/stdiet-ui/src/api/custom/healthy.js +++ b/stdiet-ui/src/api/custom/healthy.js @@ -61,4 +61,14 @@ export function download(fileName) { }) } +// 生成健康体征报告 +export function generateHealthyReport(healthyDetail) { + return request({ + url: '/custom/healthy/generateHealthyReport', + method: 'post', + data: healthyDetail + }) +} + + diff --git a/stdiet-ui/src/api/custom/recipesPlan.js b/stdiet-ui/src/api/custom/recipesPlan.js index 5fe40ae7c..b58401ef8 100644 --- a/stdiet-ui/src/api/custom/recipesPlan.js +++ b/stdiet-ui/src/api/custom/recipesPlan.js @@ -1,36 +1,43 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询食谱计划列表 export function listRecipesPlan(query) { return request({ - url: '/recipes/recipesPlan/list', - method: 'get', + url: "/recipes/recipesPlan/list", + method: "get", params: query - }) + }); } // 查询食谱计划详细 export function getRecipesPlan(id) { return request({ - url: '/recipes/recipesPlan/' + id, - method: 'get' - }) + url: "/recipes/recipesPlan/" + id, + method: "get" + }); } // 修改食谱计划 export function updateRecipesPlan(data) { return request({ - url: '/recipes/recipesPlan', - method: 'put', + url: "/recipes/recipesPlan", + method: "put", data: data - }) + }); } // 导出食谱计划 export function exportRecipesPlan(query) { return request({ - url: '/recipes/recipesPlan/export', - method: 'get', + url: "/recipes/recipesPlan/export", + method: "get", params: query - }) + }); +} + +export function listRecipesPlanByCusId(id) { + return request({ + url: "/recipes/recipesPlan/list/" + id, + method: "get" + }); } diff --git a/stdiet-ui/src/api/custom/recipesPlanModel.js b/stdiet-ui/src/api/custom/recipesPlanModel.js new file mode 100644 index 000000000..dac431cb8 --- /dev/null +++ b/stdiet-ui/src/api/custom/recipesPlanModel.js @@ -0,0 +1,33 @@ +import request from "@/utils/request"; + +export function listRecipesModel(query) { + return request({ + url: "/recipes/model/list", + method: "get", + params: query + }); +} + +export function addRecipesModel(data){ + return request({ + url: "/recipes/model/add", + method: "post", + data: data + }); +} + +export function updateRecipesModel(data) { + return request({ + url: "/recipes/model/update", + method: "put", + data: data + }); +} + + +export function deleteRecipesModel(id) { + return request({ + url: "/recipes/model/delete/" + id, + method: "get" + }); +} diff --git a/stdiet-ui/src/components/PhysicalSignsDialog/index.vue b/stdiet-ui/src/components/PhysicalSignsDialog/index.vue index be164b16f..d7702d4dd 100644 --- a/stdiet-ui/src/components/PhysicalSignsDialog/index.vue +++ b/stdiet-ui/src/components/PhysicalSignsDialog/index.vue @@ -3,6 +3,8 @@
+ 下载报告 + 减脂指导 修改备注 修改信息 删除信息 @@ -24,6 +26,15 @@ + + + + + + + +
@@ -71,23 +82,28 @@ + + diff --git a/stdiet-ui/src/components/PhysicalSignsGuidance/index.vue b/stdiet-ui/src/components/PhysicalSignsGuidance/index.vue new file mode 100644 index 000000000..fc3356095 --- /dev/null +++ b/stdiet-ui/src/components/PhysicalSignsGuidance/index.vue @@ -0,0 +1,88 @@ + + + + diff --git a/stdiet-ui/src/components/RecipesPlanDrawer/index.vue b/stdiet-ui/src/components/RecipesPlanDrawer/index.vue index dbecf5cbb..5ef6b8b44 100644 --- a/stdiet-ui/src/components/RecipesPlanDrawer/index.vue +++ b/stdiet-ui/src/components/RecipesPlanDrawer/index.vue @@ -6,19 +6,60 @@ @closed="handleOnClosed" size="40%" > -
+
客户食谱链接 + + + 查看暂停记录 + + + + + + + + + + + + + + + + 查看暂停记录 + >增加暂停记录 @@ -44,6 +85,8 @@ @@ -78,4 +155,8 @@ export default { /deep/ :focus { outline: 0; } + +.recipes_plan_drawer_wrapper { + height: calc(100vh - 77px); +} diff --git a/stdiet-ui/src/router/index.js b/stdiet-ui/src/router/index.js index 3437271be..04ff11715 100644 --- a/stdiet-ui/src/router/index.js +++ b/stdiet-ui/src/router/index.js @@ -140,9 +140,10 @@ export const constantRoutes = [ ] }, { - path: "/recipes/build", + path: "/recipes/build/:name/:planId", component: resolve => require(["@/views/custom/recipesBuild"], resolve), name: "RecipiesBuild", + props: true, meta: { title: "食谱制作" }, hidden: true }, diff --git a/stdiet-ui/src/store/modules/recipes.js b/stdiet-ui/src/store/modules/recipes.js index f8804023e..84ff42331 100644 --- a/stdiet-ui/src/store/modules/recipes.js +++ b/stdiet-ui/src/store/modules/recipes.js @@ -7,6 +7,7 @@ import { deleteDishesApi, addRecipesApi } from "@/api/custom/recipes"; +import { getRecipesPlan, updateRecipesPlan } from "@/api/custom/recipesPlan"; import { getDicts } from "@/api/system/dict/data"; const oriState = { @@ -23,7 +24,8 @@ const oriState = { typeOptions: [], currentDay: -1, startNum: 0, - endNum: 0 + endNum: 0, + reviewStatus: 0 }; const mutations = { @@ -72,32 +74,55 @@ const mutations = { const actions = { async init({ commit, dispatch }, payload) { - return new Promise((res, rej) => { - // console.log(payload); - // - commit("updateStateData", payload); - // - getDicts("cus_cus_unit").then(response => { - commit("updateStateData", { cusUnitOptions: response.data }); - }); - getDicts("cus_cus_weight").then(response => { - commit("updateStateData", { cusWeightOptions: response.data }); - }); - getDicts("cus_dishes_type").then(response => { - commit("updateStateData", { typeOptions: response.data }); - }); + // console.log(payload); + const planResponse = await getRecipesPlan(payload.planId); + const { + startNumDay, + endNumDay, + recipesId, + cusId, + reviewStatus + } = planResponse.data; + commit("updateStateData", { + cusId, + recipesId, + reviewStatus, + planId: payload.planId, + startNum: startNumDay, + endNum: endNumDay + }); + getDicts("cus_cus_unit").then(response => { + commit("updateStateData", { cusUnitOptions: response.data }); + }); + getDicts("cus_cus_weight").then(response => { + commit("updateStateData", { cusWeightOptions: response.data }); + }); + getDicts("cus_dishes_type").then(response => { + commit("updateStateData", { typeOptions: response.data }); + }); + + return new Promise((res, rej) => { // 健康数据 - if (payload.cusId) { - dispatch("getHealthyData", payload).catch(err => rej(err)); + if (cusId) { + dispatch("getHealthyData", { cusId }).catch(err => rej(err)); } // 食谱数据 - if (payload.recipesId) { - dispatch("getRecipesInfo", payload).catch(err => rej(err)); + if (recipesId) { + dispatch("getRecipesInfo", { recipesId }).catch(err => rej(err)); } }); }, + async updateReviewStatus({ commit, state }, payload) { + const response = await updateRecipesPlan({ + id: state.planId, + reviewStatus: payload.reviewStatus + }); + if (response.code === 200) { + commit("updateStateData", payload); + } + }, async getHealthyData({ commit }, payload) { commit("updateStateData", { healthDataLoading: true }); const healthyDataResult = await getCustomerPhysicalSignsByCusId( @@ -127,16 +152,14 @@ const actions = { const recipesDataResult = await getRecipesApi(payload.recipesId); let recipesData = []; if (recipesDataResult.code === 200) { - const { endNum, startNum } = state; - let length = null; - if (endNum && startNum) { - length = endNum - startNum; - } + const { endNum, startNum, recipesId } = state; + // 计算 + let length = endNum - startNum; recipesData = recipesDataResult.data.reduce((outArr, dayData, idx) => { - if (!length || (length && length >= idx)) { + if (!recipesId || length >= idx) { outArr.push({ id: dayData.id, - numDay: startNum ? startNum + idx : dayData.numDay, + numDay: !recipesId ? startNum + idx : dayData.numDay, dishes: dayData.dishes.reduce((arr, cur) => { if ( cur.dishesId > -1 && diff --git a/stdiet-ui/src/utils/request.js b/stdiet-ui/src/utils/request.js index f6261ff03..90df1b246 100644 --- a/stdiet-ui/src/utils/request.js +++ b/stdiet-ui/src/utils/request.js @@ -29,7 +29,6 @@ service.interceptors.request.use(config => { service.interceptors.response.use(res => { // 未设置状态码则默认成功状态 const code = res.data.code || 200; - console.log(res) // 获取错误信息 const msg = errorCode[code] || res.data.msg || errorCode['default'] if (code === 401) { diff --git a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesAspectCom/index.vue b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesAspectCom/index.vue index a74c628b6..26f66188a 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesAspectCom/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesAspectCom/index.vue @@ -4,6 +4,31 @@ :style="`height: ${collapse ? 30 : 200}px`" >
+ +
+ 审核通过 + 未审核通过 +
+ + {{ reviewStatus === 1 ? "未审核" : "已审核" }} + +
生成食谱 - {{ - `${collapse ? "展开分析" : "收起分析"}` - }} + + {{ `${collapse ? "展开" : "收起"}` }} + +
@@ -79,6 +113,11 @@ export default { .header { text-align: right; height: 30px; + + .arrow_icon { + transition: all 0.3s; + transform-origin: center center; + } } .content { diff --git a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/index.vue b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/index.vue index 79e5821ad..8c9c0264c 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/index.vue @@ -12,7 +12,7 @@ diff --git a/stdiet-ui/src/views/custom/recipesBuild/index.vue b/stdiet-ui/src/views/custom/recipesBuild/index.vue index 9a557b1e3..c8bdba22b 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/index.vue @@ -1,5 +1,5 @@ @@ -219,121 +182,11 @@ :limit.sync="queryParams.pageSize" @pagination="getList" /> - - - - - - - - - - - - - - - - - - - - - - - - - - 搜索 - - - - - - - - - - - - - - - - - - - - - - - -