添加设备停机率
This commit is contained in:
parent
992cecc2d4
commit
132fd6e281
@ -0,0 +1,38 @@
|
||||
using DOAN.Model.MES.dev.Dto;
|
||||
using DOAN.Service.MES.dev;
|
||||
using DOAN.Service.MES.dev.IService;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DOAN.WebApi.Controllers.MES.dev
|
||||
{
|
||||
[Route("api/DeviceMaintenancePerformance")]
|
||||
[ApiController]
|
||||
public class DeviceMaintenancePerformanceController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保全率接口
|
||||
/// </summary>
|
||||
private readonly IDeviceMaintenancePerformanceService _deviceMaintenancePerformance;
|
||||
|
||||
public DeviceMaintenancePerformanceController(IDeviceMaintenancePerformanceService deviceMaintenancePerformance)
|
||||
{
|
||||
_deviceMaintenancePerformance = deviceMaintenancePerformance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询设备运行绩效分析列表
|
||||
/// </summary>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <param name="workshop"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> QueryDevicePerformance(string startTime, string endTime, string workshop)
|
||||
{
|
||||
|
||||
var response = await _deviceMaintenancePerformance.DeviceUptimesAsync(startTime, endTime, workshop);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
109
DOAN.Admin.WebApi/Controllers/MES/dev/DeviceUptimeController.cs
Normal file
109
DOAN.Admin.WebApi/Controllers/MES/dev/DeviceUptimeController.cs
Normal file
@ -0,0 +1,109 @@
|
||||
using DOAN.Admin.WebApi.Filters;
|
||||
using DOAN.Model.MES.dev.Dto;
|
||||
using DOAN.Model.MES.dev;
|
||||
using DOAN.Service.MES.dev;
|
||||
using DOAN.Service.MES.dev.IService;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
|
||||
namespace DOAN.WebApi.Controllers.MES.dev
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保全率
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("business/DeviceUptime")]
|
||||
public class DeviceUptimeController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保全率接口
|
||||
/// </summary>
|
||||
private readonly IDeviceUptimeService _DeviceUptimeService;
|
||||
|
||||
public DeviceUptimeController(IDeviceUptimeService DeviceUptimeService)
|
||||
{
|
||||
_DeviceUptimeService = DeviceUptimeService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询设备保全率列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
[ActionPermissionFilter(Permission = "business:deviceuptime:list")]
|
||||
public IActionResult QueryDeviceUptime([FromQuery] DeviceUptimeQueryDto parm)
|
||||
{
|
||||
var response = _DeviceUptimeService.GetList(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询设备保全率详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{Id}")]
|
||||
[ActionPermissionFilter(Permission = "business:deviceuptime:query")]
|
||||
public IActionResult GetDeviceUptime(string Id)
|
||||
{
|
||||
var response = _DeviceUptimeService.GetInfo(Id);
|
||||
|
||||
var info = response.Adapt<DeviceUptime>();
|
||||
return SUCCESS(info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加设备保全率
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ActionPermissionFilter(Permission = "business:deviceuptime:add")]
|
||||
[Log(Title = "设备保全率", BusinessType = BusinessType.INSERT)]
|
||||
public IActionResult AddDeviceUptime([FromBody] DeviceUptimeDto parm)
|
||||
{
|
||||
var modal = parm.Adapt<DeviceUptime>().ToCreate(HttpContext);
|
||||
modal.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
var response = _DeviceUptimeService.AddDeviceUptime(modal);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新设备保全率
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[ActionPermissionFilter(Permission = "business:deviceuptime:edit")]
|
||||
[Log(Title = "设备保全率", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult UpdateDeviceUptime([FromBody] DeviceUptimeDto parm)
|
||||
{
|
||||
var modal = parm.Adapt<DeviceUptime>().ToUpdate(HttpContext);
|
||||
var response = _DeviceUptimeService.UpdateDeviceUptime(modal);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除设备保全率
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[ActionPermissionFilter(Permission = "business:deviceuptime:delete")]
|
||||
[Log(Title = "设备保全率", BusinessType = BusinessType.DELETE)]
|
||||
public IActionResult DeleteDeviceUptime(string ids)
|
||||
{
|
||||
int[] idsArr = Tools.SpitIntArrary(ids);
|
||||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||
|
||||
var response = _DeviceUptimeService.Delete(idsArr);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
72
DOAN.Model/MES/dev/DeviceUptime.cs
Normal file
72
DOAN.Model/MES/dev/DeviceUptime.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOAN.Model.MES.dev
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保全率
|
||||
/// </summary>
|
||||
[SugarTable("device_uptime")]
|
||||
public class DeviceUptime
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键id
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 目标率
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "target_value")]
|
||||
public string targetValue{ get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际率
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "actual_value")]
|
||||
public string ActualValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车间
|
||||
/// </summary>
|
||||
public string Workshop { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 填写时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "fill_time")]
|
||||
public string FillTime { 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; }
|
||||
|
||||
/// <summary>
|
||||
/// 类别区分
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
}
|
||||
}
|
||||
40
DOAN.Model/MES/dev/Dto/DeviceUptimeQueryDto.cs
Normal file
40
DOAN.Model/MES/dev/Dto/DeviceUptimeQueryDto.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOAN.Model.MES.dev.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保全率查询对象
|
||||
/// </summary>
|
||||
public class DeviceUptimeQueryDto : PagerInfo
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设备保全率输入输出对象
|
||||
/// </summary>
|
||||
public class DeviceUptimeDto
|
||||
{
|
||||
public string Id { get; set; }
|
||||
|
||||
public string targetValue{ get; set; }
|
||||
|
||||
public string ActualValue { get; set; }
|
||||
|
||||
public string Workshop { get; set; }
|
||||
|
||||
public string FillTime { get; set; }
|
||||
|
||||
public string CreatedBy { get; set; }
|
||||
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
|
||||
public string UpdatedBy { get; set; }
|
||||
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
public string Type { get; set; }
|
||||
}
|
||||
}
|
||||
33
DOAN.Service/MES/dev/DeviceMaintenancePerformanceService.cs
Normal file
33
DOAN.Service/MES/dev/DeviceMaintenancePerformanceService.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using Aliyun.OSS;
|
||||
using DOAN.Model.MES.dev;
|
||||
using DOAN.Model.MES.dev.Dto;
|
||||
using DOAN.Repository;
|
||||
using DOAN.Service.MES.dev.IService;
|
||||
using Infrastructure.Attribute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOAN.Service.MES.dev
|
||||
{
|
||||
[AppService(ServiceType = typeof(IDeviceMaintenancePerformanceService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class DeviceMaintenancePerformanceService:BaseService<DeviceUptime>,IDeviceMaintenancePerformanceService
|
||||
{
|
||||
public async Task<Dictionary<string, List<DeviceUptime>>> DeviceUptimesAsync(string startTime, string endTime,string workshop)
|
||||
{
|
||||
|
||||
var query = Context.Queryable<DeviceUptime>()
|
||||
.Where(x => x.Workshop == workshop)
|
||||
.Where(x => x.FillTime.CompareTo($"{startTime}") >= 0)
|
||||
.Where(x => x.FillTime.CompareTo($"{endTime}") <= 0)
|
||||
.OrderBy(x=>x.FillTime);
|
||||
|
||||
var result = (await query.ToListAsync()).GroupBy(x => x.Type)
|
||||
.ToDictionary(g => g.Key, g => g.ToList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
88
DOAN.Service/MES/dev/DeviceUptimeService.cs
Normal file
88
DOAN.Service/MES/dev/DeviceUptimeService.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using Aliyun.OSS;
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.MES.dev;
|
||||
using DOAN.Model.MES.dev.Dto;
|
||||
using DOAN.Repository;
|
||||
using DOAN.Service.MES.dev.IService;
|
||||
using Infrastructure.Attribute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOAN.Service.MES.dev
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保全率Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IDeviceUptimeService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class DeviceUptimeService : BaseService<DeviceUptime>, IDeviceUptimeService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询设备保全率列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<DeviceUptimeDto> GetList(DeviceUptimeQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<DeviceUptime>();
|
||||
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage<DeviceUptime, DeviceUptimeDto>(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public DeviceUptime GetInfo(string Id)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Where(x => x.Id == Id)
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加设备保全率
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public DeviceUptime AddDeviceUptime(DeviceUptime model)
|
||||
{
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改设备保全率
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateDeviceUptime(DeviceUptime model)
|
||||
{
|
||||
var response = Update(w => w.Id == model.Id, it => new DeviceUptime()
|
||||
{
|
||||
|
||||
targetValue = model.targetValue,
|
||||
ActualValue = model.ActualValue,
|
||||
Workshop = model.Workshop,
|
||||
FillTime = model.FillTime,
|
||||
CreatedBy = model.CreatedBy,
|
||||
CreatedTime = model.CreatedTime,
|
||||
UpdatedBy = model.UpdatedBy,
|
||||
Type = model.Type,
|
||||
UpdatedTime = model.UpdatedTime,
|
||||
});
|
||||
return response;
|
||||
//return Update(model, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
using DOAN.Model.MES.dev;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOAN.Service.MES.dev.IService
|
||||
{
|
||||
public interface IDeviceMaintenancePerformanceService
|
||||
{
|
||||
public Task<Dictionary<string, List<DeviceUptime>>> DeviceUptimesAsync(string startTime, string endTime, string workshop);
|
||||
}
|
||||
}
|
||||
26
DOAN.Service/MES/dev/IService/IDeviceUptimeIService.cs
Normal file
26
DOAN.Service/MES/dev/IService/IDeviceUptimeIService.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.MES.dev;
|
||||
using DOAN.Model.MES.dev.Dto;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOAN.Service.MES.dev.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保全率service接口
|
||||
/// </summary>
|
||||
public interface IDeviceUptimeService : IBaseService<DeviceUptime>
|
||||
{
|
||||
PagedInfo<DeviceUptimeDto> GetList(DeviceUptimeQueryDto parm);
|
||||
|
||||
DeviceUptime GetInfo(string Id);
|
||||
|
||||
DeviceUptime AddDeviceUptime(DeviceUptime parm);
|
||||
|
||||
int UpdateDeviceUptime(DeviceUptime parm);
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user