using Mapster;
|
using MapsterMapper;
|
using Microsoft.Extensions.Configuration;
|
using SqlSugar;
|
using System.DirectoryServices.Protocols;
|
using System.Text.Json;
|
using WIDESEA_Common.Constants;
|
using WIDESEA_Common.LocationEnum;
|
using WIDESEA_Common.StockEnum;
|
using WIDESEA_Common.TaskEnum;
|
using WIDESEA_Common.WareHouseEnum;
|
using WIDESEA_Core;
|
using WIDESEA_Core.BaseRepository;
|
using WIDESEA_Core.BaseServices;
|
using WIDESEA_Core.Core;
|
using WIDESEA_Core.Enums;
|
using WIDESEA_Core.Helper;
|
using WIDESEA_DTO.GradingMachine;
|
using WIDESEA_DTO.MES;
|
using WIDESEA_DTO.Stock;
|
using WIDESEA_DTO.Task;
|
using WIDESEA_IBasicService;
|
using WIDESEA_IStockService;
|
using WIDESEA_ITaskInfoService;
|
using WIDESEA_Model.Models;
|
|
namespace WIDESEA_TaskInfoService
|
{
|
public partial class TaskService
|
{
|
#region 分容柜接口
|
|
/// <summary>
|
/// 堆垛机取放货完成后物流通知化成分容柜完成信号
|
/// </summary>
|
public async Task<WebResponseContent> InOrOutCompletedAsync(GradingMachineInputDto input)
|
{
|
WebResponseContent content = new WebResponseContent();
|
if (string.IsNullOrWhiteSpace(input.PalletCode) || string.IsNullOrWhiteSpace(input.LocationCode))
|
{
|
return content.Error($"托盘号或者货位编号不能为空");
|
}
|
|
try
|
{
|
var stockInfo = await _stockInfoService.GetStockInfoAsync(input.PalletCode, input.LocationCode);
|
|
int locationStatus;
|
if (stockInfo == null)
|
{
|
var location = await _locationInfoService.GetLocationInfoAsync(input.LocationCode);
|
locationStatus = location?.LocationStatus ?? 0;
|
}
|
else
|
{
|
locationStatus = stockInfo.LocationDetails?.LocationStatus ?? 0;
|
}
|
|
OutputDto outPutDto = new OutputDto()
|
{
|
LocationCode = input.LocationCode,
|
PalletCode = input.PalletCode,
|
IsNormalProcedure = 1,
|
LocationStatus = locationStatus
|
};
|
return content.OK(data: outPutDto);
|
}
|
catch (Exception ex)
|
{
|
content.Error(ex.Message);
|
}
|
|
return content;
|
}
|
|
/// <summary>
|
/// 化成分容柜定时向物流更新分容柜状态信息
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public async Task<WebResponseContent> SendLocationStatusAsync(GradingMachineInputDto input)
|
{
|
WebResponseContent content = new WebResponseContent();
|
if (string.IsNullOrWhiteSpace(input.LocationCode))
|
{
|
return content.Error($"货位编号不能为空");
|
}
|
|
try
|
{
|
var result = await _locationInfoService.Db.Updateable<Dt_LocationInfo>()
|
.SetColumns(s => new Dt_LocationInfo
|
{
|
LocationStatus = input.LocationStatus
|
}).Where(s => s.LocationCode == input.LocationCode).ExecuteCommandAsync() > 0;
|
|
if (result)
|
{
|
content.OK("更新成功");
|
}
|
else
|
{
|
content.Error("更新失败");
|
}
|
}
|
catch (Exception ex)
|
{
|
content.Error(ex.Message);
|
}
|
return content;
|
}
|
|
/// <summary>
|
/// 分容柜工作完成后调用此接口通知物流出库
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public async Task<WebResponseContent> RequestOutboundAsync(GradingMachineInputDto input)
|
{
|
WebResponseContent content = new WebResponseContent();
|
if (string.IsNullOrWhiteSpace(input.LocationCode) || string.IsNullOrWhiteSpace(input.PalletCode))
|
{
|
return content.Error($"托盘号或者货位编号不能为空");
|
}
|
try
|
{
|
var stock = await _stockInfoService.GetStockInfoAsync(input.PalletCode, input.LocationCode);
|
if (stock == null)
|
{
|
content.Error("未找到对应的托盘");
|
}
|
else
|
{
|
var taskList = new Dt_Task
|
{
|
WarehouseId = stock.WarehouseId,
|
PalletCode = stock.PalletCode,
|
PalletType = stock.PalletType,
|
SourceAddress = stock.LocationCode,
|
CurrentAddress = stock.LocationCode,
|
NextAddress = TaskAddressConstants.DEFAULT_ADDRESS,
|
TargetAddress = TaskAddressConstants.GRADING_OUTBOUND_ADDRESS,
|
Roadway = stock.LocationDetails.RoadwayNo,
|
TaskType = TaskOutboundTypeEnum.Outbound.GetHashCode(),
|
TaskStatus = TaskOutStatusEnum.OutNew.GetHashCode(),
|
Grade = 1,
|
TaskNum = await BaseDal.GetTaskNo(),
|
Creater = "system",
|
};
|
|
var result = await BaseDal.AddDataAsync(taskList) > 0;
|
var wmstaskDto = result ? _mapper.Map<WMSTaskDTO>(taskList) : null;
|
|
var httpResponse = _httpClientHelper.Post<WebResponseContent>("http://logistics-service/api/logistics/notifyoutbound", JsonSerializer.Serialize(wmstaskDto)).Data;
|
if (result && httpResponse != null)
|
{
|
content.OK("出库请求成功");
|
}
|
else
|
{
|
content.Error("出库请求失败");
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
content.Error(ex.Message);
|
}
|
return content;
|
}
|
|
/// <summary>
|
/// 入库完成分容调用获取托盘上每个通道电芯
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public async Task<WebResponseContent> GetPalletCodeCellAsync(GradingMachineInputDto input)
|
{
|
WebResponseContent content = new WebResponseContent();
|
if (string.IsNullOrWhiteSpace(input.PalletCode) || string.IsNullOrWhiteSpace(input.LocationCode))
|
{
|
return content.Error($"托盘号或者货位编号不能为空");
|
}
|
try
|
{
|
var stockInfo = await _stockInfoService.GetStockInfoAsync(input.PalletCode, input.LocationCode);
|
if (stockInfo == null)
|
{
|
return content.Error("未找到对应的托盘");
|
}
|
var outPutDtos = stockInfo.Details.Select(x => new OutputDto()
|
{
|
LocationCode = input.LocationCode,
|
PalletCode = input.PalletCode,
|
IsNormalProcedure = 1,
|
LocationStatus = stockInfo.LocationDetails.LocationStatus,
|
CellCode = x.SerialNumber,
|
Channel = x.InboundOrderRowNo.ToString()
|
}).ToList();
|
return content.OK(data: outPutDtos);
|
}
|
catch (Exception ex)
|
{
|
return content.Error(ex.Message);
|
}
|
}
|
|
#endregion 分容柜接口
|
}
|
}
|