Beispiel #1
0
    /// <summary>
    /// 创建操作票历史路径
    /// </summary>
    public void CreateOperationTicketHistoryPath(OperationTicket operationTicketT)
    {
        GetPersonnels();
        Personnel personnel = personnels.Find((item) => item.Id == operationTicketT.OperatorPersonelId);

        if (personnel != null)
        {
            DateTime   start       = new DateTime(2018, 9, 30, 10, 0, 0);
            DateTime   end         = new DateTime(2018, 9, 30, 11, 0, 0);
            List <int> topoNodeIds = RoomFactory.Instance.GetCurrentDepNodeChildNodeIds(SceneEvents.DepNode);
            //List<Position> ps = new List<Position>();
            //List<Vector3> list = new List<Vector3>();
            //List<DateTime> timelist = new List<DateTime>();

            Loom.StartSingleThread(() =>
            {
                var ps          = GetHistoryData(personnel.Id, topoNodeIds, start, end);
                var posInfoList = new PositionInfoList();
                Loom.DispatchToMainThread(() =>
                {
                    Debug.LogError("点数:" + ps.Count);
                    if (ps.Count < 2)
                    {
                        return;
                    }

                    for (int i = 0; i < ps.Count; i++)
                    {
                        var posInfo = new PositionInfo(ps[i], start);
                        posInfoList.Add(posInfo);
                    }

                    PathInfo pathInfo   = new PathInfo();
                    pathInfo.personnelT = personnel;
                    pathInfo.color      = Color.green;
                    pathInfo.posList    = posInfoList;
                    //pathInfo.timeLength = timeLength;

                    GameObject o = new GameObject(operationTicketT.Operator + "工作票");
                    OperationTicketHistoryPath path = o.AddComponent <OperationTicketHistoryPath>();
                    path.Init(pathInfo, false);
                    operationTicketHistoryPaths.Add(path);
                });
            });
        }
    }
    Position firstPoint = null;//第一个点的位置 自动移动进度条到该点

    /// <summary>
    /// 显示某个标签的历史数据
    /// </summary>
    /// <param name="code"></param>
    public void ShowHistoryData()
    {
        if (isLoadDataSuccessed)
        {
            return;
        }
        //LocationManager.Instance.ClearHistoryPaths();
        //string code = "0002";

        List <HistoryPersonUIItem> historyPersonUIItems = personsGrid.GetComponentsInChildren <HistoryPersonUIItem>().ToList();

        DateTime end   = GetEndTime();
        DateTime start = GetStartTime();
        List <List <Position> > psList = new List <List <Position> >();

        personnel_Points = new Dictionary <Personnel, List <Position> >();
        //List<Position> ps = new List<Position>();
        List <LocationHistoryPath_M> paths = new List <LocationHistoryPath_M>();

        progressbarLoadValue = 0;

        List <int> topoNodeIds = RoomFactory.Instance.GetCurrentDepNodeChildNodeIds(SceneEvents.DepNode);

        Loom.StartSingleThread(() =>
        {
            firstPoint = null;
            foreach (Personnel p in currentPersonnels)
            {
                List <Position> ps = GetHistoryData(p.Id, topoNodeIds, start, end, 1440f);
                psList.Add(ps);
                if (personnel_Points.ContainsKey(p))
                {
                    personnel_Points[p] = ps;
                }
                else
                {
                    personnel_Points.Add(p, ps);
                }
                if (ps != null && ps.Count > 0)
                {
                    Position fps = ps[0];
                    if (firstPoint == null)
                    {
                        firstPoint = fps;
                    }
                    else
                    {
                        if (fps.Time < firstPoint.Time)
                        {
                            firstPoint = fps;
                        }
                    }
                }
            }
            Debug.Log("StartSingleThread1");
            Loom.DispatchToMainThread(() =>
            {
                ProgressbarLoad.Instance.Show(1);
                ProgressbarLoad.Instance.Hide();
                int k = 0;
                foreach (Personnel p in personnel_Points.Keys)
                {
                    List <Position> ps = personnel_Points[p];
                    Debug.LogError("点数:" + ps.Count);
                    if (ps.Count < 2)
                    {
                        continue;
                    }
                    var posInfoList = new PositionInfoList();
                    for (int i = 0; i < ps.Count; i++)
                    {
                        var posInfo = new PositionInfo(ps[i], start);
                        posInfoList.Add(posInfo);
                    }

                    Color colorT             = colors[k % colors.Count];
                    HistoryPersonUIItem item = historyPersonUIItems.Find((i) => i.personnel.Id == p.Id);
                    if (item != null)
                    {
                        colorT = item.color;
                    }

                    PathInfo pathInfo   = new PathInfo();
                    pathInfo.personnelT = p;
                    pathInfo.color      = colorT;
                    pathInfo.posList    = posInfoList;
                    pathInfo.timeLength = timeLength;

                    LocationHistoryPath_M histoyObj = LocationHistoryManager.Instance.ShowLocationHistoryPath_M(pathInfo);
                    //histoyObj.InitData(timeLength, timelist);
                    HistoryManController historyManController = histoyObj.gameObject.AddComponent <HistoryManController>();
                    histoyObj.historyManController            = historyManController;
                    historyManController.Init(colorT, histoyObj);
                    PersonAnimationController personAnimationController = histoyObj.gameObject.GetComponent <PersonAnimationController>();
                    personAnimationController.DoMove();
                    Debug.Log("StartSingleThread2");
                    k++;
                }
            });

            //Debug.Log("StartSingleThread3");
            Loom.DispatchToMainThread(() =>
            {
                isLoadDataSuccessed = true;
                //timeStart = Time.time;
                timeSum = 0;
                Debug.Log("StartSingleThread3");
                if (firstPoint != null)
                {
                    DateTime t = LocationManager.GetTimestampToDateTime(firstPoint.Time);
                    Debug.Log(firstPoint.Time);
                    timeSum = t.Hour * 3600 + t.Minute * 60 + t.Second - slider.ValueMin * 3600;
                    Debug.Log(timeSum);
                }
            });
        });
    }
Beispiel #3
0
    /// <summary>
    /// 显示某个标签的历史数据
    /// </summary>
    /// <param name="code"></param>
    public void ShowHistoryData()
    {
        if (isLoadDataSuccessed)
        {
            return;
        }
        //LocationManager.Instance.ClearHistoryPaths();
        //string code = "0002";
        List <Vector3>  list        = new List <Vector3>();
        List <DateTime> timelist    = new List <DateTime>();
        var             posInfoList = new PositionInfoList();
        DateTime        end         = GetEndTime();
        DateTime        start       = GetStartTime();

        //List<Position> positions = new List<Position>();
        positions = new List <Position>();

        List <int> topoNodeIds = RoomFactory.Instance.GetCurrentDepNodeChildNodeIds(SceneEvents.DepNode);


        Loom.StartSingleThread(() =>
        {
            //ps = CommunicationObject.Instance.GetHistoryPositonsByTime(code, start, end);
            positions = GetHistoryData(personnel.Id, topoNodeIds, start, end);

            Loom.DispatchToMainThread(() =>
            {
                Debug.LogError("点数:" + positions.Count);
                if (positions.Count < 2)
                {
                    return;
                }

                for (int i = 0; i < positions.Count; i++)
                {
                    var p = new PositionInfo(positions[i], start);
                    posInfoList.Add(p);
                }

                PathInfo pathInfo   = new PathInfo();
                pathInfo.personnelT = personnel;
                pathInfo.color      = Color.green;
                pathInfo.posList    = posInfoList;
                pathInfo.timeLength = timeLength;

                LocationHistoryPath histoyObj             = LocationHistoryManager.Instance.ShowLocationHistoryPath(pathInfo, "HistoryPath0002");
                HistoryManController historyManController = histoyObj.gameObject.AddComponent <HistoryManController>();
                histoyObj.historyManController            = historyManController;
                historyManController.Init(Color.green, histoyObj);
                PersonAnimationController personAnimationController = histoyObj.gameObject.GetComponent <PersonAnimationController>();
                personAnimationController.DoMove();

                PathFindingManager.Instance.StartNavAgent(historyManController);

                isLoadDataSuccessed = true;
                timeStart           = Time.time;
                timeSum             = 0;
                //histoyObj.InitData(timeLength, timelist);
            });
        });
    }