private void timer1_Tick(object sender, EventArgs e)
        {
            using (PersistentManager pm = new PersistentManager())
            {
                SupplyDao  supplyDao  = new SupplyDao();
                StockInDao stockInDao = new StockInDao();

                DataTable cigaretteTable = supplyDao.FindCigarette();
                DataTable stockInTable   = stockInDao.FindStockInForIsInAndNotOut();

                foreach (DataRow row in cigaretteTable.Rows)
                {
                    DataRow[] stockInRows = stockInTable.Select(string.Format("CIGARETTECODE='{0}' AND STATE ='1' AND ( STOCKOUTID IS NULL OR STOCKOUTID = 0 )", row["CIGARETTECODE"].ToString()), "STOCKINID");

                    if (stockInRows.Length <= Convert.ToInt32(Context.Attributes["StockInRequestRemainQuantity"]))
                    {
                        Context.ProcessDispatcher.WriteToProcess("StockInRequestProcess", "StockInRequest", row["CIGARETTECODE"].ToString());
                    }
                    else if (stockInRows.Length > 0 && stockInRows.Length + Convert.ToInt32(stockInRows[0]["STOCKINQUANTITY"]) <= 30)
                    {
                        Context.ProcessDispatcher.WriteToProcess("StockInRequestProcess", "StockInRequest", row["CIGARETTECODE"].ToString());
                    }
                }
            }
        }
示例#2
0
        private void AddFirstBatch()
        {
            using (PersistentManager pm = new PersistentManager())
            {
                SupplyDao  supplyDao  = new SupplyDao();
                ChannelDao channelDao = new ChannelDao();

                DataTable cigaretteTable = supplyDao.FindCigarette();
                if (cigaretteTable.Rows.Count != 0)
                {
                    foreach (DataRow row in cigaretteTable.Rows)
                    {
                        DataTable channelTable        = channelDao.FindChannelForCigaretteCode(row["CigaretteCode"].ToString());
                        int       stockRemainQuantity = Convert.ToInt32(channelTable.Rows[0]["REMAINQUANTITY"]);

                        if (Convert.ToInt32(row["Quantity"]) + stockRemainQuantity >= Convert.ToInt32(Context.Attributes["StockInCapacityQuantity"]))
                        {
                            StockInRequest(row["CigaretteCode"].ToString(), Convert.ToInt32(Context.Attributes["StockInCapacityQuantity"]), stockRemainQuantity);
                        }
                        else if (Convert.ToInt32(row["Quantity"]) + stockRemainQuantity > 0)
                        {
                            StockInRequest(row["CigaretteCode"].ToString(), Convert.ToInt32(row["Quantity"]) + stockRemainQuantity, stockRemainQuantity);
                        }
                    }
                    Logger.Info("生产第一批次入库任务成功");
                    WriteToProcess("LEDProcess", "Refresh", null);
                }
            }
        }
示例#3
0
        protected override void StateChanged(StateItem stateItem, IProcessDispatcher dispatcher)
        {
            try
            {
                string lineCode     = stateItem.ItemName.Split("_"[0])[0];
                string channelGroup = stateItem.ItemName.Split("_"[0])[1];
                object obj          = ObjectUtil.GetObject(stateItem.State);
                int    sortNo       = obj != null?Convert.ToInt32(obj) : 0;

                using (PersistentManager pm = new PersistentManager())
                {
                    SupplyDao supplyDao = new SupplyDao();
                    int       sortNo1   = supplyDao.FindSortNoForSupply(lineCode, sortNo.ToString(), channelGroup, Convert.ToInt32(Context.Attributes["SupplyAheadCount-" + lineCode + "-" + channelGroup]));
                    sortNo = sortNo > sortNo1 ? sortNo : sortNo1;
                }

                Dictionary <string, string> parameter = new Dictionary <string, string>();
                parameter.Add("OrderDate", "");
                parameter.Add("BatchNo", "");
                parameter.Add("LineCode", lineCode);
                parameter.Add("ChannelGroup", channelGroup);
                parameter.Add("SortNo", sortNo.ToString());

                WriteToProcess("SupplyRequestProcess", "SupplyRequest", parameter);
            }
            catch (Exception e)
            {
                Logger.Error(e.Message);
            }
        }
示例#4
0
        private void StockInRequest(string cigaretteCode)
        {
            using (PersistentManager pm = new PersistentManager())
            {
                StockInBatchDao stockInBatchDao = new StockInBatchDao();
                SupplyDao       supplyDao       = new SupplyDao();
                ChannelDao      channelDao      = new ChannelDao();

                DataTable stockInBatchTable = stockInBatchDao.FindStockInBatch(cigaretteCode);

                DataTable channelTable        = channelDao.FindChannelForCigaretteCode(cigaretteCode);
                int       stockRemainQuantity = Convert.ToInt32(channelTable.Rows[0]["REMAINQUANTITY"]);

                DataTable cigaretteTable = supplyDao.FindCigarette(cigaretteCode, stockRemainQuantity.ToString());

                if (stockInBatchTable.Rows.Count == 0 && cigaretteTable.Rows.Count != 0)
                {
                    DataRow row = cigaretteTable.Rows[0];

                    if (Convert.ToInt32(row["Quantity"]) >= Convert.ToInt32(Context.Attributes["StockInCapacityQuantity"]))
                    {
                        StockInRequest(row["CigaretteCode"].ToString(), Convert.ToInt32(Context.Attributes["StockInCapacityQuantity"]), 0);
                        Logger.Info(row["CigaretteName"].ToString() + "生成入库任务成功");
                    }
                    else if (Convert.ToInt32(row["Quantity"]) > 0)
                    {
                        StockInRequest(row["CigaretteCode"].ToString(), Convert.ToInt32(row["Quantity"]), 0);
                        Logger.Info(row["CigaretteName"].ToString() + "生成入库任务成功");
                    }

                    WriteToProcess("LEDProcess", "Refresh", null);
                }
            }
        }
示例#5
0
        public ProductDetailsForm(ProductDao productDao, SupplyDao supplyDao)
        {
            InitializeComponent();

            _supplyDao  = supplyDao;
            _productDao = productDao;

            InitializeData();
        }
示例#6
0
        public ProductDetailsForm(ProductDao productDao, SupplyDao supplyDao, ProductVM product)
        {
            InitializeComponent();

            _supplyDao  = supplyDao;
            _productDao = productDao;

            _product = product;

            LoadData();
        }
        private bool AddNextSupply(string lineCode, string channelGroup, string channelType, int sortNo)
        {
            bool result = false;

            try
            {
                using (PersistentManager pm = new PersistentManager())
                {
                    StockOutBatchDao batchDao  = new StockOutBatchDao();
                    SupplyDao        supplyDao = new SupplyDao();
                    StockOutDao      outDao    = new StockOutDao();
                    batchDao.SetPersistentManager(pm);
                    supplyDao.SetPersistentManager(pm);
                    outDao.SetPersistentManager(pm);

                    DataTable supplyTable = supplyDao.FindNextSupply(lineCode, channelGroup, channelType, sortNo);

                    if (supplyTable.Rows.Count != 0)
                    {
                        Logger.Info(string.Format("收到补货请求,分拣线 '{0}',烟道组 '{1}',烟道类型 '{2}',流水号 '{3}'", lineCode, channelGroup, channelType, sortNo));
                        try
                        {
                            pm.BeginTransaction();

                            int batchNo = batchDao.FindMaxBatchNo() + 1;
                            batchDao.InsertBatch(batchNo, lineCode, channelGroup, channelType, sortNo, supplyTable.Rows.Count);

                            int outID = outDao.FindMaxOutID();
                            outDao.Insert(outID, supplyTable);

                            pm.Commit();
                            result = true;

                            Logger.Info("生成出库任务成功");
                        }
                        catch (Exception e)
                        {
                            Logger.Error("生成出库任务失败,原因:" + e.Message);
                            pm.Rollback();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error("生成出库任务失败,原因:" + e.Message);
            }

            return(result);
        }
示例#8
0
        private bool AddFirstSupply()
        {
            bool result = false;

            try
            {
                using (PersistentManager pm = new PersistentManager())
                {
                    StockOutBatchDao batchDao  = new StockOutBatchDao();
                    SupplyDao        supplyDao = new SupplyDao();
                    StockOutDao      outDao    = new StockOutDao();
                    batchDao.SetPersistentManager(pm);
                    supplyDao.SetPersistentManager(pm);
                    outDao.SetPersistentManager(pm);

                    DataTable supplyTable = supplyDao.FindFirstSupply();

                    if (supplyTable.Rows.Count != 0)
                    {
                        try
                        {
                            pm.BeginTransaction();

                            int batchNo = batchDao.FindMaxBatchNo() + 1;
                            batchDao.InsertBatch(batchNo, "00", "0", "0", 0, supplyTable.Rows.Count);

                            int outID = outDao.FindMaxOutID();
                            outDao.Insert(outID, supplyTable);

                            pm.Commit();
                            result = true;

                            Logger.Info("生产第一批次出库任务成功");
                        }
                        catch (Exception e)
                        {
                            Logger.Error("生成第一批次出库任务失败,原因:" + e.Message);
                            pm.Rollback();
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                Logger.Error("生成第一批次出库任务失败,原因:" + ee.Message);
            }

            return(result);
        }
        public void Scan(string text, string cigaretteCode, string barcode)
        {
            using (PersistentManager pm = new PersistentManager())
            {
                StockOutDao outDao    = new StockOutDao();
                SupplyDao   supplyDao = new SupplyDao();

                if (barcode != string.Empty && supplyDao.Exist(barcode))
                {
                    return;
                }

                DataTable table = supplyDao.FindCigaretteAll(cigaretteCode);

                if (table.Rows.Count > 0)
                {
                    THOK.AS.Stocking.View.ScanDialog scanDialog = new THOK.AS.Stocking.View.ScanDialog(table);
                    scanDialog.setInformation(text, barcode);
                    if (scanDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (scanDialog.IsPass && scanDialog.Barcode.Length == 6)
                        {
                            cigaretteCode = scanDialog.SelectedCigaretteCode;
                            barcode       = scanDialog.Barcode;

                            using (PersistentManager pmServer = new PersistentManager("ServerConnection"))
                            {
                                ServerDao serverDao = new ServerDao();
                                serverDao.SetPersistentManager(pmServer);
                                serverDao.UpdateCigaretteToServer(barcode, cigaretteCode);
                            }
                            outDao.UpdateCigarette(barcode, cigaretteCode);
                        }
                        else
                        {
                            MessageBox.Show("验证码错误!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
        }
示例#10
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);
            }
        }
示例#11
0
        public void ExechangeChannelUSED(string lineCode, string sourceChannel, string targetChannel)
        {
            using (PersistentManager pm = new PersistentManager())
            {
                ChannelDao channelDao = new ChannelDao();
                SupplyDao  supplyDao  = new SupplyDao();
                try
                {
                    pm.BeginTransaction();

                    DataTable channelTableSource = channelDao.FindChannelUSED(lineCode, sourceChannel);
                    DataTable channelTableTarget = channelDao.FindChannelUSED(lineCode, targetChannel);

                    channelDao.UpdateChannelUSED(lineCode, targetChannel,
                                                 channelTableSource.Rows[0]["CIGARETTECODE"].ToString(),
                                                 channelTableSource.Rows[0]["CIGARETTENAME"].ToString(),
                                                 Convert.ToInt32(channelTableSource.Rows[0]["QUANTITY"]),
                                                 channelTableSource.Rows[0]["SORTNO"].ToString());

                    channelDao.UpdateChannelUSED(lineCode, sourceChannel,
                                                 channelTableTarget.Rows[0]["CIGARETTECODE"].ToString(),
                                                 channelTableTarget.Rows[0]["CIGARETTENAME"].ToString(),
                                                 Convert.ToInt32(channelTableTarget.Rows[0]["QUANTITY"]),
                                                 channelTableTarget.Rows[0]["SORTNO"].ToString());

                    supplyDao.UpdateChannelUSED(lineCode, sourceChannel, "0000", channelTableTarget.Rows[0]["GROUPNO"].ToString());
                    supplyDao.UpdateChannelUSED(lineCode, targetChannel, sourceChannel, channelTableSource.Rows[0]["GROUPNO"].ToString());
                    supplyDao.UpdateChannelUSED(lineCode, "0000", targetChannel, channelTableTarget.Rows[0]["GROUPNO"].ToString());

                    pm.Commit();
                }
                catch
                {
                    pm.Rollback();
                }
            }
        }
示例#12
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);
                }
            }
        }
示例#13
0
        /// <summary>
        /// 补货优化2010-04-19
        /// </summary>
        /// <param name="orderDate"></param>
        /// <param name="batchNo"></param>
        public void GenSupplySchedule(string orderDate, int batchNo)
        {
            using (PersistentManager pm = new PersistentManager())
            {
                OrderDao        orderDao       = new OrderDao();
                ChannelDao      channelDao     = new ChannelDao();
                LineScheduleDao lineDao        = new LineScheduleDao();
                SupplyDao       supplyDao      = new SupplyDao();
                SupplyOptimize  supplyOptimize = new SupplyOptimize();

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

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

                int currentCount = 0;
                int totalCount   = lineTable.Rows.Count;

                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 supplyTable  = supplyOptimize.Optimize(channelTable);
                    supplyDao.InsertSupply(supplyTable, Convert.ToBoolean(parameter["IsSupplyOrderbyCigaretteCode"]));

                    DataTable supplyOrderTable = supplyDao.FindSupplyOrder(orderDate, batchNo, lineCode);
                    supplyOptimize.Optimize(supplyOrderTable, 1);
                    supplyOptimize.Optimize(supplyOrderTable, 2);
                    supplyDao.Update(supplyOrderTable);

                    if (OnSchedule != null)
                    {
                        OnSchedule(this, new ScheduleEventArgs(7, "正在优化" + lineRow["LINECODE"].ToString() + "补货计划", currentCount++, totalCount));
                    }
                }

                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 serialNo = 1;
                    currentCount = 0;
                    totalCount   = masterTable.Rows.Count;

                    foreach (DataRow masterRow in masterTable.Rows)
                    {
                        DataRow[] orderRows = null;
                        //查询当前订单明细
                        orderRows = orderTable.Select(string.Format("ORDERID = '{0}'", masterRow["ORDERID"]), "CIGARETTECODE");
                        DataTable supplyTable = supplyOptimize.Optimize(channelTable, orderRows, ref serialNo);
                        supplyDao.InsertSupply(supplyTable, true);

                        if (OnSchedule != null)
                        {
                            OnSchedule(this, new ScheduleEventArgs(7, "正在优化" + lineRow["LINECODE"].ToString() + "分拣线订单补货!", ++currentCount, totalCount));
                        }
                    }
                }
            }
        }
示例#14
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;
            }
        }
示例#15
0
 public ProductForm(ProductDao productDao, SupplyDao supplyDao)
 {
     _productDao = productDao;
     _supplyDao  = supplyDao;
 }
        /// <summary>
        /// 下载数据 最后修改日期 2010-10-30
        /// </summary>
        private void DownloadData()
        {
            try
            {
                using (PersistentManager pm = new PersistentManager())
                {
                    ChannelDao       channelDao       = new ChannelDao();
                    StockOutBatchDao stockOutBatchDao = new StockOutBatchDao();
                    StockInBatchDao  stockInBatchDao  = new StockInBatchDao();
                    StockOutDao      stockOutDao      = new StockOutDao();
                    StockInDao       stockInDao       = new StockInDao();
                    SupplyDao        supplyDao        = new SupplyDao();

                    if (supplyDao.FindCount() != stockOutDao.FindOutQuantity())
                    {
                        if (DialogResult.Cancel == MessageBox.Show("还有未处理的数据,您确定要重新下载数据吗?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
                        {
                            return;
                        }
                    }

                    using (PersistentManager pmServer = new PersistentManager("ServerConnection"))
                    {
                        ServerDao serverDao = new ServerDao();
                        serverDao.SetPersistentManager(pmServer);

                        //ORDER BY ORDERDATE,BATCHNO  查找第一批次(符合已优化,并已上传一号工程,未下载的批次)
                        DataTable table = serverDao.FindBatch();
                        if (table.Rows.Count != 0)
                        {
                            using (PersistentManager pmWES = new PersistentManager("WESConnection"))
                            {
                                StockInBatchDao stockInBatchDaoWES = new StockInBatchDao();
                                stockInBatchDaoWES.SetPersistentManager(pmWES);
                                stockInBatchDaoWES.Delete();
                            }

                            string batchID   = table.Rows[0]["BATCHID"].ToString();
                            string orderDate = table.Rows[0]["ORDERDATE"].ToString();
                            string batchNo   = table.Rows[0]["BATCHNO"].ToString();

                            Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState("清空作业表", 5, 1));
                            channelDao.Delete();
                            stockOutBatchDao.Delete();
                            stockOutDao.Delete();
                            stockInBatchDao.Delete();
                            stockInDao.Delete();
                            supplyDao.Delete();
                            System.Threading.Thread.Sleep(100);

                            Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState("下载补货烟道表", 5, 2));
                            table = serverDao.FindStockChannel(orderDate, batchNo);
                            channelDao.InsertChannel(table);
                            System.Threading.Thread.Sleep(100);

                            Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState("下载补货混合烟道表", 5, 3));
                            table = serverDao.FindMixChannel(orderDate, batchNo);
                            channelDao.InsertMixChannel(table);
                            System.Threading.Thread.Sleep(100);

                            Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState("下载分拣烟道表", 5, 4));
                            table = serverDao.FindChannelUSED(orderDate, batchNo);
                            channelDao.InsertChannelUSED(table);
                            System.Threading.Thread.Sleep(100);

                            Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState("下载补货计划表", 5, 5));
                            table = serverDao.FindSupply(orderDate, batchNo);
                            supplyDao.Insert(table);
                            System.Threading.Thread.Sleep(100);

                            serverDao.UpdateBatchStatus(batchID);
                            Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState());
                            Logger.Info("数据下载完成");

                            //初始化PLC数据(叠垛线PLC,补货线PLC)
                            Context.ProcessDispatcher.WriteToService("StockPLC_01", "RestartData", 3);
                            Context.ProcessDispatcher.WriteToService("StockPLC_02", "RestartData", 1);

                            //初始化入库扫码器
                            Context.ProcessDispatcher.WriteToProcess("ScanProcess", "Init", null);

                            //初始化状态管理器
                            Context.ProcessDispatcher.WriteToProcess("LedStateProcess", "Init", null);
                            Context.ProcessDispatcher.WriteToProcess("OrderDataStateProcess", "Init", null);
                            Context.ProcessDispatcher.WriteToProcess("ScannerStateProcess", "Init", null);

                            //生成入库请求任务数据
                            Context.ProcessDispatcher.WriteToProcess("StockInRequestProcess", "FirstBatch", null);
                            //生成补货请求任务数据
                            //Context.ProcessDispatcher.WriteToProcess("SupplyFirstRequestProcess", "FirstBatch", null);
                        }
                        else
                        {
                            MessageBox.Show("没有补货计划数据!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error("数据下载处理失败,原因:" + e.Message);
            }
        }
示例#17
0
 public SupplyForm(SupplyDao supplyDao)
 {
     _supplyDao = supplyDao;
 }
示例#18
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;
            }
        }