zhaowc
2025-04-07 b9f7560cbe0e562a40e9515a0559a3e951f0fee6
Wms/WMS.BLL/SysServer/StorageLocatServer.cs
@@ -2,16 +2,19 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.Intrinsics.X86;
using System.Text;
using System.Threading.Tasks;
using Model.ModelDto.SysDto;
using Model.ModelVm.SysVm;
using SqlSugar;
using WMS.BLL.LogServer;
using WMS.DAL;
using WMS.Entity.BllAsnEntity;
using WMS.Entity.Context;
using WMS.Entity.DataEntity;
using WMS.Entity.SysEntity;
using WMS.IBLL.ILogServer;
using WMS.IBLL.ISysServer;
using WMS.IDAL.ISysInterface;
@@ -142,7 +145,7 @@
        {
            try
            {
                var bl = LocatRst.EditStorageLocat(model.Id, model.Status, model.Flag, model.Temperature, userId);
                var bl = LocatRst.EditStorageLocat(model.Id, model.Status, model.Flag, model.Temperature,model.Area, userId);
                return bl;
            }
@@ -295,6 +298,116 @@
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
        public bool EditStorageLocatListNew(EditLocateListNewVm model, int userId)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(model.RoadWayNo))
                {
                    throw new Exception("巷道不能为空");
                }
                bool isRow = false;
                if (model.Row != null)
                {
                    if (model.Row <= 0)
                    {
                        throw new Exception("排需要大于0");
                    }
                    isRow = true;
                }
                bool isColumn = false;
                if (model.Column != null)
                {
                    if (model.Column <= 0)
                    {
                        throw new Exception("列需要大于0");
                    }
                    isColumn = true;
                }
                bool isLayer = false;
                if (model.Layer != null )
                {
                    if (model.Column <= 0)
                    {
                        throw new Exception("层需要大于0");
                    }
                    isLayer = true;
                }
                bool isDepth = false;
                if (model.Dept != null)
                {
                    if (model.Dept != 1 && model.Dept != 2)
                    {
                        throw new Exception("深度只能为1或2");
                    }
                    isDepth = true;
                }
                Expression<Func<SysStorageLocat, bool>> item = Expressionable.Create<SysStorageLocat>() //创建表达式
                    .AndIF(isRow, it => it.Row == model.Row)
                    .AndIF(isColumn, it => it.Column == model.Column)
                    .AndIF(isLayer, it => it.Layer == model.Layer)
                    .AndIF(isDepth, it => it.Depth == "0"+model.Dept)
                    .AndIF(!string.IsNullOrWhiteSpace(model.RoadWayNo), it => it.RoadwayNo == model.RoadWayNo)
                    .ToExpression();//注意 这一句 不能少
                var locateList = Db.Queryable<SysStorageLocat>().Where(item).ToList();
                if (locateList.Count == 0)
                {
                    throw new Exception($"未查询到相对应的储位信息");
                }
                var com = new Common();
                var i = 0;
                Db.BeginTran();
                foreach (var locate in locateList)
                {
                    if (model.Flag == "2" && locate.Depth == "01")//标识是损坏且深度是01时 需把深度为2的储位给屏蔽
                    {
                        var locate2 = com.GetLocateNoDepth2(locate.WareHouseNo, locate.LocatNo);
                        if (locate2.Flag == "0" && !locateList.Contains(locate2))
                        {
                            locate2.Flag = "1";
                            locate2.UpdateUser = userId;
                            locate2.UpdateTime = DateTime.Now;
                            var m = Db.Updateable(locate2).ExecuteCommand();
                        }
                    }
                    if (model.Flag == "0" && locate.Depth == "02")//标识是正常且深度是02时 需判断深度为1的储位状态是否正常
                    {
                        var locate1 = com.GetLocateNoDepth1(locate.WareHouseNo, locate.LocatNo);
                        if (locate1.Flag == "2")
                        {
                            throw new Exception($"需先修改{locate1.LocatNo}的储位标识为不是损坏");
                        }
                    }
                    if (!string.IsNullOrEmpty(model.Status))
                    {
                        locate.Status = model.Status;
                    }
                    if (!string.IsNullOrEmpty(model.Flag))
                    {
                        locate.Flag = model.Flag;
                    }
                    if (!string.IsNullOrEmpty(model.AreaNo))
                    {
                        locate.AreaNo = model.AreaNo;
                    }
                    locate.UpdateUser = userId;
                    locate.UpdateTime = DateTime.Now;
                    i = Db.Updateable(locate).ExecuteCommand();
                }
                Db.CommitTran();
                return i > 0;
            }
            catch (Exception e)
            {
                Db.RollbackTran();
                throw new Exception(e.Message);
            }
        }
@@ -683,6 +796,7 @@
            try
            {
                LocateInfoVm model = new LocateInfoVm();
                string status = "";
                //储位信息
                SysStorageLocat storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == locatNo && w.IsDel == "0");
                if (storageLocat == null)
@@ -710,6 +824,19 @@
                        goodsModel.SkuName = item.SkuName;
                        goodsModel.LotNo = item.LotNo;
                        goodsModel.Qty = item.Qty;
                        switch (item.InspectStatus)
                        {
                            case "0":
                                status = "待检验";
                                break;
                            case "1":
                                status = "合格";
                                break;
                            case "2":
                                status = "不合格";
                                break;
                        }
                        goodsModel.InspectStatus = status;
                        goodsList.Add(goodsModel);
                    }
@@ -743,6 +870,7 @@
                        goodsModel.SkuName = noticeDetail.SkuName;
                        goodsModel.LotNo = noticeDetail.LotNo;
                        goodsModel.Qty = noticeDetail.Qty;
                        goodsModel.InspectStatus = "待检验";
                        goodsList.Add(goodsModel);
                    }