public static List <LineResultInfoView> MapLineResultInfoView(List <LineResultInfo> list) { var result = new List <LineResultInfoView>(); if (list != null && list.Any()) { list.ForEach(m => { var flag = m.PaiHao.GetValueOrDefault() == 0 || m.LunHao.GetValueOrDefault() == 0; var isWheel = m.LeaveLength.HasValue && m.LeaveLength == 0 ? "是" : m.IsWheel; var lineResult = new LineResultInfoView() { 出库目的地 = m.CustomerId, 电缆型号 = m.XingHao, 生产厂家 = m.Brand, 线轮位置 = flag ? "库存不足" : $"{m.PaiHao}排 {m.LunHao}号", 是否整轮 = isWheel, //m.IsWheel, 出库长度 = m.Length.GetValueOrDefault(), 剩余长度 = m.LeaveLength.GetValueOrDefault() //m.Length.GetValueOrDefault() }; result.Add(lineResult); }); } return(result); }
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 }