/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(BForkliftTaskData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("set nocount on; "); strSql.Append("insert into BForkliftTask("); strSql.Append(@"taskType,palletNo,preWareNo,preLocatorNo,nextWareNo,nextLocatorNo,effectDt,mark,isDeal,dealEmpId, dealDt,stockUpBillNo,isrtEmpId,isrtDt)"); strSql.Append(" values ("); strSql.Append(@"@taskType,@palletNo,@preWareNo,@preLocatorNo,@nextWareNo,@nextLocatorNo,@effectDt,@mark,@isDeal,@dealEmpId, @dealDt,@stockUpBillNo,@isrtEmpId,@isrtDt)"); strSql.Append("; select @@identity; set nocount off; "); SqlParameter[] parameters = { new SqlParameter("@taskType", SqlDbType.VarChar,10), new SqlParameter("@palletNo", SqlDbType.VarChar,20), new SqlParameter("@preWareNo", SqlDbType.VarChar,20), new SqlParameter("@preLocatorNo", SqlDbType.VarChar,20), new SqlParameter("@nextWareNo", SqlDbType.VarChar,20), new SqlParameter("@nextLocatorNo", SqlDbType.VarChar,20), new SqlParameter("@effectDt", SqlDbType.DateTime), new SqlParameter("@mark", SqlDbType.VarChar,200), new SqlParameter("@isDeal", SqlDbType.Bit), new SqlParameter("@dealEmpId", SqlDbType.Int), new SqlParameter("@dealDt", SqlDbType.DateTime), new SqlParameter("@stockUpBillNo", SqlDbType.VarChar,20), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime) }; parameters[0].Value = model.taskType; parameters[1].Value = model.palletNo; parameters[2].Value = model.preWareNo; parameters[3].Value = model.preLocatorNo; parameters[4].Value = model.nextWareNo; parameters[5].Value = model.nextLocatorNo; parameters[6].Value = model.effectDt == string.Empty ? null : model.effectDt; parameters[7].Value = model.mark; parameters[8].Value = model.isDeal; parameters[9].Value = model.dealEmpId; parameters[10].Value = model.dealDt == string.Empty ? null : model.dealDt; parameters[11].Value = model.stockUpBillNo; parameters[12].Value = model.isrtEmpId; parameters[13].Value = model.isrtDt == string.Empty ? null : model.isrtDt; int id = 0; try { object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ret != null && ret != DBNull.Value) { id = Convert.ToInt32(ret); } } catch (Exception ex) { throw ex; } return id; }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BForkliftTaskData model) { return this.forkliftTaskDB.ModifyRecord(model); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(BForkliftTaskData model) { return this.forkliftTaskDB.AddRecord(model); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BForkliftTaskData model) { bool ret = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update BForkliftTask set "); strSql.Append("taskType=@taskType,"); strSql.Append("palletNo=@palletNo,"); strSql.Append("preWareNo=@preWareNo,"); strSql.Append("preLocatorNo=@preLocatorNo,"); strSql.Append("nextWareNo=@nextWareNo,"); strSql.Append("nextLocatorNo=@nextLocatorNo,"); strSql.Append("effectDt=@effectDt,"); strSql.Append("mark=@mark,"); strSql.Append("isDeal=@isDeal,"); strSql.Append("dealEmpId=@dealEmpId,"); strSql.Append("dealDt=@dealDt,"); strSql.Append("stockUpBillNo=@stockUpBillNo,"); strSql.Append("isrtEmpId=@isrtEmpId,"); strSql.Append("isrtDt=@isrtDt"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@taskType", SqlDbType.VarChar,10), new SqlParameter("@palletNo", SqlDbType.VarChar,20), new SqlParameter("@preWareNo", SqlDbType.VarChar,20), new SqlParameter("@preLocatorNo", SqlDbType.VarChar,20), new SqlParameter("@nextWareNo", SqlDbType.VarChar,20), new SqlParameter("@nextLocatorNo", SqlDbType.VarChar,20), new SqlParameter("@effectDt", SqlDbType.DateTime), new SqlParameter("@mark", SqlDbType.VarChar,200), new SqlParameter("@isDeal", SqlDbType.Bit), new SqlParameter("@dealEmpId", SqlDbType.Int), new SqlParameter("@dealDt", SqlDbType.DateTime), new SqlParameter("@stockUpBillNo", SqlDbType.VarChar,20), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime) }; parameters[0].Value = model.id; parameters[1].Value = model.taskType; parameters[2].Value = model.palletNo; parameters[3].Value = model.preWareNo; parameters[4].Value = model.preLocatorNo; parameters[5].Value = model.nextWareNo; parameters[6].Value = model.nextLocatorNo; parameters[7].Value = model.effectDt == string.Empty ? null : model.effectDt; parameters[8].Value = model.mark; parameters[9].Value = model.isDeal; parameters[10].Value = model.dealEmpId; parameters[11].Value = model.dealDt == string.Empty ? null : model.dealDt; parameters[12].Value = model.stockUpBillNo; parameters[13].Value = model.isrtEmpId; parameters[14].Value = model.isrtDt == string.Empty ? null : model.isrtDt; try { SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); ret = true; } catch (Exception ex) { throw ex; } return ret; }
/// <summary> /// 保存非标准箱从质检区入库信息 /// </summary> /// <param name="strPalletNo">托盘条码号</param> /// <param name="strNextWareNo">目的库区编码</param> /// <param name="strNextWareLocatorNo">目的库位编码</param> /// <returns></returns> public bool SaveNoStandBoxInStockInfo(string strPalletNo, string strNextWareNo, string strNextWareLocatorNo) { bool ret = false; SqlTransaction trans = null; SCommBB commBB = new SCommBB(this.connection); BTallyBillBB tallyBillBB = new BTallyBillBB(this.connection); BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection); BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB(this.connection); try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransSave"); this.tallyBillDetailBB.Transaction = trans; commBB.Transaction = trans; tallyBillBB.Transaction = trans; arrangeBillBoxBB.Transaction = trans; forkliftTaskBB.Transaction = trans; } else { this.tallyBillDetailBB.Transaction = this.transaction; commBB.Transaction = this.transaction; tallyBillBB.Transaction = this.transaction; arrangeBillBoxBB.Transaction = this.transaction; forkliftTaskBB.Transaction = this.transaction; } int mainId = 0; StringBuilder strSql = new StringBuilder(); DataTable dtArrangeBillBox = new DataTable(); BTallyBillData tallyBillModel = new BTallyBillData(); BTallyBillDetailData tallyBillDetailModel = new BTallyBillDetailData(); BForkliftTaskData forkliftTaskModel = new BForkliftTaskData(); //保存理货信息 tallyBillModel = new BTallyBillData(); tallyBillModel.palletNo = strPalletNo;//托盘条码号 tallyBillModel.isInStock = false;//是否入库 tallyBillModel.isrtDt = System.DateTime.Now.ToString();//添加时间 tallyBillModel.isrtEmpId = this.empId;//添加人 tallyBillModel.instantState = "02";//理货完成 mainId = tallyBillBB.AddRecord(tallyBillModel);//称重理货单ID赋值 dtArrangeBillBox = arrangeBillBoxBB.GetList("palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''").Tables[0]; foreach (DataRow row in dtArrangeBillBox.Rows) { //保存称重理货明细数据 tallyBillDetailModel = new BTallyBillDetailData(); tallyBillDetailModel.mainId = mainId.ToString();//称重理货单ID tallyBillDetailModel.region = "0";//区域ID tallyBillDetailModel.oldPalletNo = strPalletNo;//原托盘号 tallyBillDetailModel.boxNo = row["boxNo"].ToString();//箱号 tallyBillDetailModel.isrtDt = System.DateTime.Now.ToString();//添加时间 tallyBillDetailModel.isrtEmpId = this.empId;//添加人 tallyBillDetailBB.AddRecord(tallyBillDetailModel); } //生成叉车任务 if (dtArrangeBillBox.Rows.Count > 0) { forkliftTaskModel = new BForkliftTaskData(); forkliftTaskModel.taskType = "11";//任务类型为:从质检区到正式区 forkliftTaskModel.palletNo = strPalletNo;//托盘号 forkliftTaskModel.preWareNo = dtArrangeBillBox.Rows[0]["wareNo"].ToString();//源库区 forkliftTaskModel.preLocatorNo = dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//源库位 forkliftTaskModel.nextWareNo = strNextWareNo;//目的库区 forkliftTaskModel.nextLocatorNo = strNextWareLocatorNo;//目的库位 forkliftTaskModel.effectDt = System.DateTime.Now.ToString();//生效时间 forkliftTaskModel.isDeal = false;//是否处理 forkliftTaskBB.AddRecord(forkliftTaskModel); //更新目的库区占用状态 if (strNextWareLocatorNo != "") { //更改库位的使用状态 commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='" + strNextWareLocatorNo + "'"); } } if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransSave"); throw ex; } finally { commBB.Dispose(); tallyBillBB.Dispose(); arrangeBillBoxBB.Dispose(); forkliftTaskBB.Dispose(); } return ret; }
/// <summary> /// 得到一个model /// </summary> /// <param name="id">主键值</param> /// <returns>model</returns> public BForkliftTaskData GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"select id,taskType,palletNo,preWareNo,preLocatorNo,nextWareNo,nextLocatorNo,effectDt,mark,isDeal,dealEmpId, dealDt,stockUpBillNo,isrtEmpId,isrtDt from BForkliftTask"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; BForkliftTaskData model = new BForkliftTaskData(); DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; if (row["id"] != DBNull.Value) { model.id = Convert.ToInt32(row["id"]); } if (row["taskType"] != DBNull.Value) { model.taskType = Convert.ToString(row["taskType"]); } if (row["palletNo"] != DBNull.Value) { model.palletNo = Convert.ToString(row["palletNo"]); } if (row["preWareNo"] != DBNull.Value) { model.preWareNo = Convert.ToString(row["preWareNo"]); } if (row["preLocatorNo"] != DBNull.Value) { model.preLocatorNo = Convert.ToString(row["preLocatorNo"]); } if (row["nextWareNo"] != DBNull.Value) { model.nextWareNo = Convert.ToString(row["nextWareNo"]); } if (row["nextLocatorNo"] != DBNull.Value) { model.nextLocatorNo = Convert.ToString(row["nextLocatorNo"]); } if (row["effectDt"] != DBNull.Value) { model.effectDt = Convert.ToString(row["effectDt"]); } if (row["mark"] != DBNull.Value) { model.mark = Convert.ToString(row["mark"]); } if (row["isDeal"] != DBNull.Value) { model.isDeal = Convert.ToBoolean(row["isDeal"]); } if (row["dealEmpId"] != DBNull.Value) { model.dealEmpId = Convert.ToInt32(row["dealEmpId"]); } if (row["dealDt"] != DBNull.Value) { model.dealDt = Convert.ToString(row["dealDt"]); } if (row["stockUpBillNo"] != DBNull.Value) { model.stockUpBillNo = Convert.ToString(row["stockUpBillNo"]); } if (row["isrtEmpId"] != DBNull.Value) { model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]); } if (row["isrtDt"] != DBNull.Value) { model.isrtDt = Convert.ToString(row["isrtDt"]); } return model; } else { return null; } }
public string GetSuggestWareLocator_ForkliftTask(int forkliftTaskId) { string strSuggestWareLocator = ""; BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB(); LWareLocatorBB wareLocatorBB = new LWareLocatorBB(); SCommBB commBB = new SCommBB(); LWareLocatorRelationBB wareLocatorRelation = new LWareLocatorRelationBB(); try { vBForkliftTaskData vForkliftTaskModel = new vBForkliftTaskData(); BForkliftTaskData forkliftTaskModel = new BForkliftTaskData(); DataTable dtWareLocator = new DataTable(); //获取叉车任务实例 forkliftTaskModel = forkliftTaskBB.GetModel(forkliftTaskId); vForkliftTaskModel = forkliftTaskBB.GetVModel(forkliftTaskId); if (forkliftTaskModel.taskType == "01" || forkliftTaskModel.taskType == "04" || forkliftTaskModel.taskType == "10") { #region 01 从排托区到质检区、04 从理货区返回质检区、10 从收货区到质检区 //获取没有使用的质检区的所有库位 //2015-08-04 修改增加相应的对应关系 与表LwareLocator之间产生关系 if (!string.IsNullOrEmpty(forkliftTaskModel.nextLocatorNo))//已有目的库位 { strSuggestWareLocator = vForkliftTaskModel.nextWareNo + "," + vForkliftTaskModel.nextWareNm + "," + vForkliftTaskModel.nextLocatorNo + "," + vForkliftTaskModel.nextWareLocatorNm; } else//没有目的库位 { //只有原来的库区是在收货区的时候 才进行处理 //if (vForkliftTaskModel.preWareNo == "SHQ") //{ // //首先是查找出所有的可以进行入库的库位 // DataTable dtNew = new DataTable(); // if (vForkliftTaskModel.preLocatorNo.Contains("SH")) // dtNew = wareLocatorRelation.GetList("wareLocatorStartPrefix = 'SH' and isdel = 0").Tables[0]; // else // dtNew = wareLocatorRelation.GetList("wareLocatorStartPrefix = 'S' and isdel = 0").Tables[0]; // for (int i = 0; i < dtNew.Rows.Count; i++) // { // //2015-08-04 数据库实现后发现只能通过程序来进行实现 // dtWareLocator = wareLocatorBB.GetVList("wareType='01' and isUsing=0 and isDel=0 and wareLocatorNo like '" + dtNew.Rows[i]["wareLocatorEndPrefix"] + "%'").Tables[0]; // if(dtWareLocator.Rows.Count>0) // { // break;//如果大于0的话则进行退出操作 // } // } // // dtWareLocator = wareLocatorBB.GetVList("wareType='01' and isUsing=0 and isDel=0").Tables[0]; //} //else //{ //首先要通过叉车能够获取获取托盘上此时有的信息 string palletNO = vForkliftTaskModel.palletNo; DataTable dtPallet = GetBoxByPalletNo(palletNO); string checkMaterial = ""; if (dtPallet != null) { if (dtPallet.Rows.Count > 0 && dtPallet.Rows[0]["materialNO"] != "") { checkMaterial = dtPallet.Rows[0]["materialNO"].ToString(); } } //dtWareLocator = wareLocatorBB.GetVList("wareType='01' and isUsing=0 and isDel=0").Tables[0]; dtWareLocator = wareLocatorBB.GetVListJoey(checkMaterial).Tables[0]; //} if (dtWareLocator.Rows.Count > 0) { //获取推荐库位信息 strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString() + "," + dtWareLocator.Rows[0]["wareNm"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString(); //更改叉车任务的目的库位信息 forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区 forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位 forkliftTaskBB.ModifyRecord(forkliftTaskModel); //更改目的库位的使用状态 commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='" + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "'"); } } #endregion 01 从排托区到质检区、04 从理货区返回质检区、10 从收货区到质检区 } else if (forkliftTaskModel.taskType == "08" || forkliftTaskModel.taskType == "02" || forkliftTaskModel.taskType == "03" || forkliftTaskModel.taskType == "05" || forkliftTaskModel.taskType == "06" || forkliftTaskModel.taskType == "11" || forkliftTaskModel.taskType == "12") { #region 08 从收货区到收货排托区,02 从质检区到理货区,03 从理货区到正式库区,05 从正式库区到拣货区,06 从拣货区返回正式库区,11 从质检区到正式区,12 托盘移库 strSuggestWareLocator = vForkliftTaskModel.nextWareNo + "," + vForkliftTaskModel.nextWareNm + "," + vForkliftTaskModel.nextLocatorNo + "," + vForkliftTaskModel.nextWareLocatorNm; #endregion 08 从收货区到收货排托区,02 从质检区到理货区,03 从理货区到正式库区,05 从正式库区到拣货区,06 从拣货区返回正式库区,11 从质检区到正式区,12 托盘移库 } else if (forkliftTaskModel.taskType == "07") { #region 07 拣货区发货 strSuggestWareLocator = ",发货区,,发货区"; #endregion 07 拣货区发货 } else if (forkliftTaskModel.taskType == "09") { #region 09 从收货排托区返回收货区 if (!string.IsNullOrEmpty(forkliftTaskModel.nextLocatorNo))//已有目的库位 { strSuggestWareLocator = vForkliftTaskModel.nextWareNo + "," + vForkliftTaskModel.nextWareNm + "," + vForkliftTaskModel.nextLocatorNo + "," + vForkliftTaskModel.nextWareLocatorNm; } else { //获取收货区的所有库位 dtWareLocator = wareLocatorBB.GetVList("wareType='05' and isUsing=0").Tables[0]; if (dtWareLocator.Rows.Count > 0) { strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString() + "," + dtWareLocator.Rows[0]["wareNm"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString(); //更改叉车任务的目的库位信息 forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区 forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位 forkliftTaskBB.ModifyRecord(forkliftTaskModel); //更改目的库位的使用状态 commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='" + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "'"); } } #endregion 09 从收货排托区返回收货区 } else if (forkliftTaskModel.taskType == "13" || forkliftTaskModel.taskType == "30") { #region 13 从理货区到异常区 //获取没有使用的异常区的所有库位 //if (!string.IsNullOrEmpty(forkliftTaskModel.nextLocatorNo))//已有目的库位 //{ // strSuggestWareLocator = vForkliftTaskModel.nextWareNo // + "," + vForkliftTaskModel.nextWareNm // + "," + vForkliftTaskModel.nextLocatorNo // + "," + vForkliftTaskModel.nextWareLocatorNm; //} //else //{ //} //dtWareLocator = wareLocatorBB.GetVList("wareType='09' and isUsing=0 and isDel=0").Tables[0]; dtWareLocator = wareLocatorBB.GetVList("wareType='09' and isDel=0").Tables[0];//临时不限制是否正在使用 if (dtWareLocator.Rows.Count > 0) { //获取推荐库位信息 strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString() + "," + dtWareLocator.Rows[0]["wareNm"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString(); //更改叉车任务的目的库位信息 forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区 forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位 forkliftTaskBB.ModifyRecord(forkliftTaskModel); ////更改目的库位的使用状态 //commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='" // + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "'"); } #endregion 13 从理货区到异常区 } else if (forkliftTaskModel.taskType == "14") { #region 14 从拣货区到打托区 if (!string.IsNullOrEmpty(forkliftTaskModel.nextLocatorNo))//已有目的库位 { strSuggestWareLocator = vForkliftTaskModel.nextWareNo + "," + vForkliftTaskModel.nextWareNm + "," + vForkliftTaskModel.nextLocatorNo + "," + vForkliftTaskModel.nextWareLocatorNm; } else { //获取打托区的所有库位 dtWareLocator = wareLocatorBB.GetVList("wareType='10' and isUsing=0 and isDel=0").Tables[0]; if (dtWareLocator.Rows.Count > 0) { strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString() + "," + dtWareLocator.Rows[0]["wareNm"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString(); //更改叉车任务的目的库位信息 forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区 forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位 forkliftTaskBB.ModifyRecord(forkliftTaskModel); //更改目的库位的使用状态 //日期 2014-07-22 将打托区占用取消掉 打托区当中可以有多个被占用 //commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='" // + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "'"); } } #endregion 14 从拣货区到打托区 } else if (forkliftTaskModel.taskType == "15") { #region 15 从打托区到发货区 if (!string.IsNullOrEmpty(forkliftTaskModel.nextLocatorNo))//已有目的库位 { strSuggestWareLocator = vForkliftTaskModel.nextWareNo + "," + vForkliftTaskModel.nextWareNm + "," + vForkliftTaskModel.nextLocatorNo + "," + vForkliftTaskModel.nextWareLocatorNm; } else { //获取发货区的所有库位 dtWareLocator = wareLocatorBB.GetVList("wareType='08' and isUsing=0 and isDel=0").Tables[0]; if (dtWareLocator.Rows.Count > 0) { strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString() + "," + dtWareLocator.Rows[0]["wareNm"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString(); //更改叉车任务的目的库位信息 forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区 forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位 forkliftTaskBB.ModifyRecord(forkliftTaskModel); //更改目的库位的使用状态 commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='" + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "'"); } } #endregion 15 从打托区到发货区 } else if (forkliftTaskModel.taskType == "20") { #region 20的时候 正式出库 if (!string.IsNullOrEmpty(forkliftTaskModel.nextLocatorNo))//已有目的库位 { strSuggestWareLocator = vForkliftTaskModel.nextWareNo + "," + vForkliftTaskModel.nextWareNm + "," + vForkliftTaskModel.nextLocatorNo + "," + vForkliftTaskModel.nextWareLocatorNm; } else { //获取发货区的所有库位 dtWareLocator = wareLocatorBB.GetVList("wareType='11' and isUsing=0 and isDel=0").Tables[0]; if (dtWareLocator.Rows.Count > 0) { strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString() + "," + dtWareLocator.Rows[0]["wareNm"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString(); //更改叉车任务的目的库位信息 forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区 forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位 forkliftTaskBB.ModifyRecord(forkliftTaskModel); //更改目的库位的使用状态 //commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='" // + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "'"); } } #endregion 20 正式库区发货 } else if (forkliftTaskModel.taskType == "30") { //2015-08-07进行修改 #region 退货区生成叉车任务获取相应的库位 dtWareLocator = wareLocatorBB.GetVList("wareType='09' and isUsing=0 and isDel=0 and wareNO = 'YCQ'").Tables[0]; if (dtWareLocator.Rows.Count > 0) { strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString() + "," + dtWareLocator.Rows[0]["wareNm"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString(); //更改叉车任务的目的库位信息 forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区 forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位 forkliftTaskBB.ModifyRecord(forkliftTaskModel); #endregion } } } finally { forkliftTaskBB.Dispose(); wareLocatorBB.Dispose(); commBB.Dispose(); } return strSuggestWareLocator; }
public void UpdateOutStockPalletEffectInfo(string strStockUpBillNo, string strPalletNo, string strNextWareNo, string strNextWareLocatorNo) { BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB(); UStockBB stockBB = new UStockBB(); try { DataTable dtStock = new DataTable(); BForkliftTaskData forkliftTaskModel = new BForkliftTaskData(); //获取托盘库存信息 dtStock = stockBB.GetList("palletNo='" + strPalletNo + "'").Tables[0]; forkliftTaskModel.taskType = "05";//任务类型为:从正式库区到拣货工作区 forkliftTaskModel.palletNo = strPalletNo;//托盘号 //源库位信息 if (dtStock.Rows.Count > 0) { forkliftTaskModel.preWareNo = dtStock.Rows[0]["wareNo"].ToString();//源库区 forkliftTaskModel.preLocatorNo = dtStock.Rows[0]["wareLocatorNo"].ToString();//源库位 } forkliftTaskModel.nextWareNo = strNextWareNo;//目的库区 forkliftTaskModel.nextLocatorNo = strNextWareLocatorNo;//目的库位 forkliftTaskModel.effectDt = System.DateTime.Now.ToString();//生效时间 forkliftTaskModel.isDeal = false;//是否处理 forkliftTaskModel.stockUpBillNo = strStockUpBillNo;//备货单编号 forkliftTaskBB.AddRecord(forkliftTaskModel); } finally { forkliftTaskBB.Dispose(); stockBB.Dispose(); } }
/// <summary> /// 更新一条"叉车任务信息"信息 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BForkliftTaskData model) { bool ret = false; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransModify"); this.forkliftTaskBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } this.forkliftTaskBB.ModifyRecord(model); SOperatDiaryData operatDiaryData = new SOperatDiaryData(); operatDiaryData.empId = this.empId; operatDiaryData.functionId = ""; operatDiaryData.recordId = model.id.ToString(); operatDiaryData.operateContent = "叉车任务信息修改一条id为“" + model.id.ToString() + "”的记录"; this.operatDiaryBB.AddRecord(operatDiaryData); if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransModify"); SErrorDiaryData errorDiaryData = new SErrorDiaryData(); errorDiaryData.empId = this.empId; errorDiaryData.functionId = ""; errorDiaryData.errorText = "叉车任务信息修改记录“" + model.id.ToString() + "”时报错:" + ex.Message; this.errorDiaryBB.AddRecord(errorDiaryData); throw ex; } finally { } return ret; }
public bool ExecuteEffectForkliftTask(int taskId, int empId) { BForkliftTaskBC forkliftTaskBC = new BForkliftTaskBC(); BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB(); try { BForkliftTaskData forkliftTaskModel = new BForkliftTaskData(); bool isSuccess = false; //叉车任务信息 forkliftTaskModel = forkliftTaskBB.GetModel(taskId); forkliftTaskBC.EmpID = empId; isSuccess = forkliftTaskBC.ExecuteEffectForkliftTask(taskId); if (isSuccess) { //生成SAP入库单 //if (forkliftTaskModel.taskType == "03" || forkliftTaskModel.taskType == "11") //{ // this.SAPInStock(forkliftTaskModel.palletNo); //} //else if (forkliftTaskModel.taskType == "07") //{ // //生成SAP出库单 // this.SAPOutStock(forkliftTaskModel.palletNo); //} } return isSuccess; } finally { forkliftTaskBC.Dispose(); forkliftTaskBB.Dispose(); } }
/// <summary> /// 执行叉车任务 /// </summary> /// <returns></returns> public bool ExecuteEffectForkliftTask(int taskId) { bool ret = false; SqlTransaction trans = null; SCommBB commBB = new SCommBB(this.connection); BTallyBillBB tallyBillBB = new BTallyBillBB(this.connection); UStockBB stockBB = new UStockBB(this.connection); UStockOutInDetailBB stockOutInDetailBB = new UStockOutInDetailBB(this.connection); BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection); BTallyBillDetailBB tallyBillDetailBB = new BTallyBillDetailBB(); LMaterialBB materialBB = new LMaterialBB(); LWareLocatorBB wareLocatorBB = new LWareLocatorBB(); LWareBB wareBB = new LWareBB(); CPickOutPlanBB pickOutPlanBB = new CPickOutPlanBB(); CDEPickOutBoxBB DEPickOutBoxBB = new CDEPickOutBoxBB(this.connection); try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransSave"); this.forkliftTaskBB.Transaction = trans; commBB.Transaction = trans; tallyBillBB.Transaction = trans; stockBB.Transaction = trans; stockOutInDetailBB.Transaction = trans; arrangeBillBoxBB.Transaction = trans; DEPickOutBoxBB.Transaction = trans; } else { this.forkliftTaskBB.Transaction = this.transaction; commBB.Transaction = this.transaction; tallyBillBB.Transaction = this.transaction; stockBB.Transaction = this.transaction; stockOutInDetailBB.Transaction = this.transaction; arrangeBillBoxBB.Transaction = this.transaction; DEPickOutBoxBB.Transaction = this.transaction; } BForkliftTaskData forkliftTaskModel = new BForkliftTaskData(); UStockData stockModel = new UStockData(); UStockOutInDetailData stockOutInDetailModel = new UStockOutInDetailData(); DataTable dtPreWare = new DataTable(); DataTable dtNextWare = new DataTable(); DataTable dtBox = new DataTable(); DataTable dtMaterial = new DataTable(); DataTable dtPallet = new DataTable(); string strSql = ""; #region 修改叉车任务的处理信息 //修改叉车任务的处理信息 forkliftTaskModel = forkliftTaskBB.GetModel(taskId); forkliftTaskModel.isDeal = true; forkliftTaskModel.dealEmpId = this.empId; forkliftTaskModel.dealDt = System.DateTime.Now.ToString(); //if (forkliftTaskModel.taskType == "01") //{ //} //forkliftTaskBB.ModifyRecord(forkliftTaskModel); #endregion 修改叉车任务的处理信息 //获取源库区信息 dtPreWare = wareBB.GetList("wareNo='" + forkliftTaskModel.preWareNo + "'").Tables[0]; //获取目的库区信息 dtNextWare = wareBB.GetList("wareNo='" + forkliftTaskModel.nextWareNo + "'").Tables[0]; //获取托盘上的所有物料箱 dtPallet = arrangeBillBoxBB.GetList("palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''").Tables[0]; //2015-01-30 添加 用于增加备货单号 if (forkliftTaskModel.taskType == "01") { if (dtPallet.Rows.Count > 0) { forkliftTaskModel.stockUpBillNo = dtPallet.Rows[0]["arriveBillNo"].ToString(); } } forkliftTaskBB.ModifyRecord(forkliftTaskModel); if (dtPallet.Rows.Count == 0) { //如果托盘上没有箱,释放库位 commBB.ExecuteSql("update dbo.LWareLocator set isUsing=0 where wareLocatorNo='" + forkliftTaskModel.nextLocatorNo + "'"); } #region 更改箱子库位 //更改流利货架拣货箱库位信息 commBB.ExecuteSql("update dbo.CDEPickOutBox set isOutStock=1,updtDt=getDate(),updtEmpId=" + this.EmpID.ToString() + " where palletNo='" + forkliftTaskModel.palletNo + "' and isOutStock=0"); //更改排托箱库位信息 commBB.ExecuteSql("update dbo.BArrangeBillBox set preWareNo=wareNo,wareNo='" + forkliftTaskModel.nextWareNo + "',preWareLocatorNo=wareLocatorNo,wareLocatorNo='" + forkliftTaskModel.nextLocatorNo + "' where palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''"); #endregion 更改箱子库位 //释放源库位 commBB.ExecuteSql("update dbo.LWareLocator set isUsing=0 where wareLocatorNo='" + forkliftTaskModel.preLocatorNo + "'"); if (forkliftTaskModel.taskType == "03" || forkliftTaskModel.taskType == "11") { #region 从理货区到正式库区、从质检区到正式库区(非标准箱) object obj = null; int tallyBillId = 0; BTallyBillData tallyBillModel = new BTallyBillData(); obj = commBB.ExecuteScalar("select top 1 id from dbo.BTallyBill where palletNo='" + forkliftTaskModel.palletNo + "' and instantState='02' order by id desc"); if (obj != null) { #region 修改排托单信息 tallyBillId = Convert.ToInt32(obj); tallyBillModel = tallyBillBB.GetModel(tallyBillId); tallyBillModel.instantState = "03";//指定状态为“已入库” tallyBillModel.isInStock = true;// 入库状态 tallyBillModel.wareNo = forkliftTaskModel.nextWareNo;//库区 tallyBillModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位 tallyBillBB.ModifyRecord(tallyBillModel); #endregion 修改排托单信息 } #region 出入库和出入库明细数据操作 if (dtNextWare.Rows[0]["wareSortNo"].ToString() != "D" && dtNextWare.Rows[0]["wareSortNo"].ToString() != "E") { dtBox = arrangeBillBoxBB.GetVList("palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''").Tables[0]; for (int i = 0; i < dtBox.Rows.Count; i++) { dtMaterial = materialBB.GetList("materialNo='" + dtBox.Rows[i]["materialNo"].ToString() + "'").Tables[0]; //保存库存明细数据 stockModel = new UStockData(); stockModel.wareNo = forkliftTaskModel.nextWareNo;//仓库 stockModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位 stockModel.stockDt = System.DateTime.Today.ToString();//库存日期 stockModel.palletNo = forkliftTaskModel.palletNo;//托盘号 stockModel.materialNo = dtBox.Rows[i]["materialNo"].ToString();//物料编号 stockModel.boxNo = dtBox.Rows[i]["boxNo"].ToString();//箱号 stockModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量 stockModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量 stockModel.num = Convert.ToDouble(dtBox.Rows[i]["leavingNum"]) + Convert.ToDouble(dtBox.Rows[i]["DEPickOutNum"]);//数量 stockModel.isOutStocking = false;//是否正在出库 stockModel.stockMark = "从理到正式库2"; stockModel.isrtDt = System.DateTime.Now.ToString();//操作时间 stockModel.isrtEmpId = this.EmpID;//操作人 stockBB.AddRecord(stockModel); //保存出入库明细数据 stockOutInDetailModel = new UStockOutInDetailData(); stockOutInDetailModel.billNo = dtBox.Rows[i]["arriveBillNo"].ToString();//单据编号 stockOutInDetailModel.outInType = "05";//理货入库 stockOutInDetailModel.isOut = false;//是否出库 stockOutInDetailModel.stockDt = System.DateTime.Today.ToString();//库存日期 stockOutInDetailModel.dt = System.DateTime.Today.ToString();//操作日期 stockOutInDetailModel.wareNo = forkliftTaskModel.nextWareNo;//仓库 stockOutInDetailModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位 stockOutInDetailModel.salverNo = forkliftTaskModel.palletNo;//托盘号 stockOutInDetailModel.boxNo = dtBox.Rows[i]["boxNo"].ToString();//箱号 stockOutInDetailModel.materialNo = dtBox.Rows[i]["materialNo"].ToString();//物料编号 stockOutInDetailModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量 stockOutInDetailModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量 stockOutInDetailModel.num = Convert.ToDouble(dtBox.Rows[i]["leavingNum"]) + Convert.ToDouble(dtBox.Rows[i]["DEPickOutNum"]);//数量 stockOutInDetailModel.isrtEmpId = this.empId; stockOutInDetailModel.isrtDt = System.DateTime.Now.ToString(); stockOutInDetailBB.AddRecord(stockOutInDetailModel); //更改排托箱入库信息 commBB.ExecuteSql("update dbo.BArrangeBillBox set inStockDt=getDate(),inStockEmpId=" + this.EmpID.ToString() + ",inStockNum='" + stockOutInDetailModel.num.ToString() + "' where boxNo='" + stockOutInDetailModel.boxNo + "' and isnull(wareNo,'')<>'' and inStockDt is null"); } } //更改排托箱检测结果 commBB.ExecuteSql("update dbo.BArrangeBillBox set checkResult=1,checkResultDt=getDate(),checkResultEmpId=" + this.EmpID.ToString() + " where palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>'' and checkResult=0 and checkResultDt is null"); #endregion 出入库和出入库明细数据操作 #endregion 从理货区到正式库区、从质检区到正式库区 } else if (forkliftTaskModel.taskType == "05") { #region 05 从正式库区到拣货区 //更改排托箱库位信息-库位赋值原库位 //commBB.ExecuteSql("update dbo.BArrangeBillBox set wareNo=preWareNo,wareLocatorNo=preWareLocatorNo where palletNo='" // + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''"); //锁定原库位 //commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='" // + forkliftTaskModel.preLocatorNo + "'"); #endregion 05 从正式库区到拣货区 } else if (forkliftTaskModel.taskType == "06") { #region 从拣货区到正式库区 //库存处理放在包装线体上 ////获取托盘箱明细 //dtBox = arrangeBillBoxBB.GetVList("palletNo='" + forkliftTaskModel.palletNo // + "' and isnull(wareNo,'')<>''").Tables[0]; //if (dtNextWare.Rows[0]["wareSortNo"].ToString() != "D" // && dtNextWare.Rows[0]["wareSortNo"].ToString() != "E") //{ // for (int i = 0; i < dtBox.Rows.Count; i++) // { // //保存库存明细数据 // stockModel = new UStockData(); // stockModel.wareNo = forkliftTaskModel.nextWareNo;//仓库 // stockModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位 // stockModel.stockDt = System.DateTime.Today.ToString();//库存日期 // stockModel.palletNo = forkliftTaskModel.palletNo;//托盘号 // stockModel.materialNo = dtBox.Rows[i]["materialNo"].ToString();//物料编号 // stockModel.boxNo = dtBox.Rows[i]["boxNo"].ToString();//箱号 // stockModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量 // stockModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量 // stockModel.num = Convert.ToDouble(dtBox.Rows[i]["leavingNum"]) // + Convert.ToDouble(dtBox.Rows[i]["DEPickOutNum"]);//数量 // //stockModel.isOutStocking = Convert.ToBoolean(dtBox.Rows[i]["isOutStocking"]);//是否正在出库 // stockModel.isOutStocking = false;//是否正在出库 // stockModel.stockMark = "从拣货返回正式库"; // stockModel.isrtDt = System.DateTime.Now.ToString();//操作时间 // stockModel.isrtEmpId = this.EmpID;//操作人 // stockBB.AddRecord(stockModel); // //保存出入库明细数据 // stockOutInDetailModel = new UStockOutInDetailData(); // stockOutInDetailModel.billNo = "";//单据编号 // stockOutInDetailModel.outInType = "09";//拣货返回正式库 // stockOutInDetailModel.isOut = false;//是否出库 // stockOutInDetailModel.stockDt = System.DateTime.Today.ToString();//库存日期 // stockOutInDetailModel.dt = System.DateTime.Today.ToString();//操作日期 // stockOutInDetailModel.wareNo = forkliftTaskModel.nextWareNo;//仓库 // stockOutInDetailModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位 // stockOutInDetailModel.salverNo = forkliftTaskModel.palletNo;//托盘号 // stockOutInDetailModel.boxNo = dtBox.Rows[i]["boxNo"].ToString();//箱号 // stockOutInDetailModel.materialNo = dtBox.Rows[i]["materialNo"].ToString();//物料编号 // stockOutInDetailModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量 // stockOutInDetailModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量 // stockOutInDetailModel.num = Convert.ToDouble(dtBox.Rows[i]["leavingNum"]) // + Convert.ToDouble(dtBox.Rows[i]["DEPickOutNum"]);//数量 // stockOutInDetailBB.AddRecord(stockOutInDetailModel); // //更改物料箱是否正在出库状态 // commBB.ExecuteSql("update dbo.BArrangeBillBox set isOutStocking=0 where boxNo='" // + dtBox.Rows[i]["boxNo"].ToString() + "'"); // //更改排托箱入库信息 // commBB.ExecuteSql("update dbo.BArrangeBillBox set inStockDt=getDate(),inStockEmpId=" // + this.EmpID.ToString() + ",inStockNum='" + stockOutInDetailModel.num.ToString() // + "' where boxNo='" + stockOutInDetailModel.boxNo // + "' and isnull(wareNo,'')<>'' and inStockDt is null"); // } //} #endregion 从拣货区到正式库区 } else if (forkliftTaskModel.taskType == "07") { #region 从拣货区出库 //根据托盘号,更改备货单明细的状态(05 出库完成) strSql = "update dbo.CStockUpDetail set instantState='05' where palletNo='" + forkliftTaskModel.palletNo + "'"; commBB.ExecuteSql(strSql); //如果备货单明细的状态全部为“05 出库完成”,更改备货单状态为“10 出库完成” strSql = @"update dbo.CStockUpBill set instantState='10' where not exists(select 1 from dbo.CStockUpDetail as t where t.stockUpBillNo=dbo.CStockUpBill.stockUpBillNo and instantState<>'05')"; commBB.ExecuteSql(strSql); //如果备货单明细的状态不全为“05 出库完成”,更改备货单状态为“09 出库中” strSql = @"update dbo.CStockUpBill set instantState='09' where exists(select 1 from dbo.CStockUpDetail as t where t.stockUpBillNo=dbo.CStockUpBill.stockUpBillNo and instantState<>'05')"; commBB.ExecuteSql(strSql); #endregion 从拣货区出库 } else if (forkliftTaskModel.taskType == "09") { #region 从排托区返回收货区 //更改到货箱库位信息 commBB.ExecuteSql("update dbo.BArrangeBillBox set isPalletUsing=0 where palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''"); #endregion 从排托区返回收货区 } else if (forkliftTaskModel.taskType == "10") { #region 从收货区到质检区(非标准箱) //更改到货箱库位信息 //commBB.ExecuteSql("update dbo.BArrangeBillBox set isPalletUsing=0 where palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo)<>''"); #endregion 从收货区到质检区(非标准箱) } else if (forkliftTaskModel.taskType == "12") { #region 移库处理 #region 源库区、库位处理 //释放源正式库位 commBB.ExecuteSql("update dbo.LWareLocator set isUsing=0 where wareLocatorNo='" + forkliftTaskModel.preLocatorNo + "'"); //如果从正式库出,删除库存明细 if (dtPreWare.Rows[0]["wareType"].ToString() == "03")//正式库区 { //删除库存明细(处理逻辑以后更改成正常的出入库明细) commBB.ExecuteSql("delete from dbo.UStock where palletNo='" + forkliftTaskModel.palletNo + "'"); //增加出入库明细-出库 } #endregion 源库区、库位处理 #region 目的库区、库位处理 //占用目的库位 commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='" + forkliftTaskModel.nextLocatorNo + "'"); if (dtNextWare.Rows[0]["wareType"].ToString() == "03")//正式库区 { //DataTable dtDEPickOutBox = new DataTable(); ////获取原托盘所在库位 //dtArrangeBillBox = arrangeBillBoxBB.GetList("palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''").Tables[0]; ////获取流利货架拣货箱信息 //dtDEPickOutBox = DEPickOutBoxBB.GetList("palletNo='" + forkliftTaskModel.palletNo + "' and isOutStock=0").Tables[0]; ////排托箱信息入正式库 //for (int i = 0; i < dtArrangeBillBox.Rows.Count; i++) //{ // dtMaterial = materialBB.GetList("materialNo='" + dtArrangeBillBox.Rows[i]["materialNo"].ToString() + "'").Tables[0]; // //保存库存明细数据 // stockModel = new UStockData(); // stockModel.wareNo = forkliftTaskModel.nextWareNo;//仓库 // stockModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位 // stockModel.stockDt = System.DateTime.Today.ToString();//库存日期 // stockModel.palletNo = forkliftTaskModel.palletNo;//托盘号 // stockModel.materialNo = dtArrangeBillBox.Rows[i]["materialNo"].ToString();//物料编号 // stockModel.boxNo = dtArrangeBillBox.Rows[i]["boxNo"].ToString();//箱号 // stockModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量 // stockModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量 // stockModel.num = Convert.ToDouble(dtArrangeBillBox.Rows[i]["leavingNum"]) + Convert.ToDouble(dtArrangeBillBox.Rows[i]["DEPickOutNum"]);//数量 // stockModel.isOutStocking = false;//是否正在出库 // stockModel.stockMark = "移库(正式箱)"; // stockBB.AddRecord(stockModel); //} ////流利货架拣货箱信息入正式库 //for (int i = 0; i < dtDEPickOutBox.Rows.Count; i++) //{ // dtMaterial = materialBB.GetList("materialNo='" + dtDEPickOutBox.Rows[i]["materialNo"].ToString() + "'").Tables[0]; // //保存库存明细数据 // stockModel = new UStockData(); // stockModel.wareNo = forkliftTaskModel.nextWareNo;//仓库 // stockModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位 // stockModel.stockDt = System.DateTime.Today.ToString();//库存日期 // stockModel.palletNo = forkliftTaskModel.palletNo;//托盘号 // stockModel.materialNo = dtDEPickOutBox.Rows[i]["materialNo"].ToString();//物料编号 // stockModel.boxNo = dtDEPickOutBox.Rows[i]["boxNo"].ToString();//箱号 // stockModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量 // stockModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量 // stockModel.num = Convert.ToDouble(dtDEPickOutBox.Rows[i]["num"]);//数量 // stockModel.isOutStocking = false;//是否正在出库 // stockModel.stockMark = "移库(拣货箱)"; // stockBB.AddRecord(stockModel); //} } #endregion 目的库区、库位处理 #endregion 移库处理 } else if (forkliftTaskModel.taskType == "20") { //托盘出库 DataTable dt = new DataTable(); dt = arrangeBillBoxBB.GetListOnlyStockUpBillNO("palletNo ='" + forkliftTaskModel.palletNo + "' and ISNULL(stockUpBillNo,'')<>''").Tables[0]; commBB.ExecuteSql("update dbo.BArrangeBillBox set oldPalletNo=palletNo,palletNo='',preWareNo=wareNo,wareNo='',preWareLocatorNo=wareLocatorNo,wareLocatorNo=''," + "outStockDt=getDate(),outStockEmpId=" + this.EmpID.ToString() + " where palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''"); commBB.ExecuteSql("update dbo.LWareLocator set isUsing=0 where wareLocatorNo='" + forkliftTaskModel.preLocatorNo + "'"); for (int i = 0; i < dt.Rows.Count; i++) { strSql = @"update dbo.CStockUpDetail set instantState='05' where stockUpBillNo ='" + dt.Rows[i]["stockUpBillNo"].ToString() + "'"; commBB.ExecuteSql(strSql); //如果备货单明细的状态全部为“05 出库完成”,更改备货单状态为“10 出库完成”,并且是关联到一个被货单的形式下 strSql = @"update dbo.CStockUpBill set instantState='10' where stockUpBillNo = '" + dt.Rows[i]["stockUpBillNO"].ToString() + "'"; commBB.ExecuteSql(strSql); } } else if (forkliftTaskModel.taskType == "30")//从质检区到异常区 { //首先作出库处理 //string command = @"Update BArrangeBillBox set oldPalletNo=palletNo,palletNo='',preWareNo=wareNo,wareNo='YCQ',preWareLocatorNo=wareLocatorNo,wareLocatorNo='N01.01'," // + "outStockDt=getDate(),outStockEmpId=" + this.EmpID.ToString() // + " where palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''"; //commBB.ExecuteSql(command); DataSet ds = commBB.Query("select palletNo from BArrangeBillBox where wareLocatorNo = '" + forkliftTaskModel.preLocatorNo + "' group by palletNo"); if (ds.Tables[0].Rows.Count <= 1) { commBB.ExecuteSql("Update dbo.LWareLocator set isUsing=0 where wareLocatorNo='" + forkliftTaskModel.preLocatorNo + "'"); } commBB.ExecuteSql("Update dbo.LWareLocator set isUsing=0 where wareLocatorNo='" + forkliftTaskModel.nextLocatorNo + "'");//N01.01不占用 } if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransSave"); throw ex; } finally { commBB.Dispose(); tallyBillBB.Dispose(); stockBB.Dispose(); stockOutInDetailBB.Dispose(); tallyBillDetailBB.Dispose(); arrangeBillBoxBB.Dispose(); materialBB.Dispose(); wareLocatorBB.Dispose(); wareBB.Dispose(); pickOutPlanBB.Dispose(); DEPickOutBoxBB.Dispose(); } return ret; }
/// <summary> /// 增加一条"叉车任务信息"信息 /// </summary> /// <param name="model">model</param> public int AddRecord(BForkliftTaskData model) { int id = 0; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransAdd"); this.forkliftTaskBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } id = this.forkliftTaskBB.AddRecord(model); SOperatDiaryData operatDiaryData = new SOperatDiaryData(); operatDiaryData.empId = this.empId; operatDiaryData.functionId = ""; operatDiaryData.recordId = id.ToString(); operatDiaryData.operateContent = "叉车任务信息增加一条id为“" + id.ToString() + "”的记录"; this.operatDiaryBB.AddRecord(operatDiaryData); if (this.transaction == null) trans.Commit(); } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransAdd"); SErrorDiaryData errorDiaryData = new SErrorDiaryData(); errorDiaryData.empId = this.empId; errorDiaryData.functionId = ""; errorDiaryData.errorText = "叉车任务信息增加记录时报错:" + ex.Message; this.errorDiaryBB.AddRecord(errorDiaryData); throw ex; } finally { } return id; }
/// <summary> /// 保存叉车任务信息 /// </summary> /// <param name="strPalletNo">托盘条码号</param> /// <param name="strNextWareNo">目的库区编码</param> /// <param name="strNextWareLocatorNo">目的库位编码</param> /// <param name="strTaskType">任务类型</param> /// <param name="isrtEmpId">添加人</param> /// <returns></returns> public bool SaveForkliftTaskWithTHD(string strPalletNo, string strNextWareNo, string strNextWareLocatorNo, string strTaskType, int isrtEmpId,string THD) { bool ret = false; SqlTransaction trans = null; SCommBB commBB = new SCommBB(this.connection); BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection); try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransSave"); this.forkliftTaskBB.Transaction = trans; commBB.Transaction = trans; arrangeBillBoxBB.Transaction = trans; } else { this.forkliftTaskBB.Transaction = this.transaction; commBB.Transaction = this.transaction; arrangeBillBoxBB.Transaction = this.transaction; } DataSet dsArrangeBillBox = new DataSet(); DataTable dtWareLocator = new DataTable(); DataTable dtForkliftTask = new DataTable(); BForkliftTaskData forkliftTaskModel = new BForkliftTaskData(); StringBuilder strSql = new StringBuilder(); //获取原托盘的未执行的叉车任务 dtForkliftTask = forkliftTaskBB.GetList("palletNo='" + strPalletNo + "' and isDeal=0").Tables[0]; if (dtForkliftTask.Rows.Count == 0) { string strBoxNo = ""; //获取原托盘所在库位 dsArrangeBillBox = arrangeBillBoxBB.GetList("palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''"); #region 保存叉车任务 //保存叉车任务 forkliftTaskModel.taskType = strTaskType;//任务类型 forkliftTaskModel.palletNo = strPalletNo;//托盘条码号 strBoxNo = dsArrangeBillBox.Tables[0].Rows[dsArrangeBillBox.Tables[0].Rows.Count - 1]["boxNo"].ToString(); forkliftTaskModel.preWareNo = dsArrangeBillBox.Tables[0].Rows[dsArrangeBillBox.Tables[0].Rows.Count - 1]["wareNo"].ToString();//源库位编码 forkliftTaskModel.preLocatorNo = dsArrangeBillBox.Tables[0].Rows[dsArrangeBillBox.Tables[0].Rows.Count - 1]["wareLocatorNo"].ToString();//源库位编码 if (strTaskType == "04" || strTaskType == "06" || strTaskType == "09")//04 从理货区返回质检区,09 从平台返回收货区 { //获取排托区返回库位信息 strSql.Append(@"select wareLocator.wareNo,wareLocator.returnWareLocatorNo as wareLocatorNo "); strSql.Append(@"from dbo.BArrangeBillBox as arrangeBillBoxBox "); strSql.Append(@"left join dbo.LWareLocator as wareLocator on wareLocator.wareLocatorNo=arrangeBillBoxBox.wareLocatorNo "); strSql.Append(@"where arrangeBillBoxBox.boxNo='" + strBoxNo + "'"); dtWareLocator = commBB.Query(strSql.ToString()).Tables[0]; if (dtWareLocator.Rows.Count > 0 && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "") { //源库位信息 forkliftTaskModel.preWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//源库区编码 forkliftTaskModel.preLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//源库位编码 } } else if (strTaskType == "01" || strTaskType == "03")//01 从排托区到质检区,03 从理货区到正式库区 { //获取排托区下线库位信息 strSql.Append(@"select wareLocator.wareNo,wareLocator.downWareLocatorNo as wareLocatorNo "); strSql.Append(@"from dbo.BArrangeBillBox as arrangeBillBoxBox "); strSql.Append(@"left join dbo.LWareLocator as wareLocator on wareLocator.wareLocatorNo=arrangeBillBoxBox.wareLocatorNo "); strSql.Append(@"where arrangeBillBoxBox.boxNo='" + strBoxNo + "'"); dtWareLocator = commBB.Query(strSql.ToString()).Tables[0]; if (dtWareLocator.Rows.Count > 0 && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "") { //源库位信息 forkliftTaskModel.preWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//源库区编码 forkliftTaskModel.preLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//源库位编码 } } else if (strTaskType == "06")//06 从拣货区返回正式库区 { DataTable dtForkliftTask_Last = new DataTable(); DataTable dtStockUpBill = new DataTable(); //获取叉车任务的上个库位 dtForkliftTask = commBB.Query("select top 1 * from dbo.BForkliftTask order by id desc").Tables[0]; if (dtForkliftTask.Rows.Count > 0) { //获取排托区返回库位信息 strSql.Append(@"select wareLocator.wareNo,wareLocator.returnWareLocatorNo as wareLocatorNo "); strSql.Append(@" from dbo.LWareLocator as wareLocator where wareLocator.wareLocatorNo='" + dtForkliftTask.Rows[0]["nextLocatorNo"].ToString() + "' "); dtWareLocator = commBB.Query(strSql.ToString()).Tables[0]; if (dtWareLocator.Rows.Count > 0 && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "") { //源库位信息 forkliftTaskModel.preWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//源库区编码 forkliftTaskModel.preLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//源库位编码 } } else if (strTaskType == "20")//暂定20 用来作为叉车出库 { //叉车出库 //出库操作 strSql.Append(@"select wareLocator.wareNo,wareLocator.returnWareLocatorNo as wareLocatorNo "); strSql.Append(@"from dbo.BArrangeBillBox as arrangeBillBoxBox "); strSql.Append(@"left join dbo.LWareLocator as wareLocator on wareLocator.wareLocatorNo=arrangeBillBoxBox.wareLocatorNo "); strSql.Append(@"where arrangeBillBoxBox.boxNo='" + strBoxNo + "'"); dtWareLocator = commBB.Query(strSql.ToString()).Tables[0]; if (dtWareLocator.Rows.Count > 0 && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "") { //源库位信息 forkliftTaskModel.preWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//源库区编码 forkliftTaskModel.preLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//源库位编码 } } //获取备货单号 dtStockUpBill = commBB.Query("select top 1 stockUpBillNo from dbo.BForkliftTask where palletNo='" + strPalletNo + "' and taskType='05' order by id desc").Tables[0]; if (dtStockUpBill.Rows.Count > 0) { forkliftTaskModel.stockUpBillNo = dtStockUpBill.Rows[0]["stockUpBillNo"].ToString(); } } //2015-02-03增加退货单号 用来进行后期的查询 if (forkliftTaskModel.taskType == "30") { forkliftTaskModel.stockUpBillNo = THD; } //目的库区编码 if (strNextWareNo != "") { forkliftTaskModel.nextWareNo = strNextWareNo; } //目的库位编码 if (strNextWareLocatorNo != "") { forkliftTaskModel.nextLocatorNo = strNextWareLocatorNo; } forkliftTaskModel.effectDt = System.DateTime.Now.ToString();//生效时间 forkliftTaskModel.isDeal = false;//是否处理 forkliftTaskModel.isrtDt = System.DateTime.Now.ToString();//添加时间 forkliftTaskModel.isrtEmpId = isrtEmpId;//添加人 forkliftTaskBB.AddRecord(forkliftTaskModel);//添加叉车任务信息 #endregion 保存叉车任务 #region 更改辅助信息 //更新目的库区占用状态 if (strNextWareLocatorNo != "") { //更改库位的使用状态 commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='" + strNextWareLocatorNo + "'"); } if (strTaskType == "08" || strTaskType == "12")//从收货区到排托区、托盘移库 { //更改到货箱的托盘使用状态(已使用) commBB.ExecuteSql("update dbo.BArrangeBillBox set isPalletUsing=1 where palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''"); } #endregion 更改辅助信息 } if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransSave"); throw ex; } finally { commBB.Dispose(); arrangeBillBoxBB.Dispose(); } return ret; }
//***************************************************************************** //do it later do it later do it later //***************************************************************************** /// <summary> /// 保存排托收货单信息 /// </summary> /// <param name="strArrangeBillNo">排托单号</param> /// <param name="strArriveBillNo">到货单号</param> /// <param name="strFinanceBillNos">采购订单编号组合</param> /// <param name="strPalletIndex">托盘序号</param> /// <param name="strPalletNo">托盘号</param> /// <param name="isrtEmpId">添加人</param> /// <param name="updtEmpId">修改人</param> /// <param name="strInstantState">状态:01 收货单,02 收货已完成</param> /// <returns></returns> public bool SaveRecord(string strArrangeBillNo, string strArriveBillNo,string strFinanceBillNos, string strPalletIndex, string strPalletNo, int isrtEmpId, int updtEmpId, string strInstantState) { bool ret = false; SqlTransaction trans = null; SCommBB commBB = new SCommBB(this.connection); BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB(this.connection); BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection); try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransSave"); this.arrangeBillFactBB.Transaction = trans; commBB.Transaction = trans; forkliftTaskBB.Transaction = trans; arrangeBillBoxBB.Transaction = trans; } else { this.arrangeBillFactBB.Transaction = this.transaction; commBB.Transaction = this.transaction; forkliftTaskBB.Transaction = this.transaction; arrangeBillBoxBB.Transaction = this.transaction; } DataSet ds = new DataSet(); BArrangeBillFactData arrangeBillFactModel = new BArrangeBillFactData(); #region 维护排托收货单信息 foreach (string strFinanceBillNo in strFinanceBillNos.Split(',')) { //维护排托收货单信息 ds = arrangeBillFactBB.GetList("arrangeBillNo='" + strArrangeBillNo + "' and palletIndex='" + strPalletIndex + "' and financeBillNo='" + strFinanceBillNo + "'");//添加物料编号 if (ds.Tables[0].Rows.Count == 0) { arrangeBillFactModel = new BArrangeBillFactData(); arrangeBillFactModel.arrangeBillNo = strArrangeBillNo;//排托单号 arrangeBillFactModel.arriveBillNo = strArriveBillNo;//到货单号 arrangeBillFactModel.financeBillNo = strFinanceBillNo;//采购订单号 arrangeBillFactModel.palletIndex = strPalletIndex;//托盘序号 arrangeBillFactModel.palletNo = strPalletNo;//托盘条码号 arrangeBillFactModel.isTally = false;//是否已理货 arrangeBillFactModel.isrtEmpId = isrtEmpId;//添加人 arrangeBillFactModel.isrtDt = System.DateTime.Now.ToString();//添加时间 arrangeBillFactModel.instantState = strInstantState;//状态 arrangeBillFactBB.AddRecord(arrangeBillFactModel); } else { arrangeBillFactModel = arrangeBillFactBB.GetModel(Convert.ToInt32(ds.Tables[0].Rows[0]["id"])); if (strPalletNo != "")//如果托盘号不为空,更改托盘号 { arrangeBillFactModel.palletNo = strPalletNo;//托盘条码号 } else { strPalletNo = ds.Tables[0].Rows[0]["palletNo"].ToString();//获取托盘条码 } arrangeBillFactModel.updtDt = System.DateTime.Now.ToString();//修改时间 arrangeBillFactModel.updtEmpId = updtEmpId;//修改人 arrangeBillFactModel.instantState = strInstantState;//状态 arrangeBillFactBB.ModifyRecord(arrangeBillFactModel); } } #endregion 维护排托收货单信息 #region 更改状态 //更改状态 if (strInstantState == "01")//排托中 { //更改排托单明细状态为“02 排托中” commBB.ExecuteSql("update dbo.BArrangeBillDetail set instantState='02' where arriveBillNo='" + strArriveBillNo + "' and palletIndex='" + strPalletIndex + "'"); //更改排托单状态为“03 排托中” commBB.ExecuteSql("update dbo.BArrangeBill set instantState='03' where arriveBillNo='" + strArriveBillNo + "'"); //更改到货单状态为“04 排托中” commBB.ExecuteSql("update dbo.BArriveBill set instantState='04' where billNo='" + strArriveBillNo + "'"); } else if (strInstantState == "02")//排托已完成 { #region 更改单据状态 //更改排托单明细状态为“03 排托已完成” commBB.ExecuteSql("update dbo.BArrangeBillDetail set instantState='03' where arriveBillNo='" + strArriveBillNo + "' and palletIndex='" + strPalletIndex + "'"); //如果排托单明细全部排托已完成,更改排托单状态为“排托已完成” commBB.ExecuteSql("update dbo.BArrangeBill set instantState='04' where arriveBillNo='" + strArriveBillNo + "' and not exists (select 1 from dbo.BArrangeBillDetail where dbo.BArrangeBill.arriveBillNo=dbo.BArrangeBillDetail.arriveBillNo and isnull(dbo.BArrangeBillDetail.instantState,'')<>'03')"); //如果排托单明细全部排托已完成,更改到货单状态为“排托已完成” commBB.ExecuteSql(@"update dbo.BArriveBill set instantState='05' where billNo='" + strArriveBillNo + "' and not exists (select 1 from dbo.BArrangeBillDetail where dbo.BArriveBill.billNo=dbo.BArrangeBillDetail.arriveBillNo and isnull(dbo.BArrangeBillDetail.instantState,'')<>'03')"); #endregion 更改单据状态 #region 生成叉车任务 //首先判断当前托盘存在未执行的叉车任务 DataTable dtForkliftTask = new DataTable(); dtForkliftTask = forkliftTaskBB.GetList("palletNo='" + strPalletNo + "' and isDeal=0").Tables[0]; if (dtForkliftTask.Rows.Count == 0) { BForkliftTaskData forkliftTaskModel = new BForkliftTaskData(); DataSet dsArrangeBillBox = new DataSet(); dsArrangeBillBox = arrangeBillBoxBB.GetVList("arriveBillNo='" + strArriveBillNo + "' and palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''"); if (dsArrangeBillBox.Tables[0].Rows.Count > 0) { forkliftTaskModel = new BForkliftTaskData(); forkliftTaskModel.taskType = "01";//任务类型为:从排托区到质检区 forkliftTaskModel.palletNo = strPalletNo;//托盘号 forkliftTaskModel.preWareNo = dsArrangeBillBox.Tables[0].Rows[0]["wareNo"].ToString();//源库区 forkliftTaskModel.preLocatorNo = dsArrangeBillBox.Tables[0].Rows[0]["wareLocatorNo"].ToString();//源库位 forkliftTaskModel.effectDt = System.DateTime.Now.ToString();//生效时间 forkliftTaskModel.isDeal = false;//是否处理 forkliftTaskModel.isrtDt = System.DateTime.Now.ToString();//添加时间 forkliftTaskModel.isrtEmpId = isrtEmpId;//添加人 forkliftTaskBB.AddRecord(forkliftTaskModel); } } #endregion 生成叉车任务 } #endregion 更改状态 if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransSave"); throw ex; } finally { commBB.Dispose(); forkliftTaskBB.Dispose(); arrangeBillBoxBB.Dispose(); } return ret; }
/// <summary> /// 保存非标准箱入质检区信息 /// </summary> /// <param name="strPalletNo">托盘号</param> /// <returns></returns> public bool SaveNoStandBoxInCheckInfo(string strPalletNo) { bool ret = false; SqlTransaction trans = null; SCommBB commBB = new SCommBB(this.connection); BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB(this.connection); BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection); BArrangeBillFactDetailBB arrangeBillFactDetailBB = new BArrangeBillFactDetailBB(this.connection); try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransSave"); this.arrangeBillFactBB.Transaction = trans; commBB.Transaction = trans; forkliftTaskBB.Transaction = trans; arrangeBillBoxBB.Transaction = trans; arrangeBillFactDetailBB.Transaction = trans; } else { this.arrangeBillFactBB.Transaction = this.transaction; commBB.Transaction = this.transaction; forkliftTaskBB.Transaction = this.transaction; arrangeBillBoxBB.Transaction = this.transaction; arrangeBillFactDetailBB.Transaction = this.transaction; } DataTable dtArrangeBillBox = new DataTable(); string strArriveBillNo = "", strFinanceBillNo = ""; BArrangeBillFactData arrangeBillFactModel = new BArrangeBillFactData(); BArrangeBillFactDetailData arrangeBillFactDetailModel = new BArrangeBillFactDetailData(); BArrangeBillBoxData arrangeBillBoxModel = new BArrangeBillBoxData(); int mainId = 0; //获取到货箱信息 dtArrangeBillBox = arrangeBillBoxBB.GetList("palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''").Tables[0]; if (dtArrangeBillBox.Rows.Count > 0) { strArriveBillNo = dtArrangeBillBox.Rows[0]["arriveBillNo"].ToString();//到货单号 strFinanceBillNo = dtArrangeBillBox.Rows[0]["financeBillNo"].ToString();//采购单号 } #region 维护排托收货单信息 //维护排托收货单信息 arrangeBillFactModel.arrangeBillNo = "PT" + strArriveBillNo;//排托单号 arrangeBillFactModel.arriveBillNo = strArriveBillNo;//到货单号 arrangeBillFactModel.financeBillNo = strFinanceBillNo;//采购订单号 arrangeBillFactModel.palletIndex = "0";//托盘序号 arrangeBillFactModel.palletNo = strPalletNo;//托盘条码号 arrangeBillFactModel.isTally = false;//是否已理货 arrangeBillFactModel.isrtEmpId = this.empId;//添加人 arrangeBillFactModel.isrtDt = System.DateTime.Now.ToString();//添加时间 arrangeBillFactModel.instantState = "02";//状态 mainId = arrangeBillFactBB.AddRecord(arrangeBillFactModel); #endregion 维护排托收货单信息 #region 维护排托箱信息 foreach (DataRow row in dtArrangeBillBox.Rows) { //保存排托收货单明细信息 arrangeBillFactDetailModel = new BArrangeBillFactDetailData(); arrangeBillFactDetailModel.mainId = mainId.ToString();//排托收货单ID arrangeBillFactDetailModel.boxNo = row["boxNo"].ToString();//箱号 arrangeBillFactDetailModel.region = "0";//区域 arrangeBillFactDetailModel.isrtEmpId = this.empId; arrangeBillFactDetailModel.isrtDt = System.DateTime.Now.ToString(); arrangeBillFactDetailBB.AddRecord(arrangeBillFactDetailModel); //更改到货箱排托标志 commBB.ExecuteSql("update dbo.BArrangeBillBox set isBoxArrange=1 where boxNo='" + row["boxNo"].ToString() + "'"); } #endregion 维护排托箱信息 #region 生成叉车任务 BForkliftTaskData forkliftTaskModel = new BForkliftTaskData(); if (dtArrangeBillBox.Rows.Count > 0) { forkliftTaskModel = new BForkliftTaskData(); forkliftTaskModel.taskType = "10";//任务类型为:从收货区到质检区 forkliftTaskModel.palletNo = strPalletNo;//托盘号 forkliftTaskModel.preWareNo = dtArrangeBillBox.Rows[0]["wareNo"].ToString();//源库区 forkliftTaskModel.preLocatorNo = dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//源库位 forkliftTaskModel.effectDt = System.DateTime.Now.ToString();//生效时间 forkliftTaskModel.isDeal = false;//是否处理 forkliftTaskBB.AddRecord(forkliftTaskModel); } #endregion 生成叉车任务 if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransSave"); throw ex; } finally { commBB.Dispose(); forkliftTaskBB.Dispose(); arrangeBillBoxBB.Dispose(); arrangeBillFactDetailBB.Dispose(); } return ret; }