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
{
///
/// 缺陷收集
///
[Verify]
[Route("mes/qualityManagement/IPQC/QcDefectCollection")]
public class QcDefectCollectionController : BaseController
{
///
/// 缺陷收集接口
///
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);
}
///
/// 查询缺陷收集列表
///
///
///
[HttpGet("list")]
[ActionPermissionFilter(Permission = "qualityManagement:qcdefectcollection:list")]
public IActionResult QueryQcDefectCollection([FromQuery] QcDefectCollectionQueryDto parm)
{
var response = _QcDefectCollectionService.GetList(parm);
return SUCCESS(response);
}
///
/// 查询缺陷收集详情
///
///
///
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "qualityManagement:qcdefectcollection:query")]
public IActionResult GetQcDefectCollection(string Id)
{
var response = _QcDefectCollectionService.GetInfo(Id);
var info = response.Adapt();
return SUCCESS(info);
}
///
/// 添加缺陷收集
///
///
[HttpPost]
[ActionPermissionFilter(Permission = "qualityManagement:qcdefectcollection:add")]
[Log(Title = "缺陷收集", BusinessType = BusinessType.INSERT)]
public IActionResult AddQcDefectCollection([FromBody] QcDefectCollectionDto parm)
{
var modal = parm.Adapt().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);
}
///
/// 更新缺陷收集
///
///
[HttpPut]
[ActionPermissionFilter(Permission = "qualityManagement:qcdefectcollection:edit")]
[Log(Title = "缺陷收集", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateQcDefectCollection([FromBody] QcDefectCollectionDto parm)
{
var modal = parm.Adapt().ToUpdate(HttpContext);
var response = _QcDefectCollectionService.UpdateQcDefectCollection(modal);
return ToResponse(response);
}
///
/// 删除缺陷收集
///
///
[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_add_supplier")]
public IActionResult GetAddSupplier(string supplierCode)
{
var response = _QcDefectCollectionService.GetAllSuppliers(supplierCode);
return SUCCESS(response);
}
}
}