@ -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<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);
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取简易问卷调查详细信息
|
||||
*/
|
||||
|
Reference in New Issue
Block a user