392 lines
12 KiB
C#
392 lines
12 KiB
C#
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Threading.Tasks;
|
||
using Unity.VisualScripting;
|
||
using UnityEngine;
|
||
using static BaseConf;
|
||
|
||
/// <summary>
|
||
/// 设备-查询
|
||
/// </summary>
|
||
[AddComponentMenu("设备查询"), Serializable]
|
||
public class DeviceQuery : MonoBehaviour
|
||
{
|
||
public Conf2 conf2;
|
||
|
||
public DeviceList deviceList = new DeviceList();
|
||
|
||
public GameObject hight;
|
||
|
||
private void OnEnable()
|
||
{
|
||
#region new
|
||
getRacksInfo();
|
||
#endregion
|
||
#region old
|
||
//if (deviceList.type == "2" &&
|
||
// deviceList.deviceType == "1" &&
|
||
// string.IsNullOrEmpty(deviceList.rackId))
|
||
//{
|
||
// var ParentGo = GameManager.Inst.FindParent(gameObject, GameManager.Inst.IsDesiredParent);
|
||
// if (!ParentGo)
|
||
// return;
|
||
// deviceList.rackId = ParentGo.GetComponent<DeviceQuery>().deviceList.id;
|
||
// if (!string.IsNullOrEmpty(deviceList.id))
|
||
// gameObject.name = deviceList.id;
|
||
//}
|
||
|
||
//else if (deviceList.type == "2" &&
|
||
// deviceList.deviceType == "3" &&
|
||
// string.IsNullOrEmpty(deviceList.shelfId))
|
||
//{
|
||
// //if (transform.parent.GetComponent<DeviceQuery>())
|
||
// var sb = GameManager.Inst.FindParent(gameObject, GameManager.Inst.IsFindRacks_goORTmsCards_go);
|
||
// if (sb && sb.GetComponent<DeviceQuery>())
|
||
// {
|
||
// //var d = transform.parent.GetComponent<DeviceQuery>();
|
||
// var d = sb.GetComponent<DeviceQuery>();
|
||
// if (d.deviceList.deviceType == "1" && !string.IsNullOrEmpty(d.deviceList.id))
|
||
// {
|
||
// //deviceList.shelfId = transform.parent.GetComponent<DeviceQuery>().deviceList.id;
|
||
// deviceList.shelfId = d.deviceList.id;
|
||
// }
|
||
// }
|
||
// if (!string.IsNullOrEmpty(deviceList.id))
|
||
// gameObject.name = deviceList.id;
|
||
//}
|
||
#endregion
|
||
}
|
||
|
||
private void Awake()
|
||
{
|
||
|
||
}
|
||
|
||
private void Start()
|
||
{
|
||
//await initAsync("");
|
||
}
|
||
|
||
//public async Task initAsync()
|
||
//{
|
||
// var jsonResult = await CombineJSON.GetJson_POST(GameManager.Inst.Jk_URL.sb_cx, GameManager.Inst.token);
|
||
|
||
// Root root = JsonConvert.DeserializeObject<Root>(jsonResult);
|
||
|
||
// foreach (var item in root.data)
|
||
// {
|
||
// if (item.id == deviceList.id)
|
||
// {
|
||
// deviceList = item;
|
||
// break;
|
||
// }
|
||
// }
|
||
//}
|
||
|
||
[ContextMenu("同步模型编号、容积")]
|
||
public void addscript()
|
||
{
|
||
deviceList.modelNum = transform.name;
|
||
deviceList.occupyNum = GetComponent<DragTest1>().volume.ToString();
|
||
}
|
||
|
||
public void setTag()
|
||
{
|
||
//Transform
|
||
//try
|
||
//{
|
||
|
||
//}
|
||
//catch
|
||
//{
|
||
// xuhao = transform.parent;
|
||
// U = xuhao.parent;
|
||
// cabinet = U.parent;
|
||
//}
|
||
//var xuhao = transform.parent;
|
||
//var U = xuhao.parent;
|
||
//var cabinet = U.parent;
|
||
}
|
||
|
||
|
||
public bool getRacksInfo()
|
||
{
|
||
//if (conf2.module_type != ModuleType.板卡)
|
||
// return false;
|
||
GameManager manager = new GameManager();
|
||
if (deviceList.type == "2" &&
|
||
deviceList.deviceType == "3")
|
||
{
|
||
var Cabine = manager.FindParent(gameObject, manager.IsDesiredParent);
|
||
var sb = manager.FindParent(gameObject, manager.IsFindRacks_goORMachineSlots_go);
|
||
if (Cabine && sb && sb.GetComponent<DeviceQuery>())
|
||
{
|
||
var d = sb.GetComponent<DeviceQuery>();
|
||
var c = Cabine.GetComponent<DeviceQuery>();
|
||
deviceList.rackId = c.deviceList.id;
|
||
if (d.deviceList.deviceType == "1" && string.IsNullOrEmpty(deviceList.shelfId))
|
||
{
|
||
deviceList.shelfId = d.deviceList.id;
|
||
}
|
||
else if (d.deviceList.deviceType == "2" && string.IsNullOrEmpty(deviceList.slotId))
|
||
{
|
||
deviceList.slotId = d.deviceList.id;
|
||
}
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
else if (deviceList.type == "2" &&
|
||
deviceList.deviceType == "1")
|
||
{
|
||
var sb = manager.FindParent(gameObject, manager.IsDesiredParent);
|
||
if (sb && sb.GetComponent<DeviceQuery>())
|
||
{
|
||
var d = sb.GetComponent<DeviceQuery>();
|
||
if (string.IsNullOrEmpty(deviceList.rackId))
|
||
{
|
||
deviceList.rackId = d.deviceList.id;
|
||
}
|
||
if (!string.IsNullOrEmpty(deviceList.id))
|
||
gameObject.name = deviceList.id;
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
#region JSON
|
||
[Serializable]
|
||
public class DeviceList
|
||
{
|
||
/// <summary>
|
||
/// 设备ID
|
||
/// </summary>
|
||
[Tooltip("设备ID")] public string id;
|
||
/// <summary>
|
||
/// 名称
|
||
/// </summary>
|
||
[Tooltip("名称")] public string deviceName;
|
||
/// <summary>
|
||
/// 设备编号
|
||
/// </summary>
|
||
[Tooltip("设备编号")] public string deviceCode;
|
||
/// <summary>
|
||
/// 类型:1-机柜;2-设备
|
||
/// </summary>
|
||
[Tooltip("类型:1-机柜;2-设备")] public string type;
|
||
/// <summary>
|
||
/// 类型
|
||
/// </summary>
|
||
[Tooltip("类型")] public string typeStr;
|
||
/// <summary>
|
||
/// 设备类型:1-机框;2-机槽;3-板卡
|
||
/// </summary>
|
||
[Tooltip("板卡类型:1-处理板;2-交叉板;3-光口板;4-线路板;5-主控板;6-以太网板")] public string deviceType;
|
||
/// <summary>
|
||
/// 设备类型
|
||
/// </summary>
|
||
[Tooltip("设备类型")] public string deviceTypeStr;
|
||
/// <summary>
|
||
/// 所属机柜id
|
||
/// </summary>
|
||
[Tooltip("所属机柜id")] public string rackId;
|
||
/// <summary>
|
||
/// 所属机框id
|
||
/// </summary>
|
||
[Tooltip("所属机框id")] public string shelfId;
|
||
/// <summary>
|
||
/// 所属机槽id
|
||
/// </summary>
|
||
[Tooltip("所属机槽id")] public string slotId;
|
||
/// <summary>
|
||
/// 设备位置
|
||
/// </summary>
|
||
[Tooltip("设备位置")] public string devicePosition;
|
||
/// <summary>
|
||
/// 机柜型号
|
||
/// </summary>
|
||
[Tooltip("机柜型号")] public string machineModel;
|
||
/// <summary>
|
||
/// 状态:1-正常;0-禁用
|
||
/// </summary>
|
||
[Tooltip("状态:1-正常;0-禁用")] public string status;
|
||
/// <summary>
|
||
/// 对联设备名称
|
||
/// </summary>
|
||
[Tooltip("对联设备名称")] public string conDeviceName;
|
||
/// <summary>
|
||
/// 机柜类型:1-通信机柜;2-非通信机柜
|
||
/// </summary>
|
||
[Tooltip("机柜类型:1-通信机柜;2-非通信机柜")] public string rackType;
|
||
/// <summary>
|
||
/// 柜门是否打开:1-开;0-关
|
||
/// </summary>
|
||
[Tooltip("柜门是否打开:1-开;0-关")] public string openFlag;
|
||
/// <summary>
|
||
/// 后柜门是否打开:1-开;0-关
|
||
/// </summary>
|
||
[Tooltip("后柜门是否打开:1-开;0-关")] public string backDoorFlag;
|
||
/// <summary>
|
||
/// 模型编号
|
||
/// </summary>
|
||
[Tooltip("模型编号")] public string modelNum;
|
||
/// <summary>
|
||
/// U位占用数量
|
||
/// </summary>
|
||
[Tooltip("U位占用数量")] public string occupyNum;
|
||
/// <summary>
|
||
/// U位剩余数量
|
||
/// </summary>
|
||
[Tooltip("U位剩余数量")] public string residueNum;
|
||
/// <summary>
|
||
/// 投运时间
|
||
/// </summary>
|
||
[Tooltip("投运时间")] public string operationTime;
|
||
/// <summary>
|
||
/// 负责人
|
||
/// </summary>
|
||
[Tooltip("负责人")] public string directorName;
|
||
/// <summary>
|
||
/// 手机号
|
||
/// </summary>
|
||
[Tooltip("手机号")] public string phone;
|
||
/// <summary>
|
||
/// 生产厂家
|
||
/// </summary>
|
||
[Tooltip("生产厂家")] public string manufacturer;
|
||
/// <summary>
|
||
/// 电源属性
|
||
/// </summary>
|
||
[Tooltip("电源属性")] public string powerProperties;
|
||
/// <summary>
|
||
/// 维护单位
|
||
/// </summary>
|
||
[Tooltip("维护单位")] public string maintenanceUnit;
|
||
/// <summary>
|
||
/// 机框高度
|
||
/// </summary>
|
||
[Tooltip("机框高度")] public string machineFrameHigh;
|
||
/// <summary>
|
||
/// 机框宽度
|
||
/// </summary>
|
||
[Tooltip("机框宽度")] public string machineFrameWide;
|
||
/// <summary>
|
||
/// 机框厚度
|
||
/// </summary>
|
||
[Tooltip("机框厚度")] public string machineFrameThick;
|
||
/// <summary>
|
||
/// 插槽数量
|
||
/// </summary>
|
||
[Tooltip("插槽数量")] public string slotNum;
|
||
/// <summary>
|
||
/// 插槽排列方式
|
||
/// </summary>
|
||
[Tooltip("插槽排列方式")] public string slotSort;
|
||
/// <summary>
|
||
/// 安装方式
|
||
/// </summary>
|
||
[Tooltip("安装方式")] public string installMethod;
|
||
/// <summary>
|
||
/// 所属机框
|
||
/// </summary>
|
||
[Tooltip("所属机框")] public string affiliationFrame;
|
||
/// <summary>
|
||
/// 父插槽名称
|
||
/// </summary>
|
||
[Tooltip("父插槽名称")] public string parentSlotName;
|
||
/// <summary>
|
||
/// 插槽类型
|
||
/// </summary>
|
||
[Tooltip("插槽类型")] public string slotType;
|
||
/// <summary>
|
||
/// 占用状态
|
||
/// </summary>
|
||
[Tooltip("占用状态")] public string occupyStatus;
|
||
/// <summary>
|
||
/// 所属机槽名称
|
||
/// </summary>
|
||
[Tooltip("所属机槽名称")] public string affiliationSlot;
|
||
/// <summary>
|
||
/// 端口数量
|
||
/// </summary>
|
||
[Tooltip("端口数量")] public string portNum;
|
||
/// <summary>
|
||
/// 板卡功能
|
||
/// </summary>
|
||
[Tooltip("板卡功能")] public string cardFunction;
|
||
/// <summary>
|
||
/// 板卡类型
|
||
/// </summary>
|
||
[Tooltip("板卡类型")] public string cardType;
|
||
/// <summary>
|
||
/// 运行状态
|
||
/// </summary>
|
||
[Tooltip("运行状态")] public string runStatus;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
[Tooltip("")] public string tmsId;
|
||
/// <summary>
|
||
/// 备注
|
||
/// </summary>
|
||
[Tooltip("备注")] public string remark;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
[Tooltip("")] public string deviceTypeCode;
|
||
/// <summary>
|
||
/// 功能说明
|
||
/// </summary>
|
||
[Tooltip("功能说明")] public string functionDescription;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
[Tooltip("")] public string createTime;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
[Tooltip("")] public string createName;
|
||
/// <summary>
|
||
/// 网络等级(1国网;2华东网;3省网;4地区网)
|
||
/// </summary>
|
||
[Tooltip("网络等级")] public string networkLevel;
|
||
}
|
||
|
||
|
||
[Serializable]
|
||
public class Root
|
||
{
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string code;
|
||
/// <summary>
|
||
/// 操作成功
|
||
/// </summary>
|
||
public string message;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public List<DeviceList> data;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string serverTime;
|
||
}
|
||
#endregion
|
||
}
|