[後端] 修改匯出條件, 調整join問題

[前端] 修改時間問題
This commit is contained in:
dev02 2023-07-26 09:54:36 +08:00
parent 6a4ad3abf5
commit df95bf5827
5 changed files with 184 additions and 173 deletions

View File

@ -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,

View File

@ -389,17 +389,19 @@ 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;";
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, null);
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)
@ -491,7 +493,7 @@ namespace FrontendWebApi.ApiControllers
}
if (i == 7)
{
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
@ -552,20 +554,25 @@ namespace FrontendWebApi.ApiControllers
}
}
}
}
}
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
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 = 2";
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
@ -730,6 +737,7 @@ namespace FrontendWebApi.ApiControllers
}
}
}
}
workbook.Write(fs);
}