parent
9ece140cdb
commit
28d7ad2c73
@ -0,0 +1,44 @@ |
|||||||
|
package com.bellmann.common.enums; |
||||||
|
|
||||||
|
import com.bellmann.common.base.IBaseEnum; |
||||||
|
import lombok.Getter; |
||||||
|
|
||||||
|
public enum RemoteOperateMsgEnum implements IBaseEnum<String> { |
||||||
|
|
||||||
|
GET_OBJECT_INFOS("GetObjectInfos", "设备浏览"), |
||||||
|
IP_PING("ipping", "IP Ping 测试"), |
||||||
|
DEVICE_MONITOR("devicemonitor", "设备监控"), |
||||||
|
SET_PARAMETER_VALUES("SetParameterValues", "设置设备参数值"), |
||||||
|
GET_PARAMETER_VALUES("GetParameterValues", "获取设备参数值"), |
||||||
|
SET_PARAMETER_ATTRIBUTES("SetParameterAttributes", "设置设备参数属性"), |
||||||
|
GET_PARAMETER_ATTRIBUTES("GetParameterAttributes", "获取设备参数属性"), |
||||||
|
ADD_OBJECT("AddObject", "添加设备参数实例"), |
||||||
|
DELETE_OBJECT("DeleteObject", "删除设备参数实例"), |
||||||
|
DOWNLOAD("Download", "下载文件"), |
||||||
|
UPLOAD("Upload", "上传文件"), |
||||||
|
REBOOT("Reboot", "重启设备"), |
||||||
|
TOUCH_DEVICE("TouchDevice", "设备在线测试"), |
||||||
|
UPLOAD_CONFIG("UploadConfig", "设备配置文件上传"), |
||||||
|
DOWNLOAD_CONFIG("DownloadConfig", "设备配置文件下发"), |
||||||
|
DSL_LOOP_DIAGNOSTICS("DslLoopDiagnostics", "DslLoop诊断"), |
||||||
|
ATMF5_LOOP_BACK_DIAGNOSTICS("ATMF5LoopbackDiagnostics", "ATMF5Loopback诊断"), |
||||||
|
DOWNLOAD_SOFT_VER_FILE("DownloadSoftVerFile", "设备软件版本升级"), |
||||||
|
|
||||||
|
FACTORY_RESET("FactoryReset", "恢复设备出厂设置"), |
||||||
|
|
||||||
|
UPLOAD_LOG("UploadLog", "获取设备日志文件"), |
||||||
|
|
||||||
|
BASIC_PARAMETER("basicparameter","获取设备链路信息") |
||||||
|
|
||||||
|
; |
||||||
|
@Getter |
||||||
|
private String value; |
||||||
|
|
||||||
|
@Getter |
||||||
|
private String label; |
||||||
|
|
||||||
|
RemoteOperateMsgEnum(String value, String label) { |
||||||
|
this.value = value; |
||||||
|
this.label = label; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
package com.bellmann.controller; |
||||||
|
|
||||||
|
|
||||||
|
import com.bellmann.common.result.Result; |
||||||
|
import com.bellmann.model.vo.DeviceLinkVO; |
||||||
|
import com.bellmann.plugin.dupsubmit.annotation.PreventDuplicateSubmit; |
||||||
|
import com.bellmann.service.OperateResultArgsService; |
||||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||||
|
import lombok.RequiredArgsConstructor; |
||||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* 前端控制器 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author 李小林 |
||||||
|
* @since 2024-07-11 |
||||||
|
*/ |
||||||
|
@Tag(name = "26.设备操作结果参数") |
||||||
|
@RestController |
||||||
|
@RequiredArgsConstructor |
||||||
|
@RequestMapping("/api/operate-result-args/v1") |
||||||
|
public class OperateResultArgsController { |
||||||
|
|
||||||
|
private final OperateResultArgsService operateResultArgsService; |
||||||
|
|
||||||
|
@GetMapping("/device-link-info/{devId}") |
||||||
|
@Operation(summary = "远程操作-获取设备链路信息") |
||||||
|
@PreventDuplicateSubmit |
||||||
|
public Result<List<DeviceLinkVO>> getDeviceLinkInfo(@PathVariable Long devId) { |
||||||
|
|
||||||
|
List<DeviceLinkVO> result = operateResultArgsService.getDeviceLinkInfo(devId); |
||||||
|
return Result.success(result); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -0,0 +1,18 @@ |
|||||||
|
package com.bellmann.mapper; |
||||||
|
|
||||||
|
import com.bellmann.model.entity.OperateResultArgs; |
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* Mapper 接口 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author 李小林 |
||||||
|
* @since 2024-07-11 |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface OperateResultArgsMapper extends BaseMapper<OperateResultArgs> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
package com.bellmann.model.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.time.LocalDateTime; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class DeviceDetail { |
||||||
|
private Long devId; |
||||||
|
|
||||||
|
private Long typeAndVerId; |
||||||
|
|
||||||
|
private Long custId; |
||||||
|
|
||||||
|
private Long regionAreaId; |
||||||
|
|
||||||
|
private Long corpAreaId; |
||||||
|
|
||||||
|
private String devSno; |
||||||
|
|
||||||
|
private String devMac; |
||||||
|
|
||||||
|
private String devPppoe; |
||||||
|
|
||||||
|
private String devAdNo; |
||||||
|
|
||||||
|
private String devStatus; |
||||||
|
|
||||||
|
private LocalDateTime devCreateTime; |
||||||
|
|
||||||
|
private LocalDateTime devModifyTime; |
||||||
|
|
||||||
|
private String devSoapFlag; |
||||||
|
|
||||||
|
private String devInformFlag; |
||||||
|
|
||||||
|
private String devRemark1; |
||||||
|
|
||||||
|
private String devRemark2; |
||||||
|
|
||||||
|
private String devRemark3; |
||||||
|
|
||||||
|
private String devRemark4; |
||||||
|
|
||||||
|
private String devRemark5; |
||||||
|
|
||||||
|
private String connectReqUrl; |
||||||
|
|
||||||
|
private String devIp; |
||||||
|
|
||||||
|
private String devOnline; |
||||||
|
|
||||||
|
private LocalDateTime devOnlineTime; |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package com.bellmann.model.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class OperationResultArguments { |
||||||
|
|
||||||
|
/** |
||||||
|
* 参数名 |
||||||
|
*/ |
||||||
|
private String argumentName ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 参数值 |
||||||
|
*/ |
||||||
|
private String argumentValue ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 时间值 |
||||||
|
*/ |
||||||
|
private String argumentTime; |
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
package com.bellmann.model.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class OperationTask { |
||||||
|
|
||||||
|
/** |
||||||
|
* 操作任务ID |
||||||
|
*/ |
||||||
|
private long operationTaskId = -1; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备ID |
||||||
|
*/ |
||||||
|
private long deviceId = -1; |
||||||
|
|
||||||
|
/** |
||||||
|
* 操作创建用户名 |
||||||
|
*/ |
||||||
|
private String createUser ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 操作说明 |
||||||
|
*/ |
||||||
|
private String operationTaskDescription ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 监控时长(分钟) |
||||||
|
*/ |
||||||
|
private int monitorTime = -1 ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 监控间隔(秒) |
||||||
|
*/ |
||||||
|
private int monitorPeriod = -1 ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 操作创建时间 |
||||||
|
*/ |
||||||
|
private long createTime = -1; |
||||||
|
|
||||||
|
/** |
||||||
|
* 操作名称(对应ITMS_DEV_OPER_TYPE中OPER_NAME) |
||||||
|
*/ |
||||||
|
private String operationName ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 文件ID |
||||||
|
*/ |
||||||
|
private String fileId ; |
||||||
|
} |
@ -0,0 +1,159 @@ |
|||||||
|
package com.bellmann.model.dto; |
||||||
|
|
||||||
|
import com.bellmann.common.constant.SystemConstants; |
||||||
|
import com.bellmann.model.entity.OperateResult2; |
||||||
|
import com.bellmann.model.entity.OperateTask2; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.text.SimpleDateFormat; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class RemoteOperation { |
||||||
|
/** |
||||||
|
* 远程操作编号 |
||||||
|
*/ |
||||||
|
private long operationId = -1 ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备ID |
||||||
|
*/ |
||||||
|
private long deviceId = -1 ; |
||||||
|
|
||||||
|
private String deviceSno; |
||||||
|
|
||||||
|
/** |
||||||
|
* 远程操作任务名称 |
||||||
|
*/ |
||||||
|
private String operationTaskName ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 操作描述 |
||||||
|
*/ |
||||||
|
private String operationDescription ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建时间 |
||||||
|
*/ |
||||||
|
private String createTime ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建人 |
||||||
|
*/ |
||||||
|
private String createUser ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 执行开始时间 |
||||||
|
*/ |
||||||
|
private String beginTime ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 执行结束时间 |
||||||
|
*/ |
||||||
|
private String endTime ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 操作结果 |
||||||
|
*/ |
||||||
|
private String operationResult ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 结果CODE |
||||||
|
*/ |
||||||
|
private String resultCode ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 结果描述 |
||||||
|
*/ |
||||||
|
private String resultDescription ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 结果参数信息 |
||||||
|
*/ |
||||||
|
private OperationResultArguments[] arguments ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 参数名称列表 |
||||||
|
*/ |
||||||
|
private Map<Object,Object> parameterNameList; |
||||||
|
|
||||||
|
/** |
||||||
|
* 参数名称 |
||||||
|
*/ |
||||||
|
private String parameterName; |
||||||
|
|
||||||
|
//用于设备监控:从数据库中取出设备监控信息
|
||||||
|
/** |
||||||
|
* 设备监控信息:监控时长字符描述 MONITOR_PERIOD |
||||||
|
*/ |
||||||
|
private String monitorPeriod; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备监控信息:监控时长值:(秒) |
||||||
|
*/ |
||||||
|
private String monitorPeriodValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备监控信息:采样周期字符描述 MONITOR_INTERVAL |
||||||
|
*/ |
||||||
|
private String monitorInterval; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备监控信息:采样周期值:(秒) |
||||||
|
*/ |
||||||
|
private String monitorIntervalValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备ID编号 |
||||||
|
*/ |
||||||
|
private String devADNo; |
||||||
|
|
||||||
|
/** |
||||||
|
* 卡信息 |
||||||
|
*/ |
||||||
|
private String cardId; |
||||||
|
|
||||||
|
|
||||||
|
private String cardNo; |
||||||
|
|
||||||
|
/** |
||||||
|
* 构造函数 |
||||||
|
*/ |
||||||
|
public RemoteOperation(){ |
||||||
|
|
||||||
|
} |
||||||
|
public RemoteOperation(OperateTask2 operateTask2, DeviceDetail deviceDetail, OperateResult2 operateResult2){ |
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||||
|
|
||||||
|
this.createTime = operateTask2.getOperTaskCreateTime()==null?"":dateFormat.format(operateTask2.getOperTaskCreateTime()); |
||||||
|
|
||||||
|
this.createUser = operateTask2.getUserName(); |
||||||
|
|
||||||
|
this.deviceId = operateTask2.getDevId(); |
||||||
|
|
||||||
|
this.operationTaskName = operateTask2.getOperName(); |
||||||
|
|
||||||
|
this.operationDescription = operateTask2.getOperTaskDesc(); |
||||||
|
|
||||||
|
this.operationId = operateTask2.getOperTaskId(); |
||||||
|
|
||||||
|
if (operateResult2!=null){ |
||||||
|
this.operationResult = operateResult2.getResultState(); |
||||||
|
|
||||||
|
this.resultCode = operateResult2.getErrorCode(); |
||||||
|
|
||||||
|
this.resultDescription =operateResult2.getErrorDesc(); |
||||||
|
|
||||||
|
this.beginTime =operateResult2.getOperStartTime()==null?"":dateFormat.format(operateResult2.getOperStartTime()); |
||||||
|
|
||||||
|
this.endTime = operateResult2.getOperEndTime()==null?"":dateFormat.format(operateResult2.getOperEndTime()); |
||||||
|
}else { |
||||||
|
this.operationResult = SystemConstants.NULL_RESULT; |
||||||
|
this.resultCode = ""; |
||||||
|
this.resultDescription = SystemConstants.NULL_RESULT; |
||||||
|
this.beginTime = ""; |
||||||
|
this.endTime = ""; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
package com.bellmann.model.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author 李小林 |
||||||
|
* @since 2024-07-11 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = false) |
||||||
|
@TableName("itms_oper_result_args") |
||||||
|
public class OperateResultArgs implements Serializable { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
private Long operTaskId; |
||||||
|
|
||||||
|
private String argsName; |
||||||
|
|
||||||
|
private String argsValue; |
||||||
|
|
||||||
|
private Date recTime; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package com.bellmann.model.vo; |
||||||
|
|
||||||
|
import com.bellmann.model.dto.ParamInfo; |
||||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||||
|
import lombok.Builder; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Data |
||||||
|
@Schema(description = "设备链路信息视图") |
||||||
|
@Builder |
||||||
|
public class DeviceLinkVO { |
||||||
|
private String title; |
||||||
|
|
||||||
|
private List<ParamInfo> list; |
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
package com.bellmann.model.vo; |
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||||
|
import lombok.Builder; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
@Data |
||||||
|
@Schema(description = "远程操作结果") |
||||||
|
@Builder |
||||||
|
public class RemoteOperateResult { |
||||||
|
|
||||||
|
private String resultState; |
||||||
|
|
||||||
|
private String resultCode; |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
package com.bellmann.service; |
||||||
|
|
||||||
|
import com.bellmann.model.vo.DeviceLinkVO; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* 服务类 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author 李小林 |
||||||
|
* @since 2024-07-11 |
||||||
|
*/ |
||||||
|
public interface OperateResultArgsService{ |
||||||
|
|
||||||
|
List<DeviceLinkVO> getDeviceLinkInfo(Long devId); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
package com.bellmann.service; |
||||||
|
|
||||||
|
import com.bellmann.model.dto.OperationTask; |
||||||
|
import com.bellmann.model.vo.RemoteOperateResult; |
||||||
|
|
||||||
|
public interface RemoteOperateTaskService { |
||||||
|
|
||||||
|
public Long sendTaskByDevId(Long devId,String createUser,String command); |
||||||
|
|
||||||
|
public long insertOperationTask(OperationTask operationTask); |
||||||
|
|
||||||
|
RemoteOperateResult findDevInfoArgsByDevIdIsTimeOut(Long devId, String command); |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,62 @@ |
|||||||
|
package com.bellmann.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import com.bellmann.common.enums.RemoteOperateMsgEnum; |
||||||
|
import com.bellmann.common.util.CommonUtils; |
||||||
|
import com.bellmann.mapper.OperateResultArgsMapper; |
||||||
|
import com.bellmann.mapper.OperateTask2Mapper; |
||||||
|
import com.bellmann.model.dto.ParamInfo; |
||||||
|
import com.bellmann.model.entity.OperateResultArgs; |
||||||
|
import com.bellmann.model.entity.OperateTask2; |
||||||
|
import com.bellmann.model.vo.DeviceLinkVO; |
||||||
|
import com.bellmann.service.OperateResultArgsService; |
||||||
|
import lombok.RequiredArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.text.SimpleDateFormat; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* 服务实现类 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author 李小林 |
||||||
|
* @since 2024-07-11 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
@RequiredArgsConstructor |
||||||
|
@Slf4j |
||||||
|
public class OperateResultArgsServiceImpl implements OperateResultArgsService { |
||||||
|
|
||||||
|
private final OperateTask2Mapper operateTask2Mapper; |
||||||
|
|
||||||
|
private final OperateResultArgsMapper operateResultArgsMapper; |
||||||
|
@Override |
||||||
|
public List<DeviceLinkVO> getDeviceLinkInfo(Long devId) { |
||||||
|
OperateTask2 operateTask2 = operateTask2Mapper.getLatestTaskByOperateName(devId, RemoteOperateMsgEnum.BASIC_PARAMETER.getValue()); |
||||||
|
List<OperateResultArgs> list = operateResultArgsMapper.selectList(new LambdaQueryWrapper<OperateResultArgs>() |
||||||
|
.eq(OperateResultArgs::getOperTaskId, operateTask2.getOperTaskId()) |
||||||
|
); |
||||||
|
StringBuilder html = new StringBuilder(); |
||||||
|
if (list.isEmpty()){ |
||||||
|
return new ArrayList<DeviceLinkVO>(); |
||||||
|
} |
||||||
|
for (OperateResultArgs args:list){ |
||||||
|
html.append(args.getArgsValue()); |
||||||
|
} |
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat( |
||||||
|
"yyyy-MM-dd HH:mm:ss"); |
||||||
|
List<ParamInfo> paramInfos = CommonUtils.parseHtmlToParamInfo(html.toString()); |
||||||
|
List<DeviceLinkVO> links = new ArrayList<>(); |
||||||
|
DeviceLinkVO deviceLinkVO = DeviceLinkVO |
||||||
|
.builder() |
||||||
|
.title("设备链路信息: " + dateFormat.format(operateTask2.getOperTaskCreateTime())) |
||||||
|
.list(paramInfos) |
||||||
|
.build(); |
||||||
|
links.add(deviceLinkVO); |
||||||
|
return links; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,205 @@ |
|||||||
|
package com.bellmann.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
||||||
|
import com.bellmann.common.base.IBaseEnum; |
||||||
|
import com.bellmann.common.constant.StringUtilsConstants; |
||||||
|
import com.bellmann.common.enums.DevAccessTypeEnum; |
||||||
|
import com.bellmann.common.enums.DevOnlineEnum; |
||||||
|
import com.bellmann.common.enums.RemoteOperateMsgEnum; |
||||||
|
import com.bellmann.common.exception.BusinessException; |
||||||
|
import com.bellmann.common.result.ResultCode; |
||||||
|
import com.bellmann.mapper.*; |
||||||
|
import com.bellmann.model.dto.DeviceDetail; |
||||||
|
import com.bellmann.model.dto.OperationTask; |
||||||
|
import com.bellmann.model.dto.RemoteOperation; |
||||||
|
import com.bellmann.model.entity.DeviceDynamic; |
||||||
|
import com.bellmann.model.entity.OperateResult2; |
||||||
|
import com.bellmann.model.entity.OperateTask2; |
||||||
|
import com.bellmann.model.vo.RemoteOperateResult; |
||||||
|
import com.bellmann.runner.UIService; |
||||||
|
import com.bellmann.service.RemoteOperateTaskService; |
||||||
|
import com.zznode.itms.api.InventoryManager; |
||||||
|
import com.zznode.itms.api.OAMManager; |
||||||
|
import com.zznode.itms.api.Utils; |
||||||
|
import com.zznode.itms.idl.device.DOperTask2DetailStruct; |
||||||
|
import com.zznode.itms.idl.device.DOperTask2DetailStructHolder; |
||||||
|
import com.zznode.itms.idl.device.DOperTask2Struct; |
||||||
|
import com.zznode.itms.idl.device.DOperTaskArgsStruct; |
||||||
|
import com.zznode.itms.idl.resourcedefinition.RFileInfoListHolder; |
||||||
|
import com.zznode.itms.idl.resourcedefinition.RFileInfoStruct; |
||||||
|
import com.zznode.itms.idl.resourcedefinition.RFileServerDetailListHolder; |
||||||
|
import lombok.RequiredArgsConstructor; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.text.ParseException; |
||||||
|
import java.text.SimpleDateFormat; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
import static com.bellmann.common.constant.SystemConstants.TASK_TIME_OUT_CONST; |
||||||
|
|
||||||
|
@Service |
||||||
|
@RequiredArgsConstructor |
||||||
|
public class RemoteOperateTaskServiceImpl implements RemoteOperateTaskService { |
||||||
|
|
||||||
|
private final DeviceStaticDetailMapper deviceStaticDetailMapper; |
||||||
|
|
||||||
|
private final OperateTask2Mapper operateTask2Mapper; |
||||||
|
|
||||||
|
private final DeviceStaticMapper deviceStaticMapper; |
||||||
|
|
||||||
|
private final OperateResult2Mapper operateResult2Mapper; |
||||||
|
|
||||||
|
private final DeviceDynamicMapper deviceDynamicMapper; |
||||||
|
@Override |
||||||
|
public Long sendTaskByDevId(Long devId, String createUser, String command) { |
||||||
|
OperationTask operationTask = new OperationTask(); |
||||||
|
operationTask.setDeviceId(devId); |
||||||
|
operationTask.setOperationName(command); |
||||||
|
operationTask.setOperationTaskDescription("test"); |
||||||
|
operationTask.setCreateUser(createUser); |
||||||
|
return insertOperationTask(operationTask); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public long insertOperationTask(OperationTask operationTask) { |
||||||
|
DOperTask2DetailStruct detailStruct = new DOperTask2DetailStruct(); |
||||||
|
DOperTask2Struct operateTaskStruct = new DOperTask2Struct(); |
||||||
|
operateTaskStruct.devId = operationTask.getDeviceId()==0? StringUtilsConstants.LONG_NULL:operationTask.getDeviceId(); |
||||||
|
operateTaskStruct.operName = (null == operationTask.getOperationName() ? "" |
||||||
|
: operationTask.getOperationName()); |
||||||
|
operateTaskStruct.operTaskCreateTime = (new Date()).getTime(); |
||||||
|
operateTaskStruct.operTaskDesc = IBaseEnum.getLabelByValue(operationTask.getOperationName(), RemoteOperateMsgEnum.class); |
||||||
|
operateTaskStruct.operTaskId = operationTask.getOperationTaskId() == 0 ? Utils.LONG_NULL |
||||||
|
: operationTask.getOperationTaskId(); |
||||||
|
operateTaskStruct.userName = (null == operationTask.getCreateUser() ? "" |
||||||
|
: operationTask.getCreateUser()); |
||||||
|
detailStruct.operTask = operateTaskStruct; |
||||||
|
|
||||||
|
DOperTaskArgsStruct[] argsStruct = new DOperTaskArgsStruct[2]; |
||||||
|
argsStruct[0] = new DOperTaskArgsStruct(); |
||||||
|
argsStruct[0].argsName = "FILE_URL"; |
||||||
|
argsStruct[0].argsValue = findFileURLByOperation(Long |
||||||
|
.parseLong(null == operationTask.getFileId() ? "0" |
||||||
|
: operationTask.getFileId()), operateTaskStruct.operName); |
||||||
|
argsStruct[0].operTaskId = operateTaskStruct.operTaskId; |
||||||
|
String accessType = deviceStaticDetailMapper.getDeviceAccessType(operateTaskStruct.devId); |
||||||
|
argsStruct[1] = new DOperTaskArgsStruct(); |
||||||
|
argsStruct[1].argsName = "AccessType"; |
||||||
|
argsStruct[1].argsValue = accessType == null ? "" : IBaseEnum.getLabelByValue(accessType, DevAccessTypeEnum.class); |
||||||
|
; |
||||||
|
argsStruct[1].operTaskId = operateTaskStruct.operTaskId; |
||||||
|
detailStruct.operTaskArgsList = argsStruct; |
||||||
|
DOperTask2DetailStructHolder detailStructHolder = new DOperTask2DetailStructHolder( |
||||||
|
detailStruct); |
||||||
|
int result = 0; |
||||||
|
try { |
||||||
|
result = OAMManager.sendDeviceOper2Task(detailStructHolder); |
||||||
|
}catch (Exception e){ |
||||||
|
throw new BusinessException(ResultCode.NOT_GET_DEVICE); |
||||||
|
} |
||||||
|
if (result != 0) { |
||||||
|
throw new BusinessException(ResultCode.OAM_INTERFACE_ERROR); |
||||||
|
} |
||||||
|
return detailStructHolder.value.operTask.operTaskId; |
||||||
|
} |
||||||
|
|
||||||
|
private String findFileURLByOperation(long fileId, String operation){ |
||||||
|
String url = ""; |
||||||
|
if ("DownloadSoftVerFile".equals(operation)) { |
||||||
|
url = findFileURLByFileId(fileId); |
||||||
|
} else if ("DownloadConfig".equals(operation)) { |
||||||
|
url = findFileURLByFileId(fileId); |
||||||
|
} |
||||||
|
return url; |
||||||
|
} |
||||||
|
private String findFileURLByFileId(long fileId){ |
||||||
|
StringBuffer sb = new StringBuffer("FTP://"); |
||||||
|
RFileInfoListHolder fileInfoListHolder = new RFileInfoListHolder(); |
||||||
|
String sql = "from ITMS_FILE where ITMS_FILE.FILE_ID= " + fileId; |
||||||
|
int result = InventoryManager.getFilesBySql(sql, 1, 10, |
||||||
|
fileInfoListHolder); |
||||||
|
if (result != 0) { |
||||||
|
throw new BusinessException(ResultCode.DATA_NOT_FOUND); |
||||||
|
} |
||||||
|
|
||||||
|
if (fileInfoListHolder.value.length > 0) { |
||||||
|
RFileInfoStruct fileInfoStruct = fileInfoListHolder.value[0]; |
||||||
|
RFileServerDetailListHolder fileServerDetailListHolder = new RFileServerDetailListHolder(); |
||||||
|
result = InventoryManager |
||||||
|
.getFileServerDetailByFileServerID( |
||||||
|
fileInfoStruct.fileServerId, |
||||||
|
fileServerDetailListHolder); |
||||||
|
if (result != 0) { |
||||||
|
throw new BusinessException(ResultCode.DATA_NOT_FOUND); |
||||||
|
} |
||||||
|
if (fileServerDetailListHolder.value.length > 0) { |
||||||
|
sb.append(fileServerDetailListHolder.value[0].fileServer.ftpUsername) |
||||||
|
.append(":") |
||||||
|
.append(fileServerDetailListHolder.value[0].fileServer.ftpPassword) |
||||||
|
.append("@").append(fileServerDetailListHolder.value[0].fileServer.ftpIp) |
||||||
|
.append(":").append(fileServerDetailListHolder.value[0].fileServer.ftpPort) |
||||||
|
.append("/").append(fileServerDetailListHolder.value[0].fileServer.ftpRootdir); |
||||||
|
} |
||||||
|
sb.append(fileInfoStruct.fileURL).append(fileInfoStruct.fileName); |
||||||
|
} |
||||||
|
return sb.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public RemoteOperateResult findDevInfoArgsByDevIdIsTimeOut(Long devId, String command) { |
||||||
|
String taskTimeOut = UIService.getTask_timeOut(); |
||||||
|
if (StringUtils.isEmpty(taskTimeOut)) { |
||||||
|
taskTimeOut = "10"; |
||||||
|
} |
||||||
|
long time = Long.parseLong(taskTimeOut) * TASK_TIME_OUT_CONST; |
||||||
|
RemoteOperation operation = findDevInfoArgsByDevId(devId, command); |
||||||
|
String tasktime = operation.getCreateTime(); |
||||||
|
if (StringUtils.isNotEmpty(tasktime)) { |
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat( |
||||||
|
"yyyy-MM-dd HH:mm:ss"); |
||||||
|
Date date0; |
||||||
|
try { |
||||||
|
date0 = dateFormat.parse(tasktime); |
||||||
|
} catch (ParseException e) { |
||||||
|
date0 = new Date(); |
||||||
|
} |
||||||
|
Date date1 = new Date(); |
||||||
|
long taskTime = date1.getTime() - date0.getTime(); |
||||||
|
// 连接设备超过20秒为超时
|
||||||
|
if (command.equalsIgnoreCase("TouchDevice")) { |
||||||
|
if (taskTime > 11 * 60 * 1000) //原30分钟
|
||||||
|
// 连接超时时间设为11分钟
|
||||||
|
{ |
||||||
|
operation.setOperationResult("1"); |
||||||
|
deviceDynamicMapper.update(null,new LambdaUpdateWrapper<DeviceDynamic>() |
||||||
|
.eq(DeviceDynamic::getDevId,devId) |
||||||
|
.set(DeviceDynamic::getDevOnline, DevOnlineEnum.OFF_LINE.getValue()) |
||||||
|
); |
||||||
|
} |
||||||
|
} else if (taskTime >= time) { |
||||||
|
operation.setOperationResult("2"); |
||||||
|
} |
||||||
|
// 连接设备超过20秒为超时
|
||||||
|
} |
||||||
|
return RemoteOperateResult. |
||||||
|
builder() |
||||||
|
.resultState(operation.getOperationResult()) |
||||||
|
.resultCode(operation.getResultCode()) |
||||||
|
.build(); |
||||||
|
} |
||||||
|
|
||||||
|
private RemoteOperation findDevInfoArgsByDevId (Long devId, String operateName){ |
||||||
|
OperateTask2 operateTask2 = operateTask2Mapper.findDOperateTask2StructByDevIdAndOperateName(devId,operateName); |
||||||
|
if (operateTask2==null){ |
||||||
|
return new RemoteOperation(); |
||||||
|
} |
||||||
|
DeviceDetail deviceDetail = deviceStaticMapper.findRDeviceDetailStructByDevId(devId); |
||||||
|
if (deviceDetail!=null){ |
||||||
|
OperateResult2 operateResult2 = operateResult2Mapper.findDOperateResultDetailStructByTaskIdAndDevId(operateTask2.getOperTaskId(),operateTask2.getDevId()); |
||||||
|
return new RemoteOperation(operateTask2,deviceDetail,operateResult2); |
||||||
|
} |
||||||
|
return new RemoteOperation(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
<?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.bellmann.mapper.DeviceStaticDetailMapper"> |
||||||
|
|
||||||
|
<select id="getDeviceAccessType" resultType="java.lang.String"> |
||||||
|
SELECT |
||||||
|
DEV_ACCESS_TYPE |
||||||
|
FROM |
||||||
|
ITMS_DEVICE_STATIC DEV, |
||||||
|
ITMS_DEVICE_TYPE_VER_DETAIL DETAIL |
||||||
|
WHERE |
||||||
|
DEV.TYPE_AND_VER_ID = DETAIL.TYPE_AND_VER_ID |
||||||
|
AND DEV.DEV_ID = #{devId} |
||||||
|
</select> |
||||||
|
</mapper> |
@ -0,0 +1,18 @@ |
|||||||
|
<?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.bellmann.mapper.OperateResultArgsMapper"> |
||||||
|
|
||||||
|
<!-- 通用查询映射结果 --> |
||||||
|
<resultMap id="BaseResultMap" type="com.bellmann.model.entity.OperateResultArgs"> |
||||||
|
<id column="oper_task_id" property="operTaskId" /> |
||||||
|
<result column="args_name" property="argsName" /> |
||||||
|
<result column="args_value" property="argsValue" /> |
||||||
|
<result column="rec_time" property="recTime" /> |
||||||
|
</resultMap> |
||||||
|
|
||||||
|
<!-- 通用查询结果列 --> |
||||||
|
<sql id="Base_Column_List"> |
||||||
|
oper_task_id, args_name, args_value, rec_time |
||||||
|
</sql> |
||||||
|
|
||||||
|
</mapper> |
Loading…
Reference in new issue