예제 #1
0
        /// <summary>
        /// OCV检测结果
        /// </summary>
        /// <param name="palletRfid">料框RFID</param>
        /// <param name="processStatus">检测过程状态</param>
        /// <returns>1:OK,2:NG,3:空</returns>
        public byte[] GetOcvCheckResult(string palletRfid, string processStatus)
        {
            byte[] checkResult = new byte[48];
            for (int i = 0; i < 48; i++)
            {
                checkResult[i] = 3;
            }
            //默认料框为空

            OCVPalletModel palletModel = dal.GetModel(palletRfid);

            if (palletModel == null || palletModel.processStatus.Trim() != processStatus)
            {
                return(null);
            }
            IList <OCVBatteryModel> batteryList = batteryBll.GetModelList(" palletID='" + palletRfid + "'");

            if (batteryList == null)
            {
                return(null);
            }
            //if (batteryList != null && batteryList.Count >= 48)
            {
                for (int i = 0; i < Math.Min(batteryList.Count, 48); i++)
                {
                    OCVBatteryModel battery = batteryList[i];
                    if (battery == null)
                    {
                        continue;
                    }
                    if (battery.positionCode < 1 || battery.positionCode > 48)
                    {
                        continue;
                    }
                    int batteryIndex = battery.positionCode - 1;
                    if (!battery.hasBattery)
                    {
                        checkResult[batteryIndex] = 3;
                    }
                    else
                    {
                        if (battery.checkResult.Trim() == EnumOCVCheckResult.良品.ToString())
                        {
                            checkResult[batteryIndex] = 1;
                        }
                        else
                        {
                            checkResult[batteryIndex] = 2;
                        }
                    }
                }
            }
            return(checkResult);
        }
예제 #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <OCVBatteryModel> DataTableToList(DataTable dt)
        {
            List <OCVBatteryModel> modelList = new List <OCVBatteryModel>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                OCVBatteryModel model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new OCVBatteryModel();
                    if (dt.Rows[n]["batteryID"] != null && dt.Rows[n]["batteryID"].ToString() != "")
                    {
                        model.batteryID = dt.Rows[n]["batteryID"].ToString();
                    }
                    if (dt.Rows[n]["rowIndex"] != null && dt.Rows[n]["rowIndex"].ToString() != "")
                    {
                        model.rowIndex = int.Parse(dt.Rows[n]["rowIndex"].ToString());
                    }
                    if (dt.Rows[n]["columnIndex"] != null && dt.Rows[n]["columnIndex"].ToString() != "")
                    {
                        model.columnIndex = int.Parse(dt.Rows[n]["columnIndex"].ToString());
                    }
                    if (dt.Rows[n]["positionCode"] != null && dt.Rows[n]["positionCode"].ToString() != "")
                    {
                        model.positionCode = int.Parse(dt.Rows[n]["positionCode"].ToString());
                    }
                    if (dt.Rows[n]["checkResult"] != null && dt.Rows[n]["checkResult"].ToString() != "")
                    {
                        model.checkResult = dt.Rows[n]["checkResult"].ToString();
                    }
                    if (dt.Rows[n]["palletID"] != null && dt.Rows[n]["palletID"].ToString() != "")
                    {
                        model.palletID = dt.Rows[n]["palletID"].ToString();
                    }
                    if (dt.Rows[n]["hasBattery"] != null && dt.Rows[n]["hasBattery"].ToString() != "")
                    {
                        if ((dt.Rows[n]["hasBattery"].ToString() == "1") || (dt.Rows[n]["hasBattery"].ToString().ToLower() == "true"))
                        {
                            model.hasBattery = true;
                        }
                        else
                        {
                            model.hasBattery = false;
                        }
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(OCVBatteryModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update OCVBattery set ");
            strSql.Append("rowIndex=@rowIndex,");
            strSql.Append("columnIndex=@columnIndex,");
            strSql.Append("positionCode=@positionCode,");
            strSql.Append("checkResult=@checkResult,");
            strSql.Append("hasBattery=@hasBattery");
            strSql.Append(" where batteryID=@batteryID and palletID=@palletID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@rowIndex",     SqlDbType.Int,       4),
                new SqlParameter("@columnIndex",  SqlDbType.Int,       4),
                new SqlParameter("@positionCode", SqlDbType.Int,       4),
                new SqlParameter("@checkResult",  SqlDbType.Char,     10),
                new SqlParameter("@hasBattery",   SqlDbType.Bit,       1),
                new SqlParameter("@batteryID",    SqlDbType.NVarChar, 50),
                new SqlParameter("@palletID",     SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.rowIndex;
            parameters[1].Value = model.columnIndex;
            parameters[2].Value = model.positionCode;
            parameters[3].Value = model.checkResult;
            parameters[4].Value = model.hasBattery;
            parameters[5].Value = model.batteryID;
            parameters[6].Value = model.palletID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(OCVBatteryModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OCVBattery(");
            strSql.Append("batteryID,rowIndex,columnIndex,positionCode,checkResult,palletID,hasBattery)");
            strSql.Append(" values (");
            strSql.Append("@batteryID,@rowIndex,@columnIndex,@positionCode,@checkResult,@palletID,@hasBattery)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@batteryID",    SqlDbType.NVarChar, 50),
                new SqlParameter("@rowIndex",     SqlDbType.Int,       4),
                new SqlParameter("@columnIndex",  SqlDbType.Int,       4),
                new SqlParameter("@positionCode", SqlDbType.Int,       4),
                new SqlParameter("@checkResult",  SqlDbType.Char,     10),
                new SqlParameter("@palletID",     SqlDbType.NVarChar, 50),
                new SqlParameter("@hasBattery",   SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.batteryID;
            parameters[1].Value = model.rowIndex;
            parameters[2].Value = model.columnIndex;
            parameters[3].Value = model.positionCode;
            parameters[4].Value = model.checkResult;
            parameters[5].Value = model.palletID;
            parameters[6].Value = model.hasBattery;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public OCVBatteryModel GetModel(string batteryID, string palletID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 batteryID,rowIndex,columnIndex,positionCode,checkResult,palletID,hasBattery from OCVBattery ");
            strSql.Append(" where batteryID=@batteryID and palletID=@palletID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@batteryID", SqlDbType.NVarChar, 50),
                new SqlParameter("@palletID",  SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = batteryID;
            parameters[1].Value = palletID;

            OCVBatteryModel model = new OCVBatteryModel();
            DataSet         ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["batteryID"] != null && ds.Tables[0].Rows[0]["batteryID"].ToString() != "")
                {
                    model.batteryID = ds.Tables[0].Rows[0]["batteryID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["rowIndex"] != null && ds.Tables[0].Rows[0]["rowIndex"].ToString() != "")
                {
                    model.rowIndex = int.Parse(ds.Tables[0].Rows[0]["rowIndex"].ToString());
                }
                if (ds.Tables[0].Rows[0]["columnIndex"] != null && ds.Tables[0].Rows[0]["columnIndex"].ToString() != "")
                {
                    model.columnIndex = int.Parse(ds.Tables[0].Rows[0]["columnIndex"].ToString());
                }
                if (ds.Tables[0].Rows[0]["positionCode"] != null && ds.Tables[0].Rows[0]["positionCode"].ToString() != "")
                {
                    model.positionCode = int.Parse(ds.Tables[0].Rows[0]["positionCode"].ToString());
                }
                if (ds.Tables[0].Rows[0]["checkResult"] != null && ds.Tables[0].Rows[0]["checkResult"].ToString() != "")
                {
                    model.checkResult = ds.Tables[0].Rows[0]["checkResult"].ToString();
                }
                if (ds.Tables[0].Rows[0]["palletID"] != null && ds.Tables[0].Rows[0]["palletID"].ToString() != "")
                {
                    model.palletID = ds.Tables[0].Rows[0]["palletID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["hasBattery"] != null && ds.Tables[0].Rows[0]["hasBattery"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["hasBattery"].ToString() == "1") || (ds.Tables[0].Rows[0]["hasBattery"].ToString().ToLower() == "true"))
                    {
                        model.hasBattery = true;
                    }
                    else
                    {
                        model.hasBattery = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(OCVBatteryModel model)
 {
     return(dal.Update(model));
 }
예제 #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(OCVBatteryModel model)
 {
     return(dal.Add(model));
 }