健康体征报告
This commit is contained in:
		| @@ -0,0 +1,390 @@ | ||||
| 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 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; | ||||
|  | ||||
|     /** 客户病史体征id,使用,隔开 */ | ||||
|     private String physicalSignsId; | ||||
|  | ||||
|     /** 其他病史体征 **/ | ||||
|     private String otherPhysicalSigns; | ||||
|  | ||||
|     /** 气血数据 */ | ||||
|     private String bloodData; | ||||
|  | ||||
|     //备注 | ||||
|     private String remark; | ||||
|  | ||||
|     /** 湿气数据 */ | ||||
|     private String moistureDate; | ||||
|  | ||||
| } | ||||
| @@ -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; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -4,6 +4,7 @@ import java.util.List; | ||||
|  | ||||
| import com.stdiet.common.core.domain.AjaxResult; | ||||
| import com.stdiet.custom.domain.SysCustomerHealthy; | ||||
| import com.stdiet.custom.dto.request.HealthyDetailRequest; | ||||
| import org.apache.ibatis.annotations.Param; | ||||
|  | ||||
| /** | ||||
| @@ -78,4 +79,10 @@ public interface ISysCustomerHealthyService | ||||
|      * @return | ||||
|      */ | ||||
|     int deleteCustomerHealthyByCustomerId(Long customerId); | ||||
|  | ||||
|     /** | ||||
|      * 生成健康评估报告 | ||||
|      * @return | ||||
|      */ | ||||
|     AjaxResult generateHealthyReport(HealthyDetailRequest healthyDetailRequest); | ||||
| } | ||||
| @@ -1,14 +1,22 @@ | ||||
| package com.stdiet.custom.service.impl; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import com.stdiet.common.config.RuoYiConfig; | ||||
| import com.stdiet.common.core.domain.AjaxResult; | ||||
| 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,72 @@ 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){ | ||||
|         Map<String,String> data = new HashMap<>(); | ||||
|         for (String key : healthyAttrNameAray) { | ||||
|             data.put(key, ReflectUtils.getFieldValueByFieldName(key, healthyDetailRequest)); | ||||
|         } | ||||
|         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].toString()+"-"+nutritionalCalories.getTargetEveryWeightHeat()[1].toString()); | ||||
|             } | ||||
|             if("standardEveryWeightHeat".equals(key)){ | ||||
|                 data.put(key, nutritionalCalories.getStandardEveryWeightHeat()[0].toString()+"-"+nutritionalCalories.getStandardEveryWeightHeat()[1].toString()); | ||||
|             } | ||||
|             data.put(key, ReflectUtils.getFieldValueByFieldName(key, nutritionalCalories)); | ||||
|         } | ||||
|         return data; | ||||
|     } | ||||
| } | ||||
| @@ -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; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user