2024-11-04 14:56:09 +08:00

156 lines
5.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.AspNetCore.Mvc;
using DOAN.Model.Dto;
using DOAN.Admin.WebApi.Filters;
using DOAN.Infrastructure;
using Aliyun.OSS;
using DOAN.Service.MES.quality.IPQC.IService;
using DOAN.Model.MES.quality.IPQC.Dto;
using DOAN.Model.MES.quality.IPQC;
//创建时间2024-09-30
namespace DOAN.WebApi.Controllers.MES.quality.IPQC
{
/// <summary>
/// 缺陷收集
/// </summary>
[Verify]
[Route("mes/qualityManagement/IPQC/QcDefectCollection")]
public class QcDefectCollectionController : BaseController
{
/// <summary>
/// 缺陷收集接口
/// </summary>
private readonly IQcDefectCollectionService _QcDefectCollectionService;
public QcDefectCollectionController(IQcDefectCollectionService QcDefectCollectionService)
{
_QcDefectCollectionService = QcDefectCollectionService;
}
//TODO 生成指定产线和日期的 缺陷收集计划
[HttpGet("generate_defectCollection")]
public IActionResult GenerateDefectConllectionPlan(string line_code, DateTime dateTime)
{
dateTime = ConvertDateTime.ConvertLocalDate(dateTime);
if (string.IsNullOrEmpty(line_code) || dateTime == DateTime.MinValue)
{
throw new CustomException("请求数据为空");
}
var response = _QcDefectCollectionService.GenerateDefectConllectionPlan(line_code, dateTime, HttpContext.GetName());
return SUCCESS(response);
}
/// <summary>
/// 查询缺陷收集列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
[ActionPermissionFilter(Permission = "qualityManagement:qcdefectcollection:list")]
public IActionResult QueryQcDefectCollection([FromQuery] QcDefectCollectionQueryDto parm)
{
var response = _QcDefectCollectionService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询缺陷收集详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "qualityManagement:qcdefectcollection:query")]
public IActionResult GetQcDefectCollection(string Id)
{
var response = _QcDefectCollectionService.GetInfo(Id);
var info = response.Adapt<QcDefectCollection>();
return SUCCESS(info);
}
/// <summary>
/// 添加缺陷收集
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "qualityManagement:qcdefectcollection:add")]
[Log(Title = "缺陷收集", BusinessType = BusinessType.INSERT)]
public IActionResult AddQcDefectCollection([FromBody] QcDefectCollectionDto parm)
{
var modal = parm.Adapt<QcDefectCollection>().ToCreate(HttpContext);
var response = _QcDefectCollectionService.AddQcDefectCollection(modal);
return SUCCESS(response);
}
//TODO 复制同种物料
[HttpGet("copySameMaterial")]
public IActionResult CopySameMaterial(string id)
{
if (string.IsNullOrEmpty(id))
{
throw new CustomException("id为空");
}
var response = _QcDefectCollectionService.CopySameMaterial(id);
return SUCCESS(response);
}
/// <summary>
/// 更新缺陷收集
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "qualityManagement:qcdefectcollection:edit")]
[Log(Title = "缺陷收集", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateQcDefectCollection([FromBody] QcDefectCollectionDto parm)
{
var modal = parm.Adapt<QcDefectCollection>().ToUpdate(HttpContext);
var response = _QcDefectCollectionService.UpdateQcDefectCollection(modal);
return ToResponse(response);
}
/// <summary>
/// 删除缺陷收集
/// </summary>
/// <returns></returns>
[HttpDelete("{ids}")]
[ActionPermissionFilter(Permission = "qualityManagement:qcdefectcollection:delete")]
[Log(Title = "缺陷收集", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteQcDefectCollection(string ids)
{
string[] idsArr = Tools.SpitStrArrary(ids);
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
var response = _QcDefectCollectionService.Delete(idsArr);
return ToResponse(response);
}
//TODO 获取产线
[HttpGet("get_all_line")]
public IActionResult GetAllLines()
{
var response = _QcDefectCollectionService.GetAllLines();
return SUCCESS(response);
}
//TODO 获取所有供应商
[HttpGet("get_all_supplier")]
public IActionResult GetAllSupplier(string supplierCode)
{
var response = _QcDefectCollectionService.GetAllSuppliers(supplierCode);
return SUCCESS(response);
}
}
}