using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEAWCS_Model.Models;
|
using WIDESEAWCS_Core;
|
using SqlSugar.Extensions;
|
using WIDESEAWCS_DTO.WMS;
|
using WIDESEAWCS_Common.LocationEnum;
|
using WIDESEAWCS_Common;
|
using WIDESEAWCS_Common.TaskEnum;
|
|
namespace WIDESEAWCS_TaskInfoService
|
{
|
public partial class TaskService
|
{
|
#region 凯乐士任务创建
|
/// <summary>
|
/// 创建凯乐士AGV入库任务
|
/// </summary>
|
/// <param name="taskDTO"></param>
|
/// <returns></returns>
|
public WebResponseContent CreateKLSNewInTask(TaskDTO taskDTO, int taskType)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
int containerType = taskDTO.containerCode.Contains("LLM") ? LocationTypeEnum.LargePallet.ObjToInt() : LocationTypeEnum.SmallPallet.ObjToInt();
|
//获取货位信息
|
Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode, containerType) ?? throw new Exception($"未找到终点库区【{taskDTO.toAreaCode}】可用空货位!");
|
Dt_Task dt_Task = new()
|
{
|
TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
|
WMSTaskNum = taskDTO.taskCode,
|
//WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
|
Grade = taskDTO.taskPriority,
|
PalletCode = taskDTO.containerCode,
|
Roadway = kLSLocationInfo.RoadwayNo,
|
TaskState = TaskStatusEnum.New.ObjToInt(),
|
TaskType = taskType,
|
SourceAddress = taskDTO.fromLocationCode,
|
CurrentAddress = taskDTO.fromLocationCode,
|
NextAddress = kLSLocationInfo.LocationCode,
|
TargetAddress = kLSLocationInfo.LocationCode,
|
Creater = "WMS",
|
};
|
kLSLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt();
|
try
|
{
|
Db.Ado.BeginTran();
|
BaseDal.AddData(dt_Task);
|
_kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
|
Db.Ado.CommitTran();
|
}
|
catch (Exception ex)
|
{
|
Db.Ado.RollbackTran();
|
throw new Exception(ex.Message);
|
}
|
|
return content.OK(data: new
|
{
|
taskCode = taskDTO.taskCode,
|
Message = "成功!"
|
});
|
}
|
catch (Exception ex)
|
{
|
content.Data = new
|
{
|
taskCode = taskDTO.taskCode,
|
Message = $"失败!{ex.Message}"
|
};
|
return content.Error(ex.Message);
|
}
|
}
|
/// <summary>
|
/// 创建凯乐士AGV出库任务
|
/// </summary>
|
/// <param name="taskDTO"></param>
|
/// <param name="taskType"></param>
|
/// <returns></returns>
|
public WebResponseContent CreateKLSNewOutTask(TaskDTO taskDTO, int taskType)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"未找到起点库位【{taskDTO.fromLocationCode}】!");
|
if (kLSLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"起点库位【{taskDTO.fromLocationCode}】当前库位状态不可出库!");
|
Dt_Task dt_Task = new()
|
{
|
TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
|
WMSTaskNum = taskDTO.taskCode,
|
//WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
|
Grade = taskDTO.taskPriority,
|
PalletCode = taskDTO.containerCode,
|
Roadway = kLSLocationInfo.RoadwayNo,
|
TaskState = TaskStatusEnum.New.ObjToInt(),
|
TaskType = taskType,
|
SourceAddress = taskDTO.fromLocationCode,
|
CurrentAddress = taskDTO.fromLocationCode,
|
NextAddress = taskDTO.toLocationCode,
|
TargetAddress = taskDTO.toLocationCode,
|
Creater = "WMS",
|
};
|
kLSLocationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt();
|
try
|
{
|
Db.Ado.BeginTran();
|
BaseDal.AddData(dt_Task);
|
_kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
|
Db.Ado.CommitTran();
|
}
|
catch (Exception ex)
|
{
|
Db.Ado.RollbackTran();
|
throw new Exception(ex.Message);
|
}
|
return content.OK(data: new
|
{
|
taskCode = taskDTO.taskCode,
|
Message = "成功!"
|
});
|
}
|
catch (Exception ex)
|
{
|
content.Data = new
|
{
|
taskCode = taskDTO.taskCode,
|
Message = $"失败!{ex.Message}"
|
};
|
return content.Error(ex.Message);
|
}
|
}
|
#endregion
|
|
#region 5 跨楼层运输任务创建
|
public WebResponseContent CarryTask(TaskDTO taskDTO, int taskType)
|
{
|
try
|
{
|
|
return WebResponseContent.Instance.OK();
|
}
|
catch (Exception ex)
|
{
|
throw new Exception(ex.Message);
|
}
|
}
|
#endregion
|
|
|
#region 6 裁剪送货
|
public WebResponseContent CJCarryTaske(TaskDTO taskDTO, int taskType)
|
{
|
try
|
{
|
|
return WebResponseContent.Instance.OK();
|
}
|
catch (Exception ex)
|
{
|
throw new Exception(ex.Message);
|
}
|
}
|
#endregion
|
}
|
}
|