查询设备停机时间列表

This commit is contained in:
qianhao.xu 2024-12-30 16:59:54 +08:00
parent 64bf0d2886
commit 9cc5c3fef0
6 changed files with 409 additions and 5 deletions

View File

@ -0,0 +1,113 @@
using Microsoft.AspNetCore.Mvc;
using DOAN.Model.Dto;
using DOAN.Service.MES.dev.IService;
using DOAN.Model.MES.dev.Dto;
using DOAN.Admin.WebApi.Filters;
using DOAN.Model.MES.dev;
using Infrastructure.Converter;
namespace DOAN.Admin.WebApi.Controllers
{
/// <summary>
/// 设备停机时间
/// </summary>
[Verify]
[Route("mes/deviceManagement/DeviceDowntimeRecord")]
public class DeviceDowntimeRecordController : BaseController
{
/// <summary>
/// 设备停机时间接口
/// </summary>
private readonly IDeviceDowntimeRecordService _DeviceDowntimeRecordService;
public DeviceDowntimeRecordController(IDeviceDowntimeRecordService DeviceDowntimeRecordService)
{
_DeviceDowntimeRecordService = DeviceDowntimeRecordService;
}
/// <summary>
/// 查询设备停机时间列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpPost("list")]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:list")]
public IActionResult QueryDeviceDowntimeRecord([FromBody] DeviceDowntimeRecordQueryDto parm)
{
parm.DateTimeRange[0] = DOANConvertDateTime.ConvertLocalDateTime(parm.DateTimeRange[0]);
parm.DateTimeRange[1] = DOANConvertDateTime.ConvertLocalDateTime(parm.DateTimeRange[1]);
var response = _DeviceDowntimeRecordService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询设备停机时间详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:query")]
public IActionResult GetDeviceDowntimeRecord(int Id)
{
var response = _DeviceDowntimeRecordService.GetInfo(Id);
var info = response.Adapt<DeviceDowntimeRecord>();
return SUCCESS(info);
}
/// <summary>
/// 添加设备停机时间
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:add")]
[Log(Title = "设备停机时间", BusinessType = BusinessType.INSERT)]
public IActionResult AddDeviceDowntimeRecord([FromBody] DeviceDowntimeRecordDto parm)
{
var modal = parm.Adapt<DeviceDowntimeRecord>().ToCreate(HttpContext);
var response = _DeviceDowntimeRecordService.AddDeviceDowntimeRecord(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新设备停机时间
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:edit")]
[Log(Title = "设备停机时间", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateDeviceDowntimeRecord([FromBody] DeviceDowntimeRecordDto parm)
{
var modal = parm.Adapt<DeviceDowntimeRecord>().ToUpdate(HttpContext);
var response = _DeviceDowntimeRecordService.UpdateDeviceDowntimeRecord(modal);
return ToResponse(response);
}
/// <summary>
/// 删除设备停机时间
/// </summary>
/// <returns></returns>
[HttpDelete("{ids}")]
[ActionPermissionFilter(Permission = "deviceManagement:devicedowntimerecord:delete")]
[Log(Title = "设备停机时间", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteDeviceDowntimeRecord(string ids)
{
int[] idsArr = Tools.SpitIntArrary(ids);
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
var response = _DeviceDowntimeRecordService.Delete(idsArr);
return ToResponse(response);
}
}
}

View File

@ -32,7 +32,7 @@ namespace DOAN.Admin.WebApi.Controllers
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
[ActionPermissionFilter(Permission = "business:deviceformconfig:list")]
[ActionPermissionFilter(Permission = "deviceManagement:deviceformconfig:list")]
public IActionResult QueryDeviceFormConfig([FromQuery] DeviceFormConfigQueryDto parm)
{
var response = _DeviceFormConfigService.GetList(parm);
@ -46,7 +46,7 @@ namespace DOAN.Admin.WebApi.Controllers
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "business:deviceformconfig:query")]
[ActionPermissionFilter(Permission = "deviceManagement:deviceformconfig:query")]
public IActionResult GetDeviceFormConfig(string Id)
{
var response = _DeviceFormConfigService.GetInfo(Id);
@ -60,7 +60,7 @@ namespace DOAN.Admin.WebApi.Controllers
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "business:deviceformconfig:add")]
[ActionPermissionFilter(Permission = "deviceManagement:deviceformconfig:add")]
[Log(Title = "设备检查项表单配置表", BusinessType = BusinessType.INSERT)]
public IActionResult AddDeviceFormConfig([FromBody] DeviceFormConfigDto parm)
{
@ -76,7 +76,7 @@ namespace DOAN.Admin.WebApi.Controllers
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "business:deviceformconfig:edit")]
[ActionPermissionFilter(Permission = "deviceManagement:deviceformconfig:edit")]
[Log(Title = "设备检查项表单配置表", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateDeviceFormConfig([FromBody] DeviceFormConfigDto parm)
{
@ -91,7 +91,7 @@ namespace DOAN.Admin.WebApi.Controllers
/// </summary>
/// <returns></returns>
[HttpDelete("{ids}")]
[ActionPermissionFilter(Permission = "business:deviceformconfig:delete")]
[ActionPermissionFilter(Permission = "deviceManagement:deviceformconfig:delete")]
[Log(Title = "设备检查项表单配置表", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteDeviceFormConfig(string ids)
{

View File

@ -0,0 +1,112 @@
namespace DOAN.Model.MES.dev
{
/// <summary>
/// 设备停机时间
/// </summary>
[SugarTable("device_downtime_record")]
public class DeviceDowntimeRecord
{
/// <summary>
/// Id
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 设备名称
/// </summary>
[SugarColumn(ColumnName = "device_name")]
public string DeviceName { get; set; }
/// <summary>
/// 设备id
/// </summary>
[SugarColumn(ColumnName = "device_id")]
public int? DeviceId { get; set; }
/// <summary>
/// 停机日期
/// </summary>
public DateTime? Downdate { get; set; }
/// <summary>
/// 开始时间
/// </summary>
[SugarColumn(ColumnName = "start_time")]
public DateTime? StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
[SugarColumn(ColumnName = "end_time")]
public DateTime? EndTime { get; set; }
/// <summary>
/// 停机时间合计
/// </summary>
[SugarColumn(ColumnName = "consume_time")]
public DateTime? ConsumeTime { get; set; }
/// <summary>
/// 故障现象
/// </summary>
[SugarColumn(ColumnName = "fault_phenomenon")]
public string FaultPhenomenon { get; set; }
/// <summary>
/// 故障原因
/// </summary>
[SugarColumn(ColumnName = "fault_reason")]
public string FaultReason { get; set; }
/// <summary>
/// 临时措施
/// </summary>
[SugarColumn(ColumnName = "temporary_measure")]
public string TemporaryMeasure { get; set; }
/// <summary>
/// 永居措施
/// </summary>
[SugarColumn(ColumnName = "permanent_measure")]
public string PermanentMeasure { get; set; }
/// <summary>
/// 维修人
/// </summary>
[SugarColumn(ColumnName = "repair_person")]
public string RepairPerson { get; set; }
/// <summary>
/// 维修结果
/// </summary>
[SugarColumn(ColumnName = "repair_result")]
public string RepairResult { get; set; }
/// <summary>
/// CreatedBy
/// </summary>
[SugarColumn(ColumnName = "created_by")]
public string CreatedBy { get; set; }
/// <summary>
/// CreatedTime
/// </summary>
[SugarColumn(ColumnName = "created_time")]
public DateTime? CreatedTime { get; set; }
/// <summary>
/// UpdatedBy
/// </summary>
[SugarColumn(ColumnName = "updated_by")]
public string UpdatedBy { get; set; }
/// <summary>
/// UpdatedTime
/// </summary>
[SugarColumn(ColumnName = "updated_time")]
public DateTime? UpdatedTime { get; set; }
}
}

View File

@ -0,0 +1,57 @@
using System.ComponentModel.DataAnnotations;
namespace DOAN.Model.MES.dev.Dto
{
/// <summary>
/// 设备停机时间查询对象
/// </summary>
public class DeviceDowntimeRecordQueryDto : PagerInfo
{
public DateTime[] DateTimeRange { get; set; } = new DateTime[2];
public string DeviceName { get; set; }
}
/// <summary>
/// 设备停机时间输入输出对象
/// </summary>
public class DeviceDowntimeRecordDto
{
[Required(ErrorMessage = "Id不能为空")]
public int Id { get; set; }
public string DeviceName { get; set; }
public int? DeviceId { get; set; }
public DateTime? Downdate { get; set; }
public DateTime? StartTime { get; set; }
public DateTime? EndTime { get; set; }
public DateTime? ConsumeTime { get; set; }
public string FaultPhenomenon { get; set; }
public string FaultReason { get; set; }
public string TemporaryMeasure { get; set; }
public string PermanentMeasure { get; set; }
public string RepairPerson { get; set; }
public string RepairResult { 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,99 @@
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using Microsoft.AspNetCore.Components.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DOAN.Model;
using DOAN.Model.MES.dev;
using DOAN.Model.MES.dev.Dto;
using DOAN.Model.System;
using DOAN.Repository;
using DOAN.Service.MES.dev.IService;
namespace DOAN.Service.MES.dev
{
/// <summary>
/// 设备停机时间Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IDeviceDowntimeRecordService), ServiceLifetime = LifeTime.Transient)]
public class DeviceDowntimeRecordService : BaseService<DeviceDowntimeRecord>, IDeviceDowntimeRecordService
{
/// <summary>
/// 查询设备停机时间列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<DeviceDowntimeRecordDto> GetList(DeviceDowntimeRecordQueryDto parm)
{
var predicate = Expressionable.Create<DeviceDowntimeRecord>()
.AndIF(!string.IsNullOrEmpty(parm.DeviceName), it => it.DeviceName.Contains(parm.DeviceName))
.AndIF(parm.DateTimeRange!=null&&parm.DateTimeRange.Length>0&&parm.DateTimeRange[0]>DateTime.MinValue,it=>it.CreatedTime >= parm.DateTimeRange[0])
.AndIF(parm.DateTimeRange!=null&&parm.DateTimeRange.Length>0&&parm.DateTimeRange[1]>DateTime.MinValue,it=>it.CreatedTime <= parm.DateTimeRange[1])
;
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage<DeviceDowntimeRecord, DeviceDowntimeRecordDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public DeviceDowntimeRecord GetInfo(int Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加设备停机时间
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DeviceDowntimeRecord AddDeviceDowntimeRecord(DeviceDowntimeRecord model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改设备停机时间
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateDeviceDowntimeRecord(DeviceDowntimeRecord model)
{
//var response = Update(w => w.Id == model.Id, it => new DeviceDowntimeRecord()
//{
// DeviceName = model.DeviceName,
// Downdate = model.Downdate,
// StartTime = model.StartTime,
// EndTime = model.EndTime,
// ConsumeTime = model.ConsumeTime,
// FaultPhenomenon = model.FaultPhenomenon,
// FaultReason = model.FaultReason,
// TemporaryMeasure = model.TemporaryMeasure,
// PermanentMeasure = model.PermanentMeasure,
// RepairPerson = model.RepairPerson,
// RepairResult = model.RepairResult,
// 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 DOAN.Model.MES.dev;
using DOAN.Model.MES.dev.Dto;
using System.Collections.Generic;
using DOAN.Model;
namespace DOAN.Service.MES.dev.IService
{
/// <summary>
/// 设备停机时间service接口
/// </summary>
public interface IDeviceDowntimeRecordService : IBaseService<DeviceDowntimeRecord>
{
PagedInfo<DeviceDowntimeRecordDto> GetList(DeviceDowntimeRecordQueryDto parm);
DeviceDowntimeRecord GetInfo(int Id);
DeviceDowntimeRecord AddDeviceDowntimeRecord(DeviceDowntimeRecord parm);
int UpdateDeviceDowntimeRecord(DeviceDowntimeRecord parm);
}
}