zhaowc
11 小时以前 71d1dcdf796f08fa01cbc2d3faab86eea28b295b
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;
@@ -56,6 +58,7 @@
                {
                    Id = m.Id,
                    PalletNo = m.PalletNo,
                    Standard = m.Standard,
                    Type = m.Type == "0" ? "托盘" : m.Type == "1" ? "中转箱" : "",
                    Status = m.Status,
                    LastUse = m.LastUse,
@@ -120,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 status, string url, int userId)
        {
            var db = DataContext.Db;
            try
@@ -143,6 +146,18 @@
                {
                    throw new Exception("储位地址不存在");
                }
                if (locatModel.Flag == "1")
                {
                    throw new Exception("该储位已屏蔽");
                }
                var nlocat = db.Queryable<SysStorageLocat>().First(w => w.AisleOne == locatModel.LocatNo && w.IsDel == "0");
                if (nlocat != null)
                {
                    if (nlocat.Status == "0")
                    {
                        throw new Exception("请从内侧库位开始绑定");
                    }
                }
                if (locatModel.Status != "0")
                {
                    throw new Exception("该储位地址非空闲状态");
@@ -152,40 +167,55 @@
                {
                    throw new Exception("储位地址所属区域不存在");
                }
                if (!areaModel.AreaName.Contains("净桶"))
                switch (status)
                {
                    throw new Exception("新添加的桶只能绑定净桶区");
                    case "0":
                        if (!areaModel.AreaName.Contains("净桶"))
                        {
                            throw new Exception("请选择净桶区域进行绑定");
                        }
                        break;
                    case "3":
                        if (!areaModel.AreaName.Contains("脏桶"))
                        {
                            throw new Exception("请选择脏桶区域进行绑定");
                        }
                        break;
                    default:
                        throw new Exception("请选择桶类型!");
                        break;
                }
                if (!string.IsNullOrEmpty(deviceCode))
                string deviceCode = "";
                if (!string.IsNullOrEmpty(palletNo))
                {
                    var areaInfo = db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.DeviceCode.Contains(deviceCode));
                    if (areaInfo == null)
                    switch (palletNo.Substring(2,3))
                    {
                        throw new Exception("未查到设备所属区域信息");
                        case "400":
                            deviceCode = "400L";
                            break;
                        case "800":
                            deviceCode = "800L";
                            break;
                        case "100":
                            deviceCode = "1000L";
                            break;
                        default:
                            throw new Exception("桶号录入错误,请核实!");
                    }
                    //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;
                //添加桶
                db.Insertable(palletModel).ExecuteCommand();
                var comTime = DateTime.Now;
                var model = new DataStockDetail()
@@ -218,9 +248,9 @@
                    SkuName = "",
                    LotNo = "",
                    PalletStatus = "0",//净桶
                    PalletStatus = status,
                    UDF1 = deviceCode,
                    Standard = deviceCode,  //规格
                    IsDel = "0",
                    CreateUser = userId,
@@ -232,8 +262,23 @@
                //更新储位状态
                locatModel.Status = "1";//有物品
                locatModel.UpdateTime = DateTime.Now;
                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();
            }