|
|
|
@ -385,7 +385,6 @@ public class JobMainTask { |
|
|
|
|
|
|
|
PatrolPresetPos presetPos = !presetPosList.isEmpty() ? presetPosList.get(0) : PatrolPresetPos.builder().presetPosId("0").build(); |
|
|
|
String taskPatrolId = taskExecRecord.getTaskPatrolId(); |
|
|
|
log.info("taskPatrolId: {}", taskPatrolId); |
|
|
|
|
|
|
|
/*摄像头转到预置位*/ |
|
|
|
boolean noError = setCameraToPreset(presetPos); |
|
|
|
@ -397,101 +396,138 @@ public class JobMainTask { |
|
|
|
myDelay(2000); |
|
|
|
} |
|
|
|
|
|
|
|
StringBuffer fileTypes = new StringBuffer(); |
|
|
|
StringBuffer filePaths = new StringBuffer(); |
|
|
|
PatrolPresetAction patrolPresetAction = PatrolPresetAction.builder().isEnable("1").presetPosId(presetPos.getPresetPosId()).build(); |
|
|
|
List<PatrolPresetAction> patrolPresetActionList = taskExecClient.selectPatrolPresetActionList(patrolPresetAction); |
|
|
|
PatrolPresetAction presetAction = patrolPresetActionList.isEmpty() ? |
|
|
|
PatrolPresetAction.builder().presetPosId(presetPos.getPresetPosId()).actionType("1").photoCount(1L).photoGap(1).build() |
|
|
|
: patrolPresetActionList.get(0); |
|
|
|
|
|
|
|
String basePath = (StringUtils.isEmpty(taskExecRecord.getStationCode()) ? stationCode : taskExecRecord.getStationCode()) |
|
|
|
+ "/" + DateUtils.getYearEven() |
|
|
|
+ "/" + DateUtils.getMonthEven() |
|
|
|
+ "/" + DateUtils.getDayEven() |
|
|
|
+ "/" + taskExecRecord.getTaskCode() |
|
|
|
+ "/"; |
|
|
|
log.info("basePath: {}", basePath); |
|
|
|
if (PresetAction.PHOTO.getCode().equals(presetAction.getActionType())) { |
|
|
|
String chanType = presetPos.getChannelType(); |
|
|
|
fileTypes.append("ir".equals(chanType) ? "1" : "vl".equals(chanType) ? "2" : "").append(","); |
|
|
|
int delayMilliSeconds = presetAction.getPhotoGap() * 1000; |
|
|
|
final long photoCount = presetAction.getPhotoCount(); |
|
|
|
boolean bOk = false; |
|
|
|
|
|
|
|
try { |
|
|
|
log.info("PHOTO PresetType chanType: {}, videoNvrCode: {}, channelCode: {}", chanType, presetPos.getVideoNvrCode(), presetPos.getChannelCode()); |
|
|
|
if ("vl".equals(chanType)) { |
|
|
|
String paramUrl = liveIVS_URL + "/api/v1/device/channelsnap?serial=" + presetPos.getVideoNvrCode() + "&realtime=true&code=" + presetPos.getChannelCode(); |
|
|
|
String paramFileName = taskPatrolId.split(StringUtils.UNDERLINE)[1] + StringUtils.UNDERLINE |
|
|
|
+ taskPatrolId.split(StringUtils.UNDERLINE)[2] + StringUtils.UNDERLINE |
|
|
|
+ presetPos.getPatrolPointId() + StringUtils.UNDERLINE |
|
|
|
+ taskExecRecord.getDevNo() + ".jpg"; |
|
|
|
String paramFileDir = basePath + "CCD"; |
|
|
|
log.info("paramUrl: {}, paramFileName: {}, paramFileDir: {}", paramUrl, paramFileName, paramFileDir); |
|
|
|
FtpResult ftpResult = saveFile(paramUrl, paramFileName, paramFileDir); |
|
|
|
if (ftpResult != null && StringUtils.isNotEmpty(ftpResult.getFilepath())) { |
|
|
|
log.info("filePath: {}", ftpResult.getFilepath()); |
|
|
|
bOk = ftpResult.isOk(); |
|
|
|
filePaths.append("/" + ftpResult.getFilepath()); |
|
|
|
boolean taskHalted = false; |
|
|
|
String taskPatrolledId = taskPatrolId.split(StringUtils.UNDERLINE)[1] + "_" + taskPatrolId.split(StringUtils.UNDERLINE)[2]; |
|
|
|
PatrolTaskStatus patrolTaskStatus = new PatrolTaskStatus(); |
|
|
|
patrolTaskStatus.setTaskPatrolledId(taskPatrolledId); |
|
|
|
List<PatrolTaskStatus> list = taskExecClient.selectPatrolTaskStatusList(patrolTaskStatus); |
|
|
|
if(list.size() > 0) { |
|
|
|
if("3".equals(list.get(0).getTaskState())) {//暂停 |
|
|
|
while(true) { |
|
|
|
log.info("-----------------------task pause: {}", taskPatrolledId); |
|
|
|
try { |
|
|
|
Thread.sleep(1000); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
} |
|
|
|
} else if ("ir".equals(chanType)) { |
|
|
|
InfraredModel infraredModel = new InfraredModel(); |
|
|
|
infraredModel.setChannelSerial(presetPos.getChannelCode()); |
|
|
|
infraredModel.setPresetId(Integer.parseInt(presetPos.getPresetPosCode())); |
|
|
|
EqpBook eqpbook = new EqpBook(); |
|
|
|
eqpbook.setPatrolDeviceCode(presetPos.getPatrolDeviceCode()); |
|
|
|
List<EqpBook> eqpBookListList = taskExecClient.selectBasedataEqpBookList(eqpbook); |
|
|
|
if (!eqpBookListList.isEmpty()) { |
|
|
|
Response ir_gen = remoteInvokeService.invoke("IR_GEN", presetPos.getPatrolDeviceCode().split("#")[0], new HashMap<>()); |
|
|
|
log.info("ir_gen: {}", JSONObject.toJSONString(ir_gen)); |
|
|
|
Object data = ir_gen.getData(); |
|
|
|
String path = JSONObject.parseObject(JSONObject.toJSONString(data)).getString("filePath"); |
|
|
|
path = path.split("33333")[1]; |
|
|
|
filePaths.append(path).append(","); |
|
|
|
log.info("INFRA:{}", taskExecRecord.getTaskName() + " path : " + path); |
|
|
|
|
|
|
|
list = taskExecClient.selectPatrolTaskStatusList(patrolTaskStatus); |
|
|
|
if(list.size() > 0) { |
|
|
|
log.info("-----------------------TaskState: {}", list.get(0).getTaskState()); |
|
|
|
if("4".equals(list.get(0).getTaskState())) {//终止 |
|
|
|
log.info("-----------------------task terminate: {}", taskPatrolledId); |
|
|
|
taskHalted = true; |
|
|
|
break; |
|
|
|
} else if("2".equals(list.get(0).getTaskState())) {//正在执行 |
|
|
|
log.info("-----------------------task resume: {}", taskPatrolledId); |
|
|
|
break; |
|
|
|
} |
|
|
|
} else { |
|
|
|
log.info("-----------------------selectPatrolTaskStatusList is empty"); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("error", e); |
|
|
|
} else if("4".equals(list.get(0).getTaskState())) {//终止 |
|
|
|
log.info("-----------------------task terminate: {}", taskPatrolledId); |
|
|
|
taskHalted = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
recordPersist(bOk, taskExecRecord, infoListSize, patrolTaskInfo, presetPos, fileTypes, filePaths); |
|
|
|
} else if (PresetAction.VIDEO.getCode().equals(presetAction.getActionType())) { |
|
|
|
log.info("VIDEO PresetType videoNvrCode: {}, channelCode: {}", presetPos.getVideoNvrCode(), presetPos.getChannelCode()); |
|
|
|
fileTypes.append(4).append(","); |
|
|
|
String jsonStr = HttpClientUtil.getHttpResultJson(liveIVS_URL + "/api/v1/stream/start?serial=" + presetPos.getVideoNvrCode() + "&code=" + presetPos.getChannelCode()); |
|
|
|
log.info("先调用直播开始,获取流对象:/api/v1/stream/start?serial= :{} ", presetPos.getVideoNvrCode() + "&code=" + presetPos.getChannelCode()); |
|
|
|
log.info("/api/v1/stream/start 返回 json 字符串{} ", jsonStr); |
|
|
|
JSONObject UserInfoReturn = JSON.parseObject(jsonStr); |
|
|
|
Stream stream = JSON.toJavaObject(UserInfoReturn, Stream.class); |
|
|
|
try { |
|
|
|
String rel = HttpClientUtils.get(liveIVS_URL + "/api/v1/record/start", "streamid=" + stream.getStreamID() + "&code=" + presetPos.getChannelCode()); |
|
|
|
log.info("视频录像开始:/api/v1/record/start streamid={} ", stream.getStreamID() + ",code=" + presetPos.getChannelCode() + ", 调用 /api/v1/record/start 返回值=" + rel); |
|
|
|
if (rel.isEmpty()) { |
|
|
|
rel = HttpClientUtils.get(liveIVS_URL + "/api/v1/record/start", "streamid=" + stream.getStreamID() + "&code=" + presetPos.getChannelCode()); |
|
|
|
log.info("一次调用失败,第二次调用 视频录像开始:/api/v1/record/start streamid={} ", stream.getStreamID() + ",code=" + presetPos.getChannelCode() + ", 调用 /api/v1/record/start 返回值=" + rel); |
|
|
|
if(!taskHalted) { |
|
|
|
StringBuffer fileTypes = new StringBuffer(); |
|
|
|
StringBuffer filePaths = new StringBuffer(); |
|
|
|
PatrolPresetAction patrolPresetAction = PatrolPresetAction.builder().isEnable("1").presetPosId(presetPos.getPresetPosId()).build(); |
|
|
|
List<PatrolPresetAction> patrolPresetActionList = taskExecClient.selectPatrolPresetActionList(patrolPresetAction); |
|
|
|
PatrolPresetAction presetAction = patrolPresetActionList.isEmpty() ? |
|
|
|
PatrolPresetAction.builder().presetPosId(presetPos.getPresetPosId()).actionType("1").photoCount(1L).photoGap(1).build() |
|
|
|
: patrolPresetActionList.get(0); |
|
|
|
|
|
|
|
String basePath = (StringUtils.isEmpty(taskExecRecord.getStationCode()) ? stationCode : taskExecRecord.getStationCode()) |
|
|
|
+ "/" + DateUtils.getYearEven() |
|
|
|
+ "/" + DateUtils.getMonthEven() |
|
|
|
+ "/" + DateUtils.getDayEven() |
|
|
|
+ "/" + taskExecRecord.getTaskCode() |
|
|
|
+ "/"; |
|
|
|
log.info("basePath: {}", basePath); |
|
|
|
if (PresetAction.PHOTO.getCode().equals(presetAction.getActionType())) { |
|
|
|
String chanType = presetPos.getChannelType(); |
|
|
|
fileTypes.append("ir".equals(chanType) ? "1" : "vl".equals(chanType) ? "2" : "").append(","); |
|
|
|
int delayMilliSeconds = presetAction.getPhotoGap() * 1000; |
|
|
|
final long photoCount = presetAction.getPhotoCount(); |
|
|
|
boolean bOk = false; |
|
|
|
|
|
|
|
try { |
|
|
|
log.info("PHOTO PresetType chanType: {}, videoNvrCode: {}, channelCode: {}", chanType, presetPos.getVideoNvrCode(), presetPos.getChannelCode()); |
|
|
|
if ("vl".equals(chanType)) { |
|
|
|
String paramUrl = liveIVS_URL + "/api/v1/device/channelsnap?serial=" + presetPos.getVideoNvrCode() + "&realtime=true&code=" + presetPos.getChannelCode(); |
|
|
|
String paramFileName = taskPatrolId.split(StringUtils.UNDERLINE)[1] + StringUtils.UNDERLINE |
|
|
|
+ taskPatrolId.split(StringUtils.UNDERLINE)[2] + StringUtils.UNDERLINE |
|
|
|
+ presetPos.getPatrolPointId() + StringUtils.UNDERLINE |
|
|
|
+ taskExecRecord.getDevNo() + ".jpg"; |
|
|
|
String paramFileDir = basePath + "CCD"; |
|
|
|
log.info("paramUrl: {}, paramFileName: {}, paramFileDir: {}", paramUrl, paramFileName, paramFileDir); |
|
|
|
FtpResult ftpResult = saveFile(paramUrl, paramFileName, paramFileDir); |
|
|
|
if (ftpResult != null && StringUtils.isNotEmpty(ftpResult.getFilepath())) { |
|
|
|
log.info("filePath: {}", ftpResult.getFilepath()); |
|
|
|
bOk = ftpResult.isOk(); |
|
|
|
filePaths.append("/" + ftpResult.getFilepath()); |
|
|
|
} |
|
|
|
} else if ("ir".equals(chanType)) { |
|
|
|
InfraredModel infraredModel = new InfraredModel(); |
|
|
|
infraredModel.setChannelSerial(presetPos.getChannelCode()); |
|
|
|
infraredModel.setPresetId(Integer.parseInt(presetPos.getPresetPosCode())); |
|
|
|
EqpBook eqpbook = new EqpBook(); |
|
|
|
eqpbook.setPatrolDeviceCode(presetPos.getPatrolDeviceCode()); |
|
|
|
List<EqpBook> eqpBookListList = taskExecClient.selectBasedataEqpBookList(eqpbook); |
|
|
|
if (!eqpBookListList.isEmpty()) { |
|
|
|
Response ir_gen = remoteInvokeService.invoke("IR_GEN", presetPos.getPatrolDeviceCode().split("#")[0], new HashMap<>()); |
|
|
|
log.info("ir_gen: {}", JSONObject.toJSONString(ir_gen)); |
|
|
|
Object data = ir_gen.getData(); |
|
|
|
String path = JSONObject.parseObject(JSONObject.toJSONString(data)).getString("filePath"); |
|
|
|
path = path.split("33333")[1]; |
|
|
|
filePaths.append(path).append(","); |
|
|
|
log.info("INFRA:{}", taskExecRecord.getTaskName() + " path : " + path); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("error", e); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("error", e); |
|
|
|
} |
|
|
|
|
|
|
|
final int videoTime = presetAction.getVideoTime(); |
|
|
|
Timer mTimer = new Timer(); |
|
|
|
mTimer.schedule(new TimerTask() { |
|
|
|
int mCount = 0; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
mCount++; |
|
|
|
PatrolTaskExecRecord tempRecord = taskExecClient.selectPatrolTaskExecRecordByTaskPatrolId(taskPatrolId); |
|
|
|
if (mCount >= videoTime + 2 || !isRunningState(tempRecord.getTaskPatrolId())) { |
|
|
|
log.info("视频录像结束:查询当前巡检任务执行状态,当状态为暂停或者终止时,退出当前执行方法:TaskPatrolledId :{}", taskPatrolId); |
|
|
|
videotapeRecordStop(filePaths, stream, presetPos.getChannelCode(), basePath, presetPos.getPatrolPointId(), presetPos.getVideoNvrCode()); |
|
|
|
mTimer.cancel(); |
|
|
|
recordPersist(bOk, taskExecRecord, infoListSize, patrolTaskInfo, presetPos, fileTypes, filePaths); |
|
|
|
} else if (PresetAction.VIDEO.getCode().equals(presetAction.getActionType())) { |
|
|
|
log.info("VIDEO PresetType videoNvrCode: {}, channelCode: {}", presetPos.getVideoNvrCode(), presetPos.getChannelCode()); |
|
|
|
fileTypes.append(4).append(","); |
|
|
|
String jsonStr = HttpClientUtil.getHttpResultJson(liveIVS_URL + "/api/v1/stream/start?serial=" + presetPos.getVideoNvrCode() + "&code=" + presetPos.getChannelCode()); |
|
|
|
log.info("先调用直播开始,获取流对象:/api/v1/stream/start?serial= :{} ", presetPos.getVideoNvrCode() + "&code=" + presetPos.getChannelCode()); |
|
|
|
log.info("/api/v1/stream/start 返回 json 字符串{} ", jsonStr); |
|
|
|
JSONObject UserInfoReturn = JSON.parseObject(jsonStr); |
|
|
|
Stream stream = JSON.toJavaObject(UserInfoReturn, Stream.class); |
|
|
|
try { |
|
|
|
String rel = HttpClientUtils.get(liveIVS_URL + "/api/v1/record/start", "streamid=" + stream.getStreamID() + "&code=" + presetPos.getChannelCode()); |
|
|
|
log.info("视频录像开始:/api/v1/record/start streamid={} ", stream.getStreamID() + ",code=" + presetPos.getChannelCode() + ", 调用 /api/v1/record/start 返回值=" + rel); |
|
|
|
if (rel.isEmpty()) { |
|
|
|
rel = HttpClientUtils.get(liveIVS_URL + "/api/v1/record/start", "streamid=" + stream.getStreamID() + "&code=" + presetPos.getChannelCode()); |
|
|
|
log.info("一次调用失败,第二次调用 视频录像开始:/api/v1/record/start streamid={} ", stream.getStreamID() + ",code=" + presetPos.getChannelCode() + ", 调用 /api/v1/record/start 返回值=" + rel); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("error", e); |
|
|
|
} |
|
|
|
}, 0, 1000L); |
|
|
|
|
|
|
|
final int videoTime = presetAction.getVideoTime(); |
|
|
|
Timer mTimer = new Timer(); |
|
|
|
mTimer.schedule(new TimerTask() { |
|
|
|
int mCount = 0; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
mCount++; |
|
|
|
PatrolTaskExecRecord tempRecord = taskExecClient.selectPatrolTaskExecRecordByTaskPatrolId(taskPatrolId); |
|
|
|
if (mCount >= videoTime + 2 || !isRunningState(tempRecord.getTaskPatrolId())) { |
|
|
|
log.info("视频录像结束:查询当前巡检任务执行状态,当状态为暂停或者终止时,退出当前执行方法:TaskPatrolledId :{}", taskPatrolId); |
|
|
|
videotapeRecordStop(filePaths, stream, presetPos.getChannelCode(), basePath, presetPos.getPatrolPointId(), presetPos.getVideoNvrCode()); |
|
|
|
mTimer.cancel(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, 0, 1000L); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return taskExecRecord; |
|
|
|
@ -519,7 +555,7 @@ public class JobMainTask { |
|
|
|
String rectangle = getRectangle(presetPos.getPresetPosId()); |
|
|
|
String taskPatrolId = getTaskPatrolledId(taskInfo.getDevNo(), taskExecRecord.getTaskPatrolId()); |
|
|
|
final String deviceId = taskInfo.getDeviceId(); |
|
|
|
log.info("pointExecRecord crud add taskPatrolId: {}, deviceId: {}", taskPatrolId, deviceId); |
|
|
|
log.info("pointExecRecord crud add taskPatrolId: {}, patrolPointId: {}", taskPatrolId, deviceId); |
|
|
|
|
|
|
|
PatrolTaskPointExecRecord pointExecRecord = PatrolTaskPointExecRecord |
|
|
|
.builder() |
|
|
|
@ -974,8 +1010,22 @@ public class JobMainTask { |
|
|
|
//patrolTaskInfoList size: 12 devNo: camera, taskId: 10032 |
|
|
|
log.info("EXEC patrolTaskInfoList size: {} devNo: {}, taskId: {}", patrolTaskInfoList.size(), patrolTaskExecRecord.getDevNo(), patrolTaskExecRecord.getTaskId()); |
|
|
|
for (final PatrolTaskInfo taskInfo : patrolTaskInfoList) { |
|
|
|
log.info("EXEC Immediate taskPatrolId: {}, deviceId: {}, lineId: {}", patrolTaskExecRecord.getTaskPatrolId(), taskInfo.getDeviceId(), taskInfo.getLineId()); |
|
|
|
log.info("EXEC Immediate taskPatrolId: {}, patrolPointId: {}, lineId: {}", patrolTaskExecRecord.getTaskPatrolId(), taskInfo.getDeviceId(), taskInfo.getLineId()); |
|
|
|
prePointExec(patrolTaskExecRecord, taskInfo, patrolTaskInfoList.size()); |
|
|
|
|
|
|
|
String taskPatrolledId = patrolTaskExecRecord.getTaskPatrolId().split(StringUtils.UNDERLINE)[1] + "_" + patrolTaskExecRecord.getTaskPatrolId().split(StringUtils.UNDERLINE)[2]; |
|
|
|
PatrolTaskStatus patrolTaskStatus = new PatrolTaskStatus(); |
|
|
|
patrolTaskStatus.setTaskPatrolledId(taskPatrolledId); |
|
|
|
List<PatrolTaskStatus> list = taskExecClient.selectPatrolTaskStatusList(patrolTaskStatus); |
|
|
|
if(list.size() > 0) { |
|
|
|
log.info("-----------------------2 TaskState: {}", list.get(0).getTaskState()); |
|
|
|
if("4".equals(list.get(0).getTaskState())) {//终止 |
|
|
|
log.info("-----------------------2 task terminate: {}", taskPatrolledId); |
|
|
|
return; |
|
|
|
} |
|
|
|
} else { |
|
|
|
log.info("-----------------------2 selectPatrolTaskStatusList is empty"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|