✨ 节点卡片下发整单异常标记与相关异常列表,列表支持按运单精确过滤
This commit is contained in:
+18
@@ -1103,6 +1103,24 @@ public class DriverWaybillServiceImpl implements IDriverWaybillService {
|
||||
}
|
||||
}
|
||||
|
||||
// 「整单异常」标签与相关异常 id:整单异常不归属任何节点(节点编码为空),
|
||||
// 它作用于整张运单,所以每个可打卡节点——包括已打卡的与在途的——都挂标签、都算相关。
|
||||
// 相关只有两种来源:归属本节点的、以及整单的;被前序节点异常牵连阻断的节点
|
||||
// 只是不能打卡,那条异常并不归属它,故不进入它的相关列表。
|
||||
List<ExceptionDisposal> unresolved = unresolvedExceptions(waybill.getId());
|
||||
List<String> unresolvedCodes = unresolved.stream()
|
||||
.map(item -> Func.toStr(item.getNodeCode(), "").trim())
|
||||
.collect(Collectors.toList());
|
||||
List<Long> unresolvedIds = unresolved.stream()
|
||||
.map(ExceptionDisposal::getId)
|
||||
.collect(Collectors.toList());
|
||||
boolean hasWaybillException = WaybillProcessSupport.hasWaybillLevelException(unresolvedCodes);
|
||||
for (DriverPunchNodeVO vo : nodes) {
|
||||
vo.setHasWaybillException(hasWaybillException);
|
||||
vo.setRelatedExceptionIds(
|
||||
WaybillProcessSupport.relatedExceptionIds(vo.getKey(), unresolvedCodes, unresolvedIds));
|
||||
}
|
||||
|
||||
for (DriverPunchNodeVO vo : nodes) {
|
||||
if (!Boolean.TRUE.equals(vo.getDone())
|
||||
&& !Boolean.TRUE.equals(vo.getBlocked())
|
||||
|
||||
+3
@@ -385,6 +385,9 @@ public class ExceptionDisposalServiceImpl
|
||||
private LambdaQueryWrapper<ExceptionDisposal> buildQuery(ExceptionDisposalVO query) {
|
||||
LambdaQueryWrapper<ExceptionDisposal> wrapper = Wrappers.<ExceptionDisposal>lambdaQuery()
|
||||
.eq(ExceptionDisposal::getIsDeleted, 0)
|
||||
// 按运单精确过滤,供司机端「本运单的异常」列表使用。
|
||||
// 不用运单号:它是模糊匹配,YD001 会命中 YD0011。
|
||||
.eq(query.getWaybillId() != null, ExceptionDisposal::getWaybillId, query.getWaybillId())
|
||||
.like(Func.isNotEmpty(query.getWaybillNo()), ExceptionDisposal::getWaybillNo, query.getWaybillNo())
|
||||
.like(Func.isNotEmpty(query.getVehicleNo()), ExceptionDisposal::getVehicleNo, query.getVehicleNo())
|
||||
.like(Func.isNotEmpty(query.getReporterName()), ExceptionDisposal::getReporterName, query.getReporterName())
|
||||
|
||||
+39
@@ -390,6 +390,45 @@ public final class WaybillProcessSupport {
|
||||
return DISPOSAL_COMPLETED.equalsIgnoreCase(status) || DISPOSAL_REVOKED.equalsIgnoreCase(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在未了结的整单异常。
|
||||
* <p>
|
||||
* 整单异常不归属任何过程节点,它的节点编码为空;它作用于整张运单,
|
||||
* 所以该运单每个可打卡节点都要挂上「整单异常」标记。
|
||||
*/
|
||||
public static boolean hasWaybillLevelException(List<String> unresolvedNodeCodes) {
|
||||
if (unresolvedNodeCodes == null) {
|
||||
return false;
|
||||
}
|
||||
return unresolvedNodeCodes.stream().anyMatch(code -> stringVal(code).isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* 与某节点相关的未了结异常 id,一律以字符串返回。
|
||||
* <p>
|
||||
* 相关只有两种来源:归属该节点的异常,以及整单异常(节点编码为空,对每个节点都算相关)。
|
||||
* 被前序节点异常牵连阻断的节点不算相关——它自己并没有出过事。
|
||||
* <p>
|
||||
* 顺序保持入参顺序,调用方按上报时间升序取出未了结异常即可。
|
||||
* id 转成字符串是因为主键是 int64,前端直收数字会丢精度。
|
||||
*/
|
||||
public static List<String> relatedExceptionIds(String nodeKey, List<String> unresolvedNodeCodes,
|
||||
List<Long> unresolvedIds) {
|
||||
if (unresolvedNodeCodes == null || unresolvedIds == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String key = stringVal(nodeKey);
|
||||
List<String> related = new ArrayList<>();
|
||||
int size = Math.min(unresolvedNodeCodes.size(), unresolvedIds.size());
|
||||
for (int i = 0; i < size; i++) {
|
||||
String code = stringVal(unresolvedNodeCodes.get(i));
|
||||
if (code.isEmpty() || code.equalsIgnoreCase(key)) {
|
||||
related.add(String.valueOf(unresolvedIds.get(i)));
|
||||
}
|
||||
}
|
||||
return related;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过程配置里的在途节点 key;配置中无在途节点时返回空串。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user