#region << 版 本 注 释 >>
|
/*----------------------------------------------------------------
|
* 命名空间:WIDESEA_TaskInfoService
|
* 创建者:胡童庆
|
* 创建时间:2024/8/2 16:13:36
|
* 版本:V1.0.0
|
* 描述:
|
*
|
* ----------------------------------------------------------------
|
* 修改人:
|
* 修改时间:
|
* 版本:V1.0.1
|
* 修改说明:
|
*
|
*----------------------------------------------------------------*/
|
#endregion << 版 本 注 释 >>
|
|
using AutoMapper;
|
using MailKit.Search;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Diagnostics.CodeAnalysis;
|
using System.Linq;
|
using System.Reflection;
|
using System.Reflection.Metadata;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEA_Core;
|
using WIDESEA_Core.BaseRepository;
|
using WIDESEA_Core.BaseServices;
|
using WIDESEA_Core.Enums;
|
using WIDESEA_Core.Helper;
|
using WIDESEA_DTO.Inbound;
|
using WIDESEA_DTO.Stock;
|
using WIDESEA_IBasicRepository;
|
using WIDESEA_IBasicService;
|
using WIDESEA_IOutboundRepository;
|
using WIDESEA_IOutboundService;
|
using WIDESEA_IRecordService;
|
using WIDESEA_IStockRepository;
|
using WIDESEA_IStockService;
|
using WIDESEA_ITaskInfoRepository;
|
using WIDESEA_ITaskInfoService;
|
using WIDESEA_Model.Models;
|
using WIDESEA_TaskInfoRepository;
|
|
namespace WIDESEA_TaskInfoService
|
{
|
public partial class TaskService : ServiceBase<Dt_Task, ITaskRepository>, ITaskService
|
{
|
private readonly IMapper _mapper;
|
private readonly IUnitOfWorkManage _unitOfWorkManage;
|
private readonly ILocationInfoService _locationInfoService;
|
private readonly IStockInfoService _stockInfoService;
|
private readonly ILocationStatusChangeRecordSetvice _locationStatusChangeRecordSetvice;
|
private readonly IOutboundOrderDetailService _outboundOrderDetailService;
|
private readonly IRoadwayInfoRepository _roadwayInfoRepository;
|
private readonly IOutStockLockInfoService _outStockLockInfoService;
|
|
public ITaskRepository Repository => BaseDal;
|
|
public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, ILocationInfoService locationInfoService, IStockInfoRepository stockInfoRepository, ILocationStatusChangeRecordSetvice locationStatusChangeRecordSetvice, IOutboundOrderDetailService outboundOrderDetailService, IRoadwayInfoRepository roadwayInfoRepository, IOutStockLockInfoService outStockLockInfoService, IStockInfoService stockInfoService) : base(BaseDal)
|
{
|
_mapper = mapper;
|
_locationInfoService = locationInfoService;
|
_stockInfoService = stockInfoService;
|
_locationStatusChangeRecordSetvice = locationStatusChangeRecordSetvice;
|
_outboundOrderDetailService = outboundOrderDetailService;
|
_roadwayInfoRepository = roadwayInfoRepository;
|
_unitOfWorkManage = unitOfWorkManage;
|
_outStockLockInfoService = outStockLockInfoService;
|
}
|
|
public WebResponseContent InboundTaskCompleted(Dt_Task task)
|
{
|
Dt_StockInfo stockInfo = _stockInfoService.Repository.GetStockInfo(task.PalletCode);
|
|
Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
|
|
CheckInboundCompleted(stockInfo, locationInfo);
|
|
stockInfo.LocationCode = locationInfo.LocationCode;
|
stockInfo.StockStatus = StockStatusEmun.已入库.ObjToInt();
|
_stockInfoService.Repository.UpdateData(stockInfo);
|
|
int beforeStatus = locationInfo.LocationStatus;
|
locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt();
|
_locationInfoService.Repository.UpdateData(locationInfo);
|
|
BaseDal.DeleteData(task);
|
|
_locationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);
|
|
return WebResponseContent.Instance.OK();
|
}
|
|
/// <summary>
|
/// 验证数据
|
/// </summary>
|
/// <param name="stockInfo"></param>
|
/// <param name="locationInfo"></param>
|
/// <returns></returns>
|
private (bool, string) CheckInboundCompleted(Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, bool isCheckStockDetail = true)
|
{
|
if (stockInfo == null)
|
{
|
return (false, "未找到组盘信息");
|
}
|
|
if (locationInfo == null)
|
{
|
return (false, "未找到货位信息");
|
}
|
|
if (isCheckStockDetail && (stockInfo.Details == null || stockInfo.Details.Count == 0))
|
{
|
return (false, "未找到组盘明细信息");
|
}
|
|
return (true, "成功");
|
}
|
|
/// <summary>
|
/// 任务完成
|
/// </summary>
|
/// <param name="taskNum">任务号</param>
|
/// <returns>返回处理结果</returns>
|
public WebResponseContent TaskCompleted(int taskNum)
|
{
|
Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
|
if (task == null)
|
{
|
return WebResponseContent.Instance.Error("未找到任务信息");
|
}
|
MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted");
|
if (methodInfo != null)
|
{
|
WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task });
|
if (responseContent != null)
|
{
|
return responseContent;
|
}
|
}
|
return WebResponseContent.Instance.Error();
|
}
|
|
}
|
}
|