健康评估报告
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;
|
||||
|
@ -281,6 +281,8 @@ public class HealthyDetailRequest implements Serializable {
|
||||
/** 其他运动项目,使用,隔开 */
|
||||
private String otherMotionClassify;
|
||||
|
||||
private String motion;
|
||||
|
||||
/** 运动场地,使用,隔开 */
|
||||
private String motionField;
|
||||
|
||||
@ -372,8 +374,8 @@ public class HealthyDetailRequest implements Serializable {
|
||||
/** 饮食习惯 */
|
||||
private String makeFoodType;
|
||||
|
||||
/** 客户病史体征id,使用,隔开 */
|
||||
private String physicalSignsId;
|
||||
/** 客户病史体征,使用,隔开 */
|
||||
private String physicalSigns;
|
||||
|
||||
/** 其他病史体征 **/
|
||||
private String otherPhysicalSigns;
|
||||
@ -387,4 +389,8 @@ public class HealthyDetailRequest implements Serializable {
|
||||
/** 湿气数据 */
|
||||
private String moistureDate;
|
||||
|
||||
|
||||
/** 减脂指导 **/
|
||||
private String guidance;
|
||||
|
||||
}
|
||||
|
@ -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.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;
|
||||
@ -85,4 +86,12 @@ public interface ISysCustomerHealthyService
|
||||
* @return
|
||||
*/
|
||||
AjaxResult generateHealthyReport(HealthyDetailRequest healthyDetailRequest);
|
||||
|
||||
|
||||
/**
|
||||
* 根据类型、键值集合查询字典类型
|
||||
* @param sysDictData
|
||||
* @return
|
||||
*/
|
||||
public List<SysDictData> selectDictDataByTypeAndValue(SysDictData sysDictData);
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package com.stdiet.custom.service.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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;
|
||||
@ -157,14 +157,13 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService
|
||||
@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 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);
|
||||
}
|
||||
@ -192,10 +191,35 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService
|
||||
};
|
||||
|
||||
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());
|
||||
@ -208,13 +232,28 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService
|
||||
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());
|
||||
data.put(key, nutritionalCalories.getTargetEveryWeightHeat()[0].intValue()+"-"+nutritionalCalories.getTargetEveryWeightHeat()[1].intValue());
|
||||
continue;
|
||||
}
|
||||
if("standardEveryWeightHeat".equals(key)){
|
||||
data.put(key, nutritionalCalories.getStandardEveryWeightHeat()[0].toString()+"-"+nutritionalCalories.getStandardEveryWeightHeat()[1].toString());
|
||||
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);
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ import java.util.List;
|
||||
@Service("sysRecipesPlanService")
|
||||
@Transactional
|
||||
public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
|
||||
|
||||
public static final String generateRecipesPlanLockKey = "generateRecipesPlanLock::%s";
|
||||
@Autowired
|
||||
private SysRecipesPlanMapper sysRecipesPlanMapper;
|
||||
@ -137,6 +138,7 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
|
||||
//判断是否提成单,拆分单中的副单,体验单
|
||||
if(sysOrder.getAfterSaleCommissOrder().intValue() == 1 || ("1".equals(sysOrder.getOrderType()) && sysOrder.getMainOrderId().intValue() == 1) ||
|
||||
"2".equals(sysOrder.getOrderType())){
|
||||
System.out.println("---------------------不生成食谱------------------------");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@ -144,7 +146,6 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
|
||||
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];
|
||||
@ -156,10 +157,15 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
|
||||
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, DateUtils.dateToLocalDate(sysOrder.getStartTime()), DateUtils.dateToLocalDate(sysOrder.getServerEndTime()), pauseList);
|
||||
//判断是否已存在食谱计划
|
||||
List<SysRecipesPlan> oldRecipesPlanList = sysRecipesPlanMapper.selectSysRecipesPlanList(queryParam);
|
||||
if(oldRecipesPlanList != null && oldRecipesPlanList.size() > 0){
|
||||
|
||||
}else{
|
||||
if (planList != null && planList.size() > 0) {
|
||||
sysRecipesPlanMapper.insertBatch(planList);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -174,14 +180,12 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
|
||||
* 根据订单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) {
|
||||
public List<SysRecipesPlan> generatePlan(SysOrder sysOrder, LocalDate serverStartDate, LocalDate serverEndDate, List<SysOrderPause> pauseList) {
|
||||
List<SysRecipesPlan> planList = new ArrayList<>();
|
||||
boolean breakFlag = false;
|
||||
LocalDate planStartDate = serverStartDate;
|
||||
@ -200,17 +204,12 @@ 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)));
|
||||
}*/
|
||||
sysRecipesPlan.setEndNumDay();
|
||||
//将旧食谱计划中的发送状态、发送时间、食谱复制到新食谱计划中
|
||||
boolean existFlag = oldRecipesPlanList.size() >= planList.size() + 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.setRecipesId(existFlag ? oldRecipesPlanList.get(planList.size()).getRecipesId() : null);*/
|
||||
planList.add(sysRecipesPlan);
|
||||
|
||||
planStartDate = planEndDate.plusDays(1);
|
||||
|
Reference in New Issue
Block a user