添加缓存
This commit is contained in:
parent
102f9434b6
commit
66eed711ac
|
@ -66,4 +66,9 @@ public interface CacheNames {
|
||||||
String ONLINE_TOKEN = "online_tokens";
|
String ONLINE_TOKEN = "online_tokens";
|
||||||
String SYS_QUESTION_ANSWER = "scale:question_answer";
|
String SYS_QUESTION_ANSWER = "scale:question_answer";
|
||||||
|
|
||||||
|
String SYS_SCALE_FACTOR = "scale:factor";
|
||||||
|
|
||||||
|
String MAP_SCALE_QUESTION = "scale:map:question";
|
||||||
|
String MAP_SCALE_ANSWER = "scale:map:answer";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.dromara.scale.constant;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
|
||||||
|
public enum StatusEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
DISABLED(0, "停用"),
|
||||||
|
IN_USE(1, "启用");
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
StatusEnum(Integer status, String name) {
|
||||||
|
this.status = status;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getValue() {
|
||||||
|
return this.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
|
@ -62,7 +62,6 @@ public class WebController extends BaseController {
|
||||||
return R.ok(scaleAnswerService.queryQuestionAnswerListByScaleId(id));
|
return R.ok(scaleAnswerService.queryQuestionAnswerListByScaleId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增量测记录
|
* 新增量测记录
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,11 +32,6 @@ public class SysScaleQuestion extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private Long scaleId;
|
private Long scaleId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 测评量表标题
|
|
||||||
*/
|
|
||||||
private String scaleTitle;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 问题序号
|
* 问题序号
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,17 +5,20 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.dromara.common.core.constant.CacheNames;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.scale.constant.ScaleDimensionEnum;
|
import org.dromara.scale.constant.ScaleDimensionEnum;
|
||||||
import org.dromara.scale.constant.ScoreRuleTypeEnum;
|
import org.dromara.scale.constant.ScoreRuleTypeEnum;
|
||||||
|
import org.dromara.scale.constant.StatusEnum;
|
||||||
import org.dromara.scale.domain.*;
|
import org.dromara.scale.domain.*;
|
||||||
import org.dromara.scale.domain.bo.SysEvaluationAnswerBo;
|
import org.dromara.scale.domain.bo.SysEvaluationAnswerBo;
|
||||||
import org.dromara.scale.domain.bo.SysEvaluationConclusionBo;
|
import org.dromara.scale.domain.bo.SysEvaluationConclusionBo;
|
||||||
import org.dromara.scale.domain.vo.*;
|
import org.dromara.scale.domain.vo.*;
|
||||||
import org.dromara.scale.mapper.*;
|
import org.dromara.scale.mapper.*;
|
||||||
import org.dromara.scale.service.ISysEvaluationConclusionService;
|
import org.dromara.scale.service.ISysEvaluationConclusionService;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -150,7 +153,7 @@ public class SysEvaluationConclusionServiceImpl implements ISysEvaluationConclus
|
||||||
//put("evalRecordId",evalRecord.getId());
|
//put("evalRecordId",evalRecord.getId());
|
||||||
//put("scaleName",scaleInfo.getName());
|
//put("scaleName",scaleInfo.getName());
|
||||||
put("totalScore", totalScore.doubleValue());
|
put("totalScore", totalScore.doubleValue());
|
||||||
put("list", list.stream().filter(item -> item.getStatus().equals(1)).collect(
|
put("list", list.stream().filter(item -> item.getStatus().equals(StatusEnum.IN_USE.getValue())).collect(
|
||||||
Collectors.toList()));
|
Collectors.toList()));
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
@ -160,15 +163,8 @@ public class SysEvaluationConclusionServiceImpl implements ISysEvaluationConclus
|
||||||
SysEvaluationRecordVo recordVo = recordMapper.selectVoById(recordId);
|
SysEvaluationRecordVo recordVo = recordMapper.selectVoById(recordId);
|
||||||
Long scaleId = recordVo.getScaleId();
|
Long scaleId = recordVo.getScaleId();
|
||||||
|
|
||||||
List<SysScaleQuestionVo> sysScaleQuestionVos = scaleQuestionMapper.selectVoList(
|
Map<Long, List<SysScaleQuestionVo>> questionMapByFactor = getScaleQuestionMap(scaleId);
|
||||||
new LambdaQueryWrapper<SysScaleQuestion>().eq(SysScaleQuestion::getScaleId, scaleId));
|
Map<Long, List<SysScaleAnswerVo>> answerMapByQuestion = getScaleAnswerMap(scaleId);
|
||||||
Map<Long, List<SysScaleQuestionVo>> questionMapByFactor = sysScaleQuestionVos.stream()
|
|
||||||
.collect(Collectors.groupingBy(SysScaleQuestionVo::getFactorId));
|
|
||||||
|
|
||||||
List<SysScaleAnswerVo> scaleAnswerVos = scaleAnswerMapper.selectVoList(
|
|
||||||
new LambdaQueryWrapper<SysScaleAnswer>().eq(SysScaleAnswer::getScaleId, scaleId));
|
|
||||||
Map<Long, List<SysScaleAnswerVo>> answerMapByQuestion = scaleAnswerVos.stream()
|
|
||||||
.collect(Collectors.groupingBy(SysScaleAnswerVo::getQuestionId));
|
|
||||||
|
|
||||||
List<SysScaleFactorVo> scaleFactorList = getScaleEvalItemList(scaleId);
|
List<SysScaleFactorVo> scaleFactorList = getScaleEvalItemList(scaleId);
|
||||||
List<SysEvaluationConclusionVo> list = new ArrayList<>(scaleFactorList.size());
|
List<SysEvaluationConclusionVo> list = new ArrayList<>(scaleFactorList.size());
|
||||||
|
@ -179,8 +175,7 @@ public class SysEvaluationConclusionServiceImpl implements ISysEvaluationConclus
|
||||||
SysEvaluationConclusionVo evalConclusion = new SysEvaluationConclusionVo();
|
SysEvaluationConclusionVo evalConclusion = new SysEvaluationConclusionVo();
|
||||||
evalConclusion.setFactorId(factorId);
|
evalConclusion.setFactorId(factorId);
|
||||||
evalConclusion.setRecordId(recordId);
|
evalConclusion.setRecordId(recordId);
|
||||||
//未命中
|
evalConclusion.setStatus(StatusEnum.DISABLED.getValue());
|
||||||
evalConclusion.setStatus(0);
|
|
||||||
list.add(evalConclusion);
|
list.add(evalConclusion);
|
||||||
|
|
||||||
List<SysScaleQuestionVo> questionNum = questionMapByFactor.get(factorId);
|
List<SysScaleQuestionVo> questionNum = questionMapByFactor.get(factorId);
|
||||||
|
@ -268,8 +263,20 @@ public class SysEvaluationConclusionServiceImpl implements ISysEvaluationConclus
|
||||||
//保存结果
|
//保存结果
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@Cacheable(cacheNames = CacheNames.MAP_SCALE_QUESTION, key = "#scaleId")
|
||||||
List<SysScaleFactorVo> getScaleEvalItemList(Long scaleId) {
|
public Map<Long, List<SysScaleQuestionVo>> getScaleQuestionMap(Long scaleId) {
|
||||||
|
List<SysScaleQuestionVo> scaleQuestionVos = scaleQuestionMapper.selectVoList(
|
||||||
|
new LambdaQueryWrapper<SysScaleQuestion>().eq(SysScaleQuestion::getScaleId, scaleId));
|
||||||
|
return scaleQuestionVos.stream().collect(Collectors.groupingBy(SysScaleQuestionVo::getFactorId));
|
||||||
|
}
|
||||||
|
@Cacheable(cacheNames = CacheNames.MAP_SCALE_ANSWER, key = "#scaleId")
|
||||||
|
public Map<Long, List<SysScaleAnswerVo>> getScaleAnswerMap(Long scaleId) {
|
||||||
|
List<SysScaleAnswerVo> scaleAnswerVos = scaleAnswerMapper.selectVoList(
|
||||||
|
new LambdaQueryWrapper<SysScaleAnswer>().eq(SysScaleAnswer::getScaleId, scaleId));
|
||||||
|
return scaleAnswerVos.stream().collect(Collectors.groupingBy(SysScaleAnswerVo::getQuestionId));
|
||||||
|
}
|
||||||
|
@Cacheable(cacheNames = CacheNames.SYS_SCALE_FACTOR, key = "#scaleId")
|
||||||
|
public List<SysScaleFactorVo> getScaleEvalItemList(Long scaleId) {
|
||||||
List<SysScaleFactorVo> scaleFactorVos = scaleFactorMapper.selectVoList(
|
List<SysScaleFactorVo> scaleFactorVos = scaleFactorMapper.selectVoList(
|
||||||
new LambdaQueryWrapper<SysScaleFactor>().eq(SysScaleFactor::getScaleId, scaleId));
|
new LambdaQueryWrapper<SysScaleFactor>().eq(SysScaleFactor::getScaleId, scaleId));
|
||||||
List<SysScaleFactorRangeVo> scaleFactorRangeVos = scaleFactorRangeMapper.selectVoList(
|
List<SysScaleFactorRangeVo> scaleFactorRangeVos = scaleFactorRangeMapper.selectVoList(
|
||||||
|
@ -321,15 +328,15 @@ public class SysEvaluationConclusionServiceImpl implements ISysEvaluationConclus
|
||||||
//throw new EdfRuntimeException(String.format("%s 量表配置有误!,请联系管理员!",scaleInfo.getName()));
|
//throw new EdfRuntimeException(String.format("%s 量表配置有误!,请联系管理员!",scaleInfo.getName()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
evalConclusions.forEach(item -> item.setStatus(1));
|
evalConclusions.forEach(item -> item.setStatus(StatusEnum.IN_USE.getValue()));
|
||||||
break;
|
break;
|
||||||
case MULTIPE_SINGL:
|
case MULTIPE_SINGL:
|
||||||
//择低录取
|
//择低录取
|
||||||
if (scaleInfo.getSelectDirection() == 1) {
|
if (scaleInfo.getSelectDirection() == 1) {
|
||||||
evalConclusions.stream().min(Comparator.comparing(SysEvaluationConclusionVo::getScore)).get().setStatus(1);
|
evalConclusions.stream().min(Comparator.comparing(SysEvaluationConclusionVo::getScore)).get().setStatus(StatusEnum.IN_USE.getValue());
|
||||||
} else {
|
} else {
|
||||||
//高分录取
|
//高分录取
|
||||||
evalConclusions.stream().max(Comparator.comparing(SysEvaluationConclusionVo::getScore)).get().setStatus(1);
|
evalConclusions.stream().max(Comparator.comparing(SysEvaluationConclusionVo::getScore)).get().setStatus(StatusEnum.IN_USE.getValue());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MULTIPE_MULTIPE:
|
case MULTIPE_MULTIPE:
|
||||||
|
|
|
@ -77,7 +77,6 @@ public class SysScaleQuestionServiceImpl implements ISysScaleQuestionService {
|
||||||
Map<String, Object> params = bo.getParams();
|
Map<String, Object> params = bo.getParams();
|
||||||
LambdaQueryWrapper<SysScaleQuestion> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<SysScaleQuestion> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(bo.getScaleId() != null, SysScaleQuestion::getScaleId, bo.getScaleId());
|
lqw.eq(bo.getScaleId() != null, SysScaleQuestion::getScaleId, bo.getScaleId());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getScaleTitle()), SysScaleQuestion::getScaleTitle, bo.getScaleTitle());
|
|
||||||
lqw.eq(bo.getQuestionOrder() != null, SysScaleQuestion::getQuestionOrder, bo.getQuestionOrder());
|
lqw.eq(bo.getQuestionOrder() != null, SysScaleQuestion::getQuestionOrder, bo.getQuestionOrder());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getQuestionContent()), SysScaleQuestion::getQuestionContent, bo.getQuestionContent());
|
lqw.eq(StringUtils.isNotBlank(bo.getQuestionContent()), SysScaleQuestion::getQuestionContent, bo.getQuestionContent());
|
||||||
// lqw.eq(bo.getFactorId() != null, SysScaleQuestion::getFactorId, bo.getFactorId());
|
// lqw.eq(bo.getFactorId() != null, SysScaleQuestion::getFactorId, bo.getFactorId());
|
||||||
|
|
Loading…
Reference in New Issue