lss
2025-05-29 cb58fdbdc4391136e7176210e3f1969606f11903
HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
@@ -11,8 +11,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.ServiceModel;
using System.Threading;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using static HH.WCS.JiaTong.api.ApiModel;
using static HH.WCS.JiaTong.api.OtherModel;
using static HH.WCS.JiaTong.LISTA.process.HttpModel;
@@ -155,6 +158,7 @@
                }
                else if (taskData.taskType == 2)//入库流程,直接使用起点货位和终点货位生成任务,起点需要有托盘
                {
                    note = "入库";
                    startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
                    if (startloc != null)
                    {
@@ -173,12 +177,7 @@
                        }
                    }
                    //判断是否是空托回库
                    var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == CntrCode).First();
                    if (CntrItem == null)
                    {
                        note = "空托回库";//井松空托回库,需要与叠盘机安全交互
                    }
                    endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First();
                    if (endloc != null)
                    {
@@ -194,8 +193,8 @@
                }
                else if (taskData.taskType == 3)//移库流程,直接使用起点货位和终点货位生成任务,
                {
                    note = "出库";
                    //创建托盘物料绑定信息,并计算终点货位
                    startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
                    if (startloc != null)
                    {
@@ -388,6 +387,7 @@
                //暂存位回库
                else if (taskData.taskType == 6)//入库流程,直接使用起点货位和终点货位生成任务
                {
                    note = "入库";
                    //根据托盘号找货位
                    var CntrRel = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE == partData.rfid).First();
                    if (CntrRel != null)
@@ -806,6 +806,7 @@
                        result.msg = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件";
                        LogHelper.Info($"Putin==> {result.msg}");
                        AddErrorInfo("查找库区失败", result.msg, Source);
                        return result;
                    }
                    //判断有无相同物料排
@@ -826,6 +827,7 @@
                        result.msg = $"库区:{areacode}无可用货位";
                        LogHelper.Info($"Putin==> {result.msg}");
                        AddErrorInfo("查找库区失败", result.msg, Source);
                        return result;
                    }
                }
                else
@@ -835,6 +837,7 @@
                    result.msg = $"任务起点:{Start}找不到对应货位,请检查货位表";
                    LogHelper.Info($"Putin==> {result.msg}");
                    AddErrorInfo("查找货位失败", result.msg, Source);
                    return result;
                }
                #endregion
@@ -939,6 +942,7 @@
                    result.msg = $"根据机台编码:{model.WorkCenter}未找到对应货位";
                    LogHelper.Info($"Putin==> {result.msg}");
                    AddErrorInfo("查找库区失败", result.msg, Source);
                    return result;
                }
                //根据仓库 计算库区
                var whcode = Settings.wareLoc.Where(a => a.AreaCode == locJt.S_WH_CODE).FirstOrDefault();
@@ -973,6 +977,7 @@
                    result.msg = $"根据终点库区仓库编码:{locJt.S_WH_CODE}未找到对应配置文件";
                    LogHelper.Info($"Putin==> {result.msg}");
                    AddErrorInfo("查找库区失败", result.msg, Source);
                    return result;
                }
                #endregion
@@ -991,6 +996,14 @@
                    {
                        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
                {
@@ -999,6 +1012,7 @@
                    result.msg = $"任务物料:{itemcode}找不到对应库存";
                    LogHelper.Info($"ItemBack:{result.msg}");
                    AddErrorInfo("查找库区失败", result.msg, Source);
                    return result;
                }
                #endregion
@@ -1192,6 +1206,7 @@
                            result.msg = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件";
                            LogHelper.Info($"Putin==> {result.msg}");
                            AddErrorInfo("查找库区失败", result.msg, Source);
                            return result;
                        }
                        #endregion
@@ -1333,11 +1348,12 @@
                        result.msg = $"根据起点仓库编码:{endloc.S_WH_CODE}未找到对应配置文件";
                        LogHelper.Info($"Putin==> {result.msg}");
                        AddErrorInfo("查找库区失败", result.msg, Source);
                        return result;
                    }
                    //计算出库托盘
                    startloc = airlift(areacode, itemcode);
                    startloc = LocationHelper.GetLocByAreacode(areacode);
                    if (startloc != null)
                    {
                        var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == startloc.S_CODE).First();
@@ -1365,7 +1381,7 @@
                    result.msg = $"任务起点:{End}找不到对应货位,请检查货位表";
                    LogHelper.Info($"callfixture:{result.msg}");
                    AddErrorInfo("查找货位失败", result.msg, Source);
                    return result;
                }
                #endregion
@@ -1551,7 +1567,8 @@
                            var EndLocs = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == areacode).ToList();
                            if (EndLocs.Count > 0)
                            {
                                loc = EndLocs.Find(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0);
                                //loc =  EndLocs.Find(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0);
                                loc = FindEndcolByLocList(EndLocs);
                                if (loc != null)
                                {
                                    End = loc.S_CODE;
@@ -1598,6 +1615,7 @@
                        result.msg = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件";
                        LogHelper.Info($"Putin==> {result.msg}");
                        AddErrorInfo("查找库区失败", result.msg, Source);
                        return result;
                    }
                }
@@ -2098,7 +2116,23 @@
            }
            return result;
        }
        internal static DeviceInfoModel Device()
        {
            DeviceInfoModel device = new DeviceInfoModel();
            List<DeviceInfos> deviceInfos = new List<DeviceInfos>();//叠盘机报错信息
            AgvInfos gvInfos = new AgvInfos();//agv报错信息
            //获取内存中叠盘机的报错信息
            foreach (var dpjInfo in DeviceProcess.DpjInfoDirectory)
            {
                deviceInfos.Add(new DeviceInfos() { Device = dpjInfo.Value.DeviceName, DeviceInfo = dpjInfo.Value.ErrorInfo });
            }
            device.DeviceInfos = deviceInfos;
            return device;
        }
        /// <summary>
        /// 库位清空
@@ -2133,8 +2167,8 @@
                        if (CntrItem != null)
                        {
                            LocationHelper.UnBindingLoc(loc, new List<string>() { "cntrcode" });
                            //  db.Deleteable<LocCntrRel>().Where(it => it.S_LOC_CODE.Trim() == loc).ExecuteCommand();
                            LocationHelper.UnBindingLoc(loc, new List<string>() { cntrcode });
                            // db.Deleteable<LocCntrRel>().Where(it => it.S_LOC_CODE.Trim() == loc).ExecuteCommand();
                            db.Deleteable<CntrItemDetail>().Where(it => it.S_CNTR_CODE.Trim() == cntrcode).ExecuteCommand();
                        }
@@ -2297,7 +2331,12 @@
            #endregion
            var loc = LocationHelper.GetLocByItemCode(areacode, itemcode, level);
            LogHelper.Info($"airlift=>根据库区编码:{areacode},物料编码:{itemcode},物料等级计算出有托盘货位{JsonConvert.SerializeObject(loc)}");
            result = FindStartcolByLoclist(loc);
            // result = FindStartcolByLoclist(loc);
            if (loc.Count > 0)
            {
                result = loc.OrderByDescending(a => a.N_COL).First();
            }
            LogHelper.Info($"airlift=>可用货位为:{JsonConvert.SerializeObject(result)}");
            return result;
        }
@@ -2415,7 +2454,7 @@
        /// </summary>
        /// <param name="locations"></param>
        /// <returns></returns>
        internal static Location FindEndcolByLocList(List<Location> locations, string itemcode)
        internal static Location FindEndcolByLocList(List<Location> locations)
        {
            try
            {
@@ -2508,6 +2547,28 @@
            }
        }
        /// <summary>
        /// 获取对应错误编码的小车数量
        /// </summary>
        /// <param name="Error1">错误码1</param>
        /// <param name="Error2">错误码2</param>
        /// <param name="faildCode"></param>
        /// <returns></returns>
        internal static int GetAgvQty(string Error1, string Error2 = "0", string faildCode = "0")
        {
            try
            {
                var db = new SqlHelper<HangChaAGV>().GetInstance();
                return db.Queryable<HangChaAGV>().Where(a => a.faildCode == faildCode && a.errCode2 == Error2 && a.agvErrCode == Error1).Count();
            }
            catch (Exception)
            {
                throw;
            }
        }
        #endregion