diff --git a/Frontend/_accountManagement.html b/Frontend/_accountManagement.html
index ba2e04c..9124d68 100644
--- a/Frontend/_accountManagement.html
+++ b/Frontend/_accountManagement.html
@@ -874,21 +874,20 @@
pageAct.useDevSys = [];
}
- function setAuthPage() {
- $(`#accAuthPageTable input[type=checkbox]`).prop('disabled', false);
- $.each($(`#accAuthPageTable input[type=checkbox]:checked`), function (i, v) {
- $(v).click();
- });
+ function setAuthPage() {
+ $(`#accAuthPageTable input[type=checkbox]`).removeClass();
+ $.each($(`#accAuthPageTable input[type=checkbox]:checked`), function (i, v) {
+ $(v).click();
+ });
- pageAct.authCode = pageAct.authCode.filter(function (elem, index, self) {
- return index === self.indexOf(elem);
- });
+ pageAct.authCode = pageAct.authCode.filter(function (elem, index, self) {
+ return index === self.indexOf(elem);
+ });
- $.each(pageAct.authCode, function (i, v) {
- $(`#accAuthPageTable input[id=${v}]`).click();
- $(`#accAuthPageTable input[id=${v}]`).attr('disabled', true);
- });
- }
+ $.each(pageAct.authCode, function (i, v) {
+ $(`#accAuthPageTable input[id=${v}]`).click();
+ });
+ }
function getUsrDevSys(user_guid) {
let url = baseApiUrl + "/User/GetUsrDevSys";
diff --git a/Frontend/_historyData.html b/Frontend/_historyData.html
index 09e1404..09798f0 100644
--- a/Frontend/_historyData.html
+++ b/Frontend/_historyData.html
@@ -233,6 +233,7 @@
$('#js_nested_list').html(strHtml);
$(`[data-tabname="hisListItem"]`).YTTab();
}
+ $(loadEle).Loading("close");
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
}
@@ -497,7 +498,7 @@
$(loadEle).Loading("close");
},
complete: (xhr) => {
- setLoading(false);
+ $(loadEle).Loading("close");
},
});
// ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
diff --git a/Frontend/_operation.html b/Frontend/_operation.html
index e080a32..ae880e7 100644
--- a/Frontend/_operation.html
+++ b/Frontend/_operation.html
@@ -861,7 +861,6 @@
}
opeRecTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
- $(tag).DataTable().order([10, 'desc']).draw();
}
function setType(wt) {
@@ -894,23 +893,23 @@
let ytd = displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'date').replaceAll('/', '-')
if (dateType == 'tdy') {
- pageAct.startdate = displayDate(new Date(new Date().setDate(new Date().getDate() + 1)), 'datetime');
- pageAct.enddate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() + 2)), 'date'));
+ pageAct.startdate = displayDate(new Date(new Date().setDate(new Date().getDate())), 'datetime').toString().replaceAll("/", "-").split(" ")[0] + "T00:00:00";
+ pageAct.enddate = displayDate(new Date(new Date().setDate(new Date().getDate())), 'datetime').toString().replaceAll("/", "-").split(" ")[0] + "T23:59:59";
$('#startdate').val(today);
$('#startdate').data('val', today);
$('#enddate').val(today);
$('#enddate').data('val', today);
}
else if (dateType == 'ytd') {
- pageAct.startdate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate())), 'date'));
- pageAct.enddate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() + 1)), 'date'));
+ pageAct.startdate = displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'datetime').toString().replaceAll("/", "-").split(" ")[0] + "T00:00:00";
+ pageAct.enddate = displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'datetime').toString().replaceAll("/", "-").split(" ")[0] + "T23:59:59";
$('#startdate').val(ytd);
$('#startdate').data('val', ytd);
$('#enddate').val(ytd);
$('#enddate').data('val', ytd);
}
else {
- pageAct.enddate = new Date(displayDate(new Date(pageAct.enddate.valueOf()).setDate(pageAct.enddate.getDate() + 2), 'date'));
+ pageAct.enddate = displayDate(new Date(pageAct.enddate.valueOf()).setDate(pageAct.enddate.getDate()), 'date').toString().replaceAll("/", "-") + "T23:59:59";
$(`[onclick^=setDate]`).removeClass('btn-info');
$(`[onclick^=setDate]`).addClass('btn-secondary');
if ($('#startdate').val() == $('#enddate').val()) {
@@ -947,6 +946,8 @@
function snSearch() {
clearPageAct();
+ pageAct.startdate = $('#startdate').val() + "T00:00:00";
+ pageAct.enddate = $('#enddate').val() + "T23:59:59"
pageAct.serial_number = $('#serial_number').val() || null;
refTable();
}
@@ -1005,14 +1006,14 @@
}
function exportExcel(e) {
-
+ console.log("export", e)
let url = baseApiUrl + "/operation/OpeExportExcel";
+
objSendData.Data = {
work_type: pageAct.work_type,
startdate: pageAct.startdate == undefined ? null : pageAct.startdate,
enddate: pageAct.enddate == undefined ? null : pageAct.enddate,
};
-
ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
if (rel.code == "0000")
location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + cookies.get("JWT-Authorization");
diff --git a/Frontend/css/site.css b/Frontend/css/site.css
index bc8a92e..1c890ae 100644
--- a/Frontend/css/site.css
+++ b/Frontend/css/site.css
@@ -740,3 +740,7 @@ a[data-tabname="topFunBtn"]:hover { color: var(--theme-primary-50); }
.t-yellow {
color: var(--yt-yellow-1);
}
+
+input.disabledBox {
+ pointer-events: none;
+}
\ No newline at end of file
diff --git a/FrontendWebApi/ApiControllers/OperationController.cs b/FrontendWebApi/ApiControllers/OperationController.cs
index 70679ec..d0e6e02 100644
--- a/FrontendWebApi/ApiControllers/OperationController.cs
+++ b/FrontendWebApi/ApiControllers/OperationController.cs
@@ -351,35 +351,35 @@ namespace FrontendWebApi.ApiControllers
cell = row.CreateCell(i);
if (i == 0)
{
- cell.SetCellValue(of.system_key);
+ cell.SetCellValue(of.system_key ?? "");
}
if (i == 1)
{
- cell.SetCellValue(of.name);
+ cell.SetCellValue(of.name ?? "");
}
if (i == 2)
{
- cell.SetCellValue(of.contact_person);
+ cell.SetCellValue(of.contact_person ?? "");
}
if (i == 3)
{
- cell.SetCellValue(of.phone);
+ cell.SetCellValue(of.phone ?? "");
}
if (i == 4)
{
- cell.SetCellValue(of.email);
+ cell.SetCellValue(of.email ?? "");
}
if (i == 5)
{
- cell.SetCellValue(of.tax_id_number);
+ cell.SetCellValue(of.tax_id_number ?? "");
}
if (i == 6)
{
- cell.SetCellValue(of.remark);
+ cell.SetCellValue(of.remark ?? "");
}
if (i == 7)
{
- cell.SetCellValue(of.Created_at);
+ cell.SetCellValue(of.Created_at ?? "");
}
cell.CellStyle = style12;
@@ -389,343 +389,352 @@ namespace FrontendWebApi.ApiControllers
}
else if (ee.work_type == 1)
{
- var sqlString = $@"select opr.*, concat(d.device_floor_tag, ' ', d.device_last_name, ' ', d.device_serial_tag) as device_name, ui.full_name as user_full_name
+ var sqlString = $@"select opr.*, d.full_name as device_name, ui.full_name as user_full_name
from operation_record opr
left join device d on opr.fix_do_code = d.device_number and d.deleted = 0 and d.device_area_tag = SUBSTRING_INDEX(opr.fix_do_code, '_', 1)
- and d.device_building_tag = SUBSTRING_INDEX(opr.fix_do_code, '_', 2) and d.device_floor_tag = SUBSTRING_INDEX(opr.fix_do_code, '_', 5)
+ and d.device_building_tag = SUBSTRING_INDEX(SUBSTRING_INDEX(opr.fix_do_code, '_', 2), '_', -1) and d.device_floor_tag = SUBSTRING_INDEX(SUBSTRING_INDEX(opr.fix_do_code, '_', 5), '_', -1)
and d.device_system_tag = opr.device_system_category_layer2 and d.device_name_tag = opr.device_system_category_layer3
left join userinfo ui on opr.work_person_id = ui.userinfo_guid
- where opr.deleted = 0 and opr.work_type = 1;";
- var sheet = workbook.CreateSheet("廠商資料");
- var operation_record = backendRepository.GetAllAsync(sqlString, null);
- List operation_record_file = new List();
-
- if (operation_record.Result.Count > 0)
- {
- foreach (var or in operation_record.Result)
- {
- sqlString = $@"select * from operation_record_file where record_id = @record_id";
- var param = new { @record_id = or.id };
- operation_record_file = backendRepository.GetAllAsync(sqlString, param).Result;
- or.lorf = operation_record_file;
- }
-
- int RowPosition = 0;
- #region set cell
- IRow row = sheet.CreateRow(RowPosition);
- sheet.SetColumnWidth(0, 4 * 160 * 12);
- sheet.SetColumnWidth(1, 4 * 160 * 12);
- sheet.SetColumnWidth(2, 4 * 160 * 12);
- sheet.SetColumnWidth(3, 4 * 160 * 12);
- sheet.SetColumnWidth(4, 4 * 160 * 12);
- sheet.SetColumnWidth(5, 4 * 160 * 12);
- sheet.SetColumnWidth(6, 4 * 160 * 12);
- sheet.SetColumnWidth(7, 4 * 160 * 12);
- sheet.SetColumnWidth(8, 4 * 160 * 12);
- sheet.SetColumnWidth(9, 4 * 160 * 12);
- ICell cell = row.CreateCell(0);
- cell.SetCellValue("項目");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(1);
- cell.SetCellValue("位置");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(2);
- cell.SetCellValue("表單號");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(3);
- cell.SetCellValue("設備名稱");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(4);
- cell.SetCellValue("狀態");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(5);
- cell.SetCellValue("處理人員");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(6);
- cell.SetCellValue("預計施工時間");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(7);
- cell.SetCellValue("檔案上傳");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(8);
- cell.SetCellValue("完成時間");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(9);
- cell.SetCellValue("建立時間");
- cell.CellStyle = styleLine12;
- #endregion
- foreach (var or in operation_record.Result)
- {
- RowPosition += 1;
- row = sheet.CreateRow(RowPosition);
- for (var i = 0; i < 10; i++)
- {
- cell = row.CreateCell(i);
- if (i == 0)
- {
- cell.SetCellValue(or.work_type_name);
- }
- if (i == 1)
- {
- cell.SetCellValue(or.location);
- }
- if (i == 2)
- {
- cell.SetCellValue(or.formId);
- }
- if (i == 3)
- {
- cell.SetCellValue(or.device_name);
- }
- if (i == 4)
- {
- cell.SetCellValue(or.status_name);
- }
- if (i == 5)
- {
- cell.SetCellValue(or.user_full_name);
- }
- if (i == 6)
- {
- cell.SetCellValue(or.start_time != null ? ((DateTime)or.start_time).ToString("yyyy/MM/dd HH:mm:dd") : null);
- }
- if (i == 7)
- {
- var imageNames = or.lorf.Count > 0 ? or.lorf.Select(x => x.save_file_name).ToList() : null;
- if (imageNames != null)
- {
- //insert image process
- var dy1 = 10;
- var dx1 = 10;
-
- //image column
- sheet.SetColumnWidth(i, 16 * imageNames.Count * 256); //width: picture width(16:100), image total, per character(256)
- foreach (var ins in imageNames)
- {
- //image initial
- var extName = ins.Split('.')[1].ToUpper().Equals("JPG") ? "PNG" : ins.Split('.')[1].ToUpper();
- var fullPath = Path.Combine(operationFileSaveAsPath, ins);
- var img = Image.FromFile(fullPath);
-
- //compress image
- decimal sizeRatio = ((decimal)img.Height / img.Width);
- int thumbWidth = 100;
- int thumbHeight = decimal.ToInt32(sizeRatio * thumbWidth);
- var thumbStream = img.GetThumbnailImage(thumbWidth, thumbHeight, () => false, IntPtr.Zero);
- var memoryStream = new MemoryStream();
- thumbStream.Save(memoryStream, ImageFormat.Jpeg);
-
- //setting pictureType enum
- int format = 0;
- var drawing = (XSSFDrawing)sheet.CreateDrawingPatriarch();
- format = Convert.ToInt32(Enum.Parse(typeof(PictureType), extName));
-
- //set picture size and location
- if (format != 0)
- {
- var pictureIds = workbook.AddPicture(memoryStream.ToArray(), format);
- XSSFClientAnchor anchor = new XSSFClientAnchor(XSSFShape.EMU_PER_PIXEL * dx1, XSSFShape.EMU_PER_PIXEL * dy1, 0, 0, i, j, 0, 0);
- anchor.AnchorType = AnchorType.DontMoveAndResize;
- var picture = (XSSFPicture)drawing.CreatePicture(anchor, pictureIds);
- var size = picture.GetImageDimension();
- row.HeightInPoints = size.Height;
- picture.Resize();
-
- //add 105 each new pic
- dx1 += 105;
- }
- }
- }
-
- j++;
- }
- if (i == 8)
- {
- cell.SetCellValue(or.finish_time != null ? ((DateTime)or.finish_time).ToString("yyyy/MM/dd HH:mm:dd") : null);
- }
- if (i == 9)
- {
- cell.SetCellValue(or.Created_at);
- }
-
- cell.CellStyle = style12;
- }
- }
- }
- }
- else if (ee.work_type == 2)
- {
- var sqlString = $@"select opr.*, concat(d.device_floor_tag, ' ', d.device_last_name, ' ', d.device_serial_tag) as device_name, ui.full_name as user_full_name
- from operation_record opr
- left join device d on opr.fix_do_code = d.device_number and d.deleted = 0 and d.device_area_tag = SUBSTRING_INDEX(opr.fix_do_code, '_', 1)
- and d.device_building_tag = SUBSTRING_INDEX(opr.fix_do_code, '_', 2) and d.device_floor_tag = SUBSTRING_INDEX(opr.fix_do_code, '_', 5)
- and d.device_system_tag = opr.device_system_category_layer2 and d.device_name_tag = opr.device_system_category_layer3
- left join userinfo ui on opr.work_person_id = ui.userinfo_guid
- where opr.deleted = 0 and opr.work_type = 2";
+ where opr.deleted = 0 and opr.work_type = 1 and opr.created_at >= '{ee.startdate?.ToString("yyyy-MM-dd") + "T00:00:00"}' and opr.created_at <= '{ee.enddate?.ToString("yyyy-MM-dd") + "T23:59:59"}';";
var sheet = workbook.CreateSheet("廠商資料");
var operation_record = backendRepository.GetAllAsync(sqlString);
List operation_record_file = new List();
- if (operation_record.Result.Count > 0)
+ if (operation_record.Result != null)
{
- foreach (var or in operation_record.Result)
+ if (operation_record.Result.Count > 0)
{
- sqlString = $@"select * from operation_record_file where record_id = @record_id";
- var param = new { @record_id = or.id };
- operation_record_file = backendRepository.GetAllAsync(sqlString, param).Result;
- or.lorf = operation_record_file;
- }
-
- int RowPosition = 0;
- #region set cell
- IRow row = sheet.CreateRow(RowPosition);
- sheet.SetColumnWidth(0, 4 * 160 * 12);
- sheet.SetColumnWidth(1, 4 * 160 * 12);
- sheet.SetColumnWidth(2, 4 * 160 * 12);
- sheet.SetColumnWidth(3, 4 * 160 * 12);
- sheet.SetColumnWidth(4, 4 * 160 * 12);
- sheet.SetColumnWidth(5, 4 * 160 * 12);
- sheet.SetColumnWidth(6, 4 * 160 * 12);
- sheet.SetColumnWidth(7, 4 * 160 * 12);
- sheet.SetColumnWidth(8, 4 * 160 * 12);
- sheet.SetColumnWidth(9, 4 * 160 * 12);
- sheet.SetColumnWidth(10, 4 * 160 * 12);
- ICell cell = row.CreateCell(0);
- cell.SetCellValue("項目");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(1);
- cell.SetCellValue("位置");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(2);
- cell.SetCellValue("異常代號");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(3);
- cell.SetCellValue("表單號");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(4);
- cell.SetCellValue("設備名稱");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(5);
- cell.SetCellValue("狀態");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(6);
- cell.SetCellValue("處理人員");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(7);
- cell.SetCellValue("預計施工時間");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(8);
- cell.SetCellValue("檔案上傳");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(9);
- cell.SetCellValue("完成時間");
- cell.CellStyle = styleLine12;
- cell = row.CreateCell(10);
- cell.SetCellValue("建立時間");
- cell.CellStyle = styleLine12;
-
- #endregion
- foreach (var or in operation_record.Result)
- {
- RowPosition += 1;
- row = sheet.CreateRow(RowPosition);
- for (var i = 0; i < 11; i++)//column
+ foreach (var or in operation_record.Result)
{
- cell = row.CreateCell(i);
- if (i == 0)
+ sqlString = $@"select * from operation_record_file where record_id = @record_id";
+ var param = new { @record_id = or.id };
+ operation_record_file = backendRepository.GetAllAsync(sqlString, param).Result;
+ or.lorf = operation_record_file;
+ }
+
+ int RowPosition = 0;
+ #region set cell
+ IRow row = sheet.CreateRow(RowPosition);
+ sheet.SetColumnWidth(0, 4 * 160 * 12);
+ sheet.SetColumnWidth(1, 4 * 160 * 12);
+ sheet.SetColumnWidth(2, 4 * 160 * 12);
+ sheet.SetColumnWidth(3, 4 * 160 * 12);
+ sheet.SetColumnWidth(4, 4 * 160 * 12);
+ sheet.SetColumnWidth(5, 4 * 160 * 12);
+ sheet.SetColumnWidth(6, 4 * 160 * 12);
+ sheet.SetColumnWidth(7, 4 * 160 * 12);
+ sheet.SetColumnWidth(8, 4 * 160 * 12);
+ sheet.SetColumnWidth(9, 4 * 160 * 12);
+ ICell cell = row.CreateCell(0);
+ cell.SetCellValue("項目");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(1);
+ cell.SetCellValue("位置");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(2);
+ cell.SetCellValue("表單號");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(3);
+ cell.SetCellValue("設備名稱");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(4);
+ cell.SetCellValue("狀態");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(5);
+ cell.SetCellValue("處理人員");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(6);
+ cell.SetCellValue("預計施工時間");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(7);
+ cell.SetCellValue("檔案上傳");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(8);
+ cell.SetCellValue("完成時間");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(9);
+ cell.SetCellValue("建立時間");
+ cell.CellStyle = styleLine12;
+ #endregion
+ foreach (var or in operation_record.Result)
+ {
+ RowPosition += 1;
+ row = sheet.CreateRow(RowPosition);
+ for (var i = 0; i < 10; i++)
{
- cell.SetCellValue(or.work_type_name);
- }
- if (i == 1)
- {
- cell.SetCellValue(or.location);
- }
- if (i == 2)
- {
- cell.SetCellValue(or.error_code);
- sheet.AutoSizeColumn(i);
- }
- if (i == 3)
- {
- cell.SetCellValue(or.formId);
- }
- if (i == 4)
- {
- cell.SetCellValue(or.device_name);
- }
- if (i == 5)
- {
- cell.SetCellValue(or.status_name);
- }
- if (i == 6)
- {
- cell.SetCellValue(or.user_full_name);
- }
- if (i == 7)
- {
- cell.SetCellValue(or.start_time != null ? ((DateTime)or.start_time).ToString("yyyy/MM/dd HH:mm:ss") : null);
- }
- if (i == 8)//image
- {
- var imageNames = or.lorf.Count > 0 ? or.lorf.Select(x => x.save_file_name).ToList() : null;
- if (imageNames != null)
+ cell = row.CreateCell(i);
+ if (i == 0)
{
- //insert image process
- var dy1 = 10;
- var dx1 = 10;
-
- //image column
- sheet.SetColumnWidth(i, 16 * imageNames.Count * 256); //width: picture width(16:100), image total, per character(256)
- foreach (var ins in imageNames)
+ cell.SetCellValue(or.work_type_name == "null" ? "" : or.work_type_name);
+ }
+ if (i == 1)
+ {
+ cell.SetCellValue(or.location == "null" ? "" : or.location);
+ }
+ if (i == 2)
+ {
+ cell.SetCellValue(or.formId == "null" ? "" : or.formId);
+ }
+ if (i == 3)
+ {
+ cell.SetCellValue(or.device_name == "null" ? "" : or.device_name);
+ }
+ if (i == 4)
+ {
+ cell.SetCellValue(or.status_name == "null" ? "" : or.status_name);
+ }
+ if (i == 5)
+ {
+ cell.SetCellValue(or.user_full_name == "null" ? "" : or.user_full_name);
+ }
+ if (i == 6)
+ {
+ cell.SetCellValue(or.start_time != null ? ((DateTime)or.start_time).ToString("yyyy/MM/dd HH:mm:dd") : null);
+ }
+ if (i == 7)
+ {
+ var imageNames = or.lorf.Count > 0 ? or.lorf.Where(x => x.ori_file_name.Contains("JPG") || x.ori_file_name.Contains("PNG")).Select(x => x.save_file_name).ToList() : null;
+ if (imageNames != null)
{
- //image initial
- var extName = ins.Split('.')[1].ToUpper().Equals("JPG") ? "PNG" : ins.Split('.')[1].ToUpper();
- var fullPath = Path.Combine(operationFileSaveAsPath, ins);
- var img = Image.FromFile(fullPath);
+ //insert image process
+ var dy1 = 10;
+ var dx1 = 10;
- //compress image
- decimal sizeRatio = ((decimal)img.Height / img.Width);
- int thumbWidth = 100;
- int thumbHeight = decimal.ToInt32(sizeRatio * thumbWidth);
- var thumbStream = img.GetThumbnailImage(thumbWidth, thumbHeight, () => false, IntPtr.Zero);
- var memoryStream = new MemoryStream();
- thumbStream.Save(memoryStream, ImageFormat.Jpeg);
-
- //setting pictureType enum
- int format = 0;
- var drawing = (XSSFDrawing)sheet.CreateDrawingPatriarch();
- format = Convert.ToInt32(Enum.Parse(typeof(PictureType), extName));
-
- //set picture size and location
- if (format != 0)
+ //image column
+ sheet.SetColumnWidth(i, 16 * imageNames.Count * 256); //width: picture width(16:100), image total, per character(256)
+ foreach (var ins in imageNames)
{
- var pictureIds = workbook.AddPicture(memoryStream.ToArray(), format);
- XSSFClientAnchor anchor = new XSSFClientAnchor(XSSFShape.EMU_PER_PIXEL * dx1, XSSFShape.EMU_PER_PIXEL * dy1, 0, 0, i, j, 0, 0);
- anchor.AnchorType = AnchorType.DontMoveAndResize;
- var picture = (XSSFPicture)drawing.CreatePicture(anchor, pictureIds);
- var size = picture.GetImageDimension();
- row.HeightInPoints = size.Height;
- picture.Resize();
+ //image initial
+ var extName = ins.Split('.')[1].ToUpper().Equals("JPG") ? "PNG" : ins.Split('.')[1].ToUpper();
+ var fullPath = Path.Combine(operationFileSaveAsPath, ins);
+ var img = Image.FromFile(fullPath);
- //add 105 each new pic
- dx1 += 105;
+ //compress image
+ decimal sizeRatio = ((decimal)img.Height / img.Width);
+ int thumbWidth = 100;
+ int thumbHeight = decimal.ToInt32(sizeRatio * thumbWidth);
+ var thumbStream = img.GetThumbnailImage(thumbWidth, thumbHeight, () => false, IntPtr.Zero);
+ var memoryStream = new MemoryStream();
+ thumbStream.Save(memoryStream, ImageFormat.Jpeg);
+
+ //setting pictureType enum
+ int format = 0;
+ var drawing = (XSSFDrawing)sheet.CreateDrawingPatriarch();
+ format = Convert.ToInt32(Enum.Parse(typeof(PictureType), extName));
+
+ //set picture size and location
+ if (format != 0)
+ {
+ var pictureIds = workbook.AddPicture(memoryStream.ToArray(), format);
+ XSSFClientAnchor anchor = new XSSFClientAnchor(XSSFShape.EMU_PER_PIXEL * dx1, XSSFShape.EMU_PER_PIXEL * dy1, 0, 0, i, j, 0, 0);
+ anchor.AnchorType = AnchorType.DontMoveAndResize;
+ var picture = (XSSFPicture)drawing.CreatePicture(anchor, pictureIds);
+ var size = picture.GetImageDimension();
+ row.HeightInPoints = size.Height;
+ picture.Resize();
+
+ //add 105 each new pic
+ dx1 += 105;
+ }
}
}
+
+ j++;
+ }
+ if (i == 8)
+ {
+ cell.SetCellValue(or.finish_time != null ? ((DateTime)or.finish_time).ToString("yyyy/MM/dd HH:mm:dd") : null);
+ }
+ if (i == 9)
+ {
+ cell.SetCellValue(or.Created_at ?? "");
}
- j++;
- }
- if (i == 9)
- {
- cell.SetCellValue(or.finish_time != null ? ((DateTime)or.finish_time).ToString("yyyy/MM/dd HH:mm:ss") : null);
- }
- if (i == 10)
- {
- cell.SetCellValue(or.Created_at);
+ cell.CellStyle = style12;
}
+ }
+ }
- cell.CellStyle = style12;
+ }
+ }
+ else if (ee.work_type == 2)
+ {
+ var sqlString = $@"select opr.*, d.full_name as device_name, ui.full_name as user_full_name
+ from operation_record opr
+ left join device d on opr.fix_do_code = d.device_number and d.deleted = 0 and d.device_area_tag = SUBSTRING_INDEX(opr.fix_do_code, '_', 1)
+ and d.device_building_tag = SUBSTRING_INDEX(SUBSTRING_INDEX(opr.fix_do_code, '_', 2), '_', -1) and d.device_floor_tag = SUBSTRING_INDEX(SUBSTRING_INDEX(opr.fix_do_code, '_', 5), '_', -1)
+ and d.device_system_tag = opr.device_system_category_layer2 and d.device_name_tag = opr.device_system_category_layer3
+ left join userinfo ui on opr.work_person_id = ui.userinfo_guid
+ where opr.deleted = 0 and opr.work_type = 2 and opr.created_at >= '{ee.startdate?.ToString("yyyy-MM-dd") + "T00:00:00"}' and opr.created_at <= '{ee.enddate?.ToString("yyyy-MM-dd") + "T23:59:59"}';";
+ var sheet = workbook.CreateSheet("廠商資料");
+ var operation_record = backendRepository.GetAllAsync(sqlString);
+ List operation_record_file = new List();
+
+ if (operation_record.Result != null)
+ {
+ if (operation_record.Result.Count > 0)
+ {
+ foreach (var or in operation_record.Result)
+ {
+
+ sqlString = $@"select * from operation_record_file where record_id = @record_id";
+ var param = new { @record_id = or.id };
+ operation_record_file = backendRepository.GetAllAsync(sqlString, param).Result;
+ or.lorf = operation_record_file;
+ }
+
+ int RowPosition = 0;
+ #region set cell
+ IRow row = sheet.CreateRow(RowPosition);
+ sheet.SetColumnWidth(0, 4 * 160 * 12);
+ sheet.SetColumnWidth(1, 4 * 160 * 12);
+ sheet.SetColumnWidth(2, 4 * 160 * 12);
+ sheet.SetColumnWidth(3, 4 * 160 * 12);
+ sheet.SetColumnWidth(4, 4 * 160 * 12);
+ sheet.SetColumnWidth(5, 4 * 160 * 12);
+ sheet.SetColumnWidth(6, 4 * 160 * 12);
+ sheet.SetColumnWidth(7, 4 * 160 * 12);
+ sheet.SetColumnWidth(8, 4 * 160 * 12);
+ sheet.SetColumnWidth(9, 4 * 160 * 12);
+ sheet.SetColumnWidth(10, 4 * 160 * 12);
+ ICell cell = row.CreateCell(0);
+ cell.SetCellValue("項目");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(1);
+ cell.SetCellValue("位置");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(2);
+ cell.SetCellValue("異常代號");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(3);
+ cell.SetCellValue("表單號");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(4);
+ cell.SetCellValue("設備名稱");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(5);
+ cell.SetCellValue("狀態");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(6);
+ cell.SetCellValue("處理人員");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(7);
+ cell.SetCellValue("預計施工時間");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(8);
+ cell.SetCellValue("檔案上傳");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(9);
+ cell.SetCellValue("完成時間");
+ cell.CellStyle = styleLine12;
+ cell = row.CreateCell(10);
+ cell.SetCellValue("建立時間");
+ cell.CellStyle = styleLine12;
+
+ #endregion
+ foreach (var or in operation_record.Result)
+ {
+ RowPosition += 1;
+ row = sheet.CreateRow(RowPosition);
+ for (var i = 0; i < 11; i++)//column
+ {
+ cell = row.CreateCell(i);
+ if (i == 0)
+ {
+ cell.SetCellValue(or.work_type_name == "null" ? "" : or.work_type_name);
+ }
+ if (i == 1)
+ {
+ cell.SetCellValue(or.location == "null" ? "" : or.location);
+ }
+ if (i == 2)
+ {
+ cell.SetCellValue(or.error_code == "null" ? "" : or.error_code);
+ sheet.AutoSizeColumn(i);
+ }
+ if (i == 3)
+ {
+ cell.SetCellValue(or.formId == "null" ? "" : or.formId);
+ }
+ if (i == 4)
+ {
+ cell.SetCellValue(or.device_name == "null" ? "" : or.device_name);
+ }
+ if (i == 5)
+ {
+ cell.SetCellValue(or.status_name == "null" ? "" : or.status_name);
+ }
+ if (i == 6)
+ {
+ cell.SetCellValue(or.user_full_name == "null" ? "" : or.user_full_name);
+ }
+ if (i == 7)
+ {
+ cell.SetCellValue(or.start_time != null ? ((DateTime)or.start_time).ToString("yyyy/MM/dd HH:mm:ss") : null);
+ }
+ if (i == 8)//image
+ {
+ var imageNames = or.lorf.Count > 0 ? or.lorf.Where(x => x.ori_file_name.Contains("JPG") || x.ori_file_name.Contains("PNG")).Select(x => x.save_file_name).ToList() : null;
+ if (imageNames != null)
+ {
+ //insert image process
+ var dy1 = 10;
+ var dx1 = 10;
+
+ //image column
+ sheet.SetColumnWidth(i, 16 * imageNames.Count * 256); //width: picture width(16:100), image total, per character(256)
+ foreach (var ins in imageNames)
+ {
+ //image initial
+ var extName = ins.Split('.')[1].ToUpper().Equals("JPG") ? "PNG" : ins.Split('.')[1].ToUpper();
+ var fullPath = Path.Combine(operationFileSaveAsPath, ins);
+ var img = Image.FromFile(fullPath);
+
+ //compress image
+ decimal sizeRatio = ((decimal)img.Height / img.Width);
+ int thumbWidth = 100;
+ int thumbHeight = decimal.ToInt32(sizeRatio * thumbWidth);
+ var thumbStream = img.GetThumbnailImage(thumbWidth, thumbHeight, () => false, IntPtr.Zero);
+ var memoryStream = new MemoryStream();
+ thumbStream.Save(memoryStream, ImageFormat.Jpeg);
+
+ //setting pictureType enum
+ int format = 0;
+ var drawing = (XSSFDrawing)sheet.CreateDrawingPatriarch();
+ format = Convert.ToInt32(Enum.Parse(typeof(PictureType), extName));
+
+ //set picture size and location
+ if (format != 0)
+ {
+ var pictureIds = workbook.AddPicture(memoryStream.ToArray(), format);
+ XSSFClientAnchor anchor = new XSSFClientAnchor(XSSFShape.EMU_PER_PIXEL * dx1, XSSFShape.EMU_PER_PIXEL * dy1, 0, 0, i, j, 0, 0);
+ anchor.AnchorType = AnchorType.DontMoveAndResize;
+ var picture = (XSSFPicture)drawing.CreatePicture(anchor, pictureIds);
+ var size = picture.GetImageDimension();
+ row.HeightInPoints = size.Height;
+ picture.Resize();
+
+ //add 105 each new pic
+ dx1 += 105;
+ }
+ }
+ }
+
+ j++;
+ }
+ if (i == 9)
+ {
+ cell.SetCellValue(or.finish_time != null ? ((DateTime)or.finish_time).ToString("yyyy/MM/dd HH:mm:ss") : null);
+ }
+ if (i == 10)
+ {
+ cell.SetCellValue(or.Created_at == "null" ? "" : or.Created_at);
+ }
+
+ cell.CellStyle = style12;
+
+ }
}
}
}
@@ -737,7 +746,7 @@ namespace FrontendWebApi.ApiControllers
apiResult.Code = "0000";
apiResult.Data = "operation/" + fileName;
}
- catch(Exception ex)
+ catch (Exception ex)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
diff --git a/FrontendWebApi/ApiControllers/UserController.cs b/FrontendWebApi/ApiControllers/UserController.cs
index 16b3b60..e129888 100644
--- a/FrontendWebApi/ApiControllers/UserController.cs
+++ b/FrontendWebApi/ApiControllers/UserController.cs
@@ -596,20 +596,23 @@ namespace FrontendWebApi.ApiControllers
}
else
{
+ await backendRepository.ExecuteSql($"delete from role_auth where role_guid = '{post.SelectedRoleId}' and AuthCode like '%PF%'");
if (post.SaveCheckAuth.Count > 0)
{
foreach (var item in post.SaveCheckAuth)
{
#region 新增權限
- Dictionary roleAuth = new Dictionary();
- roleAuth = new Dictionary()
- {
- { "@role_guid", post.SelectedRoleId},
- { "@AuthCode", item},
- { "@created_by", myUser.userinfo_guid}
- };
+ {
+ Dictionary roleAuth = new Dictionary();
+ roleAuth = new Dictionary()
+ {
+ { "@role_guid", post.SelectedRoleId},
+ { "@AuthCode", item},
+ { "@created_by", myUser.userinfo_guid}
+ };
- await backendRepository.AddOneByCustomTable(roleAuth, "role_auth");
+ await backendRepository.AddOneByCustomTable(roleAuth, "role_auth");
+ }
#endregion
}
}
diff --git a/FrontendWebApi/appsettings.Development.json b/FrontendWebApi/appsettings.Development.json
index f976969..9a5504c 100644
--- a/FrontendWebApi/appsettings.Development.json
+++ b/FrontendWebApi/appsettings.Development.json
@@ -16,9 +16,9 @@
"MySqlDBConfig": {
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
- //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
+ "Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
- "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
+ //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
//"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
//"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT
diff --git a/FrontendWebApi/wwwroot/excel/operation/維修_2023-08-03_2023-08-03.xlsx b/FrontendWebApi/wwwroot/excel/operation/維修_2023-08-03_2023-08-03.xlsx
new file mode 100644
index 0000000..25c52bb
Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/operation/維修_2023-08-03_2023-08-03.xlsx differ