using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using SqlSugar;
|
using WIDESEA_Common.StockEnum;
|
using WIDESEA_Core;
|
using WIDESEA_DTO.CalcOut;
|
using WIDESEA_Model.Models;
|
|
namespace WIDESEA_OutboundService
|
{
|
public partial class OutboundService
|
{
|
|
public WebResponseContent QueryPickingTasks(string palletCode, string orderNo)
|
{
|
try
|
{
|
Dt_StockInfo stockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
|
bool isMatMixed = false;
|
if (stockInfo != null)
|
{
|
isMatMixed = stockInfo.Details.GroupBy(x => new
|
{
|
x.MaterielCode,
|
x.MaterielName,
|
x.BatchNo,
|
x.SupplyCode,
|
x.WarehouseCode
|
}).Count() > 1;
|
}
|
|
|
List<Dt_OutStockLockInfo> outStockLockInfos = _outboundLockInfoRepository.QueryData(x => x.PalletCode == palletCode && x.OrderNo == orderNo);
|
return WebResponseContent.Instance.OK(data: new { outStockLockInfos, stockInfo, isMatMixed });
|
}
|
catch (Exception ex)
|
{
|
return WebResponseContent.Instance.Error(ex.Message);
|
}
|
}
|
|
/// <summary>
|
/// 查询已拣选列表(通过库存变动记录)
|
/// </summary>
|
/// <param name="request">查询请求</param>
|
/// <returns>已拣选列表</returns>
|
public WebResponseContent QueryPickedList(string orderNo, string palletCode)
|
{
|
WebResponseContent content = WebResponseContent.Instance;
|
|
try
|
{
|
// 构建查询条件
|
var query = _stockChangeRepository.Db
|
.Queryable<Dt_StockQuantityChangeRecord>()
|
.LeftJoin<Dt_OutboundOrder>((r, o) => r.OrderNo == o.OrderNo)
|
.Where((r, o) => r.ChangeType == (int)StockChangeTypeEnum.Outbound)
|
.Where((r, o) => r.OrderNo == orderNo)
|
.Where((r, o) => r.PalleCode == palletCode)
|
.OrderBy((r, o) => r.CreateDate, OrderByType.Desc)
|
.Select((r, o) => new PickedListItemDTO
|
{
|
Id = r.Id,
|
OrderNo = r.OrderNo,
|
TaskNum = r.TaskNum,
|
PalletCode = r.PalleCode,
|
MaterielCode = r.MaterielCode,
|
MaterielName = r.MaterielName,
|
BatchNo = r.BatchNo,
|
OriginalBarcode = r.OriginalSerilNumber,
|
NewBarcode = r.NewSerilNumber,
|
ChangeQuantity = r.ChangeQuantity,
|
BeforeQuantity = r.BeforeQuantity,
|
AfterQuantity = r.AfterQuantity,
|
SupplyCode = r.SupplyCode,
|
WarehouseCode = r.WarehouseCode,
|
Remark = r.Remark,
|
CreateDate = r.CreateDate,
|
OrderStatus = o.OrderStatus,
|
FactoryArea = o.FactoryArea
|
});
|
|
var result = query.ToList();
|
|
return WebResponseContent.Instance.OK(data: result);
|
}
|
catch (Exception ex)
|
{
|
return WebResponseContent.Instance.Error($"查询已拣选列表失败:{ex.Message}");
|
}
|
}
|
}
|
}
|