|
|
@ -1,23 +1,42 @@ |
|
|
|
package com.bellmann.service.impl; |
|
|
|
package com.bellmann.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.bellmann.common.base.IBaseEnum; |
|
|
|
import com.bellmann.common.base.IBaseEnum; |
|
|
|
import com.bellmann.common.enums.CustomTypeEnum; |
|
|
|
import com.bellmann.common.constant.SystemConstants; |
|
|
|
import com.bellmann.common.enums.DevAccessTypeEnum; |
|
|
|
import com.bellmann.common.enums.*; |
|
|
|
import com.bellmann.common.enums.DevStatusEnum; |
|
|
|
import com.bellmann.common.exception.BusinessException; |
|
|
|
|
|
|
|
import com.bellmann.common.result.ResultCode; |
|
|
|
|
|
|
|
import com.bellmann.common.util.CommonUtils; |
|
|
|
import com.bellmann.manger.CustomerManager; |
|
|
|
import com.bellmann.manger.CustomerManager; |
|
|
|
|
|
|
|
import com.bellmann.manger.impl.DataDictManager; |
|
|
|
import com.bellmann.mapper.DeviceStaticMapper; |
|
|
|
import com.bellmann.mapper.DeviceStaticMapper; |
|
|
|
import com.bellmann.mapper.DeviceTypeVerDetailMapper; |
|
|
|
import com.bellmann.mapper.DeviceTypeVerDetailMapper; |
|
|
|
|
|
|
|
import com.bellmann.mapper.OperateResult2Mapper; |
|
|
|
|
|
|
|
import com.bellmann.mapper.OperateResultArgsMapper; |
|
|
|
|
|
|
|
import com.bellmann.model.dto.OperationTask; |
|
|
|
import com.bellmann.model.entity.Customer; |
|
|
|
import com.bellmann.model.entity.Customer; |
|
|
|
import com.bellmann.model.entity.DeviceTypeVerDetail; |
|
|
|
import com.bellmann.model.entity.DeviceTypeVerDetail; |
|
|
|
|
|
|
|
import com.bellmann.model.entity.OperateResult2; |
|
|
|
|
|
|
|
import com.bellmann.model.entity.OperateResultArgs; |
|
|
|
import com.bellmann.model.query.FaultQuery; |
|
|
|
import com.bellmann.model.query.FaultQuery; |
|
|
|
import com.bellmann.model.vo.FaultBasicInfoVO; |
|
|
|
import com.bellmann.model.vo.FaultBasicInfoVO; |
|
|
|
|
|
|
|
import com.bellmann.model.vo.FaultDiagnosisResult; |
|
|
|
import com.bellmann.model.vo.FaultQueryVO; |
|
|
|
import com.bellmann.model.vo.FaultQueryVO; |
|
|
|
|
|
|
|
import com.bellmann.security.util.SecurityUtils; |
|
|
|
import com.bellmann.service.FaultService; |
|
|
|
import com.bellmann.service.FaultService; |
|
|
|
|
|
|
|
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 lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
@ -29,6 +48,12 @@ public class FaultServiceImpl implements FaultService { |
|
|
|
|
|
|
|
|
|
|
|
private final DeviceTypeVerDetailMapper deviceTypeVerDetailMapper; |
|
|
|
private final DeviceTypeVerDetailMapper deviceTypeVerDetailMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final DataDictManager dataDictManager; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final OperateResult2Mapper operateResult2Mapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final OperateResultArgsMapper operateResultArgsMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<FaultQueryVO> queryList(FaultQuery query) { |
|
|
|
public List<FaultQueryVO> queryList(FaultQuery query) { |
|
|
|
return deviceStaticMapper.faultQueryList(query.getLabel(), query.getValue()); |
|
|
|
return deviceStaticMapper.faultQueryList(query.getLabel(), query.getValue()); |
|
|
@ -59,4 +84,108 @@ public class FaultServiceImpl implements FaultService { |
|
|
|
} |
|
|
|
} |
|
|
|
return faultBasicInfoQuery; |
|
|
|
return faultBasicInfoQuery; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public FaultDiagnosisResult basicInfoDiagnosis(Long devId, String remote) { |
|
|
|
|
|
|
|
if (devId==null || devId==0L || remote==null){ |
|
|
|
|
|
|
|
throw new BusinessException(ResultCode.PARAM_IS_NULL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String operateName = ""; |
|
|
|
|
|
|
|
String addEponOrLan = dataDictManager.AddEponOrLan(devId); |
|
|
|
|
|
|
|
boolean flag = CommonUtils.isNeedlanOrEpon(remote); |
|
|
|
|
|
|
|
if (flag){ |
|
|
|
|
|
|
|
operateName = IBaseEnum.getLabelByValue(remote, RemoteOperateMsgEnum.class) + addEponOrLan; |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
operateName = IBaseEnum.getLabelByValue(remote, RemoteOperateMsgEnum.class); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
OperationTask operationTask = new OperationTask(); |
|
|
|
|
|
|
|
operationTask.setDeviceId(devId); |
|
|
|
|
|
|
|
operationTask.setOperationName(operateName); |
|
|
|
|
|
|
|
operationTask.setOperationTaskDescription(operateName); |
|
|
|
|
|
|
|
operationTask.setCreateUser(SecurityUtils.getUsername()); |
|
|
|
|
|
|
|
long taskId = getDiagnosisResult(operationTask); |
|
|
|
|
|
|
|
boolean isSuccess = taskIsSuccess(taskId); |
|
|
|
|
|
|
|
FaultDiagnosisResult result = new FaultDiagnosisResult(); |
|
|
|
|
|
|
|
OperateResult2 operateResult2 = operateResult2Mapper.selectOne( |
|
|
|
|
|
|
|
new QueryWrapper<OperateResult2>() |
|
|
|
|
|
|
|
.eq("oper_task_id", taskId) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if (isSuccess){ |
|
|
|
|
|
|
|
List<OperateResultArgs> list = operateResultArgsMapper.selectList(new LambdaQueryWrapper<OperateResultArgs>() |
|
|
|
|
|
|
|
.eq(OperateResultArgs::getOperTaskId, taskId) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
result.setErrorDesc(operateResult2.getErrorDesc()); |
|
|
|
|
|
|
|
if (!list.isEmpty()){ |
|
|
|
|
|
|
|
result.setEndTime(list.get(0).getRecTime()); |
|
|
|
|
|
|
|
result.setTestResult(list.get(0).getArgsValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
result.setErrorDesc(ResultCode.THE_INTERFACE_CONNECTION_TIMED_OUT.getMsg()); |
|
|
|
|
|
|
|
result.setEndTime(operateResult2.getOperEndTime()); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public long getDiagnosisResult(OperationTask operationTask) { |
|
|
|
|
|
|
|
DOperTask2DetailStruct detailStruct = new DOperTask2DetailStruct(); |
|
|
|
|
|
|
|
DOperTask2Struct operTaskStruct = new DOperTask2Struct(); |
|
|
|
|
|
|
|
operTaskStruct.devId = operationTask.getDeviceId() == 0 ? Utils.LONG_NULL |
|
|
|
|
|
|
|
: operationTask.getDeviceId(); |
|
|
|
|
|
|
|
operTaskStruct.operName = operationTask.getOperationName() == null ? "" |
|
|
|
|
|
|
|
: operationTask.getOperationName(); |
|
|
|
|
|
|
|
operTaskStruct.operTaskCreateTime = (new Date()).getTime(); |
|
|
|
|
|
|
|
operTaskStruct.operTaskDesc = operationTask.getOperationTaskDescription(); |
|
|
|
|
|
|
|
operTaskStruct.operTaskId = operationTask.getOperationTaskId() == 0 ? Utils.LONG_NULL |
|
|
|
|
|
|
|
: operationTask.getOperationTaskId(); |
|
|
|
|
|
|
|
operTaskStruct.userName = operationTask.getCreateUser() == null ? "" |
|
|
|
|
|
|
|
: operationTask.getCreateUser(); |
|
|
|
|
|
|
|
detailStruct.operTask = operTaskStruct; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DOperTaskArgsStruct[] argsStruct = new DOperTaskArgsStruct[1]; |
|
|
|
|
|
|
|
argsStruct[0] = new DOperTaskArgsStruct(); |
|
|
|
|
|
|
|
argsStruct[0].argsName = ""; |
|
|
|
|
|
|
|
argsStruct[0].argsValue = ""; |
|
|
|
|
|
|
|
argsStruct[0].operTaskId = operTaskStruct.operTaskId; |
|
|
|
|
|
|
|
detailStruct.operTaskArgsList = argsStruct; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DOperTask2DetailStructHolder detailStructHolder = new DOperTask2DetailStructHolder( |
|
|
|
|
|
|
|
detailStruct); |
|
|
|
|
|
|
|
int result = OAMManager.sendDeviceOper2Task(detailStructHolder); |
|
|
|
|
|
|
|
if (result != 0) { |
|
|
|
|
|
|
|
throw new BusinessException(ResultCode.OAM_INTERFACE_ERROR); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return detailStructHolder.value.operTask.operTaskId; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean taskIsSuccess(Long taskId) { |
|
|
|
|
|
|
|
int attempt = 0; |
|
|
|
|
|
|
|
while (attempt < 10) { |
|
|
|
|
|
|
|
OperateResult2 operateResult2 = operateResult2Mapper.selectOne( |
|
|
|
|
|
|
|
new QueryWrapper<OperateResult2>() |
|
|
|
|
|
|
|
.eq("oper_task_id", taskId) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if (operateResult2 == null) { |
|
|
|
|
|
|
|
throw new BusinessException(ResultCode.TASK_NOT_FOUND); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String state = operateResult2.getResultState(); |
|
|
|
|
|
|
|
if (OperateTaskStateEnum.NOT_EXECUTED.getValue().equals(state)) { |
|
|
|
|
|
|
|
throw new BusinessException(ResultCode.TASK_NOT_EXE); |
|
|
|
|
|
|
|
} else if (OperateTaskStateEnum.EXECUTION_FAILED.getValue().equals(state)) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} else if (OperateTaskStateEnum.THE_DEVICE_IS_NOT_ONLINE.getValue().equals(state)) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} else if (OperateTaskStateEnum.THE_EXECUTION_WAS_SUCCESSFUL.getValue().equals(state)) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
TimeUnit.MILLISECONDS.sleep(SystemConstants.TASK_TIME_OUT_CONST4); |
|
|
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
attempt++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|