diff --git a/DataServer/BLL/electricity_data.cs b/DataServer/BLL/electricity_data.cs index edbf834..b4c3a65 100644 --- a/DataServer/BLL/electricity_data.cs +++ b/DataServer/BLL/electricity_data.cs @@ -21,14 +21,14 @@ using Maticsoft.Common; using DataServer.Model; namespace DataServer.BLL { - /// - /// electricity_data - /// - public partial class electricity_data - { - private readonly DataServer.DAL.electricity_data dal=new DataServer.DAL.electricity_data(); - public electricity_data() - {} + /// + /// electricity_data + /// + public partial class electricity_data + { + private readonly DataServer.DAL.electricity_data dal = new DataServer.DAL.electricity_data(); + public electricity_data() + { } #region BasicMethod /// /// 是否存在该记录 @@ -186,9 +186,9 @@ namespace DataServer.BLL /// /// 增加一条数据 /// - public bool AddDate(DataServer.Model.electricity_data model,string date) + public bool AddDate(DataServer.Model.electricity_data model, string date) { - return dal.AddDate(model,date); + return dal.AddDate(model, date); } /// @@ -204,11 +204,36 @@ namespace DataServer.BLL /// /// 获得数据列表 /// - public List GetModelListDate(string strWhere,string date) + public List GetModelListDate(string strWhere, string date) { - DataSet ds = dal.GetListDate(strWhere,date); + DataSet ds = dal.GetListDate(strWhere, date); return DataTableToList(ds.Tables[0]); } + + /// + /// 获取数据 + /// + /// 数据来源 + /// 条件 + /// 时间字段 + /// + public List GetList(string source, string strWhere, string timeField) + { + DataSet ds = dal.GetList(source, strWhere, timeField); + return DataTableToList(ds.Tables[0]); + } + + /// + /// 获取数据 + /// + /// 数据来源 + /// 条件 + /// 求和字段 + /// + public decimal GetSum(string source, string strWhere, string sum_name) + { + return dal.GetSum(source, strWhere, sum_name); + } #endregion ExtensionMethod } } diff --git a/DataServer/BLL/electricity_quantity.cs b/DataServer/BLL/electricity_quantity.cs new file mode 100644 index 0000000..a93cc13 --- /dev/null +++ b/DataServer/BLL/electricity_quantity.cs @@ -0,0 +1,179 @@ +/** 版本信息模板在安装目录下,可自行修改。 +* electricity_quantity.cs +* +* 功 能: N/A +* 类 名: electricity_quantity +* +* Ver 变更日期 负责人 变更内容 +* ─────────────────────────────────── +* V0.01 2024/1/9 15:59:58 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 +{ + /// + /// electricity_quantity + /// + public partial class electricity_quantity + { + private readonly DataServer.DAL.electricity_quantity dal=new DataServer.DAL.electricity_quantity(); + public electricity_quantity() + {} + #region BasicMethod + /// + /// 是否存在该记录 + /// + public bool Exists(string DataId) + { + return dal.Exists(DataId); + } + + /// + /// 增加一条数据 + /// + public bool Add(DataServer.Model.electricity_quantity model) + { + return dal.Add(model); + } + + /// + /// 更新一条数据 + /// + public bool Update(DataServer.Model.electricity_quantity model) + { + return dal.Update(model); + } + + /// + /// 删除一条数据 + /// + public bool Delete(string DataId) + { + + return dal.Delete(DataId); + } + /// + /// 删除一条数据 + /// + public bool DeleteList(string DataIdlist ) + { + return dal.DeleteList(DataIdlist ); + } + + /// + /// 得到一个对象实体 + /// + public DataServer.Model.electricity_quantity GetModel(string DataId) + { + + return dal.GetModel(DataId); + } + + /// + /// 得到一个对象实体,从缓存中 + /// + public DataServer.Model.electricity_quantity GetModelByCache(string DataId) + { + + string CacheKey = "electricity_quantityModel-" + DataId; + object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey); + if (objModel == null) + { + try + { + objModel = dal.GetModel(DataId); + 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.electricity_quantity)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.electricity_quantity 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/electricity_data.cs b/DataServer/DAL/electricity_data.cs index 3a6adc9..d3f6c3c 100644 --- a/DataServer/DAL/electricity_data.cs +++ b/DataServer/DAL/electricity_data.cs @@ -21,13 +21,13 @@ using MySql.Data.MySqlClient; using Maticsoft.DBUtility;//Please add references namespace DataServer.DAL { - /// - /// 数据访问类:electricity_data - /// - public partial class electricity_data - { - public electricity_data() - {} + /// + /// 数据访问类:electricity_data + /// + public partial class electricity_data + { + public electricity_data() + { } #region BasicMethod /// @@ -475,13 +475,13 @@ namespace DataServer.DAL DbHelperMySQL.ExecuteSql(strSql.ToString()); } - /// - ///添加数据 - /// - /// - /// - /// - public bool AddDate(DataServer.Model.electricity_data model,string date) + /// + ///添加数据 + /// + /// + /// + /// + public bool AddDate(DataServer.Model.electricity_data model, string date) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into electricity_data_" + date + "("); @@ -542,17 +542,65 @@ namespace DataServer.DAL /// /// 获得数据列表 /// - public DataSet GetListDate(string strWhere,string date) + public DataSet GetListDate(string strWhere, string date) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 "); - strSql.Append(" FROM electricity_data_"+date); + strSql.Append(" FROM electricity_data_" + date); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } return DbHelperMySQL.Query(strSql.ToString()); } + + /// + /// 获取数据 + /// + /// 数据来源 + /// 条件 + /// 时间字段 + /// + public DataSet GetList(string source, string strWhere, string timeField) + { + StringBuilder strSql = new StringBuilder(); + strSql.Append("SELECT * FROM (" + source + ") as T "); + if (strWhere.Trim() != "") + { + strSql.Append(" where " + strWhere); + } + if (!string.IsNullOrEmpty(timeField)) + { + strSql.Append("ORDER BY " + timeField + " "); + } + return DbHelperMySQL.Query(strSql.ToString(), 300); + } + + /// + /// 获取数据 + /// + /// 数据来源 + /// 条件 + /// 求和字段 + /// + public decimal GetSum(string source, string strWhere, string sum_name) + { + StringBuilder strSql = new StringBuilder(); + strSql.Append("SELECT sum(" + sum_name + ") FROM (" + source + ") as T "); + if (strWhere.Trim() != "") + { + strSql.Append(" where " + strWhere); + } + object obj = DbHelperSQL.GetSingle(strSql.ToString(), 300); + if (obj == null) + { + return 0; + } + else + { + return Convert.ToDecimal(obj); + } + } #endregion ExtensionMethod } } diff --git a/DataServer/DAL/electricity_quantity.cs b/DataServer/DAL/electricity_quantity.cs new file mode 100644 index 0000000..79afd00 --- /dev/null +++ b/DataServer/DAL/electricity_quantity.cs @@ -0,0 +1,373 @@ +/** 版本信息模板在安装目录下,可自行修改。 +* electricity_quantity.cs +* +* 功 能: N/A +* 类 名: electricity_quantity +* +* Ver 变更日期 负责人 变更内容 +* ─────────────────────────────────── +* V0.01 2024/1/9 15:59:58 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 +{ + /// + /// 数据访问类:electricity_quantity + /// + public partial class electricity_quantity + { + public electricity_quantity() + {} + #region BasicMethod + + /// + /// 是否存在该记录 + /// + public bool Exists(string DataId) + { + StringBuilder strSql=new StringBuilder(); + strSql.Append("select count(1) from electricity_quantity"); + strSql.Append(" where DataId=@DataId "); + MySqlParameter[] parameters = { + new MySqlParameter("@DataId", MySqlDbType.VarChar,32) }; + parameters[0].Value = DataId; + + return DbHelperMySQL.Exists(strSql.ToString(),parameters); + } + + + /// + /// 增加一条数据 + /// + public bool Add(DataServer.Model.electricity_quantity model) + { + StringBuilder strSql=new StringBuilder(); + strSql.Append("insert into electricity_quantity("); + strSql.Append("DataId,PointedMeasure,PeakMeasure,FlatMeasure,ValleyMeasure,DeepValleyMeasure,CreateTime,Remark1,Remark2,Remark3,Remark4,Remark5)"); + strSql.Append(" values ("); + strSql.Append("@DataId,@PointedMeasure,@PeakMeasure,@FlatMeasure,@ValleyMeasure,@DeepValleyMeasure,@CreateTime,@Remark1,@Remark2,@Remark3,@Remark4,@Remark5)"); + MySqlParameter[] parameters = { + new MySqlParameter("@DataId", MySqlDbType.VarChar,32), + new MySqlParameter("@PointedMeasure", MySqlDbType.Decimal,10), + new MySqlParameter("@PeakMeasure", MySqlDbType.Decimal,10), + new MySqlParameter("@FlatMeasure", MySqlDbType.Decimal,10), + new MySqlParameter("@ValleyMeasure", MySqlDbType.Decimal,10), + new MySqlParameter("@DeepValleyMeasure", MySqlDbType.Decimal,10), + new MySqlParameter("@CreateTime", MySqlDbType.DateTime), + 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.DataId; + parameters[1].Value = model.PointedMeasure; + parameters[2].Value = model.PeakMeasure; + parameters[3].Value = model.FlatMeasure; + parameters[4].Value = model.ValleyMeasure; + parameters[5].Value = model.DeepValleyMeasure; + parameters[6].Value = model.CreateTime; + parameters[7].Value = model.Remark1; + parameters[8].Value = model.Remark2; + parameters[9].Value = model.Remark3; + parameters[10].Value = model.Remark4; + parameters[11].Value = model.Remark5; + + int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters); + if (rows > 0) + { + return true; + } + else + { + return false; + } + } + /// + /// 更新一条数据 + /// + public bool Update(DataServer.Model.electricity_quantity model) + { + StringBuilder strSql=new StringBuilder(); + strSql.Append("update electricity_quantity set "); + strSql.Append("PointedMeasure=@PointedMeasure,"); + strSql.Append("PeakMeasure=@PeakMeasure,"); + strSql.Append("FlatMeasure=@FlatMeasure,"); + strSql.Append("ValleyMeasure=@ValleyMeasure,"); + strSql.Append("DeepValleyMeasure=@DeepValleyMeasure,"); + strSql.Append("CreateTime=@CreateTime,"); + strSql.Append("Remark1=@Remark1,"); + strSql.Append("Remark2=@Remark2,"); + strSql.Append("Remark3=@Remark3,"); + strSql.Append("Remark4=@Remark4,"); + strSql.Append("Remark5=@Remark5"); + strSql.Append(" where DataId=@DataId "); + MySqlParameter[] parameters = { + new MySqlParameter("@PointedMeasure", MySqlDbType.Decimal,10), + new MySqlParameter("@PeakMeasure", MySqlDbType.Decimal,10), + new MySqlParameter("@FlatMeasure", MySqlDbType.Decimal,10), + new MySqlParameter("@ValleyMeasure", MySqlDbType.Decimal,10), + new MySqlParameter("@DeepValleyMeasure", MySqlDbType.Decimal,10), + new MySqlParameter("@CreateTime", MySqlDbType.DateTime), + 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("@DataId", MySqlDbType.VarChar,32)}; + parameters[0].Value = model.PointedMeasure; + parameters[1].Value = model.PeakMeasure; + parameters[2].Value = model.FlatMeasure; + parameters[3].Value = model.ValleyMeasure; + parameters[4].Value = model.DeepValleyMeasure; + parameters[5].Value = model.CreateTime; + parameters[6].Value = model.Remark1; + parameters[7].Value = model.Remark2; + parameters[8].Value = model.Remark3; + parameters[9].Value = model.Remark4; + parameters[10].Value = model.Remark5; + parameters[11].Value = model.DataId; + + int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters); + if (rows > 0) + { + return true; + } + else + { + return false; + } + } + + /// + /// 删除一条数据 + /// + public bool Delete(string DataId) + { + + StringBuilder strSql=new StringBuilder(); + strSql.Append("delete from electricity_quantity "); + strSql.Append(" where DataId=@DataId "); + MySqlParameter[] parameters = { + new MySqlParameter("@DataId", MySqlDbType.VarChar,32) }; + parameters[0].Value = DataId; + + int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters); + if (rows > 0) + { + return true; + } + else + { + return false; + } + } + /// + /// 批量删除数据 + /// + public bool DeleteList(string DataIdlist ) + { + StringBuilder strSql=new StringBuilder(); + strSql.Append("delete from electricity_quantity "); + strSql.Append(" where DataId in ("+DataIdlist + ") "); + int rows=DbHelperMySQL.ExecuteSql(strSql.ToString()); + if (rows > 0) + { + return true; + } + else + { + return false; + } + } + + + /// + /// 得到一个对象实体 + /// + public DataServer.Model.electricity_quantity GetModel(string DataId) + { + + StringBuilder strSql=new StringBuilder(); + strSql.Append("select DataId,PointedMeasure,PeakMeasure,FlatMeasure,ValleyMeasure,DeepValleyMeasure,CreateTime,Remark1,Remark2,Remark3,Remark4,Remark5 from electricity_quantity "); + strSql.Append(" where DataId=@DataId "); + MySqlParameter[] parameters = { + new MySqlParameter("@DataId", MySqlDbType.VarChar,32) }; + parameters[0].Value = DataId; + + DataServer.Model.electricity_quantity model=new DataServer.Model.electricity_quantity(); + 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.electricity_quantity DataRowToModel(DataRow row) + { + DataServer.Model.electricity_quantity model=new DataServer.Model.electricity_quantity(); + if (row != null) + { + if(row["DataId"]!=null) + { + model.DataId=row["DataId"].ToString(); + } + if(row["PointedMeasure"]!=null && row["PointedMeasure"].ToString()!="") + { + model.PointedMeasure=decimal.Parse(row["PointedMeasure"].ToString()); + } + if(row["PeakMeasure"]!=null && row["PeakMeasure"].ToString()!="") + { + model.PeakMeasure=decimal.Parse(row["PeakMeasure"].ToString()); + } + if(row["FlatMeasure"]!=null && row["FlatMeasure"].ToString()!="") + { + model.FlatMeasure=decimal.Parse(row["FlatMeasure"].ToString()); + } + if(row["ValleyMeasure"]!=null && row["ValleyMeasure"].ToString()!="") + { + model.ValleyMeasure=decimal.Parse(row["ValleyMeasure"].ToString()); + } + if(row["DeepValleyMeasure"]!=null && row["DeepValleyMeasure"].ToString()!="") + { + model.DeepValleyMeasure=decimal.Parse(row["DeepValleyMeasure"].ToString()); + } + if(row["CreateTime"]!=null && row["CreateTime"].ToString()!="") + { + model.CreateTime=DateTime.Parse(row["CreateTime"].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 DataId,PointedMeasure,PeakMeasure,FlatMeasure,ValleyMeasure,DeepValleyMeasure,CreateTime,Remark1,Remark2,Remark3,Remark4,Remark5 "); + strSql.Append(" FROM electricity_quantity "); + 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 electricity_quantity "); + 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.DataId desc"); + } + strSql.Append(")AS Row, T.* from electricity_quantity 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 = "electricity_quantity"; + parameters[1].Value = "DataId"; + 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 f2f2a85..3a4ee1a 100644 --- a/DataServer/DataServer.csproj +++ b/DataServer/DataServer.csproj @@ -54,6 +54,7 @@ + @@ -85,6 +86,7 @@ + @@ -93,6 +95,7 @@ + @@ -100,6 +103,7 @@ + diff --git a/DataServer/Model/electricity_quantity.cs b/DataServer/Model/electricity_quantity.cs new file mode 100644 index 0000000..12d6d31 --- /dev/null +++ b/DataServer/Model/electricity_quantity.cs @@ -0,0 +1,141 @@ +/** 版本信息模板在安装目录下,可自行修改。 +* electricity_quantity.cs +* +* 功 能: N/A +* 类 名: electricity_quantity +* +* Ver 变更日期 负责人 变更内容 +* ─────────────────────────────────── +* V0.01 2024/1/9 15:59:58 N/A 初版 +* +* Copyright (c) 2012 Maticsoft Corporation. All rights reserved. +*┌──────────────────────────────────┐ +*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │ +*│ 版权所有:动软卓越(北京)科技有限公司              │ +*└──────────────────────────────────┘ +*/ +using System; +namespace DataServer.Model +{ + /// + /// electricity_quantity:实体类(属性说明自动提取数据库字段的描述信息) + /// + [Serializable] + public partial class electricity_quantity + { + public electricity_quantity() + {} + #region Model + private string _dataid; + private decimal? _pointedmeasure; + private decimal? _peakmeasure; + private decimal? _flatmeasure; + private decimal? _valleymeasure; + private decimal? _deepvalleymeasure; + private DateTime? _createtime; + private string _remark1; + private string _remark2; + private string _remark3; + private string _remark4; + private string _remark5; + /// + /// + /// + public string DataId + { + set{ _dataid=value;} + get{return _dataid;} + } + /// + /// + /// + public decimal? PointedMeasure + { + set{ _pointedmeasure=value;} + get{return _pointedmeasure;} + } + /// + /// + /// + public decimal? PeakMeasure + { + set{ _peakmeasure=value;} + get{return _peakmeasure;} + } + /// + /// + /// + public decimal? FlatMeasure + { + set{ _flatmeasure=value;} + get{return _flatmeasure;} + } + /// + /// + /// + public decimal? ValleyMeasure + { + set{ _valleymeasure=value;} + get{return _valleymeasure;} + } + /// + /// + /// + public decimal? DeepValleyMeasure + { + set{ _deepvalleymeasure=value;} + get{return _deepvalleymeasure;} + } + /// + /// + /// + public DateTime? CreateTime + { + set{ _createtime=value;} + get{return _createtime;} + } + /// + /// + /// + 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_electricity_price_response.cs b/DataServer/api/EnergyEfficiency/get_electricity_price_response.cs index 9a6c5c8..617c665 100644 --- a/DataServer/api/EnergyEfficiency/get_electricity_price_response.cs +++ b/DataServer/api/EnergyEfficiency/get_electricity_price_response.cs @@ -42,6 +42,6 @@ namespace DataServer.api.EnergyEfficiency /// /// 月份 /// - public int Month { get; set; } + public string Month { get; set; } } } diff --git a/DataServer/api/EnergyEfficiency/get_energy_benchmarking_response.cs b/DataServer/api/EnergyEfficiency/get_energy_benchmarking_response.cs index b48cba7..49b8e51 100644 --- a/DataServer/api/EnergyEfficiency/get_energy_benchmarking_response.cs +++ b/DataServer/api/EnergyEfficiency/get_energy_benchmarking_response.cs @@ -11,5 +11,14 @@ namespace DataServer.api.EnergyEfficiency /// public class get_energy_benchmarking_response { + /// + /// 返回码 + /// + public int code { get; set; } + + /// + /// 返回说明 + /// + public string msg { get; set; } } } diff --git a/DataServer/api/EnergyEfficiency/get_energy_consumption_response.cs b/DataServer/api/EnergyEfficiency/get_energy_consumption_response.cs new file mode 100644 index 0000000..3c94bfb --- /dev/null +++ b/DataServer/api/EnergyEfficiency/get_energy_consumption_response.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataServer.api.EnergyEfficiency +{ + /// + /// 获取各回路(设备)能耗概况接口响应实体 + /// + public class get_energy_consumption_response + { + /// + /// 返回码 + /// + public int code { get; set; } + + /// + /// 返回说明 + /// + public string msg { get; set; } + + public List data { get; set; } + } + + public class energy_consumption + { + /// + /// 设备名称 + /// + public string DeviceName { get; set; } + + /// + /// 运行功率 + /// + public decimal OperatingPower { get; set; } + } +} diff --git a/DataServer/api/EnergyEfficiency/get_energy_flow_response.cs b/DataServer/api/EnergyEfficiency/get_energy_flow_response.cs index 2dcad71..a679cd9 100644 --- a/DataServer/api/EnergyEfficiency/get_energy_flow_response.cs +++ b/DataServer/api/EnergyEfficiency/get_energy_flow_response.cs @@ -11,5 +11,41 @@ namespace DataServer.api.EnergyEfficiency /// public class get_energy_flow_response { + /// + /// 返回码 + /// + public int code { get; set; } + + /// + /// 返回说明 + /// + public string msg { get; set; } + + public energy_flow data { get; set; } + } + + public class energy_flow + { + public string Name { get; set; } + + public decimal Value { get; set; } + + public List data { get; set; } + } + + public class secondary_energy_flow + { + public string Name { get; set; } + + public decimal Value { get; set; } + + public List data { get; set; } + } + + public class three_level_energy_flow + { + public string Name { get; set; } + + public decimal Value { get; set; } } } diff --git a/DataServer/api/EnergyEfficiency/get_multi_rate_response.cs b/DataServer/api/EnergyEfficiency/get_multi_rate_response.cs index 4772a2f..aaf3286 100644 --- a/DataServer/api/EnergyEfficiency/get_multi_rate_response.cs +++ b/DataServer/api/EnergyEfficiency/get_multi_rate_response.cs @@ -11,5 +11,49 @@ namespace DataServer.api.EnergyEfficiency /// public class get_multi_rate_response { + /// + /// 返回码 + /// + public int code { get; set; } + + /// + /// 返回说明 + /// + public string msg { get; set; } + + public List data { get; set; } + } + + public class multi_rate + { + /// + /// 时间 + /// + public string Time { get; set; } + + /// + /// 尖用电量 + /// + public decimal PointedMeasure { get; set; } + + /// + /// 峰用电量 + /// + public decimal PeakMeasure { get; set; } + + /// + /// 平用电量 + /// + public decimal FlatMeasure { get; set; } + + /// + /// 谷用电量 + /// + public decimal ValleyMeasure { get; set; } + + /// + /// 深谷用电量 + /// + public decimal DeepValleyMeasure { get; set; } } } diff --git a/DataServer/bin/Debug/DataServer.pdb b/DataServer/bin/Debug/DataServer.pdb index 007168e..c2503f8 100644 Binary files a/DataServer/bin/Debug/DataServer.pdb and b/DataServer/bin/Debug/DataServer.pdb differ diff --git a/DataServer/obj/Debug/DataServer.csproj.CoreCompileInputs.cache b/DataServer/obj/Debug/DataServer.csproj.CoreCompileInputs.cache index 7e6f407..a89074b 100644 --- a/DataServer/obj/Debug/DataServer.csproj.CoreCompileInputs.cache +++ b/DataServer/obj/Debug/DataServer.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -8863b3d404b4c933530616b840a3e61667fd3b30 +752a6e1b70ab5d71df5d0cbf0bbd0a7b1da79829 diff --git a/DataServer/obj/Debug/DataServer.csproj.FileListAbsolute.txt b/DataServer/obj/Debug/DataServer.csproj.FileListAbsolute.txt index 7c0a2d1..a208938 100644 --- a/DataServer/obj/Debug/DataServer.csproj.FileListAbsolute.txt +++ b/DataServer/obj/Debug/DataServer.csproj.FileListAbsolute.txt @@ -18,3 +18,13 @@ E:\林谷项目\东营两馆一宫\后端框架\DongYing\DataServer\obj\Debug\Da E:\林谷项目\东营两馆一宫\后端框架\DongYing\DataServer\obj\Debug\DataServer.csproj.CopyComplete E:\林谷项目\东营两馆一宫\后端框架\DongYing\DataServer\obj\Debug\DataServer.dll E:\林谷项目\东营两馆一宫\后端框架\DongYing\DataServer\obj\Debug\DataServer.pdb +F:\项目\东营两馆一宫项目\DongYing\DataServer\bin\Debug\DataServer.dll +F:\项目\东营两馆一宫项目\DongYing\DataServer\bin\Debug\DataServer.pdb +F:\项目\东营两馆一宫项目\DongYing\DataServer\bin\Debug\Maticsoft.Common.dll +F:\项目\东营两馆一宫项目\DongYing\DataServer\bin\Debug\Maticsoft.DBUtility.dll +F:\项目\东营两馆一宫项目\DongYing\DataServer\bin\Debug\MySql.Data.dll +F:\项目\东营两馆一宫项目\DongYing\DataServer\obj\Debug\DataServer.csproj.AssemblyReference.cache +F:\项目\东营两馆一宫项目\DongYing\DataServer\obj\Debug\DataServer.csproj.CoreCompileInputs.cache +F:\项目\东营两馆一宫项目\DongYing\DataServer\obj\Debug\DataServer.csproj.CopyComplete +F:\项目\东营两馆一宫项目\DongYing\DataServer\obj\Debug\DataServer.dll +F:\项目\东营两馆一宫项目\DongYing\DataServer\obj\Debug\DataServer.pdb diff --git a/DataServer/obj/Debug/DataServer.dll b/DataServer/obj/Debug/DataServer.dll index 1170a49..6466d25 100644 Binary files a/DataServer/obj/Debug/DataServer.dll and b/DataServer/obj/Debug/DataServer.dll differ diff --git a/DataServer/obj/Debug/DataServer.pdb b/DataServer/obj/Debug/DataServer.pdb index 007168e..c2503f8 100644 Binary files a/DataServer/obj/Debug/DataServer.pdb and b/DataServer/obj/Debug/DataServer.pdb differ diff --git a/DongYingAPI/Controllers/api/EnergyEfficiency/GetElectricityPriceController.cs b/DongYingAPI/Controllers/api/EnergyEfficiency/GetElectricityPriceController.cs index 9ed3a3c..eab19c3 100644 --- a/DongYingAPI/Controllers/api/EnergyEfficiency/GetElectricityPriceController.cs +++ b/DongYingAPI/Controllers/api/EnergyEfficiency/GetElectricityPriceController.cs @@ -39,8 +39,8 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency { var model = new electricity_price(); var new_month = start_month.AddMonths(i); - model.Month = new_month.Month; - var price_model = list.Where(a => a.Month == model.Month).FirstOrDefault(); + model.Month = new_month.Month.ToString() + "月"; + var price_model = list.Where(a => a.Month == new_month.Month).FirstOrDefault(); if (price_model != null) { model.UnitPrice = price_model.UnitPrice.Value; diff --git a/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyBenchmarkingController.cs b/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyBenchmarkingController.cs index b70fd5e..80fe4eb 100644 --- a/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyBenchmarkingController.cs +++ b/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyBenchmarkingController.cs @@ -1,8 +1,11 @@ -using System; +using DataServer.api.EnergyEfficiency; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; +using System.Text; using System.Web.Http; namespace DongYingAPI.Controllers.api.EnergyEfficiency @@ -12,5 +15,30 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency /// public class GetEnergyBenchmarkingController : ApiController { + DataServer.BLL.device_data bll = new DataServer.BLL.device_data(); + + /// + /// 获取能效对标接口 + /// + /// + public HttpResponseMessage Get() + { + var res = new get_unit_consumption_response(); + 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"; + + //根据事件查询两条数据,然后值相减为用水量 + } + catch (Exception ex) + { + res.code = 500; + res.msg = "失败," + ex.Message; + } + HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(res), Encoding.GetEncoding("UTF-8"), "application/json") }; + return result; + } } } diff --git a/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyConsumptionController.cs b/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyConsumptionController.cs new file mode 100644 index 0000000..1ca27a1 --- /dev/null +++ b/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyConsumptionController.cs @@ -0,0 +1,135 @@ +using DataServer.api.EnergyEfficiency; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data.Services; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Web.Http; + +namespace DongYingAPI.Controllers.api.EnergyEfficiency +{ + public class GetEnergyConsumptionController : ApiController + { + DataServer.BLL.device_info device_bll = new DataServer.BLL.device_info(); + + DataServer.BLL.electricity_data bll = new DataServer.BLL.electricity_data(); + + /// + /// 获取各回路(设备)能耗概况接口 + /// + /// 类型 年、月、日 + /// + public HttpResponseMessage Get(string type) + { + var res = new get_energy_consumption_response(); + try + { + var now = DateTime.Now; + var device_list = device_bll.GetModelList(""); + var list = new List(); + //判断表是否存在,不存在就创建 + var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString(); + if (type == "年") + { + var start_date = DateTime.Parse(now.ToString("yyyy") + "-01-01 00:00:00"); + var time_count = GetUsedMonth1("月", start_date, now); + var source = ""; + for (int i = 0; i <= time_count; i++) + { + var time = start_date.AddMonths(i).ToString("yyyyMM"); + if (bll.IsExistsTable(date_base, "electricity_data_" + time)) + { + 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); + } + 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 == "月") + { + var start_date = DateTime.Parse(now.ToString("yyyy-MM") + "-01 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 + "' ", ""); + } + else if (type == "日") + { + 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 + "' ", ""); + } + + 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; + } + catch (Exception ex) + { + res.code = 500; + res.msg = "失败," + ex.Message; + } + 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/GetEnergyFlowController.cs b/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyFlowController.cs index 4c706ec..1027051 100644 --- a/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyFlowController.cs +++ b/DongYingAPI/Controllers/api/EnergyEfficiency/GetEnergyFlowController.cs @@ -1,9 +1,14 @@ -using System; +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; +using System.Text; using System.Web.Http; +using System.Xml.Linq; namespace DongYingAPI.Controllers.api.EnergyEfficiency { @@ -12,5 +17,139 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency /// public class GetEnergyFlowController : ApiController { + DataServer.BLL.electricity_data bll = new DataServer.BLL.electricity_data(); + + DataServer.BLL.device_info device_bll = new DataServer.BLL.device_info(); + + DataServer.BLL.gas_data gas_bll = new DataServer.BLL.gas_data(); + + /// + /// 获取设备运行情况接口 + /// + /// + public HttpResponseMessage Get() + { + var res = new get_energy_flow_response(); + try + { + var now = DateTime.Now; + //空调 + decimal air_conditioning = 0; + //照明 + decimal lighting = 0; + //电梯 + decimal lift = 0; + //其他 + decimal other = 0; + //天然气 + decimal natural_gas = 0; + //判断表是否存在,不存在就创建 + 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 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; + } + } + } + + res.code = 200; + res.msg = "成功"; + res.data = new energy_flow() + { + Name = "原始值折标煤", + Value = (air_conditioning + lighting + lift + other + natural_gas), + data = new List() { + new secondary_energy_flow() { + Name = "天然气", + Value = natural_gas, + data=new List(){ + new three_level_energy_flow() + { + Name="食堂", + Value=natural_gas + } + } + }, + new secondary_energy_flow() { + Name = "电", + Value = (air_conditioning + lighting + lift + other), + data = new List() { + new three_level_energy_flow() { + Name="空调", + Value=air_conditioning + },new three_level_energy_flow() + { + Name="照明", + Value=lighting + },new three_level_energy_flow() + { + Name="电梯", + Value=lift + },new three_level_energy_flow() + { + Name="其他", + Value=other + } + } + } + } + }; + } + catch (Exception ex) + { + res.code = 500; + res.msg = "失败," + ex.Message; + } + HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(res), Encoding.GetEncoding("UTF-8"), "application/json") }; + return result; + } } } diff --git a/DongYingAPI/Controllers/api/EnergyEfficiency/GetMultiRateController.cs b/DongYingAPI/Controllers/api/EnergyEfficiency/GetMultiRateController.cs index 49ec700..9839d89 100644 --- a/DongYingAPI/Controllers/api/EnergyEfficiency/GetMultiRateController.cs +++ b/DongYingAPI/Controllers/api/EnergyEfficiency/GetMultiRateController.cs @@ -1,8 +1,12 @@ -using System; +using DataServer.api.EnergyEfficiency; +using Newtonsoft.Json; +using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Net; using System.Net.Http; +using System.Text; using System.Web.Http; namespace DongYingAPI.Controllers.api.EnergyEfficiency @@ -12,5 +16,94 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency /// public class GetMultiRateController : ApiController { + DataServer.BLL.electricity_quantity bll = new DataServer.BLL.electricity_quantity(); + + /// + /// 获取复费率接口 + /// + /// 类型 年、月、日 + /// + public HttpResponseMessage Get(string type) + { + var res = new get_multi_rate_response(); + try + { + res.code = 200; + res.msg = "成功"; + var list = new List(); + var now = DateTime.Now; + var data = new List(); + if (type == "年") + { + list = bll.GetModelList(""); + var month = now.Month;//当前月份 + var start_date = DateTime.Parse(now.ToString("yyyy") + "-01-01 00:00:00"); + for (int i = 0; i < month; i++) + { + var time = start_date.AddMonths(i); + var end = time.AddMonths(1); + var time_list = list.Where(a => a.CreateTime >= time && a.CreateTime < end).ToList(); + var model = new multi_rate(); + model.Time = time.Month.ToString() + "月"; + model.PointedMeasure = time_list.Sum(a => a.PointedMeasure).Value; + model.PeakMeasure = time_list.Sum(a => a.PeakMeasure).Value; + model.FlatMeasure = time_list.Sum(a => a.FlatMeasure).Value; + model.ValleyMeasure = time_list.Sum(a => a.ValleyMeasure).Value; + model.DeepValleyMeasure = time_list.Sum(a => a.DeepValleyMeasure).Value; + data.Add(model); + } + } + else if (type == "月") + { + var day = now;//当前天 + var start_date = DateTime.Parse(now.ToString("yyyy-MM") + "-01 00:00:00"); + list = bll.GetModelList(" CreateTime>='" + start_date + "' and CreateTime<='" + day + "' "); + var number = (day - start_date).TotalDays; + for (int i = 0; i < number; i++) + { + var time = start_date.AddDays(i); + var end = time.AddDays(1); + var time_list = list.Where(a => a.CreateTime >= time && a.CreateTime < end).ToList(); + var model = new multi_rate(); + model.Time = time.ToString("MM-dd"); + model.PointedMeasure = time_list.Sum(a => a.PointedMeasure).Value; + model.PeakMeasure = time_list.Sum(a => a.PeakMeasure).Value; + model.FlatMeasure = time_list.Sum(a => a.FlatMeasure).Value; + model.ValleyMeasure = time_list.Sum(a => a.ValleyMeasure).Value; + model.DeepValleyMeasure = time_list.Sum(a => a.DeepValleyMeasure).Value; + data.Add(model); + } + } + else if (type == "日") + { + var day = now;//当前天 + var start_date = DateTime.Parse(now.ToString("yyyy-MM-dd") + " 00:00:00"); + list = bll.GetModelList(" CreateTime>='" + start_date + "' and CreateTime<='" + day + "' "); + var number = (day - start_date).TotalHours; + for (int i = 0; i < number; i++) + { + var time = start_date.AddHours(i); + var end = time.AddHours(1); + var time_list = list.Where(a => a.CreateTime >= time && a.CreateTime < end).ToList(); + var model = new multi_rate(); + model.Time = time.ToString("HH:mm"); + model.PointedMeasure = time_list.Sum(a => a.PointedMeasure).Value; + model.PeakMeasure = time_list.Sum(a => a.PeakMeasure).Value; + model.FlatMeasure = time_list.Sum(a => a.FlatMeasure).Value; + model.ValleyMeasure = time_list.Sum(a => a.ValleyMeasure).Value; + model.DeepValleyMeasure = time_list.Sum(a => a.DeepValleyMeasure).Value; + data.Add(model); + } + } + res.data = data; + } + catch (Exception ex) + { + res.code = 500; + res.msg = "失败," + ex.Message; + } + HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(res), Encoding.GetEncoding("UTF-8"), "application/json") }; + return result; + } } } diff --git a/DongYingAPI/Controllers/api/EnergyEfficiency/GetUnitConsumptionController.cs b/DongYingAPI/Controllers/api/EnergyEfficiency/GetUnitConsumptionController.cs index 98c0eca..c77b982 100644 --- a/DongYingAPI/Controllers/api/EnergyEfficiency/GetUnitConsumptionController.cs +++ b/DongYingAPI/Controllers/api/EnergyEfficiency/GetUnitConsumptionController.cs @@ -11,7 +11,6 @@ using System.Web.Http; namespace DongYingAPI.Controllers.api.EnergyEfficiency { - [Route("api/[controller]")] public class GetUnitConsumptionController : ApiController { DataServer.BLL.device_data bll = new DataServer.BLL.device_data(); diff --git a/DongYingAPI/DongYingAPI.csproj b/DongYingAPI/DongYingAPI.csproj index f941b8b..34d0717 100644 --- a/DongYingAPI/DongYingAPI.csproj +++ b/DongYingAPI/DongYingAPI.csproj @@ -164,6 +164,7 @@ + diff --git a/DongYingAPI/Web.config b/DongYingAPI/Web.config index 03d0a2b..02ebcc4 100644 --- a/DongYingAPI/Web.config +++ b/DongYingAPI/Web.config @@ -4,65 +4,66 @@ https://go.microsoft.com/fwlink/?LinkId=301879 --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DongYingAPI/bin/DataServer.dll b/DongYingAPI/bin/DataServer.dll index 1170a49..6466d25 100644 Binary files a/DongYingAPI/bin/DataServer.dll and b/DongYingAPI/bin/DataServer.dll differ diff --git a/DongYingAPI/bin/DataServer.pdb b/DongYingAPI/bin/DataServer.pdb index 007168e..c2503f8 100644 Binary files a/DongYingAPI/bin/DataServer.pdb and b/DongYingAPI/bin/DataServer.pdb differ diff --git a/DongYingAPI/bin/DongYingAPI.dll b/DongYingAPI/bin/DongYingAPI.dll index 86b2821..a6e1687 100644 Binary files a/DongYingAPI/bin/DongYingAPI.dll and b/DongYingAPI/bin/DongYingAPI.dll differ diff --git a/DongYingAPI/bin/DongYingAPI.pdb b/DongYingAPI/bin/DongYingAPI.pdb index 6827a60..4f265bf 100644 Binary files a/DongYingAPI/bin/DongYingAPI.pdb and b/DongYingAPI/bin/DongYingAPI.pdb differ diff --git a/DongYingAPI/obj/Debug/DongYingAPI.csproj.AssemblyReference.cache b/DongYingAPI/obj/Debug/DongYingAPI.csproj.AssemblyReference.cache index f1233f3..c7929bf 100644 Binary files a/DongYingAPI/obj/Debug/DongYingAPI.csproj.AssemblyReference.cache and b/DongYingAPI/obj/Debug/DongYingAPI.csproj.AssemblyReference.cache differ diff --git a/DongYingAPI/obj/Debug/DongYingAPI.csproj.CoreCompileInputs.cache b/DongYingAPI/obj/Debug/DongYingAPI.csproj.CoreCompileInputs.cache index 9a2aba1..432b326 100644 --- a/DongYingAPI/obj/Debug/DongYingAPI.csproj.CoreCompileInputs.cache +++ b/DongYingAPI/obj/Debug/DongYingAPI.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -b5fe90906b5d33e0c9d21d797b9d7334cf5a65e3 +2daf8a227faca6c6caeee6c2b7aed66fd89baba1 diff --git a/DongYingAPI/obj/Debug/DongYingAPI.csproj.FileListAbsolute.txt b/DongYingAPI/obj/Debug/DongYingAPI.csproj.FileListAbsolute.txt index 76c3c08..cc9bcfe 100644 --- a/DongYingAPI/obj/Debug/DongYingAPI.csproj.FileListAbsolute.txt +++ b/DongYingAPI/obj/Debug/DongYingAPI.csproj.FileListAbsolute.txt @@ -198,3 +198,103 @@ E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI\obj\Debug\D E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI\obj\Debug\DongYingAPI.csproj.CopyComplete E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI\obj\Debug\DongYingAPI.dll E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI\obj\Debug\DongYingAPI.pdb +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\obj\Debug\DongYingAPI.csproj.AssemblyReference.cache +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\obj\Debug\DongYingAPI.csproj.CoreCompileInputs.cache +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\obj\Debug\DongYingAPI.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\obj\Debug\DongYingAPI.pdb +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\DongYingAPI.dll.config +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\DongYingAPI.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\DongYingAPI.pdb +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\csc.exe +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\csc.exe.config +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\csc.rsp +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\csi.exe +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\csi.exe.config +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\csi.rsp +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\Microsoft.Build.Tasks.CodeAnalysis.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\Microsoft.CodeAnalysis.CSharp.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\Microsoft.CodeAnalysis.CSharp.Scripting.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\Microsoft.CodeAnalysis.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\Microsoft.CodeAnalysis.Scripting.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\Microsoft.CodeAnalysis.VisualBasic.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\Microsoft.CSharp.Core.targets +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\Microsoft.DiaSymReader.Native.amd64.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\Microsoft.DiaSymReader.Native.x86.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\Microsoft.Managed.Core.targets +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\Microsoft.VisualBasic.Core.targets +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\Microsoft.Win32.Primitives.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.AppContext.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Collections.Immutable.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Console.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Diagnostics.DiagnosticSource.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Diagnostics.FileVersionInfo.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Diagnostics.StackTrace.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Globalization.Calendars.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.IO.Compression.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.IO.Compression.ZipFile.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.IO.FileSystem.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.IO.FileSystem.Primitives.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Net.Http.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Net.Sockets.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Reflection.Metadata.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Runtime.InteropServices.RuntimeInformation.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Security.Cryptography.Algorithms.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Security.Cryptography.Encoding.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Security.Cryptography.Primitives.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Security.Cryptography.X509Certificates.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Text.Encoding.CodePages.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Threading.Tasks.Extensions.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.ValueTuple.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Xml.ReaderWriter.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Xml.XmlDocument.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Xml.XPath.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\System.Xml.XPath.XDocument.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\vbc.exe +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\vbc.exe.config +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\vbc.rsp +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\VBCSCompiler.exe +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\roslyn\VBCSCompiler.exe.config +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\Antlr3.Runtime.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\DataServer.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\Microsoft.Web.Infrastructure.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\Newtonsoft.Json.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Net.Http.Formatting.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.Helpers.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.Http.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.Http.WebHost.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.Mvc.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.Optimization.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.Razor.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.WebPages.Deployment.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.WebPages.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.WebPages.Razor.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\WebGrease.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\MySql.Data.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\Maticsoft.DBUtility.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\Maticsoft.Common.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\DataServer.pdb +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\Newtonsoft.Json.xml +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Net.Http.Formatting.xml +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.Helpers.xml +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.Http.xml +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.Http.WebHost.xml +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.Mvc.xml +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.Optimization.xml +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.Razor.xml +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.WebPages.xml +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.WebPages.Deployment.xml +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\System.Web.WebPages.Razor.xml +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\Antlr3.Runtime.pdb +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.xml +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\zh-Hans\System.Net.Http.Formatting.resources.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\zh-Hans\System.Web.Helpers.resources.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\zh-Hans\System.Web.Http.resources.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\zh-Hans\System.Web.Http.WebHost.resources.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\zh-Hans\System.Web.Mvc.resources.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\zh-Hans\System.Web.Optimization.resources.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\zh-Hans\System.Web.Razor.resources.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\zh-Hans\System.Web.WebPages.resources.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\zh-Hans\System.Web.WebPages.Deployment.resources.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\zh-Hans\System.Web.WebPages.Razor.resources.dll +F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\obj\Debug\DongYingAPI.csproj.CopyComplete diff --git a/DongYingAPI/obj/Debug/DongYingAPI.dll b/DongYingAPI/obj/Debug/DongYingAPI.dll index 86b2821..a6e1687 100644 Binary files a/DongYingAPI/obj/Debug/DongYingAPI.dll and b/DongYingAPI/obj/Debug/DongYingAPI.dll differ diff --git a/DongYingAPI/obj/Debug/DongYingAPI.pdb b/DongYingAPI/obj/Debug/DongYingAPI.pdb index 6827a60..4f265bf 100644 Binary files a/DongYingAPI/obj/Debug/DongYingAPI.pdb and b/DongYingAPI/obj/Debug/DongYingAPI.pdb differ