| | |
| | | import org.sxkj.common.utils.OrderNumUtils; |
| | | import org.sxkj.gd.workorder.entity.GdClueEventEntity; |
| | | import org.sxkj.gd.workorder.entity.GdTaskResultEntity; |
| | | import org.sxkj.gd.workorder.enums.EventStatusEnum; |
| | | import org.sxkj.gd.workorder.excel.GdClueEventExcel; |
| | | import org.sxkj.gd.workorder.mapper.GdClueEventMapper; |
| | | import org.sxkj.gd.workorder.param.GdClueEventDistributeParam; |
| | | import org.sxkj.gd.workorder.param.GdClueEventRejectParam; |
| | | import org.sxkj.gd.workorder.param.GdClueEventStatusUpdateParam; |
| | | import org.sxkj.gd.workorder.service.IGdClueEventService; |
| | | import org.sxkj.gd.workorder.service.IGdClueEventStatusFlowService; |
| | | import org.sxkj.gd.workorder.service.IGdTaskResultService; |
| | | import org.sxkj.gd.workorder.vo.GdClueEventCountVO; |
| | | import org.sxkj.gd.workorder.vo.GdClueEventListVO; |
| | |
| | | public class GdClueEventServiceImpl extends BaseServiceImpl<GdClueEventMapper, GdClueEventEntity> implements IGdClueEventService { |
| | | |
| | | private final IGdTaskResultService gdTaskResultService; |
| | | private final IGdClueEventStatusFlowService gdClueEventStatusFlowService; |
| | | |
| | | @Override |
| | | public IPage<GdClueEventVO> selectGdClueEventPage(IPage<GdClueEventVO> page, GdClueEventVO gdClueEvent) { |
| | |
| | | |
| | | @Override |
| | | public GdClueEventCountVO getGdClueEventCount(String keyword) { |
| | | // 1. 获取当前用户部门ID和用户ID |
| | | Long deptId = Long.valueOf(AuthUtil.getDeptId()); |
| | | Long userId = AuthUtil.getUserId(); |
| | | |
| | | // 2. 查询统计数据 |
| | | GdClueEventCountVO countVO = baseMapper.selectGdClueEventCount(deptId, userId, keyword); |
| | | |
| | | // 3. 处理空结果,返回默认值 |
| | | if (countVO == null) { |
| | | GdClueEventCountVO empty = new GdClueEventCountVO(); |
| | | empty.setTotalCount(0L); |
| | | empty.setMyCount(0L); |
| | | empty.setReturnedCount(0L); |
| | | empty.setDisposedCount(0L); |
| | | empty.setCompletedCount(0L); |
| | | return empty; |
| | | } |
| | | |
| | | // 4. 返回统计结果 |
| | | return countVO; |
| | | } |
| | | |
| | |
| | | return saveOrUpdate(gdClueEvent); |
| | | } |
| | | |
| | | /** |
| | | * 更新事件状态 |
| | | * <p> |
| | | * 步骤: |
| | | * 1. 参数校验 |
| | | * 2. 查询事件信息 |
| | | * 3. 校验状态流转合法性 |
| | | * 4. 更新事件状态 |
| | | * 5. 插入状态流转记录 |
| | | * </p> |
| | | * |
| | | * @param updateParam 状态更新参数 |
| | | * @return 是否操作成功 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateEventStatus(GdClueEventStatusUpdateParam updateParam) { |
| | | // 1. 参数校验 |
| | | if (updateParam == null || updateParam.getEventId() == null) { |
| | | throw new RuntimeException("参数不能为空"); |
| | | } |
| | | if (updateParam.getTargetStatus() == null) { |
| | | throw new RuntimeException("目标状态不能为空"); |
| | | } |
| | | |
| | | // 2. 查询事件信息 |
| | | GdClueEventEntity eventEntity = getById(updateParam.getEventId()); |
| | | if (eventEntity == null || (eventEntity.getIsDeleted() != null && eventEntity.getIsDeleted() != 0)) { |
| | | throw new RuntimeException("事件不存在"); |
| | | } |
| | | |
| | | Integer oldStatus = eventEntity.getEventStatus(); |
| | | Integer targetStatus = updateParam.getTargetStatus(); |
| | | |
| | | // 3. 校验状态流转合法性 |
| | | if (!EventStatusEnum.isValidCode(targetStatus)) { |
| | | throw new RuntimeException("目标状态编码无效"); |
| | | } |
| | | |
| | | if (!EventStatusEnum.isValidTransition(oldStatus, targetStatus)) { |
| | | String oldStatusName = EventStatusEnum.getNameByCode(oldStatus); |
| | | String newStatusName = EventStatusEnum.getNameByCode(targetStatus); |
| | | throw new RuntimeException(String.format("状态流转非法:不允许从[%s]流转到[%s]", oldStatusName, newStatusName)); |
| | | } |
| | | |
| | | // 4. 更新事件状态 |
| | | eventEntity.setEventStatus(targetStatus); |
| | | eventEntity.setUpdateUser(AuthUtil.getUserId()); |
| | | eventEntity.setUpdateTime(new Date()); |
| | | if (!updateById(eventEntity)) { |
| | | throw new RuntimeException("更新事件状态失败"); |
| | | } |
| | | |
| | | // 5. 插入状态流转记录 |
| | | gdClueEventStatusFlowService.insertStatusFlow( |
| | | updateParam.getEventId(), |
| | | oldStatus, |
| | | targetStatus, |
| | | updateParam.getOperateContent(), |
| | | updateParam.getOperateTime() != null ? updateParam.getOperateTime() : new Date() |
| | | ); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | } |