Merge branch 'master' of http://git.umayle.com:2023/XKH/DongYing
This commit is contained in:
commit
8adda618c7
|
@ -224,15 +224,33 @@ namespace DataServer.BLL
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取数据
|
/// 获得数据列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">数据来源</param>
|
public List<DataServer.other.service_rating_data> GetSum(string source, string strWhere, string sum_name)
|
||||||
/// <param name="strWhere">条件</param>
|
|
||||||
/// <param name="sum_name">求和字段</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public decimal GetSum(string source, string strWhere, string sum_name)
|
|
||||||
{
|
{
|
||||||
return dal.GetSum(source, strWhere, sum_name);
|
DataSet ds = dal.GetSum(source, strWhere, sum_name);
|
||||||
|
return DataTableToSumList(ds.Tables[0]);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数据列表
|
||||||
|
/// </summary>
|
||||||
|
public List<DataServer.other.service_rating_data> DataTableToSumList(DataTable dt)
|
||||||
|
{
|
||||||
|
List<DataServer.other.service_rating_data> modelList = new List<DataServer.other.service_rating_data>();
|
||||||
|
int rowsCount = dt.Rows.Count;
|
||||||
|
if (rowsCount > 0)
|
||||||
|
{
|
||||||
|
DataServer.other.service_rating_data model;
|
||||||
|
for (int n = 0; n < rowsCount; n++)
|
||||||
|
{
|
||||||
|
model = dal.DataRowToSumModel(dt.Rows[n]);
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
modelList.Add(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modelList;
|
||||||
}
|
}
|
||||||
#endregion ExtensionMethod
|
#endregion ExtensionMethod
|
||||||
}
|
}
|
||||||
|
|
|
@ -583,23 +583,36 @@ namespace DataServer.DAL
|
||||||
/// <param name="strWhere">条件</param>
|
/// <param name="strWhere">条件</param>
|
||||||
/// <param name="sum_name">求和字段</param>
|
/// <param name="sum_name">求和字段</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public decimal GetSum(string source, string strWhere, string sum_name)
|
public DataSet GetSum(string source, string strWhere, string sum_name)
|
||||||
{
|
{
|
||||||
StringBuilder strSql = new StringBuilder();
|
StringBuilder strSql = new StringBuilder();
|
||||||
strSql.Append("SELECT sum(" + sum_name + ") FROM (" + source + ") as T ");
|
strSql.Append("SELECT sum(" + sum_name + ") as total,DeviceId FROM (" + source + ") as T ");
|
||||||
if (strWhere.Trim() != "")
|
if (strWhere.Trim() != "")
|
||||||
{
|
{
|
||||||
strSql.Append(" where " + strWhere);
|
strSql.Append(" where " + strWhere);
|
||||||
}
|
}
|
||||||
object obj = DbHelperSQL.GetSingle(strSql.ToString(), 300);
|
strSql.Append(" group by DeviceId ");
|
||||||
if (obj == null)
|
return DbHelperMySQL.Query(strSql.ToString(), 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到一个对象实体
|
||||||
|
/// </summary>
|
||||||
|
public DataServer.other.service_rating_data DataRowToSumModel(DataRow row)
|
||||||
|
{
|
||||||
|
DataServer.other.service_rating_data model = new DataServer.other.service_rating_data();
|
||||||
|
if (row != null)
|
||||||
{
|
{
|
||||||
return 0;
|
if (row["DeviceId"] != null)
|
||||||
}
|
{
|
||||||
else
|
model.DeviceId = row["DeviceId"].ToString();
|
||||||
{
|
}
|
||||||
return Convert.ToDecimal(obj);
|
if (row["total"] != null && row["total"].ToString() != "")
|
||||||
|
{
|
||||||
|
model.total = decimal.Parse(row["total"].ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
#endregion ExtensionMethod
|
#endregion ExtensionMethod
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,7 @@
|
||||||
<Compile Include="Model\meteorological_station.cs" />
|
<Compile Include="Model\meteorological_station.cs" />
|
||||||
<Compile Include="Model\planned_energy.cs" />
|
<Compile Include="Model\planned_energy.cs" />
|
||||||
<Compile Include="Model\water_data.cs" />
|
<Compile Include="Model\water_data.cs" />
|
||||||
|
<Compile Include="other\service_rating_data.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataServer.other
|
||||||
|
{
|
||||||
|
public class service_rating_data
|
||||||
|
{
|
||||||
|
public decimal total { get; set; }
|
||||||
|
|
||||||
|
public string DeviceId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,15 +61,22 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
var time = upper_start_time.AddMonths(i).ToString("yyyyMM");
|
var time = upper_start_time.AddMonths(i).ToString("yyyyMM");
|
||||||
if (bll.IsExistsTable(date_base, "electricity_data_" + time))
|
if (bll.IsExistsTable(date_base, "electricity_data_" + time))
|
||||||
{
|
{
|
||||||
if (time == upper_start_time.ToString("yyyyMM") || time == modern_end_time.ToString("yyyyMM"))
|
if (time == upper_start_time.ToString("yyyyMM"))
|
||||||
{
|
{
|
||||||
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime>='{1}' and EntireTime<='{2}'", time, upper_start_time, modern_end_time);
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, upper_start_time);
|
||||||
}
|
}
|
||||||
else
|
else if (time == upper_end_time.ToString("yyyyMM"))
|
||||||
{
|
{
|
||||||
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where 1=1 ", time);
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, upper_end_time);
|
||||||
|
}
|
||||||
|
else if (time == modern_start_time.ToString("yyyyMM"))
|
||||||
|
{
|
||||||
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, modern_start_time);
|
||||||
|
}
|
||||||
|
else if (time == modern_end_time.ToString("yyyyMM"))
|
||||||
|
{
|
||||||
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, modern_end_time);
|
||||||
}
|
}
|
||||||
source += ") UNION all ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(source))
|
if (!string.IsNullOrEmpty(source))
|
||||||
|
@ -78,7 +85,7 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
list = bll.GetList(source, "", "");
|
list = bll.GetList(source, "", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == "月")
|
if (type == "月")
|
||||||
{
|
{
|
||||||
modern_start_time = DateTime.Parse(now.ToString("yyyy-MM") + "-01 00:00:00");
|
modern_start_time = DateTime.Parse(now.ToString("yyyy-MM") + "-01 00:00:00");
|
||||||
modern_end_time = DateTime.Parse(now.ToString("yyyy-MM-dd HH") + ":00:00");
|
modern_end_time = DateTime.Parse(now.ToString("yyyy-MM-dd HH") + ":00:00");
|
||||||
|
@ -91,15 +98,22 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
var time = upper_start_time.AddMonths(i).ToString("yyyyMM");
|
var time = upper_start_time.AddMonths(i).ToString("yyyyMM");
|
||||||
if (bll.IsExistsTable(date_base, "electricity_data_" + time))
|
if (bll.IsExistsTable(date_base, "electricity_data_" + time))
|
||||||
{
|
{
|
||||||
if (time == upper_start_time.ToString("yyyyMM") || time == modern_end_time.ToString("yyyyMM"))
|
if (time == upper_start_time.ToString("yyyyMM"))
|
||||||
{
|
{
|
||||||
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime>='{1}' and EntireTime<='{2}'", time, upper_start_time, modern_end_time);
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, upper_start_time);
|
||||||
}
|
}
|
||||||
else
|
else if (time == upper_end_time.ToString("yyyyMM"))
|
||||||
{
|
{
|
||||||
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where 1=1 ", time);
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, upper_end_time);
|
||||||
|
}
|
||||||
|
else if (time == modern_start_time.ToString("yyyyMM"))
|
||||||
|
{
|
||||||
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, modern_start_time);
|
||||||
|
}
|
||||||
|
else if (time == modern_end_time.ToString("yyyyMM"))
|
||||||
|
{
|
||||||
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, modern_end_time);
|
||||||
}
|
}
|
||||||
source += ") UNION all ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(source))
|
if (!string.IsNullOrEmpty(source))
|
||||||
|
@ -108,7 +122,7 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
list = bll.GetList(source, "", "");
|
list = bll.GetList(source, "", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == "年")
|
if (type == "年")
|
||||||
{
|
{
|
||||||
modern_start_time = DateTime.Parse(now.ToString("yyyy") + "-01-01 00:00:00");
|
modern_start_time = DateTime.Parse(now.ToString("yyyy") + "-01-01 00:00:00");
|
||||||
modern_end_time = DateTime.Parse(now.ToString("yyyy-MM-dd HH") + ":00:00");
|
modern_end_time = DateTime.Parse(now.ToString("yyyy-MM-dd HH") + ":00:00");
|
||||||
|
@ -121,15 +135,22 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
var time = upper_start_time.AddMonths(i).ToString("yyyyMM");
|
var time = upper_start_time.AddMonths(i).ToString("yyyyMM");
|
||||||
if (bll.IsExistsTable(date_base, "electricity_data_" + time))
|
if (bll.IsExistsTable(date_base, "electricity_data_" + time))
|
||||||
{
|
{
|
||||||
if (time == upper_start_time.ToString("yyyyMM") || time == modern_end_time.ToString("yyyyMM"))
|
if (time == upper_start_time.ToString("yyyyMM"))
|
||||||
{
|
{
|
||||||
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime>='{1}' and EntireTime<='{2}'", time, upper_start_time, modern_end_time);
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, upper_start_time);
|
||||||
}
|
}
|
||||||
else
|
else if (time == upper_end_time.ToString("yyyyMM"))
|
||||||
{
|
{
|
||||||
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where 1=1 ", time);
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, upper_end_time);
|
||||||
|
}
|
||||||
|
else if (time == modern_start_time.ToString("yyyyMM"))
|
||||||
|
{
|
||||||
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, modern_start_time);
|
||||||
|
}
|
||||||
|
else if (time == modern_end_time.ToString("yyyyMM"))
|
||||||
|
{
|
||||||
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, modern_end_time);
|
||||||
}
|
}
|
||||||
source += ") UNION all ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(source))
|
if (!string.IsNullOrEmpty(source))
|
||||||
|
@ -195,10 +216,14 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
|
|
||||||
//电
|
//电
|
||||||
var device_list = device_bll.GetModelList("");
|
var device_list = device_bll.GetModelList("");
|
||||||
|
var modern_start_list = list.Where(a => a.EntireTime.Value == modern_start_time).ToList();
|
||||||
|
var modern_end_list = list.Where(a => a.EntireTime.Value == modern_end_time).ToList();
|
||||||
|
var upper_start_list = list.Where(a => a.EntireTime.Value == upper_start_time).ToList();
|
||||||
|
var upper_end_list = list.Where(a => a.EntireTime.Value == upper_end_time).ToList();
|
||||||
foreach (var item in device_list)
|
foreach (var item in device_list)
|
||||||
{
|
{
|
||||||
var modern_start_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == modern_start_time).FirstOrDefault();
|
var modern_start_data = modern_start_list.Where(a => a.DeviceId == item.DeviceId).FirstOrDefault();
|
||||||
var modern_end_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == modern_end_time).FirstOrDefault();
|
var modern_end_data = modern_end_list.Where(a => a.DeviceId == item.DeviceId).FirstOrDefault();
|
||||||
if (modern_start_data != null && modern_end_data != null)
|
if (modern_start_data != null && modern_end_data != null)
|
||||||
{
|
{
|
||||||
if (modern_start_data.EH != null && modern_end_data.EH != null)
|
if (modern_start_data.EH != null && modern_end_data.EH != null)
|
||||||
|
@ -208,8 +233,8 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var upper_start_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == upper_start_time).FirstOrDefault();
|
var upper_start_data = upper_start_list.Where(a => a.DeviceId == item.DeviceId).FirstOrDefault();
|
||||||
var upper_end_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == upper_end_time).FirstOrDefault();
|
var upper_end_data = upper_end_list.Where(a => a.DeviceId == item.DeviceId).FirstOrDefault();
|
||||||
if (upper_start_data != null && upper_end_data != null)
|
if (upper_start_data != null && upper_end_data != null)
|
||||||
{
|
{
|
||||||
if (upper_start_data.EH != null && upper_end_data.EH != null)
|
if (upper_start_data.EH != null && upper_end_data.EH != null)
|
||||||
|
|
|
@ -106,15 +106,14 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
var time = start_time.AddMonths(i).ToString("yyyyMM");
|
var time = start_time.AddMonths(i).ToString("yyyyMM");
|
||||||
if (bll.IsExistsTable(date_base, "electricity_data_" + time))
|
if (bll.IsExistsTable(date_base, "electricity_data_" + time))
|
||||||
{
|
{
|
||||||
if (time == start_time.ToString("yyyyMM") || time == end_time.ToString("yyyyMM"))
|
if (time == start_time.ToString("yyyyMM"))
|
||||||
{
|
{
|
||||||
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime>='{1}' and EntireTime<='{2}'", time, start_time, end_time);
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, start_time);
|
||||||
}
|
}
|
||||||
else
|
else if (time == end_time.ToString("yyyyMM"))
|
||||||
{
|
{
|
||||||
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where 1=1 ", time);
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, end_time);
|
||||||
}
|
}
|
||||||
source += ") UNION all ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(source))
|
if (!string.IsNullOrEmpty(source))
|
||||||
|
@ -128,10 +127,12 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
var start = start_time.AddHours(i);
|
var start = start_time.AddHours(i);
|
||||||
var end = start.AddHours(1);
|
var end = start.AddHours(1);
|
||||||
decimal electricity = 0;
|
decimal electricity = 0;
|
||||||
|
var start_list = list.Where(a => a.EntireTime.Value == start).ToList();
|
||||||
|
var end_list = list.Where(a => a.EntireTime.Value == end).ToList();
|
||||||
foreach (var item in device_list)
|
foreach (var item in device_list)
|
||||||
{
|
{
|
||||||
var start_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == start).FirstOrDefault();
|
var start_data = start_list.Where(a => a.DeviceId == item.DeviceId).FirstOrDefault();
|
||||||
var end_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == end).FirstOrDefault();
|
var end_data = end_list.Where(a => a.DeviceId == item.DeviceId).FirstOrDefault();
|
||||||
if (start_data != null && end_data != null)
|
if (start_data != null && end_data != null)
|
||||||
{
|
{
|
||||||
if (start_data.EH != null && end_data.EH != null)
|
if (start_data.EH != null && end_data.EH != null)
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
{
|
{
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
var device_list = device_bll.GetModelList("");
|
var device_list = device_bll.GetModelList("");
|
||||||
var list = new List<DataServer.Model.electricity_data>();
|
var list = new List<DataServer.other.service_rating_data>();
|
||||||
//判断表是否存在,不存在就创建
|
//判断表是否存在,不存在就创建
|
||||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||||
var start_date = DateTime.Parse(now.ToString("yyyy") + "-01-01 00:00:00");
|
var start_date = DateTime.Parse(now.ToString("yyyy") + "-01-01 00:00:00");
|
||||||
|
@ -69,7 +69,7 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
if (!string.IsNullOrEmpty(source))
|
if (!string.IsNullOrEmpty(source))
|
||||||
{
|
{
|
||||||
source = source.Substring(0, source.Length - 11);
|
source = source.Substring(0, source.Length - 11);
|
||||||
list = bll.GetList(source, "", "");
|
list = bll.GetSum(source, "", "ServiceRating");
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = new List<energy_consumption>();
|
var data = new List<energy_consumption>();
|
||||||
|
@ -77,7 +77,7 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
{
|
{
|
||||||
var model = new energy_consumption();
|
var model = new energy_consumption();
|
||||||
model.DeviceName = item.DeviceName;
|
model.DeviceName = item.DeviceName;
|
||||||
model.OperatingPower = list.Where(a => a.DeviceId == item.DeviceId).Sum(a => a.ServiceRating).Value;
|
model.OperatingPower = list.Where(a => a.DeviceId == item.DeviceId).Select(a => a.total).FirstOrDefault();
|
||||||
data.Add(model);
|
data.Add(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,15 +52,14 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
var time = start_time.AddMonths(i).ToString("yyyyMM");
|
var time = start_time.AddMonths(i).ToString("yyyyMM");
|
||||||
if (bll.IsExistsTable(date_base, "electricity_data_" + time))
|
if (bll.IsExistsTable(date_base, "electricity_data_" + time))
|
||||||
{
|
{
|
||||||
if (time == start_time.ToString("yyyyMM") || time == end_time.ToString("yyyyMM"))
|
if (time == start_time.ToString("yyyyMM"))
|
||||||
{
|
{
|
||||||
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime>='{1}' and EntireTime<='{2}'", time, start_time, end_time);
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, start_time);
|
||||||
}
|
}
|
||||||
else
|
else if (time == end_time.ToString("yyyyMM"))
|
||||||
{
|
{
|
||||||
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where 1=1 ", time);
|
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where EntireTime='{1}') UNION all ", time, end_time);
|
||||||
}
|
}
|
||||||
source += ") UNION all ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(source))
|
if (!string.IsNullOrEmpty(source))
|
||||||
|
@ -70,7 +69,6 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
}
|
}
|
||||||
|
|
||||||
var device_list = device_bll.GetModelList("");
|
var device_list = device_bll.GetModelList("");
|
||||||
|
|
||||||
for (int i = 0; i <= time_count; i++)
|
for (int i = 0; i <= time_count; i++)
|
||||||
{
|
{
|
||||||
var month = start_time.AddMonths(i).Month;
|
var month = start_time.AddMonths(i).Month;
|
||||||
|
@ -82,10 +80,12 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||||
}
|
}
|
||||||
var plan_model = plan_list.Where(a => a.Month == month).FirstOrDefault();
|
var plan_model = plan_list.Where(a => a.Month == month).FirstOrDefault();
|
||||||
decimal value = 0;
|
decimal value = 0;
|
||||||
|
var start_list = list.Where(a => a.EntireTime.Value == time).ToList();
|
||||||
|
var end_list = list.Where(a => a.EntireTime.Value == end).ToList();
|
||||||
foreach (var item in device_list)
|
foreach (var item in device_list)
|
||||||
{
|
{
|
||||||
var start_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == time).FirstOrDefault();
|
var start_data = start_list.Where(a => a.DeviceId == item.DeviceId).FirstOrDefault();
|
||||||
var end_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == end).FirstOrDefault();
|
var end_data = end_list.Where(a => a.DeviceId == item.DeviceId).FirstOrDefault();
|
||||||
if (start_data != null && end_data != null)
|
if (start_data != null && end_data != null)
|
||||||
{
|
{
|
||||||
if (start_data.EH != null && end_data.EH != null)
|
if (start_data.EH != null && end_data.EH != null)
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
<HintPath>..\packages\HslCommunication.10.1.2\lib\net451\HslCommunication.dll</HintPath>
|
<HintPath>..\packages\HslCommunication.10.1.2\lib\net451\HslCommunication.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="log4net">
|
<Reference Include="log4net">
|
||||||
<HintPath>..\..\DongYingAPI\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
|
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="MQTTnet, Version=4.1.4.563, Culture=neutral, PublicKeyToken=fdb7629f2e364a63, processorArchitecture=MSIL">
|
<Reference Include="MQTTnet, Version=4.1.4.563, Culture=neutral, PublicKeyToken=fdb7629f2e364a63, processorArchitecture=MSIL">
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
|
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
|
||||||
<WebStackScaffolding_LayoutPageFile />
|
<WebStackScaffolding_LayoutPageFile />
|
||||||
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
|
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
|
||||||
|
<ProjectView>ProjectFiles</ProjectView>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
<VisualStudio>
|
<VisualStudio>
|
||||||
|
|
Loading…
Reference in New Issue