肖洋
2024-12-05 b5fe109b08ce6e1e78696bb7cf41f415dc6a4587
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1,4 +1,5 @@

using AngleSharp.Io;
using Mapster;
using Masuit.Tools;
using WIDESEA_Core.Const;
@@ -88,7 +89,7 @@
                    content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto);
                    //ValidateResponse(content);
                    var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString());
                    if (!result.Success)
                    if (!result.Success || !agingOutputDto.SerialNos[0].SerialNoResult)
                    {
                        task.Remark = "NG";
                    }
@@ -104,8 +105,8 @@
                await UpdateLocationAsync(loc);
                await DeleteStockInfoAsync(stock.Id);
                await DeleteStockInfoDetailsAsync(stock.StockInfoDetails);
                if (task.Roadway.Contains("FR") || task.Roadway.Contains("GW"))   //如果是分容或高温出库 将任务删除
                    await DeleteTaskAsync(task.TaskId);
                //if (task.Roadway.Contains("FR") || task.Roadway.Contains("GW") || task.TaskType == (int)TaskOutboundTypeEnum.OutTray)   //如果是分容或高温出库 将任务删除
                await DeleteTaskAsync(task.TaskId);
            });
            return content.OK("任务完成成功", task.Remark);
@@ -154,7 +155,7 @@
            {
                SlotNo = x.OrderNo.ToInt32(),
                SerialNo = x.SerialNumber,
                SerialNoResult = true,
                SerialNoResult = isNG,
                ParameterInfo = new List<ParameterInfoOutput> {
                    new ParameterInfoOutput() {
                        Value = outHours.ToString(),
@@ -397,13 +398,22 @@
            throw new Exception("未找到对应位置信息");
        var area = new Dt_AreaInfo();
        var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.SourceAddress);
        if (station.stationPLC == "1017")
            area = _areaInfoRepository.QueryFirst(x => x.AreaID == Convert.ToInt32(station.stationNGLocation));
        else
        if (task.Roadway.Contains("FR"))
        {
            area = _areaInfoRepository.QueryFirst(x => x.AreaID == loation.AreaId);
        if (area == null)
            throw new Exception("未找到对应区域信息");
        }
        else
        {
            var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.SourceAddress);
            if (station.stationPLC == "1017")
                area = _areaInfoRepository.QueryFirst(x => x.AreaID == Convert.ToInt32(station.stationNGLocation));
            else
                area = _areaInfoRepository.QueryFirst(x => x.AreaID == loation.AreaId);
            if (area == null)
                throw new Exception("未找到对应区域信息");
        }
        var boxDetail = boxing.BoxingInfoDetails.Adapt<List<DtStockInfoDetail>>();
        boxDetail.ForEach(x => { x.Status = (int)StockStateEmun.已入库; });
        var stock = new DtStockInfo()
@@ -429,6 +439,7 @@
            EquipmentCode = area.Spare2,
            Software = area.Spare3
        };
        var result = _agingInOrOutInputService.GetOCVInputAsync(agingInputDto).Result;
        var respone = JsonConvert.DeserializeObject<ResponeAgingInputDto>(result.Data.ToString());
        stock.LinedProcessFeedbackTime = respone.LinedProcessFeedbackTime;
@@ -482,11 +493,13 @@
        {
            case (int)TaskInboundTypeEnum.Inbound:
            case (int)TaskInboundTypeEnum.InTray:
            case (int)TaskInboundTypeEnum.InNG:
                LogFactory.GetLog("任务完成").InfoFormat(true, "入库任务", "");
                return await CompleteInboundTaskAsync(task);
            case (int)TaskOutboundTypeEnum.OutTray:
            case (int)TaskOutboundTypeEnum.Outbound:
            case (int)TaskOutboundTypeEnum.OutNG:
                LogFactory.GetLog("任务完成").InfoFormat(true, "出库任务", "");
                return await CompleteStackTaskAsync(task, stock);
@@ -780,7 +793,7 @@
            if (result.SerialNos.Count <= 0)
            {
                // 空托盘入库逻辑
                return await RequestTrayInTaskAsync(input);
                return await RequestTrayInTaskAsync(input);
            }
            var boxing = CreateBoxingInfo(result, input.PalletCode);
@@ -1365,6 +1378,18 @@
            }
            var stocks = _stockInfoRepository.QueryData(x => x.AreaCode == stock.AreaCode && x.ProductionLine == stock.ProductionLine && x.SpecialParameterDuration != stock.SpecialParameterDuration);
            if (stocks != null && stocks.Count > 0)
            {
                foreach (var item in stocks)
                {
                    item.SpecialParameterDuration = stock.SpecialParameterDuration;
                    item.ParameterInfos = stock.ParameterInfos;
                    item.OutboundTime = Convert.ToDateTime(item.LinedProcessFeedbackTime == null ? item.CreateDate : item.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(stock.SpecialParameterDuration));
                }
                var isUpdates = await _stockInfoRepository.UpdateDataAsync(stocks);
            }
            // 添加历史任务
            var isTaskHtyAdd = await _task_HtyRepository.AddDataAsync(taskHty) > 0;
@@ -1538,6 +1563,11 @@
        {
            task.TaskId = taskId;
            isResult = await _taskExecuteDetailRepository.AddDetailAsync(task, false, TaskDescription.GetTaskUpdateDescription(input.PalletCode, input.Position, ToAddress, TaskInStatusEnum.InNew.GetIntegralRuleTypeEnumDesc()));
            //var location = _locationRepository.QueryFirst(x => x.RoadwayNo == task.Roadway && x.LocationCode == task.TargetAddress);
            //location.LocationStatus = (int)LocationEnum.Lock;
            //var isLocation = _locationRepository.UpdateData(location);
            if (isResult)
            {
                // 创建WMS任务
@@ -1612,7 +1642,7 @@
             .OrderByDescending(g => g.Count()) // 根据每个组的元素数量排序
             .ToList(); // 取出数量最多的组
        Dictionary<string,int> result = new Dictionary<string,int>();
        Dictionary<string, int> result = new Dictionary<string, int>();
        foreach (var item in minGroup)
        {
            var number = BaseDal.QueryData(x => x.TargetAddress == item.Key).Count();