13693261870
2024-04-02 2a1b873b4b78b508d5d53c57992e734c56619df8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Web;
using Terra.YaoGan.Common;
using Terra.YaoGan.Service;
 
namespace Terra.YaoGan.Web.Ashx
{
    /// <summary>
    /// DataQH 的摘要说明
    /// </summary>
    public class DataQH : IHttpHandler
    {
 
        public void ProcessRequest(HttpContext context)
        {
            string Action = context.Request["Action"];
 
            MethodInfo mif = this.GetType().GetMethod(Action);
            if (mif != null)
            {
                mif.Invoke(this, new object[] { context });
            }
        }
 
        //获取初始展示数据
        public  void GetAllQHData(HttpContext context)
        {
            string dtTable = context.Request["dataTable"];
            string clTable = context.Request["colorTable"];
            string sql = string.Format(@"SELECT  SUM(CAST (Area as FLOAT)) Area, SUM( CAST  (ZhouChang as FLOAT)) ZhouChang,ThirdLevel,Name ,R,G,B  
                                        from  {0}   LEFT JOIN  {1}  ON  ThirdLevel=Code GROUP BY ThirdLevel,Name,R,G,B ", dtTable,clTable);
            GetTableCommon gt = new GetTableCommon();
            DataTable dt = gt.GetTable(sql);
            string jsonStr = DataTableToJson.DtToJson(dt);
            context.Response.Write(jsonStr);
 
        }
 
        //获取数据颜色
        public void GetColor(HttpContext context)
        {
            string clTable = context.Request["colorTable"];
            string sql = string.Format(@"select  *  from  {0}  ORDER BY Code,Type DESC;", clTable);
            GetTableCommon gt = new GetTableCommon();
            DataTable dt = gt.GetTable(sql);
            string jsonStr = DataTableToJson.DtToJson(dt);
            context.Response.Write(jsonStr);
        }
 
        //获取青海2014年国土遥感调查成果湿地数据
        public void GetQHFZData(HttpContext context)
        {
            string dtTable = context.Request["dataTable"];
            string clTable = context.Request["colorTable"];
            string sql = string.Format(@"select   cr.Name,cr.R,cr.G,cr.B,cr.Type,lv.*  FROM {0}  cr RIGHT JOIN ( SELECT  SUM(CAST (Area as FLOAT)) Area,SUM(CAST (ZhouChang as FLOAT)) ZhouChang,SecondLevel fr  from  {1} where SecondLevel<>'' 
                                        GROUP BY SecondLevel) lv ON lv.fr=cr.Code 
                                        UNION
select cr.Name,cr.R,cr.G,cr.B,cr.Type,lv.* from {0} cr RIGHT JOIN (select  SUM(CAST(Area as FLOAT)) Area, SUM(CAST (ZhouChang as FLOAT)) ZhouChang,ThirdLevel fr from 
 {1} WHERE ThirdLevel<>''  GROUP BY ThirdLevel ) lv ON cr.Code=lv.fr ORDER BY lv.fr,Type DESC",clTable,dtTable);
            GetTableCommon gt = new GetTableCommon();
            DataTable dt = gt.GetTable(sql);
            string jsonStr = DataTableToJson.DtToJson(dt);
            context.Response.Write(jsonStr);
        }
 
 
 
        //获取筛选数据
        public  void GetSearchQHData(HttpContext context)
        {
            try
            {
                string second= context.Request["secondLevel"];
                string sStr = "";
                string colorTable = context.Request["colorTable"];
                string dataTable = context.Request["dataTable"];
                if (second != "")
                {
                    string[] sArr = second.Split('*');
                    for(int i = 0; i < sArr.Length; i++)
                    {
                        sStr += "'" + sArr[i] + "',";
                    }
                }
 
 
 
                string sql = string.Format(@"SELECT * FROM (select Code,  R,G,B,Name  FROM  {0} WHERE  Name in({1})) cr 
                        INNER  JOIN 
                        (select  ThirdLevel, SUM(CAST(Area as FLOAT)) Area, SUM(CAST (ZhouChang as FLOAT)) ZhouChang  from  {2} GROUP BY ThirdLevel)
                        ct on cr.Code=ct.ThirdLevel", colorTable,sStr.Substring(0,sStr.Length-1),dataTable);
 
 
 
                GetTableCommon gt = new GetTableCommon();
                DataTable dt = gt.GetTable(sql);
                string jsonStr = DataTableToJson.DtToJson(dt);
                context.Response.Write(jsonStr);
            }
            catch
            {
                context.Response.Write("");
            }
 
        }
 
        //获取筛选复杂数据统计
        public void GetFZDataChoose(HttpContext context)
        {
            string dtTable = context.Request["dataTable"];
            string clTable = context.Request["colorTable"];
            string first = context.Request["firstLevel"];
            string firstStr = "";
            string second = context.Request["secondLevel"];
            string secondStr = "";
 
            if (first != "")
            {
                string[] sarr = first.Split('*');
                for(int i = 0; i < sarr.Length; i++)
                {
                    firstStr += "'"+sarr[i] + "',";
                }
               
            }
 
            if (second != "")
            {
                string[] sarr = second.Split('*');
                for (int i = 0; i < sarr.Length; i++)
                {
                    secondStr += "'"+sarr[i] + "',";
                }
 
            }
 
            string sql = "", sql1 = "", sql2 = "";
 
            if (firstStr != "")
            {
                sql1 =string.Format(@"SELECT * FROM (select  Code,  R,G,B,Name,Type  FROM  {0}  WHERE Type='parent' And Name in ({1})  ) cr 
 INNER  JOIN 
(select  SecondLevel level, SUM(CAST(Area as FLOAT)) Area, SUM(CAST (ZhouChang as FLOAT)) ZhouChang  from  {2} GROUP BY SecondLevel)
ct on cr.Code=ct.level", clTable,firstStr.Substring(0,firstStr.Length-1),dtTable);
            }
 
            if (secondStr != "")
            {
                sql2 = string.Format(@"SELECT * FROM (select  Code,  R,G,B,Name,Type  FROM  {0} where  (Type IS NULL or Type='') And Name in({1}) ) cr 
 INNER  JOIN 
(select  ThirdLevel level, SUM(CAST(Area as FLOAT)) Area, SUM(CAST (ZhouChang as FLOAT)) ZhouChang  from  {2} GROUP BY ThirdLevel)
ct on cr.Code=ct.level ", clTable, secondStr.Substring(0, secondStr.Length - 1), dtTable);
            }
 
            if (sql1 != "" & sql2 != "")
            {
                sql = sql1 + " union all " + sql2 + " ORDER BY Code,Type  DESC";
            }else
            {
                sql = sql1 + sql2 + " ORDER BY Code,Type  DESC";
 
            }
 
            GetTableCommon gt = new GetTableCommon();
            DataTable dt = gt.GetTable(sql);
            string jsonStr = DataTableToJson.DtToJson(dt);
            context.Response.Write(jsonStr);
 
 
 
        }
 
 
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}