Beispiel #1
0
        ///// <summary>
        ///// db1 条码赋值
        ///// </summary>
        ///// <param name="barcode"></param>
        ///// <param name="db1StIndex">db1地址块索引起始,从0开始编号</param>
        //protected void BarcodeFillDB1(string barcode,int db1StIndex)
        //{
        //    byte[] barcodeBytes = System.Text.UTF8Encoding.Default.GetBytes(barcode);
        //    for (int i = 0; i < barcodeBytes.Count(); i++)
        //    {
        //        db1ValsToSnd[db1StIndex + i] = barcodeBytes[i];
        //    }
        //}

        ///// <summary>
        ///// 分析工位状态
        ///// </summary>
        ///// <param name="reStr"></param>
        ///// <returns></returns>
        //protected virtual bool NodeStatParse(ref string reStr)
        //{

        //    return true;
        //}
        #endregion
        #region MES接口的再封装

        /// <summary>
        /// 查询绑定数据
        /// </summary>
        /// <param name="palletID"></param>
        /// <returns></returns>
        protected bool MESGetProductsInPallet(string palletID, ref List <MesDBAccess.Model.ProductOnlineModel> batteryList, ref string reStr)
        {
            batteryList = new List <MesDBAccess.Model.ProductOnlineModel>();
            VMResultCells re = MesAcc.GetTrayBindingCell(palletID);

            if (re.ResultCode != 0)
            {
                reStr = "查询MES托盘电芯数据错误" + re.ResultMsg;
                return(false);
            }
            JObject jsonCellObj = (JObject)JsonConvert.DeserializeObject(re.Cells);

            if (jsonCellObj == null)
            {
                return(true);
            }
            for (int i = 0; i < 36; i++)
            {
                int    channel    = i + 1;
                string channelKey = "Cell" + channel.ToString();
                if (jsonCellObj[channelKey] == null)
                {
                    continue;
                }
                MesDBAccess.Model.ProductOnlineModel battery = new MesDBAccess.Model.ProductOnlineModel();
                battery.palletID     = palletID;
                battery.palletBinded = true;
                battery.tag1         = channel.ToString();
                battery.productID    = jsonCellObj[channelKey].ToString().ToUpper();
                batteryList.Add(battery);
            }
            return(true);
        }
        ///// <summary>
        ///// db1 条码赋值
        ///// </summary>
        ///// <param name="barcode"></param>
        ///// <param name="db1StIndex">db1地址块索引起始,从0开始编号</param>
        //protected void BarcodeFillDB1(string barcode,int db1StIndex)
        //{
        //    byte[] barcodeBytes = System.Text.UTF8Encoding.Default.GetBytes(barcode);
        //    for (int i = 0; i < barcodeBytes.Count(); i++)
        //    {
        //        db1ValsToSnd[db1StIndex + i] = barcodeBytes[i];
        //    }
        //}

        ///// <summary>
        ///// 分析工位状态
        ///// </summary>
        ///// <param name="reStr"></param>
        ///// <returns></returns>
        //protected virtual bool NodeStatParse(ref string reStr)
        //{

        //    return true;
        //}
        #endregion
        #region MES接口的再封装

        /// <summary>
        /// 查询绑定数据
        /// </summary>
        /// <param name="palletID"></param>
        /// <returns></returns>
        protected bool MESGetProductsInPallet(string palletID, ref List <MesDBAccess.Model.ProductOnlineModel> batteryList, ref string reStr)
        {
            batteryList = new List <MesDBAccess.Model.ProductOnlineModel>();
            string strJsonCells = "";
            bool   re           = MesAcc.GetTrayBindingCell(palletID, out strJsonCells, ref reStr);

            if (!re)
            {
                reStr = "查询MES托盘电芯数据错误" + reStr;
                return(false);
            }
            JObject jsonCellObj = (JObject)JsonConvert.DeserializeObject(strJsonCells);

            if (jsonCellObj == null)
            {
                return(true);
            }
            for (int i = 0; i < SysCfg.SysCfgModel.TrayChannelMax; i++)
            {
                int    channel    = i + 1;
                string channelKey = "Cell" + channel.ToString();
                if (jsonCellObj[channelKey] == null)
                {
                    continue;
                }
                MesDBAccess.Model.ProductOnlineModel battery = new MesDBAccess.Model.ProductOnlineModel();
                battery.palletID     = palletID;
                battery.palletBinded = true;
                battery.productID    = jsonCellObj[channelKey].ToString().ToUpper();
                batteryList.Add(battery);
            }
            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(MesDBAccess.Model.ProductOnlineModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ProductOnline(");
            strSql.Append("productID,productCata,batchName,processStepID,palletID,palletBinded,stationID,checkResult,onlineTime,modifyTime,tag1,tag2,tag3,tag4,tag5)");
            strSql.Append(" values (");
            strSql.Append("@productID,@productCata,@batchName,@processStepID,@palletID,@palletBinded,@stationID,@checkResult,@onlineTime,@modifyTime,@tag1,@tag2,@tag3,@tag4,@tag5)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@productID",     SqlDbType.NVarChar,  50),
                new SqlParameter("@productCata",   SqlDbType.NVarChar,  50),
                new SqlParameter("@batchName",     SqlDbType.NVarChar,  50),
                new SqlParameter("@processStepID", SqlDbType.NVarChar,  50),
                new SqlParameter("@palletID",      SqlDbType.NVarChar,  50),
                new SqlParameter("@palletBinded",  SqlDbType.Bit,        1),
                new SqlParameter("@stationID",     SqlDbType.NVarChar,  50),
                new SqlParameter("@checkResult",   SqlDbType.NVarChar,  50),
                new SqlParameter("@onlineTime",    SqlDbType.DateTime),
                new SqlParameter("@modifyTime",    SqlDbType.DateTime),
                new SqlParameter("@tag1",          SqlDbType.NVarChar,  50),
                new SqlParameter("@tag2",          SqlDbType.NVarChar,  50),
                new SqlParameter("@tag3",          SqlDbType.NVarChar,  50),
                new SqlParameter("@tag4",          SqlDbType.NVarChar,  50),
                new SqlParameter("@tag5",          SqlDbType.NVarChar, 50)
            };
            parameters[0].Value  = model.productID;
            parameters[1].Value  = model.productCata;
            parameters[2].Value  = model.batchName;
            parameters[3].Value  = model.processStepID;
            parameters[4].Value  = model.palletID;
            parameters[5].Value  = model.palletBinded;
            parameters[6].Value  = model.stationID;
            parameters[7].Value  = model.checkResult;
            parameters[8].Value  = model.onlineTime;
            parameters[9].Value  = model.modifyTime;
            parameters[10].Value = model.tag1;
            parameters[11].Value = model.tag2;
            parameters[12].Value = model.tag3;
            parameters[13].Value = model.tag4;
            parameters[14].Value = model.tag5;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MesDBAccess.Model.ProductOnlineModel GetModel(string productID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" productID,productCata,batchName,stepNO,palletID,palletBinded,stationID,checkResult,onlineTime,modifyTime,tag1,tag2,tag3,tag4,tag5 ");
            strSql.Append(" from ProductOnline ");
            strSql.Append(" where productID='" + productID + "' ");
            MesDBAccess.Model.ProductOnlineModel model = new MesDBAccess.Model.ProductOnlineModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MesDBAccess.Model.ProductOnlineModel GetModel(string productID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 productID,productCata,batchName,processStepID,palletID,palletBinded,stationID,checkResult,onlineTime,modifyTime,tag1,tag2,tag3,tag4,tag5 from ProductOnline ");
            strSql.Append(" where productID=@productID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@productID", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = productID;

            MesDBAccess.Model.ProductOnlineModel model = new MesDBAccess.Model.ProductOnlineModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
        bool InsertToDB(string[] batteryList, string rfid, string hmCode)
        {
            for (int i = 0; i < batteryList.Length + 1; i++)
            {
                string batteryID = string.Empty;
                if (i < batteryList.Length)
                {
                    batteryID = batteryList[i];
                }
                else
                {
                    batteryID = hmCode;
                }

                MesDBAccess.Model.ProductOnlineModel productModel = null;
                if (productOnlineBll.Exists(batteryID))
                {
                    productModel               = productOnlineBll.GetModel(batteryID);
                    productModel.productID     = batteryID;
                    productModel.palletID      = rfid;
                    productModel.modifyTime    = System.DateTime.Now;
                    productModel.processStepID = this.mesProcessStepID[0];
                    if (i < batteryList.Length)
                    {
                        productModel.productCata = SysCfg.EnumProductCata.电芯.ToString();
                    }
                    else
                    {
                        productModel.productCata = SysCfg.EnumProductCata.模组.ToString();
                    }

                    productModel.palletBinded = true;
                    productModel.stationID    = this.nodeID;
                    productModel.checkResult  = "0";
                    if (!productOnlineBll.Update(productModel))
                    {
                        return(false);
                    }
                }
                else
                {
                    productModel               = new MesDBAccess.Model.ProductOnlineModel();
                    productModel.onlineTime    = System.DateTime.Now;
                    productModel.modifyTime    = System.DateTime.Now;
                    productModel.productID     = batteryID;
                    productModel.palletID      = rfid;
                    productModel.processStepID = this.mesProcessStepID[0];
                    if (i < batteryList.Length)
                    {
                        productModel.productCata = SysCfg.EnumProductCata.电芯.ToString();
                    }
                    else
                    {
                        productModel.productCata = SysCfg.EnumProductCata.模组.ToString();
                    }
                    productModel.palletBinded = true;
                    productModel.stationID    = this.nodeID;
                    productModel.checkResult  = "0";

                    if (!productOnlineBll.Add(productModel))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        bool InsertToDB(string[] batteryList)
        {
            for (int i = 0; i < batteryList.Length; i++)
            {
                string batteryID = batteryList[i];
                MesDBAccess.Model.ProductOnlineModel productModel = null;
                if (productOnlineBll.Exists(batteryID))
                {
                    productModel               = productOnlineBll.GetModel(batteryID);
                    productModel.productID     = batteryID;
                    productModel.palletID      = this.rfidUID;
                    productModel.modifyTime    = System.DateTime.Now;
                    productModel.processStepID = this.mesProcessStepID[0];
                    productModel.productCata   = SysCfg.EnumProductCata.电芯.ToString();
                    productModel.palletBinded  = true;
                    productModel.stationID     = this.nodeID;
                    productModel.checkResult   = "0";
                    if (batteryID.Length > 22)
                    {
                        productModel.batchName = batteryID.Substring(16, 6);
                    }

                    int seq = i + 1;
                    productModel.tag1 = seq.ToString();
                    int rowIndex = i / 12 + 1;
                    productModel.tag2 = rowIndex.ToString();
                    int colIndex = i - (rowIndex - 1) * 12 + 1;
                    productModel.tag3 = colIndex.ToString();
                    if (!productOnlineBll.Update(productModel))
                    {
                        return(false);
                    }
                }
                else
                {
                    productModel               = new MesDBAccess.Model.ProductOnlineModel();
                    productModel.onlineTime    = System.DateTime.Now;
                    productModel.modifyTime    = System.DateTime.Now;
                    productModel.productID     = batteryID;
                    productModel.palletID      = this.rfidUID;
                    productModel.processStepID = this.mesProcessStepID[0];
                    productModel.productCata   = SysCfg.EnumProductCata.电芯.ToString();
                    productModel.palletBinded  = true;
                    productModel.stationID     = this.nodeID;
                    productModel.checkResult   = "0";
                    if (batteryID.Length > 22)
                    {
                        productModel.batchName = batteryID.Substring(16, 6);
                    }
                    int seq = i + 1;
                    productModel.tag1 = seq.ToString();
                    int rowIndex = i / 12 + 1;
                    productModel.tag2 = rowIndex.ToString();
                    int colIndex = i - (rowIndex - 1) * 12 + 1;
                    productModel.tag3 = colIndex.ToString();
                    if (!productOnlineBll.Add(productModel))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        public override bool ExeBusiness(ref string reStr)
        {
            //Console.WriteLine("TES P1");
            if (!nodeEnabled)
            {
                return(true);
            }
            if (!devStatusRestore)
            {
                devStatusRestore = DevStatusRestore();
            }
            if (!devStatusRestore)
            {
                return(false);
            }
            if (db2Vals[0] != 2)
            {
                db1ValsToSnd[1] = 1;
            }
            //任务撤销
            if (db2Vals[1] == 3 && db1ValsToSnd[0] != 3)
            {
                if (this.currentTask != null && this.currentTaskPhase > 0)
                {
                    this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.任务撤销.ToString();
                    this.currentTask.FinishTime = System.DateTime.Now;
                    ctlTaskBll.Update(this.currentTask);

                    logRecorder.AddDebugLog(this.nodeName, string.Format("装载任务{0}撤销,托盘号:{1}", this.currentTask.TaskID, this.rfidUID));
                    currentTaskDescribe   = "装载任务撤销";
                    this.currentTask      = null;
                    this.currentTaskPhase = 0;
                }
                Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count());
                db1ValsToSnd[0] = 3;//

                return(true);
            }
            if (db1ValsToSnd[0] == 3 && db2Vals[1] == 1)
            {
                //任务撤销命令复位,应答也复位
                db1ValsToSnd[0] = 1;
            }

            if (!FillTaskRequire(ref reStr))
            {
                return(false);
            }
            //  Console.WriteLine("TES P2");
            //if(this.currentTask == null)
            //{
            //    return true;
            //}
            switch (this.currentTaskPhase)
            {
            case 1:
            {
                currentTaskDescribe  = "开始执行装载任务";
                this.db1ValsToSnd[1] = 2;

                //如果是一次装载,判断是否第一步
                if (this.nodeID == "3001")
                {
                    //如果是第1步,则上传MES步次,直接放行。通知PLC不用扫条码

                    ANCStepResult stepRe = MesAcc.GetStep(this.rfidUID);
                    if (stepRe.ResultCode != 0)
                    {
                        this.currentTaskDescribe = "查询MES托盘步次失败:" + stepRe.ResultMsg;
                        break;
                    }

                    if (SysCfg.SysCfgModel.ZhuyeMode == 1)        //一步模式
                    {
                        #region 一步模式
                        this.db1ValsToSnd[2] = 2;
                        logRecorder.AddDebugLog(nodeName, string.Format("一次注液一步模式下,托盘{0}当前步次{1},等待装载 ", this.rfidUID, stepRe.Step));
                        #endregion
                    }
                    else if (SysCfg.SysCfgModel.ZhuyeMode == 2)       //两步模式
                    {
                        #region 两步模式
                        if (stepRe.Step < 3)
                        {
                            this.currentTaskDescribe = string.Format("{0}一次注液第1步,将跳过装载", this.rfidUID);
                            int updateStep = 2;
                            logRecorder.AddDebugLog(nodeName, string.Format("托盘{0}当前步次{1},完成一次注液第1步后过站,不装载 ", this.rfidUID, stepRe.Step));
                            VMResult re = MesAcc.UpdateStep(updateStep, this.rfidUID);
                            if (re.ResultCode != 0)
                            {
                                this.currentTaskDescribe = "更新MES步次失败," + re.ResultMsg;
                                logRecorder.AddDebugLog(nodeName, this.currentTaskDescribe);
                                break;         //zwx ,11-16
                            }
                            this.db1ValsToSnd[2] = 1;

                            this.db1ValsToSnd[0]       = 2;
                            this.currentTaskPhase      = 3;
                            this.currentTask.TaskPhase = this.currentTaskPhase;
                            this.ctlTaskBll.Update(this.currentTask);
                            break;
                        }
                        else if (stepRe.Step == 3)
                        {
                            this.db1ValsToSnd[2] = 2;
                            logRecorder.AddDebugLog(nodeName, string.Format("一次注液两步模式下,托盘{0}当前步次{1},完成一次注液第2步后装载 ", this.rfidUID, stepRe.Step));
                        }
                        else
                        {
                            if (this.db1ValsToSnd[2] != 3)
                            {
                                logRecorder.AddDebugLog(nodeName, string.Format("托盘{0}步次错误,当前步次:{1} ", this.rfidUID, stepRe.Step));
                            }

                            this.db1ValsToSnd[2] = 3;
                            break;
                        }
                        #endregion
                    }
                    else
                    {
                        if (this.db1ValsToSnd[2] != 3)
                        {
                            logRecorder.AddDebugLog(nodeName, string.Format("一次注液模式错误,实际为{0}", SysCfg.SysCfgModel.ZhuyeMode));
                        }

                        this.db1ValsToSnd[2] = 3;
                        break;
                    }
                }

                this.currentTaskPhase++;
                this.currentTask.TaskPhase = this.currentTaskPhase;
                this.ctlTaskBll.Update(this.currentTask);
                break;
            }

            case 2:
            {
                if (this.db1ValsToSnd[0] == 4)
                {
                    //装载错误状态
                    break;
                }
                //等待扫码完成
                currentTaskDescribe = "RFID读取完成,等待电池条码数据";
                if (db2Vals[1] != 2)
                {
                    break;
                }
                if (SysCfg.SysCfgModel.SimMode)
                {
                    //生成模拟数据
                    GenerateSimBatterys();
                }
                //取电池条码数据
                List <string> batteryList = new List <string>();
                int           validBatNum = 0;
                for (int i = 0; i < PalletCapacity; i++)
                {
                    List <byte> batteryBytes = new List <byte>();
                    for (int j = 0; j < 20; j++)
                    {
                        int indexSt = 2 + i * 20 + j;
                        batteryBytes.Add((byte)(this.db2Vals[indexSt] & 0xff));
                        batteryBytes.Add((byte)((this.db2Vals[indexSt] >> 8) & 0xff));
                    }

                    //字节流转换成字符串
                    string batteryID = System.Text.ASCIIEncoding.UTF8.GetString(batteryBytes.ToArray());
                    batteryID = batteryID.Trim(new char[] { '\0', '\r', '\n', '\t', ' ' }).ToUpper();
                    if (batteryID.Contains("ERROR"))
                    {
                        batteryID = "";
                    }

                    if (batteryID.Length > 22)
                    {
                        validBatNum++;
                        if (batteryID.Length < 35 && batteryID.Substring(16, 6).ToUpper() == "17K03C")
                        {
                            batteryID = batteryID.Insert(22, "1");
                        }
                    }
                    batteryList.Add(batteryID);
                }
                if (validBatNum < 1)
                {
                    if (this.db1ValsToSnd[0] != 5)
                    {
                        logRecorder.AddDebugLog(nodeName, string.Format("{0}电池数据为空", rfidUID));
                    }
                    this.db1ValsToSnd[0] = 5;
                    break;
                }


                #region 调用MES接口上传绑定数据,更新步次
                int fillSeq = 1;
                if (this.nodeID == "3002")
                {
                    fillSeq = 2;
                }
                logRecorder.AddDebugLog(nodeName, string.Format("{0}开始上传MES", rfidUID));
                if (!MESBatteryFill(fillSeq, rfidUID, batteryList, ref reStr))
                {
                    logRecorder.AddDebugLog(nodeName, string.Format(" {0}MES装载错误:{1}", rfidUID, reStr));
                    this.db1ValsToSnd[0] = 4;        //装载错误
                    currentTaskDescribe  = string.Format(" 装载错误{0}", reStr);
                    logRecorder.AddDebugLog(nodeName, currentTaskDescribe);
                    break;         //zwx,11-16
                }
                else
                {
                    logRecorder.AddDebugLog(nodeName, string.Format("{0}MES装载成功", rfidUID));
                }

                ANCStepResult stepRe = MesAcc.GetStep(this.rfidUID);
                if (stepRe.ResultCode != 0)
                {
                    this.currentTaskDescribe = "查询MES托盘步次失败:" + stepRe.ResultMsg;
                    logRecorder.AddDebugLog(nodeName, this.currentTaskDescribe);
                    break;         //zwx,11-16
                }
                int updateStep = 0;
                if (this.nodeID == "3001")
                {
                    updateStep = 4;
                }
                else
                {
                    updateStep = 8;
                }
                VMResult re = MesAcc.UpdateStep(updateStep, this.rfidUID);
                if (re.ResultCode != 0)
                {
                    this.currentTaskDescribe = "更新MES步次失败," + re.ResultMsg;
                    logRecorder.AddDebugLog(nodeName, this.currentTaskDescribe);
                    break;         //zwx ,11-16
                }
                #endregion


                //自动装载都是1次装载
                #region   杭可
                //string sndStr = "";
                //if (!hkAccess.BatteryFill(0, this.rfidUID, batteryList, ref sndStr, ref reStr))
                //{

                //    logRecorder.AddDebugLog(nodeName, string.Format(" 装载错误:{0},发送数据:{1}", reStr, sndStr));
                //    this.db1ValsToSnd[0] = 4;//装载错误
                //    currentTaskDescribe = string.Format(" 装载错误{0}", reStr);
                //    break;
                //}
                #endregion
                #region 本地数据装载
                for (int i = 0; i < batteryList.Count(); i++)
                {
                    string batteryID = batteryList[i];
                    if (string.IsNullOrWhiteSpace(batteryID) || (batteryID.Length < 23))
                    {
                        continue;
                    }
                    MesDBAccess.Model.ProductOnlineModel productModel = null;
                    if (productOnlineBll.Exists(batteryID))
                    {
                        productModel               = productOnlineBll.GetModel(batteryID);
                        productModel.productID     = batteryID;
                        productModel.palletID      = this.rfidUID;
                        productModel.modifyTime    = System.DateTime.Now;
                        productModel.processStepID = this.mesProcessStepID[0].ToString();
                        productModel.productCata   = SysCfg.EnumProductCata.电芯.ToString();
                        productModel.palletBinded  = true;
                        productModel.stationID     = this.nodeID;
                        productModel.checkResult   = "0";
                        if (batteryID.Length > 22)
                        {
                            productModel.batchName = batteryID.Substring(16, 6);
                        }

                        int seq = i + 1;
                        productModel.tag1 = seq.ToString();
                        int rowIndex = i / 12 + 1;
                        productModel.tag2 = rowIndex.ToString();
                        int colIndex = i - (rowIndex - 1) * 12 + 1;
                        productModel.tag3 = colIndex.ToString();
                        productModel.tag5 = "0";
                        if (!productOnlineBll.Update(productModel))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        productModel               = new MesDBAccess.Model.ProductOnlineModel();
                        productModel.onlineTime    = System.DateTime.Now;
                        productModel.modifyTime    = System.DateTime.Now;
                        productModel.productID     = batteryID;
                        productModel.palletID      = this.rfidUID;
                        productModel.processStepID = this.mesProcessStepID[0].ToString();
                        productModel.productCata   = SysCfg.EnumProductCata.电芯.ToString();
                        productModel.palletBinded  = true;
                        productModel.stationID     = this.nodeID;
                        productModel.checkResult   = "0";
                        productModel.tag5          = "0";
                        if (batteryID.Length > 22)
                        {
                            productModel.batchName = batteryID.Substring(16, 6);
                        }
                        int seq = i + 1;
                        productModel.tag1 = seq.ToString();
                        int rowIndex = i / 12 + 1;
                        productModel.tag2 = rowIndex.ToString();
                        int colIndex = i - (rowIndex - 1) * 12 + 1;
                        productModel.tag3 = colIndex.ToString();
                        if (!productOnlineBll.Add(productModel))
                        {
                            return(false);
                        }
                    }
                }
                #endregion

                logRecorder.AddDebugLog(nodeName, string.Format(" 装载成功{0},更新MES工步:{1}", rfidUID, updateStep));
                AddProduceRecord(this.rfidUID, string.Format("装载:{0},更新MES步次{1}", nodeName, updateStep));
                this.currentTaskPhase++;
                this.currentTask.TaskPhase = this.currentTaskPhase;
                this.ctlTaskBll.Update(this.currentTask);
                this.db1ValsToSnd[0] = 2;
                break;
            }

            case 3:
            {
                currentTaskDescribe = "托盘跟电池条码数据绑定完成,等待扫码完成信号复位";
                if (this.db2Vals[1] != 1)
                {
                    break;
                }
                DevCmdReset();
                this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.已完成.ToString();
                this.ctlTaskBll.Update(this.currentTask);
                this.currentTask    = null;
                currentTaskPhase    = 0;
                currentTaskDescribe = "等待执行下一个任务";
                //等待扫码完成
                break;
            }

            default:
                break;
            }
            //Console.WriteLine("TES P3");
            return(true);
        }
Beispiel #9
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MesDBAccess.Model.ProductOnlineModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ProductOnline set ");
            strSql.Append("productCata=@productCata,");
            strSql.Append("batchName=@batchName,");
            strSql.Append("processStepID=@processStepID,");
            strSql.Append("palletID=@palletID,");
            strSql.Append("palletBinded=@palletBinded,");
            strSql.Append("stationID=@stationID,");
            strSql.Append("checkResult=@checkResult,");
            strSql.Append("onlineTime=@onlineTime,");
            strSql.Append("modifyTime=@modifyTime,");
            strSql.Append("tag1=@tag1,");
            strSql.Append("tag2=@tag2,");
            strSql.Append("tag3=@tag3,");
            strSql.Append("tag4=@tag4,");
            strSql.Append("tag5=@tag5");
            strSql.Append(" where productID=@productID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@productCata",   SqlDbType.NVarChar,  50),
                new SqlParameter("@batchName",     SqlDbType.NVarChar,  50),
                new SqlParameter("@processStepID", SqlDbType.NVarChar,  50),
                new SqlParameter("@palletID",      SqlDbType.NVarChar,  50),
                new SqlParameter("@palletBinded",  SqlDbType.Bit,        1),
                new SqlParameter("@stationID",     SqlDbType.NVarChar,  50),
                new SqlParameter("@checkResult",   SqlDbType.NVarChar,  50),
                new SqlParameter("@onlineTime",    SqlDbType.DateTime),
                new SqlParameter("@modifyTime",    SqlDbType.DateTime),
                new SqlParameter("@tag1",          SqlDbType.NVarChar,  50),
                new SqlParameter("@tag2",          SqlDbType.NVarChar,  50),
                new SqlParameter("@tag3",          SqlDbType.NVarChar,  50),
                new SqlParameter("@tag4",          SqlDbType.NVarChar,  50),
                new SqlParameter("@tag5",          SqlDbType.NVarChar,  50),
                new SqlParameter("@productID",     SqlDbType.NVarChar, 50)
            };
            parameters[0].Value  = model.productCata;
            parameters[1].Value  = model.batchName;
            parameters[2].Value  = model.processStepID;
            parameters[3].Value  = model.palletID;
            parameters[4].Value  = model.palletBinded;
            parameters[5].Value  = model.stationID;
            parameters[6].Value  = model.checkResult;
            parameters[7].Value  = model.onlineTime;
            parameters[8].Value  = model.modifyTime;
            parameters[9].Value  = model.tag1;
            parameters[10].Value = model.tag2;
            parameters[11].Value = model.tag3;
            parameters[12].Value = model.tag4;
            parameters[13].Value = model.tag5;
            parameters[14].Value = model.productID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #10
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MesDBAccess.Model.ProductOnlineModel DataRowToModel(DataRow row)
 {
     MesDBAccess.Model.ProductOnlineModel model = new MesDBAccess.Model.ProductOnlineModel();
     if (row != null)
     {
         if (row["productID"] != null)
         {
             model.productID = row["productID"].ToString();
         }
         if (row["productCata"] != null)
         {
             model.productCata = row["productCata"].ToString();
         }
         if (row["batchName"] != null)
         {
             model.batchName = row["batchName"].ToString();
         }
         if (row["processStepID"] != null)
         {
             model.processStepID = row["processStepID"].ToString();
         }
         if (row["palletID"] != null)
         {
             model.palletID = row["palletID"].ToString();
         }
         if (row["palletBinded"] != null && row["palletBinded"].ToString() != "")
         {
             if ((row["palletBinded"].ToString() == "1") || (row["palletBinded"].ToString().ToLower() == "true"))
             {
                 model.palletBinded = true;
             }
             else
             {
                 model.palletBinded = false;
             }
         }
         if (row["stationID"] != null)
         {
             model.stationID = row["stationID"].ToString();
         }
         if (row["checkResult"] != null)
         {
             model.checkResult = row["checkResult"].ToString();
         }
         if (row["onlineTime"] != null && row["onlineTime"].ToString() != "")
         {
             model.onlineTime = DateTime.Parse(row["onlineTime"].ToString());
         }
         if (row["modifyTime"] != null && row["modifyTime"].ToString() != "")
         {
             model.modifyTime = DateTime.Parse(row["modifyTime"].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);
 }
Beispiel #11
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(MesDBAccess.Model.ProductOnlineModel model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.productID != null)
            {
                strSql1.Append("productID,");
                strSql2.Append("'" + model.productID + "',");
            }
            if (model.productCata != null)
            {
                strSql1.Append("productCata,");
                strSql2.Append("'" + model.productCata + "',");
            }
            if (model.batchName != null)
            {
                strSql1.Append("batchName,");
                strSql2.Append("'" + model.batchName + "',");
            }
            if (model.stepNO != null)
            {
                strSql1.Append("stepNO,");
                strSql2.Append("" + model.stepNO + ",");
            }
            if (model.palletID != null)
            {
                strSql1.Append("palletID,");
                strSql2.Append("'" + model.palletID + "',");
            }
            if (model.palletBinded != null)
            {
                strSql1.Append("palletBinded,");
                strSql2.Append("" + (model.palletBinded ? 1 : 0) + ",");
            }
            if (model.stationID != null)
            {
                strSql1.Append("stationID,");
                strSql2.Append("'" + model.stationID + "',");
            }
            if (model.checkResult != null)
            {
                strSql1.Append("checkResult,");
                strSql2.Append("'" + model.checkResult + "',");
            }
            if (model.onlineTime != null)
            {
                strSql1.Append("onlineTime,");
                strSql2.Append("'" + model.onlineTime + "',");
            }
            if (model.modifyTime != null)
            {
                strSql1.Append("modifyTime,");
                strSql2.Append("'" + model.modifyTime + "',");
            }
            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 ProductOnline(");
            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);
            }
        }
Beispiel #12
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MesDBAccess.Model.ProductOnlineModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ProductOnline set ");
            if (model.productCata != null)
            {
                strSql.Append("productCata='" + model.productCata + "',");
            }
            if (model.batchName != null)
            {
                strSql.Append("batchName='" + model.batchName + "',");
            }
            else
            {
                strSql.Append("batchName= null ,");
            }
            if (model.stepNO != null)
            {
                strSql.Append("stepNO=" + model.stepNO + ",");
            }
            if (model.palletBinded != null)
            {
                strSql.Append("palletBinded=" + (model.palletBinded ? 1 : 0) + ",");
            }
            if (model.stationID != null)
            {
                strSql.Append("stationID='" + model.stationID + "',");
            }
            if (model.checkResult != null)
            {
                strSql.Append("checkResult='" + model.checkResult + "',");
            }
            if (model.modifyTime != null)
            {
                strSql.Append("modifyTime='" + model.modifyTime + "',");
            }
            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 productID='" + model.productID + "' and onlineTime='" + model.onlineTime + "' ");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

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