|
|
|
@ -225,80 +225,80 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
|
|
|
|
|
public ServiceBody<GetModel> relateSchelduleRule(RelateTerminalListRuleIdVo vo) {
|
|
|
|
|
|
|
|
|
|
GetModel model = new GetModel();
|
|
|
|
|
List<TerminalSchedulesTemp> list = terminalSchedulesTempDao.selectByTermAndChannel(vo.getList(), CommonStatus.DELETE.value());
|
|
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
|
|
|
|
|
|
return Asserts.error("有装置时间尚未下发成功");
|
|
|
|
|
}
|
|
|
|
|
List<RelateTerminalListRuleIdVo.Items> termlist = vo.getList();
|
|
|
|
|
|
|
|
|
|
Integer scheduleid = vo.getScheduleid();
|
|
|
|
|
List<TerminalSchedulesTemp> temps = new ArrayList<>();
|
|
|
|
|
List<Integer> termidlist = new ArrayList<>();
|
|
|
|
|
for (RelateTerminalListRuleIdVo.Items item : termlist) {
|
|
|
|
|
termidlist.add(item.getTermid());
|
|
|
|
|
List<Integer> channelidlist = item.getChannelidlist();
|
|
|
|
|
for (Integer it : channelidlist) {
|
|
|
|
|
TerminalSchedulesTemp temp = new TerminalSchedulesTemp();
|
|
|
|
|
temp.setTermId(item.getTermid());
|
|
|
|
|
temp.setScheduleId(scheduleid);
|
|
|
|
|
temp.setChannelId(it);
|
|
|
|
|
temps.add(temp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
int i = terminalSchedulesTempDao.insertList(temps, CommonStatus.EFFECTIVE.value(), date, date);
|
|
|
|
|
|
|
|
|
|
List<ChannelAndTermDto> terminalsList = terminalsDao.selectByIdList(vo.getList(), CommonStatus.EFFECTIVE.value());
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(termidlist)) {
|
|
|
|
|
return Asserts.error("没有该装置");
|
|
|
|
|
}
|
|
|
|
|
ScheduleAndRuleDto dto = schedulesDao.selectSingle(scheduleid, CommonStatus.EFFECTIVE.value());
|
|
|
|
|
List<ScheduleRuleDto> dtoList = dto.getList();
|
|
|
|
|
if (CollectionUtil.isEmpty(dtoList)) {
|
|
|
|
|
return Asserts.error("没有该拍照时间规则");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuffer timestr = new StringBuffer();
|
|
|
|
|
for (int j = 0; j < dtoList.size(); j++) {
|
|
|
|
|
TerminalPhotosTimeModel.PhotosTimeBean bean = new TerminalPhotosTimeModel.PhotosTimeBean();
|
|
|
|
|
Integer span = dtoList.get(j).getSpan();
|
|
|
|
|
Date startTime = dtoList.get(j).getStartTime();
|
|
|
|
|
Short startHour = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[0]);
|
|
|
|
|
Short startMin = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[1]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date endTime = dtoList.get(j).getEndTime();
|
|
|
|
|
Short endTimeHour = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[0]);
|
|
|
|
|
Short endTimeMin = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[1]);
|
|
|
|
|
|
|
|
|
|
Integer span1 = -1;
|
|
|
|
|
Integer span2 = -1;
|
|
|
|
|
if (span / 60 > 0) {
|
|
|
|
|
span1 = (span / 60);
|
|
|
|
|
span2 = (span % 60);
|
|
|
|
|
} else if (span < 60) {
|
|
|
|
|
span1 = 0;
|
|
|
|
|
span2 = span;
|
|
|
|
|
}
|
|
|
|
|
String string = "--hour1=" + startHour + "\t" + "--min1=" + startMin + "\t" + "--preset1=255 --hour2=" + endTimeHour + "\t" + "--min2=" + endTimeMin + "\t"
|
|
|
|
|
+ "--preset2=255 --hour3=" + span1 + "\t" + "--min3=" + span2 + "\t" + "--preset3=255";
|
|
|
|
|
timestr.append(string);
|
|
|
|
|
}
|
|
|
|
|
for (int x = 0; x < terminalsList.size(); x++) {
|
|
|
|
|
ChannelAndTermDto channelAndTermDto = terminalsList.get(x);
|
|
|
|
|
String cmd = Constants.CMD + "schedule --flag=1 --cmdid=" + channelAndTermDto.getCmdid() + "\t" + "--channel=" + channelAndTermDto.getChannelid() + "\t" +
|
|
|
|
|
timestr.toString();
|
|
|
|
|
ProcessExecUtils.exec(cmd);
|
|
|
|
|
}
|
|
|
|
|
// List<TerminalSchedulesTemp> list = terminalSchedulesTempDao.selectByTermAndChannel(vo.getList(), CommonStatus.DELETE.value());
|
|
|
|
|
// if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
|
//
|
|
|
|
|
// return Asserts.error("有装置时间尚未下发成功");
|
|
|
|
|
// }
|
|
|
|
|
// List<RelateTerminalListRuleIdVo.Items> termlist = vo.getList();
|
|
|
|
|
//
|
|
|
|
|
// Integer scheduleid = vo.getScheduleid();
|
|
|
|
|
// List<TerminalSchedulesTemp> temps = new ArrayList<>();
|
|
|
|
|
// List<Integer> termidlist = new ArrayList<>();
|
|
|
|
|
// for (RelateTerminalListRuleIdVo.Items item : termlist) {
|
|
|
|
|
// termidlist.add(item.getTermid());
|
|
|
|
|
// List<Integer> channelidlist = item.getChannelidlist();
|
|
|
|
|
// for (Integer it : channelidlist) {
|
|
|
|
|
// TerminalSchedulesTemp temp = new TerminalSchedulesTemp();
|
|
|
|
|
// temp.setTermId(item.getTermid());
|
|
|
|
|
// temp.setScheduleId(scheduleid);
|
|
|
|
|
// temp.setChannelId(it);
|
|
|
|
|
// temps.add(temp);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// Date date = new Date();
|
|
|
|
|
// int i = terminalSchedulesTempDao.insertList(temps, CommonStatus.EFFECTIVE.value(), date, date);
|
|
|
|
|
//
|
|
|
|
|
// List<ChannelAndTermDto> terminalsList = terminalsDao.selectByIdList(vo.getList(), CommonStatus.EFFECTIVE.value());
|
|
|
|
|
//
|
|
|
|
|
// if (CollectionUtil.isEmpty(termidlist)) {
|
|
|
|
|
// return Asserts.error("没有该装置");
|
|
|
|
|
// }
|
|
|
|
|
// ScheduleAndRuleDto dto = schedulesDao.selectSingle(scheduleid, CommonStatus.EFFECTIVE.value());
|
|
|
|
|
// List<ScheduleRuleDto> dtoList = dto.getList();
|
|
|
|
|
// if (CollectionUtil.isEmpty(dtoList)) {
|
|
|
|
|
// return Asserts.error("没有该拍照时间规则");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// StringBuffer timestr = new StringBuffer();
|
|
|
|
|
// for (int j = 0; j < dtoList.size(); j++) {
|
|
|
|
|
// TerminalPhotosTimeModel.PhotosTimeBean bean = new TerminalPhotosTimeModel.PhotosTimeBean();
|
|
|
|
|
// Integer span = dtoList.get(j).getSpan();
|
|
|
|
|
// Date startTime = dtoList.get(j).getStartTime();
|
|
|
|
|
// Short startHour = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[0]);
|
|
|
|
|
// Short startMin = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[1]);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// Date endTime = dtoList.get(j).getEndTime();
|
|
|
|
|
// Short endTimeHour = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[0]);
|
|
|
|
|
// Short endTimeMin = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[1]);
|
|
|
|
|
//
|
|
|
|
|
// Integer span1 = -1;
|
|
|
|
|
// Integer span2 = -1;
|
|
|
|
|
// if (span / 60 > 0) {
|
|
|
|
|
// span1 = (span / 60);
|
|
|
|
|
// span2 = (span % 60);
|
|
|
|
|
// } else if (span < 60) {
|
|
|
|
|
// span1 = 0;
|
|
|
|
|
// span2 = span;
|
|
|
|
|
// }
|
|
|
|
|
// String string = "--hour1=" + startHour + "\t" + "--min1=" + startMin + "\t" + "--preset1=255 --hour2=" + endTimeHour + "\t" + "--min2=" + endTimeMin + "\t"
|
|
|
|
|
// + "--preset2=255 --hour3=" + span1 + "\t" + "--min3=" + span2 + "\t" + "--preset3=255";
|
|
|
|
|
// timestr.append(string);
|
|
|
|
|
// }
|
|
|
|
|
// for (int x = 0; x < terminalsList.size(); x++) {
|
|
|
|
|
// ChannelAndTermDto channelAndTermDto = terminalsList.get(x);
|
|
|
|
|
// String cmd = Constants.CMD + "schedule --flag=1 --cmdid=" + channelAndTermDto.getCmdid() + "\t" + "--channel=" + channelAndTermDto.getChannelid() + "\t" +
|
|
|
|
|
// timestr.toString();
|
|
|
|
|
// ProcessExecUtils.exec(cmd);
|
|
|
|
|
// }
|
|
|
|
|
model.setRequestId(Integer.parseInt(Constants.REQUEST_ID.toString()));
|
|
|
|
|
Constants.REQUEST_ID.addAndGet(1);
|
|
|
|
|
if (i != 0) {
|
|
|
|
|
// if (i != 0) {
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
} else {
|
|
|
|
|
return Asserts.error("关联失败");
|
|
|
|
|
}
|
|
|
|
|
// } else {
|
|
|
|
|
// return Asserts.error("关联失败");
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -308,46 +308,49 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
|
|
|
|
|
* @param vo
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public ServiceBody<String> checkScheldule(RelateTerminalListRuleIdVo vo) {
|
|
|
|
|
Integer requestid = 0;
|
|
|
|
|
ArrayList<Integer> intlist = new ArrayList<>();
|
|
|
|
|
RequestResults results = requestResultsDao.selectByRequestId(1);
|
|
|
|
|
/*
|
|
|
|
|
* 如果下发成功
|
|
|
|
|
* 1,将临时表中的数据状态改成1下发成功状态
|
|
|
|
|
* 2,将装置关联拍照时间正式表改为临时表的对应状态
|
|
|
|
|
* 3,将装置自身detial表插入新数据
|
|
|
|
|
* */
|
|
|
|
|
if (results != null) {
|
|
|
|
|
TerminalSchedulesTemp record = new TerminalSchedulesTemp();
|
|
|
|
|
record.setStatus(CommonStatus.EFFECTIVE.value());
|
|
|
|
|
record.setRequestId(requestid);
|
|
|
|
|
terminalSchedulesTempDao.updateByPrimaryKeySelective(record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ArrayList<Integer> id = new ArrayList<>();
|
|
|
|
|
TerminalSchedulesTemp temp1 = terminalSchedulesTempDao.selectByRequestId(id, CommonStatus.EFFECTIVE.value());
|
|
|
|
|
|
|
|
|
|
TerminalSchedules record = new TerminalSchedules();
|
|
|
|
|
record.setChannelId(temp1.getChannelId());
|
|
|
|
|
record.setScheduleId(temp1.getScheduleId());
|
|
|
|
|
record.setTermId(temp1.getTermId());
|
|
|
|
|
terminalSchedulesDao.updateByPrimaryKeySelective(record);//将实际的拍照时间表规则从临时表更新到正式表中
|
|
|
|
|
|
|
|
|
|
// terminalScheduleDetailsDao.deleteByPrimaryKey();//根据装置编号和通道编号删除之前对应的实际拍照时间表详情
|
|
|
|
|
|
|
|
|
|
ArrayList<TerminalScheduleDetails> record1 = new ArrayList<>();
|
|
|
|
|
terminalScheduleDetailsDao.insertList(record1);//插入新的对应的拍照时间表规则详情
|
|
|
|
|
|
|
|
|
|
int i = requestResultsDao.updateByPrimaryKey(new RequestResults());//根据requestid将结果表中的状态修改为已下发
|
|
|
|
|
//end
|
|
|
|
|
|
|
|
|
|
if (i != 0) {
|
|
|
|
|
public ServiceBody<String> checkScheldule(RequestIdListVo vo) {
|
|
|
|
|
// /*
|
|
|
|
|
// * 当定时任务或者用户主动查询下发状态时
|
|
|
|
|
// * */
|
|
|
|
|
// List<Integer> requestidlist = vo.getList();
|
|
|
|
|
// List<RequestResults> resultsList = requestResultsDao.selectByRequestIdList(requestidlist);
|
|
|
|
|
// /*
|
|
|
|
|
// * 如果下发成功
|
|
|
|
|
// * 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<TerminalSchedules> terminalSchedules = new ArrayList<>();
|
|
|
|
|
// for (TerminalSchedulesTemp item : terminalSchedulesTemps) {
|
|
|
|
|
// TerminalSchedules record = new TerminalSchedules();
|
|
|
|
|
// record.setChannelId(item.getChannelId());
|
|
|
|
|
// record.setScheduleId(item.getScheduleId());
|
|
|
|
|
// record.setTermId(item.getTermId());
|
|
|
|
|
// }
|
|
|
|
|
// terminalSchedulesDao.updateList(terminalSchedules);//将实际的拍照时间表规则从临时表更新到正式表中
|
|
|
|
|
//
|
|
|
|
|
//// terminalScheduleDetailsDao.deleteByPrimaryKey();//根据装置编号和通道编号删除之前对应的实际拍照时间表详情
|
|
|
|
|
//
|
|
|
|
|
// ArrayList<TerminalScheduleDetails> record1 = new ArrayList<>();
|
|
|
|
|
// terminalScheduleDetailsDao.insertList(record1);//插入新的对应的拍照时间表规则详情
|
|
|
|
|
//
|
|
|
|
|
// int i = requestResultsDao.updateByPrimaryKey(new RequestResults());//根据requestid将结果表中的状态修改为已下发
|
|
|
|
|
////end
|
|
|
|
|
|
|
|
|
|
// if (i != 0) {
|
|
|
|
|
return Asserts.success("下发成功");
|
|
|
|
|
} else {
|
|
|
|
|
return Asserts.error("关联失败");
|
|
|
|
|
}
|
|
|
|
|
// } else {
|
|
|
|
|
// return Asserts.error("关联失败");
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -359,45 +362,45 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
|
|
|
|
|
*/
|
|
|
|
|
@Transactional
|
|
|
|
|
public ServiceBody<GetModel> getSchedule(RelateTerminalListRuleIdVo vo) {
|
|
|
|
|
GetModel model = new GetModel();
|
|
|
|
|
Integer requestid = 0;
|
|
|
|
|
ArrayList<Integer> intlist = new ArrayList<>();
|
|
|
|
|
RequestResults results = requestResultsDao.selectByRequestId(1);
|
|
|
|
|
/*
|
|
|
|
|
* 如果下发成功
|
|
|
|
|
* 1,将临时表中的数据状态改成1下发成功状态
|
|
|
|
|
* 2,将装置关联拍照时间正式表改为临时表的对应状态
|
|
|
|
|
* 3,将装置自身detial表插入新数据
|
|
|
|
|
* */
|
|
|
|
|
if (results != null) {
|
|
|
|
|
TerminalSchedulesTemp record = new TerminalSchedulesTemp();
|
|
|
|
|
record.setStatus(CommonStatus.EFFECTIVE.value());
|
|
|
|
|
record.setRequestId(requestid);
|
|
|
|
|
terminalSchedulesTempDao.updateByPrimaryKeySelective(record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ArrayList<Integer> id = new ArrayList<>();
|
|
|
|
|
TerminalSchedulesTemp temp1 = terminalSchedulesTempDao.selectByRequestId(id, CommonStatus.EFFECTIVE.value());
|
|
|
|
|
|
|
|
|
|
TerminalSchedules record = new TerminalSchedules();
|
|
|
|
|
record.setChannelId(temp1.getChannelId());
|
|
|
|
|
record.setScheduleId(temp1.getScheduleId());
|
|
|
|
|
record.setTermId(temp1.getTermId());
|
|
|
|
|
terminalSchedulesDao.updateByPrimaryKeySelective(record);//将实际的拍照时间表规则从临时表更新到正式表中
|
|
|
|
|
|
|
|
|
|
terminalScheduleDetailsDao.deleteByPrimaryKey(0);//根据装置编号和通道编号删除之前对应的实际拍照时间表详情
|
|
|
|
|
|
|
|
|
|
ArrayList<TerminalScheduleDetails> record1 = new ArrayList<>();
|
|
|
|
|
terminalScheduleDetailsDao.insertList(record1);//插入新的对应的拍照时间表规则详情
|
|
|
|
|
|
|
|
|
|
int i = requestResultsDao.updateByPrimaryKey(new RequestResults());//根据requestid将结果表中的状态修改为已下发
|
|
|
|
|
//end
|
|
|
|
|
|
|
|
|
|
if (i != 0) {
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
} else {
|
|
|
|
|
return Asserts.error("关联失败");
|
|
|
|
|
}
|
|
|
|
|
// GetModel model = new GetModel();
|
|
|
|
|
// Integer requestid = 0;
|
|
|
|
|
// ArrayList<Integer> intlist = new ArrayList<>();
|
|
|
|
|
// RequestResults results = requestResultsDao.selectByRequestId(1);
|
|
|
|
|
// /*
|
|
|
|
|
// * 如果下发成功
|
|
|
|
|
// * 1,将临时表中的数据状态改成1下发成功状态
|
|
|
|
|
// * 2,将装置关联拍照时间正式表改为临时表的对应状态
|
|
|
|
|
// * 3,将装置自身detial表插入新数据
|
|
|
|
|
// * */
|
|
|
|
|
// if (results != null) {
|
|
|
|
|
// TerminalSchedulesTemp record = new TerminalSchedulesTemp();
|
|
|
|
|
// record.setStatus(CommonStatus.EFFECTIVE.value());
|
|
|
|
|
// record.setRequestId(requestid);
|
|
|
|
|
// terminalSchedulesTempDao.updateByPrimaryKeySelective(record);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// ArrayList<Integer> id = new ArrayList<>();
|
|
|
|
|
// TerminalSchedulesTemp temp1 = terminalSchedulesTempDao.selectByRequestId(id, CommonStatus.EFFECTIVE.value());
|
|
|
|
|
//
|
|
|
|
|
// TerminalSchedules record = new TerminalSchedules();
|
|
|
|
|
// record.setChannelId(temp1.getChannelId());
|
|
|
|
|
// record.setScheduleId(temp1.getScheduleId());
|
|
|
|
|
// record.setTermId(temp1.getTermId());
|
|
|
|
|
// terminalSchedulesDao.updateByPrimaryKeySelective(record);//将实际的拍照时间表规则从临时表更新到正式表中
|
|
|
|
|
//
|
|
|
|
|
// terminalScheduleDetailsDao.deleteByPrimaryKey(0);//根据装置编号和通道编号删除之前对应的实际拍照时间表详情
|
|
|
|
|
//
|
|
|
|
|
// ArrayList<TerminalScheduleDetails> record1 = new ArrayList<>();
|
|
|
|
|
// terminalScheduleDetailsDao.insertList(record1);//插入新的对应的拍照时间表规则详情
|
|
|
|
|
//
|
|
|
|
|
// int i = requestResultsDao.updateByPrimaryKey(new RequestResults());//根据requestid将结果表中的状态修改为已下发
|
|
|
|
|
////end
|
|
|
|
|
|
|
|
|
|
// if (i != 0) {
|
|
|
|
|
return Asserts.success(null);
|
|
|
|
|
// } else {
|
|
|
|
|
// return Asserts.error("关联失败");
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|