You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.2 KiB
C#

1 year ago
using Admin.Core.IService;
using Admin.Core.Service;
using Admin.Core.IService.ISys;
using Admin.Core.Model;
using Admin.Core.Common.Resource;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Admin.Core.Common;
using System.Linq;
using Admin.Core.Model.ViewModels;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using System.Collections;
namespace Admin.Core.Api.Controllers.Business
{
/// <summary>
/// 反应釜防错验证
/// </summary>
[Route("api/[controller]/[action]")]
[ApiController]
[AllowAnonymous]
public class WarehouseController : BaseApiUserController
{
#region 整包信息
//000524-20230805-0001-CF-130|25kg
//000524:为物料编码
//CF-130:物料名称
//25kg物料重量
#endregion
/// <summary>
/// 投料仓服务
/// </summary>
private readonly IHw_WarehouseServices _hw_WarehouseService;
/// <summary>
/// 构造方法
/// </summary>
/// <param name="hw_WarehouseServices"></param>
/// <param name="sysUserService"></param>
public WarehouseController(IHw_WarehouseServices hw_WarehouseServices, ISysUserService sysUserService) : base(sysUserService)
{
_sysUserService = sysUserService;
_hw_WarehouseService = hw_WarehouseServices;
}
#region 获取反应釜所有计划号
///// <summary>
///// 获取反应釜所有计划号
///// </summary>
///// <returns></returns>
//[HttpGet]
//public async Task<MessageModel<List<string>>> GetAllPlan()
//{
// var query = await _hw_WarehouseService.GetPlan();
// if (query == null)
// {
// return Failed<List<string>>("未查询到计划号!");
// }
// return Success(query);
//}
#endregion
#region 扫描料桶条码 获取桶绑定物料信息
/// <summary>
/// 扫描料桶条码 获取桶绑定物料信息
/// </summary>
/// <param name="code">桶条码</param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<BarrelView>> GetByBarrelInfo(string code)
{
if (!code.IsNotEmptyOrNull())
{
return Failed<BarrelView>("传入参数为空!");
}
var query = await _hw_WarehouseService.GetXlInfo(code.Trim());
if (query == null)
{
return Failed<BarrelView>("查询失败!");
}
return Success(query);
}
#endregion
#region 根据条码查询投料釜设置的物料
/// <summary>
/// 根据条码查询投料釜设置的物料
/// </summary>
/// <param name="code">投料釜条码</param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<WarehouseView>> GetByCode(string code)
{
if (!code.IsNotEmptyOrNull())
{
return Failed<WarehouseView>("传入参数为空!");
}
var query = await _hw_WarehouseService.QueryByCode(code.Trim());
if (query==null)
{
return Failed<WarehouseView>("查询失败!");
}
return Success(query);
}
#endregion
#region PLC更新状态——反应釜
/// <summary>
/// PLC更新状态——反应釜
/// </summary>
/// <param name="view">json 对象</param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<bool>> ExecPlcState([FromBody] KettleView view)
{
if (!view.IsNotEmptyOrNull())
{
return Failed<bool>("传入参数为空!");
}
var result = await _hw_WarehouseService.UpdatePlcState(view);
if (result)
{
return Success(result);
}
return Failed<bool>("执行失败!");
}
#endregion
}
}