using MailKit.Search;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.Extensions.Logging;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Reflection;
|
using System.Reflection.Metadata;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEA_Common.LocationEnum;
|
using WIDESEA_Common.OtherEnum;
|
using WIDESEA_Common.StockEnum;
|
using WIDESEA_Common.TaskEnum;
|
using WIDESEA_Core;
|
using WIDESEA_Core.Enums;
|
using WIDESEA_Core.Helper;
|
using WIDESEA_DTO.Inbound;
|
using WIDESEA_DTO.Task;
|
using WIDESEA_Model.Models;
|
using static WIDESEA_ITaskInfoService.ITaskService;
|
|
namespace WIDESEA_TaskInfoService
|
{
|
public partial class TaskService
|
{
|
|
//任务完成接口
|
/// <summary>
|
/// 任务完成
|
/// </summary>
|
/// <param name="taskNum">任务号</param>
|
/// <returns>返回处理结果</returns>
|
public WebResponseContent TaskCompleted(int taskNum)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
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 content.Error("未找到任务类型对应业务处理逻辑");
|
}
|
catch (Exception ex)
|
{
|
return content.Error("任务完成失败,系统接口原因:" + ex.Message);
|
}
|
}
|
|
|
/// <summary>
|
/// 入库完成
|
/// </summary>
|
/// <param name="task"></param>
|
/// <returns></returns>
|
public WebResponseContent InboundTaskCompleted(Dt_Task task)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
//查库存
|
Dt_StockInfo stockInfo = _stockInfoService.GetStockInfo(task.PalletCode);
|
//查货位
|
Dt_LocationInfo locationInfo = _locationInfoService.GetLocationInfo(task.WarehouseId, task.TargetAddress);
|
|
Dt_StockInfoDetail dt_StockInfodetail = _stockDetailService.Repository.QueryData(x => x.Status == (int)StockStatusEmun.组盘暂存).Where(x => x.StockId == stockInfo.Id).FirstOrDefault();
|
|
|
stockInfo.LocationCode = task.TargetAddress;
|
stockInfo.StockStatus = StockStatusEmun.已入库.ObjToInt();
|
dt_StockInfodetail.Status = StockStatusEmun.已入库.ObjToInt();
|
locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
|
|
|
_unitOfWorkManage.BeginTran();
|
_stockInfoService.Repository.UpdateData(stockInfo);
|
_stockDetailService.Repository.UpdateData(dt_StockInfodetail);
|
_locationInfoService.Repository.UpdateData(locationInfo);
|
BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
|
_unitOfWorkManage.CommitTran();
|
return content.OK();
|
}
|
catch (Exception ex)
|
{
|
_unitOfWorkManage.RollbackTran();
|
return content.Error("入库任务完成失败,系统接口原因:" + ex.Message);
|
}
|
}
|
|
/// <summary>
|
/// 出库完成
|
/// </summary>
|
/// <param name="task"></param>
|
/// <returns></returns>
|
public WebResponseContent OutboundTaskCompleted(Dt_Task task)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
|
task.TaskStatus = TaskOutStatusEnum.OutFinish.ObjToInt();
|
|
|
_unitOfWorkManage.BeginTran();
|
BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
|
_unitOfWorkManage.CommitTran();
|
return content.OK();
|
}
|
catch (Exception ex)
|
{
|
_unitOfWorkManage.RollbackTran();
|
return content.Error("出库任务完成失败,系统接口原因:" + ex.Message);
|
}
|
}
|
|
//移库完成
|
public WebResponseContent RelocationTaskCompleted(Dt_Task task)
|
{
|
WebResponseContent content = new WebResponseContent();
|
try
|
{
|
Dt_StockInfo stockInfo = _stockInfoService.GetStockInfo(task.PalletCode);
|
|
Dt_LocationInfo locationpoint = _locationInfoService.GetLocationInfo(task.WarehouseId, task.SourceAddress);
|
Dt_LocationInfo locationEnd = _locationInfoService.GetLocationInfo(task.WarehouseId, task.TargetAddress);
|
List<Dt_LocationInfo> loca = new List<Dt_LocationInfo>();
|
|
stockInfo.LocationCode = locationEnd.LocationCode;
|
stockInfo.StockStatus = StockStatusEmun.已入库.ObjToInt();
|
|
locationpoint.LocationStatus = LocationStatusEnum.Free.ObjToInt();
|
locationEnd.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
|
loca.Add(locationpoint);
|
loca.Add(locationEnd);
|
|
_unitOfWorkManage.BeginTran();
|
_stockInfoService.Repository.UpdateData(stockInfo);
|
_locationInfoService.Repository.UpdateData(loca);
|
|
BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
|
_unitOfWorkManage.CommitTran();
|
return content.OK();
|
|
}
|
catch (Exception ex)
|
{
|
_unitOfWorkManage.RollbackTran();
|
return content.Error("移库任务完成失败,系统接口原因:" + ex.Message);
|
}
|
|
}
|
|
|
}
|
}
|