211 lines
9.8 KiB
C#
211 lines
9.8 KiB
C#
using APT.BaseData.Domain.Entities.FM;
|
|
using APT.BaseData.Domain.IServices.FM;
|
|
using APT.BaseData.Domain.IServices;
|
|
using APT.Infrastructure.Core;
|
|
using APT.MS.Domain.Entities.OG;
|
|
using APT.MS.Domain.Enums;
|
|
using APT.Utility;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using APT.BaseData.Domain.Entities;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace APT.SC.WebApi.Controllers.Api.OG
|
|
{
|
|
[Route("api/OG/OGInnerContact")]
|
|
public class OGInnerContactController : AuthorizeApiController<T_OG_INNER_CONTACT>
|
|
{
|
|
IFMNotificationTaskService NotificationTaskService { get; set; }
|
|
public OGInnerContactController(IFMNotificationTaskService notificationTaskService, IPFCodeRuleService codeRuleService)
|
|
{
|
|
NotificationTaskService = notificationTaskService;
|
|
}
|
|
/// <summary>
|
|
/// 更新
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("FullUpdate")]
|
|
public JsonActionResult<bool> FullUpdate([FromBody]T_OG_INNER_CONTACT entity)
|
|
{
|
|
return SafeExecute<bool>(() =>
|
|
{
|
|
if (entity.USER_ID == null)
|
|
{
|
|
if (entity.STATUS == (int)OGEmployeeOpinionStatus.草稿)
|
|
{
|
|
entity.USER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
|
}
|
|
}
|
|
if (entity.USER_ID == null)
|
|
{
|
|
throw new Exception("用户信息错误");
|
|
}
|
|
List<T_FM_NOTIFICATION_TASK> sendNotice = new List<T_FM_NOTIFICATION_TASK>();
|
|
if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
|
|
{
|
|
if (entity.STATUS != (int)OGInnerContactStatus.草稿 && entity.STATUS != OGInnerContactStatus.落实中)
|
|
{
|
|
throw new Exception("当前状态不可提交");
|
|
}
|
|
if (entity.STATUS == (int)OGInnerContactStatus.草稿)
|
|
{
|
|
if (entity.FORM_DEPARTMENT_ID == null)
|
|
{
|
|
throw new Exception("请指定责任部门");
|
|
}
|
|
if (entity.FROM_USER_ID == null)
|
|
{
|
|
throw new Exception("请指定沟通人员");
|
|
}
|
|
if (entity.TO_USER_ID == null)
|
|
{
|
|
throw new Exception("请指定被沟通人员");
|
|
}
|
|
if (entity.DO_DEPARTMENT_ID != null && entity.DO_USER_ID == null)
|
|
{
|
|
throw new Exception("当前已选落实部门,请指定落实人员");
|
|
}
|
|
if (entity.DO_USER_ID != null && entity.DO_DEPARTMENT_ID == null)
|
|
{
|
|
var u = GetEntity<T_FM_USER>(entity.DO_USER_ID.Value);
|
|
if (u != null)
|
|
{
|
|
entity.DO_DEPARTMENT_ID = u.DEPARTMENT_ID;
|
|
}
|
|
}
|
|
}
|
|
if(entity.FROM_USER_ID == APT.Infrastructure.Api.AppContext.CurrentSession.UserID)
|
|
{
|
|
entity.FORM_USER_TIME = DateTime.Now;
|
|
}
|
|
else
|
|
{
|
|
sendNotice.Add(NotificationTaskService.InsertUserNoticeTaskModel("内部联系沟通确认", entity.ID, entity.ORG_ID, entity.FROM_USER_ID.Value, GetEntity<T_FM_USER>(entity.FROM_USER_ID.Value).NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "OG015_SHOWPRINT"));
|
|
}
|
|
sendNotice.Add(NotificationTaskService.InsertUserNoticeTaskModel("内部联系沟通确认", entity.ID, entity.ORG_ID, entity.TO_USER_ID.Value, GetEntity<T_FM_USER>(entity.TO_USER_ID.Value).NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "OG015_SHOWPRINT"));
|
|
if (entity.STATUS == (int)OGInnerContactStatus.草稿)
|
|
{
|
|
if (entity.DO_USER_ID == null)
|
|
{
|
|
entity.STATUS = OGInnerContactStatus.完成;
|
|
return true;
|
|
}
|
|
entity.STATUS = OGInnerContactStatus.落实中;
|
|
}
|
|
else
|
|
{
|
|
entity.STATUS = OGInnerContactStatus.完成;
|
|
}
|
|
}
|
|
var Nav_ItemFiles = entity.Nav_ItemFiles;
|
|
entity.Nav_ItemFiles = null;
|
|
var Nav_DoFiles = entity.Nav_DoFiles;
|
|
entity.Nav_DoFiles = null;
|
|
UnifiedCommit(() =>
|
|
{
|
|
UpdateEntityNoCommit(entity);
|
|
if (Nav_ItemFiles != null)
|
|
BantchSaveEntityNoCommit(Nav_ItemFiles);
|
|
if (Nav_DoFiles != null)
|
|
BantchSaveEntityNoCommit(Nav_DoFiles);
|
|
if (sendNotice != null)
|
|
BantchSaveEntityNoCommit(sendNotice);
|
|
});
|
|
return true;
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// 内部联系确认
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("PersonalAgree")]
|
|
public JsonActionResult<bool> PersonalAgree([FromBody] T_OG_INNER_CONTACT entity)
|
|
{
|
|
return SafeExecute<bool>(() =>
|
|
{
|
|
var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId;
|
|
var userID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
|
var taskID = entity.TaskID;
|
|
entity = GetEntity<T_OG_INNER_CONTACT>(entity.ID);
|
|
T_FM_NOTIFICATION_TASK sendNotice = null;
|
|
T_FM_NOTIFICATION_TASK finishNotice = null;
|
|
if (entity != null)
|
|
{
|
|
if(userID == entity.FROM_USER_ID)
|
|
{
|
|
entity.FORM_USER_TIME=DateTime.Now;
|
|
}
|
|
else
|
|
{
|
|
entity.TO_USER_TIME = DateTime.Now;
|
|
}
|
|
if (entity.FORM_USER_TIME != DateTime.MinValue && entity.TO_USER_TIME != DateTime.MinValue)
|
|
{
|
|
sendNotice=NotificationTaskService.InsertUserNoticeTaskModel("内部联系沟通落实", entity.ID, entity.ORG_ID, entity.DO_USER_ID.Value, GetEntity<T_FM_USER>(entity.DO_USER_ID.Value).NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "OG016_EDIT");
|
|
}
|
|
}
|
|
if (taskID != Guid.Empty)
|
|
{
|
|
finishNotice = NotificationTaskService.FOGetTaskFinishModel(taskID, entity.ID);
|
|
}
|
|
UnifiedCommit(() =>
|
|
{
|
|
AddEntityNoCommit(sendNotice);
|
|
UpdateEntityNoCommit(entity);
|
|
UpdateEntityNoCommit(finishNotice);
|
|
});
|
|
return true;
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// 落实人员填写
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("FullUpdateConfirm")]
|
|
public JsonActionResult<bool> FullUpdateConfirm([FromBody] T_OG_INNER_CONTACT entity)
|
|
{
|
|
return SafeExecute<bool>(() =>
|
|
{
|
|
List<T_FM_NOTIFICATION_TASK> sendNotice = new List<T_FM_NOTIFICATION_TASK>();
|
|
T_FM_NOTIFICATION_TASK finishNotice = null;
|
|
if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
|
|
{
|
|
if (entity.STATUS != (int)OGInnerContactStatus.草稿 && entity.STATUS != OGInnerContactStatus.落实中)
|
|
{
|
|
throw new Exception("当前状态不可提交");
|
|
}
|
|
sendNotice.Add(NotificationTaskService.InsertUserNoticeTaskModel("内部联系沟通完成确认", entity.ID, entity.ORG_ID, entity.FROM_USER_ID.Value, GetEntity<T_FM_USER>(entity.FROM_USER_ID.Value).NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "OG015_SHOWPRINT"));
|
|
sendNotice.Add(NotificationTaskService.InsertUserNoticeTaskModel("内部联系沟通完成确认", entity.ID, entity.ORG_ID, entity.TO_USER_ID.Value, GetEntity<T_FM_USER>(entity.TO_USER_ID.Value).NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "OG015_SHOWPRINT"));
|
|
entity.STATUS = OGInnerContactStatus.完成;
|
|
if (entity.TaskID != Guid.Empty)
|
|
{
|
|
finishNotice = NotificationTaskService.FOGetTaskFinishModel(entity.TaskID, entity.ID);
|
|
}
|
|
}
|
|
var Nav_ItemFiles = entity.Nav_ItemFiles;
|
|
entity.Nav_ItemFiles = null;
|
|
var Nav_DoFiles = entity.Nav_DoFiles;
|
|
entity.Nav_DoFiles = null;
|
|
UnifiedCommit(() =>
|
|
{
|
|
UpdateEntityNoCommit(entity);
|
|
if (Nav_ItemFiles != null)
|
|
BantchSaveEntityNoCommit(Nav_ItemFiles);
|
|
if (Nav_DoFiles != null)
|
|
BantchSaveEntityNoCommit(Nav_DoFiles);
|
|
if (sendNotice != null)
|
|
BantchSaveEntityNoCommit(sendNotice);
|
|
UpdateEntityNoCommit(finishNotice);
|
|
|
|
});
|
|
return true;
|
|
});
|
|
}
|
|
}
|
|
}
|