using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using LeaRun.Data; using LeaRun.Application.Entity.SecondaryWaterSupply; using LeaRun.Util.WebControl; using System.Data; using LeaRun.Util; namespace LeaRun.Application.Service.SecondaryWaterSupply { public class HistoryService { SqlHelper sqlHelper = new SqlHelper("SecondyWaterSupplyDb"); /// /// 设备历史记录 /// /// /// /// /// /// /// public IEnumerable GetHisData(string ids,Pagination pagination,string keyWord,string begin,string end) { try { string selSql = "SELECT * FROM dbo.SecondaryWaterSupplyBase WHERE SecondaryWaterSupplyId IN (" + ids + ")"; DataTable dtDevice = sqlHelper.ExecuteDataTable(selSql, CommandType.Text, null); StringBuilder hisSql = new StringBuilder(); for (int row = 0; row < dtDevice.Rows.Count; row++) { string tabName = dtDevice.Rows[row]["TableName"].ToString(); string deviceName = dtDevice.Rows[row]["PumpHouseName"].ToString(); hisSql.Append("SELECT '"+deviceName+ "' as PumpHouseName , * FROM " + tabName+ " WHERE GetDateTime BETWEEN '" + begin+"' AND '"+end+"'"); if (row < dtDevice.Rows.Count - 1) { hisSql.Append("UNION"); } } int total = pagination.records; DataTable dtHis = sqlHelper.ExecuteDataTable(hisSql.ToString(), "SecondaryWaterSupplyId",true,pagination.rows,pagination.page,out total,null); pagination.records = total; return DataHelper.DataTableToT(dtHis); } catch (Exception ex) { return null; } } } }