Beispiel #1
0
        public HttpResponseMessage Getcityata(DataParameter DP)
        {
            string result    = "";
            string defwhere  = "1=1";
            string defwhere2 = "1=1";
            string where1    = "";
            string where2    = "";
            string where3    = "";
            string where4    = "";
            string where5    = "";


            try
            {
                if (rule.Judge(DP.stcode))
                {
                    defwhere  += " and fldSTCode='" + DP.stcode + "'";
                    defwhere2 += " and fldSTCode='" + DP.stcode + "'";
                }

                if (rule.JudgeLevel(DP.level))
                {
                    defwhere  += " and fldLevel='" + DP.level + "'";
                    defwhere2 += " and fldLevel='" + DP.level + "'";
                }
                if (rule.Judge(DP.TimeType))
                {
                    defwhere  += " and fldDType='" + DP.TimeType + "'";
                    defwhere2 += " and fldDType='累计'";
                }
                else
                {
                    result = rule.JsonStr("error", "时间类型不正确!", "");
                    return(new HttpResponseMessage {
                        Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                    });
                }
                if (rule.istime(DP.BeginDate) && rule.istime(DP.EndDate))
                {
                    if (DP.TimeType == "month")
                    {
                        DateTime dtime = DateTime.Parse(DP.BeginDate);
                        if (dtime.Month < 10)
                        {
                            string ti = dtime.Year + "年0" + dtime.Month + "月";
                            where1 += " and fldDate='" + ti + "'";
                            where2 += rule.strtime(ti, "累计");
                            where3 += " and fldDate='" + (dtime.Year - 1) + "年0" + dtime.Month + "月" + "'";

                            where4 += " and fldDate<='" + ti + "' and fldDate>='" + dtime.Year + "年01'";

                            where5 += " and fldDate<='" + (dtime.Year - 1) + "年0" + dtime.Month + "月" + "' and fldDate>='" + (dtime.Year - 1) + "年01月'";
                        }
                        else
                        {
                            string ti = dtime.Year + "年" + dtime.Month + "月";
                            where1 += " and fldDate='" + ti + "'";
                            where2 += rule.strtime(ti, "累计");
                            where3 += " and fldDate='" + (dtime.Year - 1) + "年" + dtime.Month + "月" + "'";

                            where4 += " and fldDate<='" + ti + "' and fldDate>='" + dtime.Year + "年01'";

                            where5 += " and fldDate<='" + (dtime.Year - 1) + "年" + dtime.Month + "月" + "' and fldDate>='" + (dtime.Year - 1) + "年01月'";
                        }
                    }
                    if (DP.TimeType == "sea")
                    {
                        DateTime dtime = DateTime.Parse(DP.EndDate);
                        string   ti3   = dtime.Year + "年" + dtime.Month + "月";
                        string   ti    = "";
                        string   ti2   = "";
                        if (dtime.Month == 3)
                        {
                            ti  = dtime.Year + "年1季度";
                            ti2 = (dtime.Year - 1) + "年1季度";
                        }
                        if (dtime.Month == 6)
                        {
                            ti  = dtime.Year + "年2季度";
                            ti2 = (dtime.Year - 1) + "年2季度";
                        }
                        if (dtime.Month == 9)
                        {
                            ti  = dtime.Year + "年3季度";
                            ti2 = (dtime.Year - 1) + "年3季度";
                        }
                        if (dtime.Month == 12)
                        {
                            ti  = dtime.Year + "年4季度";
                            ti2 = (dtime.Year - 1) + "年4季度";
                        }
                        where1 += " and fldDate='" + ti + "'";
                        where2 += rule.strtime(ti3, "累计");
                        where3 += " and fldDate='" + ti2 + "'";

                        where4 += " and fldDate<='" + ti + "' and fldDate>='" + dtime.Year + "年1季度'";

                        where5 += " and fldDate<='" + ti2 + "' and fldDate>='" + (dtime.Year - 1) + "年1季度'";
                    }
                    if (DP.TimeType == "year")
                    {
                        DateTime dtime = DateTime.Parse(DP.EndDate);
                        string   ti3   = dtime.Year + "年";
                        string   ti    = "";
                        string   ti2   = (dtime.Year - 1) + "年";

                        where1 += " and fldDate='" + ti3 + "'";
                        where2 += rule.strtime(ti3, "累计");
                        where3 += " and fldDate='" + ti2 + "'";
                    }
                }
                else
                {
                    result = rule.JsonStr("error", "时间格式不正确!", "");
                    return(new HttpResponseMessage {
                        Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                    });
                }

                //当期
                string sql = "select * from tblEQIW_R_CityData where " + defwhere + where1;
                //累计
                string sql2 = "select * from tblEQIW_R_CityData where " + defwhere2 + where2;
                //同期
                string sql3 = "select * from tblEQIW_R_CityData where " + defwhere + where3;

                string sql4 = "select * from tblEQIW_R_CityData where " + defwhere + where4;

                string sql5 = "select * from tblEQIW_R_CityData where " + defwhere + where5;

                DataTable dt  = rule.GetMiddleData(sql);
                DataTable dt2 = rule.GetMiddleData(sql2);
                DataTable dt3 = rule.GetMiddleData(sql3);

                DataTable dt4 = rule.GetMiddleData(sql4);
                DataTable dt5 = rule.GetMiddleData(sql5);

                retudt tt = new retudt();
                tt.DQ   = dt;
                tt.LJ   = dt2;
                tt.TQ   = dt3;
                tt.DQFW = dt4;
                tt.TQFW = dt5;
                result  = rule.JsonStr("ok", "", tt);
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
        public HttpResponseMessage GetItemOver(DataParameter DP)
        {
            string result    = "";
            string defwhere  = "1=1";
            string defwhere2 = "1=1";
            string where1    = "";
            string where2    = "";
            string where3    = "";

            try
            {
                if (rule.Judge(DP.spacecode))
                {
                    defwhere  += " and fldSpaceCode='" + DP.spacecode + "'";
                    defwhere2 += " and fldSpaceCode='" + DP.spacecode + "'";
                }
                if (rule.Judge(DP.spacename))
                {
                    defwhere  += " and fldSpaceName='" + DP.spacename + "'";
                    defwhere2 += " and fldSpaceName='" + DP.spacename + "'";
                }
                if (rule.Judge(DP.stattype))
                {
                    defwhere  += " and fldStatType='" + DP.stattype + "'";
                    defwhere2 += " and fldStatType='" + DP.stattype + "'";
                }
                if (rule.JudgeLevel(DP.level))
                {
                    defwhere  += " and fldLevel='" + DP.level + "'";
                    defwhere2 += " and fldLevel='" + DP.level + "'";
                }
                if (rule.Judge(DP.TimeType))
                {
                    defwhere  += " and fldDType='" + DP.TimeType + "'";
                    defwhere2 += " and fldDType='累计'";
                }
                else
                {
                    result = rule.JsonStr("error", "时间类型不正确!", "");
                    return(new HttpResponseMessage {
                        Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                    });
                }
                #region
                if (rule.istime(DP.BeginDate) && rule.istime(DP.EndDate))
                {
                    if (DP.TimeType == "month")
                    {
                        DateTime dtime = DateTime.Parse(DP.BeginDate);
                        if (dtime.Month < 10)
                        {
                            string ti = dtime.Year + "年0" + dtime.Month + "月";
                            where1 += " and fldDate='" + ti + "'";
                            where2 += rule.strtime(ti, "累计");
                            where3 += " and fldDate='" + (dtime.Year - 1) + "年0" + dtime.Month + "月" + "'";
                        }
                        else
                        {
                            string ti = dtime.Year + "年" + dtime.Month + "月";
                            where1 += " and fldDate='" + ti + "'";
                            where2 += rule.strtime(ti, "累计");
                            where3 += " and fldDate='" + (dtime.Year - 1) + "年" + dtime.Month + "月" + "'";
                        }
                    }
                    if (DP.TimeType == "sea")
                    {
                        DateTime dtime = DateTime.Parse(DP.EndDate);
                        string   ti3   = dtime.Year + "年" + dtime.Month + "月";
                        string   ti    = "";
                        string   ti2   = "";
                        if (dtime.Month == 3)
                        {
                            ti  = dtime.Year + "年1季度";
                            ti2 = (dtime.Year - 1) + "年1季度";
                        }
                        if (dtime.Month == 6)
                        {
                            ti  = dtime.Year + "年2季度";
                            ti2 = (dtime.Year - 1) + "年2季度";
                        }
                        if (dtime.Month == 9)
                        {
                            ti  = dtime.Year + "年3季度";
                            ti2 = (dtime.Year - 1) + "年3季度";
                        }
                        if (dtime.Month == 12)
                        {
                            ti  = dtime.Year + "年4季度";
                            ti2 = (dtime.Year - 1) + "年4季度";
                        }
                        where1 += " and fldDate='" + ti + "'";
                        where2 += rule.strtime(ti3, "累计");
                        where3 += " and fldDate='" + ti2 + "'";
                    }
                    if (DP.TimeType == "year")
                    {
                        DateTime dtime = DateTime.Parse(DP.EndDate);
                        string   ti3   = dtime.Year + "年";
                        string   ti    = "";
                        string   ti2   = (dtime.Year - 1) + "年";
                        where1 += " and fldDate='" + ti3 + "'";
                        where2 += rule.strtime(ti3, "累计");
                        where3 += " and fldDate='" + ti2 + "'";
                    }
                }
                else
                {
                    result = rule.JsonStr("error", "时间格式不正确!", "");
                    return(new HttpResponseMessage {
                        Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                    });
                }
                #endregion
                string sql  = "";
                string sql2 = "";
                string sql3 = "";
                if (DP.stattype != "流域")
                {
                    sql  = "select * from vwtblEQIW_R_ItemOver where " + defwhere + where1;
                    sql2 = "select * from vwtblEQIW_R_ItemOver where " + defwhere2 + where2;
                    sql3 = "select * from vwtblEQIW_R_ItemOver where " + defwhere + where3;
                }
                else
                {
                    sql  = "select * from tblEQIW_R_ItemOver where " + defwhere + where1;
                    sql2 = "select * from tblEQIW_R_ItemOver where " + defwhere2 + where2;
                    sql3 = "select * from tblEQIW_R_ItemOver where " + defwhere + where3;
                }

                DataTable dt  = rule.GetMiddleData(sql);
                DataTable dt2 = rule.GetMiddleData(sql2);
                DataTable dt3 = rule.GetMiddleData(sql3);

                retudt tt = new retudt();
                tt.DQ  = dt;
                tt.LJ  = dt2;
                tt.TQ  = dt3;
                result = rule.JsonStr("ok", "", tt);
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }
Beispiel #3
0
        public HttpResponseMessage GetRiverTabledata(DataParameter DP)
        {
            string result    = "";
            string defwhere  = "1=1";
            string defwhere2 = "1=1";
            string where1    = "";
            string where2    = "";
            string where3    = "";

            try
            {
                if (rule.JudgeLevel(DP.level))
                {
                    defwhere  += " and fldLevel='" + DP.level + "'";
                    defwhere2 += " and fldLevel='" + DP.level + "'";
                }
                if (rule.Judge(DP.TimeType))
                {
                    defwhere  += " and fldDType='" + DP.TimeType + "'";
                    defwhere2 += " and fldDType='" + DP.TimeType + "'";
                }
                else
                {
                    result = rule.JsonStr("error", "时间类型不正确!", "");
                    return(new HttpResponseMessage {
                        Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                    });
                }
                if (rule.istime(DP.BeginDate) && rule.istime(DP.EndDate))
                {
                    if (DP.TimeType == "month")
                    {
                        DateTime dtime = DateTime.Parse(DP.BeginDate);
                        if (dtime.Month < 10)
                        {
                            string ti = dtime.Year + "年0" + dtime.Month + "月";
                            where1 += " and fldDate='" + ti + "'";
                            if (dtime.Month == 1)
                            {
                                where2 += " and fldDate='" + (dtime.Year - 1) + "年12月'";
                            }
                            else
                            {
                                where2 += " and fldDate='" + dtime.Year + "年0" + (dtime.Month - 1) + "月'";
                            }
                        }
                        else
                        {
                            string ti = dtime.Year + "年" + dtime.Month + "月";
                            where1 += " and fldDate='" + ti + "'";

                            where2 += " and fldDate='" + dtime.Year + "年" + (dtime.Month - 1) + "月'";
                        }
                    }
                    if (DP.TimeType == "sea")
                    {
                        DateTime dtime = DateTime.Parse(DP.EndDate);
                        string   ti3   = dtime.Year + "年" + dtime.Month + "月";
                        string   ti    = "";
                        string   ti2   = "";
                        if (dtime.Month == 3)
                        {
                            ti  = dtime.Year + "年1季度";
                            ti2 = (dtime.Year - 1) + "年4季度";
                        }
                        if (dtime.Month == 6)
                        {
                            ti  = dtime.Year + "年2季度";
                            ti2 = (dtime.Year) + "年1季度";
                        }
                        if (dtime.Month == 9)
                        {
                            ti  = dtime.Year + "年3季度";
                            ti2 = (dtime.Year) + "年2季度";
                        }
                        if (dtime.Month == 12)
                        {
                            ti  = dtime.Year + "年4季度";
                            ti2 = (dtime.Year) + "年3季度";
                        }
                        where1 += " and fldDate='" + ti + "'";
                        where2 += " and fldDate='" + ti2 + "'";
                    }
                    if (DP.TimeType == "year")
                    {
                        DateTime dtime = DateTime.Parse(DP.EndDate);
                        string   ti3   = dtime.Year + "年";
                        string   ti    = "";
                        string   ti2   = (dtime.Year - 1) + "年";
                        where1 += " and fldDate='" + ti3 + "'";
                        where2 += " and fldDate='" + ti2 + "'";
                    }
                }
                else
                {
                    result = rule.JsonStr("error", "时间格式不正确!", "");
                    return(new HttpResponseMessage {
                        Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
                    });
                }
                //当期
                string sql = "select * from tblEQIW_R_Province_Data where " + defwhere + where1;
                //累计
                string sql2 = "select * from tblEQIW_R_Province_Data where " + defwhere2 + where2;
                //同期
                string sql3 = "select * from tblEQIW_R_Province_Data where " + defwhere + where3;

                //城市
                string sql4 = "select * from tblEQIW_R_CityData where " + defwhere + where1 + " order by fldSTCode";

                //上期城市
                string sql5 = "select * from tblEQIW_R_CityData where " + defwhere2 + where2 + " order by fldSTCode";

                DataTable dt4 = rule.GetMiddleData(sql4);
                DataTable dt5 = rule.GetMiddleData(sql5);
                DataTable dt6 = dt4.Copy();

                for (int i = 0; i < dt4.Rows.Count; i++)
                {
                    if (dt4.Rows[i]["fldSTCode"].ToString() == dt5.Rows[i]["fldSTCode"].ToString())
                    {
                        if (rule.ismtch(dt5.Rows[i]["fldApprise"].ToString()))
                        {
                            dt6.Rows[i]["fldApprise"] = (decimal.Parse(dt4.Rows[i]["fldApprise"].ToString()) - decimal.Parse(dt5.Rows[i]["fldApprise"].ToString())) / decimal.Parse(dt5.Rows[i]["fldApprise"].ToString()) * 100;
                        }
                        else
                        {
                            dt6.Rows[i]["fldApprise"] = "0";
                        }
                    }
                }

                DataTable dt  = rule.GetMiddleData(sql);
                DataTable dt2 = rule.GetMiddleData(sql2);
                DataTable dt3 = rule.GetMiddleData(sql3);

                retudt tt = new retudt();
                tt.DQ     = dt;
                tt.LJ     = dt2;
                tt.TQ     = dt3;
                tt.city   = dt4;
                tt.BHcity = dt6;
                result    = rule.JsonStr("ok", "", tt);
            }
            catch (Exception e)
            {
                result = rule.JsonStr("error", e.Message, "");
            }

            return(new HttpResponseMessage {
                Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json")
            });
        }