|
@@ -75,53 +75,17 @@ public class WmDeptTaskServiceImpl implements WmDeptTaskService {
|
|
|
public Boolean saveEntTaskForTaskType61(DeptTaskDTO.TaskType61 params) {
|
|
|
String taskTypeId = "61";
|
|
|
|
|
|
- // 校验任务类型启用状态
|
|
|
- List<WmTaskSubmissionPercentRule> rules = wmTaskSubmissionPercentRuleService.list(Wrappers.<WmTaskSubmissionPercentRule>lambdaQuery()
|
|
|
- .eq(WmTaskSubmissionPercentRule::getDeptId, SecurityUtils.getUser().getDeptId())
|
|
|
- .eq(WmTaskSubmissionPercentRule::getSubCategory, UpmsType.TaskSubCategory2.TASK_TYPE_CONFIG));
|
|
|
- if (CollUtil.isEmpty(rules)) {
|
|
|
- throw new RuntimeException("当前企业未开启该任务!");
|
|
|
- }
|
|
|
- String[] taskTypeIds = rules.get(0).getRule().getTaskTypeIds();
|
|
|
- if (!ArrayUtil.contains(taskTypeIds, taskTypeId)) {
|
|
|
- throw new RuntimeException("当前企业未开启该任务!");
|
|
|
- }
|
|
|
-
|
|
|
- int scoreTaskTypeCount = wmScoreTaskTypeService.count(Wrappers.<WmScoreTaskType>lambdaQuery()
|
|
|
- .eq(WmScoreTaskType::getScoreId, params.getPackageId())
|
|
|
- .eq(WmScoreTaskType::getTaskTypeId, taskTypeId));
|
|
|
- if (scoreTaskTypeCount <= 0) {
|
|
|
- throw new RuntimeException("有效任务类型未启用该任务!");
|
|
|
- }
|
|
|
-
|
|
|
- // 查询积分包
|
|
|
- WmScorePackage scorePackage = wmScorePackageService.getById(params.getPackageId());
|
|
|
-
|
|
|
- // 校验是否超过可分配积分值
|
|
|
- List<WmScorePackage> scorePackagekfpjf =
|
|
|
- wmScorePackageService.getScorePackagekfpjf(null, SecurityUtils.getUser().getDeptId(),
|
|
|
- new String[]{"0", "1", "2"}, new String[]{params.getPackageId()});
|
|
|
- if (params.getScore() > scorePackagekfpjf.get(0).getKfpjf()) {
|
|
|
- throw new RuntimeException("可分配积分不足!");
|
|
|
- }
|
|
|
+ // 查询积分包
|
|
|
+ WmScorePackage scorePackage = wmScorePackageService.getById(params.getPackageId());
|
|
|
+ // 查询任务规则积分
|
|
|
+ WmTaskType wmTaskType = new WmTaskType();
|
|
|
+ wmTaskType.setRuleId(scorePackage.getRuleId());
|
|
|
+ WmTaskType queryTaskType = wmTaskTypeService.getById(taskTypeId);
|
|
|
+ wmTaskType.setTaskTypeName(queryTaskType.getTaskTypeName());
|
|
|
+ int score = wmTaskTypeService.getWmTaskTypeByEnt(wmTaskType);
|
|
|
|
|
|
- // 校验是否超过积分包企业任务上限
|
|
|
- List<WmTask> queryTaskList = wmTaskService.list(Wrappers.<WmTask>lambdaQuery()
|
|
|
- .eq(WmTask::getScorePackageId, params.getPackageId())
|
|
|
- .eq(WmTask::getEnableFlag, EnableEnum.ENABLE.val())
|
|
|
- .eq(WmTask::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
- .eq(WmTask::getTaskStatus, TaskStatusEnum.APPROVED.val()));
|
|
|
-
|
|
|
- int totalScoreSum = 0;
|
|
|
- totalScoreSum += params.getScore();
|
|
|
- if (CollUtil.isNotEmpty(queryTaskList)) {
|
|
|
- totalScoreSum += queryTaskList.stream().mapToInt(WmTask::getScore).sum();
|
|
|
- }
|
|
|
- if (BigDecimal.valueOf(totalScoreSum)
|
|
|
- .compareTo(BigDecimal.valueOf(scorePackage.getScore())
|
|
|
- .multiply(scorePackage.getEntTaskLimit()).divide(new BigDecimal("100"))) > 0) {
|
|
|
- throw new RuntimeException("已超过积分包的企业任务上限!");
|
|
|
- }
|
|
|
+ // 校验企业任务类型
|
|
|
+ this.chectDeptTask(taskTypeId, params.getScore(), scorePackage);
|
|
|
|
|
|
// 保存taskContent
|
|
|
WmTaskContent taskContent = new WmTaskContent();
|
|
@@ -704,14 +668,14 @@ public class WmDeptTaskServiceImpl implements WmDeptTaskService {
|
|
|
.filter(taskType -> "2".equals(taskType.getTaskReceiverType()) && !"p-19".equals(taskType.getParentId()))
|
|
|
.map(WmTaskType::getId).collect(Collectors.toList());
|
|
|
|
|
|
+ // 任务总积分(不包括当前提交的积分值)
|
|
|
int totalScoreSum = 0;
|
|
|
+ // 企业任务总积分(包括当前提交的积分值)
|
|
|
int entTotalScoreSum = 0;
|
|
|
- totalScoreSum += score;
|
|
|
+// totalScoreSum += score;
|
|
|
entTotalScoreSum += score;
|
|
|
if (CollUtil.isNotEmpty(queryTaskList)) {
|
|
|
- // 任务总积分
|
|
|
totalScoreSum += queryTaskList.stream().mapToInt(WmTask::getScore).sum();
|
|
|
- // 企业任务总积分
|
|
|
entTotalScoreSum += queryTaskList.stream()
|
|
|
.filter(task -> entTaskTypeIds.contains(task.getTaskTypeId()))
|
|
|
.mapToInt(WmTask::getScore).sum();
|