using RIZO.Admin.WebApi.Filters;
using RIZO.Common;
using RIZO.ServiceCore.Middleware;
using Infrastructure;
using Infrastructure.Attribute;
using Infrastructure.Controllers;
using Infrastructure.Enums;
using Infrastructure.Model;
using Mapster;
using MDM.Model.Plant;
using MDM.Model.Plant.Dto;
using MDM.Services.IPlantService;
using MDM.Services.Plant;
using Microsoft.AspNetCore.Mvc;
//创建时间:2025-11-15
namespace MDM.Controllers.Plant
{
///
/// 工站/资源组
///
[Verify]
[Route("MasterDataManagement/Plant/PlantWorkstation")]
public class PlantWorkstationController : BaseController
{
///
/// 工站/资源组接口
///
private readonly IPlantWorkstationService _PlantWorkstationService;
public PlantWorkstationController(IPlantWorkstationService PlantWorkstationService)
{
_PlantWorkstationService = PlantWorkstationService;
}
///
/// 查询工站/资源组列表
///
///
///
[HttpGet("list")]
[ActionPermissionFilter(Permission = "business:plantworkstation:list")]
public IActionResult QueryPlantWorkstation([FromQuery] PlantWorkstationQueryDto parm)
{
var response = _PlantWorkstationService.GetList(parm);
return SUCCESS(response);
}
///
/// 查询工站/资源组详情
///
///
///
[HttpGet("{WorkstationId}")]
[ActionPermissionFilter(Permission = "business:plantworkstation:query")]
public IActionResult GetPlantWorkstation(int WorkstationId)
{
var response = _PlantWorkstationService.GetInfo(WorkstationId);
var info = response.Adapt();
return SUCCESS(info);
}
///
/// 添加工站/资源组
///
///
[HttpPost]
[ActionPermissionFilter(Permission = "business:plantworkstation:add")]
[Log(Title = "工站/资源组", BusinessType = BusinessType.INSERT)]
public IActionResult AddPlantWorkstation([FromBody] PlantWorkstationDto parm)
{
var modal = parm.Adapt().ToCreate(HttpContext);
var response = _PlantWorkstationService.AddPlantWorkstation(modal);
return SUCCESS(response);
}
///
/// 更新工站/资源组
///
///
[HttpPut]
[ActionPermissionFilter(Permission = "business:plantworkstation:edit")]
[Log(Title = "工站/资源组", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdatePlantWorkstation([FromBody] PlantWorkstationDto parm)
{
var modal = parm.Adapt().ToUpdate(HttpContext);
var response = _PlantWorkstationService.UpdatePlantWorkstation(modal);
return ToResponse(response);
}
///
/// 删除工站/资源组
///
///
[HttpDelete("{ids}")]
[ActionPermissionFilter(Permission = "business:plantworkstation:delete")]
[Log(Title = "工站/资源组", BusinessType = BusinessType.DELETE)]
public IActionResult DeletePlantWorkstation(string ids)
{
int[] idsArr = Tools.SpitIntArrary(ids);
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
var response = _PlantWorkstationService.Delete(idsArr);
return ToResponse(response);
}
//TODO 获取工厂
///
/// 获取工厂
///
/// 工厂code
///
[HttpGet("get_factory_site")]
public IActionResult GetFactorySite(string site_code)
{
var response = _PlantWorkstationService.GetFactorySite(site_code);
return SUCCESS(response);
}
//获取车间
[HttpGet("get_workshop")]
public IActionResult GetWorkShop(string site_code,string workshop_code)
{
var response = _PlantWorkstationService.GetWorkShop(site_code,workshop_code);
return SUCCESS(response);
}
//获取产线
[HttpGet("get_productlinebody")]
public IActionResult GetProductlinebody(string site_code, string workshop_code,string linecode)
{
var response = _PlantWorkstationService.GetPlantProductlinebodies(site_code, workshop_code,linecode);
return SUCCESS(response);
}
}
}