wangxinhui
2 天以前 2c889b38311883ceb703c4e0034c798fdaa2e21c
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs
@@ -16,6 +16,7 @@
using WIDESEA_Common.TaskEnum;
using WIDESEA_Common.WareHouseEnum;
using WIDESEA_Core;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
using WIDESEA_DTO;
using WIDESEA_DTO.MES;
@@ -60,7 +61,7 @@
                {
                    return WebResponseContent.Instance.Error($"未找到组盘信息");
                }
                if (stockInfo.StockStatus != StockStatusEmun.组盘暂存.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.手动组盘暂存.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.拣选完成.ObjToInt())
                if (stockInfo.StockStatus != StockStatusEmun.组盘暂存.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.手动组盘暂存.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.拣选完成.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.送检库存完成.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.盘点库存完成.ObjToInt())
                {
                    return WebResponseContent.Instance.Error($"该托盘状态不正确,不可申请入库");
                }
@@ -99,6 +100,7 @@
                        PalletType = stockInfo.PalletType,
                        MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode,
                        Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity),
                        BatchNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo
                    };
                    //获取是否存在入库单
                    Dt_InboundOrder? inboundOrder =  null;
@@ -134,6 +136,16 @@
                        stockInfo.StockStatus = StockStatusEmun.入库确认.ObjToInt();
                        newTask.TaskType = TaskTypeEnum.InPick.ObjToInt();
                    }
                    else if (stockInfo.StockStatus == StockStatusEmun.送检库存完成.ObjToInt())
                    {
                        stockInfo.StockStatus = StockStatusEmun.手动组盘入库确认.ObjToInt();
                        newTask.TaskType = TaskTypeEnum.InQuality.ObjToInt();
                    }
                    else if(stockInfo.StockStatus == StockStatusEmun.盘点库存完成.ObjToInt())
                    {
                        stockInfo.StockStatus = StockStatusEmun.手动组盘入库确认.ObjToInt();
                        newTask.TaskType = TaskTypeEnum.InInventory.ObjToInt();
                    }
                    else
                    {
                        stockInfo.StockStatus = StockStatusEmun.入库确认.ObjToInt();
@@ -162,7 +174,52 @@
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        /// <summary>
        /// æŸ¥è¯¢è´¨æ£€æ•°é‡
        /// </summary>
        /// <param name="palletCode">托盘号</param>
        /// <returns></returns>
        public WebResponseContent InQualityConfirm(string palletCode)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(palletCode);
                if (stockInfo == null)
                {
                    return content.Error($"未找到该托盘库存信息");
                }
                if (stockInfo.Details.Count<=0)
                {
                    return content.Error($"该托盘库存明细为空");
                }
                if (stockInfo.StockStatus != StockStatusEmun.送检库存完成.ObjToInt())
                {
                    return content.Error($"该托盘还未送检检验完成");
                }
                Dt_OutStockLockInfo? outStockLockInfo = _outboundRepository.OutboundStockLockInfoRepository.QueryData(x => x.PalletCode == palletCode && x.Status == OutLockStockStatusEnum.出库完成.ObjToInt() && x.OrderType== OutOrderTypeEnum.Quality.ObjToInt()).OrderByDescending(x=>x.Id).FirstOrDefault();
                if (outStockLockInfo != null)
                {
                    //获取对应检验单
                    Dt_CheckOrder checkOrder = _checkOrderRepository.QueryFirst(x=>x.ReceiveDetailRowNo== outStockLockInfo.Id && x.CheckOrderStatus==CheckOrderStatusEnum.Checked.ObjToInt());
                    if (checkOrder == null)
                    {
                        return content.Error($"该托盘送检信息未检");
                    }
                    content.OK("成功", data:new { stockInfo.Details.FirstOrDefault()?.MaterielCode,checkOrder.ReceivedQuantity,checkOrder.ScrappedQuantity,checkOrder.DefectedQuantity,checkOrder.QualifiedQuantity,stockQuantity= stockInfo.Details.Sum(x=>x.StockQuantity) }) ;
                }
                else
                {
                    content.Error("该托盘送检出库详情不存在");
                }
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// å…¥ç©ºç®±
        /// </summary>
@@ -219,7 +276,7 @@
                _stockRepository.StockInfoRepository.AddData(stockInfo);
                _unitOfWorkManage.CommitTran();
                PushTasksToWCS(new List<Dt_Task> { newTask });
                PutFinish(address, newTask.PalletCode, newTask.TaskNum.ToString());
                //PutFinish(address, newTask.PalletCode, newTask.TaskNum.ToString());
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
@@ -339,10 +396,12 @@
                    };
                    string MaterielCodeGMPP = stockInfoPPorGM.Details?.Where(x => x.StockId == stockInfoPPorGM.Id).FirstOrDefault()?.MaterielCode;
                    float QuantityGMPP = (float)stockInfoPPorGM.Details?.Where(x => x.StockId == stockInfoPPorGM.Id).Sum(x => x.StockQuantity);
                    if (MaterielCodeGMPP != null && QuantityGMPP != null)
                    string batchNo = stockInfoPPorGM.Details?.Where(x => x.StockId == stockInfoPPorGM.Id).FirstOrDefault()?.BatchNo;
                    if (MaterielCodeGMPP != null && QuantityGMPP != null && batchNo != null)
                    {
                        newTaskPPorGM.MaterielCode = MaterielCodeGMPP;
                        newTaskPPorGM.Quantity = QuantityGMPP;
                        newTaskPPorGM.BatchNo = batchNo;
                    }
                    //获取是否存在入库单
@@ -382,7 +441,7 @@
                {
                    return WebResponseContent.Instance.Error($"未找到组盘信息");
                }
                if (stockInfo.StockStatus != StockStatusEmun.组盘暂存.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.手动组盘暂存.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.出库完成.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.拣选完成.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.退库.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES退库.ObjToInt())
                if (stockInfo.StockStatus != StockStatusEmun.组盘暂存.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.手动组盘暂存.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.出库完成.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.拣选完成.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.退库.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES退库.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.送检库存完成.ObjToInt() && stockInfo.StockStatus!=StockStatusEmun.盘点库存完成.ObjToInt())
                {
                    return WebResponseContent.Instance.Error($"该托盘状态不正确,不可申请入库");
                }
@@ -413,10 +472,12 @@
                };
                string MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
                float Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
                if (MaterielCode != null && Quantity != null)
                string BatchNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo;
                if (MaterielCode != null && Quantity != null && BatchNo != null)
                {
                    newTask.MaterielCode = MaterielCode;
                    newTask.Quantity = Quantity;
                    newTask.BatchNo = BatchNo;
                }
                //获取是否存在入库单
@@ -451,6 +512,16 @@
                    stockInfo.StockStatus = StockStatusEmun.入库确认.ObjToInt();
                    newTask.TaskType = TaskTypeEnum.InPick.ObjToInt();
                }
                else if (stockInfo.StockStatus == StockStatusEmun.送检库存完成.ObjToInt())
                {
                    stockInfo.StockStatus = StockStatusEmun.手动组盘入库确认.ObjToInt();
                    newTask.TaskType = TaskTypeEnum.InQuality.ObjToInt();
                }
                else if (stockInfo.StockStatus == StockStatusEmun.盘点库存完成.ObjToInt())
                {
                    stockInfo.StockStatus = StockStatusEmun.手动组盘入库确认.ObjToInt();
                    newTask.TaskType = TaskTypeEnum.InInventory.ObjToInt();
                }
                else
                {
                    stockInfo.StockStatus = StockStatusEmun.入库确认.ObjToInt();
@@ -467,7 +538,7 @@
                WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask);
                PushTasksToWCS(new List<Dt_Task> { newTask });
                if (newTask.WarehouseId == 5) PutFinish(stationCode.ToString(),newTask.PalletCode, newTask.TaskNum.ToString());
                //if (newTask.WarehouseId == 5) PutFinish(stationCode.ToString(),newTask.PalletCode, newTask.TaskNum.ToString());
                return WebResponseContent.Instance.OK(data: wMSTaskDTO);
            }
            catch (Exception ex)
@@ -528,10 +599,12 @@
                };
                string MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
                float Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
                if (MaterielCode != null && Quantity != null)
                string BatchNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo;
                if (MaterielCode != null && Quantity != null && BatchNo != null)
                {
                    newTask.MaterielCode = MaterielCode;
                    newTask.Quantity = (float)Quantity;
                    newTask.Quantity = Quantity;
                    newTask.BatchNo = BatchNo;
                }
                if (stockInfo.StockStatus == StockStatusEmun.手动组盘暂存.ObjToInt())
@@ -544,8 +617,9 @@
                }
                else if (stockInfo.StockStatus == StockStatusEmun.MES空托退库.ObjToInt())
                {
                    Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x=>x.WarehouseId==stockInfo.WarehouseId && x.PalletType==stockInfo.PalletType);
                    //todo å°æ‰˜ç›˜æš‚时未启用
                    if (stockInfo.PalletType == PalletTypeEnum.MediumPallet.ObjToInt())
                    if (palletTypeInfo.LocaitonCount==2)
                    {
                        newTask.TaskType = TaskTypeEnum.MesPalletLargeReturn.ObjToInt();
                    }
@@ -567,7 +641,7 @@
                WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask);
                PushTasksToWCS(new List<Dt_Task> { newTask });
                if (newTask.WarehouseId == 5) PutFinish(stationCode, newTask.PalletCode, newTask.TaskNum.ToString());
                //if (newTask.WarehouseId == 5) PutFinish(stationCode, newTask.PalletCode, newTask.TaskNum.ToString());
                return WebResponseContent.Instance.OK(data: wMSTaskDTO);
            }
            catch (Exception ex)
@@ -633,10 +707,12 @@
                };
                string MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
                float Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
                if (MaterielCode != null && Quantity != null)
                string BatchNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo;
                if (MaterielCode != null && Quantity != null && BatchNo != null)
                {
                    newTask.MaterielCode = MaterielCode;
                    newTask.Quantity = Quantity;
                    newTask.BatchNo = BatchNo;
                }
                if (stockInfo.StockStatus == StockStatusEmun.手动组盘暂存.ObjToInt())
                {
@@ -777,7 +853,7 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                //获取测试架原库存信息
                //获取阻焊库存信息
                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA154.ToString());
                //获取库存记录
                List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x =>
@@ -796,21 +872,21 @@
                {
                    return content.Error($"托盘类型信息不存在");
                }
                ////获取阻焊批次
                //WebResponseContent requestLotInfo = GetZHMesMaterialLot(materialLot);
                //if (!requestLotInfo.Status)
                //{
                //    return content.Error($"请求阻焊批次信息失败,{requestLotInfo.Message}");
                //}
                //MesLotInfoModel mesLotInfo = JsonConvert.DeserializeObject<MesLotInfoModel>(requestLotInfo.Data.ToString());
                MesLotInfoModel mesLotInfo = new MesLotInfoModel()
                //获取阻焊批次
                WebResponseContent requestLotInfo = GetZHMesMaterialLot(materialLot);
                if (!requestLotInfo.Status)
                {
                    Product="FH001",
                    ProductVersion="A1",
                    Qty=20,
                    LotNo= materialLot,
                    IsFullNumber=true
                };
                    return content.Error($"请求阻焊批次信息失败,{requestLotInfo.Message}");
                }
                MesLotInfoModel mesLotInfo = JsonConvert.DeserializeObject<MesLotInfoModel>(requestLotInfo.Data.ToString());
                //MesLotInfoModel mesLotInfo = new MesLotInfoModel()
                //{
                //    Product="FH001",
                //    ProductVersion="A1",
                //    Qty=20,
                //    LotNo= materialLot,
                //    IsFullNumber=true
                //};
                Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail()
                {
                    MaterielSpec = mesLotInfo.ProductVersion,
@@ -854,6 +930,7 @@
                    WarehouseId = warehouse.WarehouseId,
                    MaterielCode = mesLotInfo.Product,
                    Quantity = (float)mesLotInfo.Qty,
                    BatchNo = mesLotInfo.LotNo
                };
                _unitOfWorkManage.BeginTran();
                Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand();
@@ -966,7 +1043,9 @@
                    WarehouseId = warePoint.WarehouseId,
                    PalletType = proStockInfo.PalletType,
                    MaterielCode = proStockInfo.proStockInfoDetails?.Where(x => x.ProStockId == proStockInfo.Id).FirstOrDefault()?.ProductCode,
                    Quantity = (float)proStockInfo.proStockInfoDetails?.Where(x => x.ProStockId == proStockInfo.Id).Sum(x => x.StockPcsQty)
                    Quantity = (float)proStockInfo.proStockInfoDetails?.Where(x => x.ProStockId == proStockInfo.Id).Sum(x => x.StockPcsQty),
                    BatchNo = proStockInfo.proStockInfoDetails?.Where(x => x.ProStockId == proStockInfo.Id).FirstOrDefault()?.LotNumber
                };
                _unitOfWorkManage.BeginTran();
                int taskId = BaseDal.AddData(newTask);