lss
2025-07-04 3865194441f1e1da34c0be9034d86c8d0d68706c
HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
@@ -187,14 +187,7 @@
                                }
                            }
                            //else
                            //{
                            //    result.code = "1";
                            //    result.msg = $"根据起点{Start},未找到托盘货位绑定关系";
                            //    AddErrorInfo("托盘查找失败", result.msg, Source);
                            //    return result;
                            //}
                        }
                        else
                        {
@@ -768,7 +761,7 @@
                {
                    //创建托盘数据绑定关系
                    if (ContainerHelper.CreateCntrItem(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight, model.Qty, model.ProductionTime, model.MaturityTime))
                    if (ContainerHelper.CreateCntrItemTray(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight, model.Qty, model.ProductionTime, model.MaturityTime, model.PowderType))
                    {
                        //创建成功流程
                    }
@@ -1090,7 +1083,7 @@
                    #region 根据物料编码计算出库货位,送往线边位置
                    Location Endloc = null;
                    //根据物料编码计算出库货位
                    var loc = airlift(areacode, itemcode, model.PartLevel);
                    var loc = airlift(areacode, itemcode, model.PartLevel, model.PowderType);
                    if (loc != null)
                    {
                        Start = loc.S_CODE;
@@ -2176,8 +2169,8 @@
                    string[] state = new string[] { "执行中", "开始取货", "取货完成", "开始卸货", "卸货完成" };
                    var elevatorLoc = db.Queryable<Location>().Where(a =>  a.S_CODE == eleLoc.TN_Location).First();
                    if (elevatorLoc==null)
                    var elevatorLoc = db.Queryable<Location>().Where(a => a.S_CODE == eleLoc.TN_Location).First();
                    if (elevatorLoc == null)
                    {
                        result.code = "1";
                        result.msg = $"根据电梯配置文件货位:{eleLoc.TN_Location}未找到对于货位数据,请检查货位表";
@@ -2269,6 +2262,47 @@
        }
        /// <summary>
        /// 电梯任务推送
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        internal static Result DT(DTModel model)
        {
            Result result = new Result() { code = "200", msg = "电梯任务推送成功" };
            string Source = "WMS";
            if (model == null)
            {
                result.code = "1";
                result.msg = "参数为null";
                AddErrorInfo("参数为空", result.msg, Source);
                return result;
            }
            try
            {
                if (model.prepare == "1")
                {
                    var db = new SqlHelper<object>().GetInstance();
                    //修改对应电梯任务进行推送
                    return result;
                }
                else
                {
                    result.code = "1";
                    result.msg = $"一楼电梯搬运任务推送失败 prepare{model.prepare}不为1";
                    LogHelper.Info(result.msg);
                    return result;
                }
            }
            catch (Exception ex)
            {
                result.code = "1";
                result.msg = $"电梯任务推送失败 错误信息:{ex}";
                LogHelper.Error("点对点任务 Error:" + ex.ToString(), ex);
                return result;
            }
        }
        /// <summary>
        /// 货位信息上传
        /// </summary>
@@ -2624,8 +2658,9 @@
        /// <param name="areacode"></param>
        /// <param name="itemcode"></param>
        /// <param name="level">物料等级</param>
        /// <param name="powderType">机型</param>
        /// <returns></returns>
        internal static Location airlift(string areacode, string itemcode, string level = "")
        internal static Location airlift(string areacode, string itemcode, string level, string powderType)
        {
            var db = new SqlHelper<object>().GetInstance();
            Location result = null;
@@ -2682,8 +2717,8 @@
            //}
            #endregion
            var loc = LocationHelper.GetLocByItemCode(areacode, itemcode, level);
            LogHelper.Info($"airlift=>根据库区编码:{areacode},物料编码:{itemcode},物料等级计算出有托盘货位{JsonConvert.SerializeObject(loc)}");
            var loc = LocationHelper.GetLocByItemCode(areacode, itemcode, level, powderType);
            LogHelper.Info($"airlift=>根据库区编码:{areacode},物料编码:{itemcode},机型{powderType},物料等级计算出有托盘货位{JsonConvert.SerializeObject(loc)}");
            // result = FindStartcolByLoclist(loc);
            if (loc.Count > 0)
            {
@@ -2818,6 +2853,48 @@
        }
        /// <summary>
        /// 合肥佳通接口调用信息
        /// </summary>
        /// <param name="source">系统来源</param>
        /// <param name="name">接口名称</param>
        /// <param name="type">请求地址类型</param>
        /// <param name="body">请求参数</param>
        /// <param name="url">请求地址</param>
        /// <param name="err">错误信息</param>
        /// <returns></returns>
        public static bool AddInfo(string source, string name, string body, string err, string type, string url)
        {
            bool result = false;
            var db = new SqlHelper<object>().GetInstance();
            try
            {
                var error = new GT_Interface_Exc
                {
                    S_SOURCE = source,
                    S_NAME = name,
                    S_TYPE = type,
                    S_URL = url,
                    S_BODY = body,
                    S_ERR = err
                };
                if (result = db.Insertable<GT_Interface_Exc>(error).ExecuteCommand() > 0)
                {
                }
                //else
                //{
                //    //添加失败重新添加
                //    AddErrorInfo(errorInfo, remake, areacode, taskno);
                //}
            }
            catch (Exception ex)
            {
                LogHelper.Info($"AddInfo Error:{ex.Message}");
            }
            return result;
        }
        /// <summary>
        /// 找终点空货位
        /// </summary>
        /// <param name="locations"></param>
@@ -2834,14 +2911,14 @@
                {
                    var rowList = locations.Where(r => r.N_ROW == rows[i]).ToList();
                    LogHelper.Info($"当前排:{rows[i]},获得货位{JsonConvert.SerializeObject(rowList)}");
                    //  LogHelper.Info($"当前排:{rows[i]},获得货位{JsonConvert.SerializeObject(rowList)}");
                    if (rowList.Count(a => a.N_CURRENT_NUM == 0) > 0)
                    {
                        Location other = null;
                        //当前排没有锁并且有空位置
                        // other = rowList.OrderBy(a => a.N_COL).Where(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.C_ENABLE == "Y").FirstOrDefault();
                        other = rowList.OrderBy(a => a.N_COL).Where(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && !string.IsNullOrEmpty(a.S_CODE.Trim()) && !string.IsNullOrWhiteSpace(a.S_CODE.Trim())).FirstOrDefault();
                        other = rowList.OrderBy(a => a.N_COL).Where(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0).FirstOrDefault();
                        //if (full == null)
                        //{
                        //    //没有满位,那就找最小的空位
@@ -3012,7 +3089,6 @@
        {
            lock (AGVDeviceReceiveLock)
            {
                var db = new SqlHelper<HangChaAGV>().GetInstance();
                var agvDeviceInfo = db.Queryable<HangChaAGV>().Where(a => a.agvNo.Trim() == forkliftNo).First();
                if (agvDeviceInfo == null)