合併衝突

This commit is contained in:
Kai 2021-06-22 09:54:10 +08:00
commit d2e1549c3b
16 changed files with 734 additions and 148 deletions

View File

@ -30,6 +30,7 @@ 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>();

View File

@ -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<OperationController>
{
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<ActionResult> GetPowerStationSelectOption(int post)
{
ApiResult<List<PowerStationIdList>> apiResult = new ApiResult<List<PowerStationIdList>>();
try
{
var PowerStationIdLists = new List<PowerStationIdList>();
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;
}
}
}

View File

@ -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; }
}
}

View File

@ -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<Operation>, IOperationRepository
{
public OperationRepository(IDatabaseHelper databaseHelper) : base(databaseHelper)
{
tableName = "operation_plan_create";
}
public async Task<List<PowerStationIdList>> GetPowerStationIdList(int UserId)
{
List<PowerStationIdList> 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<PowerStationIdList>(sql, new { userid = UserId })).ToList();
}
catch (Exception exception)
{
throw exception;
}
return result;
}
}
}
}

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SolarPower.Repository.Interface
{
interface IOperation
{
}
}

View File

@ -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<List<PowerStationIdList>> GetPowerStationIdList(int UserId);
}
}

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SolarPower.Repository.Interface
{
interface Interface
{
}
}

View File

@ -7,6 +7,22 @@
<UserSecretsId>9c9a93c3-c4f5-4cc2-92ea-0ae0a51be5d3</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Views\NewFolder\**" />
<Content Remove="Views\NewFolder\**" />
<EmbeddedResource Remove="Views\NewFolder\**" />
<None Remove="Views\NewFolder\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Repository\Interface\Interface.cs" />
<Compile Remove="Repository\Interface\IOperation.cs" />
</ItemGroup>
<ItemGroup>
<Content Remove="Views\Operation\_OperationPlanCreate.cshtml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.78" />
<PackageReference Include="MySql.Data" Version="8.0.24" />

View File

@ -66,6 +66,7 @@ namespace SolarPower
services.AddScoped<IRoleRepository, RoleRepository>();
services.AddScoped<IPowerStationRepository, PowerStationRepository>();
services.AddScoped<IOperatorLogRepository, OperatorLogRepository>();
services.AddScoped<IOperationRepository, OperationRepository>();
#endregion
double loginExpireMinute = this.Configuration.GetValue<double>("LoginExpireMinute");

View File

@ -509,14 +509,22 @@
$('#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);
@ -530,7 +538,8 @@
toast_ok(rel.msg);
companyTable.ajax.reload();
}, 'json');
}
});
});
//#endregion

View File

@ -0,0 +1,313 @@
@{
ViewData["MainNum"] = "5";
ViewData["SubNum"] = "1";
ViewData["Title"] = "運維管理";
}
@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>
<li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
</ol>
<div class="subheader">
<h1 class="subheader-title">
<i class='subheader-icon fal fa-globe'></i> 定期計畫建立
</h1>
</div>
<!-- Your main content goes below here: -->
<div class="row">
<div class="col-xl-12">
<div id="panel-5" class="panel">
<div class="panel-container show">
<div class="panel-content">
<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>
</div>
</div>
</div>
<div class="row mb-3 d-flex align-items-center px-3">
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed">全部縣市</button>
</div>
<div class="pr-3">
<div class="frame-wrap">
<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">
台北市
<span class="badge bg-success-700 ml-2">4</span>
</button>
<button type="button" class="btn btn-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">
苗栗縣
<span class="badge bg-success-700 ml-2">4</span>
</button>
<button type="button" class="btn btn-outline-success waves-effect waves-themed">
台中市
<span class="badge bg-success-700 ml-2">4</span>
</button>
</div>
</div>
</div>
<div class="row mb-5 d-flex align-items-center px-3">
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed">全選</button>
</div>
<div class="pr-3">
<div class="frame-wrap">
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="defaultInline6">
<label class="custom-control-label" for="defaultInline6">新竹交大站</label>
</div>
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="defaultInline7" checked="">
<label class="custom-control-label" for="defaultInline7">新竹巨城站</label>
</div>
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="defaultInline8" checked="">
<label class="custom-control-label" for="defaultInline8">新竹動物園站</label>
</div>
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="defaultInline9" checked="">
<label class="custom-control-label" for="defaultInline9">新竹城隍廟站</label>
</div>
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="defaultInline10" checked="">
<label class="custom-control-label" for="defaultInline10">新竹清大站</label>
</div>
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="defaultInline11" checked="">
<label class="custom-control-label" for="defaultInline11">新竹高鐵站</label>
</div>
</div>
</div>
</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">
<span class="fal fa-file-excel mr-1"></span>
匯出
</button>
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3 mr-2" data-toggle="modal" data-target="#companyrule">
<span class="fal fa-plus mr-1"></span>
計劃
</a>
</div>
<div class="frame-wrap">
<table class="table table-bordered table-hover m-0 text-center">
<thead class="thead-themed">
<tr>
<th>計劃單號</th>
<th>項目</th>
<th>電站</th>
<th>排程</th>
<th>開始時間</th>
<th>填寫表單</th>
<th>描述</th>
<th>email 通知</th>
<th>建立人</th>
<th>建立時間</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">20210630003</th>
<td>巡檢</td>
<td>新竹交大站</td>
<td>每次5天內 / 1周</td>
<td>王小明</td>
<td>巡檢單01</td>
<td></td>
<td>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="defaultChecked" checked="">
<label class="custom-control-label" for="defaultChecked">當天</label>
</div>
</td>
<td>鋼鐵人</td>
<td>2021-03-5</td>
</tr>
<tr>
<th scope="row">20210630003</th>
<td>清洗</td>
<td>新竹交大站</td>
<td>每次5天內 / 5周</td>
<td>鋼鐵人</td>
<td>清洗單02</td>
<td></td>
<td>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="defaultChecked" checked="">
<label class="custom-control-label" for="defaultChecked">前一天</label>
</div>
</td>
<td>浩克</td>
<td>2021-03-5</td>
</tr>
<tr>
<th scope="row">20210630003</th>
<td>清洗</td>
<td>新竹交大站</td>
<td>每次5天內 / 5周</td>
<td>鋼鐵人</td>
<td>清洗單02</td>
<td></td>
<td>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="defaultChecked" checked="">
<label class="custom-control-label" for="defaultChecked">前一天</label>
</div>
</td>
<td>浩克</td>
<td>2021-03-5</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="Operation-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
新增/修改 定期計劃
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<div class="row mb-3">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="operation_powerStationselect_modal">電站名</label>
<select class="form-control" id="operation_powerStationselect_modal">
</select>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="operation_type_modal">項目</label>
<select class="form-control" id="operation_type_modal">
<option value="0">清洗</option>
<option value="1">巡檢</option>
</select>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-lg-6">
<div class="form-group">
<div class="row d-flex justify-content-start align-items-center">
<div class="col-4">自動排程 每</div>
<div class="col">
<input type="text" id="operation_scheduleNum_modal" class="form-control">
</div>
<div class="col">
<select class="form-control" id="operation_scheduleType_modal" width="70" style="width: 70px">
<option value="0">天</option>
<option value="1">週</option>
<option value="2">月</option>
<option value="3">季</option>
<option value="4">年</option>
</select>
</div>
<div class="col">安排一次</div>
</div>
</div>
<div class="form-group">
<div class="row d-flex justify-content-start align-items-center">
<div class="col-3">每次預期</div>
<div class="col">
<input type="text" id="operation_workDay_modal" class="form-control">
</div>
<div class="col">天內完成</div>
</div>
</div>
<div class="form-group">
<div class="row d-flex justify-content-start align-items-center">
<div class="col-3">開始時間</div>
<div class="col">
<input type="text" id="operation_startTime_modal" class="form-control" placeholder="2000-01-01">
</div>
<div class="col">~<font id="operation_endTime_modal">2021-06-30</font></div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="operation_description_modal">描述</label>
<textarea class="form-control" id="operation_description_modal" rows="5"></textarea>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="operation_emailType_modal">email提醒</label>
<select class="form-control" id="operation_emailType_modal">
<option value="0">當天</option>
<option value="1">前1天</option>
<option value="2">前2天</option>
<option value="3">前3天</option>
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary">確定</button>
</div>
</div>
</div>
</div>
@section Scripts{
<script>
$(function () {
//#region 電站下拉式選單select_option
var url_operation_select_option = "/Operation/GetPowerStationSelectOption";
$.get(url_operation_select_option, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$("#company_select").empty();
$("#company_select").append($("<option />").val(0).text("全部"));
$.each(rel.data, function (index, val) {
$("#company_select").append($("<option />").val(val.value).text(val.text));
});
//預設查詢第一個
$("#company_select").val($("#company_select option:first").val()).trigger('change');
});
//#endregion
})
</script>
}

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
</head>
<body>
<div>
@RenderBody()
</div>
</body>
</html>

View File

@ -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");
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');
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 == "9999") {
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');
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 == "9999") {
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');
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
});
});
</script>
}

View File

@ -12,8 +12,8 @@
<th>電站編號</th>
<th>電站名稱</th>
<th>項目</th>
<th>限 ( <= )</th>
<th>限 ( >= )</th>
<th>限 ( <= )</th>
<th>限 ( >= )</th>
<th>警示方式</th>
<th>建立時間</th>
<th>功能</th>

View File

@ -179,15 +179,15 @@
</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>
</a>
<ul>
<li class="">
<a href="javascript:void(0);" title="定期計劃建立" data-filter-tags="utilities disabled item">
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">定期計建立</span>
<li class="@(ViewData["MainNum"] == "5" && 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>
</li>
<li class="">

View File

@ -712,16 +712,23 @@
//#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);
@ -735,7 +742,8 @@
userTable.ajax.reload();
}, 'json');
}
});
});
//#endregion
@ -863,7 +871,17 @@
$('#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/";
@ -880,7 +898,8 @@
toast_ok(rel.msg);
roleTable.ajax.reload();
}, 'json');
}
});
});
//#endregion
@ -941,7 +960,18 @@
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/";
@ -959,6 +989,8 @@
toast_ok(rel.msg);
roleAuthTable.ajax.reload();
}, 'json');
}
});
});
//#endregion