先併版 逆變器
This commit is contained in:
parent
fce9de630a
commit
f0a4d73da5
@ -1936,5 +1936,224 @@ namespace SolarPower.Controllers
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 儲存控制器
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<string>> SaveController(DeviceControllerModal post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
PowerStation powerStation = new PowerStation();
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
var tableName = powerStation.SiteDB + ".controller";
|
||||
try
|
||||
{
|
||||
for (var i = 0; i < post.Count; i++)
|
||||
{
|
||||
var Num = await powerStationRepository.GetCurrentSerialNumber(tableName, "PowerStationId =" + powerStation.Id);
|
||||
var Newnum = GetLastSerialNumber(Num, 2);
|
||||
DeviceController deviceController = new DeviceController()
|
||||
{
|
||||
Id = post.Id,
|
||||
ControllerId = powerStation.Code + Newnum,
|
||||
PowerStationId = powerStation.Id,
|
||||
CreatedBy = myUser.Id,
|
||||
SerialNumber = Newnum
|
||||
};
|
||||
List<string> properties = new List<string>()
|
||||
{
|
||||
"Id",
|
||||
"ControllerId",
|
||||
"PowerStationId",
|
||||
"CreatedBy",
|
||||
"SerialNumber"
|
||||
};
|
||||
await powerStationRepository.AddDeviceController(deviceController, properties, powerStation.SiteDB);
|
||||
}
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "新增成功";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
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>
|
||||
/// <param name="stationId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ActionResult> DeviceControllerControllerTable (int stationId)
|
||||
{
|
||||
List<DeviceControllerTable> deviceControllerTable = new List<DeviceControllerTable>();
|
||||
ApiResult<List<DeviceControllerTable>> apiResult = new ApiResult<List<DeviceControllerTable>>();
|
||||
PowerStation powerStation = null;
|
||||
try
|
||||
{
|
||||
|
||||
powerStation = await powerStationRepository.GetOneAsync(stationId);
|
||||
deviceControllerTable = await powerStationRepository.DeviceControllerTable(stationId, powerStation.SiteDB);
|
||||
foreach (DeviceControllerTable a in deviceControllerTable)
|
||||
{
|
||||
a.Function = @"
|
||||
<button type='button' class='btn btn-danger btn-pills waves-effect waves-themed del-btn'>刪除</button>";
|
||||
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = deviceControllerTable;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "stationId = " + stationId);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
var result = Json(new
|
||||
{
|
||||
data = apiResult
|
||||
});
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 刪除控制器
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<string>> DeleteOneDeviceControllerController(PostPowerStationIdAndSelectedId post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
PowerStation powerStation = null;
|
||||
try
|
||||
{
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
var deviceController = await powerStationRepository.GetOneWithCustomDBNameAndTableAsync<DeviceController>(post.SelectedId, powerStation.SiteDB, "controller");
|
||||
|
||||
if (deviceController == null)
|
||||
{
|
||||
apiResult.Code = "9988";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await powerStationRepository.DeleteOneByIdWithCustomDBNameAndTable(post.SelectedId, powerStation.SiteDB, "controller");
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
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="post"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<string>> SaveInverter(Inverter post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
PowerStation powerStation = null;
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
var tableName = powerStation.SiteDB + ".inverter";
|
||||
try
|
||||
{
|
||||
var Num = await powerStationRepository.GetCurrentSerialNumber(tableName, "ControllerId =" + post.ControllerId);
|
||||
var Newnum = GetLastSerialNumber(Num);
|
||||
var deviceController = await powerStationRepository.GetOneWithCustomDBNameAndTableAsync<DeviceController>(post.ControllerId, powerStation.SiteDB, "controller");
|
||||
Inverter inverter = new Inverter()
|
||||
{
|
||||
ControllerId = post.ControllerId,
|
||||
SerialNumber = Newnum,
|
||||
InverterId = powerStation.Code + "-" + deviceController.ControllerId + "-" + Newnum,
|
||||
CreatedBy = myUser.Id
|
||||
};
|
||||
List<string> properties = new List<string>()
|
||||
{
|
||||
"ControllerId",
|
||||
"SerialNumber",
|
||||
"CreatedBy",
|
||||
"InverterId"
|
||||
};
|
||||
await powerStationRepository.AddInverter(inverter, properties, powerStation.SiteDB);
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "新增成功";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
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>
|
||||
/// 逆變器Table
|
||||
/// </summary>
|
||||
/// <param name="stationId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ActionResult> InverterTable(int stationId)
|
||||
{
|
||||
ApiResult<List<InverterTable>> apiResult = new ApiResult<List<InverterTable>>();
|
||||
|
||||
|
||||
PowerStation powerStation = null;
|
||||
try
|
||||
{
|
||||
|
||||
powerStation = await powerStationRepository.GetOneAsync(stationId);
|
||||
List<int> deviceControllerid = await powerStationRepository.GetAllDeviceControllerId(stationId,powerStation.SiteDB);
|
||||
List<InverterTable> InverterTable = new List<InverterTable>();
|
||||
InverterTable = await powerStationRepository.InverterTable(deviceControllerid, powerStation.SiteDB);
|
||||
|
||||
|
||||
|
||||
foreach (InverterTable a in InverterTable)
|
||||
{
|
||||
a.Function = @"
|
||||
<button type='button' class='btn btn-danger btn-pills waves-effect waves-themed del-btn'>刪除</button>";
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = InverterTable;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "stationId = " + stationId);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
var result = Json(new
|
||||
{
|
||||
data = apiResult
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ namespace SolarPower.Models
|
||||
{
|
||||
{ "0000", "OK" },
|
||||
{ "0001", "傳入參數錯誤。" },
|
||||
{ "9988", "查無該資料紀錄"},
|
||||
{ "9989", "查無該運維作業記錄"},
|
||||
{ "9990", "查無該圖片"},
|
||||
{ "9991", "查無該土地房屋資訊"},
|
||||
|
||||
@ -297,4 +297,5 @@ namespace SolarPower.Models
|
||||
public string Notice { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -472,5 +472,47 @@ namespace SolarPower.Models.PowerStation
|
||||
public string Text { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 控制器
|
||||
/// </summary>
|
||||
public class DeviceController : Created
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int PowerStationId { get; set; }
|
||||
public string SerialNumber { get; set; }
|
||||
public string ControllerId { get; set; }
|
||||
}
|
||||
|
||||
public class DeviceControllerModal : DeviceController
|
||||
{
|
||||
public int Count { get; set; }//數量
|
||||
}
|
||||
/// <summary>
|
||||
/// 控制器datatable
|
||||
/// </summary>
|
||||
public class DeviceControllerTable : DeviceController
|
||||
{
|
||||
public string CreatedName { get; set; }
|
||||
public string Function { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 逆變器
|
||||
/// </summary>
|
||||
public class Inverter : Created
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ControllerId { get; set; }
|
||||
public int PowerStationId { get; set; }
|
||||
public string SerialNumber { get; set; }
|
||||
public string InverterId { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 控制器datatable
|
||||
/// </summary>
|
||||
public class InverterTable : Inverter
|
||||
{
|
||||
public string ControllerName { get; set; }
|
||||
public string CreatedName { get; set; }
|
||||
public string Function { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1384,5 +1384,150 @@ namespace SolarPower.Repository.Implement
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AddDeviceController(DeviceController deviceController, List<string> properties, string db_name)
|
||||
{
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
int count;
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "controller");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, deviceController);
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<DeviceControllerTable>> DeviceControllerTable(int stationId, string db_name)
|
||||
{
|
||||
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
List<DeviceControllerTable> deviceControllerTable = new List<DeviceControllerTable>();
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = @$"SELECT
|
||||
col.ControllerId,user.Name As CreatedName ,col.CreatedAt,col.Id
|
||||
FROM {db_name}.controller col
|
||||
LEFT JOIN user ON col.CreatedBy = user.id
|
||||
WHERE col.Deleted = 0 AND col.PowerStationId = @StationId";
|
||||
deviceControllerTable = (await conn.QueryAsync<DeviceControllerTable>(sql, new { StationId = stationId })).ToList();
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return deviceControllerTable;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 新增逆變器
|
||||
/// </summary>
|
||||
/// <param name="inverter"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task AddInverter(Inverter inverter, List<string> properties, string db_name)
|
||||
{
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
int count;
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "inverter");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, inverter);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 取得控制器所有id
|
||||
/// </summary>
|
||||
/// <param name="stationId"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<int>> GetAllDeviceControllerId(int stationId,string db_name)
|
||||
{
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
List<int> count;
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT id FROM {db_name}.controller WHERE PowerStationId = {stationId}";
|
||||
count = (await conn.QueryAsync<int>(sql)).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 逆變器DataTable
|
||||
/// </summary>
|
||||
/// <param name="controllerid"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<InverterTable>> InverterTable(List<int> controllerid, string db_name)
|
||||
{
|
||||
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
List<InverterTable> inverterTable = new List<InverterTable>();
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = @$"SELECT
|
||||
inv.inverterId, inv.id, con.ControllerId AS ControllerName,user.Name As CreatedName ,inv.createdAt
|
||||
FROM {db_name}.inverter inv
|
||||
LEFT JOIN {db_name}.controller con ON inv.ControllerId = con.id
|
||||
LEFT JOIN user ON inv.CreatedBy = user.id
|
||||
WHERE inv.Deleted = 0 AND inv.ControllerId IN @Controllerid";
|
||||
inverterTable = (await conn.QueryAsync<InverterTable>(sql, new { Controllerid = controllerid })).ToList();
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return inverterTable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,6 +253,30 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得單一筆資料(客製化資料庫及資料表)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<A> GetOneWithCustomDBNameAndTableAsync<A>(int id, string db_name, string table_name)
|
||||
{
|
||||
A result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM {db_name}.{table_name} WHERE id = @Id";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<A>(sql, new { Id = id });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過Id,實際刪除單一筆資料
|
||||
/// </summary>
|
||||
|
||||
@ -344,5 +344,41 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="CityId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PowerStation>> GetSolarByCity(MyUser User, List<int> CityId);
|
||||
|
||||
/// <summary>
|
||||
/// 新增控制器
|
||||
/// </summary>
|
||||
/// <param name="deviceController"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task AddDeviceController(DeviceController deviceController, List<string> properties, string db_name);
|
||||
|
||||
/// <summary>
|
||||
/// 控制器dataTable
|
||||
/// </summary>
|
||||
/// <param name="stationId"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<DeviceControllerTable>> DeviceControllerTable(int stationId, string db_name);
|
||||
/// <summary>
|
||||
/// 新增逆變器
|
||||
/// </summary>
|
||||
/// <param name="inverter"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task AddInverter(Inverter inverter, List<string> properties, string db_name);
|
||||
/// <summary>
|
||||
/// 取得控制器所有id
|
||||
/// </summary>
|
||||
Task<List<int>> GetAllDeviceControllerId(int stationId,string db_name);
|
||||
/// <summary>
|
||||
/// 逆變器dataTable
|
||||
/// </summary>
|
||||
/// <param name="controllerid"></param>
|
||||
/// <param name="db_name"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<InverterTable>> InverterTable(List<int> controllerid, string db_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,5 +96,12 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="where"></param>
|
||||
/// <returns></returns>
|
||||
Task<String> GetCurrentSerialNumber(string Table_name, string where = "");
|
||||
|
||||
/// <summary>
|
||||
/// 透過Id,取得單一資料(客製化資料庫及資料表)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<A> GetOneWithCustomDBNameAndTableAsync<A>(int id, string db_name, string table_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,6 +166,151 @@
|
||||
|
||||
}, 'json');
|
||||
|
||||
//#region 控制器列表 DataTable
|
||||
DeviceControllerTable = $("#Controller_table").DataTable({
|
||||
"pageLength": 5,
|
||||
"paging": true,
|
||||
"lengthChange": false,
|
||||
"searching": false,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": true,
|
||||
"columns": [{
|
||||
"data": "controllerId"
|
||||
}, {
|
||||
"data": "createdAt"
|
||||
}, {
|
||||
"data": "createdName"
|
||||
}, {
|
||||
"data": "function"
|
||||
}],
|
||||
"columnDefs": [{
|
||||
'targets': 1,
|
||||
'searchable': false,
|
||||
'orderable': false,
|
||||
'className': 'dt-body-center'
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
"zeroRecords": "沒有符合的結果",
|
||||
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
|
||||
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
|
||||
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
|
||||
"infoPostFix": "",
|
||||
"search": "搜尋:",
|
||||
"paginate": {
|
||||
"first": "第一頁",
|
||||
"previous": "上一頁",
|
||||
"next": "下一頁",
|
||||
"last": "最後一頁"
|
||||
}
|
||||
},
|
||||
'createdRow': function (row, data, dataIndex) {
|
||||
$(row).attr('data-id', data.id);
|
||||
},
|
||||
"ajax": {
|
||||
"url": "/PowerStation/DeviceControllerControllerTable",
|
||||
"type": "POST",
|
||||
"data": function (d) {
|
||||
d.stationId = stationId;
|
||||
},
|
||||
"dataSrc": function (rel) {
|
||||
if (rel.data.code == "9999") {
|
||||
toast_error(rel.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
data = rel.data.data;
|
||||
|
||||
if (data == null || data.length == 0) {
|
||||
this.data = [];
|
||||
}
|
||||
$("#Inverter_ControllerId_modal").empty();
|
||||
|
||||
$.each(data, function (index, val) {
|
||||
$("#Inverter_ControllerId_modal").append($("<option />").val(val.id).text(val.controllerId));
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 逆變器列表 DataTable
|
||||
InverterTable = $("#Inverter_table").DataTable({
|
||||
"pageLength": 5,
|
||||
"paging": true,
|
||||
"lengthChange": false,
|
||||
"searching": false,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": true,
|
||||
"columns": [{
|
||||
"data": "controllerName"
|
||||
}, {
|
||||
"data": "inverterId"
|
||||
}, {
|
||||
"data": "createdAt"
|
||||
}, {
|
||||
"data": "createdName"
|
||||
}, {
|
||||
"data": "function"
|
||||
}],
|
||||
"columnDefs": [{
|
||||
'targets': 1,
|
||||
'searchable': false,
|
||||
'orderable': false,
|
||||
'className': 'dt-body-center'
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
"zeroRecords": "沒有符合的結果",
|
||||
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
|
||||
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
|
||||
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
|
||||
"infoPostFix": "",
|
||||
"search": "搜尋:",
|
||||
"paginate": {
|
||||
"first": "第一頁",
|
||||
"previous": "上一頁",
|
||||
"next": "下一頁",
|
||||
"last": "最後一頁"
|
||||
}
|
||||
},
|
||||
'createdRow': function (row, data, dataIndex) {
|
||||
$(row).attr('data-id', data.id);
|
||||
},
|
||||
"ajax": {
|
||||
"url": "/PowerStation/InverterTable",
|
||||
"type": "POST",
|
||||
"data": function (d) {
|
||||
d.stationId = stationId;
|
||||
},
|
||||
"dataSrc": function (rel) {
|
||||
if (rel.data.code == "9999") {
|
||||
toast_error(rel.data.msg);
|
||||
return;
|
||||
}
|
||||
data = rel.data.data;
|
||||
|
||||
if (data == null || data.length == 0) {
|
||||
this.data = [];
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 運維列表 DataTable
|
||||
OperationTable = $("#Operation_table").DataTable({
|
||||
"paging": true,
|
||||
@ -1523,7 +1668,84 @@
|
||||
|
||||
//#region 儲存控制器資料
|
||||
function SaveController() {
|
||||
var url = "/PowerStation/SaveController";
|
||||
if ($("#Controller-form").valid()) {
|
||||
var send_data = {
|
||||
Id: selected_id,
|
||||
PowerStationId: stationId,
|
||||
Count: $("#Controller_Count_modal").val(),
|
||||
}
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
toast_ok(rel.msg);
|
||||
$('#Controller-modal').modal('hide');
|
||||
DeviceControllerTable.ajax.reload();
|
||||
return;
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 刪除控制器資料
|
||||
$('#Controller_table').on("click", "button.del-btn", function () {
|
||||
selected_id = $(this).parents('tr').attr('data-id');
|
||||
Swal.fire(
|
||||
{
|
||||
title: "刪除",
|
||||
text: "你確定是否刪除此筆資料?",
|
||||
type: "warning",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "是",
|
||||
cancelButtonText: "否"
|
||||
}).then(function (result) {
|
||||
if (result.value) {
|
||||
var url = "/PowerStation/DeleteOneDeviceControllerController/";
|
||||
|
||||
var send_data = {
|
||||
SelectedId: selected_id,
|
||||
PowerStationId: stationId
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
toast_ok(rel.msg);
|
||||
DeviceControllerTable.ajax.reload();
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 儲存逆變器資料
|
||||
function SaveInverter() {
|
||||
var url = "/PowerStation/SaveInverter";
|
||||
if ($("#Inverter-form").valid()) {
|
||||
var send_data = {
|
||||
ControllerId:$("#Inverter_ControllerId_modal").val(),
|
||||
PowerStationId: stationId,
|
||||
}
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
toast_ok(rel.msg);
|
||||
$('#Inverter-modal').modal('hide');
|
||||
//DeviceTable.ajax.reload();
|
||||
return;
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
@ -1544,7 +1766,6 @@
|
||||
TableName: $("#Device_TableName_modal").val(),
|
||||
ColName: $("#Device_ColName_modal").val(),
|
||||
Remark: $("#Device_Remark_modal").val()
|
||||
|
||||
}
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
@ -1987,6 +2208,7 @@
|
||||
//#endregion
|
||||
|
||||
//#endregion
|
||||
|
||||
$('#Exception_UpperLimit_modal').change(function () {
|
||||
upper = $('#Exception_UpperLimit_modal').val();
|
||||
$("#Exception_LowerLimit_modal").rules("remove");
|
||||
|
||||
@ -168,7 +168,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="Inverter-form" id="Controller-form">
|
||||
<form class="Inverter-form" id="Inverter-form">
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="Inverter_ControllerId_modal"><span class="text-danger">*</span>逆變器編號</label>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user