wankeda
2025-03-13 a6a33f6916afbf1fc629baecb772939cda2ee981
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs
@@ -225,7 +225,73 @@
            return (true, "成功!");
        }
        //private static readonly object text = new object();
        /// <summary>
        /// å…¥åº“任务
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        public WebResponseContent InboundTask(SaveModel saveModel)
        {
            lock (text)
            {
                WebResponseContent content = new WebResponseContent();
                try
                {
                    string stationcode = saveModel.MainData["stationcode"].ToString();
                    string PalletCode = saveModel.MainData["PalletCode"].ToString();//需区分区域!!!!!!!!!
                    string PointName = saveModel.MainData["PointName"].ToString();
                    if (stationcode == "" || PalletCode == "" || PointName == "")//异常返回。。。。。。
                    {
                        return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"扫码数据不能为空"}");
                    }
                    Dt_CachePoint endCachePoint = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode.Contains("成品库") && x.PointName.Contains(PointName) && x.PointStatus == LocationStatusEnum.Free.ObjToInt());
                    if (endCachePoint == null)
                    {
                        return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"未找到成品库可用存放缓存架"}");
                    }
                    Dt_CachePoint point = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == stationcode && x.Materialtype == PalletCode);
                    if (point == null)
                    {
                        return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"扫码数据异常,未找到此缓存架或物料类型不匹配"}");
                    }
                    Dt_CachePoint points = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == stationcode && x.PointStatus == LocationStatusEnum.Free.ObjToInt());
                    if (points == null)
                    {
                        return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{"扫码数据异常,此缓存点已被锁定"}");
                    }
                    Dt_Task taskcode = BaseDal.QueryFirst(x => x.SourceAddress == stationcode || x.TargetAddress == stationcode);
                    if (taskcode != null)
                    {
                        return content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:该站点已存在任务");
                    }
                    List<Dt_Task> tasks = new List<Dt_Task>();
                    Dt_Task task = new Dt_Task()
                    {
                        CurrentAddress = "",
                        Grade = 1,
                        NextAddress = "",
                        PalletCode = "",
                        Roadway = "",
                        SourceAddress = stationcode,
                        TargetAddress = endCachePoint.PointCode,
                        TaskStatus = AGVTaskStatusEnum.AGV_New.ObjToInt(),
                        TaskType = TaskTypeEnum.Inbound.ObjToInt(),
                        Materialtype = PalletCode,
                        Depth = 1,
                        TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum))
                    };
                    tasks.Add(task);
                    Repository.AddData(tasks);
                    HCJLock(task);
                    content = WebResponseContent.Instance.OK();
                }
                catch (Exception ex)
                {
                    content = WebResponseContent.Instance.Error($"添加任务异常,错误信息:{ex.Message}");
                }
                return content;
            }
        }
    }
}