84 lines
3.0 KiB
C#
84 lines
3.0 KiB
C#
using Competition.Mysql.Other;
|
|
using LitJson;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
public class WorkPlacePanel : MonoBehaviour
|
|
{
|
|
WorkPlaceItem workPlaceItem;
|
|
public void Init(string custCodes, WorkPlaceItem workPlaceItem)
|
|
{
|
|
this.workPlaceItem = workPlaceItem;
|
|
InitModel(custCodes);
|
|
}
|
|
/// <summary>
|
|
/// 生成企业图标
|
|
/// </summary>
|
|
/// <param name="custCodes"></param>
|
|
private void InitModel(string custCodes)
|
|
{
|
|
//删除所有模型
|
|
GetComponentsInChildren<ModelItem>(true).ToList().ForEach(a =>
|
|
{
|
|
Destroy(a.gameObject);
|
|
});
|
|
|
|
//获取关区下所有企业信息
|
|
//string url = "http://" + FirstPanel.instance.serverIP + ":4000/api/Corporation/GetAllPosition?customCodes=" + custCodes;
|
|
string url = "http://" + FirstPanel.instance.serverIP + ":4000/api/GetModelList?PageIndex=1&PageSize=999999";
|
|
Debug.Log("获取企业模型:" + url);
|
|
StartCoroutine(FirstPanel.instance.CallGet(url, (isok, result) =>
|
|
{
|
|
if (isok)
|
|
{
|
|
//生成企业模型
|
|
JsonData data = JsonMapper.ToObject(result);
|
|
var tmp = data["data"]["list"];
|
|
|
|
List<erprise_model_version> list = new List<erprise_model_version>();
|
|
foreach (JsonData item in tmp)
|
|
{
|
|
erprise_model_version v = JsonMapper.ToObject<erprise_model_version>(item.ToJson());
|
|
list.Add(v);
|
|
}
|
|
|
|
//本关区的
|
|
var showAll = list.FindAll(a => custCodes.Split(',').Contains(a.DistrictCode));
|
|
if (workPlaceItem.workPlaceName == "驻罗源湾办事处")
|
|
{
|
|
|
|
}
|
|
else if (workPlaceItem.workPlaceName == "驻福清办事处")
|
|
{
|
|
//读取福清配置文件
|
|
string json = File.ReadAllText(Application.streamingAssetsPath + "/驻福清办事处.txt");
|
|
List<erprise_model_version> tmpComps = JsonMapper.ToObject<List<erprise_model_version>>(json);
|
|
showAll.AddRange(tmpComps);
|
|
}
|
|
|
|
showAll.ForEach(a =>
|
|
{
|
|
//生成本关区的图标
|
|
if (ModelItem.modelItemPrefb == null)
|
|
{
|
|
ModelItem.modelItemPrefb = Resources.Load<GameObject>("prefeb/modelItem");
|
|
}
|
|
GameObject go = Instantiate<GameObject>(ModelItem.modelItemPrefb, transform);
|
|
go.GetComponent<ModelItem>().Init(a, GetComponent<RectTransform>());
|
|
|
|
Application.ExternalCall("ClickCustom", JsonMapper.ToJson(list));
|
|
Debug.Log("调前端进入关区" + custCodes);
|
|
//Debug.Log(JsonMapper.ToJson(list));
|
|
});
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError(result);
|
|
}
|
|
}));
|
|
}
|
|
}
|