更新版本至master

This commit is contained in:
dev02 2023-08-03 12:20:37 +08:00
parent 93f7b84701
commit 93c12bbbde
8 changed files with 371 additions and 354 deletions

View File

@ -874,21 +874,20 @@
pageAct.useDevSys = []; pageAct.useDevSys = [];
} }
function setAuthPage() { function setAuthPage() {
$(`#accAuthPageTable input[type=checkbox]`).prop('disabled', false); $(`#accAuthPageTable input[type=checkbox]`).removeClass();
$.each($(`#accAuthPageTable input[type=checkbox]:checked`), function (i, v) { $.each($(`#accAuthPageTable input[type=checkbox]:checked`), function (i, v) {
$(v).click(); $(v).click();
}); });
pageAct.authCode = pageAct.authCode.filter(function (elem, index, self) { pageAct.authCode = pageAct.authCode.filter(function (elem, index, self) {
return index === self.indexOf(elem); return index === self.indexOf(elem);
}); });
$.each(pageAct.authCode, function (i, v) { $.each(pageAct.authCode, function (i, v) {
$(`#accAuthPageTable input[id=${v}]`).click(); $(`#accAuthPageTable input[id=${v}]`).click();
$(`#accAuthPageTable input[id=${v}]`).attr('disabled', true); });
}); }
}
function getUsrDevSys(user_guid) { function getUsrDevSys(user_guid) {
let url = baseApiUrl + "/User/GetUsrDevSys"; let url = baseApiUrl + "/User/GetUsrDevSys";

View File

@ -233,6 +233,7 @@
$('#js_nested_list').html(strHtml); $('#js_nested_list').html(strHtml);
$(`[data-tabname="hisListItem"]`).YTTab(); $(`[data-tabname="hisListItem"]`).YTTab();
} }
$(loadEle).Loading("close");
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send(); ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
} }
@ -497,7 +498,7 @@
$(loadEle).Loading("close"); $(loadEle).Loading("close");
}, },
complete: (xhr) => { complete: (xhr) => {
setLoading(false); $(loadEle).Loading("close");
}, },
}); });
// ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) { // ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {

View File

@ -861,7 +861,6 @@
} }
opeRecTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs); opeRecTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
$(tag).DataTable().order([10, 'desc']).draw();
} }
function setType(wt) { function setType(wt) {
@ -894,23 +893,23 @@
let ytd = displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'date').replaceAll('/', '-') let ytd = displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'date').replaceAll('/', '-')
if (dateType == 'tdy') { if (dateType == 'tdy') {
pageAct.startdate = displayDate(new Date(new Date().setDate(new Date().getDate() + 1)), 'datetime'); pageAct.startdate = displayDate(new Date(new Date().setDate(new Date().getDate())), 'datetime').toString().replaceAll("/", "-").split(" ")[0] + "T00:00:00";
pageAct.enddate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() + 2)), 'date')); pageAct.enddate = displayDate(new Date(new Date().setDate(new Date().getDate())), 'datetime').toString().replaceAll("/", "-").split(" ")[0] + "T23:59:59";
$('#startdate').val(today); $('#startdate').val(today);
$('#startdate').data('val', today); $('#startdate').data('val', today);
$('#enddate').val(today); $('#enddate').val(today);
$('#enddate').data('val', today); $('#enddate').data('val', today);
} }
else if (dateType == 'ytd') { else if (dateType == 'ytd') {
pageAct.startdate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate())), 'date')); pageAct.startdate = displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'datetime').toString().replaceAll("/", "-").split(" ")[0] + "T00:00:00";
pageAct.enddate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() + 1)), 'date')); pageAct.enddate = displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'datetime').toString().replaceAll("/", "-").split(" ")[0] + "T23:59:59";
$('#startdate').val(ytd); $('#startdate').val(ytd);
$('#startdate').data('val', ytd); $('#startdate').data('val', ytd);
$('#enddate').val(ytd); $('#enddate').val(ytd);
$('#enddate').data('val', ytd); $('#enddate').data('val', ytd);
} }
else { 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]`).removeClass('btn-info');
$(`[onclick^=setDate]`).addClass('btn-secondary'); $(`[onclick^=setDate]`).addClass('btn-secondary');
if ($('#startdate').val() == $('#enddate').val()) { if ($('#startdate').val() == $('#enddate').val()) {
@ -947,6 +946,8 @@
function snSearch() { function snSearch() {
clearPageAct(); clearPageAct();
pageAct.startdate = $('#startdate').val() + "T00:00:00";
pageAct.enddate = $('#enddate').val() + "T23:59:59"
pageAct.serial_number = $('#serial_number').val() || null; pageAct.serial_number = $('#serial_number').val() || null;
refTable(); refTable();
} }
@ -1005,14 +1006,14 @@
} }
function exportExcel(e) { function exportExcel(e) {
console.log("export", e)
let url = baseApiUrl + "/operation/OpeExportExcel"; let url = baseApiUrl + "/operation/OpeExportExcel";
objSendData.Data = { objSendData.Data = {
work_type: pageAct.work_type, work_type: pageAct.work_type,
startdate: pageAct.startdate == undefined ? null : pageAct.startdate, startdate: pageAct.startdate == undefined ? null : pageAct.startdate,
enddate: pageAct.enddate == undefined ? null : pageAct.enddate, enddate: pageAct.enddate == undefined ? null : pageAct.enddate,
}; };
ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) { ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
if (rel.code == "0000") if (rel.code == "0000")
location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + cookies.get("JWT-Authorization"); location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + cookies.get("JWT-Authorization");

View File

@ -740,3 +740,7 @@ a[data-tabname="topFunBtn"]:hover { color: var(--theme-primary-50); }
.t-yellow { .t-yellow {
color: var(--yt-yellow-1); color: var(--yt-yellow-1);
} }
input.disabledBox {
pointer-events: none;
}

View File

@ -351,35 +351,35 @@ namespace FrontendWebApi.ApiControllers
cell = row.CreateCell(i); cell = row.CreateCell(i);
if (i == 0) if (i == 0)
{ {
cell.SetCellValue(of.system_key); cell.SetCellValue(of.system_key ?? "");
} }
if (i == 1) if (i == 1)
{ {
cell.SetCellValue(of.name); cell.SetCellValue(of.name ?? "");
} }
if (i == 2) if (i == 2)
{ {
cell.SetCellValue(of.contact_person); cell.SetCellValue(of.contact_person ?? "");
} }
if (i == 3) if (i == 3)
{ {
cell.SetCellValue(of.phone); cell.SetCellValue(of.phone ?? "");
} }
if (i == 4) if (i == 4)
{ {
cell.SetCellValue(of.email); cell.SetCellValue(of.email ?? "");
} }
if (i == 5) if (i == 5)
{ {
cell.SetCellValue(of.tax_id_number); cell.SetCellValue(of.tax_id_number ?? "");
} }
if (i == 6) if (i == 6)
{ {
cell.SetCellValue(of.remark); cell.SetCellValue(of.remark ?? "");
} }
if (i == 7) if (i == 7)
{ {
cell.SetCellValue(of.Created_at); cell.SetCellValue(of.Created_at ?? "");
} }
cell.CellStyle = style12; cell.CellStyle = style12;
@ -389,343 +389,352 @@ namespace FrontendWebApi.ApiControllers
} }
else if (ee.work_type == 1) 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 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) 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 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 left join userinfo ui on opr.work_person_id = ui.userinfo_guid
where opr.deleted = 0 and opr.work_type = 1;"; 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<Operation_Record>(sqlString, null);
List<Operation_Record_File> operation_record_file = new List<Operation_Record_File>();
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<Operation_Record_File>(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";
var sheet = workbook.CreateSheet("廠商資料"); var sheet = workbook.CreateSheet("廠商資料");
var operation_record = backendRepository.GetAllAsync<Operation_Record>(sqlString); var operation_record = backendRepository.GetAllAsync<Operation_Record>(sqlString);
List<Operation_Record_File> operation_record_file = new List<Operation_Record_File>(); List<Operation_Record_File> operation_record_file = new List<Operation_Record_File>();
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"; foreach (var or in operation_record.Result)
var param = new { @record_id = or.id };
operation_record_file = backendRepository.GetAllAsync<Operation_Record_File>(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); sqlString = $@"select * from operation_record_file where record_id = @record_id";
if (i == 0) var param = new { @record_id = or.id };
operation_record_file = backendRepository.GetAllAsync<Operation_Record_File>(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); cell = row.CreateCell(i);
} if (i == 0)
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)
{ {
//insert image process cell.SetCellValue(or.work_type_name == "null" ? "" : or.work_type_name);
var dy1 = 10; }
var dx1 = 10; if (i == 1)
{
//image column cell.SetCellValue(or.location == "null" ? "" : or.location);
sheet.SetColumnWidth(i, 16 * imageNames.Count * 256); //width: picture width(16:100), image total, per character(256) }
foreach (var ins in imageNames) 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 //insert image process
var extName = ins.Split('.')[1].ToUpper().Equals("JPG") ? "PNG" : ins.Split('.')[1].ToUpper(); var dy1 = 10;
var fullPath = Path.Combine(operationFileSaveAsPath, ins); var dx1 = 10;
var img = Image.FromFile(fullPath);
//compress image //image column
decimal sizeRatio = ((decimal)img.Height / img.Width); sheet.SetColumnWidth(i, 16 * imageNames.Count * 256); //width: picture width(16:100), image total, per character(256)
int thumbWidth = 100; foreach (var ins in imageNames)
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); //image initial
XSSFClientAnchor anchor = new XSSFClientAnchor(XSSFShape.EMU_PER_PIXEL * dx1, XSSFShape.EMU_PER_PIXEL * dy1, 0, 0, i, j, 0, 0); var extName = ins.Split('.')[1].ToUpper().Equals("JPG") ? "PNG" : ins.Split('.')[1].ToUpper();
anchor.AnchorType = AnchorType.DontMoveAndResize; var fullPath = Path.Combine(operationFileSaveAsPath, ins);
var picture = (XSSFPicture)drawing.CreatePicture(anchor, pictureIds); var img = Image.FromFile(fullPath);
var size = picture.GetImageDimension();
row.HeightInPoints = size.Height;
picture.Resize();
//add 105 each new pic //compress image
dx1 += 105; 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++; cell.CellStyle = style12;
}
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; }
}
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<Operation_Record>(sqlString);
List<Operation_Record_File> operation_record_file = new List<Operation_Record_File>();
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<Operation_Record_File>(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.Code = "0000";
apiResult.Data = "operation/" + fileName; apiResult.Data = "operation/" + fileName;
} }
catch(Exception ex) catch (Exception ex)
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。";

View File

@ -596,20 +596,23 @@ namespace FrontendWebApi.ApiControllers
} }
else else
{ {
await backendRepository.ExecuteSql($"delete from role_auth where role_guid = '{post.SelectedRoleId}' and AuthCode like '%PF%'");
if (post.SaveCheckAuth.Count > 0) if (post.SaveCheckAuth.Count > 0)
{ {
foreach (var item in post.SaveCheckAuth) foreach (var item in post.SaveCheckAuth)
{ {
#region #region
Dictionary<string, object> roleAuth = new Dictionary<string, object>(); {
roleAuth = new Dictionary<string, object>() Dictionary<string, object> roleAuth = new Dictionary<string, object>();
{ roleAuth = new Dictionary<string, object>()
{ "@role_guid", post.SelectedRoleId}, {
{ "@AuthCode", item}, { "@role_guid", post.SelectedRoleId},
{ "@created_by", myUser.userinfo_guid} { "@AuthCode", item},
}; { "@created_by", myUser.userinfo_guid}
};
await backendRepository.AddOneByCustomTable(roleAuth, "role_auth"); await backendRepository.AddOneByCustomTable(roleAuth, "role_auth");
}
#endregion #endregion
} }
} }

View File

@ -16,9 +16,9 @@
"MySqlDBConfig": { "MySqlDBConfig": {
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==", "Port": "js2LutKe+rdjzdxMPQUrvQ==",
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 "Database": "VJB2XC+lAtzuHObDGMVOAA==", //30
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
//"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
//"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT