diff --git a/SolarPower/Controllers/MyBaseController.cs b/SolarPower/Controllers/MyBaseController.cs index b5719d2..3877051 100644 --- a/SolarPower/Controllers/MyBaseController.cs +++ b/SolarPower/Controllers/MyBaseController.cs @@ -30,6 +30,7 @@ namespace SolarPower.Controllers protected ILogger Logger => _logger ?? (_logger = HttpContext?.RequestServices.GetService>()); private IUserRepository userRepository => HttpContext?.RequestServices.GetService(); + private IOperationRepository operationRepository => HttpContext?.RequestServices.GetService(); private ICompanyRepository companyRepository => HttpContext?.RequestServices.GetService(); private IRoleRepository roleRepository => HttpContext?.RequestServices.GetService(); private IOperatorLogRepository operatorLogRepository => HttpContext?.RequestServices.GetService(); diff --git a/SolarPower/Controllers/OperationController.cs b/SolarPower/Controllers/OperationController.cs new file mode 100644 index 0000000..076db2f --- /dev/null +++ b/SolarPower/Controllers/OperationController.cs @@ -0,0 +1,57 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using SolarPower.Models; +using SolarPower.Models.Role; +using SolarPower.Repository.Interface; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; + +namespace SolarPower.Controllers +{ + public class OperationController : MyBaseController + { + private readonly IUserRepository userRepository; + private readonly IOperationRepository operationRepository; + private readonly IRoleRepository roleRepository; + public OperationController( + IUserRepository userRepository, + IOperationRepository operationRepository) : base() + { + this.userRepository = userRepository; + this.operationRepository = operationRepository; + } + public IActionResult Index() + { + return View(); + } + + public async Task GetPowerStationSelectOption(int post) + { + ApiResult> apiResult = new ApiResult>(); + try + { + var PowerStationIdLists = new List(); + PowerStationIdLists = await operationRepository.GetPowerStationIdList(post) ; + apiResult.Code = "0000"; + apiResult.Data = PowerStationIdLists; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + apiResult.Msg = errorCode.GetString(apiResult.Code); + + var result = Json(new + { + data = apiResult + }); + + return result; + } + } +} diff --git a/SolarPower/Models/Operation.cs b/SolarPower/Models/Operation.cs new file mode 100644 index 0000000..2da6e2c --- /dev/null +++ b/SolarPower/Models/Operation.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SolarPower.Models +{ + public class Operation:Created + { + public int Id { get; set; }//流水號 + public byte Delete { get; set; }//刪除 + public string PlanId { get; set; }//計畫單號 + public int PowerStationId { get; set; }//電站編號 + public string SerialNumber { get; set; }//計畫單號用流水號 + public int ScheduleNum { get; set; }//排程數字 + public byte ScheduleType { get; set; }//排程屬性,0:天 1:周 2:月 3:季 4:年 + public int WorkDay { get; set; }//預期工作天數 + public DateTime StartTime { get; set; }//開始時間 + public byte Type { get; set; }//項目, 0:清洗 1:巡檢 + public byte EmailType { get; set; }//email提醒種類,0:當天 1:前一天 2:前兩天 3:前三天 + public string Description { get; set; }//描述 + + } + public class PowerStationIdList + { + public string Text { get; set; } + public string Value { get; set; } + } +} diff --git a/SolarPower/Repository/Implement/OperationRepository.cs b/SolarPower/Repository/Implement/OperationRepository.cs new file mode 100644 index 0000000..dec8901 --- /dev/null +++ b/SolarPower/Repository/Implement/OperationRepository.cs @@ -0,0 +1,39 @@ +using Dapper; +using SolarPower.Helper; +using SolarPower.Models; +using SolarPower.Repository.Interface; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Threading.Tasks; + +namespace SolarPower.Repository.Implement +{ + public class OperationRepository : RepositoryBase, IOperationRepository + { + public OperationRepository(IDatabaseHelper databaseHelper) : base(databaseHelper) + { + tableName = "operation_plan_create"; + } + public async Task> GetPowerStationIdList(int UserId) + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = @$"SELECT tn.Id AS Value, tn.Name AS Text FROM {tableName} tn LEFT JOIN power_station_operation_personnel pp + ON tn.Id=pp.PowerStationId + WHERE pp.UserId = @userid"; + result = (await conn.QueryAsync(sql, new { userid = UserId })).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + } +} diff --git a/SolarPower/Repository/Interface/IOperation.cs b/SolarPower/Repository/Interface/IOperation.cs new file mode 100644 index 0000000..2a91553 --- /dev/null +++ b/SolarPower/Repository/Interface/IOperation.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SolarPower.Repository.Interface +{ + interface IOperation + { + } +} diff --git a/SolarPower/Repository/Interface/IOperationRepository.cs b/SolarPower/Repository/Interface/IOperationRepository.cs new file mode 100644 index 0000000..8b245ac --- /dev/null +++ b/SolarPower/Repository/Interface/IOperationRepository.cs @@ -0,0 +1,13 @@ +using SolarPower.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SolarPower.Repository.Interface +{ + public interface IOperationRepository + { + Task> GetPowerStationIdList(int UserId); + } +} diff --git a/SolarPower/Repository/Interface/Interface.cs b/SolarPower/Repository/Interface/Interface.cs new file mode 100644 index 0000000..7e71503 --- /dev/null +++ b/SolarPower/Repository/Interface/Interface.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SolarPower.Repository.Interface +{ + interface Interface + { + } +} diff --git a/SolarPower/SolarPower.csproj b/SolarPower/SolarPower.csproj index 268efd8..05c1a89 100644 --- a/SolarPower/SolarPower.csproj +++ b/SolarPower/SolarPower.csproj @@ -7,6 +7,22 @@ 9c9a93c3-c4f5-4cc2-92ea-0ae0a51be5d3 + + + + + + + + + + + + + + + + diff --git a/SolarPower/Startup.cs b/SolarPower/Startup.cs index eaec18b..6c549c1 100644 --- a/SolarPower/Startup.cs +++ b/SolarPower/Startup.cs @@ -66,6 +66,7 @@ namespace SolarPower services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); #endregion double loginExpireMinute = this.Configuration.GetValue("LoginExpireMinute"); diff --git a/SolarPower/Views/Company/Index.cshtml b/SolarPower/Views/Company/Index.cshtml index a97f286..1744094 100644 --- a/SolarPower/Views/Company/Index.cshtml +++ b/SolarPower/Views/Company/Index.cshtml @@ -509,28 +509,37 @@ $('#company_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 = "/Company/DeleteOneCompany/"; + var send_data = { + Id: selected_id + } + $.post(url, send_data, function (rel) { + if (rel.code == "9999") { + toast_error(rel.msg); + return; + } + else if (rel.code == "9998") { + toast_error(rel.msg); + return; + } - //取得單一系統管理員 - var url = "/Company/DeleteOneCompany/"; - - var send_data = { - Id: selected_id - } - - $.post(url, send_data, function (rel) { - if (rel.code == "9999") { - toast_error(rel.msg); - return; - } - else if (rel.code == "9998") { - toast_error(rel.msg); - return; - } - - toast_ok(rel.msg); - companyTable.ajax.reload(); - }, 'json'); - + toast_ok(rel.msg); + companyTable.ajax.reload(); + }, 'json'); + } + }); }); //#endregion diff --git a/SolarPower/Views/Operation/Index.cshtml b/SolarPower/Views/Operation/Index.cshtml new file mode 100644 index 0000000..05e4898 --- /dev/null +++ b/SolarPower/Views/Operation/Index.cshtml @@ -0,0 +1,313 @@ +@{ + ViewData["MainNum"] = "5"; + ViewData["SubNum"] = "1"; + ViewData["Title"] = "運維管理"; +} +@using SolarPower.Models.Role +@model RoleLayerEnum + + + +
+

+ 定期計畫建立 +

+
+ +
+
+
+
+
+ +
+
+
+ + + +
+
+
+ +
+
+ +
+
+
+ + + + + +
+
+
+ +
+
+ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+ + + + 計劃 + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
計劃單號項目電站排程開始時間填寫表單描述email 通知建立人建立時間
20210630003巡檢新竹交大站每次5天內 / 1周王小明巡檢單01 +
+ + +
+
鋼鐵人2021-03-5
20210630003清洗新竹交大站每次5天內 / 5周鋼鐵人清洗單02 +
+ + +
+
浩克2021-03-5
20210630003清洗新竹交大站每次5天內 / 5周鋼鐵人清洗單02 +
+ + +
+
浩克2021-03-5
+
+
+
+
+
+
+ + + + +@section Scripts{ + +} \ No newline at end of file diff --git a/SolarPower/Views/Operation/_OperationPlanCreate.cshtml b/SolarPower/Views/Operation/_OperationPlanCreate.cshtml new file mode 100644 index 0000000..3c25d93 --- /dev/null +++ b/SolarPower/Views/Operation/_OperationPlanCreate.cshtml @@ -0,0 +1,13 @@ + + + + + + @ViewBag.Title + + +
+ @RenderBody() +
+ + diff --git a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml index b3f0ff4..85ee73c 100644 --- a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml +++ b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml @@ -92,9 +92,8 @@ var isLandBuildingLock = false; var selected_id = 0; var countPowerStationImage = 0; var countPowerStationSingleLine = 0; - + var upper = 0; $(function () { - var url = new URL(location.href); stationId = url.searchParams.get('stationId'); //#region 運維列表 DataTable @@ -344,6 +343,7 @@ return data; } } + }); //#endregion @@ -1327,23 +1327,32 @@ //刪除 $('#land_buildingPart').on("click", "button.del-land-building-info-btn", function () { selectedLandBuildingId = $(this).attr("data-land-building-id"); - - var url = "/PowerStation/DeleteLandBuildingInfo"; - - var send_data = { - Id: selectedLandBuildingId - } - - $.post(url, send_data, function (rel) { - if (rel.code != "0000") { - toast_error(rel.msg); - return; - } - - toast_ok(rel.msg); - powerStationData = rel.data; - SetLandBuildingInfo(); - }, 'json'); + Swal.fire( + { + title: "刪除", + text: "你確定是否刪除此筆資料?", + type: "warning", + icon: 'warning', + showCancelButton: true, + confirmButtonText: "是", + cancelButtonText: "否" + }).then(function (result) { + if (result.value) { + var url = "/PowerStation/DeleteLandBuildingInfo"; + var send_data = { + Id: selectedLandBuildingId + } + $.post(url, send_data, function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } + toast_ok(rel.msg); + powerStationData = rel.data; + SetLandBuildingInfo(); + }, 'json'); + } + }); }); //新增土地房屋卡片 @@ -1443,25 +1452,32 @@ //#region 刪除運維資料 $('#Operation_table').on("click", "button.del-btn", function () { - selected_id = $(this).parents('tr').attr('data-id'); - - var url = "/PowerStation/DeleteOneOperation/"; - - var send_data = { - Id: selected_id - } - - $.post(url, send_data, function (rel) { - if (rel.code == "9999") { - toast_error(rel.msg); - return; - } - - toast_ok(rel.msg); - OperationTable.ajax.reload(); - }, 'json'); - + Swal.fire( + { + title: "刪除", + text: "你確定是否刪除此筆資料?", + type: "warning", + icon: 'warning', + showCancelButton: true, + confirmButtonText: "是", + cancelButtonText: "否" + }).then(function (result) { + if (result.value) { + var url = "/PowerStation/DeleteOneOperation/"; + var send_data = { + Id: selected_id + } + $.post(url, send_data, function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } + toast_ok(rel.msg); + OperationTable.ajax.reload(); + }, 'json'); + } + }); }); //#endregion @@ -1547,25 +1563,32 @@ //#region 刪除裝置 $('#Device_table').on("click", "button.del-btn", function () { - selected_id = $(this).parents('tr').attr('data-id'); - - var url = "/PowerStation/DeleteOneDevice/"; - - var send_data = { - Id: selected_id - } - - $.post(url, send_data, function (rel) { - if (rel.code == "9999") { - toast_error(rel.msg); - return; - } - - toast_ok(rel.msg); - DeviceTable.ajax.reload(); - }, 'json'); - + Swal.fire( + { + title: "刪除", + text: "你確定是否刪除此筆資料?", + type: "warning", + icon: 'warning', + showCancelButton: true, + confirmButtonText: "是", + cancelButtonText: "否" + }).then(function (result) { + if (result.value) { + var url = "/PowerStation/DeleteOneDevice/"; + var send_data = { + Id: selected_id + } + $.post(url, send_data, function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } + toast_ok(rel.msg); + DeviceTable.ajax.reload(); + }, 'json'); + } + }); }); //#endregion @@ -1641,24 +1664,33 @@ //#region 刪除異常 $('#Exception_table').on("click", "button.del-btn", function () { - selected_id = $(this).parents('tr').attr('data-id'); - var url = "/PowerStation/DeleteOneException/"; - - var send_data = { - Id: selected_id - } - - $.post(url, send_data, function (rel) { - if (rel.code == "9999") { - toast_error(rel.msg); - return; - } - - toast_ok(rel.msg); - ExceptionTable.ajax.reload(); - }, 'json'); + Swal.fire( + { + title: "刪除", + text: "你確定是否刪除此筆資料?", + type: "warning", + icon: 'warning', + showCancelButton: true, + confirmButtonText: "是", + cancelButtonText: "否" + }).then(function (result) { + if (result.value) { + var url = "/PowerStation/DeleteOneException/"; + var send_data = { + Id: selected_id + } + $.post(url, send_data, function (rel) { + if (rel.code == "9999") { + toast_error(rel.msg); + return; + } + toast_ok(rel.msg); + ExceptionTable.ajax.reload(); + }, 'json'); + } + }); }); //#endregion @@ -1913,5 +1945,14 @@ //#endregion //#endregion + $('#Exception_UpperLimit_modal').change(function () { + upper = $('#Exception_UpperLimit_modal').val(); + $("#Exception_LowerLimit_modal").rules("remove"); + $("#Exception_LowerLimit_modal").rules("add", { + required: true, + max: Number(upper), + min: 0 + }); + }); } \ No newline at end of file diff --git a/SolarPower/Views/PowerStation/_Exception.cshtml b/SolarPower/Views/PowerStation/_Exception.cshtml index 0709db5..e533220 100644 --- a/SolarPower/Views/PowerStation/_Exception.cshtml +++ b/SolarPower/Views/PowerStation/_Exception.cshtml @@ -12,8 +12,8 @@ 電站編號 電站名稱 項目 - 下限 ( <= ) - 上限 ( >= ) + 上限 ( <= ) + 下限 ( >= ) 警示方式 建立時間 功能 diff --git a/SolarPower/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index 913be82..cfa00ed 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -179,15 +179,15 @@ -
  • +
  • 運維管理
      -
    • - - 定期計劃建立 +
    • + + 定期計畫建立
    • diff --git a/SolarPower/Views/User/Index.cshtml b/SolarPower/Views/User/Index.cshtml index 5de7e2a..9607d02 100644 --- a/SolarPower/Views/User/Index.cshtml +++ b/SolarPower/Views/User/Index.cshtml @@ -712,30 +712,38 @@ //#region 刪除使用者 $('#user_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 = "/User/DeleteOneUser/"; + var send_data = { + Id: selected_id + } + $.post(url, send_data, function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } - //取得單一系統管理員 - var url = "/User/DeleteOneUser/"; + toast_ok(rel.msg); - var send_data = { - Id: selected_id - } - - $.post(url, send_data, function (rel) { - if (rel.code != "0000") { - toast_error(rel.msg); - return; - } - - toast_ok(rel.msg); - - //更新當前剩餘可註冊使用者人數 - UpdateRegisterNumber($("#select_user_company_userManager_tab").val()); - - userTable.ajax.reload(); - }, 'json'); + //更新當前剩餘可註冊使用者人數 + UpdateRegisterNumber($("#select_user_company_userManager_tab").val()); + userTable.ajax.reload(); + }, 'json'); + } + }); }); //#endregion @@ -863,24 +871,35 @@ $('#role_table').on("click", "button.del-btn", function () { selected_role_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 = "/Role/DeleteOneRole/"; - //取得單一系統管理員 - var url = "/Role/DeleteOneRole/"; + var send_data = { + Id: selected_role_id + } - var send_data = { - Id: selected_role_id - } - - $.post(url, send_data, function (rel) { - if (rel.code != "0000") { - toast_error(rel.msg); - return; - } - - toast_ok(rel.msg); - roleTable.ajax.reload(); - }, 'json'); + $.post(url, send_data, function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } + toast_ok(rel.msg); + roleTable.ajax.reload(); + }, 'json'); + } + }); }); //#endregion @@ -941,24 +960,37 @@ var row_id_authCode = $(this).parents('tr').attr('data-id-authCode'); var split_arr = row_id_authCode.split("_"); + Swal.fire( + { + title: "刪除", + text: "你確定是否刪除此筆資料?", + type: "warning", + icon: 'warning', + showCancelButton: true, + confirmButtonText: "是", + cancelButtonText: "否" + }).then(function (result) + { + if (result.value) { + //取得單一系統管理員 + var url = "/Role/DeleteOneRoleAuth/"; - //取得單一系統管理員 - var url = "/Role/DeleteOneRoleAuth/"; + var send_data = { + RoleId: split_arr[0], + AuthCode: split_arr[1] + } - var send_data = { - RoleId: split_arr[0], - AuthCode: split_arr[1] - } + $.post(url, send_data, function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } - $.post(url, send_data, function (rel) { - if (rel.code != "0000") { - toast_error(rel.msg); - return; - } - - toast_ok(rel.msg); - roleAuthTable.ajax.reload(); - }, 'json'); + toast_ok(rel.msg); + roleAuthTable.ajax.reload(); + }, 'json'); + } + }); }); //#endregion