2024-08-27 12:59:42 +08:00

195 lines
5.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
{
/// <summary>
/// 配方表
/// </summary>
[Verify]
[Route("huate_group/Recipe/Recipe")]
public class RecipeController : BaseController
{
/// <summary>
/// 配方表接口
/// </summary>
private readonly IRecipeService _RecipeService;
public RecipeController(IRecipeService RecipeService)
{
_RecipeService = RecipeService;
}
/// <summary>
/// 查询配方表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
[ActionPermissionFilter(Permission = "recipe:list")]
public IActionResult QueryRecipe([FromQuery] RecipeQueryDto parm)
{
var response = _RecipeService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询配方表详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "recipe:query")]
public IActionResult GetRecipe(int Id)
{
var response = _RecipeService.GetInfo(Id);
var info = response.Adapt<RecipeDto>();
return SUCCESS(info);
}
/// <summary>
/// 添加配方表
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "recipe:add")]
[Log(Title = "配方表", BusinessType = BusinessType.INSERT)]
public IActionResult AddRecipe([FromBody] RecipeDto parm)
{
var modal = parm.Adapt<Recipee>().ToCreate(HttpContext);
var response = _RecipeService.AddRecipe(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新配方表
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "recipe:edit")]
[Log(Title = "配方表", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateRecipe([FromBody] RecipeDto parm)
{
var modal = parm.Adapt<Recipee>().ToUpdate(HttpContext);
var response = _RecipeService.UpdateRecipe(modal);
return ToResponse(response);
}
/// <summary>
/// 删除配方表
/// </summary>
/// <returns></returns>
[HttpPost("delete/{ids}")]
[ActionPermissionFilter(Permission = "recipe:delete")]
[Log(Title = "配方表", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteRecipe([FromRoute] string ids)
{
var idArr = Tools.SplitAndConvert<int>(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);
}
}
}