Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
cab38d8e16
|
@ -0,0 +1,51 @@
|
|||
package org.dromara.scale.constant;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 应用模块名称<p>
|
||||
*
|
||||
* @description: Copyright: Copyright (C) 2019 XXX, Inc. All rights reserved. <p>
|
||||
* Company: 江苏恒沁科技有限公司<p>
|
||||
* @author: mhq
|
||||
* @date: 2019/12/03 10:55
|
||||
* @version: 1.0
|
||||
*/
|
||||
public enum ScaleDimensionEnum {
|
||||
/**
|
||||
* 单项单维
|
||||
*/
|
||||
SING_SING(0, "单项单维"),
|
||||
MULTIPE_SINGL(1, "多项单维型"),
|
||||
MULTIPE_MULTIPE(2, "多项多维型"),
|
||||
;
|
||||
|
||||
private Integer status;
|
||||
private String name;
|
||||
|
||||
private ScaleDimensionEnum(Integer status, String name) {
|
||||
this.status = status;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return this.status;
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public static ScaleDimensionEnum getByCode(Integer value) {
|
||||
if (Objects.isNull(value)) {
|
||||
return null;
|
||||
}
|
||||
ScaleDimensionEnum[] ruleFlagEnum = ScaleDimensionEnum.values();
|
||||
for (int i = 0; i < ruleFlagEnum.length; i++){
|
||||
if(ruleFlagEnum[i].getValue().equals(value)){
|
||||
return ruleFlagEnum[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package org.dromara.scale.constant;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 应用模块名称<p>
|
||||
*
|
||||
* @description: Copyright: Copyright (C) 2019 XXX, Inc. All rights reserved. <p>
|
||||
* Company: 江苏恒沁科技有限公司<p>
|
||||
* @author: mhq
|
||||
* @date: 2019/12/03 10:55
|
||||
* @version: 1.0
|
||||
*/
|
||||
public enum ScoreRuleTypeEnum {
|
||||
|
||||
/**
|
||||
* 求和型
|
||||
*/
|
||||
SUM_TYPE(0, "求和型"),
|
||||
AVG_TYPE(1, "均值型"),
|
||||
SUM_INT_TYPE(2, "求和取整型"),
|
||||
;
|
||||
|
||||
private Integer status;
|
||||
private String name;
|
||||
|
||||
private ScoreRuleTypeEnum(Integer status, String name) {
|
||||
this.status = status;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return this.status;
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public static ScoreRuleTypeEnum getByCode(Integer value) {
|
||||
if (Objects.isNull(value)) {
|
||||
return null;
|
||||
}
|
||||
ScoreRuleTypeEnum[] ruleFlagEnum = ScoreRuleTypeEnum.values();
|
||||
for (int i = 0; i < ruleFlagEnum.length; i++){
|
||||
if(ruleFlagEnum[i].getValue().equals(value)){
|
||||
return ruleFlagEnum[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package org.dromara.scale.controller.web;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
|
@ -79,7 +80,9 @@ public class WebController extends BaseController {
|
|||
@RepeatSubmit()
|
||||
@PostMapping("/record/answer")
|
||||
public R<Map<String,Object>> add(@Validated(AddGroup.class) @RequestBody List<SysEvaluationAnswerBo> answerList) {
|
||||
//todo
|
||||
if (ArrayUtil.isEmpty(answerList)) {
|
||||
R.fail("请先填写,再提交");
|
||||
}
|
||||
return R.ok(evaluationConclusionService.submitAnswer(answerList));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,12 @@ public class SysScaleFactorRange extends BaseEntity {
|
|||
private String rangeName;
|
||||
|
||||
/**
|
||||
* 因子所属量表id
|
||||
* 分段所属量表id
|
||||
*/
|
||||
private Long scaleId;
|
||||
|
||||
/**
|
||||
* 分段所属因子id
|
||||
*/
|
||||
private Long factorId;
|
||||
|
||||
|
|
|
@ -68,5 +68,20 @@ public class SysEvaluationConclusionVo implements Serializable {
|
|||
@ExcelProperty(value = "0:未命中,1:命中,若命中则,测评人符合该测评项,未命中则测评人不符合测评项")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 问题描述
|
||||
*/
|
||||
private String evalDesc;
|
||||
|
||||
/**
|
||||
* 问题建议
|
||||
*/
|
||||
private String evalPropose;
|
||||
|
||||
/**
|
||||
* 风险等级
|
||||
*/
|
||||
private Long situation;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
package org.dromara.scale.domain.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.dromara.scale.domain.SysScaleFactorRange;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.scale.domain.SysScaleFactorRange;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -42,9 +38,15 @@ public class SysScaleFactorRangeVo implements Serializable {
|
|||
private String rangeName;
|
||||
|
||||
/**
|
||||
* 因子所属量表id
|
||||
* 分段所属量表id
|
||||
*/
|
||||
@ExcelProperty(value = "因子所属量表id")
|
||||
@ExcelProperty(value = "分段所属量表id")
|
||||
private Long scaleId;
|
||||
|
||||
/**
|
||||
* 分段所属因子id
|
||||
*/
|
||||
@ExcelProperty(value = "分段所属因子id")
|
||||
private Long factorId;
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
|||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.scale.domain.SysScaleFactor;
|
||||
import org.dromara.scale.domain.SysScaleFactorRange;
|
||||
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
@ -67,5 +65,6 @@ public class SysScaleFactorVo implements Serializable {
|
|||
*/
|
||||
private List<Long> questionIds;
|
||||
|
||||
private List<SysScaleFactorRange> factorRangeList;
|
||||
|
||||
private List<SysScaleFactorRangeVo> factorRangeList;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
package org.dromara.scale.domain.vo;
|
||||
|
||||
import org.dromara.scale.domain.SysScaleAnswer;
|
||||
import org.dromara.scale.domain.SysScaleQuestion;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.scale.domain.SysScaleQuestion;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
@ -74,5 +70,5 @@ public class SysScaleQuestionVo implements Serializable {
|
|||
/**
|
||||
* 问题答案列表
|
||||
*/
|
||||
private List<SysScaleAnswer> scaleAnswerList;
|
||||
private List<SysScaleAnswerVo> scaleAnswerList;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Param;
|
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.scale.domain.SysEvaluationRecord;
|
||||
import org.dromara.scale.domain.vo.SysEvaluationRecordVo;
|
||||
import org.dromara.scale.domain.vo.SysScalePublishVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -19,4 +20,6 @@ public interface SysEvaluationRecordMapper extends BaseMapperPlus<SysEvaluationR
|
|||
|
||||
List<SysEvaluationRecordVo> selectSclaeRecordListByUserAndBatch(@Param("userId") Long userId, @Param("batchNo") Long batchNo);
|
||||
|
||||
SysScalePublishVo selectPublishByUseRecord(Long recordId);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,22 +1,29 @@
|
|||
package org.dromara.scale.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.scale.domain.SysEvaluationConclusion;
|
||||
import org.dromara.scale.constant.ScaleDimensionEnum;
|
||||
import org.dromara.scale.constant.ScoreRuleTypeEnum;
|
||||
import org.dromara.scale.domain.*;
|
||||
import org.dromara.scale.domain.bo.SysEvaluationAnswerBo;
|
||||
import org.dromara.scale.domain.bo.SysEvaluationConclusionBo;
|
||||
import org.dromara.scale.domain.vo.SysEvaluationConclusionVo;
|
||||
import org.dromara.scale.mapper.SysEvaluationAnswerMapper;
|
||||
import org.dromara.scale.mapper.SysEvaluationConclusionMapper;
|
||||
import org.dromara.scale.domain.vo.*;
|
||||
import org.dromara.scale.mapper.*;
|
||||
import org.dromara.scale.service.ISysEvaluationConclusionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 量测结果Service业务层处理
|
||||
|
@ -28,9 +35,24 @@ import java.util.Map;
|
|||
@Service
|
||||
public class SysEvaluationConclusionServiceImpl implements ISysEvaluationConclusionService {
|
||||
|
||||
private static final MathContext mathContext = new MathContext(2);
|
||||
|
||||
private final SysEvaluationConclusionMapper baseMapper;
|
||||
|
||||
private final SysEvaluationAnswerMapper answerMapper;
|
||||
private final SysScaleMapper scaleMapper;
|
||||
|
||||
private final SysEvaluationAnswerMapper evaluationAnswerMapper;
|
||||
|
||||
private final SysEvaluationRecordMapper recordMapper;
|
||||
|
||||
private final SysScaleQuestionMapper scaleQuestionMapper;
|
||||
|
||||
private final SysScaleAnswerMapper scaleAnswerMapper;
|
||||
|
||||
private final SysScaleFactorMapper scaleFactorMapper;
|
||||
|
||||
private final SysScaleFactorRangeMapper scaleFactorRangeMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 查询量测结果
|
||||
|
@ -80,14 +102,241 @@ public class SysEvaluationConclusionServiceImpl implements ISysEvaluationConclus
|
|||
|
||||
@Override
|
||||
public Map<String, Object> submitAnswer(List<SysEvaluationAnswerBo> answerList) {
|
||||
boolean allowQueryResult = true;
|
||||
Long recordId = answerList.get(0).getRecordId();
|
||||
SysScalePublishVo scalePublishVo = recordMapper.selectPublishByUseRecord(recordId);
|
||||
//查询考核结果
|
||||
if (scalePublishVo.getAllowQueryResult() == 0) {
|
||||
allowQueryResult = false;
|
||||
}
|
||||
List<SysEvaluationAnswer> answerAdd = MapstructUtils.convert(answerList, SysEvaluationAnswer.class);
|
||||
evaluationAnswerMapper.insertBatch(answerAdd);
|
||||
|
||||
//answerMapper.insertBatch();
|
||||
return null;
|
||||
List<SysEvaluationConclusionVo> list = calculateEvaluationResult(answerList);
|
||||
List<SysEvaluationConclusion> conclusionAdd = MapstructUtils.convert(list, SysEvaluationConclusion.class);
|
||||
baseMapper.insertBatch(conclusionAdd);
|
||||
|
||||
Long riskLevel = -1L;
|
||||
String riskName = "";
|
||||
//选择风险等级最高
|
||||
for(SysEvaluationConclusionVo ec: list){
|
||||
if(ec.getSituation() > riskLevel){
|
||||
riskLevel = ec.getSituation();
|
||||
//riskName = ec.getSituationName();
|
||||
}
|
||||
}
|
||||
//判断风险等级是否为"高风险、重大风险",若是,则形成预警记录
|
||||
// if(riskName.equals("高风险") || riskName.equals("重大风险")){
|
||||
// WarnRecordEval wre = new WarnRecordEval();
|
||||
// wre.setId(idWorker.nextId());
|
||||
// wre.setErId(evalRecord.getId());
|
||||
// wre.setRiskLevel(riskName);
|
||||
// wre.setUserId(evalRecord.getEvalUid());
|
||||
// wre.setScaleId(evalRecord.getScaleId());
|
||||
// wre.setTenantNo(sysUser.getTenantNo());
|
||||
// warnRecordDAO.evalWarn(wre);
|
||||
// }
|
||||
//不允许查看考核结果
|
||||
if(!allowQueryResult){
|
||||
return null;
|
||||
}
|
||||
|
||||
BigDecimal totalScore = list.stream()
|
||||
// 将Opportunity对象的金额属性取出
|
||||
.map(SysEvaluationConclusionVo::getScore)
|
||||
// 使用reduce()聚合函数,得到金额总和
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
return new HashMap<String,Object>(){{
|
||||
//put("evalRecordId",evalRecord.getId());
|
||||
//put("scaleName",scaleInfo.getName());
|
||||
put("totalScore",totalScore.doubleValue());
|
||||
put("list", list.stream().filter(item -> item.getStatus().equals(1)).collect(
|
||||
Collectors.toList()));
|
||||
}};
|
||||
}
|
||||
|
||||
private List<SysEvaluationConclusion> calculateEvaluationResult() {
|
||||
boolean allowQueryResult = true;
|
||||
private List<SysEvaluationConclusionVo> calculateEvaluationResult(List<SysEvaluationAnswerBo> answerList) {
|
||||
Long recordId = answerList.get(0).getRecordId();
|
||||
SysEvaluationRecordVo recordVo = recordMapper.selectVoById(recordId);
|
||||
Long scaleId = recordVo.getScaleId();
|
||||
|
||||
return null;
|
||||
List<SysScaleQuestionVo> sysScaleQuestionVos = scaleQuestionMapper.selectVoList(
|
||||
new LambdaQueryWrapper<SysScaleQuestion>().eq(SysScaleQuestion::getScaleId, 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<SysEvaluationConclusionVo> list = new ArrayList<>(scaleFactorList.size());
|
||||
for (SysScaleFactorVo scaleFactor : scaleFactorList) {
|
||||
Long factorId = scaleFactor.getFactorId();
|
||||
AtomicReference<BigDecimal> totalSocre = new AtomicReference<>(BigDecimal.ZERO);
|
||||
|
||||
SysEvaluationConclusionVo evalConclusion = new SysEvaluationConclusionVo();
|
||||
evalConclusion.setFactorId(factorId);
|
||||
evalConclusion.setRecordId(recordId);
|
||||
//未命中
|
||||
evalConclusion.setStatus(0);
|
||||
list.add(evalConclusion);
|
||||
|
||||
List<SysScaleQuestionVo> questionNum = questionMapByFactor.get(factorId);
|
||||
List<Long> questionIds = new ArrayList<>();
|
||||
questionNum.forEach(q -> {
|
||||
Long questionId = q.getQuestionId();
|
||||
questionIds.add(questionId);
|
||||
List<SysScaleAnswerVo> answerNum = answerMapByQuestion.get(questionId);
|
||||
if (!ArrayUtil.isEmpty(answerNum)) {
|
||||
//找出分数最大的选项
|
||||
BigDecimal s = answerNum.stream()
|
||||
.max(Comparator.comparing(SysScaleAnswerVo::getScore)).get().getScore();
|
||||
totalSocre.updateAndGet(v -> v.add(s));
|
||||
SysEvaluationAnswerBo evaluationAnswer = answerList.stream()
|
||||
.filter(answer -> questionId.equals(answer.getQuestionId())).findFirst().orElse(null);
|
||||
if (evaluationAnswer != null) {
|
||||
answerNum.stream().filter(o -> o.getAnswerId().equals(evaluationAnswer.getAnswerId())).findFirst()
|
||||
.ifPresent(
|
||||
m -> evalConclusion.setScore(m.getScore().add(evalConclusion.getScore())));
|
||||
}
|
||||
}
|
||||
});
|
||||
scaleFactor.setQuestionIds(questionIds);
|
||||
//计算得分率
|
||||
|
||||
if (totalSocre.get().compareTo(BigDecimal.ZERO) > 0) {
|
||||
evalConclusion.setScoreRate(evalConclusion.getScore()
|
||||
.multiply(new BigDecimal(100)).divide(totalSocre.get()).setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
//计算量表加强后得分
|
||||
calcScoreByRuleType(evalConclusion, scaleFactor);
|
||||
//根据将强后的分数划分到对应的范围上
|
||||
//根据将强后的分数划分到对应的范围上
|
||||
List<SysScaleFactorRangeVo> factorRangeList = scaleFactor.getFactorRangeList();
|
||||
if (factorRangeList.size() == 1) {
|
||||
evalConclusion.setEvalDesc(factorRangeList.get(0).getEvalDesc());
|
||||
evalConclusion.setEvalPropose(factorRangeList.get(0).getEvalPropose());
|
||||
evalConclusion.setFactorRangeId(factorRangeList.get(0).getRangeId());
|
||||
} else {
|
||||
for (SysScaleFactorRangeVo range : factorRangeList) {
|
||||
if (Objects.nonNull(range.getMinValue()) && Objects.nonNull(range.getMaxValue())) {
|
||||
if (evalConclusion.getScore().compareTo(range.getMinValue()) >= 0
|
||||
&& evalConclusion.getScore().compareTo(range.getMaxValue()) <= 0) {
|
||||
evalConclusion.setEvalDesc(range.getEvalDesc());
|
||||
evalConclusion.setEvalPropose(range.getEvalPropose());
|
||||
evalConclusion.setFactorRangeId(range.getRangeId());
|
||||
evalConclusion.setSituation(range.getSituation());
|
||||
//evalConclusion.setSituationName(range.getSituationName());
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
//最大值不是空,最小值是空
|
||||
if (Objects.nonNull(range.getMaxValue()) && Objects.isNull(range.getMinValue())) {
|
||||
if (evalConclusion.getScore().compareTo(range.getMaxValue()) <= 0) {
|
||||
evalConclusion.setEvalDesc(range.getEvalDesc());
|
||||
evalConclusion.setEvalPropose(range.getEvalPropose());
|
||||
evalConclusion.setFactorRangeId(range.getRangeId());
|
||||
evalConclusion.setSituation(range.getSituation());
|
||||
//evalConclusion.setSituationName(range.getSituationName());
|
||||
break;
|
||||
}
|
||||
} else if (Objects.nonNull(range.getMinValue()) && Objects.isNull(range.getMaxValue())) {
|
||||
//最大值为空,最小值不为空
|
||||
if (evalConclusion.getScore().compareTo(range.getMinValue()) >= 0) {
|
||||
evalConclusion.setEvalDesc(range.getEvalDesc());
|
||||
evalConclusion.setEvalPropose(range.getEvalPropose());
|
||||
evalConclusion.setFactorRangeId(range.getRangeId());
|
||||
evalConclusion.setSituation(range.getSituation());
|
||||
//evalConclusion.setSituationName(range.getSituationName());
|
||||
break;
|
||||
}
|
||||
} //else {
|
||||
// logger.error("量表scaleId = {},配置项={} 配置的范围超过1条,但是存在配置范围最大最小值都为null",
|
||||
// evalSubmitAnswerDto.getScaleId(), scaleEvalItem.getId());
|
||||
// throw new EdfRuntimeException("量表配置项有问题,请联系管理员检查!");
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//处理维度问题及status
|
||||
//量表
|
||||
SysScale scaleInfo = scaleMapper.selectById(scaleId);
|
||||
scaleDimension(list, scaleInfo);
|
||||
//保存结果
|
||||
return list;
|
||||
}
|
||||
|
||||
List<SysScaleFactorVo> getScaleEvalItemList(Long scaleId) {
|
||||
List<SysScaleFactorVo> scaleFactorVos = scaleFactorMapper.selectVoList(
|
||||
new LambdaQueryWrapper<SysScaleFactor>().eq(SysScaleFactor::getScaleId, scaleId));
|
||||
List<SysScaleFactorRangeVo> scaleFactorRangeVos = scaleFactorRangeMapper.selectVoList(
|
||||
new LambdaQueryWrapper<SysScaleFactorRange>().eq(SysScaleFactorRange::getScaleId, scaleId));
|
||||
if (!ArrayUtil.isEmpty(scaleFactorVos) && !ArrayUtil.isEmpty(scaleFactorRangeVos)) {
|
||||
Map<Long, List<SysScaleFactorRangeVo>> map = scaleFactorRangeVos.stream()
|
||||
.collect(Collectors.groupingBy(SysScaleFactorRangeVo::getFactorId));
|
||||
scaleFactorVos.forEach(item ->
|
||||
item.setFactorRangeList(map.get(item.getFactorId())));
|
||||
}
|
||||
return scaleFactorVos;
|
||||
}
|
||||
|
||||
private void calcScoreByRuleType(SysEvaluationConclusionVo evalConclusion, SysScaleFactorVo scaleFactor) {
|
||||
ScoreRuleTypeEnum scoleRuleTypeEnum = ScoreRuleTypeEnum.getByCode(scaleFactor.getRuleType());
|
||||
if (Objects.isNull(scoleRuleTypeEnum)) {
|
||||
return;
|
||||
}
|
||||
switch (scoleRuleTypeEnum) {
|
||||
case SUM_TYPE:
|
||||
evalConclusion.setScore(evalConclusion.getScore().multiply(scaleFactor.getWeight(), mathContext));
|
||||
break;
|
||||
case AVG_TYPE:
|
||||
BigDecimal sum = evalConclusion.getScore().multiply(scaleFactor.getWeight(), mathContext);
|
||||
int size = scaleFactor.getQuestionIds().size();
|
||||
//均值四舍五入2位小数
|
||||
BigDecimal avgScore = sum.divide(new BigDecimal(size), 2, RoundingMode.HALF_UP);
|
||||
evalConclusion.setScore(avgScore);
|
||||
break;
|
||||
case SUM_INT_TYPE:
|
||||
BigDecimal sum2 = evalConclusion.getScore().multiply(scaleFactor.getWeight(), mathContext);
|
||||
evalConclusion.setScore(sum2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void scaleDimension(List<SysEvaluationConclusionVo> evalConclusions, SysScale scaleInfo) {
|
||||
ScaleDimensionEnum scaleDimensionEnum = ScaleDimensionEnum.getByCode(scaleInfo.getDimensionType());
|
||||
if (Objects.isNull(scaleDimensionEnum)) {
|
||||
//throw new EdfRuntimeException("暂不支持该维度");
|
||||
return;
|
||||
}
|
||||
switch (scaleDimensionEnum) {
|
||||
case SING_SING:
|
||||
if (evalConclusions.size() > 1) {
|
||||
//log.error("{} - 量表维度配置有误,单项单维量表配置了多个维度",scaleInfo.getName());
|
||||
//throw new EdfRuntimeException(String.format("%s 量表配置有误!,请联系管理员!",scaleInfo.getName()));
|
||||
break;
|
||||
}
|
||||
evalConclusions.forEach(item -> item.setStatus(1));
|
||||
break;
|
||||
case MULTIPE_SINGL:
|
||||
//择低录取
|
||||
if (scaleInfo.getSelectDirection() == 1) {
|
||||
evalConclusions.stream().min(Comparator.comparing(SysEvaluationConclusionVo::getScore)).get().setStatus(1);
|
||||
} else {
|
||||
//高分录取
|
||||
evalConclusions.stream().max(Comparator.comparing(SysEvaluationConclusionVo::getScore)).get().setStatus(1);
|
||||
}
|
||||
break;
|
||||
case MULTIPE_MULTIPE:
|
||||
evalConclusions.forEach(item -> item.setStatus(1));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.dromara.scale.domain.SysScaleFactor;
|
|||
import org.dromara.scale.domain.SysScaleFactorRange;
|
||||
import org.dromara.scale.domain.SysScaleQuestion;
|
||||
import org.dromara.scale.domain.bo.SysScaleFactorBo;
|
||||
import org.dromara.scale.domain.vo.SysScaleFactorRangeVo;
|
||||
import org.dromara.scale.domain.vo.SysScaleFactorVo;
|
||||
import org.dromara.scale.domain.vo.SysScaleQuestionVo;
|
||||
import org.dromara.scale.mapper.*;
|
||||
|
@ -54,7 +55,7 @@ public class SysScaleFactorServiceImpl implements ISysScaleFactorService {
|
|||
sysScaleFactorVo.setQuestionIds(Collections.emptyList());
|
||||
}
|
||||
|
||||
List<SysScaleFactorRange> rangeList = sysScaleFactorRangeMapper.selectList(Wrappers.<SysScaleFactorRange>lambdaQuery().eq(SysScaleFactorRange::getFactorId, factorId));
|
||||
List<SysScaleFactorRangeVo> rangeList = sysScaleFactorRangeMapper.selectVoList(Wrappers.<SysScaleFactorRange>lambdaQuery().eq(SysScaleFactorRange::getFactorId, factorId));
|
||||
if (CollUtil.isNotEmpty(rangeList)) {
|
||||
sysScaleFactorVo.setFactorRangeList(rangeList);
|
||||
} else {
|
||||
|
@ -125,6 +126,7 @@ public class SysScaleFactorServiceImpl implements ISysScaleFactorService {
|
|||
List<SysScaleFactorRange> list = new ArrayList<>(bo.getFactorRangeList().size());
|
||||
for (SysScaleFactorRange range : bo.getFactorRangeList()) {
|
||||
range.setFactorId(bo.getFactorId());
|
||||
range.setScaleId(bo.getScaleId());
|
||||
list.add(range);
|
||||
}
|
||||
sysScaleFactorRangeMapper.insertBatch(list, 100);
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|||
import org.dromara.scale.domain.SysScaleAnswer;
|
||||
import org.dromara.scale.domain.SysScaleQuestion;
|
||||
import org.dromara.scale.domain.bo.SysScaleQuestionBo;
|
||||
import org.dromara.scale.domain.vo.SysScaleAnswerVo;
|
||||
import org.dromara.scale.domain.vo.SysScaleQuestionVo;
|
||||
import org.dromara.scale.mapper.SysScaleAnswerMapper;
|
||||
import org.dromara.scale.mapper.SysScaleQuestionMapper;
|
||||
|
@ -46,7 +47,7 @@ public class SysScaleQuestionServiceImpl implements ISysScaleQuestionService {
|
|||
@Override
|
||||
public SysScaleQuestionVo queryById(Long questionId) {
|
||||
SysScaleQuestionVo sysScaleQuestionVo = baseMapper.selectVoById(questionId);
|
||||
List<SysScaleAnswer> sysScaleAnswers = scaleAnswerMapper.selectList(Wrappers.lambdaQuery(SysScaleAnswer.class).eq(SysScaleAnswer::getQuestionId, questionId));
|
||||
List<SysScaleAnswerVo> sysScaleAnswers = scaleAnswerMapper.selectVoList(Wrappers.lambdaQuery(SysScaleAnswer.class).eq(SysScaleAnswer::getQuestionId, questionId));
|
||||
if (CollUtil.isNotEmpty(sysScaleAnswers)) {
|
||||
sysScaleQuestionVo.setScaleAnswerList(sysScaleAnswers);
|
||||
}
|
||||
|
|
|
@ -10,4 +10,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where user_id = #{userId}
|
||||
and batch_no = #{batchNo}
|
||||
</select>
|
||||
|
||||
<select id="selectPublishByUseRecord" resultType="org.dromara.scale.domain.vo.SysScalePublishVo">
|
||||
select sp.batch_no ,allow_query_result
|
||||
from sys_evaluation_record er
|
||||
left join sys_scale_publish sp on er.batch_no = sp.batch_no
|
||||
where er.record_id = #{recordId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue