建议问卷导出Excel
This commit is contained in:
		| @@ -1,8 +1,13 @@ | |||||||
| package com.stdiet.web.controller.custom; | package com.stdiet.web.controller.custom; | ||||||
|  |  | ||||||
|  | import java.util.ArrayList; | ||||||
|  | import java.util.Arrays; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  | import java.util.Map; | ||||||
|  |  | ||||||
| import com.stdiet.common.utils.HealthyUtils; | 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.security.access.prepost.PreAuthorize; | ||||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||||
| import org.springframework.web.bind.annotation.GetMapping; | import org.springframework.web.bind.annotation.GetMapping; | ||||||
| @@ -62,11 +67,65 @@ public class SysPreSaleSurveyController extends BaseController | |||||||
|     @GetMapping("/export") |     @GetMapping("/export") | ||||||
|     public AjaxResult export(SysPreSaleSurvey sysPreSaleSurvey) |     public AjaxResult export(SysPreSaleSurvey sysPreSaleSurvey) | ||||||
|     { |     { | ||||||
|  |         sysPreSaleSurvey.setQuestionType(1); | ||||||
|         List<SysPreSaleSurvey> list = sysPreSaleSurveyService.selectSysPreSaleSurveyList(sysPreSaleSurvey); |         List<SysPreSaleSurvey> list = sysPreSaleSurveyService.selectSysPreSaleSurveyList(sysPreSaleSurvey); | ||||||
|  |         if(list != null && list.size() > 0){ | ||||||
|  |             List<Map<String,Object>> signResult = sysPreSaleSurveyService.getDictLabelByIds("simple_sign_type", null); | ||||||
|  |             List<Map<String,Object>> moistureResult = sysPreSaleSurveyService.getDictLabelByIds("moisture_data_extended", null); | ||||||
|  |             List<Map<String,Object>>  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<String> 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<String> result = getDictLabelByIds(moistureResult, survey.getMoistureData()); | ||||||
|  |                     survey.setMoistureData(result.size() > 0 ? StringUtils.join(result, ";") : ""); | ||||||
|  |                 } | ||||||
|  |                 //获取气血 | ||||||
|  |                 if(StringUtils.isNotEmpty(survey.getBloodData())){ | ||||||
|  |                     List<String> result = getDictLabelByIds(bloodResult, survey.getBloodData()); | ||||||
|  |                     survey.setBloodData(result.size() > 0 ? StringUtils.join(result, ";") : ""); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|         ExcelUtil<SysPreSaleSurvey> util = new ExcelUtil<SysPreSaleSurvey>(SysPreSaleSurvey.class); |         ExcelUtil<SysPreSaleSurvey> util = new ExcelUtil<SysPreSaleSurvey>(SysPreSaleSurvey.class); | ||||||
|         return util.exportExcel(list, "preSaleSurvey"); |         return util.exportExcel(list, "preSaleSurvey"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public List<String> getDictLabelByIds(List<Map<String, Object>> dictResult, String dictValue){ | ||||||
|  |         List<String> result = new ArrayList<>(); | ||||||
|  |         if(dictResult != null && dictResult.size() > 0){ | ||||||
|  |             List<String> dictValueArray = Arrays.asList(dictValue.split(",")); | ||||||
|  |             for (Map<String, Object> map : dictResult) { | ||||||
|  |                 if(dictValueArray.contains(map.get("dictValue"))){ | ||||||
|  |                     result.add(String.valueOf(map.get("dictLabel"))); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 获取简易问卷调查详细信息 |      * 获取简易问卷调查详细信息 | ||||||
|      */ |      */ | ||||||
|   | |||||||
| @@ -1,10 +1,12 @@ | |||||||
| package com.stdiet.custom.domain; | package com.stdiet.custom.domain; | ||||||
|  |  | ||||||
|  | import com.fasterxml.jackson.annotation.JsonFormat; | ||||||
| import com.stdiet.common.annotation.Excel; | import com.stdiet.common.annotation.Excel; | ||||||
| import com.stdiet.common.core.domain.BaseEntity; | import com.stdiet.common.core.domain.BaseEntity; | ||||||
| import lombok.Data; | import lombok.Data; | ||||||
|  |  | ||||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||||
|  | import java.util.Date; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 售前调查,销售给客户发送简易信息调查链接对象 sys_pre_sale_survey |  * 售前调查,销售给客户发送简易信息调查链接对象 sys_pre_sale_survey | ||||||
| @@ -21,39 +23,53 @@ public class SysPreSaleSurvey extends BaseEntity | |||||||
|     private Long id; |     private Long id; | ||||||
|  |  | ||||||
|     /** 客户唯一标识 */ |     /** 客户唯一标识 */ | ||||||
|     @Excel(name = "客户唯一标识") |     //@Excel(name = "客户唯一标识") | ||||||
|     private String customerKey; |     private String customerKey; | ||||||
|  |  | ||||||
|     /** 姓名 */ |     /** 姓名 */ | ||||||
|     @Excel(name = "姓名") |     @Excel(name = "姓名") | ||||||
|     private String name; |     private String name; | ||||||
|  |  | ||||||
|     /** 身高,厘米 */ |  | ||||||
|     @Excel(name = "身高,厘米") |  | ||||||
|     private Integer tall; |  | ||||||
|  |  | ||||||
|     /** 体重 */ |  | ||||||
|     @Excel(name = "体重") |  | ||||||
|     private BigDecimal weight; |  | ||||||
|  |  | ||||||
|     /** 年龄 */ |     /** 年龄 */ | ||||||
|     @Excel(name = "年龄") |     @Excel(name = "年龄") | ||||||
|     private Integer age; |     private Integer age; | ||||||
|  |  | ||||||
|     /** 0男 1女 */ |     /** 0男 1女 */ | ||||||
|     @Excel(name = "0男 1女") |     @Excel(name = "性别", readConverterExp = "0=男,1=女") | ||||||
|     private Integer sex; |     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 = "电话") |     @Excel(name = "电话") | ||||||
|     private String phone; |     private String phone; | ||||||
|  |  | ||||||
|     /** 特殊体征ID */ |     /** 特殊体征ID */ | ||||||
|     @Excel(name = "特殊体征ID") |  | ||||||
|     private String physicalSignsId; |     private String physicalSignsId; | ||||||
|  |  | ||||||
|  |     /** 特殊体征ID */ | ||||||
|  |     @Excel(name = "特殊体征") | ||||||
|  |     private String physicalSigns; | ||||||
|  |  | ||||||
|     /** 其他体征 */ |     /** 其他体征 */ | ||||||
|     @Excel(name = "其他体征") |  | ||||||
|     private String otherPhysicalSigns; |     private String otherPhysicalSigns; | ||||||
|  |  | ||||||
|     /** 作息时间 */ |     /** 作息时间 */ | ||||||
| @@ -61,34 +77,32 @@ public class SysPreSaleSurvey extends BaseEntity | |||||||
|     private String timeTable; |     private String timeTable; | ||||||
|  |  | ||||||
|     /** 减脂或慢病调理经历 */ |     /** 减脂或慢病调理经历 */ | ||||||
|     @Excel(name = "减脂或慢病调理经历") |     @Excel(name = "调理经历") | ||||||
|     private String experience; |     private String experience; | ||||||
|  |  | ||||||
|     /** 职业 */ |     /** 职业 */ | ||||||
|     @Excel(name = "职业") |     @Excel(name = "职业") | ||||||
|     private String occupation; |     private String occupation; | ||||||
|  |  | ||||||
|     /** 气血数据 */ |  | ||||||
|     @Excel(name = "气血数据") |  | ||||||
|     private String bloodData; |  | ||||||
|  |  | ||||||
|     /** 湿气数据 */ |     /** 湿气数据 */ | ||||||
|     @Excel(name = "湿气数据") |     @Excel(name = "湿气数据") | ||||||
|     private String moistureData; |     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 */ |     /** 售前ID */ | ||||||
|     @Excel(name = "售前ID") |  | ||||||
|     private Long preSaleId; |     private Long preSaleId; | ||||||
|  |  | ||||||
|     /** 问卷类型 0售前简易问卷  1简易评估问卷 */ |     /** 问卷类型 0售前简易问卷  1简易评估问卷 */ | ||||||
|     @Excel(name = "问卷类型 0售前简易问卷  1简易评估问卷") |  | ||||||
|     private Integer questionType; |     private Integer questionType; | ||||||
|  |  | ||||||
|     /** 删除标识 0未删除 1已删除 */ |     /** 删除标识 0未删除 1已删除 */ | ||||||
|     private Integer delFlag; |     private Integer delFlag; | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 标准体重 |  | ||||||
|      */ |  | ||||||
|     private Double standardWeight; |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,6 +1,8 @@ | |||||||
| package com.stdiet.custom.mapper; | package com.stdiet.custom.mapper; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  | import java.util.Map; | ||||||
|  |  | ||||||
| import com.stdiet.custom.domain.SysPreSaleSurvey; | import com.stdiet.custom.domain.SysPreSaleSurvey; | ||||||
| import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||||
|  |  | ||||||
| @@ -65,4 +67,12 @@ public interface SysPreSaleSurveyMapper | |||||||
|      * @return |      * @return | ||||||
|      */ |      */ | ||||||
|     public SysPreSaleSurvey getSysPreSaleSurveyByKey(@Param("customerKey")String customerKey); |     public SysPreSaleSurvey getSysPreSaleSurveyByKey(@Param("customerKey")String customerKey); | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 查询字典Label值 | ||||||
|  |      * @param dictType | ||||||
|  |      * @param dictValue | ||||||
|  |      * @return | ||||||
|  |      */ | ||||||
|  |     public List<Map<String,Object>> getDictLabelByIds(@Param("dictType")String dictType, @Param("dictValue")String dictValue); | ||||||
| } | } | ||||||
| @@ -4,6 +4,7 @@ import java.util.List; | |||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| import com.stdiet.custom.domain.SysPreSaleSurvey; | import com.stdiet.custom.domain.SysPreSaleSurvey; | ||||||
|  | import org.apache.ibatis.annotations.Param; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 售前调查,销售给客户发送简易信息调查链接Service接口 |  * 售前调查,销售给客户发送简易信息调查链接Service接口 | ||||||
| @@ -66,4 +67,12 @@ public interface ISysPreSaleSurveyService | |||||||
|      * @return |      * @return | ||||||
|      */ |      */ | ||||||
|     public SysPreSaleSurvey getSysPreSaleSurveyByKey(String customerKey); |     public SysPreSaleSurvey getSysPreSaleSurveyByKey(String customerKey); | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 查询字典Label值 | ||||||
|  |      * @param dictType | ||||||
|  |      * @param dictValue | ||||||
|  |      * @return | ||||||
|  |      */ | ||||||
|  |     public List<Map<String,Object>> getDictLabelByIds(String dictType, String dictValue); | ||||||
| } | } | ||||||
| @@ -7,6 +7,7 @@ import java.util.Map; | |||||||
| import com.stdiet.common.utils.DateUtils; | import com.stdiet.common.utils.DateUtils; | ||||||
| import com.stdiet.common.utils.HealthyUtils; | import com.stdiet.common.utils.HealthyUtils; | ||||||
| import com.stdiet.custom.utils.NutritionalUtils; | import com.stdiet.custom.utils.NutritionalUtils; | ||||||
|  | import org.apache.ibatis.annotations.Param; | ||||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
| import com.stdiet.custom.mapper.SysPreSaleSurveyMapper; | import com.stdiet.custom.mapper.SysPreSaleSurveyMapper; | ||||||
| @@ -107,4 +108,15 @@ public class SysPreSaleSurveyServiceImpl implements ISysPreSaleSurveyService | |||||||
|     public SysPreSaleSurvey getSysPreSaleSurveyByKey(String customerKey){ |     public SysPreSaleSurvey getSysPreSaleSurveyByKey(String customerKey){ | ||||||
|         return sysPreSaleSurveyMapper.getSysPreSaleSurveyByKey(customerKey); |         return sysPreSaleSurveyMapper.getSysPreSaleSurveyByKey(customerKey); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 查询字典Label值 | ||||||
|  |      * @param dictType | ||||||
|  |      * @param dictValue | ||||||
|  |      * @return | ||||||
|  |      */ | ||||||
|  |     @Override | ||||||
|  |     public List<Map<String,Object>> getDictLabelByIds(String dictType, String dictValue){ | ||||||
|  |         return sysPreSaleSurveyMapper.getDictLabelByIds(dictType, dictValue); | ||||||
|  |     } | ||||||
| } | } | ||||||
| @@ -145,4 +145,12 @@ | |||||||
|         where del_flag = 0 and customer_key = #{customerKey} limit 1 |         where del_flag = 0 and customer_key = #{customerKey} limit 1 | ||||||
|     </select> |     </select> | ||||||
|  |  | ||||||
|  |     <!-- 根据字典ID(可以使用,隔开的多个ID)获取对应字典值 --> | ||||||
|  |     <select id="getDictLabelByIds" parameterType="String" resultType="Map"> | ||||||
|  |         select dict_label as dictLabel,dict_value as dictValue from sys_dict_data where status = '0' and dict_type = #{dictType} | ||||||
|  |         <if test="dictValue != null and dictValue != ''"> | ||||||
|  |             and FIND_IN_SET(dict_value, #{dictValue}) | ||||||
|  |         </if> | ||||||
|  |     </select> | ||||||
|  |  | ||||||
| </mapper> | </mapper> | ||||||
| @@ -86,7 +86,7 @@ | |||||||
|           v-hasPermi="['custom:preSaleSurvey:remove']" |           v-hasPermi="['custom:preSaleSurvey:remove']" | ||||||
|         >删除</el-button> |         >删除</el-button> | ||||||
|       </el-col> |       </el-col> | ||||||
|       <!--<el-col :span="1.5"> |       <el-col :span="1.5"> | ||||||
|         <el-button |         <el-button | ||||||
|           type="warning" |           type="warning" | ||||||
|           icon="el-icon-download" |           icon="el-icon-download" | ||||||
| @@ -94,7 +94,7 @@ | |||||||
|           @click="handleExport" |           @click="handleExport" | ||||||
|           v-hasPermi="['custom:preSaleSurvey:export']" |           v-hasPermi="['custom:preSaleSurvey:export']" | ||||||
|         >导出</el-button> |         >导出</el-button> | ||||||
|       </el-col>--> |       </el-col> | ||||||
| 	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | 	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||||||
|     </el-row> |     </el-row> | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user