andon 数据管理
This commit is contained in:
parent
a587eb8d7c
commit
260d7699b3
@ -0,0 +1,110 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Model.MES.andon;
|
||||
using ZR.Model.MES.andon.Dto;
|
||||
using ZR.Service.MES.andon.IService;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
|
||||
//创建时间:2024-06-20
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 故障记录表
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("mes/andonManagement/AndonFaultRecord")]
|
||||
public class AndonFaultRecordController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 故障记录表接口
|
||||
/// </summary>
|
||||
private readonly IAndonFaultRecordService _AndonFaultRecordService;
|
||||
|
||||
public AndonFaultRecordController(IAndonFaultRecordService AndonFaultRecordService)
|
||||
{
|
||||
_AndonFaultRecordService = AndonFaultRecordService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询故障记录表列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("list")]
|
||||
[ActionPermissionFilter(Permission = "andonManagement:andonfaultrecord:list")]
|
||||
public IActionResult QueryAndonFaultRecord([FromBody] AndonFaultRecordQueryDto parm)
|
||||
{
|
||||
|
||||
var response = _AndonFaultRecordService.GetList(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询故障记录表详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{Id}")]
|
||||
[ActionPermissionFilter(Permission = "andonManagement:andonfaultrecord:query")]
|
||||
public IActionResult GetAndonFaultRecord(string Id)
|
||||
{
|
||||
var response = _AndonFaultRecordService.GetInfo(Id);
|
||||
|
||||
var info = response.Adapt<AndonFaultRecord>();
|
||||
return SUCCESS(info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加故障记录表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ActionPermissionFilter(Permission = "andonManagement:andonfaultrecord:add")]
|
||||
[Log(Title = "故障记录表", BusinessType = BusinessType.INSERT)]
|
||||
public IActionResult AddAndonFaultRecord([FromBody] AndonFaultRecordDto parm)
|
||||
{
|
||||
var modal = parm.Adapt<AndonFaultRecord>().ToCreate(HttpContext);
|
||||
|
||||
var response = _AndonFaultRecordService.AddAndonFaultRecord(modal);
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新故障记录表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[ActionPermissionFilter(Permission = "andonManagement:andonfaultrecord:edit")]
|
||||
[Log(Title = "故障记录表", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult UpdateAndonFaultRecord([FromBody] AndonFaultRecordDto parm)
|
||||
{
|
||||
var modal = parm.Adapt<AndonFaultRecord>().ToUpdate(HttpContext);
|
||||
var response = _AndonFaultRecordService.UpdateAndonFaultRecord(modal);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除故障记录表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[ActionPermissionFilter(Permission = "andonManagement:andonfaultrecord:delete")]
|
||||
[Log(Title = "故障记录表", BusinessType = BusinessType.DELETE)]
|
||||
public IActionResult DeleteAndonFaultRecord(string ids)
|
||||
{
|
||||
int[] idsArr = Tools.SpitIntArrary(ids);
|
||||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||
|
||||
var response = _AndonFaultRecordService.Delete(idsArr);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -36,7 +36,7 @@ namespace ZR.Model.Dto
|
||||
/// <summary>
|
||||
/// 安灯签到
|
||||
/// </summary>
|
||||
public class AndonResponseQueryDto
|
||||
public class AndonResponseQueryDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 表单id
|
||||
@ -48,7 +48,7 @@ namespace ZR.Model.Dto
|
||||
/// </summary>
|
||||
public string ResponsePerson { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
@ -56,7 +56,10 @@ namespace ZR.Model.Dto
|
||||
/// </summary>
|
||||
public class AndonFaultRecordQueryDto : PagerInfo
|
||||
{
|
||||
|
||||
public string LineCode { get; set; }
|
||||
public string AskPerson { get; set; }
|
||||
public string FaultDict { get; set; }
|
||||
public DateTime[] DateTimeRange { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
113
ZR.Service/MES/andon/AndonFaultRecordService.cs
Normal file
113
ZR.Service/MES/andon/AndonFaultRecordService.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using ZR.Model;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Model.MES.andon;
|
||||
using ZR.Model.MES.andon.Dto;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.MES.andon.IService;
|
||||
using System.Linq;
|
||||
using Aliyun.OSS;
|
||||
|
||||
namespace ZR.Service.MES.andon
|
||||
{
|
||||
/// <summary>
|
||||
/// 故障记录表Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IAndonFaultRecordService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class AndonFaultRecordService : BaseService<AndonFaultRecord>, IAndonFaultRecordService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询故障记录表列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<AndonFaultRecordDto> GetList(AndonFaultRecordQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<AndonFaultRecord>()
|
||||
.AndIF(!string.IsNullOrEmpty(parm.LineCode),it=>it.LineCode.Contains(parm.LineCode))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.AskPerson),it=>it.AskPerson.Contains(parm.AskPerson))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.FaultDict),it=>it.FaultDict.Contains(parm.FaultDict))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.FaultDict),it=>it.FaultDict.Contains(parm.FaultDict))
|
||||
.AndIF(parm.DateTimeRange.Count()==2&&parm.DateTimeRange[0]>DateTime.MinValue,it=>it.StartTime>= parm.DateTimeRange[0])
|
||||
.AndIF(parm.DateTimeRange.Count() == 2&&parm.DateTimeRange[1]>DateTime.MinValue,it=>it.StartTime<= parm.DateTimeRange[1])
|
||||
;
|
||||
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage<AndonFaultRecord, AndonFaultRecordDto>(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public AndonFaultRecord GetInfo(string Id)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Where(x => x.Id == Id)
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加故障记录表
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public AndonFaultRecord AddAndonFaultRecord(AndonFaultRecord model)
|
||||
{
|
||||
model.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
if(model.StartTime>DateTime.MinValue&&model.EndTime>DateTime.MinValue)
|
||||
{
|
||||
TimeSpan timeDifference = model.EndTime.Value - model.StartTime.Value;
|
||||
model.Duration = (decimal)timeDifference.TotalMinutes;
|
||||
}
|
||||
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改故障记录表
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateAndonFaultRecord(AndonFaultRecord model)
|
||||
{
|
||||
if (model.StartTime > DateTime.MinValue && model.EndTime > DateTime.MinValue)
|
||||
{
|
||||
TimeSpan timeDifference = model.EndTime.Value - model.StartTime.Value;
|
||||
model.Duration = (decimal)timeDifference.TotalMinutes;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.Duration = 0;
|
||||
}
|
||||
//var response = Update(w => w.Id == model.Id, it => new AndonFaultRecord()
|
||||
//{
|
||||
// LineCode = model.LineCode,
|
||||
// FaultDict = model.FaultDict,
|
||||
// FaultContext = model.FaultContext,
|
||||
// StartTime = model.StartTime,
|
||||
// EndTime = model.EndTime,
|
||||
// Duration = model.Duration,
|
||||
// AskPerson = model.AskPerson,
|
||||
// ResponsePerson = model.ResponsePerson,
|
||||
// CreatedBy = model.CreatedBy,
|
||||
// CreatedTime = model.CreatedTime,
|
||||
// UpdatedBy = model.UpdatedBy,
|
||||
// UpdatedTime = model.UpdatedTime,
|
||||
//});
|
||||
//return response;
|
||||
return Update(model, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
25
ZR.Service/MES/andon/IService/IAndonFaultRecordService.cs
Normal file
25
ZR.Service/MES/andon/IService/IAndonFaultRecordService.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using ZR.Model;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Model.MES.andon;
|
||||
using ZR.Model.MES.andon.Dto;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZR.Service.MES.andon.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 故障记录表service接口
|
||||
/// </summary>
|
||||
public interface IAndonFaultRecordService : IBaseService<AndonFaultRecord>
|
||||
{
|
||||
PagedInfo<AndonFaultRecordDto> GetList(AndonFaultRecordQueryDto parm);
|
||||
|
||||
AndonFaultRecord GetInfo(string Id);
|
||||
|
||||
AndonFaultRecord AddAndonFaultRecord(AndonFaultRecord parm);
|
||||
|
||||
int UpdateAndonFaultRecord(AndonFaultRecord parm);
|
||||
|
||||
}
|
||||
}
|
||||
@ -17,8 +17,5 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZR.ServiceCore\ZR.ServiceCore.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="MES\andon\IService\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user