我這邊應該不用動(異常新增恢復時間)
This commit is contained in:
parent
b2ea9469f7
commit
7d28bca925
@ -27,24 +27,24 @@ namespace SolarPower.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
//public async Task<ApiResult<AnalysisStationCombine>> GetStationsCard(ChartInput post)
|
||||
//{
|
||||
// ApiResult<AnalysisStationCombine> apiResult = new ApiResult<AnalysisStationCombine>();
|
||||
// try
|
||||
// {
|
||||
// var PowerStationIdLists = new AnalysisStationCombine();
|
||||
// PowerStationIdLists = await analysisStationCombineRepository.GetPowerStationIdList(myUser.Id);
|
||||
// apiResult.Code = "0000";
|
||||
// apiResult.Data = PowerStationIdLists;
|
||||
// }
|
||||
// catch (Exception exception)
|
||||
// {
|
||||
// apiResult.Code = "9999";
|
||||
// Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
// }
|
||||
public async Task<ApiResult<AnalysisStationCombine>> GetStationsCard(ChartInput post)
|
||||
{
|
||||
ApiResult<AnalysisStationCombine> apiResult = new ApiResult<AnalysisStationCombine>();
|
||||
try
|
||||
{
|
||||
var GetPowerStationInfos = new AnalysisStationCombine();
|
||||
GetPowerStationInfos = await analysisStationCombineRepository.GetPowerStationInfoList(post);
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = GetPowerStationInfos;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
// apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
// return apiResult;
|
||||
//}
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1599,8 +1599,14 @@ ENGINE=InnoDB
|
||||
|
||||
-- 新增發電金額及減碳量 20210716
|
||||
ALTER TABLE `power_station_history_hour`
|
||||
ADD COLUMN `MONEY` DOUBLE(22,0) NULL DEFAULT NULL AFTER `SOLARHOUR`,
|
||||
ADD COLUMN `CARBON` DOUBLE(22,0) NULL DEFAULT NULL AFTER `MONEY`;
|
||||
ADD COLUMN `MONEY` DOUBLE NULL DEFAULT NULL AFTER `SOLARHOUR`,
|
||||
ADD COLUMN `CARBON` DOUBLE NULL DEFAULT NULL AFTER `MONEY`;
|
||||
ALTER TABLE `power_station_history_day`
|
||||
ADD COLUMN `MONEY` DOUBLE NULL DEFAULT NULL AFTER `SOLARHOUR`,
|
||||
ADD COLUMN `CARBON` DOUBLE NULL DEFAULT NULL AFTER `MONEY`;
|
||||
ALTER TABLE `power_station_history_month`
|
||||
ADD COLUMN `MONEY` DOUBLE NULL DEFAULT NULL AFTER `SOLARHOUR`,
|
||||
ADD COLUMN `CARBON` DOUBLE NULL DEFAULT NULL AFTER `MONEY`;
|
||||
|
||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
|
||||
|
||||
@ -97,6 +97,7 @@ namespace SolarPower.Models
|
||||
public int Id { get; set; }
|
||||
public string Site_id { get; set; }
|
||||
public string Dev_time { get; set; }
|
||||
public string NormalTime { get; set; }
|
||||
public string AlarmClassName { get; set; }
|
||||
public string ErrDevice { get; set; }
|
||||
public string ErrMsg { get; set; }
|
||||
|
||||
@ -587,6 +587,8 @@ namespace SolarPower.Models.PowerStation
|
||||
public double PR { get; set; }
|
||||
public double MP { get; set; }
|
||||
public double SolarHour { get; set; }
|
||||
public double MONEY { get; set; }
|
||||
public double CARBON { get; set; }
|
||||
}
|
||||
|
||||
public class AvgPowerStationHistory
|
||||
@ -608,6 +610,8 @@ namespace SolarPower.Models.PowerStation
|
||||
public double PR { get; set; }
|
||||
public double MP { get; set; }
|
||||
public double SolarHour { get; set; }
|
||||
public double MONEY { get; set; }
|
||||
public double CARBON { get; set; }
|
||||
}
|
||||
|
||||
public class PowerStationHistoryMonth
|
||||
@ -622,6 +626,8 @@ namespace SolarPower.Models.PowerStation
|
||||
public double PR { get; set; }
|
||||
public double MP { get; set; }
|
||||
public double SolarHour { get; set; }
|
||||
public double MONEY { get; set; }
|
||||
public double CARBON { get; set; }
|
||||
}
|
||||
|
||||
public class PyrheliometerHistory
|
||||
@ -751,6 +757,12 @@ namespace SolarPower.Models.PowerStation
|
||||
public string PoP { get; set; } //降雨機率
|
||||
}
|
||||
|
||||
public class MoneyAndCarbon
|
||||
{
|
||||
public double MONEY { get; set; }
|
||||
public double CARBON { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -201,9 +201,14 @@ namespace SolarPower.Quartz.Jobs
|
||||
var historyDay = await powerStationRepository.GetLastOnePowerStationHistoryByDay(dateNowDay, table_name);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【取得成功電站[{0}]在{1}的所有值的總和】", powerStation.Code, dateNowDay);
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【電站[{0}]在{1}的所有值的總和】 - {2}", powerStation.Code, dateNowDay, System.Text.Json.JsonSerializer.Serialize(historyDay));
|
||||
var daynow = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
var moneyandcarbon = await powerStationRepository.GetMoneyAndCarbonWithHistoryHour(powerStation.Id, dateNowDay, 1);
|
||||
|
||||
if (historyDay != null)
|
||||
{
|
||||
historyDay.PowerStationId = powerStation.Id;
|
||||
historyDay.CARBON = moneyandcarbon.CARBON;
|
||||
historyDay.MONEY = moneyandcarbon.MONEY;
|
||||
powerStationHistoryDays.Add(historyDay);
|
||||
}
|
||||
|
||||
@ -241,7 +246,13 @@ namespace SolarPower.Quartz.Jobs
|
||||
var historyMonth = await powerStationRepository.ClacPowerStationHistoryMonthDataByPowerStationId(powerStation.Id, dateNowMonth);
|
||||
if (historyMonth != null)
|
||||
{
|
||||
var moneyandcarbonMon = await powerStationRepository.GetMoneyAndCarbonWithHistoryHour(powerStation.Id, dateNowMonth, 0);
|
||||
|
||||
|
||||
historyMonth.Timestamp = Convert.ToDateTime(historyMonth.Timestamp).ToString("yyyy-MM-dd");
|
||||
historyMonth.MONEY = moneyandcarbonMon.MONEY;
|
||||
historyMonth.CARBON = moneyandcarbonMon.CARBON;
|
||||
|
||||
|
||||
insertPowerStationHistoryMonths.Add(historyMonth);
|
||||
}
|
||||
@ -341,7 +352,9 @@ namespace SolarPower.Quartz.Jobs
|
||||
"KWHKWP",
|
||||
"PR",
|
||||
"MP",
|
||||
"SolarHour"
|
||||
"SolarHour",
|
||||
"MONEY",
|
||||
"CARBON"
|
||||
};
|
||||
|
||||
await powerStationRepository.AddPowerStationHistoryDayList(powerStationHistoryDays, history_properties_day);
|
||||
@ -358,7 +371,9 @@ namespace SolarPower.Quartz.Jobs
|
||||
"KWHKWP",
|
||||
"PR",
|
||||
"MP",
|
||||
"SolarHour"
|
||||
"SolarHour",
|
||||
"MONEY",
|
||||
"CARBON"
|
||||
};
|
||||
|
||||
if (insertPowerStationHistoryMonths.Count > 0)
|
||||
@ -420,6 +435,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
@ -102,6 +102,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
case (int)SolarTypeEnum.SelfSold: //自建躉售
|
||||
//今日發電金額 計算方式:todaykWh * 授電費率
|
||||
calcPowerStation.Today_Monery = history.TodayKWh * powerStation.PowerRate;
|
||||
history.MONEY = history.KWH * powerStation.PowerRate;
|
||||
|
||||
//總發電金額 計算方式:totalkWh * 授電費率
|
||||
calcPowerStation.Total_Monery = history.TotalKWH * powerStation.PowerRate;
|
||||
@ -121,6 +122,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
//今日發電金額計算方式:todaykWh * 出借費率(各個土地房屋租借比率平均)
|
||||
calcPowerStation.Today_Monery = history.TodayKWh * avgLeaseRate;
|
||||
|
||||
history.MONEY = history.KWH * avgLeaseRate;
|
||||
//總發電金額 計算方式:totalkWh * 授電費率
|
||||
calcPowerStation.Total_Monery = history.TotalKWH * avgLeaseRate;
|
||||
break;
|
||||
@ -128,12 +130,16 @@ namespace SolarPower.Quartz.Jobs
|
||||
//今日發電金額 計算方式:todaykWh * 授電費率
|
||||
calcPowerStation.Today_Monery = history.TodayKWh * powerStation.PowerRate;
|
||||
|
||||
history.MONEY = history.KWH * powerStation.PowerRate;
|
||||
|
||||
//總發電金額 計算方式:totalkWh * 授電費率
|
||||
calcPowerStation.Total_Monery = history.TotalKWH * powerStation.PowerRate;
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region kWh/kWp
|
||||
//直接填寫
|
||||
calcPowerStation.Today_kwhkwp = history.KWHKWP;
|
||||
@ -149,6 +155,8 @@ namespace SolarPower.Quartz.Jobs
|
||||
|
||||
//今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值]
|
||||
calcPowerStation.Today_Carbon = history.TodayKWh * carbonRate;
|
||||
|
||||
history.CARBON = history.KWH * carbonRate;
|
||||
//總減碳量(總發電量 * (0.554/1000)[抓資料庫值]
|
||||
calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate;
|
||||
#endregion
|
||||
@ -292,7 +300,9 @@ namespace SolarPower.Quartz.Jobs
|
||||
"KWHKWP",
|
||||
"PR",
|
||||
"MP",
|
||||
"SolarHour"
|
||||
"SolarHour",
|
||||
"MONEY",
|
||||
"CARBON"
|
||||
};
|
||||
|
||||
await powerStationRepository.AddPowerStationHistory(powerStationHistoriesHour, history_properties);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
using SolarPower.Helper;
|
||||
using Dapper;
|
||||
using SolarPower.Helper;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,5 +16,36 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
tableName = "power_station";
|
||||
}
|
||||
|
||||
public async Task<AnalysisStationCombine> GetPowerStationInfoList(ChartInput post)
|
||||
{
|
||||
var a = new AnalysisStationCombine();
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = @"SELECT ";
|
||||
|
||||
a = await conn.QueryFirstOrDefaultAsync<AnalysisStationCombine>(sql);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -3054,5 +3054,32 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<MoneyAndCarbon> GetMoneyAndCarbonWithHistoryHour (int powerstationId , string dateTime ,int type)
|
||||
{
|
||||
MoneyAndCarbon result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = "";
|
||||
if (type == 0)
|
||||
{
|
||||
sql = $@"SELECT SUM(MONEY) AS MONEY, SUM(CARBON) AS CARBON FROM power_station_history_hour
|
||||
WHERE PowerStationId = {powerstationId} AND DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = '{dateTime}' ";
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = $@"SELECT SUM(MONEY) AS MONEY, SUM(CARBON) AS CARBON FROM power_station_history_hour
|
||||
WHERE PowerStationId = {powerstationId} AND DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = '{dateTime}' ";
|
||||
}
|
||||
result = await conn.QueryFirstOrDefaultAsync<MoneyAndCarbon>(sql);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,6 @@ namespace SolarPower.Repository.Interface
|
||||
public interface IAnalysisStationCombineRepository :IRepositoryBase<AnalysisStationCombine>
|
||||
{
|
||||
|
||||
|
||||
Task<AnalysisStationCombine> GetPowerStationInfoList(ChartInput post);
|
||||
}
|
||||
}
|
||||
|
||||
@ -533,6 +533,6 @@ namespace SolarPower.Repository.Interface
|
||||
Task AddWeatherObservation(List<WeatherObservation> entity, List<string> properties);
|
||||
Task AddWeatherForecast(List<WeatherForecast> entity, List<string> properties);
|
||||
Task<NowWeather> SelectNowWeather(int CityId);
|
||||
|
||||
Task<MoneyAndCarbon> GetMoneyAndCarbonWithHistoryHour(int powerstationId, string dateTime, int type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,21 +227,21 @@
|
||||
|
||||
@section Scripts{
|
||||
<script>
|
||||
var ids = new Array(0);//當前選擇縣市
|
||||
var powerids = new Array(0);//當前選擇電站
|
||||
var Allids = new Array(0);//全部縣市
|
||||
var Allpowerids = new Array(0);//全部電站
|
||||
var searchType = 0;//搜尋條件(日,日區間,月,年)
|
||||
var datepicker;
|
||||
var timerange;
|
||||
$(function () {
|
||||
var ids = new Array(0);//當前選擇縣市
|
||||
var powerids = new Array(0);//當前選擇電站
|
||||
var Allids = new Array(0);//全部縣市
|
||||
var Allpowerids = new Array(0);//全部電站
|
||||
var searchType = 0;//搜尋條件(日,日區間,月,年)
|
||||
var datepicker;
|
||||
var timerange;
|
||||
//#region 預設初始值
|
||||
$('#DateGet').val(new Date().toISOString().substring(0, 10));
|
||||
document.getElementById("DateGettextdiv").style.display = "none";//隱藏
|
||||
$('#DateGet').attr('style', 'width:205px');
|
||||
$('#DateGettext').attr('style', 'width:205px');
|
||||
timerange = $('#DateGet').val();
|
||||
getchart();
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 預設載入該使用者可以選擇的電站
|
||||
@ -277,7 +277,7 @@
|
||||
powerids.push(String(val.id));
|
||||
Allpowerids.push(String(val.id));
|
||||
});
|
||||
|
||||
//GetStationsCard();
|
||||
//modal 電站 下拉式選單
|
||||
//$("#power_station_select_modal").empty();
|
||||
//$.each(rel.data, function (index, val) {
|
||||
@ -289,7 +289,7 @@
|
||||
})
|
||||
})
|
||||
//#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
@ -431,12 +431,12 @@
|
||||
|
||||
$('#DateGet').on('change', function () {
|
||||
timerange = $('#DateGet').val();
|
||||
getchart();
|
||||
GetStationsCard();
|
||||
});
|
||||
|
||||
$('#DateGettext').on('change', function () {
|
||||
timerange = $('#DateGettext').val();
|
||||
getchart();
|
||||
GetStationsCard();
|
||||
});
|
||||
|
||||
function GetStationsCard()
|
||||
|
||||
@ -888,13 +888,15 @@
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": true,
|
||||
"order": [[6, "desc"]],
|
||||
"order": [[7, "desc"]],
|
||||
"columns": [{
|
||||
"data": "powerStationName"
|
||||
}, {
|
||||
"data": "id"
|
||||
}, {
|
||||
"data": "dev_time"
|
||||
},{
|
||||
"data": "normalTime"
|
||||
}, {
|
||||
"data": "alarmClassName"
|
||||
}, {
|
||||
@ -1222,9 +1224,9 @@
|
||||
var myDropzone = Dropzone.forElement("#recode-file-form_exc");
|
||||
|
||||
if (myDropzone.files.length > 0) {
|
||||
|
||||
selected_id = rel.data;
|
||||
myDropzone.processQueue();
|
||||
|
||||
|
||||
myDropzone.on("successmultiple", function (file, rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
@ -1455,7 +1457,7 @@
|
||||
var myDropzone = Dropzone.forElement("#recode-file-form");
|
||||
|
||||
if (myDropzone.files.length > 0) {
|
||||
|
||||
selected_id = rel.data;
|
||||
myDropzone.processQueue();
|
||||
|
||||
myDropzone.on("successmultiple", function (file, rel) {
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
<th>電站名稱</th>
|
||||
<th>異常ID</th>
|
||||
<th>發生時間</th>
|
||||
<th>恢復時間</th>
|
||||
<th>異常類別</th>
|
||||
<th>設備編號</th>
|
||||
<th>異常訊息</th>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user