1. 統一 計算方式

2. 修改 合併電站計算方式
This commit is contained in:
Kai 2021-09-23 13:53:41 +08:00
parent 18f76e4b84
commit 7c79b97825
3 changed files with 72 additions and 73 deletions

View File

@ -84,8 +84,6 @@ namespace SolarPower.Quartz.Jobs
logger.LogError("【{0}】{1}", "CalcPowerStationJob", ex.Message); logger.LogError("【{0}】{1}", "CalcPowerStationJob", ex.Message);
observation = null; observation = null;
} }
#endregion #endregion
#region step2. DB及電站編號找出該電站的控制器 #region step2. DB及電站編號找出該電站的控制器
@ -103,7 +101,7 @@ namespace SolarPower.Quartz.Jobs
if (string.IsNullOrEmpty(exist)) if (string.IsNullOrEmpty(exist))
{ {
logger.LogError("【CalcPowerStationJob】【查無電站[{0}]的s{0}01_station資料表】", powerStation.Code); logger.LogError($"【CalcPowerStationJob】【查無電站[{powerStation.Code}]的s{powerStation.Code}01_station資料表】");
} }
else else
{ {
@ -139,24 +137,24 @@ namespace SolarPower.Quartz.Jobs
{ {
case (int)SolarTypeEnum.SelfSold: //自建躉售 case (int)SolarTypeEnum.SelfSold: //自建躉售
if (lastmoneyhistorybyhour != null) //if (lastmoneyhistorybyhour != null)
{ //{
history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate; // history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate;
history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate; // history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate;
} //}
else //else
{ //{
history.TODAYMONEY = history.KWH * powerStation.PowerRate; // history.TODAYMONEY = history.KWH * powerStation.PowerRate;
history.TOTALMONEY = history.KWH * powerStation.PowerRate; // history.TOTALMONEY = history.KWH * powerStation.PowerRate;
} //}
//今日發電金額 計算方式todaykWh * 授電費率,如有上筆資料,需累加 上一筆金額 //今日發電金額 計算方式todaykWh * 授電費率
//calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate; calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate;
calcPowerStation.Today_Money = history.TODAYMONEY; //calcPowerStation.Today_Money = history.TODAYMONEY;
////總發電金額 計算方式totalkWh * 授電費率,如有上筆資料,需累加 上一筆金額 ////總發電金額 計算方式totalkWh * 授電費率
//calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate; calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate;
calcPowerStation.Total_Money = history.TOTALMONEY; //calcPowerStation.Total_Money = history.TOTALMONEY;
break; break;
case (int)SolarTypeEnum.HireSold: //租建躉售 case (int)SolarTypeEnum.HireSold: //租建躉售
//找出該電站的所有土地房屋資訊 //找出該電站的所有土地房屋資訊
@ -170,43 +168,49 @@ namespace SolarPower.Quartz.Jobs
} }
//avgLeaseRate = sumLeaseRate / landBuildings.Count(); //avgLeaseRate = sumLeaseRate / landBuildings.Count();
if (lastmoneyhistorybyhour != null) //if (lastmoneyhistorybyhour != null)
{ //{
history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate; // history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate;
history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate; // history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate;
//今日發電金額計算方式todaykWh * 出借費率(各個土地房屋租借比率平均) // //今日發電金額計算方式todaykWh * 出借費率(各個土地房屋租借比率平均)
calcPowerStation.Today_Money = lastmoneyhistorybyhour.TODAYMONEY + (history.KWH * powerStation.PowerRate * sumLeaseRate); // calcPowerStation.Today_Money = lastmoneyhistorybyhour.TODAYMONEY + (history.KWH * powerStation.PowerRate * sumLeaseRate);
//總發電金額 計算方式totalkWh * 授電費率 // //總發電金額 計算方式totalkWh * 授電費率
calcPowerStation.Total_Money = lastmoneyhistorybyhour.TOTALMONEY + (history.KWH * powerStation.PowerRate * sumLeaseRate); // calcPowerStation.Total_Money = lastmoneyhistorybyhour.TOTALMONEY + (history.KWH * powerStation.PowerRate * sumLeaseRate);
} //}
else //else
{ //{
history.TODAYMONEY = history.KWH * powerStation.PowerRate; // history.TODAYMONEY = history.KWH * powerStation.PowerRate;
history.TOTALMONEY = history.KWH * powerStation.PowerRate; // history.TOTALMONEY = history.KWH * powerStation.PowerRate;
// calcPowerStation.Today_Money = history.KWH * powerStation.PowerRate * sumLeaseRate;
// calcPowerStation.Total_Money = history.KWH * powerStation.PowerRate * sumLeaseRate;
//}
calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate * sumLeaseRate;
calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate * sumLeaseRate;
calcPowerStation.Today_Money = history.KWH * powerStation.PowerRate * sumLeaseRate;
calcPowerStation.Total_Money = history.KWH * powerStation.PowerRate * sumLeaseRate;
}
break; break;
case (int)SolarTypeEnum.SelfUse: //自建自用 case (int)SolarTypeEnum.SelfUse: //自建自用
if (lastmoneyhistorybyhour != null) //if (lastmoneyhistorybyhour != null)
{ //{
history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate; // history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate;
history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate; // history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate;
} //}
else //else
{ //{
history.TODAYMONEY = history.KWH * powerStation.PowerRate; // history.TODAYMONEY = history.KWH * powerStation.PowerRate;
history.TOTALMONEY = history.KWH * powerStation.PowerRate; // history.TOTALMONEY = history.KWH * powerStation.PowerRate;
} //}
//今日發電金額 計算方式todaykWh * 授電費率 //今日發電金額 計算方式todaykWh * 授電費率
calcPowerStation.Today_Money = history.TODAYMONEY; //calcPowerStation.Today_Money = history.TODAYMONEY;
calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate;
//總發電金額 計算方式totalkWh * 授電費率 //總發電金額 計算方式totalkWh * 授電費率
calcPowerStation.Total_Money = history.TOTALMONEY; //calcPowerStation.Total_Money = history.TOTALMONEY;
calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate;
break; break;
} }
#endregion #endregion
@ -225,29 +229,24 @@ namespace SolarPower.Quartz.Jobs
carbonRate = Convert.ToDouble(await powerStationRepository.GetOneVariableByName("CarbonRate")); carbonRate = Convert.ToDouble(await powerStationRepository.GetOneVariableByName("CarbonRate"));
history.CARBON = history.KWH * carbonRate; history.CARBON = history.KWH * carbonRate;
if (lastmoneyhistorybyhour != null) //if (lastmoneyhistorybyhour != null)
{ //{
history.TODAYCARBON = lastmoneyhistorybyhour.TODAYCARBON + history.KWH * carbonRate; // history.TODAYCARBON = lastmoneyhistorybyhour.TODAYCARBON + history.KWH * carbonRate;
history.TOTALCARBON = lastmoneyhistorybyhour.TOTALCARBON + history.KWH * carbonRate; // history.TOTALCARBON = lastmoneyhistorybyhour.TOTALCARBON + history.KWH * carbonRate;
//}
//else
//{
// history.TODAYCARBON = history.KWH * carbonRate;
// history.TOTALCARBON = history.KWH * carbonRate;
//}
//今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值] //今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值]
calcPowerStation.Today_Carbon = history.TODAYCARBON; //calcPowerStation.Today_Carbon = history.TODAYCARBON;
calcPowerStation.Today_Carbon = history.TodayKWh * carbonRate;
//總減碳量(總發電量 * (0.554/1000)[抓資料庫值] //總減碳量(總發電量 * (0.554/1000)[抓資料庫值]
calcPowerStation.Total_Carbon = history.TOTALCARBON; //calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate;
} calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate;
else
{
history.TODAYCARBON = history.KWH * carbonRate;
history.TOTALCARBON = history.KWH * carbonRate;
//今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值]
calcPowerStation.Today_Carbon = history.TODAYCARBON;
history.CARBON = history.KWH * carbonRate;
//總減碳量(總發電量 * (0.554/1000)[抓資料庫值]
calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate;
}
#endregion #endregion
@ -269,7 +268,7 @@ namespace SolarPower.Quartz.Jobs
var sensoravg_table_exist = await powerStationRepository.ExistTable(powerStation.SiteDB, sensoravg_table_name); var sensoravg_table_exist = await powerStationRepository.ExistTable(powerStation.SiteDB, sensoravg_table_name);
if (string.IsNullOrEmpty(sensoravg_table_exist)) if (string.IsNullOrEmpty(sensoravg_table_exist))
{ {
logger.LogError("【CalcPowerStationJob】【查無電站[0]的s{0}01_sensoravg資料表】", powerStation.Code); logger.LogError($"【CalcPowerStationJob】【查無電站[{powerStation.Code}]的s{powerStation.Code}01_sensoravg資料表】");
} }
else else
{ {
@ -534,7 +533,7 @@ namespace SolarPower.Quartz.Jobs
var exist_meter_table = await powerStationRepository.ExistTable(powerStation.SiteDB, meter_table_name); var exist_meter_table = await powerStationRepository.ExistTable(powerStation.SiteDB, meter_table_name);
if (string.IsNullOrEmpty(exist_meter_table)) if (string.IsNullOrEmpty(exist_meter_table))
{ {
logger.LogError("【CalcPowerStationJob】【查無電站[{0}]的s{0}01_meter資料表】", powerStation.Code); logger.LogError($"【CalcPowerStationJob】【查無電站[{powerStation.Code}]的s{powerStation.Code}01_meter資料表】");
} }
else else
{ {

View File

@ -38,8 +38,8 @@ namespace SolarPower.Repository.Implement
SUM(TOTALMONEY) AS All_money, SUM(TOTALMONEY) AS All_money,
SUM(TOTALKWH) AS All_kwh, SUM(TOTALKWH) AS All_kwh,
SUM(TOTALCARBON) AS All_Carbon SUM(TOTALCARBON) AS All_Carbon
from power_station_history_month from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN (8) GROUP BY PowerStationId) a
WHERE PowerStationId IN @ids LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP
) )
AS m, AS m,
( (

View File

@ -432,7 +432,7 @@
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney")) @if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{ {
<text> <text>
$('#card_' + val.id).find('#PowerRate').html((val.today_kWh * val.powerRate).toFixed()); $('#card_' + val.id).find('#PowerRate').html((val.today_Money).toFixed());
</text> </text>
} }
$('#card_' + val.id).find('#PR').html(val.today_PR); $('#card_' + val.id).find('#PR').html(val.today_PR);