fix 任务图片连接处理
This commit is contained in:
76
Src/Dlhis.Middle/Controllers/AssignmentsController.cs
Normal file
76
Src/Dlhis.Middle/Controllers/AssignmentsController.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Middle.Api;
|
||||
using Dlhis.Middle.Request;
|
||||
using Dlhis.Middle.Response;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Dlhis.Middle.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 任务分配
|
||||
/// </summary>
|
||||
[Route("api/scheduled/[controller]")]
|
||||
[ApiController]
|
||||
public class AssignmentsController : ControllerBase
|
||||
{
|
||||
private readonly IAssignmentDeviceTaskApi _assignmentDeviceTaskApi;
|
||||
private readonly string _internalIp;
|
||||
|
||||
public AssignmentsController(IAssignmentDeviceTaskApi assignmentDeviceTaskApi, IConfiguration configuration)
|
||||
{
|
||||
_assignmentDeviceTaskApi = assignmentDeviceTaskApi;
|
||||
_internalIp = configuration.GetSection("InternalIP").Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取设备任务(按设备)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[IgnoreTenant]
|
||||
[HttpGet("deviceTasks")]
|
||||
public async Task<DefaultApiResult<List<DeviceTaskToDeviceByDeviceResponse>>> DeviceGetTasksGetAsync([FromQuery] DeviceTaskGetRequest request)
|
||||
{
|
||||
var result = await _assignmentDeviceTaskApi.DeviceGetTasksAsync(request);
|
||||
foreach (var data in result.Data)
|
||||
{
|
||||
foreach (var task in data.Tasks.Where(x => x.Type != DeviceTaskEnumType.Delete))
|
||||
{
|
||||
var currentUser = JObject.FromObject(task.Info).ToObject<UserToDeviceResponse>();
|
||||
var token = QueryHelpers.ParseQuery(currentUser.Face).First().Value;
|
||||
currentUser.Face = $"http://{_internalIp}/api/basic/gainfos/face?token=" + token;
|
||||
|
||||
task.Info = currentUser;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取设备任务(按设备)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("deviceTasks")]
|
||||
[IgnoreTenant]
|
||||
public async Task<DefaultApiResult<List<DeviceTaskToDeviceByDeviceResponse>>> DeviceGetTasksPostAsync(DeviceTaskGetRequest request)
|
||||
{
|
||||
var result = await _assignmentDeviceTaskApi.DeviceGetTasksAsync(request);
|
||||
foreach (var data in result.Data)
|
||||
{
|
||||
foreach (var task in data.Tasks.Where(x => x.Type != DeviceTaskEnumType.Delete))
|
||||
{
|
||||
var currentUser = JObject.FromObject(task.Info).ToObject<UserToDeviceResponse>();
|
||||
var token = QueryHelpers.ParseQuery(currentUser.Face).First().Value;
|
||||
currentUser.Face = $"http://{_internalIp}/api/basic/gainfos/face?token=" + token;
|
||||
|
||||
task.Info = currentUser;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user