Exemple #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MesDBAccess.Model.palletModel DataRowToModel(DataRow row)
 {
     MesDBAccess.Model.palletModel model = new MesDBAccess.Model.palletModel();
     if (row != null)
     {
         if (row["palletID"] != null)
         {
             model.palletID = row["palletID"].ToString();
         }
         if (row["palletCata"] != null)
         {
             model.palletCata = row["palletCata"].ToString();
         }
         if (row["bind"] != null && row["bind"].ToString() != "")
         {
             if ((row["bind"].ToString() == "1") || (row["bind"].ToString().ToLower() == "true"))
             {
                 model.bind = true;
             }
             else
             {
                 model.bind = false;
             }
         }
         if (row["stepNO"] != null && row["stepNO"].ToString() != "")
         {
             model.stepNO = int.Parse(row["stepNO"].ToString());
         }
         if (row["batchName"] != null)
         {
             model.batchName = row["batchName"].ToString();
         }
         if (row["tag1"] != null)
         {
             model.tag1 = row["tag1"].ToString();
         }
         if (row["tag2"] != null)
         {
             model.tag2 = row["tag2"].ToString();
         }
         if (row["tag3"] != null)
         {
             model.tag3 = row["tag3"].ToString();
         }
         if (row["tag4"] != null)
         {
             model.tag4 = row["tag4"].ToString();
         }
         if (row["tag5"] != null)
         {
             model.tag5 = row["tag5"].ToString();
         }
     }
     return(model);
 }
Exemple #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MesDBAccess.Model.palletModel GetModel(string palletID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" palletID,palletCata,bind,stepNO,batchName,tag1,tag2,tag3,tag4,tag5 ");
            strSql.Append(" from pallet ");
            strSql.Append(" where palletID='" + palletID + "' ");
            MesDBAccess.Model.palletModel model = new MesDBAccess.Model.palletModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
 private bool AsrsTaskExtParams(List <string> cellStoreGoods, ref List <short> extParams, ref string reStr)
 {
     try
     {
         extParams = new List <short>();
         if (cellStoreGoods == null || cellStoreGoods.Count() < 1)
         {
             return(true);
         }
         string palletID = cellStoreGoods[0];
         MesDBAccess.BLL.palletBll     palletDBAcc = new MesDBAccess.BLL.palletBll();
         MesDBAccess.Model.palletModel palletM     = palletDBAcc.GetModel(palletID);
         if (palletM != null)
         {
             extParams.Add(short.Parse(palletM.palletCata));
         }
         return(true);
     }
     catch (Exception ex)
     {
         reStr = ex.ToString();
         return(false);
     }
 }
        private bool AsrsOutportBusiness(AsrsControl.AsrsPortalModel port, ref string reStr)
        {
            try
            {
                MesDBAccess.BLL.palletBll palletDBll = new MesDBAccess.BLL.palletBll();
                if (port.PortCata == 1)
                {
                    return(true);
                }

                if (port.BindedTaskOutput == SysCfg.EnumAsrsTaskType.空筐出库)
                {
                    if (port.Db2Vals[0] == 1)
                    {
                        port.Db1ValsToSnd[0] = 1;
                    }
                    return(true);
                }
                else if (port.BindedTaskOutput == SysCfg.EnumAsrsTaskType.产品出库)
                {
                    if (port.Db2Vals[1] == 1)
                    {
                        port.Db1ValsToSnd[0] = 1;
                    }
                }
                else
                {
                    return(true);
                }

                if (port.Db1ValsToSnd[0] == 2)
                {
                    return(true);
                }
                if (port.Db2Vals[1] != 2)
                {
                    return(true);
                }
                Int16 palletCata = port.Db2Vals[2];
                if (palletCata < 1 || palletCata > 3)
                {
                    return(true);
                }

                AsrsControl.AsrsCtlModel asrsCtl = port.AsrsCtl;
                string houseName = asrsCtl.HouseName;
                AsrsInterface.IAsrsManageToCtl asrsResManage = port.AsrsCtl.AsrsResManage;
                //遍历所有库位,判断材料类别,按照先入先出规则,匹配出库的货位。
                Dictionary <string, AsrsModel.GSMemTempModel> asrsStatDic = new Dictionary <string, AsrsModel.GSMemTempModel>();
                if (!asrsResManage.GetAllGsModel(ref asrsStatDic, ref reStr))
                {
                    Console.WriteLine(string.Format("{0} 获取货位状态失败", houseName));
                    return(false);
                }
                List <AsrsModel.GSMemTempModel> validCells = new List <AsrsModel.GSMemTempModel>();
                string shopRequire = "";
                if (port.NodeName == "A1库物料出口1")
                {
                    shopRequire = "1号车间";
                }
                else if (port.NodeName == "A1库物料出口2")
                {
                    shopRequire = "2号车间";
                }
                else if (port.NodeName == "A1库物料出口3")
                {
                    shopRequire = "3号车间";
                }
                //检查是否存在未执行完的任务
                List <CtlDBAccess.Model.ControlTaskModel> unFinishedTasks = GetRunningTask((int)SysCfg.EnumAsrsTaskType.产品出库, shopRequire, palletCata, ref reStr);
                if (unFinishedTasks != null && unFinishedTasks.Count() > 0)
                {
                    return(true);
                }

                int r = 1, c = 1, L = 1;
                for (r = 1; r < asrsCtl.AsrsRow + 1; r++)
                {
                    for (c = 1; c < asrsCtl.AsrsCol + 1; c++)
                    {
                        for (L = 1; L < asrsCtl.AsrsLayer + 1; L++)
                        {
                            string strKey = string.Format("{0}:{1}-{2}-{3}", houseName, r, c, L);
                            AsrsModel.GSMemTempModel cellStat = null;
                            if (!asrsStatDic.Keys.Contains(strKey))
                            {
                                continue;
                            }
                            cellStat = asrsStatDic[strKey];
                            if ((!cellStat.GSEnabled) || (cellStat.GSTaskStatus == AsrsModel.EnumGSTaskStatus.锁定.ToString()) || (cellStat.GSStatus != AsrsModel.EnumCellStatus.满位.ToString()))
                            {
                                // reStr = string.Format("货位{0}-{1}-{2}禁用,无法生成出库任务", cell.Row, cell.Col, cell.Layer);
                                continue;
                            }
                            AsrsModel.CellCoordModel cell      = new AsrsModel.CellCoordModel(r, c, L);
                            List <string>            storGoods = new List <string>();
                            if (!asrsResManage.GetStockDetail(houseName, cell, ref storGoods))
                            {
                                continue;
                            }
                            if (storGoods.Count() < 1)
                            {
                                continue;
                            }
                            MesDBAccess.Model.palletModel pallet = palletDBll.GetModel(storGoods[0]);
                            short  productCata = 0;
                            string strCataName = "";// "正极材料";

                            string shopName = "";
                            if (!PrcsCtlModelsLishen.NodeSwitchInput.ParsePalletID(storGoods[0], ref shopName, ref productCata, ref strCataName, ref reStr))
                            {
                                continue;
                            }
                            //if (pallet.palletCata == palletCata.ToString())
                            if (productCata == palletCata && shopRequire == shopName)
                            {
                                validCells.Add(cellStat);
                            }
                            //if (storGoods[0].Substring(2, 1) == palletCata.ToString())
                            //{
                            //    validCells.Add(cellStat);
                            //}
                        }
                    }
                }
                if (validCells.Count() > 0)
                {
                    //排序,按照先入先出
                    AsrsModel.GSMemTempModel firstGS = validCells[0];
                    if (validCells.Count() > 1)
                    {
                        for (int i = 1; i < validCells.Count(); i++)
                        {
                            AsrsModel.GSMemTempModel tempGS = validCells[i];
                            if (tempGS.InHouseDate < firstGS.InHouseDate)
                            {
                                firstGS = tempGS;
                            }
                        }
                    }
                    //生成出库任务
                    string[] strCellArray         = firstGS.GSPos.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
                    int      row                  = int.Parse(strCellArray[0]);
                    int      col                  = int.Parse(strCellArray[1]);
                    int      layer                = int.Parse(strCellArray[2]);
                    AsrsModel.CellCoordModel cell = new AsrsModel.CellCoordModel(row, col, layer);
                    if (asrsCtl.GenerateOutputTask(cell, port.BindedTaskOutput, true, port.PortSeq, ref reStr, new List <short> {
                        palletCata
                    }, port.AsrsTaskPri))
                    {
                        port.Db1ValsToSnd[0] = 2;
                    }
                    else
                    {
                        Console.WriteLine("生成任务{0}失败,{1}", port.BindedTaskOutput.ToString(), reStr);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                reStr = ex.ToString();
                return(false);
            }
        }
Exemple #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(MesDBAccess.Model.palletModel model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.palletID != null)
            {
                strSql1.Append("palletID,");
                strSql2.Append("'" + model.palletID + "',");
            }
            if (model.palletCata != null)
            {
                strSql1.Append("palletCata,");
                strSql2.Append("'" + model.palletCata + "',");
            }
            if (model.bind != null)
            {
                strSql1.Append("bind,");
                strSql2.Append("" + (model.bind ? 1 : 0) + ",");
            }
            if (model.stepNO != null)
            {
                strSql1.Append("stepNO,");
                strSql2.Append("" + model.stepNO + ",");
            }
            if (model.batchName != null)
            {
                strSql1.Append("batchName,");
                strSql2.Append("'" + model.batchName + "',");
            }
            if (model.tag1 != null)
            {
                strSql1.Append("tag1,");
                strSql2.Append("'" + model.tag1 + "',");
            }
            if (model.tag2 != null)
            {
                strSql1.Append("tag2,");
                strSql2.Append("'" + model.tag2 + "',");
            }
            if (model.tag3 != null)
            {
                strSql1.Append("tag3,");
                strSql2.Append("'" + model.tag3 + "',");
            }
            if (model.tag4 != null)
            {
                strSql1.Append("tag4,");
                strSql2.Append("'" + model.tag4 + "',");
            }
            if (model.tag5 != null)
            {
                strSql1.Append("tag5,");
                strSql2.Append("'" + model.tag5 + "',");
            }
            strSql.Append("insert into pallet(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MesDBAccess.Model.palletModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update pallet set ");
            if (model.palletCata != null)
            {
                strSql.Append("palletCata='" + model.palletCata + "',");
            }
            else
            {
                strSql.Append("palletCata= null ,");
            }
            if (model.bind != null)
            {
                strSql.Append("bind=" + (model.bind ? 1 : 0) + ",");
            }
            if (model.stepNO != null)
            {
                strSql.Append("stepNO=" + model.stepNO + ",");
            }
            if (model.batchName != null)
            {
                strSql.Append("batchName='" + model.batchName + "',");
            }
            else
            {
                strSql.Append("batchName= null ,");
            }
            if (model.tag1 != null)
            {
                strSql.Append("tag1='" + model.tag1 + "',");
            }
            else
            {
                strSql.Append("tag1= null ,");
            }
            if (model.tag2 != null)
            {
                strSql.Append("tag2='" + model.tag2 + "',");
            }
            else
            {
                strSql.Append("tag2= null ,");
            }
            if (model.tag3 != null)
            {
                strSql.Append("tag3='" + model.tag3 + "',");
            }
            else
            {
                strSql.Append("tag3= null ,");
            }
            if (model.tag4 != null)
            {
                strSql.Append("tag4='" + model.tag4 + "',");
            }
            else
            {
                strSql.Append("tag4= null ,");
            }
            if (model.tag5 != null)
            {
                strSql.Append("tag5='" + model.tag5 + "',");
            }
            else
            {
                strSql.Append("tag5= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where palletID='" + model.palletID + "' ");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }