AnalysisService.cs.rej 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. diff a/LeaRun.Application/LeaRun.Application.Service/PipeNetworkManage/AnalysisService.cs b/LeaRun.Application/LeaRun.Application.Service/PipeNetworkManage/AnalysisService.cs (rejected hunks)
  2. @@ -7,6 +7,7 @@
  3. using System.Threading.Tasks;
  4. using LeaRun.Data;
  5. using LeaRun.Util;
  6. +using LeaRun.Util.WebControl;
  7. namespace LeaRun.Application.Service.PipeNetworkManage
  8. {
  9. @@ -21,7 +22,7 @@
  10. /// <param name="devId"></param>
  11. /// <param name="time"></param>
  12. /// <returns></returns>
  13. - public string GetYearAnalysis(string departId, string typeID, string devId, string time)
  14. + public string GetYearAnalysis(string departId, string typeID, string devId, string time,Pagination pagination)
  15. {
  16. string strSql = "";
  17. if (!string.IsNullOrEmpty(departId))
  18. @@ -30,7 +31,7 @@
  19. {
  20. //var mIds = departId;
  21. //var child = new DeviceService().GetList(Convert.ToInt32(departId));
  22. -
  23. +
  24. //foreach (var item in child)
  25. //{
  26. // mIds += item.ID;
  27. @@ -50,11 +51,12 @@
  28. strSql = "Select MeterAssessmentId,MeterAssessmentName From MeterAssessmentBase Where MeterAssessmentId=" + devId;
  29. }
  30. -
  31. DateTime dateTime = DateTime.Parse(time + "-01-01");
  32. -
  33. int months = 12;
  34. - DataTable dt = sqlHelper.ExecuteDataTable(strSql, CommandType.Text, null);
  35. + int total = pagination.records;
  36. + //DataTable dt = sqlHelper.ExecuteDataTable(strSql, CommandType.Text, null);
  37. + DataTable dt = sqlHelper.ExecuteDataTable(strSql, "", false, pagination.rows, pagination.page, out total, null);
  38. + pagination.records = total;
  39. StringBuilder builder = new StringBuilder();
  40. builder.Append("[");
  41. for (int i = 0; i < dt.Rows.Count; i++)
  42. @@ -70,14 +72,11 @@
  43. DateTime startDay = dateTime;
  44. for (int j = 0; j < months; j++)
  45. - {
  46. -
  47. - //builder.Append("\"Day\"").Append(j + 1).Append("\":\"");
  48. + {
  49. DateTime nowDay = startDay.AddMonths(j);
  50. DateTime endDay = nowDay.AddMonths(1);
  51. - //strSql = "Select 净累计流量 From " + strTableName + " Where 净累计流量<>0 And 净累计流量 is not null And 采集时间 between '" + nowDay.ToString("yyyy-MM-dd") + "' And '" + endDay.ToString("yyyy-MM-dd") + "' Order by 采集时间";
  52. - strSql = "Select NetCumulativeFlow From " + strTableName + " Where NetCumulativeFlow<>0 And NetCumulativeFlow is not null And GetDateTime between '" + nowDay.ToString("yyyy-MM-dd") + "' And '" + endDay.ToString("yyyy-MM-dd") + "' Order by GetDateTime";
  53. - DataTable table = sqlHelper.ExecuteDataTable(strSql, CommandType.Text, null);
  54. + strSql = "Select GetDateTime,NetCumulativeFlow From " + strTableName + " Where NetCumulativeFlow<>0 And NetCumulativeFlow is not null And GetDateTime between '" + nowDay.ToString("yyyy-MM-dd") + "' And '" + endDay.ToString("yyyy-MM-dd") + "'";
  55. + DataTable table = sqlHelper.ExecuteDataTable(strSql, CommandType.Text, null);
  56. if (table.Rows.Count > 0)
  57. {
  58. decimal min = decimal.Parse(table.Rows[0]["NetCumulativeFlow"].ToString());
  59. @@ -118,7 +117,7 @@
  60. /// <param name="devId"></param>
  61. /// <param name="time"></param>
  62. /// <returns></returns>
  63. - public string GetMonthAnalysis(string departId, string typeID, string devId, string time)
  64. + public string GetMonthAnalysis(string departId, string typeID, string devId, string time,Pagination pagination)
  65. {
  66. string strSql = "";
  67. if (!string.IsNullOrEmpty(departId))
  68. @@ -150,8 +149,10 @@
  69. DateTime dateTime = DateTime.Parse(time);
  70. int days = LeaRun.Util.Time.GetDaysOfMonth(dateTime.Year, dateTime.Month);
  71. -
  72. - DataTable dt = sqlHelper.ExecuteDataTable(strSql, CommandType.Text, null);
  73. + int total = pagination.records;
  74. + //DataTable dt = sqlHelper.ExecuteDataTable(strSql, CommandType.Text, null);
  75. + DataTable dt = sqlHelper.ExecuteDataTable(strSql, "", false, pagination.rows, pagination.page, out total, null);
  76. + pagination.records = total;
  77. StringBuilder builder = new StringBuilder();
  78. builder.Append("[");
  79. for (int i = 0; i < dt.Rows.Count; i++)
  80. @@ -160,8 +161,7 @@
  81. string name = dt.Rows[i]["MeterAssessmentName"].ToString();
  82. builder.Append("{");
  83. builder.Append("\"ID\":\"").Append(deviceId).Append("\",");
  84. - builder.Append("\"DevName\":\"").Append(name).Append("\",");
  85. - //string strTableName = "历史记录_" + ("000000" + deviceId).Substring(deviceId.Length, 6) + "_" + dateTime.Year.ToString();
  86. + builder.Append("\"DevName\":\"").Append(name).Append("\",");
  87. string strTableName = "MeterAssessment_" + deviceId;
  88. if (sqlHelper.DBTableIsExists(strTableName))
  89. {
  90. @@ -171,9 +171,8 @@
  91. {
  92. DateTime nowDay = startDay.AddDays(j);
  93. DateTime endDay = nowDay.AddDays(1);
  94. - strSql = "Select NetCumulativeFlow From " + strTableName + " Where NetCumulativeFlow<>0 And NetCumulativeFlow is not null And GetDateTime between '" + nowDay.ToString("yyyy-MM-dd") + "' And '" + endDay.ToString("yyyy-MM-dd") + "' Order by GetDateTime";
  95. -
  96. - DataTable table = sqlHelper.ExecuteDataTable(strSql, CommandType.Text, null);
  97. + strSql = "Select GetDateTime, NetCumulativeFlow From " + strTableName + " Where NetCumulativeFlow<>0 And NetCumulativeFlow is not null And GetDateTime between '" + nowDay.ToString("yyyy-MM-dd") + "' And '" + endDay.ToString("yyyy-MM-dd") + "'";
  98. + DataTable table = sqlHelper.ExecuteDataTable(strSql, CommandType.Text, null);
  99. if (table.Rows.Count > 0)
  100. {
  101. decimal min = decimal.Parse(table.Rows[0]["NetCumulativeFlow"].ToString());