Example #1
0
        /// <summary>
        /// 获取监测结果列表
        /// </summary>
        /// <param name="condition">条件</param>
        /// <param name="page">数据页</param>
        /// <returns>数据页</returns>
        public DataPage GetList(InspectResultEntity condition, DataPage page)
        {
            string sql = null;
            List <DataParameter> parameters = new List <DataParameter>();

            try
            {
                sql = this.GetQuerySql(condition, ref parameters);

                //分页关键字段及排序
                page.KeyName = "Id";
                if (string.IsNullOrEmpty(page.SortExpression))
                {
                    page.SortExpression = " A.UpdateTime DESC ";
                }

                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    page = session.GetDataPage <InspectResultEntity>(sql, parameters.ToArray(), page);
                }

                return(page);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
 /// <summary>
 /// 获取统计数据列表
 /// </summary>
 /// <param name="condition">条件</param>
 /// <param name="page">数据页</param>
 /// <returns>数据页</returns>
 public List <InspectResultEntity> GetList(InspectResultEntity condition)
 {
     try
     {
         return(new InspectStatisticsEChartDAL().GetList(condition));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #3
0
 /// <summary>
 /// 获取监测设备列表
 /// </summary>
 /// <param name="condition">条件</param>
 /// <param name="page">数据页</param>
 /// <returns>数据页</returns>
 public DataPage GetList(InspectResultEntity condition, DataPage page)
 {
     try
     {
         return(new InspectResultDAL().GetList(condition, page));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #4
0
        private void BindData()
        {
            InspectStatisticsBLL bll       = null;
            DataPage             dp        = new DataPage();
            InspectResultEntity  condition = new InspectResultEntity();

            try
            {
                bll = BLLFactory.CreateBLL <InspectStatisticsBLL>();
                condition.ItemCode   = this.ItemCode.Text;
                condition.DeviceCode = this.DeviceCode.Text;
                condition.StartTime  = this.StartTime.Text;
                condition.EndTime    = this.EndTime.Text;
                condition.OrganID    = this.OrganID.Text;
                condition.DeviceType = this.DeviceType.Text;
                condition.ResultType = this.ResultType.Text;

                PagerHelper.InitPageControl(this.AspNetPager1, dp, true);
                dp = bll.GetList(condition, dp);

                List <InspectResultEntity> list = dp.Result as List <InspectResultEntity>;

                CommonDropdown  resultTypeDropdown = new CommonDropdown();
                List <DictInfo> resultTypeList     = resultTypeDropdown.getInspectResultType();

                foreach (InspectResultEntity ide in list)
                {
                    foreach (DictInfo di in resultTypeList)
                    {
                        if (di.ID.Equals(ide.ResultType))
                        {
                            ide.ResultType = di.Des;
                            break;
                        }
                    }
                }

                this.GvList.DataSource = list;
                this.GvList.DataBind();

                //for (int i = 0; i < this.GvList.Rows.Count; i++)
                //{
                //    string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["Id"].ToString());

                //    (this.GvList.Rows[i].Cells[6].Controls[0] as WebControl).Attributes.Add("onclick", click);
                //}
                PagerHelper.SetPageControl(AspNetPager1, dp, true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #5
0
        /// <summary>
        /// 获取监测统计列表
        /// </summary>
        /// <param name="condition">条件</param>
        /// <param name="page">数据页</param>
        /// <returns>数据页</returns>
        public List <InspectResultEntity> GetList(InspectResultEntity condition)
        {
            string sql = null;
            List <DataParameter> parameters = new List <DataParameter>();

            try
            {
                sql = this.GetQuerySql(condition, ref parameters);
                List <InspectResultEntity> resultList = null;
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    resultList = session.GetList <InspectResultEntity>(sql, parameters.ToArray()).ToList();
                }

                return(resultList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentEncoding = Encoding.UTF8;
            context.Response.ContentType     = "application/json";
            string ItemCode   = context.Request.QueryString["ItemCode"];
            string DeviceCode = context.Request.QueryString["DeviceCode"];
            string OrganID    = context.Request.QueryString["OrganID"];
            string DeviceType = context.Request.QueryString["DeviceType"];
            string ResultType = context.Request.QueryString["ResultType"];
            string StartTime  = context.Request.QueryString["StartTime"];

            InspectStatisticsEChartBLL bll         = BLLFactory.CreateBLL <InspectStatisticsEChartBLL>();
            InspectResultEntity        paramEntity = new InspectResultEntity();

            paramEntity.ResultType = ResultType;
            paramEntity.StartTime  = StartTime;
            paramEntity.ItemCode   = ItemCode;
            paramEntity.DeviceCode = DeviceCode;
            paramEntity.OrganID    = OrganID;
            paramEntity.DeviceType = DeviceType;

            List <InspectResultEntity> list = bll.GetList(paramEntity);

            CommonDropdown  deviceTypeDropdown = new CommonDropdown();
            List <DictInfo> deviceTypeList     = deviceTypeDropdown.getInspectDeviceType();

            CommonDropdown  resultTypeDropdown = new CommonDropdown();
            List <DictInfo> resultTypeList     = resultTypeDropdown.getInspectResultType();

            StringBuilder sb = new StringBuilder();

            if (list != null && list.Count > 0)
            {
                //记录项目种类列表
                List <string> legendList = new List <string>();
                legendList.Add("最大值");
                legendList.Add("最小值");
                legendList.Add("平均值");
                List <string> xList = new List <string>();
                foreach (InspectResultEntity ire in list)
                {
                    //统计X轴的时间列表
                    bool exist1 = false;
                    foreach (string ll in xList)
                    {
                        string temp = getStrByResultType(ire.InspectTime, ResultType);

                        if (temp == ll)
                        {
                            exist1 = true;
                            break;
                        }
                    }
                    if (!exist1)
                    {
                        xList.Add(getStrByResultType(ire.InspectTime, ResultType));
                    }
                }


                string echartTitle = "采集数据";
                echartTitle += resultTypeList.Find(p => p.ID == ResultType).Des;
                echartTitle += "变化";

                ///子标题
                string subText = StartTime;

                sb.Append(" {      ");
                sb.Append(" \"title\" : {     ");
                sb.Append("     \"text\": \"" + echartTitle + "\",     ");
                sb.Append("     \"subtext\": \"" + subText + "\"     ");
                sb.Append(" },     ");
                sb.Append(" \"tooltip\" : {     ");
                sb.Append("     \"trigger\": \"axis\"     ");
                sb.Append(" },     ");
                sb.Append(" \"legend\": {     ");
                string data  = "";
                int    index = 0;
                foreach (string d in legendList)
                {
                    data += ("\"" + d + "\"");
                    if (index < legendList.Count - 1)
                    {
                        data += ",";
                    }
                    index++;
                }
                sb.Append("     \"data\":[" + data + "]     ");
                sb.Append(" },     ");
                sb.Append(" \"toolbox\": {     ");
                sb.Append("     \"show\" : true,     ");
                sb.Append("     \"feature\" : {     ");
                sb.Append("        \"mark\" : {\"show\": true},     ");
                sb.Append("         \"magicType\" : {\"show\": true, \"type\": [\"line\", \"bar\"]},     ");
                sb.Append("         \"saveAsImage\" : {\"show\": true}     ");
                sb.Append("     }     ");
                sb.Append(" },     ");
                sb.Append(" \"calculable\" : \"true\",     ");
                sb.Append(" \"xAxis\" : [     ");
                sb.Append("     {     ");
                sb.Append("         \"type\" : \"category\",     ");
                sb.Append("         \"boundaryGap\" : \"false\",     ");

                string xdata  = "";
                int    xindex = 0;
                foreach (string d in xList)
                {
                    xdata += ("\"" + d + "\"");
                    if (xindex < xList.Count - 1)
                    {
                        xdata += ",";
                    }
                    xindex++;
                }

                sb.Append("         \"data\" : [" + xdata + "]     ");
                sb.Append("    }     ");
                sb.Append(" ],     ");
                sb.Append(" \"yAxis\" : [     ");
                sb.Append("     {     ");
                sb.Append("         \"type\" : \"value\"     ");
                sb.Append("     }     ");
                sb.Append(" ],     ");
                sb.Append(" \"series\" : [     ");

                int aa = 0;
                foreach (string d in legendList)
                {
                    string values = "";
                    int    kk     = 0;
                    foreach (InspectResultEntity ire in list)
                    {
                        if (d == "最大值")
                        {
                            values += ("\"" + ire.MaxDataValue + "\"");
                        }
                        else if (d == "最小值")
                        {
                            values += ("\"" + ire.MinDataValue + "\"");
                        }
                        else
                        {
                            values += ("\"" + ire.AvgValue + "\"");
                        }

                        if (kk < list.Count - 1)
                        {
                            values += ",";
                        }
                        kk++;
                    }

                    sb.Append(" {     ");
                    sb.Append("     \"name\":\"" + d + "\",     ");
                    sb.Append("     \"type\":\"line\",     ");
                    sb.Append("     \"data\":[" + values + "]     ");
                    //sb.Append("     \"markPoint\" : {     ");
                    //sb.Append("         \"data\" : [     ");
                    //sb.Append("             {\"type\" : \"max\", \"name\": \"最大值\"},     ");
                    //sb.Append("             {\"type\" : \"min\", \"name\": \"最小值\"}     ");
                    //sb.Append("         ]     ");
                    //sb.Append("    }       ");
                    sb.Append(" }     ");
                    if (aa < legendList.Count - 1)
                    {
                        sb.Append(",");
                    }
                    aa++;
                }


                //sb.Append(" {    ");
                //sb.Append(" \"name\":\"最低气温\",    ");
                //sb.Append(" \"type\":\"line\",    ");
                //sb.Append(" \"data\":[1, -2, 2, 5, 3, 2, 0],    ");
                //sb.Append(" \"markPoint\" : {    ");
                //sb.Append("     \"data\" : [    ");
                //sb.Append("         {\"name\" : \"周最低\", \"value\" : -2, \"xAxis\": 1, \"yAxis\": -1.5}    ");
                //sb.Append("     ]    ");
                //sb.Append(" },    ");
                //sb.Append(" \"markLine\" : {    ");
                //sb.Append("     \"data\" : [    ");
                //sb.Append("         {\"type\" : \"average\", \"name\" : \"平均值\"}    ");
                //sb.Append("     ]    ");
                //sb.Append(" }    ");
                //sb.Append(" }    ");
                sb.Append(" ]     ");
                sb.Append(" }     ");
            }

            context.Response.Write(sb.ToString());
        }
Example #7
0
        /// <summary>
        /// 获取查询语句
        /// </summary>
        /// <param name="condition">查询条件</param>
        /// <param name="parameters">查询</param>
        /// <returns>查询语句</returns>
        private string GetQuerySql(InspectResultEntity condition, ref List <DataParameter> parameters)
        {
            StringBuilder sqlBuilder   = new StringBuilder();
            StringBuilder whereBuilder = new StringBuilder();

            sqlBuilder.Append(" SELECT A.ID AS Id,A.DeviceCode,D.DeviceName,A.OrganID,O.ORGANDESC AS OrganDESC,A.UpdateTime,A.ResultType, ");
            sqlBuilder.Append(" A.ItemCode,T.ItemName,A.InspectTime,A.MaxDataValue,A.MinDataValue,A.AvgValue ");
            sqlBuilder.Append(" FROM inspectcalcresult A  ");
            sqlBuilder.Append(" LEFT JOIN deviceinfo D ON A.DeviceCode = D.DeviceCode ");
            sqlBuilder.Append(" LEFT JOIN inspectiteminfo T ON A.ItemCode = T.ItemCode ");
            sqlBuilder.Append(" LEFT JOIN t_organization O ON A.OrganID = O.OrganID ");

            //查询条件
            if (!string.IsNullOrEmpty(condition.DeviceCode))
            {
                whereBuilder.Append(" AND A.DeviceCode = @DeviceCode");
                parameters.Add(new DataParameter {
                    ParameterName = "DeviceCode", DataType = DbType.String, Value = condition.DeviceCode
                });
            }

            if (string.IsNullOrEmpty(condition.ItemCode) == false)
            {
                whereBuilder.Append(" AND A.ItemCode = @ItemCode");
                parameters.Add(new DataParameter {
                    ParameterName = "ItemCode", DataType = DbType.String, Value = condition.ItemCode
                });
            }

            if (string.IsNullOrEmpty(condition.DeviceType) == false)
            {
                whereBuilder.Append(" AND D.DeviceType = @DeviceType");
                parameters.Add(new DataParameter {
                    ParameterName = "DeviceType", DataType = DbType.String, Value = condition.DeviceType
                });
            }

            if (string.IsNullOrEmpty(condition.OrganID) == false)
            {
                whereBuilder.Append(" AND O.OrganID = @OrganID");
                parameters.Add(new DataParameter {
                    ParameterName = "OrganID", DataType = DbType.String, Value = condition.OrganID
                });
            }

            if (!string.IsNullOrEmpty(condition.StartTime))
            {
                whereBuilder.Append(" AND A.InspectTime >= @StartTime");
                parameters.Add(new DataParameter("StartTime", DateTime.Parse(condition.StartTime)));
            }

            if (!string.IsNullOrEmpty(condition.EndTime))
            {
                whereBuilder.Append(" AND A.InspectTime < @EndTime");
                parameters.Add(new DataParameter("EndTime", DateTime.Parse(condition.EndTime + " 23:59:59")));
            }

            if (whereBuilder.Length > 0)
            {
                sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
            }

            return(sqlBuilder.ToString());
        }