工单tplink定时任务(非最终版本)
This commit is contained in:
parent
4a5c82e028
commit
565a15d8ff
|
|
@ -0,0 +1,94 @@
|
|||
package com.nu.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: tplink操作日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
public class IotOptLogEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 设备标识
|
||||
*/
|
||||
private String sn;
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
private String nuId;
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
private Date optTime;
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
private String optBy;
|
||||
/**
|
||||
* 操作的事件描述
|
||||
*/
|
||||
private String optDesc;
|
||||
/**
|
||||
* 操作结果(代码层面,非tplink接口调用结果)
|
||||
*/
|
||||
private String optResult;
|
||||
/**
|
||||
* tplink接口调用结果
|
||||
*/
|
||||
private String tplinkApiResult;
|
||||
/**
|
||||
* 回放视频ftp上传进度查询返回的错误信息
|
||||
*/
|
||||
private String tplinkApiErrorMsg;
|
||||
/**
|
||||
* 服务工单id nu_biz_directive_order.id
|
||||
*/
|
||||
private String servOrderId;
|
||||
/**
|
||||
* tplink任务taskId
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
* 上传回放视频的视频开始时间(工单员工点击开始时间)
|
||||
*/
|
||||
private Date mp4EmpStartTime;
|
||||
/**
|
||||
* 上传回放视频的视频结束时间(工单员工点击结束时间)
|
||||
*/
|
||||
private Date mp4EmpEndTime;
|
||||
/**
|
||||
* 上传回放视频的视频总分钟数(工单执行时长)
|
||||
*/
|
||||
private Integer mp4Minute;
|
||||
/**
|
||||
* tplink接口调用传参
|
||||
*/
|
||||
private String tplinkParams;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.nu.modules.log.api;
|
||||
|
||||
import com.nu.entity.IotOptLogEntity;
|
||||
|
||||
public interface TplinkOptLogApi {
|
||||
int saveData(IotOptLogEntity iotOptLog);
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.nu.modules.tplink.camera.service;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nu.entity.DirectiveOrderEntity;
|
||||
import com.nu.modules.tplink.camera.entity.CameraInfo;
|
||||
import com.nu.modules.tplink.camera.model.CameraTreeModel;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-摄像头信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-01-17
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ICameraInfoJobService extends IService<CameraInfo> {
|
||||
|
||||
Map<String,Object> getUploadToServerProcess(String taskId);
|
||||
|
||||
/**
|
||||
* 下载tplink自定义录像
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> zdyTplinkVideo(DirectiveOrderEntity orderEntity, String orgCode);
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.nu.modules.tplink.camera.service;
|
|||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.entity.DirectiveOrderEntity;
|
||||
import com.nu.modules.tplink.camera.model.CameraTreeModel;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import com.nu.modules.tplink.camera.entity.CameraInfo;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,275 @@
|
|||
package com.nu.modules.tplink.camera.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nu.entity.DirectiveOrderEntity;
|
||||
import com.nu.modules.tplink.camera.entity.CameraInfo;
|
||||
import com.nu.modules.tplink.camera.mapper.CameraInfoMapper;
|
||||
import com.nu.modules.tplink.camera.service.ICameraInfoJobService;
|
||||
import com.nu.modules.tplink.common.entity.ErrorCode;
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import com.nu.modules.tplink.common.mapper.TumsConfigMapper;
|
||||
import com.nu.modules.tplink.common.service.IErrorCodeService;
|
||||
import com.nu.modules.tplink.utils.TumsApi;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-摄像头信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-01-17
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CameraInfoJobServiceImpl extends ServiceImpl<CameraInfoMapper, CameraInfo> implements ICameraInfoJobService {
|
||||
|
||||
@Autowired
|
||||
private TumsApi tumsApi;
|
||||
@Autowired
|
||||
private IErrorCodeService errorCodeService;
|
||||
@Autowired
|
||||
private TumsConfigMapper tumsConfigMapper;
|
||||
|
||||
@Value(value = "${jeecg.path.upload}")
|
||||
private String uploadpath;
|
||||
|
||||
|
||||
/**
|
||||
* 获取转存MP4上传任务进度
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getUploadToServerProcess(String taskId) {
|
||||
Map<String, Object> resultMap = Maps.newHashMap();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"taskId\"").append(":").append("\"").append(taskId).append("\"");
|
||||
sb.append("}");
|
||||
String res = tumsApi.getUploadToServerProcess(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(res);
|
||||
String errorCode = jsonObject.getStr("error_code");
|
||||
String url = jsonObject.getStr("url");
|
||||
System.out.println("↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓");
|
||||
System.out.println(url);
|
||||
System.out.println("↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑");
|
||||
if (errorCode.equals("0")) {
|
||||
JSONObject result = jsonObject.getJSONObject("result");
|
||||
String process = result.getStr("process");
|
||||
resultMap.put("result", "success");
|
||||
resultMap.put("process", process);
|
||||
return resultMap;
|
||||
} else {
|
||||
String errMsg = jsonObject.getStr("msg");
|
||||
if (errMsg == null || errMsg.equals("")) {
|
||||
try {
|
||||
ErrorCode errorVo = errorCodeService.getByCode(errorCode);
|
||||
errMsg = errorVo.getErrorMsg();
|
||||
} catch (Exception e) {
|
||||
errMsg = errorCode;
|
||||
}
|
||||
}
|
||||
log.info("getUploadToServerProcess:{}-{}", errorCode, errMsg);
|
||||
resultMap.put("result", "error");
|
||||
resultMap.put("errorCode", errorCode);
|
||||
resultMap.put("errMsg", errMsg);
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下载tplink自定义录像
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> zdyTplinkVideo(DirectiveOrderEntity orderEntity, String orgCode) {
|
||||
String nuId = orderEntity.getNuId();
|
||||
String startTime = DateUtils.formatDate(orderEntity.getEmpStartTime(), "yyyy-MM-dd HH:mm:ss");
|
||||
String endTime = DateUtils.formatDate(orderEntity.getEmpEndTime(), "yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
Map<String, Object> result = Maps.newHashMap();
|
||||
QueryWrapper<CameraInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("nu_id", nuId);
|
||||
List<CameraInfo> tplinkList = baseMapper.selectList(queryWrapper);
|
||||
if (tplinkList.size() == 0) {
|
||||
result.put("result", "error");
|
||||
return result;
|
||||
}
|
||||
String fileName = nuId + "-" + DateUtils.formatDate(new Date(), "yyyyMMddHHmmss" + "-" + orderEntity.getId());
|
||||
String year = DateUtils.formatDate(new Date(), "yyyy");
|
||||
String month = DateUtils.formatDate(new Date(), "MM");
|
||||
String day = DateUtils.formatDate(new Date(), "dd");
|
||||
CameraInfo tplinkInfo = tplinkList.get(0);
|
||||
CameraInfo cameraInfo = new CameraInfo();
|
||||
cameraInfo.setDeviceIndex(tplinkInfo.getDeviceIndex());
|
||||
cameraInfo.setParentId(tplinkInfo.getParentId());
|
||||
cameraInfo.setFileName(fileName);
|
||||
cameraInfo.setVideoType("1");
|
||||
cameraInfo.setFtpUploadpath("/tplinkVideo/fwzl" + "/" + orgCode
|
||||
+ "/" + year + "/" + month + "/" + day
|
||||
+ "/" + orderEntity.getInstructionName() + "/" + orderEntity.getCategoryName()
|
||||
+ "/" + orderEntity.getTypeName() + "/" + orderEntity.getDirectiveName());
|
||||
cameraInfo.setStartTime(startTime);
|
||||
cameraInfo.setEndTime(endTime);
|
||||
try {
|
||||
result = uploadToServerResult(cameraInfo);
|
||||
// result.put("")
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.put("result", "error");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回放视频转mp4上传
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> uploadToServerResult(CameraInfo cameraInfo) throws ParseException {
|
||||
String ftpUsername = "";
|
||||
String ftpPassword = "";
|
||||
String ftpUploadpath = "";
|
||||
String ftpIp = "";
|
||||
String ftpPort = "";
|
||||
log.info("uploadToServerResult - cameraInfo:{}:", cameraInfo);
|
||||
CameraInfo entity = baseMapper.getByDeviceId(cameraInfo);
|
||||
if (entity.getFtpIp() != null && !entity.getFtpIp().equals("")) {
|
||||
ftpIp = entity.getFtpIp();
|
||||
ftpPort = entity.getFtpPort();
|
||||
ftpUsername = entity.getFtpUsername();
|
||||
ftpPassword = entity.getFtpPassword();
|
||||
ftpUploadpath = entity.getFtpUploadpath();
|
||||
} else {
|
||||
TumsConfig tumsConfig = tumsConfigMapper.getByCode();
|
||||
ftpIp = tumsConfig.getFtpIp();
|
||||
ftpPort = tumsConfig.getFtpPort();
|
||||
ftpUsername = tumsConfig.getFtpUsername();
|
||||
ftpPassword = tumsConfig.getFtpPassword();
|
||||
ftpUploadpath = tumsConfig.getFtpUploadpath();
|
||||
}
|
||||
if (StringUtils.isNotBlank(cameraInfo.getFtpUploadpath())) {
|
||||
ftpUploadpath = cameraInfo.getFtpUploadpath();
|
||||
}
|
||||
//文件夹不存在就创建
|
||||
mkdirsFolder(ftpUploadpath);
|
||||
String deviceIndex = cameraInfo.getDeviceIndex();
|
||||
String parentId = cameraInfo.getParentId();
|
||||
String fileName = cameraInfo.getFileName();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"videoDevId\"").append(":").append("\"").append(deviceIndex).append("\",");
|
||||
if (parentId != null && !parentId.equals("") && !parentId.equals("0")) {
|
||||
//存储设备ID
|
||||
sb.append("\"storageDevId\"").append(":").append("\"").append(parentId).append("\",");
|
||||
} else {
|
||||
//SK卡,取自身设备ID
|
||||
sb.append("\"storageDevId\"").append(":").append("\"").append(deviceIndex).append("\",");
|
||||
}
|
||||
sb.append("\"videoType\"").append(":").append(cameraInfo.getVideoType()).append(",");
|
||||
sb.append("\"storageType\"").append(":").append("0").append(",");
|
||||
if (fileName != null && !fileName.equals("")) {
|
||||
//存储设备ID
|
||||
sb.append("\"fileName\"").append(":").append("\"").append(fileName).append("\",");
|
||||
}
|
||||
// 使用 SimpleDateFormat 解析
|
||||
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 = 1765993096;
|
||||
// long endTime = 1765993156;
|
||||
sb.append("\"startTime\"").append(":").append(startTime).append(",");
|
||||
sb.append("\"endTime\"").append(":").append(endTime).append(",");
|
||||
sb.append("\"downloadInfo\"").append(":{");
|
||||
sb.append("\"username\"").append(":").append("\"").append(ftpUsername).append("\",");
|
||||
sb.append("\"password\"").append(":").append("\"").append(ftpPassword).append("\",");
|
||||
sb.append("\"path\"").append(":").append("\"").append(ftpUploadpath).append("\",");
|
||||
sb.append("\"ftpIp\"").append(":").append("\"").append(ftpIp).append("\",");
|
||||
sb.append("\"ftpPort\"").append(":").append(ftpPort);
|
||||
sb.append("}");
|
||||
sb.append("}");
|
||||
System.out.println("------------------" + sb.toString());
|
||||
String res = tumsApi.uploadToServer(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(res);
|
||||
String errorCode = jsonObject.getStr("error_code");
|
||||
Map<String, Object> resultMap = Maps.newHashMap();
|
||||
if (errorCode.equals("0")) {
|
||||
JSONObject result = jsonObject.getJSONObject("result");
|
||||
String taskId = result.getStr("taskId");
|
||||
cameraInfo.setTaskId(taskId);
|
||||
// getUploadToServerProcess(cameraInfo);
|
||||
resultMap.put("result", "success");
|
||||
resultMap.put("taskId", taskId);
|
||||
resultMap.put("fileName", ftpUploadpath + "/" + fileName + ".mp4");
|
||||
return resultMap;
|
||||
} else {
|
||||
String errorMsg = "";
|
||||
try {
|
||||
ErrorCode errorVo = errorCodeService.getByCode(errorCode);
|
||||
errorMsg = errorVo.getErrorMsg();
|
||||
} catch (Exception e) {
|
||||
errorMsg = errorCode;
|
||||
}
|
||||
log.info("uploadToServerResult:{}-{}", errorCode, errorMsg);
|
||||
resultMap.put("result", "error");
|
||||
resultMap.put("errorCode", errorCode);
|
||||
resultMap.put("errorMsg", errorMsg);
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
public String mkdirsFolder(String folderPath) {
|
||||
// 创建File对象
|
||||
File folder = new File(folderPath);
|
||||
String ctxPath = uploadpath;
|
||||
String fileName = null;
|
||||
File file = new File(ctxPath + File.separator + File.separator);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();// 创建文件根目录
|
||||
} // 判断文件夹是否存在
|
||||
if (!folder.exists()) {
|
||||
System.out.println("文件夹不存在,开始创建...");
|
||||
|
||||
// 创建文件夹(包括所有不存在的父文件夹)
|
||||
boolean created = folder.mkdirs();
|
||||
|
||||
if (created) {
|
||||
System.out.println("文件夹创建成功:" + folderPath);
|
||||
} else {
|
||||
System.out.println("文件夹创建失败:" + folderPath);
|
||||
}
|
||||
} else {
|
||||
System.out.println("文件夹已存在:" + folderPath);
|
||||
|
||||
// 还可以判断是否是文件夹而不是文件
|
||||
if (folder.isDirectory()) {
|
||||
System.out.println("这是一个文件夹");
|
||||
} else {
|
||||
System.out.println("这不是一个文件夹,而是文件");
|
||||
}
|
||||
}
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nu.entity.DirectiveOrderEntity;
|
||||
import com.nu.modules.camerainfo.api.CameraInfoApi;
|
||||
import com.nu.entity.CameraInfoEntity;
|
||||
import com.nu.modules.tplink.camera.model.CameraTreeModel;
|
||||
|
|
@ -406,11 +408,12 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
|
||||
/**
|
||||
* 接口调用-获取设备详情信息
|
||||
*
|
||||
* @param ci
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<JSONObject> getDeviceDetails(CameraInfo ci){
|
||||
public Result<JSONObject> getDeviceDetails(CameraInfo ci) {
|
||||
String id = ci.getDeviceIndex();
|
||||
StringBuffer paramsSb = new StringBuffer();
|
||||
paramsSb.append("{");
|
||||
|
|
@ -418,8 +421,8 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
paramsSb.append("}");
|
||||
String ipcCapabilityRes = tumsApi.getDeviceDetails(paramsSb.toString());
|
||||
JSONObject jsonObject = new JSONObject(ipcCapabilityRes);
|
||||
if(jsonObject.getInt("error_code").equals(0)){
|
||||
JSONObject json = (JSONObject)jsonObject.get("result");
|
||||
if (jsonObject.getInt("error_code").equals(0)) {
|
||||
JSONObject json = (JSONObject) jsonObject.get("result");
|
||||
JSONObject extend = json.getJSONObject("extendInfo");
|
||||
String channel = extend.getStr("channel");
|
||||
try {
|
||||
|
|
@ -430,7 +433,7 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
cameraInfo.setDeviceStatus(deviceStatus);
|
||||
cameraInfo.setChannel(channel);
|
||||
baseMapper.updateDeviceStatusByDevId(cameraInfo);
|
||||
if(deviceStatus.equals("0")){
|
||||
if (deviceStatus.equals("0")) {
|
||||
return Result.error("设备已离线");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
@ -578,16 +581,16 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public Result<JSONObject> getImageSwitch(Map<String,Object> map){
|
||||
public Result<JSONObject> getImageSwitch(Map<String, Object> map) {
|
||||
String id = map.get("deviceIndex").toString();
|
||||
String type = map.get("type").toString();
|
||||
CameraInfo cameraInfo = new CameraInfo();
|
||||
cameraInfo.setDeviceIndex(id);
|
||||
cameraInfo = baseMapper.getByDeviceId(cameraInfo);
|
||||
String parentId = cameraInfo.getParentId();
|
||||
if(!parentId.equals("0")){
|
||||
if (!parentId.equals("0")) {
|
||||
id = parentId;
|
||||
type = "chn"+cameraInfo.getChannel()+"_switch";
|
||||
type = "chn" + cameraInfo.getChannel() + "_switch";
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
|
|
@ -602,37 +605,37 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
String addPreviewRes = tumsApi.passthrough(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(addPreviewRes);
|
||||
String errCode = jsonObject.getStr("error_code");
|
||||
if("0".equals(errCode)){
|
||||
JSONObject result = (JSONObject)jsonObject.get("result");
|
||||
JSONObject responseData = (JSONObject)result.get("responseData");
|
||||
if ("0".equals(errCode)) {
|
||||
JSONObject result = (JSONObject) jsonObject.get("result");
|
||||
JSONObject responseData = (JSONObject) result.get("responseData");
|
||||
String errorCode = responseData.getStr("error_code");
|
||||
if("0".equals(errorCode)){
|
||||
JSONObject image = (JSONObject)responseData.get("image");
|
||||
JSONObject data = (JSONObject)image.get(type);
|
||||
if ("0".equals(errorCode)) {
|
||||
JSONObject image = (JSONObject) responseData.get("image");
|
||||
JSONObject data = (JSONObject) image.get(type);
|
||||
// updateDeviceStatus(id,errorCode);
|
||||
return Result.OK(data);
|
||||
}else{
|
||||
} else {
|
||||
String errorMsg = "";
|
||||
try{
|
||||
try {
|
||||
ErrorCode errorVo = errorCodeService.getByCode(errorCode);
|
||||
errorMsg = errorVo.getErrorMsg();
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
errorMsg = errorCode;
|
||||
}
|
||||
// updateDeviceStatus(id,errorCode);
|
||||
log.info("getImageCommon:{}",errorMsg);
|
||||
log.info("getImageCommon:{}", errorMsg);
|
||||
return Result.error(errorMsg);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
String errMsg = "";
|
||||
try{
|
||||
try {
|
||||
ErrorCode errVo = errorCodeService.getByCode(errCode);
|
||||
errMsg = errVo.getErrorMsg();
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
errMsg = errCode;
|
||||
}
|
||||
// updateDeviceStatus(id,errCode);
|
||||
log.info("getImageCommon:{}",errMsg);
|
||||
log.info("getImageCommon:{}", errMsg);
|
||||
return Result.error(errMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -645,18 +648,18 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public Result setImageSwitch(Map<String,Object> map){
|
||||
public Result setImageSwitch(Map<String, Object> map) {
|
||||
String id = map.get("deviceIndex").toString();
|
||||
String type = map.get("type").toString();
|
||||
CameraInfo cameraInfo = new CameraInfo();
|
||||
cameraInfo.setDeviceIndex(id);
|
||||
cameraInfo = baseMapper.getByDeviceId(cameraInfo);
|
||||
String parentId = cameraInfo.getParentId();
|
||||
if(!parentId.equals("0")){
|
||||
if (!parentId.equals("0")) {
|
||||
id = parentId;
|
||||
type = "chn"+cameraInfo.getChannel()+"_switch";
|
||||
type = "chn" + cameraInfo.getChannel() + "_switch";
|
||||
}
|
||||
Map<String,Object> paramMap = (Map<String,Object>)map.get("param");
|
||||
Map<String, Object> paramMap = (Map<String, Object>) map.get("param");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"devId\"").append(":").append("\"").append(id).append("\"").append(",");
|
||||
|
|
@ -673,8 +676,8 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
csb.append("\"").append(key).append("\"").append(":").append("\"").append(value).append("\"").append(",");
|
||||
}
|
||||
String cstr = csb.toString();
|
||||
if(cstr.length()>0){
|
||||
cstr = cstr.substring(0,cstr.length()-1);
|
||||
if (cstr.length() > 0) {
|
||||
cstr = cstr.substring(0, cstr.length() - 1);
|
||||
}
|
||||
sb.append(cstr);
|
||||
sb.append("}");
|
||||
|
|
@ -684,34 +687,34 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
String addPreviewRes = tumsApi.passthrough(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(addPreviewRes);
|
||||
String errCode = jsonObject.getStr("error_code");
|
||||
if("0".equals(errCode)){
|
||||
JSONObject result = (JSONObject)jsonObject.get("result");
|
||||
JSONObject responseData = (JSONObject)result.get("responseData");
|
||||
if ("0".equals(errCode)) {
|
||||
JSONObject result = (JSONObject) jsonObject.get("result");
|
||||
JSONObject responseData = (JSONObject) result.get("responseData");
|
||||
String errorCode = responseData.getStr("error_code");
|
||||
if("0".equals(errorCode)){
|
||||
if ("0".equals(errorCode)) {
|
||||
return Result.OK("设置成功");
|
||||
}else{
|
||||
} else {
|
||||
String errorMsg = "";
|
||||
try{
|
||||
try {
|
||||
ErrorCode errorVo = errorCodeService.getByCode(errorCode);
|
||||
errorMsg = errorVo.getErrorMsg();
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
errorMsg = errorCode;
|
||||
}
|
||||
// updateDeviceStatus(id,errorCode);
|
||||
log.info("setImageCommon:{}",errorMsg);
|
||||
log.info("setImageCommon:{}", errorMsg);
|
||||
return Result.error(errorMsg);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
String errMsg = "";
|
||||
try{
|
||||
try {
|
||||
ErrorCode errVo = errorCodeService.getByCode(errCode);
|
||||
errMsg = errVo.getErrorMsg();
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
errMsg = errCode;
|
||||
}
|
||||
// updateDeviceStatus(id,errCode);
|
||||
log.info("setImageCommon:{}",errMsg);
|
||||
log.info("setImageCommon:{}", errMsg);
|
||||
return Result.error(errMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -2819,14 +2822,14 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
CameraInfo entity = baseMapper.getByDeviceId(cameraInfo);
|
||||
String parentId = entity.getParentId();
|
||||
String channelId = "0";
|
||||
if(!parentId.equals("0")){
|
||||
if (!parentId.equals("0")) {
|
||||
channelId = entity.getChannel();
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
if(!parentId.equals("0")){
|
||||
if (!parentId.equals("0")) {
|
||||
sb.append("\"devId\"").append(":").append("\"").append(id).append("\"");
|
||||
}else{
|
||||
} else {
|
||||
sb.append("\"devId\"").append(":").append("\"").append(parentId).append("\",");
|
||||
sb.append("\"videoDeviceIndex\"").append(":").append("\"").append(id).append("\",");
|
||||
sb.append("\"channelId\"").append(":").append(channelId);
|
||||
|
|
@ -3112,6 +3115,7 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
@Override
|
||||
public String zdyTplinkVideo(String nuId, String startTime, String endTime) {
|
||||
|
||||
Map<String, Object> result = Maps.newHashMap();
|
||||
QueryWrapper<CameraInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("nu_id", nuId);
|
||||
List<CameraInfo> tplinkList = baseMapper.selectList(queryWrapper);
|
||||
|
|
@ -3132,11 +3136,10 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
cameraInfo.setStartTime(startTime);
|
||||
cameraInfo.setEndTime(endTime);
|
||||
try {
|
||||
String fileNameRes = uploadToServerResult(cameraInfo);
|
||||
return fileNameRes;
|
||||
return uploadToServerResult(cameraInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3176,7 +3179,7 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
if (StringUtils.isNotBlank(cameraInfo.getFtpUploadpath())) {
|
||||
ftpUploadpath = cameraInfo.getFtpUploadpath();
|
||||
}
|
||||
//判断文件夹是否存在
|
||||
//文件夹不存在就创建
|
||||
mkdirsFolder(ftpUploadpath);
|
||||
String deviceIndex = cameraInfo.getDeviceIndex();
|
||||
String parentId = cameraInfo.getParentId();
|
||||
|
|
@ -3285,13 +3288,13 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
|
||||
//释放设备
|
||||
@Override
|
||||
public void release(CameraInfo cameraInfo){
|
||||
public void release(CameraInfo cameraInfo) {
|
||||
baseMapper.release(cameraInfo);
|
||||
}
|
||||
|
||||
//释放设备
|
||||
@Override
|
||||
public void updateBind(CameraInfo cameraInfo){
|
||||
public void updateBind(CameraInfo cameraInfo) {
|
||||
baseMapper.updateBind(cameraInfo);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,180 @@
|
|||
package com.nu.modules.tplink.log.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import com.nu.modules.tplink.log.entity.IotOptLog;
|
||||
import com.nu.modules.tplink.log.service.IIotOptLogService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
* @Description: tplink操作日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="tplink操作日志")
|
||||
@RestController
|
||||
@RequestMapping("/tplink/log/iotOptLog")
|
||||
@Slf4j
|
||||
public class IotOptLogController extends JeecgController<IotOptLog, IIotOptLogService> {
|
||||
@Autowired
|
||||
private IIotOptLogService iotOptLogService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param iotOptLog
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "tplink操作日志-分页列表查询")
|
||||
@ApiOperation(value="tplink操作日志-分页列表查询", notes="tplink操作日志-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<IotOptLog>> queryPageList(IotOptLog iotOptLog,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<IotOptLog> queryWrapper = QueryGenerator.initQueryWrapper(iotOptLog, req.getParameterMap());
|
||||
Page<IotOptLog> page = new Page<IotOptLog>(pageNo, pageSize);
|
||||
IPage<IotOptLog> pageList = iotOptLogService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param iotOptLog
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "tplink操作日志-添加")
|
||||
@ApiOperation(value="tplink操作日志-添加", notes="tplink操作日志-添加")
|
||||
@RequiresPermissions("tplink.log:nu_iot_opt_log:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody IotOptLog iotOptLog) {
|
||||
iotOptLogService.save(iotOptLog);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param iotOptLog
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "tplink操作日志-编辑")
|
||||
@ApiOperation(value="tplink操作日志-编辑", notes="tplink操作日志-编辑")
|
||||
@RequiresPermissions("tplink.log:nu_iot_opt_log:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody IotOptLog iotOptLog) {
|
||||
iotOptLogService.updateById(iotOptLog);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "tplink操作日志-通过id删除")
|
||||
@ApiOperation(value="tplink操作日志-通过id删除", notes="tplink操作日志-通过id删除")
|
||||
@RequiresPermissions("tplink.log:nu_iot_opt_log:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
iotOptLogService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "tplink操作日志-批量删除")
|
||||
@ApiOperation(value="tplink操作日志-批量删除", notes="tplink操作日志-批量删除")
|
||||
@RequiresPermissions("tplink.log:nu_iot_opt_log:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.iotOptLogService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "tplink操作日志-通过id查询")
|
||||
@ApiOperation(value="tplink操作日志-通过id查询", notes="tplink操作日志-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<IotOptLog> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
IotOptLog iotOptLog = iotOptLogService.getById(id);
|
||||
if(iotOptLog==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(iotOptLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param iotOptLog
|
||||
*/
|
||||
@RequiresPermissions("tplink.log:nu_iot_opt_log:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, IotOptLog iotOptLog) {
|
||||
return super.exportXls(request, iotOptLog, IotOptLog.class, "tplink操作日志");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("tplink.log:nu_iot_opt_log:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, IotOptLog.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
package com.nu.modules.tplink.log.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: tplink操作日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_iot_opt_log")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "nu_iot_opt_log对象", description = "tplink操作日志")
|
||||
public class IotOptLog implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
/**
|
||||
* 设备标识
|
||||
*/
|
||||
@Excel(name = "设备标识", width = 15)
|
||||
@ApiModelProperty(value = "设备标识")
|
||||
private java.lang.String sn;
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
@Excel(name = "区域编码", width = 15)
|
||||
@ApiModelProperty(value = "区域编码")
|
||||
private java.lang.String nuId;
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
@Excel(name = "操作时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "操作时间")
|
||||
private java.util.Date optTime;
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
@Excel(name = "操作人", width = 15)
|
||||
@ApiModelProperty(value = "操作人")
|
||||
private java.lang.String optBy;
|
||||
/**
|
||||
* 操作的事件描述
|
||||
*/
|
||||
@Excel(name = "操作的事件描述", width = 15)
|
||||
@ApiModelProperty(value = "操作的事件描述")
|
||||
private java.lang.String optDesc;
|
||||
/**
|
||||
* 操作结果(代码层面,非tplink接口调用结果)
|
||||
*/
|
||||
@Excel(name = "操作结果(代码层面,非tplink接口调用结果)", width = 15)
|
||||
@ApiModelProperty(value = "操作结果(代码层面,非tplink接口调用结果)")
|
||||
private java.lang.String optResult;
|
||||
/**
|
||||
* tplink接口调用结果
|
||||
*/
|
||||
@Excel(name = "tplink接口调用结果", width = 15)
|
||||
@ApiModelProperty(value = "tplink接口调用结果")
|
||||
private java.lang.String tplinkApiResult;
|
||||
/**
|
||||
* 回放视频ftp上传进度查询返回的错误信息
|
||||
*/
|
||||
@Excel(name = "回放视频ftp上传进度查询返回的错误信息", width = 15)
|
||||
@ApiModelProperty(value = "回放视频ftp上传进度查询返回的错误信息")
|
||||
private java.lang.String tplinkApiErrorMsg;
|
||||
/**
|
||||
* 服务工单id nu_biz_directive_order.id
|
||||
*/
|
||||
@Excel(name = "服务工单id nu_biz_directive_order.id", width = 15)
|
||||
@ApiModelProperty(value = "服务工单id nu_biz_directive_order.id")
|
||||
private java.lang.String servOrderId;
|
||||
/**
|
||||
* tplink任务taskId
|
||||
*/
|
||||
@Excel(name = "tplink任务taskId", width = 15)
|
||||
@ApiModelProperty(value = "tplink任务taskId")
|
||||
private java.lang.String taskId;
|
||||
/**
|
||||
* 上传回放视频的视频开始时间(工单员工点击开始时间)
|
||||
*/
|
||||
@Excel(name = "上传回放视频的视频开始时间(工单员工点击开始时间)", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "上传回放视频的视频开始时间(工单员工点击开始时间)")
|
||||
private java.util.Date mp4EmpStartTime;
|
||||
/**
|
||||
* 上传回放视频的视频结束时间(工单员工点击结束时间)
|
||||
*/
|
||||
@Excel(name = "上传回放视频的视频结束时间(工单员工点击结束时间)", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "上传回放视频的视频结束时间(工单员工点击结束时间)")
|
||||
private java.util.Date mp4EmpEndTime;
|
||||
/**
|
||||
* 上传回放视频的视频总分钟数(工单执行时长)
|
||||
*/
|
||||
@Excel(name = "上传回放视频的视频总分钟数(工单执行时长)", width = 15)
|
||||
@ApiModelProperty(value = "上传回放视频的视频总分钟数(工单执行时长)")
|
||||
private java.lang.Integer mp4Minute;
|
||||
/**
|
||||
* tplink接口调用传参
|
||||
*/
|
||||
@Excel(name = "tplink接口调用传参", width = 15)
|
||||
@ApiModelProperty(value = "tplink接口调用传参")
|
||||
private java.lang.String tplinkParams;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.nu.modules.tplink.log.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.nu.modules.tplink.log.entity.IotOptLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: tplink操作日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IotOptLogMapper extends BaseMapper<IotOptLog> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.tplink.log.mapper.IotOptLogMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.nu.modules.tplink.log.service;
|
||||
|
||||
import com.nu.modules.tplink.log.entity.IotOptLog;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: tplink操作日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IIotOptLogService extends IService<IotOptLog> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.nu.modules.tplink.log.service.impl;
|
||||
|
||||
import com.nu.entity.IotOptLogEntity;
|
||||
import com.nu.modules.log.api.TplinkOptLogApi;
|
||||
import com.nu.modules.tplink.log.entity.IotOptLog;
|
||||
import com.nu.modules.tplink.log.mapper.IotOptLogMapper;
|
||||
import com.nu.modules.tplink.log.service.IIotOptLogService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: tplink操作日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class IotOptLogServiceImpl extends ServiceImpl<IotOptLogMapper, IotOptLog> implements IIotOptLogService, TplinkOptLogApi {
|
||||
|
||||
@Override
|
||||
public int saveData(IotOptLogEntity iotOptLog) {
|
||||
IotOptLog saveData = new IotOptLog();
|
||||
BeanUtils.copyProperties(iotOptLog, saveData);
|
||||
return baseMapper.insert(saveData);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
package com.nu.modules.biz.order.job;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.nu.entity.DirectiveOrderEntity;
|
||||
import com.nu.modules.biz.order.entity.DirectiveOrder;
|
||||
import com.nu.modules.biz.order.service.IDirectiveOrderJobService;
|
||||
import com.nu.modules.sysconfig.ISysConfigApi;
|
||||
import com.nu.modules.tplink.camera.service.ICameraInfoJobService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 指令工单结束后,tplink上传相关处理
|
||||
*/
|
||||
@Slf4j
|
||||
public class DirectiveOrderEndTplinkJob implements Job {
|
||||
|
||||
|
||||
@Autowired
|
||||
private IDirectiveOrderJobService directiveOrderService;
|
||||
@Autowired
|
||||
private ICameraInfoJobService tplinkService;
|
||||
@Autowired
|
||||
private ISysConfigApi sysConfigApi;
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
|
||||
/**
|
||||
* tplink进度查询 + tplink上传任务
|
||||
* <p>
|
||||
* tplink上传任务 需要依赖 tplink进度查询 所以有先后顺序的 不要把两个任务分贝开线程处理
|
||||
*
|
||||
* @param jobExecutionContext
|
||||
* @throws JobExecutionException
|
||||
*/
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
log.info("OrdersJob:{}-{}", DateUtils.now(), "服务指令结束工单tplink处理定时任务");
|
||||
|
||||
//机构编码
|
||||
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||
String orgCode = deptInfo.getString("code");
|
||||
//任务一:查询tplink上传进度
|
||||
try {
|
||||
//查询工单未结束 有任务ID的(上传成功失败都把taskId 则表中有taskId的数据 就都是上传中的了 )
|
||||
List<DirectiveOrder> directiveOrderList = directiveOrderService.getUploadingTplink();
|
||||
directiveOrderList.forEach(order -> {
|
||||
//todo 上传成功失败都把taskId 则表中有 taskId的数据 就都是上传中的了
|
||||
Map<String, Object> tplinkProcessMap = tplinkService.getUploadToServerProcess(order.getTplinkTaskId());
|
||||
if ("success".equals((String) tplinkProcessMap.get("result"))) {
|
||||
String processStr = (String) tplinkProcessMap.get("process");
|
||||
int process = Integer.parseInt(processStr);
|
||||
if (process == 1000) {
|
||||
// directiveOrderService.finishTplinkUp(order.getId());
|
||||
} else {
|
||||
// directiveOrderService.upTplinkUpProcess(order.getId(), process);
|
||||
}
|
||||
System.out.println("===============成功成功成功=======================");
|
||||
System.out.println("taskId:" + order.getTplinkTaskId());
|
||||
System.out.println("进度:" + process);
|
||||
System.out.println("===============成功成功成功=======================");
|
||||
} else {
|
||||
System.out.println("===============失败失败失败=======================");
|
||||
System.out.println("taskId:" + order.getTplinkTaskId());
|
||||
System.out.println("===============失败失败失败=======================");
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
//任务二:处理tplink上传
|
||||
{
|
||||
//如果未配置,最多重试3次
|
||||
Integer tplinkMaxRetries = 3;
|
||||
JSONObject opeOpenUrl = sysConfigApi.getByKey("tplink_max_retries");
|
||||
try {
|
||||
tplinkMaxRetries = opeOpenUrl.getInteger("configValue");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//获取需要处理的工单数据 员工已结束服务 但工单未结束
|
||||
List<DirectiveOrder> directiveOrderList = directiveOrderService.getNeedProcessTpLinkList(tplinkMaxRetries);
|
||||
|
||||
for (DirectiveOrder directiveOrder : directiveOrderList) {
|
||||
try {
|
||||
String nuId = directiveOrder.getNuId();
|
||||
String startTime = DateUtils.formatDate(directiveOrder.getEmpStartTime(), "yyyy-MM-dd HH:mm:ss");
|
||||
String endTime = DateUtils.formatDate(directiveOrder.getEmpEndTime(), "yyyy-MM-dd HH:mm:ss");
|
||||
log.info("nuId:{}", nuId);
|
||||
log.info("startTime:{}", startTime);
|
||||
log.info("endTime:{}", endTime);
|
||||
DirectiveOrderEntity orderEntity = new DirectiveOrderEntity();
|
||||
BeanUtils.copyProperties(directiveOrder, orderEntity);
|
||||
Map<String, Object> resultTplink = tplinkService.zdyTplinkVideo(orderEntity, orgCode);
|
||||
String tplinkDownCount = directiveOrder.getTplinkDownCount();
|
||||
//设置处理次数
|
||||
if (StringUtils.isBlank(tplinkDownCount)) {
|
||||
directiveOrder.setTplinkDownCount("1");
|
||||
} else {
|
||||
directiveOrder.setTplinkDownCount((Integer.parseInt(tplinkDownCount) + 1) + "");
|
||||
}
|
||||
if (!StringUtils.equals("error", (String) resultTplink.get("result"))) {
|
||||
//成功调用tplink API 开始上传tplink切片 至 目标服务器
|
||||
String taskId = (String) resultTplink.get("taskId");
|
||||
String fileName = (String) resultTplink.get("fileName");
|
||||
directiveOrder.setTplinkTaskId(taskId);
|
||||
directiveOrder.setTplinkPath(fileName);
|
||||
}
|
||||
directiveOrderService.updateById(directiveOrder);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -53,5 +53,14 @@ public interface DirectiveOrderMapper extends BaseMapper<DirectiveOrder> {
|
|||
List<DirectiveOrderEntity> queryServOrderList(@Param("entity") DirectiveOrderEntity entity);
|
||||
|
||||
DirectiveOrderEntity queryOrderNeedDirectiveInfo(@Param("dto") DirectiveOrderEntity entity);
|
||||
|
||||
DirectiveOrderEntity queryOrderNeedBaseInfo(@Param("dto") DirectiveOrderEntity entity);
|
||||
|
||||
List<DirectiveOrder> getNeedProcessTpLinkList(@Param("tplinkMaxRetries") Integer tplinkMaxRetries);
|
||||
|
||||
List<DirectiveOrder> getUploadingTplink();
|
||||
|
||||
int finishTplinkUp(@Param("id") String id);
|
||||
|
||||
int upTplinkUpProcess(@Param("id") String id, @Param("process") int process);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -645,7 +645,7 @@
|
|||
dire.mp3_file,
|
||||
dire.mp4_file
|
||||
FROM nu_biz_directive_order t
|
||||
INNER JOIN (SELECT DISTINCT sub.serv_start_time,sub.instruction_id
|
||||
INNER JOIN (SELECT DISTINCT sub.serv_start_time, sub.instruction_id
|
||||
FROM nu_biz_directive_order sub
|
||||
WHERE sub.nu_id = #{entity.nuId}
|
||||
AND (
|
||||
|
|
@ -656,7 +656,8 @@
|
|||
AND (
|
||||
(sub.serv_end_time >= NOW() AND sub.emp_end_time IS NULL)
|
||||
OR (sub.emp_start_time IS NOT NULL AND sub.emp_end_time IS NULL)
|
||||
)) tmp ON t.serv_start_time = tmp.serv_start_time and t.instruction_id = tmp.instruction_id
|
||||
)) tmp
|
||||
ON t.serv_start_time = tmp.serv_start_time and t.instruction_id = tmp.instruction_id
|
||||
LEFT JOIN nu_config_service_directive dire on t.directive_id = dire.id
|
||||
where t.nu_id = #{entity.nuId}
|
||||
AND (
|
||||
|
|
@ -706,4 +707,27 @@
|
|||
LEFT JOIN nu_biz_elder_info elder ON elder.id = base.elder_id
|
||||
WHERE base.nu_id = #{dto.nuId}
|
||||
</select>
|
||||
<select id="getNeedProcessTpLinkList" resultType="com.nu.modules.biz.order.entity.DirectiveOrder">
|
||||
select ord.*
|
||||
from nu_biz_directive_order ord
|
||||
where ord.emp_end_time is not null
|
||||
and ord.order_end_time is null
|
||||
and tplink_task_id is null
|
||||
and (ord.tplink_down_count is null or ord.tplink_down_count <![CDATA[ <= ]]> #{tplinkMaxRetries})
|
||||
</select>
|
||||
|
||||
<select id="getUploadingTplink" resultType="com.nu.modules.biz.order.entity.DirectiveOrder">
|
||||
select ord.*
|
||||
from nu_biz_directive_order ord
|
||||
where ord.order_end_time is null
|
||||
and tplink_task_id is not null
|
||||
</select>
|
||||
|
||||
<update id="finishTplinkUp">
|
||||
update nu_biz_directive_order set order_end_time = now(),tplink_task_id = null,tplink_process = '1000' where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="upTplinkUpProcess">
|
||||
update nu_biz_directive_order set tplink_process = #{process} where id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package com.nu.modules.biz.order.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nu.modules.biz.order.entity.DirectiveOrder;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令工单主表
|
||||
* @Author: caolei
|
||||
* @Date: 2025-11-18
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IDirectiveOrderJobService extends IService<DirectiveOrder> {
|
||||
|
||||
List<DirectiveOrder> getNeedProcessTpLinkList(Integer tplinkMaxRetries);
|
||||
|
||||
List<DirectiveOrder> getUploadingTplink();
|
||||
|
||||
void finishTplinkUp(String id);
|
||||
|
||||
void upTplinkUpProcess(String id, int process);
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.nu.modules.biz.order.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.modules.biz.order.entity.DirectiveOrder;
|
||||
import com.nu.modules.biz.order.mapper.DirectiveOrderMapper;
|
||||
import com.nu.modules.biz.order.service.IDirectiveOrderJobService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令工单主表
|
||||
* @Author: caolei
|
||||
* @Date: 2025-11-18
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DirectiveOrderJobServiceImpl extends ServiceImpl<DirectiveOrderMapper, DirectiveOrder> implements IDirectiveOrderJobService {
|
||||
|
||||
@Override
|
||||
public List<DirectiveOrder> getNeedProcessTpLinkList(Integer tplinkMaxRetries) {
|
||||
return baseMapper.getNeedProcessTpLinkList(tplinkMaxRetries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DirectiveOrder> getUploadingTplink() {
|
||||
return baseMapper.getUploadingTplink();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishTplinkUp(String id) {
|
||||
baseMapper.finishTplinkUp(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upTplinkUpProcess(String id, int process) {
|
||||
baseMapper.upTplinkUpProcess(id, process);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue