This commit is contained in:
quowingwang
2025-12-20 13:34:43 +08:00
parent 16168ed598
commit 1221b26691
6 changed files with 297 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Model.MES.andon;
using ZR.Model.MES.andon.Dto;
using ZR.Service.mes.andon.Iservice;
//创建时间2025-12-20
namespace ZR.Admin.WebApi.Controllers.andon
{
/// <summary>
/// 报警区域表
/// </summary>
[AllowAnonymous]
[Route("business/AndonAlarmArea")]
public class AndonAlarmAreaController : BaseController
{
/// <summary>
/// 报警区域表接口
/// </summary>
private readonly IAndonAlarmAreaService _AndonAlarmAreaService;
public AndonAlarmAreaController(IAndonAlarmAreaService AndonAlarmAreaService)
{
_AndonAlarmAreaService = AndonAlarmAreaService;
}
/// <summary>
/// 查询报警区域表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
[ActionPermissionFilter(Permission = "business:andonalarmarea:list")]
public IActionResult QueryAndonAlarmArea([FromQuery] AndonAlarmAreaQueryDto parm)
{
var response = _AndonAlarmAreaService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询报警区域表详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "business:andonalarmarea:query")]
public IActionResult GetAndonAlarmArea(int Id)
{
var response = _AndonAlarmAreaService.GetInfo(Id);
var info = response.Adapt<AndonAlarmArea>();
return SUCCESS(info);
}
/// <summary>
/// 添加报警区域表
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "business:andonalarmarea:add")]
[Log(Title = "报警区域表", BusinessType = BusinessType.INSERT)]
public IActionResult AddAndonAlarmArea([FromBody] AndonAlarmAreaDto parm)
{
var modal = parm.Adapt<AndonAlarmArea>().ToCreate(HttpContext);
var response = _AndonAlarmAreaService.AddAndonAlarmArea(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新报警区域表
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "business:andonalarmarea:edit")]
[Log(Title = "报警区域表", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateAndonAlarmArea([FromBody] AndonAlarmAreaDto parm)
{
var modal = parm.Adapt<AndonAlarmArea>().ToUpdate(HttpContext);
var response = _AndonAlarmAreaService.UpdateAndonAlarmArea(modal);
return ToResponse(response);
}
/// <summary>
/// 删除报警区域表
/// </summary>
/// <returns></returns>
[HttpDelete("{ids}")]
[ActionPermissionFilter(Permission = "business:andonalarmarea:delete")]
[Log(Title = "报警区域表", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteAndonAlarmArea(string ids)
{
int[] idsArr = Tools.SpitIntArrary(ids);
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
var response = _AndonAlarmAreaService.Delete(idsArr);
return ToResponse(response);
}
}
}

View File

@@ -0,0 +1,51 @@
namespace ZR.Model.MES.andon
{
/// <summary>
/// 报警区域表
/// </summary>
[SugarTable("andon_alarm_area")]
public class AndonAlarmArea
{
/// <summary>
/// 主键
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 父ID
/// </summary>
public int? ParentId { get; set; }
/// <summary>
/// 区域名称
/// </summary>
public string Area { get; set; }
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnName = "created_by")]
public string CreatedBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnName = "created_time")]
public DateTime? CreatedTime { get; set; }
/// <summary>
/// 更新人
/// </summary>
[SugarColumn(ColumnName = "updated_by")]
public string UpdatedBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[SugarColumn(ColumnName = "updated_time")]
public DateTime? UpdatedTime { get; set; }
}
}

View File

@@ -0,0 +1,35 @@
using System.ComponentModel.DataAnnotations;
namespace ZR.Model.MES.andon.Dto
{
/// <summary>
/// 报警区域表查询对象
/// </summary>
public class AndonAlarmAreaQueryDto : PagerInfo
{
}
/// <summary>
/// 报警区域表输入输出对象
/// </summary>
public class AndonAlarmAreaDto
{
[Required(ErrorMessage = "主键不能为空")]
public int Id { get; set; }
public int? ParentId { get; set; }
public string Area { get; set; }
public string CreatedBy { get; set; }
public DateTime? CreatedTime { get; set; }
public string UpdatedBy { get; set; }
public DateTime? UpdatedTime { get; set; }
}
}

View File

@@ -0,0 +1,79 @@
using Infrastructure.Attribute;
using SqlSugar;
using ZR.Model;
using ZR.Model.MES.andon;
using ZR.Model.MES.andon.Dto;
using ZR.Repository;
using ZR.Service.mes.andon.Iservice;
namespace ZR.Service.mes.andon
{
/// <summary>
/// 报警区域表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IAndonAlarmAreaService), ServiceLifetime = LifeTime.Transient)]
public class AndonAlarmAreaService : BaseService<AndonAlarmArea>, IAndonAlarmAreaService
{
/// <summary>
/// 查询报警区域表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<AndonAlarmAreaDto> GetList(AndonAlarmAreaQueryDto parm)
{
var predicate = Expressionable.Create<AndonAlarmArea>();
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage<AndonAlarmArea, AndonAlarmAreaDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public AndonAlarmArea GetInfo(int Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加报警区域表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public AndonAlarmArea AddAndonAlarmArea(AndonAlarmArea model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改报警区域表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateAndonAlarmArea(AndonAlarmArea model)
{
//var response = Update(w => w.Id == model.Id, it => new AndonAlarmArea()
//{
// ParentId = model.ParentId,
// Area = model.Area,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
return Update(model, true);
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using ZR.Model;
using System.Collections.Generic;
using ZR.Model.MES.andon;
using ZR.Model.MES.andon.Dto;
namespace ZR.Service.mes.andon.Iservice
/// <summary>
/// 报警区域表service接口
/// </summary>
public interface IAndonAlarmAreaService : IBaseService<AndonAlarmArea>
{
PagedInfo<AndonAlarmAreaDto> GetList(AndonAlarmAreaQueryDto parm);
AndonAlarmArea GetInfo(int Id);
AndonAlarmArea AddAndonAlarmArea(AndonAlarmArea parm);
int UpdateAndonAlarmArea(AndonAlarmArea parm);
}
}