示例#1
0
        // 摘要:
        //     获取指定登陆名称的用户信息
        //
        // 参数:
        //   loginName:
        //     登陆名称
        //
        // 返回结果:
        //     用户信息


        private void CreateUserFromRow(DataRow sysUserRow)
        {
            this.id                   = sysUserRow["ID"].ToString();
            this.name                 = sysUserRow["NAME"].ToString();
            this.IsAdmin              = false;
            this.IsDisabled           = ("1" == sysUserRow["C_STATE"].ToString());
            this.LoginName            = sysUserRow["LOGINNAME"].ToString();
            this.OwningBusinessUnitId = sysUserRow["LEVELGROUPID"].ToString();
            this.UserRoleID           = sysUserRow["ROLE"].ToString();
            this.UserRole             = sysUserRow["F_ROLE"].ToString();
            this.TeamCode             = sysUserRow["TEAM_CODE"].ToString();
            DbOperator opt = new DbOperator();

            if (this.UserRoleID == "")
            {
                this.UserRoleID = opt.GetSegValue("select F_ROLE from ht_svr_org_group where F_CODE = '" + this.OwningBusinessUnitId + "'", "F_ROLE");
                this.UserRole   = opt.GetSegValue("select F_ROLE from ht_svr_sys_role where F_ID = '" + this.UserRoleID + "'", "F_ROLE");
            }
            DataSet data = opt.CreateDataSetOra("select s.f_menu,s.f_type,s.F_MAPID,s.f_id   from HT_SVR_SYS_ROLE t  left join HT_SVR_SYS_MENU s on substr (t.f_right,s.f_id,1) = '1' and s.is_del = '0' where t.f_id = '" + this.UserRoleID + "' and s.f_menu is not null");

            UserRights = new SysRightCollection();
            if (data != null && data.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in data.Tables[0].Rows)
                {
                    SysRight right = new SysRight(row);
                    UserRights.Add(right);
                }
            }
        }
示例#2
0
        public int TaskShiftNum(string Btime, string Etime, string section)//查取时间段内是否有任务报告记录
        {
            DbOperator opt  = new DbOperator();
            DataSet    data = opt.CreateDataSetOra("select count(rowid) from ht_prod_report t where t.section_code = '" + section + "' and STARTTIME between '" + Btime + "' and '" + Etime + "' or ENDTIME between '" + Btime + "' and '" + Etime + "' or (starttime <= '" + Btime + "' and endtime >= '" + Etime + "')");

            return(Convert.ToInt16(data.Tables[0].Rows[0][0].ToString()));
        }
示例#3
0
        public DataRowCollection GetData(string btime, string etime, string nodeid)
        {
            DbOperator opt  = new DbOperator();
            DataSet    data = opt.CreateDataSetOra("select s.value_tag,r.periodic from HT_QLT_COLLECTION r left join ht_pub_tech_para s on s.para_code = r.para_code where r.PARA_CODE = '" + nodeid + "'");

            if (data == null || data.Tables[0].Rows.Count == 0)
            {
                return(null);
            }
            DataRow row = data.Tables[0].Rows[0];
            ////////////////////工艺点标签//////////////////////////////////////////////
            string tagname  = row["value_tag"].ToString();
            string interval = row["PERIODIC"].ToString();


            string query = "SELECT  timestamp,value  FROM ihrawdata where tagname = '" + tagname + "' and timestamp between '" + btime + "' and '" + etime + "' and intervalmilliseconds =  " + interval + "s order by timestamp ASC";

            try
            {
                data = CreateDataSetIH(query);
                if (data != null && data.Tables[0].Rows.Count > 0)
                {
                    return(data.Tables[0].Rows);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
示例#4
0
        public DataRowCollection GetData(string btime, string etime, string nodeid, string planno)
        {
            TimeSeg    seg  = GetTimeSeg(btime, etime, nodeid, planno);
            DbOperator opt  = new DbOperator();
            DataSet    data = opt.CreateDataSetOra("select t.value_tag,r.periodic from   HT_QLT_COLLECTION  r left join ht_pub_tech_para t on r.para_code = t.para_code where r.PARA_CODE = '" + seg.nodecode + "'");

            if (data == null || data.Tables[0].Rows.Count == 0)
            {
                return(null);
            }
            DataRow row = data.Tables[0].Rows[0];
            ////////////////////工艺点标签//////////////////////////////////////////////
            string tagname  = row["value_tag"].ToString();
            string interval = row["periodic"].ToString();

            string query = "SELECT  timestamp as 时间,value as 值  FROM ihrawdata where tagname = '" + tagname + "' and timestamp between '" + seg.starttime + "' and '" + seg.endtime + "' and intervalmilliseconds =  " + interval + "s order by timestamp ASC";

            data = CreateDataSetIH(query);
            if (data != null && data.Tables[0].Rows.Count > 0)
            {
                return(data.Tables[0].Rows);
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        //
        // 摘要:
        //     初始化用户对象
        //
        // 参数:
        //   sysUserId:
        //     用户Id
        public SysUser(string sysUserId)
        {
            DbOperator opt  = new DbOperator();
            DataSet    data = opt.CreateDataSetOra("select *   from HT_SVR_USER r left join ht_svr_sys_role t on r.role = t.f_id  where r.id = '" + sysUserId + "'");

            if (data != null && data.Tables[0].Rows.Count > 0)
            {
                CreateUserFromRow(data.Tables[0].Rows[0]);
            }
        }
示例#6
0
        protected override void CreateObjfromDB(string id)
        {
            DbOperator opt  = new DbOperator();
            DataSet    data = opt.CreateDataSetOra("select *   from HT_SVR_USER r left join ht_svr_sys_role t on r.role = t.f_id  where r.id = '" + id + "'");

            if (data != null && data.Tables[0].Rows.Count > 0)
            {
                CreateUserFromRow(data.Tables[0].Rows[0]);
            }
        }
示例#7
0
        /// <summary>
        /// 重载方法 获取指定时间段的数据,由于IH所限,按每两小时进行循环读取将数据全部取出来
        /// </summary>
        /// <param name="para_code">工艺点编码</param>
        /// <param name="Btime">开始时间</param>
        /// <param name="Etime">结束时间</param>
        /// <returns></returns>
        protected List <ParaInfo> getParaRecord(string para_code, DateTime Btime, DateTime Etime)
        {
            DbOperator opt  = new DbOperator();
            DataSet    data = opt.CreateDataSetOra("select t.value_tag,r.gap_hdelay,r.gap_tdelay,r.ctrl_point,r.is_gap_judge,r.periodic,r.rst_value,r.gap_time,r.head_delay,r.tail_delay,r.batch_head_delay,r.batch_tail_delay from   HT_QLT_COLLECTION  r left join ht_pub_tech_para t on r.para_code = t.para_code where r.PARA_CODE = '" + para_code + "'");

            if (data == null || data.Tables[0].Rows.Count == 0)
            {
                return(null);
            }
            DataRow drow = data.Tables[0].Rows[0];
            ////////////////////工艺点标签//////////////////////////////////////////////
            string tagname  = drow["value_tag"].ToString();
            string interval = drow["periodic"].ToString();

            if (DateTime.Compare(Btime, Etime) > 0)
            {
                return(null);
            }
            List <ParaInfo> paralist = new List <ParaInfo>();

            MSYS.DAL.DbOperator ihopt     = new MSYS.DAL.DbOperator(new MSYS.DAL.OledbOperator());
            DateTime            starttime = Btime;
            DateTime            stoptime  = Etime;

            if (Etime - Btime > TimeSpan.FromHours(2))
            {
                starttime = Btime;
                stoptime  = Btime.AddHours(2);
            }
            do
            {
                string query = "SELECT  timestamp ,value  FROM ihrawdata where tagname = '" + tagname + "' and timestamp between '" + starttime.ToString("yyyy/MM/dd HH:mm:ss") + "' and '" + stoptime.ToString("yyyy/MM/dd HH:mm:ss") + "' and intervalmilliseconds =  " + interval + "s order by timestamp ASC";
                data = ihopt.CreateDataSetOra(query);
                if (data != null && data.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in data.Tables[0].Rows)
                    {
                        ParaInfo info = new ParaInfo();
                        info.timestamp = row["timestamp"].ToString();
                        info.value     = Convert.ToDouble(row["value"].ToString());
                        paralist.Add(info);
                    }
                }
                starttime = stoptime;
                stoptime  = starttime.AddHours(2);
                if (DateTime.Compare(stoptime, Etime) > 0)
                {
                    stoptime = Etime;
                }
            }while (Etime - starttime > TimeSpan.FromHours(0));

            return(paralist);
        }
示例#8
0
        protected override void CreateObjfromDB(string id)
        {
            DbOperator opt  = new DbOperator();
            DataSet    data = opt.CreateDataSetOra("select * from ht_eq_eqp_cls where id_key ='" + id + "' and is_del ='0'");

            if (data != null && data.Tables[0].Rows.Count > 0)
            {
                DataRow row = data.Tables[0].Rows[0];
                this.id   = row["ID_KEY"].ToString();
                this.name = row["NODE_NAME"].ToString();
                DataSet subdata = opt.CreateDataSetOra("select * from ht_eq_eqp_cls where parent_id ='" + row["ID_KEY"].ToString() + "' and is_del = '0'");
                if (subdata != null && subdata.Tables[0].Rows.Count > 0)
                {
                    this.childCls = new List <EquipCLS>();
                    foreach (DataRow subrow in subdata.Tables[0].Rows)
                    {
                        this.childCls.Add(new EquipCLS(subrow["ID_KEY"].ToString()));
                    }
                }
            }
        }
示例#9
0
        protected override void CreateObjfromDB(string id)
        {
            DbOperator opt  = new DbOperator();
            DataSet    data = opt.CreateDataSetOra("select * from ht_eq_eqp_tbl where  idkey = '" + id + "' and is_del= '0'");

            if (data != null && data.Tables[0].Rows.Count > 0)
            {
                DataRow row = data.Tables[0].Rows[0];
                this.idkey           = row["idkey"].ToString();
                this.id              = this.idkey;
                this.cls_code        = row["cls_code"].ToString();
                this.eq_name         = row["eq_name"].ToString();
                this.name            = this.eq_name;
                this.sgs_code        = row["sgs_code"].ToString();
                this.nc_code         = row["nc_code"].ToString();
                this.finance_eq_name = row["finance_eq_name"].ToString();
                this.eq_type         = row["eq_type"].ToString();
                this.eq_status       = row["eq_status"].ToString();
                this.zg_date         = row["zg_date"].ToString();
                this.eq_model        = row["eq_model"].ToString();
                this.ori_worth       = row["ori_worth"].ToString();
                this.net_worth       = row["net_worth"].ToString();
                this.used_date       = row["used_date"].ToString();
                this.rated_power     = row["rated_power"].ToString();
                this.real_power      = row["real_power"].ToString();
                this.power_unit      = row["power_unit"].ToString();
                this.owner_name      = row["owner_name"].ToString();
                this.eqp_from        = row["eqp_from"].ToString();
                this.ori_owner_name  = row["ori_owner_name"].ToString();
                this.manufacturer    = row["manufacturer"].ToString();
                this.serial_number   = row["serial_number"].ToString();
                this.supplier        = row["supplier"].ToString();
                this.is_spec_eqp     = row["is_spec_eqp"].ToString();
                this.is_madeinchina  = row["is_madeinchina"].ToString();
                this.mgt_dept_code   = row["mgt_dept_code"].ToString();
                this.mgt_dept_name   = row["mgt_dept_name"].ToString();
                this.use_dept_code   = row["use_dept_code"].ToString();
                this.use_dept_name   = row["use_dept_name"].ToString();
                this.duty_name       = row["duty_name"].ToString();
                this.eqp_ip          = row["eqp_ip"].ToString();
                this.eqp_mac         = row["eqp_mac"].ToString();
                this.eqp_sn          = row["eqp_sn"].ToString();
                this.eqp_sys         = row["eqp_sys"].ToString();
                this.remark          = row["remark"].ToString();
                this.creator         = row["creator"].ToString();
                this.create_time     = row["create_time"].ToString();
                this.process_code    = row["process_code"].ToString();
            }
        }
示例#10
0
        public TimeSeg GetTimeSegP(string btime, string etime, string nodeid, string prodcode)//显示一段时间内某一任务号某产品数据对应时间段
        {
            TimeSeg seg = new TimeSeg();

            seg.starttime = btime;
            seg.endtime   = etime;
            seg.nodecode  = nodeid;
            DbOperator opt   = new DbOperator();
            string     query = "select starttime, starttime as rstime, 'b' as tag,PLANNO from ht_prod_report t where t.section_code = '" + nodeid.Substring(0, 5) + "' and PROD_CODE = '" + prodcode + "' and STARTTIME between '" + btime + "' and '" + etime + "' union select starttime, endtime as rstime,'e' as tag,PLANNO  from ht_prod_report t where t.section_code = '" + nodeid.Substring(0, 5) + "' and PROD_CODE = '" + prodcode + "' and  endtime between '" + btime + "' and '" + etime + "'   union select starttime, endtime as rstime,'a' as tag,PLANNO  from ht_prod_report t where t.section_code =  '" + nodeid.Substring(0, 5) + "' and PROD_CODE = '" + prodcode + "'  and  starttime <  '" + btime + "' and endtime > '" + etime + "' order by rstime";
            DataSet    data  = opt.CreateDataSetOra(query);

            if (data != null && data.Tables[0].Rows.Count > 0)
            {
                seg.planno     = data.Tables[0].Rows[0]["PLANNO"].ToString();
                seg.batchStart = data.Tables[0].Rows[0]["starttime"].ToString();
                if (data.Tables[0].Rows.Count == 1)
                {
                    if (data.Tables[0].Rows[0]["tag"].ToString() == "e")
                    {
                        seg.endtime = data.Tables[0].Rows[0]["rstime"].ToString();
                        seg.type    = TimeSegType.END;
                    }

                    else if (data.Tables[0].Rows[0]["tag"].ToString() == "b")
                    {
                        seg.starttime = data.Tables[0].Rows[0]["rstime"].ToString();
                        seg.type      = TimeSegType.BEGIN;
                    }
                    else
                    {
                        seg.type = TimeSegType.ALL;
                    }
                }
                else
                {
                    seg.starttime = data.Tables[0].Rows[0]["rstime"].ToString();
                    seg.endtime   = data.Tables[0].Rows[1]["rstime"].ToString();
                    seg.type      = TimeSegType.BOTH;
                }
            }
            else
            {
                seg.type = TimeSegType.ALL;
            }
            return(seg);
        }
示例#11
0
        public paraSeginfo GetParaSegInfo(TimeSeg seg)
        {
            paraSeginfo info = new paraSeginfo();

            #region    read collection condtion
            DbOperator opt  = new DbOperator();
            DataSet    data = opt.CreateDataSetOra("select t.value_tag,r.gap_hdelay,r.gap_tdelay,r.ctrl_point,r.is_gap_judge,r.periodic,r.rst_value,r.gap_time,r.head_delay,r.tail_delay,r.batch_head_delay,r.batch_tail_delay from   HT_QLT_COLLECTION  r left join ht_pub_tech_para t on r.para_code = t.para_code where r.PARA_CODE = '" + seg.nodecode + "'");
            if (data == null || data.Tables[0].Rows.Count == 0)
            {
                return(info);
            }
            DataRow row = data.Tables[0].Rows[0];
            ////////////////////工艺点标签//////////////////////////////////////////////
            string tagname  = row["value_tag"].ToString();
            string interval = row["periodic"].ToString();
            int    timegap  = Convert.ToInt32(row["gap_time"].ToString());
            string tailRst  = row["rst_value"].ToString();
            ////////////////////是否为工艺段断流判定点/////////////////////////////////////////////
            bool gapctrl = ("1" == row["is_gap_judge"].ToString());

            //////////////////////偏移/////////////////////////////////////////////
            int headDelay      = Convert.ToInt32(row["head_delay"].ToString());       //料头
            int tailDelay      = Convert.ToInt32(row["tail_delay"].ToString());       //料尾
            int batchheadDelay = Convert.ToInt32(row["batch_head_delay"].ToString()); //批头
            int batchtailDelay = Convert.ToInt32(row["batch_tail_delay"].ToString()); //批尾
            int gap_hdelay     = Convert.ToInt32(row["gap_hdelay"].ToString());       //断流前
            int gap_tdelay     = Convert.ToInt32(row["gap_tdelay"].ToString());       //断流后
            #endregion
            #region                                                                   //////////////////////寻找数据批头尾、料头尾  以及断流信息///////////////////////////////////////////////////////////////////////
            List <ParaInfo> paralist;
            if (seg.type == TimeSegType.ALL && Convert.ToDateTime(seg.starttime) - Convert.ToDateTime(seg.batchStart) < new TimeSpan(1, 0, 0))
            {
                paralist = getParaRecord(tagname, "5", Convert.ToDateTime(seg.batchStart), Convert.ToDateTime(seg.endtime));
                seg.type = TimeSegType.BEGIN;
            }
            else
            {
                paralist = getParaRecord(tagname, "5", Convert.ToDateTime(seg.starttime), Convert.ToDateTime(seg.endtime));
            }
            if (gapctrl)
            {
                if (tagname != "" && tailRst != "" && interval != "")
                {
                    info.batchBtime = info.tailBtime = seg.starttime; //初始化料头时间
                    info.batchEtime = info.tailEtime = seg.endtime;   //初始化料尾时间

                    /////////自动寻找批头批尾/////////
                    if (seg.type == TimeSegType.BEGIN || seg.type == TimeSegType.BOTH)//寻找批头
                    {
                        DateTime temptime = Convert.ToDateTime(paralist.Find(s => s.value < Convert.ToDouble(tailRst)).timestamp);


                        if (temptime - Convert.ToDateTime(seg.batchStart) > new TimeSpan(0, 30, 0))
                        {
                            info.batchBtime = Convert.ToDateTime(seg.batchStart).AddSeconds(batchheadDelay).ToString("yyyy-MM-dd HH:mm:ss");
                        }
                        else
                        {
                            temptime = temptime.AddSeconds(batchheadDelay);
                            if (temptime - Convert.ToDateTime(seg.starttime) > new TimeSpan(0))
                            {
                                info.batchBtime = temptime.ToString("yyyy-MM-dd HH:mm:ss");
                            }
                        }
                        if (Convert.ToDateTime(info.batchBtime) - Convert.ToDateTime(seg.starttime) < new TimeSpan(0))
                        {
                            info.batchBtime = seg.starttime;
                        }
                    }
                    if (seg.type == TimeSegType.END || seg.type == TimeSegType.BOTH)//寻找批尾
                    {
                        double temp = paralist.ToArray()[paralist.Count - 1].value;

                        if (temp >= Convert.ToDouble(tailRst))
                        {
                            paralist        = getParaRecord(tagname, "5", Convert.ToDateTime(seg.starttime), Convert.ToDateTime(seg.endtime).AddHours(1));
                            info.batchEtime = Convert.ToDateTime(paralist.Find(s => s.value > Convert.ToDouble(tailRst)).timestamp).AddSeconds(batchtailDelay).ToString("yyyy-MM-dd HH:mm:ss");
                        }
                        else
                        {
                            info.batchEtime = Convert.ToDateTime(paralist.FindLast(s => s.value > Convert.ToDouble(tailRst)).timestamp).AddSeconds(batchtailDelay).ToString("yyyy-MM-dd HH:mm:ss");
                        }
                    }


                    ////////////////////////////////自动寻找料头料尾////////////////////////////////////////////////////////////////
                    if (seg.type == TimeSegType.BEGIN || seg.type == TimeSegType.BOTH)//寻找料头
                    {
                        info.tailBtime = Convert.ToDateTime(paralist.Find(s => (s.value > Convert.ToDouble(tailRst) && Convert.ToDateTime(s.timestamp) - Convert.ToDateTime(info.batchBtime) >= new TimeSpan(0) && Convert.ToDateTime(s.timestamp) - Convert.ToDateTime(info.batchEtime) <= new TimeSpan(0))).timestamp).AddSeconds(headDelay).ToString("yyyy-MM-dd HH:mm:ss");
                    }
                    if (seg.type == TimeSegType.END || seg.type == TimeSegType.BOTH)//寻找料尾
                    {
                        info.tailEtime = Convert.ToDateTime(paralist.FindLast(s => s.value > Convert.ToDouble(tailRst) && Convert.ToDateTime(s.timestamp) - Convert.ToDateTime(info.batchBtime) >= new TimeSpan(0) && Convert.ToDateTime(s.timestamp) - Convert.ToDateTime(info.batchEtime) <= new TimeSpan(0)).timestamp).AddSeconds(tailDelay).ToString("yyyy-MM-dd HH:mm:ss");
                    }

                    ////////////////////选取数据/判断是否断料,并记录下相应的断料时间//////
                    info.paralist = paralist;
                    info.gapinfo  = GetGapTime(paralist, tailRst, gap_hdelay, gap_tdelay, timegap);
                    info.tagname  = tagname;
                    info.interval = interval;
                    //////将计算的时间存入数据库/////////
                    //string[] bseg = { "ORDERNO", "PLANNO", "STARTTIME", "ENDTIME", "SECTION_CODE", "BATCH_BTIME", "BATCH_ETIME", "GAP_BTIME", "GAP_ETIME", "TYPE", };
                    //string[] bvalue = { "0", seg.planno, seg.starttime, seg.endtime, seg.nodecode.Substring(0, 5), info.batchBtime, info.batchEtime, info.tailBtime, info.tailEtime, "0" };
                    //opt.MergeInto(bseg, bvalue, 5, "HT_QLT_GAP_COLLECTION");
                    ////////////////////选取数据/判断是否断料,并记录下相应的断料时间//////

                    gaptime = info.gapinfo;
                    //int orderno = 1;
                    //string[] gapseg = { "ORDERNO", "PLANNO", "STARTTIME", "ENDTIME", "SECTION_CODE", "GAPTIME ", "GAP_BTIME", "GAP_ETIME", "TYPE" };
                    //if (gaptime != null)
                    //{
                    //    foreach (Gaptime time in gaptime)
                    //    {
                    //        string[] gapvalue = { (orderno++).ToString(), seg.planno, seg.starttime, seg.endtime, seg.nodecode.Substring(0, 5), time.gaptime.ToString(), time.starttime, time.endtime, "1" };
                    //        opt.MergeInto(gapseg, gapvalue, 5, "HT_QLT_GAP_COLLECTION");
                    //    }
                    //}
                }
            }
            else
            {
                //如果不是断流判定点,则读取该工艺段判定点的信息,获取批头批尾、料头料尾,以及断流区间信息
                string ctrlpoint = row["ctrl_point"].ToString();
                seg.nodecode = ctrlpoint;
                //DataSet gapdata = opt.CreateDataSetOra("select * from HT_QLT_GAP_COLLECTION where TYPE = '0' and  PLANNO = '" + seg.planno + "' and STARTTIME = '" + seg.starttime + "' and ENDTIME = '" + seg.endtime + "' and SECTION_CODE = '" + ctrlpoint.Substring(0, 5) + "' ");
                //////如果数据库有己计算的断流判定点结果
                //if (gapdata != null && gapdata.Tables[0].Rows.Count > 0)
                //{
                //    DataRow brow = gapdata.Tables[0].Rows[0];
                //    info.batchBtime = Convert.ToDateTime(brow["BATCH_BTIME"].ToString()).AddSeconds(batchheadDelay).ToString("yyyy-MM-dd HH:mm:ss");
                //    info.batchEtime = Convert.ToDateTime(brow["BATCH_ETIME"].ToString()).AddSeconds(batchtailDelay).ToString("yyyy-MM-dd HH:mm:ss");
                //    info.tailBtime = Convert.ToDateTime(brow["GAP_BTIME"].ToString()).AddSeconds(headDelay).ToString("yyyy-MM-dd HH:mm:ss");
                //    info.tailEtime = Convert.ToDateTime(brow["GAP_ETIME"].ToString()).AddSeconds(tailDelay).ToString("yyyy-MM-dd HH:mm:ss");
                //    gapdata = opt.CreateDataSetOra("select * from HT_QLT_GAP_COLLECTION where TYPE = '1' and  PLANNO = '" + seg.planno + "' and STARTTIME = '" + seg.starttime + "' and ENDTIME = '" + seg.endtime + "' and SECTION_CODE = '" + ctrlpoint.Substring(0, 5) + "' ");
                //    if (gapdata != null && gapdata.Tables[0].Rows.Count > 0)
                //    {
                //        if (gaptime == null)
                //            gaptime = new List<Gaptime>();
                //        else
                //            gaptime.Clear();
                //        foreach (DataRow grow in gapdata.Tables[0].Rows)
                //        {
                //            Gaptime time = new Gaptime();
                //            time.gaptime = Convert.ToInt32(grow["gaptime"].ToString());
                //            time.starttime = Convert.ToDateTime(grow["GAP_BTIME"].ToString()).AddSeconds(gap_hdelay).ToString("yyyy-MM-dd HH:mm:ss");
                //            time.endtime = Convert.ToDateTime(grow["GAP_ETIME"].ToString()).AddSeconds(gap_tdelay).ToString("yyyy-MM-dd HH:mm:ss");

                //            gaptime.Add(time);
                //        }
                //        info.gapinfo = gaptime;
                //        info.paralist = paralist;
                //        info.tagname = tagname;
                //        info.interval = interval;
                //    }
                //}
                ////如果没有
                //else
                //{
                info            = GetParaSegInfo(seg);
                info.batchBtime = Convert.ToDateTime(info.batchBtime).AddSeconds(batchheadDelay).ToString("yyyy-MM-dd HH:mm:ss");
                info.batchEtime = Convert.ToDateTime(info.batchEtime).AddSeconds(batchtailDelay).ToString("yyyy-MM-dd HH:mm:ss");
                info.tailBtime  = Convert.ToDateTime(info.tailBtime).AddSeconds(headDelay).ToString("yyyy-MM-dd HH:mm:ss");
                info.tailEtime  = Convert.ToDateTime(info.tailEtime).AddSeconds(tailDelay).ToString("yyyy-MM-dd HH:mm:ss");
                List <Gaptime> gaps = new List <Gaptime>();
                foreach (Gaptime gap in info.gapinfo)
                {
                    Gaptime g = new Gaptime();
                    g.starttime = Convert.ToDateTime(gap.starttime).AddSeconds(gap_hdelay).ToString("yyyy-MM-dd HH:mm:ss");
                    g.endtime   = Convert.ToDateTime(gap.endtime).AddSeconds(gap_tdelay).ToString("yyyy-MM-dd HH:mm:ss");
                    gaps.Add(g);
                }
                info.gapinfo  = gaps;
                info.paralist = paralist;
                info.tagname  = tagname;
                info.interval = interval;
            }
            #endregion
            return(info);
        }
示例#12
0
        public List <SectionTimeSeg> sectionTimeCut(string btime, string etime, string section)
        {
            List <SectionTimeSeg> listTimeseg = new List <SectionTimeSeg>();
            DbOperator            opt         = new DbOperator();
            string  query = "select starttime as rstime, 'b' as tag,PLANNO from ht_prod_report t where t.section_code = '" + section + "' and STARTTIME between '" + btime + "' and '" + etime + "' union select endtime as rstime,'e' as tag,PLANNO  from ht_prod_report t where t.section_code = '" + section + "' and endtime between '" + btime + "' and '" + etime + "'  order by rstime";
            DataSet data  = opt.CreateDataSetOra(query);

            if (data != null && data.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < data.Tables[0].Rows.Count; i++)
                {
                    SectionTimeSeg seg = new SectionTimeSeg();
                    seg.sectioncode = section;
                    seg.planno      = data.Tables[0].Rows[i]["PLANNO"].ToString();
                    String pathcode = opt.GetSegValue("select t.prod_code,s.path_code from ht_prod_month_plan_detail t left join ht_pub_prod_design s on s.prod_code = t.prod_code where t.plan_no = '" + seg.planno + "'", "path_code");
                    if (pathcode != "NoRecord" && pathcode != "")
                    {
                        String[] paths = pathcode.Split('-');
                        foreach (String path in paths)
                        {
                            if (path.Substring(0, 5) == seg.sectioncode)
                            {
                                seg.pathcode = path.Substring(5);
                            }
                        }
                    }
                    if (i == 0)
                    {
                        if (data.Tables[0].Rows[i]["tag"].ToString() == "e")
                        {
                            seg.starttime = btime;
                            seg.endtime   = data.Tables[0].Rows[i]["rstime"].ToString();
                            seg.type      = TimeSegType.END;
                            listTimeseg.Add(seg);
                        }
                        else
                        {
                            seg.starttime = data.Tables[0].Rows[i]["rstime"].ToString();
                            seg.endtime   = etime;
                            seg.type      = TimeSegType.BEGIN;
                            listTimeseg.Add(seg);
                        }
                    }
                    else if (i == data.Tables[0].Rows.Count - 1)
                    {
                        if (data.Tables[0].Rows[i]["tag"].ToString() == "b")
                        {
                            seg.starttime = data.Tables[0].Rows[i]["rstime"].ToString();
                            seg.endtime   = etime;
                            seg.type      = TimeSegType.BEGIN;
                            listTimeseg.Add(seg);
                        }
                    }
                    else
                    {
                        if (data.Tables[0].Rows[i - 1]["tag"].ToString() == "e" && data.Tables[0].Rows[i]["tag"].ToString() == "b")
                        {
                            continue;
                        }
                        if (data.Tables[0].Rows[i - 1]["tag"].ToString() == "b" && data.Tables[0].Rows[i]["tag"].ToString() == "e")
                        {
                            seg.starttime = data.Tables[0].Rows[i - 1]["rstime"].ToString();
                            seg.endtime   = data.Tables[0].Rows[i]["rstime"].ToString();
                            seg.type      = TimeSegType.BOTH;
                            listTimeseg.Add(seg);
                        }
                    }
                }
            }
            else
            {
                query = "select * from ht_prod_report where (starttime < '" + btime + "' and  endtime > '" + etime + "') or (starttime < '" + btime + "' and  endtime is null)";
                data  = opt.CreateDataSetOra(query);
                if (data != null && data.Tables[0].Rows.Count > 0)
                {
                    String pathcode = opt.GetSegValue("select t.prod_code,s.path_code from ht_prod_month_plan_detail t left join ht_pub_prod_design s on s.prod_code = t.prod_code where t.plan_no = '" + data.Tables[0].Rows[0]["PLANNO"].ToString() + "'", "path_code");
                    if (pathcode != "NoRecord" && pathcode != "")
                    {
                        String[] paths = pathcode.Split('-');
                        foreach (String path in paths)
                        {
                            if (path.Substring(0, 5) == section)
                            {
                                pathcode = path.Substring(5);
                            }
                        }
                    }
                    SectionTimeSeg seg = new SectionTimeSeg(btime, etime, TimeSegType.ALL, data.Tables[0].Rows[0]["PLANNO"].ToString(), section, pathcode, data.Tables[0].Rows[0]["starttime"].ToString());
                    listTimeseg.Add(seg);
                }
            }

            return(listTimeseg);
        }
示例#13
0
        /// <summary>
        /// /将一段时间按任务划分为不同的时间段
        /// </summary>
        /// <param name="btime"></param>
        /// <param name="etime"></param>
        /// <param name="nodeid"></param>
        /// <returns></returns>
        public List <TimeSeg> TimeCut(string btime, string etime, string nodeid)
        {
            List <TimeSeg> listTimeseg = new List <TimeSeg>();
            DbOperator     opt         = new DbOperator();
            string         query       = "select starttime, starttime as rstime, 'b' as tag,PLANNO from ht_prod_report t where t.section_code = '" + nodeid.Substring(0, 5) + "' and STARTTIME between '" + btime + "' and '" + etime + "' union select starttime,endtime as rstime,'e' as tag,PLANNO  from ht_prod_report t where t.section_code = '" + nodeid.Substring(0, 5) + "' and endtime between '" + btime + "' and '" + etime + "'  order by rstime";
            DataSet        data        = opt.CreateDataSetOra(query);

            if (data != null && data.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < data.Tables[0].Rows.Count; i++)
                {
                    TimeSeg seg = new TimeSeg();
                    seg.nodecode = nodeid;
                    seg.planno   = data.Tables[0].Rows[i]["PLANNO"].ToString();

                    if (i == 0)
                    {
                        if (data.Tables[0].Rows[i]["tag"].ToString() == "e")
                        {
                            seg.starttime  = btime;
                            seg.endtime    = data.Tables[0].Rows[i]["rstime"].ToString();
                            seg.batchStart = data.Tables[0].Rows[i]["starttime"].ToString();
                            // seg.planno = data.Tables[0].Rows[i]["PLANNO"].ToString();
                            seg.type = TimeSegType.END;
                            listTimeseg.Add(seg);
                        }
                        else
                        {
                            seg.starttime  = data.Tables[0].Rows[i]["rstime"].ToString();
                            seg.endtime    = etime;
                            seg.batchStart = data.Tables[0].Rows[i]["starttime"].ToString();
                            // seg.planno = data.Tables[0].Rows[i]["PLANNO"].ToString();
                            seg.type = TimeSegType.BEGIN;
                            listTimeseg.Add(seg);
                        }
                    }
                    else if (i == data.Tables[0].Rows.Count - 1)
                    {
                        if (data.Tables[0].Rows[i]["tag"].ToString() == "b")
                        {
                            seg.starttime  = data.Tables[0].Rows[i]["rstime"].ToString();
                            seg.endtime    = etime;
                            seg.batchStart = data.Tables[0].Rows[i]["starttime"].ToString();
                            // seg.planno = data.Tables[0].Rows[i]["PLANNO"].ToString();
                            seg.type = TimeSegType.BEGIN;
                            listTimeseg.Add(seg);
                        }
                    }
                    else
                    {
                        if (data.Tables[0].Rows[i - 1]["tag"].ToString() == "e" && data.Tables[0].Rows[i]["tag"].ToString() == "b")
                        {
                            continue;
                        }
                        if (data.Tables[0].Rows[i - 1]["tag"].ToString() == "b" && data.Tables[0].Rows[i]["tag"].ToString() == "e")
                        {
                            seg.starttime  = data.Tables[0].Rows[i - 1]["rstime"].ToString();
                            seg.endtime    = data.Tables[0].Rows[i]["rstime"].ToString();
                            seg.batchStart = data.Tables[0].Rows[i]["starttime"].ToString();
                            //  seg.planno = data.Tables[0].Rows[i]["PLANNO"].ToString();
                            seg.type = TimeSegType.BOTH;
                            listTimeseg.Add(seg);
                        }
                    }
                }
            }
            else
            {
                query = "select * from ht_prod_report where (starttime < '" + btime + "' and  endtime > '" + etime + "') or (starttime < '" + btime + "' and  endtime is null)";
                data  = opt.CreateDataSetOra(query);
                if (data != null && data.Tables[0].Rows.Count > 0)
                {
                    TimeSeg seg = new TimeSeg(btime, etime, TimeSegType.ALL, data.Tables[0].Rows[0]["PLANNO"].ToString(), nodeid, data.Tables[0].Rows[0]["starttime"].ToString());
                    listTimeseg.Add(seg);
                }
            }

            return(listTimeseg);
        }
示例#14
0
        public DataTable GetIHOrgDataSet(TimeSeg seg)
        {
            #region ///////////读取数据库中的采集条件////////////////////////////////////////////////////////////////////////////////////////////////
            DbOperator opt  = new DbOperator();
            DataSet    data = opt.CreateDataSetOra("select t.value_tag,r.gap_hdelay,r.gap_tdelay,r.ctrl_point,r.is_gap_judge,r.periodic,r.rst_value,r.gap_time,r.head_delay,r.tail_delay,r.batch_head_delay,r.batch_tail_delay from   HT_QLT_COLLECTION  r left join ht_pub_tech_para t on r.para_code = t.para_code where r.PARA_CODE = '" + seg.nodecode + "'");
            if (data == null || data.Tables[0].Rows.Count == 0)
            {
                return(null);
            }
            DataRow row = data.Tables[0].Rows[0];
            ////////////////////工艺点标签//////////////////////////////////////////////
            string tagname  = row["value_tag"].ToString();
            string interval = row["periodic"].ToString();
            int    timegap  = Convert.ToInt32(row["gap_time"].ToString());
            string tailRst  = row["rst_value"].ToString();
            ////////////////////是否为工艺段断流判定点/////////////////////////////////////////////
            bool gapctrl = ("1" == row["is_gap_judge"].ToString());

            //////////////////////偏移/////////////////////////////////////////////
            int headDelay      = Convert.ToInt32(row["head_delay"].ToString());       //料头
            int tailDelay      = Convert.ToInt32(row["tail_delay"].ToString());       //料尾
            int batchheadDelay = Convert.ToInt32(row["batch_head_delay"].ToString()); //批头
            int batchtailDelay = Convert.ToInt32(row["batch_tail_delay"].ToString()); //批尾
            int gap_hdelay     = Convert.ToInt32(row["gap_hdelay"].ToString());       //断流前
            int gap_tdelay     = Convert.ToInt32(row["gap_tdelay"].ToString());       //断流后
            #endregion
            #region                                                                   //////////////////////寻找数据批头尾、料头尾  以及断流信息///////////////////////////////////////////////////////////////////////
            string query;
            string batchBtime = "", batchEtime = "";                                  //电子秤参与后判定的批头批尾时间
            string tailBtime = "", tailEtime = "";                                    //电子秤参与后判定的料头料尾时间
            if (gapctrl)
            {
                if (tagname != "" && tailRst != "" && interval != "")
                {
                    batchBtime = tailBtime = seg.starttime;                            //初始化料头时间
                    batchEtime = tailEtime = seg.endtime;                              //初始化料尾时间
                    ///////////////////////////自动寻找批头批尾/////////////////////////////////////////////////
                    if (seg.type == TimeSegType.BEGIN || seg.type == TimeSegType.BOTH) //寻找批头
                    {
                        query = "SELECT  Min(timestamp),tagname  FROM ihrawdata where tagname = '" + tagname + "' and timestamp between '" + seg.starttime + "' and '" + seg.endtime + "'  and value  <" + tailRst + " group by tagname";
                        data  = CreateDataSetIH(query);
                        if (data != null && data.Tables[0].Select().Length > 0)
                        {
                            batchBtime = Convert.ToDateTime(data.Tables[0].Rows[0]["Min of timestamp"].ToString()).AddSeconds(batchheadDelay).ToString("yyyy-MM-dd HH:mm:ss");
                        }
                        ;                                                            //自动获取批头时间,向前推20秒
                    }
                    if (seg.type == TimeSegType.END || seg.type == TimeSegType.BOTH) //寻找批尾
                    {
                        string  temptime = Convert.ToDateTime(seg.endtime).AddHours(1).ToString("yyyy-MM-dd HH:mm:ss");
                        DataSet tempdata = CreateDataSetIH("select value from ihrawdata where tagname = '" + tagname + "' and timestamp between '" + seg.endtime + "' and '" + Convert.ToDateTime(seg.endtime).AddSeconds(60).ToString("yyyy-MM-dd HH:mm:ss") + "'");
                        double  temp     = 0;
                        if (tempdata != null && tempdata.Tables[0].Select().Length > 0)
                        {
                            temp = Convert.ToDouble(tempdata.Tables[0].Select()[0][0].ToString());
                        }
                        if (temp >= Convert.ToDouble(tailRst))
                        {
                            query = "SELECT  Min(timestamp),tagname  FROM ihrawdata where tagname = '" + tagname + "' and timestamp between '" + seg.endtime + "' and '" + temptime + "'  and value  <" + tailRst + " group by tagname";
                        }
                        else
                        {
                            query = "SELECT  Max(timestamp),tagname  FROM ihrawdata where tagname = '" + tagname + "' and timestamp between '" + tailBtime + "' and '" + seg.endtime + "'  and value  >" + tailRst + " group by tagname";
                        }
                        data = CreateDataSetIH(query);
                        if (data != null && data.Tables[0].Select().Length > 0)
                        {
                            if (temp >= Convert.ToDouble(tailRst))
                            {
                                batchEtime = Convert.ToDateTime(data.Tables[0].Rows[0]["Min of timestamp"].ToString()).AddSeconds(batchtailDelay).ToString("yyyy-MM-dd HH:mm:ss");//自动获取批尾时间
                            }
                            else
                            {
                                batchEtime = Convert.ToDateTime(data.Tables[0].Rows[0]["Max of timestamp"].ToString()).AddSeconds(batchtailDelay).ToString("yyyy-MM-dd HH:mm:ss");//自动获取批尾时间
                            }
                        }
                    }
                    ////////////////////////////////自动寻找料头料尾////////////////////////////////////////////////////////////////
                    if (seg.type == TimeSegType.BEGIN || seg.type == TimeSegType.BOTH)//寻找料头
                    {
                        query = "SELECT  Min(timestamp),tagname  FROM ihrawdata where tagname = '" + tagname + "' and timestamp between '" + batchBtime + "' and '" + batchEtime + "' and intervalmilliseconds =  " + interval + "s and value  >" + tailRst + " group by tagname";
                        data  = CreateDataSetIH(query);
                        if (data != null && data.Tables[0].Select().Length > 0)
                        {
                            tailBtime = Convert.ToDateTime(data.Tables[0].Rows[0]["Min of timestamp"].ToString()).AddSeconds(headDelay).ToString("yyyy-MM-dd HH:mm:ss");//经延时料头时间
                        }
                    }
                    if (seg.type == TimeSegType.END || seg.type == TimeSegType.BOTH)//寻找料尾
                    {
                        query = "SELECT  Max(timestamp),tagname  FROM ihrawdata where tagname = '" + tagname + "' and timestamp between '" + batchBtime + "' and '" + batchEtime + "' and intervalmilliseconds =  " + interval + "s and value  >" + tailRst + " group by tagname";
                        data  = CreateDataSetIH(query);
                        if (data != null && data.Tables[0].Select().Length > 0)
                        {
                            tailEtime = Convert.ToDateTime(data.Tables[0].Rows[0]["Max of timestamp"].ToString()).AddSeconds(tailDelay).ToString("yyyy-MM-dd HH:mm:ss");//经延时料尾时间
                        }
                    }
                    string[] bseg   = { "ORDERNO", "PLANNO", "STARTTIME", "ENDTIME", "SECTION_CODE", "BATCH_BTIME", "BATCH_ETIME", "GAP_BTIME", "GAP_ETIME", "TYPE", };
                    string[] bvalue = { "0", seg.planno, seg.starttime, seg.endtime, seg.nodecode.Substring(0, 5), batchBtime, batchEtime, tailBtime, tailEtime, "0" };
                    opt.MergeInto(bseg, bvalue, 5, "HT_QLT_GAP_COLLECTION");
                    ////////////////////选取数据/判断是否断料,并记录下相应的断料时间//////
                    gaptime = GetGapTime(tailBtime, tailEtime, tagname, tailRst, gap_hdelay, gap_tdelay, timegap);
                    int      orderno = 1;
                    string[] gapseg  = { "ORDERNO", "PLANNO", "STARTTIME", "ENDTIME", "SECTION_CODE", "GAPTIME ", "GAP_BTIME", "GAP_ETIME", "TYPE" };
                    if (gaptime != null)
                    {
                        foreach (Gaptime time in gaptime)
                        {
                            string[] gapvalue = { (orderno++).ToString(), seg.planno, seg.starttime, seg.endtime, seg.nodecode.Substring(0, 5), time.gaptime.ToString(), time.starttime, time.endtime, "1" };
                            opt.MergeInto(gapseg, gapvalue, 5, "HT_QLT_GAP_COLLECTION");
                        }
                    }
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                string ctrlpoint = row["ctrl_point"].ToString();
                if (ctrlpoint != "")
                {
                    DataSet gapdata = opt.CreateDataSetOra("select * from HT_QLT_GAP_COLLECTION where TYPE = '1' and  PLANNO = '" + seg.planno + "' and STARTTIME = '" + seg.starttime + "' and ENDTIME = '" + seg.endtime + "' and SECTION_CODE = '" + ctrlpoint.Substring(0, 5) + "' ");
                    if (gapdata != null && gapdata.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow grow in gapdata.Tables[0].Rows)
                        {
                            Gaptime time = new Gaptime();
                            time.gaptime   = Convert.ToInt32(grow["gaptime"].ToString());
                            time.starttime = Convert.ToDateTime(grow["STARTTIME"].ToString()).AddSeconds(gap_hdelay).ToString("yyyy-MM-dd HH:mm:ss");
                            time.endtime   = Convert.ToDateTime(grow["ENDTIME"].ToString()).AddSeconds(gap_tdelay).ToString("yyyy-MM-dd HH:mm:ss");
                            if (gaptime == null)
                            {
                                gaptime = new List <Gaptime>();
                            }
                            gaptime.Add(time);
                        }
                    }
                    gapdata = opt.CreateDataSetOra("select * from HT_QLT_GAP_COLLECTION where TYPE = '0' and  PLANNO = '" + seg.planno + "' and STARTTIME = '" + seg.starttime + "' and ENDTIME = '" + seg.endtime + "' and SECTION_CODE = '" + ctrlpoint.Substring(0, 5) + "' ");
                    if (gapdata != null && gapdata.Tables[0].Rows.Count > 0)
                    {
                        DataRow brow = gapdata.Tables[0].Rows[0];
                        batchBtime = brow["BATCH_BTIME"].ToString();
                        batchEtime = brow["BATCH_ETIME"].ToString();
                        tailBtime  = brow["GAP_BTIME"].ToString();
                        tailEtime  = brow["GAP_ETIME"].ToString();
                    }
                }
            }
            #endregion
            #region //////////////////////////////选择数据///////////////////////////////////////////////////////////////////////////////////////////////
            if (batchBtime != "")
            {
                seg.starttime = batchBtime;
            }
            if (batchEtime != "")
            {
                seg.endtime = batchEtime;
            }
            query = "SELECT  timestamp as 时间,value as 值  FROM ihrawdata where tagname = '" + tagname + "' and timestamp between '" + seg.starttime + "' and '" + seg.endtime + "' and intervalmilliseconds =  " + interval + "s order by timestamp ASC";
            data  = CreateDataSetIH(query);
            if (data != null && data.Tables[0].Select().Length > 0)
            {
                DataRow[] ResRows = data.Tables[0].Select();
                int       count   = ResRows.Length;
                DataTable ResT    = new DataTable();
                ResT = data.Tables[0];
                ResT.Columns.Add("状态");
                foreach (DataRow Res in ResRows)
                {
                    string tempstr = Convert.ToDateTime(Res["时间"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                    if (string.Compare(tempstr, tailBtime) < 0)
                    {
                        Res["状态"] = "料头";
                    }
                    else if (tailEtime != seg.starttime && string.Compare(tempstr, tailEtime) > 0)
                    {
                        Res["状态"] = "料尾";
                    }
                    else
                    {
                        Res["状态"] = "过程值";
                        if (gaptime != null)
                        {
                            int h = 0;
                            while (h < gaptime.Count)
                            {
                                if (string.Compare(tempstr, ((Gaptime)gaptime[h]).starttime) > 0 && string.Compare(tempstr, ((Gaptime)gaptime[h]).endtime) < 0)
                                {
                                    Res["状态"] = "断流值";
                                }
                                h++;
                            }
                        }
                    }
                }
                return(ResT);
            }
            else
            {
                return(null);
            }
            #endregion
        }