//选择时间下载分拣数据 public bool GetSortingOrderDate(string startDate, string endDate,string sortingLine,string batch, out string errorInfo) { bool tag = false; errorInfo = string.Empty; using (PersistentManager dbpm = new PersistentManager()) { DownSortingInfoDao dao = new DownSortingInfoDao(); try { string sort = string.Empty; if (sortingLine != string.Empty || sortingLine != null) { sort = " AND SORTINGLINECODE='" + sortingLine + "' AND BATCHID='" + batch + "'"; } //查询仓库7天内的订单号 DataTable orderdt = this.GetOrderId(startDate, endDate); string orderlist = UtinString.MakeString(orderdt, "order_id"); string orderlistDate = "ORDERDATE >='" + startDate + "' AND ORDERDATE <='" + endDate + "'" + sort; DataTable masterdt = this.GetSortingOrder(orderlistDate); DataRow[] masterdr = masterdt.Select("ORDERID NOT IN(" + orderlist + ")"); string ordermasterlist = UtinString.MakeString(masterdr, "OrderID"); ordermasterlist = "OrderID IN (" + ordermasterlist + ")"; DataTable detaildt = this.GetSortingOrderDetail(ordermasterlist); if (masterdr.Count() > 0 && detaildt.Rows.Count > 0) { DataSet masterds = this.SaveSortingOrder(masterdr); DataSet detailds = this.SaveSortingOrderDetail(detaildt); this.Insert(masterds, detailds); //上报分拣订单 //upload.uploadSort(masterds, detailds); if (sort != string.Empty) { try { DataTable diapLine = this.GetDispatchLine(ordermasterlist); DataSet dispDs = this.SaveDispatch(diapLine, sortingLine); this.Insert(dispDs); tag = true; } catch (Exception e) { errorInfo = "调度出错,请手动进行线路调度,出错原因:" + e.Message; } } else errorInfo = "没有选择分拣线!下载完成后,请手动进行线路调度!"; //tag = true; } else errorInfo = "没有可用的数据下载!"; } catch (Exception e) { errorInfo = "下载错误:" + e.Message; } } return tag; }
//下载分拣主表订单 public DataTable GetSortingOrder(string parameter) { using (PersistentManager dbpm = new PersistentManager()) { DownSortingInfoDao dao = new DownSortingInfoDao(); return dao.GetSortingOrder(parameter); } }
//查询数仓3天内分拣订单 public DataTable GetOrderId(string startDate, string endDate) { using (PersistentManager dbpm = new PersistentManager()) { DownSortingInfoDao dao = new DownSortingInfoDao(); return dao.GetOrderId(startDate, endDate); } }
//保存线路调度结果 public void Insert(DataSet dispatchDs) { using (PersistentManager pm = new PersistentManager()) { DownSortingInfoDao dao = new DownSortingInfoDao(); if (dispatchDs.Tables["WMS_SORT_ORDER_DISPATCH"].Rows.Count > 0) { dao.InsertDispatch(dispatchDs); } } }
//保存到数据库 public void Insert(DataSet masterds, DataSet detailds) { using (PersistentManager pm = new PersistentManager()) { DownSortingInfoDao dao = new DownSortingInfoDao(); if (masterds.Tables["WMS_SORT_ORDER"].Rows.Count > 0) { dao.InsertSortingOrder(masterds); } if (detailds.Tables["WMS_SORT_ORDER_DETAIL"].Rows.Count > 0) { dao.InsertSortingOrderDetail(detailds); } } }