Ejemplo n.º 1
0
    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;
    }