/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.sxkj.gd.workorder.service.impl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.secure.utils.AuthUtil; import org.sxkj.gd.workorder.entity.GdClueEventStatusFlowEntity; import org.sxkj.gd.workorder.enums.EventStatusEnum; import org.sxkj.gd.workorder.mapper.GdClueEventStatusFlowMapper; import org.sxkj.gd.workorder.service.IGdClueEventStatusFlowService; import org.sxkj.gd.workorder.vo.GdClueEventStatusFlowVO; import org.springframework.stereotype.Service; import org.springblade.core.mp.base.BaseServiceImpl; import java.util.Date; import java.util.List; /** * 事件状态流转履历表 服务实现类 * * @author system * @since 2026-07-29 */ @Slf4j @Service @AllArgsConstructor public class GdClueEventStatusFlowServiceImpl extends BaseServiceImpl implements IGdClueEventStatusFlowService { /** * 根据事件ID查询状态流转记录列表 *

* 步骤: * 1. 参数校验 * 2. 查询状态流转记录列表 * 3. 补充状态名称 *

* * @param eventId 事件ID * @return 状态流转记录列表 */ @Override public List getStatusFlowsByEventId(Long eventId) { // 1. 参数校验 if (eventId == null) { throw new RuntimeException("事件ID不能为空"); } // 2. 查询状态流转记录列表 List flows = baseMapper.selectStatusFlowsByEventId(eventId); // 3. 补充状态名称 if (flows != null && !flows.isEmpty()) { flows.forEach(flow -> { // 补充变更前状态名称 if (flow.getOldStatus() != null) { flow.setOldStatusName(EventStatusEnum.getNameByCode(flow.getOldStatus())); } // 补充变更后状态名称 if (flow.getNewStatus() != null) { flow.setNewStatusName(EventStatusEnum.getNameByCode(flow.getNewStatus())); } }); } return flows; } /** * 插入状态流转记录 *

* 步骤: * 1. 参数校验 * 2. 构建状态流转记录实体 * 3. 保存状态流转记录 *

* * @param eventId 事件ID * @param oldStatus 变更前状态 * @param newStatus 变更后状态 * @param operateContent 操作备注 * @param operateTime 操作时间 * @return 是否成功 */ @Override public boolean insertStatusFlow(Long eventId, Integer oldStatus, Integer newStatus, String operateContent, Date operateTime) { // 1. 参数校验 if (eventId == null) { throw new RuntimeException("事件ID不能为空"); } if (newStatus == null) { throw new RuntimeException("目标状态不能为空"); } // 2. 构建状态流转记录实体 GdClueEventStatusFlowEntity flowEntity = new GdClueEventStatusFlowEntity(); flowEntity.setEventId(eventId); flowEntity.setOldStatus(oldStatus); flowEntity.setNewStatus(newStatus); flowEntity.setOperateContent(operateContent); flowEntity.setOperateTime(operateTime != null ? operateTime : new Date()); flowEntity.setOperateUser(AuthUtil.getUserId()); flowEntity.setOperateDept(Long.valueOf(AuthUtil.getDeptId())); flowEntity.setCreateUser(AuthUtil.getUserId()); flowEntity.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); flowEntity.setCreateTime(new Date()); // 3. 保存状态流转记录 return save(flowEntity); } }