|
@@ -0,0 +1,443 @@
|
|
|
+package com.qunzhixinxi.hnqz.admin.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.ArrayUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.constant.CacheConstants;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskSubmissionPercentRule;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.WmScorePackage;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.WmScorePackageStatus;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.WmScoreTaskType;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.WmTask;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.WmTaskContent;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.WmTaskType;
|
|
|
+import com.qunzhixinxi.hnqz.admin.entity.dto.DeptTaskDTO;
|
|
|
+import com.qunzhixinxi.hnqz.admin.enums.DelEnum;
|
|
|
+import com.qunzhixinxi.hnqz.admin.enums.EnableEnum;
|
|
|
+import com.qunzhixinxi.hnqz.admin.enums.PackageTypeEnum;
|
|
|
+import com.qunzhixinxi.hnqz.admin.enums.TaskStatusEnum;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmDeptTaskService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmScorePackageService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmScorePackageStatusService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmScoreTaskTypeService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskContentService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionPercentRuleService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeService;
|
|
|
+import com.qunzhixinxi.hnqz.common.security.service.HnqzUser;
|
|
|
+import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
|
|
|
+import com.qunzhixinxi.hnqz.common.sequence.sequence.Sequence;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 企业任务服务
|
|
|
+ *
|
|
|
+ * @author lixuesong
|
|
|
+ * @date 2023/09/21
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class WmDeptTaskServiceImpl implements WmDeptTaskService {
|
|
|
+
|
|
|
+ private final WmTaskSubmissionPercentRuleService wmTaskSubmissionPercentRuleService;
|
|
|
+ private final WmScorePackageService wmScorePackageService;
|
|
|
+ private final WmScorePackageStatusService wmScorePackageStatusService;
|
|
|
+ private final WmTaskContentService wmTaskContentService;
|
|
|
+ private final WmTaskService wmTaskService;
|
|
|
+ private final WmTaskTypeService wmTaskTypeService;
|
|
|
+ private final WmScoreTaskTypeService wmScoreTaskTypeService;
|
|
|
+ private final Sequence taskSequence;
|
|
|
+ private final RedisTemplate redisTemplate;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业任务保存-企业通用
|
|
|
+ *
|
|
|
+ * @param params 参数
|
|
|
+ * @return {@link Boolean} 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ 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("可分配积分不足!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验是否超过积分包企业任务上限
|
|
|
+ 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("已超过积分包的企业任务上限!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存taskContent
|
|
|
+ WmTaskContent taskContent = new WmTaskContent();
|
|
|
+ // 任务类型
|
|
|
+ taskContent.setTemp30(taskTypeId);
|
|
|
+ // 积分包id
|
|
|
+ taskContent.setTemp32(params.getPackageId());
|
|
|
+ // 主题
|
|
|
+ taskContent.setTemp2(params.getMeetingtTitle());
|
|
|
+ // 时间
|
|
|
+ taskContent.setTemp3(params.getMeetingTime());
|
|
|
+ // 文件上传
|
|
|
+ taskContent.setTemp4(this.convertFileUrlArrayToString(params.getFiles()));
|
|
|
+ // 外采费用
|
|
|
+ taskContent.setTemp5(params.getOutsourcingAmount());
|
|
|
+ // 凭证
|
|
|
+ taskContent.setTemp6(this.convertFileUrlArrayToString(params.getOutsourcingAmountProof()));
|
|
|
+ // 任务积分
|
|
|
+ taskContent.setTemp7(String.valueOf(params.getScore()));
|
|
|
+ // 总结
|
|
|
+ taskContent.setTemp8(params.getMeetingSummary());
|
|
|
+ log.info("保存taskContent参数:{}", taskContent);
|
|
|
+ wmTaskContentService.save(taskContent);
|
|
|
+
|
|
|
+ // 保存企业任务通用方法
|
|
|
+ this.saveEntTaskCommon(taskTypeId, taskContent, params.getScore(), scorePackage);
|
|
|
+
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业任务保存-医学会各级年会及卫星会
|
|
|
+ *
|
|
|
+ * @param params 参数
|
|
|
+ * @return {@link Boolean} 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean saveEntTaskForTaskType62(DeptTaskDTO.TaskType62 params) {
|
|
|
+ String taskTypeId = "62";
|
|
|
+
|
|
|
+ // 查询任务类型启用状态
|
|
|
+ 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());
|
|
|
+ // 查询任务规则积分
|
|
|
+ WmTaskType wmTaskType = new WmTaskType();
|
|
|
+ wmTaskType.setRuleId(scorePackage.getRuleId());
|
|
|
+ WmTaskType queryTaskType = wmTaskTypeService.getById(taskTypeId);
|
|
|
+ wmTaskType.setTaskTypeName(queryTaskType.getTaskTypeName());
|
|
|
+ int score = wmTaskTypeService.getWmTaskTypeByEnt(wmTaskType);
|
|
|
+
|
|
|
+ // 校验是否超过可分配积分值
|
|
|
+ List<WmScorePackage> scorePackagekfpjf =
|
|
|
+ wmScorePackageService.getScorePackagekfpjf(null, SecurityUtils.getUser().getDeptId(),
|
|
|
+ new String[]{"0", "1", "2"}, new String[]{params.getPackageId()});
|
|
|
+ if (score > scorePackagekfpjf.get(0).getKfpjf()) {
|
|
|
+ throw new RuntimeException("可分配积分不足!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验是否超过积分包企业任务上限
|
|
|
+ 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 += score;
|
|
|
+ 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("已超过积分包的企业任务上限!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存taskContent
|
|
|
+ WmTaskContent taskContent = new WmTaskContent();
|
|
|
+ // 任务类型
|
|
|
+ taskContent.setTemp30(taskTypeId);
|
|
|
+ // 积分包id
|
|
|
+ taskContent.setTemp32(params.getPackageId());
|
|
|
+ // 主题
|
|
|
+ taskContent.setTemp2(params.getMeetingtTitle());
|
|
|
+ // 时间
|
|
|
+ taskContent.setTemp3(params.getMeetingTime());
|
|
|
+ // 会议人次
|
|
|
+ taskContent.setTemp4(params.getMeetingNumber());
|
|
|
+ // 会议邀请函
|
|
|
+ taskContent.setTemp5(this.convertFileUrlArrayToString(params.getMeetingInvitationUrl()));
|
|
|
+ // 会议计划表
|
|
|
+ taskContent.setTemp6(this.convertFileUrlArrayToString(params.getMeetingPlanUrl()));
|
|
|
+ // 会议签到表
|
|
|
+ taskContent.setTemp7(this.convertFileUrlArrayToString(params.getMeetingCheckInUrl()));
|
|
|
+ // 现场照片
|
|
|
+ taskContent.setTemp8(this.convertFileUrlArrayToString(params.getLivePhotosUrl()));
|
|
|
+ // 会议内容
|
|
|
+ taskContent.setTemp9(this.convertFileUrlArrayToString(params.getMeetingContentUrl()));
|
|
|
+ // 外采费用
|
|
|
+ taskContent.setTemp10(params.getOutsourcingAmount());
|
|
|
+ // 外采费用凭证
|
|
|
+ taskContent.setTemp11(this.convertFileUrlArrayToString(params.getOutsourcingAmountProof()));
|
|
|
+ // 总结
|
|
|
+ taskContent.setTemp12(params.getMeetingSummary());
|
|
|
+ log.info("保存taskContent参数:{}", taskContent);
|
|
|
+ wmTaskContentService.save(taskContent);
|
|
|
+
|
|
|
+ // 保存企业任务通用方法
|
|
|
+ this.saveEntTaskCommon(taskTypeId, taskContent, score, scorePackage);
|
|
|
+
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业任务保存-专家共识巡讲会
|
|
|
+ *
|
|
|
+ * @param params 参数
|
|
|
+ * @return {@link Boolean} 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean saveEntTaskForTaskType63(DeptTaskDTO.TaskType63 params) {
|
|
|
+ String taskTypeId = "63";
|
|
|
+
|
|
|
+ // 查询任务类型启用状态
|
|
|
+ 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());
|
|
|
+ // 查询任务规则积分
|
|
|
+ WmTaskType wmTaskType = new WmTaskType();
|
|
|
+ wmTaskType.setRuleId(scorePackage.getRuleId());
|
|
|
+ WmTaskType queryTaskType = wmTaskTypeService.getById(taskTypeId);
|
|
|
+ wmTaskType.setTaskTypeName(queryTaskType.getTaskTypeName());
|
|
|
+ int score = wmTaskTypeService.getWmTaskTypeByEnt(wmTaskType);
|
|
|
+
|
|
|
+ // 校验是否超过可分配积分值
|
|
|
+ List<WmScorePackage> scorePackagekfpjf =
|
|
|
+ wmScorePackageService.getScorePackagekfpjf(null, SecurityUtils.getUser().getDeptId(),
|
|
|
+ new String[]{"0", "1", "2"}, new String[]{params.getPackageId()});
|
|
|
+ if (score > scorePackagekfpjf.get(0).getKfpjf()) {
|
|
|
+ throw new RuntimeException("可分配积分不足!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验是否超过积分包企业任务上限
|
|
|
+ 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 += score;
|
|
|
+ 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("已超过积分包的企业任务上限!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存taskContent
|
|
|
+ WmTaskContent taskContent = new WmTaskContent();
|
|
|
+ // 任务类型
|
|
|
+ taskContent.setTemp30(taskTypeId);
|
|
|
+ // 积分包id
|
|
|
+ taskContent.setTemp32(params.getPackageId());
|
|
|
+ // 主题
|
|
|
+ taskContent.setTemp2(params.getMeetingtTitle());
|
|
|
+ // 时间
|
|
|
+ taskContent.setTemp3(params.getMeetingTime());
|
|
|
+ // 参加人次
|
|
|
+ taskContent.setTemp4(params.getMeetingNumber());
|
|
|
+ // 活动策划书
|
|
|
+ taskContent.setTemp5(this.convertFileUrlArrayToString(params.getEventPlannerUrl()));
|
|
|
+ // 活动计划表
|
|
|
+ taskContent.setTemp6(this.convertFileUrlArrayToString(params.getMeetingPlanUrl()));
|
|
|
+ // 会议签到表
|
|
|
+ taskContent.setTemp7(this.convertFileUrlArrayToString(params.getMeetingCheckInUrl()));
|
|
|
+ // 现场照片
|
|
|
+ taskContent.setTemp8(this.convertFileUrlArrayToString(params.getLivePhotosUrl()));
|
|
|
+ // 会议内容
|
|
|
+ taskContent.setTemp9(this.convertFileUrlArrayToString(params.getMeetingContentUrl()));
|
|
|
+ // 外采费用
|
|
|
+ taskContent.setTemp10(params.getOutsourcingAmount());
|
|
|
+ // 外采费用凭证
|
|
|
+ taskContent.setTemp11(this.convertFileUrlArrayToString(params.getOutsourcingAmountProof()));
|
|
|
+ // 总结
|
|
|
+ taskContent.setTemp12(params.getMeetingSummary());
|
|
|
+ log.info("保存taskContent参数:{}", taskContent);
|
|
|
+ wmTaskContentService.save(taskContent);
|
|
|
+
|
|
|
+ // 保存企业任务通用方法
|
|
|
+ this.saveEntTaskCommon(taskTypeId, taskContent, score, scorePackage);
|
|
|
+
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存企业任务通用方法
|
|
|
+ *
|
|
|
+ * @param taskTypeId 任务类型id
|
|
|
+ * @param taskContent 任务内容
|
|
|
+ * @param taskScore 任务积分
|
|
|
+ * @param scorePackage 积分包
|
|
|
+ */
|
|
|
+ private void saveEntTaskCommon(String taskTypeId, WmTaskContent taskContent, int taskScore, WmScorePackage scorePackage) {
|
|
|
+ HnqzUser user = SecurityUtils.getUser();
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+
|
|
|
+ // 保存任务
|
|
|
+ WmTask task = new WmTask();
|
|
|
+ task.setTaskContentId(String.valueOf(taskContent.getId()));
|
|
|
+ task.setTaskFrom("1");
|
|
|
+ task.setTaskTypeId(taskTypeId);
|
|
|
+ task.setTaskUserId(String.valueOf(user.getId()));
|
|
|
+ task.setScorePackageId(scorePackage.getId());
|
|
|
+ task.setScore(taskScore);
|
|
|
+ task.setLookintoDate(now);
|
|
|
+ task.setUpdateTime(now);
|
|
|
+ task.setDrugEntId(scorePackage.getDrugEntId());
|
|
|
+ task.setTaskRuleId(scorePackage.getTaskRuleId());
|
|
|
+ task.setDeptId(String.valueOf(user.getDeptId()));
|
|
|
+ task.setSubmitStatus("0");
|
|
|
+ task.setRealFlag("0");
|
|
|
+ task.setTaskStatus(TaskStatusEnum.APPROVED.val());
|
|
|
+ task.setTaskNumber(taskSequence.nextNo());
|
|
|
+ if (ArrayUtil.containsAny(user.getRoles(), 3)) {
|
|
|
+ task.setTaskUserType("3");
|
|
|
+ } else if (ArrayUtil.containsAny(user.getRoles(), 4)) {
|
|
|
+ task.setTaskUserType("4");
|
|
|
+ } else {
|
|
|
+ task.setTaskUserType(ArrayUtil.join(user.getRoles(), ","));
|
|
|
+ }
|
|
|
+ log.info("保存任务参数:{}", task);
|
|
|
+ wmTaskService.save(task);
|
|
|
+
|
|
|
+ // 创建一条领包记录
|
|
|
+ WmScorePackageStatus wmScorePackageStatus = new WmScorePackageStatus();
|
|
|
+ wmScorePackageStatus.setPackageId(scorePackage.getId());
|
|
|
+ wmScorePackageStatus.setUserId(String.valueOf(user.getId()));
|
|
|
+ wmScorePackageStatus.setDelFlag("0");
|
|
|
+ wmScorePackageStatus.setEnableFlag("0");
|
|
|
+ List<WmScorePackageStatus> wmScorePackageStatusList = wmScorePackageStatusService.
|
|
|
+ list(Wrappers.query(wmScorePackageStatus).lambda().ne(WmScorePackageStatus::getStatus, 3));
|
|
|
+ if (CollUtil.isEmpty(wmScorePackageStatusList)) {
|
|
|
+ wmScorePackageStatus.setStatus("2");
|
|
|
+ wmScorePackageStatus.setTaskAddFlag("1");
|
|
|
+ if (PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val().equals(scorePackage.getPackageType1())
|
|
|
+ || PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val().equals(scorePackage.getPackageType1())) {
|
|
|
+ wmScorePackageStatus.setUserScore(scorePackage.getScore() + "");
|
|
|
+ } else {
|
|
|
+ wmScorePackageStatus.setUserScore(scorePackage.getUserScore());
|
|
|
+ }
|
|
|
+ wmScorePackageStatus.setTaskNum(scorePackage.getTaskNum());
|
|
|
+ wmScorePackageStatus.setDeptId(String.valueOf(user.getDeptId()));
|
|
|
+ wmScorePackageStatus.setCreateTime(now);
|
|
|
+ wmScorePackageStatus.setUpdateTime(now);
|
|
|
+ log.info("创建领包记录参数:{}", wmScorePackageStatus);
|
|
|
+ wmScorePackageStatusService.save(wmScorePackageStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 扣减可分配积分值
|
|
|
+ WmScorePackage updatePackage = new WmScorePackage();
|
|
|
+ updatePackage.setId(scorePackage.getId());
|
|
|
+ updatePackage.setKfpjf(scorePackage.getKfpjf() - taskScore);
|
|
|
+ updatePackage.setUpdateUser(user.getId());
|
|
|
+ updatePackage.setUpdateTime(now);
|
|
|
+ log.info("扣减可分配积分值参数:{}", updatePackage);
|
|
|
+ wmScorePackageService.updateById(updatePackage);
|
|
|
+
|
|
|
+ // 保存成功后清除缓存
|
|
|
+ String cacheKey =
|
|
|
+ String.format("%s-%s-%s", CacheConstants.ENT_TASK_CACHE_KEY, taskTypeId, user.getId());
|
|
|
+ redisTemplate.delete(cacheKey);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将文件地址数组转换为字符串
|
|
|
+ *
|
|
|
+ * @param array 数组
|
|
|
+ * @return {@link String}
|
|
|
+ */
|
|
|
+ private String convertFileUrlArrayToString(List<DeptTaskDTO.FileUrlObj> array) {
|
|
|
+ return JSONUtil.toJsonStr(array);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|