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
using Newtonsoft.Json.Linq;
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>
    /// DataLake1 的摘要说明
    /// </summary>
    public class DataLake1 : 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 GetLakeMessage(HttpContext context)
        {
            string where = context.Request["type"];
            GetTableBySql gt = new GetTableBySql();
            DataTable dt = gt.GetLakeUrl(where);
            string jsonStr = DataTableToJson.DtToJson(dt);
            context.Response.Write(jsonStr);
 
        }
 
        //获取当前统计的数据信息
        public void GetCurrentArea(HttpContext context)
        {
            string where = context.Request["pathName"];
            DataLake gt = new DataLake();
            DataTable dt = gt.GetCurrentArea(where);
            string jsonStr = DataTableToJson.DtToJson(dt);
            context.Response.Write(jsonStr);
        }
 
        public void GetManyYearAndManyName(HttpContext context)
        {
            string where = context.Request["pathName"];
            //转化json对象
            JArray jo = JArray.Parse(where);
 
            string sql = "";
            for (int i = 0; i < jo.Count; i++)
            {
                if (i == 0)
                {
                    sql += string.Format(@"(select  SUM(CAST(area as FLOAT))  lakeArea,simName,[time] from SSHP where [time]='{0}' 
                        AND name='{1}'  GROUP BY [time],simName
                        union all
                        select '0' as lakeArea,'{2}' as simName,'{0}' as year where not exists(select  SUM(CAST(area as FLOAT)) 
                        lakeArea, simName,[time] from SSHP where [time] = '{0}'
                        AND name = '{1}' GROUP BY[time], simName))", jo[i]["year"].ToString(), jo[i]["name"].ToString(), jo[i]["titleName"].ToString());
                }
                else
                {
                    sql += string.Format(@" union all (select  SUM(CAST(area as FLOAT))  lakeArea,simName,[time] from SSHP where [time]='{0}' 
                        AND name='{1}'  GROUP BY [time],simName
                        union all
                        select '0' as lakeArea,'{2}' as simName,'{0}' as year where not exists(select  SUM(CAST(area as FLOAT)) 
                        lakeArea, simName,[time] from SSHP where [time] = '{0}'
                        AND name = '{1}' GROUP BY [time], simName))", jo[i]["year"].ToString(), jo[i]["name"].ToString(), jo[i]["titleName"].ToString());
                }
            }
            sql = sql + "order by simName,[time]";
            DataLake gt = new DataLake();
            DataTable dt = gt.GetManyYearAndManyLake(sql);
            string jsonStr = DataTableToJson.DtToJson(dt);
            context.Response.Write(jsonStr);
        }
 
        //获取数据
        public void GetAllSumData(HttpContext context)
        {
            string tableName = context.Request["pathName"];
            string sql = string.Format(@"select  SUM(CAST(area as FLOAT))  Area,[Year]  from  {0} GROUP BY [Year] ;", tableName);
            DataLake gt = new DataLake();
            DataTable dt = gt.GetManyYearAndManyLake(sql);
            string jsonStr = DataTableToJson.DtToJson(dt);
            context.Response.Write(jsonStr);
        }
 
        //获取TDGF的数据
        public void GetAllChooseDataTDGF(HttpContext context)
        {
            string where = context.Request["pathName"];
            //转化json对象
            JArray jo = JArray.Parse(where);
 
            string sql = "";
            for (int i = 0; i < jo.Count; i++)
            {
                if (i == 0)
                {
                    sql += string.Format(@"(select  SUM(CAST(area as FLOAT))  Area,[Year] from TDGF where [Year]='{0}' GROUP BY [Year]
                         union all
                        select '0' as Area, '{0}' as [Year] where not exists(select  SUM(CAST(area as FLOAT))  Area,[Year] from TDGF where [Year]='{0}' 
                        GROUP BY [Year]))", jo[i]);
                }
                else
                {
                    sql += string.Format(@" union all (select  SUM(CAST(area as FLOAT))  Area,[Year] from TDGF where [Year]='{0}' GROUP BY [Year]
                        union all
                        select '0' as Area, '{0}' as [Year] where not exists(select  SUM(CAST(area as FLOAT))  Area,[Year] from TDGF where [Year]='{0}' 
                        GROUP BY [Year]))", jo[i]);
                }
            }
            sql = sql + "order by [Year]";
            DataLake gt = new DataLake();
            DataTable dt = gt.GetManyYearAndManyLake(sql);
            string jsonStr = DataTableToJson.DtToJson(dt);
            context.Response.Write(jsonStr);
        }
 
 
        //获取湖泊的年份
        public  void GetHPyear(HttpContext context)
        {
            string where = context.Request["simName"];
            string[] arr = where.Split('*');
            string  wherecase= "";
            for(var i = 0; i < arr.Length; i++)
            {
                wherecase += "'"+arr[i]+"',";
            }
            string sql = string.Format(@"select  [time]  from  SSHP where simName in ({0}) GROUP BY [time]",
                wherecase.Substring(0,wherecase.Length-1));
            DataLake gt = new DataLake();
            DataTable dt = gt.GetYear(sql);
            string jsonStr = DataTableToJson.DtToJson(dt);
            context.Response.Write(jsonStr);
        }
 
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}