yanjinhui
2 天以前 5d756f53f07880dc8b7ba0bc9f060b9e94d4b25e
н¨Îļþ¼Ð/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/DeliveryOrderServices.cs
@@ -240,8 +240,8 @@
                    List<Dt_SupplyTask> supplyTasks = new List<Dt_SupplyTask>();
                    List<Dt_Inventory_Batch> batchesUp = new List<Dt_Inventory_Batch>();
                    List<Dt_InventoryInfo> inventoryInfosUp = new List<Dt_InventoryInfo>();
                    var inventory_Batchs = _inventory_BatchServices.Repository.QueryData(x => entityOrder.Details.Select(e => e.Goods_no).Contains(x.MaterielCode));
                    var InventoryInfos = _inventoryInfoService.Repository.QueryData(x => entityOrder.Details.Select(e => e.Goods_no).Contains(x.MaterielCode) && x.StockStatus == StockStatusEmun.入库完成.ObjToInt() && x.AvailableQuantity > 0 && x.WarehouseCode == outorder.warehouse_no);
                    var inventory_Batchs = _inventory_BatchServices.Repository.QueryData(x => entityOrder.Details.Select(e => e.Goods_no).Contains(x.MaterielCode)).ToList();
                    var InventoryInfos = _inventoryInfoService.Repository.QueryData(x => entityOrder.Details.Select(e => e.Goods_no).Contains(x.MaterielCode) && x.StockStatus == StockStatusEmun.入库完成.ObjToInt() && x.AvailableQuantity > 0 && x.WarehouseCode == outorder.warehouse_no).ToList();
                    foreach (var item in entityOrder.Details)
                    {
                        Dt_Inventory_Batch? inventory_Batch = inventory_Batchs.Where(x => x.MaterielCode == item.Goods_no && x.BatchNo == item.Batch_num).FirstOrDefault();
@@ -317,7 +317,7 @@
                    _supplyTaskService.AddData(supplyTasks);
                    _inventory_BatchServices.UpdateData(batchesUp);
                    _inventoryInfoService.UpdateData(inventoryInfosUp);
                    BaseDal.Db.CopyNew().InsertNav(entityOrder).Include(x => x.Details).ExecuteCommand();
                    BaseDal.Db.InsertNav(entityOrder).Include(x => x.Details).ExecuteCommand();
                    _unitOfWorkManage.CommitTran();
                    #endregion
                }
@@ -610,9 +610,9 @@
                        _inventory_BatchServices.UpdateData(batchesUp);
                        _inventoryInfoService.UpdateData(inventoryInfosUp);
                        if (entityOrder.Details.Count > 0)
                            BaseDal.Db.CopyNew().InsertNav(entityOrder).Include(x => x.Details).ExecuteCommand();
                            BaseDal.Db.InsertNav(entityOrder).Include(x => x.Details).ExecuteCommand();
                        if (entityOrderLK.Details.Count > 0)
                            BaseDal.Db.CopyNew().InsertNav(entityOrderLK).Include(x => x.Details).ExecuteCommand();
                            BaseDal.Db.InsertNav(entityOrderLK).Include(x => x.Details).ExecuteCommand();
                        _unitOfWorkManage.CommitTran();
                    }
                    catch (Exception ex)
@@ -947,70 +947,6 @@
        #endregion
        //盘点 æ‹¿æ•´ä¸ªæ‰¹æ¬¡ä¿¡æ¯è¡¨çš„商品批号和商品编号来进行盘点
        public WebResponseContent InventoryGood(string batchNo, string goodsNo)
        {
            var response = new WebResponseContent();
            try
            {
                // 1️⃣ æŸ¥æ‰¾æŒ‡å®šæ‰¹æ¬¡ä¸Žç‰©æ–™çš„库存信息
                var batchInfo = BaseDal.Db.CopyNew().Queryable<Dt_Inventory_Batch>()
                    .Where(x => x.BatchNo == batchNo && x.MaterielCode == goodsNo)
                    .First();
                if (batchInfo == null)
                    return response.Error($"未找到该物料 [{goodsNo}] æ‰¹æ¬¡ [{batchNo}] çš„库存信息");
                // 2️⃣ ç»„装请求 DTO(完全符合接口文档结构)
                var ediDto = new TowcsDto.ToediOutInfo
                {
                    customerCode = "905",
                    materialCode = "YY",                              // ç‰©æ–™ç±»åž‹CODE
                    externalOrderNo = $"PDCK-{batchInfo.Id}",          // å¤–部出库单号
                    outOrderType = "20",                               // ç›˜ç‚¹å‡ºåº“单
                    priority = 1,
                    Is_cancel = 0,
                    details = new List<TowcsDto.ToeOutdiInDetail>
            {
                new TowcsDto.ToeOutdiInDetail
                {
                    batchNo = batchInfo.BatchNo,
                    productCode = batchInfo.MaterielCode,
                    productName = batchInfo.MaterielName,
                    productSpecifications = batchInfo.MaterielSpec,
                    quantity = (int)batchInfo.SupplyQuantity,
                    //stocktakingDetails = new List<TowcsDto.ToOutediInStock>
                    //{
                    //    // ç›˜ç‚¹æ˜Žç»†å¯æ ¹æ®å®žé™…托盘拆分;此处示例仅1条
                    //    new TowcsDto.ToOutediInStock
                    //    {
                    //        palletCode = "FC00001",
                    //        quantity = batchInfo.SupplyQuantity.ToString()
                    //    }
                    //}
                }
            }
                };
                // 3️⃣ è°ƒç”¨æŽ¥å£
                string url = "http://172.16.1.2:9357/file-admin/api/out/ediOut";
                var result = HttpHelper.Post(url, ediDto.ToJsonString());
                var resp = JsonConvert.DeserializeObject<TowcsDto.TowcsResponse<object>>(result);
                // 4️⃣ å“åº”处理
                if (resp == null)
                    return response.Error("WCS æ— å“åº”");
                if (resp.code != "0")
                    return response.Error($"WCS返回失败: {resp.msg}");
                return response.OK("盘点出库下发成功");
            }
            catch (Exception ex)
            {
                return response.Error("盘点失败:" + ex.Message);
            }
        }
        /// <summary>
        /// æŸ¥è¯¢å‡ºåº“单列表
@@ -1093,6 +1029,7 @@
            return content;
        }
        public WebResponseContent OutTaskFinish(Dt_SupplyTask supplyTask, Dt_DeliveryOrder deliveryOrder)
        {
            WebResponseContent content = new WebResponseContent();
@@ -1141,7 +1078,7 @@
                    _inventory_BatchServices.DeleteData(inventory_Batch);
                else
                    _inventory_BatchServices.UpdateData(inventory_Batch);
                _materielInfoService.UpdateData(materielInfo);
                //_materielInfoService.UpdateData(materielInfo);
                if (inventoryInfo.StockQuantity <= 0)
                    _inventoryInfoService.DeleteData(inventoryInfo);
                else
@@ -1158,7 +1095,15 @@
                {
                    materielInfo.Business_qty -= supplyTask.StockQuantity;
                    if (materielInfo.Business_qty < materielInfo.MinQty)
                    {
                        CreateAllocatInOut(materielInfo);//创建调拨任务
                    }
                    else
                    {
                        _materielInfoService.UpdateData(materielInfo);
                    }
                }
                #endregion
                _unitOfWorkManage.CommitTran();
@@ -1178,7 +1123,7 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_DeliveryOrder? cabinOrder = BaseDal.Db.CopyNew().Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == supplyTask.OrderNo && x.Warehouse_no == supplyTask.WarehouseCode).Includes(x => x.Details).First();
                Dt_DeliveryOrder? cabinOrder = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == supplyTask.OrderNo && x.Warehouse_no == supplyTask.WarehouseCode).Includes(x => x.Details).First();
                if (cabinOrder == null) return WebResponseContent.Instance.OK($"出库单已完成");
                Dt_DeliveryOrderDetail? cabinOrderDetail = cabinOrder.Details.Where(x => x.Batch_num == supplyTask.BatchNo && x.Reservoirarea == supplyTask.WarehouseCode && x.Goods_no == supplyTask.MaterielCode).FirstOrDefault();
@@ -1202,7 +1147,7 @@
                    //_deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(cabinOrderDetail, OperateTypeEnum.自动完成);
                }
                _deliveryOrderDetailServices.Repository.UpdateData(cabinOrderDetail);
                var cabinOrder1 = BaseDal.Db.CopyNew().Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == cabinOrder.Out_no && x.Warehouse_no == supplyTask.WarehouseCode && x.Out_type != "20").Includes(x => x.Details).First();
                var cabinOrder1 = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == cabinOrder.Out_no && x.Warehouse_no == supplyTask.WarehouseCode && x.Out_type != "20").Includes(x => x.Details).First();
                if (!cabinOrder1.Details.Where(x => x.OotDetailStatus != "已完成").Any())
                    cabinOrder.OutStatus = "已完成";
                Repository.UpdateData(cabinOrder);