1. 運維作業紀錄 修改 圖片上傳

2. 電站 運維人員 改回主DB
This commit is contained in:
Kai 2021-06-26 16:39:42 +08:00
parent 89345bee79
commit 459347dcb2
13 changed files with 93 additions and 65 deletions

View File

@ -352,7 +352,13 @@ namespace SolarPower.Controllers
recode.FormId = @$"<a href='javascript:;' class='waves-effect waves-themed mb-3 mr-2 edit-btn'>{recode.FormId}</a>";
}
//TODO 替換圖片檔案
if (recode.RecodeFiles != null && recode.RecodeFiles.Count > 0)
{
foreach (var file in recode.RecodeFiles)
{
file.FileName = Path.Combine(operationRecodeFilePath, recode.Id.ToString()) + "/" + file.FileName;
}
}
}
totalRecords = recodes.Count();
@ -599,6 +605,7 @@ namespace SolarPower.Controllers
/// </summary>
/// <param name="post"></param>
/// <returns></returns>
[HttpPost]
public async Task<ApiResult<OperationRecode>> SaveOperationRecodeFile([FromForm] PostOperationRecode post)
{
ApiResult<OperationRecode> apiResult = new ApiResult<OperationRecode>();

View File

@ -351,7 +351,7 @@ namespace SolarPower.Controllers
"CreatedBy",
};
await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, operationPersonnelProperties, company.SiteDB);
await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, operationPersonnelProperties);
}
#endregion
@ -423,7 +423,7 @@ namespace SolarPower.Controllers
List<int> origOperationPersonnels = null; //原先的運維人員
origOperationPersonnels = await powerStationRepository.GetOperationPersonnelIdsByPowerStatioinId(powerStation.Id, powerStation.SiteDB);
origOperationPersonnels = await powerStationRepository.GetOperationPersonnelIdsByPowerStatioinId(powerStation.Id);
//判斷新進來的資料是否要歸類到新增 or 刪除
#region
@ -442,7 +442,7 @@ namespace SolarPower.Controllers
}
//刪除運維人員
await powerStationRepository.DeleteOperationPersonnel(deleteOperationPersonnels, powerStation.SiteDB);
await powerStationRepository.DeleteOperationPersonnel(deleteOperationPersonnels);
#endregion
#region
@ -470,7 +470,7 @@ namespace SolarPower.Controllers
"CreatedBy",
};
await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, operationPersonnelProperties, powerStation.SiteDB);
await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, operationPersonnelProperties);
}
#endregion

View File

@ -213,7 +213,6 @@ namespace SolarPower.Repository.Implement
LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id
LEFT JOIN user u ON opr.WorkPersonId = u.ID
WHERE opr.Deleted = 0
AND ps.CityId IN @CityIds
AND ps.Id IN @PowerStationIds";
if (filter.WorkType > 0)
@ -229,21 +228,26 @@ namespace SolarPower.Repository.Implement
else
{
sql += @" AND opr.WorkType IN (0, 1)";
//sql += @" UNION";
//sql += @" SELECT
// opr.*,
// ps.Name AS PowerStationName,
// 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
// WHERE opr.Deleted = 0
// AND ps.CityId IN @CityIds
// AND ps.Id IN @PowerStationIds
// AND opr.WorkType = 2";
sql += @" UNION";
sql += @" SELECT
opr.*,
ps.Name AS PowerStationName,
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
WHERE opr.Deleted = 0
AND ps.Id IN @PowerStationIds
AND opr.WorkType = 2";
}
result = (await conn.QueryAsync<OperationRecodeDataTable>(sql, filter)).ToList();
var sql_file = "SELECT * FROM operation_record_file WHERE Deleted = 0 AND RecordId = @RecordId";
foreach (var x in result)
{
x.RecodeFiles = (await conn.QueryAsync<OperationRecodeFile>(sql_file, new { RecordId = x.Id })).ToList();
}
}
catch (Exception exception)
{

View File

@ -194,7 +194,7 @@ namespace SolarPower.Repository.Implement
var db_name = result.SiteDB;
var sql_operation_personnel = @$"SELECT UserId FROM {db_name}.power_station_operation_personnel op WHERE Deleted = 0 AND op.PowerStationId = @PowerStationId";
var sql_operation_personnel = @$"SELECT UserId FROM power_station_operation_personnel op WHERE Deleted = 0 AND op.PowerStationId = @PowerStationId";
result.OperationPersonnelIds = (await conn.QueryAsync<int>(sql_operation_personnel, new { PowerStationId = result.Id })).ToList();
var sql_land_building = @$"SELECT lb.*, u.Name AS CreatorName FROM {db_name}.land_building lb
@ -892,7 +892,7 @@ namespace SolarPower.Repository.Implement
/// <param name="powerStationId"></param>
/// <param name="db_name"></param>
/// <returns></returns>
public async Task<List<int>> GetOperationPersonnelIdsByPowerStatioinId(int powerStationId, string db_name)
public async Task<List<int>> GetOperationPersonnelIdsByPowerStatioinId(int powerStationId)
{
List<int> result;
using (IDbConnection conn = this._databaseHelper.GetConnection())
@ -900,7 +900,7 @@ namespace SolarPower.Repository.Implement
conn.Open();
try
{
var sql = @$"SELECT UserId FROM {db_name}.power_station_operation_personnel WHERE Deleted = 0 AND PowerStationId = @PowerStationId";
var sql = @$"SELECT UserId FROM power_station_operation_personnel WHERE Deleted = 0 AND PowerStationId = @PowerStationId";
result = (await conn.QueryAsync<int>(sql, new { PowerStationId = powerStationId })).ToList();
}
@ -921,9 +921,8 @@ namespace SolarPower.Repository.Implement
/// </summary>
/// <param name="entity"></param>
/// <param name="properties"></param>
/// <param name="db_name"></param>
/// <returns></returns>
public async Task<int> AddOperationPersonnelAsync(List<PowerStationOperationPersonnel> entity, List<string> properties, string db_name)
public async Task<int> AddOperationPersonnelAsync(List<PowerStationOperationPersonnel> entity, List<string> properties)
{
int count;
using (IDbConnection conn = _databaseHelper.GetConnection())
@ -931,7 +930,7 @@ namespace SolarPower.Repository.Implement
conn.Open();
try
{
string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "power_station_operation_personnel");
string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_operation_personnel");
count = await conn.ExecuteAsync(sql, entity);
}
@ -954,7 +953,7 @@ namespace SolarPower.Repository.Implement
/// <param name="operationPersonnels"></param>
/// <param name="db_name"></param>
/// <returns></returns>
public async Task DeleteOperationPersonnel(List<PowerStationOperationPersonnel> operationPersonnels, string db_name)
public async Task DeleteOperationPersonnel(List<PowerStationOperationPersonnel> operationPersonnels)
{
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
@ -963,7 +962,7 @@ namespace SolarPower.Repository.Implement
{
try
{
var sql = $"UPDATE {db_name}.power_station_operation_personnel SET Deleted = 1 WHERE PowerStationId = @PowerStationId AND UserId = @UserId";
var sql = $"UPDATE power_station_operation_personnel SET Deleted = 1 WHERE PowerStationId = @PowerStationId AND UserId = @UserId";
await conn.ExecuteAsync(sql, operationPersonnels, trans);

View File

@ -229,16 +229,15 @@ namespace SolarPower.Repository.Interface
/// <param name="powerStationId"></param>
/// <param name="db_name"></param>
/// <returns></returns>
Task<List<int>> GetOperationPersonnelIdsByPowerStatioinId(int powerStationId, string db_name);
Task<List<int>> GetOperationPersonnelIdsByPowerStatioinId(int powerStationId);
/// <summary>
/// 新增電站運維人員
/// </summary>
/// <param name="entity"></param>
/// <param name="properties"></param>
/// <param name="db_name"></param>
/// <returns></returns>
Task<int> AddOperationPersonnelAsync(List<PowerStationOperationPersonnel> entity, List<string> properties, string db_name);
Task<int> AddOperationPersonnelAsync(List<PowerStationOperationPersonnel> entity, List<string> properties);
/// <summary>
/// 軟刪除電站運維人員
@ -246,7 +245,7 @@ namespace SolarPower.Repository.Interface
/// <param name="operationPersonnels"></param>
/// <param name="db_name"></param>
/// <returns></returns>
Task DeleteOperationPersonnel(List<PowerStationOperationPersonnel> operationPersonnels, string db_name);
Task DeleteOperationPersonnel(List<PowerStationOperationPersonnel> operationPersonnels);
/// <summary>
/// 電站管理 新增電站圖片

View File

@ -42,24 +42,17 @@
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="Allcity()">全部縣市</button>
</div>
<div class="pr-3">
<div class="frame-wrap" id="citytest" style="display:none">
<button type="button" class="btn btn-outline-success waves-effect waves-themed">
新北市
<span class="badge bg-success-700 ml-2" id="acount">4</span>
</button>
</div>
<div class="frame-wrap" id="city">
</div>
</div>
</div>
<div class="row mb-5 d-flex align-items-center px-3">
<div class="pr-3">
<div class="row mb-5 d-flex align-items-top px-3">
<div class="col-1 p-0">
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="Allpowerstation()">全選</button>
</div>
<div class="pr-3">
<div class="frame-wrap" id="CheckPowerStation">
<div class="col-11">
<div class="row frame-wrap" id="CheckPowerStation">
</div>
</div>
@ -215,7 +208,7 @@
</div>
</div>
<div class="row px-3">
<form id="recode-file-div" class="dropzone needsclick dz-clickable col-12" style="min-height: 7rem;">
<form id="recode-file-form" class="dropzone needsclick dz-clickable col-12" style="min-height: 7rem;">
@*<div class="fallback">
<input type="file" multiple />
</div>*@
@ -293,12 +286,22 @@
}
$('#CheckPowerStation').empty();
$.each(rel.data, function (index, val) {
$('#CheckPowerStation').append("<div class='custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' ></div>");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "' checked>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
powerids.push(String(val.id));
Allpowerids.push(String(val.id));
});
//modal 電站 下拉式選單
$("#power_station_select_modal").empty();
$.each(rel.data, function (index, val) {
$("#power_station_select_modal").append($("<option />").val(val.id).text(val.name));
});
//預設查詢第一個
$("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change');
operationRecodeTable.ajax.reload();
})
})
@ -361,14 +364,27 @@
"data": "workPersonName"
}, {
"data": "operationPredict"
},
//{
//"data": "fileList"
//}
//,
{
}, {
"data": "recodeFiles"
}, {
"data": "finishTime"
}],
"columnDefs": [{
'targets': 7,
'searchable': false,
'orderable': false,
'className': 'dt-body-center',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).empty();
$(td).append('<div class="row"></div>');
if (cellData != null) {
cellData.forEach(function (value, index) {
CreateRecodeFileBox($(td).children(".row"), value);
});
}
}
}],
"language": {
"emptyTable": "無資料...",
"processing": "處理中...",
@ -399,7 +415,6 @@
"url": "/Operation/OperationRecodeList",
"type": "POST",
"data": function (d) {
d.CityIds = [3];
d.PowerStationIds = powerids;
d.WorkType = Type;
d.Range = $('#company_taxIDNumber').val();
@ -421,8 +436,6 @@
}
});
//#endregion
});
//#region 改變項目
@ -431,7 +444,7 @@
Type = type;
for (var i = 0; i < 4; i++)
{
var name = "button" + i;
var name = "button" + i;
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");
@ -448,7 +461,6 @@
$("#power_station_select_modal").attr("disabled", false);
$(".fix-div").show();
$("#recode-form").trigger("reset");
GetPowerStation();
$("#recode-form-modal").modal();
}
@ -679,7 +691,7 @@
return;
}
var myDropzone = Dropzone.forElement("#recode-file-div");
var myDropzone = Dropzone.forElement("#recode-file-form");
if (myDropzone.files.length > 0) {
@ -697,19 +709,19 @@
operationRecodeTable.ajax.reload();
});
//} else {
// $('#recode-form-modal').modal('hide');
// myDropzone.removeAllFiles();
} else {
$('#recode-form-modal').modal('hide');
myDropzone.removeAllFiles();
// operationRecodeTable.ajax.reload();
//}
operationRecodeTable.ajax.reload();
}
}
});
}
}
//#endregion
//#region 取得電站選單資料
//#region 取得電站選單資料 (未使用)
function GetPowerStation() {
var url_power_station_select_option = "/Operation/GetPowerStationSelectOption";
$.get(url_power_station_select_option, function (rel) {
@ -732,7 +744,7 @@
//#region 表單檔案資料
Dropzone.autoDiscover = false;
recodeFileDropzone = new Dropzone("#recode-file-div", {
recodeFileDropzone = new Dropzone("#recode-file-form", {
url: "/Operation/SaveOperationRecodeFile",
acceptedFiles: "image/*, application/pdf,.doc,.docx,.xls,.xlsx",
autoProcessQueue: false,
@ -745,7 +757,7 @@
var myDropzone = this;
myDropzone.on("sendingmultiple", function (file, xhr, data) {
myDropzone.on("sending", function (file, xhr, data) {
if ((countOperationRecodeFile + myDropzone.files.length) > 5) {
toast_warning("檔案總數量不可超過 5 張");
myDropzone.removeFile(file);
@ -816,8 +828,15 @@
}
str += "</td>";
str += "<td>" + value.finishTime + "</td>" +
"</tr>";
str += "<td>";
if (value.finishTime != undefined || value.finishTime != null || value.finishTime != "") {
value.hyperLinks.forEach(function (value3, index) {
str += value3;
});
}
str += "</td>";
str += "</tr>";
});
$('#NoViewbody').append(str);

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB