[後端] 修改匯出條件, 調整join問題
[前端] 修改時間問題
This commit is contained in:
		
							parent
							
								
									6a4ad3abf5
								
							
						
					
					
						commit
						df95bf5827
					
				@ -892,6 +892,7 @@
 | 
			
		||||
 | 
			
		||||
			if (dateType == 'tdy') {
 | 
			
		||||
				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'));
 | 
			
		||||
				$('#startdate').val(today);
 | 
			
		||||
				$('#startdate').data('val', today);
 | 
			
		||||
				$('#enddate').val(today);
 | 
			
		||||
@ -899,6 +900,7 @@
 | 
			
		||||
			}
 | 
			
		||||
			else if (dateType == 'ytd') {
 | 
			
		||||
				pageAct.startdate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'date'));
 | 
			
		||||
				pageAct.enddate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() - 2)), 'date'));
 | 
			
		||||
				$('#startdate').val(ytd);
 | 
			
		||||
				$('#startdate').data('val', ytd);
 | 
			
		||||
				$('#enddate').val(ytd);
 | 
			
		||||
@ -916,7 +918,8 @@
 | 
			
		||||
				$('#startdate').data('val', $('#startdate').val());
 | 
			
		||||
				$('#enddate').data('val', $('#enddate').val());
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			console.log("start :" + pageAct.startdate);
 | 
			
		||||
			console.log("end :" + pageAct.enddate);
 | 
			
		||||
			refTable();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@ -1001,7 +1004,7 @@
 | 
			
		||||
	function exportExcel(e) {
 | 
			
		||||
		console.log("export", e)
 | 
			
		||||
		let url = baseApiUrl + "/operation/OpeExportExcel";
 | 
			
		||||
 | 
			
		||||
		console.log()
 | 
			
		||||
		objSendData.Data = {
 | 
			
		||||
			work_type: pageAct.work_type,
 | 
			
		||||
			startdate: pageAct.startdate == undefined ? null : pageAct.startdate,
 | 
			
		||||
 | 
			
		||||
@ -389,184 +389,191 @@ 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<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";
 | 
			
		||||
                                       where opr.deleted = 0 and opr.work_type = 1 and opr.created_at >= '{ee.startdate.ToString().Split("T")[0]}' and opr.created_at <= '{ee.enddate.ToString().Split("T")[0]}';";
 | 
			
		||||
                        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.Count > 0)
 | 
			
		||||
                        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);
 | 
			
		||||
                                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.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 == 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.*, 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().Split("T")[0]}' and opr.created_at <= '{ee.enddate.ToString().Split("T")[0]}';";
 | 
			
		||||
 | 
			
		||||
                        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)
 | 
			
		||||
                            {
 | 
			
		||||
@ -667,7 +674,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
                                    }
 | 
			
		||||
                                    if (i == 8)//image
 | 
			
		||||
                                    {
 | 
			
		||||
                                        var imageNames = or.lorf.Count > 0 ? or.lorf.Select(x => x.save_file_name).ToList() : null;
 | 
			
		||||
                                        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
 | 
			
		||||
@ -729,6 +736,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    workbook.Write(fs);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								FrontendWebApi/wwwroot/excel/operation/保養記錄_2023-07-24.xlsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								FrontendWebApi/wwwroot/excel/operation/保養記錄_2023-07-24.xlsx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								FrontendWebApi/wwwroot/excel/operation/廠商資料_2023-07-24.xlsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								FrontendWebApi/wwwroot/excel/operation/廠商資料_2023-07-24.xlsx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								FrontendWebApi/wwwroot/excel/operation/維修_2023-07-24.xlsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								FrontendWebApi/wwwroot/excel/operation/維修_2023-07-24.xlsx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Loading…
	
		Reference in New Issue
	
	Block a user