|
|
|
@ -2,7 +2,6 @@ package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
|
import cn.jlw.Exception.GlobalException;
|
|
|
|
|
import cn.jlw.util.BusinessUtils;
|
|
|
|
|
import cn.jlw.util.DateUtil;
|
|
|
|
|
import cn.jlw.util.JsonMergeUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
@ -22,6 +21,7 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static com.ibeetl.jlw.service.ConfigsService.getOrDefaultDecimal;
|
|
|
|
|
|
|
|
|
@ -41,8 +41,6 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ExaminationsService examinationsService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ExaminationFinancialsService examinationFinancialsService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private UsersService usersService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ExaminationInstancesService examinationInstancesService;
|
|
|
|
@ -56,10 +54,6 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取我的成绩业务处理
|
|
|
|
|
*
|
|
|
|
|
* @param users
|
|
|
|
|
* @return java.util.Map<java.lang.String, java.lang.Object>
|
|
|
|
|
* @Date 2022-07-20 11:17
|
|
|
|
|
*/
|
|
|
|
|
public UserExaminations myScores(Users users) {
|
|
|
|
|
UserExaminations userExamination = userExaminationsDao.getUserAndExaminations(users.getId());
|
|
|
|
@ -72,7 +66,6 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
userExamination.set("gt_80", 0);
|
|
|
|
|
userExamination.set("60_80", 0);
|
|
|
|
|
userExamination.set("lt_60", 0);
|
|
|
|
|
|
|
|
|
|
return userExamination;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -87,12 +80,6 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PageQuery<UserExaminations> queryByCondition(PageQuery query) {
|
|
|
|
|
PageQuery ret = userExaminationsDao.queryByCondition(query);
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteUserExaminations(String ids) {
|
|
|
|
|
try {
|
|
|
|
|
userExaminationsDao.deleteUserExaminationsByIds(ids);
|
|
|
|
@ -101,14 +88,6 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<UserExaminations> getValues(Object paras) {
|
|
|
|
|
return sqlManager.select("jlw.userExaminations.getUserExaminationsValues", UserExaminations.class, paras);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<UserExaminations> getValuesByQuery(UserExaminationsQuery userExaminationsQuery) {
|
|
|
|
|
return userExaminationsDao.getValuesByQuery(userExaminationsQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 我的成绩列表业务方法
|
|
|
|
|
*
|
|
|
|
@ -116,7 +95,7 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
* @return java.util.Map<java.lang.String, java.lang.Object>
|
|
|
|
|
* @Date 2022-07-21 18:12
|
|
|
|
|
*/
|
|
|
|
|
public PageQuery scoresListOfStudent(Users users, PageQuery page) {
|
|
|
|
|
public PageQuery<UserExaminations> scoresListOfStudent(Users users, PageQuery page) {
|
|
|
|
|
|
|
|
|
|
PageQuery<UserExaminations> pagequery = userExaminationsDao.scoresListOfStudent(page, users);
|
|
|
|
|
for (int i = 0; i < pagequery.getList().size(); i++) {
|
|
|
|
@ -135,6 +114,9 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
userExaminations.setDurationScores(BusinessUtils.doubleValueJudgment(userExaminations.getDurationScores()));
|
|
|
|
|
userExaminations.setTotalScores(BusinessUtils.doubleValueJudgment(userExaminations.getTotalScores()));
|
|
|
|
|
userExaminations.setClassOrders(BusinessUtils.integerValueJudgment(userExaminations.getClassOrders()));
|
|
|
|
|
if (BigDecimal.ZERO.compareTo(userExaminations.getTotalScores()) == 0) {
|
|
|
|
|
userExaminations.setClassOrders(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Financings financings = new Financings();
|
|
|
|
|
financings.set("init_balance", BusinessUtils.toFixed(userExaminations.get("initBalance"), 2, false));
|
|
|
|
@ -151,158 +133,16 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 学生创建实训/练习实例 个人业务处理方法
|
|
|
|
|
*
|
|
|
|
|
* @param users
|
|
|
|
|
* @param flowId
|
|
|
|
|
* @param examinationId
|
|
|
|
|
* @param isTeam
|
|
|
|
|
* @param teamId
|
|
|
|
|
* @return java.util.Map<java.lang.String, java.lang.Object>
|
|
|
|
|
* @Date 2022-07-22 15:27
|
|
|
|
|
*/
|
|
|
|
|
@Transactional
|
|
|
|
|
public Examinations addUserExamination(Users users, Long flowId, Long examinationId, Integer isTeam, Long teamId) {
|
|
|
|
|
|
|
|
|
|
Flows flows = flowsService.queryById(flowId);
|
|
|
|
|
|
|
|
|
|
Examinations examinations;
|
|
|
|
|
if (flows == null) {
|
|
|
|
|
throw new GlobalException("找不到对应业务流程");
|
|
|
|
|
}
|
|
|
|
|
if (!Objects.isNull(examinationId) && !examinationId.equals(0L)) {
|
|
|
|
|
//实训模式
|
|
|
|
|
examinations = examinationsService.queryById(examinationId);
|
|
|
|
|
if (examinations == null) {
|
|
|
|
|
throw new GlobalException("找不到对应实训");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//练习模式
|
|
|
|
|
examinations = examinationsService.getPracticeModeValue(flowId, isTeam);
|
|
|
|
|
if (examinations == null) {
|
|
|
|
|
examinations = new Examinations();
|
|
|
|
|
examinations.setFlowId(flowId);
|
|
|
|
|
examinations.setMode(isTeam);
|
|
|
|
|
examinations.setType(0);
|
|
|
|
|
examinations.setName(flows.getName() + "-" + (isTeam == 1 ? "团队练习" : "个人练习"));
|
|
|
|
|
examinations.setTeacherId(0L);
|
|
|
|
|
examinations.setStartTime(new Date());
|
|
|
|
|
examinations.setStatus(1);
|
|
|
|
|
examinations.setUserNum(0);
|
|
|
|
|
examinations.setScoresStatus(0);
|
|
|
|
|
examinations.setEndTime(DateUtil.addDays(new Date(), 365 * 10));
|
|
|
|
|
examinationId = examinationsService.insertReturnKey(examinations).getLong();
|
|
|
|
|
examinations.setId(examinationId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据条件查询userExaminations
|
|
|
|
|
UserExaminations userExaminations = userExaminationsDao.getPracticeModeValue(teamId, examinations, users);
|
|
|
|
|
// 如果查询为空,就返回一个新的对象
|
|
|
|
|
if (Objects.isNull(userExaminations)) {
|
|
|
|
|
userExaminations = new UserExaminations();
|
|
|
|
|
userExaminations.setTeamId(teamId);
|
|
|
|
|
userExaminations.setExaminationId(examinations.getId());
|
|
|
|
|
userExaminations.setFlowId(examinations.getFlowId());
|
|
|
|
|
userExaminations.setUserId(users.getId());
|
|
|
|
|
userExaminations.setClassId(users.getClassId());
|
|
|
|
|
userExaminations.setStatus(0);
|
|
|
|
|
userExaminations.setClassOrders(0);
|
|
|
|
|
userExaminations.setTeamOrders(0);
|
|
|
|
|
|
|
|
|
|
if (examinations.getType() == 0) {
|
|
|
|
|
// 同步智云平台的资产信息
|
|
|
|
|
usersService.syncFinancial(users);
|
|
|
|
|
|
|
|
|
|
// 根据条件判断ExaminationFinancials是否存在对应的值
|
|
|
|
|
BigDecimal balance = users.getBalance().add(users.getProductAssets() == null ? BigDecimal.ZERO : users.getProductAssets());
|
|
|
|
|
ExaminationFinancials examinationFinancials = examinationFinancialsService.examinationFinancialByQuery(users.getId(), examinations.getType());
|
|
|
|
|
// 如果为空就保存
|
|
|
|
|
if (Objects.isNull(examinationFinancials)) {
|
|
|
|
|
examinationFinancials = new ExaminationFinancials();
|
|
|
|
|
examinationFinancials.setBalance(balance);
|
|
|
|
|
examinationFinancials.setInitBalance(balance);
|
|
|
|
|
examinationFinancials.setProductAssets(new BigDecimal(0));
|
|
|
|
|
examinationFinancials.setCreatedAt(new Date());
|
|
|
|
|
examinationFinancials.setUserId(users.getId());
|
|
|
|
|
examinationFinancials.setType(examinations.getType());
|
|
|
|
|
KeyHolder keyHolder = examinationFinancialsService.insertReturnKey(examinationFinancials);
|
|
|
|
|
userExaminations.setFinancialId(Long.valueOf(keyHolder.getKey().toString()));
|
|
|
|
|
} else {
|
|
|
|
|
userExaminations.setFinancialId(examinationFinancials.getId());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ExaminationFinancials examinationFinancials = examinationFinancialsService.examinationFinancialByQuery(users.getId(), examinations.getType());
|
|
|
|
|
// 如果为空就保存
|
|
|
|
|
if (Objects.isNull(examinationFinancials)) {
|
|
|
|
|
examinationFinancials = new ExaminationFinancials();
|
|
|
|
|
examinationFinancials.setBalance(new BigDecimal(1000000));
|
|
|
|
|
examinationFinancials.setInitBalance(new BigDecimal(1000000));
|
|
|
|
|
examinationFinancials.setProductAssets(new BigDecimal(0));
|
|
|
|
|
examinationFinancials.setCreatedAt(new Date());
|
|
|
|
|
examinationFinancials.setUserId(users.getId());
|
|
|
|
|
examinationFinancials.setType(examinations.getType());
|
|
|
|
|
KeyHolder keyHolder = examinationFinancialsService.insertReturnKey(examinationFinancials);
|
|
|
|
|
userExaminations.setFinancialId(Long.valueOf(keyHolder.getKey().toString()));
|
|
|
|
|
} else {
|
|
|
|
|
userExaminations.setFinancialId(examinationFinancials.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
判断teamid
|
|
|
|
|
根据条件查找,如果没有就根据条件创建一条数据
|
|
|
|
|
*/
|
|
|
|
|
if (teamId > 0) {
|
|
|
|
|
ExaminationInstances examinationInstances = examinationInstancesService
|
|
|
|
|
.examinationFinancialByQuery(teamId, examinations.getId(), examinations.getFlowId());
|
|
|
|
|
// 如果为空就保存
|
|
|
|
|
if (examinationInstances == null) {
|
|
|
|
|
examinationInstances = new ExaminationInstances();
|
|
|
|
|
examinationInstances.setTeamId(teamId);
|
|
|
|
|
examinationInstances.setExaminationId(examinations.getId());
|
|
|
|
|
examinationInstances.setFlowId(examinations.getFlowId());
|
|
|
|
|
|
|
|
|
|
examinationInstances.setStatus(0);
|
|
|
|
|
examinationInstances.setCreatedAt(new Date());
|
|
|
|
|
examinationInstances.setUpdatedAt(new Date());
|
|
|
|
|
examinationInstances.setFinishStep(0);
|
|
|
|
|
|
|
|
|
|
KeyHolder keyHolder = examinationInstancesService.insertReturnKey(examinationInstances);
|
|
|
|
|
userExaminations.setInstanceId(Long.valueOf(keyHolder.getKey().toString()));
|
|
|
|
|
} else {
|
|
|
|
|
userExaminations.setInstanceId(examinationInstances.getId());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ExaminationInstances examinationInstances = new ExaminationInstances();
|
|
|
|
|
examinationInstances.setExaminationId(examinations.getId());
|
|
|
|
|
examinationInstances.setFlowId(examinations.getFlowId());
|
|
|
|
|
examinationInstances.setStatus(0);
|
|
|
|
|
|
|
|
|
|
examinationInstances.setCreatedAt(new Date());
|
|
|
|
|
examinationInstances.setUpdatedAt(new Date());
|
|
|
|
|
examinationInstances.setFinishStep(0);
|
|
|
|
|
examinationInstances.setTeamId(0L);
|
|
|
|
|
|
|
|
|
|
KeyHolder keyHolder = examinationInstancesService.insertReturnKey(examinationInstances);
|
|
|
|
|
userExaminations.setInstanceId(Long.valueOf(keyHolder.getKey().toString()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (examinations.getMode() == 1) {
|
|
|
|
|
UserTeams userTeams = new UserTeams();
|
|
|
|
|
userTeams.setTeamId(teamId);
|
|
|
|
|
userTeams.setUserId(users.getId());
|
|
|
|
|
userTeams = userTeamsService.userTeamsByQuery(userTeams);
|
|
|
|
|
if (userTeams != null) {
|
|
|
|
|
String roles = userTeams.getRoles() == null ? "[]" : userTeams.getRoles();
|
|
|
|
|
userExaminations.setData(JsonMergeUtil.twoJsonMerge(userExaminations.getData() == null ? "{}" : userExaminations.getData(),
|
|
|
|
|
"{roles:" + roles + "}"));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
userExaminations.setData(JsonMergeUtil.twoJsonMerge(userExaminations.getData() == null ? "{}" : userExaminations.getData(), flows.getData()));
|
|
|
|
|
}
|
|
|
|
|
userExaminations.setCreatedAt(new Date());
|
|
|
|
|
userExaminationsDao.insert(userExaminations);
|
|
|
|
|
}
|
|
|
|
|
ExaminationInstances examinationInstances = examinationInstancesService.queryById(userExaminations.getInstanceId());
|
|
|
|
|
final Examinations examinations = examinationsService.getOrInitExamination(examinationId, flows, isTeam);
|
|
|
|
|
final UserExaminations userExaminations = getOrInitUserExamination(users, teamId, examinations, flows);
|
|
|
|
|
final ExaminationInstances instances = examinationInstancesService.queryById(userExaminations.getInstanceId());
|
|
|
|
|
|
|
|
|
|
examinations.set("examinationId", examinations.getId());
|
|
|
|
|
examinations.setFlowId(examinations.getFlowId());
|
|
|
|
@ -311,29 +151,103 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
examinations.setMode(examinations.getMode());
|
|
|
|
|
examinations.setType(examinations.getType());
|
|
|
|
|
examinations.setEndTime(examinations.getEndTime());
|
|
|
|
|
examinations.set("instance_id", examinationInstances != null ? examinationInstances.getId() : null);
|
|
|
|
|
examinations.set("instance_id", instances != null ? instances.getId() : null);
|
|
|
|
|
examinations.set("examinationInstId", userExaminations.getId());
|
|
|
|
|
examinations.set("finishStep", examinationInstances != null ? examinationInstances.getFinishStep() == null ? 0 : examinationInstances.getFinishStep() : 0);
|
|
|
|
|
examinations.set("finishStep", instances != null ? instances.getFinishStep() == null ? 0 : instances.getFinishStep() : 0);
|
|
|
|
|
examinations.set("finishTime", userExaminations.getFinishTime() == null ? false : userExaminations.getFinishTime());
|
|
|
|
|
examinations.set("flowStep", JSONObject.parseObject(flows.getData()).getByteValue("step"));
|
|
|
|
|
examinations.set("isTeam", isTeam);
|
|
|
|
|
examinations.set("teamId", teamId);
|
|
|
|
|
|
|
|
|
|
return examinations;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private UserExaminations getOrInitUserExamination(Users users, Long teamId, Examinations examinations, Flows flows) {
|
|
|
|
|
// 根据条件查询userExaminations
|
|
|
|
|
UserExaminations userExaminations = userExaminationsDao.getPracticeModeValue(teamId, examinations, users);
|
|
|
|
|
if (userExaminations != null) {
|
|
|
|
|
return userExaminations;
|
|
|
|
|
}
|
|
|
|
|
// 如果查询为空,就返回一个新的对象
|
|
|
|
|
userExaminations = new UserExaminations();
|
|
|
|
|
userExaminations.setTeamId(teamId);
|
|
|
|
|
userExaminations.setExaminationId(examinations.getId());
|
|
|
|
|
userExaminations.setFlowId(examinations.getFlowId());
|
|
|
|
|
userExaminations.setUserId(users.getId());
|
|
|
|
|
userExaminations.setClassId(users.getClassId());
|
|
|
|
|
userExaminations.setStatus(0);
|
|
|
|
|
userExaminations.setClassOrders(0);
|
|
|
|
|
userExaminations.setTeamOrders(0);
|
|
|
|
|
|
|
|
|
|
final ExaminationInstances instances = examinationInstancesService.getOrInitInstance(users, teamId, examinations.getId(), examinations.getFlowId());
|
|
|
|
|
userExaminations.setInstanceId(instances.getId());
|
|
|
|
|
|
|
|
|
|
if (examinations.getMode() == 1) {
|
|
|
|
|
UserTeams userTeams = new UserTeams();
|
|
|
|
|
userTeams.setTeamId(teamId);
|
|
|
|
|
userTeams.setUserId(users.getId());
|
|
|
|
|
userTeams = userTeamsService.userTeamsByQuery(userTeams);
|
|
|
|
|
if (userTeams != null) {
|
|
|
|
|
String roles = userTeams.getRoles() == null ? "[]" : userTeams.getRoles();
|
|
|
|
|
userExaminations.setData(JsonMergeUtil.twoJsonMerge(userExaminations.getData() == null ? "{}" : userExaminations.getData(),
|
|
|
|
|
"{roles:" + roles + "}"));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
userExaminations.setData(JsonMergeUtil.twoJsonMerge(userExaminations.getData() == null ? "{}" : userExaminations.getData(), flows.getData()));
|
|
|
|
|
}
|
|
|
|
|
userExaminations.setCreatedAt(new Date());
|
|
|
|
|
userExaminations.setId(userExaminationsDao.insertReturnKey(userExaminations).getLong());
|
|
|
|
|
return userExaminations;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<UserExaminations> getByExaminationIdAndUserId(UserExaminations userExaminations) {
|
|
|
|
|
return userExaminationsDao.getByExaminationIdAndUserId(userExaminations);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 学生实训分数列表
|
|
|
|
|
*
|
|
|
|
|
* @param userExaminationsQuery
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public PageQuery<UserExaminations> getStudentExaminationScoreList(UserExaminationsQuery userExaminationsQuery) {
|
|
|
|
|
return userExaminationsDao.getStudentExaminationScoreList(userExaminationsQuery.getPageQuery(), userExaminationsQuery);
|
|
|
|
|
final Long examinationId = userExaminationsQuery.getExaminationId();
|
|
|
|
|
final List<UserExaminations> notParticipatingUsers = this.notParticipatingUsers(examinationId);
|
|
|
|
|
if (!notParticipatingUsers.isEmpty()) {
|
|
|
|
|
// 未提交实训/未参与实训的学生记0分
|
|
|
|
|
final Examinations examinations = examinationsService.queryById(examinationId);
|
|
|
|
|
if (examinations == null) {
|
|
|
|
|
throw new GlobalException("未查询到实训考核!");
|
|
|
|
|
}
|
|
|
|
|
List<UserExaminations> notParticipatingList = new ArrayList<>();
|
|
|
|
|
for (UserExaminations u : notParticipatingUsers) {
|
|
|
|
|
final UserExaminations nue = UserExaminationsService.noScoreUserExamination(examinationId, examinations.getFlowId(), u.getTeamId());
|
|
|
|
|
nue.setUserId(u.getUserId());
|
|
|
|
|
nue.setClassId(u.getClassId());
|
|
|
|
|
final KeyHolder neiKey = examinationInstancesService
|
|
|
|
|
.insertReturnKey(ExaminationInstancesService.noScoreInstance(examinationId, examinations.getFlowId(), u.getTeamId()));
|
|
|
|
|
nue.setInstanceId(neiKey.getLong());
|
|
|
|
|
notParticipatingList.add(nue);
|
|
|
|
|
}
|
|
|
|
|
if (!notParticipatingList.isEmpty()) {
|
|
|
|
|
this.insertBatch(notParticipatingList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
final PageQuery<UserExaminations> ses = userExaminationsDao.getStudentExaminationScoreList(userExaminationsQuery.getPageQuery(), userExaminationsQuery);
|
|
|
|
|
List<UserExaminations> updateList = new ArrayList<>();
|
|
|
|
|
for (UserExaminations ue : ses.getList()) {
|
|
|
|
|
if (ue.getStatus() < 1) {
|
|
|
|
|
final UserExaminations updateUE = new UserExaminations();
|
|
|
|
|
updateUE.setId(ue.getId());
|
|
|
|
|
if (StringUtils.isEmpty(ue.getReportFile()) || StringUtils.isEmpty(ue.getReportName())) {
|
|
|
|
|
updateUE.setReportScores(BigDecimal.ZERO);
|
|
|
|
|
updateUE.setStatus(2);
|
|
|
|
|
} else {
|
|
|
|
|
updateUE.setStatus(1);
|
|
|
|
|
}
|
|
|
|
|
updateList.add(updateUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!updateList.isEmpty()) {
|
|
|
|
|
this.updateBatchTemplate(updateList);
|
|
|
|
|
}
|
|
|
|
|
return ses;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -402,14 +316,8 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
examinationInstancesService.updateTemplate(updateInstance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void sumTotalScores(UserExaminations userExaminations, Examinations examinations, Flows flows) {
|
|
|
|
|
UserExaminations updateUserExam = new UserExaminations();
|
|
|
|
|
updateUserExam.setId(userExaminations.getId());
|
|
|
|
|
updateUserExam.setStatus(userExaminations.getStatus());
|
|
|
|
|
updateUserExam.setFinishTime(userExaminations.getFinishTime()); // 考核完成时间
|
|
|
|
|
|
|
|
|
|
final ExaminationInstances examinationInstances = examinationInstancesService.queryById(userExaminations.getInstanceId());
|
|
|
|
|
|
|
|
|
|
public void sumTotalScores(UserExaminations updateUserExam, Examinations examinations, Flows flows) {
|
|
|
|
|
final ExaminationInstances examinationInstances = examinationInstancesService.queryById(updateUserExam.getInstanceId());
|
|
|
|
|
final Configs scoreSetting = configsService.getScoreSetting(examinations.getTeacherId());
|
|
|
|
|
// 实训时长的,实训模式下,如果流程没完成,这项成绩就算是0
|
|
|
|
|
updateUserExam.setDurationScores(BigDecimal.ZERO);
|
|
|
|
@ -423,29 +331,41 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 实训模式,流程准确性评分
|
|
|
|
|
final int deductionScore = operateScoresService.totalDeductionScore(userExaminations.getId());
|
|
|
|
|
updateUserExam.setOperatorScores(BigDecimal.valueOf(100 - deductionScore));
|
|
|
|
|
|
|
|
|
|
// 资产增长率评分
|
|
|
|
|
final BigDecimal bigDecimal100 = BigDecimal.valueOf(100);
|
|
|
|
|
final ExaminationFinancials financials = examinationFinancialsService.queryById(userExaminations.getFinancialId());
|
|
|
|
|
final BigDecimal initBalance = getOrDefaultDecimal(financials.getInitBalance());
|
|
|
|
|
final BigDecimal raiseRate = (getOrDefaultDecimal(financials.getBalance())
|
|
|
|
|
.add(getOrDefaultDecimal(financials.getProductAssets()))
|
|
|
|
|
.subtract(initBalance)).divide(initBalance, RoundingMode.HALF_UP)
|
|
|
|
|
.multiply(bigDecimal100).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
|
|
|
|
|
for (ConfigsSet confRaise : scoreSetting.getRaiseSet()) {
|
|
|
|
|
if (raiseRate.compareTo(confRaise.getMin()) >= 0 && raiseRate.compareTo(confRaise.getMax()) < 0) {
|
|
|
|
|
updateUserExam.setRaiseScores(confRaise.getScores());
|
|
|
|
|
updateUserExam.setRaiseRate(raiseRate);
|
|
|
|
|
ExaminationFinancials updateEF = new ExaminationFinancials();
|
|
|
|
|
updateEF.setId(financials.getId());
|
|
|
|
|
updateEF.setRaiseRate(raiseRate);
|
|
|
|
|
examinationFinancialsService.updateTemplate(updateEF);
|
|
|
|
|
break;
|
|
|
|
|
// 未参加考核
|
|
|
|
|
boolean notParticipating = examinationInstances.getFinishStep() == null || examinationInstances.getFinishStep() < 1;
|
|
|
|
|
// 实训模式,流程准确性评分,未参加考核记0分
|
|
|
|
|
if (notParticipating) {
|
|
|
|
|
updateUserExam.setOperatorScores(BigDecimal.ZERO);
|
|
|
|
|
} else {
|
|
|
|
|
final int deductionScore = operateScoresService.totalDeductionScore(updateUserExam.getId());
|
|
|
|
|
final int deductionScoreByFinishStep = operateScoresService
|
|
|
|
|
.getDeductionScoreByFinishStep(updateUserExam.getId(), updateUserExam.getFlowId(), examinationInstances.getFinishStep());
|
|
|
|
|
updateUserExam.setOperatorScores(BigDecimal.valueOf(100 - deductionScore - deductionScoreByFinishStep));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (notParticipating) {
|
|
|
|
|
updateUserExam.setRaiseScores(BigDecimal.ZERO);
|
|
|
|
|
updateUserExam.setRaiseRate(BigDecimal.ZERO);
|
|
|
|
|
} else {
|
|
|
|
|
// 资产增长率评分
|
|
|
|
|
final ExaminationInstances financials = examinationInstancesService.queryById(updateUserExam.getInstanceId());
|
|
|
|
|
final BigDecimal initBalance = getOrDefaultDecimal(financials.getInitBalance());
|
|
|
|
|
final BigDecimal raiseRate = (getOrDefaultDecimal(financials.getBalance())
|
|
|
|
|
.add(getOrDefaultDecimal(financials.getProductAssets()))
|
|
|
|
|
.subtract(initBalance)).divide(initBalance, RoundingMode.HALF_UP)
|
|
|
|
|
.multiply(bigDecimal100).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
|
|
|
|
|
for (ConfigsSet confRaise : scoreSetting.getRaiseSet()) {
|
|
|
|
|
if (raiseRate.compareTo(confRaise.getMin()) >= 0 && raiseRate.compareTo(confRaise.getMax()) < 0) {
|
|
|
|
|
updateUserExam.setRaiseScores(confRaise.getScores());
|
|
|
|
|
updateUserExam.setRaiseRate(raiseRate);
|
|
|
|
|
ExaminationInstances updateEI = new ExaminationInstances();
|
|
|
|
|
updateEI.setId(financials.getId());
|
|
|
|
|
updateEI.setRaiseRate(raiseRate);
|
|
|
|
|
examinationInstancesService.updateTemplate(updateEI);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -457,7 +377,7 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
updateUserExam.setFlowScores(flowScore);
|
|
|
|
|
|
|
|
|
|
BigDecimal totalScores = getScoreByRate(flowScore, scoreSetting.getFlowRate())
|
|
|
|
|
.add(getScoreByRate(userExaminations.getReportScores(), scoreSetting.getReportRate()))
|
|
|
|
|
.add(getScoreByRate(updateUserExam.getReportScores(), scoreSetting.getReportRate()))
|
|
|
|
|
.add(getScoreByRate(updateUserExam.getRaiseScores(), scoreSetting.getRaiseRate()))
|
|
|
|
|
.add(getScoreByRate(updateUserExam.getDurationScores(), scoreSetting.getDurationRate()))
|
|
|
|
|
.add(getScoreByRate(updateUserExam.getOperatorScores(), scoreSetting.getOperatorRate()));
|
|
|
|
@ -487,10 +407,6 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
updateUE.setReportName(ue.getReportName());
|
|
|
|
|
updateUE.setUpdatedAt(new Date());
|
|
|
|
|
|
|
|
|
|
final Flows flows = flowsService.queryById(userExaminations.getFlowId());
|
|
|
|
|
|
|
|
|
|
// 保存流程进度
|
|
|
|
|
examinationInstancesService.finishStep(userExaminations.getInstanceId(), flows.getStep() + 1);
|
|
|
|
|
// 保存流程报告
|
|
|
|
|
this.updateTemplate(updateUE);
|
|
|
|
|
}
|
|
|
|
@ -518,7 +434,88 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
return userExaminationsDao.notParticipatingUsers(examinationId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static UserExaminations initUserExamination(Long examinationId, Long flowId) {
|
|
|
|
|
/**
|
|
|
|
|
* 练习模式设置积分,完成一个流程的个人或者团队练习,给积分。五个流程,每走完一遍个人练习流程得20积分,
|
|
|
|
|
* 每走完一遍团队练习团队中每人得50积分,走完全部五个流程的个人练习模式,奖励100积分;
|
|
|
|
|
* 走完全部五个流程的团队模式,奖励200积分。学生端界面显示学生的练习积分及班级排名。
|
|
|
|
|
*
|
|
|
|
|
* @param userId 学生ID
|
|
|
|
|
* @param classId 学生班级ID
|
|
|
|
|
* @return classOrder班级排名 integral积分
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, Integer> practiceModeIntegral(Long userId, Long classId) {
|
|
|
|
|
Map<String, Integer> result = new HashMap<>();
|
|
|
|
|
result.put("integral", 0);
|
|
|
|
|
final List<UserExaminations> ues = userExaminationsDao.practiceModeIntegralStatistics(classId);
|
|
|
|
|
|
|
|
|
|
final Map<Long, List<UserExaminations>> collect = ues.stream().collect(Collectors.groupingBy(UserExaminations::getUserId));
|
|
|
|
|
if (!collect.containsKey(userId)) {
|
|
|
|
|
// 没有成绩
|
|
|
|
|
result.put("classOrder", collect.keySet().size() + 1);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<UserExaminations> integrals = new ArrayList<>();
|
|
|
|
|
for (Long sid : collect.keySet()) {
|
|
|
|
|
final UserExaminations ue = new UserExaminations();
|
|
|
|
|
ue.setUserId(sid);
|
|
|
|
|
ue.setClassOrders(getStudentIntegral(collect.get(sid)));
|
|
|
|
|
integrals.add(ue);
|
|
|
|
|
}
|
|
|
|
|
integrals.sort(Comparator.comparing(UserExaminations::getClassOrders));
|
|
|
|
|
Collections.reverse(integrals);
|
|
|
|
|
|
|
|
|
|
int classOrder = 1;
|
|
|
|
|
for (UserExaminations integral : integrals) {
|
|
|
|
|
if (Objects.equals(integral.getUserId(), userId)) {
|
|
|
|
|
result.put("classOrder", classOrder);
|
|
|
|
|
result.put("integral", integral.getClassOrders());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
classOrder++;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int getStudentIntegral(List<UserExaminations> userExaminations) {
|
|
|
|
|
if (userExaminations == null || userExaminations.isEmpty()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
final Map<Integer, List<UserExaminations>> collect =
|
|
|
|
|
userExaminations.stream().filter(i -> i.getMode() != null)
|
|
|
|
|
.collect(Collectors.groupingBy(UserExaminations::getMode));
|
|
|
|
|
int totalIntegral = 0;
|
|
|
|
|
for (Integer mode : collect.keySet()) {
|
|
|
|
|
final List<UserExaminations> modeUEs = collect.get(mode);
|
|
|
|
|
Set<Long> flowIds = new HashSet<>();
|
|
|
|
|
for (UserExaminations modeUE : modeUEs) {
|
|
|
|
|
flowIds.add(modeUE.getFlowId());
|
|
|
|
|
}
|
|
|
|
|
// 完成全部五条流程
|
|
|
|
|
boolean allFlow = flowIds.size() > 4;
|
|
|
|
|
if (mode == 0) {
|
|
|
|
|
// 个人模式20积分
|
|
|
|
|
totalIntegral += modeUEs.size() * 20;
|
|
|
|
|
// 走完全部五个流程的个人练习模式,奖励100积分;
|
|
|
|
|
if (allFlow) {
|
|
|
|
|
totalIntegral += 100;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 团队模式50积分
|
|
|
|
|
totalIntegral += modeUEs.size() * 50;
|
|
|
|
|
// 走完全部五个流程的团队模式,奖励200积分
|
|
|
|
|
if (allFlow) {
|
|
|
|
|
totalIntegral += 200;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return totalIntegral;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 初始化没有成绩的学生实训考核
|
|
|
|
|
*/
|
|
|
|
|
public static UserExaminations noScoreUserExamination(Long examinationId, Long flowId, Long teamId) {
|
|
|
|
|
final UserExaminations nue = new UserExaminations();
|
|
|
|
|
nue.setCreatedAt(new Date());
|
|
|
|
|
nue.setExaminationId(examinationId);
|
|
|
|
@ -529,6 +526,11 @@ public class UserExaminationsService extends CoreBaseService<UserExaminations> {
|
|
|
|
|
nue.setDurationScores(BigDecimal.ZERO);
|
|
|
|
|
nue.setTotalScores(BigDecimal.ZERO);
|
|
|
|
|
nue.setOperatorScores(BigDecimal.ZERO);
|
|
|
|
|
nue.setTeamId(teamId == null ? 0L : teamId);
|
|
|
|
|
nue.setStatus(2); // 已评分
|
|
|
|
|
nue.setFinishTime(new Date());
|
|
|
|
|
nue.setClassOrders(0);
|
|
|
|
|
nue.setTeamOrders(0);
|
|
|
|
|
return nue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|