tplink上传定时任务改为传到资源服务器中(原:传到COS)
This commit is contained in:
parent
1e4fe8057f
commit
0f24a1b96c
|
|
@ -70,7 +70,7 @@ public class CameraInfoJobServiceImpl extends ServiceImpl<CameraInfoMapper, Came
|
||||||
String process = result.getStr("process");
|
String process = result.getStr("process");
|
||||||
resultMap.put("result", "success");
|
resultMap.put("result", "success");
|
||||||
resultMap.put("process", process);
|
resultMap.put("process", process);
|
||||||
resultMap.put("url",result.getStr("url"));
|
resultMap.put("url", result.getStr("url"));
|
||||||
return resultMap;
|
return resultMap;
|
||||||
} else {
|
} else {
|
||||||
String errMsg = jsonObject.getStr("msg");
|
String errMsg = jsonObject.getStr("msg");
|
||||||
|
|
@ -106,7 +106,7 @@ public class CameraInfoJobServiceImpl extends ServiceImpl<CameraInfoMapper, Came
|
||||||
String process = result.getStr("process");
|
String process = result.getStr("process");
|
||||||
resultMap.put("result", "success");
|
resultMap.put("result", "success");
|
||||||
resultMap.put("process", process);
|
resultMap.put("process", process);
|
||||||
resultMap.put("url",result.getStr("url"));
|
resultMap.put("url", result.getStr("url"));
|
||||||
return resultMap;
|
return resultMap;
|
||||||
} else {
|
} else {
|
||||||
String errMsg = jsonObject.getStr("msg");
|
String errMsg = jsonObject.getStr("msg");
|
||||||
|
|
@ -204,7 +204,7 @@ public class CameraInfoJobServiceImpl extends ServiceImpl<CameraInfoMapper, Came
|
||||||
ftpUploadpath = cameraInfo.getFtpUploadpath();
|
ftpUploadpath = cameraInfo.getFtpUploadpath();
|
||||||
}
|
}
|
||||||
//文件夹不存在就创建 上传到COS不需要管这个问题了
|
//文件夹不存在就创建 上传到COS不需要管这个问题了
|
||||||
// mkdirsFolder(ftpUploadpath);
|
mkdirsFolder(ftpUploadpath);
|
||||||
String deviceIndex = cameraInfo.getDeviceIndex();
|
String deviceIndex = cameraInfo.getDeviceIndex();
|
||||||
String parentId = cameraInfo.getParentId();
|
String parentId = cameraInfo.getParentId();
|
||||||
String fileName = cameraInfo.getFileName();
|
String fileName = cameraInfo.getFileName();
|
||||||
|
|
@ -228,8 +228,8 @@ public class CameraInfoJobServiceImpl extends ServiceImpl<CameraInfoMapper, Came
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
Date date = sdf.parse(cameraInfo.getStartTime());
|
Date date = sdf.parse(cameraInfo.getStartTime());
|
||||||
Date date2 = sdf.parse(cameraInfo.getEndTime());
|
Date date2 = sdf.parse(cameraInfo.getEndTime());
|
||||||
long startTime = date.getTime() / 1000;
|
long startTime = date.getTime() / 1000 - 1;
|
||||||
long endTime = date2.getTime() / 1000;
|
long endTime = date2.getTime() / 1000 + 1;
|
||||||
// long startTime = 1765993096;
|
// long startTime = 1765993096;
|
||||||
// long endTime = 1765993156;
|
// long endTime = 1765993156;
|
||||||
sb.append("\"startTime\"").append(":").append(startTime).append(",");
|
sb.append("\"startTime\"").append(":").append(startTime).append(",");
|
||||||
|
|
@ -247,7 +247,7 @@ public class CameraInfoJobServiceImpl extends ServiceImpl<CameraInfoMapper, Came
|
||||||
JSONObject jsonObject = new JSONObject(res);
|
JSONObject jsonObject = new JSONObject(res);
|
||||||
String errorCode = jsonObject.getStr("error_code");
|
String errorCode = jsonObject.getStr("error_code");
|
||||||
Map<String, Object> resultMap = Maps.newHashMap();
|
Map<String, Object> resultMap = Maps.newHashMap();
|
||||||
resultMap.put("tplinkParams",sb.toString());
|
resultMap.put("tplinkParams", sb.toString());
|
||||||
if (errorCode.equals("0")) {
|
if (errorCode.equals("0")) {
|
||||||
JSONObject result = jsonObject.getJSONObject("result");
|
JSONObject result = jsonObject.getJSONObject("result");
|
||||||
String taskId = result.getStr("taskId");
|
String taskId = result.getStr("taskId");
|
||||||
|
|
|
||||||
|
|
@ -60,46 +60,57 @@ public class DirectiveOrderEndTplinkJob implements Job {
|
||||||
//机构编码
|
//机构编码
|
||||||
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||||
String orgCode = deptInfo.getString("code");
|
String orgCode = deptInfo.getString("code");
|
||||||
//任务一:COS上传进度查询
|
|
||||||
|
//任务一:根据taskId查询tplink进度
|
||||||
{
|
{
|
||||||
//已完成的视频
|
|
||||||
List<String> finishPathList = Lists.newArrayList();
|
|
||||||
//查询上传中的进度 cos_status = 1的
|
|
||||||
List<DirectiveOrder> directiveOrderList = directiveOrderService.getUploadingTplink();
|
List<DirectiveOrder> directiveOrderList = directiveOrderService.getUploadingTplink();
|
||||||
directiveOrderList.forEach(order -> {
|
directiveOrderList.forEach(order -> {
|
||||||
try {
|
Map<String, Object> result = tplinkService.getUploadToServerProcess(order.getTplinkTaskId());
|
||||||
CosFileInfoEntity cosResult = cosFileUtil.checkFileStatus(order.getTplinkPath());
|
System.out.println("↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓");
|
||||||
if (cosResult.isExists()) {
|
System.out.println(result.toString());
|
||||||
//上传完了
|
System.out.println("↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
|
||||||
order.setCosStatus("2");//上传成功
|
|
||||||
order.setOrderEndTime(new Date());//工单结束时间
|
|
||||||
order.setTplinkCrc64(cosResult.getCrc64());//视频切片crc64
|
|
||||||
order.setCosLen(cosResult.getFileSize() + "");
|
|
||||||
//记录需要进行CDN预热的文件
|
|
||||||
finishPathList.add(order.getTplinkPath());
|
|
||||||
} else if (cosResult.isSuccess()) {
|
|
||||||
//传输中
|
|
||||||
order.setCosStatus("1");//上传中
|
|
||||||
} else {
|
|
||||||
//失败了
|
|
||||||
order.setCosStatus("3");//上传失败
|
|
||||||
}
|
|
||||||
//更新工单数据
|
|
||||||
directiveOrderService.updateById(order);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
//本轮所有文件都查询完结果之后
|
|
||||||
try {
|
|
||||||
if (cdnEnabled && !CollectionUtils.isEmpty(finishPathList)) {
|
|
||||||
//CDN预热
|
|
||||||
cosFileUtil.batchPreloadCdn(finishPathList);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// //任务一:COS上传进度查询
|
||||||
|
// {
|
||||||
|
// //已完成的视频
|
||||||
|
// List<String> finishPathList = Lists.newArrayList();
|
||||||
|
// //查询上传中的进度 cos_status = 1的
|
||||||
|
// List<DirectiveOrder> directiveOrderList = directiveOrderService.getUploadingTplink();
|
||||||
|
// directiveOrderList.forEach(order -> {
|
||||||
|
// try {
|
||||||
|
// CosFileInfoEntity cosResult = cosFileUtil.checkFileStatus(order.getTplinkPath());
|
||||||
|
// if (cosResult.isExists()) {
|
||||||
|
// //上传完了
|
||||||
|
// order.setCosStatus("2");//上传成功
|
||||||
|
// order.setOrderEndTime(new Date());//工单结束时间
|
||||||
|
// order.setTplinkCrc64(cosResult.getCrc64());//视频切片crc64
|
||||||
|
// order.setCosLen(cosResult.getFileSize() + "");
|
||||||
|
// //记录需要进行CDN预热的文件
|
||||||
|
// finishPathList.add(order.getTplinkPath());
|
||||||
|
// } else if (cosResult.isSuccess()) {
|
||||||
|
// //传输中
|
||||||
|
// order.setCosStatus("1");//上传中
|
||||||
|
// } else {
|
||||||
|
// //失败了
|
||||||
|
// order.setCosStatus("3");//上传失败
|
||||||
|
// }
|
||||||
|
// //更新工单数据
|
||||||
|
// directiveOrderService.updateById(order);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// //本轮所有文件都查询完结果之后
|
||||||
|
// try {
|
||||||
|
// if (cdnEnabled && !CollectionUtils.isEmpty(finishPathList)) {
|
||||||
|
// //CDN预热
|
||||||
|
// cosFileUtil.batchPreloadCdn(finishPathList);
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
//任务二:处理tplink上传
|
//任务二:处理tplink上传
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue