| | |
| | | using System.Reflection.Metadata; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_BasicRepository; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | |
| | | { |
| | | 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); |
| | | |
| | | if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) |
| | | 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()) |
| | | { |
| | | 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(); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | dt_StockInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt(); |
| | | |
| | | } |
| | | dt_StockInfo.LocationCode = dt_LocationInfo.LocationCode; |
| | | _unitOfWorkManage.BeginTran(); |
| | | task.TaskStatus = InTaskStatusEnum.InFinish.ObjToInt(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateType.人工完成 : OperateType.自动完成); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | 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(); |
| | | |
| | | _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); |
| | | _unitOfWorkManage.CommitTran(); |
| | | Dt_StockInfoDetail stockInfoDetail = _stockRepository.StockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.StockId == dt_StockInfo.Id).First(); |
| | | Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderNo == stockInfoDetail.OrderNo).Includes(x => x.Details).First(); |
| | | Dt_InboundOrderDetail inboundOrderDetail = _inboundService.InboundOrderDetailService.Repository.QueryFirst(x => x.OrderId == inboundOrder.Id); |
| | | //判断单据类型是入库还是调拨入库。。。入库 |
| | | if (inboundOrder.OrderType == 0) |
| | | { |
| | | #region //判断入库单据明细只有最后一条完成时删除入库单 |
| | | |
| | | |
| | | |
| | | if (inboundOrder.Details.Count == 1) |
| | | { |
| | | Dt_InboundOrder_Hty inboundOrder_Hty = new Dt_InboundOrder_Hty |
| | | 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 |
| | | { |
| | | 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, |
| | | LinId = stockInfoDetail.LinId, |
| | | MaterielCode = stockInfoDetail.MaterielCode, |
| | | OrderQuantity = stockInfoDetail.StockQuantity, |
| | | BatchNo = stockInfoDetail.BatchNo, |
| | | FinishQty = stockInfoDetail.StockQuantity, |
| | | LocationName = task.TargetAddress |
| | | }; |
| | | _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> |
| | | 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"); |
| | | 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 |
| | | } |
| | | #endregion |
| | | } |
| | | else |
| | | { |