|
@@ -17,6 +17,7 @@ import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeService;
|
|
|
import com.qunzhixinxi.hnqz.common.core.constant.enums.CommonFlag;
|
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -34,6 +35,7 @@ import java.util.stream.Collectors;
|
|
|
* @author snows
|
|
|
* @date 2022/12/22 15:35
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class WmTaskSubmissionPercentRuleServiceImpl
|
|
@@ -47,9 +49,9 @@ public class WmTaskSubmissionPercentRuleServiceImpl
|
|
|
/**
|
|
|
* 校验任务百分比限制规则(达到要求的积分包,【任务配置】-【百分比限制】所选的任务总完成积分值不得大于积分包值*百分比)
|
|
|
*
|
|
|
- * @param scorePackage 积分包实体
|
|
|
- * @param deptId 部门id
|
|
|
- * @param taskUserId 任务承接人userId
|
|
|
+ * @param scorePackage 积分包实体
|
|
|
+ * @param deptId 部门id
|
|
|
+ * @param taskUserId 任务承接人userId
|
|
|
* @param checkTaskTypeList 要校验的任务类型list
|
|
|
* @return
|
|
|
*/
|
|
@@ -68,6 +70,7 @@ public class WmTaskSubmissionPercentRuleServiceImpl
|
|
|
Map<Integer, Map<String, List<WmTaskSubmissionPercentRule>>> deptsMap = percentRules.stream()
|
|
|
.collect(Collectors.groupingBy(WmTaskSubmissionPercentRule::getDeptId, Collectors.groupingBy(WmTaskSubmissionPercentRule::getBatchId)));
|
|
|
|
|
|
+ log.info("积分校验规则:{}, \n积分校验规则分组:{}", percentRules, deptsMap);
|
|
|
deptsMap.forEach((dptId, batchRules) -> {
|
|
|
// 查询taskType
|
|
|
List<WmTaskType> taskTypeList = wmTaskTypeService.list(Wrappers.<WmTaskType>lambdaQuery()
|
|
@@ -85,7 +88,7 @@ public class WmTaskSubmissionPercentRuleServiceImpl
|
|
|
.flatMap(percentRule -> Arrays.stream(percentRule.getRule().getTaskTypeIds()))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
- List<String> toCheckTaskTypes = null;
|
|
|
+ List<String> toCheckTaskTypes;
|
|
|
if (checkTaskTypeList != null) {
|
|
|
// 把要校验的任务 和 已配置的规则任务 做交集,得到实际需要校验的任务类型
|
|
|
toCheckTaskTypes = new ArrayList<>(CollUtil.intersection(allTaskTypeIds, checkTaskTypeList));
|
|
@@ -93,6 +96,9 @@ public class WmTaskSubmissionPercentRuleServiceImpl
|
|
|
toCheckTaskTypes = allTaskTypeIds;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ log.info("待校验任务类型:{}", String.join(",", toCheckTaskTypes));
|
|
|
+
|
|
|
if (CollUtil.isEmpty(toCheckTaskTypes)) {
|
|
|
return;
|
|
|
}
|
|
@@ -115,12 +121,14 @@ public class WmTaskSubmissionPercentRuleServiceImpl
|
|
|
if (CollectionUtil.isNotEmpty(wmTaskList)) {
|
|
|
int totalScore = scorePackage.getScore();
|
|
|
int partScore = wmTaskList.stream().mapToInt(WmTask::getScore).sum();
|
|
|
- if (partScore * 100.0 / totalScore > Float.parseFloat(rule.getLimitPercent())) {
|
|
|
+ double rate = partScore * 100.0 / totalScore;
|
|
|
+ if (rate - Double.parseDouble(rule.getLimitPercent()) >= 0.01) {
|
|
|
+ log.info("两位小数精度校验通过");
|
|
|
failFlag.set(true);
|
|
|
-
|
|
|
String taskTypeNames = toCheckTaskTypes.stream().map(taskTypeIdMap::get).collect(Collectors.joining("、"));
|
|
|
message.set(String.format("%s任务类型的任务总积分不得大于积分包值的%s%%", taskTypeNames, rule.getLimitPercent()));
|
|
|
}
|
|
|
+ log.info("totalScore:{}, partScore:{},rate:{}%, ruleLimitPercent:{}%", totalScore, partScore, rate, rule.getLimitPercent());
|
|
|
}
|
|
|
}
|
|
|
});
|