huanghongfeng
2024-12-09 19e5b7583a2aa1968c674b4b35f618cc6c2e29ef
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -41,6 +41,7 @@
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Utilities;
using WIDESEAWCS_DTO.Enum;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_ITaskInfoRepository;
@@ -48,6 +49,7 @@
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
using static Microsoft.IO.RecyclableMemoryStreamManager;
namespace WIDESEAWCS_TaskInfoService
{
@@ -87,6 +89,7 @@
        public string urlQueryinventory = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlQueryinventory"];
        public string urlEmptyOutbound = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlEmptyOutbound"];
        public string urlRawmaterialout = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlRawmaterialout"];
        public string urlPalletQueryinventory = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlPalletQueryinventory"];
        /// <summary>
        /// æŽ¥æ”¶WMS任务信息
        /// </summary>
@@ -107,6 +110,7 @@
                    Dt_Task task = _mapper.Map<Dt_Task>(item);
                    task.TaskState = (int)TaskOutStatusEnum.OutNew;
                    task.Roadway = task.Roadway == "1" ? task.Roadway = "SC01" : task.Roadway = "SC02";
                    task.CreateDate = DateTime.Now;
                    tasks.Add(task);
                }
                BaseDal.AddData(tasks);
@@ -243,6 +247,10 @@
                        BaseDal.AddData(task);
                        return content = WebResponseContent.Instance.OK();
                    }
                    else
                    {
                        WriteLog.GetLog("PLC日志出库日志").Write($"空托出库失败,详情:{content.Message}", "需要空托");
                    }
                }
                return content = WebResponseContent.Instance.Error();
            }
@@ -295,6 +303,20 @@
            }
        }
        public WebResponseContent RequestWMSTask4()
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                return content = HttpHelper.Get<WebResponseContent>($"{urlPalletQueryinventory}");
            }
            catch (Exception ex)
            {
                return content = WebResponseContent.Instance.Error(ex.Message);
            }
        }
        /// <summary>
        /// æ ¹æ®æ·±åº“位向wms申请判断浅库位是否有货,是否需要进行移库操作
        /// </summary>
@@ -325,6 +347,10 @@
                            return task;
                        }
                    }
                }
                else
                {
                    WriteLog.GetLog("PLC日志").Write($"失败信息:{content.Message}", "移库信息");
                }
            }
@@ -403,7 +429,15 @@
        public Dt_Task IngStackerCraneTask2(string deviceNo)
        {
            //string deviceNot = deviceNo == "SC01" ? "1" : "2";
            return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting);
            try
            {
                return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
@@ -818,5 +852,63 @@
            }
            return content;
        }
        /// <summary>
        /// åˆ é™¤æ•°æ®
        /// </summary>
        /// <param name="keys">主键数组</param>
        /// <returns></returns>
        public virtual WebResponseContent DeleteData(object[] keys)
        {
            try
            {
                List<Dt_Task> tasks = BaseDal.QureyDataByIds(keys);
                foreach (Dt_Task task in tasks)
                {
                    _task_HtyService.AddTaskHty(task);
                }
                if (typeof(Dt_Task).GetNavigatePro() == null)
                    return BaseDal.DeleteDataByIds(keys) ? WebResponseContent.Instance.OK() : WebResponseContent.Instance.Error();
                else
                {
                    if (keys != null)
                    {
                        Type detailType = typeof(Dt_Task).GetDetailType();
                        string name = typeof(Dt_Task).GetMainIdByDetail();
                        List<object> dynamicDelKeys = new List<object>();
                        for (int i = 0; i < keys.Length; i++)
                        {
                            dynamicDelKeys.Add(keys[i]);
                        }
                        ((SqlSugarClient)BaseDal.Db).BeginTran();
                        if (dynamicDelKeys.Count > 0)
                            BaseDal.Db.Deleteable<object>().AS(detailType.Name).Where($"{name} in (@id)", new { id = dynamicDelKeys.ToArray() }).ExecuteCommandHasChange();
                        BaseDal.DeleteDataByIds(keys);
                        ((SqlSugarClient)BaseDal.Db).CommitTran();
                        return WebResponseContent.Instance.OK();
                    }
                    else
                    {
                        return WebResponseContent.Instance.Error("参数错误");
                    }
                }
            }
            catch (Exception ex)
            {
                ((SqlSugarClient)BaseDal.Db).RollbackTran();
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
    }
}