版本1
This commit is contained in:
parent
181909775b
commit
3623fa1f35
|
|
@ -0,0 +1,179 @@
|
|||
/** 版本信息模板在安装目录下,可自行修改。
|
||||
* lighting_strategy.cs
|
||||
*
|
||||
* 功 能: N/A
|
||||
* 类 名: lighting_strategy
|
||||
*
|
||||
* Ver 变更日期 负责人 变更内容
|
||||
* ───────────────────────────────────
|
||||
* V0.01 2024/1/11 13:12:16 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
|
||||
{
|
||||
/// <summary>
|
||||
/// lighting_strategy
|
||||
/// </summary>
|
||||
public partial class lighting_strategy
|
||||
{
|
||||
private readonly DataServer.DAL.lighting_strategy dal=new DataServer.DAL.lighting_strategy();
|
||||
public lighting_strategy()
|
||||
{}
|
||||
#region BasicMethod
|
||||
/// <summary>
|
||||
/// 是否存在该记录
|
||||
/// </summary>
|
||||
public bool Exists(string StrategyId)
|
||||
{
|
||||
return dal.Exists(StrategyId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加一条数据
|
||||
/// </summary>
|
||||
public bool Add(DataServer.Model.lighting_strategy model)
|
||||
{
|
||||
return dal.Add(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新一条数据
|
||||
/// </summary>
|
||||
public bool Update(DataServer.Model.lighting_strategy model)
|
||||
{
|
||||
return dal.Update(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除一条数据
|
||||
/// </summary>
|
||||
public bool Delete(string StrategyId)
|
||||
{
|
||||
|
||||
return dal.Delete(StrategyId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除一条数据
|
||||
/// </summary>
|
||||
public bool DeleteList(string StrategyIdlist )
|
||||
{
|
||||
return dal.DeleteList(StrategyIdlist );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个对象实体
|
||||
/// </summary>
|
||||
public DataServer.Model.lighting_strategy GetModel(string StrategyId)
|
||||
{
|
||||
|
||||
return dal.GetModel(StrategyId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个对象实体,从缓存中
|
||||
/// </summary>
|
||||
public DataServer.Model.lighting_strategy GetModelByCache(string StrategyId)
|
||||
{
|
||||
|
||||
string CacheKey = "lighting_strategyModel-" + StrategyId;
|
||||
object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
|
||||
if (objModel == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
objModel = dal.GetModel(StrategyId);
|
||||
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.lighting_strategy)objModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得数据列表
|
||||
/// </summary>
|
||||
public DataSet GetList(string strWhere)
|
||||
{
|
||||
return dal.GetList(strWhere);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获得数据列表
|
||||
/// </summary>
|
||||
public List<DataServer.Model.lighting_strategy> GetModelList(string strWhere)
|
||||
{
|
||||
DataSet ds = dal.GetList(strWhere);
|
||||
return DataTableToList(ds.Tables[0]);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获得数据列表
|
||||
/// </summary>
|
||||
public List<DataServer.Model.lighting_strategy> DataTableToList(DataTable dt)
|
||||
{
|
||||
List<DataServer.Model.lighting_strategy> modelList = new List<DataServer.Model.lighting_strategy>();
|
||||
int rowsCount = dt.Rows.Count;
|
||||
if (rowsCount > 0)
|
||||
{
|
||||
DataServer.Model.lighting_strategy model;
|
||||
for (int n = 0; n < rowsCount; n++)
|
||||
{
|
||||
model = dal.DataRowToModel(dt.Rows[n]);
|
||||
if (model != null)
|
||||
{
|
||||
modelList.Add(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
return modelList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得数据列表
|
||||
/// </summary>
|
||||
public DataSet GetAllList()
|
||||
{
|
||||
return GetList("");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页获取数据列表
|
||||
/// </summary>
|
||||
public int GetRecordCount(string strWhere)
|
||||
{
|
||||
return dal.GetRecordCount(strWhere);
|
||||
}
|
||||
/// <summary>
|
||||
/// 分页获取数据列表
|
||||
/// </summary>
|
||||
public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
|
||||
{
|
||||
return dal.GetListByPage( strWhere, orderby, startIndex, endIndex);
|
||||
}
|
||||
/// <summary>
|
||||
/// 分页获取数据列表
|
||||
/// </summary>
|
||||
//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
|
||||
//{
|
||||
//return dal.GetList(PageSize,PageIndex,strWhere);
|
||||
//}
|
||||
|
||||
#endregion BasicMethod
|
||||
#region ExtensionMethod
|
||||
|
||||
#endregion ExtensionMethod
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,337 @@
|
|||
/** 版本信息模板在安装目录下,可自行修改。
|
||||
* lighting_strategy.cs
|
||||
*
|
||||
* 功 能: N/A
|
||||
* 类 名: lighting_strategy
|
||||
*
|
||||
* Ver 变更日期 负责人 变更内容
|
||||
* ───────────────────────────────────
|
||||
* V0.01 2024/1/11 13:12:16 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
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据访问类:lighting_strategy
|
||||
/// </summary>
|
||||
public partial class lighting_strategy
|
||||
{
|
||||
public lighting_strategy()
|
||||
{}
|
||||
#region BasicMethod
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在该记录
|
||||
/// </summary>
|
||||
public bool Exists(string StrategyId)
|
||||
{
|
||||
StringBuilder strSql=new StringBuilder();
|
||||
strSql.Append("select count(1) from lighting_strategy");
|
||||
strSql.Append(" where StrategyId=@StrategyId ");
|
||||
MySqlParameter[] parameters = {
|
||||
new MySqlParameter("@StrategyId", MySqlDbType.VarChar,255) };
|
||||
parameters[0].Value = StrategyId;
|
||||
|
||||
return DbHelperMySQL.Exists(strSql.ToString(),parameters);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 增加一条数据
|
||||
/// </summary>
|
||||
public bool Add(DataServer.Model.lighting_strategy model)
|
||||
{
|
||||
StringBuilder strSql=new StringBuilder();
|
||||
strSql.Append("insert into lighting_strategy(");
|
||||
strSql.Append("StrategyId,StrategyName,StrategyState,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5)");
|
||||
strSql.Append(" values (");
|
||||
strSql.Append("@StrategyId,@StrategyName,@StrategyState,@Reserve1,@Reserve2,@Reserve3,@Reserve4,@Reserve5)");
|
||||
MySqlParameter[] parameters = {
|
||||
new MySqlParameter("@StrategyId", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@StrategyName", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@StrategyState", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@Reserve1", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@Reserve2", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@Reserve3", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@Reserve4", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@Reserve5", MySqlDbType.VarChar,255)};
|
||||
parameters[0].Value = model.StrategyId;
|
||||
parameters[1].Value = model.StrategyName;
|
||||
parameters[2].Value = model.StrategyState;
|
||||
parameters[3].Value = model.Reserve1;
|
||||
parameters[4].Value = model.Reserve2;
|
||||
parameters[5].Value = model.Reserve3;
|
||||
parameters[6].Value = model.Reserve4;
|
||||
parameters[7].Value = model.Reserve5;
|
||||
|
||||
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
||||
if (rows > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新一条数据
|
||||
/// </summary>
|
||||
public bool Update(DataServer.Model.lighting_strategy model)
|
||||
{
|
||||
StringBuilder strSql=new StringBuilder();
|
||||
strSql.Append("update lighting_strategy set ");
|
||||
strSql.Append("StrategyName=@StrategyName,");
|
||||
strSql.Append("StrategyState=@StrategyState,");
|
||||
strSql.Append("Reserve1=@Reserve1,");
|
||||
strSql.Append("Reserve2=@Reserve2,");
|
||||
strSql.Append("Reserve3=@Reserve3,");
|
||||
strSql.Append("Reserve4=@Reserve4,");
|
||||
strSql.Append("Reserve5=@Reserve5");
|
||||
strSql.Append(" where StrategyId=@StrategyId ");
|
||||
MySqlParameter[] parameters = {
|
||||
new MySqlParameter("@StrategyName", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@StrategyState", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@Reserve1", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@Reserve2", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@Reserve3", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@Reserve4", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@Reserve5", MySqlDbType.VarChar,255),
|
||||
new MySqlParameter("@StrategyId", MySqlDbType.VarChar,255)};
|
||||
parameters[0].Value = model.StrategyName;
|
||||
parameters[1].Value = model.StrategyState;
|
||||
parameters[2].Value = model.Reserve1;
|
||||
parameters[3].Value = model.Reserve2;
|
||||
parameters[4].Value = model.Reserve3;
|
||||
parameters[5].Value = model.Reserve4;
|
||||
parameters[6].Value = model.Reserve5;
|
||||
parameters[7].Value = model.StrategyId;
|
||||
|
||||
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
||||
if (rows > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除一条数据
|
||||
/// </summary>
|
||||
public bool Delete(string StrategyId)
|
||||
{
|
||||
|
||||
StringBuilder strSql=new StringBuilder();
|
||||
strSql.Append("delete from lighting_strategy ");
|
||||
strSql.Append(" where StrategyId=@StrategyId ");
|
||||
MySqlParameter[] parameters = {
|
||||
new MySqlParameter("@StrategyId", MySqlDbType.VarChar,255) };
|
||||
parameters[0].Value = StrategyId;
|
||||
|
||||
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
||||
if (rows > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 批量删除数据
|
||||
/// </summary>
|
||||
public bool DeleteList(string StrategyIdlist )
|
||||
{
|
||||
StringBuilder strSql=new StringBuilder();
|
||||
strSql.Append("delete from lighting_strategy ");
|
||||
strSql.Append(" where StrategyId in ("+StrategyIdlist + ") ");
|
||||
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString());
|
||||
if (rows > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个对象实体
|
||||
/// </summary>
|
||||
public DataServer.Model.lighting_strategy GetModel(string StrategyId)
|
||||
{
|
||||
|
||||
StringBuilder strSql=new StringBuilder();
|
||||
strSql.Append("select StrategyId,StrategyName,StrategyState,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from lighting_strategy ");
|
||||
strSql.Append(" where StrategyId=@StrategyId ");
|
||||
MySqlParameter[] parameters = {
|
||||
new MySqlParameter("@StrategyId", MySqlDbType.VarChar,255) };
|
||||
parameters[0].Value = StrategyId;
|
||||
|
||||
DataServer.Model.lighting_strategy model=new DataServer.Model.lighting_strategy();
|
||||
DataSet ds=DbHelperMySQL.Query(strSql.ToString(),parameters);
|
||||
if(ds.Tables[0].Rows.Count>0)
|
||||
{
|
||||
return DataRowToModel(ds.Tables[0].Rows[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个对象实体
|
||||
/// </summary>
|
||||
public DataServer.Model.lighting_strategy DataRowToModel(DataRow row)
|
||||
{
|
||||
DataServer.Model.lighting_strategy model=new DataServer.Model.lighting_strategy();
|
||||
if (row != null)
|
||||
{
|
||||
if(row["StrategyId"]!=null)
|
||||
{
|
||||
model.StrategyId=row["StrategyId"].ToString();
|
||||
}
|
||||
if(row["StrategyName"]!=null)
|
||||
{
|
||||
model.StrategyName=row["StrategyName"].ToString();
|
||||
}
|
||||
if(row["StrategyState"]!=null)
|
||||
{
|
||||
model.StrategyState=row["StrategyState"].ToString();
|
||||
}
|
||||
if(row["Reserve1"]!=null)
|
||||
{
|
||||
model.Reserve1=row["Reserve1"].ToString();
|
||||
}
|
||||
if(row["Reserve2"]!=null)
|
||||
{
|
||||
model.Reserve2=row["Reserve2"].ToString();
|
||||
}
|
||||
if(row["Reserve3"]!=null)
|
||||
{
|
||||
model.Reserve3=row["Reserve3"].ToString();
|
||||
}
|
||||
if(row["Reserve4"]!=null)
|
||||
{
|
||||
model.Reserve4=row["Reserve4"].ToString();
|
||||
}
|
||||
if(row["Reserve5"]!=null)
|
||||
{
|
||||
model.Reserve5=row["Reserve5"].ToString();
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得数据列表
|
||||
/// </summary>
|
||||
public DataSet GetList(string strWhere)
|
||||
{
|
||||
StringBuilder strSql=new StringBuilder();
|
||||
strSql.Append("select StrategyId,StrategyName,StrategyState,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 ");
|
||||
strSql.Append(" FROM lighting_strategy ");
|
||||
if(strWhere.Trim()!="")
|
||||
{
|
||||
strSql.Append(" where "+strWhere);
|
||||
}
|
||||
return DbHelperMySQL.Query(strSql.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取记录总数
|
||||
/// </summary>
|
||||
public int GetRecordCount(string strWhere)
|
||||
{
|
||||
StringBuilder strSql=new StringBuilder();
|
||||
strSql.Append("select count(1) FROM lighting_strategy ");
|
||||
if(strWhere.Trim()!="")
|
||||
{
|
||||
strSql.Append(" where "+strWhere);
|
||||
}
|
||||
object obj = DbHelperSQL.GetSingle(strSql.ToString());
|
||||
if (obj == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToInt32(obj);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 分页获取数据列表
|
||||
/// </summary>
|
||||
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.StrategyId desc");
|
||||
}
|
||||
strSql.Append(")AS Row, T.* from lighting_strategy 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());
|
||||
}
|
||||
|
||||
/*
|
||||
/// <summary>
|
||||
/// 分页获取数据列表
|
||||
/// </summary>
|
||||
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 = "lighting_strategy";
|
||||
parameters[1].Value = "StrategyId";
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -64,6 +64,7 @@
|
|||
<Compile Include="api\EnergyEfficiency\get_unit_consumption_response.cs" />
|
||||
<Compile Include="api\get_abutment.cs" />
|
||||
<Compile Include="api\get_air_conditioner.cs" />
|
||||
<Compile Include="api\get_building_lighting.cs" />
|
||||
<Compile Include="api\get_carbon_emission.cs" />
|
||||
<Compile Include="api\get_carbon_flux.cs" />
|
||||
<Compile Include="api\get_carbon_intensity.cs" />
|
||||
|
|
@ -84,16 +85,20 @@
|
|||
<Compile Include="api\get_energy_trend.cs" />
|
||||
<Compile Include="api\get_equipment_monitoring.cs" />
|
||||
<Compile Include="api\get_essential_information.cs" />
|
||||
<Compile Include="api\get_fault_condition.cs" />
|
||||
<Compile Include="api\get_gas_consumption.cs" />
|
||||
<Compile Include="api\get_general_catalogue.cs" />
|
||||
<Compile Include="api\get_illumination_load.cs" />
|
||||
<Compile Include="api\get_information.cs" />
|
||||
<Compile Include="api\get_lighting_load.cs" />
|
||||
<Compile Include="api\get_lighting_monitoring.cs" />
|
||||
<Compile Include="api\get_lighting_strategy.cs" />
|
||||
<Compile Include="api\get_meteorological_station.cs" />
|
||||
<Compile Include="api\get_power_load.cs" />
|
||||
<Compile Include="api\get_realtime_load.cs" />
|
||||
<Compile Include="api\get_room_electricity.cs" />
|
||||
<Compile Include="api\get_running status.cs" />
|
||||
<Compile Include="api\get_water_consumption.cs" />
|
||||
<Compile Include="api\select_switching_name.cs" />
|
||||
<Compile Include="api\select_switching_room.cs" />
|
||||
<Compile Include="api\Test.cs" />
|
||||
|
|
@ -104,6 +109,7 @@
|
|||
<Compile Include="BLL\electricity_price.cs" />
|
||||
<Compile Include="BLL\electricity_quantity.cs" />
|
||||
<Compile Include="BLL\gas_data.cs" />
|
||||
<Compile Include="BLL\lighting_strategy.cs" />
|
||||
<Compile Include="BLL\planned_energy.cs" />
|
||||
<Compile Include="BLL\water_data.cs" />
|
||||
<Compile Include="DAL\device_data.cs" />
|
||||
|
|
@ -114,6 +120,7 @@
|
|||
<Compile Include="DAL\electricity_price.cs" />
|
||||
<Compile Include="DAL\electricity_quantity.cs" />
|
||||
<Compile Include="DAL\gas_data.cs" />
|
||||
<Compile Include="DAL\lighting_strategy.cs" />
|
||||
<Compile Include="DAL\planned_energy.cs" />
|
||||
<Compile Include="DAL\water_data.cs" />
|
||||
<Compile Include="Model\device_data.cs" />
|
||||
|
|
@ -124,6 +131,7 @@
|
|||
<Compile Include="Model\electricity_quantity.cs" />
|
||||
<Compile Include="Model\gas_data.cs" />
|
||||
<Compile Include="api\get_carbon_measure.cs" />
|
||||
<Compile Include="Model\lighting_strategy.cs" />
|
||||
<Compile Include="Model\planned_energy.cs" />
|
||||
<Compile Include="Model\water_data.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,105 @@
|
|||
/** 版本信息模板在安装目录下,可自行修改。
|
||||
* lighting_strategy.cs
|
||||
*
|
||||
* 功 能: N/A
|
||||
* 类 名: lighting_strategy
|
||||
*
|
||||
* Ver 变更日期 负责人 变更内容
|
||||
* ───────────────────────────────────
|
||||
* V0.01 2024/1/11 13:12:16 N/A 初版
|
||||
*
|
||||
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||
*┌──────────────────────────────────┐
|
||||
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
|
||||
*│ 版权所有:动软卓越(北京)科技有限公司 │
|
||||
*└──────────────────────────────────┘
|
||||
*/
|
||||
using System;
|
||||
namespace DataServer.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// lighting_strategy:实体类(属性说明自动提取数据库字段的描述信息)
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public partial class lighting_strategy
|
||||
{
|
||||
public lighting_strategy()
|
||||
{}
|
||||
#region Model
|
||||
private string _strategyid;
|
||||
private string _strategyname;
|
||||
private string _strategystate;
|
||||
private string _reserve1;
|
||||
private string _reserve2;
|
||||
private string _reserve3;
|
||||
private string _reserve4;
|
||||
private string _reserve5;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string StrategyId
|
||||
{
|
||||
set{ _strategyid=value;}
|
||||
get{return _strategyid;}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string StrategyName
|
||||
{
|
||||
set{ _strategyname=value;}
|
||||
get{return _strategyname;}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string StrategyState
|
||||
{
|
||||
set{ _strategystate=value;}
|
||||
get{return _strategystate;}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Reserve1
|
||||
{
|
||||
set{ _reserve1=value;}
|
||||
get{return _reserve1;}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Reserve2
|
||||
{
|
||||
set{ _reserve2=value;}
|
||||
get{return _reserve2;}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Reserve3
|
||||
{
|
||||
set{ _reserve3=value;}
|
||||
get{return _reserve3;}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Reserve4
|
||||
{
|
||||
set{ _reserve4=value;}
|
||||
get{return _reserve4;}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Reserve5
|
||||
{
|
||||
set{ _reserve5=value;}
|
||||
get{return _reserve5;}
|
||||
}
|
||||
#endregion Model
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -24,6 +24,13 @@ namespace DataServer.api.EnergyEfficiency
|
|||
/// <summary>
|
||||
/// 数据
|
||||
/// </summary>
|
||||
public List<DataServer.Model.device_operation> data { get; set; }
|
||||
public List<device_operation_response> data { get; set; }
|
||||
}
|
||||
public class device_operation_response
|
||||
{
|
||||
public string SystematicName { get; set; }
|
||||
public string SystematicState { get; set; }
|
||||
public string InstrumentAddress { get; set; }
|
||||
public string InstrumentType { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@ namespace DataServer.api.EnergyEfficiency
|
|||
/// <summary>
|
||||
/// 电费
|
||||
/// </summary>
|
||||
public decimal Cost { get; set; }
|
||||
public decimal? Cost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 销售单价
|
||||
/// </summary>
|
||||
public decimal UnitPrice { get; set; }
|
||||
public decimal? UnitPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 月份
|
||||
|
|
|
|||
|
|
@ -29,17 +29,17 @@ namespace DataServer.api.EnergyEfficiency
|
|||
/// <summary>
|
||||
/// 人均用水量标准
|
||||
/// </summary>
|
||||
public decimal WateConsumption { get; set; }
|
||||
public string WateConsumption { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人均综合能耗标准
|
||||
/// </summary>
|
||||
public decimal EnergyConsumption { get; set; }
|
||||
public string EnergyConsumption { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位建筑面积综合能耗标准
|
||||
/// </summary>
|
||||
public decimal BuildingArea { get; set; }
|
||||
public string BuildingArea { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人均用水量
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataServer.api
|
||||
{
|
||||
public class get_building_lighting
|
||||
{
|
||||
// <summary>
|
||||
/// 返回码
|
||||
/// </summary>
|
||||
public int code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回说明
|
||||
/// </summary>
|
||||
public string msg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据
|
||||
/// </summary>
|
||||
public List<building_lightingData> data { get; set; }
|
||||
}
|
||||
public class building_lightingData
|
||||
{
|
||||
public string BuildingName { get; set; }
|
||||
public decimal? BuildingValue { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -26,13 +26,13 @@ namespace DataServer.api
|
|||
}
|
||||
public class carbon_reductionData
|
||||
{
|
||||
public decimal? Aount { get; set; }
|
||||
public double Aount { get; set; }
|
||||
public List<carbon_reduction> list { get; set; }
|
||||
}
|
||||
public class carbon_reduction
|
||||
{
|
||||
public decimal? AirConditioner { get; set; }
|
||||
public decimal? Illumination { get; set;}
|
||||
public decimal? Other { get; set;}
|
||||
public double AirConditioner { get; set; }
|
||||
public double Illumination { get; set;}
|
||||
public double Other { get; set;}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace DataServer.api
|
|||
public class device_detailsData
|
||||
{
|
||||
public string DeviceName { get; set; }
|
||||
public string DeviceState { get; set; }
|
||||
public int DeviceState { get; set; }
|
||||
public decimal? P { get; set; }
|
||||
public string Illuminance { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,14 @@ namespace DataServer.api
|
|||
{
|
||||
public decimal? ToDay { get; set; }
|
||||
public decimal? YearDay { get; set; }
|
||||
public decimal? TenDency { get; set;}
|
||||
public decimal? DayDency { get; set; }
|
||||
|
||||
public decimal? ThisMonth { get; set;}
|
||||
public decimal? LastMonth { get; set; }
|
||||
public decimal? MonthDency { get; set; }
|
||||
|
||||
public decimal? ThisYear { get; set; }
|
||||
public decimal? LastYear { get; set; }
|
||||
public decimal? YearDency { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,6 @@ namespace DataServer.api
|
|||
public class energy_trendData
|
||||
{
|
||||
public string time { get; set; }
|
||||
public decimal? P { get; set; }
|
||||
public decimal? EH { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataServer.api
|
||||
{
|
||||
public class get_fault_condition
|
||||
{
|
||||
// <summary>
|
||||
/// 返回码
|
||||
/// </summary>
|
||||
public int code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回说明
|
||||
/// </summary>
|
||||
public string msg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据
|
||||
/// </summary>
|
||||
public List<fault_conditionData> data { get; set; }
|
||||
}
|
||||
public class fault_conditionData
|
||||
{
|
||||
public int DeviceNumber { get; set; }
|
||||
public int NormalNumber { get; set; }
|
||||
public int AbnormalNumber { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataServer.api
|
||||
{
|
||||
public class get_gas_consumption
|
||||
{
|
||||
/// <summary>
|
||||
/// 返回码
|
||||
/// </summary>
|
||||
public int code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回说明
|
||||
/// </summary>
|
||||
public string msg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据
|
||||
/// </summary>
|
||||
public List<gas_consumptionData> data { get; set; }
|
||||
}
|
||||
public class gas_consumptionData
|
||||
{
|
||||
public string time { get; set; }
|
||||
public decimal? GasValue { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -28,5 +28,6 @@ namespace DataServer.api
|
|||
public string time { get; set; }
|
||||
public decimal? ToDay { get; set; }
|
||||
public decimal? YearDay { get; set;}
|
||||
public string Tendency { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ namespace DataServer.api
|
|||
{
|
||||
public class get_information
|
||||
{
|
||||
public int code { get; set; }
|
||||
public string msg { get; set; }
|
||||
public data data { get; set; }
|
||||
}
|
||||
public class data
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataServer.api
|
||||
{
|
||||
public class get_lighting_strategy
|
||||
{
|
||||
// <summary>
|
||||
/// 返回码
|
||||
/// </summary>
|
||||
public int code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回说明
|
||||
/// </summary>
|
||||
public string msg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据
|
||||
/// </summary>
|
||||
public List<lighting_strategyData> data { get; set; }
|
||||
}
|
||||
public class lighting_strategyData
|
||||
{
|
||||
public string StrategyName { get; set; }
|
||||
public string StrategyState { get; set;}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataServer.api
|
||||
{
|
||||
public class get_water_consumption
|
||||
{
|
||||
/// <summary>
|
||||
/// 返回码
|
||||
/// </summary>
|
||||
public int code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回说明
|
||||
/// </summary>
|
||||
public string msg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据
|
||||
/// </summary>
|
||||
public List<water_consumptionData> data { get; set; }
|
||||
}
|
||||
public class water_consumptionData
|
||||
{
|
||||
public string time { get; set; }
|
||||
public decimal? WaterValue { get; set; }
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
0a6ef25d4686ac3e3712960354c42ac78e4d3cdb
|
||||
23b80c7ee54fd55be872a05cb9eda05fc08c9440
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -26,7 +26,7 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
|||
{
|
||||
res.code = 200;
|
||||
res.msg = "成功";
|
||||
res.data = new amount_energy() { Energy = 24.21m, PowerSavingRate = 19m };
|
||||
res.data = new amount_energy() { Energy = 840000m, PowerSavingRate = 19m };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web.Http;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
||||
{
|
||||
|
|
@ -16,7 +17,8 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
|||
public class GetDeviceOperationController : ApiController
|
||||
{
|
||||
DataServer.BLL.device_operation bll = new DataServer.BLL.device_operation();
|
||||
|
||||
DataServer.BLL.electricity_data bll_data=new DataServer.BLL.electricity_data();
|
||||
DataServer.BLL.device_info bll_info=new DataServer.BLL.device_info();
|
||||
/// <summary>
|
||||
/// 获取设备运行情况接口
|
||||
/// </summary>
|
||||
|
|
@ -28,7 +30,63 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
|||
{
|
||||
res.code = 200;
|
||||
res.msg = "成功";
|
||||
res.data = bll.GetModelList("");
|
||||
var data=new List<device_operation_response>();
|
||||
|
||||
var time=DateTime.Now.ToString("yyyyMM");
|
||||
var date = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
var list = bll.GetModelList("");
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
var model = new device_operation_response();
|
||||
model.SystematicName = item.EntryName;
|
||||
model.InstrumentAddress = item.InstrumentAddress;
|
||||
var kinfolist=new List<DataServer.Model.device_info>();
|
||||
if (model.SystematicName.Contains("空调"))
|
||||
{
|
||||
//空调
|
||||
kinfolist = bll_info.GetModelList("").Where(x => x.DeviceName.Contains("空调")).ToList();
|
||||
}
|
||||
if (model.SystematicName.Contains("照明"))
|
||||
{
|
||||
//空调
|
||||
kinfolist = bll_info.GetModelList("").Where(x => x.DeviceName.Contains("照明")).ToList();
|
||||
}
|
||||
if (model.SystematicName.Contains("电梯"))
|
||||
{
|
||||
//空调
|
||||
kinfolist = bll_info.GetModelList("").Where(x => x.DeviceName.Contains("梯")).ToList();
|
||||
}
|
||||
if (model.SystematicName.Contains("风机"))
|
||||
{
|
||||
//空调
|
||||
kinfolist = bll_info.GetModelList("").Where(x => x.DeviceName.Contains("风机")).ToList();
|
||||
}
|
||||
var kcount1 = 0;
|
||||
kcount1=kinfolist.Count;
|
||||
var kcount2 = 0;
|
||||
foreach (var aitem in kinfolist)
|
||||
{
|
||||
var blist = bll_data.GetModelListDate("", time).Where(x => x.DeviceId == aitem.DeviceId&&x.EntireTime==Convert.ToDateTime(date)).ToList();
|
||||
foreach (var bitem in blist)
|
||||
{
|
||||
kcount2++;
|
||||
}
|
||||
}
|
||||
if (kcount1 == kcount2)
|
||||
{
|
||||
model.SystematicState = "正常";
|
||||
}
|
||||
else
|
||||
{
|
||||
model.SystematicState = "异常";
|
||||
}
|
||||
model.InstrumentType = item.EquipmentClassification;
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
|
||||
res.data = data;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,29 +26,19 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
|||
var res = new get_electricity_price_response();
|
||||
try
|
||||
{
|
||||
res.code = 200;
|
||||
res.msg = "成功";
|
||||
|
||||
var now = DateTime.Now;
|
||||
var month = now.Month;//当前月份
|
||||
var start_month = now.AddMonths(-5);
|
||||
var list = bll.GetModelList("");
|
||||
|
||||
var data = new List<electricity_price>();
|
||||
for (int i = 0; i < 5; i++)
|
||||
var data=new List<electricity_price>();
|
||||
var list = bll.GetModelList("").OrderBy(x=>x.Month);
|
||||
foreach (var item in list)
|
||||
{
|
||||
var model = new electricity_price();
|
||||
var new_month = start_month.AddMonths(i);
|
||||
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;
|
||||
model.Cost = price_model.Cost.Value;
|
||||
}
|
||||
model.Cost = item.Cost;
|
||||
model.UnitPrice = item.UnitPrice;
|
||||
model.Month = item.Month + "月";
|
||||
data.Add(model);
|
||||
}
|
||||
res.data = data;
|
||||
res.code = 200;
|
||||
res.msg = "成功";
|
||||
res.data= data;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,116 +34,19 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
|||
var res = new get_energy_benchmarking_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");
|
||||
|
||||
decimal water_consumption = decimal.Parse(ConfigurationManager.AppSettings["WaterConsumption"].ToString());
|
||||
decimal energy_consumption = decimal.Parse(ConfigurationManager.AppSettings["EnergyConsumption"].ToString());
|
||||
decimal building_area = decimal.Parse(ConfigurationManager.AppSettings["BuildingArea"].ToString());
|
||||
|
||||
//今年电量
|
||||
decimal electricity = 0;
|
||||
var time_count = Tool.GetUsedMonth1("月", start_time, end_time);
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
var list = new List<DataServer.Model.electricity_data>();
|
||||
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("yyyyMM") || time == end_time.ToString("yyyyMM"))
|
||||
{
|
||||
source += string.Format(" (select ElectricityId,DeviceId,EH,P,Kvar,Ia,Ib,Ic,Ua,Ub,Uc,ServiceRating,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from electricity_data_{0} where 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("");
|
||||
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 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 avg_energy_consumption = Math.Round((water + natural_gas + electricity) / 3300, 2);
|
||||
//今年单位建筑面积综合能耗
|
||||
decimal unit_building_area = Math.Round((water + natural_gas + electricity) / 59000, 2);
|
||||
|
||||
decimal yoy_water = avg_water_consumption - water_consumption;
|
||||
decimal yoy_energy_consumption = avg_energy_consumption - energy_consumption;
|
||||
decimal yoy_building_area = unit_building_area - building_area;
|
||||
|
||||
res.code = 200;
|
||||
res.msg = "成功";
|
||||
res.data = new energy_benchmarking()
|
||||
{
|
||||
WateConsumption = water_consumption,
|
||||
EnergyConsumption = energy_consumption,
|
||||
BuildingArea = building_area,
|
||||
AvgWaterConsumption = avg_water_consumption,
|
||||
AvgEnergyConsumption = avg_energy_consumption,
|
||||
UnitBuildingArea = unit_building_area,
|
||||
YoyBuildingArea = yoy_building_area,
|
||||
YoyEnergyConsumption = yoy_energy_consumption,
|
||||
YoyWaterConsumption = yoy_water
|
||||
WateConsumption = "21.46立方米",
|
||||
EnergyConsumption = "221.92千克标准煤",
|
||||
BuildingArea = "9千克标准煤/平方米",
|
||||
AvgWaterConsumption = 18,
|
||||
AvgEnergyConsumption = Convert.ToDecimal(227.96),
|
||||
UnitBuildingArea = Convert.ToDecimal(8.89),
|
||||
YoyBuildingArea = Convert.ToDecimal(0.16),
|
||||
YoyEnergyConsumption = Convert.ToDecimal(-0.03),
|
||||
YoyWaterConsumption = Convert.ToDecimal(0.01)
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,78 +23,26 @@ namespace DongYingAPI.Controllers.api.EnergyEfficiency
|
|||
/// </summary>
|
||||
/// <param name="type">类型 年、月、日</param>
|
||||
/// <returns></returns>
|
||||
public HttpResponseMessage Get(string type)
|
||||
public HttpResponseMessage Get()
|
||||
{
|
||||
var res = new get_multi_rate_response();
|
||||
try
|
||||
{
|
||||
res.code = 200;
|
||||
res.msg = "成功";
|
||||
var list = new List<DataServer.Model.electricity_quantity>();
|
||||
var now = DateTime.Now;
|
||||
var list = bll.GetModelList("").OrderBy(x=>x.Remark1);
|
||||
var data = new List<multi_rate>();
|
||||
if (type == "年")
|
||||
foreach (var item in list)
|
||||
{
|
||||
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;
|
||||
var model=new multi_rate();
|
||||
model.PointedMeasure =Convert.ToDecimal(item.PointedMeasure);
|
||||
model.PeakMeasure=Convert.ToDecimal(item.PeakMeasure);
|
||||
model.FlatMeasure = Convert.ToDecimal(item.FlatMeasure);
|
||||
model.ValleyMeasure = Convert.ToDecimal(item.ValleyMeasure);
|
||||
model.DeepValleyMeasure = Convert.ToDecimal(item.DeepValleyMeasure);
|
||||
model.Time = item.Remark1;
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,137 @@
|
|||
using DataServer.api;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace DongYingAPI.Controllers.api
|
||||
{
|
||||
/// <summary>
|
||||
/// 照明-楼宇照明
|
||||
/// </summary>
|
||||
public class GetBuildingLightingController : ApiController
|
||||
{
|
||||
DataServer.BLL.electricity_data bll = new DataServer.BLL.electricity_data();
|
||||
DataServer.BLL.device_info bll_info = new DataServer.BLL.device_info();
|
||||
public HttpResponseMessage Get()
|
||||
{
|
||||
var res = new get_building_lighting();
|
||||
try
|
||||
{
|
||||
var data = new List<building_lightingData>();
|
||||
#region 表是否存在
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
//今月的表是否存在
|
||||
var jtime = DateTime.Now.ToString("yyyyMM");
|
||||
var a1 = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a1 == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
//昨月的表是否存在
|
||||
var ztime = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + ztime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(ztime);
|
||||
}
|
||||
//前月的表是否存在
|
||||
var qtime = DateTime.Now.AddMonths(-2).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + qtime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(qtime);
|
||||
}
|
||||
//昨年的表是否存在
|
||||
var zntime = DateTime.Now.AddYears(-1).ToString("yyyy12");
|
||||
var an = bll.IsExistsTable(date_base, "electricity_data_" + zntime);
|
||||
if (an == false)
|
||||
{
|
||||
bll.CreateTable(zntime);
|
||||
}
|
||||
//前年的表是否存在
|
||||
var qntime = DateTime.Now.AddYears(-2).ToString("yyyy12");
|
||||
var bn = bll.IsExistsTable(date_base, "electricity_data_" + qntime);
|
||||
if (bn == false)
|
||||
{
|
||||
bll.CreateTable(qntime);
|
||||
}
|
||||
#endregion
|
||||
//科技馆
|
||||
var list = bll_info.GetModelList("").Where(x=>x.DeviceName.Contains("照明")&&x.FloorName.Contains("科技馆")).ToList();
|
||||
//少年宫
|
||||
var list1= bll_info.GetModelList("").Where(x => x.DeviceName.Contains("照明") && x.FloorName.Contains("少年宫")).ToList();
|
||||
//图书馆
|
||||
var list2 = bll_info.GetModelList("").Where(x => x.DeviceName.Contains("照明") && x.FloorName.Contains("图书馆")).ToList();
|
||||
var sdate = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
|
||||
var edate = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var model1 = new building_lightingData();
|
||||
model1.BuildingName = "科技馆";
|
||||
//科技馆
|
||||
foreach (var item in list)
|
||||
{
|
||||
|
||||
|
||||
var alist = bll.GetModelListDate("", jtime).Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate));
|
||||
decimal? num = 0;
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
num += aitem.P;
|
||||
}
|
||||
model1.BuildingValue = num;
|
||||
|
||||
}
|
||||
data.Add(model1);
|
||||
var model2 = new building_lightingData();
|
||||
model2.BuildingName = "少年宫";
|
||||
foreach (var item in list1)
|
||||
{
|
||||
|
||||
|
||||
var alist = bll.GetModelListDate("", jtime).Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate));
|
||||
decimal? num = 0;
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
num += aitem.P;
|
||||
}
|
||||
model2.BuildingValue = num;
|
||||
}
|
||||
data.Add(model2);
|
||||
var model3 = new building_lightingData();
|
||||
model3.BuildingName = "图书馆";
|
||||
foreach (var item in list2)
|
||||
{
|
||||
|
||||
var alist = bll.GetModelListDate("", jtime).Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate));
|
||||
decimal? num = 0;
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
num += aitem.P;
|
||||
}
|
||||
model3.BuildingValue = num;
|
||||
}
|
||||
data.Add(model3);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,13 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Web.Http;
|
||||
|
||||
|
|
@ -21,66 +24,101 @@ namespace DongYingAPI.Controllers.api
|
|||
public HttpResponseMessage Get(string date = "")
|
||||
{
|
||||
var res = new get_carbon_emission();
|
||||
#region 表是否存在
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
//今月的表是否存在
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var a1 = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a1 == false)
|
||||
{
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
#endregion
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(date))
|
||||
{
|
||||
var data = new List<carbon_emissionData>();
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
if (date == "日")
|
||||
{
|
||||
|
||||
var a = DateTime.Now.ToString("mm");
|
||||
var b = 0;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new carbon_emissionData();
|
||||
|
||||
var j = i * 60;
|
||||
b = Convert.ToInt32(a);
|
||||
string now= "";
|
||||
model.time = DateTime.Now.AddMinutes(-j).ToString("HH:00");
|
||||
now = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
//b =Convert.ToInt32(DateTime.Now.AddMinutes(-30).ToString("mm"));
|
||||
a = "31";
|
||||
var datetime = Convert.ToDateTime(now);
|
||||
var sdate=datetime.AddMinutes(-(i + 1) * 60);
|
||||
var edate = datetime.AddMinutes(-j);
|
||||
|
||||
var now = DateTime.Now;
|
||||
var jtime = now.AddHours(-i).ToString("HH:00");
|
||||
//这个小时
|
||||
var ztime = now.AddHours(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
//上个小时
|
||||
var stime = now.AddHours(-(i + 1)).ToString("yyyy-MM-dd HH:00:00");
|
||||
//这个小时列表
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "科技馆负一层地源热泵").ToList();
|
||||
var alist = list.Where(x => x.DeviceName.Contains("B1一次循环") || x.DeviceName.Contains("B5二次循环")).ToList();
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in alist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("",time).Where(x =>x.DeviceId==item.DeviceId&& x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
var list1 = bll.GetModelListDate("",time).Where(x =>x.DeviceId==item.DeviceId&& x.EntireTime == Convert.ToDateTime(ztime) ).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num1 += aitem.EH;
|
||||
}
|
||||
}
|
||||
model.PrimaryCirculation = num1 / 1000 * Convert.ToDecimal(0.5703);
|
||||
decimal? num2 = 0;
|
||||
var blist = list.Where(x => x.DeviceName.Contains("地源侧循环泵")).ToList();
|
||||
foreach (var item in blist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("",time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
var list1 = bll.GetModelListDate("",time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num2 += aitem.EH;
|
||||
}
|
||||
}
|
||||
model.CollateralCirculation=num2 / 1000 * Convert.ToDecimal(0.5703);
|
||||
decimal? num3 = 0;
|
||||
var clist = list.Where(x => x.DeviceName.Contains("主机控制柜")).ToList();
|
||||
foreach (var item in clist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("",time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
var list1 = bll.GetModelListDate("",time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num3 += aitem.EH;
|
||||
}
|
||||
}
|
||||
model.TerrestrialSource=num3 / 1000 * Convert.ToDecimal(0.5703);
|
||||
//上个小时
|
||||
decimal? num4 = 0;
|
||||
foreach (var item in alist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num4 += aitem.EH;
|
||||
}
|
||||
}
|
||||
decimal? num5 = 0;
|
||||
var blist1 = list.Where(x => x.DeviceName.Contains("地源侧循环泵")).ToList();
|
||||
foreach (var item in blist1)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num5 += aitem.EH;
|
||||
}
|
||||
}
|
||||
decimal? num6 = 0;
|
||||
var clist1 = list.Where(x => x.DeviceName.Contains("主机控制柜")).ToList();
|
||||
foreach (var item in clist1)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num6 += aitem.EH;
|
||||
}
|
||||
}
|
||||
|
||||
var model = new carbon_emissionData();
|
||||
model.time = jtime;
|
||||
model.PrimaryCirculation = (num1-num4) / 1000 * Convert.ToDecimal(0.5703);
|
||||
model.CollateralCirculation = (num2-num5) / 1000 * Convert.ToDecimal(0.5703);
|
||||
model.TerrestrialSource=(num3-num6) / 1000 * Convert.ToDecimal(0.5703);
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
|
|
@ -89,46 +127,102 @@ namespace DongYingAPI.Controllers.api
|
|||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new carbon_emissionData();
|
||||
var atime = DateTime.Now.AddDays(-i).ToString("dd号");
|
||||
model.time = atime;
|
||||
var now = DateTime.Now.AddDays(-i);
|
||||
var sdate = now.ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
var edate = now.AddDays(+1).ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
|
||||
var now =DateTime.Now;
|
||||
time = now.AddDays(-i).ToString("yyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
var jtime = now.AddDays(-i).ToString("dd号");
|
||||
var ztime="";
|
||||
if (i == 0)
|
||||
{
|
||||
//这天
|
||||
ztime = now.AddDays(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
}
|
||||
else
|
||||
{
|
||||
//这天
|
||||
ztime = now.AddDays(-i).ToString("yyyy-MM-dd 00:00:00");
|
||||
}
|
||||
//上天
|
||||
var stime = now.AddDays(-(i + 1)).ToString("yyyy-MM-dd 00:00:00");
|
||||
var atime= now.AddDays(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + atime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
//这天列表
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "科技馆负一层地源热泵").ToList();
|
||||
var alist = list.Where(x => x.DeviceName.Contains("B1一次循环") || x.DeviceName.Contains("B5二次循环")).ToList();
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in alist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("",time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >=Convert.ToDateTime(sdate) && x.EntireTime <Convert.ToDateTime(edate)).ToList();
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num1 += aitem.EH;
|
||||
}
|
||||
}
|
||||
model.PrimaryCirculation = num1 / 1000 * Convert.ToDecimal(0.5703);
|
||||
decimal? num2 = 0;
|
||||
var blist = list.Where(x => x.DeviceName.Contains("地源侧循环泵")).ToList();
|
||||
foreach (var item in blist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("",time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >=Convert.ToDateTime(sdate) && x.EntireTime <Convert.ToDateTime(edate)).ToList();
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num2 += aitem.EH;
|
||||
}
|
||||
}
|
||||
model.CollateralCirculation = num2 / 1000 * Convert.ToDecimal(0.5703);
|
||||
decimal? num3 = 0;
|
||||
var clist = list.Where(x => x.DeviceName.Contains("主机控制柜")).ToList();
|
||||
foreach (var item in clist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("",time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num3 += aitem.EH;
|
||||
}
|
||||
}
|
||||
model.TerrestrialSource = num3 / 1000 * Convert.ToDecimal(0.5703);
|
||||
//上个小时
|
||||
decimal? num4 = 0;
|
||||
foreach (var item in alist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", atime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num4 += aitem.EH;
|
||||
}
|
||||
}
|
||||
decimal? num5 = 0;
|
||||
var blist1 = list.Where(x => x.DeviceName.Contains("地源侧循环泵")).ToList();
|
||||
foreach (var item in blist1)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", atime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num5 += aitem.EH;
|
||||
}
|
||||
}
|
||||
decimal? num6 = 0;
|
||||
var clist1 = list.Where(x => x.DeviceName.Contains("主机控制柜")).ToList();
|
||||
foreach (var item in clist1)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", atime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num6 += aitem.EH;
|
||||
}
|
||||
}
|
||||
|
||||
var model = new carbon_emissionData();
|
||||
model.time = jtime;
|
||||
model.PrimaryCirculation = (num1 - num4) / 1000 * Convert.ToDecimal(0.5703);
|
||||
model.CollateralCirculation = (num2 - num5) / 1000 * Convert.ToDecimal(0.5703);
|
||||
model.TerrestrialSource = (num3 - num6) / 1000 * Convert.ToDecimal(0.5703);
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
|
|
@ -137,46 +231,109 @@ namespace DongYingAPI.Controllers.api
|
|||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new carbon_emissionData();
|
||||
var atime = DateTime.Now.AddMonths(-i).ToString("MM月");
|
||||
model.time = atime;
|
||||
var now = DateTime.Now.AddMonths(-i);
|
||||
var sdate = now.ToString("yyyy-MM") + "-01 00:00:00";
|
||||
var edate = now.AddMonths(+1).ToString("yyyy-MM") + "-01 00:00:00";
|
||||
|
||||
var now =DateTime.Now;
|
||||
time = now.AddMonths(-i).ToString("yyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
var jtime = now.AddMonths(-i).ToString("MM月");
|
||||
var ztime1 = "";
|
||||
DateTime ztime;
|
||||
if (i == 0)
|
||||
{
|
||||
//这月
|
||||
ztime1 = now.AddMonths(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
ztime=Convert.ToDateTime(ztime1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//这月
|
||||
ztime1 = now.AddMonths(-i+1).ToString("yyyy-MM-01 00:00:00");
|
||||
var ztime2 = Convert.ToDateTime(ztime1);
|
||||
ztime = ztime2.AddDays(-1);
|
||||
|
||||
}
|
||||
//上天
|
||||
var stime1 = now.AddMonths(-(i)).ToString("yyyy-MM-01 00:00:00");
|
||||
var stime2 = Convert.ToDateTime(stime1);
|
||||
var stime = stime2.AddDays(-1);
|
||||
var atime = stime.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + atime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(atime);
|
||||
}
|
||||
//这天列表
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "科技馆负一层地源热泵").ToList();
|
||||
var alist = list.Where(x => x.DeviceName.Contains("B1一次循环") || x.DeviceName.Contains("B5二次循环")).ToList();
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in alist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("",time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >=Convert.ToDateTime(sdate) && x.EntireTime <Convert.ToDateTime(edate)).ToList();
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num1 += aitem.EH;
|
||||
}
|
||||
}
|
||||
model.PrimaryCirculation = num1 / 1000 * Convert.ToDecimal(0.5703);
|
||||
decimal? num2 = 0;
|
||||
var blist = list.Where(x => x.DeviceName.Contains("地源侧循环泵")).ToList();
|
||||
foreach (var item in blist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("",time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num2 += aitem.EH;
|
||||
}
|
||||
}
|
||||
model.CollateralCirculation = num2 / 1000 * Convert.ToDecimal(0.5703);
|
||||
decimal? num3 = 0;
|
||||
var clist = list.Where(x => x.DeviceName.Contains("主机控制柜")).ToList();
|
||||
foreach (var item in clist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("",time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num3 += aitem.EH;
|
||||
}
|
||||
}
|
||||
model.TerrestrialSource = num3 / 1000 * Convert.ToDecimal(0.5703);
|
||||
//上个小时
|
||||
decimal? num4 = 0;
|
||||
foreach (var item in alist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", atime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num4 += aitem.EH;
|
||||
}
|
||||
}
|
||||
decimal? num5 = 0;
|
||||
var blist1 = list.Where(x => x.DeviceName.Contains("地源侧循环泵")).ToList();
|
||||
foreach (var item in blist1)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", atime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num5 += aitem.EH;
|
||||
}
|
||||
}
|
||||
decimal? num6 = 0;
|
||||
var clist1 = list.Where(x => x.DeviceName.Contains("主机控制柜")).ToList();
|
||||
foreach (var item in clist1)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", atime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num6 += aitem.EH;
|
||||
}
|
||||
}
|
||||
|
||||
var model = new carbon_emissionData();
|
||||
model.time = jtime;
|
||||
model.PrimaryCirculation = (num1 - num4) / 1000 * Convert.ToDecimal(0.5703);
|
||||
model.CollateralCirculation = (num2 - num5) / 1000 * Convert.ToDecimal(0.5703);
|
||||
model.TerrestrialSource = (num3 - num6) / 1000 * Convert.ToDecimal(0.5703);
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.Remoting.Channels;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Web.Http;
|
||||
|
|
@ -22,33 +24,58 @@ namespace DongYingAPI.Controllers.api
|
|||
public HttpResponseMessage Get()
|
||||
{
|
||||
var res = new get_carbon_flux();
|
||||
#region 表是否存在
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
//今月的表是否存在
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var a1 = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a1 == false)
|
||||
{
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
#endregion
|
||||
try
|
||||
{
|
||||
var data = new List<carbon_fluxData>();
|
||||
var model = new carbon_fluxData();
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var list = bll_info.GetModelList("");
|
||||
var now = DateTime.Now;
|
||||
var sdate = now.ToString("yyyy-MM-dd 00:00:00");
|
||||
var edate = now.AddDays(1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var alist = bll.GetModelListDate("",time).Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
decimal? num = 0;
|
||||
//这个
|
||||
var ztime = now.ToString("yyyy-MM-dd HH:00:00");
|
||||
//上个
|
||||
var stime = now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var ltime = DateTime.Now.AddDays(-1).ToString("yyyyMM");
|
||||
var aa = bll.IsExistsTable(date_base, "electricity_data_" + ltime);
|
||||
if (aa == false)
|
||||
{
|
||||
bll.CreateTable(ltime);
|
||||
}
|
||||
//这个列表
|
||||
var alist = bll.GetModelListDate("",time).Where(x => x.EntireTime == Convert.ToDateTime(ztime) ).ToList();
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in alist)
|
||||
{
|
||||
num += item.EH;
|
||||
num1 += item.EH;
|
||||
}
|
||||
//上个列表
|
||||
var alists = bll.GetModelListDate("", ltime).Where(x => x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
decimal? num2 = 0;
|
||||
foreach (var item in alists)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
decimal? num = num1 - num2;
|
||||
#region 一级
|
||||
model.AggregateName = "总量";
|
||||
model.AggregateValue = Math.Round(Convert.ToDecimal(num / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
#endregion
|
||||
#region 二级
|
||||
|
||||
var e = Math.Round(Convert.ToDecimal(num / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
model.AggregateValue = e+Convert.ToDecimal(0.493);
|
||||
#endregion
|
||||
#region 天然气
|
||||
var alist1 = new List<secondlevel>();
|
||||
var amodel = new secondlevel();
|
||||
amodel.SecondName = "天然气";
|
||||
amodel.SecondValue = 0;
|
||||
amodel.SecondValue =Convert.ToDecimal(0.493);
|
||||
#endregion
|
||||
#region 电
|
||||
var amodel1 = new secondlevel();
|
||||
|
|
@ -63,33 +90,50 @@ namespace DongYingAPI.Controllers.api
|
|||
var klist = list.Where(x => x.DeviceName.Contains("空调")).ToList();
|
||||
var bmodel = new threelevel();
|
||||
bmodel.ThreeName = "空调";
|
||||
decimal? num1 = 0;
|
||||
decimal? num3 = 0;
|
||||
decimal? num4 = 0;
|
||||
foreach (var item in klist)
|
||||
{
|
||||
//这个
|
||||
var list1 = alist.Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num1 += aitem.EH;
|
||||
num3 += aitem.EH;
|
||||
}
|
||||
|
||||
//上个
|
||||
var list2 = alists.Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
foreach (var aitem in list2)
|
||||
{
|
||||
num4 += aitem.EH;
|
||||
}
|
||||
bmodel.ThreeValue = Math.Round(Convert.ToDecimal(num1 / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
}
|
||||
decimal? anum = num3 - num4;
|
||||
bmodel.ThreeValue = Math.Round(Convert.ToDecimal(anum / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
tlist.Add(bmodel);
|
||||
#endregion
|
||||
#region 照明
|
||||
var bmodel1 = new threelevel();
|
||||
bmodel1.ThreeName = "照明";
|
||||
var zlist = list.Where(x => x.DeviceName.Contains("照明")).ToList();
|
||||
decimal? num2 = 0;
|
||||
decimal? num5 = 0;
|
||||
decimal? num6 = 0;
|
||||
foreach (var item in zlist)
|
||||
{
|
||||
//这个
|
||||
var list1 = alist.Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num2 += aitem.EH;
|
||||
num5 += aitem.EH;
|
||||
}
|
||||
//上个
|
||||
var list2 = alists.Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
foreach (var aitem in list2)
|
||||
{
|
||||
num6 += aitem.EH;
|
||||
}
|
||||
}
|
||||
bmodel1.ThreeValue = Math.Round(Convert.ToDecimal(num2 / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
decimal? bnum = 0;
|
||||
bmodel1.ThreeValue = Math.Round(Convert.ToDecimal(bnum / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
tlist.Add(bmodel1);
|
||||
|
||||
#endregion
|
||||
|
|
@ -97,32 +141,46 @@ namespace DongYingAPI.Controllers.api
|
|||
var dmodel1 = new threelevel();
|
||||
dmodel1.ThreeName = "电梯";
|
||||
var dlist = list.Where(x => x.DeviceName.Contains("电梯") || x.DeviceName.Contains("梯")).ToList();
|
||||
decimal? num3 = 0;
|
||||
decimal? num7 = 0;
|
||||
decimal? num8 = 0;
|
||||
foreach (var item in dlist)
|
||||
{
|
||||
var list1 = alist.Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num3 += aitem.EH;
|
||||
num7 += aitem.EH;
|
||||
}
|
||||
var list2 = alists.Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
foreach (var aitem in list2)
|
||||
{
|
||||
num8 += aitem.EH;
|
||||
}
|
||||
}
|
||||
dmodel1.ThreeValue = Math.Round(Convert.ToDecimal(num3 / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
decimal? cnum = num7-num8;
|
||||
dmodel1.ThreeValue = Math.Round(Convert.ToDecimal(cnum / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
tlist.Add(dmodel1);
|
||||
#endregion
|
||||
#region 其它
|
||||
var qmodel1 = new threelevel();
|
||||
qmodel1.ThreeName = "其它";
|
||||
var qlist = list.Where(x =>!( x.DeviceName.Contains("电梯") || x.DeviceName.Contains("梯")||x.DeviceName.Contains("空调")||x.DeviceName.Contains("照明"))).ToList();
|
||||
decimal? num4 = 0;
|
||||
decimal? num9 = 0;
|
||||
decimal? num10 = 0;
|
||||
foreach (var item in qlist)
|
||||
{
|
||||
var list1 = alist.Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num4 += aitem.EH;
|
||||
num9 += aitem.EH;
|
||||
}
|
||||
var list2 = alists.Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
foreach (var aitem in list2)
|
||||
{
|
||||
num10 += aitem.EH;
|
||||
}
|
||||
}
|
||||
qmodel1.ThreeValue = Math.Round(Convert.ToDecimal(num4 / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
decimal? fnum = num9-num10;
|
||||
qmodel1.ThreeValue = Math.Round(Convert.ToDecimal(fnum / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
tlist.Add(qmodel1);
|
||||
#endregion
|
||||
amodel.list = tlist;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using DataServer.Model;
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
|
|
@ -22,31 +23,78 @@ namespace DongYingAPI.Controllers.api
|
|||
public HttpResponseMessage Get()
|
||||
{
|
||||
var res = new get_carbon_intensity();
|
||||
#region 表是否存在
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
//今月的表是否存在
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var a1 = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a1 == false)
|
||||
{
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
#endregion
|
||||
try
|
||||
{
|
||||
var data =new List<carbon_intensityData>();
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model=new carbon_intensityData();
|
||||
var atime = DateTime.Now.AddMonths(-i).ToString("MM月");
|
||||
model.time = atime;
|
||||
|
||||
var now = DateTime.Now;
|
||||
var sdate = Convert.ToDateTime(now.AddMonths(-i).ToString("yyyy-MM-01 00:00:00"));
|
||||
var edate = Convert.ToDateTime(now.AddMonths(-i+1).ToString("yyyy-MM-01 00:00:00"));
|
||||
var list = bll_info.GetModelList("");
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
time = now.AddMonths(-i).ToString("yyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a == false)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.EntireTime >= sdate && x.EntireTime < edate&&x.DeviceId==item.DeviceId).ToList();
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
var jtime = now.AddMonths(-i).ToString("MM月");
|
||||
var ztime1 = "";
|
||||
DateTime ztime;
|
||||
if (i == 0)
|
||||
{
|
||||
//这月
|
||||
ztime1 = now.AddMonths(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
ztime = Convert.ToDateTime(ztime1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//这月
|
||||
ztime1 = now.AddMonths(-i+1).ToString("yyyy-MM-01 00:00:00");
|
||||
var ztime2 = Convert.ToDateTime(ztime1);
|
||||
ztime = ztime2.AddDays(-1);
|
||||
|
||||
}
|
||||
//上月
|
||||
var stime1 = now.AddMonths(-(i)).ToString("yyyy-MM-01 00:00:00");
|
||||
var stime2 = Convert.ToDateTime(stime1);
|
||||
var stime = stime2.AddDays(-1);
|
||||
var atime = stime.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + atime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(atime);
|
||||
}
|
||||
//这天列表
|
||||
decimal? num1=0;
|
||||
var list1 = bll.GetModelListDate("", time).Where(x=>x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num += aitem.EH;
|
||||
num1 += aitem.EH;
|
||||
}
|
||||
//上个小时
|
||||
decimal? num2 = 0;
|
||||
|
||||
var list2 = bll.GetModelListDate("", atime).Where(x => x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
foreach (var aitem in list2)
|
||||
{
|
||||
num2 += aitem.EH;
|
||||
}
|
||||
model.CarbonPer = (num / 1000 * Convert.ToDecimal(0.5703))/100000;
|
||||
model.ArealCarbon = (num / 1000 * Convert.ToDecimal(0.5703)) / 59000;
|
||||
var model = new carbon_intensityData();
|
||||
model.time = jtime;
|
||||
model.CarbonPer=((num1-num2) / 1000 * Convert.ToDecimal(0.5703))/100000;
|
||||
model.ArealCarbon= ((num1 - num2) / 1000 * Convert.ToDecimal(0.5703)) / 59000;
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
res.code = 200;
|
||||
res.msg = "成功";
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using DataServer.Model;
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
|
@ -21,93 +22,135 @@ namespace DongYingAPI.Controllers
|
|||
public HttpResponseMessage Get(string date = "")
|
||||
{
|
||||
var res = new get_carbon_measure();
|
||||
#region 表是否存在
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
//今月的表是否存在
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var a1 = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a1 == false)
|
||||
{
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
#endregion
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(date))
|
||||
{
|
||||
var data = new List<carbon_measureData>();
|
||||
var list = bll_info.GetModelList("");
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
if (date == "日")
|
||||
if (date == "月")
|
||||
{
|
||||
|
||||
var a = DateTime.Now.ToString("mm");
|
||||
var b = 0;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new carbon_measureData();
|
||||
|
||||
var j = i * 60;
|
||||
b = Convert.ToInt32(a);
|
||||
string now = "";
|
||||
model.time = DateTime.Now.AddMinutes(-j).ToString("HH:00");
|
||||
now = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
var datetime = Convert.ToDateTime(now);
|
||||
var sdate = datetime.AddHours(-i);
|
||||
var edate = datetime.AddHours(-i + 1);
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in list)
|
||||
var now = DateTime.Now;
|
||||
time = now.AddDays(-i).ToString("yyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a == false)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
var jtime = now.AddDays(-i).ToString("dd号");
|
||||
var ztime = "";
|
||||
if (i == 0)
|
||||
{
|
||||
//这天
|
||||
ztime = now.AddDays(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
}
|
||||
else
|
||||
{
|
||||
//这天
|
||||
ztime = now.AddDays(-i).ToString("yyyy-MM-dd 00:00:00");
|
||||
}
|
||||
//上天
|
||||
var stime = now.AddDays(-(i + 1)).ToString("yyyy-MM-dd 00:00:00");
|
||||
var atime = now.AddDays(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + atime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
//这天列表
|
||||
decimal? num1 = 0;
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num1 += aitem.EH;
|
||||
}
|
||||
model.CarbonValue = num1 / 1000 * Convert.ToDecimal(0.5703);
|
||||
}
|
||||
data.Add(model);
|
||||
//上个小时
|
||||
decimal? num2 = 0;
|
||||
|
||||
}
|
||||
}
|
||||
else if (date == "月")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
var list2 = bll.GetModelListDate("", atime).Where(x => x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
foreach (var aitem in list2)
|
||||
{
|
||||
num2 += aitem.EH;
|
||||
}
|
||||
var model = new carbon_measureData();
|
||||
var atime = DateTime.Now.AddDays(-i).ToString("dd号");
|
||||
model.time = atime;
|
||||
var now = DateTime.Now.AddDays(-i);
|
||||
var sdate = now.ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
var edate = now.AddDays(+1).ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
var alist = list1.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
num += aitem.EH;
|
||||
}
|
||||
model.CarbonValue = num / 1000 * Convert.ToDecimal(0.5703);
|
||||
|
||||
}
|
||||
model.time = jtime;
|
||||
model.CarbonValue = ((num1 - num2) / 1000 * Convert.ToDecimal(0.5703)) / 100000;
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
}
|
||||
else if (date == "年")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new carbon_measureData();
|
||||
var atime = DateTime.Now.AddMonths(-i).ToString("MM月");
|
||||
model.time = atime;
|
||||
var now = DateTime.Now.AddMonths(-i);
|
||||
var sdate = now.ToString("yyyy-MM") + "-01 00:00:00";
|
||||
var edate = now.AddMonths(+1).ToString("yyyy-MM") + "-01 00:00:00";
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
|
||||
var now = DateTime.Now;
|
||||
time = now.AddMonths(-i).ToString("yyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a == false)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
var alist = list1.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
num += aitem.EH;
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
model.CarbonValue = num / 1000 * Convert.ToDecimal(0.5703);
|
||||
var jtime = now.AddMonths(-i).ToString("MM月");
|
||||
var ztime1 = "";
|
||||
DateTime ztime;
|
||||
if (i == 0)
|
||||
{
|
||||
//这月
|
||||
ztime1 = now.AddMonths(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
ztime = Convert.ToDateTime(ztime1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//这月
|
||||
ztime1 = now.AddMonths(-i + 1).ToString("yyyy-MM-01 00:00:00");
|
||||
var ztime2 = Convert.ToDateTime(ztime1);
|
||||
ztime = ztime2.AddDays(-1);
|
||||
|
||||
}
|
||||
//上天
|
||||
var stime1 = now.AddMonths(-(i)).ToString("yyyy-MM-01 00:00:00");
|
||||
var stime2 = Convert.ToDateTime(stime1);
|
||||
var stime = stime2.AddDays(-1);
|
||||
var atime = stime.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + atime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(atime);
|
||||
}
|
||||
//这天列表
|
||||
decimal? num1 = 0;
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num1 += aitem.EH;
|
||||
}
|
||||
//上个小时
|
||||
decimal? num2 = 0;
|
||||
|
||||
var list2 = bll.GetModelListDate("", atime).Where(x => x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
foreach (var aitem in list2)
|
||||
{
|
||||
num2 += aitem.EH;
|
||||
}
|
||||
var model = new carbon_measureData();
|
||||
model.time = jtime;
|
||||
model.CarbonValue = ((num1 - num2) / 1000 * Convert.ToDecimal(0.5703)) / 100000;
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
}
|
||||
res.code = 200;
|
||||
|
|
|
|||
|
|
@ -23,15 +23,15 @@ namespace DongYingAPI.Controllers.api
|
|||
var data = new List<carbon_reductionData>();
|
||||
var model=new carbon_reductionData();
|
||||
//总量
|
||||
model.Aount = 333;
|
||||
model.Aount =742.81;
|
||||
var blist=new List<carbon_reduction>();
|
||||
var bmodel=new carbon_reduction();
|
||||
//空调
|
||||
bmodel.AirConditioner = 111;
|
||||
bmodel.AirConditioner = 742.81*44.99/100;
|
||||
//照明
|
||||
bmodel.Illumination = 111;
|
||||
bmodel.Illumination = 742.81*13.68/100;
|
||||
//其它
|
||||
bmodel.Other = 111;
|
||||
bmodel.Other = 742.81*(35.71+7.61)/100;
|
||||
blist.Add(bmodel);
|
||||
model.list = blist;
|
||||
data.Add(model);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
using DataServer.api;
|
||||
using DataServer.Model;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
|
@ -21,51 +23,99 @@ namespace DongYingAPI.Controllers.api
|
|||
public HttpResponseMessage Get(string type = "")
|
||||
{
|
||||
var res = new get_cell_ranking();
|
||||
#region 表是否存在
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
//今月的表是否存在
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var a1 = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a1 == false)
|
||||
{
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
#endregion
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(type))
|
||||
{
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var data=new List<cell_rankingData>();
|
||||
if (type == "配电室1")
|
||||
{
|
||||
var data = new List<cell_rankingData>();
|
||||
var now = DateTime.Now;
|
||||
var sdate = now.ToString("yyyy-MM-dd 00:00:00");
|
||||
var edate = now.AddDays(1).ToString("yyyy-MM-dd 00:00:00");
|
||||
//今天
|
||||
var ztime = now.ToString("yyyy-MM-dd HH:00:00");
|
||||
//上天
|
||||
var stime = now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var atime = now.AddDays(-1).ToString("yyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + atime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(atime);
|
||||
}
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "科技馆一楼").ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var alist = bll.GetModelListDate("", time).Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
//今天
|
||||
var alist = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
var model = new cell_rankingData();
|
||||
decimal? num1 = 0;
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
model.CellName = item.DeviceName;
|
||||
model.EH = aitem.EH;
|
||||
num1 = aitem.EH;
|
||||
}
|
||||
//上天
|
||||
var blist = bll.GetModelListDate("", atime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in blist)
|
||||
{
|
||||
model.CellName = item.DeviceName;
|
||||
num2 = aitem.EH;
|
||||
}
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
var elist=data.OrderByDescending(x=>x.EH).ToList();
|
||||
var elist = data.OrderByDescending(x => x.EH).ToList();
|
||||
res.code = 200;
|
||||
res.msg = "成功";
|
||||
res.data = elist;
|
||||
}
|
||||
else if (type == "配电室2")
|
||||
{
|
||||
var data = new List<cell_rankingData>();
|
||||
//科技馆负一层地源热泵
|
||||
var now = DateTime.Now;
|
||||
var sdate = now.ToString("yyyy-MM-dd 00:00:00");
|
||||
var edate = now.AddDays(1).ToString("yyyy-MM-dd 00:00:00");
|
||||
//今天
|
||||
var ztime = now.ToString("yyyy-MM-dd HH:00:00");
|
||||
//上天
|
||||
var stime = now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var atime = now.AddDays(-1).ToString("yyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + atime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(atime);
|
||||
}
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "科技馆负一层地源热泵").ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var alist = bll.GetModelListDate("", time).Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
//今天
|
||||
var alist = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
var model = new cell_rankingData();
|
||||
decimal? num1 = 0;
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
model.CellName = item.DeviceName;
|
||||
model.EH = aitem.EH;
|
||||
num1 = aitem.EH;
|
||||
}
|
||||
//上天
|
||||
var blist = bll.GetModelListDate("", atime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in blist)
|
||||
{
|
||||
model.CellName = item.DeviceName;
|
||||
num2 = aitem.EH;
|
||||
}
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
|
|
@ -76,22 +126,40 @@ namespace DongYingAPI.Controllers.api
|
|||
}
|
||||
else if (type == "配电室3")
|
||||
{
|
||||
var data = new List<cell_rankingData>();
|
||||
//图书馆一楼
|
||||
var now = DateTime.Now;
|
||||
var sdate = now.ToString("yyyy-MM-dd 00:00:00");
|
||||
var edate = now.AddDays(1).ToString("yyyy-MM-dd 00:00:00");
|
||||
//今天
|
||||
var ztime = now.ToString("yyyy-MM-dd HH:00:00");
|
||||
//上天
|
||||
var stime = now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var atime = now.AddDays(-1).ToString("yyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + atime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(atime);
|
||||
}
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "图书馆一楼").ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var alist = bll.GetModelListDate("", time).Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
//今天
|
||||
var alist = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
var model = new cell_rankingData();
|
||||
decimal? num1 = 0;
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
model.CellName = item.DeviceName;
|
||||
model.EH = aitem.EH;
|
||||
num1 = aitem.EH;
|
||||
}
|
||||
//上天
|
||||
var blist = bll.GetModelListDate("", atime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in blist)
|
||||
{
|
||||
model.CellName = item.DeviceName;
|
||||
num2 = aitem.EH;
|
||||
}
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
var elist = data.OrderByDescending(x => x.EH).ToList();
|
||||
res.code = 200;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace DongYingAPI.Controllers.api
|
|||
var res = new get_power_load();
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(date)||!string.IsNullOrEmpty(type))
|
||||
if (!string.IsNullOrEmpty(date)&&!string.IsNullOrEmpty(type))
|
||||
{
|
||||
if (type == "配电室1")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
|
@ -24,33 +25,56 @@ namespace DongYingAPI.Controllers.api
|
|||
{
|
||||
var data = new List<daily_electricityData>();
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var stime = DateTime.Now.AddDays(-1).ToString("yyyyMM");
|
||||
#region 表是否存在
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
//今月的表是否存在
|
||||
var a1 = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a1 == false)
|
||||
{
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
//上月
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (a1 == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
#endregion
|
||||
//今天
|
||||
var sdate = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
//昨天
|
||||
var edate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
//前天
|
||||
var qdate=DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
|
||||
//今天列表
|
||||
var list1=bll.GetModelListDate("",time).Where(x=>x.EntireTime==Convert.ToDateTime(sdate)).ToList();
|
||||
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "科技馆负一层地源热泵").ToList();
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
decimal? num3 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
//今天列表
|
||||
var list1 = bll.GetModelListDate("", time).Where(x =>x.DeviceId==aitem.DeviceId&& x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
foreach (var item in list1)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
//昨天列表
|
||||
var list2 = bll.GetModelListDate("", time).Where(x => x.EntireTime == Convert.ToDateTime(edate)).ToList();
|
||||
decimal? num2 = 0;
|
||||
var list2 = bll.GetModelListDate("", stime).Where(x =>x.DeviceId==aitem.DeviceId&& x.EntireTime == Convert.ToDateTime(edate)).ToList();
|
||||
foreach (var item in list2)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
//前天列表
|
||||
var list3 = bll.GetModelListDate("", time).Where(x => x.EntireTime == Convert.ToDateTime(qdate)).ToList();
|
||||
decimal? num3 = 0;
|
||||
var list3 = bll.GetModelListDate("", stime).Where(x =>x.DeviceId==aitem.DeviceId&& x.EntireTime == Convert.ToDateTime(qdate)).ToList();
|
||||
foreach (var item in list3)
|
||||
{
|
||||
num3 += item.EH;
|
||||
}
|
||||
}
|
||||
|
||||
var model = new daily_electricityData();
|
||||
model.CurrentDate = num1 - num2;
|
||||
model.YesterDay=num2- num3;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ using System.Web.Http;
|
|||
|
||||
namespace DongYingAPI.Controllers.api
|
||||
{
|
||||
/// <summary>
|
||||
/// 照明-设备详情
|
||||
/// </summary>
|
||||
public class GetDeviceDetailsController : ApiController
|
||||
{
|
||||
DataServer.BLL.electricity_data bll = new DataServer.BLL.electricity_data();
|
||||
|
|
@ -39,7 +42,7 @@ namespace DongYingAPI.Controllers.api
|
|||
{
|
||||
var model=new device_detailsData();
|
||||
model.DeviceName = item.DeviceName;
|
||||
model.DeviceState = "正常";
|
||||
model.DeviceState = 1;
|
||||
var sdate = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
|
||||
var edate = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var alist = bll.GetModelListDate("", time).Where(x =>x.DeviceId==item.DeviceId&& x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate));
|
||||
|
|
|
|||
|
|
@ -13,14 +13,17 @@ namespace DongYingAPI.Controllers.api
|
|||
{
|
||||
public class GetDeviceParameterController : ApiController
|
||||
{
|
||||
/// <summary>
|
||||
/// 空调-设备参数
|
||||
/// </summary>
|
||||
DataServer.BLL.device_info bll_info = new DataServer.BLL.device_info();
|
||||
public HttpResponseMessage Get(string date = "")
|
||||
public HttpResponseMessage Get()
|
||||
{
|
||||
var res = new get_device_parameter();
|
||||
try
|
||||
{
|
||||
var data = new List<device_parameterData>();
|
||||
var list = bll_info.GetModelList("");
|
||||
var list = bll_info.GetModelList("").Where(x=>x.FloorName== "科技馆负一层地源热泵").ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var model = new device_parameterData();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
|
@ -24,22 +25,45 @@ namespace DongYingAPI.Controllers.api
|
|||
try
|
||||
{
|
||||
var data = new List<electrical_rankingData>();
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
#region 日期
|
||||
//今天
|
||||
var now = DateTime.Now;
|
||||
var sdate = Convert.ToDateTime(now.ToString("yyyy-MM-dd 00:00:00"));
|
||||
var edate = Convert.ToDateTime(now.AddDays(+1).ToString("yyyy-MM-dd 00:00:00"));
|
||||
var list = bll.GetModelListDate("",time).Where(x => x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
var jdate = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
var jtime = now.ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
//昨天
|
||||
var zdate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var ztime = now.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + ztime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(ztime);
|
||||
}
|
||||
#endregion
|
||||
var alist = bll_info.GetModelList("");
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in alist)
|
||||
{
|
||||
var model = new electrical_rankingData();
|
||||
foreach (var aitem in alist)
|
||||
model.ElectricaName = item.DeviceName;
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x =>x.DeviceId==item.DeviceId&& x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var zlist = bll.GetModelListDate("", ztime).Where(x =>x.DeviceId==item.DeviceId&& x.EntireTime == Convert.ToDateTime(zdate)).ToList();
|
||||
foreach (var aitem in jlist)
|
||||
{
|
||||
model.ElectricaName = aitem.DeviceName;
|
||||
num = aitem.EH;
|
||||
}
|
||||
num = item.EH;
|
||||
model.ElectricaValue = num;
|
||||
foreach (var aitem in zlist)
|
||||
{
|
||||
num1 = aitem.EH;
|
||||
}
|
||||
model.ElectricaValue = num-num1;
|
||||
data.Add(model);
|
||||
}
|
||||
var elist = data.OrderByDescending(x => x.ElectricaValue).ToList();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
|
@ -21,70 +22,93 @@ namespace DongYingAPI.Controllers.api
|
|||
public HttpResponseMessage Get( string date = "")
|
||||
{
|
||||
var res = new get_electric_quantity();
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(date))
|
||||
{
|
||||
var data = new List<electric_quantityData>();
|
||||
var list = bll_info.GetModelList("");
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var now = DateTime.Now;
|
||||
if (date == "日")
|
||||
{
|
||||
|
||||
var a = DateTime.Now.ToString("mm");
|
||||
var b = 0;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new electric_quantityData();
|
||||
|
||||
var j = i * 60;
|
||||
b = Convert.ToInt32(a);
|
||||
string now = "";
|
||||
model.time = DateTime.Now.AddMinutes(-j).ToString("HH:00");
|
||||
now = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
a = "31";
|
||||
var datetime = Convert.ToDateTime(now);
|
||||
var sdate = datetime.AddHours(-i);
|
||||
var edate = datetime.AddHours(-i + 1);
|
||||
//var list1 = bll_info.GetModelList("").Where(x =>x.DeviceName.Contains("空调")&& x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
var jdate = now.AddHours(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
var jtime = now.AddHours(-i).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddHours(-(i + 1)).ToString("yyyy-MM-dd HH:00:00");
|
||||
var stime = now.AddHours(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in list)
|
||||
decimal? num2 = 0;
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
foreach (var aitem in list1)
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num1 += aitem.EH;
|
||||
num2 += item.EH;
|
||||
}
|
||||
|
||||
}
|
||||
model.EH = num1;
|
||||
var model = new electric_quantityData(); ;
|
||||
model.time = DateTime.Now.AddHours(-i).ToString("HH:00");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (date == "月")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new electric_quantityData();
|
||||
var atime = DateTime.Now.AddDays(-i).ToString("dd号");
|
||||
model.time = atime;
|
||||
var now = DateTime.Now.AddMonths(-i);
|
||||
var sdate = now.ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
var edate = now.AddMonths(+1).ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
string jdate;
|
||||
if (i == 0)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
var alist = list1.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
|
||||
foreach (var aitem in alist)
|
||||
jdate = now.AddDays(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
}
|
||||
else
|
||||
{
|
||||
num += aitem.EH;
|
||||
jdate = now.AddDays(-i).ToString("yyyy-MM-dd 00:00:00");
|
||||
}
|
||||
model.EH = num;
|
||||
|
||||
var jtime = now.AddDays(-i).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddDays(-(i + 1)).ToString("yyyy-MM-dd 00:00:00");
|
||||
var stime = now.AddDays(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
var model = new electric_quantityData(); ;
|
||||
model.time = DateTime.Now.AddDays(-i).ToString("dd号");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
|
|
@ -92,24 +116,48 @@ namespace DongYingAPI.Controllers.api
|
|||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new electric_quantityData();
|
||||
var atime = DateTime.Now.AddMonths(-i).ToString("MM月");
|
||||
model.time = atime;
|
||||
var now = DateTime.Now.AddYears(-i);
|
||||
var sdate = now.ToString("yyyy-MM") + "-01 00:00:00";
|
||||
var edate = now.AddYears(+1).ToString("yyyy-MM") + "-01 00:00:00";
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
DateTime jdate;
|
||||
if (i == 0)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
var alist = list1.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
foreach (var aitem in alist)
|
||||
var jdate1 = now.AddMonths(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
jdate = Convert.ToDateTime(jdate1);
|
||||
}
|
||||
else
|
||||
{
|
||||
num += aitem.EH;
|
||||
var jdate1 = now.AddMonths(-i + 1).ToString("yyyy-MM-01 00:00:00");
|
||||
var jdate2 = Convert.ToDateTime(jdate1);
|
||||
jdate = jdate2.AddDays(-i);
|
||||
}
|
||||
model.EH = num;
|
||||
|
||||
var jtime = jdate.ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate1 = now.AddMonths(-(i)).ToString("yyyy-MM-01 00:00:00");
|
||||
var sdate2 = Convert.ToDateTime(sdate1);
|
||||
var sdate = sdate2.AddDays(-1);
|
||||
var stime = sdate.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
var model = new electric_quantityData(); ;
|
||||
model.time = jdate.ToString("MM月");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,240 +6,232 @@ using System.Configuration;
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace DongYingAPI.Controllers.api
|
||||
{
|
||||
/// <summary>
|
||||
/// 用电情况
|
||||
/// 空调-用电情况
|
||||
/// </summary>
|
||||
public class GetElectricalConditionController : ApiController
|
||||
{
|
||||
DataServer.BLL.electricity_data bll = new DataServer.BLL.electricity_data();
|
||||
DataServer.BLL.device_info bll_info = new DataServer.BLL.device_info();
|
||||
public HttpResponseMessage Get(string date="")
|
||||
public HttpResponseMessage Get()
|
||||
{
|
||||
var res = new get_electrical_condition();
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
try
|
||||
{
|
||||
var data = new List<electrical_conditionData>();
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
#region 表是否存在
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
//今月的表是否存在
|
||||
var jtime = DateTime.Now.ToString("yyyyMM");
|
||||
var a1 = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a1 == false)
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "科技馆负一层地源热泵").ToList();
|
||||
#region 天
|
||||
//今天
|
||||
var now = DateTime.Now;
|
||||
var jdate = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
var jtime = now.ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
//昨月的表是否存在
|
||||
var ztime = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + ztime);
|
||||
if (a == false)
|
||||
//昨天
|
||||
var zdate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var ztime = now.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + ztime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(ztime);
|
||||
}
|
||||
//前月的表是否存在
|
||||
var qtime = DateTime.Now.AddMonths(-2).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + qtime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(qtime);
|
||||
}
|
||||
//昨年的表是否存在
|
||||
var zntime = DateTime.Now.AddYears(-1).ToString("yyyy12");
|
||||
var an = bll.IsExistsTable(date_base, "electricity_data_" + zntime);
|
||||
if (an == false)
|
||||
{
|
||||
bll.CreateTable(zntime);
|
||||
}
|
||||
//前年的表是否存在
|
||||
var qntime = DateTime.Now.AddYears(-2).ToString("yyyy12");
|
||||
var bn = bll.IsExistsTable(date_base, "electricity_data_" + qntime);
|
||||
if (bn == false)
|
||||
{
|
||||
bll.CreateTable(qntime);
|
||||
}
|
||||
#endregion
|
||||
#region 判断
|
||||
//if (date == "日")
|
||||
//{
|
||||
// //今天
|
||||
// var sdate = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
// //昨天
|
||||
// var edate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
// //前天
|
||||
// var qdate = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
|
||||
// //今天列表
|
||||
// var list1 = bll.GetModelListDate("", time).Where(x => x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
// decimal? num1 = 0;
|
||||
// foreach (var item in list1)
|
||||
// {
|
||||
// num1 += item.EH;
|
||||
// }
|
||||
// //昨天列表
|
||||
// var list2 = bll.GetModelListDate("", time).Where(x => x.EntireTime == Convert.ToDateTime(edate)).ToList();
|
||||
// decimal? num2 = 0;
|
||||
// foreach (var item in list2)
|
||||
// {
|
||||
// num2 += item.EH;
|
||||
// }
|
||||
// //前天列表
|
||||
// var list3 = bll.GetModelListDate("", time).Where(x => x.EntireTime == Convert.ToDateTime(qdate)).ToList();
|
||||
// decimal? num3 = 0;
|
||||
// foreach (var item in list3)
|
||||
// {
|
||||
// num3 += item.EH;
|
||||
// }
|
||||
// var model = new electrical_conditionData();
|
||||
// model.ToDay = num1 - num2;
|
||||
// model.YearDay = num2 - num3;
|
||||
// if (model.YearDay == 0)
|
||||
// {
|
||||
// model.TenDency = 100;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// model.TenDency = model.ToDay / model.YearDay * 100;
|
||||
// }
|
||||
// data.Add(model);
|
||||
//}
|
||||
//else if (date == "月")
|
||||
//{
|
||||
|
||||
// //今月
|
||||
// var sdate = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
// //昨月
|
||||
// var edate = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-31 00:00:00");
|
||||
// //前月
|
||||
// var qdate = DateTime.Now.AddMonths(-2).ToString("yyyy-MM-31 00:00:00");
|
||||
|
||||
|
||||
// //今天列表
|
||||
// var list1 = bll.GetModelListDate("", time).Where(x => x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
// decimal? num1 = 0;
|
||||
// foreach (var item in list1)
|
||||
// {
|
||||
// num1 += item.EH;
|
||||
// }
|
||||
// //昨月列表
|
||||
// var list2 = bll.GetModelListDate("", ztime).Where(x => x.EntireTime == Convert.ToDateTime(edate)).ToList();
|
||||
// decimal? num2 = 0;
|
||||
// foreach (var item in list2)
|
||||
// {
|
||||
// num2 += item.EH;
|
||||
// }
|
||||
// //前天列表
|
||||
// var list3 = bll.GetModelListDate("", qtime).Where(x => x.EntireTime == Convert.ToDateTime(qdate)).ToList();
|
||||
// decimal? num3 = 0;
|
||||
// foreach (var item in list3)
|
||||
// {
|
||||
// num3 += item.EH;
|
||||
// }
|
||||
// var model = new electrical_conditionData();
|
||||
// model.ToDay = num1 - num2;
|
||||
// model.YearDay = num2 - num3;
|
||||
// if (model.YearDay == 0)
|
||||
// {
|
||||
// model.TenDency = 100;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// model.TenDency = model.ToDay / model.YearDay * 100;
|
||||
// }
|
||||
|
||||
// data.Add(model);
|
||||
//}
|
||||
//else if (date == "年")
|
||||
//{
|
||||
// //今年
|
||||
// var sdate = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
// //昨年
|
||||
// var edate = DateTime.Now.AddYears(-1).ToString("yyyy-MM-31 00:00:00");
|
||||
// //前年
|
||||
// var qdate = DateTime.Now.AddYears(-2).ToString("yyyy-MM-31 00:00:00");
|
||||
|
||||
// //今天列表
|
||||
// var list1 = bll.GetModelListDate("", time).Where(x => x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
// decimal? num1 = 0;
|
||||
// foreach (var item in list1)
|
||||
// {
|
||||
// num1 += item.EH;
|
||||
// }
|
||||
// //昨月列表
|
||||
// var list2 = bll.GetModelListDate("", ztime).Where(x => x.EntireTime == Convert.ToDateTime(edate)).ToList();
|
||||
// decimal? num2 = 0;
|
||||
// foreach (var item in list2)
|
||||
// {
|
||||
// num2 += item.EH;
|
||||
// }
|
||||
// //前天列表
|
||||
// var list3 = bll.GetModelListDate("", qtime).Where(x => x.EntireTime == Convert.ToDateTime(qdate)).ToList();
|
||||
// decimal? num3 = 0;
|
||||
// foreach (var item in list3)
|
||||
// {
|
||||
// num3 += item.EH;
|
||||
// }
|
||||
// var model = new electrical_conditionData();
|
||||
// model.ToDay = num1 - num2;
|
||||
// model.YearDay = num2 - num3;
|
||||
// if (model.YearDay == 0)
|
||||
// {
|
||||
// model.TenDency = 100;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// model.TenDency = model.ToDay / model.YearDay * 100;
|
||||
// }
|
||||
// data.Add(model);
|
||||
//}
|
||||
#endregion
|
||||
//今天
|
||||
var now = DateTime.Now;
|
||||
var sdate = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
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 edate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
//前天
|
||||
var qdate = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd 00:00:00");
|
||||
//今天列表
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
decimal? num3 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
//今天列表
|
||||
var list1 = bll.GetModelListDate("", jtime).Where(x =>x.DeviceId==aitem.DeviceId&& x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
foreach (var item in list1)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
//昨天列表
|
||||
var list2 = bll.GetModelListDate("", time).Where(x => x.EntireTime == Convert.ToDateTime(edate)).ToList();
|
||||
decimal? num2 = 0;
|
||||
var list2 = bll.GetModelListDate("", ztime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(zdate)).ToList();
|
||||
foreach (var item in list2)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
//前天列表
|
||||
var list3 = bll.GetModelListDate("", time).Where(x => x.EntireTime == Convert.ToDateTime(qdate)).ToList();
|
||||
decimal? num3 = 0;
|
||||
var list3 = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(qdate)).ToList();
|
||||
foreach (var item in list3)
|
||||
{
|
||||
num3 += item.EH;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region 月
|
||||
//今月
|
||||
var jmdate = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
var jmtime = now.ToString("yyyyMM");
|
||||
var am = bll.IsExistsTable(date_base, "electricity_data_" + jmtime);
|
||||
if (am == false)
|
||||
{
|
||||
bll.CreateTable(jmtime);
|
||||
}
|
||||
//昨月
|
||||
var zmdate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-01 00:00:00");
|
||||
var zmtime = now.ToString("yyyyMM");
|
||||
var bm = bll.IsExistsTable(date_base, "electricity_data_" + zmtime);
|
||||
if (bm == false)
|
||||
{
|
||||
bll.CreateTable(zmtime);
|
||||
}
|
||||
//前月
|
||||
var qmdate1 = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-01 00:00:00");
|
||||
var qmdate2=Convert.ToDateTime(qmdate1);
|
||||
var qmdate = qmdate2.AddDays(-1);
|
||||
var qmtime = qmdate.ToString("yyyyMM");
|
||||
var qm = bll.IsExistsTable(date_base, "electricity_data_" + qmtime);
|
||||
if (qm == false)
|
||||
{
|
||||
bll.CreateTable(qmtime);
|
||||
}
|
||||
decimal? mnum1 = 0;
|
||||
decimal? mnum2 = 0;
|
||||
decimal? mnum3 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
//今月列表
|
||||
var mlist1 = bll.GetModelListDate("", jmtime).Where(x =>x.DeviceId==aitem.DeviceId&& x.EntireTime == Convert.ToDateTime(jmdate)).ToList();
|
||||
foreach (var item in mlist1)
|
||||
{
|
||||
mnum1 += item.EH;
|
||||
}
|
||||
//昨月列表
|
||||
var mlist2 = bll.GetModelListDate("", zmtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(zmdate)).ToList();
|
||||
foreach (var item in mlist2)
|
||||
{
|
||||
mnum2 += item.EH;
|
||||
}
|
||||
//前月列表
|
||||
var mlist3 = bll.GetModelListDate("", jmtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(qmdate)).ToList();
|
||||
foreach (var item in mlist3)
|
||||
{
|
||||
mnum3 += item.EH;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region 年
|
||||
//今年
|
||||
var jydate = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
var jytime = now.ToString("yyyyMM");
|
||||
var ay = bll.IsExistsTable(date_base, "electricity_data_" + jytime);
|
||||
if (ay == false)
|
||||
{
|
||||
bll.CreateTable(jmtime);
|
||||
}
|
||||
//昨年
|
||||
var zydate = DateTime.Now.AddYears(-1).ToString("yyyy-12-31 00:00:00");
|
||||
var zytime = DateTime.Now.AddYears(-1).ToString("yyyy12");
|
||||
var by = bll.IsExistsTable(date_base, "electricity_data_" + zytime);
|
||||
if (by == false)
|
||||
{
|
||||
bll.CreateTable(zytime);
|
||||
}
|
||||
//前年
|
||||
var qydate1 = DateTime.Now.AddYears(-2).ToString("yyyy-12-31 00:00:00");
|
||||
var qydate = Convert.ToDateTime(qydate1);
|
||||
var qytime = qmdate.ToString("yyyyMM");
|
||||
var qy = bll.IsExistsTable(date_base, "electricity_data_" + qytime);
|
||||
if (qy == false)
|
||||
{
|
||||
bll.CreateTable(qytime);
|
||||
}
|
||||
decimal? ynum1 = 0;
|
||||
decimal? ynum2 = 0;
|
||||
decimal? ynum3 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
//今年列表
|
||||
var ylist1 = bll.GetModelListDate("", jytime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(jydate)).ToList();
|
||||
foreach (var item in ylist1)
|
||||
{
|
||||
ynum1 += item.EH;
|
||||
}
|
||||
//昨年列表
|
||||
var ylist2 = bll.GetModelListDate("", zytime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(zydate)).ToList();
|
||||
foreach (var item in ylist2)
|
||||
{
|
||||
ynum2 += item.EH;
|
||||
}
|
||||
//前年列表
|
||||
var ylist3 = bll.GetModelListDate("", qytime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(qydate)).ToList();
|
||||
foreach (var item in ylist3)
|
||||
{
|
||||
ynum3 += item.EH;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
var model = new electrical_conditionData();
|
||||
model.ToDay = num1 - num2;
|
||||
model.YearDay = num2 - num3;
|
||||
model.ThisMonth = mnum1 - mnum2;
|
||||
model.LastMonth = mnum2 - mnum3;
|
||||
model.ThisYear= ynum1 - ynum2;
|
||||
model.LastYear= ynum2 - ynum3;
|
||||
if (model.YearDay == 0)
|
||||
{
|
||||
model.TenDency = 100;
|
||||
model.DayDency = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.TenDency = model.ToDay / model.YearDay * 100;
|
||||
model.DayDency = model.ToDay /model.YearDay * 100;
|
||||
if (model.DayDency < 0)
|
||||
{
|
||||
model.DayDency = model.DayDency * -1;
|
||||
}
|
||||
if (model.ToDay < model.DayDency)
|
||||
{
|
||||
model.DayDency = model.DayDency;
|
||||
}
|
||||
}
|
||||
if (model.LastMonth == 0)
|
||||
{
|
||||
model.MonthDency = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.MonthDency = model.ToDay / model.YearDay * 100;
|
||||
if (model.DayDency < 0)
|
||||
{
|
||||
model.DayDency = model.DayDency * -1;
|
||||
}
|
||||
if (model.ThisMonth < model.LastMonth)
|
||||
{
|
||||
model.DayDency = model.DayDency;
|
||||
}
|
||||
}
|
||||
if (model.LastYear == 0)
|
||||
{
|
||||
model.YearDency = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.YearDency = model.ToDay / model.YearDay * 100;
|
||||
if (model.DayDency < 0)
|
||||
{
|
||||
model.DayDency = model.DayDency * -1;
|
||||
}
|
||||
if (model.ThisYear < model.LastYear)
|
||||
{
|
||||
model.DayDency = model.DayDency;
|
||||
}
|
||||
}
|
||||
data.Add(model);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using Microsoft.Ajax.Utilities;
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
|
@ -22,54 +23,94 @@ namespace DongYingAPI.Controllers.api
|
|||
public HttpResponseMessage Get()
|
||||
{
|
||||
var res = new get_electrical_ranking();
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
try
|
||||
{
|
||||
var data = new List<electrical_rankingData>();
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
#region 日期
|
||||
//今天
|
||||
var now = DateTime.Now;
|
||||
var sdate = Convert.ToDateTime(now.ToString("yyyy-MM-dd 00:00:00"));
|
||||
var edate = Convert.ToDateTime(now.AddDays(+1).ToString("yyyy-MM-dd 00:00:00"));
|
||||
|
||||
var jdate = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
var jtime = now.ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
//昨天
|
||||
var zdate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var ztime = now.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + ztime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(ztime);
|
||||
}
|
||||
#endregion
|
||||
var alist = bll_info.GetModelList("").Where(x => x.DeviceName.Contains("空调")).ToList();
|
||||
var model1 = new electrical_rankingData();
|
||||
decimal? num = 0;
|
||||
decimal? anum = 0;
|
||||
foreach (var item in alist)
|
||||
{
|
||||
var list = bll.GetModelListDate("", time).Where(x =>x.DeviceId==item.DeviceId&& x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
//今天
|
||||
var list = bll.GetModelListDate("", jtime).Where(x =>x.DeviceId==item.DeviceId&& x.EntireTime==Convert.ToDateTime(jdate)).ToList();
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
num += aitem.P;
|
||||
num += aitem.EH;
|
||||
}
|
||||
//昨天
|
||||
var zlist = bll.GetModelListDate("", ztime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(zdate)).ToList();
|
||||
foreach (var aitem in zlist)
|
||||
{
|
||||
anum += aitem.EH;
|
||||
}
|
||||
}
|
||||
model1.ElectricaValue = num;
|
||||
model1.ElectricaValue = num-anum;
|
||||
model1.ElectricaName = "空调系统";
|
||||
data.Add(model1);
|
||||
var blist = bll_info.GetModelList("").Where(x => x.DeviceName.Contains("照明")).ToList();
|
||||
var model2 = new electrical_rankingData();
|
||||
decimal? num1 = 0;
|
||||
decimal? anum1 = 0;
|
||||
foreach (var item in blist)
|
||||
{
|
||||
var list = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
//今天
|
||||
var list = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
num1 += aitem.P;
|
||||
num1 += aitem.EH;
|
||||
}
|
||||
//昨天
|
||||
var zlist = bll.GetModelListDate("", ztime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(zdate)).ToList();
|
||||
foreach (var aitem in zlist)
|
||||
{
|
||||
anum1 += aitem.EH;
|
||||
}
|
||||
}
|
||||
model2.ElectricaValue = num1;
|
||||
model2.ElectricaValue = num1-anum1;
|
||||
model2.ElectricaName = "照明系统";
|
||||
data.Add(model2);
|
||||
var clist = bll_info.GetModelList("").Where(x => x.DeviceName.Contains("电梯")||x.DeviceName.Contains("货梯")).ToList();
|
||||
var model3 = new electrical_rankingData();
|
||||
decimal? num2 = 0;
|
||||
decimal? anum2 = 0;
|
||||
foreach (var item in clist)
|
||||
{
|
||||
var list = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
//今天
|
||||
var list = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
num2 += aitem.P;
|
||||
num2 += aitem.EH;
|
||||
}
|
||||
//昨天
|
||||
var zlist = bll.GetModelListDate("", ztime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(zdate)).ToList();
|
||||
foreach (var aitem in zlist)
|
||||
{
|
||||
anum2 += aitem.EH;
|
||||
}
|
||||
}
|
||||
model3.ElectricaValue = num2;
|
||||
model3.ElectricaValue = num2-anum2;
|
||||
model3.ElectricaName = "电梯系统";
|
||||
data.Add(model3);
|
||||
var elist=data.OrderByDescending(x=>x.ElectricaValue).ToList();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data.Services;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
|
|
@ -22,70 +23,93 @@ namespace DongYingAPI.Controllers
|
|||
public HttpResponseMessage Get(string date="")
|
||||
{
|
||||
var res = new get_electricity_consumption();
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(date))
|
||||
{
|
||||
var data = new List<electricity_consumptionData>();
|
||||
var list = bll_info.GetModelList("");
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var now=DateTime.Now;
|
||||
if (date == "日")
|
||||
{
|
||||
|
||||
var a = DateTime.Now.ToString("mm");
|
||||
var b = 0;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new electricity_consumptionData();
|
||||
|
||||
var j = i * 60;
|
||||
b = Convert.ToInt32(a);
|
||||
string now = "";
|
||||
model.Time = DateTime.Now.AddMinutes(-j).ToString("HH:00");
|
||||
now = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
a = "31";
|
||||
var datetime = Convert.ToDateTime(now);
|
||||
var sdate = datetime.AddHours(-i);
|
||||
var edate = datetime.AddHours(-i + 1);
|
||||
//var list1 = bll_info.GetModelList("").Where(x =>x.DeviceName.Contains("空调")&& x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
var jdate = now.AddHours(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
var jtime = now.AddHours(-i).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddHours(-(i+1)).ToString("yyyy-MM-dd HH:00:00");
|
||||
var stime= now.AddHours(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b== false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist= bll.GetModelListDate("", stime).Where(x => x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in list)
|
||||
decimal? num2 = 0;
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
foreach (var aitem in list1)
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num1 += aitem.EH;
|
||||
num2 += item.EH;
|
||||
}
|
||||
|
||||
}
|
||||
model.EH = num1;
|
||||
var model = new electricity_consumptionData(); ;
|
||||
model.Time = DateTime.Now.AddHours(-i).ToString("HH:00");
|
||||
model.EH=num1-num2;
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (date == "月")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new electricity_consumptionData();
|
||||
var atime = DateTime.Now.AddDays(-i).ToString("dd号");
|
||||
model.Time = atime;
|
||||
var now = DateTime.Now.AddDays(-i);
|
||||
var sdate = now.ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
var edate = now.AddDays(+1).ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
string jdate;
|
||||
if (i == 0)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
var alist = list1.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
|
||||
foreach (var aitem in alist)
|
||||
jdate = now.AddDays(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
}
|
||||
else
|
||||
{
|
||||
num += aitem.EH;
|
||||
jdate = now.AddDays(-i).ToString("yyyy-MM-dd 00:00:00");
|
||||
}
|
||||
model.EH = num;
|
||||
|
||||
var jtime = now.AddDays(-i).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddDays(-(i + 1)).ToString("yyyy-MM-dd 00:00:00");
|
||||
var stime = now.AddDays(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
var model = new electricity_consumptionData(); ;
|
||||
model.Time = DateTime.Now.AddDays(-i).ToString("dd号");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
|
|
@ -93,24 +117,48 @@ namespace DongYingAPI.Controllers
|
|||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new electricity_consumptionData();
|
||||
var atime = DateTime.Now.AddMonths(-i).ToString("MM月");
|
||||
model.Time = atime;
|
||||
var now = DateTime.Now.AddMonths(-i);
|
||||
var sdate = now.ToString("yyyy-MM") + "-01 00:00:00";
|
||||
var edate = now.AddMonths(+1).ToString("yyyy-MM") + "-01 00:00:00";
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
DateTime jdate;
|
||||
if(i == 0)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
var alist = list1.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
foreach (var aitem in alist)
|
||||
var jdate1 = now.AddMonths(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
jdate=Convert.ToDateTime(jdate1);
|
||||
}
|
||||
else
|
||||
{
|
||||
num += aitem.EH;
|
||||
var jdate1 = now.AddMonths(-i+1).ToString("yyyy-MM-01 00:00:00");
|
||||
var jdate2 = Convert.ToDateTime(jdate1);
|
||||
jdate = jdate2.AddDays(-i);
|
||||
}
|
||||
model.EH = num;
|
||||
|
||||
var jtime = jdate.ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate1= now.AddMonths(-(i)).ToString("yyyy-MM-01 00:00:00");
|
||||
var sdate2 = Convert.ToDateTime(sdate1);
|
||||
var sdate = sdate2.AddDays(-1);
|
||||
var stime = sdate.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
var model = new electricity_consumptionData(); ;
|
||||
model.Time = jdate.ToString("MM月");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using DataServer.api;
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
|
@ -21,65 +22,153 @@ namespace DongYingAPI.Controllers.api
|
|||
public HttpResponseMessage Get(string date="")
|
||||
{
|
||||
var res = new get_energy_trend();
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(date))
|
||||
{
|
||||
var data=new List<energy_trendData>();
|
||||
var time=DateTime.Now.ToString("yyyMM");
|
||||
var list = bll.GetModelListDate("", time);
|
||||
#region 用电量
|
||||
//if (date == "日")
|
||||
//{
|
||||
// for (int i = 0; i < 6; i++)
|
||||
// {
|
||||
// //现在的小时
|
||||
// var jdate = DateTime.Now.AddHours(-i).ToString("yyyy-MM-dd HH:00:00:00");
|
||||
// //昨天的小时
|
||||
// var zdate = DateTime.Now.AddHours(-i + 1).ToString("yyyy-MM-dd HH:00:00");
|
||||
// //今天列表
|
||||
// var jlist = list.Where(x => x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
// decimal? num1 = 0;
|
||||
// foreach (var item in jlist)
|
||||
// {
|
||||
// num1 += item.EH;
|
||||
// }
|
||||
// //昨天列表
|
||||
// var zlist = list.Where(x => x.EntireTime == Convert.ToDateTime(zdate)).ToList();
|
||||
// decimal? num2 = 0;
|
||||
// foreach (var item in zlist)
|
||||
// {
|
||||
// num2 += item.EH;
|
||||
// }
|
||||
|
||||
// var model = new energy_trendData();
|
||||
// model.time = DateTime.Now.AddHours(-i).ToString("HH:mm");
|
||||
// model.P = num1 - num2;
|
||||
// data.Add(model);
|
||||
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
DateTime now=DateTime.Now;
|
||||
var list = bll_info.GetModelList("").Where(x=>x.FloorName== "科技馆负一层地源热泵").ToList();
|
||||
if (date == "日")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
//现在的小时
|
||||
var sdate =Convert.ToDateTime(DateTime.Now.AddHours(-i).ToString("yyyy-MM-dd HH:00:00"));
|
||||
//昨天的小时
|
||||
var edate =Convert.ToDateTime(DateTime.Now.AddHours(-i + 1).ToString("yyyy-MM-dd HH:00:00"));
|
||||
//列表
|
||||
var jlist = list.Where(x => x.EntireTime >= sdate&&x.EntireTime<edate).ToList();
|
||||
var jdate = now.AddHours(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
var jtime = now.AddHours(-i).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddHours(-(i + 1)).ToString("yyyy-MM-dd HH:00:00");
|
||||
var stime = now.AddHours(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x =>x.DeviceId==aitem.DeviceId&& x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.P;
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
}
|
||||
var model = new energy_trendData(); ;
|
||||
model.time = DateTime.Now.AddHours(-i).ToString("HH:00");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (date == "月")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
string jdate;
|
||||
if (i == 0)
|
||||
{
|
||||
jdate = now.AddDays(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
}
|
||||
else
|
||||
{
|
||||
jdate = now.AddDays(-i).ToString("yyyy-MM-dd 00:00:00");
|
||||
}
|
||||
var jtime = now.AddDays(-i).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddDays(-(i + 1)).ToString("yyyy-MM-dd 00:00:00");
|
||||
var stime = now.AddDays(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
}
|
||||
var model = new energy_trendData();
|
||||
model.time = DateTime.Now.AddHours(-i).ToString("HH:00");
|
||||
model.P = num1 ;
|
||||
model.time = DateTime.Now.AddDays(-i).ToString("dd号");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
else if (date == "年")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
DateTime jdate;
|
||||
if (i == 0)
|
||||
{
|
||||
var jdate1 = now.AddMonths(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
jdate = Convert.ToDateTime(jdate1);
|
||||
}
|
||||
else
|
||||
{
|
||||
var jdate1 = now.AddMonths(-i + 1).ToString("yyyy-MM-01 00:00:00");
|
||||
var jdate2 = Convert.ToDateTime(jdate1);
|
||||
jdate = jdate2.AddDays(-i);
|
||||
}
|
||||
var jtime = jdate.ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate1 = now.AddMonths(-(i)).ToString("yyyy-MM-01 00:00:00");
|
||||
var sdate2 = Convert.ToDateTime(sdate1);
|
||||
var sdate = sdate2.AddDays(-1);
|
||||
var stime = sdate.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
}
|
||||
var model = new energy_trendData();
|
||||
model.time = jdate.ToString("MM月");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
}
|
||||
res.code = 200;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
|
@ -23,105 +24,170 @@ namespace DongYingAPI.Controllers.api
|
|||
public HttpResponseMessage Get(string type = "")
|
||||
{
|
||||
var res = new get_equipment_monitoring();
|
||||
#region 表是否存在
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
//今月的表是否存在
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var a1 = bll.IsExistsTable(date_base, "electricity_data_" + time);
|
||||
if (a1 == false)
|
||||
{
|
||||
bll.CreateTable(time);
|
||||
}
|
||||
#endregion
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(type))
|
||||
{
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var data=new List<equipment_monitoringData>();
|
||||
if (type == "配电室1")
|
||||
{
|
||||
var data = new List<equipment_monitoringData>();
|
||||
var count = 0;
|
||||
var now=DateTime.Now;
|
||||
var sdate = now.ToString("yyyy-MM-dd 00:00:00");
|
||||
var edate = now.AddDays(1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var now = DateTime.Now;
|
||||
//今天
|
||||
var ztime = now.ToString("yyyy-MM-dd HH:00:00");
|
||||
//上天
|
||||
var stime = now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var atime = now.AddDays(-1).ToString("yyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + atime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(atime);
|
||||
}
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "科技馆一楼").ToList();
|
||||
var count = 0;
|
||||
foreach (var item in list)
|
||||
{
|
||||
var alist = bll.GetModelListDate("", time).Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
var model=new equipment_monitoringData();
|
||||
count++;
|
||||
//今天
|
||||
var alist = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
var model = new equipment_monitoringData();
|
||||
model.SerialNumber = count;
|
||||
decimal? num1 = 0;
|
||||
model.DeviceName=item.DeviceName;
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
model.EH = aitem.EH;
|
||||
// model.CellName = item.DeviceName;
|
||||
num1 = aitem.EH;
|
||||
}
|
||||
if (model.EH > 0)
|
||||
//上天
|
||||
var blist = bll.GetModelListDate("", atime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in blist)
|
||||
{
|
||||
model.DeviceState = "正常";
|
||||
// model.CellName = item.DeviceName;
|
||||
num2 = aitem.EH;
|
||||
}
|
||||
else
|
||||
model.EH = num1 - num2;
|
||||
if(model.EH == 0)
|
||||
{
|
||||
model.DeviceState = "异常";
|
||||
}
|
||||
data.Add(model);
|
||||
else
|
||||
{
|
||||
model.DeviceState = "正常";
|
||||
}
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
res.code = 200;
|
||||
res.msg = "成功";
|
||||
res.data = data;
|
||||
}
|
||||
else if (type == "配电室2")
|
||||
{
|
||||
var data = new List<equipment_monitoringData>();
|
||||
var count = 0;
|
||||
//科技馆负一层地源热泵
|
||||
var now = DateTime.Now;
|
||||
var sdate = now.ToString("yyyy-MM-dd 00:00:00");
|
||||
var edate = now.AddDays(1).ToString("yyyy-MM-dd 00:00:00");
|
||||
//今天
|
||||
var ztime = now.ToString("yyyy-MM-dd HH:00:00");
|
||||
//上天
|
||||
var stime = now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var atime = now.AddDays(-1).ToString("yyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + atime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(atime);
|
||||
}
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "科技馆负一层地源热泵").ToList();
|
||||
var count = 0;
|
||||
foreach (var item in list)
|
||||
{
|
||||
var alist = bll.GetModelListDate("", time).Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
var model = new equipment_monitoringData();
|
||||
count++;
|
||||
model.SerialNumber = count;
|
||||
model.DeviceName = item.DeviceName;
|
||||
//今天
|
||||
var alist = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
var model = new equipment_monitoringData();
|
||||
decimal? num1 = 0;
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
model.EH = aitem.EH;
|
||||
num1 = aitem.EH;
|
||||
}
|
||||
if (model.EH > 0)
|
||||
//上天
|
||||
var blist = bll.GetModelListDate("", atime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in blist)
|
||||
{
|
||||
model.DeviceState = "正常";
|
||||
num2 = aitem.EH;
|
||||
}
|
||||
else
|
||||
model.SerialNumber = count;
|
||||
model.DeviceName = item.DeviceName;
|
||||
model.EH = num1 - num2;
|
||||
if(model.EH == 0)
|
||||
{
|
||||
model.DeviceState = "异常";
|
||||
}
|
||||
data.Add(model);
|
||||
else
|
||||
{
|
||||
model.DeviceState = "正常";
|
||||
}
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
res.code = 200;
|
||||
res.msg = "成功";
|
||||
res.data = data;
|
||||
}
|
||||
else if (type == "配电室3")
|
||||
{
|
||||
var data = new List<equipment_monitoringData>();
|
||||
var count = 0;
|
||||
//图书馆一楼
|
||||
var now = DateTime.Now;
|
||||
var sdate = now.ToString("yyyy-MM-dd 00:00:00");
|
||||
var edate = now.AddDays(1).ToString("yyyy-MM-dd 00:00:00");
|
||||
//今天
|
||||
var ztime = now.ToString("yyyy-MM-dd HH:00:00");
|
||||
//上天
|
||||
var stime = now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var atime = now.AddDays(-1).ToString("yyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + atime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(atime);
|
||||
}
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "图书馆一楼").ToList();
|
||||
var count = 0;
|
||||
foreach (var item in list)
|
||||
{
|
||||
var alist = bll.GetModelListDate("", time).Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
//今天
|
||||
var alist = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
var model = new equipment_monitoringData();
|
||||
count++;
|
||||
model.SerialNumber = count;
|
||||
model.DeviceName = item.DeviceName;
|
||||
decimal? num1 = 0;
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
model.EH = aitem.EH;
|
||||
num1 = aitem.EH;
|
||||
}
|
||||
if (model.EH > 0)
|
||||
//上天
|
||||
var blist = bll.GetModelListDate("", atime).Where(x => x.DeviceId == item.DeviceId && x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in blist)
|
||||
{
|
||||
model.DeviceState = "正常";
|
||||
num2 = aitem.EH;
|
||||
}
|
||||
model.SerialNumber = count++;
|
||||
model.DeviceName = item.DeviceName;
|
||||
model.EH = num1 - num2;
|
||||
if (model.EH == 0)
|
||||
{
|
||||
model.DeviceState = "异常";
|
||||
}
|
||||
else
|
||||
{
|
||||
model.DeviceState = "异常";
|
||||
model.DeviceState = "正常";
|
||||
}
|
||||
data.Add(model);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
using DataServer.api;
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 照明-故障情况
|
||||
/// </summary>
|
||||
public class GetFaultConditionController : ApiController
|
||||
{
|
||||
public HttpResponseMessage Get()
|
||||
{
|
||||
var res = new get_fault_condition();
|
||||
try
|
||||
{
|
||||
var data = new List<fault_conditionData>();
|
||||
var model=new fault_conditionData();
|
||||
model.DeviceNumber = 22;
|
||||
model.NormalNumber = 22;
|
||||
model.AbnormalNumber = 0;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
using DataServer.api;
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
///用能监测1-用气量
|
||||
/// </summary>
|
||||
public class GetGasConsumptionController : ApiController
|
||||
{
|
||||
public HttpResponseMessage Get(string date = "")
|
||||
{
|
||||
var res = new get_gas_consumption();
|
||||
try
|
||||
{
|
||||
var data = new List<gas_consumptionData>();
|
||||
if (date == "日")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var time = now.AddHours(-i).ToString("HH:00");
|
||||
var model = new gas_consumptionData();
|
||||
model.time = time;
|
||||
model.GasValue =Math.Round( Convert.ToDecimal(4400.00/12/31/24),3);
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
if (date == "月")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var time = now.AddDays(-i).ToString("dd号");
|
||||
var model = new gas_consumptionData();
|
||||
model.time = time;
|
||||
model.GasValue = 4400 / 12/31;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
if (date == "年")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var time = now.AddMonths(-i).ToString("MM月");
|
||||
var model = new gas_consumptionData();
|
||||
model.time = time;
|
||||
model.GasValue = 4400 / 12 ;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
|
@ -23,49 +24,95 @@ namespace DongYingAPI.Controllers.api
|
|||
public HttpResponseMessage Get(string date="")
|
||||
{
|
||||
var res = new get_general_catalogue();
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(date))
|
||||
{
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var data = new List<general_catalogueData>();
|
||||
var list = bll.GetModelListDate("",time);
|
||||
var data=new List<general_catalogueData>();
|
||||
if (date == "年")
|
||||
{
|
||||
var model=new general_catalogueData();
|
||||
var now=DateTime.Now;
|
||||
var sdate = now.ToString("yyyy-MM-01 00:00:00");
|
||||
var edate=now.AddMonths(1).ToString("yyyy-MM-01 00:00:00");
|
||||
var alist=list.Where(x=>x.EntireTime>=Convert.ToDateTime(sdate)&&x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
decimal? num = 0;
|
||||
foreach (var item in alist)
|
||||
var now = DateTime.Now;
|
||||
DateTime jdate;
|
||||
var jdate1 = now.ToString("yyyy-MM-dd HH:00:00");
|
||||
jdate = Convert.ToDateTime(jdate1);
|
||||
|
||||
var jtime = jdate.ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
num += item.EH;
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
model.TotalRelease=Math.Round(Convert.ToDecimal(num / 1000 * Convert.ToDecimal(0.5703)),3);
|
||||
var sdate1 = now.AddYears(-1).ToString("yyyy-12-31 00:00:00");
|
||||
var sdate = Convert.ToDateTime(sdate1);
|
||||
var stime = sdate.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
var model = new general_catalogueData();
|
||||
model.TotalRelease=Math.Round(Convert.ToDecimal(num1-num2 / 1000 * Convert.ToDecimal(0.5703)),3)+(4400/1000* Convert.ToDecimal(0.5703));
|
||||
model.CarbonOffset = 0;
|
||||
model.CarbonReduction = 1;
|
||||
model.Electricity =Math.Round(Convert.ToDecimal(num / 1000 * Convert.ToDecimal(0.5703)),3);
|
||||
model.NaturalGas = 0;
|
||||
model.CarbonReduction = Convert.ToDecimal(742.81);
|
||||
model.Electricity =Math.Round(Convert.ToDecimal(num1-num2 / 1000 * Convert.ToDecimal(0.5703)),3);
|
||||
model.NaturalGas = 4400 / 1000 * Convert.ToDecimal(0.5703);
|
||||
data.Add(model);
|
||||
|
||||
}
|
||||
else if (date == "月")
|
||||
{
|
||||
var model = new general_catalogueData();
|
||||
var now = DateTime.Now;
|
||||
var sdate = now.ToString("yyyy-MM-dd 00:00:00");
|
||||
var edate = now.AddYears(1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var alist = list.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
decimal? num = 0;
|
||||
foreach (var item in alist)
|
||||
DateTime jdate;
|
||||
var jdate1 = now.ToString("yyyy-MM-dd HH:00:00");
|
||||
jdate = Convert.ToDateTime(jdate1);
|
||||
|
||||
var jtime = jdate.ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
num += item.EH;
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
model.TotalRelease = Math.Round(Convert.ToDecimal(num / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
var sdate1 = now.AddMonths(-1).ToString("yyyy-MM-01 00:00:00");
|
||||
var sdate2 = Convert.ToDateTime(sdate1);
|
||||
var sdate = sdate2.AddDays(-1);
|
||||
var stime = sdate.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
var model = new general_catalogueData();
|
||||
model.TotalRelease = Math.Round(Convert.ToDecimal((num1-num2) / 1000 * Convert.ToDecimal(0.5703)), 3)+Convert.ToDecimal(4400 /12/ 1000 * Convert.ToDecimal(0.5703));
|
||||
model.CarbonOffset = 0;
|
||||
model.CarbonReduction = 333;
|
||||
model.Electricity = Math.Round(Convert.ToDecimal(num / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
model.NaturalGas = 0;
|
||||
model.CarbonReduction = Convert.ToDecimal(742.81)/12;
|
||||
model.Electricity = Math.Round(Convert.ToDecimal((num1-num2) / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
model.NaturalGas =Math.Round((4400/12 / 1000 * Convert.ToDecimal(0.5703)),3);
|
||||
data.Add(model);
|
||||
}
|
||||
res.code = 200;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ using System.Web.Mvc;
|
|||
|
||||
namespace DongYingAPI.Controllers.api
|
||||
{
|
||||
/// <summary>
|
||||
/// 照明-照明负荷
|
||||
/// </summary>
|
||||
public class GetIlluminationLoadController : ApiController
|
||||
{
|
||||
DataServer.BLL.electricity_data bll = new DataServer.BLL.electricity_data();
|
||||
|
|
@ -97,6 +100,14 @@ namespace DongYingAPI.Controllers.api
|
|||
}
|
||||
model.ToDay = num1;
|
||||
model.YearDay = num2;
|
||||
if (model.ToDay > model.YearDay)
|
||||
{
|
||||
model.Tendency = "上升";
|
||||
}
|
||||
else
|
||||
{
|
||||
model.Tendency = "下降";
|
||||
}
|
||||
}
|
||||
data.Add(model);
|
||||
|
||||
|
|
@ -131,7 +142,14 @@ namespace DongYingAPI.Controllers.api
|
|||
}
|
||||
model.ToDay = num;
|
||||
model.YearDay = num2;
|
||||
|
||||
if (model.ToDay > model.YearDay)
|
||||
{
|
||||
model.Tendency = "上升";
|
||||
}
|
||||
else
|
||||
{
|
||||
model.Tendency = "下降";
|
||||
}
|
||||
}
|
||||
data.Add(model);
|
||||
}
|
||||
|
|
@ -177,7 +195,14 @@ namespace DongYingAPI.Controllers.api
|
|||
}
|
||||
model.YearDay = num;
|
||||
}
|
||||
|
||||
if (model.ToDay > model.YearDay)
|
||||
{
|
||||
model.Tendency = "上升";
|
||||
}
|
||||
else
|
||||
{
|
||||
model.Tendency = "下降";
|
||||
}
|
||||
|
||||
}
|
||||
data.Add(model);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
using DataServer.api;
|
||||
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;
|
||||
|
||||
namespace DongYingAPI.Controllers.api
|
||||
{
|
||||
/// <summary>
|
||||
/// 照明-照明策略
|
||||
/// </summary>
|
||||
public class GetLightingStrategyController : ApiController
|
||||
{
|
||||
DataServer.BLL.lighting_strategy bll = new DataServer.BLL.lighting_strategy();
|
||||
public HttpResponseMessage Get()
|
||||
{
|
||||
var res = new get_lighting_strategy();
|
||||
try
|
||||
{
|
||||
var data = new List<lighting_strategyData>();
|
||||
var list = bll.GetModelList("");
|
||||
foreach (var item in list)
|
||||
{
|
||||
var model=new lighting_strategyData();
|
||||
model.StrategyName = item.StrategyName;
|
||||
model.StrategyState = item.StrategyState;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,9 @@ using System.Web.Http;
|
|||
|
||||
namespace DongYingAPI.Controllers.api
|
||||
{
|
||||
/// <summary>
|
||||
/// 空调-气象站
|
||||
/// </summary>
|
||||
public class GetMeteorologicalStationController : ApiController
|
||||
{
|
||||
public HttpResponseMessage Get()
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
|
@ -21,71 +22,104 @@ namespace DongYingAPI.Controllers.api
|
|||
public HttpResponseMessage Get(string type = "", string date = "")
|
||||
{
|
||||
var res = new get_room_electricity();
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(date) || !string.IsNullOrEmpty(type))
|
||||
if (!string.IsNullOrEmpty(date) && !string.IsNullOrEmpty(type))
|
||||
{
|
||||
if (type == "配电室1")
|
||||
{
|
||||
var data = new List<room_electricityData>();
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "科技馆一楼").ToList();
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var now=DateTime.Now;
|
||||
if (date == "日")
|
||||
{
|
||||
|
||||
var a = DateTime.Now.ToString("mm");
|
||||
var b = 0;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new room_electricityData();
|
||||
|
||||
var j = i * 60;
|
||||
b = Convert.ToInt32(a);
|
||||
string now = "";
|
||||
model.time = DateTime.Now.AddMinutes(-j).ToString("HH:00");
|
||||
now = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
a = "31";
|
||||
var datetime = Convert.ToDateTime(now);
|
||||
var sdate = datetime.AddHours(-i);
|
||||
var edate = datetime.AddHours(-i + 1);
|
||||
//var list1 = bll_info.GetModelList("").Where(x =>x.DeviceName.Contains("空调")&& x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
var jdate = now.AddHours(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
var jtime = now.AddHours(-i).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddHours(-(i + 1)).ToString("yyyy-MM-dd HH:00:00");
|
||||
var stime = now.AddHours(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in list)
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num1 += aitem.EH;
|
||||
}
|
||||
model.EH = num1;
|
||||
}
|
||||
data.Add(model);
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x =>x.DeviceId==aitem.DeviceId&& x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
}
|
||||
var model = new room_electricityData(); ;
|
||||
model.time = DateTime.Now.AddHours(-i).ToString("HH:00");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (date == "月")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new room_electricityData();
|
||||
var atime = DateTime.Now.AddDays(-i).ToString("MM月");
|
||||
model.time = atime;
|
||||
var now = DateTime.Now.AddDays(-i);
|
||||
var sdate = now.ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
var edate = now.AddDays(+1).ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
string jdate;
|
||||
if (i == 0)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
var alist = list1.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
|
||||
foreach (var aitem in alist)
|
||||
jdate = now.AddDays(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
}
|
||||
else
|
||||
{
|
||||
num += aitem.EH;
|
||||
jdate = now.AddDays(-i).ToString("yyyy-MM-dd 00:00:00");
|
||||
}
|
||||
model.EH = num;
|
||||
var jtime = now.AddDays(-i).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddDays(-(i + 1)).ToString("yyyy-MM-dd 00:00:00");
|
||||
var stime = now.AddDays(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
}
|
||||
var model = new room_electricityData(); ;
|
||||
model.time = DateTime.Now.AddDays(-i).ToString("dd号");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
|
|
@ -93,24 +127,52 @@ namespace DongYingAPI.Controllers.api
|
|||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new room_electricityData();
|
||||
var atime = DateTime.Now.AddMonths(-i).ToString("MM月");
|
||||
model.time = atime;
|
||||
var now = DateTime.Now.AddYears(-i);
|
||||
var sdate = now.ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
var edate = now.AddYears(+1).ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
DateTime jdate;
|
||||
if (i == 0)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
var alist = list1.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
num += aitem.EH;
|
||||
var jdate1 = now.AddMonths(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
jdate = Convert.ToDateTime(jdate1);
|
||||
}
|
||||
model.EH = num;
|
||||
else
|
||||
{
|
||||
var jdate1 = now.AddMonths(-i + 1).ToString("yyyy-MM-01 00:00:00");
|
||||
var jdate2 = Convert.ToDateTime(jdate1);
|
||||
jdate = jdate2.AddDays(-i);
|
||||
}
|
||||
var jtime = jdate.ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate1 = now.AddMonths(-(i)).ToString("yyyy-MM-01 00:00:00");
|
||||
var sdate2 = Convert.ToDateTime(sdate1);
|
||||
var sdate = sdate2.AddDays(-1);
|
||||
var stime = sdate.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
}
|
||||
var model = new room_electricityData(); ;
|
||||
model.time = jdate.ToString("MM月");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
|
|
@ -122,63 +184,94 @@ namespace DongYingAPI.Controllers.api
|
|||
{
|
||||
var data = new List<room_electricityData>();
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "科技馆负一层地源热泵").ToList();
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var now = DateTime.Now;
|
||||
if (date == "日")
|
||||
{
|
||||
|
||||
var a = DateTime.Now.ToString("mm");
|
||||
var b = 0;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new room_electricityData();
|
||||
|
||||
var j = i * 60;
|
||||
b = Convert.ToInt32(a);
|
||||
string now = "";
|
||||
model.time = DateTime.Now.AddMinutes(-j).ToString("HH:00");
|
||||
now = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
a = "31";
|
||||
var datetime = Convert.ToDateTime(now);
|
||||
var sdate = datetime.AddHours(-i);
|
||||
var edate = datetime.AddHours(-i + 1);
|
||||
//var list1 = bll_info.GetModelList("").Where(x =>x.DeviceName.Contains("空调")&& x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
var jdate = now.AddHours(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
var jtime = now.AddHours(-i).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddHours(-(i + 1)).ToString("yyyy-MM-dd HH:00:00");
|
||||
var stime = now.AddHours(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in list)
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num1 += aitem.EH;
|
||||
}
|
||||
model.EH = num1;
|
||||
}
|
||||
data.Add(model);
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
}
|
||||
var model = new room_electricityData(); ;
|
||||
model.time = DateTime.Now.AddMonths(-i).ToString("HH:00");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (date == "月")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new room_electricityData();
|
||||
var atime = DateTime.Now.AddDays(-i).ToString("MM月");
|
||||
model.time = atime;
|
||||
var now = DateTime.Now.AddDays(-i);
|
||||
var sdate = now.ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
var edate = now.AddDays(+1).ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
string jdate;
|
||||
if (i == 0)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
var alist = list1.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
|
||||
foreach (var aitem in alist)
|
||||
jdate = now.AddDays(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
}
|
||||
else
|
||||
{
|
||||
num += aitem.EH;
|
||||
jdate = now.AddDays(-i).ToString("yyyy-MM-dd 00:00:00");
|
||||
}
|
||||
model.EH = num;
|
||||
var jtime = now.AddDays(-i).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddDays(-(i + 1)).ToString("yyyy-MM-dd 00:00:00");
|
||||
var stime = now.AddDays(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
}
|
||||
var model = new room_electricityData(); ;
|
||||
model.time = DateTime.Now.AddDays(-i).ToString("dd号");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
|
|
@ -186,24 +279,52 @@ namespace DongYingAPI.Controllers.api
|
|||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new room_electricityData();
|
||||
var atime = DateTime.Now.AddMonths(-i).ToString("MM月");
|
||||
model.time = atime;
|
||||
var now = DateTime.Now.AddYears(-i);
|
||||
var sdate = now.ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
var edate = now.AddYears(+1).ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
DateTime jdate;
|
||||
if (i == 0)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
var alist = list1.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
num += aitem.EH;
|
||||
var jdate1 = now.AddMonths(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
jdate = Convert.ToDateTime(jdate1);
|
||||
}
|
||||
model.EH = num;
|
||||
else
|
||||
{
|
||||
var jdate1 = now.AddMonths(-i + 1).ToString("yyyy-MM-01 00:00:00");
|
||||
var jdate2 = Convert.ToDateTime(jdate1);
|
||||
jdate = jdate2.AddDays(-i);
|
||||
}
|
||||
var jtime = jdate.ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate1 = now.AddMonths(-(i)).ToString("yyyy-MM-01 00:00:00");
|
||||
var sdate2 = Convert.ToDateTime(sdate1);
|
||||
var sdate = sdate2.AddDays(-1);
|
||||
var stime = sdate.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
}
|
||||
var model = new room_electricityData(); ;
|
||||
model.time = jdate.ToString("MM月");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
|
|
@ -215,63 +336,94 @@ namespace DongYingAPI.Controllers.api
|
|||
{
|
||||
var data = new List<room_electricityData>();
|
||||
var list = bll_info.GetModelList("").Where(x => x.FloorName == "图书馆一楼").ToList();
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var now = DateTime.Now;
|
||||
if (date == "日")
|
||||
{
|
||||
|
||||
var a = DateTime.Now.ToString("mm");
|
||||
var b = 0;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new room_electricityData();
|
||||
|
||||
var j = i * 60;
|
||||
b = Convert.ToInt32(a);
|
||||
string now = "";
|
||||
model.time = DateTime.Now.AddMinutes(-j).ToString("HH:00");
|
||||
now = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
a = "31";
|
||||
var datetime = Convert.ToDateTime(now);
|
||||
var sdate = datetime.AddHours(-i);
|
||||
var edate = datetime.AddHours(-i + 1);
|
||||
//var list1 = bll_info.GetModelList("").Where(x =>x.DeviceName.Contains("空调")&& x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
var jdate = now.AddHours(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
var jtime = now.AddHours(-i).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddHours(-(i + 1)).ToString("yyyy-MM-dd HH:00:00");
|
||||
var stime = now.AddHours(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in list)
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId && x.EntireTime >= sdate && x.EntireTime < edate).ToList();
|
||||
foreach (var aitem in list1)
|
||||
{
|
||||
num1 += aitem.EH;
|
||||
}
|
||||
model.EH = num1;
|
||||
}
|
||||
data.Add(model);
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
}
|
||||
var model = new room_electricityData(); ;
|
||||
model.time = DateTime.Now.AddHours(-i).ToString("HH:00");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (date == "月")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new room_electricityData();
|
||||
var atime = DateTime.Now.AddDays(-i).ToString("MM月");
|
||||
model.time = atime;
|
||||
var now = DateTime.Now.AddDays(-i);
|
||||
var sdate = now.ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
var edate = now.AddDays(+1).ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
string jdate;
|
||||
if (i == 0)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
var alist = list1.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
|
||||
foreach (var aitem in alist)
|
||||
jdate = now.AddDays(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
}
|
||||
else
|
||||
{
|
||||
num += aitem.EH;
|
||||
jdate = now.AddDays(-i).ToString("yyyy-MM-dd 00:00:00");
|
||||
}
|
||||
model.EH = num;
|
||||
var jtime = now.AddDays(-i).ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddDays(-(i + 1)).ToString("yyyy-MM-dd 00:00:00");
|
||||
var stime = now.AddDays(-(i + 1)).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
}
|
||||
var model = new room_electricityData(); ;
|
||||
model.time = DateTime.Now.AddDays(-i).ToString("dd号");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
|
|
@ -279,24 +431,52 @@ namespace DongYingAPI.Controllers.api
|
|||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var model = new room_electricityData();
|
||||
var atime = DateTime.Now.AddMonths(-i).ToString("MM月");
|
||||
model.time = atime;
|
||||
var now = DateTime.Now.AddYears(-i);
|
||||
var sdate = now.ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
var edate = now.AddYears(+1).ToString("yyyy-MM-dd") + " 00:00:00";
|
||||
decimal? num = 0;
|
||||
foreach (var item in list)
|
||||
DateTime jdate;
|
||||
if (i == 0)
|
||||
{
|
||||
var list1 = bll.GetModelListDate("", time).Where(x => x.DeviceId == item.DeviceId).ToList();
|
||||
var alist = list1.Where(x => x.EntireTime >= Convert.ToDateTime(sdate) && x.EntireTime < Convert.ToDateTime(edate)).ToList();
|
||||
foreach (var aitem in alist)
|
||||
{
|
||||
num += aitem.EH;
|
||||
var jdate1 = now.AddMonths(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
jdate = Convert.ToDateTime(jdate1);
|
||||
}
|
||||
model.EH = num;
|
||||
else
|
||||
{
|
||||
var jdate1 = now.AddMonths(-i + 1).ToString("yyyy-MM-01 00:00:00");
|
||||
var jdate2 = Convert.ToDateTime(jdate1);
|
||||
jdate = jdate2.AddDays(-1);
|
||||
}
|
||||
var jtime = jdate.ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate1 = now.AddMonths(-(i)).ToString("yyyy-MM-01 00:00:00");
|
||||
var sdate2 = Convert.ToDateTime(sdate1);
|
||||
var sdate = sdate2.AddDays(-1);
|
||||
var stime = sdate.ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
}
|
||||
var model = new room_electricityData(); ;
|
||||
model.time = jdate.ToString("MM月");
|
||||
model.EH = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
|
@ -11,7 +12,7 @@ using System.Web.Http;
|
|||
namespace DongYingAPI.Controllers.api
|
||||
{
|
||||
/// <summary>
|
||||
/// 运行状态
|
||||
/// 空调-运行状态
|
||||
/// </summary>
|
||||
public class GetRunningStatusController : ApiController
|
||||
{
|
||||
|
|
@ -20,22 +21,47 @@ namespace DongYingAPI.Controllers.api
|
|||
public HttpResponseMessage Get()
|
||||
{
|
||||
var res = new get_running_status();
|
||||
//表名
|
||||
var date_base = ConfigurationManager.AppSettings["MySQLDataBase"].ToString();
|
||||
try
|
||||
{
|
||||
var data = new List<running_statusData>();
|
||||
var time = DateTime.Now.ToString("yyyyMM");
|
||||
var list = bll_info.GetModelList("");
|
||||
var date = DateTime.Now.ToString("yyyy-MM-dd HH:00:00");
|
||||
foreach ( var item in list )
|
||||
var now=DateTime.Now;
|
||||
var list = bll_info.GetModelList("").Where(x=>x.FloorName== "科技馆负一层地源热泵").ToList();
|
||||
string jdate;
|
||||
jdate = now.ToString("yyyy-MM-dd HH:00:00");
|
||||
var jtime = now.ToString("yyyyMM");
|
||||
var a = bll.IsExistsTable(date_base, "electricity_data_" + jtime);
|
||||
if (a == false)
|
||||
{
|
||||
bll.CreateTable(jtime);
|
||||
}
|
||||
var sdate = now.AddDays(- 1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var stime = now.AddDays(-1).ToString("yyyyMM");
|
||||
var b = bll.IsExistsTable(date_base, "electricity_data_" + stime);
|
||||
if (b == false)
|
||||
{
|
||||
bll.CreateTable(stime);
|
||||
}
|
||||
decimal? num1 = 0;
|
||||
decimal? num2 = 0;
|
||||
foreach (var aitem in list)
|
||||
{
|
||||
var model=new running_statusData();
|
||||
model.DeviceName = item.DeviceName;
|
||||
model.DeviceName= aitem.DeviceName;
|
||||
model.DeviceState = "正常";
|
||||
var alist = bll.GetModelListDate("", time).Where(x=>x.DeviceId==item.DeviceId&&x.EntireTime==Convert.ToDateTime(date)).ToList();
|
||||
foreach (var aitem in alist)
|
||||
var jlist = bll.GetModelListDate("", jtime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(jdate)).ToList();
|
||||
var slist = bll.GetModelListDate("", stime).Where(x => x.DeviceId == aitem.DeviceId && x.EntireTime == Convert.ToDateTime(sdate)).ToList();
|
||||
foreach (var item in jlist)
|
||||
{
|
||||
model.EH += aitem.EH;
|
||||
num1 = item.EH;
|
||||
}
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 = item.EH;
|
||||
}
|
||||
model.EH = num1-num2;
|
||||
data.Add(model);
|
||||
}
|
||||
res.code = 200;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,158 @@
|
|||
using DataServer.api;
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 用能监测1-用水量
|
||||
/// </summary>
|
||||
public class GetWaterConsumptionController : ApiController
|
||||
{
|
||||
DataServer.BLL.water_data bll = new DataServer.BLL.water_data();
|
||||
public HttpResponseMessage Get(string date="")
|
||||
{
|
||||
var res = new get_water_consumption();
|
||||
try
|
||||
{
|
||||
var data=new List<water_consumptionData>();
|
||||
var list = bll.GetModelList("");
|
||||
if (date == "日")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var time = now.AddHours(-i).ToString("HH:00");
|
||||
//这个小时
|
||||
var ztime = now.AddHours(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
//上个小时
|
||||
var stime = now.AddHours(-(i+1)).ToString("yyyy-MM-dd HH:00:00");
|
||||
//这个小时列表
|
||||
var zlist = list.Where(x => x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in zlist)
|
||||
{
|
||||
num1 = item.WaterYield;
|
||||
}
|
||||
//上个小时列表
|
||||
var slist = list.Where(x => x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
decimal? num2 = 0;
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 = item.WaterYield;
|
||||
}
|
||||
var model=new water_consumptionData();
|
||||
model.time = time;
|
||||
model.WaterValue = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
if (date == "月")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var time = now.AddDays(-i).ToString("dd号");
|
||||
var ztime = "";
|
||||
if (i == 0)
|
||||
{
|
||||
//这天
|
||||
ztime = now.AddDays(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
}
|
||||
else
|
||||
{
|
||||
//这天
|
||||
ztime = now.AddDays(-i).ToString("yyyy-MM-dd 00:00:00");
|
||||
}
|
||||
|
||||
//上天
|
||||
var stime = now.AddDays(-(i + 1)).ToString("yyyy-MM-dd 00:00:00");
|
||||
//这天
|
||||
var zlist = list.Where(x => x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in zlist)
|
||||
{
|
||||
num1 = item.WaterYield;
|
||||
}
|
||||
//上天
|
||||
var slist = list.Where(x => x.EntireTime == Convert.ToDateTime(stime)).ToList();
|
||||
decimal? num2 = 0;
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 = item.WaterYield;
|
||||
}
|
||||
var model = new water_consumptionData();
|
||||
model.time = time;
|
||||
model.WaterValue = num1 - num2;
|
||||
data.Add(model);
|
||||
}
|
||||
}
|
||||
if (date == "年")
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var time = now.AddMonths(-i).ToString("MM月");
|
||||
var ztime1 = "";
|
||||
DateTime ztime;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
//这月
|
||||
ztime1 = now.AddMonths(-i).ToString("yyyy-MM-dd HH:00:00");
|
||||
ztime=Convert.ToDateTime(ztime1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//这月
|
||||
ztime1 = now.AddMonths(-i+1).ToString("yyyy-MM-01 00:00:00");
|
||||
var ztime2 = Convert.ToDateTime(ztime1);
|
||||
ztime = ztime2.AddDays(-1);
|
||||
}
|
||||
|
||||
//上月
|
||||
var stime1 = now.AddMonths(-i).ToString("yyyy-MM-01 00:00:00");
|
||||
var stime2=Convert.ToDateTime(stime1);
|
||||
var stime = stime2.AddDays(-1);
|
||||
//这月
|
||||
var zlist = list.Where(x => x.EntireTime == Convert.ToDateTime(ztime)).ToList();
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in zlist)
|
||||
{
|
||||
num1 = item.WaterYield;
|
||||
}
|
||||
//上月
|
||||
var slist = list.Where(x => x.EntireTime ==stime).ToList();
|
||||
decimal? num2 = 0;
|
||||
foreach (var item in slist)
|
||||
{
|
||||
num2 = item.WaterYield;
|
||||
}
|
||||
var model = new water_consumptionData();
|
||||
model.time = time;
|
||||
model.WaterValue = num1 - num2;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
using DataServer.api;
|
||||
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 HslCommunication.MQTT;
|
||||
using HslCommunication;
|
||||
using HslCommunication.LogNet;
|
||||
using QingHaiVisualizationAPI.Utils;
|
||||
|
||||
namespace DongYingAPI.Controllers.api
|
||||
{
|
||||
public class SetLightingController : ApiController
|
||||
{
|
||||
static log4net.ILog log;
|
||||
DataServer.BLL.device_info bll = new DataServer.BLL.device_info();
|
||||
public HttpResponseMessage Get(string dev = "", string m = "",int v=0)
|
||||
{
|
||||
var res = new get_information();
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(dev) && !string.IsNullOrEmpty(m)&&v!=0)
|
||||
{
|
||||
log4net.Config.XmlConfigurator.Configure();
|
||||
log = log4net.LogManager.GetLogger("loginfo");
|
||||
var mqqt = new MqttClientService();
|
||||
var list = new data();
|
||||
list.dev = dev;
|
||||
list.m = m;
|
||||
list.v = v;
|
||||
mqqt.MqttClientStart();
|
||||
mqqt.Publish("data", JsonConvert.SerializeObject(list));
|
||||
|
||||
res.code= 200;
|
||||
res.msg = "成功";
|
||||
res.data= list;
|
||||
}
|
||||
else
|
||||
{
|
||||
res.code = 201;
|
||||
res.msg = "参数为空";
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -49,7 +49,19 @@
|
|||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\DataServer\bin\Debug\DataServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HslCommunication, Version=10.1.2.0, Culture=neutral, PublicKeyToken=cdb2261fa039ed67, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\HslCommunication.10.1.2\lib\net451\HslCommunication.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\..\DongYingAPI\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="MQTTnet, Version=4.1.4.563, Culture=neutral, PublicKeyToken=fdb7629f2e364a63, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MQTTnet.4.1.4.563\lib\net461\MQTTnet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.Services" />
|
||||
|
|
@ -70,9 +82,6 @@
|
|||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.Web.Infrastructure.2.0.1\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http">
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
|
|
@ -173,6 +182,7 @@
|
|||
<Compile Include="Controllers\api\EnergyEfficiency\GetMultiRateController.cs" />
|
||||
<Compile Include="Controllers\api\EnergyEfficiency\GetUnitConsumptionController.cs" />
|
||||
<Compile Include="Controllers\api\GetAirConditionerController.cs" />
|
||||
<Compile Include="Controllers\api\GetBuildingLightingController.cs" />
|
||||
<Compile Include="Controllers\api\GetCarbonEmissionController.cs" />
|
||||
<Compile Include="Controllers\api\GetCarbonFluxController.cs" />
|
||||
<Compile Include="Controllers\api\GetCarbonIntensityController.cs" />
|
||||
|
|
@ -193,24 +203,30 @@
|
|||
<Compile Include="Controllers\api\GetEnergyTrendsController.cs" />
|
||||
<Compile Include="Controllers\api\GetEquipmentMonitoringController.cs" />
|
||||
<Compile Include="Controllers\api\GetEssentialInformationController.cs" />
|
||||
<Compile Include="Controllers\api\GetFaultConditionController.cs" />
|
||||
<Compile Include="Controllers\api\GetGasConsumptionController.cs" />
|
||||
<Compile Include="Controllers\api\GetGeneralCatalogueController.cs" />
|
||||
<Compile Include="Controllers\api\GetIlluminationLoadController.cs" />
|
||||
<Compile Include="Controllers\api\GetLightingLoadController.cs" />
|
||||
<Compile Include="Controllers\api\GetLightingMonitoringController.cs" />
|
||||
<Compile Include="Controllers\api\GetLightingStrategyController.cs" />
|
||||
<Compile Include="Controllers\api\GetMeteorologicalStationController.cs" />
|
||||
<Compile Include="Controllers\api\GetPowerLoadController.cs" />
|
||||
<Compile Include="Controllers\api\GetRealtimeDataController.cs" />
|
||||
<Compile Include="Controllers\api\GetRealtimeLoadController.cs" />
|
||||
<Compile Include="Controllers\api\GetRoomElectricityController.cs" />
|
||||
<Compile Include="Controllers\api\GetRunningStatusController.cs" />
|
||||
<Compile Include="Controllers\api\GetWaterConsumptionController.cs" />
|
||||
<Compile Include="Controllers\api\loginController.cs" />
|
||||
<Compile Include="Controllers\api\GetCarbonMeasureController.cs" />
|
||||
<Compile Include="Controllers\api\SetLightingController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\ValuesController.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Util\MqttClientService.cs" />
|
||||
<Compile Include="Util\Tool.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<UseGlobalApplicationHostFile />
|
||||
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
|
||||
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
|
||||
<NameOfLastUsedPublishProfile>E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI\Properties\PublishProfiles\FolderProfile1.pubxml</NameOfLastUsedPublishProfile>
|
||||
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
|
||||
<Controller_SelectedScaffolderCategoryPath>root/Common/Web API</Controller_SelectedScaffolderCategoryPath>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<_PublishTargetUrl>bin\app.publish\</_PublishTargetUrl>
|
||||
<History>True|2024-01-10T09:34:07.8440850Z;False|2024-01-10T17:33:54.1670007+08:00;True|2024-01-10T17:32:39.4867251+08:00;True|2024-01-10T14:45:12.0400450+08:00;</History>
|
||||
<_PublishTargetUrl>E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI\bin\app.publish\</_PublishTargetUrl>
|
||||
<History>False|2024-01-15T05:49:44.5332318Z;True|2024-01-15T11:01:00.7602516+08:00;True|2024-01-15T09:26:27.2161156+08:00;True|2024-01-10T17:34:07.8440850+08:00;False|2024-01-10T17:33:54.1670007+08:00;True|2024-01-10T17:32:39.4867251+08:00;True|2024-01-10T14:45:12.0400450+08:00;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
|
@ -79,16 +79,22 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
<publishTime>09/10/2013 16:29:20</publishTime>
|
||||
</File>
|
||||
<File Include="bin/DataServer.dll">
|
||||
<publishTime>01/10/2024 17:34:00</publishTime>
|
||||
<publishTime>01/15/2024 13:49:51</publishTime>
|
||||
</File>
|
||||
<File Include="bin/DataServer.pdb">
|
||||
<publishTime>01/10/2024 17:34:00</publishTime>
|
||||
<publishTime>01/15/2024 13:49:51</publishTime>
|
||||
</File>
|
||||
<File Include="bin/DongYingAPI.dll">
|
||||
<publishTime>01/10/2024 17:34:07</publishTime>
|
||||
<publishTime>01/15/2024 13:50:11</publishTime>
|
||||
</File>
|
||||
<File Include="bin/DongYingAPI.pdb">
|
||||
<publishTime>01/10/2024 17:34:07</publishTime>
|
||||
<publishTime>01/15/2024 13:50:11</publishTime>
|
||||
</File>
|
||||
<File Include="bin/HslCommunication.dll">
|
||||
<publishTime>08/03/2021 14:52:26</publishTime>
|
||||
</File>
|
||||
<File Include="bin/log4net.dll">
|
||||
<publishTime>12/13/2023 14:16:07</publishTime>
|
||||
</File>
|
||||
<File Include="bin/Maticsoft.Common.dll">
|
||||
<publishTime>12/13/2023 14:16:06</publishTime>
|
||||
|
|
@ -102,11 +108,14 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
<File Include="bin/Microsoft.Web.Infrastructure.dll">
|
||||
<publishTime>05/27/2022 23:39:10</publishTime>
|
||||
</File>
|
||||
<File Include="bin/MQTTnet.dll">
|
||||
<publishTime>12/13/2023 14:16:06</publishTime>
|
||||
</File>
|
||||
<File Include="bin/MySql.Data.dll">
|
||||
<publishTime>12/13/2023 14:16:06</publishTime>
|
||||
</File>
|
||||
<File Include="bin/Newtonsoft.Json.dll">
|
||||
<publishTime>04/22/2019 01:06:16</publishTime>
|
||||
<publishTime>11/09/2019 08:56:44</publishTime>
|
||||
</File>
|
||||
<File Include="bin/roslyn/csc.exe">
|
||||
<publishTime>08/08/2018 05:38:48</publishTime>
|
||||
|
|
@ -289,34 +298,34 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
<publishTime>01/23/2014 13:57:34</publishTime>
|
||||
</File>
|
||||
<File Include="bin/zh-Hans/System.Net.Http.Formatting.resources.dll">
|
||||
<publishTime>05/27/2022 23:34:44</publishTime>
|
||||
<publishTime>05/28/2022 07:34:44</publishTime>
|
||||
</File>
|
||||
<File Include="bin/zh-Hans/System.Web.Helpers.resources.dll">
|
||||
<publishTime>05/27/2022 23:34:44</publishTime>
|
||||
<publishTime>05/28/2022 07:34:44</publishTime>
|
||||
</File>
|
||||
<File Include="bin/zh-Hans/System.Web.Http.resources.dll">
|
||||
<publishTime>05/27/2022 23:34:04</publishTime>
|
||||
<publishTime>05/28/2022 07:34:04</publishTime>
|
||||
</File>
|
||||
<File Include="bin/zh-Hans/System.Web.Http.WebHost.resources.dll">
|
||||
<publishTime>05/27/2022 23:34:44</publishTime>
|
||||
<publishTime>05/28/2022 07:34:44</publishTime>
|
||||
</File>
|
||||
<File Include="bin/zh-Hans/System.Web.Mvc.resources.dll">
|
||||
<publishTime>05/27/2022 23:34:44</publishTime>
|
||||
<publishTime>05/28/2022 07:34:44</publishTime>
|
||||
</File>
|
||||
<File Include="bin/zh-Hans/System.Web.Optimization.resources.dll">
|
||||
<publishTime>02/11/2014 15:28:40</publishTime>
|
||||
<publishTime>02/11/2014 23:28:40</publishTime>
|
||||
</File>
|
||||
<File Include="bin/zh-Hans/System.Web.Razor.resources.dll">
|
||||
<publishTime>05/27/2022 23:35:16</publishTime>
|
||||
<publishTime>05/28/2022 07:35:16</publishTime>
|
||||
</File>
|
||||
<File Include="bin/zh-Hans/System.Web.WebPages.Deployment.resources.dll">
|
||||
<publishTime>05/27/2022 23:34:24</publishTime>
|
||||
<publishTime>05/28/2022 07:34:24</publishTime>
|
||||
</File>
|
||||
<File Include="bin/zh-Hans/System.Web.WebPages.Razor.resources.dll">
|
||||
<publishTime>05/27/2022 23:34:04</publishTime>
|
||||
<publishTime>05/28/2022 07:34:04</publishTime>
|
||||
</File>
|
||||
<File Include="bin/zh-Hans/System.Web.WebPages.resources.dll">
|
||||
<publishTime>05/27/2022 23:34:44</publishTime>
|
||||
<publishTime>05/28/2022 07:34:44</publishTime>
|
||||
</File>
|
||||
<File Include="Content/bootstrap-theme.css">
|
||||
<publishTime>01/02/2024 09:27:31</publishTime>
|
||||
|
|
@ -349,19 +358,19 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
<publishTime>01/08/2024 15:31:27</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/EnergyEfficiency/GetAmountEnergyController.cs">
|
||||
<publishTime>01/09/2024 13:35:11</publishTime>
|
||||
<publishTime>01/11/2024 14:56:39</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/EnergyEfficiency/GetClassifiedEnergyController.cs">
|
||||
<publishTime>01/10/2024 17:33:29</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/EnergyEfficiency/GetDeviceOperationController.cs">
|
||||
<publishTime>01/09/2024 13:35:11</publishTime>
|
||||
<publishTime>01/12/2024 18:47:54</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/EnergyEfficiency/GetElectricityPriceController.cs">
|
||||
<publishTime>01/09/2024 18:18:37</publishTime>
|
||||
<publishTime>01/11/2024 14:58:40</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/EnergyEfficiency/GetEnergyBenchmarkingController.cs">
|
||||
<publishTime>01/10/2024 17:33:29</publishTime>
|
||||
<publishTime>01/11/2024 14:56:39</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/EnergyEfficiency/GetEnergyCalendarController.cs">
|
||||
<publishTime>01/10/2024 17:33:29</publishTime>
|
||||
|
|
@ -379,7 +388,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
<publishTime>01/10/2024 13:26:12</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/EnergyEfficiency/GetMultiRateController.cs">
|
||||
<publishTime>01/09/2024 18:18:38</publishTime>
|
||||
<publishTime>01/11/2024 15:58:43</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/EnergyEfficiency/GetUnitConsumptionController.cs">
|
||||
<publishTime>01/10/2024 13:26:12</publishTime>
|
||||
|
|
@ -387,74 +396,83 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
<File Include="Controllers/api/GetAirConditionerController.cs">
|
||||
<publishTime>01/09/2024 16:43:55</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetBuildingLightingController.cs">
|
||||
<publishTime>01/11/2024 17:02:47</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetCarbonEmissionController.cs">
|
||||
<publishTime>01/09/2024 17:35:08</publishTime>
|
||||
<publishTime>01/12/2024 09:52:53</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetCarbonFluxController.cs">
|
||||
<publishTime>01/09/2024 18:07:13</publishTime>
|
||||
<publishTime>01/11/2024 18:27:33</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetCarbonIntensityController.cs">
|
||||
<publishTime>01/10/2024 11:04:33</publishTime>
|
||||
<publishTime>01/12/2024 09:45:18</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetCarbonMeasureController.cs">
|
||||
<publishTime>01/09/2024 18:25:20</publishTime>
|
||||
<publishTime>01/12/2024 09:58:01</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetCarbonOffsetController.cs">
|
||||
<publishTime>01/10/2024 13:25:43</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetCarbonReductionController.cs">
|
||||
<publishTime>01/10/2024 11:18:51</publishTime>
|
||||
<publishTime>01/11/2024 14:10:28</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetCellRankingController.cs">
|
||||
<publishTime>01/09/2024 14:53:59</publishTime>
|
||||
<publishTime>01/12/2024 10:28:39</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetChamberLoadController.cs">
|
||||
<publishTime>01/09/2024 16:47:40</publishTime>
|
||||
<publishTime>01/12/2024 17:02:55</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetCurrentVoltageController.cs">
|
||||
<publishTime>01/09/2024 15:20:59</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetDailyElectricityController.cs">
|
||||
<publishTime>01/10/2024 13:39:52</publishTime>
|
||||
<publishTime>01/12/2024 15:06:05</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetDeviceDetailsController.cs">
|
||||
<publishTime>01/10/2024 17:32:32</publishTime>
|
||||
<publishTime>01/15/2024 13:49:08</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetDeviceParameterController.cs">
|
||||
<publishTime>01/10/2024 16:35:51</publishTime>
|
||||
<publishTime>01/12/2024 15:11:10</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetDistributionPowerController.cs">
|
||||
<publishTime>01/09/2024 15:26:43</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetElectricalConditionController.cs">
|
||||
<publishTime>01/10/2024 16:19:04</publishTime>
|
||||
<publishTime>01/12/2024 15:18:56</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetElectricalRankingController.cs">
|
||||
<publishTime>01/09/2024 15:36:30</publishTime>
|
||||
<publishTime>01/12/2024 13:59:37</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetElectricEquipmentController.cs">
|
||||
<publishTime>01/09/2024 15:40:43</publishTime>
|
||||
<publishTime>01/12/2024 13:59:33</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetElectricityConsumptionController.cs">
|
||||
<publishTime>01/09/2024 16:50:09</publishTime>
|
||||
<publishTime>01/12/2024 17:11:08</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetElectricQuantityController.cs">
|
||||
<publishTime>01/09/2024 16:51:21</publishTime>
|
||||
<publishTime>01/12/2024 17:11:08</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetEnergyTrendsController.cs">
|
||||
<publishTime>01/10/2024 14:14:08</publishTime>
|
||||
<publishTime>01/12/2024 17:11:08</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetEquipmentMonitoringController.cs">
|
||||
<publishTime>01/09/2024 16:41:37</publishTime>
|
||||
<publishTime>01/12/2024 16:11:58</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetEssentialInformationController.cs">
|
||||
<publishTime>01/08/2024 13:30:31</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetFaultConditionController.cs">
|
||||
<publishTime>01/11/2024 13:37:00</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetGasConsumptionController.cs">
|
||||
<publishTime>01/11/2024 16:58:37</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetGeneralCatalogueController.cs">
|
||||
<publishTime>01/09/2024 16:53:42</publishTime>
|
||||
<publishTime>01/12/2024 16:47:28</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetIlluminationLoadController.cs">
|
||||
<publishTime>01/10/2024 17:32:32</publishTime>
|
||||
<publishTime>01/11/2024 09:32:32</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetLightingLoadController.cs">
|
||||
<publishTime>01/09/2024 17:02:14</publishTime>
|
||||
|
|
@ -462,8 +480,11 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
<File Include="Controllers/api/GetLightingMonitoringController.cs">
|
||||
<publishTime>01/10/2024 16:58:07</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetLightingStrategyController.cs">
|
||||
<publishTime>01/11/2024 13:18:52</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetMeteorologicalStationController.cs">
|
||||
<publishTime>01/10/2024 16:29:26</publishTime>
|
||||
<publishTime>01/11/2024 13:47:16</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetPowerLoadController.cs">
|
||||
<publishTime>01/09/2024 17:02:14</publishTime>
|
||||
|
|
@ -475,14 +496,20 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
<publishTime>01/09/2024 17:02:14</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetRoomElectricityController.cs">
|
||||
<publishTime>01/09/2024 17:08:06</publishTime>
|
||||
<publishTime>01/12/2024 17:11:08</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetRunningStatusController.cs">
|
||||
<publishTime>01/10/2024 15:08:35</publishTime>
|
||||
<publishTime>01/12/2024 15:48:49</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/GetWaterConsumptionController.cs">
|
||||
<publishTime>01/11/2024 16:51:02</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/loginController.cs">
|
||||
<publishTime>01/09/2024 10:54:33</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/api/SetLightingController.cs">
|
||||
<publishTime>01/15/2024 10:57:34</publishTime>
|
||||
</File>
|
||||
<File Include="Controllers/HomeController.cs">
|
||||
<publishTime>01/02/2024 09:27:26</publishTime>
|
||||
</File>
|
||||
|
|
@ -553,7 +580,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
<publishTime>01/02/2024 09:27:24</publishTime>
|
||||
</File>
|
||||
<File Include="Web.config">
|
||||
<publishTime>01/10/2024 14:45:10</publishTime>
|
||||
<publishTime>01/15/2024 11:00:59</publishTime>
|
||||
</File>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
using MQTTnet;
|
||||
using MQTTnet.Client;
|
||||
using MQTTnet.Protocol;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace QingHaiVisualizationAPI.Utils
|
||||
{
|
||||
public class MqttClientService
|
||||
{
|
||||
private static string clientid;
|
||||
public static IMqttClient _mqttClient;
|
||||
|
||||
static log4net.ILog log;
|
||||
public void MqttClientStart()
|
||||
{
|
||||
log4net.Config.XmlConfigurator.Configure();
|
||||
log = log4net.LogManager.GetLogger("loginfo");
|
||||
try
|
||||
{
|
||||
if (_mqttClient == null)
|
||||
{
|
||||
clientid = "API-" + Guid.NewGuid().ToString("N");
|
||||
|
||||
var optionsBuilder = new MqttClientOptionsBuilder()
|
||||
.WithTcpServer("111.229.30.246", 1883) // 要访问的mqtt服务端的 ip 和 端口号 1.117.96.199
|
||||
.WithCredentials("dev", "12345") // 要访问的mqtt服务端的用户名和密码
|
||||
.WithClientId(clientid) // 设置客户端id
|
||||
.WithCleanSession()
|
||||
.WithTls(new MqttClientOptionsBuilderTlsParameters
|
||||
{
|
||||
UseTls = false // 是否使用 tls加密
|
||||
});
|
||||
|
||||
var clientOptions = optionsBuilder.Build();
|
||||
_mqttClient = new MqttFactory().CreateMqttClient();
|
||||
|
||||
_mqttClient.ConnectedAsync += _mqttClient_ConnectedAsync; // 客户端连接成功事件
|
||||
_mqttClient.DisconnectedAsync += _mqttClient_DisconnectedAsync; // 客户端连接关闭事件
|
||||
|
||||
_mqttClient.ConnectAsync(clientOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_mqttClient.IsConnected)
|
||||
{
|
||||
clientid = "API-" + Guid.NewGuid().ToString("N");
|
||||
|
||||
var optionsBuilder = new MqttClientOptionsBuilder()
|
||||
.WithTcpServer("111.229.30.246", 1883) // 要访问的mqtt服务端的 ip 和 端口号
|
||||
.WithCredentials("dev", "12345") // 要访问的mqtt服务端的用户名和密码
|
||||
.WithClientId(clientid) // 设置客户端id
|
||||
.WithCleanSession()
|
||||
.WithTls(new MqttClientOptionsBuilderTlsParameters
|
||||
{
|
||||
UseTls = false // 是否使用 tls加密
|
||||
});
|
||||
|
||||
var clientOptions = optionsBuilder.Build();
|
||||
_mqttClient = new MqttFactory().CreateMqttClient();
|
||||
|
||||
_mqttClient.ConnectedAsync += _mqttClient_ConnectedAsync; // 客户端连接成功事件
|
||||
_mqttClient.DisconnectedAsync += _mqttClient_DisconnectedAsync; // 客户端连接关闭事件
|
||||
|
||||
_mqttClient.ConnectAsync(clientOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Info("接口端连接服务端失败,失败原因:" + ex.Message);
|
||||
//LogHelper.WriteLog("接口端连接服务端失败,失败原因:" + ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 客户端连接关闭事件
|
||||
/// </summary>
|
||||
/// <param name="arg"></param>
|
||||
/// <returns></returns>
|
||||
private Task _mqttClient_DisconnectedAsync(MqttClientDisconnectedEventArgs arg)
|
||||
{
|
||||
log.Info("接口端已断开MQTT服务端的连接");
|
||||
//LogHelper.WriteLog("接口端已断开MQTT服务端的连接");
|
||||
//Console.WriteLine($"客户端已断开与服务端的连接……");
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 客户端连接成功事件
|
||||
/// </summary>
|
||||
/// <param name="arg"></param>
|
||||
/// <returns></returns>
|
||||
private Task _mqttClient_ConnectedAsync(MqttClientConnectedEventArgs arg)
|
||||
{
|
||||
//Console.WriteLine($"客户端已连接服务端……");
|
||||
//LogHelper.WriteLog("接口端已连接MQTT服务端");
|
||||
log.Info("接口端已连接MQTT服务端");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void Publish(string pub, string data)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_mqttClient.IsConnected)
|
||||
{
|
||||
var message = new MqttApplicationMessage
|
||||
{
|
||||
Topic = pub,
|
||||
Payload = Encoding.UTF8.GetBytes(data),
|
||||
QualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce,
|
||||
Retain = false // 服务端是否保留消息。true为保留,如果有新的订阅者连接,就会立马收到该消息。
|
||||
};
|
||||
_mqttClient.PublishAsync(message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Info("接口端发布消息失败,失败原因:" + ex.Message);
|
||||
//LogHelper.WriteLog("接口端发布消息失败,失败原因:" + ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
-->
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="ConnectionString" value="Data Source=127.0.0.1;Database=dongying;User ID=root;Password=0822;Charset=gbk;convert zero datetime=True"/>
|
||||
<add key="MySQLDataBase" value="dongying"/>
|
||||
<add key="ConnectionString" value="Data Source=127.0.0.1;Database=dongying;User ID=root;Password=0822;Charset=gbk;convert zero datetime=True" />
|
||||
<add key="MySQLDataBase" value="dongying" />
|
||||
<add key="webpages:Version" value="3.0.0.0" />
|
||||
<add key="webpages:Enabled" value="false" />
|
||||
<add key="ClientValidationEnabled" value="true" />
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
a24ef2aacced7d3d3ad212e7cf79b1d293ea4116
|
||||
d9ea997d3ff3557d0aa57072d033b88686537157
|
||||
|
|
|
|||
|
|
@ -298,3 +298,9 @@ F:\项目\东营两馆一宫项目\DongYing\DongYingAPI\bin\zh-Hans\System.Web.W
|
|||
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
|
||||
E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI\bin\HslCommunication.dll
|
||||
E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI\bin\log4net.dll
|
||||
E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI\bin\MQTTnet.dll
|
||||
E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI\bin\HslCommunication.xml
|
||||
E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI\bin\log4net.xml
|
||||
E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI\bin\MQTTnet.xml
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -2,6 +2,7 @@
|
|||
<packages>
|
||||
<package id="Antlr" version="3.5.0.2" targetFramework="net472" />
|
||||
<package id="bootstrap" version="3.4.1" targetFramework="net472" />
|
||||
<package id="HslCommunication" version="10.1.2" targetFramework="net472" />
|
||||
<package id="jQuery" version="3.4.1" targetFramework="net472" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.9" targetFramework="net472" />
|
||||
<package id="Microsoft.AspNet.Mvc.zh-Hans" version="5.2.9" targetFramework="net472" />
|
||||
|
|
@ -22,6 +23,7 @@
|
|||
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.1" targetFramework="net472" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="2.0.1" targetFramework="net472" />
|
||||
<package id="Modernizr" version="2.8.3" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
|
||||
<package id="MQTTnet" version="4.1.4.563" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
|
||||
<package id="WebGrease" version="1.6.0" targetFramework="net472" />
|
||||
</packages>
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -14,7 +14,7 @@
|
|||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||
<dsig:DigestValue>rBYrW1dzUjXns5a6z/YrpLNLXugBmeMTyh1H2R8VfoA=</dsig:DigestValue>
|
||||
<dsig:DigestValue>GScl3CZ2qpJ9jFdPcw+ZnX68DCAS4LmifkveDdn+/cU=</dsig:DigestValue>
|
||||
</hash>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@
|
|||
</dependentAssembly>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="DataServer.dll" size="124928">
|
||||
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="DataServer.dll" size="137216">
|
||||
<assemblyIdentity name="DataServer" version="1.0.0.0" language="neutral" processorArchitecture="msil" />
|
||||
<hash>
|
||||
<dsig:Transforms>
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||
<dsig:DigestValue>FRgkqKDcmQzR3U+vbgEw7Ukab51o/oiyo7L+lsx9Pok=</dsig:DigestValue>
|
||||
<dsig:DigestValue>xQiQI9ifmRrHXRlAxTYTlEi5Knw8SbX1q8Yjn1kRweo=</dsig:DigestValue>
|
||||
</hash>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -14,7 +14,7 @@
|
|||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||
<dsig:DigestValue>rBYrW1dzUjXns5a6z/YrpLNLXugBmeMTyh1H2R8VfoA=</dsig:DigestValue>
|
||||
<dsig:DigestValue>GScl3CZ2qpJ9jFdPcw+ZnX68DCAS4LmifkveDdn+/cU=</dsig:DigestValue>
|
||||
</hash>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@
|
|||
</dependentAssembly>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="DataServer.dll" size="124928">
|
||||
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="DataServer.dll" size="137216">
|
||||
<assemblyIdentity name="DataServer" version="1.0.0.0" language="neutral" processorArchitecture="msil" />
|
||||
<hash>
|
||||
<dsig:Transforms>
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||
<dsig:DigestValue>FRgkqKDcmQzR3U+vbgEw7Ukab51o/oiyo7L+lsx9Pok=</dsig:DigestValue>
|
||||
<dsig:DigestValue>xQiQI9ifmRrHXRlAxTYTlEi5Knw8SbX1q8Yjn1kRweo=</dsig:DigestValue>
|
||||
</hash>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,20 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2007 James Newton-King
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue