admin
10 小时以前 7be24b469c3a423c509c39cf24052ba43e7b1e77
Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs
@@ -1,29 +1,30 @@
using System;
using System.Collections.Generic;
using SqlSugar;
using System.Linq;
using System.Linq.Expressions;
using Model.InterFaceModel;
using Model.InterFaceModel;
using Model.ModelDto;
using SqlSugar.Extensions;
using WMS.Entity.BllSoEntity;
using WMS.Entity.Context;
using WMS.Entity.DataEntity;
using WMS.Entity.SysEntity;
using WMS.IBLL.IPdaServer;
using Model.ModelVm;
using Model.ModelVm.PdaVm;
using Newtonsoft.Json;
using SqlSugar;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using System.Web;
using Utility;
using Utility.Tools;
using WMS.BLL.Logic;
using WMS.BLL.LogServer;
using WMS.DAL;
using WMS.Entity.LogEntity;
using WMS.Entity.BllQualityEntity;
using WMS.Entity.BllAsnEntity;
using System.Threading.Tasks;
using Utility;
using WMS.BLL.Logic;
using System.Web;
using WMS.Entity.BllQualityEntity;
using WMS.Entity.BllSoEntity;
using WMS.Entity.Context;
using WMS.Entity.DataEntity;
using WMS.Entity.LogEntity;
using WMS.Entity.SysEntity;
using WMS.IBLL.IPdaServer;
namespace WMS.BLL.BllPdaServer
{
@@ -80,9 +81,15 @@
                {
                    throw Oops.Bah("未查询到该出库单的信息");
                }
                if (notice.Status != "3")
                //if (notice.Status != "3")
                //{
                //    throw Oops.Bah("出库单的状态不是正在执行,不能拣货");
                //}
                //2025年12月05日甲方要求超捡,出库单调整为执行完毕也可以超捡
                List<string> statusList = new List<string>() { "3", "4" };
                if (!statusList.Contains(notice.Status))
                {
                    throw Oops.Bah("出库单的状态不是正在执行,不能拣货");
                    throw Oops.Bah("出库单的状态非正在执行,不能拣货");
                }
                //出库单明细
                var noticeDetail = await Db.Queryable<BllExportNoticeDetail>().FirstAsync(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
@@ -122,18 +129,19 @@
                if (pinStockDetail != null)
                {
                    //修改托盘表状态让托盘表和库存明细表保持一致
                    string uptPalletStatusSql = $@"update SysPallets set Status='1' where PalletNo='{palletNoNew}'";
                    int uptPalletStatus = Db.Ado.ExecuteCommand(uptPalletStatusSql);
                    Db.CommitTran();
                    if (palletNo != palletNoNew)//非整托拣货                                                
                    {
                        var pinStockDetails = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.Id != pinStockDetail.Id).ToList();
                        var pinStockDetails = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNoNew).ToList();
                        ////只允许绑定同一个出库单下的物料
                        //if (pinStockDetails.Count(m => m.SONo != notice.SONo) > 0)
                        //{
                        //    throw Oops.Bah("拼托托盘上只能放同一个出库单下的物料!");
                        //}
                        //只允许绑定同一个出库单下的物料
                        if (pinStockDetails.GroupBy(e => e.SONo).Count() > 0 && pinStockDetails.Count(m => m.SONo != notice.SONo) > 0)
                        {
                            throw Oops.Bah("拼托托盘上只能放同一个出库单下的物料!");
                        }
                    }
                    sdId = pinStockDetail.Id;
@@ -150,14 +158,10 @@
                    if (newPalletInfo.Status == "0")
                    {
                        var pinStockDetails = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNoNew && (m.SkuNo != stockDetail.SkuNo || m.LotNo != stockDetail.LotNo)).ToList();
                        //if (pinStockDetails.Count(m => m.SONo != notice.SONo) > 0)
                        //{
                        //    throw Oops.Bah("一个托盘只能接受一个出库单拼托!");
                        //}
                        //只允许绑定同一个出库单下的物料
                        if (pinStockDetails.GroupBy(e => e.SONo).Count() > 0 && pinStockDetails.Count(m => m.SONo != notice.SONo) > 0)
                        if (pinStockDetails.Count(m => m.SONo != notice.SONo) > 0)
                        {
                            throw Oops.Bah("拼托托盘上只能放同一个出库单下的物料!");
                            throw Oops.Bah("新托盘信息不存在或已被使用!");
                        }
                    }
                    else
@@ -214,6 +218,10 @@
                    sd.UDF5 = "1";
                    //新增拼托库存明细信息
                    sdId = await Db.Insertable(sd).ExecuteReturnIdentityAsync();
                    //修改托盘表状态让托盘表和库存明细表保持一致
                    string uptPalletStatusSql = $@"update SysPallets set Status='1' where PalletNo='{palletNoNew}'";
                    int uptPalletStatus = Db.Ado.ExecuteCommand(uptPalletStatusSql);
                }
                #endregion
@@ -605,25 +613,36 @@
                #region 拼托信息
                bool isNew = false;
                var pinStockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.SkuNo == stockDetail.SkuNo && m.LotNo == stockDetail.LotNo);
                if (pinStockDetail != null)
                {
                    //修改托盘表状态让托盘表和库存明细表保持一致
                    string uptPalletStatusSql = $@"update SysPallets set Status='1' where PalletNo='{palletNoNew}'";
                    int uptPalletStatus = Db.Ado.ExecuteCommand(uptPalletStatusSql);
                    Db.CommitTran();
                    if (palletNo != palletNoNew)//非整托拣货
                    {
                        var pinStockDetails = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.Id != pinStockDetail.Id).ToList();
                        if (pinStockDetails.Count(m => m.SONo != notice.SONo) > 0)
                        {
                            throw Oops.Bah("拼托托盘上只能放同一个出库单下的物料!");
                        }
                        var pinStockDetails = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNoNew).ToList();
                        //if (pinStockDetails.Count(m => m.SONo != notice.SONo) > 0)
                        //{
                        //    throw Oops.Bah("拼托托盘上只能放同一个出库单下的物料!");
                        //}
                    }
                }
                else
                {
                    isNew = true;
                    var newPalletInfo = await Db.Queryable<SysPallets>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.Status == "0");
                    var newPalletInfo = await Db.Queryable<SysPallets>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNoNew);
                    if (newPalletInfo == null)
                    {
                        var pinStockDetails = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNoNew && (m.SkuNo != stockDetail.SkuNo && m.LotNo != stockDetail.LotNo)).ToList();
                        throw Oops.Bah("新托盘信息不存在!");
                    }
                    if (newPalletInfo.Status == "0")
                    {
                        //var pinStockDetails = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNoNew && (m.SkuNo != stockDetail.SkuNo && m.LotNo != stockDetail.LotNo)).ToList();
                        var pinStockDetails = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNoNew && (m.SkuNo != stockDetail.SkuNo || m.LotNo != stockDetail.LotNo)).ToList();
                        if (pinStockDetails.Count(m => m.SONo != notice.SONo) > 0)
                        {
                            throw Oops.Bah("新托盘信息不存在或已被使用!");
@@ -685,9 +704,12 @@
                        CreateTime = nowDate,
                        UDF5 = "1"
                    };
                    //新增拼托库存明细信息
                    await Db.Insertable(sd).ExecuteReturnIdentityAsync();
                    //修改托盘表状态让托盘表和库存明细表保持一致
                    string uptPalletStatusSql = $@"update SysPallets set Status='1' where PalletNo='{palletNoNew}'";
                    int uptPalletStatus = Db.Ado.ExecuteCommand(uptPalletStatusSql);
                }
                else
                {
@@ -1543,9 +1565,12 @@
                string skuNo = boxInfos.First().SkuNo;
                string skuName = boxInfos.First().SkuName;
                // 验证是否车间线边仓库
                var areaList = new List<string>() { "B06", "B07", "B09", "B24" };
                if (!areaList.Contains(stockDetail.AreaNo))
                //验证是否车间线边仓库
                string areaNoSql = $@"select AreaNo from SysStorageArea where IsDel='0' and AreaType='1'";
                DataTable areaNoDt = Db.Ado.GetDataTable(areaNoSql);
                List<string> areaNoList = areaNoDt.Rows.Cast<DataRow>().Select(e => e["AreaNo"] + "").ToList();
                if (!areaNoList.Contains(stockDetail.AreaNo))
                {
                    throw Oops.Bah("托盘不是车间托盘!");
                }
@@ -1635,10 +1660,10 @@
                    boxNo, "出库", $"在PDA上对箱号为:{boxNo}的托盘码为:{palletNo}的拣货操作", userId);
                Db.CommitTran();
            }
            catch (AppFriendlyException e)
            {
                Db.RollbackTran();
            }
            //catch (AppFriendlyException e)
            //{
            //    Db.RollbackTran();
            //}
            catch (Exception e)
            {
                Db.RollbackTran();
@@ -1701,9 +1726,12 @@
                    throw Oops.Bah("未查询到该托盘上货物的库存明细信息!");
                }
                // 验证是否车间线边仓库
                var areaList = new List<string>() { "B06", "B07", "B09", "B24" };
                if (!areaList.Contains(stockDetail.AreaNo))
                //验证是否车间线边仓库
                string areaNoSql = $@"select AreaNo from SysStorageArea where IsDel='0' and AreaType='1'";
                DataTable areaNoDt = Db.Ado.GetDataTable(areaNoSql);
                List<string> areaNoList = areaNoDt.Rows.Cast<DataRow>().Select(e => e["AreaNo"] + "").ToList();
                if (!areaNoList.Contains(stockDetail.AreaNo))
                {
                    throw Oops.Bah("托盘不是车间托盘!");
                }
@@ -1900,10 +1928,12 @@
                throw Oops.Bah("出库明细为空,请选择物料-批次");
            }
            var allotList = await Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.Status == "0" && m.SONo == soNo && m.SODetailNo == int.Parse(soDetailId)).Select(m => m.PalletNo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToListAsync();
            //var allotList = await Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.Status == "0" && m.SONo == soNo && m.SODetailNo == int.Parse(soDetailId)).Select(m => m.PalletNo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToListAsync();
            //获取状态为0待下发、1任务下发、2待拣货、3部分拣货的出库单
            List<string> statusList = new List<string>() { "0", "1", "2", "3" };
            var allotList = await Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && statusList.Contains(m.Status) && m.SONo == soNo && m.SODetailNo == int.Parse(soDetailId)).Select(m => m.PalletNo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToListAsync();
            return allotList;
        }
@@ -1913,7 +1943,8 @@
        {
            if (type == "1")//平库出库获取单据
            {
                var allotList = await Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && (m.Status == "1" || m.Status == "0")).Select(m => m.SONo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToListAsync();
                List<string> statusList = new List<string>() { "0", "1", "2", "3" };
                var allotList = await Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && statusList.Contains(m.Status)).Select(m => m.SONo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToListAsync();
                return allotList;
            }
            //获取状态为待拣货或者部分拣货的出库单
@@ -1933,8 +1964,9 @@
            {
                throw Oops.Bah("单据为空,请选择单据");
            }
            //获取状态为待拣货或者部分拣货的出库单
            var allotList = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SONo == soNo && (m.Status == "0" || m.Status == "1"));
            //获取状态为0待下发、1任务下发、2待拣货、3部分拣货的出库单
            List<string> statusList = new List<string>() { "0", "1", "2", "3" };
            var allotList = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SONo == soNo && (statusList.Contains(m.Status)));
            var list = await allotList.GroupBy(m => new { m.SODetailNo, m.SkuNo, m.SkuName, m.LotNo }).Select(m => new DetailIdSkuLotNo()
            {