|
|
|
@ -31,11 +31,11 @@ import com.inspect.job.mapper.PatrolDeviceStateMapper; |
|
|
|
import com.inspect.job.util.HttpClientUtil; |
|
|
|
import com.inspect.system.base.domain.SysDictData; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.net.URLConnection; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
@ -43,7 +43,6 @@ import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.concurrent.locks.Condition; |
|
|
|
import java.util.concurrent.locks.Lock; |
|
|
|
import java.util.concurrent.locks.ReentrantLock; |
|
|
|
import java.util.function.Supplier; |
|
|
|
|
|
|
|
import feign.RetryableException; |
|
|
|
import org.slf4j.Logger; |
|
|
|
@ -58,6 +57,7 @@ import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import javax.annotation.PostConstruct; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
@Component("jobMainTask") |
|
|
|
@RestController |
|
|
|
@ -116,6 +116,9 @@ public class JobMainTask { |
|
|
|
@Value("${task.test-mode:false}") |
|
|
|
private boolean testMode; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private CameraOperateRetryableDelegate cameraOperateRetryableDelegate; |
|
|
|
|
|
|
|
private ExecutorService threadPool; |
|
|
|
|
|
|
|
final ShaoXinBigModel shaoXinBigModel; |
|
|
|
@ -453,6 +456,8 @@ public class JobMainTask { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private PatrolTaskExecRecord prePointExec(PatrolTaskExecRecord taskExecRecord, PatrolTaskInfo patrolTaskInfo, int infoListSize) { |
|
|
|
String uuid = UUID.randomUUID().toString().trim().replaceAll(StringUtils.DASH, StringUtils.EMPTY); |
|
|
|
PatrolPresetPos patrolPresetPos = PatrolPresetPos.builder() |
|
|
|
@ -472,8 +477,18 @@ public class JobMainTask { |
|
|
|
String taskPatrolId = taskExecRecord.getTaskPatrolId(); |
|
|
|
|
|
|
|
/*摄像头转到预置位*/ |
|
|
|
boolean noError = setCameraToPreset(presetPos); |
|
|
|
// if ("prod".equals(activeProfile) && noError) { |
|
|
|
//boolean noError = setCameraToPreset(presetPos); |
|
|
|
|
|
|
|
boolean noError = true; |
|
|
|
try { |
|
|
|
noError = cameraOperateRetryableDelegate.sendCameraPresetRequest(presetPos); |
|
|
|
} catch (IOException e) { |
|
|
|
log.error("最终重试失败: channelCode: {}, presetPosName: {}, patrolPointId: {}, msg: {}", |
|
|
|
presetPos.getChannelCode(), presetPos.getPresetPosName(), presetPos.getPatrolPointId(), e.getMessage()); |
|
|
|
noError = false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!testMode && noError) { |
|
|
|
log.info("setCameraToPreset no error, delay 20 seconds"); |
|
|
|
myDelay(20000); |
|
|
|
@ -482,178 +497,140 @@ public class JobMainTask { |
|
|
|
myDelay(2000); |
|
|
|
} |
|
|
|
|
|
|
|
// 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.isEmpty()) { |
|
|
|
// if ("3".equals(list.get(0).getTaskState())) {//暂停 |
|
|
|
// while (true) { |
|
|
|
// log.info("-----------------------task pause: {}", taskPatrolledId); |
|
|
|
// try { |
|
|
|
// Thread.sleep(1000); |
|
|
|
// } catch (InterruptedException e) { |
|
|
|
// } |
|
|
|
// |
|
|
|
// list = taskExecClient.selectPatrolTaskStatusList(patrolTaskStatus); |
|
|
|
// if (!list.isEmpty()) { |
|
|
|
// 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"); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } else if ("4".equals(list.get(0).getTaskState())) {//终止 |
|
|
|
// log.info("-----------------------task terminate: {}", taskPatrolledId); |
|
|
|
// taskHalted = true; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// 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("uuid: {}, basePath: {}", uuid, basePath); |
|
|
|
if (PresetAction.PHOTO.getCode().equals(presetAction.getActionType())) { |
|
|
|
final String chanType = presetPos.getChannelType(); |
|
|
|
fileTypes.append("ir".equals(chanType) ? "1" : "vl".equals(chanType) ? "2" : "").append(","); |
|
|
|
boolean bOk = false; |
|
|
|
try { |
|
|
|
log.info("PHOTO PresetType uuid: {}, chanType: {}, videoNvrCode: {}, channelCode: {}, patrolPointId: {}", uuid, chanType, presetPos.getVideoNvrCode(), presetPos.getChannelCode(), presetPos.getPatrolPointId()); |
|
|
|
if ("vl".equals(chanType)) { |
|
|
|
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("uuid: {}, basePath: {}", uuid, basePath); |
|
|
|
if (PresetAction.PHOTO.getCode().equals(presetAction.getActionType())) { |
|
|
|
final String chanType = presetPos.getChannelType(); |
|
|
|
fileTypes.append("ir".equals(chanType) ? "1" : "vl".equals(chanType) ? "2" : "").append(","); |
|
|
|
boolean bOk = false; |
|
|
|
try { |
|
|
|
log.info("PHOTO PresetType uuid: {}, chanType: {}, videoNvrCode: {}, channelCode: {}, patrolPointId: {}", uuid, chanType, presetPos.getVideoNvrCode(), presetPos.getChannelCode(), presetPos.getPatrolPointId()); |
|
|
|
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 |
|
|
|
+ patrolTaskInfo.getDevNo() + ".jpg"; |
|
|
|
String paramFileDir = basePath + "CCD"; |
|
|
|
log.info("paramUrl: {}, paramFileName: {}, paramFileDir: {}", paramUrl, paramFileName, paramFileDir); |
|
|
|
FtpResult ftpResult = getFileAndSave(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)) { |
|
|
|
log.info("[JOB] 红外处理流程, chanType: {}, patrolPointId: {}", chanType, presetPos.getPatrolPointId()); |
|
|
|
Map<String, String> algSubtypeIdMap = taskExecClient.getAlgTypeListByPatrolPointId(String.valueOf(presetPos.getPatrolPointId())); |
|
|
|
log.info("prePointExec algorithmTypeMap: {}", algSubtypeIdMap); |
|
|
|
final String algSubtypeCode = algSubtypeIdMap == null ? StringUtils.EMPTY : |
|
|
|
algSubtypeIdMap.getOrDefault(AlgConstants.ALG_SUBTYPE_CODE, StringUtils.EMPTY); |
|
|
|
if (algSubtypeCode.contains(AlgConstants.INFRA_1800) |
|
|
|
|| algSubtypeCode.contains(AlgConstants.INFRA_YU3) |
|
|
|
|| algSubtypeCode.contains(AlgConstants.INFRA_CAMERA) |
|
|
|
|| algSubtypeCode.contains(AlgConstants.INFRA_CAMERA_REVERSE)) { |
|
|
|
log.info("[infra_1800] 红外处理新流程: prePointExec algSubtypeCode: {}", algSubtypeCode); |
|
|
|
String paramFileName; |
|
|
|
if (algSubtypeCode.contains(AlgConstants.INFRA_1800)) { |
|
|
|
Map<String, String> threshold = patrolDeviceStateMapper.selectPatrolPresetParam(presetPos.getPatrolPointId()); |
|
|
|
final String temperUrl = liveIVS_URL + "/api/v1/device/temper"; |
|
|
|
JSONObject temperParam = new JSONObject(); |
|
|
|
temperParam.put("ruleId", threshold.get("preset_param_code")); |
|
|
|
log.info("[infra_1800] =======ruleId: {}", threshold.get("preset_param_code")); |
|
|
|
temperParam.put("presetId", Integer.parseInt(presetPos.getPresetPosCode())); |
|
|
|
temperParam.put("cameraCode", presetPos.getChannelCode()); |
|
|
|
final String temperUrlRes = HttpClientUtils.sendPostAgain(temperUrl, temperParam.toString()); |
|
|
|
log.info("[infra_1800] prePointExec temperUrlRes: {}", temperUrlRes); |
|
|
|
paramFileName = taskPatrolId.split(StringUtils.UNDERLINE)[1] + StringUtils.UNDERLINE |
|
|
|
+ taskPatrolId.split(StringUtils.UNDERLINE)[2] + StringUtils.UNDERLINE |
|
|
|
+ presetPos.getPatrolPointId() + StringUtils.UNDERLINE |
|
|
|
+ patrolTaskInfo.getDevNo() + "_" + temperUrlRes + ".jpg"; |
|
|
|
} else { |
|
|
|
paramFileName = taskPatrolId.split(StringUtils.UNDERLINE)[1] + StringUtils.UNDERLINE |
|
|
|
+ taskPatrolId.split(StringUtils.UNDERLINE)[2] + StringUtils.UNDERLINE |
|
|
|
+ presetPos.getPatrolPointId() + StringUtils.UNDERLINE |
|
|
|
+ patrolTaskInfo.getDevNo() + ".jpg"; |
|
|
|
} |
|
|
|
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 |
|
|
|
+ patrolTaskInfo.getDevNo() + ".jpg"; |
|
|
|
String paramFileDir = basePath + "CCD"; |
|
|
|
log.info("paramUrl: {}, paramFileName: {}, paramFileDir: {}", paramUrl, paramFileName, paramFileDir); |
|
|
|
FtpResult ftpResult = saveFile(paramUrl, paramFileName, paramFileDir); |
|
|
|
log.info("红外处理新流程: paramUrl: {}, paramFileName: {}, paramFileDir: {}", paramUrl, paramFileName, paramFileDir); |
|
|
|
FtpResult ftpResult = getFileAndSave(paramUrl, paramFileName, paramFileDir); |
|
|
|
if (ftpResult != null && StringUtils.isNotEmpty(ftpResult.getFilepath())) { |
|
|
|
log.info("filePath: {}", ftpResult.getFilepath()); |
|
|
|
log.info("红外处理新流程: filePath: {}", ftpResult.getFilepath()); |
|
|
|
bOk = ftpResult.isOk(); |
|
|
|
filePaths.append("/" + ftpResult.getFilepath()); |
|
|
|
} |
|
|
|
} else if ("ir".equals(chanType)) { |
|
|
|
log.info("[JOB] 红外处理流程, chanType: {}, patrolPointId: {}", chanType, presetPos.getPatrolPointId()); |
|
|
|
Map<String, String> algSubtypeIdMap = taskExecClient.getAlgTypeListByPatrolPointId(String.valueOf(presetPos.getPatrolPointId())); |
|
|
|
log.info("prePointExec algorithmTypeMap: {}", algSubtypeIdMap); |
|
|
|
final String algSubtypeCode = algSubtypeIdMap == null ? StringUtils.EMPTY : |
|
|
|
algSubtypeIdMap.getOrDefault(AlgConstants.ALG_SUBTYPE_CODE, StringUtils.EMPTY); |
|
|
|
if (algSubtypeCode.contains(AlgConstants.INFRA_1800) |
|
|
|
|| algSubtypeCode.contains(AlgConstants.INFRA_YU3) |
|
|
|
|| algSubtypeCode.contains(AlgConstants.INFRA_CAMERA) |
|
|
|
|| algSubtypeCode.contains(AlgConstants.INFRA_CAMERA_REVERSE)) { |
|
|
|
log.info("[infra_1800] 红外处理新流程: prePointExec algSubtypeCode: {}", algSubtypeCode); |
|
|
|
String paramFileName; |
|
|
|
if (algSubtypeCode.contains(AlgConstants.INFRA_1800)) { |
|
|
|
Map<String, String> threshold = patrolDeviceStateMapper.selectPatrolPresetParam(presetPos.getPatrolPointId()); |
|
|
|
final String temperUrl = liveIVS_URL + "/api/v1/device/temper"; |
|
|
|
JSONObject temperParam = new JSONObject(); |
|
|
|
temperParam.put("ruleId", threshold.get("preset_param_code")); |
|
|
|
log.info("[infra_1800] =======ruleId: {}", threshold.get("preset_param_code")); |
|
|
|
temperParam.put("presetId", Integer.parseInt(presetPos.getPresetPosCode())); |
|
|
|
temperParam.put("cameraCode", presetPos.getChannelCode()); |
|
|
|
final String temperUrlRes = HttpClientUtils.sendPostAgain(temperUrl, temperParam.toString()); |
|
|
|
log.info("[infra_1800] prePointExec temperUrlRes: {}", temperUrlRes); |
|
|
|
paramFileName = taskPatrolId.split(StringUtils.UNDERLINE)[1] + StringUtils.UNDERLINE |
|
|
|
+ taskPatrolId.split(StringUtils.UNDERLINE)[2] + StringUtils.UNDERLINE |
|
|
|
+ presetPos.getPatrolPointId() + StringUtils.UNDERLINE |
|
|
|
+ patrolTaskInfo.getDevNo() + "_" + temperUrlRes + ".jpg"; |
|
|
|
} else { |
|
|
|
paramFileName = taskPatrolId.split(StringUtils.UNDERLINE)[1] + StringUtils.UNDERLINE |
|
|
|
+ taskPatrolId.split(StringUtils.UNDERLINE)[2] + StringUtils.UNDERLINE |
|
|
|
+ presetPos.getPatrolPointId() + StringUtils.UNDERLINE |
|
|
|
+ patrolTaskInfo.getDevNo() + ".jpg"; |
|
|
|
} |
|
|
|
String paramUrl = liveIVS_URL + "/api/v1/device/channelsnap?serial=" + presetPos.getVideoNvrCode() + "&realtime=true&code=" + presetPos.getChannelCode(); |
|
|
|
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 { // 古老的红外处理流程,保留勿删除 |
|
|
|
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); |
|
|
|
} |
|
|
|
} else { // 古老的红外处理流程,保留勿删除 |
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
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(); |
|
|
|
} |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
}, 0, 1000L); |
|
|
|
} |
|
|
|
|
|
|
|
return taskExecRecord; |
|
|
|
@ -950,7 +927,7 @@ public class JobMainTask { |
|
|
|
JSONObject jsonObject = JSON.parseObject(jsonStr); |
|
|
|
RecordData recordData = JSON.toJavaObject(jsonObject, RecordData.class); |
|
|
|
String path = recordData.getRecordList().get(0).getDownloadURL(); |
|
|
|
FtpResult ftpResult = saveFile(path, patrolpointId + "_" + devNo + "_" + path.split("/")[path.split("/").length - 1].split("_")[2] + ".mp4", basePath + "Video"); |
|
|
|
FtpResult ftpResult = getFileAndSave(path, patrolpointId + "_" + devNo + "_" + path.split("/")[path.split("/").length - 1].split("_")[2] + ".mp4", basePath + "Video"); |
|
|
|
filePaths.append(path).append(","); |
|
|
|
log.info("视频保存路径 path={} ", path); |
|
|
|
} catch (Exception e) { |
|
|
|
@ -1411,7 +1388,7 @@ public class JobMainTask { |
|
|
|
return resList; |
|
|
|
} |
|
|
|
|
|
|
|
public FtpResult saveFile(String url, String fileName, String fileTypeDir) { |
|
|
|
public FtpResult getFileAndSave(String url, String fileName, String fileTypeDir) { |
|
|
|
try { |
|
|
|
log.info("saveFile STREAM url: {}", url); |
|
|
|
String[] split = url.split(StringUtils.QUESTION); |
|
|
|
|