lss
2025-05-19 f7d36a3dd47e06bf76863179af1d76bd0e23054f
HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
@@ -6,6 +6,7 @@
using HH.WCS.JiaTong.wms;
using Newtonsoft.Json;
using NLog.Fluent;
using S7.Net;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -152,7 +153,7 @@
                        AddErrorInfo("货位查找失败", result.msg);
                    }
                }
                else if (taskData.taskType == 2)//入库流程,直接使用起点货位和终点货位生成任务
                else if (taskData.taskType == 2)//入库流程,直接使用起点货位和终点货位生成任务,起点需要有托盘
                {
                    startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
                    if (startloc != null)
@@ -171,6 +172,12 @@
                            return result;
                        }
                    }
                    //判断是否是空托回库
                    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)
@@ -426,6 +433,34 @@
                        return result;
                    }
                }
                else if (taskData.taskType == 8)//叠盘机空托回库
                {
                    note = "空托回库";//井松空托回库,需要与叠盘机安全交互
                    startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
                    if (startloc != null)
                    {
                        Start = startloc.S_CODE;
                    }
                    else
                    {
                        result.code = "1";
                        result.msg = $"根据起点:{taskData.pickStation},找不到对应货位,请检查货位表";
                        AddErrorInfo("货位查找失败", result.msg);
                        return result;
                    }
                    endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First();
                    if (endloc != null)
                    {
                        End = taskData.dropStation;
                    }
                    else
                    {
                        result.code = "1";
                        result.msg = $"根据终点:{End},找不到对应货位,请检查货位表";
                        AddErrorInfo("货位查找失败", result.msg);
                        return result;
                    }
                }
                else
                {
                    LogHelper.Info($"Createtask==> 任务类型有误");
@@ -506,6 +541,8 @@
        }
        /// <summary>
        /// 预备库任务状态下发
@@ -620,7 +657,7 @@
            try
            {
                //创建托盘数据绑定关系
                if (ContainerHelper.CreateCntrItem(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight))
                if (ContainerHelper.CreateCntrItem(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight,model.Qty))
                {
                    //创建成功流程
                }
@@ -667,7 +704,8 @@
            string areacode = "";
            try
            {
                #region 判断托盘绑定货位是否和下发绑定起点相同
                #region 判断托盘绑定货位是否和下发绑定起点相同,如果没绑定托盘则绑定托盘
                var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First();
                if (CntrLoc != null)
                {
@@ -682,11 +720,12 @@
                }
                else
                {
                    LogHelper.Info($"ItemBack:创建任务失败,托盘:{model.Rfid}未找到绑定货位");
                    result.code = "1";
                    result.msg = $"创建任务失败,托盘:{model.Rfid}未找到绑定货位";
                    AddErrorInfo("查找托盘货位失败", result.msg);
                    return result;
                    LocationHelper.BindingLoc(Start, new List<string> { model.Rfid });
                    //LogHelper.Info($"ItemBack:创建任务失败,托盘:{model.Rfid}未找到绑定货位");
                    //result.code = "1";
                    //result.msg = $"创建任务失败,托盘:{model.Rfid}未找到绑定货位";
                    //AddErrorInfo("查找托盘货位失败", result.msg);
                    //return result;
                }
                // Console.WriteLine("查询货位绑定关系");
                //判断托盘与货位是否有绑定关系,如果没有则进行绑定
@@ -712,7 +751,6 @@
                //}
                #endregion
                #region 根据起点货位的仓库编码 获取平库编码,并计算入库货位
                string End = "";
@@ -802,6 +840,7 @@
                    return result;
                }
                #endregion
                return result;
            }
            catch (Exception ex)
@@ -1032,7 +1071,7 @@
                        var dploc = db.Queryable<Location>().Where(a => a.S_NOTE.Trim() == "叠盘" && a.N_LAYER == startloc.N_LAYER && a.S_WH_CODE.Trim() == startloc.S_WH_CODE).ToList();
                        if (dploc.Count > 0)
                        {
                            LogHelper.Info($"获取叠盘货位:{JsonConvert.SerializeObject(dploc)}");
                            // LogHelper.Info($"获取叠盘货位:{JsonConvert.SerializeObject(dploc)}");
                            loc = dploc.FindAll(a => a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM < 6).OrderByDescending(a => a.N_CURRENT_NUM).FirstOrDefault();
                            if (loc == null)
                            {
@@ -1055,6 +1094,34 @@
                            return result;
                        }
                    }
                    else if (startloc.S_NOTE == "PM")
                    {
                        //找块胶堆叠区
                        var KjDploc = db.Queryable<Location>().Where(a => a.S_NOTE.Trim() == "片胶堆叠位" && a.S_WH_CODE.Trim() == startloc.S_WH_CODE).ToList();
                        if (KjDploc.Count > 0)
                        {
                            loc = KjDploc.FindAll(a => a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM < 6).OrderByDescending(a => a.N_CURRENT_NUM).FirstOrDefault();
                            if (loc == null)
                            {
                                result.code = "1";
                                result.msg = $"叠盘货位不可用";
                                AddErrorInfo("查找库区失败", result.msg);
                                return result;
                            }
                            else
                            {
                                endlayer = loc.N_CURRENT_NUM + 1;
                            }
                        }
                        else
                        {
                            LogHelper.Info($"根据货位备注:片胶堆叠位,货位仓库:{startloc.S_WH_CODE},找不到叠盘货位");
                            result.code = "1";
                            result.msg = $"叠盘货位不可用";
                            AddErrorInfo("查找货位失败", result.msg);
                            return result;
                        }
                    }
                    else
                    {
                        #region 根据托盘找呼叫空托任务,并获得出库库区