#region << 版 本 注 释 >>
|
/*----------------------------------------------------------------
|
* 命名空间:WIDESEAWCS_TaskInfoService
|
* 创建者:胡童庆
|
* 创建时间:2024/8/2 16:13:36
|
* 版本:V1.0.0
|
* 描述:
|
*
|
* ----------------------------------------------------------------
|
* 修改人:
|
* 修改时间:
|
* 版本:V1.0.1
|
* 修改说明:
|
*
|
*----------------------------------------------------------------*/
|
#endregion << 版 本 注 释 >>
|
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Linq;
|
using System.Reflection;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEAWCS_Common.TaskEnum;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.BaseServices;
|
using WIDESEAWCS_Core.Enums;
|
using WIDESEAWCS_ITaskInfoRepository;
|
using WIDESEAWCS_ITaskInfoService;
|
using WIDESEAWCS_Model.Models;
|
|
namespace WIDESEAWCS_TaskInfoService
|
{
|
public class TaskExecuteDetailService : ServiceBase<Dt_TaskExecuteDetail, ITaskExecuteDetailRepository>, ITaskExecuteDetailService
|
{
|
private readonly ITaskRepository _taskRepository;
|
|
public TaskExecuteDetailService(ITaskExecuteDetailRepository BaseDal, ITaskRepository taskRepository) : base(BaseDal)
|
{
|
_taskRepository = taskRepository;
|
}
|
|
public void AddTaskExecuteDetail(int taskId, string description = "")
|
{
|
try
|
{
|
bool isNormal = true;
|
Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskId);
|
if (task == null) return;
|
int taskNum = task.TaskNum;
|
int taskState = task.TaskState;
|
|
if(taskState > (int)TaskStatusEnum.Finish)
|
{
|
isNormal = false;
|
}
|
Dt_TaskExecuteDetail taskExecuteDetail = new()
|
{
|
IsManual = App.User?.UserId > 0,
|
IsNormal = isNormal,
|
TaskNum = taskNum,
|
TaskId = taskId,
|
TaskState = taskState,
|
Description = description,
|
CurrentAddress = task.CurrentAddress,
|
NextAddress = task.NextAddress,
|
};
|
BaseDal.AddData(taskExecuteDetail);
|
}
|
catch (Exception ex)
|
{
|
|
}
|
}
|
|
public void AddTaskExecuteDetail(List<int> taskNums, string description = "")
|
{
|
try
|
{
|
List<Dt_TaskExecuteDetail> taskExecuteDetails = new List<Dt_TaskExecuteDetail>();
|
foreach (var item in taskNums)
|
{
|
bool isNormal = true;
|
Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == item);
|
if (task == null) return;
|
int taskNum = task.TaskNum;
|
int taskState = task.TaskState;
|
|
if (taskState > (int)TaskStatusEnum.Finish)
|
{
|
isNormal = false;
|
}
|
Dt_TaskExecuteDetail taskExecuteDetail = new()
|
{
|
IsManual = App.User?.UserId > 0,
|
IsNormal = isNormal,
|
TaskNum = taskNum,
|
TaskId = task.TaskId,
|
TaskState = taskState,
|
Description = description,
|
CurrentAddress = task.CurrentAddress,
|
NextAddress = task.NextAddress,
|
};
|
taskExecuteDetails.Add(taskExecuteDetail);
|
}
|
|
BaseDal.AddData(taskExecuteDetails);
|
}
|
catch (Exception ex)
|
{
|
|
}
|
}
|
|
public WebResponseContent GetDetailInfo(int taskNum)
|
{
|
WebResponseContent content = new();
|
try
|
{
|
int active = -1;
|
List<object> list = new();
|
List<int> steps = new();
|
Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
|
if (task != null)
|
{
|
active = steps.IndexOf(task.TaskState) + 1;
|
|
}
|
|
content = WebResponseContent.Instance.OK(data: new { active, list });
|
}
|
catch (Exception ex)
|
{
|
|
}
|
return content;
|
}
|
|
public WebResponseContent GetDetailDatas(int taskNum)
|
{
|
WebResponseContent content = new();
|
try
|
{
|
Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
|
if (task != null)
|
{
|
List<Dt_TaskExecuteDetail> taskExecuteDetails = BaseDal.QueryData(x => x.TaskId == task.TaskId, new Dictionary<string, SqlSugar.OrderByType> { { nameof(Dt_TaskExecuteDetail.TaskDetailId), SqlSugar.OrderByType.Asc } });
|
|
content = WebResponseContent.Instance.OK(data: taskExecuteDetails);
|
}
|
else
|
{
|
content = WebResponseContent.Instance.Error($"未找到该任务信息,任务号:【{taskNum}】");
|
}
|
}
|
catch (Exception ex)
|
{
|
|
}
|
return content;
|
}
|
}
|
}
|