From 566d52dd7c2375f6be99dffdc20f28be32ee9b4d Mon Sep 17 00:00:00 2001 From: Kai Date: Thu, 24 Jun 2021 10:39:34 +0800 Subject: [PATCH] =?UTF-8?q?1.=E9=81=8B=E7=B6=AD=E4=BD=9C=E6=A5=AD=E8=A8=98?= =?UTF-8?q?=E9=8C=84=20part1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/OperationController.cs | 330 +++++++++- .../Controllers/PowerStationController.cs | 21 + SolarPower/Models/ErrorCode.cs | 1 + SolarPower/Models/Operation.cs | 206 ++++-- SolarPower/Models/PowerStation.cs | 6 + .../Implement/OperationRepository.cs | 165 ++++- .../Implement/PowerStationRepository.cs | 25 +- .../Repository/Implement/RepositoryBase.cs | 9 +- .../Interface/IOperationRepository.cs | 31 + .../Interface/IPowerStationRepository.cs | 4 + .../Repository/Interface/IRepositoryBase.cs | 2 +- .../Views/Operation/OperationRecord.cshtml | 604 +++++++++--------- .../Views/PowerStation/_UploadImage.cshtml | 120 +--- SolarPower/wwwroot/css/site.css | 5 +- 14 files changed, 1033 insertions(+), 496 deletions(-) diff --git a/SolarPower/Controllers/OperationController.cs b/SolarPower/Controllers/OperationController.cs index d63e536..852db4e 100644 --- a/SolarPower/Controllers/OperationController.cs +++ b/SolarPower/Controllers/OperationController.cs @@ -14,10 +14,16 @@ namespace SolarPower.Controllers public class OperationController : MyBaseController { private readonly IOperationRepository operationRepository; + private string operationRecodeFilePath = "/upload/operation_recode/"; + private string operationRecodeSaveAsPath = ""; + + public OperationController( IOperationRepository operationRepository) : base() { this.operationRepository = operationRepository; + + operationRecodeSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "operation_recode"); } public IActionResult Index() @@ -35,13 +41,13 @@ namespace SolarPower.Controllers /// /// /// - public async Task GetPowerStationSelectOption(int post) + public async Task>> GetPowerStationSelectOption() { ApiResult> apiResult = new ApiResult>(); try { var PowerStationIdLists = new List(); - PowerStationIdLists = await operationRepository.GetPowerStationIdList(myUser.Id) ; + PowerStationIdLists = await operationRepository.GetPowerStationIdList(myUser.Id); apiResult.Code = "0000"; apiResult.Data = PowerStationIdLists; } @@ -52,13 +58,7 @@ namespace SolarPower.Controllers } apiResult.Msg = errorCode.GetString(apiResult.Code); - - var result = Json(new - { - data = apiResult - }); - - return result; + return apiResult; } /// @@ -189,7 +189,7 @@ namespace SolarPower.Controllers OperationPlanTable = await operationRepository.OperationPlanTable(id); foreach (OperationPlanTable a in OperationPlanTable) { - if(a.Type == 0) + if (a.Type == 0) { a.TypeName = "清洗"; } @@ -198,9 +198,9 @@ namespace SolarPower.Controllers a.TypeName = "巡檢"; } - if(a.ScheduleType == 0) + if (a.ScheduleType == 0) { - a.Schedule = "每" + a.ScheduleNum.ToString() + "天" ; + a.Schedule = "每" + a.ScheduleNum.ToString() + "天"; } else if (a.ScheduleType == 1) { @@ -223,11 +223,11 @@ namespace SolarPower.Controllers var crst = a.CreatedAt.Split(" "); a.CreateTimeString = crst[0]; - if(a.EmailType == 0) + if (a.EmailType == 0) { a.EmailTypeName = "當天"; } - else if(a.EmailType == 1) + else if (a.EmailType == 1) { a.EmailTypeName = "前一天"; } @@ -341,6 +341,20 @@ namespace SolarPower.Controllers recodes = await operationRepository.GetAllRecodeByFilterAsync(post); + foreach (var recode in recodes) + { + if (string.IsNullOrEmpty(recode.FormId)) + { + recode.FormId = @$"填寫表單"; + } + else + { + recode.FormId = @$"{recode.FormId}"; + } + + //TODO 替換圖片檔案 + } + totalRecords = recodes.Count(); recFilter = recodes.Count(); @@ -365,5 +379,293 @@ namespace SolarPower.Controllers return result; } + + /// + /// 取得單一運維作業記錄列表 + /// + /// + /// + [HttpPost] + public async Task> GetOneOperationRecode(int id) + { + ApiResult apiResult = new ApiResult(); + + OperationRecode operationRecode; + + try + { + + //if (!IsPlatformLayer(myUser.Role.Layer)) + //{ //如果只是身分公司管理員 或 公司使用者,就只能看自己公司的資料 + // post.SelectedCompanyId = myUser.CompanyId; + //} + + operationRecode = await operationRepository.GetOneOperationRecodeAsync(id); + + if (operationRecode == null) + { + apiResult.Code = "9989"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + foreach (var recodeFile in operationRecode.RecodeFiles) + { + recodeFile.FileName = Path.Combine(operationRecodeFilePath, operationRecode.Id.ToString()) + "/" + recodeFile.FileName; + } + + apiResult.Code = "0000"; + apiResult.Data = operationRecode; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + + public async Task> SaveOperationRecode([FromForm] PostOperationRecode post) + { + ApiResult apiResult = new ApiResult(); + + OperationRecode operationRecode = null; + + try + { + operationRecode = await operationRepository.GetOneOperationRecodeAsync(post.Id); + + //取得運維作業記錄最後流水號 + var currentSerialNumber = await operationRepository.GetCurrentSerialNumber("operation_record"); + + if (operationRecode == null) + { + if (post.Id != 0) + { + apiResult.Code = "9989"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + #region 新增運維作業記錄 - 維修單 + + var tempSerialNumber = GetLastSerialNumber(currentSerialNumber); + + var finishTime = string.Empty; + if (post.Status == (int)OperationRecodeStatusEnum.Complete) + { + finishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + + operationRecode = new OperationRecode() + { + FormId = "op" + DateTime.Now.ToString("yyyyMMdd") + tempSerialNumber, + SerialNumber = tempSerialNumber, + PowerStationId = post.PowerStationId, + WorkType = post.WorkType, + ErrorCode = post.ErrorCode, + FixDo = post.FixDo, + Status = post.Status, + WorkPersonId = post.WorkPersonId, + FinishTime = finishTime, + WorkTime = post.WorkTime, + Notice = post.Notice, + Description = post.Description, + CreatedBy = myUser.Id + }; + + List properties = new List() + { + "FormId", + "SerialNumber", + "PowerStationId", + "WorkType", + "ErrorCode", + "FixDo", + "Status", + "WorkPersonId", + "FinishTime", + "WorkTime", + "Notice", + "Description", + "CreatedBy" + }; + + var id = await operationRepository.AddOneOperationRecodeAsync(operationRecode, properties); + + apiResult.Code = "0000"; + apiResult.Msg = "儲存成功"; + #endregion + } + else + { + + #region 修改運維作業記錄 + + var finishTime = string.Empty; + if (post.Status == (int)OperationRecodeStatusEnum.Complete) + { + finishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + + if (operationRecode.WorkType != (int)OperationRecodeWorkTypeEnum.Fix) + { //針對清洗、巡檢 + var now = DateTime.Now; + + var startTime = DateTime.Parse(post.StartTime + " 00:00:00"); + var endTime = DateTime.Parse(post.EndTime + " 23:59:59"); + + if (now > endTime) + { + if (post.Status == (int)OperationRecodeStatusEnum.NoneComplete) + { //超過時間修改成 未完成-過期 + post.Status = (int)OperationRecodeStatusEnum.NoneCompleteExpired; + } + else if (post.Status == (int)OperationRecodeStatusEnum.Complete) + { //超過時間修改成 完成-過期 + post.Status = (int)OperationRecodeStatusEnum.CompleteExpired; + } + } + } + + UpdateOperationRecode update = new UpdateOperationRecode() + { + Id = post.Id, + ErrorCode = post.ErrorCode, + FixDo = post.FixDo, + Status = post.Status, + FinishTime = !string.IsNullOrEmpty(finishTime) ? finishTime : null, + WorkTime = post.WorkTime, + Notice = post.Notice, + Description = post.Description, + UpdatedBy = myUser.Id + }; + + + + List properties = new List() + { + "Id", + "ErrorCode", + "FixDo", + "Status", + "FinishTime", + "WorkTime", + "Notice", + "Description", + "UpdatedBy", + }; + + if (string.IsNullOrEmpty(operationRecode.FormId)) + { + var tempSerialNumber = GetLastSerialNumber(currentSerialNumber); + + update.FormId = "op" + DateTime.Now.ToString("yyyyMMdd") + tempSerialNumber; + update.SerialNumber = tempSerialNumber; + + properties.Add("FormId"); + properties.Add("SerialNumber"); + } + + await operationRepository.UpdateOperationRecodeAsync(update, properties); + + apiResult.Code = "0000"; + apiResult.Msg = "儲存成功"; + #endregion + } + } + 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; + } + + public async Task> SaveOperationRecodeFile([FromForm] PostOperationRecode post) + { + ApiResult apiResult = new ApiResult(); + + OperationRecode operationRecode = null; + + try + { + operationRecode = await operationRepository.GetOneOperationRecodeAsync(post.Id); + + if (operationRecode == null) + { + apiResult.Code = "9989"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + #region 新增運維作業記錄檔案 + List operationRecodeFiles; + + if (post.RecodeFiles != null && post.RecodeFiles.Length > 0) + { + FolderFunction folderFunction = new FolderFunction(); + + var fileSaveAsPath = Path.Combine(operationRecodeSaveAsPath, operationRecode.Id.ToString()); + + folderFunction.CreateFolder(fileSaveAsPath, 0); + + operationRecodeFiles = new List(); + + foreach (var file in post.RecodeFiles) + { + var split = file.FileName.Split("."); + + var fileName = Guid.NewGuid() + "." + split[split.Length - 1]; + + var fullPath = Path.Combine(fileSaveAsPath, fileName); + + using (var stream = new FileStream(fullPath, FileMode.Create)) + { + file.CopyTo(stream); + } + + OperationRecodeFile operationRecodeFile = new OperationRecodeFile() + { + RecordId = operationRecode.Id, + FileName = fileName, + CreatedBy = myUser.Id + }; + + operationRecodeFiles.Add(operationRecodeFile); + } + + List fileProperties = new List() + { + "RecordId", + "FileName", + "CreatedBy" + }; + + await operationRepository.AddOperationRecodeFilesAsync(operationRecodeFiles, fileProperties); + } + #endregion + + 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; + } } } diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs index 16f33b7..e760cc1 100644 --- a/SolarPower/Controllers/PowerStationController.cs +++ b/SolarPower/Controllers/PowerStationController.cs @@ -143,6 +143,27 @@ namespace SolarPower.Controllers return apiResult; } + [HttpPost] + public async Task>> GetOperationPersonnelSelectOptionList(int powerStationId) + { + ApiResult> apiResult = new ApiResult>(); + try + { + var personnelSelectItemLists = await powerStationRepository.GetOperationPersonnelSelectOptionListAsync(powerStationId); + + apiResult.Code = "0000"; + apiResult.Data = personnelSelectItemLists; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + /// /// 取得單一電站基本資料 /// diff --git a/SolarPower/Models/ErrorCode.cs b/SolarPower/Models/ErrorCode.cs index a3d77ca..26e2197 100644 --- a/SolarPower/Models/ErrorCode.cs +++ b/SolarPower/Models/ErrorCode.cs @@ -17,6 +17,7 @@ namespace SolarPower.Models { { "0000", "OK" }, { "0001", "傳入參數錯誤。" }, + { "9989", "查無該運維作業記錄"}, { "9990", "查無該圖片"}, { "9991", "查無該土地房屋資訊"}, { "9992", "查無該電站資訊"}, diff --git a/SolarPower/Models/Operation.cs b/SolarPower/Models/Operation.cs index a217ee4..66939df 100644 --- a/SolarPower/Models/Operation.cs +++ b/SolarPower/Models/Operation.cs @@ -1,11 +1,27 @@ -using System; +using Microsoft.AspNetCore.Http; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace SolarPower.Models { - public class Operation:Created + public enum OperationRecodeStatusEnum : byte + { + NoneComplete = 0, //未完成 + Complete = 1, //完成 + NoneCompleteExpired = 2, //未完成-過期 + CompleteExpired = 3, //完成-過期 + } + + public enum OperationRecodeWorkTypeEnum : byte + { + Clearn = 0, //清潔 + Inspection = 1, //巡檢 + Fix = 2, //維修 + } + + public class Operation : Created { public int Id { get; set; }//流水號 public byte Delete { get; set; }//刪除 @@ -98,58 +114,19 @@ namespace SolarPower.Models public string EndTime { get; set; } } - /// - /// 運維作業記錄的搜尋條件 - /// - public class PostOperationRecodeFilter + public class OperationRecode : Created { - public List CityIds { get; set; } //縣市編號 - public List PowerStationIds { get; set; } //電站編號 - public byte WorkType { get; set; } //工作項目 - public string Range { get; set; } //取得搜尋範圍 - } - - /// - /// 運維作業記錄的表單 - /// - public class OperationRecodeDataTable - { - private string startTime, endTime, finishTime; - public string PowerStationName { get; set; } //電站名稱 - public string FormId { get; set; } //表單號 - public byte WorkType { get; set; } //工作項目 - public string WorkTypeText - { - get - { - Dictionary pairs = new Dictionary() - { - { 0, "清洗"}, - { 1, "巡檢"}, - { 2, "維修"}, - }; - - return pairs[WorkType]; - } - } //工作項目名稱 - public string FixDo { get; set; } //維修項目 - public byte Status { get; set; } //狀態 - public string StatusText - { - get - { - Dictionary pairs = new Dictionary() - { - { 0, "未完成"}, - { 1, "完成"}, - { 2, "未完成-過期"}, - { 3, "完成-過期"}, - }; - - return pairs[Status]; - } - } //狀態名稱 - public string WorkPersonName { get; set; } //處理人員 + private string startTime, endTime, finishTime, workTime; + public int Id { get; set; } + public string FormId { get; set; } + public string SerialNumber { get; set; } + public int PowerStationId { get; set; } + public string PowerStationName { get; set; } + public byte WorkType { get; set; } + public string ErrorCode { get; set; } + public string FixDo { get; set; } + public byte Status { get; set; } + public int WorkPersonId { get; set; } public string StartTime { get @@ -180,6 +157,94 @@ namespace SolarPower.Models } set { endTime = value; } } // 結束時間 + public string FinishTime + { + get + { + if (!string.IsNullOrEmpty(finishTime)) + { + return Convert.ToDateTime(finishTime).ToString("yyyy-MM-dd"); + } + else + { + return null; + } + } + set { finishTime = value; } + } // 完成時間 + public string WorkTime + { + get + { + if (!string.IsNullOrEmpty(workTime)) + { + return Convert.ToDateTime(workTime).ToString("yyyy-MM-dd"); + } + else + { + return null; + } + } + set { workTime = value; } + } // 工作時間 + public string Notice { get; set; } + public string Description { get; set; } + public List RecodeFiles { get; set; } + } + + public class OperationRecodeFile : Created + { + public int Id { get; set; } + public int RecordId { get; set; } + public string FileName { get; set; } + } + + /// + /// 運維作業記錄的搜尋條件 + /// + public class PostOperationRecodeFilter + { + public List CityIds { get; set; } //縣市編號 + public List PowerStationIds { get; set; } //電站編號 + public byte WorkType { get; set; } //工作項目 + public string Range { get; set; } //取得搜尋範圍 + } + + /// + /// 運維作業記錄的表單 + /// + public class OperationRecodeDataTable : OperationRecode + { + public string WorkTypeText + { + get + { + Dictionary pairs = new Dictionary() + { + { 0, "清洗"}, + { 1, "巡檢"}, + { 2, "維修"}, + }; + + return pairs[WorkType]; + } + } //工作項目名稱 + public string StatusText + { + get + { + Dictionary pairs = new Dictionary() + { + { 0, "未完成"}, + { 1, "完成"}, + { 2, "未完成-過期"}, + { 3, "完成-過期"}, + }; + + return pairs[Status]; + } + } //狀態名稱 + public string WorkPersonName { get; set; } //處理人員 public string OperationPredict { get @@ -187,7 +252,38 @@ namespace SolarPower.Models return StartTime + " ~ " + EndTime; } } //本次作業預計 - public string FileList { get; set; } //本次作業預計 - public string FinishTime { get; set; } //本次作業預計 + public string FileList { get; set; } //檔案顯示 + } + + public class PostOperationRecode + { + public int Id { get; set; } + public int PowerStationId { get; set; } + public byte WorkType { get; set; } + public string ErrorCode { get; set; } + public string FixDo { get; set; } + public byte Status { get; set; } + public int WorkPersonId { get; set; } + public string StartTime { get; set; }//開始時間 + public string EndTime { get; set; } // 結束時間 + public string FinishTime { get; set; } // 完成時間 + public string WorkTime { get; set; } // 工作時間 + public string Notice { get; set; } + public string Description { get; set; } + public IFormFile[] RecodeFiles { get; set; } + } + + public class UpdateOperationRecode : Updated + { + public string FormId { get; set; } + public string SerialNumber { get; set; } + public string ErrorCode { get; set; } + public string FixDo { get; set; } + public byte Status { get; set; } + public int WorkPersonId { get; set; } + public string FinishTime { get; set; } // 完成時間 + public string WorkTime { get; set; } // 工作時間 + public string Notice { get; set; } + public string Description { get; set; } } } diff --git a/SolarPower/Models/PowerStation.cs b/SolarPower/Models/PowerStation.cs index 316e244..b17938a 100644 --- a/SolarPower/Models/PowerStation.cs +++ b/SolarPower/Models/PowerStation.cs @@ -467,4 +467,10 @@ namespace SolarPower.Models.PowerStation public int Amount { get; set; } } + public class OperationPersonnelSelectItemList + { + public string Text { get; set; } + public string Value { get; set; } + } + } diff --git a/SolarPower/Repository/Implement/OperationRepository.cs b/SolarPower/Repository/Implement/OperationRepository.cs index f34ca08..603c77a 100644 --- a/SolarPower/Repository/Implement/OperationRepository.cs +++ b/SolarPower/Repository/Implement/OperationRepository.cs @@ -183,15 +183,9 @@ namespace SolarPower.Repository.Implement try { var sql = @$"SELECT + opr.*, ps.Name AS PowerStationName, - opr.FormId, - opr.WorkType, - opr.FixDO, - opr.Status, - u.Name AS WorkPersonName, - opr.StartTime, - opr.EndTime, - opr.FinishTime + u.Name AS WorkPersonName FROM operation_record opr LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id LEFT JOIN user u ON opr.WorkPersonId = u.ID @@ -213,15 +207,9 @@ namespace SolarPower.Repository.Implement sql += @" AND opr.WorkType IN (0, 1)"; sql += @" UNION"; sql += @" SELECT + opr.*, ps.Name AS PowerStationName, - opr.FormId, - opr.WorkType, - opr.FixDO, - opr.Status, - u.Name AS WorkPersonName, - opr.StartTime, - opr.EndTime, - opr.FinishTime + u.Name AS WorkPersonName FROM operation_record opr LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id LEFT JOIN user u ON opr.WorkPersonId = u.ID @@ -240,5 +228,150 @@ namespace SolarPower.Repository.Implement return result; } } + + /// + /// 透過Id,取得單一筆運維作業記錄 + /// + /// + /// + public async Task GetOneOperationRecodeAsync(int id) + { + OperationRecode result; + + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + conn.Open(); + try + { + var sql = @$"SELECT opr.*, ps.Name AS PowerStationName + FROM operation_record opr + LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id + WHERE opr.Deleted = 0 AND opr.Id = @Id"; + + result = await conn.QueryFirstOrDefaultAsync(sql, new { Id = id }); + + if(result != null) + { + //取得圖片 or 檔案 + var sql_file = @"SELECT * FROM operation_record_file WHERE Deleted = 0 AND RecordId = @RecordId"; + + result.RecodeFiles = (await conn.QueryAsync(sql_file, new { RecordId = result.Id })).ToList(); + } + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + return result; + } + } + + /// + /// 新增一筆運維作業記錄 + /// + /// + /// + /// + public async Task AddOneOperationRecodeAsync(OperationRecode entity, List properties) + { + var id = 0; + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + string sql = GenerateInsertQueryWithCustomTable(properties, "operation_record"); + + sql += "SELECT LAST_INSERT_ID();"; + + id = (await conn.QueryAsync(sql, entity, trans)).Single(); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + + return id; + } + } + + /// + /// 修改運維作業記錄 + /// + /// + /// + /// + /// + public async Task UpdateOperationRecodeAsync(UpdateOperationRecode entity, List properties) + { + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + var sql = GenerateUpdateQueryWithCustomTable(properties, "operation_record"); + await conn.ExecuteAsync(sql, entity, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + } + } + + /// + /// 新增運維作業記錄的檔案 + /// + /// + /// + /// + public async Task AddOperationRecodeFilesAsync(List entity, List properties) + { + int count; + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + try + { + string sql = GenerateInsertQueryWithCustomTable(properties, "operation_record_file"); + + count = await conn.ExecuteAsync(sql, entity); + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + + return count; + } + } } } diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 2eae156..79f1a2a 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -343,7 +343,7 @@ namespace SolarPower.Repository.Implement } /// - /// 新增 土地房屋資訊 + /// 取得 土地房屋資訊 /// /// /// @@ -1361,5 +1361,28 @@ namespace SolarPower.Repository.Implement } return powerstation; } + + + public async Task> GetOperationPersonnelSelectOptionListAsync(int powerStationId) + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = @$"SELECT u.Id AS Value, u.Name AS Text + FROM power_station_operation_personnel op + LEFT JOIN user u ON op.UserId = u.Id + WHERE op.Deleted = 0 AND op.PowerStationId = @PowerStationId"; + + result = (await conn.QueryAsync(sql, new { PowerStationId = powerStationId })).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } } } diff --git a/SolarPower/Repository/Implement/RepositoryBase.cs b/SolarPower/Repository/Implement/RepositoryBase.cs index a0a2fe7..e53802f 100644 --- a/SolarPower/Repository/Implement/RepositoryBase.cs +++ b/SolarPower/Repository/Implement/RepositoryBase.cs @@ -519,14 +519,19 @@ namespace SolarPower.Repository.Implement /// /// /// - public async Task GetCurrentSerialNumber(string Table_name, string where) + public async Task GetCurrentSerialNumber(string Table_name, string where = "") { string Num; using IDbConnection conn = _databaseHelper.GetConnection(); conn.Open(); try { - var sql = $"SELECT SerialNumber FROM {Table_name} WHERE {where} ORDER BY SerialNumber DESC"; + var sql = @$"SELECT SerialNumber FROM {Table_name}"; + if (!string.IsNullOrEmpty(where)) + { + sql += $" WHERE {where}"; + } + sql += " ORDER BY SerialNumber DESC"; Num = await conn.QueryFirstOrDefaultAsync(sql); } catch (Exception exception) diff --git a/SolarPower/Repository/Interface/IOperationRepository.cs b/SolarPower/Repository/Interface/IOperationRepository.cs index ef999a4..452622f 100644 --- a/SolarPower/Repository/Interface/IOperationRepository.cs +++ b/SolarPower/Repository/Interface/IOperationRepository.cs @@ -22,6 +22,37 @@ namespace SolarPower.Repository.Interface /// /// Task> GetAllRecodeByFilterAsync(PostOperationRecodeFilter filter); + + /// + /// 透過Id,取得單一筆運維作業記錄 + /// + /// + /// + Task GetOneOperationRecodeAsync(int id); + + /// + /// 新增一筆運維作業記錄 + /// + /// + /// + /// + Task AddOneOperationRecodeAsync(OperationRecode entity, List properties); + + /// + /// 修改運維作業記錄 + /// + /// + /// + /// + Task UpdateOperationRecodeAsync(UpdateOperationRecode entity, List properties); + + /// + /// 新增運維作業記錄的檔案 + /// + /// + /// + /// + Task AddOperationRecodeFilesAsync(List entity, List properties); } } diff --git a/SolarPower/Repository/Interface/IPowerStationRepository.cs b/SolarPower/Repository/Interface/IPowerStationRepository.cs index d9ab904..d52eefd 100644 --- a/SolarPower/Repository/Interface/IPowerStationRepository.cs +++ b/SolarPower/Repository/Interface/IPowerStationRepository.cs @@ -25,6 +25,10 @@ namespace SolarPower.Repository.Interface /// Task> GetAreaSelectOptionListAsync(int cityId); + Task> GetOperationPersonnelSelectOptionListAsync(int powerStationId); + + + /// /// 透過編號取得,縣市資訊 /// diff --git a/SolarPower/Repository/Interface/IRepositoryBase.cs b/SolarPower/Repository/Interface/IRepositoryBase.cs index 2b7f0c8..5eb0719 100644 --- a/SolarPower/Repository/Interface/IRepositoryBase.cs +++ b/SolarPower/Repository/Interface/IRepositoryBase.cs @@ -95,6 +95,6 @@ namespace SolarPower.Repository.Interface /// /// /// - Task GetCurrentSerialNumber(string Table_name, string where); + Task GetCurrentSerialNumber(string Table_name, string where = ""); } } diff --git a/SolarPower/Views/Operation/OperationRecord.cshtml b/SolarPower/Views/Operation/OperationRecord.cshtml index ecbe6e9..5ba4d7e 100644 --- a/SolarPower/Views/Operation/OperationRecord.cshtml +++ b/SolarPower/Views/Operation/OperationRecord.cshtml @@ -44,7 +44,7 @@ 匯出 - + 維修單 @@ -56,9 +56,9 @@ 電廠 表單號 項目 - 類型 + 維修項目 狀態 - 處理人員 + 執行人員 本次作業預計 照片 完成時間 @@ -66,75 +66,6 @@ - @* - 新竹巨城站 - op20210630001 - 維修 - 逆變器異常 - -
- - -
- - 王小明 - - - 2021-03-5 - - 修改 - - - - - 新竹巨城站 - - - 填寫表單 - - - 維修 - 逆變器異常 - -
- - -
- - 王小明 - - - 2021-03-5 - - 修改 - - - - - 新竹巨城站 - - - 填寫表單 - - - 維修 - 逆變器異常 - -
- - -
- - 王小明 - - - 2021-03-5 - - 修改 - - - *@ - @@ -142,12 +73,172 @@ + + @section Scripts{ } \ No newline at end of file diff --git a/SolarPower/Views/PowerStation/_UploadImage.cshtml b/SolarPower/Views/PowerStation/_UploadImage.cshtml index 6163973..9d5610a 100644 --- a/SolarPower/Views/PowerStation/_UploadImage.cshtml +++ b/SolarPower/Views/PowerStation/_UploadImage.cshtml @@ -12,65 +12,6 @@
- @*
-
- ... - - - -
-
- - -
-
-
-
-
-
- ... -
-
- - -
-
-
-
-
-
- ... -
-
- - -
-
-
-
-
-
- ... -
-
- - -
-
-
-
-
-
- ... -
-
- - -
-
-
-
*@ -
@@ -106,65 +47,6 @@
- @*
-
- ... - - - -
-
- - -
-
-
-
-
-
- ... -
-
- - -
-
-
-
-
-
- ... -
-
- - -
-
-
-
-
-
- ... -
-
- - -
-
-
-
-
-
- ... -
-
- - -
-
-
-
*@ -
@@ -172,7 +54,7 @@
- +

diff --git a/SolarPower/wwwroot/css/site.css b/SolarPower/wwwroot/css/site.css index 5882a5e..d26ff7e 100644 --- a/SolarPower/wwwroot/css/site.css +++ b/SolarPower/wwwroot/css/site.css @@ -19,6 +19,9 @@ label.error { /* 隱藏圖片上傳 progress bar */ -#power-station-images-form .dz-preview .dz-progress, #power-station-single-line-form .dz-preview .dz-progress { +#power-station-images-form .dz-preview .dz-progress, +#power-station-single-line-form .dz-preview .dz-progress, +#recode-file-div .dz-preview .dz-progress +{ display: none; } \ No newline at end of file