/// <summary> /// 查询仓库入库单据细表上报 /// </summary> public string FindInDetailBill() { string tag = "上报仓库入库单据细表成功!"; using (PersistentManager dbpm = new PersistentManager("ZYDB2Connection")) { UploadDao dao = new UploadDao(); dao.SetPersistentManager(dbpm); DataTable inDetailTable = this.QueryInDetailBill(); if (inDetailTable.Rows.Count > 0) { try { dbpm.BeginTransaction(); dao.InsertInDetailBill(inDetailTable); this.UpdateInDetail(""); dbpm.Commit(); } catch (Exception exp) { dbpm.Rollback(); throw new Exception(exp.Message); } } else { tag = "没有新的仓库入库细表信息要上报!"; } } return(tag); }
/// <summary> /// 查询业务库存表表上报 /// </summary> public string FindBusiStock() { string tag = "上报业务库存表成功!"; using (PersistentManager dbpm = new PersistentManager("ZYDB2Connection")) { UploadDao dao = new UploadDao(); dao.SetPersistentManager(dbpm); DataTable busiStockTable = this.QueryBusiStock(); if (busiStockTable.Rows.Count > 0) { try { dbpm.BeginTransaction(); dao.InsertBustStock(busiStockTable); this.UpdateBusiStock(""); dbpm.Commit(); } catch (Exception exp) { dbpm.Rollback(); throw new Exception(exp.Message); } } else { tag = "没有新的业务库存信息要上报!"; } } return(tag); }
/// <summary> /// 上报国家局分拣数据主表 /// </summary> /// <param name="masterTable"></param> public void UploadSortingOrderMaster(DataTable masterTable) { //上报分拣主表数据 using (PersistentManager pm = new PersistentManager("DB2Connection")) { UploadSortingDao udao = new UploadSortingDao(); udao.SetPersistentManager(pm); try { pm.BeginTransaction(); foreach (DataRow row in masterTable.Rows) { string sql = string.Format("INSERT INTO DWV_IORD_ORDER(ORDER_ID,ORG_CODE,SALE_REG_CODE,ORDER_DATE,ORDER_TYPE," + "CUST_CODE,CUST_NAME,QUANTITY_SUM,AMOUNT_SUM,DETAIL_NUM,ISACTIVE,UPDATE_DATE,IS_IMPORT)VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}',{7},{8},{9},'{10}','{11}','{12}')", row["ORDER_ID"], row["ORG_CODE"], row["SALE_REG_CODE"], Convert.ToDateTime(row["ORDER_DATE"]).ToString("yyyyMMdd"), row["ORDER_TYPE"], row["CUST_CODE"], row["CUST_NAME"], row["QUANTITY_SUM"], row["AMOUNT_SUM"], row["DETAIL_NUM"], row["ISACTIVE"], DateTime.Now.ToString("yyyyMMddHHmmss"), row["IS_IMPORT"]); udao.setData(sql); } pm.Commit(); } catch (Exception exp) { pm.Rollback(); throw exp; } } }
/// <summary> /// 查询出库业务单据表上报 /// </summary> public string FindOutBusiBill() { string tag = "上报仓库出库业务单据表成功!"; using (PersistentManager dbpm = new PersistentManager("ZYDB2Connection")) { UploadDao dao = new UploadDao(); dao.SetPersistentManager(dbpm); DataTable outBusiTable = this.QueryOutBusiBill(); if (outBusiTable.Rows.Count > 0) { try { dbpm.BeginTransaction(); dao.InsertOutBusiBill(outBusiTable); this.UpdateOutBusi(""); dbpm.Commit(); } catch (Exception exp) { dbpm.Rollback(); throw new Exception(exp.Message); } } else { tag = "没有新的仓库出库业务单据表要上报!"; } } return(tag); }
/// <summary> /// 上报国家局分拣数据细表 /// </summary> /// <param name="detailTable"></param> public void UploadSortingOrderDetail(DataTable detailTable) { //上报分拣细表数据 using (PersistentManager pm = new PersistentManager("DB2Connection")) { UploadSortingDao udao = new UploadSortingDao(); udao.SetPersistentManager(pm); try { pm.BeginTransaction(); foreach (DataRow row in detailTable.Rows) { string sql = string.Format("INSERT INTO DWV_IORD_ORDER_DETAIL(ORDER_DETAIL_ID,ORDER_ID,BRAND_CODE,BRAND_NAME,BRAND_UNIT_NAME," + "QTY_DEMAND,QUANTITY,PRICE,AMOUNT,IS_IMPORT)VALUES('{0}','{1}','{2}','{3}','{4}',{5},{6},{7},{8},'{9}')", row["ORDER_DETAIL_ID"], row["ORDER_ID"], row["BRAND_CODE"], row["BRAND_NAME"], row["BRAND_UNIT_NAME"], row["QTY_DEMAND"], row["QUANTITY"], row["PRICE"], row["AMOUNT"], row["IS_IMPORT"]); udao.setData(sql); } pm.Commit(); } catch (Exception exp) { pm.Rollback(); throw exp; } } }
/// <summary> /// 查询同步状态表上报 /// </summary> public string FindSynchroInfo() { string tag = "上报同步状态表成功!"; using (PersistentManager dbpm = new PersistentManager("ZYDB2Connection")) { UploadDao dao = new UploadDao(); dao.SetPersistentManager(dbpm); DataTable synchroTable = this.QuerySynchroInfo(); if (synchroTable.Rows.Count > 0) { try { dbpm.BeginTransaction(); dao.InsertSynchro(synchroTable); this.UpdateSyachro(""); dbpm.Commit(); } catch (Exception exp) { dbpm.Rollback(); throw new Exception(exp.Message); } } else { tag = "没有同步状态表数据可上报!"; } } return(tag); }
/// <summary> /// 查询分拣订单主表上报 /// </summary> public string FindIordMasterOrder() { string tag = "上报分拣订单主表成功!"; using (PersistentManager dbpm = new PersistentManager("ZYDB2Connection")) { UploadDao dao = new UploadDao(); dao.SetPersistentManager(dbpm); DataTable orderMasterTable = this.QueryIordMasterOrder(); if (orderMasterTable.Rows.Count > 0) { try { dbpm.BeginTransaction(); dao.InsertIordOrder(orderMasterTable); this.UpdateOrderMaster(""); dbpm.Commit(); } catch (Exception exp) { dbpm.Rollback(); throw new Exception(exp.Message); } } else { tag = "没有新的分拣订单主表要上报!"; } } return(tag); }
/// <summary> /// 查询卷烟信息表上报 /// </summary> public string FindProduct() { string tag = "上报卷烟信息表成功!"; using (PersistentManager dbpm = new PersistentManager("ZYDB2Connection")) { UploadDao dao = new UploadDao(); dao.SetPersistentManager(dbpm); DataTable brandTable = this.QueryProductInfo(); if (brandTable.Rows.Count > 0) { try { dbpm.BeginTransaction(); dao.InsertProduct(brandTable); this.UpdateProduct(); dbpm.Commit(); } catch (Exception exp) { dbpm.Rollback(); throw new Exception(exp.Message); } } else { tag = "没有新的卷烟信息要上报!"; } } return(tag); }
private void StockInRequest(string cigaretteCode, int quantity, int stockRemainQuantity) { using (PersistentManager pm = new PersistentManager()) { StockInBatchDao stockInBatchDao = new StockInBatchDao(); StockInDao stockInDao = new StockInDao(); ChannelDao channelDao = new ChannelDao(); stockInBatchDao.SetPersistentManager(pm); stockInDao.SetPersistentManager(pm); channelDao.SetPersistentManager(pm); pm.BeginTransaction(); try { DataTable cigaretteTable = channelDao.FindChannelForCigaretteCode(cigaretteCode); if (cigaretteTable.Rows.Count != 0) { DataRow row = cigaretteTable.Rows[0]; bool isStockIn = row["ISSTOCKIN"].ToString() == "1" ? true : false; int batchNo = stockInBatchDao.FindMaxBatchNo() + 1; stockInBatchDao.InsertBatch(batchNo, row["CHANNELCODE"].ToString(), cigaretteCode, row["CIGARETTENAME"].ToString(), quantity, isStockIn ? stockRemainQuantity : 0); int stockInID = stockInDao.FindMaxInID(); for (int i = 1; i <= quantity; i++) { stockInID = stockInID + 1; stockInDao.Insert(stockInID, batchNo, row["CHANNELCODE"].ToString(), cigaretteCode, row["CIGARETTENAME"].ToString(), row["BARCODE"].ToString(), (isStockIn && stockRemainQuantity-- > 0) ? "1" : "0"); } pm.Commit(); try { using (PersistentManager pmWES = new PersistentManager("WESConnection")) { StockInBatchDao stockInBatchDaoWES = new StockInBatchDao(); stockInBatchDaoWES.SetPersistentManager(pmWES); stockInBatchDaoWES.InsertBatch(batchNo, row["CHANNELCODE"].ToString(), cigaretteCode, row["CIGARETTENAME"].ToString(), quantity, isStockIn ? stockRemainQuantity : 0); } } catch (Exception e) { Logger.Error("上传入库计划失败,详情:" + e.Message); } } } catch (Exception ex) { pm.Rollback(); Logger.Error("生成入库计划失败,详情:" + ex.Message); } } }
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); }
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 SaveParameter(Dictionary <string, string> parameters) { using (PersistentManager pm = new PersistentManager()) { try { SysSystemParameterDao parameterDao = new SysSystemParameterDao(); pm.BeginTransaction(); foreach (string key in parameters.Keys) { parameterDao.UpdateEntity(key, parameters[key]); } pm.Commit(); } catch { pm.Rollback(); } } }
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(); } } }
private void Scanner_Process_StockIn(string scannerCode, string barcode) { if (barcode.Length == 32) { barcode = barcode.Substring(2, 6); Logger.Info(barcode); } if (barcode.Length != 6) { string text = scannerCode + "号条码扫描器处理失败!详情:条码格式不正确!"; ShowMessageBox(text, "询问", MessageBoxButtons.OK, MessageBoxIcon.Question); Logger.Error(text); return; } using (PersistentManager pm = new PersistentManager()) { StockInDao stockInDao = new StockInDao(); StockInBatchDao stockInBatch = new StockInBatchDao(); DataTable stockInTable = null; int pQuantity = scannerParameters.GetParameter(scannerCode, "Quantity") != null ? (int)scannerParameters.GetParameter(scannerCode, "Quantity") : 0; string pBarcode = scannerParameters.GetParameter(scannerCode, "Barcode") != null ? (string)scannerParameters.GetParameter(scannerCode, "Barcode") : ""; stockInTable = stockInDao.FindCigarette(); if (stockInTable.Rows.Count == 0) { //提示当前已无入库申请任务。 string text = scannerCode + "号条码扫描器处理失败!详情:当前已无入库申请任务!"; ShowMessageBox(text, "询问", MessageBoxButtons.OK, MessageBoxIcon.Question); Logger.Error(text); return; } if (barcode != pBarcode && pBarcode != string.Empty) { //是否可换品牌,进行入库 if (pQuantity == Convert.ToInt32(Context.Attributes["StockInStackQuantity"])) { //可换品牌入库(未完成的品牌可,下次再重入库) stockInTable = stockInDao.FindCigarette(barcode); } else { //不可换品牌入库。 //进行提示,并要求人工确认。进行搬回卷烟,按原计划重新上烟。 //或人工强行更换品牌(将未完成的入库品牌,强行结束,不再重新入库)。 stockInTable = stockInDao.FindCigarette(pBarcode); if (stockInTable.Rows.Count != 0) { string text = string.Format("当前计划入库卷烟品牌为‘{0}’,是否强制更换其他品牌!是请点击‘Yes’否则请点击‘No’", stockInTable.Rows[0]["CIGARETTENAME"]); if (DialogResult.Yes == MessageBox.Show(Application.OpenForms["MainForm"], text, "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { //强行更换品牌。 stockInBatch.UpdateState(stockInTable.Rows[0]["BATCHNO"].ToString()); stockInTable = stockInDao.FindCigarette(barcode); scannerParameters.SetParameter(scannerCode, "Barcode", ""); scannerParameters.SetParameter(scannerCode, "Quantity", Convert.ToInt32(Context.Attributes["StockInStackQuantity"])); } else { //提示进行搬回卷烟,按原计划重新上烟。并退出本次扫码流程。 text = scannerCode + "号条码扫描器处理失败!详情:请搬回卷烟,按原计划重新上烟!"; ShowMessageBox(text, "询问", MessageBoxButtons.OK, MessageBoxIcon.Question); Logger.Error(text); return; } } else { stockInTable = stockInDao.FindCigarette(barcode); } } } else { stockInTable = stockInDao.FindCigarette(barcode); } //判断当前扫到卷烟条码是否有入库申请任务,如果没有则提示:进行搬回卷烟,按原计划重新上烟。并退出本次扫码流程。 if (stockInTable.Rows.Count == 0) { //提示当前扫到条码卷烟,已无入库申请任务。 string text = scannerCode + "号条码扫描器处理失败!详情:当前卷烟已无入库申请任务!"; Logger.Error(text); ShowMessageBox(text, "询问", MessageBoxButtons.OK, MessageBoxIcon.Question); text = scannerCode + "号条码扫描器处理失败!详情:当前卷烟需要更新更条码,请确认!"; string cigaretteCode = ""; Scan(text, cigaretteCode, barcode); return; } if (barcode == stockInTable.Rows[0]["BARCODE"].ToString()) { int [] data = new int [3]; int supplyAddress = Convert.ToInt32(stockInTable.Rows[0]["CHANNELCODE"].ToString()); int change = Convert.ToInt32(stockInTable.Rows[0]["QUANTITY"]) <= 1 ? 1 : 0; int orderNo = scannerParameters.GetParameter(scannerCode, "OrderNo") != null ? (int)scannerParameters.GetParameter(scannerCode, "OrderNo") : 0; data[0] = supplyAddress; data[1] = change; data[2] = orderNo + 1; if (WriteToService("StockPLC_01", "Scanner_DirectoryData_" + scannerCode, data)) { scannerParameters.SetParameter(scannerCode, "SupplyAddress", supplyAddress); scannerParameters.SetParameter(scannerCode, "Change", change); scannerParameters.SetParameter(scannerCode, "OrderNo", orderNo + 1); //更新数据库状态 pm.BeginTransaction(); //更新为已入库,并更新当前批次已入库数量。 stockInDao.UpdateScanStatus(stockInTable.Rows[0]["STOCKINID"].ToString()); stockInBatch.UpdateQuantityForBatch(stockInTable.Rows[0]["BATCHNO"].ToString()); if (Convert.ToInt32(stockInTable.Rows[0]["QUANTITY"]) <= 1) { stockInBatch.UpdateState(stockInTable.Rows[0]["BATCHNO"].ToString()); } pm.Commit(); //更新扫码器参数信息 if (pBarcode == barcode) { if (pQuantity < Convert.ToInt32(Context.Attributes["StockInStackQuantity"])) { scannerParameters.SetParameter(scannerCode, "Quantity", pQuantity + 1); } else { scannerParameters.SetParameter(scannerCode, "Quantity", 1); WriteToProcess("DataRequestProcess", "StockInRequest", 1); } } else { scannerParameters.SetParameter(scannerCode, "Barcode", barcode); scannerParameters.SetParameter(scannerCode, "Quantity", 1); } if (Convert.ToInt32(stockInTable.Rows[0]["QUANTITY"]) <= 1) { scannerParameters.SetParameter(scannerCode, "Barcode", ""); scannerParameters.SetParameter(scannerCode, "Quantity", Convert.ToInt32(Context.Attributes["StockInStackQuantity"])); } WriteToProcess("LEDProcess", "Refresh", null); Logger.Info(string.Format(scannerCode + "号条码扫描,写分流数据,卷烟名称:{0},目标:{1} !", stockInTable.Rows[0]["CIGARETTENAME"], Convert.ToInt32(stockInTable.Rows[0]["CHANNELCODE"].ToString()))); } return; } } }
/// <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; } }
protected override void StateChanged(StateItem stateItem, IProcessDispatcher dispatcher) { try { using (PersistentManager pm = new PersistentManager()) { StockOutBatchDao stockOutBatchDao = new StockOutBatchDao(); StockOutDao stockOutDao = new StockOutDao(); StockInDao stockInDao = new StockInDao(); stockOutBatchDao.SetPersistentManager(pm); stockOutDao.SetPersistentManager(pm); stockInDao.SetPersistentManager(pm); try { DataTable outTable = stockOutDao.FindSupply(); DataTable stockInTable = stockInDao.FindStockInForIsInAndNotOut(); if (outTable.Rows.Count > 0) { pm.BeginTransaction(); for (int i = 0; i < outTable.Rows.Count; i++) { DataRow[] stockInRows = stockInTable.Select(string.Format("CIGARETTECODE='{0}' AND STATE ='1' AND ( STOCKOUTID IS NULL OR STOCKOUTID = 0 )", outTable.Rows[i]["CIGARETTECODE"].ToString()), "STOCKINID"); if (stockInRows.Length <= Convert.ToInt32(Context.Attributes["StockInRequestRemainQuantity"]) + 1) { WriteToProcess("StockInRequestProcess", "StockInRequest", outTable.Rows[i]["CIGARETTECODE"].ToString()); } else if (stockInRows.Length > 0 && stockInRows.Length + Convert.ToInt32(stockInRows[0]["STOCKINQUANTITY"]) <= Convert.ToInt32(Context.Attributes["StockInCapacityQuantity"]) + 1) { WriteToProcess("StockInRequestProcess", "StockInRequest", outTable.Rows[i]["CIGARETTECODE"].ToString()); } if (stockInRows.Length > 0) { stockInRows[0]["STOCKOUTID"] = outTable.Rows[i]["STOCKOUTID"].ToString(); outTable.Rows[i]["STATE"] = 1; } else { Logger.Error(string.Format("[{0}] [{1}] 库存不足!", outTable.Rows[i]["CIGARETTECODE"].ToString(), outTable.Rows[i]["CIGARETTENAME"].ToString())); WriteToProcess("LEDProcess", "StockInRequestShow", outTable.Rows[0]["CIGARETTENAME"]); break; } } stockOutDao.UpdateStatus(outTable); stockInDao.UpdateStockOutIdToStockIn(stockInTable); pm.Commit(); Logger.Info("处理出库数据成功。"); } } catch (Exception e) { Logger.Error("处理出库数据失败,原因:" + e.Message); pm.Rollback(); } } } catch (Exception e) { Logger.Error("处理出库数据失败,原因:" + e.Message); } }
/// <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; } }