Merge branch 'xzj' of gitee.com:darlk/ShengTangManage into develop

This commit is contained in:
huangdeliang 2021-02-27 20:17:36 +08:00
commit 2d2e68ae10
22 changed files with 1019 additions and 67 deletions
running/pdf
stdiet-admin/src/main/java/com/stdiet/web/controller/custom
stdiet-common/src/main/java/com/stdiet/common
stdiet-custom/src/main
stdiet-ui/src
api/custom
components
PhysicalSignsDialog
PhysicalSignsGuidance

Binary file not shown.

@ -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);
}
}

@ -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<String> dictValueList;
/** 字典类型 */
@Excel(name = "字典类型")
private String dictType;
/** 样式属性(其他样式扩展) */
@ -153,7 +157,15 @@ public class SysDictData extends BaseEntity
{
this.status = status;
}
public List<String> getDictValueList() {
return dictValueList;
}
public void setDictValueList(List<String> dictValueList) {
this.dictValueList = dictValueList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -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;
}
}

@ -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 "";
}
}
}

@ -433,6 +433,9 @@ public class SysCustomerHealthy extends BaseEntity
//备注
private String remark;
/** 减脂指导 */
private String guidance;
/** 湿气数据 */
@Excel(name = "湿气数据")
private String moistureDate;

@ -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;
}

@ -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;
}

@ -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<SysDictData> selectDictDataByTypeAndValue(SysDictData sysDictData);
}

@ -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<SysRecipesPlan> selectPlanListByCondition(SysRecipesPlan sysRecipesPlan);
/**
* 根据客户ID查询最后一天食谱计划
* @param customerId
* @return
*/
SysRecipesPlan getLastDayRecipesPlan(@Param("customerId")Long customerId);
/**
* 根据订单ID查询食谱计划
* @param sysRecipesPlan
@ -93,6 +101,13 @@ public interface SysRecipesPlanMapper
List<SysRecipesPlanListInfo> selectRecipesPlanListInfo(String outId);
List<SysRecipesPlan> selectPlanListByCusId(Long cusId);
List<SysRecipesPlan> selectRecipesModelList(SysRecipesPlan sysRecipesPlan);
/**
* 批量更新食谱计划的开始时间结束时间
* @param list
* @return
*/
int updateMuchRecipesPlanDate(SysRecipesPlan sysRecipesPlan);
}

@ -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<SysDictData> selectDictDataByTypeAndValue(SysDictData sysDictData);
}

@ -99,6 +99,13 @@ public interface ISysRecipesPlanService
*/
Long getCusIdByOutId(String outId);
/**
* 根据客户ID查询最后一天食谱计划
* @param customerId
* @return
*/
SysRecipesPlan getLastDayRecipesPlan(Long customerId);
/**
* 通过outId查询食谱计划简要
* @param outId

@ -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<String,String> 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<SysDictData> 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<SysDictData> moistureData = selectDictDataByTypeAndValue(param);
String moistureString = "";
for (SysDictData moisture : moistureData) {
moistureString += moisture.getDictValue() + "" + moisture.getDictLabel() + "\n";
}
healthyDetailRequest.setMoistureDate(moistureString);
}
Map<String,String> 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<SysDictData> selectDictDataByTypeAndValue(SysDictData sysDictData){
return sysCustomerHealthyMapper.selectDictDataByTypeAndValue(sysDictData);
}
}

@ -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;
}

@ -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<SysRecipesPlan> 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<SysOrderPause> pauseList = sysOrderPauseService.selectSysOrderPauseList(pauseParam);
List<SysRecipesPlan> planList = generatePlan(sysOrder, oldRecipesPlanList,
DateUtils.dateToLocalDate(sysOrder.getStartTime()), DateUtils.dateToLocalDate(sysOrder.getServerEndTime()), pauseList);
if (planList != null && planList.size() > 0) {
sysRecipesPlanMapper.insertBatch(planList);
List<SysRecipesPlan> 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<SysRecipesPlan> oldRecipesPlanList, List<SysRecipesPlan> newRecipesPlanList){
int newSize = newRecipesPlanList.size();
int index = 0;
List<SysRecipesPlan> addList = new ArrayList<>();
List<SysRecipesPlan> updateList = new ArrayList<>();
List<Long> 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<SysRecipesPlan> generatePlan(SysOrder sysOrder, List<SysRecipesPlan> oldRecipesPlanList,
LocalDate serverStartDate, LocalDate serverEndDate, List<SysOrderPause> pauseList) {
private List<SysRecipesPlan> generatePlan(SysOrder sysOrder, List<SysRecipesPlan> oldRecipesPlanList, LocalDate serverStartDate, LocalDate serverEndDate, List<SysOrderPause> 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<SysRecipesPlan> 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<SysOrderPause> pauseList) {
private long getPauseDayeCount(LocalDate planStartDate, LocalDate planEndDate, List<SysOrderPause> pauseList) {
long pauseDay = 0;
//判断这个时间内是否存在暂停
if (pauseList != null && pauseList.size() > 0) {
@ -293,6 +327,15 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
return sysRecipesPlanMapper.selectPlanListByOrderId(sysRecipesPlan);
}
/**
* 根据客户ID查询最后一天食谱计划
* @param customerId
* @return
*/
public SysRecipesPlan getLastDayRecipesPlan(Long customerId){
return sysRecipesPlanMapper.getLastDayRecipesPlan(customerId);
}
@Override
public Long getCusIdByOutId(String outId) {
return sysRecipesPlanMapper.getCusIdByOutId(outId);

@ -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;
}

@ -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<String,String> 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;
}
}

@ -112,6 +112,7 @@
<result property="bloodData" column="blood_data" />
<result property="moistureDate" column="moisture_date" />
<result property="remark" column="remark"></result>
<result property="guidance" column="guidance" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
@ -123,7 +124,7 @@
<sql id="selectSysCustomerHealthyVo">
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
</sql>
@ -261,6 +262,7 @@
<if test="bloodData != null">blood_data,</if>
<if test="moistureDate != null">moisture_date,</if>
<if test="remark != null">remark,</if>
<if test="guidance != null">guidance,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
@ -369,6 +371,7 @@
<if test="bloodData != null">#{bloodData},</if>
<if test="moistureDate != null">#{moistureDate},</if>
<if test="remark != null">#{remark},</if>
<if test="guidance != null">#{guidance},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
@ -480,6 +483,7 @@
<if test="bloodData != null">blood_data = #{bloodData},</if>
<if test="moistureDate != null">moisture_date = #{moistureDate},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="guidance != null">guidance = #{guidance},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
@ -517,4 +521,20 @@
update sys_customer_healthy set del_flag = 1 where customer_id = #{customerId}
</update>
<resultMap type="SysDictData" id="SysDictDataResult">
<id property="dictCode" column="dict_code" />
<result property="dictSort" column="dict_sort" />
<result property="dictLabel" column="dict_label" />
<result property="dictValue" column="dict_value" />
<result property="dictType" column="dict_type" />
</resultMap>
<select id="selectDictDataByTypeAndValue" parameterType="SysDictData" resultMap="SysDictDataResult">
select dict_code, dict_sort, dict_label, dict_value, dict_type from sys_dict_data
where status = '0' and dict_type = #{dictType}
and dict_value in <foreach collection="dictValueList" item="item" index="index"
open="(" separator="," close=")">#{item}</foreach>
order by dict_sort asc
</select>
</mapper>

@ -52,6 +52,8 @@
<if test="sendFlag != null ">and send_flag = #{sendFlag}</if>
<if test="sendTime != null ">and send_time = #{sendTime}</if>
<if test="reviewStatus != null ">and review_status = #{reviewStatus}</if>
<!-- 请勿轻易修改排序方式,会影响食谱生成等逻辑 -->
order by id ASC
</select>
<select id="selectSysRecipesPlanById" parameterType="Long" resultMap="SysRecipesPlanResult">
@ -59,11 +61,18 @@
where id = #{id} and del_flag = 0
</select>
<!-- 根据用户ID查询是否存在该用户最后一天食谱 -->
<select id="getLastDayRecipesPlan" resultMap="SysRecipesPlanResult" parameterType="Long">
<include refid="selectSysRecipesPlanVo"/>
where cus_id = #{customerId} and del_flag = 0 order by end_num_day DESC limit 1
</select>
<insert id="insertSysRecipesPlan" parameterType="SysRecipesPlan" useGeneratedKeys="true" keyProperty="id">
insert into sys_recipes_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null">order_id,</if>
<if test="cusId != null">cus_id,</if>
<if test="outId != null">out_id,</if>
<if test="startDate != null">start_date,</if>
<if test="endDate != null">end_date,</if>
<if test="startNumDay != null">start_num_day,</if>
@ -81,6 +90,7 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if>
<if test="cusId != null">#{cusId},</if>
<if test="outId != null">#{outId},</if>
<if test="startDate != null">#{startDate},</if>
<if test="endDate != null">#{endDate},</if>
<if test="startNumDay != null">#{startNumDay},</if>
@ -102,6 +112,7 @@
<trim prefix="SET" suffixOverrides=",">
<if test="orderId != null">order_id = #{orderId},</if>
<if test="cusId != null">cus_id = #{cusId},</if>
<if test="outId != null">out_id = #{outId},</if>
<if test="startDate != null">start_date = #{startDate},</if>
<if test="endDate != null">end_date = #{endDate},</if>
<if test="startNumDay != null">start_num_day = #{startNumDay},</if>
@ -133,10 +144,10 @@
<!-- 批量插入食谱计划 -->
<insert id="insertBatch">
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
<foreach collection="list" item="plan" separator=",">
(#{plan.orderId}, #{plan.cusId}, #{plan.startDate}, #{plan.endDate}, #{plan.startNumDay}, #{plan.endNumDay},
(#{plan.orderId}, #{plan.cusId}, #{plan.outId}, #{plan.startDate}, #{plan.endDate}, #{plan.startNumDay}, #{plan.endNumDay},
#{plan.sendFlag}, #{plan.sendTime}, #{plan.recipesId})
</foreach>
</insert>
@ -234,4 +245,11 @@
select id, num_day from sys_customer_daily_menu where recipes_id=#{recipes_id} order by num_day asc
</select>
<!-- 批量修改食谱计划 -->
<update id="updateMuchRecipesPlanDate" parameterType="SysRecipesPlan"> 
<!--<foreach collection="list" item="item" separator=";" open="" close="">
</foreach>-->
update sys_recipes_plan set start_date = #{startDate},end_date = #{endDate} where id = #{id}
</update>
</mapper>

@ -61,4 +61,14 @@ export function download(fileName) {
})
}
// 生成健康体征报告
export function generateHealthyReport(healthyDetail) {
return request({
url: '/custom/healthy/generateHealthyReport',
method: 'post',
data: healthyDetail
})
}

@ -3,6 +3,8 @@
<div v-if="showFlag">
<div style="float:right;margin-top:-10px;margin-bottom: 10px;" v-show="dataList.length > 0">
<!-- 只有新版健康评估信息才可修改旧的体征数据不支持修改 -->
<el-button type="info" v-show="dataType == 0" @click="generateReport()" plain>下载报告</el-button>
<el-button type="info" v-show="dataType == 0" @click="handleEditGuidanceClick()" plain>减脂指导</el-button>
<el-button v-hasPermi="['custom:healthy:edit']" type="info" v-show="dataType == 0" @click="handleEditRemarkClick()" plain>修改备注</el-button>
<el-button v-hasPermi="['custom:healthy:edit']" type="warning" v-show="dataType == 0" @click="handleEditHealthyClick()" plain>修改信息</el-button>
<el-button type="danger" v-hasPermi="['custom:healthy:remove']" @click="handleDelete()" plain>删除信息</el-button>
@ -24,6 +26,15 @@
<auto-hide-message :data="scope.row.remarkValue" :maxLength="100"/></template>
</el-table-column>
</el-table>
<!-- 指导 -->
<el-table :data="guidanceList" :show-header="false" border :cell-style="remarkColumnStyle" style="width: 100%;">
<el-table-column width="140" prop="guidanceTitle">
</el-table-column>
<el-table-column prop="guidanceValue">
<template slot-scope="scope">
<auto-hide-message :data="scope.row.guidanceValue" :maxLength="100"/></template>
</el-table-column>
</el-table>
</div>
<!-- 其他信息 -->
<div style="height:400px;overflow: auto">
@ -71,23 +82,28 @@
<physicalSigns-edit ref="physicalSignsEditDialog" @refreshHealthyData="getCustomerHealthyByCusId()"></physicalSigns-edit>
<!-- 编辑备注 -->
<physicalSigns-remark ref="physicalSignsRemarkDialog" @refreshHealthyData="getCustomerHealthyByCusId()"></physicalSigns-remark>
<!-- 编辑减脂指导 -->
<physicalSigns-guidance ref="physicalSignsGuidanceDialog" @refreshHealthyData="getCustomerHealthyByCusId()"></physicalSigns-guidance>
</el-dialog>
</template>
<script>
import { getCustomerPhysicalSignsByCusId,delCustomerHealthy } from "@/api/custom/customer";
import { generateHealthyReport } from "@/api/custom/healthy";
import TableDetailMessage from "@/components/TableDetailMessage";
import AutoHideMessage from "@/components/AutoHideMessage";
import * as healthyData from "@/utils/healthyData";
import Clipboard from 'clipboard';
import PhysicalSignsEdit from "@/components/PhysicalSignsEdit";
import PhysicalSignsRemark from "@/components/PhysicalSignsRemark";
import PhysicalSignsGuidance from "@/components/PhysicalSignsGuidance";
export default {
name: "PhysicalSignsDialog",
components: {
"auto-hide-message": AutoHideMessage,
"table-detail-message": TableDetailMessage,
"physicalSigns-edit":PhysicalSignsEdit,
"physicalSigns-remark":PhysicalSignsRemark
"physicalSigns-remark":PhysicalSignsRemark,
"physicalSigns-guidance":PhysicalSignsGuidance
},
data() {
return {
@ -99,6 +115,7 @@ export default {
dataType: 0,
healthyData: null,
remarkList:[{"remarkTitle": "备注信息", "remarkValue": ""}],
guidanceList:[{"guidanceTitle": "减脂指导", "guidanceValue": ""}],
//
signTitleData: [
["创建时间", "姓名", "年龄"],
@ -203,7 +220,8 @@ export default {
["medicalReport_one","medicalReport_two","medicalReport_three"]
]
],
copyValue: ""
copyValue: "",
detailHealthy: null,
};
},
methods: {
@ -239,6 +257,7 @@ export default {
if(this.dataType == 0){
this.healthyData = Object.assign({}, res.data.customerHealthy);
this.remarkList[0].remarkValue = this.healthyData.remark;
this.guidanceList[0].guidanceValue = this.healthyData.guidance;
this.getDataListByHealthyMessage(res.data.customerHealthy);
}else{
this.getDataListBySignMessage(res.data.customerHealthy)
@ -252,6 +271,7 @@ export default {
onClosed() {
this.dataList = [];
this.data = null;
this.detailHealthy = null;
//this.enc_id = "";
this.copyValue = "";
},
@ -358,7 +378,7 @@ export default {
});
}
detailHealthy.motion = this.trimComma(motionStr + (detailHealthy.otherMotionClassify ? ( ""+ detailHealthy.otherMotionClassify) : ""));
detailHealthy.motionField += this.trimComma(detailHealthy.otherMotionField ? (""+detailHealthy.otherMotionField) : "");
detailHealthy.motionField = this.trimComma(detailHealthy.motionField + (detailHealthy.otherMotionField ? (""+detailHealthy.otherMotionField) : ""));
detailHealthy.sleepDrugFlag = detailHealthy.sleepDrugFlag == 1 ? "有" : "无";
detailHealthy.stayupLateFlag = detailHealthy.stayupLateFlag == 1 ? "有" : "无";
detailHealthy.stayupLateWeekNum += "次/周";
@ -370,20 +390,20 @@ export default {
}*/
physicalSigns += "" + (detailHealthy.otherPhysicalSigns ? detailHealthy.otherPhysicalSigns : "");
detailHealthy.physicalSigns = this.trimComma(physicalSigns);
detailHealthy.familyIllnessHistory += this.trimComma(detailHealthy.otherFamilyIllnessHistory ? ("" + detailHealthy.otherFamilyIllnessHistory) : "");
detailHealthy.operationHistory += this.trimComma(detailHealthy.otherOperationHistory ? ("" + detailHealthy.otherOperationHistory) : "");
detailHealthy.familyIllnessHistory = this.trimComma(detailHealthy.familyIllnessHistory + ""+ (detailHealthy.otherFamilyIllnessHistory ? detailHealthy.otherFamilyIllnessHistory : ""));
detailHealthy.operationHistory = this.trimComma(detailHealthy.operationHistory + ""+ (detailHealthy.otherOperationHistory ? detailHealthy.otherOperationHistory : ""));
detailHealthy.nearOperationFlag = detailHealthy.nearOperationFlag == 1 ? "有" : "无";
detailHealthy.longEatDrugFlag = detailHealthy.longEatDrugFlag == 1 ? "有" : "无";
detailHealthy.longEatDrugClassify += detailHealthy.otherLongEatDrugClassify ? ("" + detailHealthy.otherLongEatDrugClassify) : "";
detailHealthy.longEatDrugClassify = this.trimComma(detailHealthy.longEatDrugClassify + "" + (detailHealthy.otherLongEatDrugClassify ? detailHealthy.otherLongEatDrugClassify : ""));
detailHealthy.allergyFlag = detailHealthy.allergyFlag == 1 ? "有" : "无";
detailHealthy.allergen += detailHealthy.otherAllergen ? ("" +detailHealthy.otherAllergen) : "";
detailHealthy.allergen = this.trimComma(detailHealthy.allergen);
detailHealthy.allergen = this.trimComma(detailHealthy.allergen + "" + (detailHealthy.otherAllergen ? detailHealthy.otherAllergen : ""));
let medicalReportPathArray = detailHealthy.medicalReport ? detailHealthy.medicalReport.split(",") : [];
let medicalReportNameArray = detailHealthy.medicalReportName ? detailHealthy.medicalReportName.split(",") : [];
this.medicalReportPathArray = medicalReportPathArray;
detailHealthy.medicalReport_one = medicalReportPathArray.length > 0 ? (medicalReportNameArray.length > 0 ? medicalReportNameArray[0] : "体检报告1") : "";
detailHealthy.medicalReport_two = medicalReportPathArray.length > 1 ? (medicalReportNameArray.length > 1 ? medicalReportNameArray[1] : "体检报告2") : "";
detailHealthy.medicalReport_three = medicalReportPathArray.length > 2 ? (medicalReportNameArray.length > 2 ? medicalReportNameArray[2] : "体检报告3") : "";
this.detailHealthy = detailHealthy;
for(let i = 0; i < this.healthyTitleData.length; i++){
let stepArray = [];
for(let j= 0; j < this.healthyTitleData[i].length; j++){
@ -426,6 +446,28 @@ export default {
downloadFile(fileName){
this.downloadResource(fileName);
},
generateReport(){
let data = this.detailHealthy;
if(!this.guidanceList[0].guidanceValue || this.guidanceList[0].guidanceValue.length == 0){
this.$confirm("该客户还未添加减脂指导,是否确认下载报告?", "警告", {
confirmButtonText: "确定", cancelButtonText: "取消", type: "warning"
})
.then(function(){
return generateHealthyReport(data);
})
.then((response) => {
if(response.code == 200 && response.path != null){
this.download(response.path);
}
}).catch(function () {});
}else{
generateHealthyReport(data).then((res) => {
if(res.code == 200 && res.path != null){
this.download(res.path);
}
});
}
},
trimComma(str){
if(str.startsWith("") || str.startsWith(",")){
str = str.substring(1,str.length);
@ -467,7 +509,11 @@ export default {
},
handleEditRemarkClick(){
this.$refs["physicalSignsRemarkDialog"].showDialog(this.data, this.healthyData);
},
handleEditGuidanceClick(){
this.$refs["physicalSignsGuidanceDialog"].showDialog(this.data, this.healthyData);
}
}
};
</script>

@ -0,0 +1,88 @@
<template>
<el-dialog :visible.sync="visible" :title="title" width="500px" append-to-body @closed="onClosed">
<el-form ref="form" :model="form" :rules="rules" label-position="top" label-width="100px">
<el-form-item label="" prop="guidance" >
<el-input
type="textarea"
:rows="8"
maxlength="300"
show-word-limit
placeholder="请输入减脂指导"
v-model="form.guidance">
</el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()"> </el-button>
<el-button @click="onClosed()"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer";
import { updateHealthy } from "@/api/custom/healthy";
export default {
name: "PhysicalSignsGuidance",
components: {
},
data() {
return {
visible: false,
title: "",
data: undefined,
form: {
id: null,
guidance: null
},
rules: {
}
};
},
methods: {
showDialog(data, healthy) {
this.data = data;
this.title = "修改"+`${data.name}`+"减脂指导";
this.form.id = healthy.id;
this.form.guidance = healthy.guidance;
this.visible = true;
},
onClosed() {
this.visible = false;
this.data = null;
},
submit(){
this.$refs.form.validate((valid) => {
if (valid) {
this.editCustomerHealthy();
} else {
this.$message({message: "数据未填写完整", type: "warning"});
}
});
},
editCustomerHealthy(){
updateHealthy(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.onClosed();
this.$emit('refreshHealthyData');
}
}).catch(function() {
console.log("error");
});
}
}
};
</script>
<style scoped>
.margin-top-20{
margin-top:20px;
}
.p_title_1{
font-size: 18px;
font-weight: bold;
margin-top: 20px;
}
</style>