DESKTOP-9BNTV8O
2024-12-14 ef48a7627cbb8dd2a257960a0890cebf190f75b5
Wms/WMS.BLL/BllTransServer/RcsServer.cs
@@ -56,8 +56,11 @@
                switch (model.Type)
                {
                    case "0"://叫净桶
                        //查找到该车间净桶区
                        List<string> areaNoList = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "0" && w.WareHouseNo == houseNo).Select(s=>s.AreaNo).ToList();
                        //查找净桶
                        pallet = stockDetail.Where(w => w.WareHouseNo == houseNo && w.PalletStatus == "0" && w.Status == "0"
                        && (w.AreaNo.Contains("01") || w.AreaNo.Contains("11") || w.AreaNo.Contains("21") || w.AreaNo.Contains("31"))).OrderByDescending(o => o.CreateTime).First();
                        && areaNoList.Contains(w.AreaNo)).OrderByDescending(o => o.CreateTime).First();
                        if (pallet == null)
                        {
                            throw new Exception("暂无净桶可分配");
@@ -74,9 +77,11 @@
                        {
                            throw new Exception("批次号为空!");
                        }
                        //查找到该车间预混区
                        List<string> areaNoList2 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "1" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        //查找库存中是否有可用的此批次的混料桶
                        pallet = stockDetail.Where(w => w.WareHouseNo == houseNo && w.PalletStatus == "1" && w.Status == "0" && w.LotNo == model.LotNo
                        && (w.AreaNo.Contains("02") || w.AreaNo.Contains("12") || w.AreaNo.Contains("22") || w.AreaNo.Contains("32"))).OrderByDescending(o => o.CompleteTime).First();
                        && areaNoList2.Contains(w.AreaNo)).OrderByDescending(o => o.CompleteTime).First();
                        if (pallet == null)
                        {
                            throw new Exception("暂无混料桶可分配");
@@ -112,9 +117,11 @@
                        //更新出库单
                        Db.Updateable(soNotice).ExecuteCommand();
                        //查找到该车间半成品区
                        List<string> areaNoList3 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "2" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        //查找库存中是否有此批次的合格下料桶
                        pallet = stockDetail.Where(w => w.WareHouseNo == houseNo && w.PalletStatus == "2" && w.Status == "0" && w.LotNo == model.LotNo && w.InspectStatus=="1"
                        && (w.AreaNo.Contains("03") || w.AreaNo.Contains("13") || w.AreaNo.Contains("23") || w.AreaNo.Contains("33"))).OrderByDescending(o => o.CompleteTime).First();
                        && areaNoList3.Contains(w.AreaNo)).OrderByDescending(o => o.CompleteTime).First();
                        if (pallet == null)
                        {
                            throw new Exception("暂无下料桶可分配");
@@ -126,8 +133,10 @@
                        taskMsg = "设备叫料桶下料任务";
                        break;
                    case "3"://叫脏桶
                        //查找到该车间脏桶区
                        List<string> areaNoList4 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "3" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        List<DataStockDetail> palletList = stockDetail.Where(w => w.WareHouseNo == houseNo && w.PalletStatus == "3" && w.Status == "0"
                        && (w.AreaNo.Contains("03") || w.AreaNo.Contains("13") || w.AreaNo.Contains("23") || w.AreaNo.Contains("33"))).OrderByDescending(o => o.CompleteTime).ToList();
                        && areaNoList4.Contains(w.AreaNo)).OrderByDescending(o => o.CompleteTime).ToList();
                        if (palletList.Count <= 0)
                        {
                            throw new Exception("暂无脏桶可分配");
@@ -348,7 +357,9 @@
                switch (model.Type)
                {
                    case "3"://清洗设备申请储位(净桶申请储位)
                        loction = storageLocat.Where(w => w.WareHouseNo == houseNo && (w.AreaNo.Contains("01") || w.AreaNo.Contains("11") || w.AreaNo.Contains("21") || w.AreaNo.Contains("31"))).OrderByDescending(o => o.CreateTime).First();
                        //查找到该车间净桶区
                        List<string> areaNoList = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "0" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        loction = storageLocat.Where(w => w.WareHouseNo == houseNo && areaNoList.Contains(w.AreaNo)).OrderByDescending(o => o.CreateTime).First();
                        if (loction == null)
                        {
                            throw new Exception("该车间净桶区暂无空余储位");
@@ -362,7 +373,9 @@
                        {
                            throw new Exception("批次号为空!");
                        }
                        loction = storageLocat.Where(w => w.WareHouseNo == houseNo && (w.AreaNo.Contains("02") || w.AreaNo.Contains("12") || w.AreaNo.Contains("22") || w.AreaNo.Contains("32"))).OrderByDescending(o => o.CreateTime).First();
                        //查找到该车间预混区
                        List<string> areaNoList2 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "1" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        loction = storageLocat.Where(w => w.WareHouseNo == houseNo && areaNoList2.Contains(w.AreaNo)).OrderByDescending(o => o.CreateTime).First();
                        if (loction == null)
                        {
                            throw new Exception("该车间预混区暂无空余储位");
@@ -393,7 +406,9 @@
                        //更新入库单状态
                        Db.Updateable(notice).ExecuteCommand();
                        loction = storageLocat.Where(w => w.WareHouseNo == houseNo && (w.AreaNo.Contains("03") || w.AreaNo.Contains("13") || w.AreaNo.Contains("23") || w.AreaNo.Contains("33"))).OrderByDescending(o => o.CreateTime).First();
                        //查找到该车间半成品区
                        List<string> areaNoList3 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "2" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        loction = storageLocat.Where(w => w.WareHouseNo == houseNo && areaNoList3.Contains(w.AreaNo)).OrderByDescending(o => o.CreateTime).First();
                        if (loction == null)
                        {
                            throw new Exception("该车间半成品区暂无空余储位");
@@ -402,7 +417,9 @@
                        taskMsg = "接料设备(混料桶)申请储位任务";
                        break;
                    case "2"://下料设备申请储位(脏桶申请储位)
                        loction = storageLocat.Where(w => w.WareHouseNo == houseNo && (w.AreaNo.Contains("04") || w.AreaNo.Contains("14") || w.AreaNo.Contains("24") || w.AreaNo.Contains("34"))).OrderByDescending(o => o.CreateTime).First();
                        //查找到该车间脏桶区
                        List<string> areaNoList4 = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Type == "3" && w.WareHouseNo == houseNo).Select(s => s.AreaNo).ToList();
                        loction = storageLocat.Where(w => w.WareHouseNo == houseNo && areaNoList4.Contains(w.AreaNo)).OrderByDescending(o => o.CreateTime).First();
                        if (loction == null)
                        {
                            throw new Exception("该车间脏桶区暂无空余储位");
@@ -617,7 +634,8 @@
            //下车任务单
            AgvSchedulingTask agvTask = new AgvSchedulingTask();
            agvTask.reqCode = taskDetial.Taskno;//任务号
            agvTask.reqCode = taskDetial.Taskno;//请求编号
            agvTask.taskCode= taskDetial.Taskno;//任务号
            agvTask.ctnrCode = taskDetial.Pallno;//桶号
            agvTask.ctnrTyp = "1";
            agvTask.reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//请求时间                
@@ -737,26 +755,33 @@
                //修改目标储位状态
                Db.Updateable(endLocatInfo).ExecuteCommand();
                //目标储位所属区域
                var endAreaInfo = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.WareHouseNo == endLocatInfo.WareHouseNo && w.AreaNo == endLocatInfo.AreaNo);
                if (endAreaInfo == null)
                {
                    throw new Exception($"目标储位所属区域信息不存在");
                }
                stockDetail.WareHouseNo = endLocatInfo.WareHouseNo;//所属仓库
                stockDetail.RoadwayNo = endLocatInfo.RoadwayNo;//所属巷道
                stockDetail.AreaNo = endLocatInfo.AreaNo;//所属区域
                stockDetail.LocatNo = endLocatInfo.LocatNo;//储位地址               
                if (endLocatInfo.AreaNo.Contains("01") || endLocatInfo.AreaNo.Contains("11") || endLocatInfo.AreaNo.Contains("21") || endLocatInfo.AreaNo.Contains("31"))//洁净区
                if (endAreaInfo.Type=="0")//洁净区
                {
                    stockDetail.PalletStatus = "0";
                    stockDetail.Status = "0";//待分配
                }
                else if (endLocatInfo.AreaNo.Contains("02") || endLocatInfo.AreaNo.Contains("12") || endLocatInfo.AreaNo.Contains("22") || endLocatInfo.AreaNo.Contains("32"))//预混区
                else if (endAreaInfo.Type == "1")//预混区
                {
                    stockDetail.PalletStatus = "1";
                    stockDetail.Status = "0";//待分配
                }
                else if (endLocatInfo.AreaNo.Contains("03") || endLocatInfo.AreaNo.Contains("13") || endLocatInfo.AreaNo.Contains("23") || endLocatInfo.AreaNo.Contains("33"))//半成品区
                else if (endAreaInfo.Type == "2")//半成品区
                {
                    stockDetail.PalletStatus = "2";
                    stockDetail.Status = "0";//待分配
                }
                else if (endLocatInfo.AreaNo.Contains("04") || endLocatInfo.AreaNo.Contains("14") || endLocatInfo.AreaNo.Contains("24")|| endLocatInfo.AreaNo.Contains("34"))//脏桶区
                else if (endAreaInfo.Type == "3")//脏桶区
                {
                    stockDetail.PalletStatus = "3";
                    stockDetail.LotNo = "";//批次