| | |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IStockRepository _stockRepository; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IBasicRepository _basicRepository; |
| | | private readonly IOutboundService _outboundService; |
| | | private readonly IInboundService _inboundService; |
| | | private readonly IInboundOrderDetailService _inboundOrderDetailService; |
| | |
| | | private readonly IOutboundOrderDetail_HtyService _outboundOrderDetail_HtyService; |
| | | private readonly IPalletTypeInfoRepository _palletTypeInfoRepository; |
| | | private readonly IOutboundOrderDetailRepository _outboundOrderDetailRepository; |
| | | private readonly IStockInfoDetailRepository _stockInfoDetailRepository; |
| | | public ITaskRepository Repository => BaseDal; |
| | | |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IMaterielInfoService materielInfoService, IInboundOrderDetail_HtyService inboundOrderDetail_HtyService, IOutboundOrder_HtyService outboundOrder_HtyService, IOutboundOrderDetail_HtyService outboundOrderDetail_HtyService, IInboundOrder_HtyService inboundOrder_HtyService, IStockRepository stockRepository, IInboundOrderDetailService inboundOrderDetailService, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService, IOutboundOrderDetailRepository outboundOrderDetailRepository) : base(BaseDal) |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IMaterielInfoService materielInfoService, IInboundOrderDetail_HtyService inboundOrderDetail_HtyService, IOutboundOrder_HtyService outboundOrder_HtyService, IOutboundOrderDetail_HtyService outboundOrderDetail_HtyService, IInboundOrder_HtyService inboundOrder_HtyService, IStockRepository stockRepository, IInboundOrderDetailService inboundOrderDetailService, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IBasicRepository basicRepository, IStockInfoDetailRepository stockInfoDetailRepository) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _stockRepository = stockRepository; |
| | |
| | | _outboundOrder_HtyService = outboundOrder_HtyService; |
| | | _outboundOrderDetail_HtyService = outboundOrderDetail_HtyService; |
| | | _outboundOrderDetailRepository = outboundOrderDetailRepository; |
| | | _basicRepository = basicRepository; |
| | | _stockInfoDetailRepository = stockInfoDetailRepository; |
| | | } |
| | | |
| | | public string ReceiveWMSTaskin = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskin"]; |
| | |
| | | /// </summary> |
| | | /// <param name="taskNum">任务号</param> |
| | | /// <returns>返回处理结果</returns> |
| | | public WebResponseContent TaskCompleted(int taskNum) |
| | | public async Task<WebResponseContent> TaskCompleted(int taskNum) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | Dt_Task task = await Repository.QueryFirstAsync(x => x.TaskNum == taskNum); |
| | | if (task == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到任务信息"); |
| | | return await Task.FromResult(WebResponseContent.Instance.Error($"未找到任务信息")); |
| | | } |
| | | MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted"); |
| | | if (methodInfo != null) |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) |
| | | { |
| | | WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); |
| | | if (responseContent != null) |
| | | { |
| | | return responseContent; |
| | | } |
| | | return await Task.FromResult(InboundTaskCompleted(taskNum)); |
| | | } |
| | | return WebResponseContent.Instance.Error("未找到任务类型对应业务处理逻辑"); |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | return await Task.FromResult(OutboundTaskCompleted(taskNum)); |
| | | } |
| | | //else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) |
| | | //{ |
| | | // return await Task.FromResult(RelocationTaskCompleted(task)); |
| | | //} |
| | | else |
| | | { |
| | | return await Task.FromResult(WebResponseContent.Instance.Error($"未找到该类型任务,任务类型:{task.TaskType}")); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message)); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 修改任务状态 |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent UpdateTaskInfo(WCSTaskDTO task) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task wmsTask = BaseDal.QueryFirst(x => x.TaskNum == task.TaskNum); |
| | | if (wmsTask != null) |
| | | { |
| | | wmsTask.TaskStatus = task.TaskState; |
| | | wmsTask.CurrentAddress = task.CurrentAddress; |
| | | wmsTask.NextAddress = task.NextAddress; |
| | | wmsTask.Dispatchertime = task.Dispatchertime; |
| | | BaseDal.UpdateData(wmsTask); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public WebResponseContent UpdateTaskStatus(int taskNum, int tasktype) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | |
| | | Dt_StockInfoDetail stockInfoDetail = stockInfo.Details.FirstOrDefault(x => x.StockId == stockInfo.Id); |
| | | |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.Repository.LocationCodesGetStockInfos(new List<string> { stockInfo.LocationCode }).Where(x => x.StockStatus == (int)StockStatusEmun.已入库.ObjToInt()).ToList(); |
| | | if (task.TaskType == TaskTypeEnum.PalletInbound.ObjToInt()) |
| | | if (task.TaskType == TaskTypeEnum.Inbound.ObjToInt()) |
| | | { |
| | | stockInfo.SerialNumber = stockInfos.Count + 1; |
| | | stockInfo.InDate = DateTime.Now; |
| | |
| | | _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail); |
| | | //_recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); |
| | | Db.Ado.CommitTran(); |
| | | SendInboundInfoToWMS(task, inboundOrder, stockInfoDetail); |
| | | SendInboundInfoToWMS(task, inboundOrder, stockInfo); |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | |
| | | // 更新入库单 |
| | | UpdateInboundOrder(inboundOrder, inboundOrderDetail); |
| | | |
| | | // 如果是最后一条明细,处理WMS回传 |
| | | if (inboundOrder.Details.Count == 1) |
| | | // 单据数量全部上架完成,处理WMS回传 |
| | | if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | { |
| | | var stockInfoDetail = stockInfo.Details.FirstOrDefault(); |
| | | SendInboundInfoToWMS(task, inboundOrder, stockInfoDetail); |
| | | SendInboundInfoToWMS(task, inboundOrder, stockInfo); |
| | | } |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | |
| | | int lastStatus, Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) |
| | | { |
| | | // 如果是最后一条明细 |
| | | if (inboundOrder.Details.Count == 1) |
| | | if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void SendInboundInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, Dt_StockInfoDetail stockInfoDetail) |
| | | private void SendInboundInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, Dt_StockInfo stockInfo) |
| | | { |
| | | if (stockInfoDetail == null) return; |
| | | |
| | | List<Dt_StockInfoDetail> dt_StockInfo = _stockInfoDetailRepository.QueryData(x => x.BatchNo == stockInfo.BatchNo).ToList(); |
| | | if (dt_StockInfo.Count == 0) return; |
| | | var houseInboundPassBack = new HouseInboundPassBack |
| | | { |
| | | ApiType = "AsnController", |
| | | Method = "AsrsGroudingAsn", |
| | | Parameters = new List<HouseInboundPassBack.data> |
| | | { |
| | | new HouseInboundPassBack.data |
| | | { |
| | | new HouseInboundPassBack.data |
| | | Value = new List<data.data1> |
| | | { |
| | | Value = new List<data.data1> |
| | | new data.data1 |
| | | { |
| | | new data.data1 |
| | | AsnNo = task.OrderNo, |
| | | InWarehouse = task.Roadway, |
| | | TransactionCode = inboundOrder.TransactionCode, |
| | | InoutType = inboundOrder.OrderType, |
| | | OrderType = inboundOrder.InoutType, |
| | | // 遍历所有库存明细,添加到 DetailList |
| | | DetailList = dt_StockInfo.Select(d => new data.data1.Inbound |
| | | { |
| | | AsnNo = task.OrderNo, |
| | | InWarehouse = task.Roadway, |
| | | TransactionCode = inboundOrder.TransactionCode, |
| | | InoutType = inboundOrder.OrderType, |
| | | OrderType = inboundOrder.InoutType, |
| | | DetailList = new List<data.data1.Inbound> |
| | | { |
| | | new data.data1.Inbound |
| | | { |
| | | LinId = stockInfoDetail.LinId, |
| | | MaterielCode = stockInfoDetail.MaterielCode, |
| | | OrderQuantity = stockInfoDetail.StockQuantity, |
| | | BatchNo = stockInfoDetail.BatchNo, |
| | | FinishQty = stockInfoDetail.StockQuantity, |
| | | LocationName = task.TargetAddress |
| | | } |
| | | } |
| | | } |
| | | LinId = d.LinId, |
| | | MaterielCode = d.MaterielCode, |
| | | OrderQuantity = d.StockQuantity, |
| | | BatchNo = d.BatchNo, |
| | | LPNNo = task.PalletCode, |
| | | FinishQty = d.StockQuantity, |
| | | LocationName = task.TargetAddress |
| | | }).ToList() |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | var authResult = AuthenticateWithWMS(); |
| | | if (authResult.IsSuccess) |
| | | { |
| | | houseInboundPassBack.Context = new Dictionary<string, string> |
| | | { |
| | | { "Ticket", authResult.Ticket }, |
| | | { "InvOrgId", authResult.InvOrgId } |
| | | }; |
| | | { |
| | | { "Ticket", authResult.Ticket }, |
| | | { "InvOrgId", authResult.InvOrgId } |
| | | }; |
| | | |
| | | HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskin, houseInboundPassBack, "立库入库数量回传WMS"); |
| | | } |
| | |
| | | ApiType = "AuthenticationController", |
| | | Parameters = new List<Parameter> |
| | | { |
| | | new Parameter { Value = "LKAdmin" }, |
| | | new Parameter { Value = "LKAdmin" } |
| | | new Parameter { Value = "LK-Admin" }, |
| | | new Parameter { Value = "LK-Admin" } |
| | | }, |
| | | Method = "Login", |
| | | }; |
| | | |
| | | var response = HttpHelper.Post<WebResponseContent>(ReceiveWMSTaskAUT, authentication, "登录WMS账号"); |
| | | |
| | | if (response.Status && response.Context != null) |
| | | if (response.Context != null) |
| | | { |
| | | return (true, response.Context["Ticket"].ToString(), response.Context["InvOrgId"].ToString()); |
| | | } |