| | |
| | | using MailKit.Search; |
| | | using Microsoft.AspNetCore.SignalR; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Database; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using Org.BouncyCastle.Asn1.Tsp; |
| | | using SqlSugar; |
| | |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_BasicRepository; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_Core.TaskEnum; |
| | | using WIDESEA_DTO.Basic; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundRepository; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IOutboundRepository; |
| | | using WIDESEA_IOutboundService; |
| | |
| | | using WIDESEA_ITaskInfoRepository; |
| | | using WIDESEA_ITaskInfoService; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.Inbound; |
| | | using WIDESEA_StockRepository; |
| | | using WIDESEA_TaskInfoRepository; |
| | | using static WIDESEA_Common.Authentication; |
| | | using static WIDESEA_Common.HouseBackboundPassBack; |
| | | using static WIDESEA_Common.HouseInboundPassBack; |
| | | using static WIDESEA_Common.HouseoutboundPassBack; |
| | | using static WIDESEA_Common.InventoryAllocate; |
| | | using static WIDESEA_ITaskInfoService.ITaskService; |
| | | using Parameter = WIDESEA_Common.Parameter; |
| | | using WIDESEA_DTO.ERP; |
| | | using WIDESEA_OutboundRepository; |
| | | using System.ComponentModel.DataAnnotations; |
| | | using System; |
| | | using System.IO; |
| | | using System.Net.Http; |
| | | using System.Threading.Tasks; |
| | | using Spire.Pdf; |
| | | using WIDESEA_InboundRepository; |
| | | using System.Drawing.Printing; |
| | | using System; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IStockRepository _stockRepository; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IBasicRepository _basicRepository; |
| | | private readonly IOutboundService _outboundService; |
| | | private readonly IInboundService _inboundService; |
| | | private readonly IInboundOrderDetailService _inboundOrderDetailService; |
| | |
| | | private readonly IOutboundOrderDetail_HtyService _outboundOrderDetail_HtyService; |
| | | private readonly IPalletTypeInfoRepository _palletTypeInfoRepository; |
| | | private readonly IOutboundOrderDetailRepository _outboundOrderDetailRepository; |
| | | private readonly IStockInfoDetailRepository _stockInfoDetailRepository; |
| | | private readonly IReturnOrderRepository _returnOrderRepository; |
| | | private readonly IProductionRepository _productionRepository; |
| | | private readonly IInboundRepository _inboundRepository; |
| | | public ITaskRepository Repository => BaseDal; |
| | | |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IMaterielInfoService materielInfoService, IInboundOrderDetail_HtyService inboundOrderDetail_HtyService, IOutboundOrder_HtyService outboundOrder_HtyService, IOutboundOrderDetail_HtyService outboundOrderDetail_HtyService, IInboundOrder_HtyService inboundOrder_HtyService, IStockRepository stockRepository, IInboundOrderDetailService inboundOrderDetailService, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService, IOutboundOrderDetailRepository outboundOrderDetailRepository) : base(BaseDal) |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IMaterielInfoService materielInfoService, IInboundOrderDetail_HtyService inboundOrderDetail_HtyService, IOutboundOrder_HtyService outboundOrder_HtyService, IOutboundOrderDetail_HtyService outboundOrderDetail_HtyService, IInboundOrder_HtyService inboundOrder_HtyService, IStockRepository stockRepository, IInboundOrderDetailService inboundOrderDetailService, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IBasicRepository basicRepository, IStockInfoDetailRepository stockInfoDetailRepository, IPalletTypeInfoRepository palletTypeInfoRepository, IReturnOrderRepository returnOrderRepository, IProductionRepository productionRepository,IInboundRepository inboundRepository) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _stockRepository = stockRepository; |
| | |
| | | _outboundOrder_HtyService = outboundOrder_HtyService; |
| | | _outboundOrderDetail_HtyService = outboundOrderDetail_HtyService; |
| | | _outboundOrderDetailRepository = outboundOrderDetailRepository; |
| | | _basicRepository = basicRepository; |
| | | _stockInfoDetailRepository = stockInfoDetailRepository; |
| | | _palletTypeInfoRepository = palletTypeInfoRepository; |
| | | _returnOrderRepository = returnOrderRepository; |
| | | _productionRepository = productionRepository; |
| | | _inboundRepository = inboundRepository; |
| | | } |
| | | |
| | | public string ReceiveWMSTaskin = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskin"]; |
| | | public string ReceiveWMSTaskreturn = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskreturn"]; |
| | | public string ReceiveWMSTaskout = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskout"]; |
| | | public string ReceiveWMSTaskAUT = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskAUT"]; |
| | | public string ReceiveWMSTaskAllocatein = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskAllocatein"]; |
| | | |
| | | public string ReceiveERPTaskout = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveERPTaskout"]; |
| | | public string InMaterialWarehousingCallback = WIDESEA_Core.Helper.AppSettings.Configuration["InMaterialWarehousingCallback"]; |
| | | |
| | | /// <summary> |
| | | /// 任务信息推送至WCS |
| | |
| | | return WebResponseContent.Instance.Error($"未找到WCSApi地址,请检查配置文件"); |
| | | } |
| | | string response = HttpHelper.Post($"{url}/api/Task/ReceiveTask", taskDTOs.Serialize()); |
| | | |
| | | return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("返回错误"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent FeedBackWCSTaskCompleted(int taskNum) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到该任务信息"); |
| | | } |
| | | string url = AppSettings.app("WCS"); |
| | | if (string.IsNullOrEmpty(url)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到WCSApi地址,请检查配置文件"); |
| | | } |
| | | string response = HttpHelper.Get($"{url}/api/Task/RecWMSTaskCompleted?taskNum=" + taskNum); |
| | | |
| | | return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("返回错误"); |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="taskNum">任务号</param> |
| | | /// <returns>返回处理结果</returns> |
| | | public WebResponseContent TaskCompleted(int taskNum) |
| | | public async Task<WebResponseContent> TaskCompleted(int taskNum) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | Dt_Task task = await Repository.QueryFirstAsync(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到任务信息"); |
| | | return await Task.FromResult(WebResponseContent.Instance.Error($"未找到任务信息")); |
| | | } |
| | | MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted"); |
| | | if (methodInfo != null) |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) |
| | | { |
| | | WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); |
| | | if (responseContent != null) |
| | | { |
| | | return responseContent; |
| | | } |
| | | return await Task.FromResult(InboundTaskCompleted(taskNum)); |
| | | } |
| | | return WebResponseContent.Instance.Error("未找到任务类型对应业务处理逻辑"); |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | return await Task.FromResult(OutboundTaskCompleted(taskNum)); |
| | | } |
| | | //else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) |
| | | //{ |
| | | // return await Task.FromResult(RelocationTaskCompleted(task)); |
| | | //} |
| | | else |
| | | { |
| | | return await Task.FromResult(WebResponseContent.Instance.Error($"未找到该类型任务,任务类型:{task.TaskType}")); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message)); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 修改任务状态 |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent UpdateTaskInfo(WCSTaskDTO task) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task wmsTask = BaseDal.QueryFirst(x => x.TaskNum == task.TaskNum); |
| | | if (wmsTask != null) |
| | | { |
| | | wmsTask.TaskStatus = task.TaskState; |
| | | wmsTask.CurrentAddress = task.CurrentAddress; |
| | | wmsTask.NextAddress = task.NextAddress; |
| | | wmsTask.Dispatchertime = task.Dispatchertime; |
| | | BaseDal.UpdateData(wmsTask); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public WebResponseContent UpdateTaskStatus(int taskNum, int tasktype) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | |
| | | Dt_StockInfoDetail stockInfoDetail = stockInfo.Details.FirstOrDefault(x => x.StockId == stockInfo.Id); |
| | | |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.Repository.LocationCodesGetStockInfos(new List<string> { stockInfo.LocationCode }).Where(x => x.StockStatus == (int)StockStatusEmun.已入库.ObjToInt()).ToList(); |
| | | if (task.TaskType == TaskTypeEnum.PalletInbound.ObjToInt()) |
| | | if (task.TaskType == TaskTypeEnum.Inbound.ObjToInt()) |
| | | { |
| | | stockInfo.SerialNumber = stockInfos.Count + 1; |
| | | stockInfo.InDate = DateTime.Now; |
| | |
| | | _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail); |
| | | //_recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); |
| | | Db.Ado.CommitTran(); |
| | | SendInboundInfoToWMS(task, inboundOrder, stockInfoDetail); |
| | | SendInboundInfoToWMS(task, inboundOrder, stockInfo); |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到该任务"); |
| | | } |
| | | if (task.TaskType != TaskTypeEnum.Inbound.ObjToInt()) |
| | | if (task.TaskType.GetTaskTypeGroup() != TaskTypeGroup.InboundGroup) |
| | | { |
| | | return WebResponseContent.Instance.Error($"任务类型错误"); |
| | | } |
| | |
| | | Dt_InboundOrderDetail? inboundOrderDetail = null; |
| | | |
| | | // 3. 处理入库逻辑 |
| | | return ProcessInbound(task, dt_StockInfo, dt_LocationInfo); |
| | | if (task.TaskType == TaskTypeEnum.Inbound.ObjToInt()) |
| | | { |
| | | return ProcessInbound(task, dt_StockInfo, dt_LocationInfo); |
| | | } |
| | | if (task.TaskType == TaskTypeEnum.SurplusReturn.ObjToInt() || task.TaskType == TaskTypeEnum.ReverseIn.ObjToInt()) |
| | | { |
| | | return ReturnInbound(task, dt_StockInfo, dt_LocationInfo); |
| | | } |
| | | if(task.TaskType == TaskTypeEnum.InInventory.ObjToInt()) |
| | | { |
| | | int lastStatus = dt_LocationInfo.LocationStatus; |
| | | dt_LocationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | dt_StockInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt(); |
| | | // 更新库存明细状态 |
| | | dt_StockInfo.Details.ForEach(x => x.Status = StockStatusEmun.入库完成.ObjToInt()); |
| | | _unitOfWorkManage.BeginTran(); |
| | | UpdateTaskStatus(task); |
| | | UpdateLocationStatus(dt_LocationInfo, lastStatus); |
| | | UpdateStockInfo(dt_StockInfo); |
| | | AddRecords(task, dt_StockInfo, dt_LocationInfo, lastStatus); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | .Includes(x => x.Details) |
| | | .First(); |
| | | |
| | | if (inboundOrder == null) return WebResponseContent.Instance.Error("未找到入库单信息"); |
| | | |
| | | if (task.TaskType == TaskTypeEnum.Inbound.ObjToInt() && inboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到入库单信息"); |
| | | } |
| | | Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details |
| | | .FirstOrDefault(x => x.LinId == stockInfo.Details.FirstOrDefault()?.LinId); |
| | | .FirstOrDefault(x => x.LinId == stockInfo.Details.FirstOrDefault()?.LinId); |
| | | //if (inboundOrder != null && stockInfo.StockStatus == StockStatusEmun.入库确认.ObjToInt()) |
| | | //{ |
| | | //入库数量回传 |
| | | return ProcessNormalInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); |
| | | //} |
| | | //else |
| | | //{ |
| | | // //调拨出入库任务数量回传 |
| | | // return ProcessAllocateInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); |
| | | //} |
| | | } |
| | | private WebResponseContent ReturnInbound(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo) |
| | | { |
| | | int lastStatus = locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | |
| | | if (inboundOrder.OrderType == 0 && inboundOrder != null && stockInfo.StockStatus == StockStatusEmun.入库确认.ObjToInt()) |
| | | Dt_ReturnOrder returnOrder = _returnOrderRepository.QueryFirst(x => x.OrderNo == stockInfo.Details.FirstOrDefault().OrderNo); |
| | | if (returnOrder == null) |
| | | { |
| | | //入库数量回传 |
| | | return ProcessNormalInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); |
| | | return WebResponseContent.Instance.Error("未找到回库单信息"); |
| | | } |
| | | else |
| | | { |
| | | //调拨出入库任务数量回传 |
| | | return ProcessAllocateInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); |
| | | } |
| | | //if (inboundOrder != null && stockInfo.StockStatus == StockStatusEmun.入库确认.ObjToInt()) |
| | | //{ |
| | | //入库数量回传 |
| | | return SurplusReturnInbound(task, stockInfo, locationInfo, lastStatus, returnOrder); |
| | | //} |
| | | //else |
| | | //{ |
| | | // //调拨出入库任务数量回传 |
| | | // return ProcessAllocateInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); |
| | | //} |
| | | } |
| | | |
| | | |
| | | //其他入库 |
| | | private WebResponseContent ProcessNormalInbound(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, |
| | | int lastStatus, Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) |
| | | { |
| | | // 更新入库单明细状态 |
| | | UpdateInboundOrderDetails(stockInfo, inboundOrder, ref inboundOrderDetail); |
| | | |
| | | ///更新库存状态 |
| | | stockInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt(); |
| | | // 更新库存明细状态 |
| | | stockInfo.Details.ForEach(x => x.Status = StockStatusEmun.入库完成.ObjToInt()); |
| | | |
| | |
| | | // 更新入库单 |
| | | UpdateInboundOrder(inboundOrder, inboundOrderDetail); |
| | | |
| | | // 如果是最后一条明细,处理WMS回传 |
| | | if (inboundOrder.Details.Count == 1) |
| | | // 单据数量全部上架完成,处理WMS回传 |
| | | if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt() && inboundOrder.System.Equals("ERP")) |
| | | { |
| | | var stockInfoDetail = stockInfo.Details.FirstOrDefault(); |
| | | SendInboundInfoToWMS(task, inboundOrder, stockInfoDetail); |
| | | FeedBackInboundERP(inboundOrder.UpperOrderNo, inboundOrderDetail.LinId); |
| | | } |
| | | if (inboundOrder.OrderStatus == InboundStatusEnum.入库完成.ObjToInt() && inboundOrder.OrderType == 0 && inboundOrder.System.Equals("SMOM")) |
| | | { |
| | | SendInboundInfoToWMS(task, inboundOrder, stockInfo); |
| | | } |
| | | else if (inboundOrder.OrderStatus == InboundStatusEnum.入库完成.ObjToInt() && inboundOrder.OrderType == 2 && inboundOrder.System.Equals("SMOM")) |
| | | { |
| | | SendAllocateInfoToWMS(task, inboundOrder, stockInfo); |
| | | } |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | private WebResponseContent ProcessAllocateInbound(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, |
| | | int lastStatus, Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) |
| | | //回库逻辑处理并上报WMS |
| | | private WebResponseContent SurplusReturnInbound(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, |
| | | int lastStatus, Dt_ReturnOrder returnOrder) |
| | | { |
| | | // 如果是最后一条明细 |
| | | if (inboundOrder.Details.Count == 1) |
| | | returnOrder.OrderStatus = InOrderStatusEnum.入库完成.ObjToInt(); |
| | | |
| | | if (task.TaskType == TaskTypeEnum.ReverseIn.ObjToInt()) |
| | | { |
| | | try |
| | | foreach (var item in stockInfo.Details) |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | // 处理调拨入库单 |
| | | //ProcessAllocateInboundOrder(inboundOrder, inboundOrderDetail); |
| | | |
| | | // 获取相关库存信息 |
| | | var relatedStockInfo = _stockService.StockInfoService.Repository |
| | | .QueryData(x => x.BatchNo == inboundOrderDetail.BatchNo); |
| | | |
| | | // 发送调拨信息到WMS |
| | | SendAllocateInfoToWMS(task, inboundOrder, relatedStockInfo); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | catch |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw; |
| | | item.StockQuantity = returnOrder.OrderQuantity; |
| | | returnOrder.OverInQuantity = returnOrder.OrderQuantity; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | foreach (var item in stockInfo.Details) |
| | | { |
| | | returnOrder.OverInQuantity += item.StockQuantity; |
| | | } |
| | | } |
| | | ///更新库存状态 |
| | | stockInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt(); |
| | | // 更新库存明细状态 |
| | | stockInfo.Details.ForEach(x => x.Status = StockStatusEmun.入库完成.ObjToInt()); |
| | | |
| | | // 添加历史记录 |
| | | AddInboundOrderDetailHistory(inboundOrderDetail); |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | // 更新任务状态 |
| | | UpdateTaskStatus(task); |
| | | |
| | | // 更新货位状态 |
| | | UpdateLocationStatus(locationInfo, lastStatus); |
| | | |
| | | // 更新库存信息 |
| | | UpdateStockInfo(stockInfo); |
| | | |
| | | // 添加记录 |
| | | AddRecords(task, stockInfo, locationInfo, lastStatus); |
| | | |
| | | //更新回库单 |
| | | _returnOrderRepository.UpdateData(returnOrder); |
| | | |
| | | if (returnOrder.OrderType == OrderTypeEnum.反拣回库单.ObjToInt() && (returnOrder.LocationCode == null || returnOrder.LocationCode == "")) |
| | | { |
| | | SurplusReturnInboundToWMS(task, returnOrder, stockInfo, locationInfo); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | ////调拨入库 |
| | | //private WebResponseContent ProcessAllocateInbound(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, |
| | | // int lastStatus, Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) |
| | | //{ |
| | | // // 更新入库单明细状态 |
| | | // UpdateInboundOrderDetails(stockInfo, inboundOrder, ref inboundOrderDetail); |
| | | |
| | | // // 更新库存明细状态 |
| | | // stockInfo.Details.ForEach(x => x.Status = StockStatusEmun.入库完成.ObjToInt()); |
| | | |
| | | // try |
| | | // { |
| | | // _unitOfWorkManage.BeginTran(); |
| | | |
| | | // // 更新任务状态 |
| | | // UpdateTaskStatus(task); |
| | | |
| | | // // 更新货位状态 |
| | | // UpdateLocationStatus(locationInfo, lastStatus); |
| | | |
| | | // // 更新库存信息 |
| | | // UpdateStockInfo(stockInfo); |
| | | |
| | | // // 添加记录 |
| | | // AddRecords(task, stockInfo, locationInfo, lastStatus); |
| | | |
| | | // // 更新入库单 |
| | | // UpdateInboundOrder(inboundOrder, inboundOrderDetail); |
| | | |
| | | // // 单据数量全部上架完成,处理WMS回传 |
| | | // if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | // { |
| | | // var stockInfoDetail = stockInfo.Details.FirstOrDefault(); |
| | | // SendInboundInfoToWMS(task, inboundOrder, stockInfo); |
| | | // } |
| | | |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // return WebResponseContent.Instance.OK(); |
| | | // } |
| | | // catch |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // throw; |
| | | // } |
| | | //} |
| | | |
| | | #region Helper Methods |
| | | |
| | |
| | | else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = InboundStatusEnum.入库中.ObjToInt(); |
| | | inboundOrder.OrderStatus = InboundStatusEnum.入库中.ObjToInt(); |
| | | } |
| | | } |
| | | if (inboundOrder.Details.Count == overCount) |
| | | { |
| | | inboundOrder.OrderStatus = InboundStatusEnum.入库完成.ObjToInt(); |
| | | } |
| | | } |
| | | |
| | | private void UpdateTaskStatus(Dt_Task task) |
| | | { |
| | | task.TaskStatus = InTaskStatusEnum.InFinish.ObjToInt(); |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | FeedBackWCSTaskCompleted(task.TaskNum); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateType.人工完成 : OperateType.自动完成); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private void SendInboundInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, Dt_StockInfoDetail stockInfoDetail) |
| | | private WebResponseContent SendInboundInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, Dt_StockInfo stockInfo) |
| | | { |
| | | if (stockInfoDetail == null) return; |
| | | |
| | | |
| | | List<Dt_StockInfo> StockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == task.WarehouseId).Includes(x => x.Details).Where(x => x.Details.Any(v => v.OrderNo == inboundOrder.OrderNo)).ToList(); |
| | | //var dt_StockInfo = _stockRepository.StockInfoRepository.QueryData(x => x.Id == stockInfo.Id).ToList(); |
| | | //List<Dt_StockInfo> StockInfos = new List<Dt_StockInfo>(); |
| | | //foreach (var item in dt_StockInfo) |
| | | //{ |
| | | // Dt_StockInfo StockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.Id == item.Id).Includes(x => x.Details).First(); |
| | | // StockInfos.Add(StockInfo); |
| | | //} |
| | | |
| | | if (StockInfos.Count == 0) throw new Exception("未找到库存信息"); |
| | | var houseInboundPassBack = new HouseInboundPassBack |
| | | { |
| | | ApiType = "AsnController", |
| | | Method = "AsrsGroudingAsn", |
| | | Parameters = new List<HouseInboundPassBack.data> |
| | | { |
| | | new HouseInboundPassBack.data |
| | | { |
| | | Value = new List<data.data1> |
| | | { |
| | | new data.data1 |
| | | new HouseInboundPassBack.data |
| | | { |
| | | AsnNo = task.OrderNo, |
| | | InWarehouse = task.Roadway, |
| | | TransactionCode = inboundOrder.TransactionCode, |
| | | InoutType = inboundOrder.OrderType, |
| | | OrderType = inboundOrder.InoutType, |
| | | DetailList = new List<data.data1.Inbound> |
| | | Value = new List<data.data1> |
| | | { |
| | | new data.data1.Inbound |
| | | new data.data1 |
| | | { |
| | | LinId = stockInfoDetail.LinId, |
| | | MaterielCode = stockInfoDetail.MaterielCode, |
| | | OrderQuantity = stockInfoDetail.StockQuantity, |
| | | BatchNo = stockInfoDetail.BatchNo, |
| | | FinishQty = stockInfoDetail.StockQuantity, |
| | | LocationName = task.TargetAddress |
| | | AsnNo = inboundOrder.OrderNo, |
| | | //InWarehouse = task.Roadway, |
| | | TransactionCode = inboundOrder.TransactionCode, |
| | | InoutType = inboundOrder.OrderType, |
| | | OrderType = inboundOrder.InoutType, |
| | | // 遍历所有库存明细,添加到 DetailList |
| | | DetailList = StockInfos.Select(d => new data.data1.Inbound |
| | | { |
| | | LinId = d.Details.FirstOrDefault()?.LinId?? "", |
| | | MaterielCode = d.Details.FirstOrDefault()?.MaterielCode?? "", |
| | | OrderQuantity = d.Details.FirstOrDefault().StockQuantity, |
| | | BatchNo = d.BatchNo, |
| | | LPNNo = d.PalletCode, |
| | | FinishQty = d.Details.FirstOrDefault().StockQuantity, |
| | | LocationName = d.LocationCode |
| | | }).ToList() |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | var authResult = AuthenticateWithWMS(); |
| | | if (authResult.IsSuccess) |
| | | { |
| | | houseInboundPassBack.Context = new Dictionary<string, string> |
| | | { |
| | | { "Ticket", authResult.Ticket }, |
| | | { "InvOrgId", authResult.InvOrgId } |
| | | }; |
| | | { |
| | | { "Ticket", authResult.Ticket }, |
| | | { "InvOrgId", authResult.InvOrgId } |
| | | }; |
| | | |
| | | HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, houseInboundPassBack, "立库入库数量回传WMS"); |
| | | var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskin, houseInboundPassBack, "立库入库数量回传WMS"); |
| | | // 判断Success的值 |
| | | if (response.Success) |
| | | { |
| | | // 如果Success为true,返回需要的值(这里以返回整个响应对象为例) |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | | { |
| | | // 如果Success为false,抛出异常并包含错误信息 |
| | | throw new Exception($"操作失败: {response.Message ?? "未提供错误信息"}"); |
| | | } |
| | | |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | |
| | | private WebResponseContent SurplusReturnInboundToWMS(Dt_Task task, Dt_ReturnOrder returnOrder, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo) |
| | | { |
| | | List<Dt_StockInfo> StockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == task.WarehouseId).Includes(x => x.Details).Where(x => x.Details.Any(v => v.OrderNo == returnOrder.OrderNo)).ToList(); |
| | | Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseId == task.WarehouseId); |
| | | if (StockInfos.Count == 0) throw new Exception("未找到库存信息"); |
| | | var houseReturnOrders = new HouseBackboundPassBack |
| | | { |
| | | ApiType = "ShippingOrderController", |
| | | Method = "returnShippingOrderUnPickingToAsrsCallback", |
| | | Parameters = new List<HouseBackboundPassBack.backdata> |
| | | { |
| | | new HouseBackboundPassBack.backdata |
| | | { |
| | | Value= new List<backdata.backdata1> |
| | | { |
| | | new backdata.backdata1 |
| | | { |
| | | OrderType = returnOrder.OrderType, |
| | | MaterielCode = returnOrder.MaterielCode, |
| | | MaterielName = returnOrder.MaterielName, |
| | | MaterieSpec = returnOrder.MaterieSpec, |
| | | BatchNo = returnOrder.BatchNo, |
| | | OrderQuantity = returnOrder.OrderQuantity, |
| | | Remark = returnOrder.Remark, |
| | | LinId = returnOrder.LinId, |
| | | LPNNo = returnOrder.LPNNo, |
| | | LocationCode = locationInfo.LocationCode, |
| | | WarehouseCode = returnOrder.WarehouseCode, |
| | | System = returnOrder.System, |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | var authResult = AuthenticateWithWMS(); |
| | | if (authResult.IsSuccess) |
| | | { |
| | | houseReturnOrders.Context = new Dictionary<string, string> |
| | | { |
| | | { "Ticket", authResult.Ticket }, |
| | | { "InvOrgId", authResult.InvOrgId } |
| | | }; |
| | | var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskreturn, houseReturnOrders, "取消发货后立库反拣入库回传WMS"); |
| | | // 判断Success的值 |
| | | if (response.Success) |
| | | { |
| | | // 如果Success为true,返回需要的值(这里以返回整个响应对象为例) |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | | { |
| | | // 如果Success为false,抛出异常并包含错误信息 |
| | | throw new Exception($"操作失败: {response.Message ?? "未提供错误信息"}"); |
| | | } |
| | | |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | |
| | | private void ProcessAllocateInboundOrder(Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) |
| | |
| | | _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail); |
| | | } |
| | | |
| | | private void SendAllocateInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, List<Dt_StockInfo> stockInfos) |
| | | private void SendAllocateInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, Dt_StockInfo stockInfos) |
| | | { |
| | | |
| | | var detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockInfos.FirstOrDefault().Id); |
| | | List<Dt_StockInfo> StockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == task.WarehouseId).Includes(x => x.Details).Where(x => x.Details.Any(v => v.OrderNo == inboundOrder.OrderNo)).ToList(); |
| | | //var dt_StockInfo = _stockRepository.StockInfoRepository.QueryData(x => x.Id == stockInfo.Id).ToList(); |
| | | //List<Dt_StockInfo> StockInfos = new List<Dt_StockInfo>(); |
| | | //foreach (var item in dt_StockInfo) |
| | | //{ |
| | | // Dt_StockInfo StockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.Id == item.Id).Includes(x => x.Details).First(); |
| | | // StockInfos.Add(StockInfo); |
| | | //} |
| | | |
| | | if (StockInfos.Count == 0) throw new Exception("未找到库存信息"); |
| | | var inventoryAllocate = new InventoryAllocate |
| | | { |
| | | ApiType = "AsnController", |
| | | Method = "AsrsGroudingAsn", |
| | | ApiType = "InventoryAllocateController", |
| | | Method = "AsrsFinishedStockCount", |
| | | Parameters = new List<InventoryAllocate.Allocate> |
| | | { |
| | | new InventoryAllocate.Allocate |
| | | { |
| | | Value = new List<Allocate.data1> |
| | | { |
| | | new Allocate.data1 |
| | | new Allocate.data1 |
| | | { |
| | | No = inboundOrder.OrderNo, |
| | | //InWarehouse = task.Roadway, |
| | | TransactionCode = inboundOrder.TransactionCode, |
| | | InoutType = inboundOrder.OrderType, |
| | | OrderType = inboundOrder.InoutType, |
| | | // 遍历所有库存明细,添加到 DetailList |
| | | DetailList = StockInfos.Select(d => new Allocate.data1.Inventory |
| | | { |
| | | No = task.OrderNo, |
| | | InWarehouse = task.Roadway, |
| | | TransactionCode = inboundOrder.TransactionCode, |
| | | InoutType = inboundOrder.OrderType, |
| | | OrderType = inboundOrder.InoutType, |
| | | DetailList = new List<Allocate.data1.Inventory> |
| | | { |
| | | new Allocate.data1.Inventory |
| | | { |
| | | LinId = detail.LinId, |
| | | MaterielCode = detail.MaterielCode, |
| | | OrderQuantity = detail.StockQuantity, |
| | | BatchNo = detail.BatchNo, |
| | | FinishQty = detail.StockQuantity, |
| | | LocationName = task.TargetAddress |
| | | } |
| | | } |
| | | } |
| | | LinId = d.Details.FirstOrDefault()?.LinId?? "", |
| | | MaterielCode = d.Details.FirstOrDefault()?.MaterielCode?? "", |
| | | OrderQuantity = d.Details.FirstOrDefault().StockQuantity, |
| | | BatchNo = d.BatchNo, |
| | | LPN_No = d.PalletCode, |
| | | FinishQty = d.Details.FirstOrDefault().StockQuantity, |
| | | LocationName = d.LocationCode |
| | | }).ToList() |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | ApiType = "AuthenticationController", |
| | | Parameters = new List<Parameter> |
| | | { |
| | | new Parameter { Value = "LKAdmin" }, |
| | | new Parameter { Value = "LKAdmin" } |
| | | new Parameter { Value = "LK-Admin" }, |
| | | new Parameter { Value = "LK-Admin" } |
| | | }, |
| | | Method = "Login", |
| | | }; |
| | | |
| | | var response = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "登录WMS账号"); |
| | | |
| | | if (response.Status && response.Context != null) |
| | | if (response.Context != null) |
| | | { |
| | | return (true, response.Context["Ticket"].ToString(), response.Context["InvOrgId"].ToString()); |
| | | } |
| | |
| | | out var locationInfo, out var outStockLockInfos); |
| | | if (!validationResult.Status) return validationResult; |
| | | |
| | | int lastStatus = locationInfo.LocationStatus; |
| | | Dt_Task task1 = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task1 == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到该任务信息"); |
| | | } |
| | | ///盘点出库任务完成逻辑 |
| | | if ((task.TaskType == TaskTypeEnum.OutInventory.ObjToInt())) |
| | | { |
| | | return OutInventoryCompleted(task, stockInfo, locationInfo); |
| | | } |
| | | Dt_OutboundOrder inboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>() |
| | | .Where(x => x.OrderNo == task1.OrderNo) |
| | | .Includes(x => x.Details) |
| | | .First(); |
| | | |
| | | if (inboundOrder == null) return WebResponseContent.Instance.Error("未找到出库单信息"); |
| | | |
| | | Dt_OutboundOrderDetail outboundOrderDetails = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrderDetail>() |
| | | .Where(x => x.OrderId == inboundOrder.Id && x.BatchNo == stockInfo.Details.FirstOrDefault().BatchNo) |
| | | .First(); |
| | | if (outboundOrderDetails.LocationName != null && outboundOrderDetails.LocationName != "") |
| | | { |
| | | outboundOrderDetails = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrderDetail>() |
| | | .Where(x => x.OrderId == inboundOrder.Id && x.BatchNo == stockInfo.Details.FirstOrDefault().BatchNo && x.LocationName == stockInfo.LocationCode) |
| | | .First(); |
| | | } |
| | | if (outboundOrderDetails == null) return WebResponseContent.Instance.Error("未找到出库单信息"); |
| | | |
| | | // 2. 处理出库订单详情 |
| | | var outboundOrderDetails = ProcessOutboundOrderDetails(outStockLockInfos); |
| | | //var outboundOrderDetails = ProcessOutboundOrderDetails(outStockLockInfos); |
| | | |
| | | UpdateOutboundOrderDetails(stockInfo, inboundOrder, ref outboundOrderDetails); |
| | | |
| | | // 3. 执行核心出库逻辑 |
| | | return ExecuteOutboundLogic(task, stockInfo, locationInfo, outboundOrderDetails); |
| | | return ExecuteOutboundLogic(task, stockInfo, locationInfo, outboundOrderDetails, inboundOrder); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | |
| | | if (stockInfo == null) return WebResponseContent.Instance.Error("未找到库存信息"); |
| | | if (locationInfo == null) return WebResponseContent.Instance.Error("未找到货位信息"); |
| | | if (outStockLockInfos == null || outStockLockInfos.Count == 0) |
| | | if ((outStockLockInfos == null || outStockLockInfos.Count == 0)&& task.TaskType != TaskTypeEnum.OutInventory.ObjToInt()) |
| | | return WebResponseContent.Instance.Error("未找到出库详情信息"); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | |
| | | private List<Dt_OutboundOrderDetail> ProcessOutboundOrderDetails(List<Dt_OutStockLockInfo> outStockLockInfos) |
| | | { |
| | | var outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); |
| | | //private List<Dt_OutboundOrderDetail> ProcessOutboundOrderDetails(List<Dt_OutStockLockInfo> outStockLockInfos) |
| | | //{ |
| | | // var outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); |
| | | |
| | | foreach (var lockInfo in outStockLockInfos) |
| | | { |
| | | var detail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == lockInfo.OrderDetailId); |
| | | if (detail != null) |
| | | { |
| | | detail.OverOutQuantity = detail.LockQuantity; |
| | | if (detail.LockQuantity == detail.OrderQuantity) |
| | | { |
| | | detail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | } |
| | | outboundOrderDetails.Add(detail); |
| | | } |
| | | } |
| | | // foreach (var lockInfo in outStockLockInfos) |
| | | // { |
| | | // List<Dt_OutboundOrderDetail> detail = _outboundService.OutboundOrderDetailService.Repository.QueryData(x => x.Id == lockInfo.Id); |
| | | // if (detail != null) |
| | | // { |
| | | // detail.OverOutQuantity = lockInfo.OriginalQuantity; |
| | | // if (detail.LockQuantity == detail.OrderQuantity) |
| | | // { |
| | | // detail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | // } |
| | | // outboundOrderDetails.Add(detail); |
| | | // } |
| | | // } |
| | | |
| | | return outboundOrderDetails; |
| | | } |
| | | // return outboundOrderDetails; |
| | | //} |
| | | |
| | | private WebResponseContent ExecuteOutboundLogic(Dt_Task task, Dt_StockInfo stockInfo, |
| | | Dt_LocationInfo locationInfo, List<Dt_OutboundOrderDetail> outboundOrderDetails) |
| | | Dt_LocationInfo locationInfo, Dt_OutboundOrderDetail outboundOrderDetails, Dt_OutboundOrder inboundOrder) |
| | | { |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | ///更新出库单 |
| | | _outboundService.OutboundOrderService.Repository.UpdateData(inboundOrder); |
| | | // 更新出库订单详情 |
| | | _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | |
| | | // 更新库存状态 |
| | | UpdateStockStatus(stockInfo, locationInfo); |
| | | AddRetrueOrder(stockInfo, inboundOrder); |
| | | |
| | | // 更新货位状态 |
| | | UpdateLocationStatus(locationInfo); |
| | | |
| | | // 区分单据数据来源更新货位状态 |
| | | if (inboundOrder.System == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("出库单数据源为空"); |
| | | } |
| | | if (!inboundOrder.System.Equals("SMOM")) |
| | | { |
| | | UpdateLocationStatus(locationInfo); |
| | | } |
| | | // 处理任务完成 |
| | | CompleteTask(task); |
| | | |
| | |
| | | AddStatusChangeRecord(task, stockInfo, locationInfo); |
| | | |
| | | // 根据订单类型处理不同逻辑 |
| | | var outDetail = _outboundService.OutboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>() |
| | | .Where(x => x.LPNNo == stockInfo.PalletCode).First(); |
| | | var outboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>() |
| | | .Where(x => x.Id == outDetail.OrderId).Includes(x => x.Details).First(); |
| | | |
| | | if (outboundOrder.OrderType == 1) // 普通出库 |
| | | var outboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>() |
| | | .Where(x => x.OrderNo == inboundOrder.OrderNo).First(); |
| | | var outDetail = _outboundService.OutboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>() |
| | | .Where(x => x.OrderId == outboundOrder.Id && x.BatchNo == outboundOrderDetails.BatchNo).First(); |
| | | |
| | | string path = "http://fr.mankun.com:8080/webroot/decision/view/report?viewlet=fr-report\\SMOM/Product/Produce/OutBoundDetileReport.cpt&op=write&format=pdf"; |
| | | string fullPath = AppDomain.CurrentDomain.BaseDirectory; |
| | | var url = Path.Combine(fullPath, "wwwroot", "Reports"); |
| | | string savePath = Path.Combine(url, "本次出库.pdf"); |
| | | |
| | | |
| | | if (outboundOrderDetails.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt() && inboundOrder.System.Equals("ERP")) |
| | | { |
| | | ProcessNormalOutbound(task, stockInfo, outboundOrder, outDetail); |
| | | FeedBackOutERP(outboundOrder.OrderNo, outboundOrderDetails.LinId); |
| | | //DownloadReport(path, savePath, outboundOrderDetails.Id); |
| | | //printTest(savePath); |
| | | } |
| | | else if (outboundOrder.OrderType == 240) // 盘点出库 |
| | | ///单据完成推送SMOM系统 |
| | | if (outboundOrder.OrderStatus == OutboundStatusEnum.出库完成.ObjToInt() && inboundOrder.System.Equals("SMOM")) |
| | | { |
| | | var stockInfoDetail = stockInfo.Details.FirstOrDefault(); |
| | | ProcessNormalOutbound(task, stockInfo, outboundOrder, outDetail); |
| | | //DownloadReport(path, savePath, outboundOrderDetails.Id); |
| | | //printTest(savePath); |
| | | //SendNormalOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); |
| | | } |
| | | |
| | | if (outboundOrder.OrderType == 240) // 盘点出库 |
| | | { |
| | | // 盘点出库特殊处理逻辑 |
| | | } |
| | | else // 调拨出库 |
| | | { |
| | | ProcessAllocateOutbound(task, stockInfo, outboundOrder, outDetail); |
| | | } |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | private void UpdateStockStatus(Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo) |
| | | private void UpdateOutboundOrderDetails(Dt_StockInfo stockInfo, Dt_OutboundOrder inboundOrder, ref Dt_OutboundOrderDetail inboundOrderDetail) |
| | | { |
| | | stockInfo.LocationCode = locationInfo.LocationCode; |
| | | stockInfo.StockStatus = StockStatusEmun.出库完成.ObjToInt(); |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | int overCount = inboundOrder.Details.Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()); |
| | | inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfo.Details.FirstOrDefault()?.BatchNo); |
| | | |
| | | foreach (var item in stockInfo.Details) |
| | | { |
| | | if (inboundOrderDetail == null) continue; |
| | | |
| | | inboundOrderDetail.OverOutQuantity += item.OutboundQuantity; |
| | | |
| | | if (inboundOrderDetail.OverOutQuantity == inboundOrderDetail.OrderQuantity) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | overCount++; |
| | | } |
| | | else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = OutboundStatusEnum.出库中.ObjToInt(); |
| | | inboundOrder.OrderStatus = OutboundStatusEnum.出库中.ObjToInt(); |
| | | } |
| | | } |
| | | if (inboundOrder.Details.Count == overCount) |
| | | { |
| | | inboundOrder.OrderStatus = OutboundStatusEnum.出库完成.ObjToInt(); |
| | | } |
| | | } |
| | | |
| | | private void DeleteAndMoveIntoHtStockStatus(Dt_StockInfo stockInfo) |
| | | { |
| | | _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | } |
| | | |
| | | private void UpdateLocationStatus(Dt_LocationInfo locationInfo) |
| | |
| | | |
| | | private void CompleteTask(Dt_Task task) |
| | | { |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | FeedBackWCSTaskCompleted(task.TaskNum); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | } |
| | | |
| | |
| | | var stockInfoDetail = _stockRepository.StockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>() |
| | | .Where(x => x.StockId == stockInfo.Id).First(); |
| | | |
| | | if (outboundOrder.Details.Count == 1) |
| | | { |
| | | MoveOutboundOrderToHistory(outboundOrder); |
| | | } |
| | | //if (outboundOrder.OrderStatus == OutboundStatusEnum.出库完成.ObjToInt()) |
| | | //{ |
| | | // var history = new Dt_OutboundOrder_Hty |
| | | // { |
| | | // OrderStatus = outboundOrder.OrderStatus, |
| | | // CreateType = outboundOrder.CreateType, |
| | | // UpperOrderNo = outboundOrder.UpperOrderNo, |
| | | // OrderNo = outboundOrder.OrderNo, |
| | | // OutWareHouse = outboundOrder.OutWareHouse, |
| | | // TransactionCode = outboundOrder.TransactionCode, |
| | | // InoutType = outboundOrder.InoutType, |
| | | // OrderType = outboundOrder.OrderType, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _outboundOrder_HtyService.AddData(history); |
| | | // _outboundService.OutboundOrderService.DeleteData(outboundOrder); |
| | | //} |
| | | |
| | | MoveOutboundDetailToHistory(outDetail); |
| | | //MoveOutboundDetailToHistory(outDetail); |
| | | |
| | | // 发送出库信息到WMS |
| | | SendNormalOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); |
| | | if (outboundOrder.OrderStatus == OutboundStatusEnum.出库完成.ObjToInt() && outboundOrder.OrderType == 1) |
| | | { |
| | | SendNormalOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); |
| | | } |
| | | else if (outboundOrder.OrderStatus == OutboundStatusEnum.出库完成.ObjToInt() && outboundOrder.OrderType == 2) |
| | | { |
| | | SendAllocateOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); |
| | | } |
| | | |
| | | |
| | | // 删除库存信息 |
| | | DeleteStockInfo(stockInfo); |
| | | //DeleteStockInfo(stockInfo); |
| | | } |
| | | |
| | | private void ProcessAllocateOutbound(Dt_Task task, Dt_StockInfo stockInfo, |
| | |
| | | |
| | | if (outboundOrder.Details.Count == 1) |
| | | { |
| | | MoveOutboundOrderToHistory(outboundOrder); |
| | | var history = new Dt_OutboundOrder_Hty |
| | | { |
| | | OrderStatus = outboundOrder.OrderStatus, |
| | | CreateType = outboundOrder.CreateType, |
| | | UpperOrderNo = outboundOrder.UpperOrderNo, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | OutWareHouse = outboundOrder.OutWareHouse, |
| | | TransactionCode = outboundOrder.TransactionCode, |
| | | InoutType = outboundOrder.InoutType, |
| | | OrderType = outboundOrder.OrderType, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | _outboundOrder_HtyService.AddData(history); |
| | | _outboundService.OutboundOrderService.DeleteData(outboundOrder); |
| | | } |
| | | |
| | | MoveOutboundDetailToHistory(outDetail); |
| | | |
| | | // 发送调拨出库信息到WMS |
| | | SendAllocateOutboundToWMS(task, outboundOrder, outDetail, relatedStockInfos); |
| | | |
| | | |
| | | // 删除库存信息 |
| | | DeleteStockInfo(stockInfo); |
| | | } |
| | | |
| | | private void MoveOutboundOrderToHistory(Dt_OutboundOrder outboundOrder) |
| | | { |
| | | var history = new Dt_OutboundOrder_Hty |
| | | { |
| | | OrderStatus = outboundOrder.OrderStatus, |
| | | CreateType = outboundOrder.CreateType, |
| | | UpperOrderNo = outboundOrder.UpperOrderNo, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | OutWareHouse = outboundOrder.OutWareHouse, |
| | | TransactionCode = outboundOrder.TransactionCode, |
| | | InoutType = outboundOrder.InoutType, |
| | | OrderType = outboundOrder.OrderType, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | _outboundOrder_HtyService.AddData(history); |
| | | _outboundService.OutboundOrderService.DeleteData(outboundOrder); |
| | | } |
| | | |
| | | private void MoveOutboundDetailToHistory(Dt_OutboundOrderDetail outDetail) |
| | | { |
| | |
| | | _outboundService.OutboundOrderService.DeleteData(outDetail); |
| | | } |
| | | |
| | | private void SendNormalOutboundToWMS(Dt_Task task, Dt_OutboundOrder outboundOrder, |
| | | private WebResponseContent SendNormalOutboundToWMS(Dt_Task task, Dt_OutboundOrder outboundOrder, |
| | | Dt_StockInfoDetail stockInfoDetail, Dt_OutboundOrderDetail outDetail) |
| | | { |
| | | |
| | | //List<Dt_StockInfo> StockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == task.WarehouseId).Includes(x => x.Details).Where(x => x.Details.Any(v => v.BatchNo == outDetail.BatchNo)).ToList(); |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryData(x => x.OrderNo == outboundOrder.OrderNo); |
| | | |
| | | if (outStockLockInfos.Count == 0) throw new Exception("未找到库存信息"); |
| | | |
| | | // 构建回传数据,将所有匹配的库存明细加入 DetailList |
| | | var passBack = new HouseoutboundPassBack |
| | | { |
| | | ApiType = "ShippingOrderController", |
| | | Method = "AsrsOutboundSO", |
| | | Parameters = new List<HouseoutboundPassBack.datas> |
| | | { |
| | | { |
| | | new HouseoutboundPassBack.datas |
| | | { |
| | | Value = new List<HouseoutboundPassBack.datas.data1> |
| | |
| | | TransactionCode = outboundOrder.TransactionCode, |
| | | InoutType = outboundOrder.OrderType, |
| | | OrderType = outboundOrder.InoutType, |
| | | DetailList = new List<HouseoutboundPassBack.datas.data1.Inbound> |
| | | { |
| | | new HouseoutboundPassBack.datas.data1.Inbound |
| | | DetailList = outStockLockInfos.Select(d => new HouseoutboundPassBack.datas.data1.Inbound |
| | | { |
| | | LinId = outDetail.LinId, |
| | | LPN_No = task.PalletCode, |
| | | MaterielCode = stockInfoDetail.MaterielCode, |
| | | OrderQuantity = stockInfoDetail.OutboundQuantity, |
| | | BatchNo = stockInfoDetail.BatchNo, |
| | | FinishQty = stockInfoDetail.OutboundQuantity, |
| | | LocationName = task.SourceAddress |
| | | } |
| | | } |
| | | LinId = d.LinId?? "", |
| | | LPN_No = d.PalletCode, |
| | | MaterielCode = d.MaterielCode?? "", |
| | | OrderQuantity = d.OrderQuantity, |
| | | BatchNo = d.BatchNo, |
| | | FinishQty = d.OrderQuantity, |
| | | LocationName = d.LocationCode |
| | | }) |
| | | .ToList() |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | var authResult = AuthenticateWithWMS(); |
| | |
| | | { "InvOrgId", authResult.InvOrgId } |
| | | }; |
| | | |
| | | HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, passBack, "立库入库数量回传WMS"); |
| | | var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskout, passBack, "立库出库数量回传WMS"); |
| | | // 判断Success的值 |
| | | if (response.Success) |
| | | { |
| | | // 如果Success为true,返回需要的值(这里以返回整个响应对象为例) |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | | { |
| | | // 如果Success为false,抛出异常并包含错误信息 |
| | | throw new Exception($"操作失败: {response.Message ?? "未提供错误信息"}"); |
| | | } |
| | | |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | |
| | | private void SendAllocateOutboundToWMS(Dt_Task task, Dt_OutboundOrder outboundOrder, |
| | | Dt_OutboundOrderDetail outDetail, List<Dt_StockInfo> stockInfos) |
| | | Dt_StockInfoDetail stockInfoDetail, Dt_OutboundOrderDetail outDetail) |
| | | { |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryData(x => x.OrderNo == outboundOrder.OrderNo); |
| | | |
| | | |
| | | if (outStockLockInfos.Count == 0) throw new Exception("未找到库存信息"); |
| | | var allocate = new InventoryAllocate |
| | | { |
| | | ApiType = "InventoryAllocateController", |
| | |
| | | TransactionCode = outboundOrder.TransactionCode, |
| | | InoutType = outboundOrder.OrderType, |
| | | OrderType = outboundOrder.InoutType, |
| | | DetailList = stockInfos.Select(item => |
| | | DetailList = outStockLockInfos.Select(item => |
| | | { |
| | | var detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == item.Id); |
| | | return new Allocate.data1.Inventory |
| | |
| | | App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | } |
| | | |
| | | #endregion |
| | | #endregion |
| | | private void AddRetrueOrder(Dt_StockInfo stockInfo, Dt_OutboundOrder outboundOrder) |
| | | { |
| | | Dt_StockInfoDetail stockInfoDetail = _stockService.StockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>() |
| | | .Where(x => x.StockId == stockInfo.Id) |
| | | .First(); |
| | | if (stockInfoDetail == null) |
| | | { |
| | | throw new Exception("建立回库单时,未找到该库存信息"); |
| | | } |
| | | if (outboundOrder.OrderType == OrderTypeEnum.反拣出库单.ObjToInt()) |
| | | { |
| | | Dt_ReturnOrder returnOrder = _returnOrderRepository.QueryFirst(x => x.LPNNo == stockInfo.PalletCode && x.LocationCode == stockInfo.LocationCode && x.OrderStatus == InOrderStatusEnum.未开始.ObjToInt()); |
| | | if (returnOrder == null) |
| | | { |
| | | throw new Exception("反拣出库后,未找到对应反拣回库单信息"); |
| | | } |
| | | stockInfo.LocationCode = ""; |
| | | stockInfo.StockStatus = StockStatusEmun.反拣入库.ObjToInt(); |
| | | stockInfo.Remark = "反拣入库"; |
| | | stockInfoDetail.OutboundQuantity = 0; |
| | | stockInfoDetail.StockQuantity += returnOrder.OrderQuantity; |
| | | stockInfoDetail.OrderNo = returnOrder.OrderNo; |
| | | } |
| | | else |
| | | { |
| | | decimal returnQuantity = stockInfoDetail.StockQuantity - stockInfoDetail.OutboundQuantity; |
| | | if (returnQuantity > 0) |
| | | { |
| | | Dt_ReturnOrder returnOrder = new Dt_ReturnOrder |
| | | { |
| | | MaterielCode = stockInfoDetail.MaterielCode, |
| | | MaterielName = stockInfoDetail.MaterielName, |
| | | BatchNo = stockInfoDetail.BatchNo, |
| | | OrderQuantity = returnQuantity, |
| | | ReceiptQuantity = returnQuantity, |
| | | OrderStatus = InOrderStatusEnum.未开始.ObjToInt(), |
| | | LinId = stockInfoDetail.LinId, |
| | | LPNNo = stockInfo.PalletCode, |
| | | Creater = "LK", |
| | | CreateDate = DateTime.Now, |
| | | OrderType = OrderTypeEnum.余料回库单.ObjToInt(), |
| | | System = "WMS" |
| | | }; |
| | | if (outboundOrder.System == "SMOM" && stockInfo.LocationCode != null) |
| | | { |
| | | returnOrder.LocationCode = stockInfo.LocationCode; |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | _returnOrderRepository.AddData(returnOrder); |
| | | stockInfo.LocationCode = ""; |
| | | stockInfo.StockStatus = StockStatusEmun.余料退库.ObjToInt(); |
| | | stockInfo.Remark = "余料退库"; |
| | | stockInfoDetail.OutboundQuantity = 0; |
| | | stockInfoDetail.StockQuantity = returnQuantity; |
| | | stockInfoDetail.OrderNo = returnOrder.OrderNo; |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | else |
| | | { |
| | | DeleteAndMoveIntoHtStockStatus(stockInfo); |
| | | } |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 单据明细出库完成回调ERP(表单提交) |
| | | /// </summary> |
| | | /// <param name="outboundOrder"></param> |
| | | /// <param name="outboundOrderDetail"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public WebResponseContent FeedBackOutERP(string orderNO, string linId) |
| | | { |
| | | Dt_OutStockLockInfo outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryFirst(x => x.OrderNo == orderNO && x.LinId == linId); |
| | | if (outStockLockInfos == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到出库库存信息"); |
| | | } |
| | | var postContent = new MultipartFormDataContent(); |
| | | postContent.Headers.Add("ContentType", $"multipart/form-data"); |
| | | postContent.Add(new StringContent(outStockLockInfos.LinId), "ids"); |
| | | string result = string.Empty; |
| | | HttpClient client = null; |
| | | try |
| | | { |
| | | using (client = new HttpClient()) |
| | | { |
| | | HttpResponseMessage response = client.PostAsync(ReceiveERPTaskout, postContent) |
| | | .ConfigureAwait(false).GetAwaiter().GetResult(); |
| | | |
| | | // 确保响应成功 |
| | | response.EnsureSuccessStatusCode(); |
| | | |
| | | result = response.Content.ReadAsStringAsync() |
| | | .ConfigureAwait(false).GetAwaiter().GetResult(); |
| | | } |
| | | |
| | | // 假设ERP返回成功时返回成功响应 |
| | | return WebResponseContent.Instance.OK(result); |
| | | } |
| | | catch (HttpRequestException ex) |
| | | { |
| | | // 处理HTTP请求相关异常 |
| | | return WebResponseContent.Instance.Error($"HTTP请求错误: {ex.Message}"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 处理其他异常 |
| | | return WebResponseContent.Instance.Error($"处理失败: {ex.Message}"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public WebResponseContent FeedBackInboundERP(string upperOrderNo, string linId) |
| | | { |
| | | if (upperOrderNo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到入库单信息"); |
| | | } |
| | | List<FeedbackInboundOrderERP> feedbackInboundOrderERPs = new List<FeedbackInboundOrderERP>(); |
| | | |
| | | FeedbackInboundOrderERP feedbackInboundOrder = new FeedbackInboundOrderERP() |
| | | { |
| | | code = upperOrderNo, |
| | | itemId = linId, |
| | | success = true |
| | | |
| | | }; |
| | | feedbackInboundOrderERPs.Add(feedbackInboundOrder); |
| | | var response = HttpHelper.Post<WebResponseContent>(InMaterialWarehousingCallback, feedbackInboundOrderERPs, "入库单完成回传ERP"); |
| | | // 判断Success的值 |
| | | if (response.Code == 0) |
| | | { |
| | | // 如果Success为true,返回需要的值(这里以返回整个响应对象为例) |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | | { |
| | | // 如果Success为false,抛出异常并包含错误信息 |
| | | throw new Exception($"操作失败: {response.Message ?? "未提供错误信息"}"); |
| | | } |
| | | } |
| | | public string DownloadReport(string path, string savePath, int orderId) |
| | | { |
| | | // 构建完整 URL,(报表传参) |
| | | string reportUrl = path + "&orderId=" + orderId; |
| | | |
| | | try |
| | | { |
| | | // 确保保存目录存在 |
| | | string directory = Path.GetDirectoryName(savePath); |
| | | if (!Directory.Exists(directory)) |
| | | { |
| | | Directory.CreateDirectory(directory); |
| | | } |
| | | |
| | | string[] files = Directory.GetFiles(directory); |
| | | // 删除每个文件 |
| | | foreach (string filePath in files) |
| | | { |
| | | File.Delete(filePath); |
| | | } |
| | | // 使用 HttpClient 下载文件 |
| | | using (var httpClient = new HttpClient()) |
| | | { |
| | | // 设置超时时间(帆软报表生成可能需要较长时间) |
| | | httpClient.Timeout = TimeSpan.FromMinutes(5); |
| | | |
| | | // 发送 GET 请求(同步方式) |
| | | using (var response = httpClient.GetAsync(reportUrl, HttpCompletionOption.ResponseHeadersRead).GetAwaiter().GetResult()) |
| | | { |
| | | // 检查响应状态 |
| | | response.EnsureSuccessStatusCode(); |
| | | |
| | | // 获取内容流(同步方式) |
| | | using (var contentStream = response.Content.ReadAsStreamAsync().GetAwaiter().GetResult()) |
| | | { |
| | | // 创建文件流 |
| | | using (var fileStream = new FileStream(savePath, FileMode.Create, FileAccess.Write, FileShare.None)) |
| | | { |
| | | // 复制内容到文件(同步方式) |
| | | contentStream.CopyToAsync(fileStream).GetAwaiter().GetResult(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return savePath; |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new ValidationException(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public virtual void printTest(string fullPath) |
| | | { |
| | | Spire.Pdf.PdfDocument pdf = new PdfDocument(); |
| | | //文件地址 |
| | | pdf.LoadFromFile(fullPath); |
| | | //指定打印机位置 |
| | | string url = AppSettings.app("PrinterName"); |
| | | pdf.PrintSettings.PrinterName = url; |
| | | //执行打印 |
| | | pdf.Print(); |
| | | //内存释放 |
| | | pdf.Dispose(); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | #region |
| | | //public WebResponseContent InboundTaskCompleted(int taskNum) |
| | | //{ |
| | | // try |
| | | // { |
| | | // Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | // if (task == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到该任务"); |
| | | // } |
| | | // if (task.TaskType != TaskTypeEnum.Inbound.ObjToInt()) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"任务类型错误"); |
| | | // } |
| | | // Dt_StockInfo dt_StockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x => x.Details).First(); |
| | | // if (dt_StockInfo == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到托盘对应的组盘信息"); |
| | | // } |
| | | |
| | | // if (!string.IsNullOrEmpty(dt_StockInfo.LocationCode)) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"该托盘已绑定货位"); |
| | | // } |
| | | |
| | | // if (dt_StockInfo.Details == null || dt_StockInfo.Details.Count == 0) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到该托盘库存明细信息"); |
| | | // } |
| | | // Dt_LocationInfo dt_LocationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); |
| | | // if (dt_LocationInfo == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到目标货位信息"); |
| | | // } |
| | | |
| | | // if (dt_LocationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"货位状态不正确"); |
| | | // } |
| | | // int lastStatus = dt_LocationInfo.LocationStatus; |
| | | // dt_LocationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | // Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseId == task.WarehouseId); |
| | | |
| | | // dt_StockInfo.LocationCode = dt_LocationInfo.LocationCode; |
| | | |
| | | |
| | | // Dt_InboundOrder? inboundOrder = _inboundService.InbounOrderService.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == dt_StockInfo.Details.FirstOrDefault().OrderNo).Includes(x => x.Details).First(); |
| | | // Dt_InboundOrderDetail? inboundOrderDetail = null; |
| | | // //判断单据类型是入库还是调拨入库。。。入库 |
| | | // if (inboundOrder.OrderType == 0 && inboundOrder != null && dt_StockInfo.StockStatus == StockStatusEmun.入库确认.ObjToInt()) |
| | | // { |
| | | // #region //判断入库单据明细只有最后一条完成时删除入库单 |
| | | // //查询原完成的入库明细数量 |
| | | // int overCount = inboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; |
| | | // //明细id查询 |
| | | // inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.LinId == dt_StockInfo.Details.FirstOrDefault()?.LinId); |
| | | // foreach (var item in dt_StockInfo.Details) |
| | | // { |
| | | // if (inboundOrderDetail == null) |
| | | // { |
| | | // continue; |
| | | // } |
| | | // inboundOrderDetail.OverInQuantity += item.StockQuantity; |
| | | // if (inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity) |
| | | // { |
| | | // inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | // overCount += 1; |
| | | // } |
| | | // else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | // { |
| | | // inboundOrderDetail.OrderDetailStatus = InboundStatusEnum.入库中.ObjToInt(); |
| | | // } |
| | | // } |
| | | // dt_StockInfo.Details.ForEach(x => |
| | | // { |
| | | // x.Status = StockStatusEmun.入库完成.ObjToInt(); |
| | | // }); |
| | | |
| | | // _unitOfWorkManage.BeginTran(); |
| | | // task.TaskStatus = InTaskStatusEnum.InFinish.ObjToInt(); |
| | | // BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateType.人工完成 : OperateType.自动完成); |
| | | |
| | | // _basicService.LocationInfoService.Repository.UpdateData(dt_LocationInfo); |
| | | // _stockRepository.StockInfoRepository.UpdateData(dt_StockInfo); |
| | | // _stockRepository.StockInfoDetailRepository.UpdateData(dt_StockInfo.Details); |
| | | // _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(dt_LocationInfo, lastStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); |
| | | // _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(dt_StockInfo, dt_StockInfo.Details, dt_StockInfo.Details.Sum(x => x.StockQuantity), dt_StockInfo.Details.Sum(x => x.StockQuantity), StockChangeType.Inbound, task.TaskNum); |
| | | // if (inboundOrder != null) |
| | | // { |
| | | // _inboundService.InbounOrderService.UpdateData(inboundOrder); |
| | | // _inboundService.InboundOrderDetailService.UpdateData(inboundOrderDetail); |
| | | // } |
| | | // _unitOfWorkManage.CommitTran(); |
| | | |
| | | |
| | | |
| | | |
| | | // if (inboundOrder.Details.Count == 1) |
| | | // { |
| | | // var stockInfoDetail = dt_StockInfo.Details.FirstOrDefault(); |
| | | |
| | | // #region//入库信息返回上位WMS。。立库入库数量回传 |
| | | // HouseInboundPassBack houseInboundPassBack = new HouseInboundPassBack(); |
| | | // houseInboundPassBack.ApiType = "AsnController"; |
| | | // houseInboundPassBack.Method = "AsrsGroudingAsn"; |
| | | // data data = new data(); |
| | | // data.data1 data1 = new data.data1(); |
| | | // data1.AsnNo = task.OrderNo; |
| | | // data1.InWarehouse = task.Roadway; |
| | | // data1.TransactionCode = inboundOrder.TransactionCode; |
| | | // data1.InoutType = inboundOrder.OrderType; |
| | | // data1.OrderType = inboundOrder.InoutType; |
| | | // data.data1.Inbound inbound = new data.data1.Inbound |
| | | // { |
| | | // LinId = stockInfoDetail.LinId, |
| | | // MaterielCode = stockInfoDetail.MaterielCode, |
| | | // OrderQuantity = stockInfoDetail.StockQuantity, |
| | | // BatchNo = stockInfoDetail.BatchNo, |
| | | // FinishQty = stockInfoDetail.StockQuantity, |
| | | // LocationName = task.TargetAddress |
| | | // }; |
| | | // data.Value.Add(data1); |
| | | // data1.DetailList.Add(inbound); |
| | | // houseInboundPassBack.Parameters.Add(data); |
| | | // Authentication authentication = new Authentication() |
| | | // { |
| | | // ApiType = "AuthenticationController", |
| | | // Parameters = new List<Parameter> |
| | | // { |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // }, |
| | | // Method = "Login", |
| | | // }; |
| | | // var responses1 = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "登录WMS账号"); |
| | | // var Ticket = responses1.Context["Ticket"].ToString(); |
| | | // var InvOrgId = responses1.Context["InvOrgId"].ToString(); |
| | | // if (Ticket != null) |
| | | // { |
| | | // houseInboundPassBack.Context = new Dictionary<string, string>(); |
| | | // houseInboundPassBack.Context.Add("Ticket", Ticket); |
| | | // houseInboundPassBack.Context.Add("InvOrgId", InvOrgId); |
| | | // var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, houseInboundPassBack, "立库入库数量回传WMS"); |
| | | // } |
| | | // #endregion |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // #region //判断调拨入库单据明细只有最后一条完成时删除入库单并一次返回入库明细信息 |
| | | // if (inboundOrder.Details.Count == 1) |
| | | // { |
| | | // List<Dt_StockInfo> StockInfo = _stockService.StockInfoService.Repository.QueryData(x => x.BatchNo == inboundOrderDetail.BatchNo); |
| | | // Dt_InboundOrder_Hty inboundOrder_Hty = new Dt_InboundOrder_Hty |
| | | // { |
| | | // OrderStatus = inboundOrder.OrderStatus, |
| | | // CreateType = inboundOrder.CreateType, |
| | | // //SourceId = oldOutboundOrder.SourceId, |
| | | // UpperOrderNo = inboundOrder.UpperOrderNo, |
| | | // OrderNo = inboundOrder.OrderNo, |
| | | // //OutWareHouse = inboundOrder.OutWareHouse, |
| | | // TransactionCode = inboundOrder.TransactionCode, |
| | | // InoutType = inboundOrder.InoutType, |
| | | // OrderType = inboundOrder.OrderType, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _inboundOrder_HtyService.AddData(inboundOrder_Hty); |
| | | // _inboundService.InbounOrderService.DeleteData(inboundOrder); |
| | | // Dt_InboundOrderDetail_Hty dt_InboundOrderDetail_HtyS = new Dt_InboundOrderDetail_Hty |
| | | // { |
| | | // OrderId = inboundOrderDetail.OrderId, |
| | | // MaterielCode = inboundOrderDetail.MaterielCode, |
| | | // MaterielName = inboundOrderDetail.MaterielName, |
| | | // BatchNo = inboundOrderDetail.BatchNo, |
| | | // OrderQuantity = inboundOrderDetail.OrderQuantity, |
| | | // ReceiptQuantity = inboundOrderDetail.ReceiptQuantity, |
| | | // OverInQuantity = inboundOrderDetail.OverInQuantity, |
| | | // OrderDetailStatus = inboundOrderDetail.OrderDetailStatus, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _inboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_HtyS); |
| | | // _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail); |
| | | // #endregion |
| | | // #region//调拨任务数量回传WMS |
| | | // InventoryAllocate inventoryAllocate = new InventoryAllocate(); |
| | | // inventoryAllocate.ApiType = "InventoryAllocateController"; |
| | | // inventoryAllocate.Method = "AsrsFinishedStockCount"; |
| | | |
| | | // Allocate allocate = new Allocate(); |
| | | |
| | | // Allocate.data1 data1 = new Allocate.data1(); |
| | | // data1.No = task.OrderNo; |
| | | // data1.InWarehouse = task.Roadway; |
| | | // data1.TransactionCode = inboundOrder.TransactionCode; |
| | | // data1.InoutType = inboundOrder.OrderType; |
| | | // data1.OrderType = inboundOrder.InoutType; |
| | | // foreach (var item in StockInfo) |
| | | // { |
| | | // Dt_StockInfoDetail detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == item.Id); |
| | | // Allocate.data1.Inventory inbound = new Allocate.data1.Inventory(); |
| | | // inbound.LinId = detail.LinId; |
| | | // inbound.LPN_No = item.PalletCode; |
| | | // inbound.MaterielCode = detail.MaterielCode; |
| | | // inbound.OrderQuantity = detail.StockQuantity; |
| | | // inbound.BatchNo = detail.BatchNo; |
| | | // inbound.FinishQty = detail.StockQuantity; |
| | | // inbound.LocationName = item.LocationCode; |
| | | // data1.DetailList.Add(inbound); |
| | | // } |
| | | // allocate.Value.Add(data1); |
| | | // inventoryAllocate.Parameters.Add(allocate); |
| | | // Authentication authentication = new Authentication() |
| | | // { |
| | | // ApiType = "AuthenticationController", |
| | | // Parameters = new List<Parameter> |
| | | // { |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // }, |
| | | // Method = "Login", |
| | | // }; |
| | | // var responses1 = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "登录WMS账号"); |
| | | // var Ticket = responses1.Context["Ticket"].ToString(); |
| | | // var InvOrgId = responses1.Context["InvOrgId"].ToString(); |
| | | // if (Ticket != null) |
| | | // { |
| | | // inventoryAllocate.Context = new Dictionary<string, string>(); |
| | | // inventoryAllocate.Context.Add("Ticket", Ticket); |
| | | // inventoryAllocate.Context.Add("InvOrgId", InvOrgId); |
| | | // var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAllocatein, inventoryAllocate, "调拨入库数量回传WMS"); |
| | | // } |
| | | // } |
| | | // #endregion |
| | | // Dt_InboundOrderDetail_Hty dt_InboundOrderDetail_Hty = new Dt_InboundOrderDetail_Hty |
| | | // { |
| | | // OrderId = inboundOrderDetail.OrderId, |
| | | // MaterielCode = inboundOrderDetail.MaterielCode, |
| | | // MaterielName = inboundOrderDetail.MaterielName, |
| | | // BatchNo = inboundOrderDetail.BatchNo, |
| | | // OrderQuantity = inboundOrderDetail.OrderQuantity, |
| | | // ReceiptQuantity = inboundOrderDetail.ReceiptQuantity, |
| | | // OverInQuantity = inboundOrderDetail.OverInQuantity, |
| | | // OrderDetailStatus = inboundOrderDetail.OrderDetailStatus, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _inboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_Hty); |
| | | // _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail); |
| | | // } |
| | | // return WebResponseContent.Instance.OK(); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | //} |
| | | #endregion |
| | | #region |
| | | //public WebResponseContent OutboundTaskCompleted(int taskNum) |
| | | //{ |
| | | // try |
| | | // { |
| | | // Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | // if (task == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到任务信息"); |
| | | // } |
| | | |
| | | // Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); |
| | | |
| | | // Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); |
| | | // if (stockInfo == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到库存信息"); |
| | | // } |
| | | // if (locationInfo == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到货位信息"); |
| | | // } |
| | | |
| | | // List<Dt_OutStockLockInfo> outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryData(x => x.TaskNum == taskNum); |
| | | // if (outStockLockInfos == null || outStockLockInfos.Count == 0) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到出库详情信息"); |
| | | // } |
| | | |
| | | // List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); |
| | | // for (int i = 0; i < outStockLockInfos.Count; i++) |
| | | // { |
| | | // Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == outStockLockInfos[i].OrderDetailId); |
| | | // if (outboundOrderDetail != null) |
| | | // { |
| | | // outboundOrderDetail.OverOutQuantity = outboundOrderDetail.LockQuantity; |
| | | // if (outboundOrderDetail.LockQuantity == outboundOrderDetail.OrderQuantity) |
| | | // { |
| | | // outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | // } |
| | | // outboundOrderDetails.Add(outboundOrderDetail); |
| | | // } |
| | | // } |
| | | |
| | | // _unitOfWorkManage.BeginTran(); |
| | | // _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | |
| | | // stockInfo.LocationCode = locationInfo.LocationCode; |
| | | // stockInfo.StockStatus = StockStatusEmun.出库完成.ObjToInt(); |
| | | // _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | |
| | | // int beforeStatus = locationInfo.LocationStatus; |
| | | // locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | // _basicService.LocationInfoService.Repository.UpdateData(locationInfo); |
| | | // BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | |
| | | // _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // Dt_StockInfoDetail stockInfoDetail = _stockRepository.StockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.StockId == stockInfo.Id).First(); |
| | | // Dt_OutboundOrderDetail outDetail = _outboundService.OutboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>().Where(x => x.LPNNo == stockInfo.PalletCode).First(); |
| | | // Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == outDetail.OrderId).Includes(x => x.Details).First(); |
| | | // //判断单据类型是出库还是调拨出库。。。出库 |
| | | // if (outboundOrder.OrderType == 1) |
| | | // { |
| | | // #region //判断出库单据明细只有最后一条完成时删除出库单 |
| | | // if (outboundOrder.Details.Count == 1) |
| | | // { |
| | | // Dt_OutboundOrder_Hty inboundOrder_Hty = new Dt_OutboundOrder_Hty |
| | | // { |
| | | // OrderStatus = outboundOrder.OrderStatus, |
| | | // CreateType = outboundOrder.CreateType, |
| | | // //SourceId = oldOutboundOrder.SourceId, |
| | | // UpperOrderNo = outboundOrder.UpperOrderNo, |
| | | // OrderNo = outboundOrder.OrderNo, |
| | | // OutWareHouse = outboundOrder.OutWareHouse, |
| | | // TransactionCode = outboundOrder.TransactionCode, |
| | | // InoutType = outboundOrder.InoutType, |
| | | // OrderType = outboundOrder.OrderType, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _outboundOrder_HtyService.AddData(inboundOrder_Hty); |
| | | // _outboundService.OutboundOrderService.DeleteData(outboundOrder); |
| | | // } |
| | | // Dt_OutboundOrderDetail_Hty dt_InboundOrderDetail_Hty = new Dt_OutboundOrderDetail_Hty |
| | | // { |
| | | // OrderId = outDetail.OrderId, |
| | | // MaterielCode = outDetail.MaterielCode, |
| | | // MaterielName = outDetail.MaterielName, |
| | | // BatchNo = outDetail.BatchNo, |
| | | // OrderQuantity = outDetail.OrderQuantity, |
| | | // //ReceiptQuantity = outDetail.ReceiptQuantity, |
| | | // //OverInQuantity = outDetail.OverInQuantity, |
| | | // OrderDetailStatus = outDetail.OrderDetailStatus, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _outboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_Hty); |
| | | // _outboundService.OutboundOrderService.DeleteData(outDetail); |
| | | // #endregion |
| | | // #region//出库信息返回上位WMS。。。立库出库数量回传 |
| | | // HouseoutboundPassBack houseInboundPassBack = new HouseoutboundPassBack(); |
| | | // houseInboundPassBack.ApiType = "ShippingOrderController"; |
| | | // houseInboundPassBack.Method = "AsrsOutboundSO"; |
| | | // datas datas = new datas(); |
| | | // datas.data1 data1 = new datas.data1(); |
| | | // data1.No = outboundOrder.OrderNo; |
| | | // data1.OutWareHouse = task.Roadway; |
| | | // data1.TransactionCode = outboundOrder.TransactionCode; |
| | | // data1.InoutType = outboundOrder.OrderType; |
| | | // data1.OrderType = outboundOrder.InoutType; |
| | | |
| | | // datas.data1.Inbound inbound = new datas.data1.Inbound(); |
| | | // inbound.LinId = outDetail.LinId; |
| | | // inbound.LPN_No = task.PalletCode; |
| | | // inbound.MaterielCode = stockInfoDetail.MaterielCode; |
| | | // inbound.OrderQuantity = stockInfoDetail.OutboundQuantity; |
| | | // inbound.BatchNo = stockInfoDetail.BatchNo; |
| | | // inbound.FinishQty = stockInfoDetail.OutboundQuantity; |
| | | // inbound.LocationName = task.SourceAddress; |
| | | // datas.Value.Add(data1); |
| | | // data1.DetailList.Add(inbound); |
| | | // houseInboundPassBack.Parameters.Add(datas); |
| | | // Authentication authentication = new Authentication() |
| | | // { |
| | | // ApiType = "AuthenticationController", |
| | | // Parameters = new List<Parameter> |
| | | // { |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // }, |
| | | // Method = "Login", |
| | | // }; |
| | | // var responses1 = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "登录WMS账号"); |
| | | // var Ticket = responses1.Context["Ticket"].ToString(); |
| | | // var InvOrgId = responses1.Context["InvOrgId"].ToString(); |
| | | // if (Ticket != null) |
| | | // { |
| | | // houseInboundPassBack.Context = new Dictionary<string, string>(); |
| | | // houseInboundPassBack.Context.Add("Ticket", Ticket); |
| | | // houseInboundPassBack.Context.Add("InvOrgId", InvOrgId); |
| | | // var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskout, houseInboundPassBack, "立库出库数量回传WMS"); |
| | | // } |
| | | // #endregion |
| | | // //删除库存信息 |
| | | // _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | // _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | // } |
| | | // else if (outboundOrder.OrderType == 240) |
| | | // { |
| | | // //盘点出库任务完成、、、、、、、、、不能删除库存等逻辑 |
| | | // } |
| | | // else |
| | | // { |
| | | |
| | | // List<Dt_StockInfo> StockInfo = _stockService.StockInfoService.Repository.QueryData(x => x.BatchNo == outDetail.BatchNo); |
| | | // if (outboundOrder.Details.Count == 1) |
| | | // { |
| | | // Dt_OutboundOrder_Hty inboundOrder_Hty = new Dt_OutboundOrder_Hty |
| | | // { |
| | | // OrderStatus = outboundOrder.OrderStatus, |
| | | // CreateType = outboundOrder.CreateType, |
| | | // //SourceId = oldOutboundOrder.SourceId, |
| | | // UpperOrderNo = outboundOrder.UpperOrderNo, |
| | | // OrderNo = outboundOrder.OrderNo, |
| | | // OutWareHouse = outboundOrder.OutWareHouse, |
| | | // TransactionCode = outboundOrder.TransactionCode, |
| | | // InoutType = outboundOrder.InoutType, |
| | | // OrderType = outboundOrder.OrderType, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _outboundOrder_HtyService.AddData(inboundOrder_Hty); |
| | | // _outboundService.OutboundOrderService.DeleteData(outboundOrder); |
| | | // } |
| | | // Dt_OutboundOrderDetail_Hty dt_InboundOrderDetail_Hty = new Dt_OutboundOrderDetail_Hty |
| | | // { |
| | | // OrderId = outDetail.OrderId, |
| | | // MaterielCode = outDetail.MaterielCode, |
| | | // MaterielName = outDetail.MaterielName, |
| | | // BatchNo = outDetail.BatchNo, |
| | | // OrderQuantity = outDetail.OrderQuantity, |
| | | // //ReceiptQuantity = outDetail.ReceiptQuantity, |
| | | // //OverInQuantity = outDetail.OverInQuantity, |
| | | // OrderDetailStatus = outDetail.OrderDetailStatus, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _outboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_Hty); |
| | | // _outboundService.OutboundOrderService.DeleteData(outDetail); |
| | | |
| | | // InventoryAllocate inventoryAllocate = new InventoryAllocate(); |
| | | // inventoryAllocate.ApiType = "InventoryAllocateController"; |
| | | // inventoryAllocate.Method = "AsrsFinishedStockCount"; |
| | | |
| | | // Allocate allocate = new Allocate(); |
| | | |
| | | // Allocate.data1 data1 = new Allocate.data1(); |
| | | // data1.No = outboundOrder.OrderNo; |
| | | // data1.InWarehouse = task.Roadway; |
| | | // data1.TransactionCode = outboundOrder.TransactionCode; |
| | | // data1.InoutType = outboundOrder.OrderType; |
| | | // data1.OrderType = outboundOrder.InoutType; |
| | | |
| | | // foreach (var item in StockInfo) |
| | | // { |
| | | // Dt_StockInfoDetail detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == item.Id); |
| | | // Allocate.data1.Inventory inbound = new Allocate.data1.Inventory(); |
| | | // inbound.LinId = outDetail.LinId; |
| | | // inbound.LPN_No = item.PalletCode; |
| | | // inbound.MaterielCode = detail.MaterielCode; |
| | | // inbound.OrderQuantity = detail.OutboundQuantity; |
| | | // inbound.BatchNo = detail.BatchNo; |
| | | // inbound.FinishQty = detail.OutboundQuantity; |
| | | // inbound.LocationName = task.SourceAddress; |
| | | // data1.DetailList.Add(inbound); |
| | | // } |
| | | |
| | | |
| | | // allocate.Value.Add(data1); |
| | | // inventoryAllocate.Parameters.Add(allocate); |
| | | // Authentication authentication = new Authentication() |
| | | // { |
| | | // ApiType = "AuthenticationController", |
| | | // Parameters = new List<Parameter> |
| | | // { |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // }, |
| | | // Method = "Login", |
| | | // }; |
| | | // var responses1 = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "登录WMS账号"); |
| | | // var Ticket = responses1.Context["Ticket"].ToString(); |
| | | // var InvOrgId = responses1.Context["InvOrgId"].ToString(); |
| | | // if (Ticket != null) |
| | | // { |
| | | // inventoryAllocate.Context = new Dictionary<string, string>(); |
| | | // inventoryAllocate.Context.Add("Ticket", Ticket); |
| | | // inventoryAllocate.Context.Add("InvOrgId", InvOrgId); |
| | | // var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAllocatein, inventoryAllocate, "调拨出库数量回传WMS"); |
| | | // } |
| | | // _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | // _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | // } |
| | | // return WebResponseContent.Instance.OK(); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | //} |
| | | #endregion |
| | | /// <summary> |
| | | /// 盘点出库完成 |
| | | /// </summary> |
| | | public WebResponseContent OutInventoryCompleted(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //获取对应盘点单 |
| | | Dt_TakeStockOrder takeStockOrder = _inboundRepository.TakeStockOrderRepository.Db.Queryable<Dt_TakeStockOrder>().Where(x => x.OrderNo == task.OrderNo).Includes(x => x.Details).First(); |
| | | if (takeStockOrder == null) |
| | | { |
| | | return content.Error($"盘点单{task.OrderNo}不存在"); |
| | | } |
| | | if (takeStockOrder.TakeStockStatus != TakeStockStatusEnum.盘点中.ObjToInt()) |
| | | { |
| | | return content.Error($"盘点单{task.OrderNo}盘点已完成或未开始"); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.出库锁定.ObjToInt()) |
| | | { |
| | | return content.Error($"{stockInfo.PalletCode}库存状态不正确"); |
| | | } |
| | | if (locationInfo.LocationStatus != LocationStatusEnum.Lock.ObjToInt()) |
| | | { |
| | | return content.Error($"{locationInfo.LocationCode}货位状态不正确"); |
| | | } |
| | | //根据任务托盘查盘点明细 |
| | | Dt_TakeStockOrderDetail? takeStockOrderDetail = takeStockOrder.Details.FirstOrDefault(x => x.TakePalletCode == stockInfo.PalletCode); |
| | | if (takeStockOrderDetail == null) |
| | | { |
| | | return content.Error($"{stockInfo.PalletCode}未找到对应盘点明细"); |
| | | } |
| | | if (takeStockOrderDetail.TakeDetalStatus != TakeStockDetailStatusEnum.盘点出库中.ObjToInt()) |
| | | { |
| | | return content.Error($"{stockInfo.PalletCode}盘点明细状态不正确"); |
| | | } |
| | | takeStockOrderDetail.TakeDetalStatus = TakeStockDetailStatusEnum.盘点出库完成.ObjToInt(); |
| | | stockInfo.StockStatus = StockStatusEmun.盘点出库完成.ObjToInt(); |
| | | stockInfo.Details.ForEach(x => |
| | | { |
| | | x.Status = StockStatusEmun.盘点出库完成.ObjToInt(); |
| | | }); |
| | | stockInfo.LocationCode = ""; |
| | | task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); |
| | | int beforeStatus = locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | //货位变动记录 |
| | | _basicService.LocationInfoService.UpdateData(locationInfo); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, LocationStatusEnum.Free.ObjToInt(), LocationChangeType.OutboundCompleted.ObjToInt(), takeStockOrder?.OrderNo ?? "", task.TaskNum); |
| | | _inboundRepository.TakeStockOrderDetailRepository.UpdateData(takeStockOrderDetail); |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | #region |
| | | //public WebResponseContent InboundTaskCompleted(int taskNum) |
| | | //{ |
| | | // try |
| | | // { |
| | | // Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | // if (task == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到该任务"); |
| | | // } |
| | | // if (task.TaskType != TaskTypeEnum.Inbound.ObjToInt()) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"任务类型错误"); |
| | | // } |
| | | // Dt_StockInfo dt_StockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x => x.Details).First(); |
| | | // if (dt_StockInfo == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到托盘对应的组盘信息"); |
| | | // } |
| | | |
| | | // if (!string.IsNullOrEmpty(dt_StockInfo.LocationCode)) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"该托盘已绑定货位"); |
| | | // } |
| | | |
| | | // if (dt_StockInfo.Details == null || dt_StockInfo.Details.Count == 0) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到该托盘库存明细信息"); |
| | | // } |
| | | // Dt_LocationInfo dt_LocationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); |
| | | // if (dt_LocationInfo == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到目标货位信息"); |
| | | // } |
| | | |
| | | // if (dt_LocationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"货位状态不正确"); |
| | | // } |
| | | // int lastStatus = dt_LocationInfo.LocationStatus; |
| | | // dt_LocationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | // Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseId == task.WarehouseId); |
| | | |
| | | // dt_StockInfo.LocationCode = dt_LocationInfo.LocationCode; |
| | | |
| | | |
| | | // Dt_InboundOrder? inboundOrder = _inboundService.InbounOrderService.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == dt_StockInfo.Details.FirstOrDefault().OrderNo).Includes(x => x.Details).First(); |
| | | // Dt_InboundOrderDetail? inboundOrderDetail = null; |
| | | // //判断单据类型是入库还是调拨入库。。。入库 |
| | | // if (inboundOrder.OrderType == 0 && inboundOrder != null && dt_StockInfo.StockStatus == StockStatusEmun.入库确认.ObjToInt()) |
| | | // { |
| | | // #region //判断入库单据明细只有最后一条完成时删除入库单 |
| | | // //查询原完成的入库明细数量 |
| | | // int overCount = inboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; |
| | | // //明细id查询 |
| | | // inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.LinId == dt_StockInfo.Details.FirstOrDefault()?.LinId); |
| | | // foreach (var item in dt_StockInfo.Details) |
| | | // { |
| | | // if (inboundOrderDetail == null) |
| | | // { |
| | | // continue; |
| | | // } |
| | | // inboundOrderDetail.OverInQuantity += item.StockQuantity; |
| | | // if (inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity) |
| | | // { |
| | | // inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | // overCount += 1; |
| | | // } |
| | | // else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | // { |
| | | // inboundOrderDetail.OrderDetailStatus = InboundStatusEnum.入库中.ObjToInt(); |
| | | // } |
| | | // } |
| | | // dt_StockInfo.Details.ForEach(x => |
| | | // { |
| | | // x.Status = StockStatusEmun.入库完成.ObjToInt(); |
| | | // }); |
| | | |
| | | // _unitOfWorkManage.BeginTran(); |
| | | // task.TaskStatus = InTaskStatusEnum.InFinish.ObjToInt(); |
| | | // BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateType.人工完成 : OperateType.自动完成); |
| | | |
| | | // _basicService.LocationInfoService.Repository.UpdateData(dt_LocationInfo); |
| | | // _stockRepository.StockInfoRepository.UpdateData(dt_StockInfo); |
| | | // _stockRepository.StockInfoDetailRepository.UpdateData(dt_StockInfo.Details); |
| | | // _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(dt_LocationInfo, lastStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); |
| | | // _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(dt_StockInfo, dt_StockInfo.Details, dt_StockInfo.Details.Sum(x => x.StockQuantity), dt_StockInfo.Details.Sum(x => x.StockQuantity), StockChangeType.Inbound, task.TaskNum); |
| | | // if (inboundOrder != null) |
| | | // { |
| | | // _inboundService.InbounOrderService.UpdateData(inboundOrder); |
| | | // _inboundService.InboundOrderDetailService.UpdateData(inboundOrderDetail); |
| | | // } |
| | | // _unitOfWorkManage.CommitTran(); |
| | | |
| | | |
| | | |
| | | |
| | | // if (inboundOrder.Details.Count == 1) |
| | | // { |
| | | // var stockInfoDetail = dt_StockInfo.Details.FirstOrDefault(); |
| | | |
| | | // #region//入库信息返回上位WMS。。立库入库数量回传 |
| | | // HouseInboundPassBack houseInboundPassBack = new HouseInboundPassBack(); |
| | | // houseInboundPassBack.ApiType = "AsnController"; |
| | | // houseInboundPassBack.Method = "AsrsGroudingAsn"; |
| | | // data data = new data(); |
| | | // data.data1 data1 = new data.data1(); |
| | | // data1.AsnNo = task.OrderNo; |
| | | // data1.InWarehouse = task.Roadway; |
| | | // data1.TransactionCode = inboundOrder.TransactionCode; |
| | | // data1.InoutType = inboundOrder.OrderType; |
| | | // data1.OrderType = inboundOrder.InoutType; |
| | | // data.data1.Inbound inbound = new data.data1.Inbound |
| | | // { |
| | | // LinId = stockInfoDetail.LinId, |
| | | // MaterielCode = stockInfoDetail.MaterielCode, |
| | | // OrderQuantity = stockInfoDetail.StockQuantity, |
| | | // BatchNo = stockInfoDetail.BatchNo, |
| | | // FinishQty = stockInfoDetail.StockQuantity, |
| | | // LocationName = task.TargetAddress |
| | | // }; |
| | | // data.Value.Add(data1); |
| | | // data1.DetailList.Add(inbound); |
| | | // houseInboundPassBack.Parameters.Add(data); |
| | | // Authentication authentication = new Authentication() |
| | | // { |
| | | // ApiType = "AuthenticationController", |
| | | // Parameters = new List<Parameter> |
| | | // { |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // }, |
| | | // Method = "Login", |
| | | // }; |
| | | // var responses1 = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "登录WMS账号"); |
| | | // var Ticket = responses1.Context["Ticket"].ToString(); |
| | | // var InvOrgId = responses1.Context["InvOrgId"].ToString(); |
| | | // if (Ticket != null) |
| | | // { |
| | | // houseInboundPassBack.Context = new Dictionary<string, string>(); |
| | | // houseInboundPassBack.Context.Add("Ticket", Ticket); |
| | | // houseInboundPassBack.Context.Add("InvOrgId", InvOrgId); |
| | | // var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, houseInboundPassBack, "立库入库数量回传WMS"); |
| | | // } |
| | | // #endregion |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // #region //判断调拨入库单据明细只有最后一条完成时删除入库单并一次返回入库明细信息 |
| | | // if (inboundOrder.Details.Count == 1) |
| | | // { |
| | | // List<Dt_StockInfo> StockInfo = _stockService.StockInfoService.Repository.QueryData(x => x.BatchNo == inboundOrderDetail.BatchNo); |
| | | // Dt_InboundOrder_Hty inboundOrder_Hty = new Dt_InboundOrder_Hty |
| | | // { |
| | | // OrderStatus = inboundOrder.OrderStatus, |
| | | // CreateType = inboundOrder.CreateType, |
| | | // //SourceId = oldOutboundOrder.SourceId, |
| | | // UpperOrderNo = inboundOrder.UpperOrderNo, |
| | | // OrderNo = inboundOrder.OrderNo, |
| | | // //OutWareHouse = inboundOrder.OutWareHouse, |
| | | // TransactionCode = inboundOrder.TransactionCode, |
| | | // InoutType = inboundOrder.InoutType, |
| | | // OrderType = inboundOrder.OrderType, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _inboundOrder_HtyService.AddData(inboundOrder_Hty); |
| | | // _inboundService.InbounOrderService.DeleteData(inboundOrder); |
| | | // Dt_InboundOrderDetail_Hty dt_InboundOrderDetail_HtyS = new Dt_InboundOrderDetail_Hty |
| | | // { |
| | | // OrderId = inboundOrderDetail.OrderId, |
| | | // MaterielCode = inboundOrderDetail.MaterielCode, |
| | | // MaterielName = inboundOrderDetail.MaterielName, |
| | | // BatchNo = inboundOrderDetail.BatchNo, |
| | | // OrderQuantity = inboundOrderDetail.OrderQuantity, |
| | | // ReceiptQuantity = inboundOrderDetail.ReceiptQuantity, |
| | | // OverInQuantity = inboundOrderDetail.OverInQuantity, |
| | | // OrderDetailStatus = inboundOrderDetail.OrderDetailStatus, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _inboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_HtyS); |
| | | // _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail); |
| | | // #endregion |
| | | // #region//调拨任务数量回传WMS |
| | | // InventoryAllocate inventoryAllocate = new InventoryAllocate(); |
| | | // inventoryAllocate.ApiType = "InventoryAllocateController"; |
| | | // inventoryAllocate.Method = "AsrsFinishedStockCount"; |
| | | |
| | | // Allocate allocate = new Allocate(); |
| | | |
| | | // Allocate.data1 data1 = new Allocate.data1(); |
| | | // data1.No = task.OrderNo; |
| | | // data1.InWarehouse = task.Roadway; |
| | | // data1.TransactionCode = inboundOrder.TransactionCode; |
| | | // data1.InoutType = inboundOrder.OrderType; |
| | | // data1.OrderType = inboundOrder.InoutType; |
| | | // foreach (var item in StockInfo) |
| | | // { |
| | | // Dt_StockInfoDetail detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == item.Id); |
| | | // Allocate.data1.Inventory inbound = new Allocate.data1.Inventory(); |
| | | // inbound.LinId = detail.LinId; |
| | | // inbound.LPN_No = item.PalletCode; |
| | | // inbound.MaterielCode = detail.MaterielCode; |
| | | // inbound.OrderQuantity = detail.StockQuantity; |
| | | // inbound.BatchNo = detail.BatchNo; |
| | | // inbound.FinishQty = detail.StockQuantity; |
| | | // inbound.LocationName = item.LocationCode; |
| | | // data1.DetailList.Add(inbound); |
| | | // } |
| | | // allocate.Value.Add(data1); |
| | | // inventoryAllocate.Parameters.Add(allocate); |
| | | // Authentication authentication = new Authentication() |
| | | // { |
| | | // ApiType = "AuthenticationController", |
| | | // Parameters = new List<Parameter> |
| | | // { |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // }, |
| | | // Method = "Login", |
| | | // }; |
| | | // var responses1 = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "登录WMS账号"); |
| | | // var Ticket = responses1.Context["Ticket"].ToString(); |
| | | // var InvOrgId = responses1.Context["InvOrgId"].ToString(); |
| | | // if (Ticket != null) |
| | | // { |
| | | // inventoryAllocate.Context = new Dictionary<string, string>(); |
| | | // inventoryAllocate.Context.Add("Ticket", Ticket); |
| | | // inventoryAllocate.Context.Add("InvOrgId", InvOrgId); |
| | | // var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAllocatein, inventoryAllocate, "调拨入库数量回传WMS"); |
| | | // } |
| | | // } |
| | | // #endregion |
| | | // Dt_InboundOrderDetail_Hty dt_InboundOrderDetail_Hty = new Dt_InboundOrderDetail_Hty |
| | | // { |
| | | // OrderId = inboundOrderDetail.OrderId, |
| | | // MaterielCode = inboundOrderDetail.MaterielCode, |
| | | // MaterielName = inboundOrderDetail.MaterielName, |
| | | // BatchNo = inboundOrderDetail.BatchNo, |
| | | // OrderQuantity = inboundOrderDetail.OrderQuantity, |
| | | // ReceiptQuantity = inboundOrderDetail.ReceiptQuantity, |
| | | // OverInQuantity = inboundOrderDetail.OverInQuantity, |
| | | // OrderDetailStatus = inboundOrderDetail.OrderDetailStatus, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _inboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_Hty); |
| | | // _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail); |
| | | // } |
| | | // return WebResponseContent.Instance.OK(); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | //} |
| | | #endregion |
| | | #region |
| | | //public WebResponseContent OutboundTaskCompleted(int taskNum) |
| | | //{ |
| | | // try |
| | | // { |
| | | // Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | // if (task == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到任务信息"); |
| | | // } |
| | | |
| | | // Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); |
| | | |
| | | // Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); |
| | | // if (stockInfo == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到库存信息"); |
| | | // } |
| | | // if (locationInfo == null) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到货位信息"); |
| | | // } |
| | | |
| | | // List<Dt_OutStockLockInfo> outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryData(x => x.TaskNum == taskNum); |
| | | // if (outStockLockInfos == null || outStockLockInfos.Count == 0) |
| | | // { |
| | | // return WebResponseContent.Instance.Error($"未找到出库详情信息"); |
| | | // } |
| | | |
| | | // List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); |
| | | // for (int i = 0; i < outStockLockInfos.Count; i++) |
| | | // { |
| | | // Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == outStockLockInfos[i].OrderDetailId); |
| | | // if (outboundOrderDetail != null) |
| | | // { |
| | | // outboundOrderDetail.OverOutQuantity = outboundOrderDetail.LockQuantity; |
| | | // if (outboundOrderDetail.LockQuantity == outboundOrderDetail.OrderQuantity) |
| | | // { |
| | | // outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | // } |
| | | // outboundOrderDetails.Add(outboundOrderDetail); |
| | | // } |
| | | // } |
| | | |
| | | // _unitOfWorkManage.BeginTran(); |
| | | // _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | |
| | | // stockInfo.LocationCode = locationInfo.LocationCode; |
| | | // stockInfo.StockStatus = StockStatusEmun.出库完成.ObjToInt(); |
| | | // _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | |
| | | // int beforeStatus = locationInfo.LocationStatus; |
| | | // locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | // _basicService.LocationInfoService.Repository.UpdateData(locationInfo); |
| | | // BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | |
| | | // _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // Dt_StockInfoDetail stockInfoDetail = _stockRepository.StockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.StockId == stockInfo.Id).First(); |
| | | // Dt_OutboundOrderDetail outDetail = _outboundService.OutboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>().Where(x => x.LPNNo == stockInfo.PalletCode).First(); |
| | | // Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == outDetail.OrderId).Includes(x => x.Details).First(); |
| | | // //判断单据类型是出库还是调拨出库。。。出库 |
| | | // if (outboundOrder.OrderType == 1) |
| | | // { |
| | | // #region //判断出库单据明细只有最后一条完成时删除出库单 |
| | | // if (outboundOrder.Details.Count == 1) |
| | | // { |
| | | // Dt_OutboundOrder_Hty inboundOrder_Hty = new Dt_OutboundOrder_Hty |
| | | // { |
| | | // OrderStatus = outboundOrder.OrderStatus, |
| | | // CreateType = outboundOrder.CreateType, |
| | | // //SourceId = oldOutboundOrder.SourceId, |
| | | // UpperOrderNo = outboundOrder.UpperOrderNo, |
| | | // OrderNo = outboundOrder.OrderNo, |
| | | // OutWareHouse = outboundOrder.OutWareHouse, |
| | | // TransactionCode = outboundOrder.TransactionCode, |
| | | // InoutType = outboundOrder.InoutType, |
| | | // OrderType = outboundOrder.OrderType, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _outboundOrder_HtyService.AddData(inboundOrder_Hty); |
| | | // _outboundService.OutboundOrderService.DeleteData(outboundOrder); |
| | | // } |
| | | // Dt_OutboundOrderDetail_Hty dt_InboundOrderDetail_Hty = new Dt_OutboundOrderDetail_Hty |
| | | // { |
| | | // OrderId = outDetail.OrderId, |
| | | // MaterielCode = outDetail.MaterielCode, |
| | | // MaterielName = outDetail.MaterielName, |
| | | // BatchNo = outDetail.BatchNo, |
| | | // OrderQuantity = outDetail.OrderQuantity, |
| | | // //ReceiptQuantity = outDetail.ReceiptQuantity, |
| | | // //OverInQuantity = outDetail.OverInQuantity, |
| | | // OrderDetailStatus = outDetail.OrderDetailStatus, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _outboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_Hty); |
| | | // _outboundService.OutboundOrderService.DeleteData(outDetail); |
| | | // #endregion |
| | | // #region//出库信息返回上位WMS。。。立库出库数量回传 |
| | | // HouseoutboundPassBack houseInboundPassBack = new HouseoutboundPassBack(); |
| | | // houseInboundPassBack.ApiType = "ShippingOrderController"; |
| | | // houseInboundPassBack.Method = "AsrsOutboundSO"; |
| | | // datas datas = new datas(); |
| | | // datas.data1 data1 = new datas.data1(); |
| | | // data1.No = outboundOrder.OrderNo; |
| | | // data1.OutWareHouse = task.Roadway; |
| | | // data1.TransactionCode = outboundOrder.TransactionCode; |
| | | // data1.InoutType = outboundOrder.OrderType; |
| | | // data1.OrderType = outboundOrder.InoutType; |
| | | |
| | | // datas.data1.Inbound inbound = new datas.data1.Inbound(); |
| | | // inbound.LinId = outDetail.LinId; |
| | | // inbound.LPN_No = task.PalletCode; |
| | | // inbound.MaterielCode = stockInfoDetail.MaterielCode; |
| | | // inbound.OrderQuantity = stockInfoDetail.OutboundQuantity; |
| | | // inbound.BatchNo = stockInfoDetail.BatchNo; |
| | | // inbound.FinishQty = stockInfoDetail.OutboundQuantity; |
| | | // inbound.LocationName = task.SourceAddress; |
| | | // datas.Value.Add(data1); |
| | | // data1.DetailList.Add(inbound); |
| | | // houseInboundPassBack.Parameters.Add(datas); |
| | | // Authentication authentication = new Authentication() |
| | | // { |
| | | // ApiType = "AuthenticationController", |
| | | // Parameters = new List<Parameter> |
| | | // { |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // }, |
| | | // Method = "Login", |
| | | // }; |
| | | // var responses1 = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "登录WMS账号"); |
| | | // var Ticket = responses1.Context["Ticket"].ToString(); |
| | | // var InvOrgId = responses1.Context["InvOrgId"].ToString(); |
| | | // if (Ticket != null) |
| | | // { |
| | | // houseInboundPassBack.Context = new Dictionary<string, string>(); |
| | | // houseInboundPassBack.Context.Add("Ticket", Ticket); |
| | | // houseInboundPassBack.Context.Add("InvOrgId", InvOrgId); |
| | | // var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskout, houseInboundPassBack, "立库出库数量回传WMS"); |
| | | // } |
| | | // #endregion |
| | | // //删除库存信息 |
| | | // _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | // _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | // } |
| | | // else if (outboundOrder.OrderType == 240) |
| | | // { |
| | | // //盘点出库任务完成、、、、、、、、、不能删除库存等逻辑 |
| | | // } |
| | | // else |
| | | // { |
| | | |
| | | // List<Dt_StockInfo> StockInfo = _stockService.StockInfoService.Repository.QueryData(x => x.BatchNo == outDetail.BatchNo); |
| | | // if (outboundOrder.Details.Count == 1) |
| | | // { |
| | | // Dt_OutboundOrder_Hty inboundOrder_Hty = new Dt_OutboundOrder_Hty |
| | | // { |
| | | // OrderStatus = outboundOrder.OrderStatus, |
| | | // CreateType = outboundOrder.CreateType, |
| | | // //SourceId = oldOutboundOrder.SourceId, |
| | | // UpperOrderNo = outboundOrder.UpperOrderNo, |
| | | // OrderNo = outboundOrder.OrderNo, |
| | | // OutWareHouse = outboundOrder.OutWareHouse, |
| | | // TransactionCode = outboundOrder.TransactionCode, |
| | | // InoutType = outboundOrder.InoutType, |
| | | // OrderType = outboundOrder.OrderType, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _outboundOrder_HtyService.AddData(inboundOrder_Hty); |
| | | // _outboundService.OutboundOrderService.DeleteData(outboundOrder); |
| | | // } |
| | | // Dt_OutboundOrderDetail_Hty dt_InboundOrderDetail_Hty = new Dt_OutboundOrderDetail_Hty |
| | | // { |
| | | // OrderId = outDetail.OrderId, |
| | | // MaterielCode = outDetail.MaterielCode, |
| | | // MaterielName = outDetail.MaterielName, |
| | | // BatchNo = outDetail.BatchNo, |
| | | // OrderQuantity = outDetail.OrderQuantity, |
| | | // //ReceiptQuantity = outDetail.ReceiptQuantity, |
| | | // //OverInQuantity = outDetail.OverInQuantity, |
| | | // OrderDetailStatus = outDetail.OrderDetailStatus, |
| | | // Creater = "WMS", |
| | | // CreateDate = DateTime.Now, |
| | | // }; |
| | | // _outboundOrderDetail_HtyService.AddData(dt_InboundOrderDetail_Hty); |
| | | // _outboundService.OutboundOrderService.DeleteData(outDetail); |
| | | |
| | | // InventoryAllocate inventoryAllocate = new InventoryAllocate(); |
| | | // inventoryAllocate.ApiType = "InventoryAllocateController"; |
| | | // inventoryAllocate.Method = "AsrsFinishedStockCount"; |
| | | |
| | | // Allocate allocate = new Allocate(); |
| | | |
| | | // Allocate.data1 data1 = new Allocate.data1(); |
| | | // data1.No = outboundOrder.OrderNo; |
| | | // data1.InWarehouse = task.Roadway; |
| | | // data1.TransactionCode = outboundOrder.TransactionCode; |
| | | // data1.InoutType = outboundOrder.OrderType; |
| | | // data1.OrderType = outboundOrder.InoutType; |
| | | |
| | | // foreach (var item in StockInfo) |
| | | // { |
| | | // Dt_StockInfoDetail detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == item.Id); |
| | | // Allocate.data1.Inventory inbound = new Allocate.data1.Inventory(); |
| | | // inbound.LinId = outDetail.LinId; |
| | | // inbound.LPN_No = item.PalletCode; |
| | | // inbound.MaterielCode = detail.MaterielCode; |
| | | // inbound.OrderQuantity = detail.OutboundQuantity; |
| | | // inbound.BatchNo = detail.BatchNo; |
| | | // inbound.FinishQty = detail.OutboundQuantity; |
| | | // inbound.LocationName = task.SourceAddress; |
| | | // data1.DetailList.Add(inbound); |
| | | // } |
| | | |
| | | |
| | | // allocate.Value.Add(data1); |
| | | // inventoryAllocate.Parameters.Add(allocate); |
| | | // Authentication authentication = new Authentication() |
| | | // { |
| | | // ApiType = "AuthenticationController", |
| | | // Parameters = new List<Parameter> |
| | | // { |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // new Parameter { Value = "LKAdmin"}, |
| | | // }, |
| | | // Method = "Login", |
| | | // }; |
| | | // var responses1 = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "登录WMS账号"); |
| | | // var Ticket = responses1.Context["Ticket"].ToString(); |
| | | // var InvOrgId = responses1.Context["InvOrgId"].ToString(); |
| | | // if (Ticket != null) |
| | | // { |
| | | // inventoryAllocate.Context = new Dictionary<string, string>(); |
| | | // inventoryAllocate.Context.Add("Ticket", Ticket); |
| | | // inventoryAllocate.Context.Add("InvOrgId", InvOrgId); |
| | | // var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAllocatein, inventoryAllocate, "调拨出库数量回传WMS"); |
| | | // } |
| | | // _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | // _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | // } |
| | | // return WebResponseContent.Instance.OK(); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return WebResponseContent.Instance.Error(ex.Message); |
| | | // } |
| | | //} |
| | | #endregion |
| | | } |