|
|
@@ -808,23 +808,24 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
.or().eq(WorkOrder::getVerifyUser, userId));
|
|
|
}
|
|
|
|
|
|
- /** 移动端“我的工单/待办工单”最终数据范围。 */
|
|
|
+ /**
|
|
|
+ * 移动端“我的工单/待办工单”最终数据范围。
|
|
|
+ *
|
|
|
+ * <p>设备所属公司范围只用于“待派单 + 派单权限”场景:待派单无设备工单,
|
|
|
+ * 有派单权限即可查看;有设备工单则限制为当前公司设备(含共享类型 4)。
|
|
|
+ * 工单进入派单后,统一按创建人、责任人、核验人控制可见范围。</p>
|
|
|
+ */
|
|
|
private void applyMobileScope(LambdaQueryWrapper<WorkOrder> wrapper, Long userId, boolean pending) {
|
|
|
String companySql = currentCompanyEquipmentSql();
|
|
|
int hasDispatch = SecurityUtils.hasPermi(PERM_DISPATCH) ? 1 : 0;
|
|
|
if (pending) {
|
|
|
- wrapper.apply("((device_id IS NOT NULL AND " + companySql + " AND (" +
|
|
|
- "({1}=1 AND order_status=0) OR " +
|
|
|
- "(receive_user={0} AND order_status IN (1,2,3,6)) OR " +
|
|
|
- "(verify_user={0} AND (order_status=4 OR (order_status=3 AND delay_apply_status=1))))) OR " +
|
|
|
- "(device_id IS NULL AND (((create_by={0} AND {1}=1 AND order_status=0)) OR " +
|
|
|
+ wrapper.apply("(((order_status=0 AND {1}=1) AND (device_id IS NULL OR " + companySql + ")) OR " +
|
|
|
"(receive_user={0} AND order_status IN (1,2,3,6)) OR " +
|
|
|
- "(verify_user={0} AND (order_status=4 OR (order_status=3 AND delay_apply_status=1))))))",
|
|
|
+ "(verify_user={0} AND (order_status=4 OR (order_status=3 AND delay_apply_status=1))))",
|
|
|
userId, hasDispatch);
|
|
|
} else {
|
|
|
- wrapper.apply("((device_id IS NOT NULL AND " + companySql + " AND " +
|
|
|
- "(create_by={0} OR receive_user={0} OR verify_user={0} OR ({1}=1 AND order_status=0))) OR " +
|
|
|
- "(device_id IS NULL AND (create_by={0} OR receive_user={0} OR verify_user={0})))",
|
|
|
+ wrapper.apply("(((order_status=0 AND {1}=1) AND (device_id IS NULL OR " + companySql + ")) OR " +
|
|
|
+ "(create_by={0} OR receive_user={0} OR verify_user={0}))",
|
|
|
userId, hasDispatch);
|
|
|
}
|
|
|
}
|
|
|
@@ -846,13 +847,15 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
|
|
|
private boolean isMobileManagementVisible(WorkOrder order, Long userId) {
|
|
|
if (order == null || userId == null) return false;
|
|
|
+ boolean dispatchable = Objects.equals(order.getOrderStatus(), WorkOrderStatusEnum.PENDING_DISPATCH.getCode())
|
|
|
+ && SecurityUtils.hasPermi(PERM_DISPATCH);
|
|
|
+ if (dispatchable) {
|
|
|
+ return StringUtils.isEmpty(order.getDeviceId()) || isDeviceInCurrentCompany(order.getDeviceId());
|
|
|
+ }
|
|
|
boolean participant = Objects.equals(order.getCreateBy(), userId)
|
|
|
|| Objects.equals(order.getReceiveUser(), userId)
|
|
|
|| Objects.equals(order.getVerifyUser(), userId);
|
|
|
- if (StringUtils.isEmpty(order.getDeviceId())) return participant;
|
|
|
- return isDeviceInCurrentCompany(order.getDeviceId())
|
|
|
- && (participant || (SecurityUtils.hasPermi(PERM_DISPATCH)
|
|
|
- && Objects.equals(order.getOrderStatus(), WorkOrderStatusEnum.PENDING_DISPATCH.getCode())));
|
|
|
+ return participant;
|
|
|
}
|
|
|
|
|
|
private boolean isDeviceInCurrentCompany(String deviceId) {
|
|
|
@@ -870,11 +873,8 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
}
|
|
|
|
|
|
private void requireDispatchScope(WorkOrder order) {
|
|
|
- Long userId = currentUserId();
|
|
|
if (StringUtils.isEmpty(order.getDeviceId())) {
|
|
|
- if (!Objects.equals(order.getCreateBy(), userId)) {
|
|
|
- throw new ServiceException("无设备工单仅创建人可以派单");
|
|
|
- }
|
|
|
+ // 派单接口已由 Controller 校验 ops:workOrder:dispatch 权限;无设备工单不再限制创建人。
|
|
|
return;
|
|
|
}
|
|
|
requireDeviceCompanyScope(order);
|