using Microsoft.AspNetCore.Mvc;
using DOAN.Admin.WebApi.Filters;
using DOAN.Service.huate_group.Recipe.IService;
using DOAN.Model.huate_group.recipe;
using DOAN.Model.huate_group.recipe.Dto;
using System.ComponentModel;
using Microsoft.AspNetCore.Http;
//创建时间:2024-08-21
namespace DOAN.Admin.WebApi.Controllers.huate_group.Recipe
{
///
/// 配方表
///
[Verify]
[Route("huate_group/Recipe/Recipe")]
public class RecipeController : BaseController
{
///
/// 配方表接口
///
private readonly IRecipeService _RecipeService;
public RecipeController(IRecipeService RecipeService)
{
_RecipeService = RecipeService;
}
///
/// 查询配方表列表
///
///
///
[HttpGet("list")]
[ActionPermissionFilter(Permission = "recipe:list")]
public IActionResult QueryRecipe([FromQuery] RecipeQueryDto parm)
{
var response = _RecipeService.GetList(parm);
return SUCCESS(response);
}
///
/// 查询配方表详情
///
///
///
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "recipe:query")]
public IActionResult GetRecipe(int Id)
{
var response = _RecipeService.GetInfo(Id);
var info = response.Adapt();
return SUCCESS(info);
}
///
/// 添加配方表
///
///
[HttpPost]
[ActionPermissionFilter(Permission = "recipe:add")]
[Log(Title = "配方表", BusinessType = BusinessType.INSERT)]
public IActionResult AddRecipe([FromBody] RecipeDto parm)
{
var modal = parm.Adapt().ToCreate(HttpContext);
var response = _RecipeService.AddRecipe(modal);
return SUCCESS(response);
}
///
/// 更新配方表
///
///
[HttpPut]
[ActionPermissionFilter(Permission = "recipe:edit")]
[Log(Title = "配方表", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateRecipe([FromBody] RecipeDto parm)
{
var modal = parm.Adapt().ToUpdate(HttpContext);
var response = _RecipeService.UpdateRecipe(modal);
return ToResponse(response);
}
///
/// 删除配方表
///
///
[HttpPost("delete/{ids}")]
[ActionPermissionFilter(Permission = "recipe:delete")]
[Log(Title = "配方表", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteRecipe([FromRoute] string ids)
{
var idArr = Tools.SplitAndConvert(ids);
return ToResponse(_RecipeService.Delete(idArr));
}
// TODO 根据配方id 获取上下限列表
[HttpGet("get_recipe/{Id}")]
public IActionResult GetRecipebyLimit(int Id)
{
if (Id <= 0)
{
throw new Exception("参数异常,请检查常数");
}
var response = _RecipeService.GetRecipebyLimit(Id);
return SUCCESS(response);
}
//TODO 获取公司
[HttpGet("get_company")]
public IActionResult GetAllCompany()
{
var response = _RecipeService.GetAllCompany();
return SUCCESS(response);
}
//TODO 获取车间
[HttpGet("get_workshop")]
public IActionResult GetWorkShopByCompany(int company_id)
{
if (company_id <= 0)
{
throw new Exception("参数异常,请检查常数");
}
var response = _RecipeService.GetWorkShopByCompany(company_id);
return SUCCESS(response);
}
//TODO 获取产线和设备 children
[HttpGet("get_line_childen_device")]
public IActionResult GetLineChildenDevice(int workshop_id)
{
if (workshop_id <= 0)
{
throw new Exception("参数异常,请检查常数");
}
var response = _RecipeService.GetLineChildenDevice(workshop_id);
return SUCCESS(response);
}
//TODO 选中配方
[HttpGet("selected")]
public IActionResult SelectedRecipe(int recipe_id)
{
if (recipe_id <= 0)
{
throw new Exception("参数异常,请检查常数");
}
var response = _RecipeService.SelectedRecipe(recipe_id);
return SUCCESS(response);
}
//TODO 获取车型
[HttpGet("get_vehicelmodel")]
public IActionResult GetVehicelModel(string? partString)
{
var response = _RecipeService.GetVehicelModel(partString);
return SUCCESS(response);
}
//TODO 获取零件号
[HttpGet("get_partnumber")]
public IActionResult GetPartNumber(string? partString)
{
var response = _RecipeService.GetPartNumber(partString);
return SUCCESS(response);
}
//TODO 根据设备获取参数
[HttpGet("get_paramter_list")]
public IActionResult GetParamterListByDevice(int device_id) {
var response = _RecipeService.GetParamterListByDevice(device_id);
return SUCCESS(response);
}
}
}