diff --git a/DataServer/BLL/planned_energy.cs b/DataServer/BLL/planned_energy.cs
new file mode 100644
index 0000000..bf836fc
--- /dev/null
+++ b/DataServer/BLL/planned_energy.cs
@@ -0,0 +1,179 @@
+/** 版本信息模板在安装目录下,可自行修改。
+* planned_energy.cs
+*
+* 功 能: N/A
+* 类 名: planned_energy
+*
+* Ver 变更日期 负责人 变更内容
+* ───────────────────────────────────
+* V0.01 2024/1/10 13:19:01 N/A 初版
+*
+* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
+*┌──────────────────────────────────┐
+*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
+*│ 版权所有:动软卓越(北京)科技有限公司 │
+*└──────────────────────────────────┘
+*/
+using System;
+using System.Data;
+using System.Collections.Generic;
+using Maticsoft.Common;
+using DataServer.Model;
+namespace DataServer.BLL
+{
+ ///
+ /// planned_energy
+ ///
+ public partial class planned_energy
+ {
+ private readonly DataServer.DAL.planned_energy dal=new DataServer.DAL.planned_energy();
+ public planned_energy()
+ {}
+ #region BasicMethod
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(string Id)
+ {
+ return dal.Exists(Id);
+ }
+
+ ///
+ /// 增加一条数据
+ ///
+ public bool Add(DataServer.Model.planned_energy model)
+ {
+ return dal.Add(model);
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(DataServer.Model.planned_energy model)
+ {
+ return dal.Update(model);
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(string Id)
+ {
+
+ return dal.Delete(Id);
+ }
+ ///
+ /// 删除一条数据
+ ///
+ public bool DeleteList(string Idlist )
+ {
+ return dal.DeleteList(Idlist );
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public DataServer.Model.planned_energy GetModel(string Id)
+ {
+
+ return dal.GetModel(Id);
+ }
+
+ ///
+ /// 得到一个对象实体,从缓存中
+ ///
+ public DataServer.Model.planned_energy GetModelByCache(string Id)
+ {
+
+ string CacheKey = "planned_energyModel-" + Id;
+ object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
+ if (objModel == null)
+ {
+ try
+ {
+ objModel = dal.GetModel(Id);
+ if (objModel != null)
+ {
+ int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
+ Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
+ }
+ }
+ catch{}
+ }
+ return (DataServer.Model.planned_energy)objModel;
+ }
+
+ ///
+ /// 获得数据列表
+ ///
+ public DataSet GetList(string strWhere)
+ {
+ return dal.GetList(strWhere);
+ }
+ ///
+ /// 获得数据列表
+ ///
+ public List GetModelList(string strWhere)
+ {
+ DataSet ds = dal.GetList(strWhere);
+ return DataTableToList(ds.Tables[0]);
+ }
+ ///
+ /// 获得数据列表
+ ///
+ public List DataTableToList(DataTable dt)
+ {
+ List modelList = new List();
+ int rowsCount = dt.Rows.Count;
+ if (rowsCount > 0)
+ {
+ DataServer.Model.planned_energy model;
+ for (int n = 0; n < rowsCount; n++)
+ {
+ model = dal.DataRowToModel(dt.Rows[n]);
+ if (model != null)
+ {
+ modelList.Add(model);
+ }
+ }
+ }
+ return modelList;
+ }
+
+ ///
+ /// 获得数据列表
+ ///
+ public DataSet GetAllList()
+ {
+ return GetList("");
+ }
+
+ ///
+ /// 分页获取数据列表
+ ///
+ public int GetRecordCount(string strWhere)
+ {
+ return dal.GetRecordCount(strWhere);
+ }
+ ///
+ /// 分页获取数据列表
+ ///
+ public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
+ {
+ return dal.GetListByPage( strWhere, orderby, startIndex, endIndex);
+ }
+ ///
+ /// 分页获取数据列表
+ ///
+ //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
+ //{
+ //return dal.GetList(PageSize,PageIndex,strWhere);
+ //}
+
+ #endregion BasicMethod
+ #region ExtensionMethod
+
+ #endregion ExtensionMethod
+ }
+}
+
diff --git a/DataServer/DAL/planned_energy.cs b/DataServer/DAL/planned_energy.cs
new file mode 100644
index 0000000..d577137
--- /dev/null
+++ b/DataServer/DAL/planned_energy.cs
@@ -0,0 +1,346 @@
+/** 版本信息模板在安装目录下,可自行修改。
+* planned_energy.cs
+*
+* 功 能: N/A
+* 类 名: planned_energy
+*
+* Ver 变更日期 负责人 变更内容
+* ───────────────────────────────────
+* V0.01 2024/1/10 13:19:01 N/A 初版
+*
+* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
+*┌──────────────────────────────────┐
+*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
+*│ 版权所有:动软卓越(北京)科技有限公司 │
+*└──────────────────────────────────┘
+*/
+using System;
+using System.Data;
+using System.Text;
+using MySql.Data.MySqlClient;
+using Maticsoft.DBUtility;//Please add references
+namespace DataServer.DAL
+{
+ ///
+ /// 数据访问类:planned_energy
+ ///
+ public partial class planned_energy
+ {
+ public planned_energy()
+ {}
+ #region BasicMethod
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(string Id)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("select count(1) from planned_energy");
+ strSql.Append(" where Id=@Id ");
+ MySqlParameter[] parameters = {
+ new MySqlParameter("@Id", MySqlDbType.VarChar,32) };
+ parameters[0].Value = Id;
+
+ return DbHelperMySQL.Exists(strSql.ToString(),parameters);
+ }
+
+
+ ///
+ /// 增加一条数据
+ ///
+ public bool Add(DataServer.Model.planned_energy model)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("insert into planned_energy(");
+ strSql.Append("Id,Month,Plan,Type,Remark1,Remark2,Remark3,Remark4,Remark5)");
+ strSql.Append(" values (");
+ strSql.Append("@Id,@Month,@Plan,@Type,@Remark1,@Remark2,@Remark3,@Remark4,@Remark5)");
+ MySqlParameter[] parameters = {
+ new MySqlParameter("@Id", MySqlDbType.VarChar,32),
+ new MySqlParameter("@Month", MySqlDbType.Int32),
+ new MySqlParameter("@Plan", MySqlDbType.Decimal,10),
+ new MySqlParameter("@Type", MySqlDbType.VarChar,255),
+ new MySqlParameter("@Remark1", MySqlDbType.VarChar,255),
+ new MySqlParameter("@Remark2", MySqlDbType.VarChar,255),
+ new MySqlParameter("@Remark3", MySqlDbType.VarChar,255),
+ new MySqlParameter("@Remark4", MySqlDbType.VarChar,255),
+ new MySqlParameter("@Remark5", MySqlDbType.VarChar,255)};
+ parameters[0].Value = model.Id;
+ parameters[1].Value = model.Month;
+ parameters[2].Value = model.Plan;
+ parameters[3].Value = model.Type;
+ parameters[4].Value = model.Remark1;
+ parameters[5].Value = model.Remark2;
+ parameters[6].Value = model.Remark3;
+ parameters[7].Value = model.Remark4;
+ parameters[8].Value = model.Remark5;
+
+ int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(DataServer.Model.planned_energy model)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("update planned_energy set ");
+ strSql.Append("Month=@Month,");
+ strSql.Append("Plan=@Plan,");
+ strSql.Append("Type=@Type,");
+ strSql.Append("Remark1=@Remark1,");
+ strSql.Append("Remark2=@Remark2,");
+ strSql.Append("Remark3=@Remark3,");
+ strSql.Append("Remark4=@Remark4,");
+ strSql.Append("Remark5=@Remark5");
+ strSql.Append(" where Id=@Id ");
+ MySqlParameter[] parameters = {
+ new MySqlParameter("@Month", MySqlDbType.Int32),
+ new MySqlParameter("@Plan", MySqlDbType.Decimal,10),
+ new MySqlParameter("@Type", MySqlDbType.VarChar,255),
+ new MySqlParameter("@Remark1", MySqlDbType.VarChar,255),
+ new MySqlParameter("@Remark2", MySqlDbType.VarChar,255),
+ new MySqlParameter("@Remark3", MySqlDbType.VarChar,255),
+ new MySqlParameter("@Remark4", MySqlDbType.VarChar,255),
+ new MySqlParameter("@Remark5", MySqlDbType.VarChar,255),
+ new MySqlParameter("@Id", MySqlDbType.VarChar,32)};
+ parameters[0].Value = model.Month;
+ parameters[1].Value = model.Plan;
+ parameters[2].Value = model.Type;
+ parameters[3].Value = model.Remark1;
+ parameters[4].Value = model.Remark2;
+ parameters[5].Value = model.Remark3;
+ parameters[6].Value = model.Remark4;
+ parameters[7].Value = model.Remark5;
+ parameters[8].Value = model.Id;
+
+ int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(string Id)
+ {
+
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("delete from planned_energy ");
+ strSql.Append(" where Id=@Id ");
+ MySqlParameter[] parameters = {
+ new MySqlParameter("@Id", MySqlDbType.VarChar,32) };
+ parameters[0].Value = Id;
+
+ int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ ///
+ /// 批量删除数据
+ ///
+ public bool DeleteList(string Idlist )
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("delete from planned_energy ");
+ strSql.Append(" where Id in ("+Idlist + ") ");
+ int rows=DbHelperMySQL.ExecuteSql(strSql.ToString());
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public DataServer.Model.planned_energy GetModel(string Id)
+ {
+
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("select Id,Month,Plan,Type,Remark1,Remark2,Remark3,Remark4,Remark5 from planned_energy ");
+ strSql.Append(" where Id=@Id ");
+ MySqlParameter[] parameters = {
+ new MySqlParameter("@Id", MySqlDbType.VarChar,32) };
+ parameters[0].Value = Id;
+
+ DataServer.Model.planned_energy model=new DataServer.Model.planned_energy();
+ DataSet ds=DbHelperMySQL.Query(strSql.ToString(),parameters);
+ if(ds.Tables[0].Rows.Count>0)
+ {
+ return DataRowToModel(ds.Tables[0].Rows[0]);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public DataServer.Model.planned_energy DataRowToModel(DataRow row)
+ {
+ DataServer.Model.planned_energy model=new DataServer.Model.planned_energy();
+ if (row != null)
+ {
+ if(row["Id"]!=null)
+ {
+ model.Id=row["Id"].ToString();
+ }
+ if(row["Month"]!=null && row["Month"].ToString()!="")
+ {
+ model.Month=int.Parse(row["Month"].ToString());
+ }
+ if(row["Plan"]!=null && row["Plan"].ToString()!="")
+ {
+ model.Plan=decimal.Parse(row["Plan"].ToString());
+ }
+ if(row["Type"]!=null)
+ {
+ model.Type=row["Type"].ToString();
+ }
+ if(row["Remark1"]!=null)
+ {
+ model.Remark1=row["Remark1"].ToString();
+ }
+ if(row["Remark2"]!=null)
+ {
+ model.Remark2=row["Remark2"].ToString();
+ }
+ if(row["Remark3"]!=null)
+ {
+ model.Remark3=row["Remark3"].ToString();
+ }
+ if(row["Remark4"]!=null)
+ {
+ model.Remark4=row["Remark4"].ToString();
+ }
+ if(row["Remark5"]!=null)
+ {
+ model.Remark5=row["Remark5"].ToString();
+ }
+ }
+ return model;
+ }
+
+ ///
+ /// 获得数据列表
+ ///
+ public DataSet GetList(string strWhere)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("select Id,Month,Plan,Type,Remark1,Remark2,Remark3,Remark4,Remark5 ");
+ strSql.Append(" FROM planned_energy ");
+ if(strWhere.Trim()!="")
+ {
+ strSql.Append(" where "+strWhere);
+ }
+ return DbHelperMySQL.Query(strSql.ToString());
+ }
+
+ ///
+ /// 获取记录总数
+ ///
+ public int GetRecordCount(string strWhere)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("select count(1) FROM planned_energy ");
+ if(strWhere.Trim()!="")
+ {
+ strSql.Append(" where "+strWhere);
+ }
+ object obj = DbHelperMySQL.GetSingle(strSql.ToString());
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+ ///
+ /// 分页获取数据列表
+ ///
+ public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("SELECT * FROM ( ");
+ strSql.Append(" SELECT ROW_NUMBER() OVER (");
+ if (!string.IsNullOrEmpty(orderby.Trim()))
+ {
+ strSql.Append("order by T." + orderby );
+ }
+ else
+ {
+ strSql.Append("order by T.Id desc");
+ }
+ strSql.Append(")AS Row, T.* from planned_energy T ");
+ if (!string.IsNullOrEmpty(strWhere.Trim()))
+ {
+ strSql.Append(" WHERE " + strWhere);
+ }
+ strSql.Append(" ) TT");
+ strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
+ return DbHelperMySQL.Query(strSql.ToString());
+ }
+
+ /*
+ ///
+ /// 分页获取数据列表
+ ///
+ public DataSet GetList(int PageSize,int PageIndex,string strWhere)
+ {
+ MySqlParameter[] parameters = {
+ new MySqlParameter("@tblName", MySqlDbType.VarChar, 255),
+ new MySqlParameter("@fldName", MySqlDbType.VarChar, 255),
+ new MySqlParameter("@PageSize", MySqlDbType.Int32),
+ new MySqlParameter("@PageIndex", MySqlDbType.Int32),
+ new MySqlParameter("@IsReCount", MySqlDbType.Bit),
+ new MySqlParameter("@OrderType", MySqlDbType.Bit),
+ new MySqlParameter("@strWhere", MySqlDbType.VarChar,1000),
+ };
+ parameters[0].Value = "planned_energy";
+ parameters[1].Value = "Id";
+ parameters[2].Value = PageSize;
+ parameters[3].Value = PageIndex;
+ parameters[4].Value = 0;
+ parameters[5].Value = 0;
+ parameters[6].Value = strWhere;
+ return DbHelperMySQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
+ }*/
+
+ #endregion BasicMethod
+ #region ExtensionMethod
+
+ #endregion ExtensionMethod
+ }
+}
+
diff --git a/DataServer/DataServer.csproj b/DataServer/DataServer.csproj
index 6a243d8..e3df65e 100644
--- a/DataServer/DataServer.csproj
+++ b/DataServer/DataServer.csproj
@@ -96,6 +96,7 @@
+
@@ -105,6 +106,7 @@
+
@@ -114,6 +116,7 @@
+
diff --git a/DataServer/Model/planned_energy.cs b/DataServer/Model/planned_energy.cs
new file mode 100644
index 0000000..d3b13ee
--- /dev/null
+++ b/DataServer/Model/planned_energy.cs
@@ -0,0 +1,114 @@
+/** 版本信息模板在安装目录下,可自行修改。
+* planned_energy.cs
+*
+* 功 能: N/A
+* 类 名: planned_energy
+*
+* Ver 变更日期 负责人 变更内容
+* ───────────────────────────────────
+* V0.01 2024/1/10 13:19:01 N/A 初版
+*
+* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
+*┌──────────────────────────────────┐
+*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
+*│ 版权所有:动软卓越(北京)科技有限公司 │
+*└──────────────────────────────────┘
+*/
+using System;
+namespace DataServer.Model
+{
+ ///
+ /// planned_energy:实体类(属性说明自动提取数据库字段的描述信息)
+ ///
+ [Serializable]
+ public partial class planned_energy
+ {
+ public planned_energy()
+ {}
+ #region Model
+ private string _id;
+ private int? _month;
+ private decimal? _plan;
+ private string _type;
+ private string _remark1;
+ private string _remark2;
+ private string _remark3;
+ private string _remark4;
+ private string _remark5;
+ ///
+ ///
+ ///
+ public string Id
+ {
+ set{ _id=value;}
+ get{return _id;}
+ }
+ ///
+ ///
+ ///
+ public int? Month
+ {
+ set{ _month=value;}
+ get{return _month;}
+ }
+ ///
+ ///
+ ///
+ public decimal? Plan
+ {
+ set{ _plan=value;}
+ get{return _plan;}
+ }
+ ///
+ ///
+ ///
+ public string Type
+ {
+ set{ _type=value;}
+ get{return _type;}
+ }
+ ///
+ ///
+ ///
+ public string Remark1
+ {
+ set{ _remark1=value;}
+ get{return _remark1;}
+ }
+ ///
+ ///
+ ///
+ public string Remark2
+ {
+ set{ _remark2=value;}
+ get{return _remark2;}
+ }
+ ///
+ ///
+ ///
+ public string Remark3
+ {
+ set{ _remark3=value;}
+ get{return _remark3;}
+ }
+ ///
+ ///
+ ///
+ public string Remark4
+ {
+ set{ _remark4=value;}
+ get{return _remark4;}
+ }
+ ///
+ ///
+ ///
+ public string Remark5
+ {
+ set{ _remark5=value;}
+ get{return _remark5;}
+ }
+ #endregion Model
+
+ }
+}
+
diff --git a/DataServer/api/EnergyEfficiency/get_classified_energy_response.cs b/DataServer/api/EnergyEfficiency/get_classified_energy_response.cs
index ce319f4..289cd33 100644
--- a/DataServer/api/EnergyEfficiency/get_classified_energy_response.cs
+++ b/DataServer/api/EnergyEfficiency/get_classified_energy_response.cs
@@ -20,5 +20,58 @@ namespace DataServer.api.EnergyEfficiency
/// 返回说明
///
public string msg { get; set; }
+
+ ///
+ /// 数据
+ ///
+ public classified_energy data { get; set; }
+ }
+
+ public class classified_energy
+ {
+ ///
+ /// 今日、今月、今年水量
+ ///
+ public decimal ModernWater { get; set; }
+
+ ///
+ /// 昨日、上月、去年水量
+ ///
+ public decimal UpperWater { get; set; }
+
+ ///
+ /// 水量同比
+ ///
+ public decimal YoyWater { get; set; }
+
+ ///
+ /// 今日、今月、今年天然气
+ ///
+ public decimal ModernGas { get; set; }
+
+ ///
+ /// 昨日、上月、去年天然气
+ ///
+ public decimal UpperGas { get; set; }
+
+ ///
+ /// 天然气同比
+ ///
+ public decimal YoyGas { get; set; }
+
+ ///
+ /// 今日、今月、今年电量
+ ///
+ public decimal ModernElectricity { get; set; }
+
+ ///
+ /// 昨日、上月、去年电量
+ ///
+ public decimal UpperElectricity { get; set; }
+
+ ///
+ /// 电量同比
+ ///
+ public decimal YoyElectricity { get; set; }
}
}
diff --git a/DataServer/api/EnergyEfficiency/get_energy_trend_response.cs b/DataServer/api/EnergyEfficiency/get_energy_trend_response.cs
index 80c4296..47ec3f1 100644
--- a/DataServer/api/EnergyEfficiency/get_energy_trend_response.cs
+++ b/DataServer/api/EnergyEfficiency/get_energy_trend_response.cs
@@ -20,5 +20,28 @@ namespace DataServer.api.EnergyEfficiency
/// 返回说明
///
public string msg { get; set; }
+
+ ///
+ /// 数据
+ ///
+ public List data { get; set; }
+ }
+
+ public class energy_trend
+ {
+ ///
+ /// 月份
+ ///
+ public string Month { get; set; }
+
+ ///
+ /// 计划能耗
+ ///
+ public decimal Plan { get; set; }
+
+ ///
+ /// 值
+ ///
+ public decimal Value { get; set; }
}
}
diff --git a/DataServer/api/EnergyEfficiency/get_itemize_energy_response.cs b/DataServer/api/EnergyEfficiency/get_itemize_energy_response.cs
index ffaea48..919f939 100644
--- a/DataServer/api/EnergyEfficiency/get_itemize_energy_response.cs
+++ b/DataServer/api/EnergyEfficiency/get_itemize_energy_response.cs
@@ -20,5 +20,33 @@ namespace DataServer.api.EnergyEfficiency
/// 返回说明
///
public string msg { get; set; }
+
+ ///
+ /// 数据
+ ///
+ public itemize_energy data { get; set; }
+ }
+
+ public class itemize_energy
+ {
+ ///
+ /// 电梯
+ ///
+ public decimal Lift { get; set; }
+
+ ///
+ /// 照明
+ ///
+ public decimal Lighting { get; set; }
+
+ ///
+ /// 空调
+ ///
+ public decimal AirConditioning { get; set; }
+
+ ///
+ /// 其他
+ ///
+ public decimal Other { get; set; }
}
}
diff --git a/DataServer/obj/Debug/DataServer.csproj.CoreCompileInputs.cache b/DataServer/obj/Debug/DataServer.csproj.CoreCompileInputs.cache
index 6f8fa5a..318629e 100644
--- a/DataServer/obj/Debug/DataServer.csproj.CoreCompileInputs.cache
+++ b/DataServer/obj/Debug/DataServer.csproj.CoreCompileInputs.cache
@@ -1 +1,5 @@
+<<<<<<< HEAD
4c49ecb8992ee253af38dc297bc68a59dc3931a1
+=======
+f8c698525a16b5084430f058269e79a2d843daa4
+>>>>>>> ed1a5636011cbbab43211edc340b78e5091aabc9
diff --git a/DongYingAPI/Controllers/api/EnergyEfficiency/GetClassifiedEnergyController.cs b/DongYingAPI/Controllers/api/EnergyEfficiency/GetClassifiedEnergyController.cs
index 02cc3bc..ebaefad 100644
--- a/DongYingAPI/Controllers/api/EnergyEfficiency/GetClassifiedEnergyController.cs
+++ b/DongYingAPI/Controllers/api/EnergyEfficiency/GetClassifiedEnergyController.cs
@@ -1,7 +1,9 @@
using DataServer.api.EnergyEfficiency;
+using DongYingAPI.Util;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
+using System.Configuration;
using System.Linq;
using System.Net;
using System.Net.Http;
@@ -12,15 +14,235 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
{
public class GetClassifiedEnergyController : ApiController
{
+ DataServer.BLL.device_info device_bll = new DataServer.BLL.device_info();
+
+ DataServer.BLL.electricity_data bll = new DataServer.BLL.electricity_data();
+
+ DataServer.BLL.water_data water_bll = new DataServer.BLL.water_data();
+
+ DataServer.BLL.gas_data gas_bll = new DataServer.BLL.gas_data();
+
///
/// 获取分类能耗接口
///
+ /// 类型 年、月、日
///
- public HttpResponseMessage Get()
+ public HttpResponseMessage Get(string type)
{
var res = new get_classified_energy_response();
try
{
+ var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
+ decimal modern_water = 0;
+ decimal upper_water = 0;
+
+ decimal modern_gas = 0;
+ decimal upper_gas = 0;
+
+ decimal modern_electricity = 0;
+ decimal upper_electricity = 0;
+ var now = DateTime.Now;
+ var modern_start_time = DateTime.Parse(now.ToString("yyyy-MM-dd") + " 00:00:00");
+ var modern_end_time = DateTime.Parse(now.ToString("yyyy-MM-dd HH") + ":00:00");
+ var upper_start_time = DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd") + " 00:00:00");
+ var upper_end_time = DateTime.Parse(now.ToString("yyyy-MM-dd") + " 00:00:00");
+ var list = new List();
+ if (type == "日")
+ {
+ modern_start_time = DateTime.Parse(now.ToString("yyyy-MM-dd") + " 00:00:00");
+ modern_end_time = DateTime.Parse(now.ToString("yyyy-MM-dd HH") + ":00:00");
+ upper_start_time = DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd") + " 00:00:00");
+ upper_end_time = DateTime.Parse(now.ToString("yyyy-MM-dd") + " 00:00:00");
+
+ //电
+ //判断表是否存在,不存在就创建
+ var time = now.ToString("yyyyMM");
+ if (!bll.IsExistsTable(date_base, "electricity_data_" + time))
+ {
+ bll.CreateTable(time);
+ }
+ list = bll.GetModelListDate(" EntireTime='" + modern_start_time + "' or EntireTime='" + modern_end_time + "' or EntireTime='" + upper_start_time + "' or EntireTime='" + upper_end_time + "' ", time);
+ }
+ else if (type == "月")
+ {
+ 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");
+ upper_start_time = DateTime.Parse(now.AddMonths(-1).ToString("yyyy-MM") + "-01 00:00:00");
+ upper_end_time = modern_start_time;
+ var time_count = Tool.GetUsedMonth1("月", upper_start_time, modern_end_time);
+ var source = "";
+ for (int i = 0; i <= time_count; i++)
+ {
+ var time = upper_start_time.AddMonths(i).ToString("yyyyMM");
+ if (bll.IsExistsTable(date_base, "electricity_data_" + time))
+ {
+ if (time == upper_start_time.ToString("yyyyMMdd") || time == modern_end_time.ToString("yyyyMMdd"))
+ {
+ 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);
+ }
+ else
+ {
+ 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 += ") UNION all ";
+ }
+ }
+ if (!string.IsNullOrEmpty(source))
+ {
+ source = source.Substring(0, source.Length - 11);
+ list = bll.GetList(source, "", "");
+ }
+ }
+ else if (type == "年")
+ {
+ 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");
+ upper_start_time = DateTime.Parse(now.AddYears(-1).ToString("yyyy") + "-01-01 00:00:00");
+ upper_end_time = modern_start_time;
+ var time_count = Tool.GetUsedMonth1("月", upper_start_time, modern_end_time);
+ var source = "";
+ for (int i = 0; i <= time_count; i++)
+ {
+ var time = upper_start_time.AddMonths(i).ToString("yyyyMM");
+ if (bll.IsExistsTable(date_base, "electricity_data_" + time))
+ {
+ if (time == upper_start_time.ToString("yyyyMMdd") || time == modern_end_time.ToString("yyyyMMdd"))
+ {
+ 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);
+ }
+ else
+ {
+ 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 += ") UNION all ";
+ }
+ }
+ if (!string.IsNullOrEmpty(source))
+ {
+ source = source.Substring(0, source.Length - 11);
+ list = bll.GetList(source, "", "");
+ }
+ }
+
+ //水
+ var water_list = water_bll.GetModelList(" EntireTime='" + modern_start_time + "' or EntireTime='" + modern_end_time + "' or EntireTime='" + upper_start_time + "' or EntireTime='" + upper_end_time + "' ");
+ if (water_list.Count > 0)
+ {
+ var modern_start_data = water_list.Where(a => a.EntireTime.Value == modern_start_time).FirstOrDefault();
+ var modern_end_data = water_list.Where(a => a.EntireTime.Value == modern_end_time).FirstOrDefault();
+ if (modern_start_data != null && modern_end_data != null)
+ {
+ if (modern_start_data.WaterYield != null && modern_end_data.WaterYield != null)
+ {
+ decimal water_yield = modern_end_data.WaterYield.Value - modern_start_data.WaterYield.Value;
+ modern_water = water_yield;
+ }
+ }
+
+ var upper_start_data = water_list.Where(a => a.EntireTime.Value == upper_start_time).FirstOrDefault();
+ var upper_end_data = water_list.Where(a => a.EntireTime.Value == upper_end_time).FirstOrDefault();
+ if (upper_start_data != null && upper_end_data != null)
+ {
+ if (upper_start_data.WaterYield != null && upper_end_data.WaterYield != null)
+ {
+ decimal water_yield = upper_end_data.WaterYield.Value - upper_start_data.WaterYield.Value;
+ upper_water = water_yield;
+ }
+ }
+ }
+
+ //天然气
+ var gas_list = gas_bll.GetModelList(" EntireTime='" + modern_start_time + "' or EntireTime='" + modern_end_time + "' or EntireTime='" + upper_start_time + "' or EntireTime='" + upper_end_time + "' ");
+ if (gas_list.Count > 0)
+ {
+ var modern_start_data = gas_list.Where(a => a.EntireTime.Value == modern_start_time).FirstOrDefault();
+ var modern_end_data = gas_list.Where(a => a.EntireTime.Value == modern_end_time).FirstOrDefault();
+ if (modern_start_data != null && modern_end_data != null)
+ {
+ if (modern_start_data.GasConsumption != null && modern_end_data.GasConsumption != null)
+ {
+ decimal gas_consumption = modern_end_data.GasConsumption.Value - modern_start_data.GasConsumption.Value;
+ modern_gas = gas_consumption;
+ }
+ }
+
+ var upper_start_data = gas_list.Where(a => a.EntireTime.Value == upper_start_time).FirstOrDefault();
+ var upper_end_data = gas_list.Where(a => a.EntireTime.Value == upper_end_time).FirstOrDefault();
+ if (upper_start_data != null && upper_end_data != null)
+ {
+ if (upper_start_data.GasConsumption != null && upper_end_data.GasConsumption != null)
+ {
+ decimal gas_consumption = upper_end_data.GasConsumption.Value - upper_start_data.GasConsumption.Value;
+ upper_gas = gas_consumption;
+ }
+ }
+ }
+
+ //电
+ var device_list = device_bll.GetModelList("");
+ 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_end_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == modern_end_time).FirstOrDefault();
+ if (modern_start_data != null && modern_end_data != null)
+ {
+ if (modern_start_data.EH != null && modern_end_data.EH != null)
+ {
+ decimal eh = modern_end_data.EH.Value - modern_start_data.EH.Value;
+ modern_electricity += eh;
+ }
+ }
+
+ var upper_start_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == upper_start_time).FirstOrDefault();
+ var upper_end_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == upper_end_time).FirstOrDefault();
+ if (upper_start_data != null && upper_end_data != null)
+ {
+ if (upper_start_data.EH != null && upper_end_data.EH != null)
+ {
+ decimal eh = upper_end_data.EH.Value - upper_start_data.EH.Value;
+ upper_electricity += eh;
+ }
+ }
+ }
+ decimal yoy_water = 0;
+ decimal yoy_gas = 0;
+ decimal yoy_electricity = 0;
+ if (upper_water > 0)
+ {
+ yoy_water = Math.Round((modern_water - upper_water) / upper_water * 100, 2);
+ }
+ else
+ {
+ if (modern_water > 0)
+ {
+ yoy_water = 100;
+ }
+ }
+ if (upper_gas > 0)
+ {
+ yoy_gas = Math.Round((modern_gas - upper_gas) / upper_gas * 100, 2);
+ }
+ else
+ {
+ if (modern_gas > 0)
+ {
+ yoy_gas = 100;
+ }
+ }
+ if (upper_electricity > 0)
+ {
+ yoy_electricity = Math.Round((modern_electricity - upper_electricity) / upper_electricity * 100, 2);
+ }
+ else
+ {
+ if (modern_electricity > 0)
+ {
+ yoy_electricity = 100;
+ }
+ }
+ res.code = 200;
+ res.msg = "成功";
+ res.data = new classified_energy() { ModernElectricity = modern_electricity, ModernGas = modern_gas, ModernWater = modern_water, UpperElectricity = upper_electricity, UpperGas = upper_gas, UpperWater = upper_water, YoyElectricity = yoy_electricity, YoyGas = yoy_gas, YoyWater = yoy_water };
}
catch (Exception ex)
{
diff --git a/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyConsumptionController.cs b/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyConsumptionController.cs
index 1ca27a1..c1d5a0f 100644
--- a/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyConsumptionController.cs
+++ b/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyConsumptionController.cs
@@ -1,4 +1,5 @@
using DataServer.api.EnergyEfficiency;
+using DongYingAPI.Util;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -36,7 +37,7 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
if (type == "年")
{
var start_date = DateTime.Parse(now.ToString("yyyy") + "-01-01 00:00:00");
- var time_count = GetUsedMonth1("月", start_date, now);
+ var time_count = Tool.GetUsedMonth1("月", start_date, now);
var source = "";
for (int i = 0; i <= time_count; i++)
{
@@ -45,7 +46,7 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
{
if (time == start_date.ToString("yyyyMMdd") || time == now.ToString("yyyyMMdd"))
{
- 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 CreateTime>='{1}' and CreateTime<='{2}'", time, start_date, now);
+ 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_date, now);
}
else
{
@@ -68,7 +69,7 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
{
bll.CreateTable(time);
}
- list = bll.GetList("(select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_" + time + ")", " CreateTime>='" + start_date + "' and CreateTime<='" + now + "' ", "");
+ list = bll.GetList("(select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_" + time + ")", " EntireTime>='" + start_date + "' and EntireTime<='" + now + "' ", "");
}
else if (type == "日")
{
@@ -78,7 +79,7 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
{
bll.CreateTable(time);
}
- list = bll.GetList("(select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_" + time + ")", " CreateTime>='" + start_date + "' and CreateTime<='" + now + "' ", "");
+ list = bll.GetList("(select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_" + time + ")", " EntireTime>='" + start_date + "' and EntireTime<='" + now + "' ", "");
}
var data = new List();
@@ -102,34 +103,5 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(res), Encoding.GetEncoding("UTF-8"), "application/json") };
return result;
}
-
- ///
- /// 计算两个时间年份月份差
- ///
- ///
- public int GetUsedMonth1(string type, DateTime dynamicTime, DateTime currentDate)
- {
- try
- {
- int year = currentDate.Year - dynamicTime.Year; //相差的年份
- int month = (currentDate.Year - dynamicTime.Year) * 12 + (currentDate.Month - dynamicTime.Month); //相差的月份
- //int month1 = currentDate.Year * 12 + currentDate.Month - dynamicTime.Year * 12 - dynamicTime.Month; //相差的月份
-
- TimeSpan used = DateTime.Now - dynamicTime;
- double totalDays = used.TotalDays; //相差总天数
- if (type == "年")
- {
- return Convert.ToInt32(year);
- }
- else
- {
- return Convert.ToInt32(month);
- }
- }
- catch (Exception)
- {
- return 0;
- }
- }
}
}
diff --git a/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyTrendController.cs b/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyTrendController.cs
index 5655e86..5a155e1 100644
--- a/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyTrendController.cs
+++ b/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyTrendController.cs
@@ -1,7 +1,11 @@
using DataServer.api.EnergyEfficiency;
+using DongYingAPI.Util;
using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
+using System.Configuration;
+using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Http;
@@ -12,15 +16,164 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
{
public class GetEnergyTrendController : ApiController
{
+ DataServer.BLL.device_info device_bll = new DataServer.BLL.device_info();
+
+ DataServer.BLL.electricity_data bll = new DataServer.BLL.electricity_data();
+
+ DataServer.BLL.water_data water_bll = new DataServer.BLL.water_data();
+
+ DataServer.BLL.gas_data gas_bll = new DataServer.BLL.gas_data();
+
+ DataServer.BLL.planned_energy plan_bll = new DataServer.BLL.planned_energy();
+
///
/// 获取能耗趋势接口
///
+ /// 类型 电、水、天然气
///
- public HttpResponseMessage Get()
+ public HttpResponseMessage Get(string type)
{
var res = new get_energy_trend_response();
try
{
+ var now = DateTime.Now;
+ var start_time = DateTime.Parse(now.ToString("yyyy") + "-01-01 00:00:00");
+ var end_time = DateTime.Parse(now.ToString("yyyy-MM-dd HH") + ":00:00");
+ var time_count = Tool.GetUsedMonth1("月", start_time, end_time);
+ var data = new List();
+ var plan_list = plan_bll.GetModelList(" Type='" + type + "' ");
+ if (type == "电")
+ {
+ var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
+ var list = new List();
+ var source = "";
+ for (int i = 0; i <= time_count; i++)
+ {
+ var time = start_time.AddMonths(i).ToString("yyyyMM");
+ if (bll.IsExistsTable(date_base, "electricity_data_" + time))
+ {
+ if (time == start_time.ToString("yyyyMMdd") || time == end_time.ToString("yyyyMMdd"))
+ {
+ 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);
+ }
+ else
+ {
+ 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 += ") UNION all ";
+ }
+ }
+ if (!string.IsNullOrEmpty(source))
+ {
+ source = source.Substring(0, source.Length - 11);
+ list = bll.GetList(source, "", "");
+ }
+
+ var device_list = device_bll.GetModelList("");
+
+ for (int i = 0; i <= time_count; i++)
+ {
+ var month = start_time.AddMonths(i).Month;
+ var time = start_time.AddMonths(i);
+ var end = time.AddMonths(1);
+ if (time.ToString("yyyy-MM") == end_time.ToString("yyyy-MM"))
+ {
+ end = end_time;
+ }
+ var plan_model = plan_list.Where(a => a.Month == month).FirstOrDefault();
+ decimal value = 0;
+ foreach (var item in device_list)
+ {
+ var start_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == time).FirstOrDefault();
+ var end_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == end).FirstOrDefault();
+ if (start_data != null && end_data != null)
+ {
+ if (start_data.EH != null && end_data.EH != null)
+ {
+ decimal eh = end_data.EH.Value - start_data.EH.Value;
+ value += eh;
+ }
+ }
+ }
+
+ var model = new energy_trend();
+ model.Month = month.ToString() + "月";
+ if (plan_model != null)
+ {
+ model.Plan = plan_model.Plan.Value;
+ }
+ model.Value = value;
+ data.Add(model);
+ }
+ }
+ else if (type == "水")
+ {
+ var water_list = water_bll.GetModelList(" EntireTime>='" + start_time + "' or EntireTime<='" + end_time + "' ");
+ for (int i = 0; i <= time_count; i++)
+ {
+ var month = start_time.AddMonths(i).Month;
+ var time = start_time.AddMonths(i);
+ var end = time.AddMonths(1);
+ if (time.ToString("yyyy-MM") == end_time.ToString("yyyy-MM"))
+ {
+ end = end_time;
+ }
+ var plan_model = plan_list.Where(a => a.Month == month).FirstOrDefault();
+ var start_data = water_list.Where(a => a.EntireTime.Value == time).FirstOrDefault();
+ var end_data = water_list.Where(a => a.EntireTime.Value == end).FirstOrDefault();
+ if (start_data != null && end_data != null)
+ {
+ if (start_data.WaterYield != null && end_data.WaterYield != null)
+ {
+ decimal water_yield = end_data.WaterYield.Value - start_data.WaterYield.Value;
+ var model = new energy_trend();
+ model.Month = month.ToString() + "月";
+ model.Value = water_yield;
+ if (plan_model != null)
+ {
+ model.Plan = plan_model.Plan.Value;
+ }
+ data.Add(model);
+ }
+ }
+ }
+ }
+ else if (type == "天然气")
+ {
+ var gas_list = gas_bll.GetModelList(" EntireTime>='" + start_time + "' or EntireTime<='" + end_time + "' ");
+ for (int i = 0; i <= time_count; i++)
+ {
+ var month = start_time.AddMonths(i).Month;
+ var time = start_time.AddMonths(i);
+ var end = time.AddMonths(1);
+ if (time.ToString("yyyy-MM") == end_time.ToString("yyyy-MM"))
+ {
+ end = end_time;
+ }
+ var plan_model = plan_list.Where(a => a.Month == month).FirstOrDefault();
+ var start_data = gas_list.Where(a => a.EntireTime.Value == time).FirstOrDefault();
+ var end_data = gas_list.Where(a => a.EntireTime.Value == end).FirstOrDefault();
+ if (start_data != null && end_data != null)
+ {
+ if (start_data.GasConsumption != null && end_data.GasConsumption != null)
+ {
+ decimal gas_consumption = end_data.GasConsumption.Value - start_data.GasConsumption.Value;
+ var model = new energy_trend();
+ model.Month = month.ToString() + "月";
+ model.Value = gas_consumption;
+ if (plan_model != null)
+ {
+ model.Plan = plan_model.Plan.Value;
+ }
+ data.Add(model);
+ }
+ }
+ }
+ }
+
+ res.code = 200;
+ res.msg = "成功";
+ res.data = data;
}
catch (Exception ex)
{
diff --git a/DongYingAPI/Controllers/api/EnergyEfficiency/GetItemizeEnergyController.cs b/DongYingAPI/Controllers/api/EnergyEfficiency/GetItemizeEnergyController.cs
index 7b2b4f5..e583964 100644
--- a/DongYingAPI/Controllers/api/EnergyEfficiency/GetItemizeEnergyController.cs
+++ b/DongYingAPI/Controllers/api/EnergyEfficiency/GetItemizeEnergyController.cs
@@ -26,31 +26,60 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
var res = new get_itemize_energy_response();
try
{
- //var now = DateTime.Now;
- //var device_list = device_bll.GetModelList("");
- //var list = new List();
- ////判断表是否存在,不存在就创建
- //var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
- //var start_date = DateTime.Parse(now.ToString("yyyy-MM-dd") + " 00:00:00");
- //var time = now.ToString("yyyyMM");
- //if (!bll.IsExistsTable(date_base, "electricity_data_" + time))
- //{
- // bll.CreateTable(time);
- //}
- //list = bll.GetList("(select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_" + time + ")", " CreateTime>='" + start_date + "' and CreateTime<='" + now + "' ", "");
+ //空调
+ decimal air_conditioning = 0;
+ //照明
+ decimal lighting = 0;
+ //电梯
+ decimal lift = 0;
+ //其他
+ decimal other = 0;
+ var now = DateTime.Now;
+ //判断表是否存在,不存在就创建
+ var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
+ var time = now.ToString("yyyyMM");
+ if (!bll.IsExistsTable(date_base, "electricity_data_" + time))
+ {
+ bll.CreateTable(time);
+ }
+ //查询今天0点和当前小时整点的数据出来
+ var start_time = DateTime.Parse(now.ToString("yyyy-MM-dd") + " 00:00:00");
+ var end_time = DateTime.Parse(now.ToString("yyyy-MM-dd HH") + ":00:00");
+ var list = bll.GetModelListDate(" EntireTime='" + start_time + "' or EntireTime='" + end_time + "' ", time);
+ //查询电设备表,计算每个设备的用电量,然后按空调、电梯、照明、其它累加用电量
+ var device_list = device_bll.GetModelList("");
+ foreach (var item in device_list)
+ {
+ var start_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == start_time).FirstOrDefault();
+ var end_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == end_time).FirstOrDefault();
+ if (start_data != null && end_data != null)
+ {
+ if (start_data.EH != null && end_data.EH != null)
+ {
+ decimal eh = end_data.EH.Value - start_data.EH.Value;
+ if (item.DeviceName.Contains("照明"))
+ {
+ lighting += eh;
+ }
+ else if (item.DeviceName.Contains("空调"))
+ {
+ air_conditioning += eh;
+ }
+ else if (item.DeviceName.Contains("梯"))
+ {
+ lift += eh;
+ }
+ else
+ {
+ other += eh;
+ }
+ }
+ }
+ }
- //var data = new List();
- //foreach (var item in device_list)
- //{
- // var model = new energy_consumption();
- // model.DeviceName = item.DeviceName;
- // model.OperatingPower = list.Where(a => a.DeviceId == item.DeviceId).Sum(a => a.ServiceRating).Value;
- // data.Add(model);
- //}
-
- //res.code = 200;
- //res.msg = "成功";
- //res.data = data;
+ res.code = 200;
+ res.msg = "成功";
+ res.data = new itemize_energy() { Lift = lift, AirConditioning = air_conditioning, Lighting = lighting, Other = other };
}
catch (Exception ex)
{
diff --git a/DongYingAPI/Controllers/api/EnergyEfficiency/GetUnitConsumptionController.cs b/DongYingAPI/Controllers/api/EnergyEfficiency/GetUnitConsumptionController.cs
index c77b982..2097959 100644
--- a/DongYingAPI/Controllers/api/EnergyEfficiency/GetUnitConsumptionController.cs
+++ b/DongYingAPI/Controllers/api/EnergyEfficiency/GetUnitConsumptionController.cs
@@ -3,6 +3,7 @@ using DataServer.api.EnergyEfficiency;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
+using System.Configuration;
using System.Linq;
using System.Net;
using System.Net.Http;
@@ -13,7 +14,13 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
{
public class GetUnitConsumptionController : ApiController
{
- DataServer.BLL.device_data bll = new DataServer.BLL.device_data();
+ DataServer.BLL.device_info device_bll = new DataServer.BLL.device_info();
+
+ DataServer.BLL.electricity_data bll = new DataServer.BLL.electricity_data();
+
+ DataServer.BLL.water_data water_bll = new DataServer.BLL.water_data();
+
+ DataServer.BLL.gas_data gas_bll = new DataServer.BLL.gas_data();
///
/// 获取单耗接口
@@ -25,10 +32,79 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
try
{
var now = DateTime.Now;
- var start_time = now.ToString("yyyy-MM-dd") + " 00:00:00";
- var end_time = now.ToString("yyyy-MM-dd HH") + ":00:00";
-
+ var start_time = DateTime.Parse(now.ToString("yyyy-MM-dd") + " 00:00:00");
+ var end_time = DateTime.Parse(now.ToString("yyyy-MM-dd HH") + ":00:00");
+
+ //今日用水量
+ decimal water = 0;
+ //人均用水量
+ decimal avg_water_consumption = 0;
//根据事件查询两条数据,然后值相减为用水量
+ var water_list = water_bll.GetModelList(" EntireTime='" + start_time + "' or EntireTime='" + end_time + "' ");
+ if (water_list.Count >= 2)
+ {
+ var start_data = water_list.Where(a => a.EntireTime.Value == start_time).FirstOrDefault();
+ var end_data = water_list.Where(a => a.EntireTime.Value == end_time).FirstOrDefault();
+ if (start_data != null && end_data != null)
+ {
+ if (start_data.WaterYield != null && end_data.WaterYield != null)
+ {
+ decimal water_yield = end_data.WaterYield.Value - start_data.WaterYield.Value;
+ avg_water_consumption = Math.Round(water_yield / 3300, 2);
+ water = water_yield;
+ }
+ }
+ }
+
+ //今日天然气
+ decimal natural_gas = 0;
+ var gas_list = gas_bll.GetModelList(" EntireTime='" + start_time + "' or EntireTime='" + end_time + "' ");
+ if (gas_list.Count >= 2)
+ {
+ var start_data = gas_list.Where(a => a.EntireTime.Value == start_time).FirstOrDefault();
+ var end_data = gas_list.Where(a => a.EntireTime.Value == end_time).FirstOrDefault();
+ if (start_data != null && end_data != null)
+ {
+ if (start_data.GasConsumption != null && end_data.GasConsumption != null)
+ {
+ decimal gas_consumption = end_data.GasConsumption.Value - start_data.GasConsumption.Value;
+ natural_gas = gas_consumption;
+ }
+ }
+ }
+
+ //今日电量
+ decimal electricity = 0;
+ //判断表是否存在,不存在就创建
+ var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
+ var time = now.ToString("yyyyMM");
+ if (!bll.IsExistsTable(date_base, "electricity_data_" + time))
+ {
+ bll.CreateTable(time);
+ }
+ var list = bll.GetModelListDate(" EntireTime='" + start_time + "' or EntireTime='" + end_time + "' ", time);
+ var device_list = device_bll.GetModelList("");
+ foreach (var item in device_list)
+ {
+ var start_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == start_time).FirstOrDefault();
+ var end_data = list.Where(a => a.DeviceId == item.DeviceId && a.EntireTime.Value == end_time).FirstOrDefault();
+ if (start_data != null && end_data != null)
+ {
+ if (start_data.EH != null && end_data.EH != null)
+ {
+ decimal eh = end_data.EH.Value - start_data.EH.Value;
+ electricity += eh;
+ }
+ }
+ }
+
+ //人均综合能耗
+ decimal avg_energy_consumption = Math.Round((water + natural_gas + electricity) / 3300, 2);
+ //单位建筑面积综合能耗
+ decimal unit_building_area = Math.Round((water + natural_gas + electricity) / 59000, 2);
+ res.code = 200;
+ res.msg = "成功";
+ res.data = new unit_consumption() { avg_energy_consumption = avg_energy_consumption, avg_water_consumption = avg_water_consumption, unit_building_area = unit_building_area };
}
catch (Exception ex)
{
diff --git a/DongYingAPI/DongYingAPI.csproj b/DongYingAPI/DongYingAPI.csproj
index 8301d03..34725ae 100644
--- a/DongYingAPI/DongYingAPI.csproj
+++ b/DongYingAPI/DongYingAPI.csproj
@@ -203,6 +203,7 @@
Global.asax
+
diff --git a/DongYingAPI/Util/Tool.cs b/DongYingAPI/Util/Tool.cs
new file mode 100644
index 0000000..2b24b46
--- /dev/null
+++ b/DongYingAPI/Util/Tool.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace DongYingAPI.Util
+{
+ public class Tool
+ {
+ ///
+ /// 计算两个时间年份月份差
+ ///
+ ///
+ public static int GetUsedMonth1(string type, DateTime dynamicTime, DateTime currentDate)
+ {
+ try
+ {
+ int year = currentDate.Year - dynamicTime.Year; //相差的年份
+ int month = (currentDate.Year - dynamicTime.Year) * 12 + (currentDate.Month - dynamicTime.Month); //相差的月份
+ //int month1 = currentDate.Year * 12 + currentDate.Month - dynamicTime.Year * 12 - dynamicTime.Month; //相差的月份
+
+ TimeSpan used = DateTime.Now - dynamicTime;
+ double totalDays = used.TotalDays; //相差总天数
+ if (type == "年")
+ {
+ return Convert.ToInt32(year);
+ }
+ else
+ {
+ return Convert.ToInt32(month);
+ }
+ }
+ catch (Exception)
+ {
+ return 0;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/DongYingAPI/obj/Debug/DongYingAPI.csproj.CoreCompileInputs.cache b/DongYingAPI/obj/Debug/DongYingAPI.csproj.CoreCompileInputs.cache
index ae7b09a..4da2ea6 100644
--- a/DongYingAPI/obj/Debug/DongYingAPI.csproj.CoreCompileInputs.cache
+++ b/DongYingAPI/obj/Debug/DongYingAPI.csproj.CoreCompileInputs.cache
@@ -1 +1,5 @@
+<<<<<<< HEAD
468880470fff5b79419feffd9db81238259f3645
+=======
+6c9d14040a1da93afa29b893b8d2e1b7aae7c133
+>>>>>>> ed1a5636011cbbab43211edc340b78e5091aabc9
diff --git a/Security/bin/Debug/ServiceSecurity.application b/Security/bin/Debug/ServiceSecurity.application
index 1f40c85..3924311 100644
--- a/Security/bin/Debug/ServiceSecurity.application
+++ b/Security/bin/Debug/ServiceSecurity.application
@@ -14,7 +14,11 @@
+<<<<<<< HEAD
DFDrtnOeo9dpim2EB6ODebG9pNDAOWi8cJsCQmPQWpo=
+=======
+ 5bGkkmasvGwv0JCWHDW7zc72Mkr/5VqC8X+hEudh6w0=
+>>>>>>> ed1a5636011cbbab43211edc340b78e5091aabc9
diff --git a/Security/bin/Debug/ServiceSecurity.exe b/Security/bin/Debug/ServiceSecurity.exe
index 1f07314..6b06382 100644
Binary files a/Security/bin/Debug/ServiceSecurity.exe and b/Security/bin/Debug/ServiceSecurity.exe differ
diff --git a/Security/bin/Debug/ServiceSecurity.exe.manifest b/Security/bin/Debug/ServiceSecurity.exe.manifest
index 3b60276..936fbec 100644
--- a/Security/bin/Debug/ServiceSecurity.exe.manifest
+++ b/Security/bin/Debug/ServiceSecurity.exe.manifest
@@ -42,14 +42,22 @@
+<<<<<<< HEAD
+=======
+
+>>>>>>> ed1a5636011cbbab43211edc340b78e5091aabc9
+<<<<<<< HEAD
aWndXXAkdQBx2rtrRCdbWDqmcwtd1zO16Sk2hz+kv6w=
+=======
+ wXbJaoaVkZ4nWsDBuqFZJDHFJELkSuDr//lug4KQing=
+>>>>>>> ed1a5636011cbbab43211edc340b78e5091aabc9
@@ -145,7 +153,7 @@
- b7bJqDqIliuUbju1w2YkDRMyG9ErRnhvTZORdOTarU8=
+ NlUxB64kpcpWp/F6qJjJfIknsIZvtNiB+8LS/k8lx1c=
diff --git a/Security/bin/Debug/ServiceSecurity.pdb b/Security/bin/Debug/ServiceSecurity.pdb
index f6da23a..e8a93de 100644
Binary files a/Security/bin/Debug/ServiceSecurity.pdb and b/Security/bin/Debug/ServiceSecurity.pdb differ
diff --git a/Security/bin/Debug/app.publish/ServiceSecurity.exe b/Security/bin/Debug/app.publish/ServiceSecurity.exe
index 65bf737..2efd66f 100644
Binary files a/Security/bin/Debug/app.publish/ServiceSecurity.exe and b/Security/bin/Debug/app.publish/ServiceSecurity.exe differ
diff --git a/Security/obj/Debug/Security.csproj.CoreCompileInputs.cache b/Security/obj/Debug/Security.csproj.CoreCompileInputs.cache
index 9610b55..c69f0c7 100644
--- a/Security/obj/Debug/Security.csproj.CoreCompileInputs.cache
+++ b/Security/obj/Debug/Security.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-9188912aea4f3bf964cf72ec7e5362953260c83a
+cc564066d33e4a8809c3c565190fcf15db34768f
diff --git a/Security/obj/Debug/Security.csproj.FileListAbsolute.txt b/Security/obj/Debug/Security.csproj.FileListAbsolute.txt
index f27a567..fbc76c3 100644
--- a/Security/obj/Debug/Security.csproj.FileListAbsolute.txt
+++ b/Security/obj/Debug/Security.csproj.FileListAbsolute.txt
@@ -52,3 +52,30 @@ E:\林谷项目\东营两馆一宫\后端框架\DongYing\Security\obj\Debug\Serv
E:\林谷项目\东营两馆一宫\后端框架\DongYing\Security\obj\Debug\Security.csproj.CopyComplete
E:\林谷项目\东营两馆一宫\后端框架\DongYing\Security\obj\Debug\ServiceSecurity.exe
E:\林谷项目\东营两馆一宫\后端框架\DongYing\Security\obj\Debug\ServiceSecurity.pdb
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\ServiceSecurity.exe.config
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\ServiceSecurity.exe.manifest
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\ServiceSecurity.application
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\ServiceSecurity.exe
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\ServiceSecurity.pdb
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\DataServer.dll
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\HslCommunication.dll
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\LitJSON.dll
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\log4net.dll
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\Newtonsoft.Json.dll
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\MySql.Data.dll
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\Maticsoft.DBUtility.dll
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\Maticsoft.Common.dll
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\DataServer.pdb
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\HslCommunication.xml
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\log4net.xml
+F:\项目\东营两馆一宫项目\DongYing\Security\bin\Debug\Newtonsoft.Json.xml
+F:\项目\东营两馆一宫项目\DongYing\Security\obj\Debug\Security.csproj.AssemblyReference.cache
+F:\项目\东营两馆一宫项目\DongYing\Security\obj\Debug\Security.csproj.SuggestedBindingRedirects.cache
+F:\项目\东营两馆一宫项目\DongYing\Security\obj\Debug\Security.ProjectInstaller.resources
+F:\项目\东营两馆一宫项目\DongYing\Security\obj\Debug\Security.csproj.GenerateResource.cache
+F:\项目\东营两馆一宫项目\DongYing\Security\obj\Debug\Security.csproj.CoreCompileInputs.cache
+F:\项目\东营两馆一宫项目\DongYing\Security\obj\Debug\ServiceSecurity.exe.manifest
+F:\项目\东营两馆一宫项目\DongYing\Security\obj\Debug\ServiceSecurity.application
+F:\项目\东营两馆一宫项目\DongYing\Security\obj\Debug\Security.csproj.CopyComplete
+F:\项目\东营两馆一宫项目\DongYing\Security\obj\Debug\ServiceSecurity.exe
+F:\项目\东营两馆一宫项目\DongYing\Security\obj\Debug\ServiceSecurity.pdb
diff --git a/Security/obj/Debug/ServiceSecurity.application b/Security/obj/Debug/ServiceSecurity.application
index 1f40c85..3924311 100644
--- a/Security/obj/Debug/ServiceSecurity.application
+++ b/Security/obj/Debug/ServiceSecurity.application
@@ -14,7 +14,11 @@
+<<<<<<< HEAD
DFDrtnOeo9dpim2EB6ODebG9pNDAOWi8cJsCQmPQWpo=
+=======
+ 5bGkkmasvGwv0JCWHDW7zc72Mkr/5VqC8X+hEudh6w0=
+>>>>>>> ed1a5636011cbbab43211edc340b78e5091aabc9
diff --git a/Security/obj/Debug/ServiceSecurity.exe b/Security/obj/Debug/ServiceSecurity.exe
index 1f07314..6b06382 100644
Binary files a/Security/obj/Debug/ServiceSecurity.exe and b/Security/obj/Debug/ServiceSecurity.exe differ
diff --git a/Security/obj/Debug/ServiceSecurity.exe.manifest b/Security/obj/Debug/ServiceSecurity.exe.manifest
index 3b60276..936fbec 100644
--- a/Security/obj/Debug/ServiceSecurity.exe.manifest
+++ b/Security/obj/Debug/ServiceSecurity.exe.manifest
@@ -42,14 +42,22 @@
+<<<<<<< HEAD
+=======
+
+>>>>>>> ed1a5636011cbbab43211edc340b78e5091aabc9
+<<<<<<< HEAD
aWndXXAkdQBx2rtrRCdbWDqmcwtd1zO16Sk2hz+kv6w=
+=======
+ wXbJaoaVkZ4nWsDBuqFZJDHFJELkSuDr//lug4KQing=
+>>>>>>> ed1a5636011cbbab43211edc340b78e5091aabc9
@@ -145,7 +153,7 @@
- b7bJqDqIliuUbju1w2YkDRMyG9ErRnhvTZORdOTarU8=
+ NlUxB64kpcpWp/F6qJjJfIknsIZvtNiB+8LS/k8lx1c=
diff --git a/Security/obj/Debug/ServiceSecurity.pdb b/Security/obj/Debug/ServiceSecurity.pdb
index f6da23a..e8a93de 100644
Binary files a/Security/obj/Debug/ServiceSecurity.pdb and b/Security/obj/Debug/ServiceSecurity.pdb differ