-
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using Apollinare.API.Modules.Production.Dtos;
|
||||
using Apollinare.API.Modules.Production.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Apollinare.API.Modules.Production.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/production/bom")]
|
||||
public class BillOfMaterialsController : ControllerBase
|
||||
{
|
||||
private readonly IProductionService _productionService;
|
||||
|
||||
public BillOfMaterialsController(IProductionService productionService)
|
||||
{
|
||||
_productionService = productionService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<List<BillOfMaterialsDto>>> GetAll()
|
||||
{
|
||||
return Ok(await _productionService.GetBillOfMaterialsAsync());
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<BillOfMaterialsDto>> GetById(int id)
|
||||
{
|
||||
var bom = await _productionService.GetBillOfMaterialsByIdAsync(id);
|
||||
if (bom == null) return NotFound();
|
||||
return Ok(bom);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<BillOfMaterialsDto>> Create(CreateBillOfMaterialsDto dto)
|
||||
{
|
||||
var bom = await _productionService.CreateBillOfMaterialsAsync(dto);
|
||||
return CreatedAtAction(nameof(GetById), new { id = bom.Id }, bom);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<ActionResult<BillOfMaterialsDto>> Update(int id, UpdateBillOfMaterialsDto dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bom = await _productionService.UpdateBillOfMaterialsAsync(id, dto);
|
||||
return Ok(bom);
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<ActionResult> Delete(int id)
|
||||
{
|
||||
await _productionService.DeleteBillOfMaterialsAsync(id);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using Apollinare.API.Modules.Production.Dtos;
|
||||
using Apollinare.API.Modules.Production.Services;
|
||||
using Apollinare.Domain.Entities.Production;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Apollinare.API.Modules.Production.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/production/mrp")]
|
||||
public class MrpController : ControllerBase
|
||||
{
|
||||
private readonly IMrpService _mrpService;
|
||||
|
||||
public MrpController(IMrpService mrpService)
|
||||
{
|
||||
_mrpService = mrpService;
|
||||
}
|
||||
|
||||
[HttpPost("run")]
|
||||
public async Task<IActionResult> RunMrp([FromBody] MrpConfigurationDto config)
|
||||
{
|
||||
await _mrpService.RunMrpAsync(config);
|
||||
return Ok(new { message = "MRP Run completed successfully" });
|
||||
}
|
||||
|
||||
[HttpGet("suggestions")]
|
||||
public async Task<ActionResult<List<MrpSuggestion>>> GetSuggestions([FromQuery] bool includeProcessed = false)
|
||||
{
|
||||
return await _mrpService.GetSuggestionsAsync(includeProcessed);
|
||||
}
|
||||
|
||||
[HttpPost("suggestions/{id}/process")]
|
||||
public async Task<IActionResult> ProcessSuggestion(int id)
|
||||
{
|
||||
await _mrpService.ProcessSuggestionAsync(id);
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using Apollinare.API.Modules.Production.Dtos;
|
||||
using Apollinare.API.Modules.Production.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Apollinare.API.Modules.Production.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/production/cycles")]
|
||||
public class ProductionCyclesController : ControllerBase
|
||||
{
|
||||
private readonly IProductionService _productionService;
|
||||
|
||||
public ProductionCyclesController(IProductionService productionService)
|
||||
{
|
||||
_productionService = productionService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<List<ProductionCycleDto>>> GetProductionCycles()
|
||||
{
|
||||
return await _productionService.GetProductionCyclesAsync();
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<ProductionCycleDto>> GetProductionCycle(int id)
|
||||
{
|
||||
var cycle = await _productionService.GetProductionCycleByIdAsync(id);
|
||||
if (cycle == null) return NotFound();
|
||||
return cycle;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ProductionCycleDto>> CreateProductionCycle(CreateProductionCycleDto dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
var cycle = await _productionService.CreateProductionCycleAsync(dto);
|
||||
return CreatedAtAction(nameof(GetProductionCycle), new { id = cycle.Id }, cycle);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
return BadRequest(new { message = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<ActionResult<ProductionCycleDto>> UpdateProductionCycle(int id, UpdateProductionCycleDto dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _productionService.UpdateProductionCycleAsync(id, dto);
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteProductionCycle(int id)
|
||||
{
|
||||
await _productionService.DeleteProductionCycleAsync(id);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using Apollinare.API.Modules.Production.Dtos;
|
||||
using Apollinare.API.Modules.Production.Services;
|
||||
using Apollinare.Domain.Entities.Production;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Apollinare.API.Modules.Production.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/production/orders")]
|
||||
public class ProductionOrdersController : ControllerBase
|
||||
{
|
||||
private readonly IProductionService _productionService;
|
||||
|
||||
public ProductionOrdersController(IProductionService productionService)
|
||||
{
|
||||
_productionService = productionService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<List<ProductionOrderDto>>> GetAll()
|
||||
{
|
||||
return Ok(await _productionService.GetProductionOrdersAsync());
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<ProductionOrderDto>> GetById(int id)
|
||||
{
|
||||
var order = await _productionService.GetProductionOrderByIdAsync(id);
|
||||
if (order == null) return NotFound();
|
||||
return Ok(order);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ProductionOrderDto>> Create(CreateProductionOrderDto dto)
|
||||
{
|
||||
var order = await _productionService.CreateProductionOrderAsync(dto);
|
||||
return CreatedAtAction(nameof(GetById), new { id = order.Id }, order);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<ActionResult<ProductionOrderDto>> Update(int id, UpdateProductionOrderDto dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
var order = await _productionService.UpdateProductionOrderAsync(id, dto);
|
||||
return Ok(order);
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("{id}/status")]
|
||||
public async Task<ActionResult<ProductionOrderDto>> ChangeStatus(int id, [FromBody] ProductionOrderStatus status)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _productionService.ChangeProductionOrderStatusAsync(id, status);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
return BadRequest(new { message = ex.Message });
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("{id}/phases/{phaseId}")]
|
||||
public async Task<ActionResult<ProductionOrderDto>> UpdatePhase(int id, int phaseId, UpdateProductionOrderPhaseDto dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _productionService.UpdateProductionOrderPhaseAsync(id, phaseId, dto);
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<ActionResult> Delete(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _productionService.DeleteProductionOrderAsync(id);
|
||||
return NoContent();
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using Apollinare.API.Modules.Production.Dtos;
|
||||
using Apollinare.API.Modules.Production.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Apollinare.API.Modules.Production.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/production/work-centers")]
|
||||
public class WorkCentersController : ControllerBase
|
||||
{
|
||||
private readonly IProductionService _productionService;
|
||||
|
||||
public WorkCentersController(IProductionService productionService)
|
||||
{
|
||||
_productionService = productionService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<List<WorkCenterDto>>> GetWorkCenters()
|
||||
{
|
||||
return await _productionService.GetWorkCentersAsync();
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<WorkCenterDto>> GetWorkCenter(int id)
|
||||
{
|
||||
var wc = await _productionService.GetWorkCenterByIdAsync(id);
|
||||
if (wc == null) return NotFound();
|
||||
return wc;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<WorkCenterDto>> CreateWorkCenter(CreateWorkCenterDto dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
var wc = await _productionService.CreateWorkCenterAsync(dto);
|
||||
return CreatedAtAction(nameof(GetWorkCenter), new { id = wc.Id }, wc);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
return BadRequest(new { message = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<ActionResult<WorkCenterDto>> UpdateWorkCenter(int id, UpdateWorkCenterDto dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _productionService.UpdateWorkCenterAsync(id, dto);
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteWorkCenter(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _productionService.DeleteWorkCenterAsync(id);
|
||||
return NoContent();
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
return BadRequest(new { message = ex.Message });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user