dengjunjie
2024-12-24 18d1f45193e34e00fc1b6f65b8596ddb29c5267d
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -33,6 +33,7 @@
using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Stock;
using WIDESEA_DTO.Task;
using WIDESEA_External.ERPService;
using WIDESEA_IBasicRepository;
using WIDESEA_IBasicService;
using WIDESEA_IInboundService;
@@ -58,6 +59,8 @@
        private readonly IOutboundService _outboundService;
        private readonly IStockService _stockService;
        private readonly IBasicRepository _basicRepository;
        private readonly IApiInfoRepository _apiInfoRepository;
        private readonly IInvokeERPService _invokeERPService;
        public ITaskRepository Repository => BaseDal;
@@ -71,7 +74,7 @@
        public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList();
        public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService, IOutboundService outboundService, IStockService stockService, IBasicRepository basicRepository) : base(BaseDal)
        public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService, IOutboundService outboundService, IStockService stockService, IBasicRepository basicRepository, IApiInfoRepository apiInfoRepository, IInvokeERPService invokeERPService) : base(BaseDal)
        {
            _mapper = mapper;
            _unitOfWorkManage = unitOfWorkManage;
@@ -81,19 +84,23 @@
            _outboundService = outboundService;
            _stockService = stockService;
            _basicRepository = basicRepository;
            _apiInfoRepository = apiInfoRepository;
            _invokeERPService = invokeERPService;
        }
        /// <summary>
        /// ä»»åŠ¡ä¿¡æ¯æŽ¨é€è‡³WCS
        /// </summary>
        /// <returns></returns>
        public WebResponseContent PushTasksToWCS()
        public WebResponseContent PushTasksToWCS(List<Dt_Task> tasks, string agvDescription = "")
        {
            try
            {
                List<Dt_Task> tasks = BaseDal.QueryData(x => (TaskTypes.Contains(x.TaskType) && x.TaskStatus == (int)TaskStatusEnum.New));
                List<WMSTaskDTO> taskDTOs = _mapper.Map<List<WMSTaskDTO>>(tasks);
                taskDTOs.ForEach(x =>
                {
                    x.AGVArea = agvDescription;
                });
                string response = HttpHelper.Post("http://127.0.0.1:9291/api/Task/ReceiveTask", taskDTOs.Serialize());
                return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("返回错误");
@@ -155,9 +162,13 @@
                locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                //测试架入库库存状态
                if (task.TaskType == TaskTypeEnum.TestInbound.ObjToInt())
                if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
                {
                    stockInfo.StockStatus = StockStatusEmun.入库完成未建出库单.ObjToInt();
                    stockInfo.Details.ForEach(x =>
                    {
                        x.Status = StockStatusEmun.入库完成.ObjToInt();
                    });
                }
                else
                {
@@ -168,10 +179,10 @@
                _unitOfWorkManage.BeginTran();
                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.人工完成 : OperateTypeEnum.自动完成);
                _basicService.LocationInfoService.Repository.UpdateData(locationInfo);
                _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, (PalletTypeEnum)stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId);
                _stockRepository.StockInfoRepository.UpdateData(stockInfo);
                _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details);
                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationChangeType.InboundCompleted);
                _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, stockInfo.Details.Sum(x => x.StockQuantity), stockInfo.Details.Sum(x => x.StockQuantity), StockChangeTypeEnum.Inbound, taskNum);
                _unitOfWorkManage.CommitTran();
@@ -241,7 +252,7 @@
                int beforeStatus = locationInfo.LocationStatus;
                locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
                _basicService.LocationInfoService.Repository.UpdateData(locationInfo);
                _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, (PalletTypeEnum)stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId);
                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, (LocationStatusEnum)beforeStatus, LocationChangeType.OutboundCompleted, stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);