Exemplo n.º 1
0
 /// <summary>
 /// 更新仓库信息
 /// </summary>
 /// <param name="obj"></param>
 protected void Update(TB_Warehouse obj)
 {
     WarehouseInstance.Update(f => f.id == obj.id, act =>
     {
         act.Code    = obj.Code;
         act.Address = obj.Address;
         act.Name    = obj.Name;
     });
 }
Exemplo n.º 2
0
 public static Solver GetSolver(SolverType type, WarehouseInstance instance)
 {
     return(type switch
     {
         SolverType.CBS => new CBS(instance),
         SolverType.PrioritizedPlanner => new PrioritizedPlanner(instance),
         SolverType.PrioritizedPlannerClassesL => new PrioritizedPlanner(instance, PrioritizedPlanner.Heuristic.ClassesLow),
         SolverType.PrioritizedPlannerClassesH => new PrioritizedPlanner(instance, PrioritizedPlanner.Heuristic.ClassesHigh),
         SolverType.Heuristic => null,
         _ => throw new NotImplementedException("Solver not implemented."),
     });
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Exemplo n.º 4
0
        public static void RunTests(List <TestScenario> tests, int iterations)
        {
            StringBuilder     sb        = new StringBuilder();
            TextWriter        writer    = Console.Out;
            Stopwatch         stopwatch = new Stopwatch();
            List <TestResult> results   = new List <TestResult>();

            sb.Append("TestScenarioID,Iteration,ElapsedTime,SoC,Makespan\n");

            for (int testIdx = 0; testIdx < tests.Count; testIdx++)
            {
                var        test   = tests[testIdx];
                TestResult result = new TestResult();
                result.AddScenario(test);

                for (int i = 0; i < iterations; i++)
                {
                    WarehouseInstance instance = InstanceGenerator.GenerateInstance(test.description, 42 + i);
                    // TODO: Generate new items and orders without the need for whole new instance
                    Solver solver = SolverFactory.GetSolver(test.solver, instance);
                    stopwatch.Restart();

                    stopwatch.Start();
                    var tours = solver.FindTours();
                    stopwatch.Stop();

                    int makespan   = Tour.GetMakespan(tours);
                    int sumOfCosts = Tour.GetSumOfCosts(tours);
                    result.AddMeasurement((stopwatch.ElapsedMilliseconds, sumOfCosts, makespan, tours));
                    sb.Append($"{testIdx},{i},{stopwatch.ElapsedMilliseconds},{sumOfCosts},{makespan}\n");
                }

                result.Evaluate();
                results.Add(result);
            }
            Console.ReadKey();
            StreamWriter sw = new StreamWriter("./output.csv");

            sw.Write(sb.ToString());
            sw.Close();

            /*
             * void LogResults() {
             *  writer.WriteLine($"Time elapsed in {i}-th iteration: {stopwatch.ElapsedMilliseconds}");
             *
             *
             * Console.WriteLine("Agent {0} route has been found in {1}", i, sw.Elapsed);
             *  Console.WriteLine("   Items {0}\n    classes {1}", instance.agents[i].orders[0].vertices.Length, instance.agents[i].orders[0].classes[^1]);
             *  Console.WriteLine("   Constraint: {0}", constraints.Count);
             */
        }
Exemplo n.º 5
0
        private void showEdit()
        {
            var w = WarehouseInstance.Find(f => f.id == ParseInt(Utility.Decrypt(hidID.Value)));

            if (null != w)
            {
                txtAbbreviation.Value = w.Code;
                txtAddress.Value      = w.Address;
                txtName.Value         = w.Name;
            }
            else
            {
                ShowNotification("./warehouse.aspx", "Error: paramenter error, cannot edit the warehouse information.", false);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 新建仓库信息
        /// </summary>
        private void NewWarehouse()
        {
            var w = WarehouseInstance.GetObject();

            BuildWarehouse(w);
            WarehouseInstance.Add(w);

            // 保存历史记录
            SaveHistory(new TB_AccountHistory
            {
                ActionId = ActionInstance.Find(f => f.Name.Equals("AddWarehouse")).id,
                ObjectA  = "[id=" + w.id + "] " + w.Name + ", " + w.Code
            });

            ShowNotification("./warehouse.aspx", "You have added a new warehouse.");
        }
Exemplo n.º 7
0
        protected void btSaveChangeWarehouse_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                var id  = ParseInt(Utility.Decrypt(hidWarehouseEquipmentId.Value));
                var obj = EquipmentInstance.Find(f => f.id == id);
                var tmp = JsonConverter.ToObject <TB_Equipment>(hidWarehouseTo.Value);
                if (obj.TB_EquipmentStatusName.IsItInventory == false)
                {
                    ShowNotification("./equipment_change_warehouse.aspx", "The equipment is not in storage status.", false);
                }
                else if (obj.Warehouse == tmp.Warehouse)
                {
                    ShowNotification("./equipment_change_warehouse.aspx", "The equipment in same warehouse you selected.", false);
                }
                else
                {
                    //var transfer = CodeInstance.Find(f =>
                    //        f.TB_EquipmentStatusName.IsInventory == true && f.Code.Equals("T"));
                    EquipmentInstance.Update(f => f.id == obj.id && f.Deleted == false, act =>
                    {
                        act.Warehouse = tmp.Warehouse;
                        // 状态变为库存转移状态
                        //act.Status = transfer.id;
                    });

                    // 保存转库信息
                    var history = StoreInstance.GetObject();
                    history.Equipment = obj.id;
                    history.Status    = obj.Status;//transfer.id;// 移库状态
                    history.Stocktime = DateTime.Now;
                    // 入库次数
                    history.StoreTimes = obj.StoreTimes;
                    history.Warehouse  = tmp.Warehouse;// 保持目的仓库
                    StoreInstance.Add(history);

                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("Transfer")).id,
                        ObjectA  = EquipmentInstance.GetFullNumber(obj) + ", \"" + obj.TB_Warehouse.Name + "\" to \"" +
                                   WarehouseInstance.Find(f => f.id == tmp.Warehouse).Name + "\""
                    });

                    ShowEquipments();
                }
            }
        }
Exemplo n.º 8
0
        protected ConstraintSolver(WarehouseInstance instance)
        {
            this.instance       = instance;
            this.agents         = instance.AgentCount;
            this.nodesVisitors0 = new List <int> [instance.graph.vertices.Count];
            this.nodesVisitors1 = new List <int> [instance.graph.vertices.Count];
            for (int i = 0; i < nodesVisitors0.Length; i++)
            {
                nodesVisitors0[i] = new List <int>();
                nodesVisitors1[i] = new List <int>();
            }

            GTSPSolver.FindMaxValues(instance.orders, out int maxClasses,
                                     out int maxItems, out int maxOrders, out int maxSolverTime);
            solver  = new GTSPSolver(maxClasses, maxItems, maxSolverTime);
            maxTime = maxSolverTime * maxOrders;
        }
Exemplo n.º 9
0
        /// <summary>
        /// 显示仓库列表
        /// </summary>
        private void ShowWarehouses()
        {
            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);
            var list         = WarehouseInstance.FindPageList <TB_Warehouse>(pageIndex, PageSize, out totalRecords,
                                                                             f => f.Delete == false, "Name");
            var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"5\">No records, you can change condition and try again, or " +
                       " <a href=\"./warehouse.aspx\">Add</a> some new one.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                foreach (var obj in list)
                {
                    cnt++;
                    var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));
                    html += "<tr>" +
                            // 系统默认角色无法删除
                            "<td style=\"width: 40px; text-align: center;\"><input type=\"checkbox\" id=\"cb_" + id + "\" /></td>" +
                            "<td style=\"width: 40px; text-align: center;\">" + cnt + "</td>" +
                            "<td><a href=\"./warehouse.aspx?key=" + id + "\" >" + ("" == obj.Name ? "-" : obj.Name) + "</a></td>" +
                            "<td>" + obj.Code + "</td>" +
                            "<td>" + obj.Address + "</td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./warehouse.aspx", divPagging);
            }
        }
Exemplo n.º 10
0
        private void EditWarehouse()
        {
            var w = WarehouseInstance.Find(f => f.id == ParseInt(Utility.Decrypt(hidID.Value)));

            if (null != w)
            {
                BuildWarehouse(w);
                Update(w);

                // 保存历史记录
                SaveHistory(new TB_AccountHistory
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("EditWarehouse")).id,
                    ObjectA  = "[id=" + w.id + "] " + w.Name + ", " + w.Code
                });

                ShowNotification("./warehouse.aspx", "You changed the warehouse information.");
            }
            else
            {
                ShowNotification("./warehouse.aspx", "Error: paramenter error, cannot edit the role information.", false);
            }
        }
Exemplo n.º 11
0
 public CBS(WarehouseInstance instance) : base(instance)
 {
 }
Exemplo n.º 12
0
        /// <summary>
        /// 保存设备的更改信息
        /// </summary>
        private void SaveChanges()
        {
            var    id = ParseInt(Utility.Decrypt(_key));
            var    equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
            bool   needSave = false;
            string msg = "";
            int    wh = 0, md = 0;

            if (null != equipment)
            {
                msg = EquipmentInstance.GetFullNumber(equipment);
                var tmp = int.Parse(hidWarehouse.Value);
                if (tmp > 0)
                {
                    var oh = WarehouseInstance.Find(f => f.id == equipment.Warehouse);
                    var nh = WarehouseInstance.Find(f => f.id == tmp && f.Delete == false);
                    msg += ", " + oh.Name + " to " + nh.Name;
                    //equipment.Warehouse = tmp;
                    wh       = tmp;
                    needSave = true;
                }
                tmp = int.Parse(selectedModel.Value);
                if (tmp > 0)
                {
                    var om = ModelInstance.Find(f => f.id == equipment.Model);
                    var nm = ModelInstance.Find(f => f.id == tmp && f.Delete == false);
                    msg += ", " + om.Code + " to " + nm.Code;
                    //equipment.Model = tmp;
                    md       = tmp;
                    needSave = true;
                }
                tmp = int.Parse(hidFunctional.Value);
                if (tmp != 0 && tmp != int.Parse(oldFunc.Value))
                {
                    msg += ", " + Utility.GetEquipmentFunctional(equipment.Functional.Value) + " to " + Utility.GetEquipmentFunctional((byte)tmp);
                    equipment.Functional = (byte)tmp;
                    needSave             = true;
                }
                var num = number.Value.Trim();
                if (!string.IsNullOrEmpty(num))
                {
                    if (!num.Equals(equipment.Number))
                    {
                        msg += ", Number: " + equipment.Number + " to " + num;
                        equipment.Number = num;
                        needSave         = true;
                    }
                }
                //tmp = int.Parse(Utility.Decrypt(Utility.UrlDecode(oldTerminal.Value)));
                var         n      = string.IsNullOrEmpty(newTerminal.Value) ? 0 : int.Parse(Utility.Decrypt(Utility.UrlDecode(newTerminal.Value)));
                TB_Terminal newOne = null;
                if (n > 0)
                {
                    msg += ", Terminal: ";
                    // 更新旧终端为未绑定状态
                    if ((int?)null != equipment.Terminal)
                    {
                        var ter = equipment.TB_Terminal.Number;
                        TerminalInstance.Update(f => f.id == equipment.Terminal, act =>
                        {
                            act.HasBound = false;
                        });
                        // 保存旧终端的解绑状态
                        SaveHistory(new TB_AccountHistory()
                        {
                            ActionId = ActionInstance.Find(f => f.Name.Equals("Unbind")).id,
                            ObjectA  = "unbind terminal " + ter + " and equipment " + EquipmentInstance.GetFullNumber(equipment)
                        });
                        msg += ter + "(unbind) to ";
                    }
                    newOne             = TerminalInstance.Find(f => f.id == n);
                    msg               += newOne.Number + "(bind)";
                    equipment.Terminal = n;
                    // 更新新终端的绑定状态
                    TerminalInstance.Update(f => f.id == n, act => { act.HasBound = true; });
                    // 保存新终端的绑定状态
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("Unbind")).id,
                        ObjectA  = "bind terminal " + newOne.Number + " and equipment " + EquipmentInstance.GetFullNumber(equipment)
                    });
                    needSave = true;
                }
                if (needSave)
                {
                    EquipmentInstance.Update(f => f.id == equipment.id && f.Deleted == false, act =>
                    {
                        if (md > 0)
                        {
                            //if (act.Model != equipment.Model)
                            act.Model = md;
                        }
                        if (wh > 0)
                        {
                            //if (act.Warehouse != equipment.Warehouse)
                            act.Warehouse = wh;
                        }
                        if (!act.Number.Equals(equipment.Number))
                        {
                            act.Number = equipment.Number;
                        }
                        if (act.Functional != equipment.Functional)
                        {
                            act.Functional = equipment.Functional;
                        }
                        if (act.Terminal != equipment.Terminal)
                        {
                            act.Terminal    = equipment.Terminal;
                            act.Socket      = newOne.Socket;
                            act.OnlineTime  = newOne.OnlineTime;
                            act.OnlineStyle = newOne.OnlineStyle;
                        }
                    });
                    // 保存更改设备信息的历史
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("EditEquipmentInfo")).id,
                        ObjectA  = msg
                    });
                    ShowNotification("./equipment_setting.aspx?key=" + Utility.UrlEncode(_key), "You have saved the equipment info.", true);
                }
            }
            else
            {
                ShowNotification("./equipment_setting.aspx?key=" + Utility.UrlEncode(_key), "Not found the equipment", false);
            }
        }