| | |
| | | using AutoMapper; |
| | | using Microsoft.AspNetCore.Mvc.ApiExplorer; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; |
| | | using SqlSugar; |
| | | using System.Reflection.Emit; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.MaterielEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_DTO.ERP; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_DTO.Outbound; |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_External.ERPService; |
| | | using WIDESEA_External.MESService; |
| | | using WIDESEA_External.Model; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundRepository; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_InboundRepository; |
| | | using WIDESEA_IOutboundRepository; |
| | | using WIDESEA_IOutboundService; |
| | |
| | | { |
| | | private readonly IMapper _mapper; |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IStockRepository _stockRepository; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IRecordService _recordService; |
| | | private readonly IStockRepository _stockRepository; |
| | | private readonly IStockService _stockService; |
| | | private readonly IBasicRepository _basicRepository; |
| | | private readonly IApiInfoRepository _apiInfoRepository; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IInvokeERPService _invokeERPService; |
| | | private readonly IPalletTypeInfoRepository _palletTypeInfoRepository; |
| | | private readonly IAGVStationInfoRepository _agvStationInfoRepository; |
| | | private readonly IPurchaseBSTOrderRepository _purchaseBSTOrderRepository; |
| | | private readonly IPurchaseBSTOrderDetailRepository _purchaseBSTOrderDetailRepository; |
| | | private readonly IOutBSTOrderDetailRepository _outBSTOrderDetailRepository; |
| | | private readonly IOutBSTOrderRepository _outBSTOrderRepository; |
| | | private readonly IOutBSTOrderDetailService _outBSTOrderDetailService; |
| | | private readonly IOutMESOrderService _outMESOrderService; |
| | | private readonly IOutMESOrderRepository _outMESOrderRepository; |
| | | private readonly IInvokeMESService _invokeMESService; |
| | | private readonly IOutboundRepository _outboundRepository; |
| | | private readonly IOutboundService _outboundService; |
| | | private readonly IInboundRepository _inboundRepository; |
| | | private readonly IInboundService _inboundService; |
| | | public ITaskRepository Repository => BaseDal; |
| | | |
| | | private Dictionary<string, OrderByType> _taskOrderBy = new() |
| | |
| | | |
| | | public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 100 && x < 500).ToList(); |
| | | |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService, IStockService stockService, IBasicRepository basicRepository, IApiInfoRepository apiInfoRepository, IInvokeERPService invokeERPService, IPalletTypeInfoRepository palletTypeInfoRepository, IAGVStationInfoRepository agvStationInfoRepository, IPurchaseBSTOrderRepository purchaseBSTOrderRepository, IPurchaseBSTOrderDetailRepository purchaseBSTOrderDetailRepository, IOutBSTOrderDetailRepository outBSTOrderDetailRepository, IOutBSTOrderRepository outBSTOrderRepository,IOutBSTOrderDetailService outBSTOrderDetailService, IOutMESOrderService outMESOrderService, IOutMESOrderRepository outMESOrderRepository) : base(BaseDal) |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService, IStockService stockService, IBasicRepository basicRepository, IInvokeERPService invokeERPService, IOutboundRepository outboundRepository, IOutboundService outboundService, IInboundRepository inboundRepository,IInboundService inboundService,IInvokeMESService invokeMESService) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _recordService = recordService; |
| | | _stockService = stockService; |
| | | _basicRepository = basicRepository; |
| | | _apiInfoRepository = apiInfoRepository; |
| | | _invokeERPService = invokeERPService; |
| | | _palletTypeInfoRepository = palletTypeInfoRepository; |
| | | _agvStationInfoRepository = agvStationInfoRepository; |
| | | _purchaseBSTOrderRepository = purchaseBSTOrderRepository; |
| | | _purchaseBSTOrderDetailRepository = purchaseBSTOrderDetailRepository; |
| | | _outBSTOrderRepository = outBSTOrderRepository; |
| | | _outBSTOrderDetailRepository = outBSTOrderDetailRepository; |
| | | _outBSTOrderDetailService = outBSTOrderDetailService; |
| | | _outMESOrderService = outMESOrderService; |
| | | _outMESOrderRepository = outMESOrderRepository; |
| | | _invokeMESService = invokeMESService; |
| | | _outboundRepository = outboundRepository; |
| | | _outboundService = outboundService; |
| | | _inboundRepository = inboundRepository; |
| | | _inboundService = inboundService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | try |
| | | { |
| | | if (tasks==null || tasks.Count == 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ä¼ å
¥ä»»å¡ä¸ºç©º"); |
| | | } |
| | | List<WMSTaskDTO> taskDTOs = _mapper.Map<List<WMSTaskDTO>>(tasks); |
| | | taskDTOs.ForEach(x => |
| | | { |
| | |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// ä»»å¡ä¿¡æ¯æ¨éè³WCS |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<string> ExistRoadwaysError() |
| | | { |
| | | try |
| | | { |
| | | string url = AppSettings.Get("WCS"); |
| | | if (string.IsNullOrEmpty(url)) |
| | | { |
| | | return null; |
| | | } |
| | | string response = HttpHelper.Get($"{url}/api/Task/ExistRoadwaysError"); |
| | | |
| | | return JsonConvert.DeserializeObject<List<string>>(response) ?? throw new Exception("è¿åé误"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | private readonly static object lockerAddSG = new object(); |
| | | public WebResponseContent AddOutSGOrder(List<SGOutOrderDTO> outOrderDTOs) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | lock (lockerAddSG) |
| | | { |
| | | int outDetailId = _outboundRepository.OutSGOrderDetailRepository.QueryData().OrderByDescending(x=>x.Id).FirstOrDefault()?.Id ?? 0; |
| | | content = _outboundService.OutSGOrderService.AddOutSGOrder(outOrderDTOs); |
| | | if (!content.Status) |
| | | { |
| | | return content; |
| | | } |
| | | //è·åææçåºåºè¯¦æ
夿æ¯å¦æ»¡è¶³åºåºéå°äº5ä¸ä¸å°äº17å· |
| | | //List<Dt_OutStockLockInfo> outStockLockInfos = _outboundRepository.OutStockLockInfoRepository.QueryData(x=>x.OrderType==OutOrderTypeEnum.OutSGPick.ObjToInt() && x.Status<OutLockStockStatusEnum.å
³é.ObjToInt()); |
| | | //decimal sumAssignQty = outStockLockInfos.Sum(x => x.AssignQuantity); |
| | | //int outCount= outStockLockInfos.Select(x=>x.PalletCode).Distinct().Count(); |
| | | //if (sumAssignQty < AppSettings.Get("OutSGLength").ObjToInt() && outCount < AppSettings.Get("OutSGCount").ObjToInt()) |
| | | //{ |
| | | List<int> ints = _outboundRepository.OutSGOrderDetailRepository.QueryData(x => x.Id > outDetailId).Select(x => x.Id).ToList(); |
| | | int[] reseponse = new int[ints.Count]; |
| | | for (int i = 0; i < ints.Count; i++) |
| | | { |
| | | reseponse[i] = ints[i]; |
| | | } |
| | | content.Message = CreateSGOutboundTasks(reseponse).Message; |
| | | //} |
| | | //else |
| | | //{ |
| | | // return content.Error($"å½ååºåºéï¼{sumAssignQty},å½ååºåºå·æ°ï¼{outCount},䏿»¡è¶³å°äº5ä¸ä¸å°äº17å·åºåºæ¡ä»¶"); |
| | | //} |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å¯ç¨ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent EnableStatus(int[] keys) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_Task> tasks = BaseDal.QueryData(x => x.TaskType < TaskTypeEnum.Inbound.ObjToInt()); |
| | | List<Dt_AGVStationInfo> stationInfos = _basicRepository.AGVStationInfoRepository.QueryData(x => keys.Contains(x.Id)); |
| | | foreach (var station in stationInfos) |
| | | { |
| | | Dt_Task? taskOld = tasks.FirstOrDefault(x => x.TargetAddress == station.AGVStationCode); |
| | | if (taskOld!=null) |
| | | { |
| | | content.Message+= $"{station.AGVStationCode}åºåº{taskOld.TaskNum}任塿§è¡ä¸;"; |
| | | continue; |
| | | } |
| | | if (station.StationArea==StationAreaEnum.䏿¥¼æåæ¶.ToString()) |
| | | { |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x=>x.LocationCode==station.AGVStationCode); |
| | | if (stockInfo!=null) |
| | | { |
| | | content.Message += $"{station.AGVStationCode}{stockInfo.PalletCode}åºåç»å®;"; |
| | | continue; |
| | | } |
| | | } |
| | | station.IsOccupied = WhetherEnum.False.ObjToInt(); |
| | | } |
| | | _basicRepository.AGVStationInfoRepository.UpdateData(stationInfos); |
| | | content.OK(content.Message.IsNullOrEmpty() ? "æå" : $"é¨åæåå¯ç¨!{content.Message}æ æ³å¯ç¨"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// ç¦ç¨ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent DisableStatus(int[] keys) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_AGVStationInfo> stationInfos = _basicRepository.AGVStationInfoRepository.QueryData(x => keys.Contains(x.Id)); |
| | | stationInfos.ForEach(x => |
| | | { |
| | | x.IsOccupied = WhetherEnum.True.ObjToInt(); |
| | | }); |
| | | _basicRepository.AGVStationInfoRepository.UpdateData(stationInfos); |
| | | content.OK("æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |