This commit is contained in:
b110212000 2021-06-24 09:45:09 +08:00
parent 6de3525a05
commit f05bd9e1a7
11 changed files with 268 additions and 88 deletions

View File

@ -179,14 +179,14 @@ namespace SolarPower.Controllers
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<ActionResult> OperationPlanTable(List<int> id)
public async Task<ActionResult> OperationPlanTable(List<int> id,int type)
{
List<OperationPlanTable> OperationPlanTable = new List<OperationPlanTable>();
ApiResult<List<OperationPlanTable>> apiResult = new ApiResult<List<OperationPlanTable>>();
try
{
apiResult.Code = "0000";
OperationPlanTable = await operationRepository.OperationPlanTable(id);
OperationPlanTable = await operationRepository.OperationPlanTable(id,type);
foreach (OperationPlanTable a in OperationPlanTable)
{
if(a.Type == 0)

View File

@ -937,11 +937,12 @@ namespace SolarPower.Controllers
ApiResult<string> apiResult = new ApiResult<string>();
try
{
PowerStation powerStation = null;
powerStation = await powerStationRepository.GetOneAsync(Device.PowerStationId);
if (Device.Id == 0)
{
PowerStation powerStation = null;
powerStation = await powerStationRepository.GetOneAsync(Device.PowerStationId);
string Number = await powerStationRepository.GetFinalSerialNumber(Device.PowerStationId, Device.Type);
string Number = await powerStationRepository.GetFinalSerialNumber(Device.PowerStationId, Device.Type,powerStation.SiteDB);
var tempSerialNumber = 0;
if (!string.IsNullOrEmpty(Number))
{
@ -985,7 +986,7 @@ namespace SolarPower.Controllers
"TypeName",
"SerialNumber"
};
await powerStationRepository.AddDevice(DeviceInfo, properties);
await powerStationRepository.AddDevice(DeviceInfo, properties, powerStation.SiteDB);
apiResult.Code = "0000";
apiResult.Msg = "新增成功";
@ -1018,7 +1019,7 @@ namespace SolarPower.Controllers
"CreatedBy",
"TypeName"
};
await powerStationRepository.UpdateDevice(DeviceInfo, properties);
await powerStationRepository.UpdateDevice(DeviceInfo, properties, powerStation.SiteDB);
apiResult.Code = "0000";
apiResult.Msg = "儲存成功";
}
@ -1028,6 +1029,8 @@ namespace SolarPower.Controllers
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Device=" + Device);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
@ -1042,8 +1045,10 @@ namespace SolarPower.Controllers
ApiResult<List<DeviceTable>> apiResult = new ApiResult<List<DeviceTable>>();
try
{
PowerStation powerStation = null;
powerStation = await powerStationRepository.GetOneAsync(stationId);
apiResult.Code = "0000";
deviceTables = await powerStationRepository.DeviceTable(stationId);
deviceTables = await powerStationRepository.DeviceTable(stationId, powerStation.SiteDB);
foreach (DeviceTable a in deviceTables)
{
a.Function = @"
@ -1056,6 +1061,8 @@ namespace SolarPower.Controllers
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "stationId=" + stationId);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
var result = Json(new
{
@ -1112,20 +1119,24 @@ namespace SolarPower.Controllers
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<ApiResult<DeviceInfo>> GetOneDevice(int id)
public async Task<ApiResult<DeviceInfo>> GetOneDevice(PostPowerStationIdAndSelectedId id)
{
DeviceInfo Device = new DeviceInfo();
ApiResult<DeviceInfo> apiResult = new ApiResult<DeviceInfo>();
try
{
PowerStation powerStation = null;
powerStation = await powerStationRepository.GetOneAsync(id.PowerStationId);
apiResult.Code = "0000";
Device = await powerStationRepository.OneDeviceInfo(id);
Device = await powerStationRepository.OneDeviceInfo(id.SelectedId, powerStation.SiteDB);
apiResult.Data = Device;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "id=" + id);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
@ -1136,13 +1147,15 @@ namespace SolarPower.Controllers
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<ApiResult<string>> DeleteOneDevice(int id)
public async Task<ApiResult<string>> DeleteOneDevice(PostPowerStationIdAndSelectedId id)
{
ApiResult<string> apiResult = new ApiResult<string>();
DeviceInfo Device = new DeviceInfo();
try
{
Device = await powerStationRepository.OneDeviceInfo(id);
PowerStation powerStation = null;
powerStation = await powerStationRepository.GetOneAsync(id.PowerStationId);
Device = await powerStationRepository.OneDeviceInfo(id.SelectedId, powerStation.SiteDB);
if (Device == null)
{
@ -1178,8 +1191,11 @@ namespace SolarPower.Controllers
ApiResult<string> apiResult = new ApiResult<string>();
try
{
PowerStation powerStation = null;
powerStation = await powerStationRepository.GetOneAsync(exceptionModal.PowerStationId);
if (exceptionModal.Id == 0)
{
ExceptionModal Exception = new ExceptionModal()
{
Alarm = exceptionModal.Alarm,
@ -1200,7 +1216,7 @@ namespace SolarPower.Controllers
"Type",
"UpperLimit",
};
await powerStationRepository.AddException(Exception, properties);
await powerStationRepository.AddException(Exception, properties,powerStation.SiteDB);
apiResult.Code = "0000";
apiResult.Msg = "新增成功";
@ -1227,7 +1243,7 @@ namespace SolarPower.Controllers
"Type",
"UpperLimit",
};
await powerStationRepository.UpdateException(Exception, properties);
await powerStationRepository.UpdateException(Exception, properties,powerStation.SiteDB);
apiResult.Code = "0000";
apiResult.Msg = "儲存成功";
}
@ -1237,6 +1253,8 @@ namespace SolarPower.Controllers
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "ExceptionModal=" + exceptionModal);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
@ -1251,8 +1269,10 @@ namespace SolarPower.Controllers
ApiResult<List<ExceptionTable>> apiResult = new ApiResult<List<ExceptionTable>>();
try
{
PowerStation powerStation = null;
powerStation = await powerStationRepository.GetOneAsync(stationId);
apiResult.Code = "0000";
exceptionTable = await powerStationRepository.ExceptionTable(stationId);
exceptionTable = await powerStationRepository.ExceptionTable(stationId,powerStation.SiteDB);
foreach (ExceptionTable a in exceptionTable)
{
a.Function = @"
@ -1273,6 +1293,8 @@ namespace SolarPower.Controllers
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "stationId=" + stationId);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
var result = Json(new
{
@ -1285,20 +1307,24 @@ namespace SolarPower.Controllers
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<ApiResult<ExceptionModal>> GetOneException(int id)
public async Task<ApiResult<ExceptionModal>> GetOneException(PostPowerStationIdAndSelectedId id)
{
ExceptionModal Exception = new ExceptionModal();
ApiResult<ExceptionModal> apiResult = new ApiResult<ExceptionModal>();
try
{
PowerStation powerStation = null;
powerStation = await powerStationRepository.GetOneAsync(id.PowerStationId);
apiResult.Code = "0000";
Exception = await powerStationRepository.OneException(id);
Exception = await powerStationRepository.OneException(id.SelectedId,powerStation.SiteDB);
apiResult.Data = Exception;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "id=" + id);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
@ -1309,17 +1335,19 @@ namespace SolarPower.Controllers
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<ApiResult<string>> DeleteOneException(int id)
public async Task<ApiResult<string>> DeleteOneException(PostPowerStationIdAndSelectedId id)
{
ApiResult<string> apiResult = new ApiResult<string>();
ExceptionModal Exception = new ExceptionModal();
try
{
Exception = await powerStationRepository.OneException(id);
PowerStation powerStation = null;
powerStation = await powerStationRepository.GetOneAsync(id.PowerStationId);
Exception = await powerStationRepository.OneException(id.SelectedId,powerStation.SiteDB);
if (Exception == null)
{
apiResult.Code = "9996";
apiResult.Code = "9999";
apiResult.Msg = errorCode.GetString(apiResult.Code);
return apiResult;
}
@ -1334,7 +1362,7 @@ namespace SolarPower.Controllers
{
apiResult.Code = "9999";
apiResult.Msg = errorCode.GetString(apiResult.Code);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "id=" + id);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}

View File

@ -37,7 +37,7 @@ namespace SolarPower.Helper
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;database=solar_power;user=root;password=000000;charset=utf8;";
var connStr = @"server=210.61.91.43;port=10068;database=solar_power_test;user=idafenweb;password=P@ssw0rd;charset=utf8;";
this._connectionString = connStr;
}

View File

@ -26,6 +26,10 @@ namespace SolarPower.Models
public string Text { get; set; }
public string Value { get; set; }
}
public class SendData
{
public List<int> id { get; set; }
}
public class OperationCreatePlanModal : Created
{
private string startTime = "", endTime = "";

View File

@ -58,7 +58,7 @@ namespace SolarPower.Repository.Implement
}
}
public async Task<List<OperationPlanTable>> OperationPlanTable(List<int> id)
public async Task<List<OperationPlanTable>> OperationPlanTable(List<int> id,int Type)
{
List<OperationPlanTable> result;
var count = 0;
@ -80,11 +80,25 @@ namespace SolarPower.Repository.Implement
{
try
{
var sql = @$"SELECT oc.Id,oc.PlanId,oc.PowerStationId,oc.Type,
var sql = "";
if (Type != 9)
{
sql = @$"SELECT oc.Id,oc.PlanId,oc.PowerStationId,oc.Type,
oc.ScheduleNum,oc.ScheduleType,oc.WorkDay,oc.StartTime,
oc.EmailType,oc.Description,oc.CreatedAt,ps.Name AS PowerStationName ,us.Name AS CreatedPerson FROM operation_plan_create oc LEFT JOIN power_station ps
ON oc.PowerStationId = ps.Id LEFT JOIN user us
ON us.Id = oc.CreatedBy WHERE {Wheresql} AND oc.Deleted = 0";
ON us.Id = oc.CreatedBy WHERE ({Wheresql}) AND oc.Deleted = 0 AND oc.Type = {Type}";
}
else
{
sql = @$"SELECT oc.Id,oc.PlanId,oc.PowerStationId,oc.Type,
oc.ScheduleNum,oc.ScheduleType,oc.WorkDay,oc.StartTime,
oc.EmailType,oc.Description,oc.CreatedAt,ps.Name AS PowerStationName ,us.Name AS CreatedPerson FROM operation_plan_create oc LEFT JOIN power_station ps
ON oc.PowerStationId = ps.Id LEFT JOIN user us
ON us.Id = oc.CreatedBy WHERE ({Wheresql}) AND oc.Deleted = 0";
}
result = (await conn.QueryAsync<OperationPlanTable>(sql)).ToList();
}
catch (Exception exception)

View File

@ -651,16 +651,17 @@ namespace SolarPower.Repository.Implement
/// <param name="DeviceInfo"></param>
/// <param name="properties"></param>
/// <returns></returns>
public async Task AddDevice(Device DeviceInfo, List<string> properties)
public async Task AddDevice(Device DeviceInfo, List<string> properties, string db_name)
{
using IDbConnection conn = _databaseHelper.GetConnection();
var trans = conn.BeginTransaction();
conn.Open();
try
{
string sql = GenerateInsertQueryWithCustomTable(properties, "device");
string sql = GenerateUpdateQueryWithCustomDBNameAndTable(properties,db_name, "device");
await conn.ExecuteAsync(sql, DeviceInfo);
trans.Commit();
}
catch (Exception exception)
{
@ -668,6 +669,7 @@ namespace SolarPower.Repository.Implement
}
finally
{
trans.Rollback();
conn.Close();
}
@ -678,14 +680,14 @@ namespace SolarPower.Repository.Implement
/// <param name="DeviceInfo"></param>
/// <param name="properties"></param>
/// <returns></returns>
public async Task UpdateDevice(Device DeviceInfo, List<string> properties)
public async Task UpdateDevice(Device DeviceInfo, List<string> properties, string db_name)
{
using IDbConnection conn = _databaseHelper.GetConnection();
conn.Open();
var trans = conn.BeginTransaction();
try
{
var updateQuery = GenerateUpdateQueryWithCustomTable(properties, "device");
var updateQuery = GenerateUpdateQueryWithCustomDBNameAndTable(properties,db_name, "device");
await conn.ExecuteAsync(updateQuery.ToString(), DeviceInfo, trans);
trans.Commit();
}
@ -704,14 +706,14 @@ namespace SolarPower.Repository.Implement
/// </summary>
/// <param name="stationId"></param>
/// <returns></returns>
public async Task<List<DeviceTable>> DeviceTable(int stationId)
public async Task<List<DeviceTable>> DeviceTable(int stationId, string db_name)
{
using IDbConnection conn = _databaseHelper.GetConnection();
conn.Open();
List<DeviceTable> Device = new List<DeviceTable>();
try
{
string sql = @$"SELECT * FROM device WHERE Deleted = 0 AND PowerStationId = @StationId";
string sql = @$"SELECT * FROM {db_name}.device WHERE Deleted = 0 AND PowerStationId = @StationId";
Device = (await conn.QueryAsync<DeviceTable>(sql, new { StationId = stationId })).ToList();
}
catch (Exception exception)
@ -729,7 +731,7 @@ namespace SolarPower.Repository.Implement
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<DeviceInfo> OneDeviceInfo(int id)
public async Task<DeviceInfo> OneDeviceInfo(int id, string db_name)
{
using (IDbConnection conn = _databaseHelper.GetConnection())
{
@ -737,7 +739,7 @@ namespace SolarPower.Repository.Implement
conn.Open();
try
{
string sql = @$"SELECT * FROM device WHERE Id = @Id";
string sql = @$"SELECT * FROM {db_name}.device WHERE Id = @Id";
Device = await conn.QueryFirstOrDefaultAsync<DeviceInfo>(sql, new { Id = id });
}
catch (Exception exception)
@ -757,13 +759,13 @@ namespace SolarPower.Repository.Implement
/// <param name="Exception"></param>
/// <param name="properties"></param>
/// <returns></returns>
public async Task AddException(ExceptionModal Exception, List<string> properties)
public async Task AddException(ExceptionModal Exception, List<string> properties, string db_name)
{
using IDbConnection conn = _databaseHelper.GetConnection();
conn.Open();
try
{
string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_exception");
string sql = GenerateUpdateQueryWithCustomDBNameAndTable(properties,db_name,"power_station_exception");
await conn.ExecuteAsync(sql, Exception);
@ -783,7 +785,7 @@ namespace SolarPower.Repository.Implement
/// </summary>
/// <param name="stationId"></param>
/// <returns></returns>
public async Task<List<ExceptionTable>> ExceptionTable(int stationId)
public async Task<List<ExceptionTable>> ExceptionTable(int stationId, string db_name)
{
using IDbConnection conn = _databaseHelper.GetConnection();
conn.Open();
@ -791,8 +793,8 @@ namespace SolarPower.Repository.Implement
try
{
string sql = @$"SELECT pe.Type,pe.UpperLimit,pe.LowerLimit,pe.Alarm,ps.Code AS PowerStationCode ,ps.Name AS PowerStationName,pe.CreatedAt,pe.Id
FROM power_station_exception pe
LEFT JOIN power_station ps ON pe.PowerStationId = ps.Id
FROM {db_name}.power_station_exception pe
LEFT JOIN {db_name}.power_station ps ON pe.PowerStationId = ps.Id
WHERE pe.Deleted = 0 AND pe.PowerStationId = @StationId";
Exception = (await conn.QueryAsync<ExceptionTable>(sql, new { StationId = stationId })).ToList();
}
@ -811,7 +813,7 @@ namespace SolarPower.Repository.Implement
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<ExceptionModal> OneException(int id)
public async Task<ExceptionModal> OneException(int id, string db_name)
{
using (IDbConnection conn = _databaseHelper.GetConnection())
{
@ -819,7 +821,7 @@ namespace SolarPower.Repository.Implement
conn.Open();
try
{
string sql = @$"SELECT * FROM power_station_exception WHERE Id = @Id";
string sql = @$"SELECT * FROM {db_name}.power_station_exception WHERE Id = @Id";
Exception = await conn.QueryFirstOrDefaultAsync<ExceptionModal>(sql, new { Id = id });
}
catch (Exception exception)
@ -839,14 +841,14 @@ namespace SolarPower.Repository.Implement
/// <param name="Exception"></param>
/// <param name="properties"></param>
/// <returns></returns>
public async Task UpdateException(ExceptionModal Exception, List<string> properties)
public async Task UpdateException(ExceptionModal Exception, List<string> properties, string db_name)
{
using IDbConnection conn = _databaseHelper.GetConnection();
conn.Open();
var trans = conn.BeginTransaction();
try
{
var updateQuery = GenerateUpdateQueryWithCustomTable(properties, "power_station_exception");
var updateQuery = GenerateUpdateQueryWithCustomDBNameAndTable(properties,db_name,"power_station_exception");
await conn.ExecuteAsync(updateQuery.ToString(), Exception, trans);
trans.Commit();
}
@ -860,7 +862,7 @@ namespace SolarPower.Repository.Implement
conn.Close();
}
}
public async Task<string> GetFinalSerialNumber(int PowerStationId, string Type)
public async Task<string> GetFinalSerialNumber(int PowerStationId, string Type, string db_name)
{
string Num;
using IDbConnection conn = _databaseHelper.GetConnection();
@ -868,7 +870,7 @@ namespace SolarPower.Repository.Implement
var trans = conn.BeginTransaction();
try
{
var sql = "SELECT SerialNumber FROM device WHERE PowerStationId = @PowerStationId AND Type = @Type ORDER BY SerialNumber DESC";
var sql = $"SELECT SerialNumber FROM {db_name}.device WHERE PowerStationId = @PowerStationId AND Type = @Type ORDER BY SerialNumber DESC";
Num = await conn.QueryFirstOrDefaultAsync<string>(sql, new { PowerStationId = PowerStationId, Type = Type });
trans.Commit();
}

View File

@ -10,7 +10,7 @@ namespace SolarPower.Repository.Interface
{
Task<List<PowerStationIdList>> GetPowerStationIdList(int UserId);
Task AddOperationPlan(OperationCreatePlan OperationPlan, List<string> properties);
Task<List<OperationPlanTable>> OperationPlanTable(List<int> id);
Task<List<OperationPlanTable>> OperationPlanTable(List<int> id,int Type);
Task<OperationCreatePlan> GetOneOperation(int id);
Task UpdateOperationPlan(OperationCreatePlan OperationPlan, List<string> properties);
Task AddToRecord(PlanToRecord record, List<string> properties2);

View File

@ -159,34 +159,34 @@ namespace SolarPower.Repository.Interface
/// </summary>
/// <param name=""></param>
/// <returns></returns>
Task AddDevice(Device DeviceInfo, List<string> properties);
Task AddDevice(Device DeviceInfo, List<string> properties, string db_name);
/// <summary>
/// 修改 裝置
/// </summary>
/// <param name="DeviceInfo"></param>
/// <param name="properties"></param>
/// <returns></returns>
Task UpdateDevice(Device DeviceInfo, List<string> properties);
Task UpdateDevice(Device DeviceInfo, List<string> properties, string db_name);
/// <summary>
/// 設備datatable
/// </summary>
/// <param name="stationId"></param>
/// <returns></returns>
Task<List<DeviceTable>> DeviceTable(int stationId);
Task<List<DeviceTable>> DeviceTable(int stationId, string db_name);
/// <summary>
/// 異常datatable
/// </summary>
/// <param name="stationId"></param>
/// <returns></returns>
Task<List<ExceptionTable>> ExceptionTable(int stationId);
Task<List<ExceptionTable>> ExceptionTable(int stationId, string db_name);
/// <summary>
/// 取單一筆DeviceInfo
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<DeviceInfo> OneDeviceInfo(int id);
Task<DeviceInfo> OneDeviceInfo(int id, string db_name);
/// <summary>
/// 新增 異常設定
@ -194,14 +194,14 @@ namespace SolarPower.Repository.Interface
/// <param name="Exception"></param>
/// <param name="properties"></param>
/// <returns></returns>
Task AddException(ExceptionModal Exception, List<string> properties);
Task AddException(ExceptionModal Exception, List<string> properties, string db_name);
/// <summary>
/// 取一筆異常設定
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<ExceptionModal> OneException(int id);
Task<ExceptionModal> OneException(int id, string db_name);
/// <summary>
/// 更新異常設定
@ -209,7 +209,7 @@ namespace SolarPower.Repository.Interface
/// <param name="Exception"></param>
/// <param name="properties"></param>
/// <returns></returns>
Task UpdateException(ExceptionModal Exception, List<string> properties);
Task UpdateException(ExceptionModal Exception, List<string> properties, string db_name);
/// <summary>
/// 取最後一個設備流水號
@ -217,7 +217,7 @@ namespace SolarPower.Repository.Interface
/// <param name="PowerStationId"></param>
/// <param name="Type"></param>
/// <returns></returns>
Task<string> GetFinalSerialNumber(int PowerStationId, string Type);
Task<string> GetFinalSerialNumber(int PowerStationId, string Type, string db_name);
/// <summary>
/// 透過電站編號,取得該電站的運維人員編號

View File

@ -6,6 +6,7 @@
@using SolarPower.Models.Role
@model RoleLayerEnum
<ol class="breadcrumb page-breadcrumb">
<li class="breadcrumb-item"><a href="javascript:void(0);">系統管理</a></li>
<li class="breadcrumb-item active">定期計畫建立</li>
@ -26,9 +27,9 @@
<div class="row mb-3 px-3">
<div class="pr-3">
<div class="btn-group btn-group-md">
<button type="button" class="btn btn-success waves-effect waves-themed">全部</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed">巡檢</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed">清洗</button>
<button type="button" class="btn btn-success waves-effect waves-themed" onclick="ChangeType(9)" id="button9">全部</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="ChangeType(1)" id="button1">巡檢</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="ChangeType(0)" id="button0">清洗</button>
</div>
</div>
</div>
@ -38,12 +39,12 @@
<button type="button" class="btn btn-secondary waves-effect waves-themed">全部縣市</button>
</div>
<div class="pr-3">
<div class="frame-wrap">
<div class="frame-wrap" id="citytest" style="display:none">
<button type="button" class="btn btn-outline-success waves-effect waves-themed">
新北市
<span class="badge bg-success-700 ml-2">4</span>
</button>
<button type="button" class="btn btn-outline-success waves-effect waves-themed">
@*<button type="button" class="btn btn-outline-success waves-effect waves-themed">
台北市
<span class="badge bg-success-700 ml-2">4</span>
</button>
@ -58,7 +59,10 @@
<button type="button" class="btn btn-outline-success waves-effect waves-themed">
台中市
<span class="badge bg-success-700 ml-2">4</span>
</button>
</button>*@
</div>
<div class="frame-wrap" id="city">
</div>
</div>
</div>
@ -98,7 +102,7 @@
</div>
<div class="row d-flex justify-content-end px-3">
<button type="button" class="btn btn-info waves-effect waves-themed mb-3 mr-2">
<button type="button" class="btn btn-info waves-effect waves-themed mb-3 mr-2" onClick="saveToExcel();">
<span class="fal fa-file-excel mr-1"></span>
匯出
</button>
@ -126,6 +130,34 @@
<tbody>
</tbody>
</table>
<table id="NoView">
<thead class="thead-themed">
<tr>
<th>計劃單號</th>
<th>項目</th>
<th>電站</th>
<th>排程週期</th>
<th>每次預期/天</th>
<th>開始時間</th>
<th>email 通知</th>
<th>建立人</th>
<th>建立時間</th>
</tr>
</thead>
<tbody id="NoViewbody">
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
@ -236,8 +268,11 @@
@section Scripts{
<script>
var selected_id = 0;
var type = 9;
$(function () {
//#region 電站下拉式選單select_option
var url_operation_select_option = "/Operation/GetPowerStationSelectOption";
@ -266,26 +301,26 @@
"responsive": true,
"order": [[9, "desc"]],
"columns": [{
"data": "planId"
}, {
"data": "typeName"
}, {
"data": "powerStationName"
}, {
"data": "schedule"
}, {
"data": "workDay"
}, {
"data": "startTimeString"
}, {
"data": "emailTypeName"
}, {
"data": "createdPerson"
}, {
"data": "createTimeString"
}, {
"data": "function"
}],
"data": "planId"
}, {
"data": "typeName"
}, {
"data": "powerStationName"
}, {
"data": "schedule"
}, {
"data": "workDay"
}, {
"data": "startTimeString"
}, {
"data": "emailTypeName"
}, {
"data": "createdPerson"
}, {
"data": "createTimeString"
}, {
"data": "function"
}],
"columnDefs": [{
'targets': 1,
'searchable': false,
@ -321,7 +356,8 @@
"url": "/Operation/OperationPlanTable",
"type": "POST",
"data": function (d) {
d.id = [1,2];
d.id = [1, 2],
d.type = type
},
"dataSrc": function (rel) {
if (rel.data.code == "9999") {
@ -337,7 +373,61 @@
}
});
//#endregion
var Nurl = "/PowerStation/GetSolarCitySummary";
var ids = new Array(0);
$.post(Nurl, function (rel)
{
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$.each(rel.data, function (index, val) {
ids.push(val.cityId);
$('#citytest').find('button').attr('id', 'cityID' + val.cityId).clone().appendTo($('#city'));
var name = 'cityID' + val.cityId;
document.getElementById(name).innerHTML = val.city;
/* $('#cityID1').text = val.city;*/
$('#cityID' + val.cityId).find('span').attr('id', 'cityspan' + val.cityId);
document.getElementById('cityspan' + String(val.cityId)).innerHTML = val.amount;
});
//for (var i = 0; i < rel.data.length; i++)
//{
// $('#city').append(h[i]);
// //$('#city').append("<button type='button' class='btn btn-outline-success waves-effect waves-themed ' style='margin - right: 40px;' >" +
// // rel.data[i].city +
// // "<span class= 'badge bg-success-700 ml-2' >" + rel.data[i].amount + "</span >" +
// // "</button >");
//}
})
})
function ChangeType(Num) {
type = Num;
OperationPlanTable.ajax.reload();
if (Num == 9)
{
document.getElementById("button9").setAttribute("class", "btn btn-success waves-effect waves-themed");
document.getElementById("button1").setAttribute("class", "btn btn-secondary waves-effect waves-themed");
document.getElementById("button0").setAttribute("class", "btn btn-secondary waves-effect waves-themed");
}
else if (Num == 1)
{
document.getElementById("button1").setAttribute("class", "btn btn-success waves-effect waves-themed");
document.getElementById("button9").setAttribute("class", "btn btn-secondary waves-effect waves-themed");
document.getElementById("button0").setAttribute("class", "btn btn-secondary waves-effect waves-themed");
}
else if(Num == 0)
{
document.getElementById("button0").setAttribute("class", "btn btn-success waves-effect waves-themed");
document.getElementById("button1").setAttribute("class", "btn btn-secondary waves-effect waves-themed");
document.getElementById("button9").setAttribute("class", "btn btn-secondary waves-effect waves-themed");
}
}
//#region 新增計畫基本資料
function AddOperationPlan() {
@ -453,5 +543,43 @@
});
//#endregion
function saveToExcel() {
var url = "/Operation/OperationPlanTable";
var send_data = {
id: [1, 2]
};
$.post(url, send_data, function (rel) {
if (rel.data.code != "0000") {
toast_error(rel.msg);
return;
}
for (var i = 0; i < rel.data.data.length; i++)
{
$('#NoViewbody').append("<tr>");
$('#NoViewbody').append("<td>" + rel.data.data[i].planId + "</td>");
$('#NoViewbody').append("<td>" + rel.data.data[i].typeName + "</td>");
$('#NoViewbody').append("<td>" + rel.data.data[i].powerStationName + "</td>");
$('#NoViewbody').append("<td>" + rel.data.data[i].schedule + "</td>");
$('#NoViewbody').append("<td>" + rel.data.data[i].workDay + "</td>");
$('#NoViewbody').append("<td>" + rel.data.data[i].startTimeString + "</td>");
$('#NoViewbody').append("<td>" + rel.data.data[i].emailTypeName + "</td>");
$('#NoViewbody').append("<td>" + rel.data.data[i].createdPerson + "</td>");
$('#NoViewbody').append("<td>" + rel.data.data[i].createTimeString + "</td>");
$('#NoViewbody').append("</tr>");
}
}, 'json');
$("#NoView").table2excel({
// 匯出的Excel文件的名稱
name: "Excel Document Name",
// Excel檔案的名稱
filename: "test",
//檔案字尾名
fileext: ".xls",
});
}
</script>
}

View File

@ -1541,7 +1541,8 @@
var url = "/PowerStation/GetOneDevice/";
var send_data = {
id: selected_id
SelectedId: selected_id,
PowerStationId: stationId,
}
@ -1581,7 +1582,8 @@
if (result.value) {
var url = "/PowerStation/DeleteOneDevice/";
var send_data = {
Id: selected_id
SelectedId: selected_id,
PowerStationId: stationId
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
@ -1645,7 +1647,8 @@
var url = "/PowerStation/GetOneException/";
var send_data = {
id: selected_id
SelectedId: selected_id,
PowerStationId: stationId,
}
@ -1683,7 +1686,8 @@
if (result.value) {
var url = "/PowerStation/DeleteOneException/";
var send_data = {
Id: selected_id
SelectedId: selected_id,
PowerStationId: stationId,
}
$.post(url, send_data, function (rel) {
if (rel.code == "9999") {

View File

@ -1,5 +1,5 @@
@{
ViewData["MainNum"] = "6";
ViewData["MainNum"] = "7";
ViewData["SubNum"] = "3";
ViewData["Title"] = "帳號管理";
}