Merge branch 'master' of https://github.com/shanghohui-Company/SolarPower
This commit is contained in:
commit
05e9a1b09e
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.Company;
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Models.User;
|
||||
using SolarPower.Repository.Interface;
|
||||
@ -124,6 +125,37 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ApiResult<List<CompanySelectItemList>>> GetCompanySelectOptionListAsync()
|
||||
{
|
||||
ApiResult<List<CompanySelectItemList>> apiResult = new ApiResult<List<CompanySelectItemList>>();
|
||||
|
||||
try
|
||||
{
|
||||
var companySelectItemLists = new List<CompanySelectItemList>();
|
||||
|
||||
if (!IsPlatformLayer(myUser.Role.Layer))
|
||||
{
|
||||
companySelectItemLists = await powerStationRepository.GetCompanySelectOptionListAsync(myUser.CompanyId);
|
||||
}
|
||||
else
|
||||
{
|
||||
companySelectItemLists = await powerStationRepository.GetCompanySelectOptionListAsync(0);
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = companySelectItemLists;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取裝置類型下拉選單
|
||||
/// </summary>
|
||||
|
||||
@ -363,7 +363,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
calcPowerStation.TodayWeatherTemp = Convert.ToDouble(Location.WeatherElement[0].ElementValue);
|
||||
weatherObservation.PowerStationId = powerStation.Id;
|
||||
weatherObservation.Temp = Convert.ToDouble(Location.WeatherElement[0].ElementValue);
|
||||
weatherObservation.ObsTime = Convert.ToInt32(Location.Time.ObsTime.Substring(0, 4)) < 1970 ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : Location.Time.ObsTime;
|
||||
weatherObservation.ObsTime = !string.IsNullOrEmpty(Location.Time.ObsTime)? Convert.ToInt32(Location.Time.ObsTime.Substring(0, 4)) >= 1971 ? Location.Time.ObsTime : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
calcPowerStation.WeathersStationId = powerStation.WeathersStationId;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -608,7 +608,7 @@ namespace SolarPower.Repository.Implement
|
||||
, (DENSE_RANK() OVER(ORDER BY C.TIMESTAMP)) - 1 AS PreROWID,
|
||||
C.TIMESTAMP,{kwh} AS KWH,C.SOLARHOUR,C.PR,P.Irradiance,P.Temperature AS Temp
|
||||
FROM {usedb} C
|
||||
LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}')
|
||||
LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}') AND P.PowerStationId = C.PowerStationId
|
||||
WHERE C.PowerStationId = {post.PowerstationId}{range2} GROUP BY C.TIMESTAMP ORDER BY C.TIMESTAMP
|
||||
) A
|
||||
RIGHT OUTER JOIN
|
||||
@ -617,7 +617,7 @@ namespace SolarPower.Repository.Implement
|
||||
, (DENSE_RANK() OVER(ORDER BY C.TIMESTAMP)) - 1 AS PreROWID,
|
||||
C.TIMESTAMP,{kwh} AS KWH,C.SOLARHOUR,C.PR,P.Irradiance,P.Temperature AS Temp
|
||||
FROM {usedb} C
|
||||
LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}')
|
||||
LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}') AND P.PowerStationId = C.PowerStationId
|
||||
WHERE C.PowerStationId = {post.PowerstationId}{range2} GROUP BY C.TIMESTAMP ORDER BY C.TIMESTAMP
|
||||
) B
|
||||
ON A.ROWID = B.PreROWID
|
||||
|
||||
@ -12,6 +12,7 @@ using System.Threading.Tasks;
|
||||
using System.Text.Json;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.Role;
|
||||
using SolarPower.Models.Company;
|
||||
|
||||
namespace SolarPower.Repository.Implement
|
||||
{
|
||||
@ -54,6 +55,8 @@ namespace SolarPower.Repository.Implement
|
||||
sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')";
|
||||
}
|
||||
|
||||
sql += " ORDER BY c.Priority";
|
||||
|
||||
var myPowerStationInfos = conn.Query<MyPowerStationInfo>(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id, Filter = filter }).ToList();
|
||||
|
||||
var myPowerStationInfos_group = myPowerStationInfos.GroupBy(x => x.CityId);
|
||||
@ -132,6 +135,35 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得下拉式公司選單,須為Deleted: 0
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CompanySelectItemList>> GetCompanySelectOptionListAsync(int companyId = 0)
|
||||
{
|
||||
List<CompanySelectItemList> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT Id AS Value, CONCAT(Name, '/', SiteDB) AS Text FROM company WHERE Deleted = 0";
|
||||
|
||||
if (companyId > 0)
|
||||
{
|
||||
sql += " AND Id = @SelectedCompanyId";
|
||||
}
|
||||
|
||||
result = (await conn.QueryAsync<CompanySelectItemList>(sql, new { SelectedCompanyId = companyId })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過編號取得,縣市資訊
|
||||
/// </summary>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.Company;
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Models.User;
|
||||
using System;
|
||||
@ -34,6 +35,13 @@ namespace SolarPower.Repository.Interface
|
||||
|
||||
Task<List<OperationPersonnelSelectItemList>> GetOperationPersonnelSelectOptionListAsync(int powerStationId);
|
||||
|
||||
/// <summary>
|
||||
/// 取得下拉式公司選單,須為Deleted: 0、Status: 1
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<CompanySelectItemList>> GetCompanySelectOptionListAsync(int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 透過編號取得,縣市資訊
|
||||
/// </summary>
|
||||
|
||||
@ -243,7 +243,7 @@
|
||||
$("#today_carbon").html(mapOverview.today_carbon.toFixed(2));
|
||||
$("#total_carbon").html(mapOverview.total_carbon.toFixed(2));
|
||||
$("#total_power_station_count").html(mapOverview.totalPowerStationCount);
|
||||
$("#total_capacity").html(mapOverview.totalCapacity);
|
||||
$("#total_capacity").html(mapOverview.totalCapacity.toFixed(2));
|
||||
$("#update_at").html(mapOverview.updatedAt);
|
||||
|
||||
capacityTable.clear().rows.add(mapOverview.capacityDataTables).draw();
|
||||
|
||||
@ -100,7 +100,7 @@
|
||||
stationId = url.searchParams.get('stationId');
|
||||
|
||||
//#region 預先載入公司下拉式選單select_option
|
||||
var url_company_select_option = "/Company/GetCompanySelectOptionList";
|
||||
var url_company_select_option = "/PowerStation/GetCompanySelectOptionList";
|
||||
$.get(url_company_select_option, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
@ -972,118 +972,31 @@
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser)
|
||||
{
|
||||
<text>
|
||||
Swal.fire(
|
||||
{
|
||||
title: "",
|
||||
text: "你確定是否要將該電站加入至【" + ps_company_text + "】?",
|
||||
type: "question",
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "是",
|
||||
cancelButtonText: "否"
|
||||
}).then(function (result) {
|
||||
if (result.value) {
|
||||
var url = "/PowerStation/SavePowerStationInfo";
|
||||
|
||||
var send_data = {
|
||||
Id: stationId,
|
||||
CityId: $("#select_city").val(),
|
||||
AreaId: $("#select_area").val(),
|
||||
Address: $("#address_detail").val(),
|
||||
Name: $("#power_station_name").val(),
|
||||
IsEscrow: $('#check_escrow').is(':checked') ? 1 : 0,
|
||||
ElectricityMeterAt: $("#electricity_meter_at").val(),
|
||||
EstimatedRecoveryTime: $("#estimated_recovery_time").val(),
|
||||
GeneratingCapacity: $("#generating_capacity").val(),
|
||||
EscrowName: $('#check_escrow').is(':checked') ? $("#escrow_name").val() : "",
|
||||
PowerRate: $("#power_rate").val(),
|
||||
Coordinate: $("#coordinate").val(),
|
||||
OperationPersonnelIds: $("#power_station_operation_personnel").val(),
|
||||
InverterBrand: $("#inverter_brand").val(),
|
||||
InverterProductModel: $("#inverter_product_model").val(),
|
||||
InverterAmount: $("#inverter_amount").val(),
|
||||
PhotovoltaicPanelBrand: $("#photovoltaic_panel_brand").val(),
|
||||
PhotovoltaicPanelSpecification: $("#photovoltaic_panel_specification").val(),
|
||||
PhotovoltaicPanelAmount: $("#photovoltaic_panel_amount").val(),
|
||||
PhotovoltaicPanelProductModel: $("#photovoltaic_panel_product_model").val(),
|
||||
SolarType: $("#select_solar_tpye").val(),
|
||||
line_token: $("#line_token").val(),
|
||||
Estimate_kwh: $("#estimate_kwh").val(),
|
||||
EstimateEfficacy: $("#estimate_efficacy").val(),
|
||||
CompanyId: $("#select_power_station_company").val(),
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
|
||||
if (stationId == "new") {
|
||||
window.location = "/PowerStation/Edit?stationId=" + rel.data.id
|
||||
} else {
|
||||
//回填資料
|
||||
powerStationData = rel.data;
|
||||
SetStationInfo();
|
||||
ChangeMode("station_info", "view");
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
if (stationId == 'new') {
|
||||
Swal.fire(
|
||||
{
|
||||
title: "",
|
||||
text: "你確定是否要將該電站加入至【" + ps_company_text + "】?",
|
||||
type: "question",
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "是",
|
||||
cancelButtonText: "否"
|
||||
}).then(function (result) {
|
||||
if (result.value) {
|
||||
PostPowerStationDate();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
PostPowerStationDate();
|
||||
}
|
||||
</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>
|
||||
var url = "/PowerStation/SavePowerStationInfo";
|
||||
|
||||
var send_data = {
|
||||
Id: stationId,
|
||||
CityId: $("#select_city").val(),
|
||||
AreaId: $("#select_area").val(),
|
||||
Address: $("#address_detail").val(),
|
||||
Name: $("#power_station_name").val(),
|
||||
IsEscrow: $('#check_escrow').is(':checked') ? 1 : 0,
|
||||
ElectricityMeterAt: $("#electricity_meter_at").val(),
|
||||
EstimatedRecoveryTime: $("#estimated_recovery_time").val(),
|
||||
GeneratingCapacity: $("#generating_capacity").val(),
|
||||
EscrowName: $('#check_escrow').is(':checked') ? $("#escrow_name").val() : "",
|
||||
PowerRate: $("#power_rate").val(),
|
||||
Coordinate: $("#coordinate").val(),
|
||||
OperationPersonnelIds: $("#power_station_operation_personnel").val(),
|
||||
InverterBrand: $("#inverter_brand").val(),
|
||||
InverterProductModel: $("#inverter_product_model").val(),
|
||||
InverterAmount: $("#inverter_amount").val(),
|
||||
PhotovoltaicPanelBrand: $("#photovoltaic_panel_brand").val(),
|
||||
PhotovoltaicPanelSpecification: $("#photovoltaic_panel_specification").val(),
|
||||
PhotovoltaicPanelAmount: $("#photovoltaic_panel_amount").val(),
|
||||
PhotovoltaicPanelProductModel: $("#photovoltaic_panel_product_model").val(),
|
||||
SolarType: $("#select_solar_tpye").val(),
|
||||
line_token: $("#line_token").val(),
|
||||
Estimate_kwh: $("#estimate_kwh").val(),
|
||||
EstimateEfficacy: $("#estimate_efficacy").val(),
|
||||
CompanyId: $("#select_power_station_company").val(),
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
|
||||
if (stationId == "new") {
|
||||
window.location = "/PowerStation/Edit?stationId=" + rel.data.id
|
||||
} else {
|
||||
//回填資料
|
||||
powerStationData = rel.data;
|
||||
SetStationInfo();
|
||||
ChangeMode("station_info", "view");
|
||||
}
|
||||
}, 'json');
|
||||
PostPowerStationDate();
|
||||
</text>
|
||||
}
|
||||
|
||||
@ -1091,6 +1004,56 @@
|
||||
}
|
||||
//#endregion
|
||||
|
||||
function PostPowerStationDate() {
|
||||
var url = "/PowerStation/SavePowerStationInfo";
|
||||
|
||||
var send_data = {
|
||||
Id: stationId,
|
||||
CityId: $("#select_city").val(),
|
||||
AreaId: $("#select_area").val(),
|
||||
Address: $("#address_detail").val(),
|
||||
Name: $("#power_station_name").val(),
|
||||
IsEscrow: $('#check_escrow').is(':checked') ? 1 : 0,
|
||||
ElectricityMeterAt: $("#electricity_meter_at").val(),
|
||||
EstimatedRecoveryTime: $("#estimated_recovery_time").val(),
|
||||
GeneratingCapacity: $("#generating_capacity").val(),
|
||||
EscrowName: $('#check_escrow').is(':checked') ? $("#escrow_name").val() : "",
|
||||
PowerRate: $("#power_rate").val(),
|
||||
Coordinate: $("#coordinate").val(),
|
||||
OperationPersonnelIds: $("#power_station_operation_personnel").val(),
|
||||
InverterBrand: $("#inverter_brand").val(),
|
||||
InverterProductModel: $("#inverter_product_model").val(),
|
||||
InverterAmount: $("#inverter_amount").val(),
|
||||
PhotovoltaicPanelBrand: $("#photovoltaic_panel_brand").val(),
|
||||
PhotovoltaicPanelSpecification: $("#photovoltaic_panel_specification").val(),
|
||||
PhotovoltaicPanelAmount: $("#photovoltaic_panel_amount").val(),
|
||||
PhotovoltaicPanelProductModel: $("#photovoltaic_panel_product_model").val(),
|
||||
SolarType: $("#select_solar_tpye").val(),
|
||||
line_token: $("#line_token").val(),
|
||||
Estimate_kwh: $("#estimate_kwh").val(),
|
||||
EstimateEfficacy: $("#estimate_efficacy").val(),
|
||||
CompanyId: $("#select_power_station_company").val(),
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
|
||||
if (stationId == "new") {
|
||||
window.location = "/PowerStation/Edit?stationId=" + rel.data.id
|
||||
} else {
|
||||
//回填資料
|
||||
powerStationData = rel.data;
|
||||
SetStationInfo();
|
||||
ChangeMode("station_info", "view");
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
//#region 儲存能源局台電資料資訊
|
||||
function SaveBoETPCInfo() {
|
||||
var url = "/PowerStation/SaveBoETPCInfo";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user