|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.shxy.xymanager_common.bean.ServiceBody;
|
|
|
|
|
import com.shxy.xymanager_common.dto.TerminalPhotoScheduleDto;
|
|
|
|
|
import com.shxy.xymanager_common.entity.TerminalPhoto;
|
|
|
|
|
import com.shxy.xymanager_common.entity.Terminals;
|
|
|
|
|
import com.shxy.xymanager_common.enums.CommonStatus;
|
|
|
|
@ -15,6 +16,7 @@ import com.shxy.xymanager_common.model.TerminalPhotoSelectListModel;
|
|
|
|
|
import com.shxy.xymanager_common.model.TerminalPhotosModel;
|
|
|
|
|
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.TerminalPhotoDao;
|
|
|
|
@ -22,6 +24,7 @@ import com.shxy.xymanager_dao.dao.TerminalsDao;
|
|
|
|
|
import com.shxy.xymanager_service.interaction.Cma;
|
|
|
|
|
import com.shxy.xymanager_service.service.TerminalPhotoService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import net.sf.jsqlparser.expression.StringValue;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -32,9 +35,8 @@ import java.io.BufferedReader;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 装置图片实现层
|
|
|
|
@ -222,33 +224,10 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<Boolean> getLatestPhoto(TerminalPhotoVo vo) {
|
|
|
|
|
/* Cma cma = new Cma(server, port);*/
|
|
|
|
|
|
|
|
|
|
String line = "";
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
String result = "";
|
|
|
|
|
Boolean hasNew = false;
|
|
|
|
|
try {
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=capture --cmdid="+vo.getCmdid() +"\t" +"--channel="+ vo.getChannel() +"\t"+ "--preset=255 --type=0";
|
|
|
|
|
Process ps = Runtime.getRuntime().exec(cmd);
|
|
|
|
|
log.info("传入cmd信息:{}", cmd);
|
|
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(ps.getInputStream()));
|
|
|
|
|
int sendToCode = ps.waitFor();
|
|
|
|
|
log.info("进程返回结果:{}", sendToCode);
|
|
|
|
|
while ((line = reader.readLine()) != null) {
|
|
|
|
|
sb.append(line).append("\n");
|
|
|
|
|
}
|
|
|
|
|
result = sb.toString();
|
|
|
|
|
if (StringUtils.isNotBlank(result)) {
|
|
|
|
|
log.info("查询最新图片结果:{}", result);
|
|
|
|
|
hasNew = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error("IOException", e);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
log.error("InterruptedException", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Integer result = ProcessExecUtils.exec(cmd);
|
|
|
|
|
hasNew = result == 0?true:false;
|
|
|
|
|
/* Boolean hasNew = cma.requestCapture(vo.getCmdid(), vo.getChannel(), vo.getPreset(), vo.getCaptureType());*/
|
|
|
|
|
return Asserts.success(hasNew);
|
|
|
|
|
}
|
|
|
|
@ -308,4 +287,56 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<Boolean> getPhotoTime(TerminalPhotoTimeVo vo) {
|
|
|
|
|
List<TerminalPhotoScheduleDto> dtoList = terminalPhotoDao.selectPhotoSchedule(vo);
|
|
|
|
|
Map<String,List<TerminalPhotoScheduleDto>> map =dtoList.stream().collect(Collectors.groupingBy(TerminalPhotoScheduleDto :: getCmid)) ;
|
|
|
|
|
map.forEach((key,value) ->{
|
|
|
|
|
Short[] timeList = new Short[255];
|
|
|
|
|
int i = 0 ;
|
|
|
|
|
for(int j = 0; j<value.size();j++){
|
|
|
|
|
Short span = value.get(j).getSpan();
|
|
|
|
|
Date startTime = value.get(j).getStartTime();
|
|
|
|
|
Short startHour = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[0]);
|
|
|
|
|
Short startMin = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[1]);
|
|
|
|
|
|
|
|
|
|
timeList[i]= startHour;
|
|
|
|
|
i++;
|
|
|
|
|
timeList[i]= startMin;
|
|
|
|
|
i++;
|
|
|
|
|
timeList[i]= 255;
|
|
|
|
|
Date endTime = value.get(j).getStartTime();
|
|
|
|
|
Short endTimeHour = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[0]);
|
|
|
|
|
Short endTimeMin = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[1]);
|
|
|
|
|
i++;
|
|
|
|
|
timeList[i]= endTimeHour;
|
|
|
|
|
i++;
|
|
|
|
|
timeList[i]= endTimeMin;
|
|
|
|
|
i++;
|
|
|
|
|
timeList[i]= 255;
|
|
|
|
|
|
|
|
|
|
String spanStr;
|
|
|
|
|
if(span/60 > 0) {
|
|
|
|
|
i++;
|
|
|
|
|
timeList[i]= (short)(span/60);
|
|
|
|
|
i++;
|
|
|
|
|
timeList[i]= (short)(span % 60);
|
|
|
|
|
}else if(span<60 ){
|
|
|
|
|
i++;
|
|
|
|
|
timeList[i]= (short)0;
|
|
|
|
|
i++;
|
|
|
|
|
timeList[i]= span ;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
timeList[i]= 255 ;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=updateSchedule[0xCA] --cmdid="+key +"\t" +"--channel="+ vo.getChannel() +"\t"+ "--scheduleData="+timeList;
|
|
|
|
|
ProcessExecUtils.exec(cmd);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Asserts.success(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|