[FrontedWebApi][運維管理] API 調整

This commit is contained in:
dev01 2022-11-11 17:39:40 +08:00
parent 582b8b97ba
commit 20d02afa33
2 changed files with 26 additions and 26 deletions

View File

@ -75,7 +75,7 @@ namespace FrontendWebApi.ApiControllers
var sqlString = @$"SELECT v2.* var sqlString = @$"SELECT v2.*
FROM variable 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 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"; 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 }; 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 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 from operation_record opr
left join device d on opr.fix_do_code = d.device_number 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"; where opr.deleted = 0 and opr.work_type = 1";
var sheet = workbook.CreateSheet("廠商資料"); var sheet = workbook.CreateSheet("廠商資料");
var operation_record = backendRepository.GetAllAsync<Operation_Record>(sqlString, null); var operation_record = backendRepository.GetAllAsync<Operation_Record>(sqlString, null);
@ -598,20 +598,20 @@ namespace FrontendWebApi.ApiControllers
{ {
if (ofl.start_created_at != null || ofl.end_created_at != null) 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))"; 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)";
} }
//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) 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 var sqlString = @$"select of.*, v2.system_key
@ -774,7 +774,7 @@ namespace FrontendWebApi.ApiControllers
string sWhere = ""; string sWhere = "";
try try
{ {
if (ofl.work_type != 1 || ofl.work_type != 2) if (ofl.work_type != 1 && ofl.work_type != 2)
{ {
apiResult.Code = "0001"; apiResult.Code = "0001";
apiResult.Msg = "無此項目類別"; apiResult.Msg = "無此項目類別";
@ -783,20 +783,20 @@ namespace FrontendWebApi.ApiControllers
if (ofl.start_created_at != null || ofl.end_created_at != null) 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))"; 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)";
} }
//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) 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) 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 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 from operation_record opr
left join device d on opr.fix_do_code = d.device_number 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; 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 }; 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 };

View File

@ -41,8 +41,8 @@ namespace FrontendWebApi.Models
public string serial_number { get; set; } //表单号 public string serial_number { get; set; } //表单号
public DateTime? start_created_at { get; set; }//开始建立时间 public DateTime? start_created_at { get; set; }//开始建立时间
public DateTime? end_created_at { get; set; }//结束建立时间 public DateTime? end_created_at { get; set; }//结束建立时间
public bool today { get; set; }//今天建立时间 //public bool today { get; set; }//今天建立时间
public bool yesterday { get; set; }//昨天建立时间 //public bool yesterday { get; set; }//昨天建立时间
public string main_system_tag { get; set; }//大类tag public string main_system_tag { get; set; }//大类tag
public string sub_system_tag { get; set; }//小类tag public string sub_system_tag { get; set; }//小类tag
public byte work_type { get; set; } // 1:保養, 2:維修 public byte work_type { get; set; } // 1:保養, 2:維修