8.17(new)
This commit is contained in:
parent
4ed5f1482e
commit
7f2ded38ff
File diff suppressed because it is too large
Load Diff
|
@ -111,13 +111,328 @@ public class GameManager : MonoBehaviour
|
|||
public IEnumerator dsaklj()
|
||||
{
|
||||
yield return StartCoroutine(LoadJSON(Application.streamingAssetsPath + "/设备查询.json"));
|
||||
#region 正式
|
||||
deleteInit();
|
||||
TransparentGlowManage.Inst.addScript();
|
||||
#region 加载场景所有设备
|
||||
//信息分类-保存
|
||||
foreach (var item in root_AllDevice.data)
|
||||
{
|
||||
//(机柜)
|
||||
if (item.type == "1")
|
||||
{
|
||||
Cabinets.Add(item);
|
||||
}
|
||||
//(机框)
|
||||
if (item.type == "2" && item.deviceType == "1")
|
||||
{
|
||||
Racks.Add(item);
|
||||
}
|
||||
//(机槽)
|
||||
else if (item.type == "2" && item.deviceType == "2")
|
||||
{
|
||||
MachineSlots.Add(item);
|
||||
}
|
||||
//(板卡)
|
||||
else if (item.type == "2" && item.deviceType == "3")
|
||||
{
|
||||
TmsCards.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < root_AllENV.data.Count; i++)
|
||||
{
|
||||
ENVs.Add(root_AllENV.data[i]);
|
||||
}
|
||||
|
||||
//读取机柜配置
|
||||
#region 单独机柜
|
||||
//if (Cabinets_POS != null)
|
||||
//{
|
||||
// for (int i = 0; i < Cabinets_POS.Count; i++)
|
||||
// {
|
||||
// for (int j = 0; j < Cabinets.Count; j++)
|
||||
// {
|
||||
// if (Cabinets_POS[i].name == Cabinets[j].devicePosition && Cabinets[j].type == "1")
|
||||
// {
|
||||
// GameObject go;
|
||||
// try
|
||||
// {
|
||||
// go = Instantiate(Resources.Load<GameObject>("古泉站换流站机房/" + ""));//??
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// Debug.Log("模型生成错误:" + e.Message);
|
||||
// break;
|
||||
// }
|
||||
// var n = Cabinets_POS[i].name.Split('-');//拆分区域-编号
|
||||
// go.name = Cabinets_POS[i].name;
|
||||
// go.transform.SetParent(Cabinet_quYu[CengJi(n[0])]);
|
||||
// go.transform.position = Cabinets_POS[i].position;
|
||||
// go.transform.rotation = Cabinets_POS[i].rotation;
|
||||
// go.GetComponent<DeviceQuery>().deviceList = root_AllDevice.data[j];
|
||||
// Cabinets_go.Add(go);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
|
||||
//读取机柜配置
|
||||
for (int i = 0; i < Cabinets_go.Count; i++)
|
||||
{
|
||||
var n = Cabinets_go[i].GetComponent<DeviceQuery>().deviceList;
|
||||
for (int j = 0; j < Cabinets.Count; j++)
|
||||
{
|
||||
if (n.devicePosition == Cabinets[j].devicePosition)
|
||||
{
|
||||
n = Cabinets[j];
|
||||
Cabinets_go[i].GetComponent<DeviceQuery>().deviceList = n;
|
||||
//AssignFields(n, Cabinets[j]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//读取机柜环境配置
|
||||
for (int j = 0; j < ENVs.Count;)
|
||||
{
|
||||
for (int i = 0; i < Cabinets_go.Count; i++)
|
||||
{
|
||||
var n = Cabinets_go[i].GetComponent<DeviceQuery>().deviceList;
|
||||
var e = Cabinets_go[i].GetComponent<ENVQuery>();
|
||||
if (ENVs[j].pointDeviceId == n.id)
|
||||
{
|
||||
if (ENVs[j].pointType == "1")
|
||||
{
|
||||
e.eNVList_W = ENVs[j];
|
||||
break;
|
||||
}
|
||||
else if (ENVs[j].pointType == "2")
|
||||
{
|
||||
e.eNVList_S = ENVs[j];
|
||||
break;
|
||||
}
|
||||
else if (ENVs[j].pointType == "3")
|
||||
{
|
||||
|
||||
}
|
||||
else if (ENVs[j].pointType == "4")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//动态加载设备(机框)
|
||||
for (int i = 0; i < Racks.Count; i++)
|
||||
{
|
||||
foreach (var item in Cabinets_go)
|
||||
{
|
||||
/*if (item.deviceType == "1")
|
||||
{
|
||||
}*/
|
||||
if (item.GetComponent<DeviceQuery>().deviceList.id == Racks[i].rackId)
|
||||
{
|
||||
//获取模型编号
|
||||
string modelNum = Racks[i].modelNum;
|
||||
//获取U位
|
||||
var U = Racks[i].devicePosition;
|
||||
GameObject go;
|
||||
try
|
||||
{
|
||||
go = Instantiate(Resources.Load<GameObject>("古泉站机房模型90个型号/" + modelNum));
|
||||
//写入机框配置
|
||||
go.GetComponent<DeviceQuery>().deviceList = Racks[i];
|
||||
Racks_go.Add(go);
|
||||
|
||||
Renderer renderer = go.GetComponentInChildren<Renderer>();
|
||||
if (renderer)
|
||||
{
|
||||
var initrot = go.transform.rotation;
|
||||
go.transform.rotation = Quaternion.identity;
|
||||
|
||||
var bounds = renderer.bounds;
|
||||
var a = go.AddComponent<BoxCollider>();
|
||||
a.isTrigger = false;
|
||||
a.center = bounds.center - go.transform.position;
|
||||
a.size = bounds.size;
|
||||
//a.transform.rotation = Quaternion.identity; //重置其旋转为默认值
|
||||
|
||||
go.transform.rotation = initrot;
|
||||
}
|
||||
Vector3 center = renderer.bounds.center;
|
||||
go.transform.position = item.transform.Find("U位/" + U).position;
|
||||
//go.transform.rotation = item.transform.Find("U位/" + U).rotation;
|
||||
go.name = Racks[i].deviceName;
|
||||
go.transform.SetParent(item.transform.Find("U位/" + U));
|
||||
break;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Log("模型生成错误:" + item.name + "\n" + e.Message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//动态加载设备(机槽)
|
||||
for (int i = 0; i < Racks_go.Count; i++)//遍历机框
|
||||
{
|
||||
//机框下所有设备
|
||||
var jc = Racks_go[i].transform.GetComponentsInChildren<DeviceQuery>().ToList();
|
||||
for (int j = 0; j < jc.Count; j++)
|
||||
{
|
||||
//如果是机槽
|
||||
if (jc[j].deviceList.deviceType == "2")
|
||||
{
|
||||
MachineSlots_go.Add(jc[j].gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
//读取机槽配置
|
||||
for (int i = 0; i < MachineSlots_go.Count; i++)
|
||||
{
|
||||
DeviceQuery DP;
|
||||
DP = MachineSlots_go[i].transform.parent.GetComponent<DeviceQuery>();//机槽父物体
|
||||
if (!DP) continue;
|
||||
foreach (var item in MachineSlots)
|
||||
{
|
||||
//机槽在机框里
|
||||
/*if (item.deviceType == "2")
|
||||
{
|
||||
|
||||
}*/
|
||||
if (DP.deviceList.deviceType == "1" && item.shelfId == DP.deviceList.id)
|
||||
{
|
||||
MachineSlots_go[i].GetComponent<DeviceQuery>().deviceList = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//动态加载设备(板卡)
|
||||
for (int i = 0; i < MachineSlots_go.Count; i++)//遍历机槽
|
||||
{
|
||||
//机槽下所有设备
|
||||
var bk = MachineSlots_go[i].transform.GetComponentsInChildren<DeviceQuery>().ToList();
|
||||
for (int j = 0; j < bk.Count; j++)
|
||||
{
|
||||
//如果是板卡
|
||||
if (bk[j].deviceList.deviceType == "3")
|
||||
{
|
||||
TmsCards_go.Add(bk[j].gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < Racks_go.Count; i++)//遍历机框
|
||||
{
|
||||
//机框下所有设备
|
||||
var bk = Racks_go[i].transform.GetComponentsInChildren<DeviceQuery>().ToList();
|
||||
for (int j = 0; j < bk.Count; j++)
|
||||
{
|
||||
//如果是板卡
|
||||
if (bk[j].deviceList.deviceType == "3")
|
||||
{
|
||||
TmsCards_go.Add(bk[j].gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
//读取板卡配置
|
||||
for (int i = 0; i < TmsCards_go.Count; i++)
|
||||
{
|
||||
DeviceQuery DP;
|
||||
DeviceQuery D;
|
||||
DP = TmsCards_go[i].transform.parent.GetComponent<DeviceQuery>();//板卡父物体
|
||||
//D = TmsCards_go[i].transform.GetComponent<DeviceQuery>();//板卡
|
||||
if (!DP) continue;
|
||||
foreach (var item in TmsCards)
|
||||
{
|
||||
/*if (item.deviceType == "3")
|
||||
{
|
||||
|
||||
}*/
|
||||
//板卡在机槽里
|
||||
if (DP.deviceList.deviceType == "2" && item.slotId == DP.deviceList.id)
|
||||
{
|
||||
TmsCards_go[i].GetComponent<DeviceQuery>().deviceList = item;
|
||||
break;
|
||||
}
|
||||
//板卡在机框里
|
||||
else if (DP.deviceList.deviceType == "1" && item.shelfId == DP.deviceList.id)
|
||||
{
|
||||
TmsCards_go[i].GetComponent<DeviceQuery>().deviceList = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
//端口信息-保存
|
||||
foreach (var item in root_AllPort.data)
|
||||
{
|
||||
TmsPorts.Add(item);
|
||||
}
|
||||
//动态加载设备(端口)
|
||||
for (int i = 0; i < TmsCards_go.Count; i++)//遍历板卡
|
||||
{
|
||||
//板卡下所有设备
|
||||
var dk = TmsCards_go[i].transform.GetComponentsInChildren<PortQuery>().ToList();
|
||||
for (int j = 0; j < dk.Count; j++)
|
||||
{
|
||||
TmsPorts_go.Add(dk[j].gameObject);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < Racks_go.Count; i++)//遍历机框
|
||||
{
|
||||
//机框下所有设备
|
||||
var dk = Racks_go[i].transform.GetComponentsInChildren<PortQuery>().ToList();
|
||||
for (int j = 0; j < dk.Count; j++)
|
||||
{
|
||||
TmsPorts_go.Add(dk[j].gameObject);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < MachineSlots.Count; i++)//遍历机槽
|
||||
{
|
||||
//机槽下所有设备
|
||||
var dk = MachineSlots_go[i].transform.GetComponentsInChildren<PortQuery>().ToList();
|
||||
for (int j = 0; j < dk.Count; j++)
|
||||
{
|
||||
TmsPorts_go.Add(dk[j].gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
//读取端口配置
|
||||
for (int i = 0; i < TmsPorts_go.Count; i++)
|
||||
{
|
||||
DeviceQuery DP;
|
||||
DP = TmsPorts_go[i].transform.parent.GetComponent<DeviceQuery>();
|
||||
if (!DP) continue;
|
||||
foreach (var item in TmsPorts)
|
||||
{
|
||||
if (item.deviceId == DP.deviceList.id)
|
||||
{
|
||||
TmsPorts_go[i].GetComponent<PortQuery>().portList = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
private async void OnEnable()
|
||||
{
|
||||
//StartCoroutine(dsaklj());//²âÊÔ
|
||||
//return;//²âÊÔ
|
||||
StartCoroutine(dsaklj());//测试
|
||||
return;//测试
|
||||
#region 正式
|
||||
await deleteInit();
|
||||
TransparentGlowManage.Inst.addScript();
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using AutoMapper;
|
||||
using UnityEngine.UI;
|
||||
using static UnityEditor.Progress;
|
||||
|
||||
|
@ -19,6 +20,8 @@ public class TOOL : MonoBehaviour
|
|||
|
||||
public Transform UI_follow;
|
||||
|
||||
public RedactDevice redactDevice;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
|
@ -209,4 +212,22 @@ public class TOOL : MonoBehaviour
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("修改机柜")]
|
||||
public void dsadsa()
|
||||
{
|
||||
var objA = gameObjects[0].GetComponent<DeviceQuery>().deviceList;
|
||||
|
||||
|
||||
MapperConfiguration config = new MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.CreateMap<RedactDevice.Body, DeviceQuery.DeviceList>();
|
||||
cfg.CreateMap<DeviceQuery.DeviceList, RedactDevice.Body>();
|
||||
});
|
||||
|
||||
IMapper mapper = config.CreateMapper();
|
||||
|
||||
// 转换 ClassA 到 ClassB
|
||||
redactDevice.mybody = mapper.Map<RedactDevice.Body>(objA);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using AutoMapper;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
|
@ -13,6 +14,7 @@ public class RedactDevice : MonoBehaviour
|
|||
{
|
||||
public Body mybody;
|
||||
public Root URlreturn;
|
||||
DeviceQuery.DeviceList device;
|
||||
|
||||
/// <summary>
|
||||
/// 类型
|
||||
|
@ -35,8 +37,38 @@ public class RedactDevice : MonoBehaviour
|
|||
#endregion
|
||||
public Button save_bt;
|
||||
|
||||
|
||||
|
||||
MapperConfiguration config;
|
||||
IMapper mapper;
|
||||
public void OnEnable()
|
||||
{
|
||||
config = new MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.CreateMap<RedactDevice.Body, DeviceQuery.DeviceList>();
|
||||
cfg.CreateMap<DeviceQuery.DeviceList, RedactDevice.Body>();
|
||||
});
|
||||
mapper = config.CreateMapper();
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(GameManager.Inst.nowDeviceID))
|
||||
{
|
||||
for (int i = 0; i < GameManager.Inst.root_AllDevice.data.Count; i++)
|
||||
{
|
||||
if (GameManager.Inst.root_AllDevice.data[i].id == GameManager.Inst.nowDeviceID)
|
||||
{
|
||||
device = GameManager.Inst.root_AllDevice.data[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
mybody = mapper.Map<RedactDevice.Body>(device);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (type) type.value = int.Parse(String.IsNullOrEmpty(mybody.type) ? "0" : mybody.type);
|
||||
if (deviceType) deviceType.value = String.IsNullOrEmpty(mybody.deviceType) ? 0 : int.Parse(mybody.deviceType);
|
||||
if (deviceName) deviceName.text = mybody.deviceName;
|
||||
|
@ -67,6 +99,13 @@ public class RedactDevice : MonoBehaviour
|
|||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public async Task saveJson()
|
||||
{
|
||||
if (string.IsNullOrEmpty(mybody.id)) return;
|
||||
|
||||
if (type) mybody.type = type.value.ToString();
|
||||
if (deviceType) mybody.deviceType = deviceType.value == 0 ? null : deviceType.value.ToString();
|
||||
if (deviceName) mybody.deviceName = deviceName.text;
|
||||
|
@ -77,11 +116,7 @@ public class RedactDevice : MonoBehaviour
|
|||
if (rackType) mybody.rackType = rackType.value == 0 ? null : rackType.value.ToString();
|
||||
if (openFlag) mybody.openFlag = openFlag.value == 2 ? null : openFlag.value.ToString();
|
||||
if (manufacturer) mybody.manufacturer = manufacturer.text;
|
||||
}
|
||||
|
||||
public async Task saveJson()
|
||||
{
|
||||
if (string.IsNullOrEmpty(mybody.id)) return;
|
||||
string json = JsonConvert.SerializeObject(mybody);
|
||||
//Debug.Log(json);
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using AutoMapper;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -15,6 +16,7 @@ public class RedactPort : MonoBehaviour
|
|||
public Root URlreturn;
|
||||
//public PortQuery.Root root;
|
||||
public Button save_bt;
|
||||
PortQuery.PortList portlist;
|
||||
|
||||
/// <summary>
|
||||
/// 端口
|
||||
|
@ -54,35 +56,59 @@ public class RedactPort : MonoBehaviour
|
|||
/// </summary>
|
||||
public Dropdown conPort;
|
||||
|
||||
|
||||
MapperConfiguration config;
|
||||
IMapper mapper;
|
||||
private void OnEnable()
|
||||
{
|
||||
if (gameObject.activeSelf)
|
||||
config = new MapperConfiguration(cfg =>
|
||||
{
|
||||
#region 正式
|
||||
initAsync();
|
||||
port.text = mybody.port;
|
||||
portCode.text = mybody.portCode;
|
||||
remark.text = mybody.remark;
|
||||
//deviceId.text = mybody.deviceId;
|
||||
portModel.text = mybody.portModel;
|
||||
status.value = mybody.status;
|
||||
if (!string.IsNullOrEmpty(mybody.conDevice))
|
||||
cfg.CreateMap<RedactPort.Body, PortQuery.PortList>();
|
||||
cfg.CreateMap<PortQuery.PortList, RedactPort.Body>();
|
||||
});
|
||||
mapper = config.CreateMapper();
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(GameManager.Inst.nowDeviceID))
|
||||
{
|
||||
//自动识别对联设备
|
||||
for (int i = 0; i < conDevice.options.Count; i++)
|
||||
for (int i = 0; i < GameManager.Inst.TmsPorts.Count; i++)
|
||||
{
|
||||
if (conDevice.options[i].text == mybody.conDevice)
|
||||
if (GameManager.Inst.TmsPorts[i].id == GameManager.Inst.nowDeviceID)
|
||||
{
|
||||
conDevice.value = 0;
|
||||
conDevice.value = i;
|
||||
portlist = GameManager.Inst.TmsPorts[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mybody = mapper.Map<RedactPort.Body>(portlist);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region 正式
|
||||
initAsync();
|
||||
port.text = mybody.port;
|
||||
portCode.text = mybody.portCode;
|
||||
remark.text = mybody.remark;
|
||||
//deviceId.text = mybody.deviceId;
|
||||
portModel.text = mybody.portModel;
|
||||
status.value = mybody.status;
|
||||
if (!string.IsNullOrEmpty(mybody.conDevice))
|
||||
{
|
||||
//自动识别对联设备
|
||||
for (int i = 0; i < conDevice.options.Count; i++)
|
||||
{
|
||||
if (conDevice.options[i].text == mybody.conDevice)
|
||||
{
|
||||
conDevice.value = 0;
|
||||
conDevice.value = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -191,15 +217,7 @@ public class RedactPort : MonoBehaviour
|
|||
|
||||
private void Update()
|
||||
{
|
||||
mybody.port = port.text;
|
||||
mybody.portCode = portCode.text;
|
||||
mybody.portName = portName.text;
|
||||
if (conDevice.value != 0 && conPort.value != 0) mybody.remark = remark.text;
|
||||
//mybody.deviceId = deviceId.text;
|
||||
mybody.portModel = portModel.text;
|
||||
mybody.status = status.value;
|
||||
mybody.conDevice = conDevice.options[conDevice.value].text;
|
||||
mybody.conPort = conPort.options[conPort.value].text;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -209,6 +227,17 @@ public class RedactPort : MonoBehaviour
|
|||
public async Task saveJson()
|
||||
{
|
||||
if (string.IsNullOrEmpty(mybody.id)) return;
|
||||
|
||||
mybody.port = port.text;
|
||||
mybody.portCode = portCode.text;
|
||||
mybody.portName = portName.text;
|
||||
if (conDevice.value != 0 && conPort.value != 0) mybody.remark = remark.text;
|
||||
//mybody.deviceId = deviceId.text;
|
||||
mybody.portModel = portModel.text;
|
||||
mybody.status = status.value;
|
||||
mybody.conDevice = conDevice.options[conDevice.value].text;
|
||||
mybody.conPort = conPort.options[conPort.value].text;
|
||||
|
||||
string json = JsonConvert.SerializeObject(mybody);
|
||||
Debug.Log(json);
|
||||
|
||||
|
|
Loading…
Reference in New Issue