|
@@ -1,292 +0,0 @@
|
|
-package com.diagbot.facade;
|
|
|
|
-
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
-import com.diagbot.dto.PhysicalInfoDTO;
|
|
|
|
-import com.diagbot.dto.SearchEvaluatorDTO;
|
|
|
|
-import com.diagbot.entity.Evaluator;
|
|
|
|
-import com.diagbot.entity.PhysicalInfo;
|
|
|
|
-import com.diagbot.entity.PhysicalVal;
|
|
|
|
-import com.diagbot.enums.IsDeleteEnum;
|
|
|
|
-import com.diagbot.enums.PhysicalTypeEnum;
|
|
|
|
-import com.diagbot.enums.SexEnum;
|
|
|
|
-import com.diagbot.exception.CommonErrorCode;
|
|
|
|
-import com.diagbot.exception.CommonException;
|
|
|
|
-import com.diagbot.service.impl.EvaluatorServiceImpl;
|
|
|
|
-import com.diagbot.util.BeanUtil;
|
|
|
|
-import com.diagbot.util.DateUtil;
|
|
|
|
-import com.diagbot.util.ListUtil;
|
|
|
|
-import com.diagbot.util.RegexValidateUtil;
|
|
|
|
-import com.diagbot.vo.AddEvaluatorVO;
|
|
|
|
-import com.diagbot.vo.SearchEvaluatorVO;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
|
-
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
-import java.util.Comparator;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * @Description:
|
|
|
|
- * @author: gaodm
|
|
|
|
- * @time: 2019/5/30 10:41
|
|
|
|
- */
|
|
|
|
-@Component
|
|
|
|
-public class EvaluatorFacade extends EvaluatorServiceImpl {
|
|
|
|
- @Autowired
|
|
|
|
- private PhysicalInfoFacade physicalInfoFacade;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public static void main(String[] args) {
|
|
|
|
- EvaluatorFacade evaluatorFacade = new EvaluatorFacade();
|
|
|
|
- Evaluator evaluator = new Evaluator();
|
|
|
|
- evaluator.setMildValue(new BigDecimal(70.0)); // 平和体质
|
|
|
|
- evaluator.setFaintValue(new BigDecimal(50.0)); // 气虚体质
|
|
|
|
- evaluator.setStagnantValue(new BigDecimal(49.0)); // 积滞同质
|
|
|
|
- evaluator.setWetValue(new BigDecimal(31.0)); // 湿滞体质
|
|
|
|
- evaluator.setHeartValue(new BigDecimal(31.000)); // 心肝火旺体质
|
|
|
|
- evaluator.setExceptValue(new BigDecimal(22.01)); // 异禀体质
|
|
|
|
-// evaluatorFacade.valueSort(evaluator);
|
|
|
|
- evaluatorFacade.cal(evaluator);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 计算体质
|
|
|
|
- *
|
|
|
|
- * @param evaluator 参数
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public Evaluator cal(Evaluator evaluator) {
|
|
|
|
-
|
|
|
|
- List<PhysicalVal> list = this.valueSort(evaluator);
|
|
|
|
- Double max = list.get(0).getValue();
|
|
|
|
- Double min = list.get(4).getValue();
|
|
|
|
-
|
|
|
|
- if (max >= 50) {
|
|
|
|
- // 最大值有多个【是XX体质兼有XX体质】,最大值只有1个【是XX体质】
|
|
|
|
- if (list.get(1).getValue() >= 50) {
|
|
|
|
- evaluator.setPhysicalRes("是" +
|
|
|
|
- PhysicalTypeEnum.getName(list.get(0).getEnumNo())
|
|
|
|
- + "兼有" +
|
|
|
|
- PhysicalTypeEnum.getName(list.get(1).getEnumNo()));
|
|
|
|
- evaluator.setPhysicalTypes("" + list.get(0).getEnumNo() + "," + list.get(1).getEnumNo());
|
|
|
|
- } else {
|
|
|
|
- evaluator.setPhysicalRes("是" +
|
|
|
|
- PhysicalTypeEnum.getName(list.get(0).getEnumNo()));
|
|
|
|
- evaluator.setPhysicalTypes("" + list.get(0).getEnumNo());
|
|
|
|
- }
|
|
|
|
- } else if (max < 30) {
|
|
|
|
- // 同时其他5种体质转化分均<30分, max[2/3/4/5/6] < 30
|
|
|
|
- evaluator.setPhysicalRes("平和体质");
|
|
|
|
- evaluator.setPhysicalTypes(String.valueOf(PhysicalTypeEnum.mild.getKey()));
|
|
|
|
- } else {
|
|
|
|
- if (evaluator.getMildValue().doubleValue() >= 60.0) {
|
|
|
|
- if (max < 50 && min >= 30) {
|
|
|
|
- // 同时其他5种体质转化分均<50分,min[2/3/4/5/6] >= 30 and max[2/3/4/5/6] < 50
|
|
|
|
- evaluator.setPhysicalRes("基本是平和体质");
|
|
|
|
- evaluator.setPhysicalTypes(String.valueOf(PhysicalTypeEnum.mild.getKey()));
|
|
|
|
- } else if (max < 50 && max >= 30 && min < 30) {
|
|
|
|
- // 同时其他5种体质转化分有30-49分,max[2/3/4/5/6] < 50 and max[2/3/4/5/6] >= 30 and min[2/3/4/5/6] < 30
|
|
|
|
- evaluator.setPhysicalRes("基本是平和体质兼倾向" + PhysicalTypeEnum.getName(list.get(0).getEnumNo()));
|
|
|
|
- evaluator.setPhysicalTypes(String.valueOf(PhysicalTypeEnum.mild.getKey()) + "," + list.get(0).getEnumNo());
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if (list.get(0).getValue().equals(list.get(1).getValue())) {
|
|
|
|
- evaluator.setPhysicalRes(
|
|
|
|
- "倾向是" +
|
|
|
|
- PhysicalTypeEnum.getName(list.get(0).getEnumNo())
|
|
|
|
- + "兼有" +
|
|
|
|
- PhysicalTypeEnum.getName(list.get(1).getEnumNo()));
|
|
|
|
- evaluator.setPhysicalTypes("" + list.get(0).getEnumNo() + "," + list.get(1).getEnumNo());
|
|
|
|
- } else {
|
|
|
|
- evaluator.setPhysicalRes("倾向是" +
|
|
|
|
- PhysicalTypeEnum.getName(list.get(0).getEnumNo()));
|
|
|
|
- evaluator.setPhysicalTypes("" + list.get(0).getEnumNo());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-// /**
|
|
|
|
-// * 判断平和质:
|
|
|
|
-// * 平和质转化分≥60分,同时其他5种体质转化分均<30分,判断结果:“平和质”。
|
|
|
|
-// * 平和质转化分≥60分,同时其他5种体质转化分均<50分,判断结果:“基本是平和质”。
|
|
|
|
-// * 平和质转化分≥60分,同时其他5种体质转化分有30-49分,判断结果:“基本是平和质兼倾向XX体质”。
|
|
|
|
-// * 不满足上述条件,判断结果:否。
|
|
|
|
-// */
|
|
|
|
-// // 平和质转化分≥60分
|
|
|
|
-// if (evaluator.getMildValue().doubleValue() >= 60.0) {
|
|
|
|
-// if (max < 30) {
|
|
|
|
-// // 同时其他5种体质转化分均<30分, max[2/3/4/5/6] < 30
|
|
|
|
-// evaluator.setPhysicalRes("平和体质");
|
|
|
|
-// evaluator.setPhysicalTypes(String.valueOf(PhysicalTypeEnum.mild.getKey()));
|
|
|
|
-// } else if (max < 50 && min >= 30) {
|
|
|
|
-// // 同时其他5种体质转化分均<50分,min[2/3/4/5/6] >= 30 and max[2/3/4/5/6] < 50
|
|
|
|
-// evaluator.setPhysicalRes("基本是平和体质");
|
|
|
|
-// evaluator.setPhysicalTypes(String.valueOf(PhysicalTypeEnum.mild.getKey()));
|
|
|
|
-// } else if (max < 50 && max >= 30 && min < 30) {
|
|
|
|
-// // 同时其他5种体质转化分有30-49分,max[2/3/4/5/6] < 50 and max[2/3/4/5/6] >= 30 and min[2/3/4/5/6] < 30
|
|
|
|
-// evaluator.setPhysicalRes("基本是平和体质兼倾向" + PhysicalTypeEnum.getName(list.get(0).getEnumNo()));
|
|
|
|
-// evaluator.setPhysicalTypes(String.valueOf(PhysicalTypeEnum.mild.getKey()) + "," + list.get(0).getEnumNo());
|
|
|
|
-// } else if (max >= 50) {
|
|
|
|
-// // 同时其他5种体质转化分有>=50分, max[2/3/4/5/6] >= 50
|
|
|
|
-// if ((list.get(0).getValue() == list.get(1).getValue()) || (list.get(1).getValue() > 50)) {
|
|
|
|
-// evaluator.setPhysicalRes("是" + PhysicalTypeEnum.getName(list.get(0).getEnumNo()) + "兼有" + PhysicalTypeEnum.getName(list.get(1).getEnumNo()));
|
|
|
|
-// evaluator.setPhysicalTypes(list.get(0).getEnumNo() + "," + list.get(1).getEnumNo());
|
|
|
|
-// } else {
|
|
|
|
-// evaluator.setPhysicalRes("是" + PhysicalTypeEnum.getName(list.get(0).getEnumNo()));
|
|
|
|
-// evaluator.setPhysicalTypes("" + list.get(0).getEnumNo());
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 判断偏颇体质:
|
|
|
|
-// * 转化分≥50分,判断结果:是XX体质。
|
|
|
|
-// * 转化分30-49分,判断结果:倾向XX体质。
|
|
|
|
-// * 转化分<30分,判断结果:否。
|
|
|
|
-// * 结论:按照偏颇体质得分高低顺序排序,得分最高的为主要偏颇体质,结论按此体质显示,并在结果中按分值顺序提选兼有体质。
|
|
|
|
-// * 首先判定5种偏颇体质得分是否均大于或等于≧50分。
|
|
|
|
-// * 有一个或多个大于等于50分的情况,按照偏颇体质选择分值最大的为偏颇体质,排名第二的为兼有体质,其余的不考虑;如果得分排名第一的有两个或以上,则按照自然顺序将第一个列为主要偏颇体质,第二个列为兼有体质,其余的不予考虑。
|
|
|
|
-// * 如出现得分一样的两种偏颇体质,则按照5种偏颇体质的排列顺序为:气虚质、积滞质、湿滞质、心火偏旺质、异禀质,
|
|
|
|
-// * 5种全部小于<30分的情况,按照平和质判定条件执行。
|
|
|
|
-// * 平和质转化分<60分,同时其他6种体质转化分30-49分,判断结果:倾向是XX体质。如果有两种或以上的得分一样,则按照6种偏颇体质的排列顺序为:气虚质、积滞质、湿滞质、心肝火旺质、异禀质,判断结果:“倾向是XX体质兼XX体质”,其余不考虑。如果等分倾向是体质有3个或以上,则仅选择分值最高的前两个,判断结果:“倾向是XX体质兼XX体质”,其余不考虑。
|
|
|
|
-// * 注意:有偏颇体质的不再考虑倾向体质。
|
|
|
|
-// */
|
|
|
|
-// else if (evaluator.getMildValue().doubleValue() < 60.0) {
|
|
|
|
-// if (max < 30) { // max[2/3/4/5/6] < 30
|
|
|
|
-// evaluator.setPhysicalRes("平和体质");
|
|
|
|
-// evaluator.setPhysicalTypes(String.valueOf(PhysicalTypeEnum.mild.getKey()));
|
|
|
|
-// } else if (max < 50 && max >= 30) { // min[2/3/4/5/6] >= 30 and max[2/3/4/5/6] < 50
|
|
|
|
-// // 最大值有多个【倾向XX体质兼有XX体质】, 最大值只有1个【倾向XX体质】
|
|
|
|
-// if (list.get(0).getValue() == list.get(1).getValue()) {
|
|
|
|
-// evaluator.setPhysicalRes(
|
|
|
|
-// "倾向是" +
|
|
|
|
-// PhysicalTypeEnum.getName(list.get(0).getEnumNo())
|
|
|
|
-// + "兼有" +
|
|
|
|
-// PhysicalTypeEnum.getName(list.get(1).getEnumNo()));
|
|
|
|
-// evaluator.setPhysicalTypes("" + list.get(0).getEnumNo() + "," + list.get(1).getEnumNo());
|
|
|
|
-// } else {
|
|
|
|
-// evaluator.setPhysicalRes("倾向是" +
|
|
|
|
-// PhysicalTypeEnum.getName(list.get(0).getEnumNo()));
|
|
|
|
-// evaluator.setPhysicalTypes("" + list.get(0).getEnumNo());
|
|
|
|
-// }
|
|
|
|
-// } else if (max >= 50) { // max[2/3/4/5/6] >= 50
|
|
|
|
-// // 最大值有多个【是XX体质兼有XX体质】,最大值只有1个【是XX体质】
|
|
|
|
-// if ((list.get(0).getValue() == list.get(1).getValue()) || (list.get(1).getValue() > 50)) {
|
|
|
|
-// evaluator.setPhysicalRes("是" +
|
|
|
|
-// PhysicalTypeEnum.getName(list.get(0).getEnumNo())
|
|
|
|
-// + "兼有" +
|
|
|
|
-// PhysicalTypeEnum.getName(list.get(1).getEnumNo()));
|
|
|
|
-// evaluator.setPhysicalTypes("" + list.get(0).getEnumNo() + "," + list.get(1).getEnumNo());
|
|
|
|
-// } else {
|
|
|
|
-// evaluator.setPhysicalRes("是" +
|
|
|
|
-// PhysicalTypeEnum.getName(list.get(0).getEnumNo()));
|
|
|
|
-// evaluator.setPhysicalTypes("" + list.get(0).getEnumNo());
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
- System.out.println(evaluator.getPhysicalRes());
|
|
|
|
- System.out.println(evaluator.getPhysicalTypes());
|
|
|
|
- return evaluator;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 对偏颇体质排序
|
|
|
|
- *
|
|
|
|
- * @param evaluator
|
|
|
|
- * @return 列表
|
|
|
|
- */
|
|
|
|
- private List<PhysicalVal> valueSort(Evaluator evaluator){
|
|
|
|
- List<PhysicalVal> res = ListUtil.newArrayList();
|
|
|
|
- //气虚体质转化分
|
|
|
|
- PhysicalVal faintValue = new PhysicalVal();
|
|
|
|
- faintValue.setValue(evaluator.getFaintValue().doubleValue());
|
|
|
|
- faintValue.setEnumNo(PhysicalTypeEnum.faint.getKey());
|
|
|
|
- faintValue.setOrderNo(1);
|
|
|
|
- res.add(faintValue);
|
|
|
|
- //积滞体质转化分
|
|
|
|
- PhysicalVal stagnantValue = new PhysicalVal();
|
|
|
|
- stagnantValue.setValue(evaluator.getStagnantValue().doubleValue());
|
|
|
|
- stagnantValue.setEnumNo(PhysicalTypeEnum.stagnant.getKey());
|
|
|
|
- stagnantValue.setOrderNo(2);
|
|
|
|
- res.add(stagnantValue);
|
|
|
|
- //湿滞体质转化分
|
|
|
|
- PhysicalVal wetValue = new PhysicalVal();
|
|
|
|
- wetValue.setValue(evaluator.getWetValue().doubleValue());
|
|
|
|
- wetValue.setEnumNo(PhysicalTypeEnum.wet.getKey());
|
|
|
|
- wetValue.setOrderNo(3);
|
|
|
|
- res.add(wetValue);
|
|
|
|
- //心肝火旺体质转化分
|
|
|
|
- PhysicalVal heartValue = new PhysicalVal();
|
|
|
|
- heartValue.setValue(evaluator.getHeartValue().doubleValue());
|
|
|
|
- heartValue.setEnumNo(PhysicalTypeEnum.heart.getKey());
|
|
|
|
- heartValue.setOrderNo(4);
|
|
|
|
- res.add(heartValue);
|
|
|
|
- //异禀体质转化分
|
|
|
|
- PhysicalVal exceptValue = new PhysicalVal();
|
|
|
|
- exceptValue.setValue(evaluator.getExceptValue().doubleValue());
|
|
|
|
- exceptValue.setEnumNo(PhysicalTypeEnum.except.getKey());
|
|
|
|
- exceptValue.setOrderNo(5);
|
|
|
|
- res.add(exceptValue);
|
|
|
|
-
|
|
|
|
- List<PhysicalVal> collect
|
|
|
|
- = res.stream()
|
|
|
|
- .sorted(Comparator.comparing(PhysicalVal::getValue).reversed()
|
|
|
|
- .thenComparing(PhysicalVal::getOrderNo))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- return collect;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public Boolean addEvaluator(AddEvaluatorVO addDeptInfoVO) {
|
|
|
|
- //参数验证
|
|
|
|
- if (!RegexValidateUtil.checkMobileNumber(addDeptInfoVO.getPhone())) {
|
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_ERROR,
|
|
|
|
- "请输入正确的手机号");
|
|
|
|
- }
|
|
|
|
- if (null == SexEnum.getName(addDeptInfoVO.getSex())) {
|
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_ERROR,
|
|
|
|
- "请输入正确的性别类型");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Evaluator evaluator = new Evaluator();
|
|
|
|
- BeanUtil.copyProperties(addDeptInfoVO, evaluator);
|
|
|
|
- //计算
|
|
|
|
- this.cal(evaluator);
|
|
|
|
-
|
|
|
|
- //保存结果
|
|
|
|
- Date now = DateUtil.now();
|
|
|
|
- evaluator.setIsDeleted(IsDeleteEnum.N.getKey());
|
|
|
|
- evaluator.setGmtCreate(now);
|
|
|
|
- evaluator.setGmtModified(now);
|
|
|
|
- Boolean res = this.save(evaluator);
|
|
|
|
- if (!res) {
|
|
|
|
- throw new CommonException(CommonErrorCode.INSERT_DATA_FAILED, "评估结果提交失败!");
|
|
|
|
- }
|
|
|
|
- return res;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public IPage<SearchEvaluatorDTO> getEvaluatorPage(SearchEvaluatorVO searchEvaluatorVO) {
|
|
|
|
- IPage<SearchEvaluatorDTO> res = this.getEvaluators(searchEvaluatorVO);
|
|
|
|
- if (ListUtil.isNotEmpty(res.getRecords())) {
|
|
|
|
- Map<String, PhysicalInfo> pMap = physicalInfoFacade.getPhysicalMap();
|
|
|
|
-
|
|
|
|
- for (SearchEvaluatorDTO searchEvaluatorDTO : res.getRecords()) {
|
|
|
|
- String[] physicalTypes = searchEvaluatorDTO.getPhysicalTypes().split(",");
|
|
|
|
- List<PhysicalInfoDTO> physicalInfoDTOList = ListUtil.newArrayList();
|
|
|
|
- for (String s : physicalTypes) {
|
|
|
|
- PhysicalInfoDTO physicalInfoDTO = new PhysicalInfoDTO();
|
|
|
|
- if (null != pMap.get(s)) {
|
|
|
|
- BeanUtil.copyProperties(pMap.get(s), physicalInfoDTO);
|
|
|
|
- physicalInfoDTOList.add(physicalInfoDTO);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- searchEvaluatorDTO.setPhysicalInfoDTOList(physicalInfoDTOList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return res;
|
|
|
|
- }
|
|
|
|
-}
|
|
|