647556386
7 天以前 f29f358f589f5b1c2589c07b65845650be7aafef
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs
@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
@@ -36,6 +37,7 @@
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Basic;
using WIDESEA_Model.Models.Check;
using WIDESEA_Model.Models.Outbound;
namespace WIDESEA_OutboundService
{
@@ -66,6 +68,7 @@
        private readonly IReCheckOrderService _reCheckOrderService;
        private readonly ITask_HtyService _task_HtyService;
        private readonly ILogger<OutboundPickingService> _logger;
        private readonly IRepository<Dt_InterfaceLog> _interfaceLog;
        private Dictionary<string, string> stations = new Dictionary<string, string>
        {
@@ -84,7 +87,7 @@
        public OutboundPickingService(IRepository<Dt_PickingRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IStockService stockService,
            IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, ILocationInfoService locationInfoService,
            IOutboundOrderDetailService outboundOrderDetailService, ISplitPackageService splitPackageService, IOutboundOrderService outboundOrderService,
            IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService, IAllocateService allocateService, IRepository<Dt_InboundOrder> inboundOrderRepository, IInboundOrderDetailService inboundOrderDetailService, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IReCheckOrderService reCheckOrderService, ITask_HtyService task_HtyService) : base(BaseDal)
            IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService, IAllocateService allocateService, IRepository<Dt_InboundOrder> inboundOrderRepository, IInboundOrderDetailService inboundOrderDetailService, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IReCheckOrderService reCheckOrderService, ITask_HtyService task_HtyService,IRepository<Dt_InterfaceLog> interfaceLog) : base(BaseDal)
        {
            _unitOfWorkManage = unitOfWorkManage;
            _stockInfoService = stockInfoService;
@@ -106,6 +109,7 @@
            _warehouseAreaRepository = warehouseAreaRepository;
            _reCheckOrderService = reCheckOrderService;
            _task_HtyService = task_HtyService;
            _interfaceLog = interfaceLog;
        }
@@ -1703,6 +1707,7 @@
            }
            var targetAddress = originalTask.TargetAddress;
            _logger.LogInformation($"CreateReturnTaskAndHandleESS åˆ é™¤åŽ†å²ä»»åŠ¡: {orderNo} ï¼Œ {originalTask.TaskNum}");
            // åˆ é™¤åŽŸå§‹å‡ºåº“ä»»åŠ¡
            // _taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.自动完成);
            var result = _task_HtyService.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.人工删除);
@@ -1710,7 +1715,7 @@
            {
                await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync();
            }
            _logger.LogInformation($"CreateReturnTaskAndHandleESS åˆ é™¤åŽ†å²ä»»åŠ¡: {orderNo} ï¼Œ {originalTask.TaskNum},影响行  {result}");
            // ç»™ ESS å‘送流动信号和创建任务
            await SendESSCommands(palletCode, targetAddress, returnTask);
@@ -2850,10 +2855,11 @@
                var result1 = await _invokeMESService.FeedbackInbound(infeedmodel);
                if (result1 != null && result1.code == 200)
                {
                    var orderIds = inboundOrderDetails.Select(x => x.Id).Distinct().ToList();
                    _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
                    .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
                    _inboundOrderDetailService.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
                    .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
                    .Where(it => orderIds.Contains(it.Id)).ExecuteCommand();
                }
                //出库回传MES
@@ -2872,7 +2878,7 @@
                    status = outboundOrder.OrderStatus,
                    details = new List<FeedbackOutboundDetailsModel>()
                };
                foreach (var detail in outboundOrder.Details)
                foreach (var detail in outboundOrderDetails)
                {
                    // èŽ·å–è¯¥æ˜Žç»†å¯¹åº”çš„æ¡ç ä¿¡æ¯ï¼ˆä»Žé”å®šè®°å½•ï¼‰
                    var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
@@ -2902,17 +2908,36 @@
                          }).ToList();
                    outfeedmodel.details.AddRange(groupdata);
                }
                //存储回传参数,保证异常手动回传
                Dt_InterfaceLog interfaceLog = new Dt_InterfaceLog
                {
                    OrderNo = outboundOrder.UpperOrderNo,
                    DocumentNo = documentNo,
                    OrderType = "虚拟出入库",
                    Content = outfeedmodel.ToJson(),
                    ReturnToMESStatus = 0,
                    IsDeleted = false
                };
                _interfaceLog.AddData(interfaceLog);
                var result = await _invokeMESService.FeedbackOutbound(outfeedmodel);
                if (result != null && result.code == 200)
                {
                    var orderIds = outboundOrderDetails.Select(x => x.Id).Distinct().ToList();
                    await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
                        .SetColumns(x => x.ReturnToMESStatus == 1)
                        .Where(x => x.OrderId == outboundOrder.Id)
                        .Where(x => orderIds.Contains(x.Id))
                        .ExecuteCommandAsync();
                    await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
                        .SetColumns(x => x.ReturnToMESStatus == 1)
                        .Where(x => x.Id == outboundOrder.Id)
                        .ExecuteCommandAsync();
                    await _interfaceLog.Db.Updateable<Dt_InterfaceLog>()
                        .SetColumns(x => x.ReturnToMESStatus == 1)
                        .Where(x=>x.DocumentNo == documentNo)
                        .ExecuteCommandAsync();
                }
                return WebResponseContent.Instance.OK();
@@ -2923,6 +2948,30 @@
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        public WebResponseContent GetPurchaseOrderByBarcode(string barcode)
        {
            try
            {
                Dt_InboundOrderDetail inboundOrderDetail = _stockInfoDetailService.Db.Queryable<Dt_InboundOrderDetail>().Where(x=>x.Barcode == barcode&& x.OrderDetailStatus !=OrderDetailStatusEnum.Over.ObjToInt()).First();
                if(inboundOrderDetail == null)
                {
                    return WebResponseContent.Instance.Error($"未找到该条码{barcode}的入库明细或者明细状态已入智仓完成");
                }
                Dt_InboundOrder inboundOrder = _inboundOrderRepository.QueryFirst(x => x.Id == inboundOrderDetail.OrderId && x.OrderStatus != InOrderStatusEnum.入库完成.ObjToInt());
                if (inboundOrder == null)
                {
                    return WebResponseContent.Instance.Error($"该入库单{inboundOrder}状态已入智仓完成");
                }
                var resultData = new { purchaseOrderNo = inboundOrder.UpperOrderNo };
                return WebResponseContent.Instance.OK("查询采购单成功", data: resultData);
            }
            catch(Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        #endregion
        public WebResponseContent UnPalletQuantity(string orderNo)