|
|
|
@ -29,6 +29,7 @@ import com.shxy.xymanager_dao.dao.*;
|
|
|
|
|
import com.shxy.xymanager_service.service.TerminalScheduleRuleService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
@ -65,6 +66,13 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
|
|
|
|
|
@Autowired
|
|
|
|
|
TerminalScheduleDetailsDao terminalScheduleDetailsDao;
|
|
|
|
|
|
|
|
|
|
@Value("${cma.clientid}")
|
|
|
|
|
public int clientid;
|
|
|
|
|
|
|
|
|
|
@Value("${cma.scheduletype}")
|
|
|
|
|
public int scheduletype;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取时间任务规则列表
|
|
|
|
|
*
|
|
|
|
@ -357,6 +365,71 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*定时任务查询下发*/
|
|
|
|
|
public ServiceBody<String> TimerscheckScheldule() {
|
|
|
|
|
/*
|
|
|
|
|
* 当定时任务或者用户主动查询下发状态时
|
|
|
|
|
* */
|
|
|
|
|
List<Integer> requestidlist = new ArrayList<>();
|
|
|
|
|
List<RequestResults> resultsList = requestResultsDao.selectByTypeAndStatus(scheduletype, clientid, null);
|
|
|
|
|
for (RequestResults item : resultsList) {
|
|
|
|
|
requestidlist.add(item.getRequestId());
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* 如果下发成功
|
|
|
|
|
* 1,将临时表中的数据状态改成1下发成功状态
|
|
|
|
|
* 2,将装置关联拍照时间正式表改为临时表的对应状态
|
|
|
|
|
* 3,将装置自身detial表插入新数据
|
|
|
|
|
* */
|
|
|
|
|
if (CollectionUtil.isEmpty(resultsList)) {
|
|
|
|
|
return Asserts.success("尚未查询到下发数据");
|
|
|
|
|
}
|
|
|
|
|
terminalSchedulesTempDao.updateStatusByRequestIdList(requestidlist, CommonStatus.EFFECTIVE.value(), new Date());
|
|
|
|
|
|
|
|
|
|
List<TerminalSchedulesTemp> terminalSchedulesTemps = terminalSchedulesTempDao.selectByRequestId(requestidlist, CommonStatus.EFFECTIVE.value());
|
|
|
|
|
|
|
|
|
|
ArrayList<TerminalSchedule> terminalSchedules = new ArrayList<>();
|
|
|
|
|
ArrayList<Integer> scheduleidlist = new ArrayList<>();
|
|
|
|
|
for (TerminalSchedulesTemp item : terminalSchedulesTemps) {
|
|
|
|
|
TerminalSchedule record = new TerminalSchedule();
|
|
|
|
|
record.setChannelId(item.getChannelId());
|
|
|
|
|
record.setScheduleId(item.getScheduleId());
|
|
|
|
|
record.setTermId(item.getTermId());
|
|
|
|
|
scheduleidlist.add(item.getScheduleId());
|
|
|
|
|
terminalSchedules.add(record);
|
|
|
|
|
}
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
terminalScheduleDao.insertOrUpdate(terminalSchedules, date, date);//将实际的拍照时间表规则从临时表更新到正式表中
|
|
|
|
|
|
|
|
|
|
ArrayList<Integer> distinct = CollectionUtil.distinct(scheduleidlist);
|
|
|
|
|
List<ScheduleDetails> scheduleDetails = scheduleDetailsDao.selectAllBySceduleidList(distinct);
|
|
|
|
|
ArrayList<TerminalScheduleDetails> terminalScheduleDetails = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < terminalSchedules.size(); i++) {
|
|
|
|
|
for (int j = 0; j < scheduleDetails.size(); j++) {
|
|
|
|
|
TerminalSchedule terminalSchedule = terminalSchedules.get(i);
|
|
|
|
|
ScheduleDetails scheduleDetailsbean = scheduleDetails.get(j);
|
|
|
|
|
if (scheduleDetailsbean.getScheduleId().intValue() == terminalSchedule.getScheduleId().intValue()) {
|
|
|
|
|
TerminalScheduleDetails bean = new TerminalScheduleDetails();
|
|
|
|
|
bean.setTermId(terminalSchedule.getTermId());
|
|
|
|
|
bean.setChannelId(terminalSchedule.getChannelId());
|
|
|
|
|
bean.setStartTime(scheduleDetailsbean.getStartTime());
|
|
|
|
|
bean.setEndTime(scheduleDetailsbean.getEndTime());
|
|
|
|
|
bean.setSpan(scheduleDetailsbean.getSpan());
|
|
|
|
|
terminalScheduleDetails.add(bean);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
terminalScheduleDetailsDao.deleteByTermidAndChannelIdList(terminalSchedules);
|
|
|
|
|
terminalScheduleDetailsDao.insertList(terminalScheduleDetails, date, date);
|
|
|
|
|
int i = requestResultsDao.updateByRequestIdList(requestidlist, CommonStatus.EFFECTIVE.value());//根据requestid将结果表中的状态修改为已下发
|
|
|
|
|
if (i != 0) {
|
|
|
|
|
return Asserts.success("下发成功");
|
|
|
|
|
} else {
|
|
|
|
|
return Asserts.error("关联失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据装置和通道编号查询拍照时间表
|
|
|
|
|
*
|
|
|
|
|