衝突合併

This commit is contained in:
Kai 2021-07-10 13:43:32 +08:00
commit 6d6ddf6a98
12 changed files with 940 additions and 29 deletions

View File

@ -316,5 +316,47 @@ namespace SolarPower.Controllers
apiResult.Msg = errorCode.GetString(apiResult.Code); apiResult.Msg = errorCode.GetString(apiResult.Code);
return apiResult; return apiResult;
} }
public async Task<ActionResult> GetExceptionTable(ExceptionSent post)
{
List<ExceptionDataTable> exceptionDataTable = new List<ExceptionDataTable>();
ApiResult<List<ExceptionDataTable>> apiResult = new ApiResult<List<ExceptionDataTable>>();
PowerStation powerStation = null;
try
{
powerStation = await powerStationRepository.GetOneAsync(post.Id);
exceptionDataTable = await overviewRepository.GetExceptionTable(post);
foreach (ExceptionDataTable a in exceptionDataTable)
{
if (string.IsNullOrEmpty(a.FormId))
{
a.Function = @$"<a href='javascript:;' class='btn btn-success waves-effect waves-themed mb-3 mr-2 add-btn'>填寫表單</a>";
}
else
{
a.Function = @$"<a href='javascript:;' class='waves-effect waves-themed mb-3 mr-2 edit-btn'>{a.FormId}</a>";
}
}
apiResult.Code = "0000";
apiResult.Data = exceptionDataTable;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = errorCode.GetString(apiResult.Code);
Logger.LogError("【" + controllerName + "/" + actionName + "】");
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
var result = Json(new
{
data = apiResult
});
return result;
}
} }
} }

View File

@ -1024,8 +1024,22 @@ COMMENT='各電站每月日照度的平均值'
COLLATE='utf8mb4_unicode_ci' COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB ENGINE=InnoDB
; ;
-- 子DB逆變器新增欄位 20210708
ALTER TABLE `inverter`
ADD COLUMN `Enabled` tinyint(4) DEFAULT '0' COMMENT '是否啟用0:未啟用 1:啟用' AFTER `Deleted`,
ADD COLUMN `Status` tinyint(4) DEFAULT '0' COMMENT '狀態0:未啟用 1:正常 2:異常' AFTER `Enabled`,
ADD COLUMN `InstallDate` timestamp NULL DEFAULT NULL COMMENT '安裝日期' AFTER `Status`,
ADD COLUMN `InverterName` varchar(50) DEFAULT NULL COMMENT '逆變器名稱' AFTER `SerialNumber`,
ADD COLUMN `Brand` varchar(50) DEFAULT NULL COMMENT '廠牌' AFTER `ControllerId`,
ADD COLUMN `Model` varchar(50) DEFAULT NULL COMMENT '型號' AFTER `Brand`,
ADD COLUMN `Capacity` double(10,3) DEFAULT NULL COMMENT '裝置容量 kWp' AFTER `Model`,
ADD COLUMN `Pyrheliometer` int(10) DEFAULT NULL COMMENT '日照計設備流水號'AFTER `Capacity`;
-- 子DB裝置列表新增欄位 20210708
ALTER TABLE `device`
ADD COLUMN `Enabled` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否啟用, 0:否 1:是' AFTER `PowerStationId`,
ADD COLUMN `InstallDate` timestamp NULL DEFAULT NULL COMMENT '安裝日期' AFTER `ColName`,
DROP COLUMN `Remark`,
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;

View File

@ -78,6 +78,32 @@ namespace SolarPower.Models
public List<double> IrradianceDatas { get; set; } public List<double> IrradianceDatas { get; set; }
} }
public class ExceptionSent
{
public int Id { get; set; }
public int Status { get; set; }
public string Range { get; set; }
public string StartTime { get; set; } //起始日期
public string EndTime { get; set; } //結束日期
}
public class ExceptionInfo
{
public int Id { get; set; }
public string Site_id { get; set; }
public string Dev_time { get; set; }
public string AlarmClassName { get; set; }
public string ErrDevice { get; set; }
public string ErrMsg { get; set; }
public int Err_status { get; set; }
}
public class ExceptionDataTable:ExceptionInfo
{
public string Function { get; set; }
public string PowerStationName { get; set; }
public int ErrorID { get; set; }
public string FormId { get; set; }
}
public class PostInverterAnalysis public class PostInverterAnalysis
{ {
public int PowerStationId { get; set; } public int PowerStationId { get; set; }

View File

@ -452,8 +452,10 @@ namespace SolarPower.Repository.Implement
`Deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1:', `Deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1:',
`UID` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT ' ++(0001~9999)+(3) + SN(3)', `UID` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT ' ++(0001~9999)+(3) + SN(3)',
`PowerStationId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '', `PowerStationId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
`SerialNumber` varchar(4) COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '', `Enabled` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1:',
`Name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Status` tinyint(4) NOT NULL DEFAULT '0' COMMENT ' 0: 1: 2:',
`SerialNumber` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '',
`Name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`Type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `Type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`TypeName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '', `TypeName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`ControllerId` int(10) unsigned DEFAULT NULL COMMENT 'Id', `ControllerId` int(10) unsigned DEFAULT NULL COMMENT 'Id',
@ -462,7 +464,7 @@ namespace SolarPower.Repository.Implement
`DBName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, `DBName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`TableName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, `TableName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`ColName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, `ColName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Remark` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '', `InstallDate` timestamp NULL DEFAULT NULL COMMENT '',
`CreatedBy` int(10) unsigned NOT NULL COMMENT '', `CreatedBy` int(10) unsigned NOT NULL COMMENT '',
`CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '', `CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '', `UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '',
@ -476,9 +478,17 @@ namespace SolarPower.Repository.Implement
CREATE TABLE IF NOT EXISTS `inverter` ( CREATE TABLE IF NOT EXISTS `inverter` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '', `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '',
`Deleted` tinyint(4) DEFAULT '0' COMMENT '', `Deleted` tinyint(4) DEFAULT '0' COMMENT '',
`Enabled` tinyint(4) DEFAULT '0' COMMENT '0: 1:',
`Status` tinyint(4) DEFAULT '0' COMMENT '0: 1: 2:',
`InstallDate` timestamp NULL DEFAULT NULL COMMENT '',
`SerialNumber` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '()', `SerialNumber` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '()',
`InverterName` varchar(50) DEFAULT NULL COMMENT '',
`InverterId` varchar(50) DEFAULT NULL COMMENT 'UID', `InverterId` varchar(50) DEFAULT NULL COMMENT 'UID',
`ControllerId` int(10) DEFAULT NULL COMMENT '', `ControllerId` int(10) DEFAULT NULL COMMENT '',
`Brand` varchar(50) DEFAULT NULL COMMENT '',
`Model` varchar(50) DEFAULT NULL COMMENT '',
`Capacity` double(10,3) DEFAULT NULL COMMENT ' kWp',
`Pyrheliometer` int(10) DEFAULT NULL COMMENT '',
`CreatedBy` int(10) unsigned NOT NULL, `CreatedBy` int(10) unsigned NOT NULL,
`CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`UpdatedBy` int(10) DEFAULT NULL, `UpdatedBy` int(10) DEFAULT NULL,

View File

@ -327,5 +327,56 @@ namespace SolarPower.Repository.Implement
} }
} }
public async Task<List<ExceptionDataTable>> GetExceptionTable(ExceptionSent post)
{
List<ExceptionDataTable> result;
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
try
{
DateTime start;
DateTime end;
var sql = @$"select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time , a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName,
errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate,
case when c.errMsg_tw is null then d.errMsg_tw else c.errMsg_tw end errMsg
from err_main a
join alarmorion_orionalarmclass b on a.alarmclass = b.id
left join ref_err_device c on trim(b.alarmClass) = c.deviceType
left join ref_err_inv d on lower(b.alarmClass) = d.deviceType
and case when lower(b.alarmClass) = 'inverter' and err_valuekind = 'e' then errvalue else '' end = d.errCode
left join power_station ps on ps.Code = site_id
left join operation_record pr on pr.ErrorCode = a.id
WHERE a.sourceState = @Status AND ps.Id = @PowerStationId";
if (!string.IsNullOrEmpty(post.Range))
{
post.StartTime = post.Range.Split('-')[0];
post.EndTime = post.Range.Split('-')[1];
start = Convert.ToDateTime(post.StartTime);
end = Convert.ToDateTime(post.EndTime);
var startime = (Int64)(start.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
var endtime = (Int64)(end.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
sql += @$" AND `timestamp` BETWEEN {startime*1000} AND {endtime*1000}";
}
result = (await conn.QueryAsync<ExceptionDataTable>(sql,
new
{
PowerStationId = post.Id,
Status = post.Status,
})).ToList();
}
catch (Exception exception)
{
throw exception;
}
return result;
}
}
} }
} }

View File

@ -20,6 +20,7 @@ namespace SolarPower.Repository.Interface
Task<List<PowerIrradiance>> GetListPowerIrradiance7dayByPowerStationId(int powerStationId, string nowDay); Task<List<PowerIrradiance>> GetListPowerIrradiance7dayByPowerStationId(int powerStationId, string nowDay);
Task<List<PowerIrradiance>> GetListPowerIrradianceMonthByPowerStationId(int powerStationId, string nowDay); Task<List<PowerIrradiance>> GetListPowerIrradianceMonthByPowerStationId(int powerStationId, string nowDay);
Task<List<PowerIrradiance>> GetListPowerIrradianceYearByPowerStationId(int powerStationId, string nowDay); Task<List<PowerIrradiance>> GetListPowerIrradianceYearByPowerStationId(int powerStationId, string nowDay);
Task<List<ExceptionDataTable>> GetExceptionTable(ExceptionSent post);
Task<List<CheckBox>> GetInvertCheckBoxByPowerStationId(int powerStationId, string db_name); Task<List<CheckBox>> GetInvertCheckBoxByPowerStationId(int powerStationId, string db_name);
Task<List<InverterHistory>> GetListInverterByPowerStationIdAndDate(int powerStationId, string nowDay); Task<List<InverterHistory>> GetListInverterByPowerStationIdAndDate(int powerStationId, string nowDay);

View File

@ -103,10 +103,14 @@
var powerids = new Array(0);//當前選擇電站 var powerids = new Array(0);//當前選擇電站
var Type = 0; // 項目 var Type = 0; // 項目
var stationId; var stationId;
var errortoID;
var powerStationData; var powerStationData;
var stationOverview; var stationOverview;
var recode; var recode;
var selected_work_type = -1; var selected_work_type = -1;
var err_status = 0;//異常紀錄0:為解決 1:已解決
var groupType = 0; //0:日 1:月 2:年 3:歷年
var historyRange = "";
$(function () { $(function () {
var url = new URL(location.href); var url = new URL(location.href);
@ -540,7 +544,7 @@
//#endregion //#endregion
//#endregion //#endregion
//#region Date Picker //#region Date Picker record
datepicker = $('#date-range-record').daterangepicker({ datepicker = $('#date-range-record').daterangepicker({
autoUpdateInput: false, autoUpdateInput: false,
locale: { format: 'YYYY/MM/DD' }, locale: { format: 'YYYY/MM/DD' },
@ -560,6 +564,26 @@
}); });
//#endregion //#endregion
//#region Date Picker exception
datepicker = $('#date-range-exception').daterangepicker({
autoUpdateInput: false,
locale: { format: 'YYYY/MM/DD' },
opens: 'left'
}, function (start, end, label) {
@* console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));*@
});
$('#date-range-exception').on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('YYYY/MM/DD') + ' - ' + picker.endDate.format('YYYY/MM/DD'));
$(this).trigger('change');
});
$('#date-range-exception').on('cancel.daterangepicker', function (ev, picker) {
$(this).val('');
$(this).trigger('change');
});
//#endregion
//#region 運維作業記錄 DataTable //#region 運維作業記錄 DataTable
powerids.push(stationId); powerids.push(stationId);
operationRecodeTable = $("#operation_recode_table").DataTable({ operationRecodeTable = $("#operation_recode_table").DataTable({
@ -675,6 +699,7 @@
} }
$("#work_person_select_modal").empty(); $("#work_person_select_modal").empty();
if (rel.data.length > 0) { if (rel.data.length > 0) {
$.each(rel.data, function (index, val) { $.each(rel.data, function (index, val) {
@ -719,25 +744,109 @@
//#endregion //#endregion
}); });
//#region 改變日期 //#region 維修單運維人員(異常紀錄)
$('#date-range-record').on('change', function () { var url_power_station_operation_personnel = "/PowerStation/GetOperationPersonnelSelectOptionList";
operationRecodeTable.ajax.reload(); send_data = {
PowerStationId: stationId
}
$.post(url_power_station_operation_personnel, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$("#work_person_select_modal_exc").empty();
if (rel.data.length > 0) {
$.each(rel.data, function (index, val) {
$("#work_person_select_modal_exc").append($("<option />").val(val.value).text(val.text));
});
if (recode != null || recode != undefined) {
$("#work_person_select_modal_exc").val(recode.workPersonId);
}
}
}); });
//#endregion //#endregion
//#region 改變項目 //#region 異常table
function ChangeType(type) { ExceptionTable = $("#Exception_Table").DataTable({
Type = type; "pageLength": 20,
for (var i = 0; i < 4; i++) { "paging": true,
var name = "button" + i; "lengthChange": false,
document.getElementById(name).setAttribute("class", "btn btn-secondary waves-effect waves-themed"); "searching": false,
"ordering": true,
"info": true,
"autoWidth": false,
"responsive": true,
"order": [[6, "desc"]],
"columns": [{
"data": "powerStationName"
}, {
"data": "id"
}, {
"data": "dev_time"
}, {
"data": "alarmClassName"
}, {
"data": "errDevice"
}, {
"data": "errMsg"
}, {
"data": "function"
}],
"language": {
"emptyTable": "無資料...",
"processing": "處理中...",
"loadingRecords": "載入中...",
"lengthMenu": "顯示 _MENU_ 項結果",
"zeroRecords": "沒有符合的結果",
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
"infoPostFix": "",
"search": "搜尋:",
"paginate": {
"first": "第一頁",
"previous": "上一頁",
"next": "下一頁",
"last": "最後一頁"
},
"aria": {
"sortAscending": ": 升冪排列",
"sortDescending": ": 降冪排列"
} }
document.getElementById("button" + type).setAttribute("class", "btn btn-success waves-effect waves-themed"); },
operationRecodeTable.ajax.reload(); 'createdRow': function (row, data, dataIndex) {
$(row).attr('data-id', data.id);
$(row).attr('data-error', data.errorID);
},
"ajax": {
"url": "/StationOverview/GetExceptionTable",
"type": "POST",
"data": function (d) {
d.id = stationId,
d.status = err_status,
d.range = $('#date-range-exception').val()
},
"dataSrc": function (rel) {
if (rel.data.code == "9999") {
toast_error(rel.data.msg);
return;
} }
data = rel.data.data;
if (data == null || data.length == 0) {
this.data = [];
}
return data;
}
}
});
//#endregion //#endregion
});
//#region 產生檔案html //#region 產生檔案html
function CreateRecodeFileBox(dom, value, show_del_btn) { function CreateRecodeFileBox(dom, value, show_del_btn) {
var str = ""; var str = "";
@ -766,7 +875,256 @@
} }
//#endregion //#endregion
//#region 編輯表單內容 //#region 異常
//#region 改變日期(異常)
$('#date-range-exception').on('change', function () {
ExceptionTable.ajax.reload();
});
//#endregion
//#region 匯出excel(異常)
function ExportExcelToExc() {
var url = "/StationOverview/GetExceptionTable";
var send_data = {
id: stationId,
status: err_status,
range: $('#date-range-exception').val()
};
$.post(url, send_data, function (rel) {
if (rel.data.code != "0000") {
toast_error(rel.data.msg);
return;
}
$('#NOSEEBODY').empty();
var str = "";
rel.data.data.forEach(function (value, index) {
str += "<tr>" +
"<td>" + value.powerStationName + "</td>" +
"<td>" + value.id + "</td>" +
"<td>" + value.dev_time + "</td>" +
"<td>" + value.alarmClassName + "</td>" +
"<td>" + value.errDevice + "</td>" +
"<td>" + value.errMsg + "</td>";
});
$('#NOSEEBODY').append(str);
$("#NOSEE").table2excel({
// 匯出的Excel文件的名稱
name: "檔案",
// Excel檔案的名稱
filename: "test",
//檔案字尾名
fileext: ".xls",
});
}, 'json');
}
//#endregion
//#region 編輯異常表單內容(異常)
$('#Exception_Table').on("click", "a.edit-btn", function () {
$("#exception-form-modal .modal-title .main-title").html("維修單 - ");
selected_id = $(this).parents('tr').attr('data-id');
errortoID = $(this).parents('tr').attr('data-error');
//取得單一記錄表單
var url = "/Operation/GetOneOperationRecode/";
var send_data = {
id: errortoID
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
recode = rel.data;
countOperationRecodeFile = recode.recodeFiles.length;
$("#exception-form-modal .modal-title .sub-title").html(powerStationData.name);
$("#power_station_select_modal_exc").val(powerStationData.name);
$("#power_station_select_modal_exc").attr("disabled", true);
$("#work_time_modal").val(recode.workTime);
var status = -1;
if (recode.status == 0 || recode.status == 2) {
status = 0;
} else if (recode.status == 1 || recode.status == 3) {
status = 1;
}
$("input[name=status_modal][value='" + status + "']").prop('checked', true); //狀態
$('#work_person_select_modal_exc').val(recode.workPersonId);
$(".fix-div").show();
$("#error_code_modal_exc").val(recode.errorCode);
$("#error_code_modal_exc").attr("disabled", true);
$("#fix_do_modal_exc").val(recode.fixDo);
$("#notice_textarea_modal_exc").val(recode.notice);
$("#description_textarea_modal_exc").val(recode.description);
var str = "";
RecodeFileBox = $("#recode_files_div_exc > .row");
RecodeFileBox.empty();
recode.recodeFiles.forEach(function (value, index) {
CreateRecodeFileBox(RecodeFileBox, value, true);
});
$("#exception-form-modal").modal();
}, 'json');
});
//#endregion
//#region 派工新增表單(異常)
$('#Exception_Table').on("click", "a.add-btn", function () {
$("#exception-form-modal .modal-title .main-title").html("維修單 - ");
$("#exception-form-modal .modal-title .sub-title").html(powerStationData.name);
$("#recode-form-exc").trigger("reset");
$("#power_station_select_modal_exc").val(powerStationData.name);
$("#power_station_select_modal_exc").attr("disabled", true);
selected_id = $(this).parents('tr').attr('data-id');
errortoID = $(this).parents('tr').attr('data-error');
$("#error_code_modal_exc").val(selected_id);
$("#error_code_modal_exc").attr("disabled", true);
$("#exception-form-modal").modal();
});
//#endregion
//#region 查詢近30天(異常)
function ChangeDate30exception() {
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 30));
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
datepicker.data('daterangepicker').setStartDate(dateLimit_format);
datepicker.data('daterangepicker').setEndDate(today_format);
$('#date-range-exception').val(dateLimit_format + ' - ' + today_format);
$('#date-range-exception').trigger('change');
}
//#endregion
//#region 儲存表單資料(異常)
function SaveException() {
if ($("#recode-form-exc").valid()) {
var url = "/Operation/SaveOperationRecode";
var formData = new FormData();
formData.append("Id", errortoID);
formData.append("PowerStationId", stationId);
formData.append("WorkType", 2);
formData.append("ErrorCode", $("#error_code_modal_exc").val());
formData.append("FixDo", $("#fix_do_modal_exc").val());
formData.append("Status", $("input[name=status_modal]:checked").val());
formData.append("WorkPersonId", $("#work_person_select_modal_exc").val());
formData.append("WorkTime", $("#work_time_modal_exc").val());
formData.append("Notice", $("#notice_textarea_modal_exc").val());
formData.append("Description", $("#description_textarea_modal_exc").val());
$.ajax({
type: "POST",
url: url,
data: formData,
cache: false,
contentType: false,
processData: false,
success: function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
var myDropzone = Dropzone.forElement("#recode-file-form_exc");
if (myDropzone.files.length > 0) {
myDropzone.processQueue();
myDropzone.on("successmultiple", function (file, rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
toast_ok(rel.msg);
$('#exception-form-modal').modal('hide');
recodeFileDropzone.removeAllFiles();
ExceptionTable.ajax.reload();
});
} else {
$('#exception-form-modal').modal('hide');
myDropzone.removeAllFiles();
ExceptionTable.ajax.reload();
}
}
});
}
}
//#endregion
//#region 表單檔案資料(異常)
Dropzone.autoDiscover = false;
recodeFileDropzone = new Dropzone("#recode-file-form_exc", {
url: "/Operation/SaveOperationRecodeFile",
acceptedFiles: "image/*, application/pdf,.doc,.docx,.xls,.xlsx",
autoProcessQueue: false,
parallelUploads: 5,
maxFiles: 5,
addRemoveLinks: true,
uploadMultiple: true,
dictRemoveFile: "移除",
init: function (e) {
var myDropzone = this;
myDropzone.on("sending", function (file, xhr, data) {
if ((countOperationRecodeFile + myDropzone.files.length) > 5) {
toast_warning("檔案總數量不可超過 5 張");
myDropzone.removeFile(file);
return;
} else {
data.append("Id", selected_id);
data.append("RecodeFiles", file);
}
});
}
});
//#endregion
//#region 改變異常紀錄狀態
function ChangeStatus(type) {
err_status = type;
var name;
var name2;
if (type == 0) {
name = "errbutton" + "0";
name2 = "errbutton" + "1";
} else {
name = "errbutton" + "1";
name2 = "errbutton" + "0";
}
document.getElementById(name).setAttribute("class", "btn btn-success waves-effect waves-themed");
document.getElementById(name2).setAttribute("class", "btn btn-secondary waves-effect waves-themed");
ExceptionTable.ajax.reload();
}
//#endregion
//#endregion
//#region 運維
//#region 編輯表單內容(運維)
$('#operation_recode_table').on("click", "a.edit-btn", function () { $('#operation_recode_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');
@ -835,7 +1193,7 @@
}); });
//#endregion //#endregion
//#region 表單檔案資料 //#region 表單檔案資料(運維)
Dropzone.autoDiscover = false; Dropzone.autoDiscover = false;
recodeFileDropzone = new Dropzone("#recode-file-form", { recodeFileDropzone = new Dropzone("#recode-file-form", {
url: "/Operation/SaveOperationRecodeFile", url: "/Operation/SaveOperationRecodeFile",
@ -867,7 +1225,7 @@
}); });
//#endregion //#endregion
//#region 查詢近30天 //#region 查詢近30天(運維)
function ChangeDate30() { function ChangeDate30() {
var today = new Date(); var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 30)); var dateLimit = new Date(new Date().setDate(today.getDate() - 30));
@ -883,7 +1241,7 @@
} }
//#endregion //#endregion
//#region 儲存表單資料 //#region 儲存表單資料(運維)
function SaveRecode() { function SaveRecode() {
if ($("#recode-form").valid()) { if ($("#recode-form").valid()) {
@ -945,14 +1303,14 @@
} }
//#endregion //#endregion
//#region 點擊圖片放大 //#region 點擊圖片放大(運維)
$('#operation_recode_table').on("click", "img.img-zoom", function () { $('#operation_recode_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 匯出excel //#region 匯出excel(運維)
function ExportExcel() { function ExportExcel() {
var url = "/Operation/ExportOperationRecodeExcel"; var url = "/Operation/ExportOperationRecodeExcel";
var send_data = { var send_data = {
@ -1011,6 +1369,27 @@
} }
//#endregion //#endregion
//#region 改變日期(運維)
$('#date-range-record').on('change', function () {
operationRecodeTable.ajax.reload();
});
//#endregion
//#region 改變項目(運維)
function ChangeType(type) {
err_status = type;
for (var i = 0; i < 4; 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");
operationRecodeTable.ajax.reload();
}
//#endregion
//#endregion
//#region 設定電站基本資料 //#region 設定電站基本資料
function SetStationInfo() { function SetStationInfo() {
@ -1365,5 +1744,131 @@
} }
//#region 歷史
//#region 改選擇族群(日 月 年 歷年)
function ChangeGroup(type) {
for (var i = 0; i <= 3; i++)
{
document.getElementById("Group" + i).setAttribute("class", "btn btn-secondary waves-effect waves-themed");
}
document.getElementById("Group" + type).setAttribute("class", "btn btn-success waves-effect waves-themed");
switch (type)
{
case 0:
document.getElementById("Today").style.display = "";//隱藏
document.getElementById("ToMonth").style.display = "none";//隱藏
document.getElementById("ToYear").style.display = "none";//隱藏
document.getElementById("DateGet").style.display = "";//隱藏
document.getElementById("MonthGet").style.display = "none";//隱藏
document.getElementById("YearGet").style.display = "none";//隱藏
groupType = type;
break;
case 1:
document.getElementById("Today").style.display = "none";//隱藏
document.getElementById("ToMonth").style.display = "";//隱藏
document.getElementById("ToYear").style.display = "none";//隱藏
document.getElementById("DateGet").style.display = "none";//隱藏
document.getElementById("MonthGet").style.display = "";//隱藏
document.getElementById("YearGet").style.display = "none";//隱藏
groupType = type;
break;
case 2:
document.getElementById("Today").style.display = "none";//隱藏
document.getElementById("ToMonth").style.display = "none";//隱藏
document.getElementById("ToYear").style.display = "";//隱藏
document.getElementById("DateGet").style.display = "none";//隱藏
document.getElementById("MonthGet").style.display = "none";//隱藏
document.getElementById("YearGet").style.display = "";//隱藏
groupType = type;
break;
case 3:
document.getElementById("Today").style.display = "none";//隱藏
document.getElementById("ToMonth").style.display = "none";//隱藏
document.getElementById("ToYear").style.display = "none";//隱藏
document.getElementById("DateGet").style.display = "none";//隱藏
document.getElementById("MonthGet").style.display = "none";//隱藏
document.getElementById("YearGet").style.display = "none";//隱藏
groupType = type;
break;
default:
console.log('壞掉了');
}
}
//#endregion
//#region 選擇今昨日
function getday(post)
{
if (post == 0) {
var today = new Date();
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "-");
$('#DateGet').val(today_format);
}
else
{
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 1));
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "-");
$('#DateGet').val(dateLimit_format);
}
historyRange = $('#DateGet').val();
getTable();
}
//#endregion
//#region 選擇這上個月
function getmonth(post) {
if (post == 0) {
var today = new Date();
var today_format = today.toISOString().slice(0, 7).replace(/-/g, "-");
$('#MonthGet').val(today_format);
}
else {
var today = new Date();
today.setMonth(new Date().getMonth() - 1);
var dateLimit_format = today.toISOString().slice(0, 7).replace(/-/g, "-");
$('#MonthGet').val(dateLimit_format);
}
historyRange = $('#MonthGet').val();
getTable();
}
//#endregion
//#region 選擇今去年
function getyear(post) {
if (post == 0) {
var today = new Date();
var today_format = today.toISOString().slice(0, 4).replace(/-/g, "-");
$('#YearGet').val(today_format);
}
else {
var today = new Date();
today.setFullYear(new Date().getFullYear() - 1);
var dateLimit_format = today.toISOString().slice(0, 4).replace(/-/g, "-");
$('#YearGet').val(dateLimit_format);
}
historyRange = $('#YearGet').val();
getTable();
}
//#endregion
function getTable()
{
console.log(groupType);
console.log(historyRange);
}
//#endregion
</script> </script>
} }

View File

@ -1 +1,177 @@
<p>1</p> <div class="row mb-5 d-flex justify-content-start">
<div class="pr-3">
<div class="btn-group btn-group-md">
<button type="button" class="btn btn-success waves-effect waves-themed" onclick="ChangeStatus(0)" id="errbutton0">未解決</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="ChangeStatus(1)" id="errbutton1">己解決</button>
</div>
</div>
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="ChangeDate30exception()">近30天</button>
</div>
<div class="pr-6">
<div class="form-group">
<input class="form-control" id="date-range-exception" type="text" name="date" value="">
</div>
</div>
</div>
<div class="row d-flex justify-content-end">
<button type="button" class="btn btn-success waves-effect waves-themed mb-3" onclick="ExportExcelToExc()">
<span class="fal fa-file-excel mr-1"></span>
匯出
</button>
</div>
<div class="row mb-5">
<div class="w-100">
<table class="table table-bordered table-hover m-0 text-center" id="Exception_Table">
<thead class="thead-themed">
<tr>
<th>電站名稱</th>
<th>異常ID</th>
<th>發生時間</th>
<th>異常類別</th>
<th>設備編號</th>
<th>異常原因</th>
<th>派工/維運單號</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<table class="table table-bordered table-hover m-0 text-center" id="NOSEE" style="display:none">
<thead class="thead-themed">
<tr>
<th>電站名稱</th>
<th>異常ID</th>
<th>發生時間</th>
<th>異常類別</th>
<th>設備編號</th>
<th>異常原因</th>
</tr>
</thead>
<tbody id="NOSEEBODY">
</tbody>
</table>
</div>
</div>
<div class="modal fade" id="exception-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-content">
<div class="modal-header">
<h4 class="modal-title">
<span class="main-title"></span><span class="sub-title"></span>
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<form id="recode-form-exc">
<div class="row mb-3">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="power_station_select_modal_exc">電站</label>
<input class="form-control" id="power_station_select_modal_exc" type="text" name="power_station_select_modal_exc" />
@*<select class="form-control" id="power_station_select_modal_exc">
</select>*@
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="work_time_modal_exc">作業日期</label>
<input class="form-control" id="work_time_modal_exc" type="date" name="work_time_modal_exc" />
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="example-select">狀態</label>
<div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input ml-auto" id="status_none_complete_exc" name="status_modal" value="0" />
<label class="custom-control-label" for="status_none_complete_exc">未完成</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input ml-auto" id="status_complete_exc" name="status_modal" value="1" />
<label class="custom-control-label" for="status_complete_exc">完成</label>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="work_person_select_modal_exc">執行人員</label>
<select class="form-control" id="work_person_select_modal_exc">
</select>
</div>
</div>
</div>
<div class="row mb-3 fix-div">
<div class="col-lg-6">
<div class="form-group">
<div class="form-group">
<label class="form-label" for="error_code_modal_exc">異常編號</label>
<input class="form-control" id="error_code_modal_exc" type="text" name="error_code_modal_exc" />
</div>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="fix_do_modal_exc">維修項目</label>
<input class="form-control" id="fix_do_modal_exc" type="text" name="fix_do_modal_exc" />
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-lg-12">
<div class="form-group">
<label class="form-label" for="notice_textarea_modal_exc">巡檢注意事項</label>
<textarea class="form-control" id="notice_textarea_modal_exc" rows="5"></textarea>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-lg-12">
<div class="form-group">
<label class="form-label" for="description_textarea_modal_exc">結果描述</label>
<textarea class="form-control" id="description_textarea_modal_exc" rows="5"></textarea>
</div>
</div>
</div>
</form>
<div class="row align-items-center">
<div class="col-2">
<p>檔案上傳</p>
</div>
<div id="recode_files_div_exc" class="col-10">
<div class="row px-3 mb-3 d-flex justify-content-start align-items-center img-zoom-div">
</div>
</div>
</div>
<div class="row px-3">
<form id="recode-file-form_exc" class="dropzone needsclick dz-clickable col-12" style="min-height: 7rem;">
<div class="fallback">
<input type="file" multiple />
</div>
<div class="dz-message needsclick">
<i class="fal fa-cloud-upload text-muted mb-3"></i> <br>
<span class="text-uppercase">將圖片拖曳至這裡或點擊選擇圖片.</span>
<br>
<span class="fs-sm text-muted">僅供預覽,並未實際上傳。</span>
</div>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary" id="save-recode-btn" onclick="SaveException()">確定</button>
</div>
</div>
</div>
</div>

View File

@ -1 +1,87 @@
<p>2</p> <div class="row mb-5 d-flex justify-content-start">
<div class="pr-3">
<div class="btn-group btn-group-md">
<button type="button" class="btn btn-success waves-effect waves-themed" id="Group0" onclick="ChangeGroup(0)">日</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" id="Group1" onclick="ChangeGroup(1)">月</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" id="Group2" onclick="ChangeGroup(2)">年</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" id="Group3" onclick="ChangeGroup(3)">歷年</button>
</div>
</div>
<div class="pr-3" id="Today">
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="getday(0)">今日</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="getday(1)">昨日</button>
</div>
<div class="pr-3" id="ToMonth" style="display:none">
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="getmonth(0)">這個月</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="getmonth(1)">上個月</button>
</div>
<div class="pr-3" id="ToYear" style="display:none">
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="getyear(0)">今年</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="getyear(1)">去年</button>
</div>
<div class="pr-3">
<div class="btn-group" id="js-demo-nesting" role="group" aria-label="Button group with nested dropdown">
@*<button type="button" class="btn btn-secondary waves-effect waves-themed"> &lt; </button>
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle waves-effect waves-themed" data-toggle="dropdown">2021 五月 </button>
<div class="dropdown-menu">
<a class="dropdown-item" href="javascript:void(0)">2021 四月</a>
<a class="dropdown-item" href="javascript:void(0)">2021 三月</a>
</div>
</div>
<button type="button" class="btn btn-secondary waves-effect waves-themed"> &gt; </button>*@
<input type="date" class="form-control" id="DateGet"/>
<input type="month" class="form-control" id="MonthGet" style="display:none"/>
<input type="number" class="form-control" min="1900" max="2099" step="1" id="YearGet" style="display:none"/>
</div>
</div>
@*<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed">列印報告</button>
</div>*@
</div>
<div class="row mb-5">
<div class="card p-3 w-100">
<h5 class="font-weight-bold mb-3 pl-5 pb-3">總結</h5>
<table class="table m-0">
<thead>
<tr>
<th>時間</th>
<th>發電量(kWh)</th>
<th>發電小時</th>
<th>日射量(kWh/m2)</th>
<th>PR(%)</th>
<th>溫度(℃)</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">2021-05</th>
<td>126,121.7</td>
<td>119.04</td>
<td>140.39</td>
<td>84.8</td>
<td>91.9</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row mb-5">
<div class="card p-3 w-100">
<div class="row mb-5 d-flex justify-content-end">
</div>
<p>放圖表</p>
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB