using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using HWSB = SuperMap.RealEstate.HighWay.Storage.Business; using HZQR.Common; namespace PlatformModuleManage { public partial class RecognizePage : SuperMap.RealEstate.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; //设置按钮回车事件 SetControlClientAction(BtnRecognize); } protected void BtnRecognize_Click(object sender, EventArgs e) { if (sentence.Text.Trim() != "") { string WhereSQL = "", ShopSQL = "", ServerpartSQL = "", SearchValue; ResultInfo.Text = "为您查找"; DataTable dtResult = new DataTable(); dtResult.Columns.Add("StartDate"); dtResult.Columns.Add("EndDate"); dtResult.Columns.Add("HolidayName"); dtResult.Columns.Add("ServerpartName"); dtResult.Columns.Add("RegionName"); dtResult.Columns.Add("BrandName"); dtResult.Columns.Add("YOYDate"); dtResult.Columns.Add("QOQDate"); dtResult.Columns.Add("BusinessType"); dtResult.Columns.Add("ShopName"); DataRow drResult = dtResult.NewRow(); bool hasAppoint = Common.CommonHelper.sentenceKey(sentence.Text, 1), hasHoliday = Common.CommonHelper.sentenceKey(sentence.Text, 2), hasServerpart = Common.CommonHelper.sentenceKey(sentence.Text, 3), hasRegion = Common.CommonHelper.sentenceKey(sentence.Text, 5), hasBrand = Common.CommonHelper.sentenceKey(sentence.Text, 4), hasBusinessType = Common.CommonHelper.sentenceKey(sentence.Text, 6), hasShopName = Common.CommonHelper.sentenceKey(sentence.Text, 7); string AppointDays = Common.CommonHelper.GetSentenceKeyName(sentence.Text, 1), Holiday = Common.CommonHelper.GetSentenceKeyName(sentence.Text, 2), ServerpartName = Common.CommonHelper.GetSentenceKeyName(sentence.Text, 3), RegionName = Common.CommonHelper.GetSentenceKeyName(sentence.Text, 5), BrandName = Common.CommonHelper.GetSentenceKeyName(sentence.Text, 4), BusinessType = Common.CommonHelper.GetSentenceKeyName(sentence.Text, 6), ShopName = Common.CommonHelper.GetSentenceKeyName(sentence.Text, 7); DateTime[] curDate = null; KeyNameInfo.Text = "指定日期:" + (hasAppoint ? AppointDays + $"【{ Common.TimeParser.ParseDate(AppointDays) }】" : AppointDays); if (hasAppoint) { if (hasHoliday) { drResult[2] = Holiday; ResultInfo.Text += $"【{ Holiday }】"; int curYear = Common.TimeParser.timeParsingRules[AppointDays].Invoke()[0].Year; curDate = Common.TimeParser.holidayParsingRules[Holiday].Invoke(curYear); Holiday = Common.TimeParser.ParseHoliday(Holiday, curYear); } else { curDate = Common.TimeParser.timeParsingRules[AppointDays].Invoke(); } drResult[0] = curDate[0].ToShortDateString(); drResult[1] = curDate[1].ToShortDateString(); } KeyNameInfo.Text += "\r\n节假日:" + Holiday; KeyNameInfo.Text += "\r\n服务区:" + ServerpartName; KeyNameInfo.Text += "\r\n片区:" + RegionName; KeyNameInfo.Text += "\r\n品牌名称:" + BrandName; KeyNameInfo.Text += "\r\n经营模式:" + BusinessType; KeyNameInfo.Text += "\r\n自营业态:" + ShopName; if (hasBusinessType) { drResult[8] = BusinessType; ResultInfo.Text += $"【{ BusinessType }】"; SearchValue = ""; foreach (string single in BusinessType.Split(',')) { SearchValue += (SearchValue == "" ? "" : ",") + Common.CommonHelper.businessTypes[single]; } WhereSQL += $" AND C.BUSINESS_TYPE IN ({ SearchValue })"; } ResultInfo.Text += "在"; if (hasRegion) { drResult[4] = RegionName; ResultInfo.Text += (ResultInfo.Text.EndsWith("在") ? "" : "|") + $"【{ RegionName }】"; SearchValue = ""; foreach (string single in RegionName.Split(',')) { SearchValue += (SearchValue == "" ? "" : ",") + Common.CommonHelper.regionRules[single]; } ServerpartSQL += (ServerpartSQL == "" ? "" : " OR ") + $"B.SPREGIONTYPE_ID IN ({ SearchValue })"; } if (hasServerpart) { drResult[3] = ServerpartName; ResultInfo.Text += (ResultInfo.Text.EndsWith("在") ? "" : "|") + $"【{ ServerpartName }】"; SearchValue = ""; foreach (string single in ServerpartName.Split(',')) { SearchValue += (SearchValue == "" ? "" : ",") + Common.CommonHelper.serverpartRules[single]; } ServerpartSQL += (ServerpartSQL == "" ? "" : " OR ") + $"B.SERVERPART_ID IN ({ SearchValue })"; } if (hasBrand) { drResult[5] = BrandName; ResultInfo.Text += (ResultInfo.Text.EndsWith("在") ? "" : "|") + $"【{ BrandName }】"; ShopSQL += (ShopSQL == "" ? "" : " OR ") + $"C.BRAND_NAME IN ('{ BrandName.Replace(",", "','") }')"; } if (hasShopName) { drResult[9] = ShopName; ResultInfo.Text += (ResultInfo.Text.EndsWith("在") ? "" : "|") + $"【{ ShopName }】"; ShopSQL += (ShopSQL == "" ? "" : " OR ") + $"C.SHOPSHORTNAME IN ('{ ShopName.Replace(",", "','") }')"; } ResultInfo.Text += "的营收数据"; if (sentence.Text.Contains("同环比")) { if (hasAppoint) { drResult[6] = curDate[0].AddYears(-1).ToShortDateString() + "至" + curDate[1].AddYears(-1).ToShortDateString(); drResult[7] = curDate[0].AddMonths(-1).ToShortDateString() + "至" + curDate[1].AddMonths(-1).ToShortDateString(); KeyNameInfo.Text += "\r\n同比日期:"; KeyNameInfo.Text += drResult[6].ToString(); KeyNameInfo.Text += "\r\n环比日期:"; KeyNameInfo.Text += drResult[7].ToString(); ResultInfo.Text += "(同比/环比)"; } } else if (sentence.Text.Contains("环比")) { KeyNameInfo.Text += "\r\n环比日期:"; if (hasAppoint) { drResult[7] = curDate[0].AddMonths(-1).ToShortDateString() + "至" + curDate[1].AddMonths(-1).ToShortDateString(); KeyNameInfo.Text += drResult[7].ToString(); ResultInfo.Text += "(环比)"; } } else if (sentence.Text.Contains("同比")) { KeyNameInfo.Text += "\r\n同比日期:"; if (hasAppoint) { drResult[6] = curDate[0].AddYears(-1).ToShortDateString() + "至" + curDate[1].AddYears(-1).ToShortDateString(); KeyNameInfo.Text += drResult[6].ToString(); ResultInfo.Text += "(同比)"; } } dtResult.Rows.Add(drResult); GridViewEx1.DataSource = dtResult; string SQLString = @"SELECT SUM(REVENUE_AMOUNT) FROM PLATFORM_DASHBOARD.T_REVENUEDAILY A WHERE A.STATISTICS_DATE BETWEEN {0} AND {1} AND EXISTS (SELECT 1 FROM HIGHWAY_STORAGE.T_SERVERPART B,HIGHWAY_STORAGE.T_SERVERPARTSHOP C WHERE A.SERVERPART_ID = B.SERVERPART_ID AND B.SERVERPART_ID = C.SERVERPART_ID AND ',' || A.SERVERPARTSHOP_ID || ',' LIKE '%,' || C.SERVERPARTSHOP_ID || ',%'{2})"; DataTable dtRevenueAmount = new HWSB.SERVERPART(Transaction).ExecuteDataTable(string.Format( SQLString, curDate[0].ToString("yyyyMMdd"), curDate[1].ToString("yyyyMMdd"), WhereSQL + (ServerpartSQL == "" ? "" : $" AND ({ ServerpartSQL })") + (ShopSQL == "" ? "" : $" AND ({ ShopSQL })"))); decimal curRevenue = dtRevenueAmount.Rows[0][0].TryParseToDecimal(); ResultInfo.Text += $":【{ curDate[0].ToShortDateString() }】至【{ curDate[1].ToShortDateString() }】:" + $"{ Math.Floor(curRevenue / 100) / 100 }万元"; if (sentence.Text.Contains("同环比") || sentence.Text.Contains("同比")) { dtRevenueAmount = new HWSB.SERVERPART(Transaction).ExecuteDataTable(string.Format(SQLString, curDate[0].AddYears(-1).ToString("yyyyMMdd"), curDate[1].AddYears(-1).ToString("yyyyMMdd"), WhereSQL + (ServerpartSQL == "" ? "" : $" AND ({ ServerpartSQL })") + (ShopSQL == "" ? "" : $" AND ({ ShopSQL })"))); decimal YOYRevenue = dtRevenueAmount.Rows[0][0].TryParseToDecimal(); ResultInfo.Text += $";【{ curDate[0].AddYears(-1).ToShortDateString() }】至" + $"【{ curDate[1].AddYears(-1).ToShortDateString() }】:{ Math.Floor(YOYRevenue / 100) / 100 }万元"; if (YOYRevenue > 0) { ResultInfo.Text += $",同比增幅{ Math.Round(curRevenue / YOYRevenue * 100 - 100, 2) }%"; } } if (sentence.Text.Contains("同环比") || sentence.Text.Contains("环比")) { dtRevenueAmount = new HWSB.SERVERPART(Transaction).ExecuteDataTable(string.Format(SQLString, curDate[0].AddMonths(-1).ToString("yyyyMMdd"), curDate[1].AddMonths(-1).ToString("yyyyMMdd"), WhereSQL + (ServerpartSQL == "" ? "" : $" AND ({ ServerpartSQL })") + (ShopSQL == "" ? "" : $" AND ({ ShopSQL })"))); decimal QOQRevenue = dtRevenueAmount.Rows[0][0].TryParseToDecimal(); ResultInfo.Text += $";【{ curDate[0].AddMonths(-1).ToShortDateString() }】至" + $"【{ curDate[1].AddMonths(-1).ToShortDateString() }】:{ Math.Floor(QOQRevenue / 100) / 100 }万元"; if (QOQRevenue > 0) { ResultInfo.Text += $",同比增幅{ Math.Round(curRevenue / QOQRevenue * 100 - 100, 2) }%"; } } ResultInfo.Text += "。"; } else { KeyNameInfo.Text = ""; ResultInfo.Text = ""; GridViewEx1.DataSource = null; } GridViewEx1.DataBind(); } protected void GridViewEx1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.Cells[1].Text.Replace(" ", "") == "") { e.Row.Cells[1].Text = "未找到指定日期"; } if (e.Row.Cells[2].Text.Replace(" ", "") == "") { e.Row.Cells[2].Text = "未找到指定日期"; } if (e.Row.Cells[3].Text.Replace(" ", "") == "") { e.Row.Cells[3].Text = "未找到节假日"; } if (e.Row.Cells[4].Text.Replace(" ", "") == "") { e.Row.Cells[4].Text = "未找到服务区"; } if (e.Row.Cells[6].Text.Replace(" ", "") == "") { e.Row.Cells[6].Text = "未找到匹配的品牌"; } if (e.Row.Cells[7].Text.Replace(" ", "") == "") { e.Row.Cells[7].Text = "未找到经营模式"; } if (e.Row.Cells[8].Text.Replace(" ", "") == "") { e.Row.Cells[8].Text = "未找到自营业态"; } } } } }