zhuangpei-mesbackend/ZR.Service/MES/dev/DeviceTaskExecuteService.cs

649 lines
25 KiB
C#
Raw Normal View History

2024-05-31 10:17:33 +08:00
using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using ZR.Model;
using ZR.Repository;
2024-06-03 18:26:07 +08:00
2024-05-31 10:17:33 +08:00
using System.Linq;
2024-06-03 18:26:07 +08:00
2024-06-01 11:20:28 +08:00
using JinianNet.JNTemplate;
2024-06-03 15:45:21 +08:00
using Microsoft.AspNetCore.Authentication;
2024-06-03 18:26:07 +08:00
using ZR.Model.MES.dev;
using ZR.Model.MES.dev.Dto;
using ZR.Service.MES.dev.IService;
2024-06-04 11:25:17 +08:00
using Newtonsoft.Json.Linq;
2024-06-05 11:43:38 +08:00
using JinianNet.JNTemplate.Nodes;
2024-06-05 13:24:53 +08:00
using Mapster;
2024-05-31 10:17:33 +08:00
namespace ZR.Service.MES.dev
{
/// <summary>
/// 任务执行Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IDeviceTaskExecuteService), ServiceLifetime = LifeTime.Transient)]
public class DeviceTaskExecuteService : BaseService<DeviceTaskExecute>, IDeviceTaskExecuteService
{
/// <summary>
/// 查询任务执行列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<DeviceTaskExecuteDto> GetList(DeviceTaskExecuteQueryDto parm)
{
2024-06-17 10:17:04 +08:00
var predicate = Expressionable.Create<DeviceTaskExecute>()
.AndIF(!string.IsNullOrEmpty(parm.TaskName), it => it.TaskName.Contains(parm.TaskName))
2024-06-17 10:38:03 +08:00
.AndIF(parm.TimeRange != null && (parm.TimeRange[0] > new DateTime(1990, 1, 1)), it => it.CreatedTime >= parm.TimeRange[0])
.AndIF(parm.TimeRange != null && (parm.TimeRange[1] > new DateTime(1990, 1, 1)), it => it.CreatedTime <= parm.TimeRange[1])
2024-07-01 15:02:52 +08:00
.AndIF(parm.Type > -1, it => it.Type == parm.Type)
.AndIF(parm.Status > -1, it => it.Status == parm.Status)
2024-06-17 10:17:04 +08:00
;
2024-05-31 10:17:33 +08:00
var response = Queryable()
2024-06-04 11:25:17 +08:00
.OrderByDescending(x => x.Id)
2024-05-31 10:17:33 +08:00
.Where(predicate.ToExpression())
.ToPage<DeviceTaskExecute, DeviceTaskExecuteDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
2024-06-04 09:00:11 +08:00
public DeviceTaskExecute GetInfo(string Id)
2024-05-31 10:17:33 +08:00
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加任务执行
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DeviceTaskExecute AddDeviceTaskExecute(DeviceTaskExecute model)
{
2024-06-04 11:25:17 +08:00
model.Id = SnowFlakeSingle.Instance.NextId().ToString();
2024-05-31 10:17:33 +08:00
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改任务执行
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateDeviceTaskExecute(DeviceTaskExecute model)
{
//var response = Update(w => w.Id == model.Id, it => new DeviceTaskExecute()
//{
// TaskName = model.TaskName,
// Type = model.Type,
// DistributedTime = model.DistributedTime,
// StartTime = model.StartTime,
// EndTime = model.EndTime,
// Status = model.Status,
// Remark = model.Remark,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
return Update(model, true);
}
2024-06-24 17:09:07 +08:00
public int Update_task_status(DeviceTaskExecuteQueryDto2 parm)
{
var response = Update(w => w.Id == parm.Id, it => new DeviceTaskExecute()
{
2024-07-01 15:02:52 +08:00
2024-06-24 17:09:07 +08:00
Status = parm.Status,
2024-07-01 15:02:52 +08:00
2024-06-24 17:09:07 +08:00
UpdatedBy = parm.UpdatedBy,
UpdatedTime = parm.UpdatedTime,
});
return response;
}
2024-05-31 10:17:33 +08:00
/// <summary>
/// 清空任务执行
/// </summary>
/// <returns></returns>
public bool TruncateDeviceTaskExecute()
{
var newTableName = $"device_task_execute_{DateTime.Now:yyyyMMdd}";
if (Queryable().Any() && !Context.DbMaintenance.IsAnyTable(newTableName))
{
Context.DbMaintenance.BackupTable("device_task_execute", newTableName);
}
2024-06-01 11:20:28 +08:00
2024-05-31 10:17:33 +08:00
return Truncate();
}
/// <summary>
/// 导入任务执行
/// </summary>
/// <returns></returns>
public (string, object, object) ImportDeviceTaskExecute(List<DeviceTaskExecute> list)
{
var x = Context.Storageable(list)
.SplitInsert(it => !it.Any())
.SplitError(x => x.Item.Type.IsEmpty(), "任务类型1是巡检2是点检不能为空")
//.WhereColumns(it => it.UserName)//如果不是主键可以这样实现多字段it=>new{it.x1,it.x2}
.ToStorage();
var result = x.AsInsertable.ExecuteCommand();//插入可插入部分;
2024-06-01 11:20:28 +08:00
string msg = $"插入{x.InsertList.Count} 更新{x.UpdateList.Count} 错误数据{x.ErrorList.Count} 不计算数据{x.IgnoreList.Count} 删除数据{x.DeleteList.Count} 总共{x.TotalList.Count}";
2024-05-31 10:17:33 +08:00
Console.WriteLine(msg);
//输出错误信息
foreach (var item in x.ErrorList)
{
Console.WriteLine("错误" + item.StorageMessage);
}
foreach (var item in x.IgnoreList)
{
Console.WriteLine("忽略" + item.StorageMessage);
}
return (msg, x.ErrorList, x.IgnoreList);
}
2024-06-01 11:20:28 +08:00
/// <summary>
/// 任务计划调度 扫描每日巡检任务
/// </summary>
/// <returns></returns>
2024-06-03 15:45:21 +08:00
public int ScanEveryTask()
2024-06-01 11:20:28 +08:00
{
int result = 0;
// 今日时间
DateTime CurrentTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
//1. 扫描巡检
List<DeviceRouteInspectionPlan> deviceRouteInspectionPlan_execute_List = new List<DeviceRouteInspectionPlan>();
#region 1.1
2024-06-04 11:09:51 +08:00
List<DeviceRouteInspectionPlan> RouteInspectionPlan_day_List = Context.Queryable<DeviceRouteInspectionPlan>()
.Where(it => it.ExcuteCycleType == 1)
2024-06-01 11:20:28 +08:00
.Where(it => it.Status == 1).ToList();
2024-06-04 11:09:51 +08:00
Console.WriteLine("每日类型处理" + RouteInspectionPlan_day_List.Count);
2024-06-01 11:20:28 +08:00
if (RouteInspectionPlan_day_List != null && RouteInspectionPlan_day_List.Count > 0)
{
foreach (var item in RouteInspectionPlan_day_List)
{
//开始日期
DateTime start_cal = (DateTime)item.CreatedTime;
start_cal = new DateTime(start_cal.Year, start_cal.Month, start_cal.Day, 0, 0, 0);
//循环周期
int cycle_period = (int)item.DayNum;
DateTime date = start_cal;
do
{
date = date.AddDays(cycle_period);
if (date == CurrentTime)
{
//今日要执行任务
deviceRouteInspectionPlan_execute_List.Add(item);
break;
}
} while (date <= CurrentTime);
}
}
#endregion
#region 1.2
2024-06-04 11:09:51 +08:00
List<DeviceRouteInspectionPlan> DeviceRouteInspectionPlan_week_list = Context.Queryable<DeviceRouteInspectionPlan>().Where(it => it.ExcuteCycleType == 2).Where(it => it.Status == 1).ToList();
2024-06-01 11:20:28 +08:00
2024-06-04 11:09:51 +08:00
Console.WriteLine("每周类型处理" + DeviceRouteInspectionPlan_week_list.Count);
2024-06-01 11:20:28 +08:00
int dayofweek = (int)CurrentTime.DayOfWeek;
if (CurrentTime.DayOfWeek == DayOfWeek.Sunday)
{
dayofweek = 7;
}
if (DeviceRouteInspectionPlan_week_list != null && DeviceRouteInspectionPlan_week_list.Count > 0)
{
2024-06-04 11:09:51 +08:00
foreach (var item in DeviceRouteInspectionPlan_week_list)
2024-06-01 11:20:28 +08:00
{
string[] cycle_period = item.WeekList.Split(",");
2024-06-04 11:09:51 +08:00
if (cycle_period.Length > 0)
2024-06-01 11:20:28 +08:00
{
2024-06-04 11:09:51 +08:00
for (int i = 0; i < cycle_period.Length; i++)
{
2024-06-01 11:20:28 +08:00
2024-06-04 11:09:51 +08:00
try
{
2024-06-04 11:25:17 +08:00
Console.WriteLine("cycle_period[i]=" + cycle_period[i]);
2024-06-04 11:09:51 +08:00
if (dayofweek == Convert.ToInt32(cycle_period[i]))
{
deviceRouteInspectionPlan_execute_List.Add((DeviceRouteInspectionPlan)item); break;
}
}
catch (FormatException ex)
{
Console.WriteLine("An error occurred: " + ex.Message);
continue;
2024-06-04 11:25:17 +08:00
2024-06-04 11:09:51 +08:00
}
2024-06-01 11:20:28 +08:00
}
}
2024-06-04 11:25:17 +08:00
2024-06-01 11:20:28 +08:00
}
}
#endregion
#region 1.3
2024-06-04 11:09:51 +08:00
List<DeviceRouteInspectionPlan> DeviceRouteInspectionPlan_month_list = Context.Queryable<DeviceRouteInspectionPlan>().Where(it => it.ExcuteCycleType == 3).Where(it => it.Status == 1).ToList();
2024-06-03 15:45:21 +08:00
2024-06-04 11:09:51 +08:00
Console.WriteLine("每月类型处理" + DeviceRouteInspectionPlan_month_list.Count);
2024-07-01 15:02:52 +08:00
if (DeviceRouteInspectionPlan_month_list != null && DeviceRouteInspectionPlan_month_list.Count > 0)
2024-06-01 11:20:28 +08:00
{
2024-07-01 15:02:52 +08:00
foreach (var item in DeviceRouteInspectionPlan_month_list)
2024-06-01 11:20:28 +08:00
{
2024-06-04 11:25:17 +08:00
2024-07-01 15:02:52 +08:00
try
{
if (CurrentTime.Day == Convert.ToInt32(item.MonthDayList))
2024-06-01 11:20:28 +08:00
{
2024-07-01 15:02:52 +08:00
deviceRouteInspectionPlan_execute_List.Add((DeviceRouteInspectionPlan)item); break;
2024-06-04 11:09:51 +08:00
}
2024-07-01 15:02:52 +08:00
}
catch (FormatException ex)
{
Console.WriteLine("An error occurred: " + ex.Message);
continue;
2024-06-04 11:09:51 +08:00
2024-06-01 11:20:28 +08:00
}
2024-07-01 15:02:52 +08:00
2024-06-01 11:20:28 +08:00
}
}
#endregion
// 插入数据库
2024-06-03 15:45:21 +08:00
List<DeviceTaskExecute> executes = new List<DeviceTaskExecute>();
2024-06-04 11:25:17 +08:00
if (deviceRouteInspectionPlan_execute_List.Count > 0)
{
2024-06-04 11:09:51 +08:00
foreach (var item in deviceRouteInspectionPlan_execute_List)
{
2024-06-01 11:20:28 +08:00
2024-06-04 11:09:51 +08:00
DeviceTaskExecute taskExecute = new DeviceTaskExecute();
taskExecute.Id = SnowFlakeSingle.Instance.NextId().ToString();
taskExecute.TaskName = item.Name;
taskExecute.TaskId = item.Id;
taskExecute.Type = 1;
taskExecute.DistributedTime = DateTime.Now;
taskExecute.Status = 0;
taskExecute.CreatedTime = DateTime.Now;
executes.Add(taskExecute);
}
if (executes.Count > 0)
{
result = Context.Insertable(executes).ExecuteCommand();
}
2024-06-03 15:45:21 +08:00
2024-06-01 11:20:28 +08:00
}
2024-06-04 11:25:17 +08:00
2024-06-01 11:20:28 +08:00
return result;
}
/// <summary>
/// 派发点检任务
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
2024-06-03 15:45:21 +08:00
public int ExecutionTask_point(string id)
2024-06-01 11:20:28 +08:00
{
2024-06-03 15:45:21 +08:00
DevicePointInspectionPlan point = Context.Queryable<DevicePointInspectionPlan>().Where(it => it.Id == id).First();
2024-06-01 11:20:28 +08:00
DeviceTaskExecute taskExecute = new DeviceTaskExecute();
2024-06-04 11:25:17 +08:00
taskExecute.Id = SnowFlakeSingle.Instance.NextId().ToString();
2024-06-01 11:20:28 +08:00
taskExecute.TaskName = point.Name;
2024-06-03 15:45:21 +08:00
taskExecute.TaskId = point.Id;
taskExecute.Type = 2;
2024-06-01 11:20:28 +08:00
taskExecute.DistributedTime = DateTime.Now;
taskExecute.Status = 0;
taskExecute.CreatedTime = DateTime.Now;
2024-06-03 15:45:21 +08:00
return Context.Insertable(taskExecute).ExecuteCommand();
2024-06-01 11:20:28 +08:00
}
2024-06-03 15:45:21 +08:00
/// <summary>
/// 获取任务执行绑定的巡检任务和点检任务绑定的设备
/// </summary>
2024-06-04 11:25:17 +08:00
public List<DeviceAccount> AchieveTaskbindDevice(string id)
2024-06-03 15:45:21 +08:00
{
List<DeviceAccount> resul = null;
DeviceTaskExecute executeTask = Context.Queryable<DeviceTaskExecute>().Where(it => it.Id == id).First();
if (executeTask != null)
{
// 类型为巡检
if (executeTask.Type == 1)
{
resul = Context.Queryable<DeviceRelRpAt>()
.LeftJoin<DeviceAccount>((r, a) => r.FkDeviceAccountId == a.Id)
2024-06-04 09:41:46 +08:00
.Where(r => r.FkRouteInspectionPlanId == executeTask.TaskId)
2024-06-03 15:45:21 +08:00
.Select((r, a) => a)
.ToList();
}
// 类型为点检
else if (executeTask.Type == 2)
{
resul = Context.Queryable<DeviceRelPpAt>()
.LeftJoin<DeviceAccount>((p, a) => p.FkDeviceAccountId == a.Id)
.Where(p => p.FkPointInspectionPlanId == executeTask.TaskId)
2024-06-04 09:41:46 +08:00
.Select((p, a) => a)
2024-06-03 15:45:21 +08:00
.ToList();
}
}
return resul;
}
/// <summary>
/// 获取设备绑定的检查项
/// </summary>
public List<DeviceInspect> AchieveDevicebindInspect(int fk_device_id)
{
List<DeviceInspect> resul = null;
2024-06-04 11:25:17 +08:00
resul = Context.Queryable<DeviceRelAccountInspect>()
2024-06-03 15:45:21 +08:00
.LeftJoin<DeviceInspect>((r, i) => r.FkInspectId == i.Id)
.Where(r => r.FkAccountId == fk_device_id)
.Select((r, i) => i)
.ToList();
return resul;
}
/// <summary>
/// 获取检查项绑定的检查表单
/// </summary>
2024-06-04 11:25:17 +08:00
public List<DeviceFormConfig> AchieveInspectbindForm(int fk_device_inspect_id)
2024-06-03 15:45:21 +08:00
{
List<DeviceFormConfig> result = null;
2024-06-04 11:25:17 +08:00
result = Context.Queryable<DeviceFormConfig>()
2024-06-03 15:45:21 +08:00
.Where(it => it.FkDeviceInspectId == fk_device_inspect_id)
.ToList();
2024-06-04 11:25:17 +08:00
return result;
2024-06-03 15:45:21 +08:00
}
2024-06-04 11:25:17 +08:00
/// <summary>
/// 获取表单结果
/// </summary>
/// <returns></returns>
2024-06-05 16:16:33 +08:00
public List<DeviceTaskExecuteResult1_result> AchieveFormResult(DeviceTaskExecuteResult1QueryDto_TaskExecute query)
{
List<DeviceTaskExecuteResult1_result> final_result_list = new List<DeviceTaskExecuteResult1_result>();
2024-06-11 13:35:00 +08:00
List<DeviceTaskExecuteResult> resultList = Context.Queryable<DeviceTaskExecuteResult>()
2024-06-05 16:16:33 +08:00
.Where(it => it.PlanType == query.PlanType)
.Where(it => it.FkPlanId == query.FkPlanId)
.Where(it => it.FkDeviceId == query.FkDeviceId)
.Where(it => it.FkInspectId == query.FkInspectId)
.ToList();
if (resultList.Count == 0)
{
//初始化结果表
List<DeviceFormConfig> configlist = Context.Queryable<DeviceFormConfig>().Where(it => it.FkDeviceInspectId == query.FkInspectId).ToList();
if (configlist.Count > 0)
{
2024-06-11 13:35:00 +08:00
List<DeviceTaskExecuteResult> addResultList = new List<DeviceTaskExecuteResult>();
2024-06-05 16:16:33 +08:00
string PlanName = Context.Queryable<DeviceRouteInspectionPlan>().Where(it => it.Id == query.FkPlanId).First()?.Name;
string DeviceName = Context.Queryable<DeviceAccount>().Where(it => it.Id == query.FkDeviceId).First()?.DeviceName;
string InspectName = Context.Queryable<DeviceInspect>().Where(it => it.Id == query.FkInspectId).First()?.Name;
2024-07-01 15:02:52 +08:00
2024-06-05 16:16:33 +08:00
foreach (DeviceFormConfig config in configlist)
{
2024-06-11 13:35:00 +08:00
DeviceTaskExecuteResult result1 = new DeviceTaskExecuteResult();
2024-06-05 16:16:33 +08:00
result1.Id = SnowFlakeSingle.Instance.NextId().ToString();
result1.PlanType = query.PlanType;
result1.FkPlanId = query.FkPlanId;
result1.PlanName = PlanName;
result1.FkDeviceId = query.FkDeviceId;
result1.DeviceName = DeviceName;
result1.FkInspectId = query.FkInspectId;
result1.InspectName = InspectName;
result1.FormType = config.Type;
result1.FormTitle = config.Title;
result1.FormName = config.Content;
addResultList.Add(result1);
//生成返回结果
}
Context.Insertable(addResultList).ExecuteCommand();
// 处理初始化返回
if (addResultList.Count > 0)
{
// 1 取出所有的类别
int?[] FormTypeArray = addResultList.Select(it => it.FormType).Distinct().ToArray();
//2. 分别处理类别
for (int i = 0; i < FormTypeArray.Length; i++)
{
var temp = addResultList.Where(it => it.FormType == FormTypeArray[i]).ToList();
DeviceTaskExecuteResult1_result item = new DeviceTaskExecuteResult1_result();
item.Id = temp[0].Id;
item.Title = temp[0].FormTitle;
item.Type = temp[0].FormType;
item.Value = "";
item.Children = addResultList.Where(it => it.FormType == FormTypeArray[i]).Select(it => it.FormName).Distinct().ToArray();
item.Value = item.Children[0];
final_result_list.Add(item);
}
}
}
}
else if (resultList.Count > 0)
{
// 直接从结果表中获取
if (resultList.Count > 0)
{
// 1 取出所有的类别
int?[] FormTypeArray = resultList.Select(it => it.FormType).Distinct().ToArray();
//2. 分别处理类别
for (int i = 0; i < FormTypeArray.Length; i++)
{
var temp = resultList.Where(it => it.FormType == FormTypeArray[i]).ToList();
DeviceTaskExecuteResult1_result item = new DeviceTaskExecuteResult1_result();
item.Id = temp[0].Id;
item.Title = temp[0].FormTitle;
item.Type = temp[0].FormType;
item.Value = "";
item.Children = resultList.Where(it => it.FormType == FormTypeArray[i]).Select(it => it.FormName).Distinct().ToArray();
2024-06-11 13:35:00 +08:00
List<DeviceTaskExecuteResult> FormResultArray = resultList.Where(it => it.FormType == FormTypeArray[i]).ToList();
2024-06-05 16:16:33 +08:00
if (FormResultArray.Count == 1)
{
item.Value = FormResultArray[0].FormName;
}
else if (FormResultArray.Count > 1)
{
string[] str = new string[FormResultArray.Count];
for (int ii = 0; ii < str.Length; ii++)
{
str[i] = FormResultArray[ii].FormName;
}
item.Value = string.Join(", ", str).ToString();
}
else
{
item.Value = item.Children[0];
}
final_result_list.Add(item);
}
}
}
return final_result_list;
}
2024-06-05 15:02:11 +08:00
/// <summary>
2024-06-05 16:16:33 +08:00
/// 获取表单结果2
2024-06-05 15:02:11 +08:00
/// 结果表只存选中的结果,多选也只有一个结果
/// </summary>
/// <returns></returns>
public List<DeviceTaskExecuteResult1_result> AchieveFormResult2(DeviceTaskExecuteResult1QueryDto_TaskExecute query)
{
List<DeviceTaskExecuteResult1_result> final_result_list = new List<DeviceTaskExecuteResult1_result>();
// 获取 设备检查项 所有表单类型
List<DeviceFormConfig> all_config_list = Context.Queryable<DeviceFormConfig>().Where(it => it.FkDeviceInspectId == query.FkInspectId).ToList();
int?[] config_type = all_config_list.Select(it => it.Type).Distinct().ToArray();
if (config_type.Length > 0)
{
for (int i = 0; i < config_type.Length; i++)
{
//在结果表里查看是否有结果
2024-06-11 13:35:00 +08:00
DeviceTaskExecuteResult executeResult = Context.Queryable<DeviceTaskExecuteResult>()
2024-06-05 15:02:11 +08:00
.Where(it => it.PlanType == query.PlanType)
.Where(it => it.FkPlanId == query.FkPlanId)
.Where(it => it.FkDeviceId == query.FkDeviceId)
.Where(it => it.FkInspectId == query.FkInspectId)
2024-06-05 15:48:16 +08:00
.Where(it => it.FormType == config_type[i])
2024-06-05 15:02:11 +08:00
.First();
2024-06-05 16:16:33 +08:00
2024-06-05 15:02:11 +08:00
if (executeResult != null)
{
DeviceTaskExecuteResult1_result item = new DeviceTaskExecuteResult1_result();
item.Id = executeResult.Id;
item.Title = executeResult.FormTitle;
item.Value = executeResult.FormName;
item.Type = executeResult.FormType;
item.Children = all_config_list.Where(it => it.Type == config_type[i]).Select(it => it.Content).ToArray();
final_result_list.Add(item);
}
else
{
2024-06-11 13:35:00 +08:00
DeviceTaskExecuteResult insertData = new DeviceTaskExecuteResult();
2024-06-05 15:02:11 +08:00
insertData.Id = SnowFlakeSingle.Instance.NextId().ToString();
insertData.PlanType = query.PlanType;
insertData.FkPlanId = query.FkPlanId;
2024-07-01 15:02:52 +08:00
if (query.PlanType == 1)
2024-06-05 15:47:49 +08:00
{
2024-06-05 16:16:33 +08:00
insertData.PlanName = Context.Queryable<DeviceRouteInspectionPlan>().Where(it => it.Id == query.FkPlanId).First()?.Name;
2024-07-01 15:02:52 +08:00
}
else if (query.PlanType == 2)
2024-06-05 15:47:49 +08:00
{
2024-06-05 16:16:33 +08:00
insertData.PlanName = Context.Queryable<DevicePointInspectionPlan>().Where(it => it.Id == query.FkPlanId).First()?.Name;
2024-06-05 15:47:49 +08:00
}
2024-07-01 15:02:52 +08:00
2024-06-05 15:02:11 +08:00
insertData.FkDeviceId = query.FkDeviceId;
2024-07-01 15:02:52 +08:00
insertData.DeviceName = Context.Queryable<DeviceAccount>().Where(it => it.Id == query.FkDeviceId).First().DeviceName;
2024-06-05 15:02:11 +08:00
insertData.FkInspectId = query.FkInspectId;
2024-07-01 15:02:52 +08:00
insertData.InspectName = Context.Queryable<DeviceInspect>().Where(it => it.Id == query.FkInspectId).First().Name;
2024-06-05 15:02:11 +08:00
insertData.FormType = config_type[i];
insertData.FormTitle = all_config_list.Where(it => it.Type == config_type[i]).Select(it => it.Title).First();
Context.Insertable(insertData).ExecuteReturnIdentity();
DeviceTaskExecuteResult1_result item = new DeviceTaskExecuteResult1_result();
item.Id = insertData.Id;
item.Title = insertData.FormTitle;
item.Value = "";
item.Type = insertData.FormType;
item.Children = all_config_list.Where(it => it.Type == config_type[i]).Select(it => it.Content).ToArray();
final_result_list.Add(item);
}
}
}
return final_result_list;
}
2024-06-05 13:24:53 +08:00
/// <summary>
/// 更新结果表单
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
2024-06-11 13:35:00 +08:00
public int UpdateFormResult(DeviceTaskExecuteResultDto result)
2024-06-05 13:24:53 +08:00
{
2024-06-24 17:29:41 +08:00
result.Person = result.UpdatedBy;
2024-06-11 13:35:00 +08:00
DeviceTaskExecuteResult item = result.Adapt<DeviceTaskExecuteResult>();
2024-07-01 15:02:52 +08:00
2024-06-05 13:24:53 +08:00
return Context.Updateable(item).IgnoreColumns(true).EnableDiffLogEvent("更新结果表单").ExecuteCommand();
}
2024-06-05 15:02:11 +08:00
2024-06-05 13:24:53 +08:00
2024-05-31 10:17:33 +08:00
}
}