|
@@ -1,12 +1,20 @@
|
|
|
package com.qunzhixinxi.hnqz.admin.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.ArrayUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskSubmissionPercentRule;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskSubmissionRule;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionPercentRuleService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionRuleService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeSubCate2Service;
|
|
|
+import com.qunzhixinxi.hnqz.common.core.constant.enums.CommonFlag;
|
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
|
+import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -18,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.validation.constraints.NotEmpty;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
@@ -37,6 +46,8 @@ public class WmTaskSubmissionRuleController {
|
|
|
|
|
|
private final WmTaskSubmissionRuleService taskSubmissionRuleService;
|
|
|
private final SysDeptService deptService;
|
|
|
+ private final WmTaskTypeSubCate2Service wmTaskTypeSubCate2Service;
|
|
|
+ private final WmTaskSubmissionPercentRuleService taskSubmissionPercentRuleService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -50,6 +61,75 @@ public class WmTaskSubmissionRuleController {
|
|
|
return R.ok(taskSubmissionRuleService.listDeptTaskSubmissionRules(deptId));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取企业的任务类型
|
|
|
+ *
|
|
|
+ * @param deptId 企业id
|
|
|
+ * @return 任务类型列表
|
|
|
+ */
|
|
|
+ @GetMapping("/list-task-type")
|
|
|
+ public R<?> listTaskType(@RequestParam(value = "deptId") Integer deptId) {
|
|
|
+ List<Map<String, Object>> taskTypeList = wmTaskTypeSubCate2Service.listTaskTypeTree(deptId);
|
|
|
+ if (CollectionUtil.isNotEmpty(taskTypeList)) {
|
|
|
+ // 查询任务类型启用状态
|
|
|
+ List<WmTaskSubmissionPercentRule> rules = taskSubmissionPercentRuleService.list(Wrappers.<WmTaskSubmissionPercentRule>lambdaQuery()
|
|
|
+ .eq(WmTaskSubmissionPercentRule::getDeptId, deptId)
|
|
|
+ .eq(WmTaskSubmissionPercentRule::getSubCategory, UpmsType.TaskSubCategory2.TASK_TYPE_CONFIG));
|
|
|
+ String[] taskTypeIds;
|
|
|
+ if (CollUtil.isNotEmpty(rules)) {
|
|
|
+ taskTypeIds = rules.get(0).getRule().getTaskTypeIds();
|
|
|
+ } else {
|
|
|
+ taskTypeIds = new String[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置任务类型是否启用状态
|
|
|
+ taskTypeList.forEach(map -> {
|
|
|
+ List<Map<String, Object>> children = (List<Map<String, Object>>) map.get("children");
|
|
|
+ if (CollUtil.isNotEmpty(children)) {
|
|
|
+ // 拼接是否启用标记
|
|
|
+ children.forEach(childMap -> {
|
|
|
+ String taskTypeId = (String) childMap.get("taskTypeId");
|
|
|
+ childMap.put("enableFlag", ArrayUtil.contains(taskTypeIds, taskTypeId));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok(taskTypeList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新启用的任务类型
|
|
|
+ *
|
|
|
+ * @param rule 任务类型
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @PostMapping("/update-task-type")
|
|
|
+ public R<Boolean> updateEnableTaskType(@RequestBody WmTaskSubmissionPercentRule.PercentRule rule) {
|
|
|
+ rule.setLimitPercent("");
|
|
|
+ rule.setStartScore(0);
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
+
|
|
|
+ List<WmTaskSubmissionPercentRule> rules = taskSubmissionPercentRuleService.list(Wrappers.<WmTaskSubmissionPercentRule>lambdaQuery()
|
|
|
+ .eq(WmTaskSubmissionPercentRule::getDeptId, deptId)
|
|
|
+ .eq(WmTaskSubmissionPercentRule::getSubCategory, UpmsType.TaskSubCategory2.TASK_TYPE_CONFIG));
|
|
|
+ if (CollUtil.isEmpty(rules)) {
|
|
|
+ WmTaskSubmissionPercentRule percentRule = new WmTaskSubmissionPercentRule();
|
|
|
+ percentRule.setDeptId(deptId);
|
|
|
+ percentRule.setRule(rule);
|
|
|
+ percentRule.setSubCategory(UpmsType.TaskSubCategory2.TASK_TYPE_CONFIG);
|
|
|
+ percentRule.setOptFlag(CommonFlag.OptFlag.OK);
|
|
|
+ taskSubmissionPercentRuleService.save(percentRule);
|
|
|
+ } else {
|
|
|
+ taskSubmissionPercentRuleService.update(Wrappers.<WmTaskSubmissionPercentRule>lambdaUpdate()
|
|
|
+ .eq(WmTaskSubmissionPercentRule::getDeptId, deptId)
|
|
|
+ .eq(WmTaskSubmissionPercentRule::getSubCategory, UpmsType.TaskSubCategory2.TASK_TYPE_CONFIG)
|
|
|
+ .set(WmTaskSubmissionPercentRule::getRule, rule));
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok(Boolean.TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 初始化企业限制
|
|
|
*
|