Ejemplo n.º 1
0
        public DataTable GetOrder(string orderDate, int batchNo, int mode, bool isSortAbnormityOrderByOrder)
        {
            using (PersistentManager pm = new PersistentManager())
            {
                OrderScheduleDao            orderDao     = new OrderScheduleDao();
                THOK.AS.Dao.SysParameterDao parameterDao = new SysParameterDao();

                Dictionary <string, string> parameter = parameterDao.FindParameters();
                string handleSortLineCode             = parameter["handleSortLineCode"].ToString();
                string wholePiecesSortLineCode        = parameter["WholePiecesSortLineCode"].ToString();
                string abnormitySortLineCode          = parameter["AbnormitySortLineCode"].ToString();

                switch (mode)
                {
                case 1:    //正常分拣打码
                    return(orderDao.FindOrder(orderDate, batchNo));

                    break;

                case 2:    //手工分拣打码
                    if (handleSortLineCode != string.Empty)
                    {
                        return(orderDao.FindOrderForHandleSort(orderDate, batchNo, handleSortLineCode));
                    }
                    else
                    {
                        return(new DataTable());
                    }
                    break;

                case 3:    //整件分拣打码
                    if (wholePiecesSortLineCode != string.Empty)
                    {
                        return(orderDao.FindOrderForWholePieces(orderDate, batchNo, wholePiecesSortLineCode));
                    }
                    else
                    {
                        return(new DataTable());
                    }
                    break;

                case 4:    //异形分拣打码
                    if (abnormitySortLineCode != string.Empty)
                    {
                        return(orderDao.FindOrderForAbnormity(orderDate, batchNo, abnormitySortLineCode, isSortAbnormityOrderByOrder));
                    }
                    else
                    {
                        return(new DataTable());
                    }
                    break;

                default:
                    return(new DataTable());

                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public DataTable GetLineAll(int pageIndex, int pageSize, string filter)
        {
            DataTable table = null;

            using (PersistentManager pm = new PersistentManager())
            {
                OrderScheduleDao orderDao = new OrderScheduleDao();
                table = orderDao.FindLineAll((pageIndex - 1) * pageSize, pageSize, filter);
            }
            return(table);
        }
Ejemplo n.º 3
0
        public int GetLineCount(string filter)
        {
            int count = 0;

            using (PersistentManager pm = new PersistentManager())
            {
                OrderScheduleDao orderDao = new OrderScheduleDao();
                count = orderDao.FindLineCount(filter);
            }
            return(count);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 清除指定批次数据
        /// </summary>
        /// <param name="orderDate"></param>
        /// <param name="batchNo"></param>
        public void ClearSchedule(string orderDate, int batchNo)
        {
            using (PersistentManager pm = new PersistentManager())
            {
                //AS_BI_BATCH
                BatchDao batchDao = new BatchDao();
                batchDao.UpdateExecuter("0", "0", orderDate, batchNo);
                batchDao.UpdateIsValid(orderDate, batchNo, "0");

                //AS_SC_CHANNELUSED
                ChannelScheduleDao csDao = new ChannelScheduleDao();
                csDao.DeleteSchedule(orderDate, batchNo);

                //AS_SC_LINE
                LineScheduleDao lsDao = new LineScheduleDao();
                lsDao.DeleteSchedule(orderDate, batchNo);

                //AS_SC_PALLETMASTER,AS_SC_ORDER
                OrderScheduleDao osDao = new OrderScheduleDao();
                osDao.DeleteSchedule(orderDate, batchNo);

                //AS_I_ORDERDETAIL,AS_I_ORDERMASTER
                OrderDao orderDao = new OrderDao();
                orderDao.DeleteOrder(orderDate, batchNo);

                //AS_SC_STOCKMIXCHANNEL
                StockChannelDao scDao = new StockChannelDao();
                scDao.DeleteSchedule(orderDate, batchNo);

                //AS_SC_SUPPLY
                SupplyDao supplyDao = new SupplyDao();
                supplyDao.DeleteSchedule(orderDate, batchNo);

                //AS_SC_HANDLESUPPLY
                HandleSupplyDao handleSupplyDao = new HandleSupplyDao();
                handleSupplyDao.DeleteHandleSupply(orderDate, batchNo);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 清除历史数据,并下载数据。
        /// </summary>
        /// <param name="orderDate"></param>
        /// <param name="batchNo"></param>
        public void DownloadData(string orderDate, int batchNo, string dataBase)
        {
            try
            {
                ProcessState.Status     = "PROCESSING";
                ProcessState.TotalCount = 15;
                ProcessState.Step       = 1;

                DateTime dtOrder     = DateTime.Parse(orderDate);
                string   historyDate = dtOrder.AddDays(-7).ToShortDateString();
                using (PersistentManager pm = new PersistentManager())
                {
                    BatchDao batchDao = new BatchDao();
                    using (PersistentManager ssPM = new PersistentManager(dataBase))
                    {
                        SalesSystemDao ssDao = new SalesSystemDao();
                        ssDao.SetPersistentManager(ssPM);
                        try
                        {
                            pm.BeginTransaction();

                            //AS_BI_BATCH
                            batchDao.DeleteHistory(historyDate);
                            ProcessState.CompleteCount = 1;

                            //AS_SC_CHANNELUSED
                            ChannelScheduleDao csDao = new ChannelScheduleDao();
                            csDao.DeleteHistory(historyDate);
                            ProcessState.CompleteCount = 2;

                            //AS_SC_LINE
                            LineScheduleDao lsDao = new LineScheduleDao();
                            lsDao.DeleteHistory(historyDate);
                            ProcessState.CompleteCount = 3;

                            //AS_SC_PALLETMASTER ,AS_SC_ORDER
                            OrderScheduleDao osDao = new OrderScheduleDao();
                            osDao.DeleteHistory(historyDate);
                            ProcessState.CompleteCount = 4;

                            //AS_I_ORDERMASTER,AS_I_ORDERDETAIL,
                            OrderDao orderDao = new OrderDao();
                            orderDao.DeleteHistory(historyDate);
                            ProcessState.CompleteCount = 5;

                            //AS_SC_STOCKMIXCHANNEL
                            StockChannelDao scDao = new StockChannelDao();
                            scDao.DeleteHistory(historyDate);
                            ProcessState.CompleteCount = 6;

                            //AS_SC_SUPPLY
                            SupplyDao supplyDao = new SupplyDao();
                            supplyDao.DeleteHistory(historyDate);
                            ProcessState.CompleteCount = 7;

                            //AS_SC_HANDLESUPPLY
                            HandleSupplyDao handleSupplyDao = new HandleSupplyDao();
                            handleSupplyDao.DeleteHistory(historyDate);
                            ProcessState.CompleteCount = 8;

                            ClearSchedule(orderDate, batchNo);

                            //////////////////////////////////////////////////////////////////////////

                            //下载区域表
                            AreaDao   areaDao   = new AreaDao();
                            DataTable areaTable = ssDao.FindArea();
                            areaDao.SynchronizeArea(areaTable);
                            ProcessState.CompleteCount = 9;

                            //下载配送线路表
                            RouteDao  routeDao   = new RouteDao();
                            DataTable routeTable = ssDao.FindRoute();
                            routeDao.SynchronizeRoute(routeTable);
                            ProcessState.CompleteCount = 10;

                            //下载客户表
                            CustomerDao customerDao   = new CustomerDao();
                            DataTable   customerTable = ssDao.FindCustomer(dtOrder);
                            customerDao.SynchronizeCustomer(customerTable);
                            ProcessState.CompleteCount = 11;

                            //下载卷烟表 进行同步
                            CigaretteDao cigaretteDao   = new CigaretteDao();
                            DataTable    cigaretteTable = ssDao.FindCigarette(dtOrder);
                            cigaretteDao.SynchronizeCigarette(cigaretteTable);
                            ProcessState.CompleteCount = 12;

                            //查询已优化过的线路,以进行排除。
                            string routes = lsDao.FindRoutes(orderDate);

                            //下载订单主表
                            DataTable masterTable = ssDao.FindOrderMaster(dtOrder, batchNo, routes);
                            orderDao.BatchInsertMaster(masterTable);
                            ProcessState.CompleteCount = 13;

                            //下载订单明细
                            DataTable detailTable = ssDao.FindOrderDetail(dtOrder, batchNo, routes);
                            orderDao.BatchInsertDetail(detailTable);
                            ProcessState.CompleteCount = 14;

                            pm.Commit();
                        }
                        catch (Exception e)
                        {
                            pm.Rollback();
                            throw e;
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                ProcessState.Status  = "ERROR";
                ProcessState.Message = ee.Message;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 清除历史数据,并下载数据。
        /// </summary>
        /// <param name="orderDate"></param>
        /// <param name="batchNo"></param>
        public void DownloadData(string orderDate, int batchNo, string dataBase)
        {
            try
            {
                DateTime dtOrder     = DateTime.Parse(orderDate);
                string   historyDate = dtOrder.AddDays(-5).ToShortDateString();
                using (PersistentManager pm = new PersistentManager())
                {
                    BatchDao batchDao = new BatchDao();
                    using (PersistentManager ssPM = new PersistentManager(dataBase))
                    {
                        SalesSystemDao ssDao = new SalesSystemDao();
                        ssDao.SetPersistentManager(ssPM);
                        try
                        {
                            pm.BeginTransaction();

                            //AS_BI_BATCH
                            batchDao.DeleteHistory(historyDate);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 1, 14));
                            }

                            //AS_SC_CHANNELUSED
                            ChannelScheduleDao csDao = new ChannelScheduleDao();
                            csDao.DeleteHistory(historyDate);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 2, 14));
                            }

                            //AS_SC_LINE
                            LineScheduleDao lsDao = new LineScheduleDao();
                            lsDao.DeleteHistory(historyDate);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 3, 14));
                            }

                            //AS_SC_PALLETMASTER ,AS_SC_ORDER
                            OrderScheduleDao osDao = new OrderScheduleDao();
                            osDao.DeleteHistory(historyDate);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 4, 14));
                            }

                            //AS_I_ORDERMASTER,AS_I_ORDERDETAIL,
                            OrderDao orderDao = new OrderDao();
                            orderDao.DeleteHistory(historyDate);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 5, 14));
                            }

                            //AS_SC_STOCKMIXCHANNEL
                            StockChannelDao scDao = new StockChannelDao();
                            scDao.DeleteHistory(historyDate);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 6, 14));
                            }

                            //AS_SC_SUPPLY
                            SupplyDao supplyDao = new SupplyDao();
                            supplyDao.DeleteHistory(historyDate);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 7, 14));
                            }

                            //AS_SC_HANDLESUPPLY
                            HandleSupplyDao handleSupplyDao = new HandleSupplyDao();
                            handleSupplyDao.DeleteHistory(historyDate);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 8, 14));
                            }

                            ClearSchedule(orderDate, batchNo);

                            //////////////////////////////////////////////////////////////////////////

                            //下载区域表
                            AreaDao   areaDao   = new AreaDao();
                            DataTable areaTable = ssDao.FindArea();
                            areaDao.SynchronizeArea(areaTable);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 9, 14));
                            }

                            //下载配送线路表
                            RouteDao  routeDao   = new RouteDao();
                            DataTable routeTable = ssDao.FindRoute();
                            routeDao.SynchronizeRoute(routeTable);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 10, 14));
                            }

                            //下载客户表
                            CustomerDao customerDao   = new CustomerDao();
                            DataTable   customerTable = ssDao.FindCustomer(dtOrder);
                            customerDao.SynchronizeCustomer(customerTable);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 11, 14));
                            }

                            //下载卷烟表 进行同步
                            CigaretteDao cigaretteDao   = new CigaretteDao();
                            DataTable    cigaretteTable = ssDao.FindCigarette(dtOrder);
                            cigaretteDao.SynchronizeCigarette(cigaretteTable);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 12, 14));
                            }

                            //查询已优化过的线路,以进行排除。
                            string routes = lsDao.FindRoutes(orderDate);

                            //下载订单主表
                            DataTable masterTable = ssDao.FindOrderMaster(dtOrder, batchNo, routes);
                            orderDao.BatchInsertMaster(masterTable);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 13, 14));
                            }

                            //下载订单明细
                            DataTable detailTable = ssDao.FindOrderDetail(dtOrder, batchNo, routes);
                            orderDao.BatchInsertDetail(detailTable);
                            if (OnSchedule != null)
                            {
                                OnSchedule(this, new ScheduleEventArgs(1, "数据清除与下载", 14, 14));
                            }

                            pm.Commit();
                        }
                        catch (Exception e)
                        {
                            pm.Rollback();
                            throw e;
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                if (OnSchedule != null)
                {
                    OnSchedule(this, new ScheduleEventArgs(OptimizeStatus.ERROR, ee.Message));
                }
                throw ee;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 订单优化2010-07-07
        /// </summary>
        /// <param name="orderDate"></param>
        /// <param name="batchNo"></param>
        public void GenOrderSchedule(string orderDate, int batchNo)
        {
            using (THOK.Util.PersistentManager pm = new THOK.Util.PersistentManager())
            {
                OrderDao         orderDao         = new OrderDao();
                ChannelDao       channelDao       = new ChannelDao();
                OrderScheduleDao orderScheduleDao = new OrderScheduleDao();
                SupplyDao        supplyDao        = new SupplyDao();
                OrderOptimize    orderSchedule    = new OrderOptimize();

                SysParameterDao             parameterDao = new SysParameterDao();
                Dictionary <string, string> parameter    = parameterDao.FindParameters();

                LineScheduleDao lineDao   = new LineScheduleDao();
                DataTable       lineTable = lineDao.FindAllLine(orderDate, batchNo).Tables[0];

                foreach (DataRow lineRow in lineTable.Rows)
                {
                    string lineCode = lineRow["LINECODE"].ToString();

                    //查询订单主表
                    DataTable masterTable = orderDao.FindTmpMaster(orderDate, batchNo, lineCode);
                    //查询订单明细表
                    DataTable orderTable = orderDao.FindTmpDetail(orderDate, batchNo, lineCode);
                    //查询分拣烟道表
                    DataTable channelTable = channelDao.FindChannelSchedule(orderDate, batchNo, lineCode, Convert.ToInt32(parameter["RemainCount"])).Tables[0];

                    int sortNo       = 1;
                    int currentCount = 0;
                    int totalCount   = masterTable.Rows.Count;

                    foreach (DataRow masterRow in masterTable.Rows)
                    {
                        DataRow[] orderRows = null;

                        //查询当前订单明细
                        orderRows = orderTable.Select(string.Format("SORTNO = '{0}'", masterRow["SORTNO"]), "CHANNELGROUP, CHANNELCODE");
                        DataSet ds = orderSchedule.Optimize(masterRow, orderRows, channelTable, ref sortNo);

                        orderScheduleDao.SaveOrder(ds);
                        supplyDao.InsertSupply(ds.Tables["SUPPLY"], lineCode, orderDate, batchNo);

                        if (OnSchedule != null)
                        {
                            OnSchedule(this, new ScheduleEventArgs(5, "正在优化" + lineRow["LINECODE"].ToString() + "分拣线订单", ++currentCount, totalCount));
                        }
                    }

                    channelDao.Update(channelTable);
                }

                LineInfoDao lineDao1   = new LineInfoDao();
                DataTable   lineTable1 = lineDao1.GetAvailabeLine("3").Tables[0];

                foreach (DataRow lineRow in lineTable1.Rows)
                {
                    string lineCode = lineRow["LINECODE"].ToString();

                    //查询烟道信息表
                    DataTable channelTable = channelDao.FindChannelSchedule(orderDate, batchNo, lineCode, Convert.ToInt32(parameter["RemainCount"])).Tables[0];
                    //查询订单主表
                    DataTable masterTable = orderDao.FindOrderMaster(orderDate, batchNo, lineCode).Tables[0];
                    //查询订单明细表
                    DataTable orderTable = orderDao.FindOrderDetail(orderDate, batchNo, lineCode).Tables[0];

                    int sortNo       = 1;
                    int currentCount = 0;
                    int totalCount   = masterTable.Rows.Count;

                    foreach (DataRow masterRow in masterTable.Rows)
                    {
                        DataRow[] orderRows = null;
                        //查询当前订单明细
                        orderRows = orderTable.Select(string.Format("ORDERID = '{0}'", masterRow["ORDERID"]), "CIGARETTECODE");
                        DataSet ds = orderSchedule.OptimizeUseWholePiecesSortLine(masterRow, orderRows, channelTable, ref sortNo);
                        orderScheduleDao.SaveOrder(ds);

                        if (OnSchedule != null)
                        {
                            OnSchedule(this, new ScheduleEventArgs(5, "正在优化" + lineRow["LINECODE"].ToString() + "分拣线订单", ++currentCount, totalCount));
                        }
                    }

                    channelDao.UpdateQuantity(channelTable, false);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 订单拆分2010-07-05
        /// </summary>
        /// <param name="orderDate"></param>
        /// <param name="batchNo"></param>
        public void GenSplitOrder(string orderDate, int batchNo)
        {
            using (THOK.Util.PersistentManager pm = new THOK.Util.PersistentManager())
            {
                OrderDao         orderDao         = new OrderDao();
                ChannelDao       channelDao       = new ChannelDao();
                OrderScheduleDao orderScheduleDao = new OrderScheduleDao();
                LineScheduleDao  lineDao          = new LineScheduleDao();

                OrderSplitOptimize orderSchedule = new OrderSplitOptimize();

                THOK.AS.Dao.SysParameterDao parameterDao = new SysParameterDao();
                Dictionary <string, string> parameter    = parameterDao.FindParameters();

                //查询分拣线表
                DataTable lineTable = lineDao.FindAllLine(orderDate, batchNo).Tables[0];

                //清理临时表
                orderScheduleDao.ClearSplitOrder();

                LineInfoDao lineDao1   = new LineInfoDao();
                DataTable   lineTable1 = lineDao1.GetAvailabeLine("3").Tables[0];
                bool        isUseWholePiecesSortLine = lineTable1.Rows.Count > 0;

                foreach (DataRow lineRow in lineTable.Rows)
                {
                    string lineCode = lineRow["LINECODE"].ToString();

                    //查询烟道信息表
                    DataTable channelTable = channelDao.FindChannelSchedule(orderDate, batchNo, lineCode, Convert.ToInt32(parameter["RemainCount"])).Tables[0];
                    //查询订单主表
                    DataTable masterTable = orderDao.FindOrderMaster(orderDate, batchNo, lineCode).Tables[0];
                    //查询订单明细表
                    DataTable orderTable = orderDao.FindOrderDetail(orderDate, batchNo, lineCode).Tables[0];

                    DataTable       orderDetail     = null;
                    HashTableHandle hashTableHandle = new HashTableHandle(orderTable);

                    int sortNo       = 1;
                    int currentCount = 0;
                    int totalCount   = masterTable.Rows.Count;
                    orderSchedule.moveToMixChannelProducts.Clear();
                    orderSchedule.moveToMixTChannelProducts.Clear();

                    foreach (DataRow masterRow in masterTable.Rows)
                    {
                        DataRow[] orderRows = null;

                        orderDetail = hashTableHandle.Select("ORDERID", masterRow["ORDERID"]);
                        orderRows   = orderDetail.Select(string.Format("ORDERID = '{0}'", masterRow["ORDERID"]), "QUANTITY");

                        DataSet ds = orderSchedule.Optimize(masterRow, orderRows, channelTable, lineCode, ref sortNo, parameter, isUseWholePiecesSortLine);
                        orderScheduleDao.SaveSplitOrder(ds);

                        if (OnSchedule != null)
                        {
                            OnSchedule(this, new ScheduleEventArgs(4, "正在优化" + lineRow["LINECODE"].ToString() + "分拣线订单", ++currentCount, totalCount));
                        }
                    }

                    channelDao.UpdateQuantity(channelTable, Convert.ToBoolean(parameter["IsUseBalance"]));
                }
            }
        }