| | |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.Inbound; |
| | | using static WIDESEA_Common.HouseInventoryIn; |
| | | using static WIDESEA_Common.HouseSyncretism; |
| | | using static WIDESEA_Common.InventoryAllocate; |
| | | using Parameter = WIDESEA_Common.Parameter; |
| | | |
| | | namespace WIDESEA_InboundService |
| | | { |
| | |
| | | private readonly IStockRepository _stockRepository; |
| | | private IPalletTypeInfoRepository _palletTypeInfoRepository; |
| | | private readonly IReturnOrderRepository _returnOrderRepository; |
| | | private readonly ICPInboundOrderDetailRepository _cPInboundOrderDetailRepository; |
| | | |
| | | |
| | | public IInboundOrderRepository Repository => BaseDal; |
| | | |
| | | public InboundOrderService(IInboundOrderRepository BaseDal, IMapper mapper, IBasicService basicService, IBasicRepository basicRepository, IInboundRepository inboundRepository, IUnitOfWorkManage unitOfWorkManage, ITaskRepository taskRepository, IStockService stockService, IInboundOrderDetailService inboundOrderDetailService, IInboundOrder_HtyService inboundOrderHtyService, IInboundOrderDetail_HtyService inboundOrderDetail_HtyService, IWarehouseService warehouseService, IStockRepository stockRepository, IPalletTypeInfoRepository palletTypeInfoRepository, IReturnOrderRepository returnOrderRepository) : base(BaseDal) |
| | | public InboundOrderService(IInboundOrderRepository BaseDal, IMapper mapper, IBasicService basicService, IBasicRepository basicRepository, IInboundRepository inboundRepository, IUnitOfWorkManage unitOfWorkManage, ITaskRepository taskRepository, IStockService stockService, IInboundOrderDetailService inboundOrderDetailService, IInboundOrder_HtyService inboundOrderHtyService, IInboundOrderDetail_HtyService inboundOrderDetail_HtyService, IWarehouseService warehouseService, IStockRepository stockRepository, IPalletTypeInfoRepository palletTypeInfoRepository, IReturnOrderRepository returnOrderRepository, ICPInboundOrderDetailRepository cPInboundOrderDetailRepository) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _stockRepository = stockRepository; |
| | | _palletTypeInfoRepository = palletTypeInfoRepository; |
| | | _returnOrderRepository = returnOrderRepository; |
| | | _cPInboundOrderDetailRepository = cPInboundOrderDetailRepository; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到该物料的信息"); |
| | | } |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>(); |
| | | ///找数量匹配的 |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode && x.SupplierBatch == (models.FirstOrDefault()?.LotNo ?? "") && x.OrderQuantity > x.ReceiptQuantity && x.OrderQuantity == (quantitys.FirstOrDefault())).ToList(); |
| | | if (warehouse.WarehouseCode.Contains("BC")) |
| | | { |
| | | inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode && x.SupplierBatch == (models.FirstOrDefault()?.LotNo ?? "") && x.OrderQuantity > x.ReceiptQuantity && x.OrderQuantity == (quantitys.FirstOrDefault())).ToList(); |
| | | } |
| | | else |
| | | { |
| | | inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode && x.BatchNo == (models.FirstOrDefault()?.LotNo ?? "")).ToList(); |
| | | } |
| | | |
| | | |
| | | if (inboundOrderDetails == null || inboundOrderDetails.Count <= 0) |
| | | { |
| | |
| | | List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>(); |
| | | foreach (var model in models) |
| | | { |
| | | Dt_InboundOrderDetail? notGroupDetail = inboundOrderDetails.Where(x => x.OrderDetailStatus <= OrderDetailStatusEnum.Inbounding.ObjToInt() && x.MaterielCode == model.MaterielCode && x.SupplierBatch == model.LotNo && x.OrderQuantity > x.ReceiptQuantity).FirstOrDefault(); |
| | | |
| | | Dt_InboundOrderDetail notGroupDetail = new Dt_InboundOrderDetail(); |
| | | ///找数量匹配的 |
| | | if (warehouse.WarehouseCode.Contains("BC")) |
| | | { |
| | | notGroupDetail = inboundOrderDetails.Where(x => x.OrderDetailStatus <= OrderDetailStatusEnum.Inbounding.ObjToInt() && x.MaterielCode == model.MaterielCode && x.SupplierBatch == model.LotNo && x.OrderQuantity > x.ReceiptQuantity).FirstOrDefault(); |
| | | } |
| | | else |
| | | { |
| | | notGroupDetail = inboundOrderDetails.Where(x => x.OrderDetailStatus <= OrderDetailStatusEnum.Inbounding.ObjToInt() && x.MaterielCode == model.MaterielCode && x.BatchNo == model.LotNo && x.OrderQuantity > x.ReceiptQuantity).FirstOrDefault(); |
| | | } |
| | | |
| | | |
| | | if (notGroupDetail == null) |
| | | { |
| | |
| | | Id = inboundOrderDet.LinId.ObjToInt(), |
| | | DeliveryNote = model.DeliveryNote, |
| | | SupplierBatch = inboundOrderDet.SupplierBatch, |
| | | MaterieSpec = inboundOrderDet.MaterieSpec |
| | | MaterieSpec = inboundOrderDet.MaterieSpec, |
| | | OrinalLocation = inboundOrderDet.OrinalLocation |
| | | }; |
| | | |
| | | if (stockInfo.Id > 0) |
| | |
| | | var orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | var palletCode = saveModel.MainData["palletCode"].ToString(); |
| | | var warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); |
| | | var Initiallife = saveModel.MainData["initiallife"].ObjToInt(); |
| | | // 首先验证输入数据 |
| | | var serialNumbers = new List<string>(); |
| | | var quantities = new List<decimal>(); |
| | | var lotNos = new List<string>(); |
| | | var materielCodes = new List<string>(); |
| | | |
| | | foreach (var item in saveModel.DelKeys) |
| | | { |
| | | // 直接使用动态类型访问属性,避免多余的序列化/反序列化 |
| | | var delKeyDict = item as IDictionary<string, object>; |
| | | if (delKeyDict == null) |
| | | { |
| | |
| | | return WebResponseContent.Instance.Error("serialNumber的值为空"); |
| | | } |
| | | serialNumbers.Add(serialNumber); |
| | | |
| | | // 处理数量 |
| | | if (!delKeyDict.TryGetValue("quantity", out object quantityObj) || quantityObj == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("缺少物料数量字段或值为空"); |
| | | } |
| | | |
| | | if (!decimal.TryParse(quantityObj.ToString(), out decimal quantity)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"物料数量'{quantityObj}'无法转换为数字"); |
| | | } |
| | | |
| | | if (quantity <= 0) |
| | | { |
| | | return WebResponseContent.Instance.Error("物料数量必须大于0"); |
| | | } |
| | | quantities.Add(quantity); |
| | | } |
| | | |
| | | // 验证数量与序列号数量一致 |
| | | if (serialNumbers.Count != quantities.Count) |
| | | { |
| | | return WebResponseContent.Instance.Error("序列号数量与物料数量不匹配"); |
| | | } |
| | | |
| | | // 获取仓库信息 |
| | | Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == warehouseId); |
| | | if (warehouse == null) |
| | |
| | | return WebResponseContent.Instance.Error($"未找到入库单信息"); |
| | | } |
| | | |
| | | // 批量查询所有相关箱号/托盘号的CP入库单明细 |
| | | // 根据您的业务逻辑,这里应该是查询 BoxCode 或者 PalletCode 在 serialNumbers 中的记录 |
| | | // 我假设您需要查询 BoxCode 在 serialNumbers 列表中的所有记录 |
| | | // 批量查询所有相关箱号的CP入库单明细 |
| | | List<Dt_CPInboundOrderDetail> CPinboundOrderDetails = BaseDal.Db.Queryable<Dt_CPInboundOrderDetail>() |
| | | .LeftJoin<Dt_InboundOrderDetail>((cp, d) => cp.OrderDetailId == d.Id) |
| | | .LeftJoin<Dt_InboundOrder>((cp, d, o) => d.OrderId == o.Id) |
| | | .Where((cp, d, o) => |
| | | o.OrderNo == orderNo && |
| | | o.WarehouseId == warehouse.WarehouseId && |
| | | serialNumbers.Contains(cp.BoxCode) // 修改这里:批量查询 |
| | | serialNumbers.Contains(cp.BoxCode) |
| | | ) |
| | | .Select((cp, d, o) => cp) |
| | | .ToList(); |
| | | |
| | | //float totalQty = CPinboundOrderDetails.Sum(x => x.QtyOfpcs); |
| | | |
| | | // 方式2:如果您需要分别处理箱号和托盘号,可以分开查询 |
| | | var boxDetails = CPinboundOrderDetails.Where(x => serialNumbers.Contains(x.BoxCode)).ToList(); |
| | | |
| | | // 验证查询到的数据数量是否匹配 |
| | | if (CPinboundOrderDetails.Count < serialNumbers.Count) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到所有对应的箱号/托盘号信息,找到{CPinboundOrderDetails.Count}条,期望{serialNumbers.Count}条"); |
| | | return WebResponseContent.Instance.Error($"未找到所有对应的箱号信息,找到{CPinboundOrderDetails.Count}条,期望{serialNumbers.Count}条"); |
| | | } |
| | | |
| | | // 按照箱号分组,用于后续处理 |
| | | var cpDetailsByBoxCode = CPinboundOrderDetails |
| | | .GroupBy(x => x.BoxCode) |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | |
| | | |
| | | var existingStockBoxCodes = _stockRepository.StockInfoRepository.Db |
| | | .Queryable<Dt_StockInfo>() |
| | | .LeftJoin<Dt_StockInfoDetail>((s, d) => s.Id == d.StockId) |
| | | .LeftJoin<Dt_StockInfoDetailCP>((s, d, cp) => d.Id == cp.StockDetailId) |
| | | .Where((s, d, cp) => |
| | | serialNumbers.Contains(cp.BoxCode)) |
| | | .Select((s, d, cp) => cp.BoxCode) |
| | | .Distinct() |
| | | .ToList(); |
| | | |
| | | if (existingStockBoxCodes.Any()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"以下箱号已在库存中:{string.Join(",", existingStockBoxCodes)}"); |
| | | } |
| | | |
| | | // 获取所有相关的入库单明细ID |
| | | var orderDetailIds = CPinboundOrderDetails.Select(x => x.OrderDetailId).Distinct().ToList(); |
| | | |
| | | // 查询对应的入库单明细 |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = BaseDal.Db.Queryable<Dt_InboundOrderDetail>() |
| | | .Where(x => orderDetailIds.Contains(x.Id)) |
| | | .ToList(); |
| | | |
| | | if (inboundOrderDetails.Sum(x => x.OrderQuantity) <= inboundOrderDetails.Sum(x => x.ReceiptQuantity)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"此单据已全部组盘完成"); |
| | | } |
| | | |
| | | // 按订单明细ID分组,检查每个明细的所有箱号是否都扫描了 |
| | | var detailsByOrderDetailId = CPinboundOrderDetails |
| | | .GroupBy(x => x.OrderDetailId) |
| | | .ToDictionary(g => g.Key, g => g.ToList()); |
| | | |
| | | // 获取相关的订单明细 |
| | | List<Dt_InboundOrderDetail> orderDetails = new List<Dt_InboundOrderDetail>(); |
| | | List<Dt_InboundOrderDetail> detailsToUpdate = new List<Dt_InboundOrderDetail>(); |
| | | |
| | | // 检查每个订单明细是否完成了所有箱号的扫描 |
| | | foreach (var kvp in detailsByOrderDetailId) |
| | | { |
| | | int orderDetailId = kvp.Key; |
| | | var cpDetails = kvp.Value; |
| | | |
| | | // 获取订单明细 |
| | | var orderDetail = inboundOrder.Details.FirstOrDefault(x => x.Id == orderDetailId); |
| | | if (orderDetail == null) |
| | | { |
| | | orderDetail = BaseDal.Db.Queryable<Dt_InboundOrderDetail>() |
| | | .First(x => x.Id == orderDetailId); |
| | | } |
| | | |
| | | if (orderDetail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到订单明细ID:{orderDetailId}"); |
| | | } |
| | | |
| | | orderDetails.Add(orderDetail); |
| | | |
| | | // 标记该明细为已完成组盘 |
| | | orderDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | var recqty = orderDetail.ReceiptQuantity; |
| | | float totalQty = cpDetails.Sum(item => item.QtyOfpcs); |
| | | orderDetail.ReceiptQuantity = (decimal)totalQty + recqty; // 收货数量等于订单数量 |
| | | |
| | | detailsToUpdate.Add(orderDetail); |
| | | } |
| | | |
| | | |
| | | |
| | | // 检查托盘是否已存在 |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db |
| | | .Queryable<Dt_StockInfo>() |
| | | .Where(x => x.PalletCode == palletCode) |
| | | .Includes(x => x.Details) |
| | | .First(); |
| | | |
| | | if (stockInfo == null) |
| | |
| | | // 创建新托盘 |
| | | stockInfo = new Dt_StockInfo() |
| | | { |
| | | //BatchNo = models.FirstOrDefault()?.LotNo ?? "", |
| | | BatchNo = "", // 使用入库单批次号 |
| | | PalletCode = palletCode, |
| | | PalletType = GetPalletType(warehouse, palletCode), |
| | | IsFull = true, |
| | |
| | | } |
| | | } |
| | | |
| | | // 验证和更新每个物料的组盘数量 |
| | | List<Dt_InboundOrderDetail> detailsToUpdate = new List<Dt_InboundOrderDetail>(); |
| | | List<Dt_CPInboundOrderDetail> cPInboundOrderDetail = new List<Dt_CPInboundOrderDetail>(); |
| | | // 创建库存明细 - 按订单明细创建 |
| | | foreach (var orderDetail in orderDetails) |
| | | { |
| | | // 获取该明细对应的所有箱号 |
| | | var detailBoxCodes = detailsByOrderDetailId[orderDetail.Id] |
| | | .Select(x => x.BoxCode) |
| | | .ToList(); |
| | | |
| | | cPInboundOrderDetail = BaseDal.Db.Queryable<Dt_CPInboundOrderDetail>().Where(x => detailBoxCodes.Contains(x.BoxCode)).ToList(); |
| | | |
| | | List<Dt_StockInfoDetailCP> stockInfoDetailCP = new List<Dt_StockInfoDetailCP>(); |
| | | foreach (var item in cPInboundOrderDetail) |
| | | { |
| | | Dt_StockInfoDetailCP stockInfoDetailCP1 = new Dt_StockInfoDetailCP() |
| | | { |
| | | BoxId = item.BoxId, |
| | | BoxCode = item.BoxCode, |
| | | DateCode = item.DateCode, |
| | | JobId = item.JobId, |
| | | PartNum = item.PartNum, |
| | | QtyOfpcs = item.QtyOfpcs, |
| | | QtyOfxout = item.QtyOfxout, |
| | | CPStockDetailStatus = (int)StockStatusEmun.组盘暂存, |
| | | Creater = "上游WMS", |
| | | }; |
| | | stockInfoDetailCP.Add(stockInfoDetailCP1); |
| | | |
| | | item.CPOrderDetailStatus = InOrderStatusEnum.入库中.ObjToInt(); |
| | | } |
| | | |
| | | // 创建库存明细 |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | MaterielCode = orderDetail.MaterielCode, |
| | | MaterielName = orderDetail.MaterielName, |
| | | OrderNo = inboundOrder.OrderNo, |
| | | BatchNo = orderDetail.BatchNo, |
| | | SupplierBatch = orderDetail.SupplierBatch, |
| | | LinId = orderDetail.LinId, |
| | | StockQuantity = (decimal)cPInboundOrderDetail.Sum(item => item.QtyOfpcs), |
| | | Status = (int)StockStatusEmun.组盘暂存, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | | Id = orderDetail.LinId.ObjToInt(), |
| | | //DeliveryNote = orderDetail.DeliveryNote, |
| | | MaterieSpec = orderDetail.MaterieSpec, |
| | | StockDetails = stockInfoDetailCP, |
| | | OrinalLocation = orderDetail.OrinalLocation |
| | | }; |
| | | |
| | | if (stockInfo.Id > 0) |
| | | { |
| | | stockInfoDetail.StockId = stockInfo.Id; |
| | | } |
| | | stockInfo.Details.Add(stockInfoDetail); |
| | | } |
| | | |
| | | // 检查入库单是否所有明细都已完成组盘 |
| | | bool allDetailsCompleted = inboundOrder.Details.All(x => |
| | | detailsToUpdate.Any(d => d.Id == x.Id) || |
| | | x.OrderDetailStatus == OrderDetailStatusEnum.GroupAndInbound.ObjToInt()); |
| | | |
| | | |
| | | |
| | | // 更新订单状态 |
| | | inboundOrder.OrderStatus = InOrderStatusEnum.入库中.ObjToInt(); |
| | | |
| | | // 事务处理 |
| | | _unitOfWorkManage.BeginTran(); |
| | |
| | | if (stockInfo.Id == 0) |
| | | { |
| | | _stockRepository.StockInfoRepository.Db.InsertNav(stockInfo) |
| | | .Include(x => x.Details) |
| | | .Include(x => x.Details).ThenInclude(x => x.StockDetails) |
| | | .ExecuteCommand(); |
| | | } |
| | | else |
| | |
| | | .Include(x => x.Details, new UpdateNavOptions() |
| | | { |
| | | OneToManyInsertOrUpdate = true |
| | | }) |
| | | }).ThenInclude(x => x.StockDetails) |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | // 更新订单明细 |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(detailsToUpdate); |
| | | if (detailsToUpdate.Count > 0) |
| | | { |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(detailsToUpdate); |
| | | } |
| | | |
| | | // 更新订单 |
| | | _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); |
| | | |
| | | _cPInboundOrderDetailRepository.UpdateData(cPInboundOrderDetail); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | |
| | | content = WebResponseContent.Instance.OK("组盘成功"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw; |
| | | throw new Exception($"组盘事务处理失败:{ex.Message}", ex); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | |
| | | return content; |
| | | } |
| | | public string ReceiveWMSTaskin = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskin"]; |
| | | /// <summary> |
| | | /// 组盘合托 |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent SYMaterielGroup(SaveModel saveModel) |
| | | { |
| | | |
| | | WebResponseContent webResponseContent = new WebResponseContent(); |
| | | try |
| | | { |
| | | var soussAddress = saveModel.MainData["soussAddress"]; |
| | | var targetAddress = saveModel.MainData["targetAddress"]; |
| | | |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == soussAddress).First(); |
| | | Dt_StockInfo targetstockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == targetAddress).First(); |
| | | Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == targetstockInfo.WarehouseId); |
| | | if (stockInfo == null || targetstockInfo == null) |
| | | { |
| | | throw new Exception("库存未找到托盘号"); |
| | | } |
| | | foreach (var item in stockInfo.Details) |
| | | { |
| | | item.StockId = targetstockInfo.Id; |
| | | } |
| | | if (warehouse.WarehouseCode == "SC02_CP") |
| | | { |
| | | warehouse.WarehouseCode = "SC01_CP"; |
| | | } |
| | | if (warehouse.WarehouseCode == "SC02_BC") |
| | | { |
| | | warehouse.WarehouseCode = "SC01_BC"; |
| | | } |
| | | var houseSyncretism = new HouseSyncretism |
| | | { |
| | | ApiType = "InventoryMoveController", |
| | | Method = "AsrsSubmitMoveDatas", |
| | | |
| | | Parameters = new List<HouseSyncretism.Parame> |
| | | { |
| | | new HouseSyncretism.Parame { |
| | | Value = stockInfo.Details.Select(g => new Parame.Syncretism |
| | | { |
| | | Lpn = stockInfo.PalletCode, |
| | | MoveType = 0, |
| | | WareHouseCode = warehouse.WarehouseCode, |
| | | ItemCode = g.MaterielCode, |
| | | MoveNumber = g.StockQuantity, |
| | | LotNo = g.BatchNo, |
| | | WipBatch = g.BatchNo, |
| | | LocationName = stockInfo.LocationCode, |
| | | TargetLocName = targetstockInfo.LocationCode, |
| | | TargetLpn = targetstockInfo.PalletCode, |
| | | |
| | | }).ToList() |
| | | } |
| | | } |
| | | // Parameters = stockInfo.Details.Select(g => new HouseSyncretism.data |
| | | // { |
| | | // Lpn = stockInfo.PalletCode, |
| | | // MoveType = 0, |
| | | // WareHouseCode = warehouse.WarehouseCode, |
| | | // ItemCode = g.MaterielCode, |
| | | // MoveNumber = g.StockQuantity, |
| | | // //LotNo = g., |
| | | // WipBatch = g.BatchNo, |
| | | // LocationName = stockInfo.PalletCode, |
| | | // TargetLocName = targetstockInfo.PalletCode, |
| | | // TargetLpn = targetstockInfo.PalletCode, |
| | | |
| | | // }).ToList() |
| | | //}; |
| | | }; |
| | | var authResult = AuthenticateWithWMS(); |
| | | if (authResult.IsSuccess) |
| | | { |
| | | houseSyncretism.Context = new Dictionary<string, string> |
| | | { |
| | | { "Ticket", authResult.Ticket }, |
| | | { "InvOrgId", authResult.InvOrgId } |
| | | |
| | | }; |
| | | |
| | | var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskin, houseSyncretism, "立库入库数量回传WMS"); |
| | | // 判断Success的值 |
| | | if (!response.Success) |
| | | { |
| | | throw new Exception($"操作失败: {response.Message ?? "未提供错误信息"}"); |
| | | } |
| | | |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | targetstockInfo.Details.AddRange(stockInfo.Details); |
| | | _stockRepository.StockInfoRepository.UpdateData(targetstockInfo); |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); |
| | | _stockRepository.StockInfoRepository.DeleteData(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | webResponseContent = WebResponseContent.Instance.OK("合托成功"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | webResponseContent = WebResponseContent.Instance.Error($"组盘失败:{ex.Message}"); |
| | | } |
| | | return webResponseContent; |
| | | } |
| | | |
| | | private (bool IsSuccess, string Ticket, string InvOrgId) AuthenticateWithWMS() |
| | | { |
| | | var authentication = new Authentication |
| | | { |
| | | ApiType = "AuthenticationController", |
| | | Parameters = new List<Parameter> |
| | | { |
| | | new Parameter { Value = "LK-Admin" }, |
| | | new Parameter { Value = "LK-Admin" } |
| | | }, |
| | | Method = "Login", |
| | | }; |
| | | |
| | | var response = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, authentication, "登录WMS账号"); |
| | | |
| | | if (response.Context != null) |
| | | { |
| | | return (true, response.Context["Ticket"].ToString(), response.Context["InvOrgId"].ToString()); |
| | | } |
| | | |
| | | return (false, null, null); |
| | | } |
| | | |
| | | |
| | | public int GetPalletType(Dt_Warehouse warehouse, string palletCode) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | List<Dt_CPInboundOrderDetail> cPInboundOrderDetail = new List<Dt_CPInboundOrderDetail>(); |
| | | foreach (var list in item.BoxList) |
| | | { |
| | | Dt_CPInboundOrderDetail cPInboundOrderDetail1 = new Dt_CPInboundOrderDetail() |
| | | { |
| | | BoxId = (float)list.BoxId, |
| | | BoxCode = list.BoxCode, |
| | | DateCode = list.DateCode, |
| | | JobId = (float)list.JobId, |
| | | PartNum = list.PartNum, |
| | | QtyOfpcs = (float)list.QtyOfpcs, |
| | | QtyOfxout = (float)list.QtyOfxout, |
| | | CPOrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), |
| | | Creater = "上游WMS", |
| | | }; |
| | | cPInboundOrderDetail.Add(cPInboundOrderDetail1); |
| | | } |
| | | |
| | | Dt_InboundOrderDetail orderDetail = new Dt_InboundOrderDetail() |
| | | { |
| | | OrderId = orderDetail1.OrderId, |
| | |
| | | OverInQuantity = 0, |
| | | OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), |
| | | LinId = item.LinId, |
| | | LPNNo = item.LPN_No, |
| | | MaterielName = item.MaterielName, |
| | | MaterieSpec = item.MaterieSpec, |
| | | Creater = "上游WMS", |
| | | SupplierBatch = item.SupplierBatch |
| | | }; |
| | | _inboundRepository.InboundOrderDetailRepository.AddData(orderDetail); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | foreach (var list in item.BoxList) |
| | | { |
| | | Dt_CPInboundOrderDetail cPInboundOrderDetail = new Dt_CPInboundOrderDetail() |
| | | { |
| | | BoxId = list.BoxId, |
| | | BoxCode = list.BoxCode, |
| | | DateCode = list.DateCode, |
| | | JobId = list.JobId, |
| | | PartNum = list.PartNum, |
| | | QtyOfpcs = list.QtyOfpcs, |
| | | QtyOfxout = list.QtyOfxout, |
| | | Creater = "上游WMS", |
| | | }; |
| | | |
| | | Dt_InboundOrderDetail orderDetail = new Dt_InboundOrderDetail() |
| | | { |
| | | MaterielCode = item.MaterielCode, |
| | | BatchNo = item.BatchNo, |
| | | OrderQuantity = item.OrderQuantity, |
| | | ReceiptQuantity = 0, |
| | | OverInQuantity = 0, |
| | | OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), |
| | | LinId = item.LinId, |
| | | LPNNo = item.LPN_No, |
| | | LPNNo = item.LPNNo, |
| | | MaterielName = item.MaterielName, |
| | | MaterieSpec = item.MaterieSpec, |
| | | Creater = "上游WMS", |
| | | SupplierBatch = item.SupplierBatch, |
| | | CPDetails = new List<Dt_CPInboundOrderDetail> { cPInboundOrderDetail } |
| | | OrinalLocation = item.OrinalLocation, |
| | | CPDetails = cPInboundOrderDetail |
| | | }; |
| | | |
| | | Dt_InboundOrder inboundOrder = new Dt_InboundOrder() |
| | | { |
| | | OrderNo = model.AsnNo, |
| | | UpperOrderNo = model.AsnNo, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | //SupplierId = "", |
| | | OrderStatus = InboundStatusEnum.未开始.ObjToInt(), |
| | | CreateType = CreateType.UpperSystemPush.ObjToInt(), |
| | | Remark = "", |
| | | TransactionCode = model.TransactionCode, |
| | | InoutType = model.OrderType, |
| | | OrderType = model.InoutType.ObjToInt(), |
| | | Creater = "上游WMS", |
| | | System = model.System, |
| | | Details = new List<Dt_InboundOrderDetail> { orderDetail } |
| | | }; |
| | | //switch (model.OrderType)//单据类型 |
| | | //{ |
| | | // case 1: |
| | | // inboundOrder.OrderType = InOrderTypeEnum.Allocat.ObjToInt(); |
| | | // break; |
| | | // case 3: |
| | | // inboundOrder.OrderType = InOrderTypeEnum.CustomerRecovery.ObjToInt(); |
| | | // break; |
| | | // case 6: |
| | | // inboundOrder.OrderType = InOrderTypeEnum.SaleReturn.ObjToInt(); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | //}; |
| | | Db.InsertNav(inboundOrder).Include(x => x.Details).ThenInclude(x => x.CPDetails).ExecuteCommand(); |
| | | //_inboundRepository.InboundOrderDetailRepository.AddData(orderDetail); |
| | | Db.InsertNav(orderDetail).Include(x => x.CPDetails).ExecuteCommand(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | List<Dt_CPInboundOrderDetail> cPInboundOrderDetail = new List<Dt_CPInboundOrderDetail>(); |
| | | foreach (var list in item.BoxList) |
| | | { |
| | | Dt_CPInboundOrderDetail cPInboundOrderDetail1 = new Dt_CPInboundOrderDetail() |
| | | { |
| | | BoxId = (float)list.BoxId, |
| | | BoxCode = list.BoxCode, |
| | | DateCode = list.DateCode, |
| | | JobId = (float)list.JobId, |
| | | PartNum = list.PartNum, |
| | | QtyOfpcs = (float)list.QtyOfpcs, |
| | | QtyOfxout = (float)list.QtyOfxout, |
| | | CPOrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), |
| | | Creater = "上游WMS", |
| | | }; |
| | | cPInboundOrderDetail.Add(cPInboundOrderDetail1); |
| | | } |
| | | |
| | | Dt_InboundOrderDetail orderDetail = new Dt_InboundOrderDetail() |
| | | { |
| | | MaterielCode = item.MaterielCode, |
| | | BatchNo = item.BatchNo, |
| | | OrderQuantity = item.OrderQuantity, |
| | | ReceiptQuantity = 0, |
| | | OverInQuantity = 0, |
| | | OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), |
| | | LinId = item.LinId, |
| | | LPNNo = item.LPNNo, |
| | | MaterielName = item.MaterielName, |
| | | MaterieSpec = item.MaterieSpec, |
| | | Creater = "上游WMS", |
| | | SupplierBatch = item.SupplierBatch, |
| | | OrinalLocation = item.OrinalLocation, |
| | | CPDetails = cPInboundOrderDetail |
| | | }; |
| | | |
| | | Dt_InboundOrder inboundOrder = new Dt_InboundOrder() |
| | | { |
| | | OrderNo = model.AsnNo, |
| | | UpperOrderNo = model.AsnNo, |
| | | WarehouseId = warehouse.WarehouseId, |
| | | //SupplierId = "", |
| | | OrderStatus = InboundStatusEnum.未开始.ObjToInt(), |
| | | CreateType = CreateType.UpperSystemPush.ObjToInt(), |
| | | Remark = "", |
| | | TransactionCode = model.TransactionCode, |
| | | InoutType = model.OrderType, |
| | | OrderType = model.InoutType.ObjToInt(), |
| | | Creater = "上游WMS", |
| | | System = model.System, |
| | | Details = new List<Dt_InboundOrderDetail> { orderDetail } |
| | | }; |
| | | //switch (model.OrderType)//单据类型 |
| | | //{ |
| | | // case 1: |
| | | // inboundOrder.OrderType = InOrderTypeEnum.Allocat.ObjToInt(); |
| | | // break; |
| | | // case 3: |
| | | // inboundOrder.OrderType = InOrderTypeEnum.CustomerRecovery.ObjToInt(); |
| | | // break; |
| | | // case 6: |
| | | // inboundOrder.OrderType = InOrderTypeEnum.SaleReturn.ObjToInt(); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | //}; |
| | | |
| | | |
| | | Db.InsertNav(inboundOrder).Include(x => x.Details).ThenInclude(x => x.CPDetails).ExecuteCommand(); |
| | | } |
| | | } |
| | | else |
| | |
| | | OverInQuantity = 0, |
| | | OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), |
| | | LinId = item.LinId, |
| | | LPNNo = item.LPN_No, |
| | | LPNNo = item.LPNNo, |
| | | MaterielName = item.MaterielName, |
| | | MaterieSpec = item.MaterieSpec, |
| | | Creater = "上游WMS", |
| | |
| | | OverInQuantity = 0, |
| | | OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(), |
| | | LinId = item.LinId, |
| | | LPNNo = item.LPN_No, |
| | | LPNNo = item.LPNNo, |
| | | MaterielName = item.MaterielName, |
| | | MaterieSpec = item.MaterieSpec, |
| | | Creater = "上游WMS", |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// erp单据下发 |
| | | /// </summary> |
| | | /// <param name="addInboundOrder"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent Save(AddInboundOrderModel addInboundOrder) |
| | | { |
| | | try |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | //反拣回库单 |
| | | public WebResponseContent ReceiveReturnOrder(List<HouseReturnOrder> houseReturnOrder) |
| | | { |
| | | try |