package com.gkhy.safePlatform.safeCheck.service.baseService.impl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.gkhy.safePlatform.commons.enums.E;
|
import com.gkhy.safePlatform.commons.enums.ResultCodes;
|
import com.gkhy.safePlatform.commons.exception.AusinessException;
|
import com.gkhy.safePlatform.commons.exception.BusinessException;
|
import com.gkhy.safePlatform.safeCheck.entity.SafeCheckWork;
|
import com.gkhy.safePlatform.safeCheck.repository.SafeCheckWorkRepository;
|
import com.gkhy.safePlatform.safeCheck.service.baseService.SafeCheckWorkService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.Date;
|
import java.util.List;
|
|
@Service("SafeCheckWorkService")
|
public class SafeCheckWorkServiceImpl extends ServiceImpl<SafeCheckWorkRepository, SafeCheckWork> implements SafeCheckWorkService {
|
|
@Autowired
|
private SafeCheckWorkRepository safeCheckWorkRepository;
|
|
/**
|
* @description 新建一个调度记录
|
*/
|
@Override
|
public int saveWork(SafeCheckWork work) {
|
int insertResult = safeCheckWorkRepository.insert(work);
|
return insertResult;
|
}
|
|
/**
|
* @description 根据巡检单元id查询对应的调度信息记录
|
*/
|
@Override
|
public SafeCheckWork getWorkByTaskUnitId(Long taskUnitId, int deleteStatus) {
|
SafeCheckWork work = safeCheckWorkRepository.getWorkByTaskUnitId(taskUnitId,deleteStatus);
|
if (work == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"无此任务单元对应的调度信息");
|
}
|
return work;
|
}
|
|
/**
|
* @description 根据调度信息id删除调度记录
|
*/
|
@Override
|
public int deleteWorkById(SafeCheckWork work, List<Integer> workStatus,int deleteStatus) {
|
int deleteResult = safeCheckWorkRepository.deleteWorkById(work,workStatus,deleteStatus);
|
return deleteResult;
|
}
|
|
/**
|
* @description 根据workid更新work的状态
|
*/
|
@Override
|
public void updateWorkStatusById(SafeCheckWork work, int deleteStatus) {
|
int updateResult = safeCheckWorkRepository.updateWorkStatusById(work,deleteStatus);
|
if (updateResult == 0){
|
throw new AusinessException(E.UPDATE_FAIL,"调用数据状态变更失败");
|
}
|
}
|
|
/**
|
* @description 根据workid更新任务单元中主部分关于调度的信息
|
*/
|
@Override
|
public void updateWorkInfoById(SafeCheckWork newWork, int deleteStatus) {
|
int updateResult = safeCheckWorkRepository.updateWorkInfoById(newWork,deleteStatus);
|
if (updateResult == 0){
|
throw new AusinessException(E.UPDATE_FAIL,"任务单元信息修改失败");
|
}
|
}
|
|
/**
|
* @description 获取未来30分钟内的任务单元
|
*/
|
@Override
|
public List<SafeCheckWork> findActiveWorkListByTime(Date startTime, Date endTime,int status) {
|
List<SafeCheckWork> safeCheckWorkList = safeCheckWorkRepository.findActiveWorkListByTime(startTime,endTime,status);
|
return safeCheckWorkList;
|
}
|
|
/**
|
* @description 根据work的id获取work调度表的记录
|
*/
|
@Override
|
public SafeCheckWork getWorkById(Long workId) {
|
SafeCheckWork work = safeCheckWorkRepository.getWorkById(workId);
|
if (work == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"数据库无对应的调度信息");
|
}
|
return work;
|
}
|
|
/**
|
* @description 根据workid将work状态由调度中状态改为开启状态
|
*/
|
@Override
|
public int resetWorkStatus(SafeCheckWork work, Byte newStatus) {
|
int updateResult = safeCheckWorkRepository.resetWorkStatus(work,newStatus);
|
if (updateResult == 0){
|
throw new AusinessException(E.UPDATE_FAIL,"任务单元状态变更失败【调度中--->开启】");
|
}
|
return updateResult;
|
}
|
|
/**
|
* @description 获取当前异常调度信息(下次通知时间在当前时间之前的)
|
*/
|
@Override
|
public List<SafeCheckWork> findFaildScheduleList(Date nowTime, Byte openStatus,Byte dispatchingStatus) {
|
List<SafeCheckWork> safeCheckWorkList = safeCheckWorkRepository.findFaildScheduleList(nowTime,openStatus,dispatchingStatus);
|
return safeCheckWorkList;
|
}
|
|
/**
|
* @description 根据work的id和work状态查询work
|
*/
|
@Override
|
public SafeCheckWork getWorkByIdAndWorkStatus(Long workId, Byte status) {
|
SafeCheckWork safeCheckWork = safeCheckWorkRepository.getWorkByIdAndWorkStatus(workId,status);
|
return safeCheckWork;
|
}
|
}
|