| | |
| | | #region MyRegion |
| | | |
| | | #region << 版 本 注 释 >> |
| | | |
| | | /*---------------------------------------------------------------- |
| | |
| | | |
| | | using AutoMapper; |
| | | using HslCommunication; |
| | | using Microsoft.AspNetCore.Server.HttpSys; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using SqlSugar; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Net; |
| | | using System.Reflection; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_BasicInfoService; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Caches; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.HttpContextUser; |
| | | using WIDESEAWCS_DTO.MOM; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_IProcessRepository; |
| | | using WIDESEAWCS_ISystemRepository; |
| | | using WIDESEAWCS_ISystemServices; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DeviceBase; |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_SignalR; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; |
| | | using ICacheService = WIDESEAWCS_Core.Caches.ICacheService; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | |
| | | if (conveyorLine != null) |
| | | { |
| | | #region 站台方式 |
| | | |
| | | List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode); |
| | | |
| | | foreach (var station in stationManagers) |
| | |
| | | } |
| | | |
| | | #region 调用事件总线通知前端 |
| | | var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); |
| | | if (tokenInfos == null || !tokenInfos.Any()) |
| | | { |
| | | //throw new Exception(conveyorLine.DeviceName + "缓存中未找到Token缓存"); |
| | | continue; |
| | | } |
| | | var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList(); |
| | | var userIds = tokenInfos?.Select(x => x.UserId).ToList(); |
| | | |
| | | object obj = new |
| | | { |
| | | station.stationChildCode, |
| | | commandAfter = command, |
| | | }; |
| | | _noticeService.StackerData(userIds?.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, data = obj }); |
| | | //var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); |
| | | //if (tokenInfos == null || !tokenInfos.Any()) |
| | | //{ |
| | | // //throw new Exception(conveyorLine.DeviceName + "缓存中未找到Token缓存"); |
| | | // continue; |
| | | //} |
| | | //var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList(); |
| | | //var userIds = tokenInfos?.Select(x => x.UserId).ToList(); |
| | | |
| | | //object obj = new |
| | | //{ |
| | | // station.stationChildCode, |
| | | // commandAfter = command, |
| | | //}; |
| | | //_noticeService.StackerData(userIds?.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, data = obj }); |
| | | |
| | | #endregion 调用事件总线通知前端 |
| | | } |
| | | #endregion |
| | | |
| | | #endregion 站台方式 |
| | | |
| | | #region 路由方式 |
| | | |
| | | //List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); |
| | | //foreach (string childDeviceCode in childDeviceCodes) |
| | | //{ |
| | |
| | | // } |
| | | // } |
| | | //} |
| | | #endregion |
| | | |
| | | #endregion 路由方式 |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | public void RequestOutbound(CommonConveyorLine_BZ conveyorLine, ConveyorLineTaskCommand_After command, Dt_StationManager station) |
| | | { |
| | | //查询对应产线的在途数据 |
| | | dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.productLine == station.stationRemark); |
| | | dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.productLine == station.productLine && x.toArea == station.stationChildCode); |
| | | |
| | | //needBarcode.haveOutNum |
| | | needBarcode.inLineNum = _taskRepository.QueryData(x => x.TargetAddress == station.stationChildCode).Count(); |
| | | |
| | | //若在途数量小于目标位置的缓存数量 则寻找对应常温库存中常温3工序的可出库数据 并建立出库任务 |
| | | if (needBarcode.inLineNum <= needBarcode.cacheNum) |
| | | if (needBarcode.inLineNum < needBarcode.cacheNum) |
| | | { |
| | | if (_taskService.RequestOutTaskToBZAsync(station).Result.Status) |
| | | { |
| | |
| | | dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.toArea == station.stationChildCode); |
| | | if (needBarcode == null) throw new Exception($"未配置相关{station.stationChildCode}的产线在途数据"); |
| | | |
| | | if (task != null) |
| | | if (task != null) //如任务不为空 则为送包装料 写入下一地址 清除对应任务 并更新在途数据 |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, task.NextAddress, station.stationChildCode); |
| | | _taskRepository.DeleteData(task); |
| | | } |
| | | else |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, station.stationNGChildCode, station.stationChildCode); |
| | | } |
| | | |
| | | needBarcode.inLineNum--; |
| | | _needBarcodeRepository.UpdateData(needBarcode); |
| | | if (--needBarcode.inLineNum <= 0) needBarcode.inLineNum = 0; |
| | | _needBarcodeRepository.UpdateData(needBarcode); |
| | | } |
| | | else //如无任务 则判定为从NG口上料 调取MOM接口 判断返回参数 无异常则送入包装,有异常则退回NG口 |
| | | { |
| | | var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.MOMIP_BASE)?.ConfigValue; |
| | | var ipAddress = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.TrayCellsStatus)?.ConfigValue; |
| | | if (wmsBase == null || ipAddress == null) |
| | | { |
| | | throw new InvalidOperationException("MOM IP 未配置"); |
| | | } |
| | | TrayCellsStatusDto trayCells = new TrayCellsStatusDto() |
| | | { |
| | | Software = "WMS", |
| | | TrayBarcode = command.ConveyorLineBarcode, |
| | | EquipmentCode = station.stationEquipMOM, |
| | | SessionId = Guid.NewGuid().ToString(), |
| | | EmployeeNo = "MITest", |
| | | //SceneType = "1", |
| | | RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ") |
| | | }; |
| | | |
| | | var MOMIpAddress = wmsBase + ipAddress; |
| | | |
| | | var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.ToJsonString()).Result; |
| | | ResultTrayCellsStatus result1 = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(result); |
| | | |
| | | if (!result1.Success) |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, station.stationNGChildCode, station.stationChildCode); |
| | | } |
| | | else |
| | | { |
| | | //写入对应产线的目标地址 |
| | | if (station.productLine == "ZJ-7") |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, "", station.stationChildCode); |
| | | } |
| | | else |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, "", station.stationChildCode); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |