lss
2025-05-20 fe442ab8c9ba6648b140f253902b4ef24c5618bf
HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
@@ -53,9 +53,14 @@
            try
            {
                var db = new SqlHelper<object>().GetInstance();
                string CntrCode = "";//托盘编码
                string ItemCode = "";//物料编码
                if (partData != null)
                {
                    CntrCode = partData.rfid;//托盘编码
                    ItemCode = partData.partNumber;//物料编码
                }
                string Start = ""; //取货点
                string CntrCode = partData.rfid;//托盘编码
                string ItemCode = partData.partNumber;//物料编码
                string End = "";
                string areacode = "";
                string note = ""; //立库下发任务需要通知mes接口物料到位,用备注自动进行区分
@@ -85,20 +90,24 @@
                //    return result;
                //}
                int n_type = 0;  //任务来源 1.钢丝立库  2.胶片库  3.预备库 ,4.原材料库,通过物料确认任务来源
                string Source = "";
                switch (areacode)
                {
                    case "ML":
                        n_type = 1;
                        Source = "密炼";
                        break;
                    case "JP":
                        n_type = 2;
                        Source = "井松";
                        break;
                    case "YBK":
                        n_type = 3;
                        Source = "预备库";
                        break;
                    case "wmwhse1":
                        n_type = 4;
                        Source = "原材料";
                        break;
                }
                LogHelper.Info($"Createtask==>任务类型:{n_type}");
@@ -109,6 +118,8 @@
                    AddErrorInfo("物料库区未定义", result.msg);
                    return result;
                }
                #endregion
                Location endloc = new Location();
@@ -122,7 +133,7 @@
                    {
                        //创建托盘物料绑定信息,并计算终点货位
                        Start = taskData.pickStation;
                        if (CreateCntrIteminfo(Start, CntrCode, ItemCode, partData.partDesc, partData.partType, partData.lotNumber, partData.unit, partData.weight, taskData.carrierType, taskData.grade))
                        if (CreateCntrIteminfo(partData, taskData))
                        {
                            endloc = Computeloc(CntrCode, taskData.dropStation, taskData.carrierType);
                            if (endloc != null)
@@ -133,7 +144,7 @@
                            {
                                result.code = "1";
                                result.msg = $"机台编码:{taskData.dropStation},未找到可用货位";
                                AddErrorInfo("寻找出库货位失败", result.msg);
                                AddErrorInfo("寻找出库货位失败", result.msg, Source);
                                return result;
                            }
                        }
@@ -141,19 +152,20 @@
                        {
                            result.code = "1";
                            result.msg = "创建托盘物料信息失败";
                            AddErrorInfo("创建托盘失败", result.msg);
                            AddErrorInfo("创建托盘失败", result.msg, Source);
                            return result;
                        }
                    }
                    else
                    {
                        LogHelper.Info($"Putin==> 任务起点:{taskData.pickStation}找不到对应货位,请检查货位表");
                        result.code = "1";
                        result.msg = $"Putin==> 任务起点:{taskData.pickStation}找不到对应货位,请检查货位表";
                        AddErrorInfo("货位查找失败", result.msg);
                        LogHelper.Info($"Putin==> {result.msg}");
                        AddErrorInfo("货位查找失败", result.msg, Source);
                    }
                }
                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)
@@ -168,7 +180,7 @@
                        {
                            result.code = "1";
                            result.msg = $"根据起点{Start},未找到托盘货位绑定关系";
                            AddErrorInfo("托盘查找失败", result.msg);
                            AddErrorInfo("托盘查找失败", result.msg, Source);
                            return result;
                        }
@@ -188,7 +200,7 @@
                    {
                        result.code = "1";
                        result.msg = $"根据终点{End},找不到对应货位,请检查货位表";
                        AddErrorInfo("货位查找失败", result.msg);
                        AddErrorInfo("货位查找失败", result.msg, Source);
                        return result;
                    }
                }
@@ -201,10 +213,24 @@
                    {
                        Start = taskData.pickStation;
                    }
                    else
                    {
                        result.code = "1";
                        result.msg = $"根据起点{taskData.pickStation},找不到对应货位,请检查货位表";
                        AddErrorInfo("货位查找失败", result.msg, Source);
                        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 = $"根据终点{taskData.dropStation},找不到对应货位,请检查货位表";
                        AddErrorInfo("货位查找失败", result.msg, Source);
                        return result;
                    }
                }
                else if (taskData.taskType == 4)//原材料库需要判断是否需要分配电梯任务,创建分档任务
@@ -229,7 +255,7 @@
                        {
                            result.code = "1";
                            result.msg = $"创建任务失败,起点:{startloc.S_AREA_CODE},终点:{endloc.S_AREA_CODE}未找到对应库区";
                            AddErrorInfo("货位查找失败", result.msg);
                            AddErrorInfo("货位查找失败", result.msg, Source);
                            return result;
                        }
                        if (startArea.N_FLOOR == endArea.N_FLOOR)
@@ -329,27 +355,41 @@
                        return result;
                    }
                }
                else if (taskData.taskType == 5)//移库流程,直接使用起点货位和终点货位生成任务,
                else if (taskData.taskType == 5)//移库流程,直接使用起点货位和终点货位生成任务,并绑定托盘
                {
                    //创建托盘物料绑定信息,并计算终点货位
                    if (CreateCntrIteminfo(taskData.pickStation, CntrCode, ItemCode, partData.partDesc, partData.partType, partData.lotNumber, partData.unit, partData.weight, taskData.carrierType, taskData.grade))
                    if (CreateCntrIteminfo(partData, taskData))
                    {
                        startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
                        if (startloc != null)
                        {
                            Start = taskData.pickStation;
                        }
                        else
                        {
                            result.code = "1";
                            result.msg = $"根据起点{taskData.pickStation},找不到对应货位,请检查货位表";
                            AddErrorInfo("货位查找失败", result.msg, Source);
                            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 = $"根据终点{taskData.dropStation},找不到对应货位,请检查货位表";
                            AddErrorInfo("货位查找失败", result.msg, Source);
                            return result;
                        }
                    }
                    else
                    {
                        result.code = "1";
                        result.msg = "创建托盘物料信息失败";
                        AddErrorInfo("创建托盘失败", result.msg);
                        AddErrorInfo("创建托盘失败", result.msg, Source);
                        return result;
                    }
@@ -371,7 +411,7 @@
                        {
                            result.code = "1";
                            result.msg = $"根据托盘{partData.rfid},未找到托盘货位绑定关系";
                            AddErrorInfo("货位查找失败", result.msg);
                            AddErrorInfo("货位查找失败", result.msg, Source);
                            return result;
                        }
                    }
@@ -384,7 +424,7 @@
                    {
                        result.code = "1";
                        result.msg = $"根据终点{End},找不到对应货位,请检查货位表";
                        AddErrorInfo("货位查找失败", result.msg);
                        AddErrorInfo("货位查找失败", result.msg, Source);
                        return result;
                    }
                }
@@ -393,7 +433,7 @@
                {
                    note = "异常库区入库";
                    //创建托盘物料绑定信息,并计算终点货位
                    if (CreateCntrIteminfo(taskData.pickStation, CntrCode, ItemCode, partData.partDesc, partData.partType, partData.lotNumber, partData.unit, partData.weight, taskData.carrierType, taskData.grade))
                    if (CreateCntrIteminfo(partData, taskData))
                    {
                        startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
                        if (startloc != null)
@@ -412,7 +452,7 @@
                            {
                                result.code = "1";
                                result.msg = $"终点库区:{taskData.dropStation}无可用货位";
                                AddErrorInfo("查找库区失败", result.msg);
                                AddErrorInfo("查找库区失败", result.msg, Source);
                                return result;
                            }
@@ -421,7 +461,7 @@
                        {
                            result.code = "1";
                            result.msg = $"根据终点库区:{taskData.dropStation},未找到对应货位";
                            AddErrorInfo("查找库区失败", result.msg);
                            AddErrorInfo("查找库区失败", result.msg, Source);
                            return result;
                        }
                    }
@@ -429,7 +469,35 @@
                    {
                        result.code = "1";
                        result.msg = "创建托盘物料信息失败";
                        AddErrorInfo("创建托盘失败", result.msg);
                        AddErrorInfo("创建托盘失败", result.msg, Source);
                        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, Source);
                        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, Source);
                        return result;
                    }
                }
@@ -438,7 +506,7 @@
                    LogHelper.Info($"Createtask==> 任务类型有误");
                    result.code = "1";
                    result.msg = "任务类型:{taskData.taskType}不在规定范围内";
                    AddErrorInfo("任务类型错误", result.msg);
                    AddErrorInfo("任务类型错误", result.msg, Source);
                }
                if (taskData.taskType != 4)
                {
@@ -514,8 +582,6 @@
        }
        /// <summary>
        /// 预备库任务状态下发
        /// </summary>
@@ -574,7 +640,7 @@
                LogHelper.Info($"AllowThrough==> 参数为null");
                result.code = "1";
                result.msg = "参数为null值,请检查参数格式";
                AddErrorInfo("参数为空", result.msg);
                AddErrorInfo("参数为空", result.msg, "", model.task_no);
                return result;
            }
@@ -596,7 +662,7 @@
                {
                    result.code = "1";
                    result.msg = $"根据下发任务号{model.task_no}未找到对应任务";
                    AddErrorInfo("未找到任务", result.msg);
                    AddErrorInfo("未找到任务", result.msg, "", model.task_no);
                    return result;
                }
                return result;
@@ -629,7 +695,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))
                {
                    //创建成功流程
                }
@@ -637,7 +703,7 @@
                {
                    result.code = "1";
                    result.msg = "产出信息下发失败,托盘物料绑定关系创建失败";
                    AddErrorInfo("创建绑定关系失败", result.msg);
                    AddErrorInfo("创建绑定关系失败", result.msg, "Mes");
                    return result;
                }
                return result;
@@ -662,31 +728,38 @@
        internal static Result Putin(Putin model, int n_type)
        {
            Result result = new Result() { code = "200", msg = "入平库任务下发成功" };
            string Source = "Mes";
            if (n_type == 0)
            {
                Source = "PDA";
            }
            if (model == null)
            {
                result.code = "1";
                result.msg = "参数为null";
                AddErrorInfo("参数为空", result.msg);
                AddErrorInfo("参数为空", result.msg, Source);
                return result;
            }
            var db = new SqlHelper<object>().GetInstance();
            Location loc = new Location();
            string Start = model.InitialLocation;  //起点货位
            string itemcode = model.PartNumber;    //物料编码
            string areacode = "";
            try
            {
                #region 判断托盘绑定货位是否和下发绑定起点相同,如果没绑定托盘则绑定托盘
                var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First();
                if (CntrLoc != null)
                {
                    if (CntrLoc.S_LOC_CODE != Start)
                    {
                        LogHelper.Info($"ItemBack:创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}");
                        result.code = "1";
                        result.msg = $"创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}";
                        AddErrorInfo("托盘绑定位置不同", result.msg);
                        LogHelper.Info($"ItemBack:{result.msg}");
                        AddErrorInfo("托盘绑定位置不同", result.msg, Source);
                        return result;
                    }
                }
@@ -753,18 +826,20 @@
                    }
                    else
                    {
                        LogHelper.Info($"Putin==>库区:{areacode}无可用货位");
                        result.code = "1";
                        result.msg = $"库区:{areacode}无可用货位";
                        AddErrorInfo("查找库区失败", result.msg);
                        LogHelper.Info($"Putin==> {result.msg}");
                        AddErrorInfo("查找库区失败", result.msg, Source);
                    }
                }
                else
                {
                    LogHelper.Info($"Putin==> 任务起点:{Start}找不到对应货位,请检查货位表");
                    result.code = "1";
                    result.msg = $"任务起点:{Start}找不到对应货位,请检查货位表";
                    AddErrorInfo("查找货位失败", result.msg);
                    LogHelper.Info($"Putin==> {result.msg}");
                    AddErrorInfo("查找货位失败", result.msg, Source);
                }
                #endregion
@@ -775,7 +850,7 @@
                    {
                        result.code = "1";
                        result.msg = $"创建任务失败,起点:{Start}有锁";
                        AddErrorInfo("货位有锁", result.msg);
                        AddErrorInfo("货位有锁", result.msg, Source);
                        return result;
                    }
                    //创建wcs任务
@@ -834,11 +909,16 @@
        internal static Result PutOut(PutOut model, int n_type)
        {
            Result result = new Result() { code = "200", msg = "出平库任务下发成功" };
            string Source = "Mes";
            if (n_type == 0)
            {
                Source = "PDA";
            }
            if (model == null)
            {
                result.code = "1";
                result.msg = "参数为null";
                AddErrorInfo("参数为空", result.msg);
                AddErrorInfo("参数为空", result.msg, Source);
                return result;
            }
@@ -846,6 +926,7 @@
            string Start = "";
            string End = "";
            string CntrCode = "";
            string itemcode = model.PartNumber;
            string cntrType = "";
            string areacode = "";
@@ -872,10 +953,11 @@
                    }
                    else
                    {
                        LogHelper.Info($"ItemBack:创建任务失败,物料号{model.PartNumber}不属于规定物料");
                        result.code = "1";
                        result.msg = $"创建任务失败,物料号{model.PartNumber}不属于规定物料";
                        AddErrorInfo("物料编码格式错误", result.msg);
                        LogHelper.Info($"ItemBack:{result.msg}");
                        AddErrorInfo("物料编码格式错误", result.msg, Source);
                        return result;
                    }
                }
@@ -917,10 +999,11 @@
                }
                else
                {
                    LogHelper.Info($"PutOut==> 任务物料:{itemcode}找不到对应库存");
                    result.code = "1";
                    result.msg = $"任务物料:{itemcode}找不到对应库存";
                    AddErrorInfo("查找库区失败", result.msg);
                    LogHelper.Info($"ItemBack:{result.msg}");
                    AddErrorInfo("查找库区失败", result.msg, Source);
                }
                #endregion
@@ -931,7 +1014,7 @@
                    {
                        result.code = "1";
                        result.msg = $"创建任务失败,起点{Start}有锁";
                        AddErrorInfo("货位有锁", result.msg);
                        AddErrorInfo("货位有锁", result.msg, Source);
                        return result;
                    }
                    //创建wcs任务
@@ -989,11 +1072,12 @@
        internal static Result Empty(Empty model)
        {
            Result result = new Result() { code = "200", msg = "空工装回库任务下发成功" };
            string Source = "MES";
            if (model == null)
            {
                result.code = "1";
                result.msg = "参数为null";
                AddErrorInfo("参数为空", result.msg);
                AddErrorInfo("参数为空", result.msg, Source);
                return result;
            }
@@ -1049,7 +1133,7 @@
                            {
                                result.code = "1";
                                result.msg = $"叠盘货位不可用";
                                AddErrorInfo("查找库区失败", result.msg);
                                AddErrorInfo("查找库区失败", result.msg, Source);
                                return result;
                            }
                            else
@@ -1059,10 +1143,11 @@
                        }
                        else
                        {
                            LogHelper.Info($"根据货位备注:叠盘,货位楼层:{startloc.N_LAYER},货位仓库:{startloc.S_WH_CODE},找不到叠盘货位");
                            result.code = "1";
                            result.msg = $"叠盘货位不可用";
                            AddErrorInfo("查找货位失败", result.msg);
                            LogHelper.Info($"根据货位备注:叠盘,货位楼层:{startloc.N_LAYER},货位仓库:{startloc.S_WH_CODE},找不到叠盘货位");
                            AddErrorInfo("查找货位失败", result.msg, Source);
                            return result;
                        }
                    }
@@ -1077,7 +1162,7 @@
                            {
                                result.code = "1";
                                result.msg = $"叠盘货位不可用";
                                AddErrorInfo("查找库区失败", result.msg);
                                AddErrorInfo("查找库区失败", result.msg, Source);
                                return result;
                            }
                            else
@@ -1090,7 +1175,7 @@
                            LogHelper.Info($"根据货位备注:片胶堆叠位,货位仓库:{startloc.S_WH_CODE},找不到叠盘货位");
                            result.code = "1";
                            result.msg = $"叠盘货位不可用";
                            AddErrorInfo("查找货位失败", result.msg);
                            AddErrorInfo("查找货位失败", result.msg, Source);
                            return result;
                        }
                    }
@@ -1110,18 +1195,20 @@
                        }
                        else
                        {
                            LogHelper.Info($"创建任务失败,根据托盘编码{model.Rfid}未找到托盘出库任务");
                            result.code = "1";
                            result.msg = $"创建任务失败,根据托盘编码{model.Rfid}未找到托盘出库任务";
                            AddErrorInfo("查找任务失败", result.msg);
                            LogHelper.Info($"{result.msg}");
                            AddErrorInfo("查找任务失败", result.msg, Source);
                            return result;
                        }
                        if (string.IsNullOrEmpty(areacode))
                        {
                            LogHelper.Info($"创建任务失败,根据托盘编码{model.Rfid}找到出库任务{mst.S_CODE}的起点库区为空");
                            result.code = "1";
                            result.msg = $"创建任务失败,根据托盘编码{model.Rfid}找到出库任务{mst.S_CODE}的起点库区为空";
                            AddErrorInfo("查找库区失败", result.msg);
                            LogHelper.Info($"{result.msg}");
                            AddErrorInfo("查找库区失败", result.msg, Source);
                            return result;
                        }
                        #endregion
@@ -1138,10 +1225,11 @@
                        }
                        else
                        {
                            LogHelper.Info($"库区:{areacode}无可用货位");
                            result.code = "1";
                            result.msg = $"库区:{areacode}无可用货位";
                            AddErrorInfo("查找货位失败", result.msg);
                            LogHelper.Info($"{result.msg}");
                            AddErrorInfo("查找货位失败", result.msg, Source);
                            return result;
                        }
                    }
@@ -1149,10 +1237,11 @@
                }
                else
                {
                    LogHelper.Info($"Empty==> 任务起点:{Start}找不到对应货位,请检查货位表");
                    result.code = "1";
                    result.msg = $"Empty==> 任务起点:{Start}找不到对应货位,请检查货位表";
                    AddErrorInfo("查找货位失败", result.msg);
                    LogHelper.Info($"{result.msg}");
                    AddErrorInfo("查找货位失败", result.msg, Source);
                    return result;
                }
                #endregion
@@ -1225,11 +1314,12 @@
        {
            var db = new SqlHelper<object>().GetInstance();
            Result result = new Result() { code = "200", msg = "空工装呼叫任务下发成功" };
            string Source = "MES";
            if (model == null)
            {
                result.code = "1";
                result.msg = "参数为null";
                AddErrorInfo("参数为空", result.msg);
                AddErrorInfo("参数为空", result.msg, Source);
                return result;
            }
@@ -1271,10 +1361,10 @@
                        }
                        else
                        {
                            LogHelper.Info($"callfixture:创建空工装呼叫任务==>根据货位{endloc.S_CODE}未找到托盘货位绑定关系");
                            result.code = "1";
                            result.msg = $"创建空工装呼叫任务==>根据货位{endloc.S_CODE}未找到托盘货位绑定关系";
                            AddErrorInfo("查找托盘失败", result.msg);
                            LogHelper.Info($"callfixture:{result.msg}");
                            AddErrorInfo("查找托盘失败", result.msg, Source);
                            return result;
                        }
@@ -1283,10 +1373,11 @@
                }
                else
                {
                    LogHelper.Info($"callfixture==> 任务起点:{End}找不到对应货位,请检查货位表");
                    result.code = "1";
                    result.msg = $"任务起点:{End}找不到对应货位,请检查货位表";
                    AddErrorInfo("查找货位失败", result.msg);
                    LogHelper.Info($"callfixture:{result.msg}");
                    AddErrorInfo("查找货位失败", result.msg, Source);
                }
                #endregion
@@ -1359,11 +1450,12 @@
        internal static Result ItemBack(ItemBack model)
        {
            Result result = new Result() { code = "200", msg = "余料返回任务下发成功" };
            string Source = "MES";
            if (model == null)
            {
                result.code = "1";
                result.msg = "参数为null";
                AddErrorInfo("参数为空", result.msg);
                AddErrorInfo("参数为空", result.msg, Source);
                return result;
            }
@@ -1387,19 +1479,21 @@
                {
                    if (CntrLoc.S_LOC_CODE != Start)
                    {
                        LogHelper.Info($"ItemBack:创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}");
                        result.code = "1";
                        result.msg = $"创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}";
                        AddErrorInfo("托盘绑定位置不同", result.msg);
                        LogHelper.Info($"ItemBack:{result.msg}");
                        AddErrorInfo("托盘绑定位置不同", result.msg, Source);
                        return result;
                    }
                }
                else
                {
                    LogHelper.Info($"ItemBack:创建任务失败,托盘:{model.Rfid}未找到绑定货位");
                    result.code = "1";
                    result.msg = $"创建任务失败,托盘:{model.Rfid}未找到绑定货位";
                    AddErrorInfo("查找托盘货位失败", result.msg);
                    LogHelper.Info($"ItemBack:{result.msg}");
                    AddErrorInfo("查找托盘货位失败", result.msg, Source);
                    return result;
                }
                #endregion
@@ -1455,10 +1549,11 @@
                        }
                        else
                        {
                            LogHelper.Info($"ItemBack:创建任务失败,物料号{model.PartNumber}不属于规定物料");
                            result.code = "1";
                            result.msg = $"创建任务失败,物料号{model.PartNumber}不属于规定物料";
                            AddErrorInfo("物料编码格式错误", result.msg);
                            LogHelper.Info($"ItemBack:{result.msg}");
                            AddErrorInfo("物料编码格式错误", result.msg, Source);
                            return result;
                        }
                        var EndLocs = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == areacode).ToList();
@@ -1473,7 +1568,7 @@
                            {
                                result.code = "1";
                                result.msg = $"终点库区:{areacode}无可用货位";
                                AddErrorInfo("查找库区失败", result.msg);
                                AddErrorInfo("查找库区失败", result.msg, Source);
                                return result;
                            }
@@ -1482,7 +1577,7 @@
                        {
                            result.code = "1";
                            result.msg = $"根据终点库区:{areacode},未找到对应货位";
                            AddErrorInfo("查找库区失败", result.msg);
                            AddErrorInfo("查找库区失败", result.msg, Source);
                            return result;
                        }
                        //loc = StorageCompute(itemcode, areacode);
@@ -1497,19 +1592,19 @@
                    }
                    else
                    {
                        LogHelper.Info($"库区:{areacode}无可用货位");
                        result.code = "1";
                        result.msg = $"库区:{areacode}无可用货位";
                        AddErrorInfo("查找货位失败", result.msg);
                        AddErrorInfo("查找货位失败", result.msg, Source);
                        return result;
                    }
                }
                else
                {
                    LogHelper.Info($"货位:{Start}找不到对应货位");
                    result.code = "1";
                    result.msg = $"货位:{Start}找不到对应货位";
                    AddErrorInfo("查找货位失败", result.msg);
                    AddErrorInfo("查找货位失败", result.msg, Source);
                    return result;
                }
@@ -1599,11 +1694,12 @@
                msg = "线边库存查询成功"
            };
            string Source = "MES";
            if (model == null)
            {
                result.code = "1";
                result.msg = "参数为null";
                AddErrorInfo("参数为空", result.msg);
                AddErrorInfo("参数为空", result.msg, Source);
                return result;
            }
@@ -1650,11 +1746,12 @@
        internal static Result add(add model)
        {
            Result result = new Result() { code = "200", msg = "物料主数据创建成功" };
            string Source = "MES";
            if (model == null)
            {
                result.code = "1";
                result.msg = "参数为null";
                AddErrorInfo("参数为空", result.msg);
                AddErrorInfo("参数为空", result.msg, Source);
                return result;
            }
            try
@@ -1663,24 +1760,26 @@
                if (db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE == model.PartNumber).Count() > 0)
                {
                    result.code = "1";
                    result.msg = "物料主数据已存在";
                    AddErrorInfo("物料主数据已存在", result.msg);
                    result.msg = $"物料编码:{model.PartNumber}的物料主数据已存在";
                    //  AddErrorInfo("物料主数据已存在", result.msg, Source);
                    LogHelper.Info($"add:{result.msg}");
                    return result;
                }
                TN_Material itemInfo = new TN_Material();
                itemInfo.S_ITEM_CODE = model.PartNumber;
                itemInfo.ITEM_TYPE = model.PartClass;
                itemInfo.S_ITEM_NAME = model.PartDesc;
                itemInfo.REMARK1 = model.StewingTime.ToString("yyyy-MM-dd");
                itemInfo.REMARK2 = model.OverdueTime.ToString("yyyy-MM-dd");
                itemInfo.REMARK1 = model.StewingTime;
                itemInfo.REMARK2 = model.OverdueTime;
                itemInfo.S_MP_TYPE = model.Unit;
                db.Insertable<TN_Material>(itemInfo).ExecuteCommand();
                if (db.Insertable<TN_Material>(itemInfo).ExecuteCommand()>0)
                {
                    LogHelper.Info($"add:物料编码:{model.PartNumber}的物料主数据已同步");
                } ;
                return result;
            }
            catch (Exception ex)
            {
                result.code = "1";
                result.msg = $"物料主数据创建失败 错误信息:{ex}";
                LogHelper.Error("add Error:" + ex.ToString(), ex);
@@ -1696,11 +1795,12 @@
        internal static Result CreatTask(CreatTask model)
        {
            Result result = new Result() { code = "200", msg = "点对点任务创建成功" };
            string Source = "MES";
            if (model == null)
            {
                result.code = "1";
                result.msg = "参数为null";
                AddErrorInfo("参数为空", result.msg);
                AddErrorInfo("参数为空", result.msg, Source);
                return result;
            }
            string Start = ""; //取货点
@@ -1726,7 +1826,7 @@
                    {
                        result.code = "1";
                        result.msg = $"创建任务失败,根据起点{model.InitialLocation}未找到对应货位绑定托盘托盘";
                        AddErrorInfo("查找托盘失败", result.msg);
                        AddErrorInfo("查找托盘失败", result.msg, Source);
                        return result;
                    }
                }
@@ -1804,11 +1904,12 @@
        internal static Result CreatelevatorTask(Elevator model)
        {
            Result result = new Result() { code = "200", msg = "点对点任务创建成功" };
            string Source = "MES";
            if (model == null)
            {
                result.code = "1";
                result.msg = "参数为null";
                AddErrorInfo("参数为空", result.msg);
                AddErrorInfo("参数为空", result.msg, Source);
                return result;
            }
@@ -1828,17 +1929,18 @@
                    {
                        result.code = "1";
                        result.msg = $"创建任务失败,起点{startloc.S_CODE}有锁";
                        AddErrorInfo("货位有锁", result.msg);
                        AddErrorInfo("货位有锁", result.msg, Source);
                        return result;
                    }
                    var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == startloc.S_CODE).First();
                    if (cntr == null)
                    {
                        LogHelper.Info($"callfixture:创建空工装呼叫任务==>根据货位{endloc.S_CODE}未找到托盘货位绑定关系");
                        result.code = "1";
                        result.msg = $"起点{model.Data.start_loc_code}未查询绑定托盘";
                        AddErrorInfo("查找托盘失败", result.msg);
                        LogHelper.Info($"callfixture:创建空工装呼叫任务==>{result.msg}");
                        AddErrorInfo("查找托盘失败", result.msg, Source);
                        return result;
                    }
@@ -1852,7 +1954,7 @@
                    {
                        result.code = "1";
                        result.msg = $"创建任务失败,根据货位编码:{dtcode}未找到电梯货位";
                        AddErrorInfo("查找货位失败", result.msg);
                        AddErrorInfo("查找货位失败", result.msg, Source);
                        return result;
                    }
@@ -1936,6 +2038,7 @@
        {
            Result result = new Result() { code = "200", msg = "货位信息上传成功" };
            String Source = "MES";
            RequestList<UploadLoc> result1 = new RequestList<UploadLoc>();
            List<UploadLoc> listuploadloc = new List<UploadLoc>();
            var db = new SqlHelper<object>().GetInstance();
@@ -1959,7 +2062,7 @@
                {
                    result.code = "1";
                    result.msg = $"货位上传失败,根据货位编码{item.Location}未找到对应的货位信息";
                    AddErrorInfo("查找货位失败", result.msg);
                    AddErrorInfo("查找货位失败", result.msg, Source);
                    return result;
                }
            }
@@ -1990,7 +2093,7 @@
                LogHelper.Info($"物料到位回报失败=>回报地址没有配置");
                result.code = "1";
                result.msg = $"物料到位回报失败=>回报地址没有配置";
                AddErrorInfo("地址错误", result.msg);
                AddErrorInfo("地址错误", result.msg, Source);
            }
            return result;
        }
@@ -2004,11 +2107,12 @@
        internal static Result ClearLoc(ClearTask model)
        {
            Result result = new Result() { code = "200", msg = "库位清除成功" };
            string Source = "MES";
            if (model == null)
            {
                result.code = "1";
                result.msg = "参数为null";
                AddErrorInfo("参数为空", result.msg);
                AddErrorInfo("参数为空", result.msg, Source);
                return result;
            }
            string loc = model.LocationNum;
@@ -2048,7 +2152,7 @@
                {
                    result.code = "1";
                    result.msg = $"根据货位:{loc}找不到货位关系";
                    AddErrorInfo("货位为空", result.msg);
                    AddErrorInfo("货位为空", result.msg, Source);
                    return result;
                }
            }
@@ -2215,25 +2319,28 @@
            return result;
        }
        /// <summary>
        /// 创建托盘物料绑定关系
        /// 立库任务下发创建托盘物料绑定关系
        /// </summary>
        /// <param name="loc">货位编码</param>
        /// <param name="cntr">托盘编码</param>
        /// <param name="partNumber">物料编码</param>
        /// <param name="partDesc">物料描述</param>
        /// <param name="partType">物料类型</param>
        /// <param name="cntrtype">托盘类型</param>
        /// <param name="unit">物料单位</param>
        /// <param name="weight">物料重量</param>
        internal static bool CreateCntrIteminfo(string loc, string cntr, string partNumber, string partDesc, string partType, string batch, string unit, string weight, string cntrtype = "1", string level = "")
        internal static bool CreateCntrIteminfo(partData partData, taskData taskData)
        {
            return ContainerHelper.CreateCntrItem(loc, cntr, partNumber, partDesc, partType, cntrtype, batch, weight, unit, level);
            if (partData == null && taskData == null)
            {
                LogHelper.Info($"CreateCntrIteminfo==> 立库任务下发参数有空,创建物料托盘绑定关系失败");
                return false;
            }
            else
            {
                return ContainerHelper.CreateCntrItem(taskData.pickStation, partData.rfid, partData.partNumber, partData.partDesc, partData.partType, taskData.carrierType, partData.lotNumber, partData.weight, partData.unit,
                    taskData.tyreType, taskData.supplier, taskData.receiveLot, taskData.subpool, partData.productionTime, partData.maturityTime, taskData.grade);
            }
        }
        /// <summary>
        /// 根据托盘编码,机台编码,工装类型计算机台线边区域
        /// </summary>
        /// <param name="cntrcode">托盘编码</param>
        /// <param name="jtcode">机台编码</param>
        /// <param name="cntrType">托盘类型</param>
        /// <returns></returns>
        internal static Location Computeloc(string cntrcode, string jtcode, string cntrType)
        {
@@ -2273,7 +2380,7 @@
            {
                var error = new ErrorInfo
                {
                    EEEORMESSAGE = errorInfo,
                    ERRORMESSAGE = errorInfo,
                    TASKNO = taskno,
                    AREACODE = areacode,
                    REMAKE = remake,