修改運維管理api
This commit is contained in:
parent
3b49a6642d
commit
0ac7a1813e
@ -100,16 +100,16 @@ namespace FrontendWebApi.ApiControllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<List<BuildingList>>> AreaList()
|
||||
public async Task<ApiResult<List<BuildingList>>> AreaList([FromBody] BuildingList b)
|
||||
{
|
||||
ApiResult<List<BuildingList>> apiResult = new ApiResult<List<BuildingList>>();
|
||||
List<BuildingList> bl = new List<BuildingList>();
|
||||
|
||||
try
|
||||
{
|
||||
var sqlString = @$"select system_key as area_name, system_value as device_area_tag from variable where deleted = 0 and system_type = 'area'";
|
||||
var sqlString = @$"select device_area_tag from device where deleted = 0 and device_system_tag = @main_system_tag and device_name_tag = @sub_system_tag";
|
||||
|
||||
bl = await backendRepository.GetAllAsync<BuildingList>(sqlString);
|
||||
bl = await backendRepository.GetAllAsync<BuildingList>(sqlString, new { @main_system_tag = b.main_system_tag, @sub_system_tag = b.sub_system_tag });
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = bl;
|
||||
@ -139,10 +139,10 @@ namespace FrontendWebApi.ApiControllers
|
||||
var sqlString = @$"select d.device_building_tag, b.full_name as building_name
|
||||
from device d
|
||||
join building b on d.device_building_tag = b.building_tag
|
||||
where d.deleted = 0 and d.device_area_tag = @device_area_tag
|
||||
where d.deleted = 0 and d.device_area_tag = @device_area_tag and d.device_system_tag = @main_system_tag and d.device_name_tag = @sub_system_tag
|
||||
group by b.building_name, d.device_building_tag";
|
||||
|
||||
bl = await backendRepository.GetAllAsync<BuildingList>(sqlString, new { @device_area_tag = b.device_area_tag });
|
||||
bl = await backendRepository.GetAllAsync<BuildingList>(sqlString, new { @device_area_tag = b.device_area_tag, @main_system_tag = b.main_system_tag, @sub_system_tag = b.sub_system_tag });
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = bl;
|
||||
@ -171,10 +171,10 @@ namespace FrontendWebApi.ApiControllers
|
||||
{
|
||||
var sqlString = @$"select d.device_floor_tag
|
||||
from device d
|
||||
where d.deleted = 0 and d.device_area_tag = @device_area_tag and d.device_building_tag = @device_building_tag
|
||||
where d.deleted = 0 and d.device_area_tag = @device_area_tag and d.device_building_tag = @device_building_tag and d.device_system_tag = @main_system_tag and d.device_name_tag = @sub_system_tag
|
||||
group by d.device_floor_tag";
|
||||
|
||||
bl = await backendRepository.GetAllAsync<BuildingList>(sqlString, new { @device_area_tag = b.device_area_tag, @device_building_tag = b.device_building_tag });
|
||||
bl = await backendRepository.GetAllAsync<BuildingList>(sqlString, new { @device_area_tag = b.device_area_tag, @device_building_tag = b.device_building_tag, @main_system_tag = b.main_system_tag, @sub_system_tag = b.sub_system_tag });
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = bl;
|
||||
@ -202,9 +202,9 @@ namespace FrontendWebApi.ApiControllers
|
||||
try
|
||||
{
|
||||
var sqlString = @$"select device_number, concat(device_floor_tag, ' ', device_last_name, ' ', device_serial_tag) as device_name
|
||||
from device where deleted = 0 and device_area_tag = @device_area_tag and device_building_tag = @device_building_tag and device_floor_tag = @device_floor_tag";
|
||||
from device where deleted = 0 and device_area_tag = @device_area_tag and device_building_tag = @device_building_tag and device_floor_tag = @device_floor_tag and d.device_system_tag = @main_system_tag and d.device_name_tag = @sub_system_tag ";
|
||||
|
||||
var param = new { @device_building_tag = bl.device_building_tag, @device_floor_tag = bl.device_floor_tag, @device_area_tag = bl.device_area_tag };
|
||||
var param = new { @device_building_tag = bl.device_building_tag, @device_floor_tag = bl.device_floor_tag, @device_area_tag = bl.device_area_tag, @main_system_tag = bl.main_system_tag, @sub_system_tag = bl.sub_system_tag };
|
||||
|
||||
d = await backendRepository.GetAllAsync<Device>(sqlString, param);
|
||||
|
||||
@ -677,11 +677,10 @@ namespace FrontendWebApi.ApiControllers
|
||||
|
||||
var sqlString = @$"select of.*, v2.system_key
|
||||
from operation_firm of
|
||||
left join variable v1 on of.device_system_category_layer2 = v1.system_value and v1.system_type = @main_system_type and v1.delted = 0
|
||||
left join variable v1 on of.device_system_category_layer2 = v1.system_value and v1.system_type = @main_system_type and v1.deleted = 0 and of.device_system_category_layer2 = v1.system_value
|
||||
left join variable v2 on v1.id = v2.system_parent_id and of.device_system_category_layer3 = v2.system_value and v2.system_type = @sub_system_type and v2.deleted = 0
|
||||
where of.deleted = 0" + sWhere;
|
||||
|
||||
|
||||
var param = new { @sub_system_type = sub_system_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 };
|
||||
opList = await backendRepository.GetAllAsync<Operation_Firm>(sqlString, param);
|
||||
}
|
||||
@ -704,6 +703,39 @@ namespace FrontendWebApi.ApiControllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 廠商資料讀取(搜寻) / selection讀取 ofl = null
|
||||
/// </summary>
|
||||
/// <param name="ofl"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<Operation_Firm>> OpeFirRead([FromBody] OperationFindList ofl)
|
||||
{
|
||||
ApiResult<Operation_Firm> apiResult = new ApiResult<Operation_Firm>();
|
||||
Operation_Firm opList = new Operation_Firm();
|
||||
try
|
||||
{
|
||||
var sqlString = @$"select of.*, v2.system_key
|
||||
from operation_firm of
|
||||
left join variable v1 on of.device_system_category_layer2 = v1.system_value and v1.system_type = @main_system_type and v1.deleted = 0 and of.device_system_category_layer2 = v1.system_value
|
||||
left join variable v2 on v1.id = v2.system_parent_id and of.device_system_category_layer3 = v2.system_value and v2.deleted = 0
|
||||
where of.deleted = 0 and of.id = @id";
|
||||
|
||||
var param = new { @id = ofl.id };
|
||||
opList = await backendRepository.GetOneAsync<Operation_Firm>(sqlString, param);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = opList;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增一笔廠商資料
|
||||
/// </summary>
|
||||
@ -820,6 +852,36 @@ namespace FrontendWebApi.ApiControllers
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 廠商---刪除
|
||||
/// </summary>
|
||||
/// <param name="or"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<string>> DelOpeFirm([FromBody] Operation_Firm or)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
try
|
||||
{
|
||||
var sqlString = @$"UPDATE operation_firm SET deleted = 1 WHERE id = @id";
|
||||
var param = new { @id = or.id };
|
||||
await backendRepository.ExecuteSql(sqlString, param);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = "刪除成功";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(or);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 維修/保養
|
||||
@ -901,6 +963,52 @@ namespace FrontendWebApi.ApiControllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
#region 維修/保養
|
||||
/// <summary>
|
||||
/// 維修/保養 讀取(work_type)
|
||||
/// </summary>
|
||||
/// <param name="ofl"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<Operation_Record>> OpeRecRead([FromBody] OperationFindList ofl)
|
||||
{
|
||||
ApiResult<Operation_Record> apiResult = new ApiResult<Operation_Record>();
|
||||
Operation_Record orl = new Operation_Record();
|
||||
|
||||
try
|
||||
{
|
||||
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
|
||||
where opr.deleted = 0 and opr.id = @id";
|
||||
|
||||
var param = new { @id = ofl.id };
|
||||
|
||||
orl = await backendRepository.GetOneAsync<Operation_Record>(sqlString, param);
|
||||
|
||||
if (orl != null)
|
||||
{
|
||||
sqlString = $@"select * from operation_record_file where record_id = @record_id and deleted = 0";
|
||||
var oParam = new { @record_id = orl.id };
|
||||
var orfl = await backendRepository.GetAllAsync<Operation_Record_File>(sqlString, oParam);
|
||||
orl.lorf = orfl;
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = orl;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(ofl);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 維修/保養---新增/編輯
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user