diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs
index b017a3e..eb63f51 100644
--- a/SolarPower/Controllers/PowerStationController.cs
+++ b/SolarPower/Controllers/PowerStationController.cs
@@ -2472,9 +2472,9 @@ namespace SolarPower.Controllers
/// 其他電站下拉式選單
///
///
- public async Task>> GetPowerstationOption(int stationId)
+ public async Task>> GetPowerstationOption(int stationId)
{
- ApiResult> apiResult = new ApiResult>();
+ ApiResult> apiResult = new ApiResult>();
try
{
var powerStation = await powerStationRepository.GetOneAsync(stationId);
@@ -2497,9 +2497,9 @@ namespace SolarPower.Controllers
///
///
///
- public async Task>> GetDeviceUIDList(int stationId)
+ public async Task>> GetDeviceUIDList(int stationId)
{
- ApiResult> apiResult = new ApiResult>();
+ ApiResult> apiResult = new ApiResult>();
try
{
var powerStation = await powerStationRepository.GetOneAsync(stationId);
diff --git a/SolarPower/Models/PowerStation.cs b/SolarPower/Models/PowerStation.cs
index ba42f78..c37bcde 100644
--- a/SolarPower/Models/PowerStation.cs
+++ b/SolarPower/Models/PowerStation.cs
@@ -574,6 +574,12 @@ namespace SolarPower.Models.PowerStation
public string Text { get; set; }
public string Value { get; set; }
}
+ public class PowerstationOptionAndName
+ {
+ public string Text { get; set; }
+ public string Value { get; set; }
+ public string Name { get; set; }
+ }
///
/// 共享設備
///
diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs
index 63d8644..f68a67e 100644
--- a/SolarPower/Repository/Implement/PowerStationRepository.cs
+++ b/SolarPower/Repository/Implement/PowerStationRepository.cs
@@ -1760,16 +1760,16 @@ namespace SolarPower.Repository.Implement
/// 其餘電站列表
///
///
- public async Task> GetPowerstationOptionAsync(string db_name, int stationId)
+ public async Task> GetPowerstationOptionAsync(string db_name, int stationId)
{
- List result;
+ List result;
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
try
{
- var sql = $@"SELECT Id AS Value, Code AS Text FROM {db_name}.power_station WHERE Deleted = 0 AND Id !={stationId}";
+ var sql = $@"SELECT Id AS Value, Code AS Text ,Name FROM {db_name}.power_station WHERE Deleted = 0 AND Id !={stationId}";
- result = (await conn.QueryAsync(sql)).ToList();
+ result = (await conn.QueryAsync(sql)).ToList();
}
catch (Exception exception)
{
@@ -1808,16 +1808,16 @@ namespace SolarPower.Repository.Implement
///
///
///
- public async Task> GetDeviceUIDListAsync(string db_name, int stationId)
+ public async Task> GetDeviceUIDListAsync(string db_name, int stationId)
{
- List result;
+ List result;
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
try
{
- var sql = $@"SELECT Id AS Value, UID AS Text FROM {db_name}.device WHERE Deleted = 0 AND PowerStationId ={stationId}";
+ var sql = $@"SELECT Id AS Value, UID AS Text, Name FROM {db_name}.device WHERE Deleted = 0 AND PowerStationId ={stationId}";
- result = (await conn.QueryAsync(sql)).ToList();
+ result = (await conn.QueryAsync(sql)).ToList();
}
catch (Exception exception)
{
diff --git a/SolarPower/Repository/Interface/IPowerStationRepository.cs b/SolarPower/Repository/Interface/IPowerStationRepository.cs
index fa85721..6a09846 100644
--- a/SolarPower/Repository/Interface/IPowerStationRepository.cs
+++ b/SolarPower/Repository/Interface/IPowerStationRepository.cs
@@ -405,14 +405,14 @@ namespace SolarPower.Repository.Interface
/// 電站下拉式選單
///
///
- Task> GetPowerstationOptionAsync(string db_name, int stationId);
+ Task> GetPowerstationOptionAsync(string db_name, int stationId);
///
/// 設備編號下拉式選單
///
///
///
///
- Task> GetDeviceUIDListAsync(string db_name, int stationId);
+ Task> GetDeviceUIDListAsync(string db_name, int stationId);
///
/// 新增共享設備
///
diff --git a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml
index 21888d5..8142cae 100644
--- a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml
+++ b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml
@@ -796,7 +796,7 @@
$("#ShareDevice_PowerStationId_modal").empty();
$.each(rel.data, function (index, val) {
- $("#ShareDevice_PowerStationId_modal").append($("").val(val.value).text(val.text));
+ $("#ShareDevice_PowerStationId_modal").append($("").val(val.value).text(val.text +"/"+ val.name));
});
if (rel.data.length > 0)
{
@@ -914,7 +914,7 @@
}
else {
$.each(rel.data, function (index, val) {
- $("#ShareDevice_UID_modal").append($("").val(val.value).text(val.text));
+ $("#ShareDevice_UID_modal").append($("").val(val.value).text(val.text + "/" + val.name));
});
@@ -2105,6 +2105,7 @@
document.getElementById('Device_Enabled_modal').disabled = true;
$("#Device-modal .modal-title").html("裝置資料 - 新增");
$("#Device-form").trigger("reset");
+ /*$("#Device_TableName_modal").val("s" + $("#Device_Controller_modal").text() + "_sensoravg");*/
$("#Device-modal").modal();
}
//#endregion
@@ -2284,6 +2285,7 @@
if ($("#Device-form").valid()) {
var url = "/PowerStation/SaveDevice";
+ var a = padLeft($("#Device_ColName_modal").val(), 2);
var send_data = {
Id: selected_id,
PowerStationId: stationId,
@@ -2295,7 +2297,7 @@
ProductModel: $("#Device_ProductModel_modal").val(),
//DBName: $("#Device_DBName_modal").val(),
TableName: $("#Device_TableName_modal").val(),
- ColName: $("#Device_ColName_modal").val(),
+ ColName: "SENSORAVG" + a,
InstallDate: $("#Device_InstallDate_modal").val(),
Status: $("#Device_Status_modal").val(),
Enabled: $("#Device_Enabled_modal").val(),
@@ -2345,7 +2347,9 @@
$("#Device_ProductModel_modal").val(rel.data.productModel);
//$("#Device_DBName_modal").val(rel.data.dbName);
$("#Device_TableName_modal").val(rel.data.tableName);
- $("#Device_ColName_modal").val(rel.data.colName);
+ var colNameNum = rel.data.colName.substr(9, 2);
+
+ $("#Device_ColName_modal").val(colNameNum);
$("#Device_Controller_modal").val(rel.data.controllerId);
$("#Device_Name_modal").val(rel.data.name);
$("#Device_Status_modal").val(rel.data.status);
@@ -2791,5 +2795,55 @@
min: 0
});
});
+
+ function padLeft(str, lenght) {
+ if (str.length >= lenght)
+ return str;
+ else
+ return padLeft("0" + str, lenght);
+ }
+ $("#Device-form").validate({
+ rules: {
+ Device_Brand_modal: {
+ required: true
+ },
+ Device_Name_modal: {
+ required: true
+ },
+ Device_ProductModel_modal: {
+ required: true
+ },
+ Device_InstallDate_modal: {
+ required: true
+ },
+ Device_ColName_modal: {
+ max: 50,
+ min: 1
+ }
+ }
+ });
+ $("#Inverter-form").validate({
+ rules: {
+ Inverter_ControllerId_modal: {
+ required: true
+ },
+ Inverter_InverterName_modal: {
+ required: true
+ },
+ Inverter_InstallDate_modal: {
+ required: true
+ },
+ Inverter_Brand_modal: {
+ required: true
+ },
+ Inverter_Model_modal: {
+ required: true
+ },
+ Inverter_Capacity_modal: {
+ required: true
+ },
+ }
+ });
+
}
\ No newline at end of file
diff --git a/SolarPower/Views/PowerStation/_DeviceSetting.cshtml b/SolarPower/Views/PowerStation/_DeviceSetting.cshtml
index 041d783..a17e3d6 100644
--- a/SolarPower/Views/PowerStation/_DeviceSetting.cshtml
+++ b/SolarPower/Views/PowerStation/_DeviceSetting.cshtml
@@ -275,22 +275,19 @@
- @**@