/// <summary> /// 生成装车任务 /// </summary> private void btnCreateTask_Click(object sender, EventArgs e) { try { object obj = null; if ((obj = this.InvokeScript(M_SUB_BILL)) == null) { MsgBox.Warn("未找到已排序订单!"); return; } List <SortMapReceiveDataEntity> list = JsonConvert.DeserializeObject <List <SortMapReceiveDataEntity> >(obj.ToString()); if (list == null || list.Count == 0) { MsgBox.Warn("未找到已排序订单"); return; } if (list.Count == this._list.Count || MsgBox.AskOK("还有未排序的订单,是否继续提交?") == DialogResult.OK) { string billIDs = string.Empty; List <OrderSortEntity> sortList = new List <OrderSortEntity>(); foreach (SortMapReceiveDataEntity data in list) { SOHeaderEntity header = this._list.Find(new Predicate <SOHeaderEntity>( (item) => { return(item.BillNO == data.orderId); })); if (header == null) { continue; } sortList.Add(new OrderSortEntity() { VehicleNo = ConvertUtil.ToString(this._vehicle.ID), BillNo = data.orderId, InVehicleSort = ConvertUtil.ToInt(data.paixu), PiecesQty = data.boxNum, Attri1 = 10 }); } // 存储排序记录 OrderSortDal.Insert(sortList); string selectedBillIDs = StringUtil.JoinBySign <SOHeaderEntity>(this._list, "BillID"); string errMsg = TaskDal.CreateLoadingTask(selectedBillIDs, ConvertUtil.ToString(this._vehicle.ID)); if (!string.IsNullOrEmpty(errMsg)) { throw new Exception(errMsg); } this.DialogResult = DialogResult.OK; } } catch (Exception ex) { MsgBox.Err("错误:" + ex.Message); } }