diff --git a/FrontendWebApi/ApiControllers/OperationController.cs b/FrontendWebApi/ApiControllers/OperationController.cs index 445851c..edc9e26 100644 --- a/FrontendWebApi/ApiControllers/OperationController.cs +++ b/FrontendWebApi/ApiControllers/OperationController.cs @@ -75,7 +75,7 @@ namespace FrontendWebApi.ApiControllers var sqlString = @$"SELECT v2.* FROM variable v2 JOIN variable v1 ON v2.system_parent_id = v1.id AND v1.system_type = @main_system_type AND v1.deleted = 0 - WHERE v2.system_type = @sub_system_type AND v2.deleted = 0 AND v1.system_type = @main_system_tag + WHERE v2.system_type = @sub_system_type AND v2.deleted = 0 AND v1.system_value = @main_system_tag ORDER BY v2.system_priority, v2.created_at desc"; var param = new { @main_system_type = main_system_type, @sub_system_type = sub_system_type, @main_system_tag = main_system_tag }; @@ -308,7 +308,7 @@ namespace FrontendWebApi.ApiControllers 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 - left join userinfo ui on opr.work_person_id = ui.id + 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); @@ -598,20 +598,20 @@ namespace FrontendWebApi.ApiControllers { if (ofl.start_created_at != null || ofl.end_created_at != null) { - sWhere += $@" and (of.created_at >= isnull(@start_created_at, of.created_at) AND of.created_at <= isnull(@end_created_at, of.created_at))"; - } - else if (ofl.today) - { - sWhere += $@" and convert(of.created_at, DATE) = convert(NOW(), DATE)"; - } - else if (ofl.yesterday) - { - sWhere += $@" and convert(of.created_at, DATE) = convert(ADDDATE(NOW(), -1), DATE)"; + sWhere += $@" and (of.created_at >= ifnull(@start_created_at, of.created_at) AND of.created_at <= ifnull(@end_created_at, of.created_at))"; } + //else if (ofl.today) + //{ + // sWhere += $@" and convert(of.created_at, DATE) = convert(NOW(), DATE)"; + //} + //else if (ofl.yesterday) + //{ + // sWhere += $@" and convert(of.created_at, DATE) = convert(ADDDATE(NOW(), -1), DATE)"; + //} if (ofl.sub_system_tag != null || ofl.main_system_tag != null) { - sWhere += $@" and (of.device_system_category_layer2 = isnull(@main_system_tag, device_system_category_layer2) AND of.device_system_category_layer3 = isnull(@sub_system_tag, device_system_category_layer3))"; + sWhere += $@" and (of.device_system_category_layer2 = ifnull(@main_system_tag, device_system_category_layer2) AND of.device_system_category_layer3 = ifnull(@sub_system_tag, device_system_category_layer3))"; } var sqlString = @$"select of.*, v2.system_key @@ -774,7 +774,7 @@ namespace FrontendWebApi.ApiControllers string sWhere = ""; try { - if (ofl.work_type != 1 || ofl.work_type != 2) + if (ofl.work_type != 1 && ofl.work_type != 2) { apiResult.Code = "0001"; apiResult.Msg = "無此項目類別"; @@ -783,20 +783,20 @@ namespace FrontendWebApi.ApiControllers if (ofl.start_created_at != null || ofl.end_created_at != null) { - sWhere += $@" and (opr.created_at >= isnull(@start_created_at, opr.created_at) AND opr.created_at <= isnull(@end_created_at, opr.created_at))"; - } - else if (ofl.today) - { - sWhere += $@" and convert(opr.created_at, DATE) = convert(NOW(), DATE)"; - } - else if (ofl.yesterday) - { - sWhere += $@" and convert(opr.created_at, DATE) = convert(ADDDATE(NOW(), -1), DATE)"; + sWhere += $@" and (opr.created_at >= ifnull(@start_created_at, opr.created_at) AND opr.created_at <= ifnull(@end_created_at, opr.created_at))"; } + //else if (ofl.today) + //{ + // sWhere += $@" and convert(opr.created_at, DATE) = convert(NOW(), DATE)"; + //} + //else if (ofl.yesterday) + //{ + // sWhere += $@" and convert(opr.created_at, DATE) = convert(ADDDATE(NOW(), -1), DATE)"; + //} if (ofl.sub_system_tag != null || ofl.main_system_tag != null) { - sWhere += $@" and (opr.device_system_category_layer2 = isnull(@main_system_tag, opr.device_system_category_layer2) AND opr.device_system_category_layer3 = isnull(@sub_system_tag, opr.device_system_category_layer3))"; + sWhere += $@" and (opr.device_system_category_layer2 = ifnull(@main_system_tag, opr.device_system_category_layer2) AND opr.device_system_category_layer3 = ifnull(@sub_system_tag, opr.device_system_category_layer3))"; } if (ofl.serial_number != null) @@ -807,7 +807,7 @@ namespace FrontendWebApi.ApiControllers 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 - left join userinfo ui on opr.work_person_id = ui.id + left join userinfo ui on opr.work_person_id = ui.userinfo_guid where opr.deleted = 0 and opr.work_type = @work_type" + sWhere; var param = new { @work_type = ofl.work_type, @start_created_at = ofl.start_created_at, @end_created_at = ofl.end_created_at, @sub_system_tag = ofl.sub_system_tag, @main_system_tag = ofl.main_system_tag, @formId = ofl.serial_number }; diff --git a/FrontendWebApi/Models/Operation.cs b/FrontendWebApi/Models/Operation.cs index 4f1c81a..09833fa 100644 --- a/FrontendWebApi/Models/Operation.cs +++ b/FrontendWebApi/Models/Operation.cs @@ -41,8 +41,8 @@ namespace FrontendWebApi.Models public string serial_number { get; set; } //表单号 public DateTime? start_created_at { get; set; }//开始建立时间 public DateTime? end_created_at { get; set; }//结束建立时间 - public bool today { get; set; }//今天建立时间 - public bool yesterday { get; set; }//昨天建立时间 + //public bool today { get; set; }//今天建立时间 + //public bool yesterday { get; set; }//昨天建立时间 public string main_system_tag { get; set; }//大类tag public string sub_system_tag { get; set; }//小类tag public byte work_type { get; set; } // 1:保養, 2:維修