Files
wcs/WCS.WebApi/Controllers/BatchBindMatDetailController.cs
2025-01-18 18:22:02 +08:00

100 lines
3.4 KiB
C#

using Microsoft.AspNetCore.Mvc;
using WCS.BLL.DbModels;
using WCS.BLL.Services.IService;
using WCS.DAL.Db;
using WCS.DAL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel;
using WCS.Model.ApiModel.BatchBindMatDetail;
using WCS.Model.ApiModel.Home;
using WCS.Model.ApiModel.PDAMatBind;
using WCS.Model.ApiModel.User;
using WCS.Model.WebSocketModel;
namespace WCS.WebApi.Controllers
{
/// <summary>
/// PDA物料绑定相关接口
/// </summary>
[ApiController]
[Route("[controller]")]
public class BatchBindMatDetailController : ControllerBase
{
public IBatchBindMatDetailService _batchBindMatDetailService { get; set; }
public BatchBindMatDetailController(IBatchBindMatDetailService batchBindMatDetailService)
{
_batchBindMatDetailService = batchBindMatDetailService;
}
[Route("getOrderTypes")]
[HttpPost(Name = "getOrderTypes")]
public async Task<ResponseBase> getOrderTypes(RequestBase request)
{
try
{
//直接获取当前所有货架类型并返回
var OrderTypes = DbHelp.db.Queryable<OrderTypeInfo>()
.Select(t => new OrderTypeModel()
{
Id = t.Id,
OrderTypeName = t.OrderTypeName
})
.ToList();
return new PageQueryResponse<OrderTypeModel>()
{
Code = 200,
Message = "success",
Data = new PageQueryResponseData<OrderTypeModel>
{
Lists = OrderTypes,
Count = OrderTypes.Count
}
};
}
catch (Exception ex)
{
return new PageQueryResponse<OrderTypeModel>()
{
Code = 300,
Message = $"查询失败:{ex.Message}",
};
}
}
[Route("getMatDetailCurrentInfosByStationCode")]
[HttpPost(Name = "getMatDetailCurrentInfosByStationCode")]
public async Task<ResponseBase> GetMatDetailCurrentInfosByStationCode(GetMatDetailCurrentInfosByStationCodeRequest request)
{
//判断参数
if (string.IsNullOrEmpty(request.StationCode))
{
return new ResponseCommon()
{
Code = 201,
Message = "工位编码为空,请联系相关人员进行配置!",
Data = null,
};
}
//判断工位是否存在
var isExsistLocation = await DbHelp.db.Queryable<LocationInfo>()
.Where(t => t.LocationCode == request.StationCode)
.AnyAsync();
//不存在工位
if (!isExsistLocation)
{
return new ResponseCommon()
{
Code = 201,
Message = $"工位[{request.StationCode}]不存在,暂时无法使用此功能!",
Data = null,
};
}
return await _batchBindMatDetailService.GetMatDetailCurrentInfosByStationCode(request);
}
}
}