zhaowc
2025-05-20 d09a1552e45e6cfc8f83c0249cd296b8706c0dc2
Wms/WMS.BLL/SysServer/PalletsServer.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Security.Policy;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -9,6 +10,7 @@
using Model.ModelDto.LogDto;
using Model.ModelDto.SysDto;
using SqlSugar;
using Utility.Tools;
using WMS.BLL.LogServer;
using WMS.Entity.Context;
using WMS.Entity.DataEntity;
@@ -121,7 +123,7 @@
        /// <param name="locatNo"></param>
        /// <param name="userId"></param>
        /// <exception cref="Exception"></exception>
        public void AddPallets(string palletNo,string locatNo, string deviceCode, int userId)
        public void AddPallets(string palletNo,string locatNo, string deviceCode, string url, int userId)
        {
            var db = DataContext.Db;
            try
@@ -157,31 +159,50 @@
                {
                    throw new Exception("新添加的桶只能绑定净桶区");
                }
                //if (!string.IsNullOrEmpty(deviceCode))
                //{
                //    var areaInfo = db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.DeviceCode.Contains(deviceCode));
                //    if (areaInfo == null)
                //    {
                //        throw new Exception("未查到设备所属区域信息");
                //    }
                //    //125设备是接料和混料一体机
                //    if (deviceCode != "125")
                //    {
                //        if (!areaInfo.AreaName.Contains("接料设备"))
                //        {
                //            throw new Exception("只能绑定接料设备");
                //        }
                //        if (areaInfo.WareHouseNo != "M03")
                //        {
                //            throw new Exception("只有大单体车间才能绑定设备");
                //        }
                //    }
                //}
                if (!string.IsNullOrEmpty(deviceCode))
                {
                    var areaInfo = db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.DeviceCode.Contains(deviceCode));
                    if (areaInfo == null)
                    switch (deviceCode)
                    {
                        throw new Exception("未查到设备所属区域信息");
                        case "400":
                            deviceCode = "400L";
                            break;
                        case "800":
                            deviceCode = "800L";
                            break;
                        case "1000":
                            deviceCode = "1000L";
                            break;
                        default:
                            throw new Exception("不能录入400,800,1000以外的值");
                    }
                    //125设备是接料和混料一体机
                    if (deviceCode != "125")
                    {
                        if (!areaInfo.AreaName.Contains("接料设备"))
                        {
                            throw new Exception("只能绑定接料设备");
                        }
                        if (areaInfo.WareHouseNo != "M03")
                        {
                            throw new Exception("只有大单体车间才能绑定设备");
                        }
                    }
                }
                //开启事务
                db.BeginTran();
                palletModel = new SysPallets();
                palletModel.PalletNo = palletNo;
                palletModel.Standard = deviceCode;
                palletModel.Type = "0";
                palletModel.Status = "0";
                palletModel.CreateUser = userId;
@@ -221,7 +242,7 @@
                    PalletStatus = "0",//净桶
                    UDF1 = deviceCode,
                    Standard = deviceCode,  //规格
                    IsDel = "0",
                    CreateUser = userId,
@@ -235,6 +256,20 @@
                locatModel.Status = "1";//有物品
                db.Updateable(locatModel).ExecuteCommand();
                //下发AGV绑定载具接口
                //调用AGV接口下发任务
                //string agvMsg = string.Empty;
                ////给下车下发任务
                //var agvResult = RcsHelper.BindPalletAndSite(palletNo, locatNo,url, out agvMsg);
                //if (agvResult)//成功
                //{
                //     //增加日志
                //}
                //else//失败
                //{
                //    throw new Exception("小车载具和库位关系绑定失败,原因:"+agvMsg);
                //}
                //提交事务
                db.CommitTran();
            }