149 lines
5.0 KiB
C#
149 lines
5.0 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
using DOAN.Model.Bydlms.Dto;
|
||
using DOAN.Model.Bydlms;
|
||
using DOAN.Service.Bydlms.IBydlmsService;
|
||
using DOAN.Admin.WebApi.Filters;
|
||
using Azure;
|
||
|
||
//创建时间:2025-02-19
|
||
namespace DOAN.Admin.WebApi.Controllers.Bydlms
|
||
{
|
||
/// <summary>
|
||
/// 生产工单
|
||
/// </summary>
|
||
|
||
[Route("bydlms/BydWorkorder")]
|
||
public class BydWorkorderController : BaseController
|
||
{
|
||
/// <summary>
|
||
/// 生产工单接口
|
||
/// </summary>
|
||
private readonly IBydWorkorderService _BydWorkorderService;
|
||
|
||
public BydWorkorderController(IBydWorkorderService BydWorkorderService)
|
||
{
|
||
_BydWorkorderService = BydWorkorderService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// BYD-MES传入生产工单
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("accept_BYD_MES_wrokorder_list")]
|
||
[AllowAnonymousAttribute]
|
||
[Log(Title = "BYD-MES传入生产工单", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult BatchAddBydWorkorder([FromBody] QueryParam parm)
|
||
{
|
||
try
|
||
{
|
||
var modalList = parm.Data.Adapt<List<BydWorkorder>>();
|
||
var response = _BydWorkorderService.AddBydWorkorderList(modalList);
|
||
Dictionary<string, string> result = new Dictionary<string, string>();
|
||
|
||
if (response)
|
||
{
|
||
result.Add("code", "000000");
|
||
result.Add("mesg", "操作成功");
|
||
return Ok(result); // 返回成功的响应
|
||
}
|
||
else
|
||
{
|
||
result.Add("code", "999999");
|
||
result.Add("mesg", "传入数据为空");
|
||
return BadRequest(result); // 返回失败的响应
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Dictionary<string, string> errorResult = new Dictionary<string, string>
|
||
{
|
||
{ "code", "999999" },
|
||
{ "mesg", ex.Message }
|
||
};
|
||
return StatusCode(500, errorResult); // 返回异常响应
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询生产工单列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[Verify]
|
||
[HttpGet("list")]
|
||
[ActionPermissionFilter(Permission = "bydworkorder:list")]
|
||
public IActionResult QueryBydWorkorder([FromQuery] BydWorkorderQueryDto parm)
|
||
{
|
||
var response = _BydWorkorderService.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询生产工单详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "bydworkorder:query")]
|
||
[Verify]
|
||
public IActionResult GetBydWorkorder(string Id)
|
||
{
|
||
var response = _BydWorkorderService.GetInfo(Id);
|
||
|
||
var info = response.Adapt<BydWorkorderDto>();
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加生产工单
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[ActionPermissionFilter(Permission = "bydworkorder:add")]
|
||
[Log(Title = "生产工单", BusinessType = BusinessType.INSERT)]
|
||
[Verify]
|
||
public IActionResult AddBydWorkorder([FromBody] BydWorkorderDto parm)
|
||
{
|
||
var modal = parm.Adapt<BydWorkorder>().ToCreate(HttpContext);
|
||
|
||
var response = _BydWorkorderService.AddBydWorkorder(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 更新生产工单
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "bydworkorder:edit")]
|
||
[Log(Title = "生产工单", BusinessType = BusinessType.UPDATE)]
|
||
[Verify]
|
||
public IActionResult UpdateBydWorkorder([FromBody] BydWorkorderDto parm)
|
||
{
|
||
var modal = parm.Adapt<BydWorkorder>().ToUpdate(HttpContext);
|
||
var response = _BydWorkorderService.UpdateBydWorkorder(modal);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除生产工单
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("delete/{ids}")]
|
||
[ActionPermissionFilter(Permission = "bydworkorder:delete")]
|
||
[Log(Title = "生产工单", BusinessType = BusinessType.DELETE)]
|
||
[Verify]
|
||
public IActionResult DeleteBydWorkorder([FromRoute]string ids)
|
||
{
|
||
var idArr = Tools.SplitAndConvert<string>(ids);
|
||
|
||
return ToResponse(_BydWorkorderService.Delete(idArr));
|
||
}
|
||
|
||
}
|
||
} |