552 lines
27 KiB
C#
552 lines
27 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text.Json;
|
||
using APT.BaseData.Domain.Entities;
|
||
using APT.BaseData.Domain.Entities.FM;
|
||
using APT.BaseData.Domain.Enums;
|
||
using APT.BaseData.Domain.IServices.FM;
|
||
using APT.BaseData.Services.Services.FM;
|
||
using APT.Infrastructure.Core;
|
||
using APT.MS.Domain.Entities.FO;
|
||
using APT.MS.Domain.Entities.SE;
|
||
using APT.MS.Domain.Enums;
|
||
using APT.Utility;
|
||
using log4net.Core;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using NPOI.SS.Formula.Functions;
|
||
using Renci.SshNet.Common;
|
||
using static APT.SC.WebApi.Controllers.Api.BI.BIController;
|
||
|
||
namespace APT.SC.WebApi.Controllers.Api.SE
|
||
{
|
||
[Route("api/SE/SETrainNotify")]
|
||
public class SETTrainNotifyController : AuthorizeApiController<T_SE_TRAIN_NOTIFY>
|
||
{
|
||
IFMNotificationTaskService NotificationTaskService { get; set; }
|
||
public SETTrainNotifyController(IFMNotificationTaskService notificationTaskService)
|
||
{
|
||
NotificationTaskService = notificationTaskService;
|
||
}
|
||
/// <summary>
|
||
/// 保存
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("FullUpdate")]
|
||
public JsonActionResult<bool> FullUpdate([FromBody] T_SE_TRAIN_NOTIFY entity)
|
||
{
|
||
return SafeExecute(() =>
|
||
{
|
||
//try
|
||
//{
|
||
if (entity == null)
|
||
{
|
||
throw new Exception("请注意培训时长不能为小数");
|
||
}
|
||
if (entity.STATUS >= SETrainNotifyStatus.通知中)
|
||
{
|
||
throw new Exception("通知发送,不可更改");
|
||
}
|
||
var Nav_TrainContentList = entity.Nav_TrainContentList;
|
||
var ListCour = entity.Nav_ListCour;
|
||
//if (Nav_TrainContentList == null || !Nav_TrainContentList.Any() || Nav_TrainContentList.Count() < 1)
|
||
//{
|
||
// throw new Exception("请选择培训内容");
|
||
//}
|
||
if (entity.Nav_TrainUserList == null || entity.Nav_TrainUserList.Count() < 1)
|
||
{
|
||
throw new Exception("请选择培训人员");
|
||
}
|
||
if (entity.TRAIN_START_TIME.HasValue && entity.TRAIN_START_TIME.Value <= DateTime.Now)
|
||
{
|
||
throw new Exception("培训开始时间不能小于当前时间!");
|
||
}
|
||
if (entity.TRAIN_START_TIME.HasValue && entity.TRAIN_END_TIME.HasValue && entity.TRAIN_START_TIME.Value > entity.TRAIN_END_TIME.Value)
|
||
{
|
||
throw new Exception("培训开始时间不能大于培训结束时间!");
|
||
}
|
||
if (entity.DT_START_SIGN.HasValue && entity.TRAIN_END_TIME.HasValue && entity.DT_START_SIGN.Value >= entity.TRAIN_END_TIME.Value)
|
||
{
|
||
throw new Exception("签到开始时间不能大于培训结束时间!");
|
||
}
|
||
var Nav_TrainUserList = entity.Nav_TrainUserList.Where(t => t.USER_ID != Guid.Empty);
|
||
var Nav_Files = entity.Nav_Files;
|
||
List<T_FM_NOTIFICATION_TASK> sendNoticeTask = null;
|
||
T_FM_NOTIFICATION_TASK finishNoticeTask = null;
|
||
|
||
//foreach (var item in Nav_TrainContentList)
|
||
//{
|
||
// item.Nav_Point = null;
|
||
//}
|
||
if (Nav_TrainContentList != null)
|
||
Nav_TrainContentList.ForEach(e => e.Nav_Point = null);
|
||
if (ListCour != null)
|
||
ListCour.ForEach(e => e.Nav_Cour = null);
|
||
|
||
if (entity.LAUNCH_TIME == null)
|
||
{
|
||
entity.LAUNCH_TIME = DateTime.Now;
|
||
}
|
||
if (entity.CODE == null)
|
||
{
|
||
entity.CODE = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||
}
|
||
if (entity.LAUNCH_USER_ID == null)
|
||
{
|
||
entity.LAUNCH_USER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
||
}
|
||
if (entity.LAUNCH_DEPARTMENT_ID == null)
|
||
{
|
||
entity.LAUNCH_DEPARTMENT_ID = GetEntity<T_FM_USER>(entity.LAUNCH_USER_ID.ToString()).DEPARTMENT_ID;
|
||
}
|
||
|
||
var noDeleteUsers = Nav_TrainUserList.Where(t => t.IS_DELETED == false);
|
||
var hasDuplicates = noDeleteUsers.GroupBy(x => x.USER_ID).Where(g => g.Count() > 1).Select(g => g.Key).ToList();
|
||
if (hasDuplicates.Any())
|
||
{
|
||
BaseFilter filter = new BaseFilter(entity.ORG_ID);
|
||
filter.SelectField = new string[] { "NAME" };
|
||
var duplicateName = string.Join(",", GetEntities<T_FM_USER>(t => hasDuplicates.Contains(t.ID), filter).Select(t => t.NAME));
|
||
throw new Exception("人员:" + duplicateName + " 重复!");
|
||
}
|
||
|
||
if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
|
||
{
|
||
entity.LAUNCH_TIME = DateTime.Now;
|
||
var transferUsersCount = Nav_TrainUserList.Count(t => t.IS_DELETED == false && t.TRANSFER_TRAINING == true);
|
||
if (entity.CREATE_NOTIFY_RECORD == false && transferUsersCount > 0)
|
||
{
|
||
throw new Exception("未触发培训记录不能转训!");
|
||
}
|
||
if (entity.CREATE_NOTIFY_RECORD && entity.RECORD_USER_ID == null)
|
||
{
|
||
throw new Exception("触发培训记录请选择记录人!");
|
||
}
|
||
if (entity.TRAIN_END_TIME <= entity.TRAIN_START_TIME)
|
||
{
|
||
throw new Exception("培训结束时间需大于培训开始时间");
|
||
}
|
||
//在线考核 必须 课件、考核内容 二选一
|
||
if ((Nav_TrainContentList == null || Nav_TrainContentList.Count() < 1) && (ListCour == null || ListCour.Count() < 1))
|
||
{
|
||
throw new Exception("培训内容或课件至少二选一!");//原来 培训内容必填 现可不必填
|
||
}
|
||
if (Nav_TrainUserList == null || Nav_TrainUserList.Where(t => t.IS_DELETED == false).Count() == 0)
|
||
{
|
||
throw new Exception("培训人员不可为空!");
|
||
}
|
||
if (entity.HOURS == 0)
|
||
{
|
||
throw new Exception("培训时长不能为0!");
|
||
}
|
||
|
||
#region 如果没有课件 只有知识点 判断 题库数量是否足够
|
||
|
||
if (entity.CHECKTYPE == PlanCheckType.InOnLine && entity.IN_OUT == TrainInOut.In && (ListCour == null || ListCour.Count() < 1))
|
||
{
|
||
|
||
#region 题目数量判断
|
||
|
||
var config = GetEntity<T_SE_SECONFIG>(t => true);
|
||
var SCount = 1;
|
||
var MCount = 1;
|
||
var CCount = 1;
|
||
if (config != null)
|
||
{
|
||
if (config.M_TEST_COUNT > 0 || config.S_TEST_COUNT > 0 || config.C_TEST_COUNT > 0)
|
||
{
|
||
//王永文 只要有配置 就获取
|
||
MCount = config.M_TEST_COUNT;
|
||
SCount = config.S_TEST_COUNT;
|
||
CCount = config.C_TEST_COUNT;
|
||
}
|
||
else
|
||
{
|
||
//保持原来的版本
|
||
if (config.M_TEST_COUNT > 0)
|
||
{
|
||
MCount = config.M_TEST_COUNT;
|
||
}
|
||
if (config.S_TEST_COUNT > 0)
|
||
{
|
||
SCount = config.S_TEST_COUNT;
|
||
}
|
||
if (config.C_TEST_COUNT > 0)
|
||
{
|
||
CCount = config.C_TEST_COUNT;
|
||
}
|
||
}
|
||
}
|
||
var pointIDS = Nav_TrainContentList.Where(e => !e.IS_DELETED).Select(t => t.POINT_ID).ToList();
|
||
var testidlist = new List<Guid>();
|
||
var testFilter = new BaseFilter(entity.ORG_ID);
|
||
testFilter.Include = new string[] { "Nav_Points" };
|
||
|
||
|
||
var allTests = GetEntities<T_SE_TEST>(st => st.Nav_Points.Any(pt => pointIDS.Contains(pt.POINT_ID.Value)), testFilter).ToList();
|
||
if (allTests.Count() == 0)
|
||
{
|
||
allTests = GetEntities<T_SE_TEST>(st => st.TRAINNAME.Contains(entity.NAME) && st.Nav_Points.Any(pt => pointIDS.Contains(pt.POINT_ID.Value)), testFilter).ToList();
|
||
}
|
||
|
||
var errorMsg = "";
|
||
foreach (var testPoint in pointIDS)
|
||
{
|
||
var havepoint = allTests.Where(st => st.Nav_Points.Any(pt => pt.POINT_ID == testPoint));
|
||
if (havepoint.Count() < 1)
|
||
{
|
||
var noPoint = GetEntity<T_SE_TEST_ENUM_POINT>(testPoint);
|
||
errorMsg += noPoint.NAME + ",";
|
||
}
|
||
}
|
||
if (errorMsg != "")
|
||
{
|
||
throw new Exception("知识点 " + errorMsg + " 没有题目!");
|
||
}
|
||
var SCurrentCount = allTests.Count(t => t.TYPE == SETestTypeEnum.单选题);
|
||
var MCurrentCount = allTests.Count(t => t.TYPE == SETestTypeEnum.多选题);
|
||
var CCurrentCount = allTests.Count(t => t.TYPE == SETestTypeEnum.是非题);
|
||
errorMsg = "";
|
||
if (SCurrentCount < SCount)
|
||
{
|
||
errorMsg += "单选题还需" + (SCount - SCurrentCount) + "题\n";
|
||
}
|
||
if (MCurrentCount < MCount)
|
||
{
|
||
errorMsg += "多选题还需" + (MCount - MCurrentCount) + "题\n";
|
||
}
|
||
if (CCurrentCount < CCount)
|
||
{
|
||
errorMsg += "是非题还需" + (CCount - CCurrentCount) + "题\n";
|
||
}
|
||
if (errorMsg != "")
|
||
{
|
||
errorMsg = "题库中题目数量不足!\n" + errorMsg;
|
||
throw new Exception(errorMsg);
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
#endregion
|
||
|
||
if (entity.ISSENDNOTICE)
|
||
{
|
||
entity.STATUS = SETrainNotifyStatus.通知中;
|
||
//触发培训通知给所有培训人员
|
||
var allSendUserNames = new List<string>();
|
||
var sendUsers = Nav_TrainUserList.Where(t => t.IS_DELETED == false && t.USER_ID != entity.LAUNCH_USER_ID).Select(t => t.USER_ID).ToList();
|
||
var sendUserAll = Nav_TrainUserList.Where(t => t.IS_DELETED == false).Select(t => t.USER_ID).ToList();
|
||
|
||
BaseFilter userFilter = new BaseFilter(entity.ORG_ID);
|
||
userFilter.Include = new string[] { "Nav_Person.Nav_Post", "Nav_Department" };
|
||
IEnumerable<T_FM_USER> userNames = GetEntities<T_FM_USER>(t => sendUserAll.Contains(t.ID), userFilter);
|
||
|
||
//List<Guid> listAuto = new List<Guid>();
|
||
//if (entity.RECORD_USER_ID.HasValue && sendUsers.Contains(entity.RECORD_USER_ID.Value))
|
||
//{
|
||
// listAuto.Add(entity.RECORD_USER_ID.Value);
|
||
//}
|
||
//if (entity.USER_ID_TEACHER.HasValue && !listAuto.Contains(entity.USER_ID_TEACHER.Value))
|
||
//{
|
||
// listAuto.Add(entity.USER_ID_TEACHER.Value);
|
||
//}
|
||
|
||
T_FM_USER userCheck = null;
|
||
foreach (var user in Nav_TrainUserList)
|
||
{
|
||
if (user.IS_DELETED)
|
||
continue;
|
||
userCheck = userNames.FirstOrDefault(t => t.ID == user.USER_ID);
|
||
if (userCheck == null)
|
||
{
|
||
var modelDel = GetEntity<T_FM_USER>(user.USER_ID);
|
||
if (modelDel != null && modelDel.IS_DELETED)
|
||
{
|
||
throw new Exception("人员【" + modelDel.NAME + " " + (String.IsNullOrEmpty(user.POST_NAME) ? "" : user.POST_NAME) + "】已删除,不能进行培训,请移除此人后再发布通知!");
|
||
}
|
||
else
|
||
{
|
||
throw new Exception("查找人员失败【ID:" + user.USER_ID + " " + (String.IsNullOrEmpty(user.POST_NAME) ? "" : user.POST_NAME) + "】失败,如果已删除活禁用,请移除此人!");
|
||
}
|
||
}
|
||
if (userCheck.Nav_Department == null)
|
||
{
|
||
throw new Exception("人员组织异常【" + userCheck.NAME + "】,请先处理对应组织后再提交!");
|
||
}
|
||
if (userCheck.Nav_Person == null)
|
||
{
|
||
throw new Exception("人员信息异常【" + userCheck.NAME + "】,请联系管理员处理对应信息!");
|
||
}
|
||
if (userCheck.Nav_Person.Nav_Post == null)
|
||
{
|
||
throw new Exception("人员岗位信息异常【" + userCheck.NAME + "】,请联系管理员处理对应信息!");
|
||
}
|
||
|
||
user.DEPARTMENT_NAME = userCheck.Nav_Department?.NAME;
|
||
user.POST_NAME = userCheck.Nav_Person?.Nav_Post?.NAME;
|
||
|
||
//if (listAuto != null && listAuto.Count > 0 && listAuto.Contains(user.USER_ID))
|
||
//{
|
||
// user.IS_LEAVE = SETrainYesNoEnum.参加;
|
||
//}
|
||
}
|
||
foreach (var user in sendUsers)
|
||
{
|
||
allSendUserNames.Add(userNames.FirstOrDefault(t => t.ID == user).NAME);
|
||
}
|
||
|
||
//2023/04/23当前人自动签到
|
||
var currTrainUser = Nav_TrainUserList.FirstOrDefault(t => t.USER_ID == entity.LAUNCH_USER_ID);
|
||
if (currTrainUser != null)
|
||
{
|
||
currTrainUser.IS_LEAVE = SETrainYesNoEnum.参加;
|
||
}
|
||
|
||
sendNoticeTask = NotificationTaskService.InsertUserNoticeTaskModels("培训通知-" + entity.NAME + "-确认", entity.ID, entity.ORG_ID, sendUsers, allSendUserNames, DateTime.Now, DateTime.Now.AddDays(1), (int)FMNoticeTypeEnum.消息, "SE013_SHOWPRINT");
|
||
|
||
//if (listAuto != null && listAuto.Count > 0)
|
||
//{
|
||
// foreach (var item in sendNoticeTask)
|
||
// {
|
||
// if (listAuto.Contains(item.USER_ID))
|
||
// {
|
||
// item.NOTICE_STATUS = 1;
|
||
// item.TASK_DT = DateTime.Now;
|
||
// item.MODIFIER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
||
// }
|
||
// }
|
||
//}
|
||
}
|
||
else
|
||
{
|
||
//没有触发培训通知
|
||
if (entity.CREATE_NOTIFY_RECORD)
|
||
{
|
||
entity.STATUS = SETrainNotifyStatus.签到完成;
|
||
}
|
||
else
|
||
{
|
||
entity.STATUS = SETrainNotifyStatus.归档;
|
||
}
|
||
}
|
||
|
||
if (entity.TaskID != Guid.Empty)
|
||
{
|
||
finishNoticeTask = NotificationTaskService.GetTaskFinishModel(entity.TaskID, "SE013_SHOWPRINT");
|
||
}
|
||
}
|
||
entity.Nav_Files = null;
|
||
entity.Nav_TrainUserList = null;
|
||
entity.Nav_TrainContentList = null;
|
||
entity.Nav_ListCour = null;
|
||
|
||
|
||
UnifiedCommit(() =>
|
||
{
|
||
UpdateEntityNoCommit(entity);
|
||
if (Nav_TrainContentList != null && Nav_TrainContentList.Any())
|
||
BantchSaveEntityNoCommit(Nav_TrainContentList);
|
||
if (ListCour != null && ListCour.Any())
|
||
BantchSaveEntityNoCommit(ListCour);
|
||
if (Nav_TrainUserList != null && Nav_TrainUserList.Any())
|
||
BantchSaveEntityNoCommit(Nav_TrainUserList);
|
||
if (Nav_Files != null && Nav_Files.Any())
|
||
BantchSaveEntityNoCommit(Nav_Files);
|
||
if (sendNoticeTask != null && sendNoticeTask.Any())
|
||
BantchAddEntityNoCommit(sendNoticeTask);
|
||
if (finishNoticeTask != null)
|
||
UpdateEntityNoCommit(finishNoticeTask);
|
||
|
||
});
|
||
//}
|
||
//catch (Exception ex)
|
||
//{
|
||
// if (!string.IsNullOrEmpty(ex.Message))
|
||
// {
|
||
// throw new Exception(ex.Message);
|
||
// }
|
||
// else
|
||
// {
|
||
// if (!string.IsNullOrEmpty(ex.StackTrace))
|
||
// throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
|
||
// else
|
||
// throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
||
// }
|
||
//}
|
||
return true;
|
||
});
|
||
}
|
||
|
||
/// 参加/请假
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("TrainPersonStatus")]
|
||
public JsonActionResult<bool> AttendStatus([FromBody] T_SE_TRAIN_NOTIFY_PERSONS entity)
|
||
{
|
||
return SafeExecute(() =>
|
||
{
|
||
//var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId;
|
||
T_FM_NOTIFICATION_TASK finishTask = null;
|
||
T_FM_NOTIFICATION_TASK finishTaskSign = null;
|
||
T_SE_TRAIN_NOTIFY model = null;
|
||
T_SE_TRAIN_RECORD_USER modelRU = null;
|
||
var allUsers = GetEntities<T_SE_TRAIN_NOTIFY_PERSONS>(t => t.NOTIFY_ID == entity.NOTIFY_ID, null, "Nav_Notify");
|
||
if (allUsers == null || allUsers.Count() < 1)
|
||
{
|
||
throw new Exception("获取培训通知信息失败,请刷新页面后重试!");
|
||
}
|
||
model = allUsers.First(e => true).Nav_Notify;
|
||
if (model.TRAIN_START_TIME.HasValue && model.TRAIN_START_TIME.Value < DateTime.Now)
|
||
{
|
||
if (entity.TaskID != Guid.Empty)
|
||
{
|
||
finishTask = NotificationTaskService.GetTaskFinishModel(entity.TaskID);
|
||
UnifiedCommit(() =>
|
||
{
|
||
if (finishTask != null)
|
||
UpdateEntityNoCommit(finishTask);
|
||
});
|
||
}
|
||
throw new Exception("操作失败,该培训已开始!");
|
||
}
|
||
var updateUsers = allUsers.Where(t => t.USER_ID == entity.USER_ID);
|
||
foreach (var updateUser in updateUsers)
|
||
{
|
||
updateUser.IS_LEAVE = entity.IS_LEAVE;
|
||
updateUser.LEAVE_REASON = entity.LEAVE_REASON;
|
||
updateUser.MODIFY_TIME = DateTime.Now;
|
||
updateUser.Nav_Notify = null;
|
||
}
|
||
finishTask = NotificationTaskService.GetTaskFinishModel(entity.TaskID);
|
||
var todoCount = allUsers.Count(t => t.IS_LEAVE == SETrainYesNoEnum.未签到);
|
||
if (todoCount == 0)
|
||
{
|
||
//model = GetEntity<T_SE_TRAIN_NOTIFY>(entity.NOTIFY_ID);
|
||
if (model.CREATE_NOTIFY_RECORD && model.STATUS != SETrainNotifyStatus.归档)
|
||
{
|
||
model.STATUS = SETrainNotifyStatus.签到完成;
|
||
}
|
||
else
|
||
{
|
||
model.STATUS = SETrainNotifyStatus.归档;
|
||
}
|
||
model.MODIFY_TIME = DateTime.Now;
|
||
}
|
||
|
||
if (entity.IS_LEAVE == SETrainYesNoEnum.请假 && model.ISSENDSIGN)
|
||
{
|
||
//查看是否有培训签到单子 如果有 处理掉
|
||
var recordModel = GetEntity<T_SE_TRAIN_RECORD>(e => e.NOTIFY_ID == entity.NOTIFY_ID);
|
||
if (recordModel != null && !recordModel.ISSTOPSIGN)
|
||
{
|
||
//已发送签到 但是未 停止签到
|
||
finishTaskSign = GetEntity<T_FM_NOTIFICATION_TASK>(e => e.SOURCE_DATA_ID.HasValue && e.SOURCE_DATA_ID.Value == recordModel.ID && e.NOTICE_STATUS == 0 && e.USER_ID == entity.USER_ID && e.SOURCE_FORMCODE == "SE017_SHOWPRINT");
|
||
if (finishTaskSign != null)
|
||
{
|
||
finishTaskSign.NOTICE_STATUS = 4;
|
||
finishTaskSign.MODIFY_TIME = DateTime.Now;
|
||
|
||
modelRU = GetEntity<T_SE_TRAIN_RECORD_USER>(e => e.USER_ID == entity.USER_ID && e.RECORD_ID == recordModel.ID);
|
||
if (modelRU != null)
|
||
{
|
||
modelRU.STATUS = SETrainRecordUserStatusEnum.请假;
|
||
modelRU.MODIFY_TIME = DateTime.Now;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
UnifiedCommit(() =>
|
||
{
|
||
if (updateUsers != null)
|
||
BantchUpdateEntityNoCommit(updateUsers, "IS_LEAVE", "LEAVE_REASON", "MODIFY_TIME");
|
||
if (model != null)
|
||
UpdateEntityNoCommit(model, "STATUS", "MODIFY_TIME");
|
||
if (finishTask != null)
|
||
UpdateEntityNoCommit(finishTask);
|
||
if (finishTaskSign != null)
|
||
UpdateEntityNoCommit(finishTaskSign);
|
||
if (modelRU != null)
|
||
UpdateEntityNoCommit(modelRU);
|
||
});
|
||
return true;
|
||
});
|
||
}
|
||
/// 参加/请假
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("overTimeSign")]
|
||
public JsonActionResult<bool> overTimeSign([FromBody] T_SE_TRAIN_NOTIFY_PERSONS entity)
|
||
{
|
||
return SafeExecute(() =>
|
||
{
|
||
var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId;
|
||
T_FM_NOTIFICATION_TASK finishTask = null;
|
||
var allUsers = GetEntities<T_SE_TRAIN_NOTIFY_PERSONS>(t => t.NOTIFY_ID == entity.NOTIFY_ID, new BaseFilter(orgId));
|
||
var updateUsers = allUsers.Where(t => t.USER_ID == entity.USER_ID);
|
||
foreach (var updateUser in updateUsers)
|
||
{
|
||
updateUser.IS_LEAVE = SETrainYesNoEnum.参加;
|
||
updateUser.MODIFY_TIME = DateTime.Now;
|
||
}
|
||
finishTask = NotificationTaskService.GetTaskFinishModel(entity.TaskID);
|
||
|
||
UnifiedCommit(() =>
|
||
{
|
||
if (updateUsers != null)
|
||
BantchUpdateEntityNoCommit(updateUsers, "IS_LEAVE", "LEAVE_REASON", "MODIFY_TIME");
|
||
if (finishTask != null)
|
||
UpdateEntityNoCommit(finishTask);
|
||
});
|
||
return true;
|
||
});
|
||
}
|
||
/// <summary>
|
||
/// 排序分页查询数据
|
||
/// </summary>
|
||
/// <param name="pageFilter">分页过滤实体</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("OrderPaged")]
|
||
public PagedActionResult<T_SE_TRAIN_NOTIFY> OrderPaged([FromBody] KeywordPageFilter pageFilter)
|
||
{
|
||
return WitOrderPaged(t => t.ORIGINAL_NOTIFY_ID != null, pageFilter);
|
||
}
|
||
public class notifyData
|
||
{
|
||
public T_SE_TRAIN_NOTIFY mainNotify { get; set; }
|
||
|
||
public List<T_SE_TRAIN_RECORD> subRecords { get; set; }
|
||
|
||
}
|
||
/// <summary>
|
||
/// 获得单条实体数据
|
||
/// </summary>
|
||
/// <param name="filter">过滤实体</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("Get")]
|
||
public JsonActionResult<notifyData> Get([FromBody] KeywordFilter filter)
|
||
{
|
||
return SafeExecute<notifyData>(() =>
|
||
{
|
||
List<Guid> notifys = new List<Guid>();
|
||
notifyData notifyDatas = new notifyData();
|
||
notifyDatas.mainNotify = GetEntity<T_SE_TRAIN_NOTIFY>(filter.Parameter1, new string[] { "Nav_LaunchDepartment", "Nav_LaunchUser", "Nav_TrainType", "Nav_TrainCheckType", "Nav_TrainContentList", "Nav_TrainContentList.Nav_Point", "Nav_TrainUserList", "Nav_TrainUserList.Nav_User", "Nav_TrainUserList.Nav_User.Nav_Department", "Nav_TrainUserList.Nav_User.Nav_Person.Nav_Post", "Nav_Files.Nav_ImgFile" });
|
||
var subnotifys = GetEntities<T_SE_TRAIN_NOTIFY>(t => t.ORIGINAL_NOTIFY_ID == Guid.Parse(filter.Parameter1), new BaseFilter(filter.GetOrgId()));
|
||
notifys.Add(notifyDatas.mainNotify.ID);
|
||
foreach (var item in subnotifys)
|
||
{
|
||
notifys.Add(item.ID);
|
||
}
|
||
var recordFilter = new BaseFilter(filter.GetOrgId());
|
||
recordFilter.Include = new string[] { "Nav_Notify.Nav_LaunchDepartment", "Nav_Users.Nav_User", "Nav_Papers", "Nav_Files" };
|
||
var allRecords = GetEntities<T_SE_TRAIN_RECORD>(t => notifys.Contains(t.NOTIFY_ID), recordFilter).ToList();
|
||
notifyDatas.subRecords = allRecords;
|
||
return notifyDatas;
|
||
});
|
||
}
|
||
}
|
||
}
|