|
|
|
@ -0,0 +1,84 @@
|
|
|
|
|
package com.ibeetl.jlw.flow.operatescores.entity;
|
|
|
|
|
|
|
|
|
|
import com.ibeetl.jlw.flow.operatescores.service.OperateScoresService;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 流程扣分点
|
|
|
|
|
*/
|
|
|
|
|
@Data
|
|
|
|
|
public class FlowDeductionPoint {
|
|
|
|
|
|
|
|
|
|
private int maxScore;
|
|
|
|
|
private Integer step; // 流程步骤
|
|
|
|
|
private Integer flowId; // 流程ID
|
|
|
|
|
private String desc; // 描述
|
|
|
|
|
private List<String> deductionItems = new ArrayList<>(); // 扣分项
|
|
|
|
|
private FlowDeductionPoint next; // 下一节点
|
|
|
|
|
|
|
|
|
|
public FlowDeductionPoint next(FlowDeductionPoint next) {
|
|
|
|
|
this.setNext(next);
|
|
|
|
|
return next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据未完成的流程进度扣分
|
|
|
|
|
*/
|
|
|
|
|
public int getDeductionScoreByFinishStep(Integer finishStep, List<OperateScores> deductionScores) {
|
|
|
|
|
FlowDeductionPoint node = this;
|
|
|
|
|
while (node.getStep() <= finishStep) {
|
|
|
|
|
if (node.getNext() == null) {
|
|
|
|
|
return 0; // 流程节点全部完成 不扣分
|
|
|
|
|
}
|
|
|
|
|
node = node.getNext();
|
|
|
|
|
}
|
|
|
|
|
// 扣分 = 当前节点所有分数 + 之后节点所有分数 - 当前节点已扣分数
|
|
|
|
|
return node.maxScore + node.getAfterScores() - node.currentDeductionScores(deductionScores);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取当前流程节点以及之后节点的总分数
|
|
|
|
|
*/
|
|
|
|
|
public int getAfterScores() {
|
|
|
|
|
if (this.getNext() == null) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return this.getNext().maxScore + this.getNext().getAfterScores();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 返回当前节点已经扣过的分数,用于防止重复扣分
|
|
|
|
|
*/
|
|
|
|
|
public int currentDeductionScores(List<OperateScores> deductionScores) {
|
|
|
|
|
int totalScore = 0;
|
|
|
|
|
for (OperateScores ds : deductionScores) {
|
|
|
|
|
if (this.deductionItems.contains(ds.getType())) {
|
|
|
|
|
totalScore += ds.getScore() == null ? 0 : ds.getScore();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Math.min(totalScore, this.maxScore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FlowDeductionPoint generate(String prefix, Integer flowId, Integer step, int maxScore,
|
|
|
|
|
int start, int end, List<Integer> excludes) {
|
|
|
|
|
final FlowDeductionPoint fdp = new FlowDeductionPoint();
|
|
|
|
|
fdp.setFlowId(flowId); // 存货质押
|
|
|
|
|
fdp.setDesc(prefix);
|
|
|
|
|
fdp.setStep(step);
|
|
|
|
|
fdp.setMaxScore(maxScore);
|
|
|
|
|
|
|
|
|
|
for (int i = start; i <= end; i++) {
|
|
|
|
|
if (excludes != null && excludes.contains(i)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
String key = prefix + i;
|
|
|
|
|
fdp.deductionItems.add(key);
|
|
|
|
|
}
|
|
|
|
|
return fdp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|