1. 維修單 負責人員多選
2. 維修單 新增廠商欄位
This commit is contained in:
parent
c8f605168c
commit
72e2daebeb
@ -8,14 +8,15 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Transactions;
|
||||||
|
|
||||||
namespace SolarPower.Controllers
|
namespace SolarPower.Controllers
|
||||||
{
|
{
|
||||||
public class OperationController : MyBaseController<OperationController>
|
public class OperationController : MyBaseController<OperationController>
|
||||||
{
|
{
|
||||||
private readonly IOperationRepository operationRepository;
|
private readonly IOperationRepository operationRepository;
|
||||||
private string operationRecodeFilePath = "/upload/operation_recode/";
|
private string operationRecordFilePath = "/upload/operation_recode/";
|
||||||
private string operationRecodeSaveAsPath = "";
|
private string operationRecordSaveAsPath = "";
|
||||||
|
|
||||||
|
|
||||||
public OperationController(
|
public OperationController(
|
||||||
@ -23,7 +24,7 @@ namespace SolarPower.Controllers
|
|||||||
{
|
{
|
||||||
this.operationRepository = operationRepository;
|
this.operationRepository = operationRepository;
|
||||||
|
|
||||||
operationRecodeSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "operation_recode");
|
operationRecordSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "operation_recode");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
@ -71,7 +72,7 @@ namespace SolarPower.Controllers
|
|||||||
ApiResult<string> apiResult = new ApiResult<string>();
|
ApiResult<string> apiResult = new ApiResult<string>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(Convert.ToDateTime(post.StartTime) < Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")))
|
if (Convert.ToDateTime(post.StartTime) < Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")))
|
||||||
{
|
{
|
||||||
apiResult.Msg = "開始時間不能選擇過去";
|
apiResult.Msg = "開始時間不能選擇過去";
|
||||||
apiResult.Code = "0099";
|
apiResult.Code = "0099";
|
||||||
@ -115,13 +116,13 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(post.StartTime == DateTime.Now.ToString("yyyy-MM-dd"))
|
if (post.StartTime == DateTime.Now.ToString("yyyy-MM-dd"))
|
||||||
{
|
{
|
||||||
string endtime = "";
|
string endtime = "";
|
||||||
switch (post.ScheduleType)
|
switch (post.ScheduleType)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
endtime = (Convert.ToDateTime(post.StartTime).AddDays(post.ScheduleNum)).ToString("yyyy-MM-dd 00:00:00");break;
|
endtime = (Convert.ToDateTime(post.StartTime).AddDays(post.ScheduleNum)).ToString("yyyy-MM-dd 00:00:00"); break;
|
||||||
case 1:
|
case 1:
|
||||||
endtime = (Convert.ToDateTime(post.StartTime).AddDays(post.ScheduleNum * 7)).ToString("yyyy-MM-dd 00:00:00"); break;
|
endtime = (Convert.ToDateTime(post.StartTime).AddDays(post.ScheduleNum * 7)).ToString("yyyy-MM-dd 00:00:00"); break;
|
||||||
case 2:
|
case 2:
|
||||||
@ -388,45 +389,45 @@ namespace SolarPower.Controllers
|
|||||||
/// <param name="post"></param>
|
/// <param name="post"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ActionResult> OperationRecodeListAsync(PostOperationRecodeFilter post)
|
public async Task<ActionResult> OperationRecordListAsync(PostOperationRecordFilter post)
|
||||||
{
|
{
|
||||||
ApiResult<List<OperationRecodeDataTable>> apiResult = new ApiResult<List<OperationRecodeDataTable>>();
|
ApiResult<List<OperationRecordDataTable>> apiResult = new ApiResult<List<OperationRecordDataTable>>();
|
||||||
|
|
||||||
int totalRecords = 0; //總資料筆數
|
int totalRecords = 0; //總資料筆數
|
||||||
int recFilter = 0; //過濾後資料筆數
|
int recFilter = 0; //過濾後資料筆數
|
||||||
|
|
||||||
List<OperationRecodeDataTable> recodes = null;
|
List<OperationRecordDataTable> records = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
recodes = await operationRepository.GetAllRecodeByFilterAsync(post);
|
records = await operationRepository.GetAllRecordByFilterAsync(post);
|
||||||
|
|
||||||
foreach (var recode in recodes)
|
foreach (var record in records)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(recode.FormId))
|
if (string.IsNullOrEmpty(record.FormId))
|
||||||
{
|
{
|
||||||
recode.FormId = @$"<a href='javascript:;' class='btn btn-success waves-effect waves-themed mb-3 mr-2 edit-btn'>填寫表單</a>";
|
record.FormId = @$"<a href='javascript:;' class='btn btn-success waves-effect waves-themed mb-3 mr-2 edit-btn'>填寫表單</a>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
recode.FormId = @$"<a href='javascript:;' class='waves-effect waves-themed mb-3 mr-2 edit-btn'>{recode.FormId}</a>";
|
record.FormId = @$"<a href='javascript:;' class='waves-effect waves-themed mb-3 mr-2 edit-btn'>{record.FormId}</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recode.RecodeFiles != null && recode.RecodeFiles.Count > 0)
|
if (record.RecordFiles != null && record.RecordFiles.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var file in recode.RecodeFiles)
|
foreach (var file in record.RecordFiles)
|
||||||
{
|
{
|
||||||
file.FileName = Path.Combine(operationRecodeFilePath, recode.Id.ToString()) + "/" + file.FileName;
|
file.FileName = Path.Combine(operationRecordFilePath, record.Id.ToString()) + "/" + file.FileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
totalRecords = recodes.Count();
|
totalRecords = records.Count();
|
||||||
recFilter = recodes.Count();
|
recFilter = records.Count();
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = recodes;
|
apiResult.Data = records;
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -453,11 +454,11 @@ namespace SolarPower.Controllers
|
|||||||
/// <param name="post"></param>
|
/// <param name="post"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ApiResult<OperationRecode>> GetOneOperationRecode(int id)
|
public async Task<ApiResult<OperationRecord>> GetOneOperationRecord(int id)
|
||||||
{
|
{
|
||||||
ApiResult<OperationRecode> apiResult = new ApiResult<OperationRecode>();
|
ApiResult<OperationRecord> apiResult = new ApiResult<OperationRecord>();
|
||||||
|
|
||||||
OperationRecode operationRecode;
|
OperationRecord operationRecord;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -467,22 +468,22 @@ namespace SolarPower.Controllers
|
|||||||
// post.SelectedCompanyId = myUser.CompanyId;
|
// post.SelectedCompanyId = myUser.CompanyId;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
operationRecode = await operationRepository.GetOneOperationRecodeAsync(id);
|
operationRecord = await operationRepository.GetOneOperationRecordAsync(id);
|
||||||
|
|
||||||
if (operationRecode == null)
|
if (operationRecord == null)
|
||||||
{
|
{
|
||||||
apiResult.Code = "9989";
|
apiResult.Code = "9989";
|
||||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var recodeFile in operationRecode.RecodeFiles)
|
foreach (var recodeFile in operationRecord.RecordFiles)
|
||||||
{
|
{
|
||||||
recodeFile.FileName = Path.Combine(operationRecodeFilePath, operationRecode.Id.ToString()) + "/" + recodeFile.FileName;
|
recodeFile.FileName = Path.Combine(operationRecordFilePath, operationRecord.Id.ToString()) + "/" + recodeFile.FileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = operationRecode;
|
apiResult.Data = operationRecord;
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -500,20 +501,21 @@ namespace SolarPower.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="post"></param>
|
/// <param name="post"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ApiResult<int>> SaveOperationRecode([FromForm] PostOperationRecode post)
|
public async Task<ApiResult<int>> SaveOperationRecord([FromForm] PostOperationRecord post)
|
||||||
{
|
{
|
||||||
ApiResult<int> apiResult = new ApiResult<int>();
|
ApiResult<int> apiResult = new ApiResult<int>();
|
||||||
|
|
||||||
OperationRecode operationRecode = null;
|
OperationRecord operationRecord = null;
|
||||||
|
var id = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
operationRecode = await operationRepository.GetOneOperationRecodeAsync(post.Id);
|
operationRecord = await operationRepository.GetOneOperationRecordAsync(post.Id);
|
||||||
|
|
||||||
//取得運維作業記錄最後流水號
|
//取得運維作業記錄最後流水號
|
||||||
var currentSerialNumber = await operationRepository.GetCurrentSerialNumber("operation_record");
|
var currentSerialNumber = await operationRepository.GetCurrentSerialNumber("operation_record");
|
||||||
|
|
||||||
if (operationRecode == null)
|
if (operationRecord == null)
|
||||||
{
|
{
|
||||||
if (post.Id != 0)
|
if (post.Id != 0)
|
||||||
{
|
{
|
||||||
@ -527,48 +529,75 @@ namespace SolarPower.Controllers
|
|||||||
var tempSerialNumber = GetLastSerialNumber(currentSerialNumber);
|
var tempSerialNumber = GetLastSerialNumber(currentSerialNumber);
|
||||||
|
|
||||||
var finishTime = string.Empty;
|
var finishTime = string.Empty;
|
||||||
if (post.Status == (int)OperationRecodeStatusEnum.Complete)
|
if (post.Status == (int)OperationRecordStatusEnum.Complete)
|
||||||
{
|
{
|
||||||
finishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
finishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
}
|
}
|
||||||
|
|
||||||
operationRecode = new OperationRecode()
|
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||||
{
|
{
|
||||||
FormId = "op" + DateTime.Now.ToString("yyyyMMdd") + tempSerialNumber,
|
operationRecord = new OperationRecord()
|
||||||
SerialNumber = tempSerialNumber,
|
{
|
||||||
PowerStationId = post.PowerStationId,
|
FormId = "op" + DateTime.Now.ToString("yyyyMMdd") + tempSerialNumber,
|
||||||
WorkType = (int)OperationRecodeWorkTypeEnum.Fix,
|
SerialNumber = tempSerialNumber,
|
||||||
ErrorCode = post.ErrorCode,
|
PowerStationId = post.PowerStationId,
|
||||||
FixDo = post.FixDo,
|
WorkType = (int)OperationRecordWorkTypeEnum.Fix,
|
||||||
FixFirm = post.FixFirm,
|
ErrorCode = post.ErrorCode,
|
||||||
Status = post.Status,
|
FixDo = post.FixDo,
|
||||||
WorkPersonId = post.WorkPersonId,
|
FixFirm = post.FixFirm,
|
||||||
FinishTime = finishTime,
|
Status = post.Status,
|
||||||
WorkTime = post.WorkTime,
|
//WorkPersonId = post.WorkPersonId,
|
||||||
Notice = post.Notice,
|
FinishTime = finishTime,
|
||||||
Description = post.Description,
|
WorkTime = post.WorkTime,
|
||||||
CreatedBy = myUser.Id
|
Notice = post.Notice,
|
||||||
};
|
Description = post.Description,
|
||||||
|
CreatedBy = myUser.Id
|
||||||
|
};
|
||||||
|
|
||||||
List<string> properties = new List<string>()
|
List<string> properties = new List<string>()
|
||||||
{
|
{
|
||||||
"FormId",
|
"FormId",
|
||||||
"SerialNumber",
|
"SerialNumber",
|
||||||
"PowerStationId",
|
"PowerStationId",
|
||||||
"WorkType",
|
"WorkType",
|
||||||
"ErrorCode",
|
"ErrorCode",
|
||||||
"FixDo",
|
"FixDo",
|
||||||
"FixFirm",
|
"FixFirm",
|
||||||
"Status",
|
"Status",
|
||||||
"WorkPersonId",
|
//"WorkPersonId",
|
||||||
"FinishTime",
|
"FinishTime",
|
||||||
"WorkTime",
|
"WorkTime",
|
||||||
"Notice",
|
"Notice",
|
||||||
"Description",
|
"Description",
|
||||||
"CreatedBy"
|
"CreatedBy"
|
||||||
};
|
};
|
||||||
|
|
||||||
var id = await operationRepository.AddOneOperationRecodeAsync(operationRecode, properties);
|
id = await operationRepository.AddOneOperationRecordAsync(operationRecord, properties);
|
||||||
|
|
||||||
|
//加入執行人員
|
||||||
|
if (post.WorkPersonIds != null)
|
||||||
|
{
|
||||||
|
List<OperationRecordPersonnel> insertOperationRecordPersonnels = new List<OperationRecordPersonnel>();
|
||||||
|
|
||||||
|
foreach (var op in post.WorkPersonIds)
|
||||||
|
{
|
||||||
|
OperationRecordPersonnel operationRecordPersonnel = new OperationRecordPersonnel();
|
||||||
|
operationRecordPersonnel.OperationRecordId = id;
|
||||||
|
operationRecordPersonnel.UserId = op;
|
||||||
|
|
||||||
|
insertOperationRecordPersonnels.Add(operationRecordPersonnel);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<string> operationRecordPersonnelProperties = new List<string>()
|
||||||
|
{
|
||||||
|
"OperationRecordId",
|
||||||
|
"UserId",
|
||||||
|
};
|
||||||
|
|
||||||
|
await operationRepository.AddOperationRecordPersonnelAsync(insertOperationRecordPersonnels, operationRecordPersonnelProperties);
|
||||||
|
}
|
||||||
|
scope.Complete();
|
||||||
|
}
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Msg = "儲存成功";
|
apiResult.Msg = "儲存成功";
|
||||||
@ -581,12 +610,12 @@ namespace SolarPower.Controllers
|
|||||||
#region 修改運維作業記錄
|
#region 修改運維作業記錄
|
||||||
|
|
||||||
var finishTime = string.Empty;
|
var finishTime = string.Empty;
|
||||||
if (post.Status == (int)OperationRecodeStatusEnum.Complete)
|
if (post.Status == (int)OperationRecordStatusEnum.Complete)
|
||||||
{
|
{
|
||||||
finishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
finishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operationRecode.WorkType != (int)OperationRecodeWorkTypeEnum.Fix)
|
if (operationRecord.WorkType != (int)OperationRecordWorkTypeEnum.Fix)
|
||||||
{ //針對清洗、巡檢
|
{ //針對清洗、巡檢
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
|
|
||||||
@ -595,18 +624,18 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
if (now > endTime)
|
if (now > endTime)
|
||||||
{
|
{
|
||||||
if (post.Status == (int)OperationRecodeStatusEnum.NoneComplete)
|
if (post.Status == (int)OperationRecordStatusEnum.NoneComplete)
|
||||||
{ //超過時間修改成 未完成-過期
|
{ //超過時間修改成 未完成-過期
|
||||||
post.Status = (int)OperationRecodeStatusEnum.NoneCompleteExpired;
|
post.Status = (int)OperationRecordStatusEnum.NoneCompleteExpired;
|
||||||
}
|
}
|
||||||
else if (post.Status == (int)OperationRecodeStatusEnum.Complete)
|
else if (post.Status == (int)OperationRecordStatusEnum.Complete)
|
||||||
{ //超過時間修改成 完成-過期
|
{ //超過時間修改成 完成-過期
|
||||||
post.Status = (int)OperationRecodeStatusEnum.CompleteExpired;
|
post.Status = (int)OperationRecordStatusEnum.CompleteExpired;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateOperationRecode update = new UpdateOperationRecode()
|
UpdateOperationRecord update = new UpdateOperationRecord()
|
||||||
{
|
{
|
||||||
Id = post.Id,
|
Id = post.Id,
|
||||||
ErrorCode = post.ErrorCode,
|
ErrorCode = post.ErrorCode,
|
||||||
@ -614,7 +643,7 @@ namespace SolarPower.Controllers
|
|||||||
FixFirm = post.FixFirm,
|
FixFirm = post.FixFirm,
|
||||||
Status = post.Status,
|
Status = post.Status,
|
||||||
FinishTime = !string.IsNullOrEmpty(finishTime) ? finishTime : null,
|
FinishTime = !string.IsNullOrEmpty(finishTime) ? finishTime : null,
|
||||||
WorkPersonId = post.WorkPersonId,
|
//WorkPersonId = post.WorkPersonId,
|
||||||
WorkTime = post.WorkTime,
|
WorkTime = post.WorkTime,
|
||||||
Notice = post.Notice,
|
Notice = post.Notice,
|
||||||
Description = post.Description,
|
Description = post.Description,
|
||||||
@ -634,11 +663,11 @@ namespace SolarPower.Controllers
|
|||||||
"WorkTime",
|
"WorkTime",
|
||||||
"Notice",
|
"Notice",
|
||||||
"Description",
|
"Description",
|
||||||
"WorkPersonId",
|
//"WorkPersonId",
|
||||||
"UpdatedBy",
|
"UpdatedBy",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(operationRecode.FormId))
|
if (string.IsNullOrEmpty(operationRecord.FormId))
|
||||||
{
|
{
|
||||||
var tempSerialNumber = GetLastSerialNumber(currentSerialNumber);
|
var tempSerialNumber = GetLastSerialNumber(currentSerialNumber);
|
||||||
|
|
||||||
@ -649,11 +678,69 @@ namespace SolarPower.Controllers
|
|||||||
properties.Add("SerialNumber");
|
properties.Add("SerialNumber");
|
||||||
}
|
}
|
||||||
|
|
||||||
await operationRepository.UpdateOperationRecodeAsync(update, properties);
|
await operationRepository.UpdateOperationRecordAsync(update, properties);
|
||||||
|
|
||||||
|
List<int> origOperationRecordPersonnels = null; //原先的運維人員
|
||||||
|
|
||||||
|
origOperationRecordPersonnels = await operationRepository.GetOperationRecordPersonnelIdsByOperationRecordId(operationRecord.Id);
|
||||||
|
|
||||||
|
//判斷新進來的執行人員是否要歸類到新增 or 刪除
|
||||||
|
#region 刪除執行人員編號
|
||||||
|
if(post.WorkPersonIds != null && post.WorkPersonIds.Count() > 0)
|
||||||
|
{
|
||||||
|
//找出要刪除的
|
||||||
|
List<int> deleteOperationRecordPersonnelIds = origOperationRecordPersonnels.Where(x => !post.WorkPersonIds.Contains(x)).ToList();
|
||||||
|
|
||||||
|
List<OperationRecordPersonnel> deleteOperationRecordPersonnels = new List<OperationRecordPersonnel>();
|
||||||
|
foreach (var opId in deleteOperationRecordPersonnelIds)
|
||||||
|
{
|
||||||
|
OperationRecordPersonnel operationRecordPersonnel = new OperationRecordPersonnel();
|
||||||
|
operationRecordPersonnel.OperationRecordId = operationRecord.Id;
|
||||||
|
operationRecordPersonnel.UserId = opId;
|
||||||
|
|
||||||
|
deleteOperationRecordPersonnels.Add(operationRecordPersonnel);
|
||||||
|
}
|
||||||
|
|
||||||
|
//刪除執行人員
|
||||||
|
await operationRepository.DeleteOperationRecordPersonnel(deleteOperationRecordPersonnels);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 新增人員
|
||||||
|
//找出要新增的
|
||||||
|
if (post.WorkPersonIds != null && post.WorkPersonIds.Count() > 0)
|
||||||
|
{
|
||||||
|
List<int> insertOperationRecordPersonnelIds = post.WorkPersonIds.Where(x => !origOperationRecordPersonnels.Contains(x)).ToList();
|
||||||
|
|
||||||
|
List<OperationRecordPersonnel> insertOperationRecordPersonnels = new List<OperationRecordPersonnel>();
|
||||||
|
|
||||||
|
foreach (var op in insertOperationRecordPersonnelIds)
|
||||||
|
{
|
||||||
|
OperationRecordPersonnel operationPersonnel = new OperationRecordPersonnel();
|
||||||
|
operationPersonnel.OperationRecordId = operationRecord.Id;
|
||||||
|
operationPersonnel.Deleted = 0;
|
||||||
|
operationPersonnel.UserId = op;
|
||||||
|
operationPersonnel.CreatedBy = myUser.Id;
|
||||||
|
|
||||||
|
insertOperationRecordPersonnels.Add(operationPersonnel);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<string> operationRecordPersonnelProperties = new List<string>()
|
||||||
|
{
|
||||||
|
"OperationRecordId",
|
||||||
|
"Deleted",
|
||||||
|
"UserId",
|
||||||
|
"CreatedBy",
|
||||||
|
};
|
||||||
|
|
||||||
|
await operationRepository.AddOperationRecordPersonnelAsync(insertOperationRecordPersonnels, operationRecordPersonnelProperties);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Msg = "儲存成功";
|
apiResult.Msg = "儲存成功";
|
||||||
apiResult.Data = operationRecode.Id;
|
apiResult.Data = operationRecord.Id;
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -669,22 +756,22 @@ namespace SolarPower.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ApiResult<string>> DeleteOneOperationRecode(int id)
|
public async Task<ApiResult<string>> DeleteOneOperationRecord(int id)
|
||||||
{
|
{
|
||||||
ApiResult<string> apiResult = new ApiResult<string>();
|
ApiResult<string> apiResult = new ApiResult<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationRecode = await operationRepository.GetOneOperationRecodeAsync(id);
|
var operationRecord = await operationRepository.GetOneOperationRecordAsync(id);
|
||||||
|
|
||||||
if (operationRecode == null)
|
if (operationRecord == null)
|
||||||
{
|
{
|
||||||
apiResult.Code = "9989";
|
apiResult.Code = "9989";
|
||||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
await operationRepository.DeleteOneOperationRecodeAsync(id);
|
await operationRepository.DeleteOneOperationRecordAsync(id);
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Msg = "刪除成功";
|
apiResult.Msg = "刪除成功";
|
||||||
@ -706,17 +793,17 @@ namespace SolarPower.Controllers
|
|||||||
/// <param name="post"></param>
|
/// <param name="post"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ApiResult<OperationRecode>> SaveOperationRecodeFile([FromForm] PostOperationRecode post)
|
public async Task<ApiResult<OperationRecord>> SaveOperationRecordFile([FromForm] PostOperationRecord post)
|
||||||
{
|
{
|
||||||
ApiResult<OperationRecode> apiResult = new ApiResult<OperationRecode>();
|
ApiResult<OperationRecord> apiResult = new ApiResult<OperationRecord>();
|
||||||
|
|
||||||
OperationRecode operationRecode = null;
|
OperationRecord operationRecord = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
operationRecode = await operationRepository.GetOneOperationRecodeAsync(post.Id);
|
operationRecord = await operationRepository.GetOneOperationRecordAsync(post.Id);
|
||||||
|
|
||||||
if (operationRecode == null)
|
if (operationRecord == null)
|
||||||
{
|
{
|
||||||
apiResult.Code = "9989";
|
apiResult.Code = "9989";
|
||||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
@ -724,19 +811,19 @@ namespace SolarPower.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region 新增運維作業記錄檔案
|
#region 新增運維作業記錄檔案
|
||||||
List<OperationRecodeFile> operationRecodeFiles;
|
List<OperationRecordFile> operationRecordFiles;
|
||||||
|
|
||||||
if (post.RecodeFiles != null && post.RecodeFiles.Length > 0)
|
if (post.RecordFiles != null && post.RecordFiles.Length > 0)
|
||||||
{
|
{
|
||||||
FolderFunction folderFunction = new FolderFunction();
|
FolderFunction folderFunction = new FolderFunction();
|
||||||
|
|
||||||
var fileSaveAsPath = Path.Combine(operationRecodeSaveAsPath, operationRecode.Id.ToString());
|
var fileSaveAsPath = Path.Combine(operationRecordSaveAsPath, operationRecord.Id.ToString());
|
||||||
|
|
||||||
folderFunction.CreateFolder(fileSaveAsPath, 0);
|
folderFunction.CreateFolder(fileSaveAsPath, 0);
|
||||||
|
|
||||||
operationRecodeFiles = new List<OperationRecodeFile>();
|
operationRecordFiles = new List<OperationRecordFile>();
|
||||||
|
|
||||||
foreach (var file in post.RecodeFiles)
|
foreach (var file in post.RecordFiles)
|
||||||
{
|
{
|
||||||
var split = file.FileName.Split(".");
|
var split = file.FileName.Split(".");
|
||||||
|
|
||||||
@ -749,14 +836,14 @@ namespace SolarPower.Controllers
|
|||||||
file.CopyTo(stream);
|
file.CopyTo(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
OperationRecodeFile operationRecodeFile = new OperationRecodeFile()
|
OperationRecordFile operationRecordFile = new OperationRecordFile()
|
||||||
{
|
{
|
||||||
RecordId = operationRecode.Id,
|
RecordId = operationRecord.Id,
|
||||||
FileName = fileName,
|
FileName = fileName,
|
||||||
CreatedBy = myUser.Id
|
CreatedBy = myUser.Id
|
||||||
};
|
};
|
||||||
|
|
||||||
operationRecodeFiles.Add(operationRecodeFile);
|
operationRecordFiles.Add(operationRecordFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<string> fileProperties = new List<string>()
|
List<string> fileProperties = new List<string>()
|
||||||
@ -766,7 +853,7 @@ namespace SolarPower.Controllers
|
|||||||
"CreatedBy"
|
"CreatedBy"
|
||||||
};
|
};
|
||||||
|
|
||||||
await operationRepository.AddOperationRecodeFilesAsync(operationRecodeFiles, fileProperties);
|
await operationRepository.AddOperationRecordFilesAsync(operationRecordFiles, fileProperties);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -785,34 +872,34 @@ namespace SolarPower.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ApiResult<string>> DeleteOperationRecodeFile(PostOperationRecodeIdAndSelectedId post)
|
public async Task<ApiResult<string>> DeleteOperationRecordFile(PostOperationRecordIdAndSelectedId post)
|
||||||
{
|
{
|
||||||
ApiResult<string> apiResult = new ApiResult<string>();
|
ApiResult<string> apiResult = new ApiResult<string>();
|
||||||
|
|
||||||
OperationRecode operationRecode = null;
|
OperationRecord operationRecord = null;
|
||||||
OperationRecodeFile operationRecodeFile = null;
|
OperationRecordFile operationRecordFile = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
operationRecode = await operationRepository.GetOneOperationRecodeAsync(post.ReocdeId);
|
operationRecord = await operationRepository.GetOneOperationRecordAsync(post.ReocdeId);
|
||||||
|
|
||||||
if (operationRecode == null)
|
if (operationRecord == null)
|
||||||
{
|
{
|
||||||
apiResult.Code = "9989";
|
apiResult.Code = "9989";
|
||||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
operationRecodeFile = await operationRepository.GetOneOperationRecodeFileAsync(post.SelectedId);
|
operationRecordFile = await operationRepository.GetOneOperationRecordFileAsync(post.SelectedId);
|
||||||
|
|
||||||
if (operationRecodeFile == null)
|
if (operationRecordFile == null)
|
||||||
{
|
{
|
||||||
apiResult.Code = "9987";
|
apiResult.Code = "9987";
|
||||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
await operationRepository.DeleteOneOperationRecodeFile(post.SelectedId);
|
await operationRepository.DeleteOneOperationRecordFile(post.SelectedId);
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Msg = "刪除成功";
|
apiResult.Msg = "刪除成功";
|
||||||
@ -829,11 +916,11 @@ namespace SolarPower.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ApiResult<List<OperationRecodeDataTable>>> ExportOperationRecodeExcel(PostOperationRecodeFilter post)
|
public async Task<ApiResult<List<OperationRecordDataTable>>> ExportOperationRecordExcel(PostOperationRecordFilter post)
|
||||||
{
|
{
|
||||||
ApiResult<List<OperationRecodeDataTable>> apiResult = new ApiResult<List<OperationRecodeDataTable>>();
|
ApiResult<List<OperationRecordDataTable>> apiResult = new ApiResult<List<OperationRecordDataTable>>();
|
||||||
|
|
||||||
List<OperationRecodeDataTable> recodes = null;
|
List<OperationRecordDataTable> records = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -843,32 +930,32 @@ namespace SolarPower.Controllers
|
|||||||
// post.SelectedCompanyId = myUser.CompanyId;
|
// post.SelectedCompanyId = myUser.CompanyId;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
recodes = await operationRepository.GetAllRecodeByFilterAsync(post);
|
records = await operationRepository.GetAllRecordByFilterAsync(post);
|
||||||
|
|
||||||
foreach (var recode in recodes)
|
foreach (var record in records)
|
||||||
{
|
{
|
||||||
recode.PowerStationName = !string.IsNullOrEmpty(recode.PowerStationName) ? recode.PowerStationName : "";
|
record.PowerStationName = !string.IsNullOrEmpty(record.PowerStationName) ? record.PowerStationName : "";
|
||||||
recode.FormId = !string.IsNullOrEmpty(recode.FormId) ? recode.FormId : "";
|
record.FormId = !string.IsNullOrEmpty(record.FormId) ? record.FormId : "";
|
||||||
recode.FixDo = !string.IsNullOrEmpty(recode.FixDo) ? recode.FixDo : "";
|
record.FixDo = !string.IsNullOrEmpty(record.FixDo) ? record.FixDo : "";
|
||||||
recode.WorkPersonName = !string.IsNullOrEmpty(recode.WorkPersonName) ? recode.WorkPersonName : "";
|
record.WorkPersonName = !string.IsNullOrEmpty(record.WorkPersonName) ? record.WorkPersonName : "";
|
||||||
//recode.FinishTime = !string.IsNullOrEmpty(recode.FinishTime) ? recode.FinishTime : "";
|
//record.FinishTime = !string.IsNullOrEmpty(record.FinishTime) ? record.FinishTime : "";
|
||||||
|
|
||||||
if (recode.RecodeFiles != null && recode.RecodeFiles.Count > 0)
|
if (record.RecordFiles != null && record.RecordFiles.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var file in recode.RecodeFiles)
|
foreach (var file in record.RecordFiles)
|
||||||
{
|
{
|
||||||
var hyperLink = "<a href='" + baseURL + file.FileName + "'>" + file.FileName + "</a>";
|
var hyperLink = "<a href='" + baseURL + file.FileName + "'>" + file.FileName + "</a>";
|
||||||
if(recode.HyperLinks == null)
|
if (record.HyperLinks == null)
|
||||||
{
|
{
|
||||||
recode.HyperLinks = new List<string>();
|
record.HyperLinks = new List<string>();
|
||||||
}
|
}
|
||||||
recode.HyperLinks.Add(hyperLink);
|
record.HyperLinks.Add(hyperLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = recodes;
|
apiResult.Data = records;
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -882,18 +969,19 @@ namespace SolarPower.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void Schedule ()
|
public async void Schedule()
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
var getTime = await operationRepository.GetOperationSchedules();
|
var getTime = await operationRepository.GetOperationSchedules();
|
||||||
foreach(OperationCreatePlanModal a in getTime)
|
foreach (OperationCreatePlanModal a in getTime)
|
||||||
{
|
{
|
||||||
DateTime Updatedtime;
|
DateTime Updatedtime;
|
||||||
if (a.ScheduleType == 0)//日
|
if (a.ScheduleType == 0)//日
|
||||||
{
|
{
|
||||||
Updatedtime = Convert.ToDateTime(a.StartTime).AddDays(a.ScheduleNum);
|
Updatedtime = Convert.ToDateTime(a.StartTime).AddDays(a.ScheduleNum);
|
||||||
}
|
}
|
||||||
else if(a.ScheduleType == 1)//周
|
else if (a.ScheduleType == 1)//周
|
||||||
{
|
{
|
||||||
Updatedtime = Convert.ToDateTime(a.StartTime).AddDays(a.ScheduleNum * 7);
|
Updatedtime = Convert.ToDateTime(a.StartTime).AddDays(a.ScheduleNum * 7);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace SolarPower.Models
|
namespace SolarPower.Models
|
||||||
{
|
{
|
||||||
public enum OperationRecodeStatusEnum : byte
|
public enum OperationRecordStatusEnum : byte
|
||||||
{
|
{
|
||||||
NoneComplete = 0, //未完成
|
NoneComplete = 0, //未完成
|
||||||
Complete = 1, //完成
|
Complete = 1, //完成
|
||||||
@ -14,7 +14,7 @@ namespace SolarPower.Models
|
|||||||
CompleteExpired = 3, //完成-過期
|
CompleteExpired = 3, //完成-過期
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum OperationRecodeWorkTypeEnum : byte
|
public enum OperationRecordWorkTypeEnum : byte
|
||||||
{
|
{
|
||||||
Clearn = 0, //清潔
|
Clearn = 0, //清潔
|
||||||
Inspection = 1, //巡檢
|
Inspection = 1, //巡檢
|
||||||
@ -123,7 +123,7 @@ namespace SolarPower.Models
|
|||||||
public string EndTime { get; set; }
|
public string EndTime { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OperationRecode : Created
|
public class OperationRecord : Created
|
||||||
{
|
{
|
||||||
private string startTime, endTime, finishTime, workTime;
|
private string startTime, endTime, finishTime, workTime;
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
@ -136,7 +136,7 @@ namespace SolarPower.Models
|
|||||||
public string FixDo { get; set; }
|
public string FixDo { get; set; }
|
||||||
public byte FixFirm { get; set; }
|
public byte FixFirm { get; set; }
|
||||||
public byte Status { get; set; }
|
public byte Status { get; set; }
|
||||||
public int WorkPersonId { get; set; }
|
public List<int> WorkPersonIds { get; set; }
|
||||||
public string StartTime
|
public string StartTime
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -199,10 +199,10 @@ namespace SolarPower.Models
|
|||||||
} // 工作時間
|
} // 工作時間
|
||||||
public string Notice { get; set; }
|
public string Notice { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public List<OperationRecodeFile> RecodeFiles { get; set; }
|
public List<OperationRecordFile> RecordFiles { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OperationRecodeFile : Created
|
public class OperationRecordFile : Created
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int RecordId { get; set; }
|
public int RecordId { get; set; }
|
||||||
@ -212,7 +212,7 @@ namespace SolarPower.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 運維作業記錄的搜尋條件
|
/// 運維作業記錄的搜尋條件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PostOperationRecodeFilter
|
public class PostOperationRecordFilter
|
||||||
{
|
{
|
||||||
public List<int> CityIds { get; set; } //縣市編號
|
public List<int> CityIds { get; set; } //縣市編號
|
||||||
public List<int> PowerStationIds { get; set; } //電站編號
|
public List<int> PowerStationIds { get; set; } //電站編號
|
||||||
@ -226,7 +226,7 @@ namespace SolarPower.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 運維作業記錄的表單
|
/// 運維作業記錄的表單
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OperationRecodeDataTable : OperationRecode
|
public class OperationRecordDataTable : OperationRecord
|
||||||
{
|
{
|
||||||
public string WorkTypeText
|
public string WorkTypeText
|
||||||
{
|
{
|
||||||
@ -275,7 +275,7 @@ namespace SolarPower.Models
|
|||||||
public List<string> HyperLinks { get; set; }
|
public List<string> HyperLinks { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PostOperationRecode
|
public class PostOperationRecord
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int PowerStationId { get; set; }
|
public int PowerStationId { get; set; }
|
||||||
@ -284,17 +284,17 @@ namespace SolarPower.Models
|
|||||||
public string FixDo { get; set; }
|
public string FixDo { get; set; }
|
||||||
public byte FixFirm { get; set; }
|
public byte FixFirm { get; set; }
|
||||||
public byte Status { get; set; }
|
public byte Status { get; set; }
|
||||||
public int WorkPersonId { get; set; }
|
public List<int> WorkPersonIds { get; set; }
|
||||||
public string StartTime { get; set; }//開始時間
|
public string StartTime { get; set; }//開始時間
|
||||||
public string EndTime { get; set; } // 結束時間
|
public string EndTime { get; set; } // 結束時間
|
||||||
public string FinishTime { get; set; } // 完成時間
|
public string FinishTime { get; set; } // 完成時間
|
||||||
public string WorkTime { get; set; } // 工作時間
|
public string WorkTime { get; set; } // 工作時間
|
||||||
public string Notice { get; set; }
|
public string Notice { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public IFormFile[] RecodeFiles { get; set; }
|
public IFormFile[] RecordFiles { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UpdateOperationRecode : Updated
|
public class UpdateOperationRecord : Updated
|
||||||
{
|
{
|
||||||
public string FormId { get; set; }
|
public string FormId { get; set; }
|
||||||
public string SerialNumber { get; set; }
|
public string SerialNumber { get; set; }
|
||||||
@ -312,7 +312,7 @@ namespace SolarPower.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 針對運維作業記錄檔案
|
/// 針對運維作業記錄檔案
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PostOperationRecodeIdAndSelectedId
|
public class PostOperationRecordIdAndSelectedId
|
||||||
{
|
{
|
||||||
public int ReocdeId { get; set; }
|
public int ReocdeId { get; set; }
|
||||||
public int SelectedId { get; set; }
|
public int SelectedId { get; set; }
|
||||||
@ -327,4 +327,12 @@ namespace SolarPower.Models
|
|||||||
public string StartTime { get { return Convert.ToDateTime(startTime).ToString("yyyy-MM-dd HH:mm:ss"); } set { startTime = value; } } //修改時間
|
public string StartTime { get { return Convert.ToDateTime(startTime).ToString("yyyy-MM-dd HH:mm:ss"); } set { startTime = value; } } //修改時間
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class OperationRecordPersonnel : Created
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public byte Deleted { get; set; }
|
||||||
|
public int OperationRecordId { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -198,9 +198,9 @@ namespace SolarPower.Repository.Implement
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<List<OperationRecodeDataTable>> GetAllRecodeByFilterAsync(PostOperationRecodeFilter filter)
|
public async Task<List<OperationRecordDataTable>> GetAllRecordByFilterAsync(PostOperationRecordFilter filter)
|
||||||
{
|
{
|
||||||
List<OperationRecodeDataTable> result;
|
List<OperationRecordDataTable> result;
|
||||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -266,7 +266,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
|
|
||||||
sql += " ) aa ORDER BY aa.CreatedAt DESC";
|
sql += " ) aa ORDER BY aa.CreatedAt DESC";
|
||||||
|
|
||||||
result = (await conn.QueryAsync<OperationRecodeDataTable>(sql,
|
result = (await conn.QueryAsync<OperationRecordDataTable>(sql,
|
||||||
new {
|
new {
|
||||||
PowerStationIds = filter.PowerStationIds,
|
PowerStationIds = filter.PowerStationIds,
|
||||||
WorkType = filter.WorkType,
|
WorkType = filter.WorkType,
|
||||||
@ -277,7 +277,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
var sql_file = "SELECT * FROM operation_record_file WHERE Deleted = 0 AND RecordId = @RecordId";
|
var sql_file = "SELECT * FROM operation_record_file WHERE Deleted = 0 AND RecordId = @RecordId";
|
||||||
foreach (var x in result)
|
foreach (var x in result)
|
||||||
{
|
{
|
||||||
x.RecodeFiles = (await conn.QueryAsync<OperationRecodeFile>(sql_file, new { RecordId = x.Id })).ToList();
|
x.RecordFiles = (await conn.QueryAsync<OperationRecordFile>(sql_file, new { RecordId = x.Id })).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
@ -293,9 +293,9 @@ namespace SolarPower.Repository.Implement
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<OperationRecode> GetOneOperationRecodeAsync(int id)
|
public async Task<OperationRecord> GetOneOperationRecordAsync(int id)
|
||||||
{
|
{
|
||||||
OperationRecode result;
|
OperationRecord result;
|
||||||
|
|
||||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
{
|
{
|
||||||
@ -307,15 +307,22 @@ namespace SolarPower.Repository.Implement
|
|||||||
LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id
|
LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id
|
||||||
WHERE opr.Deleted = 0 AND opr.Id = @Id";
|
WHERE opr.Deleted = 0 AND opr.Id = @Id";
|
||||||
|
|
||||||
result = await conn.QueryFirstOrDefaultAsync<OperationRecode>(sql, new { Id = id });
|
result = await conn.QueryFirstOrDefaultAsync<OperationRecord>(sql, new { Id = id });
|
||||||
|
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
//取得圖片 or 檔案
|
//取得圖片 or 檔案
|
||||||
var sql_file = @"SELECT * FROM operation_record_file WHERE Deleted = 0 AND RecordId = @RecordId";
|
var sql_file = @"SELECT * FROM operation_record_file WHERE Deleted = 0 AND RecordId = @RecordId";
|
||||||
|
|
||||||
result.RecodeFiles = (await conn.QueryAsync<OperationRecodeFile>(sql_file, new { RecordId = result.Id })).ToList();
|
result.RecordFiles = (await conn.QueryAsync<OperationRecordFile>(sql_file, new { RecordId = result.Id })).ToList();
|
||||||
|
|
||||||
|
//取得負責人員
|
||||||
|
var sql_operation_record_personnel = @"SELECT UserId FROM operation_record_personnel WHERE Deleted = 0 AND OperationRecordId = @OperationRecordId";
|
||||||
|
|
||||||
|
result.WorkPersonIds = (await conn.QueryAsync<int>(sql_operation_record_personnel, new { OperationRecordId = result.Id })).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -335,7 +342,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// <param name="properties"></param>
|
/// <param name="properties"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<int> AddOneOperationRecodeAsync(OperationRecode entity, List<string> properties)
|
public async Task<int> AddOneOperationRecordAsync(OperationRecord entity, List<string> properties)
|
||||||
{
|
{
|
||||||
var id = 0;
|
var id = 0;
|
||||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||||
@ -375,7 +382,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
/// <param name="properties"></param>
|
/// <param name="properties"></param>
|
||||||
/// <param name="db_name"></param>
|
/// <param name="db_name"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task UpdateOperationRecodeAsync(UpdateOperationRecode entity, List<string> properties)
|
public async Task UpdateOperationRecordAsync(UpdateOperationRecord entity, List<string> properties)
|
||||||
{
|
{
|
||||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
{
|
{
|
||||||
@ -402,7 +409,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteOneOperationRecodeAsync(int id)
|
public async Task DeleteOneOperationRecordAsync(int id)
|
||||||
{
|
{
|
||||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
{
|
{
|
||||||
@ -436,7 +443,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// <param name="properties"></param>
|
/// <param name="properties"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<int> AddOperationRecodeFilesAsync(List<OperationRecodeFile> entity, List<string> properties)
|
public async Task<int> AddOperationRecordFilesAsync(List<OperationRecordFile> entity, List<string> properties)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||||
@ -466,9 +473,9 @@ namespace SolarPower.Repository.Implement
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<OperationRecodeFile> GetOneOperationRecodeFileAsync(int id)
|
public async Task<OperationRecordFile> GetOneOperationRecordFileAsync(int id)
|
||||||
{
|
{
|
||||||
OperationRecodeFile result;
|
OperationRecordFile result;
|
||||||
|
|
||||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
{
|
{
|
||||||
@ -479,7 +486,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
FROM operation_record_file
|
FROM operation_record_file
|
||||||
WHERE Deleted = 0 AND Id = @Id";
|
WHERE Deleted = 0 AND Id = @Id";
|
||||||
|
|
||||||
result = await conn.QueryFirstOrDefaultAsync<OperationRecodeFile>(sql, new { Id = id });
|
result = await conn.QueryFirstOrDefaultAsync<OperationRecordFile>(sql, new { Id = id });
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -498,7 +505,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task DeleteOneOperationRecodeFile(int id)
|
public async Task DeleteOneOperationRecordFile(int id)
|
||||||
{
|
{
|
||||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
{
|
{
|
||||||
@ -598,5 +605,82 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task AddOperationRecordPersonnelAsync(List<OperationRecordPersonnel> entity, List<string> properties)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = GenerateInsertQueryWithCustomTable(properties, "operation_record_personnel");
|
||||||
|
|
||||||
|
count = await conn.ExecuteAsync(sql, entity);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
//return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<int>> GetOperationRecordPersonnelIdsByOperationRecordId(int operationRecordId)
|
||||||
|
{
|
||||||
|
List<int> result;
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = @$"SELECT UserId FROM operation_record_personnel WHERE Deleted = 0 AND OperationRecordId = @OperationRecordId";
|
||||||
|
|
||||||
|
result = (await conn.QueryAsync<int>(sql, new { OperationRecordId = operationRecordId })).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteOperationRecordPersonnel(List<OperationRecordPersonnel> operationPersonnels)
|
||||||
|
{
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
using (var trans = conn.BeginTransaction())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = $"UPDATE operation_record_personnel SET Deleted = 1 WHERE OperationRecordId = @OperationRecordId AND UserId = @UserId";
|
||||||
|
|
||||||
|
await conn.ExecuteAsync(sql, operationPersonnels, trans);
|
||||||
|
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
trans.Rollback();
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4184,7 +4184,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
sql = string.Join(" UNION ", sql_perSiteDB);
|
sql = string.Join(" UNION ", sql_perSiteDB);
|
||||||
sql = "(" + sql + ") ORDER BY Priority";
|
sql = "(" + sql + ") ORDER BY c.Priority, inv.CreatedAt";
|
||||||
|
|
||||||
result = (await conn.QueryAsync<PowerStationInverter>(sql, new { Filter = filter })).ToList();
|
result = (await conn.QueryAsync<PowerStationInverter>(sql, new { Filter = filter })).ToList();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,14 +21,14 @@ namespace SolarPower.Repository.Interface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<OperationRecodeDataTable>> GetAllRecodeByFilterAsync(PostOperationRecodeFilter filter);
|
Task<List<OperationRecordDataTable>> GetAllRecordByFilterAsync(PostOperationRecordFilter filter);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 透過Id,取得單一筆運維作業記錄
|
/// 透過Id,取得單一筆運維作業記錄
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<OperationRecode> GetOneOperationRecodeAsync(int id);
|
Task<OperationRecord> GetOneOperationRecordAsync(int id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新增一筆運維作業記錄
|
/// 新增一筆運維作業記錄
|
||||||
@ -36,7 +36,7 @@ namespace SolarPower.Repository.Interface
|
|||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// <param name="properties"></param>
|
/// <param name="properties"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> AddOneOperationRecodeAsync(OperationRecode entity, List<string> properties);
|
Task<int> AddOneOperationRecordAsync(OperationRecord entity, List<string> properties);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修改運維作業記錄
|
/// 修改運維作業記錄
|
||||||
@ -44,7 +44,7 @@ namespace SolarPower.Repository.Interface
|
|||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// <param name="properties"></param>
|
/// <param name="properties"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task UpdateOperationRecodeAsync(UpdateOperationRecode entity, List<string> properties);
|
Task UpdateOperationRecordAsync(UpdateOperationRecord entity, List<string> properties);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新增運維作業記錄的檔案
|
/// 新增運維作業記錄的檔案
|
||||||
@ -52,29 +52,35 @@ namespace SolarPower.Repository.Interface
|
|||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// <param name="properties"></param>
|
/// <param name="properties"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> AddOperationRecodeFilesAsync(List<OperationRecodeFile> entity, List<string> properties);
|
Task<int> AddOperationRecordFilesAsync(List<OperationRecordFile> entity, List<string> properties);
|
||||||
|
|
||||||
Task DeleteOneOperationRecodeAsync(int id);
|
Task DeleteOneOperationRecordAsync(int id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 透過Id,取得單一運維作業記錄檔案
|
/// 透過Id,取得單一運維作業記錄檔案
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<OperationRecodeFile> GetOneOperationRecodeFileAsync(int id);
|
Task<OperationRecordFile> GetOneOperationRecordFileAsync(int id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 透過Id,軟刪除運維作業記錄檔案
|
/// 透過Id,軟刪除運維作業記錄檔案
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task DeleteOneOperationRecodeFile(int id);
|
Task DeleteOneOperationRecordFile(int id);
|
||||||
|
|
||||||
Task<List<OperationCreatePlan>> GetOperationSchedules();
|
Task<List<OperationCreatePlan>> GetOperationSchedules();
|
||||||
|
|
||||||
Task<List<MyUser>> GetOperationPersonnel(int PowerStationId);
|
Task<List<MyUser>> GetOperationPersonnel(int PowerStationId);
|
||||||
|
|
||||||
Task InsertNoticeSchedule(List<MyUser> personal, string Title, string content);
|
Task InsertNoticeSchedule(List<MyUser> personal, string Title, string content);
|
||||||
|
|
||||||
|
Task AddOperationRecordPersonnelAsync(List<OperationRecordPersonnel> entity, List<string> properties);
|
||||||
|
|
||||||
|
Task<List<int>> GetOperationRecordPersonnelIdsByOperationRecordId(int operationRecordId);
|
||||||
|
|
||||||
|
Task DeleteOperationRecordPersonnel(List<OperationRecordPersonnel> operationRecordPersonnels);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -403,9 +403,9 @@
|
|||||||
|
|
||||||
$('#js_list_accordion').on("change", 'input[name="selectedInverterLayer2[]"]', function (event) {
|
$('#js_list_accordion').on("change", 'input[name="selectedInverterLayer2[]"]', function (event) {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
$(this).parents(".list-group-item").find('input[name="selectedInverterId[]"]').prop("checked", true).trigger("change");
|
$(this).parents(".selected_group").find('input[name="selectedInverterId[]"]').prop("checked", true).trigger("change");
|
||||||
} else {
|
} else {
|
||||||
$(this).parents(".list-group-item").find('input[name="selectedInverterId[]"]').prop("checked", false).trigger("change");
|
$(this).parents(".selected_group").find('input[name="selectedInverterId[]"]').prop("checked", false).trigger("change");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -435,6 +435,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("default_compare_col", default_compare_col)
|
||||||
|
|
||||||
ReloadHighCharts();
|
ReloadHighCharts();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -79,13 +79,13 @@
|
|||||||
<span class="fal fa-file-excel mr-1"></span>
|
<span class="fal fa-file-excel mr-1"></span>
|
||||||
匯出
|
匯出
|
||||||
</button>
|
</button>
|
||||||
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3 mr-2" onclick="AddRecode()">
|
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3 mr-2" onclick="AddRecord()">
|
||||||
<span class="fal fa-plus mr-1"></span>
|
<span class="fal fa-plus mr-1"></span>
|
||||||
維修單
|
維修單
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="frame-wrap">
|
<div class="frame-wrap">
|
||||||
<table id="operation_recode_table" class="table table-bordered table-hover m-0 text-center">
|
<table id="operation_record_table" class="table table-bordered table-hover m-0 text-center">
|
||||||
<thead class="thead-themed">
|
<thead class="thead-themed">
|
||||||
<tr>
|
<tr>
|
||||||
<th>電廠</th>
|
<th>電廠</th>
|
||||||
@ -130,7 +130,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal fade" id="recode-form-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
<div class="modal fade" id="record-form-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
||||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
@ -142,7 +142,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form id="recode-form">
|
<form id="record-form">
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -176,9 +176,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<div class="form-group">
|
<div class="">
|
||||||
<label class="form-label" for="work_person_select_modal">執行人員</label>
|
<label class="form-label" for="work_person_select_modal">執行人員</label>
|
||||||
<select class="form-control" id="work_person_select_modal">
|
<select class="form-control" id="work_person_select_modal" multiple="multiple">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -231,14 +231,14 @@
|
|||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<p>檔案上傳</p>
|
<p>檔案上傳</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="recode_files_div" class="col-10">
|
<div id="record_files_div" class="col-10">
|
||||||
<div class="row px-3 mb-3 d-flex justify-content-start align-items-center img-zoom-div">
|
<div class="row px-3 mb-3 d-flex justify-content-start align-items-center img-zoom-div">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row px-3">
|
<div class="row px-3">
|
||||||
<form id="recode-file-form" class="dropzone needsclick dz-clickable col-12" style="min-height: 7rem;">
|
<form id="record-file-form" class="dropzone needsclick dz-clickable col-12" style="min-height: 7rem;">
|
||||||
@*<div class="fallback">
|
@*<div class="fallback">
|
||||||
<input type="file" multiple />
|
<input type="file" multiple />
|
||||||
</div>*@
|
</div>*@
|
||||||
@ -253,7 +253,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||||
<button type="button" class="btn btn-primary" id="save-recode-btn" onclick="SaveRecode()">確定</button>
|
<button type="button" class="btn btn-primary" id="save-record-btn" onclick="SaveRecord()">確定</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -261,11 +261,11 @@
|
|||||||
|
|
||||||
@section Scripts{
|
@section Scripts{
|
||||||
<script>
|
<script>
|
||||||
var operationRecodeTable;
|
var operationRecordTable;
|
||||||
var selected_id = 0; var selected_work_type = -1;
|
var selected_id = 0; var selected_work_type = -1;
|
||||||
var recode;
|
var record;
|
||||||
var countOperationRecodeFile = 0;
|
var countOperationRecordFile = 0;
|
||||||
var recodeFileDropzone;
|
var recordFileDropzone;
|
||||||
var ids = new Array(0);//當前選擇縣市
|
var ids = new Array(0);//當前選擇縣市
|
||||||
var powerids = new Array(0);//當前選擇電站
|
var powerids = new Array(0);//當前選擇電站
|
||||||
var Allids = new Array(0);//全部縣市
|
var Allids = new Array(0);//全部縣市
|
||||||
@ -354,7 +354,7 @@
|
|||||||
$("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change');
|
$("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change');
|
||||||
|
|
||||||
$('#Allcity').trigger("click");
|
$('#Allcity').trigger("click");
|
||||||
operationRecodeTable.ajax.reload();
|
operationRecordTable.ajax.reload();
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -383,10 +383,14 @@
|
|||||||
$("#work_person_select_modal").append($("<option />").val(val.value).text(val.text));
|
$("#work_person_select_modal").append($("<option />").val(val.value).text(val.text));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (recode != null || recode != undefined) {
|
if (record != null || record != undefined) {
|
||||||
$("#work_person_select_modal").val(recode.workPersonId);
|
$("#work_person_select_modal").val(record.workPersonIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$("#work_person_select_modal").select2({ dropdownParent: $('#record-form-modal') });
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//查詢該電站的廠商
|
//查詢該電站的廠商
|
||||||
@ -407,12 +411,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$("#fix_firm_select_modal").val($("#fix_firm_select_modal option:first").val()).trigger('change');
|
$("#fix_firm_select_modal").val($("#fix_firm_select_modal option:first").val()).trigger('change');
|
||||||
|
|
||||||
|
if (record != undefined && record != null) {
|
||||||
|
$("#fix_firm_select_modal").val(record.fixFirm)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 運維作業記錄 DataTable
|
//#region 運維作業記錄 DataTable
|
||||||
operationRecodeTable = $("#operation_recode_table").DataTable({
|
operationRecordTable = $("#operation_record_table").DataTable({
|
||||||
"pageLength": 20,
|
"pageLength": 20,
|
||||||
"paging": true,
|
"paging": true,
|
||||||
"lengthChange": false,
|
"lengthChange": false,
|
||||||
@ -437,7 +445,7 @@
|
|||||||
}, {
|
}, {
|
||||||
"data": "operationPredict"
|
"data": "operationPredict"
|
||||||
}, {
|
}, {
|
||||||
"data": "recodeFiles"
|
"data": "recordFiles"
|
||||||
}, {
|
}, {
|
||||||
"data": "finishTime"
|
"data": "finishTime"
|
||||||
},{
|
},{
|
||||||
@ -457,7 +465,7 @@
|
|||||||
|
|
||||||
if (cellData != null) {
|
if (cellData != null) {
|
||||||
cellData.forEach(function (value, index) {
|
cellData.forEach(function (value, index) {
|
||||||
CreateRecodeFileBox($(td).children(".row"), value, false);
|
CreateRecordFileBox($(td).children(".row"), value, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -492,7 +500,7 @@
|
|||||||
$(row).attr('data-work-type', data.workType);
|
$(row).attr('data-work-type', data.workType);
|
||||||
},
|
},
|
||||||
"ajax": {
|
"ajax": {
|
||||||
"url": "/Operation/OperationRecodeList",
|
"url": "/Operation/OperationRecordList",
|
||||||
"type": "POST",
|
"type": "POST",
|
||||||
"data": function (d) {
|
"data": function (d) {
|
||||||
d.PowerStationIds = powerids;
|
d.PowerStationIds = powerids;
|
||||||
@ -544,29 +552,29 @@
|
|||||||
document.getElementById(name).setAttribute("class", "btn btn-secondary waves-effect waves-themed");
|
document.getElementById(name).setAttribute("class", "btn btn-secondary waves-effect waves-themed");
|
||||||
}
|
}
|
||||||
document.getElementById("button" + type).setAttribute("class", "btn btn-success waves-effect waves-themed");
|
document.getElementById("button" + type).setAttribute("class", "btn btn-success waves-effect waves-themed");
|
||||||
operationRecodeTable.ajax.reload();
|
operationRecordTable.ajax.reload();
|
||||||
|
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 改變日期
|
//#region 改變日期
|
||||||
$('#date-range').on('change', function () {
|
$('#date-range').on('change', function () {
|
||||||
operationRecodeTable.ajax.reload();
|
operationRecordTable.ajax.reload();
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 新增維修單
|
//#region 新增維修單
|
||||||
function AddRecode() {
|
function AddRecord() {
|
||||||
selected_id = 0;
|
selected_id = 0;
|
||||||
$("#recode-form-modal .modal-title .main-title").html("維修單");
|
$("#record-form-modal .modal-title .main-title").html("維修單");
|
||||||
$("#recode-form-modal .modal-title .sub-title").html("");
|
$("#record-form-modal .modal-title .sub-title").html("");
|
||||||
$("#power_station_select_modal").attr("disabled", false);
|
$("#power_station_select_modal").attr("disabled", false);
|
||||||
$(".fix-div").show();
|
$(".fix-div").show();
|
||||||
$("#recode-form").trigger("reset");
|
$("#record-form").trigger("reset");
|
||||||
$("input[name=status_modal][value='" + 0 + "']").prop('checked', true); //狀態
|
$("input[name=status_modal][value='" + 0 + "']").prop('checked', true); //狀態
|
||||||
$("#recode_files_div > .row").empty();
|
$("#record_files_div > .row").empty();
|
||||||
|
|
||||||
$("#recode-form-modal").modal();
|
$("#record-form-modal").modal();
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
@ -621,7 +629,7 @@
|
|||||||
powerids = [];
|
powerids = [];
|
||||||
powerids = Newpowerids;
|
powerids = Newpowerids;
|
||||||
})
|
})
|
||||||
operationRecodeTable.ajax.reload();
|
operationRecordTable.ajax.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
function Allcity2() {
|
function Allcity2() {
|
||||||
@ -691,7 +699,7 @@
|
|||||||
powerids = [];
|
powerids = [];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
operationRecodeTable.ajax.reload();
|
operationRecordTable.ajax.reload();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
@ -714,7 +722,7 @@
|
|||||||
powerids = [];
|
powerids = [];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
operationRecodeTable.ajax.reload();
|
operationRecordTable.ajax.reload();
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
@ -764,7 +772,7 @@
|
|||||||
powerids = [];
|
powerids = [];
|
||||||
powerids = Newpowerids;
|
powerids = Newpowerids;
|
||||||
})
|
})
|
||||||
operationRecodeTable.ajax.reload();
|
operationRecordTable.ajax.reload();
|
||||||
})
|
})
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
@ -779,35 +787,35 @@
|
|||||||
else {
|
else {
|
||||||
powerids.remove(classid[1]);
|
powerids.remove(classid[1]);
|
||||||
}
|
}
|
||||||
operationRecodeTable.ajax.reload();
|
operationRecordTable.ajax.reload();
|
||||||
})
|
})
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 點擊圖片放大
|
//#region 點擊圖片放大
|
||||||
$('#operation_recode_table').on("click", "img.img-zoom", function () {
|
$('#operation_record_table').on("click", "img.img-zoom", function () {
|
||||||
var _this = $(this);//將當前的pimg元素作為_this傳入函式
|
var _this = $(this);//將當前的pimg元素作為_this傳入函式
|
||||||
imgShow("#img-zoom-outer-div", "#innerdiv", "#bigimg", _this);
|
imgShow("#img-zoom-outer-div", "#innerdiv", "#bigimg", _this);
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 編輯表單內容
|
//#region 編輯表單內容
|
||||||
$('#operation_recode_table').on("click", "a.edit-btn", function () {
|
$('#operation_record_table').on("click", "a.edit-btn", function () {
|
||||||
|
|
||||||
work_type = $(this).parents('tr').attr('data-work-type');
|
work_type = $(this).parents('tr').attr('data-work-type');
|
||||||
|
|
||||||
if (work_type == 0) {
|
if (work_type == 0) {
|
||||||
$("#recode-form-modal .modal-title .main-title").html("清洗單 - ");
|
$("#record-form-modal .modal-title .main-title").html("清洗單 - ");
|
||||||
} else if (work_type == 1) {
|
} else if (work_type == 1) {
|
||||||
$("#recode-form-modal .modal-title .main-title").html("巡檢單 - ");
|
$("#record-form-modal .modal-title .main-title").html("巡檢單 - ");
|
||||||
} else {
|
} else {
|
||||||
$("#recode-form-modal .modal-title .main-title").html("維修單 - ");
|
$("#record-form-modal .modal-title .main-title").html("維修單 - ");
|
||||||
}
|
}
|
||||||
|
|
||||||
selected_id = $(this).parents('tr').attr('data-id');
|
selected_id = $(this).parents('tr').attr('data-id');
|
||||||
|
|
||||||
//取得單一記錄表單
|
//取得單一記錄表單
|
||||||
var url = "/Operation/GetOneOperationRecode/";
|
var url = "/Operation/GetOneOperationRecord/";
|
||||||
|
|
||||||
var send_data = {
|
var send_data = {
|
||||||
id: selected_id
|
id: selected_id
|
||||||
@ -819,62 +827,67 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
recode = rel.data;
|
record = rel.data;
|
||||||
|
|
||||||
countOperationRecodeFile = recode.recodeFiles.length;
|
countOperationRecordFile = record.recordFiles.length;
|
||||||
|
|
||||||
$("#recode-form-modal .modal-title .sub-title").html(recode.powerStationName);
|
$("#record-form-modal .modal-title .sub-title").html(record.powerStationName);
|
||||||
|
|
||||||
$("#power_station_select_modal").val(recode.powerStationId).trigger('change');
|
$("#power_station_select_modal").val(record.powerStationId).trigger('change');
|
||||||
$("#power_station_select_modal").attr("disabled", true);
|
$("#power_station_select_modal").attr("disabled", true);
|
||||||
|
|
||||||
$("#work_time_modal").val(recode.workTime);
|
$("#work_time_modal").val(record.workTime);
|
||||||
var status = -1;
|
var status = -1;
|
||||||
if (recode.status == 0 || recode.status == 2) {
|
if (record.status == 0 || record.status == 2) {
|
||||||
status = 0;
|
status = 0;
|
||||||
} else if (recode.status == 1 || recode.status == 3) {
|
} else if (record.status == 1 || record.status == 3) {
|
||||||
status = 1;
|
status = 1;
|
||||||
}
|
}
|
||||||
$("input[name=status_modal][value='" + status + "']").prop('checked', true); //狀態
|
$("input[name=status_modal][value='" + status + "']").prop('checked', true); //狀態
|
||||||
$('#work_person_select_modal').val(recode.workPersonId);
|
$('#work_person_select_modal').val(record.workPersonIds).trigger("change");
|
||||||
if (work_type != 2) {
|
if (work_type != 2) {
|
||||||
$(".fix-div").hide();
|
$(".fix-div").hide();
|
||||||
} else {
|
} else {
|
||||||
$(".fix-div").show();
|
$(".fix-div").show();
|
||||||
$("#error_code_modal").val(recode.errorCode);
|
$("#error_code_modal").val(record.errorCode);
|
||||||
$("#fix_do_modal").val(recode.fixDo);
|
$("#fix_do_modal").val(record.fixDo);
|
||||||
}
|
}
|
||||||
$("#notice_textarea_modal").val(recode.notice);
|
$("#fix_firm_select_modal").val(record.fixFirm).trigger("change");
|
||||||
$("#description_textarea_modal").val(recode.description);
|
$("#notice_textarea_modal").val(record.notice);
|
||||||
|
$("#description_textarea_modal").val(record.description);
|
||||||
|
|
||||||
var str = "";
|
var str = "";
|
||||||
|
|
||||||
RecodeFileBox = $("#recode_files_div > .row");
|
RecordFileBox = $("#record_files_div > .row");
|
||||||
RecodeFileBox.empty();
|
RecordFileBox.empty();
|
||||||
recode.recodeFiles.forEach(function (value, index) {
|
record.recordFiles.forEach(function (value, index) {
|
||||||
CreateRecodeFileBox(RecodeFileBox, value, true);
|
CreateRecordFileBox(RecordFileBox, value, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#recode-form-modal").modal();
|
$("#record-form-modal").modal();
|
||||||
}, 'json');
|
}, 'json');
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 表單驗證
|
//#region 表單驗證
|
||||||
$("#recode-form").validate({
|
$("#record-form").validate({
|
||||||
rules: {
|
rules: {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 儲存表單資料
|
//#region 儲存表單資料
|
||||||
function SaveRecode() {
|
function SaveRecord() {
|
||||||
|
|
||||||
if ($("#recode-form").valid()) {
|
if ($("#record-form").valid()) {
|
||||||
var url = "/Operation/SaveOperationRecode";
|
var url = "/Operation/SaveOperationRecord";
|
||||||
|
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
|
|
||||||
|
@*var work_person_ids = $.map($("#work_person_select_modal").val(), function (item) {
|
||||||
|
return parseInt(item);
|
||||||
|
})*@
|
||||||
|
|
||||||
formData.append("Id", selected_id);
|
formData.append("Id", selected_id);
|
||||||
formData.append("PowerStationId", $("#power_station_select_modal").val());
|
formData.append("PowerStationId", $("#power_station_select_modal").val());
|
||||||
formData.append("WorkType", selected_work_type);
|
formData.append("WorkType", selected_work_type);
|
||||||
@ -882,7 +895,9 @@
|
|||||||
formData.append("FixDo", $("#fix_do_modal").val());
|
formData.append("FixDo", $("#fix_do_modal").val());
|
||||||
formData.append("FixFirm", $("#fix_firm_select_modal").val());
|
formData.append("FixFirm", $("#fix_firm_select_modal").val());
|
||||||
formData.append("Status", $("input[name=status_modal]:checked").val());
|
formData.append("Status", $("input[name=status_modal]:checked").val());
|
||||||
formData.append("WorkPersonId", $("#work_person_select_modal").val());
|
$("#work_person_select_modal").val().forEach(function (item) {
|
||||||
|
formData.append("WorkPersonIds", parseInt(item));
|
||||||
|
});
|
||||||
formData.append("WorkTime", $("#work_time_modal").val());
|
formData.append("WorkTime", $("#work_time_modal").val());
|
||||||
formData.append("Notice", $("#notice_textarea_modal").val());
|
formData.append("Notice", $("#notice_textarea_modal").val());
|
||||||
formData.append("Description", $("#description_textarea_modal").val());
|
formData.append("Description", $("#description_textarea_modal").val());
|
||||||
@ -900,7 +915,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var myDropzone = Dropzone.forElement("#recode-file-form");
|
var myDropzone = Dropzone.forElement("#record-file-form");
|
||||||
|
|
||||||
if (myDropzone.files.length > 0) {
|
if (myDropzone.files.length > 0) {
|
||||||
|
|
||||||
@ -915,16 +930,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
toast_ok(rel.msg);
|
toast_ok(rel.msg);
|
||||||
$('#recode-form-modal').modal('hide');
|
$('#record-form-modal').modal('hide');
|
||||||
recodeFileDropzone.removeAllFiles();
|
recordFileDropzone.removeAllFiles();
|
||||||
|
|
||||||
operationRecodeTable.ajax.reload();
|
operationRecordTable.ajax.reload();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$('#recode-form-modal').modal('hide');
|
$('#record-form-modal').modal('hide');
|
||||||
myDropzone.removeAllFiles();
|
myDropzone.removeAllFiles();
|
||||||
|
|
||||||
operationRecodeTable.ajax.reload();
|
operationRecordTable.ajax.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -933,7 +948,7 @@
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 刪除公司
|
//#region 刪除公司
|
||||||
$('#operation_recode_table').on("click", "button.del-btn", function () {
|
$('#operation_record_table').on("click", "button.del-btn", function () {
|
||||||
|
|
||||||
selected_id = $(this).parents('tr').attr('data-id');
|
selected_id = $(this).parents('tr').attr('data-id');
|
||||||
Swal.fire(
|
Swal.fire(
|
||||||
@ -948,7 +963,7 @@
|
|||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
if (result.value) {
|
if (result.value) {
|
||||||
//刪除單一運維紀錄
|
//刪除單一運維紀錄
|
||||||
var url = "/Operation/DeleteOneOperationRecode/";
|
var url = "/Operation/DeleteOneOperationRecord/";
|
||||||
var send_data = {
|
var send_data = {
|
||||||
Id: selected_id
|
Id: selected_id
|
||||||
}
|
}
|
||||||
@ -963,7 +978,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
toast_ok(rel.msg);
|
toast_ok(rel.msg);
|
||||||
operationRecodeTable.ajax.reload();
|
operationRecordTable.ajax.reload();
|
||||||
}, 'json');
|
}, 'json');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -993,8 +1008,8 @@
|
|||||||
|
|
||||||
//#region 表單檔案資料
|
//#region 表單檔案資料
|
||||||
Dropzone.autoDiscover = false;
|
Dropzone.autoDiscover = false;
|
||||||
recodeFileDropzone = new Dropzone("#recode-file-form", {
|
recordFileDropzone = new Dropzone("#record-file-form", {
|
||||||
url: "/Operation/SaveOperationRecodeFile",
|
url: "/Operation/SaveOperationRecordFile",
|
||||||
acceptedFiles: "image/*, application/pdf,.doc,.docx,.xls,.xlsx",
|
acceptedFiles: "image/*, application/pdf,.doc,.docx,.xls,.xlsx",
|
||||||
autoProcessQueue: false,
|
autoProcessQueue: false,
|
||||||
parallelUploads: 5,
|
parallelUploads: 5,
|
||||||
@ -1007,14 +1022,14 @@
|
|||||||
var myDropzone = this;
|
var myDropzone = this;
|
||||||
|
|
||||||
myDropzone.on("sending", function (file, xhr, data) {
|
myDropzone.on("sending", function (file, xhr, data) {
|
||||||
if ((countOperationRecodeFile + myDropzone.files.length) > 5) {
|
if ((countOperationRecordFile + myDropzone.files.length) > 5) {
|
||||||
toast_warning("檔案總數量不可超過 5 張");
|
toast_warning("檔案總數量不可超過 5 張");
|
||||||
myDropzone.removeFile(file);
|
myDropzone.removeFile(file);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
data.append("Id", selected_id);
|
data.append("Id", selected_id);
|
||||||
data.append("RecodeFiles", file);
|
data.append("RecordFiles", file);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1024,7 +1039,7 @@
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 產生檔案html
|
//#region 產生檔案html
|
||||||
function CreateRecodeFileBox(dom, value, show_del_btn) {
|
function CreateRecordFileBox(dom, value, show_del_btn) {
|
||||||
var str = "";
|
var str = "";
|
||||||
str += '<div class="col-2 px-0 py-2 mx-2">';
|
str += '<div class="col-2 px-0 py-2 mx-2">';
|
||||||
var split = value.fileName.split(".");
|
var split = value.fileName.split(".");
|
||||||
@ -1041,7 +1056,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (show_del_btn) {
|
if (show_del_btn) {
|
||||||
str += '<a href="javascript:;" class="del-operation-recode-file-btn" data-id="' + value.id + '">';
|
str += '<a href="javascript:;" class="del-operation-record-file-btn" data-id="' + value.id + '">';
|
||||||
str += '<span class="badge border border-light rounded-pill bg-danger-500 position-absolute pos-top pos-right"><i class="fal fa-times"></i></span>';
|
str += '<span class="badge border border-light rounded-pill bg-danger-500 position-absolute pos-top pos-right"><i class="fal fa-times"></i></span>';
|
||||||
str += '</a>';
|
str += '</a>';
|
||||||
}
|
}
|
||||||
@ -1052,7 +1067,7 @@
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region 刪除檔案
|
//#region 刪除檔案
|
||||||
$('#recode_files_div').on("click", "a.del-operation-recode-file-btn", function () {
|
$('#record_files_div').on("click", "a.del-operation-record-file-btn", function () {
|
||||||
|
|
||||||
var selectedFileId = $(this).attr("data-id");
|
var selectedFileId = $(this).attr("data-id");
|
||||||
|
|
||||||
@ -1069,7 +1084,7 @@
|
|||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
if (result.value) {
|
if (result.value) {
|
||||||
|
|
||||||
var url = "/Operation/DeleteOperationRecodeFile";
|
var url = "/Operation/DeleteOperationRecordFile";
|
||||||
|
|
||||||
var send_data = {
|
var send_data = {
|
||||||
ReocdeId: selected_id,
|
ReocdeId: selected_id,
|
||||||
@ -1092,7 +1107,7 @@
|
|||||||
|
|
||||||
//#region 匯出excel
|
//#region 匯出excel
|
||||||
function ExportExcel() {
|
function ExportExcel() {
|
||||||
var url = "/Operation/ExportOperationRecodeExcel";
|
var url = "/Operation/ExportOperationRecordExcel";
|
||||||
var send_data = {
|
var send_data = {
|
||||||
CityIds: [3],
|
CityIds: [3],
|
||||||
PowerStationIds: [1]
|
PowerStationIds: [1]
|
||||||
@ -1172,7 +1187,7 @@
|
|||||||
$(".status-type").removeClass("btn-success").addClass("btn-secondary");
|
$(".status-type").removeClass("btn-success").addClass("btn-secondary");
|
||||||
}
|
}
|
||||||
$(e).removeClass("btn-secondary").addClass("btn-success");
|
$(e).removeClass("btn-secondary").addClass("btn-success");
|
||||||
operationRecodeTable.ajax.reload();
|
operationRecordTable.ajax.reload();
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user