diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysPreSaleSurveyController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysPreSaleSurveyController.java index 1b17670e3..50bfda153 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysPreSaleSurveyController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysPreSaleSurveyController.java @@ -1,8 +1,13 @@ package com.stdiet.web.controller.custom; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Map; import com.stdiet.common.utils.HealthyUtils; +import com.stdiet.common.utils.NumberUtils; +import com.stdiet.common.utils.StringUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -62,11 +67,65 @@ public class SysPreSaleSurveyController extends BaseController @GetMapping("/export") public AjaxResult export(SysPreSaleSurvey sysPreSaleSurvey) { + sysPreSaleSurvey.setQuestionType(1); List list = sysPreSaleSurveyService.selectSysPreSaleSurveyList(sysPreSaleSurvey); + if(list != null && list.size() > 0){ + List> signResult = sysPreSaleSurveyService.getDictLabelByIds("simple_sign_type", null); + List> moistureResult = sysPreSaleSurveyService.getDictLabelByIds("moisture_data_extended", null); + List> bloodResult = sysPreSaleSurveyService.getDictLabelByIds("blood_data_extended", null); + for (SysPreSaleSurvey survey : list) { + //计算标准体重 + survey.setStandardWeight(HealthyUtils.calculateStandardWeightByBMI(survey.getTall(), survey.getAge(), survey.getSex())); + //计算超重 + survey.setOverWeight(NumberUtils.getNumberByRoundHalfUp(survey.getWeight().doubleValue() - survey.getStandardWeight(),2).doubleValue()); + //作息时间 + if(StringUtils.isNotEmpty(survey.getTimeTable())){ + String [] timeTableArray = survey.getTimeTable().split(","); + String timeTable = timeTableArray.length > 0 ? "睡觉:" + timeTableArray[0] : ""; + timeTable += timeTableArray.length > 1 ? ",起床:" + timeTableArray[1] : ""; + survey.setTimeTable(timeTable); + } + //隐藏手机号 + if(StringUtils.isNotEmpty(survey.getPhone())){ + survey.setPhone(StringUtils.hiddenPhoneNumber(survey.getPhone())); + } + //获取病史 + if(StringUtils.isNotEmpty(survey.getPhysicalSignsId())){ + List result = getDictLabelByIds(signResult, survey.getPhysicalSignsId()); + System.out.println(StringUtils.join(result, ";")); + survey.setPhysicalSigns(result.size() > 0 ? (StringUtils.join(result, ";") + ";" + survey.getOtherPhysicalSigns()) : survey.getOtherPhysicalSigns()); + }else{ + survey.setPhysicalSigns(survey.getOtherPhysicalSigns()); + } + //获取湿气 + if(StringUtils.isNotEmpty(survey.getMoistureData())){ + List result = getDictLabelByIds(moistureResult, survey.getMoistureData()); + survey.setMoistureData(result.size() > 0 ? StringUtils.join(result, ";") : ""); + } + //获取气血 + if(StringUtils.isNotEmpty(survey.getBloodData())){ + List result = getDictLabelByIds(bloodResult, survey.getBloodData()); + survey.setBloodData(result.size() > 0 ? StringUtils.join(result, ";") : ""); + } + } + } ExcelUtil util = new ExcelUtil(SysPreSaleSurvey.class); return util.exportExcel(list, "preSaleSurvey"); } + public List getDictLabelByIds(List> dictResult, String dictValue){ + List result = new ArrayList<>(); + if(dictResult != null && dictResult.size() > 0){ + List dictValueArray = Arrays.asList(dictValue.split(",")); + for (Map map : dictResult) { + if(dictValueArray.contains(map.get("dictValue"))){ + result.add(String.valueOf(map.get("dictLabel"))); + } + } + } + return result; + } + /** * 获取简易问卷调查详细信息 */ diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysPreSaleSurvey.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysPreSaleSurvey.java index c5d6a9d08..4d141330c 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysPreSaleSurvey.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysPreSaleSurvey.java @@ -1,10 +1,12 @@ package com.stdiet.custom.domain; +import com.fasterxml.jackson.annotation.JsonFormat; import com.stdiet.common.annotation.Excel; import com.stdiet.common.core.domain.BaseEntity; import lombok.Data; import java.math.BigDecimal; +import java.util.Date; /** * 售前调查,销售给客户发送简易信息调查链接对象 sys_pre_sale_survey @@ -21,39 +23,53 @@ public class SysPreSaleSurvey extends BaseEntity private Long id; /** 客户唯一标识 */ - @Excel(name = "客户唯一标识") + //@Excel(name = "客户唯一标识") private String customerKey; /** 姓名 */ @Excel(name = "姓名") private String name; - /** 身高,厘米 */ - @Excel(name = "身高,厘米") - private Integer tall; - - /** 体重 */ - @Excel(name = "体重") - private BigDecimal weight; - /** 年龄 */ @Excel(name = "年龄") private Integer age; /** 0男 1女 */ - @Excel(name = "0男 1女") + @Excel(name = "性别", readConverterExp = "0=男,1=女") private Integer sex; + /** 身高,厘米 */ + @Excel(name = "身高(厘米)") + private Integer tall; + + /** 体重 */ + @Excel(name = "体重(斤)") + private BigDecimal weight; + + /** + * 标准体重 + */ + @Excel(name = "标准体重") + private Double standardWeight; + + /** + * 标准体重 + */ + @Excel(name = "超重") + private Double overWeight ; + /** 电话 */ @Excel(name = "电话") private String phone; /** 特殊体征ID */ - @Excel(name = "特殊体征ID") private String physicalSignsId; + /** 特殊体征ID */ + @Excel(name = "特殊体征") + private String physicalSigns; + /** 其他体征 */ - @Excel(name = "其他体征") private String otherPhysicalSigns; /** 作息时间 */ @@ -61,34 +77,32 @@ public class SysPreSaleSurvey extends BaseEntity private String timeTable; /** 减脂或慢病调理经历 */ - @Excel(name = "减脂或慢病调理经历") + @Excel(name = "调理经历") private String experience; /** 职业 */ @Excel(name = "职业") private String occupation; - /** 气血数据 */ - @Excel(name = "气血数据") - private String bloodData; - /** 湿气数据 */ @Excel(name = "湿气数据") private String moistureData; + /** 气血数据 */ + @Excel(name = "气血数据") + private String bloodData; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm") + @Excel(name = "创建时间",dateFormat="yyyy-MM-dd HH:mm") + private Date createTime; + /** 售前ID */ - @Excel(name = "售前ID") private Long preSaleId; /** 问卷类型 0售前简易问卷 1简易评估问卷 */ - @Excel(name = "问卷类型 0售前简易问卷 1简易评估问卷") private Integer questionType; /** 删除标识 0未删除 1已删除 */ private Integer delFlag; - - /** - * 标准体重 - */ - private Double standardWeight; } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysPreSaleSurveyMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysPreSaleSurveyMapper.java index 7996395dd..f7e6edbde 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysPreSaleSurveyMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysPreSaleSurveyMapper.java @@ -1,6 +1,8 @@ package com.stdiet.custom.mapper; import java.util.List; +import java.util.Map; + import com.stdiet.custom.domain.SysPreSaleSurvey; import org.apache.ibatis.annotations.Param; @@ -65,4 +67,12 @@ public interface SysPreSaleSurveyMapper * @return */ public SysPreSaleSurvey getSysPreSaleSurveyByKey(@Param("customerKey")String customerKey); + + /** + * 查询字典Label值 + * @param dictType + * @param dictValue + * @return + */ + public List> getDictLabelByIds(@Param("dictType")String dictType, @Param("dictValue")String dictValue); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysPreSaleSurveyService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysPreSaleSurveyService.java index f43fbfc48..8b32de2f9 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysPreSaleSurveyService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysPreSaleSurveyService.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; import com.stdiet.custom.domain.SysPreSaleSurvey; +import org.apache.ibatis.annotations.Param; /** * 售前调查,销售给客户发送简易信息调查链接Service接口 @@ -66,4 +67,12 @@ public interface ISysPreSaleSurveyService * @return */ public SysPreSaleSurvey getSysPreSaleSurveyByKey(String customerKey); + + /** + * 查询字典Label值 + * @param dictType + * @param dictValue + * @return + */ + public List> getDictLabelByIds(String dictType, String dictValue); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysPreSaleSurveyServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysPreSaleSurveyServiceImpl.java index a41fba1d9..bdca4e880 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysPreSaleSurveyServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysPreSaleSurveyServiceImpl.java @@ -7,6 +7,7 @@ import java.util.Map; import com.stdiet.common.utils.DateUtils; import com.stdiet.common.utils.HealthyUtils; import com.stdiet.custom.utils.NutritionalUtils; +import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.stdiet.custom.mapper.SysPreSaleSurveyMapper; @@ -107,4 +108,15 @@ public class SysPreSaleSurveyServiceImpl implements ISysPreSaleSurveyService public SysPreSaleSurvey getSysPreSaleSurveyByKey(String customerKey){ return sysPreSaleSurveyMapper.getSysPreSaleSurveyByKey(customerKey); } + + /** + * 查询字典Label值 + * @param dictType + * @param dictValue + * @return + */ + @Override + public List> getDictLabelByIds(String dictType, String dictValue){ + return sysPreSaleSurveyMapper.getDictLabelByIds(dictType, dictValue); + } } \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysPreSaleSurveyMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysPreSaleSurveyMapper.xml index e06a982a7..bd9093290 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysPreSaleSurveyMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysPreSaleSurveyMapper.xml @@ -145,4 +145,12 @@ where del_flag = 0 and customer_key = #{customerKey} limit 1 + + + \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml index c7fea0a00..a59dcdafe 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml @@ -73,7 +73,7 @@ select srp.* from sys_recipes_plan srp left join sys_order so on so.order_id = srp.order_id and so.del_flag = 0 - where srp.cus_id = #{customerId} and srp.del_flag = 0 and #{orderTime} > so.order_time order by srp.end_num_day DESC limit 1 + where srp.cus_id = #{customerId} and srp.del_flag = 0 and #{orderTime} > so.order_time order by so.order_time DESC,srp.end_num_day DESC limit 1 diff --git a/stdiet-ui/src/views/custom/preSaleSurvey/index.vue b/stdiet-ui/src/views/custom/preSaleSurvey/index.vue index a64fff10f..295059edb 100644 --- a/stdiet-ui/src/views/custom/preSaleSurvey/index.vue +++ b/stdiet-ui/src/views/custom/preSaleSurvey/index.vue @@ -86,7 +86,7 @@ v-hasPermi="['custom:preSaleSurvey:remove']" >删除 - +