dengjunjie
4 天以前 bea5e8a7d4d764ec0eb35e766a879e85a1424ca4
н¨Îļþ¼Ð/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/DeliveryOrderServices.cs
@@ -60,6 +60,11 @@
            _materielInfoService = materielInfoService;
            _locationInfoService = locationInfoService;
        }
        public override WebResponseContent UpdateData(SaveModel saveModel)
        {
            return base.UpdateData(saveModel);
        }
        #region åˆ›å»ºå‡ºåº“单
        /// <summary>
        /// åˆ›å»ºå‡ºåº“单
@@ -350,7 +355,7 @@
                            #region æ•´ä»¶ä¼˜å…ˆåˆ†é…å¤§ä»¶åº“,计划库存,添加出库任务
                            foreach (var item in dt_InventoryInfos.Where(x => x.WarehouseCode == WareCodeDJ))
                            {
                                if (xs <= 0) break;
                                if (xs <= 0 || item.AvailableQuantity <= 0) break;
                                decimal outqty = 0;
                                while (item.AvailableQuantity > 0 && xs > 0)
                                {
@@ -431,7 +436,9 @@
                            if (orderDetailLK != null)
                            {
                                #region æ·»åŠ å‡ºåº“ä»»åŠ¡ã€ä¿®æ”¹åº“å­˜ä¿¡æ¯
                                Dt_InventoryInfo inventoryInfo = dt_InventoryInfos.Where(x => x.WarehouseCode == WareCodeLK).First();
                                Dt_InventoryInfo? inventoryInfo = dt_InventoryInfos.FirstOrDefault(x => x.WarehouseCode == WareCodeLK);
                                if (inventoryInfo == null)
                                    throw new Exception($"未找到物料编号【{detail.goods_no}】物料批次【{detail.batch_num}】在立库中的库存信息;所需数量【{orderDetailLK.Order_qty}】请补货");
                                inventoryInfo.AvailableQuantity -= orderDetailLK.Order_qty;
                                inventoryInfo.OutboundQuantity += orderDetailLK.Order_qty;
                                Dt_SupplyTask supplyTask = new Dt_SupplyTask()
@@ -464,22 +471,29 @@
                            //_supplyTaskService.AddData(supplyTasks);
                        }
                    }
                    _unitOfWorkManage.BeginTran();
                    _supplyTaskService.AddData(supplyTasks);
                    _inventory_BatchServices.UpdateData(batchesUp);
                    _inventoryInfoService.UpdateData(inventoryInfosUp);
                    if (entityOrder.Details.Count > 0)
                        BaseDal.Db.CopyNew().InsertNav(entityOrder).Include(x => x.Details).ExecuteCommand();
                    if (entityOrderLK.Details.Count > 0)
                        BaseDal.Db.CopyNew().InsertNav(entityOrderLK).Include(x => x.Details).ExecuteCommand();
                    _unitOfWorkManage.CommitTran();
                    try
                    {
                        _unitOfWorkManage.BeginTran();
                        _supplyTaskService.AddData(supplyTasks);
                        _inventory_BatchServices.UpdateData(batchesUp);
                        _inventoryInfoService.UpdateData(inventoryInfosUp);
                        if (entityOrder.Details.Count > 0)
                            BaseDal.Db.CopyNew().InsertNav(entityOrder).Include(x => x.Details).ExecuteCommand();
                        if (entityOrderLK.Details.Count > 0)
                            BaseDal.Db.CopyNew().InsertNav(entityOrderLK).Include(x => x.Details).ExecuteCommand();
                        _unitOfWorkManage.CommitTran();
                    }
                    catch (Exception ex)
                    {
                        _unitOfWorkManage.RollbackTran();
                    }
                    #endregion
                }
                webResponseContent.OK();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                _messageInfoService.AddMessageInfo(MessageGroupByEnum.OutOrderAlarm, (outorder.order_type == "3" ? "入库退货" : "正常出库") + $":单号【{outorder.order_no}】", ex.Message);
                webResponseContent.Error(ex.Message);
            }
            return webResponseContent;
@@ -541,10 +555,12 @@
                            }
                            #endregion
                            inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity;
                            inventoryInfo.AvailableQuantity = inventoryInfo.StockQuantity;
                            inventoryInfo.SupplyQuantity = 0;
                            inventoryInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt();
                        }
                        inventory_Batch.StockQuantity = inventory_Batch.SupplyQuantity;
                        inventory_Batch.AvailableQuantity = inventory_Batch.StockQuantity;
                        inventory_Batch.SupplyQuantity = 0;
                        infosUp.AddRange(inventoryInfos);
                        batchesUp.Add(inventory_Batch);
@@ -638,11 +654,13 @@
                                }
                                #endregion
                                inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity;
                                inventoryInfo.AvailableQuantity = inventoryInfo.StockQuantity;
                                inventoryInfo.SupplyQuantity = 0;
                                inventoryInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt();
                            }
                            //_inventoryInfoService.UpdateData(inventoryInfos);
                            inventory_Batch.StockQuantity = inventory_Batch.SupplyQuantity;
                            inventory_Batch.AvailableQuantity = inventory_Batch.StockQuantity;
                            inventory_Batch.SupplyQuantity = 0;
                            //_inventory_BatchServices.UpdateData(inventory_Batch);
                            infosUp.AddRange(inventoryInfos);
@@ -709,6 +727,7 @@
                                }
                                #endregion
                                inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity;
                                inventoryInfo.AvailableQuantity = inventoryInfo.StockQuantity;
                                inventoryInfo.SupplyQuantity = 0;
                                inventoryInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt();
                            }
@@ -979,12 +998,6 @@
                    inventory_Batch.OutboundQuantity -= supplyTask.StockQuantity;
                }
                #endregion
                if (supplyTask.WarehouseCode == WarehouseEnum.立库.ObjToInt().ToString("000"))
                {
                    materielInfo.Business_qty -= supplyTask.StockQuantity;
                    if (materielInfo.Business_qty < materielInfo.MinQty)
                        CreateAllocatInOut(materielInfo);//创建调拨任务
                }
                supplyTask.TaskStatus = SupplyStatusEnum.OutFinish.ObjToInt();
                _unitOfWorkManage.BeginTran();
@@ -1000,13 +1013,21 @@
                if (location != null) _locationInfoService.UpdateData(location);
                _deliveryOrderDetailServices.UpdateData(cabinOrderDetail);
                _supplyTaskService.Repository.DeleteAndMoveIntoHty(supplyTask, OperateTypeEnum.人工完成);
                _unitOfWorkManage.CommitTran();
                #region åˆ¤æ–­è¯¦æƒ…是否全部完成
                if (!_deliveryOrderDetailServices.Repository.QueryData(x => x.DeliveryOrderId == deliveryOrder.Id && x.OotDetailStatus != "已完成").Any())
                    deliveryOrder.OutStatus = "已完成";
                BaseDal.UpdateData(deliveryOrder);
                if (supplyTask.WarehouseCode == WarehouseEnum.立库.ObjToInt().ToString("000"))
                {
                    materielInfo.Business_qty -= supplyTask.StockQuantity;
                    if (materielInfo.Business_qty < materielInfo.MinQty)
                        CreateAllocatInOut(materielInfo);//创建调拨任务
                }
                #endregion
                _unitOfWorkManage.CommitTran();
                content.OK();
            }
            catch (Exception ex)
            {
@@ -1144,6 +1165,7 @@
                else
                {
                    var url = "http://121.37.118.63:80/GYZ2/95fck/outOrderOk";
                    if (deliveryOrder.Out_type == "3") url = "http://121.37.118.63:80/GYZ2/95fck/inOrderOk";
                    var requestDate = new
                    {
                        order_no = deliveryOrder.Out_no
@@ -1151,7 +1173,7 @@
                    var result = HttpHelper.Post(url, requestDate.ToJsonString());
                    var response = JsonConvert.DeserializeObject<UpstreamOrderResponse>(result);
                    if (response == null) throw new Exception("上报ERP出库单完成失败!");
                    if (response.resultCode != "0") throw new Exception(response.resultMsg);
                    if (response.resultCode != "0" && response.resultMsg != "未找到合法单据") throw new Exception(response.resultMsg);
                    _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(deliveryOrderDetails, OperateTypeEnum.人工完成);
                    BaseDal.DeleteAndMoveIntoHty(deliveryOrders, OperateTypeEnum.人工完成);
                }