111
lss
2025-07-09 00ecab4ee5cec0d04665ca16d0eb30c1ba4ea1f3
HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
@@ -47,6 +47,7 @@
        /// <returns></returns>
        internal static Result Createtask(CreateTask model)
        {
            Result result = new Result() { code = "0", msg = "创建成功" };
            if (model == null)
            {
@@ -582,6 +583,15 @@
                                AddErrorInfo("库区查找失败", result.msg);
                                return result;
                            }
                            int pri = 1;
                            var area = Settings.wareLoc.Where(a => a.AreaCode == endloc.S_WH_CODE).First();
                            if (area != null)
                            {
                                if (area.XbAreaCodes.Contains(endloc.S_AREA_CODE))
                                {
                                    pri = 2;
                                }
                            }
                            //创建wcs任务
                            var wcsTask = new WCSTask
                            {
@@ -596,7 +606,7 @@
                                S_END_AREA = endloc.S_AREA_CODE,
                                N_SCHEDULE_TYPE = 1,
                                S_CNTR_CODE = CntrCode,
                                N_PRIORITY = taskData.priority,
                                N_PRIORITY = pri,
                                Z_TYPE = n_type,
                                N_START_LAYER = 1,
                                N_END_LAYER = 1,
@@ -954,6 +964,7 @@
                            S_CNTR_CODE = model.Rfid,
                            N_START_LAYER = 1,
                            N_END_LAYER = 1,
                            N_PRIORITY = 1,
                            Z_TYPE = n_type
                        };
                        LogHelper.Info("创建入平库任务:" + JsonConvert.SerializeObject(wcsTask));
@@ -1082,27 +1093,51 @@
                    #region 根据物料编码计算出库货位,送往线边位置
                    Location Endloc = null;
                    //根据物料编码计算出库货位
                    var loc = airlift(areacode, itemcode, model.PartLevel, model.PowderType);
                    if (loc != null)
                    {
                        Start = loc.S_CODE;
                        //根据出库货位找到绑定托盘,获取入机台货位
                        var CntrRel = LocationHelper.GetLocCntrRel(loc.S_CODE).FirstOrDefault();
                        CntrCode = CntrRel.S_CNTR_CODE;
                        Endloc = Computeloc(CntrCode, model.WorkCenter, cntrType);
                        if (Endloc != null)
                        //给终点用终点,没给终点用机台库区计算货位
                        if (string.IsNullOrEmpty(model.TargetLocation))
                        {
                            End = Endloc.S_CODE;
                            Endloc = Computeloc(CntrCode, model.WorkCenter, cntrType);
                            if (Endloc != null)
                            {
                                End = Endloc.S_CODE;
                            }
                            else
                            {
                                result.code = "1";
                                result.msg = $"Computeloc==》根据机台编码:{model.WorkCenter},工装类型:{cntrType} 未找到空货位数据,请检查货位表";
                                LogHelper.Info($"ItemBack:{result.msg}");
                                AddErrorInfo("查找库区失败", result.msg, Source);
                                return result;
                            }
                        }
                        else
                        {
                            result.code = "1";
                            result.msg = $"Computeloc==》根据机台编码:{model.WorkCenter},工装类型:{cntrType} 未找到空货位数据,请检查货位表";
                            LogHelper.Info($"ItemBack:{result.msg}");
                            AddErrorInfo("查找库区失败", result.msg, Source);
                            return result;
                            Endloc = db.Queryable<Location>().Where(a => a.S_CODE == model.TargetLocation).First();
                            if (Endloc != null)
                            {
                                End = Endloc.S_CODE;
                            }
                            else
                            {
                                result.code = "1";
                                result.msg = $"Computeloc==》根据终点货位:{model.TargetLocation} 未找到货位数据,请检查货位表";
                                LogHelper.Info($"ItemBack:{result.msg}");
                                AddErrorInfo("查找库区失败", result.msg, Source);
                                return result;
                            }
                        }
                    }
                    else
                    {
@@ -1152,6 +1187,7 @@
                        S_CNTR_CODE = CntrCode,
                        N_START_LAYER = 1,
                        N_END_LAYER = 1,
                        N_PRIORITY = 1,
                        Z_TYPE = n_type
                    };
@@ -1411,6 +1447,8 @@
                            S_CNTR_CODE = model.Rfid,
                            N_START_LAYER = 1,
                            N_END_LAYER = endlayer,
                            N_PRIORITY = 1,
                            S_B_STATE="等待推送",
                            Z_TYPE = 5
                        };
                        LogHelper.Info("创建空托回库任务:" + JsonConvert.SerializeObject(wcsTask));
@@ -1590,6 +1628,7 @@
                            N_START_LAYER = 1,
                            N_END_LAYER = 1,
                            Z_TYPE = 5,
                            N_PRIORITY = 1,
                            S_NOTE = "粉料"
                        };
                        LogHelper.Info("创建呼叫空托任务:" + JsonConvert.SerializeObject(wcsTask));
@@ -1814,6 +1853,7 @@
                            S_CNTR_CODE = model.Rfid,
                            N_START_LAYER = 1,
                            N_END_LAYER = 1,
                            N_PRIORITY = 1,
                            Z_TYPE = 5
                        };
@@ -2065,6 +2105,7 @@
                        S_CNTR_CODE = CntrCode,
                        N_START_LAYER = 1,
                        N_END_LAYER = 1,
                        N_PRIORITY = 1,
                        //  N_TYPE = n_type
@@ -2201,6 +2242,7 @@
                        S_CNTR_CODE = cntr.S_CNTR_CODE,
                        N_END_LAYER = 1,
                        Z_TYPE = 6,
                        N_PRIORITY = 1,
                        S_B_STATE = "电梯推送"
                    };
@@ -2471,10 +2513,9 @@
                    var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First();
                    if (location != null)
                    {
                        var loccntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc).ToList();
                        var loccntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc.Trim()).ToList();
                        if (loccntr.Count > 0)
                        {
                            var cntrcodes = loccntr.Select(a => a.S_CNTR_CODE.Trim()).ToList();
                            if (LocationHelper.Clear(loc, cntrcodes))
                            {
@@ -2660,7 +2701,8 @@
        /// <param name="level">物料等级</param>
        /// <param name="powderType">机型</param>
        /// <returns></returns>
        internal static Location airlift(string areacode, string itemcode, string level, string powderType)
        internal static Location
            airlift(string areacode, string itemcode, string level, string powderType)
        {
            var db = new SqlHelper<object>().GetInstance();
            Location result = null;
@@ -2800,16 +2842,20 @@
            lock (_lockLocation)
            {
                var loc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.S_NOTE == cntrType && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无").First();
                if (loc != null)
                if (string.IsNullOrEmpty(cntrType))
                {
                    End = loc;
                    End = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim()  && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无").First();
                }
                else
                {
                    End = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.S_NOTE == cntrType && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无").First();
                }
                if (End == null)
                {
                    LogHelper.Info($"Computeloc==》根据机台分组:{jtcode},工装类型:{cntrType} 未找到空货位数据,请检查货位表");
                }
            }
            return End;
        }