| | |
| | | */ |
| | | package org.sxkj.gd.workorder.service.impl; |
| | | |
| | | import org.sxkj.gd.workorder.entity.GdClueEventEntity; |
| | | import org.sxkj.gd.workorder.vo.GdClueEventVO; |
| | | import org.sxkj.gd.workorder.excel.GdClueEventExcel; |
| | | import org.sxkj.gd.workorder.mapper.GdClueEventMapper; |
| | | import org.sxkj.gd.workorder.service.IGdClueEventService; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.sxkj.gd.workorder.entity.GdClueEventEntity; |
| | | import org.sxkj.gd.workorder.entity.GdTaskResultEntity; |
| | | 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.service.IGdClueEventService; |
| | | import org.sxkj.gd.workorder.service.IGdTaskResultService; |
| | | import org.sxkj.gd.workorder.vo.GdClueEventVO; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @since 2026-01-14 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class GdClueEventServiceImpl extends BaseServiceImpl<GdClueEventMapper, GdClueEventEntity> implements IGdClueEventService { |
| | | |
| | | private final IGdTaskResultService gdTaskResultService; |
| | | |
| | | @Override |
| | | public IPage<GdClueEventVO> selectGdClueEventPage(IPage<GdClueEventVO> page, GdClueEventVO gdClueEvent) { |
| | | return page.setRecords(baseMapper.selectGdClueEventPage(page, gdClueEvent)); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<GdClueEventVO> selectGdClueEventList(IPage<GdClueEventVO> page, Wrapper<GdClueEventEntity> queryWrapper) { |
| | | return page.setRecords(baseMapper.selectGdClueEventList(page, queryWrapper)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean distributeClueEvent(GdClueEventDistributeParam distributeParam) { |
| | | GdTaskResultEntity taskResult = gdTaskResultService.getById(distributeParam.getResultId()); |
| | | if (taskResult == null || (taskResult.getIsDeleted() != null && taskResult.getIsDeleted() != 0)) { |
| | | throw new RuntimeException("成果不存在"); |
| | | } |
| | | if (taskResult.getDistributeStatus() != null && taskResult.getDistributeStatus() == 1) { |
| | | throw new RuntimeException("成果已分发,无法再次分发"); |
| | | } |
| | | GdClueEventEntity clueEvent = new GdClueEventEntity(); |
| | | clueEvent.setResultId(distributeParam.getResultId()); |
| | | clueEvent.setWorkOrderId(distributeParam.getWorkOrderId()); |
| | | clueEvent.setDisposeUser(distributeParam.getDisposeUser()); |
| | | clueEvent.setDisposeDept(distributeParam.getDisposeDept()); |
| | | clueEvent.setLongitude(distributeParam.getLongitude()); |
| | | clueEvent.setLatitude(distributeParam.getLatitude()); |
| | | clueEvent.setEventStatus(1); |
| | | if (StringUtil.isBlank(distributeParam.getAreaCode())) { |
| | | clueEvent.setAreaCode(taskResult.getAreaCode()); |
| | | } else { |
| | | clueEvent.setAreaCode(distributeParam.getAreaCode()); |
| | | } |
| | | clueEvent.setCreateUser(AuthUtil.getUserId()); |
| | | clueEvent.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | clueEvent.setCreateTime(new Date()); |
| | | if (!save(clueEvent)) { |
| | | throw new RuntimeException("事件分发失败"); |
| | | } |
| | | taskResult.setDistributeStatus(1); |
| | | taskResult.setUpdateUser(AuthUtil.getUserId()); |
| | | taskResult.setUpdateTime(new Date()); |
| | | if (!gdTaskResultService.updateById(taskResult)) { |
| | | throw new RuntimeException("成果状态更新失败"); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean rejectClueEvent(GdClueEventRejectParam rejectParam) { |
| | | GdClueEventEntity clueEvent = getById(rejectParam.getEventId()); |
| | | if (clueEvent == null || (clueEvent.getIsDeleted() != null && clueEvent.getIsDeleted() != 0)) { |
| | | throw new RuntimeException("事件不存在"); |
| | | } |
| | | if (clueEvent.getEventStatus() == null || clueEvent.getEventStatus() != 1) { |
| | | throw new RuntimeException("事件当前状态无法驳回"); |
| | | } |
| | | clueEvent.setEventStatus(2); |
| | | clueEvent.setUpdateUser(AuthUtil.getUserId()); |
| | | clueEvent.setUpdateTime(new Date()); |
| | | if (!updateById(clueEvent)) { |
| | | throw new RuntimeException("事件驳回失败"); |
| | | } |
| | | GdTaskResultEntity taskResult = gdTaskResultService.getById(clueEvent.getResultId()); |
| | | if (taskResult == null || (taskResult.getIsDeleted() != null && taskResult.getIsDeleted() != 0)) { |
| | | throw new RuntimeException("成果不存在"); |
| | | } |
| | | taskResult.setDistributeStatus(2); |
| | | taskResult.setUpdateUser(AuthUtil.getUserId()); |
| | | taskResult.setUpdateTime(new Date()); |
| | | if (!gdTaskResultService.updateById(taskResult)) { |
| | | throw new RuntimeException("成果状态更新失败"); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public List<GdClueEventExcel> exportGdClueEvent(Wrapper<GdClueEventEntity> queryWrapper) { |