Merge branch 'master' of https://github.com/shanghohui-Company/SolarPower
This commit is contained in:
commit
7dcca6b66d
@ -280,9 +280,9 @@ namespace SolarPower.Controllers
|
||||
|
||||
var id = await companyRepository.AddOneAsync(company, properties);
|
||||
|
||||
|
||||
UpdateCompany updateCompany;
|
||||
//處裡公司Logo圖片
|
||||
|
||||
#region 處理公司Logo圖片
|
||||
if (post.LogoFile != null)
|
||||
{
|
||||
var split = post.LogoFile.FileName.Split(".");
|
||||
@ -309,6 +309,7 @@ namespace SolarPower.Controllers
|
||||
|
||||
await companyRepository.UpdateCompany(updateCompany, properties);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 幫別間公司新增"公司管理員"之角色
|
||||
Role role = new Role()
|
||||
@ -332,23 +333,24 @@ namespace SolarPower.Controllers
|
||||
|
||||
#region 新增公司DB及Table,公司DB編號規則 solar_com_(公司編號共四碼),ex:solar_com_0001
|
||||
|
||||
var relationalDB = "solar_com_" + id.ToString().Trim().PadLeft(4, '0');
|
||||
//var siteDB = "solar_com" + id.ToString().Trim().PadLeft(4, '0');
|
||||
var siteDB = "solar_com" + id.ToString().Trim().PadLeft(4, '0') + "_test";
|
||||
//修改
|
||||
updateCompany = new UpdateCompany()
|
||||
{
|
||||
Id = id,
|
||||
RelationalDB = relationalDB
|
||||
SiteDB = siteDB
|
||||
};
|
||||
|
||||
properties = new List<string>()
|
||||
{
|
||||
"Id",
|
||||
"RelationalDB"
|
||||
"SiteDB"
|
||||
};
|
||||
|
||||
await companyRepository.UpdateCompany(updateCompany, properties);
|
||||
|
||||
await companyRepository.CreatCompanyDB(relationalDB);
|
||||
await companyRepository.CreatCompanyDB(siteDB);
|
||||
#endregion
|
||||
|
||||
apiResult.Code = "0000";
|
||||
@ -357,7 +359,7 @@ namespace SolarPower.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
#region 修改使用者
|
||||
#region 修改公司
|
||||
|
||||
//先檢查統編是否已被使用
|
||||
var exist = await companyRepository.GetOneNormalSimpleCompanyByTaxIDNumber(post.TaxIDNumber);
|
||||
|
||||
@ -30,7 +30,6 @@ namespace SolarPower.Controllers
|
||||
|
||||
protected ILogger<T> Logger => _logger ?? (_logger = HttpContext?.RequestServices.GetService<ILogger<T>>());
|
||||
private IUserRepository userRepository => HttpContext?.RequestServices.GetService<IUserRepository>();
|
||||
private IOperationRepository operationRepository => HttpContext?.RequestServices.GetService<IOperationRepository>();
|
||||
private ICompanyRepository companyRepository => HttpContext?.RequestServices.GetService<ICompanyRepository>();
|
||||
private IRoleRepository roleRepository => HttpContext?.RequestServices.GetService<IRoleRepository>();
|
||||
private IOperatorLogRepository operatorLogRepository => HttpContext?.RequestServices.GetService<IOperatorLogRepository>();
|
||||
@ -131,7 +130,7 @@ namespace SolarPower.Controllers
|
||||
/// </summary>
|
||||
/// <param name="current">當前的</param>
|
||||
/// <param name="pad"></param>
|
||||
/// <param name="direction">0: PadLeft;0: PadRight</param>
|
||||
/// <param name="direction">0: PadLeft;1: PadRight</param>
|
||||
/// <returns></returns>
|
||||
public string GetLastSerialNumber(string current = "", int pad = 4, byte direction = 0)
|
||||
{
|
||||
@ -145,7 +144,7 @@ namespace SolarPower.Controllers
|
||||
tempSerialNumber = 1;
|
||||
}
|
||||
|
||||
if (direction == 0)
|
||||
if(direction == 0)
|
||||
{
|
||||
return tempSerialNumber.ToString().Trim().PadLeft(pad, '0');
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ namespace SolarPower.Controllers
|
||||
public class PowerStationController : MyBaseController<PowerStationController>
|
||||
{
|
||||
private readonly IUserRepository userRepository;
|
||||
private readonly ICompanyRepository companyRepository;
|
||||
private readonly IPowerStationRepository powerStationRepository;
|
||||
private string boeFilePath = "/upload/power_station/boe_file/";
|
||||
private string stationImageFilePath = "/upload/power_station/";
|
||||
@ -25,9 +26,11 @@ namespace SolarPower.Controllers
|
||||
|
||||
public PowerStationController(
|
||||
IUserRepository userRepository,
|
||||
ICompanyRepository companyRepository,
|
||||
IPowerStationRepository powerStationRepository) : base()
|
||||
{
|
||||
this.userRepository = userRepository;
|
||||
this.companyRepository = companyRepository;
|
||||
this.powerStationRepository = powerStationRepository;
|
||||
|
||||
powerSationSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "power_station");
|
||||
@ -37,11 +40,6 @@ namespace SolarPower.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Add()
|
||||
{
|
||||
return View("~/Views/PowerStation/PowerStationAdd.cshtml");
|
||||
}
|
||||
|
||||
public IActionResult Edit()
|
||||
{
|
||||
return View("~/Views/PowerStation/PowerStationEdit.cshtml");
|
||||
@ -73,6 +71,7 @@ namespace SolarPower.Controllers
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取裝置類型下拉選單
|
||||
/// </summary>
|
||||
@ -209,6 +208,9 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.Id);
|
||||
|
||||
//取得該公司DB Name
|
||||
var company = await companyRepository.GetOneAsync(myUser.CompanyId);
|
||||
|
||||
if (powerStation == null)
|
||||
{
|
||||
if (post.Id != 0)
|
||||
@ -219,20 +221,13 @@ namespace SolarPower.Controllers
|
||||
}
|
||||
|
||||
#region 新增電站資訊
|
||||
|
||||
//取得電站該縣市的Zipcode
|
||||
var zipcode = await powerStationRepository.GetCityAreaZipcodeAsync(post.AreaId);
|
||||
|
||||
//取得電站該縣市地區最後流水號
|
||||
var lastSerialNumber = await powerStationRepository.GetLastSerialNumberByCityAreaIdAsync(post.CityId, post.AreaId);
|
||||
var tempSerialNumber = 0;
|
||||
if (!string.IsNullOrEmpty(lastSerialNumber))
|
||||
{
|
||||
tempSerialNumber = Convert.ToInt32(lastSerialNumber) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tempSerialNumber = 1;
|
||||
}
|
||||
var currentSerialNumber = await powerStationRepository.GetLastSerialNumberByCityAreaIdAsync(post.CityId, post.AreaId);
|
||||
|
||||
var tempSerialNumber = GetLastSerialNumber(currentSerialNumber);
|
||||
|
||||
var codeFormat = "{0}-{1}-{2}";
|
||||
|
||||
@ -243,8 +238,8 @@ namespace SolarPower.Controllers
|
||||
AreaId = post.AreaId,
|
||||
Address = post.Address,
|
||||
Name = post.Name,
|
||||
Code = String.Format(codeFormat, zipcode.City, zipcode.Area, tempSerialNumber.ToString().PadLeft(4, '0')),
|
||||
SerialNumber = tempSerialNumber.ToString().PadLeft(4, '0'),
|
||||
Code = String.Format(codeFormat, zipcode.City, zipcode.Area, tempSerialNumber),
|
||||
SerialNumber = tempSerialNumber,
|
||||
IsEscrow = post.IsEscrow,
|
||||
EscrowName = post.EscrowName,
|
||||
ElectricityMeterAt = post.ElectricityMeterAt,
|
||||
@ -259,6 +254,7 @@ namespace SolarPower.Controllers
|
||||
PhotovoltaicPanelProductModel = post.PhotovoltaicPanelProductModel,
|
||||
PhotovoltaicPanelSpecification = post.PhotovoltaicPanelSpecification,
|
||||
PhotovoltaicPanelAmount = post.PhotovoltaicPanelAmount,
|
||||
SiteDB = company.SiteDB,
|
||||
CreatedBy = myUser.Id
|
||||
};
|
||||
|
||||
@ -285,10 +281,11 @@ namespace SolarPower.Controllers
|
||||
"PhotovoltaicPanelProductModel",
|
||||
"PhotovoltaicPanelSpecification",
|
||||
"PhotovoltaicPanelAmount",
|
||||
"SiteDB",
|
||||
"CreatedBy"
|
||||
};
|
||||
|
||||
var id = await powerStationRepository.AddOneAsync(powerStation, properties);
|
||||
var id = await powerStationRepository.AddOnePowerStationAsync(powerStation, properties, company.SiteDB);
|
||||
|
||||
#region 新增土地與房屋資訊
|
||||
var city = await powerStationRepository.GetOneCityByIdAsync(post.CityId);
|
||||
@ -307,7 +304,7 @@ namespace SolarPower.Controllers
|
||||
"PowerStationId",
|
||||
"CreatedBy"
|
||||
};
|
||||
await powerStationRepository.AddOneLandBuildingInfo(landBuilding, landBuildingProperties);
|
||||
await powerStationRepository.AddOneLandBuildingInfo(landBuilding, landBuildingProperties, company.SiteDB);
|
||||
#endregion
|
||||
|
||||
#region 新增運維人員
|
||||
@ -333,7 +330,7 @@ namespace SolarPower.Controllers
|
||||
"CreatedBy",
|
||||
};
|
||||
|
||||
await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, properties);
|
||||
await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, operationPersonnelProperties, company.SiteDB);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -401,11 +398,11 @@ namespace SolarPower.Controllers
|
||||
"UpdatedBy",
|
||||
};
|
||||
|
||||
await powerStationRepository.UpdatePowerStationInfo(update, properties);
|
||||
await powerStationRepository.UpdatePowerStationInfo(update, properties, powerStation.SiteDB);
|
||||
|
||||
List<int> origOperationPersonnels = null; //原先的運維人員
|
||||
|
||||
origOperationPersonnels = await powerStationRepository.GetOperationPersonnelIdsByPowerStatioinId(powerStation.Id);
|
||||
origOperationPersonnels = await powerStationRepository.GetOperationPersonnelIdsByPowerStatioinId(powerStation.Id, powerStation.SiteDB);
|
||||
|
||||
//判斷新進來的資料是否要歸類到新增 or 刪除
|
||||
#region 刪除電站運維人員編號
|
||||
@ -424,7 +421,7 @@ namespace SolarPower.Controllers
|
||||
}
|
||||
|
||||
//刪除運維人員
|
||||
await powerStationRepository.DeleteOperationPersonnel(deleteOperationPersonnels);
|
||||
await powerStationRepository.DeleteOperationPersonnel(deleteOperationPersonnels, powerStation.SiteDB);
|
||||
#endregion
|
||||
|
||||
#region 新增電站運維人員
|
||||
@ -452,7 +449,7 @@ namespace SolarPower.Controllers
|
||||
"CreatedBy",
|
||||
};
|
||||
|
||||
await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, operationPersonnelProperties);
|
||||
await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, operationPersonnelProperties, powerStation.SiteDB);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -559,11 +556,13 @@ namespace SolarPower.Controllers
|
||||
"UpdatedBy",
|
||||
};
|
||||
|
||||
await powerStationRepository.UpdateBoETPCInfo(update, properties);
|
||||
await powerStationRepository.UpdateBoETPCInfo(update, properties, powerStation.SiteDB);
|
||||
#endregion
|
||||
}
|
||||
|
||||
//重新取得資料
|
||||
powerStation = await powerStationRepository.GetOneAsync(powerStation.Id);
|
||||
|
||||
//替能源局換檔案路徑
|
||||
if (!string.IsNullOrEmpty(powerStation.BoEFile))
|
||||
{
|
||||
@ -619,7 +618,7 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
landBuilding = await powerStationRepository.GetOneLandBuildingInfo(post.Id);
|
||||
landBuilding = await powerStationRepository.GetOneLandBuildingInfo(post.Id, powerStation.SiteDB);
|
||||
|
||||
if (landBuilding == null)
|
||||
{
|
||||
@ -659,7 +658,7 @@ namespace SolarPower.Controllers
|
||||
"CreatedBy"
|
||||
};
|
||||
|
||||
var id = await powerStationRepository.AddOneLandBuildingInfo(landBuilding, properties);
|
||||
var id = await powerStationRepository.AddOneLandBuildingInfo(landBuilding, properties, powerStation.SiteDB);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
@ -695,7 +694,7 @@ namespace SolarPower.Controllers
|
||||
"UpdatedBy",
|
||||
};
|
||||
|
||||
await powerStationRepository.UpdateLandBuildingInfo(update, properties);
|
||||
await powerStationRepository.UpdateLandBuildingInfo(update, properties, powerStation.SiteDB);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "修改成功";
|
||||
@ -715,6 +714,7 @@ namespace SolarPower.Controllers
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增/修改 運維資料
|
||||
/// </summary>
|
||||
@ -723,8 +723,13 @@ namespace SolarPower.Controllers
|
||||
public async Task<ApiResult<string>> SaveOperation(OperationInfo post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
PowerStation powerStation = null;
|
||||
|
||||
try
|
||||
{
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
if (post.Id == 0)
|
||||
{
|
||||
OperationInfo operation = new OperationInfo()
|
||||
@ -749,7 +754,7 @@ namespace SolarPower.Controllers
|
||||
"PowerStationId",
|
||||
"Type"
|
||||
};
|
||||
await powerStationRepository.AddOperation(operation, properties);
|
||||
await powerStationRepository.AddOperation(operation, properties, powerStation.SiteDB);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "新增成功";
|
||||
@ -778,7 +783,7 @@ namespace SolarPower.Controllers
|
||||
"PowerStationId",
|
||||
"Type"
|
||||
};
|
||||
await powerStationRepository.UpdateOperation(operation, properties);
|
||||
await powerStationRepository.UpdateOperation(operation, properties, powerStation.SiteDB);
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
}
|
||||
@ -787,11 +792,15 @@ namespace SolarPower.Controllers
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = exception.ToString();
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 運維資料DataTable
|
||||
/// </summary>
|
||||
@ -802,10 +811,15 @@ namespace SolarPower.Controllers
|
||||
|
||||
List<OperationTable> operationTable = new List<OperationTable>();
|
||||
ApiResult<List<OperationTable>> apiResult = new ApiResult<List<OperationTable>>();
|
||||
|
||||
PowerStation powerStation = null;
|
||||
|
||||
try
|
||||
{
|
||||
apiResult.Code = "0000";
|
||||
operationTable = await powerStationRepository.OperationTable(stationId);
|
||||
|
||||
powerStation = await powerStationRepository.GetOneAsync(stationId);
|
||||
|
||||
operationTable = await powerStationRepository.OperationTable(stationId, powerStation.SiteDB);
|
||||
foreach (OperationTable a in operationTable)
|
||||
{
|
||||
a.Function = @"
|
||||
@ -825,13 +839,15 @@ namespace SolarPower.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = operationTable;
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = exception.ToString();
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "stationId = " + stationId);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
var result = Json(new
|
||||
{
|
||||
@ -840,41 +856,52 @@ namespace SolarPower.Controllers
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得一筆 運維 資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<OperationInfo>> GetOneOperation(int id)
|
||||
public async Task<ApiResult<OperationInfo>> GetOneOperation(PostPowerStationIdAndSelectedId post)
|
||||
{
|
||||
OperationInfo operation = new OperationInfo();
|
||||
ApiResult<OperationInfo> apiResult = new ApiResult<OperationInfo>();
|
||||
|
||||
PowerStation powerStation = null;
|
||||
try
|
||||
{
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
operation = await powerStationRepository.OneOperationInfo(id);
|
||||
var operation = await powerStationRepository.OneOperationInfo(post.SelectedId, powerStation.SiteDB);
|
||||
apiResult.Data = operation;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = exception.ToString();
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刪除 運維 資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<string>> DeleteOneOperation(int id)
|
||||
public async Task<ApiResult<string>> DeleteOneOperation(PostPowerStationIdAndSelectedId post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
OperationInfo operation = new OperationInfo();
|
||||
|
||||
PowerStation powerStation = null;
|
||||
try
|
||||
{
|
||||
operation = await powerStationRepository.OneOperationInfo(id);
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
var operation = await powerStationRepository.OneOperationInfo(post.SelectedId, powerStation.SiteDB);
|
||||
|
||||
if (operation == null)
|
||||
{
|
||||
@ -883,7 +910,7 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await powerStationRepository.DeleteOneOtherTable(operation.Id, "operation_firm");
|
||||
await powerStationRepository.DeleteOneByIdWithCustomDBNameAndTable(operation.Id, powerStation.SiteDB, "operation_firm");
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
@ -892,12 +919,14 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增 / 修改 裝置資料
|
||||
/// </summary>
|
||||
@ -1034,21 +1063,24 @@ namespace SolarPower.Controllers
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除單一土地房屋資訊
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<PowerStation>> DeleteLandBuildingInfo(int id)
|
||||
public async Task<ApiResult<PowerStation>> DeleteLandBuildingInfo(PostPowerStationIdAndSelectedId post)
|
||||
{
|
||||
ApiResult<PowerStation> apiResult = new ApiResult<PowerStation>();
|
||||
|
||||
|
||||
PowerStation powerStation = null;
|
||||
LandBuilding landBuilding;
|
||||
try
|
||||
{
|
||||
landBuilding = await powerStationRepository.GetOneLandBuildingInfo(id);
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
landBuilding = await powerStationRepository.GetOneLandBuildingInfo(post.SelectedId, powerStation.SiteDB);
|
||||
|
||||
if (landBuilding == null)
|
||||
{
|
||||
@ -1057,7 +1089,7 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await powerStationRepository.DeleteOneLandBuildingInfo(landBuilding.Id);
|
||||
await powerStationRepository.DeleteOneLandBuildingInfo(landBuilding.Id, powerStation.SiteDB);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
@ -1067,12 +1099,14 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取單一設備資料
|
||||
/// </summary>
|
||||
@ -1096,6 +1130,7 @@ namespace SolarPower.Controllers
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刪除設備
|
||||
/// </summary>
|
||||
@ -1116,7 +1151,8 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await powerStationRepository.DeleteOneOtherTable(Device.Id, "device");
|
||||
//TODO
|
||||
//await powerStationRepository.DeleteOneByIdWithCustomDBNameAndTable(Device.Id, "device");
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
@ -1131,6 +1167,7 @@ namespace SolarPower.Controllers
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增/修改異常
|
||||
/// </summary>
|
||||
@ -1287,7 +1324,8 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await powerStationRepository.DeleteOneOtherTable(Exception.Id, "power_station_exception");
|
||||
//TODO
|
||||
//await powerStationRepository.DeleteOneOtherTable(Exception.Id, "power_station_exception");
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
@ -1303,7 +1341,6 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 取得所有電站圖片
|
||||
/// </summary>
|
||||
@ -1328,7 +1365,15 @@ namespace SolarPower.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
powerStationImages = await powerStationRepository.GetAllPowerStationImageAsync(powerStationId);
|
||||
|
||||
if(powerStation.CompanyId != myUser.CompanyId)
|
||||
{
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
powerStationImages = await powerStationRepository.GetAllPowerStationImageAsync(powerStationId, powerStation.SiteDB);
|
||||
|
||||
foreach (var stationImage in powerStationImages)
|
||||
{
|
||||
@ -1424,13 +1469,13 @@ namespace SolarPower.Controllers
|
||||
"CreatedBy"
|
||||
};
|
||||
|
||||
await powerStationRepository.AddPowerStationImageAsync(powerStationImages, properties);
|
||||
await powerStationRepository.AddPowerStationImageAsync(powerStationImages, properties, powerStation.SiteDB);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 重新取得圖片資訊
|
||||
powerStationImages = null;
|
||||
powerStationImages = await powerStationRepository.GetAllPowerStationImageAsync(powerStation.Id);
|
||||
powerStationImages = await powerStationRepository.GetAllPowerStationImageAsync(powerStation.Id, powerStation.SiteDB);
|
||||
|
||||
foreach (var stationImage in powerStationImages)
|
||||
{
|
||||
@ -1460,15 +1505,17 @@ namespace SolarPower.Controllers
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<string>> DeletePowerStationImage(int id)
|
||||
public async Task<ApiResult<string>> DeletePowerStationImage(PostPowerStationIdAndSelectedId post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
PowerStation powerStation;
|
||||
PowerStationImage powerStationImage;
|
||||
|
||||
try
|
||||
{
|
||||
powerStationImage = await powerStationRepository.GetOnePowerStationImageAsync(id);
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
powerStationImage = await powerStationRepository.GetOnePowerStationImageAsync(post.SelectedId, powerStation.SiteDB);
|
||||
|
||||
if (powerStationImage == null)
|
||||
{
|
||||
@ -1477,7 +1524,14 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await powerStationRepository.DeleteOnePowerStationImage(id);
|
||||
if (powerStation.CompanyId != myUser.CompanyId)
|
||||
{
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await powerStationRepository.DeleteOnePowerStationImage(powerStationImage.Id, powerStation.SiteDB);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
@ -1486,7 +1540,8 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
@ -1502,11 +1557,13 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
PowerStation powerStation;
|
||||
PowerStationImage powerStationImage;
|
||||
|
||||
try
|
||||
{
|
||||
powerStationImage = await powerStationRepository.GetOnePowerStationImageAsync(post.TargetImageId);
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
powerStationImage = await powerStationRepository.GetOnePowerStationImageAsync(post.TargetImageId, powerStation.SiteDB);
|
||||
|
||||
if (powerStationImage == null)
|
||||
{
|
||||
@ -1515,11 +1572,18 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
if (powerStation.CompanyId != myUser.CompanyId)
|
||||
{
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
UpdataPowerStationImage updata = new UpdataPowerStationImage();
|
||||
List<string> properties = new List<string>();
|
||||
|
||||
//找出原本的圖片
|
||||
var origMainDisplay = await powerStationRepository.GetMainDisplayAsync(post.PowerStationId);
|
||||
var origMainDisplay = await powerStationRepository.GetMainDisplayAsync(post.PowerStationId, powerStation.SiteDB);
|
||||
if (origMainDisplay != null)
|
||||
{
|
||||
updata = new UpdataPowerStationImage()
|
||||
@ -1536,7 +1600,7 @@ namespace SolarPower.Controllers
|
||||
"UpdatedBy"
|
||||
};
|
||||
|
||||
await powerStationRepository.UpdatePowerStationImage(updata, properties);
|
||||
await powerStationRepository.UpdatePowerStationImage(updata, properties, powerStation.SiteDB);
|
||||
}
|
||||
|
||||
// 更新被選擇的圖維卡片顯示圖
|
||||
@ -1554,7 +1618,7 @@ namespace SolarPower.Controllers
|
||||
"UpdatedBy"
|
||||
};
|
||||
|
||||
await powerStationRepository.UpdatePowerStationImage(updata, properties);
|
||||
await powerStationRepository.UpdatePowerStationImage(updata, properties, powerStation.SiteDB);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "修改卡片顯示圖成功";
|
||||
@ -1596,7 +1660,14 @@ namespace SolarPower.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
powerStationSingleLines = await powerStationRepository.GetAllPowerStationSingleLineAsync(powerStationId);
|
||||
if (powerStation.CompanyId != myUser.CompanyId)
|
||||
{
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
powerStationSingleLines = await powerStationRepository.GetAllPowerStationSingleLineAsync(powerStationId, powerStation.SiteDB);
|
||||
|
||||
foreach (var singleLine in powerStationSingleLines)
|
||||
{
|
||||
@ -1692,13 +1763,13 @@ namespace SolarPower.Controllers
|
||||
"CreatedBy"
|
||||
};
|
||||
|
||||
await powerStationRepository.AddPowerStationSingleLineAsync(powerStationSingleLines, properties);
|
||||
await powerStationRepository.AddPowerStationSingleLineAsync(powerStationSingleLines, properties, powerStation.SiteDB);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 重新取得圖片資訊
|
||||
powerStationSingleLines = null;
|
||||
powerStationSingleLines = await powerStationRepository.GetAllPowerStationSingleLineAsync(powerStation.Id);
|
||||
powerStationSingleLines = await powerStationRepository.GetAllPowerStationSingleLineAsync(powerStation.Id, powerStation.SiteDB);
|
||||
|
||||
foreach (var singleLine in powerStationSingleLines)
|
||||
{
|
||||
@ -1728,15 +1799,25 @@ namespace SolarPower.Controllers
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<string>> DeletePowerStationSingleLine(int id)
|
||||
public async Task<ApiResult<string>> DeletePowerStationSingleLine(PostPowerStationIdAndSelectedId post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
PowerStation powerStation;
|
||||
PowerStationSingleLine powerStationSingleLine;
|
||||
|
||||
try
|
||||
{
|
||||
powerStationSingleLine = await powerStationRepository.GetOnePowerStationSingleLineAsync(id);
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
if (powerStation.CompanyId != myUser.CompanyId)
|
||||
{
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
powerStationSingleLine = await powerStationRepository.GetOnePowerStationSingleLineAsync(post.SelectedId, powerStation.SiteDB);
|
||||
|
||||
if (powerStationSingleLine == null)
|
||||
{
|
||||
@ -1745,7 +1826,7 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await powerStationRepository.DeleteOnePowerStationSingleLine(id);
|
||||
await powerStationRepository.DeleteOnePowerStationSingleLine(powerStationSingleLine.Id, powerStation.SiteDB);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
@ -1754,10 +1835,33 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// 取得該使用者可看的所有電站分佈縣市以及各縣市電站數量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<List<SolarCityAmount>>> GetSolarCitySummary()
|
||||
{
|
||||
ApiResult<List<SolarCityAmount>> apiResult = new ApiResult<List<SolarCityAmount>>();
|
||||
List<SolarCityAmount> solaramount = new List<SolarCityAmount>();
|
||||
try
|
||||
{
|
||||
apiResult.Code = "0000";
|
||||
solaramount = await powerStationRepository.GetSolarCitySummary(myUser);
|
||||
apiResult.Data = solaramount;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = exception.ToString();
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,12 +32,12 @@ namespace SolarPower.Helper
|
||||
EDFunction ed = new EDFunction();
|
||||
|
||||
var serverStr = ed.AESDecrypt(dbConfig.Server);
|
||||
var databaseStr = ed.DESDecrypt(dbConfig.Database);
|
||||
var rootStr = ed.DESDecrypt(dbConfig.Root);
|
||||
var passwordStr = ed.DESDecrypt(dbConfig.Password);
|
||||
var databaseStr = ed.AESDecrypt(dbConfig.Database);
|
||||
var rootStr = ed.AESDecrypt(dbConfig.Root);
|
||||
var passwordStr = ed.AESDecrypt(dbConfig.Password);
|
||||
|
||||
//var connStr = $"server={serverStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;";
|
||||
var connStr = @"server=127.0.0.1;port=3308;database=solar_power;user=root;password=00000000;charset=utf8;";
|
||||
var connStr = @"server=127.0.0.1;port=3306;database=solar_power;user=root;password=000000;charset=utf8;";
|
||||
|
||||
this._connectionString = connStr;
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ namespace SolarPower.Models.Company
|
||||
public string Phone { get; set; }
|
||||
public string Address { get; set; }
|
||||
public int RegisterUpperLimit { get; set; } //註冊上限
|
||||
public string SiteDB { get; set; } //公司各自DB
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -51,7 +52,7 @@ namespace SolarPower.Models.Company
|
||||
public string TaxIDNumber { get; set; } //統一編號
|
||||
public string Phone { get; set; } //電話
|
||||
public string Address { get; set; }
|
||||
public string RelationalDB { get; set; } //關聯的公司自己資料庫
|
||||
public string SiteDB { get; set; } //關聯的公司自己資料庫
|
||||
public int RegisterUpperLimit { get; set; } //註冊上限
|
||||
}
|
||||
|
||||
|
||||
@ -63,4 +63,10 @@ namespace SolarPower.Models
|
||||
public byte Layer { get; set; } //角色層級
|
||||
public List<string> Auths { get; set; } //可操作頁面
|
||||
}
|
||||
|
||||
public class Variable
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,6 +101,17 @@ namespace SolarPower.Models.PowerStation
|
||||
set { tpcPurchaseElectricityAt = value; }
|
||||
}
|
||||
public List<LandBuilding> LandBuildings { get; set; } //土地房屋資料
|
||||
public byte SolarType { get; set; } //電站類型
|
||||
public double kwh { get; set; } //
|
||||
public double Today_kwh { get; set; } //今日發電量
|
||||
public double Total_kwh { get; set; } //總發電量
|
||||
public double kwhkwp { get; set; }
|
||||
public double PR { get; set; }
|
||||
public double MP { get; set; }
|
||||
public double SolarHour { get; set; } //總運轉小時
|
||||
public string SiteDB { get; set; } //電站 DB name: solar_com
|
||||
public string TodayWeather { get; set; } //今日天氣
|
||||
public double TodayWeatherTemp { get; set; } //今日溫度
|
||||
public string CreatorName { get; set; } //創建者名稱
|
||||
}
|
||||
|
||||
@ -288,9 +299,13 @@ namespace SolarPower.Models.PowerStation
|
||||
public string Email { get; set; }//Email
|
||||
}
|
||||
|
||||
public class OperationStationId
|
||||
/// <summary>
|
||||
/// 針對電站管理的運維、設備及異常設定
|
||||
/// </summary>
|
||||
public class PostPowerStationIdAndSelectedId
|
||||
{
|
||||
public int stationId { get; set; }
|
||||
public int PowerStationId { get; set; }
|
||||
public int SelectedId { get; set; }
|
||||
}
|
||||
|
||||
public class OperationTable : OperationInfo
|
||||
@ -442,4 +457,14 @@ namespace SolarPower.Models.PowerStation
|
||||
public string Image { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 電站縣市分佈
|
||||
/// </summary>
|
||||
public class SolarCityAmount
|
||||
{
|
||||
public int CityId { get; set; }
|
||||
public string City { get; set; }
|
||||
public int Amount { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ namespace SolarPower.Repository.Implement
|
||||
tableName = "company";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 取得下拉式公司選單,須為Deleted: 0
|
||||
/// </summary>
|
||||
@ -413,9 +412,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// <summary>
|
||||
/// 創建公司自己的DB
|
||||
/// </summary>
|
||||
/// <param name="dbName"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task CreatCompanyDB(string dbName)
|
||||
public async Task CreatCompanyDB(string db_name)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
@ -425,9 +424,9 @@ namespace SolarPower.Repository.Implement
|
||||
try
|
||||
{
|
||||
var sql = @$"
|
||||
-- 傾印 資料庫結構
|
||||
CREATE DATABASE IF NOT EXISTS `{dbName}`;
|
||||
USE `{dbName}`;
|
||||
-- 傾印 子資料庫結構
|
||||
CREATE DATABASE IF NOT EXISTS `{db_name}`;
|
||||
USE `{db_name}`;
|
||||
|
||||
-- 傾印 資料表 device 結構
|
||||
CREATE TABLE IF NOT EXISTS `device` (
|
||||
@ -437,6 +436,7 @@ namespace SolarPower.Repository.Implement
|
||||
`PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '所屬電站編號',
|
||||
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名稱',
|
||||
`Type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '類型',
|
||||
`TypeName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '類型名稱',
|
||||
`Brand` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '廠牌',
|
||||
`ProductModel` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '型號',
|
||||
`DBName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
@ -463,7 +463,7 @@ namespace SolarPower.Repository.Implement
|
||||
`Purpose` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '房屋用途',
|
||||
`LeaseRate` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '租金比例(%)',
|
||||
`Coordinate` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '座標',
|
||||
`phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電話',
|
||||
`Phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電話',
|
||||
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
|
||||
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
|
||||
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者',
|
||||
@ -492,53 +492,88 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
-- 傾印 資料表 power_station 結構
|
||||
CREATE TABLE IF NOT EXISTS `power_station` (
|
||||
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Id` int(10) unsigned NOT NULL DEFAULT 0,
|
||||
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除, 0:否 1:是',
|
||||
`CompanyId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '公司編號',
|
||||
`CityId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '電站縣市',
|
||||
`AreaId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '電站區域',
|
||||
`Address` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站詳細地址',
|
||||
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名稱',
|
||||
`Code` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站代碼,縣市+區域+流水號 ',
|
||||
`Code` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站代碼,縣市+區域+四碼流水號',
|
||||
`SerialNumber` varchar(4) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '四碼流水號',
|
||||
`IsEscrow` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否為代管,0:否 1:是',
|
||||
`EscrowName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '代管名稱',
|
||||
`ElectricityMeterAt` timestamp NULL DEFAULT NULL COMMENT '台電掛錶日',
|
||||
`EstimatedRecoveryTime` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '預估回收時間',
|
||||
`GeneratingCapacity` decimal(10,1) NOT NULL DEFAULT 0.0 COMMENT '電廠發電容量,單位(千瓦)',
|
||||
`PowerRate` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '受電費率',
|
||||
`PowerRate` decimal(10,3) NOT NULL DEFAULT 0.000 COMMENT '受電費率',
|
||||
`Coordinate` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '座標',
|
||||
`InverterBrand` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逆變器廠牌',
|
||||
`InverterProductModel` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逆變器型號',
|
||||
`InverterAmount` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '逆變器數量',
|
||||
`PhotovoltaicPanelBrand` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板廠牌',
|
||||
`PhotovoltaicPanelProductModel` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板型號',
|
||||
`PhotovoltaicPanelSpecification` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '光電板規格',
|
||||
`PhotovoltaicPanelSpecification` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板規格',
|
||||
`PhotovoltaicPanelAmount` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '光電板數量',
|
||||
`BoEFileName` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局原檔案名',
|
||||
`BoEFile` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局檔案',
|
||||
`BoEDiscountRate` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '能源局折扣率',
|
||||
`BoEDeviceRegisterNumber` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局設備登記編號',
|
||||
`BoERentRatio` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '能源局租金比率,單位(%)',
|
||||
`TPCContractNumber` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '台電契約編號',
|
||||
`TPCContractAt` timestamp NULL DEFAULT NULL COMMENT '台電簽約日期',
|
||||
`TPCSellDeadline` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '台電售電期限,單位(年)',
|
||||
`TPCSellDeadline` int(10) unsigned DEFAULT 0 COMMENT '台電售電期限,單位(年)',
|
||||
`TPCMeterReading` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '台電每期抄錶日',
|
||||
`TPCPurchaseElectricityAt` timestamp NULL DEFAULT NULL COMMENT '台電正式購電日',
|
||||
`TPCSellElectricityAt` timestamp NULL DEFAULT NULL COMMENT '台電正式售電日',
|
||||
`kwh` decimal(10,3) unsigned NOT NULL DEFAULT 0.000,
|
||||
`Today_kwh` decimal(10,3) unsigned NOT NULL DEFAULT 0.000 COMMENT '今日發電量',
|
||||
`Total_kwh` decimal(10,3) unsigned NOT NULL DEFAULT 0.000 COMMENT '總發電量',
|
||||
`kwhkwp` decimal(10,3) unsigned NOT NULL DEFAULT 0.000,
|
||||
`PR` decimal(5,2) unsigned NOT NULL DEFAULT 0.00 COMMENT '電站Pr值',
|
||||
`MP` decimal(5,2) unsigned NOT NULL DEFAULT 0.00,
|
||||
`SolarHour` decimal(5,2) unsigned NOT NULL DEFAULT 0.00 COMMENT '總運轉小時',
|
||||
`SiteDB` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0.000' COMMENT '電站 DB name: solar_com',
|
||||
`TodayWeather` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0.000' COMMENT '今日天氣',
|
||||
`TodayWeatherTemp` decimal(5,2) unsigned NOT NULL DEFAULT 0.00 COMMENT '今日溫度',
|
||||
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
|
||||
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
|
||||
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者',
|
||||
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '修改時間',
|
||||
PRIMARY KEY (`Id`),
|
||||
KEY `IDX_01` (`Deleted`),
|
||||
KEY `IDX_02` (`CompanyId`)
|
||||
KEY `IDX_02` (`CompanyId`),
|
||||
KEY `IDX_03` (`CityId`,`AreaId`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='電站資料';
|
||||
|
||||
-- 傾印 資料表 power_station_exception 結構
|
||||
CREATE TABLE IF NOT EXISTS `power_station_exception` (
|
||||
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除, 0:否 1:是',
|
||||
`PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '電站編號',
|
||||
`Type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '類型,0:PR值',
|
||||
`UpperLimit` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '上限值',
|
||||
`LowerLimit` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '下限值',
|
||||
`Alarm` tinyint(4) NOT NULL DEFAULT 0 COMMENT '警報方式,0:email通知',
|
||||
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
|
||||
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
|
||||
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者',
|
||||
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '修改時間',
|
||||
PRIMARY KEY (`Id`),
|
||||
KEY `IDX_01` (`Deleted`,`PowerStationId`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='電站異常值設定';
|
||||
|
||||
-- 傾印 資料表 power_station_image 結構
|
||||
CREATE TABLE IF NOT EXISTS `power_station_image` (
|
||||
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除, 0:否 1:是',
|
||||
`PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '電站編號',
|
||||
`IsMainDisplay` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否主要顯示圖片, 0:否 1:是',
|
||||
` image` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '圖片檔名',
|
||||
`Image` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '圖片檔名',
|
||||
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
|
||||
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
|
||||
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者',
|
||||
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '修改時間',
|
||||
PRIMARY KEY (`Id`),
|
||||
KEY `IDX_01` (`Deleted`,`IsMainDisplay`,`PowerStationId`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='電站資料';
|
||||
@ -561,7 +596,7 @@ namespace SolarPower.Repository.Implement
|
||||
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除, 0:否 1:是',
|
||||
`PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '電站編號',
|
||||
` image` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '圖片檔名',
|
||||
`Image` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '圖片檔名',
|
||||
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
|
||||
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
|
||||
PRIMARY KEY (`Id`),
|
||||
|
||||
@ -10,6 +10,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.Json;
|
||||
using SolarPower.Models;
|
||||
|
||||
namespace SolarPower.Repository.Implement
|
||||
{
|
||||
@ -116,7 +117,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得縣市地區代碼
|
||||
/// 透過地區編號,取得縣市地區代碼
|
||||
/// </summary>
|
||||
/// <param name="areaId"></param>
|
||||
/// <returns></returns>
|
||||
@ -186,14 +187,17 @@ namespace SolarPower.Repository.Implement
|
||||
LEFT JOIN user u ON ps.CreatedBy = u.Id
|
||||
WHERE ps.Deleted = 0 AND ps.Id = @Id";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<PowerStation>(sql, new { Id = id});
|
||||
result = await conn.QueryFirstOrDefaultAsync<PowerStation>(sql, new { Id = id });
|
||||
|
||||
if(result!= null)
|
||||
if (result != null)
|
||||
{
|
||||
var sql_operation_personnel = @"SELECT UserId FROM power_station_operation_personnel op WHERE Deleted = 0 AND op.PowerStationId = @PowerStationId";
|
||||
|
||||
var db_name = result.SiteDB;
|
||||
|
||||
var sql_operation_personnel = @$"SELECT UserId FROM {db_name}.power_station_operation_personnel op WHERE Deleted = 0 AND op.PowerStationId = @PowerStationId";
|
||||
result.OperationPersonnelIds = (await conn.QueryAsync<int>(sql_operation_personnel, new { PowerStationId = result.Id })).ToList();
|
||||
|
||||
var sql_land_building = @$"SELECT lb.*, u.Name AS CreatorName FROM land_building lb
|
||||
var sql_land_building = @$"SELECT lb.*, u.Name AS CreatorName FROM {db_name}.land_building lb
|
||||
LEFT JOIN user u ON lb.CreatedBy = u.Id
|
||||
WHERE lb.Deleted = 0 AND PowerStationId = @PowerStationId";
|
||||
result.LandBuildings = (await conn.QueryAsync<LandBuilding>(sql_land_building, new { PowerStationId = result.Id })).ToList();
|
||||
@ -212,11 +216,61 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改電站基本資訊
|
||||
/// 新增電站資料至 主、子資料庫
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdatePowerStationInfo(UpdatePowerStationInfo entity, List<string> properties)
|
||||
public async Task<int> AddOnePowerStationAsync(PowerStation entity, List<string> properties, string db_name)
|
||||
{
|
||||
int id; int sub_count;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
//新增資料 至主資料庫
|
||||
string sql = GenerateInsertQuery(properties);
|
||||
|
||||
sql += "SELECT LAST_INSERT_ID();";
|
||||
|
||||
id = (await conn.QueryAsync<int>(sql, entity, trans)).Single();
|
||||
|
||||
//新增資料 至子資料庫
|
||||
properties.Add("Id");
|
||||
entity.Id = id;
|
||||
|
||||
string sub_sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, tableName);
|
||||
sub_count = await conn.ExecuteAsync(sub_sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改主、子資料庫電站基本資訊
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdatePowerStationInfo(UpdatePowerStationInfo entity, List<string> properties, string db_name)
|
||||
{
|
||||
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
@ -226,10 +280,14 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
//修改主資料庫
|
||||
var sql = GenerateUpdateQuery(properties);
|
||||
|
||||
await conn.ExecuteAsync(sql, entity, trans);
|
||||
|
||||
//修改子資料庫
|
||||
var sub_sql = GenerateUpdateQueryWithCustomDBNameAndTable(properties, db_name, tableName);
|
||||
await conn.ExecuteAsync(sub_sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -246,13 +304,14 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改能源局與台電資訊
|
||||
/// 修改主、子資料庫能源局與台電資訊
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateBoETPCInfo(UpdateBoETPCInfo entity, List<string> properties)
|
||||
public async Task UpdateBoETPCInfo(UpdateBoETPCInfo entity, List<string> properties, string db_name)
|
||||
{
|
||||
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
@ -260,10 +319,14 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
//修改主資料庫
|
||||
var sql = GenerateUpdateQuery(properties);
|
||||
|
||||
await conn.ExecuteAsync(sql, entity, trans);
|
||||
|
||||
//修改子資料庫
|
||||
var sub_sql = GenerateUpdateQueryWithCustomDBNameAndTable(properties, db_name, tableName);
|
||||
await conn.ExecuteAsync(sub_sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -283,8 +346,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// 新增 土地房屋資訊
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<LandBuilding> GetOneLandBuildingInfo(int id)
|
||||
public async Task<LandBuilding> GetOneLandBuildingInfo(int id, string db_name)
|
||||
{
|
||||
LandBuilding result;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
@ -292,7 +356,7 @@ namespace SolarPower.Repository.Implement
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
var sql = @"SELECT * FROM land_building WHERE Deleted =0 AND Id = @Id";
|
||||
var sql = @$"SELECT * FROM {db_name}.land_building WHERE Deleted = 0 AND Id = @Id";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<LandBuilding>(sql, new { Id = id });
|
||||
}
|
||||
@ -314,8 +378,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> AddOneLandBuildingInfo(LandBuilding entity, List<string> properties)
|
||||
public async Task<int> AddOneLandBuildingInfo(LandBuilding entity, List<string> properties, string db_name)
|
||||
{
|
||||
int id;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
@ -323,7 +388,7 @@ namespace SolarPower.Repository.Implement
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "land_building");
|
||||
string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "land_building");
|
||||
|
||||
sql += "SELECT LAST_INSERT_ID();";
|
||||
|
||||
@ -347,8 +412,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateLandBuildingInfo(UpdateLandBuilding entity, List<string> properties)
|
||||
public async Task UpdateLandBuildingInfo(UpdateLandBuilding entity, List<string> properties, string db_name)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
@ -357,7 +423,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = GenerateUpdateQueryWithCustomTable(properties, "land_building");
|
||||
var sql = GenerateUpdateQueryWithCustomDBNameAndTable(properties, db_name, "land_building");
|
||||
|
||||
await conn.ExecuteAsync(sql, entity, trans);
|
||||
|
||||
@ -380,8 +446,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// 軟刪除土地房屋資訊
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteOneLandBuildingInfo(int id)
|
||||
public async Task DeleteOneLandBuildingInfo(int id, string db_name)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
@ -390,7 +457,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"UPDATE land_building SET deleted = 1 WHERE id = @Id";
|
||||
var sql = $"UPDATE {db_name}.land_building SET Deleted = 1 WHERE Id = @Id";
|
||||
|
||||
await conn.ExecuteAsync(sql, new { Id = id }, trans);
|
||||
|
||||
@ -414,8 +481,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> AddOperation(OperationInfo operation, List<string> properties)
|
||||
public async Task<int> AddOperation(OperationInfo operation, List<string> properties, string db_name)
|
||||
{
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
@ -423,7 +491,7 @@ namespace SolarPower.Repository.Implement
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "operation_firm");
|
||||
string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "operation_firm");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, operation);
|
||||
|
||||
@ -440,12 +508,14 @@ namespace SolarPower.Repository.Implement
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 運維DataTable
|
||||
/// </summary>
|
||||
/// <param name="stationId"></param>
|
||||
/// <param name="stationId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<OperationTable>> OperationTable (int stationId)
|
||||
public async Task<List<OperationTable>> OperationTable(int stationId, string db_name)
|
||||
{
|
||||
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
@ -454,10 +524,18 @@ namespace SolarPower.Repository.Implement
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = @$"SELECT operation_firm.Name,
|
||||
string sql = @$"SELECT
|
||||
operation_firm.Name,
|
||||
operation_firm.PowerStationId,
|
||||
operation_firm.Id,operation_firm.ContactPerson,operation_firm.Phone,operation_firm.Email,user.Name AS CreatedName,operation_firm.CreatedAt,operation_firm.Type
|
||||
FROM operation_firm LEFT JOIN user ON operation_firm.CreatedBy = user.id WHERE operation_firm.Deleted = 0 AND operation_firm.PowerStationId = @StationId";
|
||||
operation_firm.Id,
|
||||
operation_firm.ContactPerson,
|
||||
operation_firm.Phone,
|
||||
operation_firm.Email,
|
||||
user.Name AS CreatedName,
|
||||
operation_firm.CreatedAt,operation_firm.Type
|
||||
FROM {db_name}.operation_firm
|
||||
LEFT JOIN user ON operation_firm.CreatedBy = user.id
|
||||
WHERE operation_firm.Deleted = 0 AND operation_firm.PowerStationId = @StationId";
|
||||
operation = (await conn.QueryAsync<OperationTable>(sql, new { StationId = stationId })).ToList();
|
||||
|
||||
}
|
||||
@ -476,8 +554,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// 選取單一運維
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<OperationInfo> OneOperationInfo (int id)
|
||||
public async Task<OperationInfo> OneOperationInfo(int id, string db_name)
|
||||
{
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
@ -485,7 +564,7 @@ namespace SolarPower.Repository.Implement
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = @$"SELECT * FROM operation_firm WHERE Id = @Id";
|
||||
string sql = @$"SELECT * FROM {db_name}.operation_firm WHERE Id = @Id";
|
||||
operation = await conn.QueryFirstOrDefaultAsync<OperationInfo>(sql, new { Id = id });
|
||||
|
||||
}
|
||||
@ -500,30 +579,23 @@ namespace SolarPower.Repository.Implement
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新運維
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateOperation(OperationInfo operation , List<string> properties)
|
||||
public async Task UpdateOperation(OperationInfo operation, List<string> properties, string db_name)
|
||||
{
|
||||
using IDbConnection conn = _databaseHelper.GetConnection();
|
||||
conn.Open();
|
||||
var trans = conn.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var updateQuery = new StringBuilder($"UPDATE operation_firm SET ");
|
||||
properties.ForEach(property =>
|
||||
{
|
||||
if (!property.Equals("Id"))
|
||||
{
|
||||
updateQuery.Append($"{property}=@{property},");
|
||||
}
|
||||
});
|
||||
updateQuery.Remove(updateQuery.Length - 1, 1); //remove last comma
|
||||
updateQuery.Append(" WHERE id = @Id");
|
||||
await conn.ExecuteAsync(updateQuery.ToString(), operation, trans);
|
||||
var sql = GenerateUpdateQueryWithCustomDBNameAndTable(properties, db_name, "operation_firm");
|
||||
await conn.ExecuteAsync(sql, operation, trans);
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -551,7 +623,7 @@ namespace SolarPower.Repository.Implement
|
||||
string sql = @$"SELECT * FROM variable WHERE name = @name";
|
||||
var json = await conn.QueryFirstOrDefaultAsync<Variable>(sql, new { name = "Type" });
|
||||
Root jsonfor = JsonSerializer.Deserialize<Root>(json.value);
|
||||
foreach(Models.PowerStation.Type a in jsonfor.Type)
|
||||
foreach (Models.PowerStation.Type a in jsonfor.Type)
|
||||
{
|
||||
UserSelectItemList KeyValue = new UserSelectItemList
|
||||
{
|
||||
@ -816,8 +888,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// 透過電站編號,取得該電站的運維人員編號
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<int>> GetOperationPersonnelIdsByPowerStatioinId(int powerStationId)
|
||||
public async Task<List<int>> GetOperationPersonnelIdsByPowerStatioinId(int powerStationId, string db_name)
|
||||
{
|
||||
List<int> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
@ -825,7 +898,7 @@ namespace SolarPower.Repository.Implement
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT UserId FROM power_station_operation_personnel WHERE Deleted = 0 AND PowerStationId = @PowerStationId";
|
||||
var sql = @$"SELECT UserId FROM {db_name}.power_station_operation_personnel WHERE Deleted = 0 AND PowerStationId = @PowerStationId";
|
||||
|
||||
result = (await conn.QueryAsync<int>(sql, new { PowerStationId = powerStationId })).ToList();
|
||||
}
|
||||
@ -846,8 +919,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> AddOperationPersonnelAsync(List<PowerStationOperationPersonnel> entity, List<string> properties)
|
||||
public async Task<int> AddOperationPersonnelAsync(List<PowerStationOperationPersonnel> entity, List<string> properties, string db_name)
|
||||
{
|
||||
int count;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
@ -855,7 +929,7 @@ namespace SolarPower.Repository.Implement
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_operation_personnel");
|
||||
string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "power_station_operation_personnel");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity);
|
||||
}
|
||||
@ -876,8 +950,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// 軟刪除電站運維人員
|
||||
/// </summary>
|
||||
/// <param name="operationPersonnels"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteOperationPersonnel(List<PowerStationOperationPersonnel> operationPersonnels)
|
||||
public async Task DeleteOperationPersonnel(List<PowerStationOperationPersonnel> operationPersonnels, string db_name)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
@ -886,7 +961,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"UPDATE power_station_operation_personnel SET deleted = 1 WHERE PowerStationId = @PowerStationId AND UserId = @UserId";
|
||||
var sql = $"UPDATE {db_name}.power_station_operation_personnel SET Deleted = 1 WHERE PowerStationId = @PowerStationId AND UserId = @UserId";
|
||||
|
||||
await conn.ExecuteAsync(sql, operationPersonnels, trans);
|
||||
|
||||
@ -909,28 +984,34 @@ namespace SolarPower.Repository.Implement
|
||||
/// 電站管理 新增電站圖片
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> AddPowerStationImageAsync(List<PowerStationImage> entity, List<string> properties)
|
||||
public async Task<int> AddPowerStationImageAsync(List<PowerStationImage> entity, List<string> properties, string db_name)
|
||||
{
|
||||
int count;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_image");
|
||||
string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "power_station_image");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity);
|
||||
count = await conn.ExecuteAsync(sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
@ -940,15 +1021,16 @@ namespace SolarPower.Repository.Implement
|
||||
/// 電站管理 取得所有電站圖片的資料
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<PowerStationImage>> GetAllPowerStationImageAsync(int powerStationId)
|
||||
public async Task<List<PowerStationImage>> GetAllPowerStationImageAsync(int powerStationId, string db_name)
|
||||
{
|
||||
List<PowerStationImage> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM power_station_image WHERE Deleted = 0 AND PowerStationId = @PowerStationId";
|
||||
var sql = $"SELECT * FROM {db_name}.power_station_image WHERE Deleted = 0 AND PowerStationId = @PowerStationId";
|
||||
|
||||
result = (await conn.QueryAsync<PowerStationImage>(sql, new { PowerStationId = powerStationId })).ToList();
|
||||
}
|
||||
@ -964,15 +1046,16 @@ namespace SolarPower.Repository.Implement
|
||||
/// 電站管理 取得單一電站圖片的資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PowerStationImage> GetOnePowerStationImageAsync(int id)
|
||||
public async Task<PowerStationImage> GetOnePowerStationImageAsync(int id, string db_name)
|
||||
{
|
||||
PowerStationImage result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM power_station_image WHERE Deleted = 0 AND Id = @Id";
|
||||
var sql = $"SELECT * FROM {db_name}.power_station_image WHERE Deleted = 0 AND Id = @Id";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<PowerStationImage>(sql, new { Id = id });
|
||||
}
|
||||
@ -988,8 +1071,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// 軟刪除 單一電站圖片
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteOnePowerStationImage(int id)
|
||||
public async Task DeleteOnePowerStationImage(int id, string db_name)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
@ -998,7 +1082,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"UPDATE power_station_image SET deleted = 1 WHERE id = @Id";
|
||||
var sql = $"UPDATE {db_name}.power_station_image SET Deleted = 1 WHERE id = @Id";
|
||||
|
||||
await conn.ExecuteAsync(sql, new { Id = id }, trans);
|
||||
|
||||
@ -1021,15 +1105,16 @@ namespace SolarPower.Repository.Implement
|
||||
/// 電站管理 取得主要卡片顯示圖
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PowerStationImage> GetMainDisplayAsync(int powerStationId)
|
||||
public async Task<PowerStationImage> GetMainDisplayAsync(int powerStationId, string db_name)
|
||||
{
|
||||
PowerStationImage result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM power_station_image WHERE Deleted = 0 AND IsMainDisplay = 1 AND PowerStationId = @PowerStationId";
|
||||
var sql = $"SELECT * FROM {db_name}.power_station_image WHERE Deleted = 0 AND IsMainDisplay = 1 AND PowerStationId = @PowerStationId";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<PowerStationImage>(sql, new { PowerStationId = powerStationId });
|
||||
}
|
||||
@ -1046,8 +1131,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// </summary>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdatePowerStationImage(UpdataPowerStationImage image, List<string> properties)
|
||||
public async Task UpdatePowerStationImage(UpdataPowerStationImage image, List<string> properties, string db_name)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
@ -1056,7 +1142,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = GenerateUpdateQueryWithCustomTable(properties, "power_station_image");
|
||||
var sql = GenerateUpdateQueryWithCustomDBNameAndTable(properties, db_name, "power_station_image");
|
||||
|
||||
await conn.ExecuteAsync(sql, image, trans);
|
||||
|
||||
@ -1080,8 +1166,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> AddPowerStationSingleLineAsync(List<PowerStationSingleLine> entity, List<string> properties)
|
||||
public async Task<int> AddPowerStationSingleLineAsync(List<PowerStationSingleLine> entity, List<string> properties, string db_name)
|
||||
{
|
||||
int count;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
@ -1089,7 +1176,7 @@ namespace SolarPower.Repository.Implement
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_single_line_diagram");
|
||||
string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "power_station_single_line_diagram");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity);
|
||||
}
|
||||
@ -1110,15 +1197,16 @@ namespace SolarPower.Repository.Implement
|
||||
/// 電站管理 取得所有單線圖的資料
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<PowerStationSingleLine>> GetAllPowerStationSingleLineAsync(int powerStationId)
|
||||
public async Task<List<PowerStationSingleLine>> GetAllPowerStationSingleLineAsync(int powerStationId, string db_name)
|
||||
{
|
||||
List<PowerStationSingleLine> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM power_station_single_line_diagram WHERE Deleted = 0 AND PowerStationId = @PowerStationId";
|
||||
var sql = $"SELECT * FROM {db_name}.power_station_single_line_diagram WHERE Deleted = 0 AND PowerStationId = @PowerStationId";
|
||||
|
||||
result = (await conn.QueryAsync<PowerStationSingleLine>(sql, new { PowerStationId = powerStationId })).ToList();
|
||||
}
|
||||
@ -1134,15 +1222,16 @@ namespace SolarPower.Repository.Implement
|
||||
/// 電站管理 取得單一單線圖的資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PowerStationSingleLine> GetOnePowerStationSingleLineAsync(int id)
|
||||
public async Task<PowerStationSingleLine> GetOnePowerStationSingleLineAsync(int id, string db_name)
|
||||
{
|
||||
PowerStationSingleLine result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM power_station_single_line_diagram WHERE Deleted = 0 AND Id = @Id";
|
||||
var sql = $"SELECT * FROM {db_name}.power_station_single_line_diagram WHERE Deleted = 0 AND Id = @Id";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<PowerStationSingleLine>(sql, new { Id = id });
|
||||
}
|
||||
@ -1158,8 +1247,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// 軟刪除 單一單線圖
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteOnePowerStationSingleLine(int id)
|
||||
public async Task DeleteOnePowerStationSingleLine(int id, string db_name)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
@ -1168,7 +1258,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"UPDATE power_station_single_line_diagram SET deleted = 1 WHERE id = @Id";
|
||||
var sql = $"UPDATE {db_name}.power_station_single_line_diagram SET deleted = 1 WHERE id = @Id";
|
||||
|
||||
await conn.ExecuteAsync(sql, new { Id = id }, trans);
|
||||
|
||||
@ -1186,6 +1276,43 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<SolarCityAmount>> GetSolarCitySummary(MyUser User)
|
||||
{
|
||||
using IDbConnection conn = _databaseHelper.GetConnection();
|
||||
List<SolarCityAmount> solaramount = new List<SolarCityAmount>();
|
||||
conn.Open();
|
||||
var trans = conn.BeginTransaction();
|
||||
try
|
||||
{
|
||||
if (User.Role.Layer == 0 || User.Role.Layer == 1)
|
||||
{
|
||||
var sql = "SELECT city.Id AS CityId city.Name AS City,COUNT(*) AS Amount FROM power_station LEFT JOIN city ON power_station.CityId = city.Id GROUP BY power_station.CityId";
|
||||
solaramount = (await conn.QueryAsync<SolarCityAmount>(sql)).ToList();
|
||||
trans.Commit();
|
||||
}
|
||||
else if (User.Role.Layer == 2)
|
||||
{
|
||||
var sql = "SELECT city.Id AS CityId city.Name AS City,COUNT(*) AS Amount FROM power_station LEFT JOIN city ON power_station.CityId = city.Id WHERE CompanyId = @CompanyId GROUP BY power_station.CityId ORDER BY power_station.CityId ";
|
||||
solaramount = (await conn.QueryAsync<SolarCityAmount>(sql, new { CompanyId = User.CompanyId })).ToList();
|
||||
trans.Commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
var sql = "SELECT city.Id AS CityId city.Name AS City,COUNT(*) AS Amount FROM power_station LEFT JOIN city ON power_station.CityId = city.Id LEFT JOIN power_station_operation_personnel ON power_station.Id = power_station_operation_personnel.PowerStationId WHERE UserId = @UserId GROUP BY power_station.CityId ORDER BY power_station.CityId";
|
||||
solaramount = (await conn.QueryAsync<SolarCityAmount>(sql, new { UserId = User.Id })).ToList();
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return solaramount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
|
||||
using Dapper;
|
||||
using SolarPower.Helper;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -36,20 +37,26 @@ namespace SolarPower.Repository.Implement
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQuery(properties);
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity);
|
||||
count = await conn.ExecuteAsync(sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
@ -67,22 +74,28 @@ namespace SolarPower.Repository.Implement
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQuery(properties);
|
||||
|
||||
sql += "SELECT LAST_INSERT_ID();";
|
||||
|
||||
id = (await conn.QueryAsync<int>(sql, entity)).Single();
|
||||
id = (await conn.QueryAsync<int>(sql, entity, trans)).Single();
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
@ -123,12 +136,13 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 透過Id,軟刪除單一筆資料(不同資料表)
|
||||
/// 透過Id、db_name、table_name,刪除指定的資料庫之資料表的一筆資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="tablename"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <param name="table_name"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task DeleteOneOtherTable(int id,string table_name)
|
||||
public virtual async Task DeleteOneByIdWithCustomDBNameAndTable(int id, string db_name, string table_name)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
@ -137,7 +151,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"UPDATE {table_name} SET deleted = 1 WHERE id = @Id";
|
||||
var sql = $"UPDATE {db_name}.{table_name} SET Deleted = 1 WHERE Id = @Id";
|
||||
|
||||
await conn.ExecuteAsync(sql, new { Id = id }, trans);
|
||||
|
||||
@ -152,7 +166,6 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -270,6 +283,56 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過name list,取得指定的多筆設定變數
|
||||
/// </summary>
|
||||
/// <param name="names"></param>
|
||||
/// <returns>回傳為字典格式</returns>
|
||||
public virtual async Task<Dictionary<string, string>> GetDictVariableByNames(List<string> names)
|
||||
{
|
||||
Dictionary<string, string> dict;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM variable WHERE Name IN @Names";
|
||||
|
||||
var result = (await conn.QueryAsync<Variable>(sql, new { Names = names })).ToList();
|
||||
|
||||
dict = result.ToDictionary(x => x.Name, x => x.Value);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過name,取得單一設定變數
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<string> GetOneVariableByName(string name)
|
||||
{
|
||||
string result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM variable WHERE Name = @Name";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<string>(sql, new { Name = name });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 產生Insert語句
|
||||
/// </summary>
|
||||
@ -303,7 +366,7 @@ namespace SolarPower.Repository.Implement
|
||||
/// <returns></returns>
|
||||
protected string GenerateInsertQueryWithCustomTable(List<string> properties, string table_name)
|
||||
{
|
||||
var insertQuery = new StringBuilder($"INSERT INTO {table_name} ");
|
||||
var insertQuery = new StringBuilder($"INSERT INTO `{table_name}` ");
|
||||
|
||||
insertQuery.Append("(");
|
||||
|
||||
@ -322,6 +385,34 @@ namespace SolarPower.Repository.Implement
|
||||
return insertQuery.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 產生Insert語句,可選擇自己要加入資料庫及資料表
|
||||
/// </summary>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name">欲新增至目標資料庫</param>
|
||||
/// <param name="table_name">欲新增至目標資料表</param>
|
||||
/// <returns></returns>
|
||||
protected string GenerateInsertQueryWithCustomDBNameAndTable(List<string> properties, string db_name, string table_name)
|
||||
{
|
||||
var insertQuery = new StringBuilder($"INSERT INTO `{db_name}`.`{table_name}` ");
|
||||
|
||||
insertQuery.Append("(");
|
||||
|
||||
properties.ForEach(prop => { insertQuery.Append($"`{table_name}`.{prop},"); });
|
||||
|
||||
insertQuery
|
||||
.Remove(insertQuery.Length - 1, 1)
|
||||
.Append(") VALUES (");
|
||||
|
||||
properties.ForEach(prop => { insertQuery.Append($"@{prop},"); });
|
||||
|
||||
insertQuery
|
||||
.Remove(insertQuery.Length - 1, 1)
|
||||
.Append(");");
|
||||
|
||||
return insertQuery.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 產生Update語句
|
||||
/// </summary>
|
||||
@ -368,6 +459,24 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
return updateQuery.ToString();
|
||||
}
|
||||
|
||||
protected string GenerateUpdateQueryWithCustomDBNameAndTable(List<string> properties, string db_name, string table_name)
|
||||
{
|
||||
var updateQuery = new StringBuilder($"UPDATE {db_name}.{table_name} SET ");
|
||||
|
||||
properties.ForEach(property =>
|
||||
{
|
||||
if (!property.Equals("Id"))
|
||||
{
|
||||
updateQuery.Append($"{table_name}.{property}=@{property},");
|
||||
}
|
||||
});
|
||||
|
||||
updateQuery.Remove(updateQuery.Length - 1, 1); //remove last comma
|
||||
updateQuery.Append(" WHERE id = @Id");
|
||||
|
||||
return updateQuery.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// 取資料庫當前流水號
|
||||
/// </summary>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Models.User;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -54,27 +55,39 @@ namespace SolarPower.Repository.Interface
|
||||
Task<string> GetLastSerialNumberByCityAreaIdAsync(int cityId, int areaId);
|
||||
|
||||
/// <summary>
|
||||
/// 修改電站基本資訊
|
||||
/// 新增電站資料至 主、子資料庫
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdatePowerStationInfo(UpdatePowerStationInfo entity, List<string> properties);
|
||||
Task<int> AddOnePowerStationAsync(PowerStation entity, List<string> properties, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 修改能源局與台電資訊
|
||||
/// 修改主、子資料庫電站基本資訊
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateBoETPCInfo(UpdateBoETPCInfo entity, List<string> properties);
|
||||
Task UpdatePowerStationInfo(UpdatePowerStationInfo entity, List<string> properties, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 修改主、子資料庫能源局與台電資訊
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateBoETPCInfo(UpdateBoETPCInfo entity, List<string> properties, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 取得 土地房屋資訊
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<LandBuilding> GetOneLandBuildingInfo(int id);
|
||||
Task<LandBuilding> GetOneLandBuildingInfo(int id, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 新增 土地房屋資訊
|
||||
@ -82,53 +95,65 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> AddOneLandBuildingInfo(LandBuilding entity, List<string> properties);
|
||||
Task<int> AddOneLandBuildingInfo(LandBuilding entity, List<string> properties, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 更新 土地房屋資訊
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateLandBuildingInfo(UpdateLandBuilding entity, List<string> properties);
|
||||
Task UpdateLandBuildingInfo(UpdateLandBuilding entity, List<string> properties, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除土地房屋資訊
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOneLandBuildingInfo(int id);
|
||||
Task DeleteOneLandBuildingInfo(int id, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 新增運維
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> AddOperation(OperationInfo operation, List<string> properties);
|
||||
Task<int> AddOperation(OperationInfo operation, List<string> properties, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 運維dataTable
|
||||
/// </summary>
|
||||
/// <param name="stationId"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<OperationTable>> OperationTable (int stationId);
|
||||
Task<List<OperationTable>> OperationTable (int stationId, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 取一筆運維
|
||||
/// </summary>
|
||||
/// <param name="stationId"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationInfo> OneOperationInfo (int stationId);
|
||||
Task<OperationInfo> OneOperationInfo (int stationId, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 更新運維
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateOperation(OperationInfo operation, List<string> properties);
|
||||
Task UpdateOperation(OperationInfo operation, List<string> properties, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 裝置類型下拉式選單
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<UserSelectItemList>> DeviceType();
|
||||
|
||||
/// <summary>
|
||||
/// 新增 裝置
|
||||
/// </summary>
|
||||
@ -155,12 +180,14 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="stationId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<ExceptionTable>> ExceptionTable(int stationId);
|
||||
|
||||
/// <summary>
|
||||
/// 取單一筆DeviceInfo
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<DeviceInfo> OneDeviceInfo(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 新增 異常設定
|
||||
/// </summary>
|
||||
@ -168,12 +195,14 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
Task AddException(ExceptionModal Exception, List<string> properties);
|
||||
|
||||
/// <summary>
|
||||
/// 取一筆異常設定
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<ExceptionModal> OneException(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 更新異常設定
|
||||
/// </summary>
|
||||
@ -181,6 +210,7 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateException(ExceptionModal Exception, List<string> properties);
|
||||
|
||||
/// <summary>
|
||||
/// 取最後一個設備流水號
|
||||
/// </summary>
|
||||
@ -193,95 +223,108 @@ namespace SolarPower.Repository.Interface
|
||||
/// 透過電站編號,取得該電站的運維人員編號
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<int>> GetOperationPersonnelIdsByPowerStatioinId(int powerStationId);
|
||||
Task<List<int>> GetOperationPersonnelIdsByPowerStatioinId(int powerStationId, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 新增電站運維人員
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> AddOperationPersonnelAsync(List<PowerStationOperationPersonnel> entity, List<string> properties);
|
||||
Task<int> AddOperationPersonnelAsync(List<PowerStationOperationPersonnel> entity, List<string> properties, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除電站運維人員
|
||||
/// </summary>
|
||||
/// <param name="operationPersonnels"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOperationPersonnel(List<PowerStationOperationPersonnel> operationPersonnels);
|
||||
Task DeleteOperationPersonnel(List<PowerStationOperationPersonnel> operationPersonnels, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 新增電站圖片
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> AddPowerStationImageAsync(List<PowerStationImage> entity, List<string> properties);
|
||||
Task<int> AddPowerStationImageAsync(List<PowerStationImage> entity, List<string> properties, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得所有電站圖片的資料
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PowerStationImage>> GetAllPowerStationImageAsync(int powerStationId);
|
||||
Task<List<PowerStationImage>> GetAllPowerStationImageAsync(int powerStationId, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得單一電站圖片的資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<PowerStationImage> GetOnePowerStationImageAsync(int id);
|
||||
Task<PowerStationImage> GetOnePowerStationImageAsync(int id, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除 單一電站圖片
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOnePowerStationImage(int id);
|
||||
Task DeleteOnePowerStationImage(int id, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得主要卡片顯示圖
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<PowerStationImage> GetMainDisplayAsync(int powerStationId);
|
||||
Task<PowerStationImage> GetMainDisplayAsync(int powerStationId, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 更新上傳圖片
|
||||
/// </summary>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdatePowerStationImage(UpdataPowerStationImage image, List<string> properties);
|
||||
Task UpdatePowerStationImage(UpdataPowerStationImage image, List<string> properties, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 新增單線圖
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> AddPowerStationSingleLineAsync(List<PowerStationSingleLine> entity, List<string> properties);
|
||||
Task<int> AddPowerStationSingleLineAsync(List<PowerStationSingleLine> entity, List<string> properties, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得所有單線圖的資料
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PowerStationSingleLine>> GetAllPowerStationSingleLineAsync(int powerStationId);
|
||||
Task<List<PowerStationSingleLine>> GetAllPowerStationSingleLineAsync(int powerStationId, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得單一單線圖的資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<PowerStationSingleLine> GetOnePowerStationSingleLineAsync(int id);
|
||||
Task<PowerStationSingleLine> GetOnePowerStationSingleLineAsync(int id, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除 單一單線圖
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOnePowerStationSingleLine(int id);
|
||||
Task DeleteOnePowerStationSingleLine(int id, string db_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +36,6 @@ namespace SolarPower.Repository.Interface
|
||||
/// <returns></returns>
|
||||
Task<int> AddOneAsync(T entity, List<string> properties);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 修改資料
|
||||
/// </summary>
|
||||
@ -58,13 +57,30 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
Task PurgeOneAsync(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 透過Id,軟刪除單一筆資料(不同資料表)
|
||||
/// 透過Id、db_name、table_name,刪除指定的資料庫之資料表的一筆資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="tablename"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <param name="table_name"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOneOtherTable(int id, string tablename);
|
||||
Task DeleteOneByIdWithCustomDBNameAndTable(int id, string db_name, string table_name);
|
||||
|
||||
/// <summary>
|
||||
/// 透過name list,取得指定的多筆設定變數
|
||||
/// </summary>
|
||||
/// <param name="names"></param>
|
||||
/// <returns>回傳為字典格式</returns>
|
||||
Task<Dictionary<string, string>> GetDictVariableByNames(List<string> names);
|
||||
|
||||
/// <summary>
|
||||
/// 透過name,取得單一設定變數
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetOneVariableByName(string name);
|
||||
|
||||
/// <summary>
|
||||
/// 取資料庫最後流水號
|
||||
/// </summary>
|
||||
@ -72,6 +88,5 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="where"></param>
|
||||
/// <returns></returns>
|
||||
Task<String> GetCurrentSerialNumber(string Table_name, string where);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
@{
|
||||
ViewData["MainNum"] = "6";
|
||||
ViewData["SubNum"] = "2";
|
||||
ViewData["Title"] = "客戶公司管理";
|
||||
ViewData["MainNum"] = "7";
|
||||
ViewData["SubNum"] = "1";
|
||||
ViewData["Title"] = "公司管理";
|
||||
}
|
||||
@using SolarPower.Models.Role
|
||||
@model RoleLayerEnum
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
@{
|
||||
ViewData["MainNum"] = "6";
|
||||
ViewData["MainNum"] = "2";
|
||||
ViewData["SubNum"] = "1";
|
||||
ViewData["Title"] = "電站資料管理";
|
||||
ViewData["Title"] = "電站管理";
|
||||
}
|
||||
|
||||
<ol class="breadcrumb page-breadcrumb">
|
||||
@ -410,7 +410,30 @@
|
||||
$(function () {
|
||||
|
||||
var localurl = this.location.href;
|
||||
//電站區域Tab要佳LI
|
||||
|
||||
//#region 電站區域Tab
|
||||
|
||||
|
||||
var url = "/PowerStation/GetSolarCitySummary";
|
||||
$.post(url, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$.each(rel.data, function (index, val) {
|
||||
//alert(val.city + val.amount);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}, 'json');
|
||||
|
||||
|
||||
//#endregion
|
||||
|
||||
//電站區域
|
||||
$('#templateAreaTab').find('li').attr('id', 'AreaTabnewtaipei').clone().appendTo($('#areaTab'));
|
||||
$('#AreaTabnewtaipei').find('a').attr('href', '#tab-newtaipei');
|
||||
$('#AreaTabnewtaipei').find('a').attr('class', 'nav-link fs-lg px-4');
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
@{
|
||||
ViewData["MainNum"] = "6";
|
||||
ViewData["MainNum"] = "2";
|
||||
ViewData["SubNum"] = "1";
|
||||
ViewData["Title"] = "電站資料管理";
|
||||
}
|
||||
@ -96,6 +96,76 @@
|
||||
$(function () {
|
||||
var url = new URL(location.href);
|
||||
stationId = url.searchParams.get('stationId');
|
||||
|
||||
//#region 電站資料 view 控制
|
||||
if (stationId == 'new') {
|
||||
//#region 電站基本資料
|
||||
$("#address_detail_text").hide();
|
||||
$("#power_station_code_text").hide();
|
||||
$("#power_station_name_text").hide();
|
||||
$("#electricity_meter_at_text").hide();
|
||||
$("#estimated_recovery_time_text").hide();
|
||||
$("#created_by_text").hide();
|
||||
|
||||
$("#generating_capacity_text").hide();
|
||||
$("#escrow_name_text").hide();
|
||||
$("#power_rate_text").hide();
|
||||
$("#coordinate_text").hide();
|
||||
$("#created_at_text").hide();
|
||||
|
||||
//逆變器
|
||||
$("#inverter_brand_text").hide();
|
||||
$("#inverter_product_model_text").hide();
|
||||
$("#inverter_amount_text").hide();
|
||||
|
||||
//光電板
|
||||
$("#photovoltaic_panel_brand_text").hide();
|
||||
$("#photovoltaic_panel_specification_text").hide();
|
||||
$("#photovoltaic_panel_amount_text").hide();
|
||||
$("#photovoltaic_panel_product_model_text").hide();
|
||||
//#endregion
|
||||
|
||||
$("#edit-station-info-btn").hide();
|
||||
$("#canecl-station-info-btn").hide();
|
||||
$("#check_escrow").attr('disabled', false);
|
||||
|
||||
$("#BoEPart").hide();
|
||||
$("#land_buildingPart").hide();
|
||||
|
||||
$("#tablist").hide();
|
||||
$("#tablist").find(".nav-item > a").first().click();
|
||||
} else {
|
||||
var url = "/PowerStation/GetOnePowerStation"
|
||||
|
||||
var send_data = {
|
||||
id: stationId
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
powerStationData = rel.data;
|
||||
|
||||
//#region 電站基本資料
|
||||
ChangeMode("station_info", "view");
|
||||
SetStationInfo();
|
||||
//#endregion
|
||||
|
||||
//#region 能源局與台電資料
|
||||
ChangeMode("BOE_TPC", "view");
|
||||
SetBoETPCInfo();
|
||||
//#endregion
|
||||
|
||||
//#region 土地與房屋資料
|
||||
ChangeMode("land_building_info", "view");
|
||||
SetLandBuildingInfo();
|
||||
//#endregion
|
||||
|
||||
}, 'json');
|
||||
|
||||
//#region 運維列表 DataTable
|
||||
OperationTable = $("#Operation_table").DataTable({
|
||||
"paging": true,
|
||||
@ -206,7 +276,7 @@
|
||||
"data": "colName"
|
||||
}, {
|
||||
"data": "remark"
|
||||
},{
|
||||
}, {
|
||||
"data": "function"
|
||||
}],
|
||||
"columnDefs": [{
|
||||
@ -280,10 +350,10 @@
|
||||
"data": "powerStationName"
|
||||
}, {
|
||||
"data": "typeName"
|
||||
}, {
|
||||
"data": "upperLimit"
|
||||
}, {
|
||||
"data": "lowerLimit"
|
||||
}, {
|
||||
"data": "upperLimit"
|
||||
}, {
|
||||
"data": "alarmName"
|
||||
}, {
|
||||
@ -347,74 +417,57 @@
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 電站資料 view 控制
|
||||
if (stationId == 'new') {
|
||||
//#region 電站基本資料
|
||||
$("#address_detail_text").hide();
|
||||
$("#power_station_code_text").hide();
|
||||
$("#power_station_name_text").hide();
|
||||
$("#electricity_meter_at_text").hide();
|
||||
$("#estimated_recovery_time_text").hide();
|
||||
$("#created_by_text").hide();
|
||||
|
||||
$("#generating_capacity_text").hide();
|
||||
$("#escrow_name_text").hide();
|
||||
$("#power_rate_text").hide();
|
||||
$("#coordinate_text").hide();
|
||||
$("#created_at_text").hide();
|
||||
|
||||
//逆變器
|
||||
$("#inverter_brand_text").hide();
|
||||
$("#inverter_product_model_text").hide();
|
||||
$("#inverter_amount_text").hide();
|
||||
|
||||
//光電板
|
||||
$("#photovoltaic_panel_brand_text").hide();
|
||||
$("#photovoltaic_panel_specification_text").hide();
|
||||
$("#photovoltaic_panel_amount_text").hide();
|
||||
$("#photovoltaic_panel_product_model_text").hide();
|
||||
//#endregion
|
||||
|
||||
$("#edit-station-info-btn").hide();
|
||||
$("#canecl-station-info-btn").hide();
|
||||
$("#check_escrow").attr('disabled', false);
|
||||
|
||||
$("#BoEPart").hide();
|
||||
$("#land_buildingPart").hide();
|
||||
|
||||
$("#tablist").hide();
|
||||
$("#tablist").find(".nav-item > a").first().click();
|
||||
} else {
|
||||
var url = "/PowerStation/GetOnePowerStation"
|
||||
|
||||
//#region 載入上傳資料 - 電站圖片
|
||||
var url_image = "/PowerStation/GetAllPowerStationImage";
|
||||
var send_data = {
|
||||
id: stationId
|
||||
}
|
||||
powerStationId: stationId
|
||||
};
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
$.post(url_image, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
powerStationData = rel.data;
|
||||
var powerStationImages = rel.data;
|
||||
|
||||
//#region 電站基本資料
|
||||
ChangeMode("station_info", "view");
|
||||
SetStationInfo();
|
||||
//#endregion
|
||||
countPowerStationImage = powerStationImages.length;
|
||||
|
||||
//#region 能源局與台電資料
|
||||
ChangeMode("BOE_TPC", "view");
|
||||
SetBoETPCInfo();
|
||||
//#endregion
|
||||
|
||||
//#region 土地與房屋資料
|
||||
ChangeMode("land_building_info", "view");
|
||||
SetLandBuildingInfo();
|
||||
//#endregion
|
||||
powerStationSingleLineCard = $("#power-station-image-card > .row");
|
||||
powerStationSingleLineCard.empty();
|
||||
rel.data.forEach(function (value, index) {
|
||||
CreatePowerStationSingleLineBox(powerStationSingleLineCard, value);
|
||||
});
|
||||
|
||||
}, 'json');
|
||||
//#endregion
|
||||
|
||||
//#region 載入上傳資料 - 單線圖
|
||||
var url_image = "/PowerStation/GetAllPowerStationSingleLine";
|
||||
var send_data = {
|
||||
powerStationId: stationId
|
||||
};
|
||||
|
||||
$.post(url_image, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var powerStationSingleLines = rel.data;
|
||||
|
||||
countPowerStationSingleLine = powerStationSingleLines.length;
|
||||
|
||||
powerStationSingleLineCard = $("#power-station-single-line-card > .row");
|
||||
powerStationSingleLineCard.empty();
|
||||
rel.data.forEach(function (value, index) {
|
||||
CreatePowerStationSingleLineBox(powerStationSingleLineCard, value);
|
||||
});
|
||||
|
||||
|
||||
|
||||
}, 'json');
|
||||
//#endregion
|
||||
}
|
||||
//#endregion
|
||||
|
||||
@ -509,59 +562,6 @@
|
||||
});
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 載入上傳資料 - 電站圖片
|
||||
var url_image = "/PowerStation/GetAllPowerStationImage";
|
||||
var send_data = {
|
||||
powerStationId: stationId
|
||||
};
|
||||
|
||||
$.post(url_image, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var powerStationImages = rel.data;
|
||||
|
||||
countPowerStationImage = powerStationImages.length;
|
||||
|
||||
powerStationSingleLineCard = $("#power-station-image-card > .row");
|
||||
powerStationSingleLineCard.empty();
|
||||
rel.data.forEach(function (value, index) {
|
||||
CreatePowerStationSingleLineBox(powerStationSingleLineCard, value);
|
||||
});
|
||||
|
||||
}, 'json');
|
||||
//#endregion
|
||||
|
||||
//#region 載入上傳資料 - 單線圖
|
||||
var url_image = "/PowerStation/GetAllPowerStationSingleLine";
|
||||
var send_data = {
|
||||
powerStationId: stationId
|
||||
};
|
||||
|
||||
$.post(url_image, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var powerStationSingleLines = rel.data;
|
||||
|
||||
countPowerStationSingleLine = powerStationSingleLines.length;
|
||||
|
||||
powerStationSingleLineCard = $("#power-station-single-line-card > .row");
|
||||
powerStationSingleLineCard.empty();
|
||||
rel.data.forEach(function (value, index) {
|
||||
CreatePowerStationSingleLineBox(powerStationSingleLineCard, value);
|
||||
});
|
||||
|
||||
|
||||
|
||||
}, 'json');
|
||||
//#endregion
|
||||
|
||||
});
|
||||
|
||||
//#region 代管切換
|
||||
@ -1340,7 +1340,8 @@
|
||||
if (result.value) {
|
||||
var url = "/PowerStation/DeleteLandBuildingInfo";
|
||||
var send_data = {
|
||||
Id: selectedLandBuildingId
|
||||
SelectedId: selectedLandBuildingId,
|
||||
PowerStationId: stationId
|
||||
}
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
@ -1428,10 +1429,10 @@
|
||||
var url = "/PowerStation/GetOneOperation/";
|
||||
|
||||
var send_data = {
|
||||
id: selected_id
|
||||
SelectedId: selected_id,
|
||||
PowerStationId: stationId
|
||||
}
|
||||
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
@ -1465,9 +1466,12 @@
|
||||
}).then(function (result) {
|
||||
if (result.value) {
|
||||
var url = "/PowerStation/DeleteOneOperation/";
|
||||
|
||||
var send_data = {
|
||||
Id: selected_id
|
||||
SelectedId: selected_id,
|
||||
PowerStationId: stationId
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
@ -1796,7 +1800,8 @@
|
||||
var url = "/PowerStation/DeletePowerStationImage";
|
||||
|
||||
var send_data = {
|
||||
Id: selectedImageId
|
||||
SelectedId: selectedImageId,
|
||||
PowerStationId: stationId
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
<th>電站編號</th>
|
||||
<th>電站名稱</th>
|
||||
<th>項目</th>
|
||||
<th>上限 ( <= )</th>
|
||||
<th>下限 ( >= )</th>
|
||||
<th>下限 ( <= )</th>
|
||||
<th>上限 ( >= )</th>
|
||||
<th>警示方式</th>
|
||||
<th>建立時間</th>
|
||||
<th>功能</th>
|
||||
@ -52,14 +52,14 @@
|
||||
<option value="1">email通知</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="Exception_UpperLimit_modal"><span class="text-danger">*</span>上限</label>
|
||||
<input type="number" id="Exception_UpperLimit_modal" name="Exception_UpperLimit_modal" class="form-control">
|
||||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="Exception_LowerLimit_modal"><span class="text-danger">*</span>下限</label>
|
||||
<input type="number" id="Exception_LowerLimit_modal" name="Exception_LowerLimit_modal" class="form-control">
|
||||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="Exception_UpperLimit_modal"><span class="text-danger">*</span>上限</label>
|
||||
<input type="number" id="Exception_UpperLimit_modal" name="Exception_UpperLimit_modal" class="form-control">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@ -86,18 +86,18 @@
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-title">Navigation Title</li>-->
|
||||
<li class="">
|
||||
<li class="@(ViewData["MainNum"] == "1" ? "active open" : "")">
|
||||
<a href="#" title="Category" data-filter-tags="category">
|
||||
<i class="fal fa-file"></i>
|
||||
<span class="nav-link-text" data-i18n="nav.category">總覽</span>
|
||||
</a>
|
||||
<ul>
|
||||
<li class="">
|
||||
<li class="@(ViewData["MainNum"] == "1" && ViewData["SubNum"] == "1" ? "active" : "")">
|
||||
<a href="javascript:void(0);" title="地圖總覽" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">地圖總覽</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<li class="@(ViewData["MainNum"] == "1" && ViewData["SubNum"] == "2" ? "active" : "")">
|
||||
<a href="0stations.html" title="電站總覽" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站總覽</span>
|
||||
</a>
|
||||
@ -105,20 +105,20 @@
|
||||
</ul>
|
||||
</li>
|
||||
<!-- Example of open and active states -->
|
||||
<li class="">
|
||||
<li class="@(ViewData["MainNum"] == "2" ? "active open" : "")">
|
||||
<a href="#" title="Category" data-filter-tags="category">
|
||||
<i class="fal fa-file"></i>
|
||||
<span class="nav-link-text" data-i18n="nav.category">電站資訊</span>
|
||||
</a>
|
||||
<ul>
|
||||
<li class="@(ViewData["MainNum"] == "6" && ViewData["SubNum"] == "1" ? "active" : "")">
|
||||
<li class="@(ViewData["MainNum"] == "2" && ViewData["SubNum"] == "1" ? "active" : "")">
|
||||
<a asp-controller="PowerStation" asp-action="Index" title="電站管理" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站管理</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="">
|
||||
<li class="@(ViewData["MainNum"] == "3" ? "active open" : "")">
|
||||
<a href="#" title="Category" data-filter-tags="category">
|
||||
<i class="fal fa-alien"></i>
|
||||
<span class="nav-link-text" data-i18n="nav.category">交叉分析</span>
|
||||
@ -141,7 +141,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="">
|
||||
<li class="@(ViewData["MainNum"] == "4" ? "active open" : "")">
|
||||
<a href="#" title="Category" data-filter-tags="category">
|
||||
<i class="fal fa-alien"></i>
|
||||
<span class="nav-link-text" data-i18n="nav.category">報表查詢</span>
|
||||
@ -164,7 +164,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="">
|
||||
<li class="@(ViewData["MainNum"] == "5" ? "active open" : "")">
|
||||
<a href="#" title="Category" data-filter-tags="category">
|
||||
<i class="fal fa-alien"></i>
|
||||
<span class="nav-link-text" data-i18n="nav.category">即時告警</span>
|
||||
@ -179,13 +179,13 @@
|
||||
</li>
|
||||
|
||||
|
||||
<li class="@(ViewData["MainNum"] == "5" ? "active open" : "")">
|
||||
<li class="@(ViewData["MainNum"] == "6" ? "active open" : "")">
|
||||
<a href="#" title="Category" data-filter-tags="category">
|
||||
<i class="fal fa-alien"></i>
|
||||
<span class="nav-link-text" data-i18n="nav.category">運維管理</span>
|
||||
</a>
|
||||
<ul>
|
||||
<li class="@(ViewData["MainNum"] == "5" && ViewData["SubNum"] == "1" ? "active" : "")">
|
||||
<li class="@(ViewData["MainNum"] == "6" && ViewData["SubNum"] == "1" ? "active" : "")">
|
||||
<a asp-controller="Operation" asp-action="Index" title="定期計畫建立" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">定期計畫建立</span>
|
||||
</a>
|
||||
@ -197,18 +197,18 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="@(ViewData["MainNum"] == "6" ? "active open" : "")">
|
||||
<li class="@(ViewData["MainNum"] == "7" ? "active open" : "")">
|
||||
<a href="#" title="Category" data-filter-tags="category">
|
||||
<i class="fal fa-alien"></i>
|
||||
<span class="nav-link-text" data-i18n="nav.category">系統管理</span>
|
||||
</a>
|
||||
<ul>
|
||||
<li class="@(ViewData["MainNum"] == "6" && ViewData["SubNum"] == "2" ? "active" : "")">
|
||||
<li class="@(ViewData["MainNum"] == "7" && ViewData["SubNum"] == "1" ? "active" : "")">
|
||||
<a asp-controller="Company" asp-action="Index" title="公司管理" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">公司管理</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="@(ViewData["MainNum"] == "6" && ViewData["SubNum"] == "3" ? "active" : "")">
|
||||
<li class="@(ViewData["MainNum"] == "7" && ViewData["SubNum"] == "2" ? "active" : "")">
|
||||
<a asp-controller="User" asp-action="Index" title="帳號管理" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">帳號管理</span>
|
||||
</a>
|
||||
|
||||
@ -9,9 +9,9 @@
|
||||
"LoginExpireMinute": 60, //登入到期時間,單位(分)
|
||||
"DBConfig": {
|
||||
"Server": "LPp7aTdHGEFQJieGkSGl0g==",
|
||||
"Database": "k48iBBWXwJHPZF9zkF8UjreGN2uYWz6R",
|
||||
"Root": "2TdWJL+VXK8xbnhD8iA0zNJMT95nSE5W",
|
||||
"Password": "BxXjVEJCYCyPmlt03xAKmUNEnXzHhw1j"
|
||||
"Database": "z8TVtiXZ6MwgWbUEAOXA/fiHzd7c0iUhFqn1mHzxhKo=",
|
||||
"Root": "mWlR2HshQNhRRE34jg4kdg==",
|
||||
"Password": "y4uPqlH9ncTgR/I07qpwaA=="
|
||||
},
|
||||
"SMTPConfig": {
|
||||
"Host": "smtp.gmail.com",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user