|
@@ -1,6 +1,8 @@
|
|
|
package com.qunzhixinxi.hnqz.admin;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
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.UpmsType;
|
|
@@ -16,7 +18,16 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
|
|
|
+import javax.validation.constraints.NotEmpty;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.Comparator;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
+
|
|
|
+import static java.util.Collections.addAll;
|
|
|
|
|
|
/**
|
|
|
* @author snows
|
|
@@ -60,7 +71,43 @@ public class WmTaskSubmissionRuleServiceTest {
|
|
|
taskSubmissionPercentRuleService.save(percentRule);
|
|
|
}
|
|
|
});
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 增量更新企业的任务类型配置数据
|
|
|
+ */
|
|
|
+// @Test
|
|
|
+ public void initNewTaskTypeConfig() {
|
|
|
+
|
|
|
+ // 平台新增的任务类型
|
|
|
+ Set<String> taskTypeIds = new HashSet<>();
|
|
|
+ taskTypeIds.add("51");
|
|
|
+ taskTypeIds.add("52");
|
|
|
+ taskTypeIds.add("53");
|
|
|
+ taskTypeIds.add("54");
|
|
|
+ taskTypeIds.add("55");
|
|
|
+ taskTypeIds.add("56");
|
|
|
+ taskTypeIds.add("57");
|
|
|
|
|
|
+ // 查询待修改企业的规则
|
|
|
+ List<WmTaskSubmissionPercentRule> queryRules = taskSubmissionPercentRuleService.list(Wrappers.<WmTaskSubmissionPercentRule>lambdaQuery()
|
|
|
+ .eq(WmTaskSubmissionPercentRule::getSubCategory, UpmsType.TaskSubCategory2.TASK_TYPE_CONFIG));
|
|
|
+ if (CollUtil.isNotEmpty(queryRules)) {
|
|
|
+ queryRules.forEach(percentRule -> {
|
|
|
+ log.info("初始化deptId={}", percentRule.getDeptId());
|
|
|
|
|
|
+ String[] oldTaskTypeIds = percentRule.getRule().getTaskTypeIds();
|
|
|
+
|
|
|
+ WmTaskSubmissionPercentRule updateRule = new WmTaskSubmissionPercentRule();
|
|
|
+ updateRule.setRuleId(percentRule.getRuleId());
|
|
|
+ Set<String> newTaskTypeIdSet = Stream.of(oldTaskTypeIds).collect(Collectors.toSet());
|
|
|
+ newTaskTypeIdSet.addAll(taskTypeIds);
|
|
|
+ WmTaskSubmissionPercentRule.PercentRule updatePercentRule = BeanUtil.copyProperties(percentRule.getRule(), WmTaskSubmissionPercentRule.PercentRule.class);
|
|
|
+ updatePercentRule.setTaskTypeIds(newTaskTypeIdSet.stream().sorted(Comparator.comparingInt(Integer::parseInt)).toArray(String[]::new));
|
|
|
+ updateRule.setRule(updatePercentRule);
|
|
|
+ updateRule.setUpdateTime(LocalDateTime.now());
|
|
|
+ taskSubmissionPercentRuleService.updateById(updateRule);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|