feat(ops): add-iot-clean-order-integration阶段三-业务执行与审计

This commit is contained in:
lzh
2026-01-17 17:20:35 +08:00
parent de427b15ab
commit 82966dc61b
14 changed files with 1203 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
package com.viewsh.module.ops.dal.dataobject.log;
import com.baomidou.mybatisplus.annotation.TableField;
import com.viewsh.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import java.time.LocalDateTime;
import java.util.Map;
/**
* 保洁业务日志 DO
*
* @author lzh
*/
@TableName(value = "ops_order_clean_log", autoResultMap = true)
@KeySequence("ops_order_clean_log_seq")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OpsOrderCleanLogDO extends BaseDO {
/**
* 日志ID
*/
@TableId
private Long id;
/**
* 事件发生时间
*/
private LocalDateTime eventTime;
/**
* 日志级别INFO=信息/WARN=警告/ERROR=错误)
*/
private String eventLevel;
/**
* 领域RULE=规则引擎/DISPATCH=调度/BADGE=工牌/BEACON=信标/SYSTEM=系统)
*
* 枚举 {@link com.viewsh.module.ops.enums.EventDomainEnum}
*/
private String eventDomain;
/**
* 事件类型
*/
private String eventType;
/**
* 关联工单ID
*
* 关联 {@link com.viewsh.module.ops.dal.dataobject.workorder.OpsOrderDO#getId()}
*/
private Long opsOrderId;
/**
* 区域ID
*
* 关联 {@link com.viewsh.module.ops.dal.dataobject.area.OpsBusAreaDO#getId()}
*/
private Long areaId;
/**
* 保洁员ID
*/
private Long cleanerId;
/**
* 设备ID工牌/信标)
*/
private Long deviceId;
/**
* 可读日志内容
*/
private String eventMessage;
/**
* 结构化上下文
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Map<String, Object> eventPayload;
}

View File

@@ -118,6 +118,38 @@ public class OpsOrderDO extends BaseDO {
* Flowable流程实例ID预留
*/
private String flowInstanceId;
/**
* 触发来源IOT_TRAFFIC=客流阈值/IOT_BEACON=蓝牙信标/IOT_SIGNAL_LOSS=信号丢失超时)
* <p>
* 记录工单是由IoT设备的哪个检测规则触发的
*/
private String triggerSource;
/**
* 触发规则ID关联 ops_area_device_relation.id
* <p>
* 记录具体是哪个设备关联配置触发的工单
*/
private Long triggerRuleId;
/**
* 触发设备ID关联 iot_device.id
* <p>
* 记录触发工单的IoT设备如客流计数器、蓝牙信标
*/
private Long triggerDeviceId;
/**
* 触发设备Key冗余便于查询
*/
private String triggerDeviceKey;
/**
* 受理人工牌设备ID关联 iot_device.id
* <p>
* 记录分配处理此工单的保洁员的工牌设备ID用于自动到岗/完成检测
*/
private Long assigneeDeviceId;
/**
* 受理人工牌设备Key冗余便于查询
*/
private String assigneeDeviceKey;
// ==================== 便捷方法 ====================

View File

@@ -0,0 +1,46 @@
package com.viewsh.module.ops.dal.mysql.log;
import com.viewsh.framework.mybatis.core.mapper.BaseMapperX;
import com.viewsh.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.viewsh.module.ops.dal.dataobject.log.OpsOrderCleanLogDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 保洁业务日志 Mapper
*
* @author lzh
*/
@Mapper
public interface OpsOrderCleanLogMapper extends BaseMapperX<OpsOrderCleanLogDO> {
/**
* 根据工单ID查询日志
*/
default List<OpsOrderCleanLogDO> selectListByOpsOrderId(Long opsOrderId) {
return selectList(new LambdaQueryWrapperX<OpsOrderCleanLogDO>()
.eq(OpsOrderCleanLogDO::getOpsOrderId, opsOrderId)
.orderByDesc(OpsOrderCleanLogDO::getEventTime));
}
/**
* 根据保洁员查询日志
*/
default List<OpsOrderCleanLogDO> selectListByCleanerId(Long cleanerId) {
return selectList(new LambdaQueryWrapperX<OpsOrderCleanLogDO>()
.eq(OpsOrderCleanLogDO::getCleanerId, cleanerId)
.orderByDesc(OpsOrderCleanLogDO::getEventTime));
}
/**
* 根据事件领域和类型查询日志
*/
default List<OpsOrderCleanLogDO> selectListByDomainAndType(String eventDomain, String eventType) {
return selectList(new LambdaQueryWrapperX<OpsOrderCleanLogDO>()
.eq(OpsOrderCleanLogDO::getEventDomain, eventDomain)
.eq(OpsOrderCleanLogDO::getEventType, eventType)
.orderByDesc(OpsOrderCleanLogDO::getEventTime));
}
}

View File

@@ -106,4 +106,16 @@ public interface OpsOrderService {
*/
void cancelOrder(Long orderId, String reason, OperatorTypeEnum operatorType, Long operatorId);
/**
* 更新工单集成字段IoT 设备触发信息)
* <p>
* 用于更新工单的触发来源、触发设备、受理人工牌等集成相关字段
*
* @param orderId 工单ID
* @param triggerSource 触发来源IOT_TRAFFIC/IOT_BEACON/IOT_SIGNAL_LOSS
* @param triggerDeviceId 触发设备ID
* @param triggerDeviceKey 触发设备Key
*/
void updateIntegrationFields(Long orderId, String triggerSource, Long triggerDeviceId, String triggerDeviceKey);
}

View File

@@ -281,6 +281,29 @@ public class OpsOrderServiceImpl implements OpsOrderService {
log.info("取消工单成功: orderId={}, reason={}", orderId, reason);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateIntegrationFields(Long orderId, String triggerSource, Long triggerDeviceId, String triggerDeviceKey) {
// 1. 查询工单
OpsOrderDO order = opsOrderMapper.selectById(orderId);
if (order == null) {
throw new RuntimeException("工单不存在: " + orderId);
}
// 2. 更新集成字段
OpsOrderDO updateObj = new OpsOrderDO();
updateObj.setId(orderId);
updateObj.setTriggerSource(triggerSource);
updateObj.setTriggerDeviceId(triggerDeviceId);
updateObj.setTriggerDeviceKey(triggerDeviceKey);
// 3. 执行更新
opsOrderMapper.updateById(updateObj);
log.info("更新工单集成字段成功: orderId={}, triggerSource={}, triggerDeviceId={}",
orderId, triggerSource, triggerDeviceId);
}
/**
* 生成工单编号
* 格式WO + yyyyMMddHHmmss + 3位随机数