87 lines
3.7 KiB
C#
87 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using APT.BaseData.Domain.Entities;
|
|
using APT.BaseData.Domain.Entities.FM;
|
|
using APT.BaseData.Domain.Enums;
|
|
using APT.BaseData.Domain.IServices.FM;
|
|
using APT.Infrastructure.Core;
|
|
using APT.MS.Domain.Entities.LR;
|
|
using APT.MS.Domain.Entities.SE;
|
|
using APT.MS.Domain.Entities.WB;
|
|
using APT.MS.Domain.Enums;
|
|
using APT.Utility;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
namespace APT.SC.WebApi.Controllers.Api.WB
|
|
{
|
|
[Route("api/WB/WBTrainSelect")]
|
|
public class WBTrainSelectController : AuthorizeApiController<T_WB_TRAIN_SELECT>
|
|
{
|
|
IFMNotificationTaskService NotificationTaskService { get; set; }
|
|
public WBTrainSelectController(IFMNotificationTaskService notificationTaskService)
|
|
{
|
|
NotificationTaskService = notificationTaskService;
|
|
}
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("FullUpdate")]
|
|
public JsonActionResult<bool> FullUpdate([FromBody] T_WB_TRAIN_SELECT entity)
|
|
{
|
|
return SafeExecute(() =>
|
|
{
|
|
T_WB_OUTSOURCE_TRAIN_RECORD newRecord = null;
|
|
T_FM_NOTIFICATION_TASK sendNotice = null;
|
|
T_FM_NOTIFICATION_TASK finishTask = null;
|
|
|
|
if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
|
|
{
|
|
if (!entity.END_TIME.HasValue)
|
|
{
|
|
throw new Exception("最迟时间不能为空!");
|
|
}
|
|
else if (entity.END_TIME.Value < DateTime.Now.AddMinutes(2))
|
|
{
|
|
throw new Exception("最迟时间必须大于当前时间!");
|
|
}
|
|
if (entity.TaskID != Guid.Empty)
|
|
{
|
|
finishTask = NotificationTaskService.FOGetTaskFinishModel(entity.TaskID, entity.ID, "WB006_SHOWPRINT");
|
|
}
|
|
newRecord = new T_WB_OUTSOURCE_TRAIN_RECORD();
|
|
newRecord.ID = Guid.NewGuid();
|
|
newRecord.ORG_ID = entity.ORG_ID;
|
|
newRecord.PARENT_ID = entity.ID;
|
|
newRecord.END_TIME = entity.END_TIME;
|
|
|
|
var modelInput = GetEntity<T_WB_PROJECT_INPUT>(e => e.ID == entity.PROJECT_ID);
|
|
if (modelInput != null && modelInput.DEPARTMENT_ID.HasValue)
|
|
{
|
|
newRecord.DEPARTMENT_ID = modelInput.DEPARTMENT_ID.Value;//数据权限处理
|
|
}
|
|
|
|
sendNotice = new T_FM_NOTIFICATION_TASK();
|
|
sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("外包单位入厂安全培训记录", newRecord.ID, entity.ORG_ID, (Guid)entity.USER_ID, GetEntity<T_FM_USER>(t => t.ID == entity.USER_ID).NAME, DateTime.Now, entity.END_TIME.Value, 1, "WB008");
|
|
//sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("外包单位入厂安全培训记录", newRecord.ID, entity.ORG_ID, (Guid)entity.USER_ID, GetEntity<T_FM_USER>(t => t.ID == entity.USER_ID).NAME, DateTime.Now, DateTime.Now.AddDays(7), 1, "WB008");
|
|
}
|
|
UnifiedCommit(() =>
|
|
{
|
|
UpdateEntityNoCommit(entity);
|
|
if (newRecord != null)
|
|
AddEntityNoCommit(newRecord);
|
|
if (sendNotice != null)
|
|
AddEntityNoCommit(sendNotice);
|
|
if (finishTask != null)
|
|
UpdateEntityNoCommit(finishTask);
|
|
|
|
});
|
|
return true;
|
|
});
|
|
}
|
|
}
|
|
}
|