|
|
|
@ -6,10 +6,14 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import com.shxy.xymanager_common.bean.ServiceBody;
|
|
|
|
|
import com.shxy.xymanager_common.constant.Constants;
|
|
|
|
|
import com.shxy.xymanager_common.dto.ChannelAndTermDto;
|
|
|
|
|
import com.shxy.xymanager_common.dto.PhotoTimeResultDto;
|
|
|
|
|
import com.shxy.xymanager_common.dto.ScheduleAndRuleDto;
|
|
|
|
|
import com.shxy.xymanager_common.dto.ScheduleRuleDto;
|
|
|
|
|
import com.shxy.xymanager_common.entity.*;
|
|
|
|
@ -19,14 +23,18 @@ import com.shxy.xymanager_common.model.*;
|
|
|
|
|
import com.shxy.xymanager_common.page.PageUtils;
|
|
|
|
|
import com.shxy.xymanager_common.util.MyDateUtils;
|
|
|
|
|
import com.shxy.xymanager_common.util.ProcessExecUtils;
|
|
|
|
|
import com.shxy.xymanager_common.util.StringUtils;
|
|
|
|
|
import com.shxy.xymanager_common.vo.*;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.*;
|
|
|
|
|
import com.shxy.xymanager_service.service.TerminalScheduleRuleService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.omg.PortableInterceptor.INACTIVE;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.sql.Time;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
@ -57,6 +65,9 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
|
|
|
|
|
@Autowired
|
|
|
|
|
RequestResultsDao requestResultsDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TerminalScheduleDetailsDao terminalScheduleDetailsDao;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取时间任务规则列表
|
|
|
|
|
*
|
|
|
|
@ -291,7 +302,6 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询拍照时间表任务是否下发成功
|
|
|
|
|
*
|
|
|
|
@ -299,85 +309,90 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional
|
|
|
|
|
public ServiceBody<GetModel> checkScheldule(RelateTerminalListRuleIdVo vo) {
|
|
|
|
|
public ServiceBody<String> checkScheldule(RelateTerminalListRuleIdVo vo) {
|
|
|
|
|
Integer requestid = 0;
|
|
|
|
|
ArrayList<Integer> intlist = new ArrayList<>();
|
|
|
|
|
RequestResults results = requestResultsDao.selectByRequestId(1);
|
|
|
|
|
String data = results.getData();
|
|
|
|
|
Integer result = results.getResult();
|
|
|
|
|
if (result == 255) {
|
|
|
|
|
// terminalSchedulesTempDao.selectByRequestId(intlist);
|
|
|
|
|
/*
|
|
|
|
|
* 如果下发成功
|
|
|
|
|
* 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());
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
TerminalSchedules record = new TerminalSchedules();
|
|
|
|
|
record.setChannelId(temp1.getChannelId());
|
|
|
|
|
record.setScheduleId(temp1.getScheduleId());
|
|
|
|
|
record.setTermId(temp1.getTermId());
|
|
|
|
|
terminalSchedulesDao.updateByPrimaryKeySelective(record);//将实际的拍照时间表规则从临时表更新到正式表中
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
// terminalScheduleDetailsDao.deleteByPrimaryKey();//根据装置编号和通道编号删除之前对应的实际拍照时间表详情
|
|
|
|
|
|
|
|
|
|
List<ChannelAndTermDto> terminalsList = terminalsDao.selectByIdList(vo.getList(), CommonStatus.EFFECTIVE.value());
|
|
|
|
|
ArrayList<TerminalScheduleDetails> record1 = new ArrayList<>();
|
|
|
|
|
terminalScheduleDetailsDao.insertList(record1);//插入新的对应的拍照时间表规则详情
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(termidlist)) {
|
|
|
|
|
return Asserts.error("没有该装置");
|
|
|
|
|
int i = requestResultsDao.updateByPrimaryKey(new RequestResults());//根据requestid将结果表中的状态修改为已下发
|
|
|
|
|
//end
|
|
|
|
|
|
|
|
|
|
if (i != 0) {
|
|
|
|
|
return Asserts.success("下发成功");
|
|
|
|
|
} else {
|
|
|
|
|
return Asserts.error("关联失败");
|
|
|
|
|
}
|
|
|
|
|
ScheduleAndRuleDto dto = schedulesDao.selectSingle(scheduleid, CommonStatus.EFFECTIVE.value());
|
|
|
|
|
List<ScheduleRuleDto> dtoList = dto.getList();
|
|
|
|
|
if (CollectionUtil.isEmpty(dtoList)) {
|
|
|
|
|
return Asserts.error("没有该拍照时间规则");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据装置和通道编号查询拍照时间表
|
|
|
|
|
*
|
|
|
|
|
* @param vo
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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]);
|
|
|
|
|
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);//将实际的拍照时间表规则从临时表更新到正式表中
|
|
|
|
|
|
|
|
|
|
Date endTime = dtoList.get(j).getEndTime();
|
|
|
|
|
Short endTimeHour = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[0]);
|
|
|
|
|
Short endTimeMin = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[1]);
|
|
|
|
|
terminalScheduleDetailsDao.deleteByPrimaryKey(0);//根据装置编号和通道编号删除之前对应的实际拍照时间表详情
|
|
|
|
|
|
|
|
|
|
ArrayList<TerminalScheduleDetails> record1 = new ArrayList<>();
|
|
|
|
|
terminalScheduleDetailsDao.insertList(record1);//插入新的对应的拍照时间表规则详情
|
|
|
|
|
|
|
|
|
|
int i = requestResultsDao.updateByPrimaryKey(new RequestResults());//根据requestid将结果表中的状态修改为已下发
|
|
|
|
|
//end
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
} else {
|
|
|
|
@ -417,4 +432,56 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//调用CMA获取装置的拍照时间表详情
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<GetModel> cmaSchelduleDetials(TerminalAndChannelIdVo vo) {
|
|
|
|
|
GetModel model = new GetModel();
|
|
|
|
|
|
|
|
|
|
Integer terminalid = vo.getTerminalid();
|
|
|
|
|
Integer channelid = vo.getChannelid();
|
|
|
|
|
String cmdIdByTermId = terminalsDao.getCmdIdByTermId(terminalid);
|
|
|
|
|
|
|
|
|
|
String cmd = Constants.CMD + "schedule --cmdid=" + cmdIdByTermId + "\t" + "--reqid=" + Constants.REQUEST_ID + "\t" + "--clientid=10 --flag=0 --rf=7 --channel=" + channelid;
|
|
|
|
|
ProcessExecUtils.exec(cmd);
|
|
|
|
|
Integer requestId = Integer.parseInt(Constants.REQUEST_ID.toString());
|
|
|
|
|
model.setRequestId(requestId);
|
|
|
|
|
Constants.REQUEST_ID.addAndGet(1);
|
|
|
|
|
model.setRequestId(requestId);
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*获取Cma调用获取装置拍照时间表结果*/
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<TerminalScheduleRuleTimeListModel> getCmaSchelduleDetials(RequestIdVo vo) {
|
|
|
|
|
TerminalScheduleRuleTimeListModel model = new TerminalScheduleRuleTimeListModel();
|
|
|
|
|
RequestResults results = requestResultsDao.selectByRequestId(vo.getRequestid());
|
|
|
|
|
String resultsData = results.getData();
|
|
|
|
|
if (StringUtils.isNotBlank(resultsData)) {
|
|
|
|
|
JSONObject resultObj = JSONObject.parseObject(resultsData);
|
|
|
|
|
if (null != resultObj.get("groupData")) {
|
|
|
|
|
List<PhotoTimeResultDto> resultDtoList = JSONArray.parseArray(resultObj.get("groupData").toString(), PhotoTimeResultDto.class);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(resultDtoList)) {
|
|
|
|
|
List<String> resultList = Lists.newArrayList();
|
|
|
|
|
String startTimeStr = resultDtoList.get(0).getHour() + ":" + resultDtoList.get(0).getMinute() + ":00";
|
|
|
|
|
String endTimeStr = resultDtoList.get(1).getHour() + ":" + resultDtoList.get(1).getMinute() + ":00";
|
|
|
|
|
Date startTime = DateUtil.parseTime(startTimeStr);
|
|
|
|
|
Date endTime = DateUtil.parseTime(endTimeStr);
|
|
|
|
|
Integer span = resultDtoList.get(2).getHour() * 60 + resultDtoList.get(2).getMinute();
|
|
|
|
|
List<DateTime> dateTimes = MyDateUtils.rangeToList(startTime, endTime, DateField.MINUTE, span);
|
|
|
|
|
for (DateTime data : dateTimes) {
|
|
|
|
|
String dateTime = DateUtil.formatTime(data);
|
|
|
|
|
resultList.add(dateTime);
|
|
|
|
|
}
|
|
|
|
|
model.setList(resultList);
|
|
|
|
|
model.setIsNew(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
} else {
|
|
|
|
|
return Asserts.error("查询失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|