diff --git a/FrontendWebApi/ApiControllers/OperationController.cs b/FrontendWebApi/ApiControllers/OperationController.cs
index 666d771..3b95d07 100644
--- a/FrontendWebApi/ApiControllers/OperationController.cs
+++ b/FrontendWebApi/ApiControllers/OperationController.cs
@@ -100,16 +100,16 @@ namespace FrontendWebApi.ApiControllers
///
///
[HttpPost]
- public async Task>> AreaList()
+ public async Task>> AreaList([FromBody] BuildingList b)
{
ApiResult> apiResult = new ApiResult>();
List bl = new List();
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(sqlString);
+ bl = await backendRepository.GetAllAsync(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(sqlString, new { @device_area_tag = b.device_area_tag });
+ bl = await backendRepository.GetAllAsync(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(sqlString, new { @device_area_tag = b.device_area_tag, @device_building_tag = b.device_building_tag });
+ bl = await backendRepository.GetAllAsync(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(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(sqlString, param);
}
@@ -704,6 +703,39 @@ namespace FrontendWebApi.ApiControllers
return apiResult;
}
+ ///
+ /// 廠商資料讀取(搜寻) / selection讀取 ofl = null
+ ///
+ ///
+ ///
+ public async Task> OpeFirRead([FromBody] OperationFindList ofl)
+ {
+ ApiResult apiResult = new ApiResult();
+ 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(sqlString, param);
+
+ apiResult.Code = "0000";
+ apiResult.Data = opList;
+ }
+ catch (Exception exception)
+ {
+ apiResult.Code = "9999";
+ apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
+ Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
+ }
+
+ return apiResult;
+ }
+
///
/// 新增一笔廠商資料
///
@@ -820,6 +852,36 @@ namespace FrontendWebApi.ApiControllers
return apiResult;
}
+
+ ///
+ /// 廠商---刪除
+ ///
+ ///
+ ///
+ public async Task> DelOpeFirm([FromBody] Operation_Firm or)
+ {
+ ApiResult apiResult = new ApiResult();
+
+ 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 維修/保養
+ ///
+ /// 維修/保養 讀取(work_type)
+ ///
+ ///
+ ///
+ public async Task> OpeRecRead([FromBody] OperationFindList ofl)
+ {
+ ApiResult apiResult = new ApiResult();
+ 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(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(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;
+ }
+
///
/// 維修/保養---新增/編輯
///