You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

211 lines
7.2 KiB
C#

using DS.Module.Core;
using DS.Module.Core.Attributes;
using DS.Module.DjyServiceStatus;
using DS.WMS.Core.TaskPlat.Dtos;
using DS.WMS.Core.TaskPlat.Interface;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
namespace DS.WMS.TaskApi.Controllers;
/// <summary>
/// 任务台相关接口
/// </summary>
public class TaskManageController : ApiController
{
private readonly ITaskManageService taskManageService;
public TaskManageController(ITaskManageService taskManageService)
{
this.taskManageService = taskManageService;
}
/// <summary>
/// 创建任务
/// </summary>
/// <param name="info">任务详情</param>
/// <returns>返回回执</returns>
[HttpPost("CreateTaskJob")]
[ApiUser(ApiCode = "BCTaskManage"), AllowAnonymous]
public async Task<DataResult> CreateTaskJob(TaskManageOrderMessageInfo info)
{
var result = await taskManageService.InitTaskJob(info);
return result;
}
/// <summary>
/// 创建BC任务
/// </summary>
/// <param name="file">文件</param>
/// <param name="modifyFile">BC变更内容后文件</param>
/// <param name="jsonData">BC任务详情JSON</param>
/// <returns>返回回执</returns>
[HttpPost("CreateBCTaskJob")]
[ApiUser(ApiCode = "BCTaskManage"), AllowAnonymous]
public async Task<DataResult> CreateBCTaskJob(IFormFile file, IFormFile modifyFile, [FromForm] string jsonData)
{
TaskManageOrderMessageInfo? info = JsonConvert.DeserializeObject<TaskManageOrderMessageInfo>(jsonData);
if (info == null)
{
throw new ArgumentException(nameof(jsonData));
}
var result = await taskManageService.InitTaskJob(info, file, modifyFile);
return result;
}
/// <summary>
/// (测试)工作流设置任务在个人下的状态
/// </summary>
[HttpPost("SetTaskUserStatus")]
[ApiUser(ApiCode = "BCTaskManage"), AllowAnonymous]
public async Task<DataResult> SetTaskUserStatus(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, TaskStatusEnum taskStatusEnum, DateTime? statusTime, [FromBody] List<RecvUserInfo> userInfos)
{
var result = await taskManageService.SetTaskUserStatus(bsno, taskBaseTypeEnum, taskStatusEnum, statusTime, userInfos);
return result;
}
/// <summary>
/// (测试)工作流设置任务状态
/// </summary>
[HttpPost("SetTaskStatus")]
[ApiUser(ApiCode = "BCTaskManage"), AllowAnonymous]
public async Task<DataResult> SetTaskStatus(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, TaskStatusEnum taskStatusEnum, DateTime? statusTime)
{
var result = await taskManageService.SetTaskStatus(bsno, taskBaseTypeEnum, taskStatusEnum, statusTime);
return result;
}
/// <summary>
/// (测试)工作流转交任务
/// </summary>
[HttpPost("TransferTask")]
[ApiUser(ApiCode = "BCTaskManage"), AllowAnonymous]
public async Task<DataResult> TransferTask(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, List<RecvUserInfo> userInfos)
{
var result = await taskManageService.TransferTask(bsno, taskBaseTypeEnum, userInfos);
return result;
}
/// <summary>
/// 任务台台账列表查询
/// </summary>
[HttpPost("GetPageAsync")]
public async Task<DataResult<List<dynamic>>> GetPageAsync(PageRequest<QueryTaskManageDto> querySearch)
{
var result = await taskManageService.GetPageAsync(querySearch);
return result;
}
/// <summary>
/// 获取登陆人相关的任务统计信息
/// </summary>
/// <param name="isReCalc">是否强制计算</param>
[HttpPost("GetCurrentTotalStat")]
public async Task<DataResult<TaskUserStatResultInfo>> GetCurrentTotalStat([FromQuery] bool isReCalc = false)
{
var result = await taskManageService.GetCurrentTotalStat(isReCalc);
return result;
}
/// <summary>
/// 完成任务(可批量)
/// </summary>
/// <param name="Ids">任务主键数组</param>
/// <returns>返回结果</returns>
[HttpPost("CompleteTask")]
public async Task<DataResult<TaskManageOrderResultDto>> CompleteTask([FromBody] long[] Ids)
{
var result = await taskManageService.CompleteTask(Ids);
return result;
}
/// <summary>
/// 取消任务(可批量)
/// </summary>
/// <param name="Ids">任务主键数组</param>
/// <returns>返回结果</returns>
[HttpPost("CancelTask")]
public async Task<DataResult<TaskManageOrderResultDto>> CancelTask([FromBody] long[] Ids)
{
var result = await taskManageService.CancelTask(Ids);
return result;
}
/// <summary>
/// 获取任务台相关的枚举类型的值
/// </summary>
[HttpPost("GetTaskPlatEnumDict")]
public DataResult<object> GetTaskPlatEnumDict()
{
Dictionary<string, List<(string key, string value)>> dict = new()
{
{
"STATUS",
EnumUtil.GetEnumDictionaryWithKey(typeof(TaskStatusEnum))
.Select(x => (x.Key.ToString(), x.Value))
.ToList()
},
{
"TASK_TYPE",
EnumUtil.GetEnumDictionaryWithKey(typeof(TaskBaseTypeEnum))
.Select(x => (x.Key.ToString(), x.Value))
.ToList()
},
{
"SOURCE",
EnumUtil.GetEnumDictionaryWithKey(typeof(TaskSourceEnum))
.Select(x => (x.Key.ToString(), x.Value))
.ToList()
},
{
"CATEGORY",
EnumUtil.GetEnumDictionaryWithKey(typeof(TaskStatLevelEnum))
.Select(x => (x.Key.ToString(), x.Value))
.ToList()
}
};
var result = dict.Select(x => new
{
Type = x.Key,
Data = x.Value.Select(y => new
{
Code = y.key,
Name = y.value
})
});
return DataResult.Success(result);
}
/// <summary>
/// 设置任务处理人(可批量)
/// </summary>
/// <param name="taskIds"></param>
/// <param name="userInfo"></param>
[HttpPost("SetTaskOwner")]
public async Task<DataResult> SetTaskOwner([FromQuery] long[] taskIds, [FromBody] List<RecvUserInfo> userInfo)
{
await taskManageService.SetTaskOwner(taskIds, userInfo);
return DataResult.SuccessedWithDesc(nameof(MultiLanguageConst.OperationSuccess));
}
/// <summary>
/// 根据任务ID下载附件
/// </summary>
/// <param name="taskId">任务主键</param>
/// <param name="fileCategory">附件分类代码</param>
/// <returns>返回数据流</returns>
[HttpGet("DownloadFile")]
public async Task<IActionResult> DownloadFile([FromQuery] long taskId, [FromQuery] string fileCategory = "BC")
{
(string fileFullPath, string fileName) = await taskManageService.GetTaskFileInfo(taskId, fileCategory);
return PhysicalFile(fileFullPath, "application/octet-stream", fileName);
}
}