| | |
| | | |
| | | using AutoMapper; |
| | | using MailKit.Search; |
| | | using Microsoft.AspNetCore.SignalR; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using Org.BouncyCastle.Asn1.Tsp; |
| | |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_BasicRepository; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_Core.TaskEnum; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundService; |
| | |
| | | private readonly IInboundOrderDetail_HtyService _inboundOrderDetail_HtyService; |
| | | private readonly IOutboundOrder_HtyService _outboundOrder_HtyService; |
| | | private readonly IOutboundOrderDetail_HtyService _outboundOrderDetail_HtyService; |
| | | |
| | | private readonly IPalletTypeInfoRepository _palletTypeInfoRepository; |
| | | private readonly IOutboundOrderDetailRepository _outboundOrderDetailRepository; |
| | | 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) : 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) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _stockRepository = stockRepository; |
| | |
| | | _inboundOrderDetail_HtyService = inboundOrderDetail_HtyService; |
| | | _outboundOrder_HtyService = outboundOrder_HtyService; |
| | | _outboundOrderDetail_HtyService = outboundOrderDetail_HtyService; |
| | | |
| | | _outboundOrderDetailRepository = outboundOrderDetailRepository; |
| | | } |
| | | |
| | | public string ReceiveWMSTaskin = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskin"]; |
| | | 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"]; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 任务信息推送至WCS |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent PushTasksToWCS(List<Dt_Task> tasks, string agvDescription = "") |
| | | { |
| | | try |
| | | { |
| | | List<WMSTaskDTO> taskDTOs = _mapper.Map<List<WMSTaskDTO>>(tasks); |
| | | taskDTOs.ForEach(x => |
| | | { |
| | | x.AGVArea = agvDescription; |
| | | }); |
| | | string url = AppSettings.app("WCS"); |
| | | if (string.IsNullOrEmpty(url)) |
| | | { |
| | | 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); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 放货完成 |
| | | /// </summary> |
| | | /// <param name="code"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent PutFinish(string code) |
| | | { |
| | | try |
| | | { |
| | | string url = AppSettings.app("WCS"); |
| | | if (string.IsNullOrEmpty(url)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到WCSAApi地址,请检查配置文件"); |
| | | } |
| | | string response = HttpHelper.Post($"{url}/api/CTU_AGV/PutFinish?code=" + code); |
| | | |
| | | return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("返回错误"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 任务完成 |
| | |
| | | } |
| | | |
| | | } |
| | | public WebResponseContent UpdateTaskStatus(int taskNum, int tasktype) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.TaskType == tasktype); |
| | | if (task == null) return WebResponseContent.Instance.Error("未找到任务信息"); |
| | | if (TaskEnumHelper.GetTaskTypeGroup(task.TaskType) == TaskTypeGroup.InboundGroup) |
| | | { |
| | | task.TaskStatus = TaskInStatusEnum.InFinish.ObjToInt(); |
| | | content = UpdateTaskStatusInFinish(task); |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public WebResponseContent UpdateTaskStatusInFinish(Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode);//组盘库存 |
| | | Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);//货位 |
| | | var result = CheckCompleted(stockInfo, locationInfo); |
| | | if (!result.Item1) |
| | | { |
| | | throw new Exception(result.Item2); |
| | | } |
| | | |
| | | if (stockInfo.StockStatus != StockStatusEmun.入库中.ObjToInt()) throw new Exception($"托盘[{task.PalletCode}],该组盘状态不可入库"); |
| | | 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()) |
| | | { |
| | | stockInfo.SerialNumber = stockInfos.Count + 1; |
| | | stockInfo.InDate = DateTime.Now; |
| | | stockInfo.StockStatus = StockStatusEmun.已入库.ObjToInt(); |
| | | stockInfoDetail.Status = StockStatusEmun.已入库.ObjToInt(); |
| | | locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = string.Empty; |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | _basicService.LocationInfoService.Repository.UpdateData(locationInfo); |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail); |
| | | Db.Ado.CommitTran(); |
| | | return content; |
| | | } |
| | | #region 入库单 |
| | | Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(stockInfoDetail.OrderNo); |
| | | if (inboundOrder != null || inboundOrder.Details.Count < 1) throw new Exception($"未找到托盘[{task.PalletCode}]的入库单明细信息"); |
| | | Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfoDetail.BatchNo && x.MaterielCode == stockInfoDetail.MaterielCode); |
| | | inboundOrderDetail.OrderDetailStatus = inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity ? OrderDetailStatusEnum.Over.ObjToInt() : OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | if (inboundOrder.Details.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) == null) |
| | | { |
| | | inboundOrder.OrderStatus = InboundStatusEnum.入库完成.ObjToInt(); |
| | | } |
| | | else if (inboundOrder.OrderStatus == InboundStatusEnum.未开始.ObjToInt()) |
| | | { |
| | | inboundOrder.OrderStatus = InboundStatusEnum.入库中.ObjToInt(); |
| | | } |
| | | stockInfo.SerialNumber = stockInfos.Count + 1; |
| | | stockInfo.InDate = DateTime.Now; |
| | | stockInfo.StockStatus = StockStatusEmun.已入库.ObjToInt(); |
| | | stockInfoDetail.Status = StockStatusEmun.已入库.ObjToInt(); |
| | | locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = string.Empty; |
| | | Db.Ado.BeginTran(); |
| | | #region 任务和入库单 |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | if (inboundOrder.OrderStatus != InboundStatusEnum.入库完成.ObjToInt()) |
| | | { |
| | | _inboundService.InbounOrderService.Repository.UpdateData(inboundOrder); |
| | | _inboundService.InboundOrderDetailService.Repository.UpdateData(inboundOrderDetail); |
| | | } |
| | | else |
| | | { |
| | | List<Dt_InboundOrderDetail> orderDetails = inboundOrder.Details; |
| | | inboundOrder.Details = null; |
| | | _inboundService.InbounOrderService.Repository.DeleteAndMoveIntoHty(inboundOrder, OperateType.自动完成); |
| | | _inboundService.InboundOrderDetailService.Repository.DeleteAndMoveIntoHty(orderDetails, OperateType.自动完成); |
| | | } |
| | | #endregion |
| | | _basicService.LocationInfoService.Repository.UpdateData(locationInfo); |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | _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); |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 验证数据 |
| | | /// </summary> |
| | | /// <param name="stockInfo"></param> |
| | | /// <param name="locationInfo"></param> |
| | | /// <returns></returns> |
| | | private (bool, string) CheckCompleted(Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, bool isCheckStockDetail = true) |
| | | { |
| | | if (stockInfo == null) |
| | | { |
| | | return (false, "未找到组盘信息"); |
| | | } |
| | | |
| | | if (locationInfo == null) |
| | | { |
| | | return (false, "未找到货位信息"); |
| | | } |
| | | |
| | | if (isCheckStockDetail && (stockInfo.Details == null || stockInfo.Details.Count == 0)) |
| | | { |
| | | return (false, "未找到组盘明细信息"); |
| | | } |
| | | |
| | | return (true, "成功"); |
| | | } |
| | | |
| | | #region 入库任务完成 |
| | | public WebResponseContent InboundTaskCompleted(int taskNum) |
| | | { |
| | | try |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"货位状态不正确"); |
| | | } |
| | | int lastStatus = dt_LocationInfo.LocationStatus; |
| | | dt_LocationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | //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_InboundOrder? inboundOrder = _inboundService.InbounOrderService.Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderNo == 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(); |
| | | // 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_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); |
| | | #endregion |
| | | #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(); |
| | | // 3. 处理入库逻辑 |
| | | return ProcessInbound(task, dt_StockInfo, dt_LocationInfo); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private WebResponseContent ProcessInbound(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo) |
| | | { |
| | | int lastStatus = locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | |
| | | Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.Db.Queryable<Dt_InboundOrder>() |
| | | .Where(x => x.OrderNo == stockInfo.Details.FirstOrDefault().OrderNo) |
| | | .Includes(x => x.Details) |
| | | .First(); |
| | | |
| | | if (inboundOrder == null) return WebResponseContent.Instance.Error("未找到入库单信息"); |
| | | |
| | | Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details |
| | | .FirstOrDefault(x => x.LinId == stockInfo.Details.FirstOrDefault()?.LinId); |
| | | |
| | | if (inboundOrder.OrderType == 0 && 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 ProcessNormalInbound(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 (inboundOrder.Details.Count == 1) |
| | | { |
| | | var stockInfoDetail = stockInfo.Details.FirstOrDefault(); |
| | | SendInboundInfoToWMS(task, inboundOrder, stockInfoDetail); |
| | | } |
| | | |
| | | _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) |
| | | { |
| | | // 如果是最后一条明细 |
| | | if (inboundOrder.Details.Count == 1) |
| | | { |
| | | try |
| | | { |
| | | _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; |
| | | } |
| | | } |
| | | |
| | | // 添加历史记录 |
| | | AddInboundOrderDetailHistory(inboundOrderDetail); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | |
| | | #region Helper Methods |
| | | |
| | | private void UpdateInboundOrderDetails(Dt_StockInfo stockInfo, Dt_InboundOrder inboundOrder, |
| | | ref Dt_InboundOrderDetail inboundOrderDetail) |
| | | { |
| | | int overCount = inboundOrder.Details.Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()); |
| | | inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.LinId == stockInfo.Details.FirstOrDefault()?.LinId); |
| | | |
| | | foreach (var item in stockInfo.Details) |
| | | { |
| | | if (inboundOrderDetail == null) continue; |
| | | |
| | | inboundOrderDetail.OverInQuantity += item.StockQuantity; |
| | | |
| | | if (inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | overCount++; |
| | | } |
| | | else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = InboundStatusEnum.入库中.ObjToInt(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void UpdateTaskStatus(Dt_Task task) |
| | | { |
| | | task.TaskStatus = InTaskStatusEnum.InFinish.ObjToInt(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateType.人工完成 : OperateType.自动完成); |
| | | } |
| | | |
| | | private void UpdateLocationStatus(Dt_LocationInfo locationInfo, int lastStatus) |
| | | { |
| | | _basicService.LocationInfoService.Repository.UpdateData(locationInfo); |
| | | } |
| | | |
| | | private void UpdateStockInfo(Dt_StockInfo stockInfo) |
| | | { |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); |
| | | } |
| | | |
| | | private void AddRecords(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, int lastStatus) |
| | | { |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord( |
| | | locationInfo, lastStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); |
| | | |
| | | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord( |
| | | stockInfo, stockInfo.Details, |
| | | stockInfo.Details.Sum(x => x.StockQuantity), |
| | | stockInfo.Details.Sum(x => x.StockQuantity), |
| | | StockChangeType.Inbound, task.TaskNum); |
| | | } |
| | | |
| | | private void UpdateInboundOrder(Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) |
| | | { |
| | | if (inboundOrder != null) |
| | | { |
| | | _inboundService.InbounOrderService.UpdateData(inboundOrder); |
| | | _inboundService.InboundOrderDetailService.UpdateData(inboundOrderDetail); |
| | | } |
| | | } |
| | | |
| | | private void SendInboundInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, Dt_StockInfoDetail stockInfoDetail) |
| | | { |
| | | if (stockInfoDetail == null) return; |
| | | |
| | | var houseInboundPassBack = new HouseInboundPassBack |
| | | { |
| | | ApiType = "AsnController", |
| | | Method = "AsrsGroudingAsn", |
| | | Parameters = new List<HouseInboundPassBack.data> |
| | | { |
| | | new HouseInboundPassBack.data |
| | | { |
| | | Value = new List<data.data1> |
| | | { |
| | | new data.data1 |
| | | { |
| | | AsnNo = task.OrderNo, |
| | | InWarehouse = task.Roadway, |
| | | TransactionCode = inboundOrder.TransactionCode, |
| | | InoutType = inboundOrder.OrderType, |
| | | OrderType = inboundOrder.InoutType, |
| | | DetailList = new List<data.data1.Inbound> |
| | | { |
| | | new data.data1.Inbound |
| | | { |
| | | LinId = stockInfoDetail.LinId, |
| | | MaterielCode = stockInfoDetail.MaterielCode, |
| | | OrderQuantity = stockInfoDetail.StockQuantity, |
| | | BatchNo = stockInfoDetail.BatchNo, |
| | | FinishQty = stockInfoDetail.StockQuantity, |
| | | LocationName = task.TargetAddress |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | var authResult = AuthenticateWithWMS(); |
| | | if (authResult.IsSuccess) |
| | | { |
| | | houseInboundPassBack.Context = new Dictionary<string, string> |
| | | { |
| | | { "Ticket", authResult.Ticket }, |
| | | { "InvOrgId", authResult.InvOrgId } |
| | | }; |
| | | |
| | | HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, houseInboundPassBack, "立库入库数量回传WMS"); |
| | | } |
| | | } |
| | | |
| | | private void ProcessAllocateInboundOrder(Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) |
| | | { |
| | | // 添加历史记录 |
| | | var history = new Dt_InboundOrder_Hty |
| | | { |
| | | OrderStatus = inboundOrder.OrderStatus, |
| | | CreateType = inboundOrder.CreateType, |
| | | UpperOrderNo = inboundOrder.UpperOrderNo, |
| | | OrderNo = inboundOrder.OrderNo, |
| | | TransactionCode = inboundOrder.TransactionCode, |
| | | InoutType = inboundOrder.InoutType, |
| | | OrderType = inboundOrder.OrderType, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | _inboundOrder_HtyService.AddData(history); |
| | | |
| | | // 添加明细历史记录 |
| | | var detailHistory = 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(detailHistory); |
| | | |
| | | // 删除原数据 |
| | | _inboundService.InbounOrderService.DeleteData(inboundOrder); |
| | | _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail); |
| | | } |
| | | |
| | | private void SendAllocateInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, List<Dt_StockInfo> stockInfos) |
| | | { |
| | | |
| | | var detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockInfos.FirstOrDefault().Id); |
| | | var inventoryAllocate = new InventoryAllocate |
| | | { |
| | | ApiType = "AsnController", |
| | | Method = "AsrsGroudingAsn", |
| | | Parameters = new List<InventoryAllocate.Allocate> |
| | | { |
| | | new InventoryAllocate.Allocate |
| | | { |
| | | Value = new List<Allocate.data1> |
| | | { |
| | | new Allocate.data1 |
| | | { |
| | | 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 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | var authResult = AuthenticateWithWMS(); |
| | | if (authResult.IsSuccess) |
| | | { |
| | | inventoryAllocate.Context = new Dictionary<string, string> |
| | | { |
| | | { "Ticket", authResult.Ticket }, |
| | | { "InvOrgId", authResult.InvOrgId } |
| | | }; |
| | | |
| | | HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAllocatein, inventoryAllocate, "调拨入库数量回传WMS"); |
| | | } |
| | | } |
| | | |
| | | private void AddInboundOrderDetailHistory(Dt_InboundOrderDetail inboundOrderDetail) |
| | | { |
| | | var history = 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(history); |
| | | _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail); |
| | | } |
| | | |
| | | private (bool IsSuccess, string Ticket, string InvOrgId) AuthenticateWithWMS() |
| | | { |
| | | var authentication = new Authentication |
| | | { |
| | | ApiType = "AuthenticationController", |
| | | Parameters = new List<Parameter> |
| | | { |
| | | new Parameter { Value = "LKAdmin" }, |
| | | new Parameter { Value = "LKAdmin" } |
| | | }, |
| | | Method = "Login", |
| | | }; |
| | | |
| | | var response = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "登录WMS账号"); |
| | | |
| | | if (response.Status && response.Context != null) |
| | | { |
| | | return (true, response.Context["Ticket"].ToString(), response.Context["InvOrgId"].ToString()); |
| | | } |
| | | |
| | | return (false, null, null); |
| | | } |
| | | |
| | | #endregion |
| | | #endregion |
| | | |
| | | |
| | | |
| | | |
| | | #region//出库任务完成 |
| | | public WebResponseContent OutboundTaskCompleted(int taskNum) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到任务信息"); |
| | | } |
| | | // 1. 验证任务和获取基础数据 |
| | | var validationResult = ValidateAndGetBaseData(taskNum, out var task, out var stockInfo, |
| | | out var locationInfo, out var outStockLockInfos); |
| | | if (!validationResult.Status) return validationResult; |
| | | |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); |
| | | // 2. 处理出库订单详情 |
| | | var outboundOrderDetails = ProcessOutboundOrderDetails(outStockLockInfos); |
| | | |
| | | 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(); |
| | | // 3. 执行核心出库逻辑 |
| | | return ExecuteOutboundLogic(task, stockInfo, locationInfo, outboundOrderDetails); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | #region 私有方法 |
| | | |
| | | private WebResponseContent ValidateAndGetBaseData(int taskNum, out Dt_Task task, |
| | | out Dt_StockInfo stockInfo, out Dt_LocationInfo locationInfo, |
| | | out List<Dt_OutStockLockInfo> outStockLockInfos) |
| | | { |
| | | task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | stockInfo = null; |
| | | locationInfo = null; |
| | | outStockLockInfos = null; |
| | | return WebResponseContent.Instance.Error("未找到任务信息"); |
| | | } |
| | | var SourceAddress = task.SourceAddress; |
| | | stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); |
| | | locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == SourceAddress); |
| | | outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryData(x => x.TaskNum == taskNum); |
| | | |
| | | if (stockInfo == null) return WebResponseContent.Instance.Error("未找到库存信息"); |
| | | if (locationInfo == null) return WebResponseContent.Instance.Error("未找到货位信息"); |
| | | if (outStockLockInfos == null || outStockLockInfos.Count == 0) |
| | | return WebResponseContent.Instance.Error("未找到出库详情信息"); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | return outboundOrderDetails; |
| | | } |
| | | |
| | | private WebResponseContent ExecuteOutboundLogic(Dt_Task task, Dt_StockInfo stockInfo, |
| | | Dt_LocationInfo locationInfo, List<Dt_OutboundOrderDetail> outboundOrderDetails) |
| | | { |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | // 更新出库订单详情 |
| | | _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | |
| | | // 更新库存状态 |
| | | UpdateStockStatus(stockInfo, locationInfo); |
| | | |
| | | // 更新货位状态 |
| | | 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) // 普通出库 |
| | | { |
| | | ProcessNormalOutbound(task, stockInfo, outboundOrder, outDetail); |
| | | } |
| | | else if (outboundOrder.OrderType == 240) // 盘点出库 |
| | | { |
| | | // 盘点出库特殊处理逻辑 |
| | | } |
| | | else // 调拨出库 |
| | | { |
| | | ProcessAllocateOutbound(task, stockInfo, outboundOrder, outDetail); |
| | | } |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | private void UpdateStockStatus(Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo) |
| | | { |
| | | stockInfo.LocationCode = locationInfo.LocationCode; |
| | | stockInfo.StockStatus = StockStatusEmun.出库完成.ObjToInt(); |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | } |
| | | |
| | | private void UpdateLocationStatus(Dt_LocationInfo locationInfo) |
| | | { |
| | | int beforeStatus = locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | _basicService.LocationInfoService.Repository.UpdateData(locationInfo); |
| | | } |
| | | |
| | | private void CompleteTask(Dt_Task task) |
| | | { |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成); |
| | | } |
| | | |
| | | private void AddStatusChangeRecord(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo) |
| | | { |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord( |
| | | locationInfo, |
| | | locationInfo.LocationStatus, |
| | | StockChangeType.Outbound.ObjToInt(), |
| | | stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", |
| | | task.TaskNum); |
| | | } |
| | | |
| | | private void ProcessNormalOutbound(Dt_Task task, Dt_StockInfo stockInfo, |
| | | Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail outDetail) |
| | | { |
| | | var stockInfoDetail = _stockRepository.StockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>() |
| | | .Where(x => x.StockId == stockInfo.Id).First(); |
| | | |
| | | if (outboundOrder.Details.Count == 1) |
| | | { |
| | | MoveOutboundOrderToHistory(outboundOrder); |
| | | } |
| | | |
| | | MoveOutboundDetailToHistory(outDetail); |
| | | |
| | | // 发送出库信息到WMS |
| | | SendNormalOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); |
| | | |
| | | // 删除库存信息 |
| | | DeleteStockInfo(stockInfo); |
| | | } |
| | | |
| | | private void ProcessAllocateOutbound(Dt_Task task, Dt_StockInfo stockInfo, |
| | | Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail outDetail) |
| | | { |
| | | var relatedStockInfos = _stockService.StockInfoService.Repository.QueryData(x => x.BatchNo == outDetail.BatchNo); |
| | | |
| | | if (outboundOrder.Details.Count == 1) |
| | | { |
| | | MoveOutboundOrderToHistory(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) |
| | | { |
| | | var detailHistory = new Dt_OutboundOrderDetail_Hty |
| | | { |
| | | OrderId = outDetail.OrderId, |
| | | MaterielCode = outDetail.MaterielCode, |
| | | MaterielName = outDetail.MaterielName, |
| | | BatchNo = outDetail.BatchNo, |
| | | OrderQuantity = outDetail.OrderQuantity, |
| | | OrderDetailStatus = outDetail.OrderDetailStatus, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | _outboundOrderDetail_HtyService.AddData(detailHistory); |
| | | _outboundService.OutboundOrderService.DeleteData(outDetail); |
| | | } |
| | | |
| | | private void SendNormalOutboundToWMS(Dt_Task task, Dt_OutboundOrder outboundOrder, |
| | | Dt_StockInfoDetail stockInfoDetail, Dt_OutboundOrderDetail outDetail) |
| | | { |
| | | var passBack = new HouseoutboundPassBack |
| | | { |
| | | ApiType = "ShippingOrderController", |
| | | Method = "AsrsOutboundSO", |
| | | Parameters = new List<HouseoutboundPassBack.datas> |
| | | { |
| | | new HouseoutboundPassBack.datas |
| | | { |
| | | Value = new List<HouseoutboundPassBack.datas.data1> |
| | | { |
| | | new HouseoutboundPassBack.datas.data1 |
| | | { |
| | | No = outboundOrder.OrderNo, |
| | | OutWareHouse = task.Roadway, |
| | | TransactionCode = outboundOrder.TransactionCode, |
| | | InoutType = outboundOrder.OrderType, |
| | | OrderType = outboundOrder.InoutType, |
| | | DetailList = new List<HouseoutboundPassBack.datas.data1.Inbound> |
| | | { |
| | | 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 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | var authResult = AuthenticateWithWMS(); |
| | | if (authResult.IsSuccess) |
| | | { |
| | | passBack.Context = new Dictionary<string, string> |
| | | { |
| | | { "Ticket", authResult.Ticket }, |
| | | { "InvOrgId", authResult.InvOrgId } |
| | | }; |
| | | |
| | | HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, passBack, "立库入库数量回传WMS"); |
| | | } |
| | | } |
| | | |
| | | private void SendAllocateOutboundToWMS(Dt_Task task, Dt_OutboundOrder outboundOrder, |
| | | Dt_OutboundOrderDetail outDetail, List<Dt_StockInfo> stockInfos) |
| | | { |
| | | var allocate = new InventoryAllocate |
| | | { |
| | | ApiType = "InventoryAllocateController", |
| | | Method = "AsrsFinishedStockCount", |
| | | Parameters = new List<Allocate> |
| | | { |
| | | new Allocate |
| | | { |
| | | Value = new List<Allocate.data1> |
| | | { |
| | | new Allocate.data1 |
| | | { |
| | | No = outboundOrder.OrderNo, |
| | | InWarehouse = task.Roadway, |
| | | TransactionCode = outboundOrder.TransactionCode, |
| | | InoutType = outboundOrder.OrderType, |
| | | OrderType = outboundOrder.InoutType, |
| | | DetailList = stockInfos.Select(item => |
| | | { |
| | | var detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == item.Id); |
| | | return new Allocate.data1.Inventory |
| | | { |
| | | LinId = outDetail.LinId, |
| | | LPN_No = item.PalletCode, |
| | | MaterielCode = detail.MaterielCode, |
| | | OrderQuantity = detail.OutboundQuantity, |
| | | BatchNo = detail.BatchNo, |
| | | FinishQty = detail.OutboundQuantity, |
| | | LocationName = task.SourceAddress |
| | | }; |
| | | }).ToList() |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | var authResult = AuthenticateWithWMS(); |
| | | if (authResult.IsSuccess) |
| | | { |
| | | allocate.Context = new Dictionary<string, string> |
| | | { |
| | | { "Ticket", authResult.Ticket }, |
| | | { "InvOrgId", authResult.InvOrgId } |
| | | }; |
| | | |
| | | HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, allocate, "立库入库数量回传WMS"); |
| | | } |
| | | } |
| | | |
| | | private void DeleteStockInfo(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.人工完成); |
| | | } |
| | | |
| | | #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 |
| | | } |
| | | } |