任务链上报状态新增状态记录到系统日志
This commit is contained in:
@@ -3,11 +3,18 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Manager;
|
||||
using JNPF.Common.Net;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.EventBus;
|
||||
using JNPF.EventHandler;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -33,12 +40,22 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IWareHouseService _wareHouseService;
|
||||
|
||||
private readonly ICacheManager _cacheManager;
|
||||
private readonly IEventPublisher _eventPublisher;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public DeviceProviderService(ISqlSugarRepository<WmsInstockH> repository, IWareHouseService wareHouseService)
|
||||
|
||||
public DeviceProviderService(ISqlSugarRepository<WmsInstockH> repository, IWareHouseService wareHouseService,
|
||||
ICacheManager cacheManager,
|
||||
IEventPublisher eventPublisher,
|
||||
IUserManager userManger
|
||||
)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_wareHouseService = wareHouseService;
|
||||
_cacheManager = cacheManager;
|
||||
_eventPublisher = eventPublisher;
|
||||
_userManager = userManger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -101,7 +118,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// 任务链状态上报
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost, NonUnify,AllowAnonymous]
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Result> TaskChainCallBack(TaskChainCallBackInput input)
|
||||
{
|
||||
try
|
||||
@@ -110,8 +127,9 @@ namespace Tnb.WarehouseMgr
|
||||
switch (input.status)
|
||||
{
|
||||
case "CREATED": break;
|
||||
case "ALLOCATED":break;
|
||||
case "ALLOCATED": break;
|
||||
case "PROCESSING":
|
||||
if (await _cacheManager.GetAsync($"{input.taskChainCode}") == "任务链状态上报,上报状态PROCESSING") break;
|
||||
if (input.taskChainCode.Trim().IsNullOrEmpty()) break;
|
||||
var disTasks = await _db.Queryable<WmsDistaskH>().Where(it => it.bill_code.Contains(input.taskChainCode)).ToListAsync();
|
||||
var eps = await _db.Queryable<EqpEquipment>().Where(it => it.code.Contains(input.deviceID)).ToListAsync();
|
||||
@@ -127,6 +145,24 @@ namespace Tnb.WarehouseMgr
|
||||
case "FINISHED": break;
|
||||
default: break;
|
||||
}
|
||||
//写入redis
|
||||
await _cacheManager.SetAsync($"{input.taskChainCode}", $"任务链状态上报,上报状态{input.status}");
|
||||
var opts = App.GetOptions<ConnectionConfigOptions>();
|
||||
UserAgent userAgent = new(App.HttpContext);
|
||||
//写系统日志
|
||||
await _eventPublisher.PublishAsync(new LogEventSource("Log:CreateOpLog", opts, new SysLogEntity
|
||||
{
|
||||
Id = SnowflakeIdHelper.NextId(),
|
||||
Category = 4,
|
||||
UserId = _userManager.UserId,
|
||||
UserName = _userManager.User.RealName,
|
||||
IPAddress = NetHelper.Ip,
|
||||
RequestURL = App.HttpContext.Request.Path,
|
||||
RequestMethod = App.HttpContext.Request.Method,
|
||||
Json = $"任务链状态上报,任务链编号:{input.taskChainCode},上报状态:{input.status},设备编号:{input.deviceID}",
|
||||
PlatForm = string.Format("{0}-{1}", userAgent.OS.ToString(), userAgent.RawValue),
|
||||
CreatorTime = DateTime.Now
|
||||
}));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@@ -360,7 +360,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
dynamic reqBody = new ExpandoObject();
|
||||
reqBody.taskChainCode = k;
|
||||
reqBody.type = (int)EnumTaskChainType.KIVA;
|
||||
reqBody.type = (int)EnumTaskChainType.AGV;
|
||||
reqBody.sequential = false;
|
||||
reqBody.taskChainPriority = 0;
|
||||
reqBody.taskList = v;
|
||||
|
||||
Reference in New Issue
Block a user