Merge branch 'xzj' of gitee.com:darlk/ShengTangManage into develop
This commit is contained in:
		| @@ -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> | ||||
		Reference in New Issue
	
	Block a user