Exemple #1
0
        private void CheckExecResult()
        {
            var flag = this.KuCunInfoList != null && KuCunInfoList.Any() && FaHuoTaskItemList != null && this.FaHuoTaskItemList.Any();

            if (flag)
            {
                this.btnExecResult.Enabled = true;
            }
            else
            {
                this.btnExecResult.Enabled = false;
            }

            #region  copy
            if (this.KuCunInfoList == null || !this.KuCunInfoList.Any())
            {
                MessageBox.Show("请上传库存信息");
                return;
            }

            if (this.FaHuoTaskItemList == null || !this.FaHuoTaskItemList.Any())
            {
                MessageBox.Show("请上传发货任务信息");
                return;
            }

            if (int.TryParse(this.txtLine.Text ?? string.Empty, out int minLength))
            {
                if (minLength <= 0)
                {
                    MessageBox.Show("剩余最小长度必须是大于0的正整数");
                    return;
                }
            }
            else
            {
                MessageBox.Show("请输入有效的剩余最小长度");
                return;
            }

            var ticks = DateTime.Now.Ticks;

            var kuCunfilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"库存信息-{ticks}.txt");
            File.WriteAllText(kuCunfilePath, JsonConvert.SerializeObject(KuCunInfoList));

            var faHuoFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"发货任务信息-{ticks}.txt");
            File.WriteAllText(faHuoFilePath, JsonConvert.SerializeObject(FaHuoTaskItemList));

            var condition = InitCondition();
            var result    = CalcResultInfo2.Calc(this.KuCunInfoList, this.FaHuoTaskItemList, condition);
            LineResultDatas = result;
            var data      = LineResultInfoView.MapLineResultInfoView(result);
            var finalData = data.OrderBy(m => m.出库目的地).ThenBy(m => m.电缆型号).ThenBy(m => m.线轮位置).ToList();

            FillDataInfos(finalData, dvgLinesInfo);
            #endregion
        }
Exemple #2
0
        public static void Test()
        {
            //var kuCunContent = File.ReadAllText(@"C:\Users\yifalei\Desktop\新建文件夹\LineManager\LineManager\bin\Debug\库存信息-636623591882140833.txt");
            //var kuCunInfo = JsonConvert.DeserializeObject<List<KuCunInfo>>(kuCunContent);

            //var faHuoContent =File.ReadAllText(@"C:\Users\yifalei\Desktop\新建文件夹\LineManager\LineManager\bin\Debug\发货任务信息-636623591882140833.txt");

            //var faHuoInfo = JsonConvert.DeserializeObject<List<FaHuoTaskItem>>(faHuoContent);
            var condition = new Condition()
            {
                MinLeaveLength     = 100,
                GEqualsLengthCount = 2,
                Length             = 500,
                LessLengthCount    = 3
            };

            //var testData = CalcResultInfo2.Calc(kuCunInfo, faHuoInfo, condition);

            //var dataJson = JsonConvert.SerializeObject(testData);

            //Console.WriteLine();


            //var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"result-{DateTime.Now.Ticks}.xlsx");

            //ExcelHelper.DownLoad(testData, filePath);

            //Console.WriteLine(filePath);

            List <LineResultInfo> testData = null;
            var kuCunInfo = InitKuCunInfos();
            var faHuoInfo = new List <FaHuoTaskItem>()
            {
                new FaHuoTaskItem()
                {
                    CustomerId = "1",
                    Length     = 700,
                    XingHao    = "A"
                }
            };


            //testData = CalcResultInfo2.Calc(kuCunInfo, faHuoInfo, condition);

            kuCunInfo = InitKuCunInfos();

            faHuoInfo = new List <FaHuoTaskItem>()
            {
                new FaHuoTaskItem()
                {
                    CustomerId = "1",
                    Length     = 500,
                    XingHao    = "A"
                }
            };

            //testData = CalcResultInfo2.Calc(kuCunInfo, faHuoInfo, condition);

            kuCunInfo = InitKuCunInfos();
            faHuoInfo = new List <FaHuoTaskItem>()
            {
                new FaHuoTaskItem()
                {
                    CustomerId = "1",
                    Length     = 400,
                    XingHao    = "A"
                }
            };

            //testData = CalcResultInfo2.Calc(kuCunInfo, faHuoInfo, condition);

            kuCunInfo = InitKuCunInfos();
            faHuoInfo = new List <FaHuoTaskItem>()
            {
                new FaHuoTaskItem()
                {
                    CustomerId = "1",
                    Length     = 100,
                    XingHao    = "A"
                }
            };

            //testData = CalcResultInfo2.Calc(kuCunInfo, faHuoInfo, condition);

            kuCunInfo = InitKuCunInfos();
            faHuoInfo = new List <FaHuoTaskItem>()
            {
                new FaHuoTaskItem()
                {
                    CustomerId = "1",
                    Length     = 1400,
                    XingHao    = "A"
                }
            };

            testData = CalcResultInfo2.Calc(kuCunInfo, faHuoInfo, condition);
        }