using Microsoft.AspNetCore.Mvc;
using WCS.BLL.DbModels;
using WCS.BLL.Services.IService;
using WCS.BLL.Services.Service;
using WCS.DAL.Db;
using WCS.DAL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel.LocationInfo;
using WCS.Model.ApiModel.MatBaseInfo;
using WCS.Model.ApiModel.MatDetailCurrentInfo;
using WCS.Model.ApiModel.MatDetailHistoryInfo;
using WCS.Model.ApiModel.PDAProductionLineCallIn;
using WCS.Model.ApiModel.PDAProductionLineCallOut;
using WCS.Model.ApiModel.PDAShelfLocationBindUnbind;
using WCS.Model.ApiModel.Stocktaking;
using WCS.Model.ApiModel.StoreInfo;
namespace WCS.WebApi.Controllers
{
///
/// PDA产线呼叫功能
///
[ApiController]
[Route("[controller]")]
public class PDAProductionLineCallOutController : ControllerBase
{
public PDAProductionLineCallOutController(IStockTakingService stockTakingService)
{
}
///
/// 获取当前货架、当前货架的工位、当前工位可以作为起点可以到的目标区域
///
///
///
[Route("getShelfInfoForCallOut")]
[HttpPost(Name = "getShelfInfoForCallOut")]
public async Task getShelfInfoForCallOut(GetShelfInfoForCallOutRequest request)
{
try
{
//校验参数
if (string.IsNullOrEmpty(request.ShelfCode))
{
return new ResponseCommon()
{
Code = 201,
Message = "参数错误,请重新扫描货架码!",
Data = null,
};
}
//通过货架编码获取货架
var shelfInfo = await DbHelp.db.Queryable()
.Where(t => t.ShelfCode == request.ShelfCode)
.Where(t => t.IsEnable)
.FirstAsync();
if (shelfInfo == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"货架{request.ShelfCode}不存在或已被禁用!",
Data = null,
};
}
//货架不处于静止状态
if (shelfInfo.TransStatus == TransStatusEnum.运输中)
{
return new ResponseCommon()
{
Code = 201,
Message = $"货架{request.ShelfCode}处于运输中!",
Data = null,
};
}
//货架未绑定位置信息
if (string.IsNullOrEmpty(shelfInfo.CurrentLocaiotnCode) || shelfInfo.CurrentLocationId == 0)
{
return new ResponseCommon()
{
Code = 201,
Message = $"货架{request.ShelfCode}未绑定位置信息!",
Data = null,
};
}
//位置校验
var locationInfo = await DbHelp.db.Queryable()
.Where(t => t.Id == shelfInfo.CurrentLocationId)
.Where(t => t.IsEnable)
.FirstAsync();
if (locationInfo == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"工位{shelfInfo.CurrentLocaiotnCode}不存在或已被禁用!",
Data = null,
};
}
//获取工位作为起点 可以放置的目标区域
var locationAreas = await DbHelp.db.Queryable()
.WhereIF(locationInfo.AllowDestinationLocationArea != null && locationInfo.AllowDestinationLocationArea.Count > 0, t => locationInfo.AllowDestinationLocationArea.Contains(t.Id))
.Select(t => new LocationAreaInfoModel()
{
Id = t.Id,
LocationAreaName = t.LocationAreaName,
})
.ToListAsync();
return new ResponseCommon()
{
Code = 200,
Message = "success",
Data = new GetShelfInfoForCallOutResponseData()
{
ShelfId = shelfInfo.Id,
ShelfCode = shelfInfo.ShelfCode,
LocationId = locationInfo.Id,
LocationCode = locationInfo.LocationCode,
LocationAreas = locationAreas
}
};
}
catch (Exception ex)
{
return new ResponseCommon()
{
Code = 201,
Message = ex.Message,
Data = null,
};
}
}
///
/// 货架送回修改数量
///
///
///
[Route("updateMatDetailCurrentInfoForCallOut")]
[HttpPost(Name = "updateMatDetailCurrentInfoForCallOut")]
public async Task> updateMatDetailCurrentInfoForCallOut(UpdateMatDetailCurrentInForCallOutRequest request)
{
try
{
var matDetailCurrentInfo = await DbHelp.db.Queryable() //.Where(t => t.MatDetailCurrentCode == request.MatDetailCurrentInfo.MatDetailCurrentCode)
.Where(t => t.Id == request.MatDetailCurrentInfoId)
.FirstAsync();
if (matDetailCurrentInfo == null)
{
return new ResponseCommon