tplink上传定时任务改为传到资源服务器中(原:传到COS)

This commit is contained in:
1378012178@qq.com 2026-04-29 10:29:25 +08:00
parent 1e4fe8057f
commit 0f24a1b96c
2 changed files with 52 additions and 41 deletions

View File

@ -70,7 +70,7 @@ public class CameraInfoJobServiceImpl extends ServiceImpl<CameraInfoMapper, Came
String process = result.getStr("process");
resultMap.put("result", "success");
resultMap.put("process", process);
resultMap.put("url",result.getStr("url"));
resultMap.put("url", result.getStr("url"));
return resultMap;
} else {
String errMsg = jsonObject.getStr("msg");
@ -106,7 +106,7 @@ public class CameraInfoJobServiceImpl extends ServiceImpl<CameraInfoMapper, Came
String process = result.getStr("process");
resultMap.put("result", "success");
resultMap.put("process", process);
resultMap.put("url",result.getStr("url"));
resultMap.put("url", result.getStr("url"));
return resultMap;
} else {
String errMsg = jsonObject.getStr("msg");
@ -204,7 +204,7 @@ public class CameraInfoJobServiceImpl extends ServiceImpl<CameraInfoMapper, Came
ftpUploadpath = cameraInfo.getFtpUploadpath();
}
//文件夹不存在就创建 上传到COS不需要管这个问题了
// mkdirsFolder(ftpUploadpath);
mkdirsFolder(ftpUploadpath);
String deviceIndex = cameraInfo.getDeviceIndex();
String parentId = cameraInfo.getParentId();
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");
Date date = sdf.parse(cameraInfo.getStartTime());
Date date2 = sdf.parse(cameraInfo.getEndTime());
long startTime = date.getTime() / 1000;
long endTime = date2.getTime() / 1000;
long startTime = date.getTime() / 1000 - 1;
long endTime = date2.getTime() / 1000 + 1;
// long startTime = 1765993096;
// long endTime = 1765993156;
sb.append("\"startTime\"").append(":").append(startTime).append(",");
@ -247,7 +247,7 @@ public class CameraInfoJobServiceImpl extends ServiceImpl<CameraInfoMapper, Came
JSONObject jsonObject = new JSONObject(res);
String errorCode = jsonObject.getStr("error_code");
Map<String, Object> resultMap = Maps.newHashMap();
resultMap.put("tplinkParams",sb.toString());
resultMap.put("tplinkParams", sb.toString());
if (errorCode.equals("0")) {
JSONObject result = jsonObject.getJSONObject("result");
String taskId = result.getStr("taskId");

View File

@ -60,46 +60,57 @@ public class DirectiveOrderEndTplinkJob implements Job {
//机构编码
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
String orgCode = deptInfo.getString("code");
//任务一COS上传进度查询
//任务一根据taskId查询tplink进度
{
//已完成的视频
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();
}
Map<String, Object> result = tplinkService.getUploadToServerProcess(order.getTplinkTaskId());
System.out.println("↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓");
System.out.println(result.toString());
System.out.println("↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
});
//本轮所有文件都查询完结果之后
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上传