wangxinhui
6 小时以前 5cf8be1f30878aeb2af568f471949d0b9190036a
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -18,6 +18,8 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
using System.DirectoryServices.Protocols;
@@ -30,6 +32,7 @@
using WIDESEAWCS_BasicInfoService;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.APIEnum;
using WIDESEAWCS_Common.Helper;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
@@ -66,6 +69,7 @@
        private readonly ILocationInfoRepository _locationInfoRepository;
        private readonly ILocationInfoService _locationInfoService;
        private readonly ILocationStatusChangeRecordService _locationStatusChangeRecordService;
        private readonly IErrorInfoRepository _errorInfoRepository;
        private Dictionary<string, OrderByType> _taskOrderBy = new()
            {
@@ -83,7 +87,7 @@
        public List<int> TaskRelocationTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 900 && x < 1000).ToList();
        public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IApiInfoRepository apiInfoRepository,ILocationInfoRepository locationInfoRepository,IUnitOfWorkManage unitOfWorkManage, ILocationInfoService locationInfoService,ILocationStatusChangeRecordService locationStatusChangeRecordService) : base(BaseDal)
        public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IApiInfoRepository apiInfoRepository,ILocationInfoRepository locationInfoRepository,IUnitOfWorkManage unitOfWorkManage, ILocationInfoService locationInfoService,ILocationStatusChangeRecordService locationStatusChangeRecordService,IErrorInfoRepository errorInfoRepository) : base(BaseDal)
        {
            _mapper = mapper;
            _cacheService = cacheService;
@@ -97,6 +101,7 @@
            _unitOfWorkManage = unitOfWorkManage;
            _locationInfoService = locationInfoService;
            _locationStatusChangeRecordService=locationStatusChangeRecordService;
            _errorInfoRepository = errorInfoRepository;
        }
        static object lock_taskReceive = new object();
        /// <summary>
@@ -116,8 +121,8 @@
                    List<Dt_Task> taskOlds = BaseDal.QueryData(x=> taskDTO.Tasks.Select(x => x.TaskDescribe.ContainerCode).Contains(x.PalletCode));
                    List<Dt_LocationInfo> locationInfos = _locationInfoRepository.GetCanOut(taskDTO.Tasks.Select(x=>x.TaskDescribe.ContainerCode).ToList());
                    List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData();
                    //下发任务组
                    string taskGroup= taskDTO.TaskGroupCode.IsNullOrEmpty() ? Guid.NewGuid().ToString().Replace("-","") : taskDTO.TaskGroupCode;
                    ////下发任务组
                    //string taskGroup= taskDTO.TaskGroupCode.IsNullOrEmpty() ? Guid.NewGuid().ToString().Replace("-","") : taskDTO.TaskGroupCode;
                    foreach (var item in taskDTO.Tasks.OrderBy(x=>x.TaskDescribe.ToStationCode))
                    {
                        if (item.TaskDescribe.ToStationCode.IsNullOrEmpty()) throw new Exception($"任务{item.TaskCode}出库目标操作台不能为空");
@@ -150,7 +155,7 @@
                        task.CurrentAddress = locationInfo.LocationCode;
                        task.NextAddress = stationManger.PickStationCode;
                        task.TargetAddress = stationManger.PickStationCode;
                        task.GroupId = taskGroup;
                        //task.GroupId = taskGroup;
                        task.TaskType = TaskTypeEnum.Outbound.ObjToInt();
                        task.Roadway = locationInfo.RoadwayNo;
                        task.DeviceCode = stationManger.CraneCode;
@@ -315,8 +320,8 @@
                                "Red" => "4",
                                _ => throw new Exception($"未找到颜色定义")
                            },
                            ORDERTYPE=taskSendLight.Mode.ToString(),
                            LIGHTTYPE="1",
                            ORDERTYPE="1",
                            LIGHTTYPE=taskSendLight.Mode.ToString(),
                        }
                    };
                    EPLightContent pLightContent = PickOrderInfoRequest(lightSendDTOs);
@@ -793,5 +798,30 @@
            }
            return content;
        }
        public override WebResponseContent Export(PageDataOptions options)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string savePath = AppDomain.CurrentDomain.BaseDirectory + "ExcelExport";
                // ç¡®ä¿ç›®å½•存在
                if (!Directory.Exists(savePath))
                    Directory.CreateDirectory(savePath);
                // èŽ·å–æ•°æ®
                ISugarQueryable<Dt_Task> query = BaseDal.Db.Queryable<Dt_Task>();
                var dataList = query.ToList();
                var properties = typeof(Dt_Task).GetProperties();
                string filePath = TExportHelper.GetExport(savePath, properties, dataList);
                return WebResponseContent.Instance.OK(data: filePath);
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
            }
            return content;
        }
    }
}