237 lines
7.8 KiB
C#
237 lines
7.8 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
using ZR.Model.Dto;
|
||
using ZR.Service.MES.dev.IService;
|
||
using ZR.Model.MES.dev.Dto;
|
||
using ZR.Admin.WebApi.Filters;
|
||
using ZR.Model.MES.dev.Dto;
|
||
using ZR.Model.MES.dev;
|
||
using ZR.Admin.WebApi.Extensions;
|
||
|
||
//创建时间:2024-05-20
|
||
namespace ZR.Admin.WebApi.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 设备台账
|
||
/// </summary>
|
||
[Verify]
|
||
[Route("mes/deviceManagement/DeviceAccount")]
|
||
public class DeviceAccountController : BaseController
|
||
{
|
||
/// <summary>
|
||
/// 设备台账接口
|
||
/// </summary>
|
||
private readonly IDeviceAccountService _DeviceAccountService;
|
||
|
||
public DeviceAccountController(IDeviceAccountService DeviceAccountService)
|
||
{
|
||
_DeviceAccountService = DeviceAccountService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询设备台账列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list")]
|
||
[ActionPermissionFilter(Permission = "deviceManagement:deviceaccount:list")]
|
||
public IActionResult QueryDeviceAccount([FromQuery] DeviceAccountQueryDto parm)
|
||
{
|
||
var response = _DeviceAccountService.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 查询绑定或者未绑定巡检任务的设备台账
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list_route_inspect")]
|
||
[AllowAnonymous]
|
||
public IActionResult QueryDeviceAccount_Route([FromQuery] DeviceAccountQueryDto2 parm)
|
||
{
|
||
var response = _DeviceAccountService.GetList_Route(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询设备台账详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "deviceManagement:deviceaccount:query")]
|
||
public IActionResult GetDeviceAccount(int Id)
|
||
{
|
||
var response = _DeviceAccountService.GetInfo(Id);
|
||
|
||
var info = response.Adapt<DeviceAccount>();
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加设备台账
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[ActionPermissionFilter(Permission = "deviceManagement:deviceaccount:add")]
|
||
[Log(Title = "设备台账", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult AddDeviceAccount([FromBody] DeviceAccountDto parm)
|
||
{
|
||
var modal = parm.Adapt<DeviceAccount>().ToCreate(HttpContext);
|
||
|
||
var response = _DeviceAccountService.AddDeviceAccount(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新设备台账
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "deviceManagement:deviceaccount:edit")]
|
||
[Log(Title = "设备台账", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult UpdateDeviceAccount([FromBody] DeviceAccountDto parm)
|
||
{
|
||
var modal = parm.Adapt<DeviceAccount>().ToUpdate(HttpContext);
|
||
var response = _DeviceAccountService.UpdateDeviceAccount(modal);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除设备台账
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpDelete("{ids}")]
|
||
[ActionPermissionFilter(Permission = "deviceManagement:deviceaccount:delete")]
|
||
[Log(Title = "设备台账", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteDeviceAccount(string ids)
|
||
{
|
||
string[] idsArr = ids.Split(',');
|
||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||
|
||
var response = _DeviceAccountService.Delete(idsArr);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取设备下拉选择树
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("getSelectTree")]
|
||
[ActionPermissionFilter(Permission = "deviceManagement:deviceaccount:list")]
|
||
public IActionResult GetSelectTree([FromQuery] DeviceAccountQueryDto parm)
|
||
{
|
||
try
|
||
{
|
||
var response = _DeviceAccountService.GetSelectTree(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return ToResponse(ApiResult.Error(500, ex.Message));
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 添加绑定关系 巡检计划和设备台账
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpPost("AddRelation")]
|
||
[AllowAnonymous]
|
||
public IActionResult AddRelation([FromBody] DeviceAccount_routeinspect_Dto parm)
|
||
{
|
||
if (parm == null || parm.FkDeviceAccountIdList == null)
|
||
{
|
||
SUCCESS(null);
|
||
}
|
||
var response = _DeviceAccountService.AddRelation(parm, HttpContext.GetName());
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 删除关系
|
||
/// </summary>
|
||
/// <param name="FkRouteInspectionPlanId"></param>
|
||
/// <param name="FkDeviceAccountId"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("remove_relation")]
|
||
public IActionResult Remove_relation(string FkRouteInspectionPlanId,int FkDeviceAccountId)
|
||
{
|
||
var response = _DeviceAccountService.Remove_relation(FkRouteInspectionPlanId, FkDeviceAccountId);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询绑定或者未绑定点检任务的设备台账
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list_point_inspect")]
|
||
[AllowAnonymous]
|
||
public IActionResult QueryDeviceAccount_point([FromQuery] DeviceAccountQueryDto3 parm)
|
||
{
|
||
var response = _DeviceAccountService.GetList_Point(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 添加绑定关系 点检计划和设备台账
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpPost("AddRelation_point_account")]
|
||
[AllowAnonymous]
|
||
public IActionResult AddRelationPointAccount([FromBody] DeviceAccount_pointinspect_Dto parm)
|
||
{
|
||
if (parm == null || parm.FkDeviceAccountIdList == null)
|
||
{
|
||
SUCCESS(null);
|
||
}
|
||
var response = _DeviceAccountService.AddRelationPointAccount(parm, HttpContext.GetName());
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 删除关系
|
||
/// </summary>
|
||
/// <param name="FkRouteInspectionPlanId"></param>
|
||
/// <param name="FkDeviceAccountId"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("remove_relation_point_account")]
|
||
public IActionResult RemoveRelationPointAccount(string FkPointInspectionPlanId, int FkDeviceAccountId)
|
||
{
|
||
var response = _DeviceAccountService.RemoveRelationPointAccount(FkPointInspectionPlanId, FkDeviceAccountId);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 获取设备状态 设备看板用
|
||
/// </summary>
|
||
/// <param name="devicetype_id">设备类型id</param>
|
||
/// <returns></returns>
|
||
[HttpGet("getDeviceStatusBoardData")]
|
||
public IActionResult GetDeviceStatus(int devicetype_id)
|
||
{
|
||
DeviceStatusAnalysisDto response= _DeviceAccountService.GetDeviceStatus(devicetype_id);
|
||
return SUCCESS(response);
|
||
}
|
||
}
|
||
} |