using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.Enums;
using WIDESEA_Core;
using WIDESEA_Model.Models;
using WIDESEA_Core.Helper;
using Microsoft.Extensions.Logging;
using MailKit.Search;
using System.Reflection.Metadata;
using static WIDESEA_ITaskInfoService.ITaskService;
using WIDESEA_Common;
using WIDESEA_Core.LogHelper;
using WIDESEA_DTO.Task;
using WIDESEA_Common.TaskEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.LocationEnum;
namespace WIDESEA_TaskInfoService
{
public partial class TaskService
{
///
/// 仅申请任务,让WCS根据路由确定下一地址
///
///
///
///
public WebResponseContent DeviceRequestInboundTaskSimple(string stationCode, string palletCode)
{
try
{
Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode);
if (task != null)
{
PushTasksToWCS(new List { task });
return WebResponseContent.Instance.OK($"该托盘已生成任务", _mapper.Map(task));
}
Dt_Task newTask = new Dt_Task()
{
CurrentAddress = stationCode,
Grade = 0,
NextAddress = stationCode,//堆垛机
PalletCode = palletCode,
OrderNo = "1",
Roadway = "1",
SourceAddress = "",
TargetAddress = "2-20-1",
TaskType = TaskTypeEnum.Inbound.ObjToInt(),
TaskStatus = TaskStatusEnum.New.ObjToInt(),
WarehouseId = 1,
//PalletType = GetPalletType(warehouse, palletCode),//GetPalletType(warehouse, palletCode)
Creater = "WCS",
CreateDate = DateTime.Now
};
_unitOfWorkManage.BeginTran();
int taskId = BaseDal.AddData(newTask);
newTask.TaskId = taskId;
//_stockRepository.UpdateData(stockInfo);
//_locationInfoRepository.UpdateData(locationInfo);
_unitOfWorkManage.CommitTran();
WMSTaskDTO wMSTaskDTO = _mapper.Map(newTask);
//PushTasksToWCS(new List { newTask });
return WebResponseContent.Instance.OK(data: wMSTaskDTO);
}
catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
return WebResponseContent.Instance.Error(ex.Message);
}
}
}
}