210 lines
8.7 KiB
C#
210 lines
8.7 KiB
C#
|
|
using APT.BaseData.Domain.Entities;
|
|||
|
|
using APT.BaseData.Domain.Entities.FM;
|
|||
|
|
using APT.BaseData.Domain.Enums.PF;
|
|||
|
|
using APT.BaseData.Domain.IServices;
|
|||
|
|
using APT.BaseData.Domain.IServices.FM;
|
|||
|
|
using APT.Infrastructure.Core;
|
|||
|
|
using APT.MS.Domain.Entities.SC;
|
|||
|
|
using APT.MS.Domain.Entities.TI;
|
|||
|
|
using APT.MS.Domain.Enums;
|
|||
|
|
using APT.Utility;
|
|||
|
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
namespace APT.SC.WebApi.Controllers.Api.SC
|
|||
|
|
{
|
|||
|
|
[Route("api/TI/TIProject")]
|
|||
|
|
public class TIProjectController : AuthorizeApiController<T_TI_PROJECT>
|
|||
|
|
{
|
|||
|
|
IFMFlowPermitService MFlowPermitService { get; set; }
|
|||
|
|
IPFApproveCallBackService ApproveCallBackService { get; set; }
|
|||
|
|
IFMNotificationTaskService NotificationTaskService { get; set; }
|
|||
|
|
public TIProjectController(IFMFlowPermitService mFlowPermitService, IPFApproveCallBackService approveCallBackService, IFMNotificationTaskService notificationTaskService)
|
|||
|
|
{
|
|||
|
|
MFlowPermitService = mFlowPermitService;
|
|||
|
|
ApproveCallBackService = approveCallBackService;
|
|||
|
|
NotificationTaskService = notificationTaskService;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 立项申请/任务书上报 修改
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost, Route("FullUpdate")]
|
|||
|
|
public JsonActionResult<bool> FullUpdate([FromBody] T_TI_PROJECT entity)
|
|||
|
|
{
|
|||
|
|
return SafeExecute<bool>(() =>
|
|||
|
|
{
|
|||
|
|
if (entity.STATUS != PFStandardStatus.Draft && entity.STATUS != PFStandardStatus.Archived)
|
|||
|
|
{
|
|||
|
|
throw new Exception("获取操作方式有误!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//if (entity.BEGINTIME.HasValue)
|
|||
|
|
//{
|
|||
|
|
// if (entity.BEGINTIME.Value >= DateTime.Now)
|
|||
|
|
// {
|
|||
|
|
// throw new Exception("使用日期不能大于当前时间!");
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
//if (entity.DEPARTMENT_ID == null)
|
|||
|
|
//{
|
|||
|
|
// throw new Exception("请选择发起部门!");
|
|||
|
|
//}
|
|||
|
|
//if (entity.USER_ID == null)
|
|||
|
|
//{
|
|||
|
|
// throw new Exception("请选择发起人!");
|
|||
|
|
//}
|
|||
|
|
entity.BEGINTIME = DateTime.Now;
|
|||
|
|
entity.DEPARTMENT_ID = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID;
|
|||
|
|
entity.USER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
|||
|
|
if (entity.YEAR == 0)
|
|||
|
|
{
|
|||
|
|
throw new Exception("请选择计划年度!");
|
|||
|
|
}
|
|||
|
|
else if (entity.YEAR < DateTime.Now.Year)
|
|||
|
|
{
|
|||
|
|
throw new Exception("计划年度不能小于当年!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var files = entity.Nav_Files;//附件
|
|||
|
|
entity.Nav_Files = null;
|
|||
|
|
//if (files == null || !files.Any())
|
|||
|
|
//{
|
|||
|
|
// throw new Exception("请上传立项附件!");
|
|||
|
|
//}
|
|||
|
|
var WFFiles = entity.Nav_WFFiles;
|
|||
|
|
entity.Nav_WFFiles = null;
|
|||
|
|
var Ranges = entity.Nav_Ranges;
|
|||
|
|
entity.Nav_Ranges = null;
|
|||
|
|
var Sources = entity.Nav_Sources;
|
|||
|
|
entity.Nav_Sources = null;
|
|||
|
|
if (Ranges != null && Ranges.Any())
|
|||
|
|
{
|
|||
|
|
foreach (var range in Ranges)
|
|||
|
|
{
|
|||
|
|
range.Nav_Range = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (Sources != null && Sources.Any())
|
|||
|
|
{
|
|||
|
|
foreach (var source in Sources)
|
|||
|
|
{
|
|||
|
|
source.Nav_Source = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
T_FM_NOTIFICATION_TASK taskEnd = null;
|
|||
|
|
T_FM_NOTIFICATION_TASK taskCheck = null;
|
|||
|
|
T_TI_PROJECT_CHECK modelProjectCheck = null;
|
|||
|
|
|
|||
|
|
if (entity.STATUS == PFStandardStatus.Archived)
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(entity.CODE))
|
|||
|
|
{
|
|||
|
|
throw new Exception("项目编号不能为空!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var checkCode = GetEntity<T_TI_PROJECT>(e => e.ID != entity.ID && e.CODE == entity.CODE);
|
|||
|
|
if (checkCode != null)
|
|||
|
|
{
|
|||
|
|
throw new Exception("项目编号不能重复!");
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(entity.NAME))
|
|||
|
|
{
|
|||
|
|
throw new Exception("项目名称不能为空!");
|
|||
|
|
}
|
|||
|
|
if (!entity.MANAGER_ID.HasValue)
|
|||
|
|
{
|
|||
|
|
throw new Exception("请选择项目负责人!");
|
|||
|
|
}
|
|||
|
|
if (Sources == null || !Sources.Any())
|
|||
|
|
{
|
|||
|
|
throw new Exception("请选择项目来源!");
|
|||
|
|
}
|
|||
|
|
if (Ranges == null || !Ranges.Any())
|
|||
|
|
{
|
|||
|
|
throw new Exception("请选择所属范围!");
|
|||
|
|
}
|
|||
|
|
if (files == null || !files.Any())
|
|||
|
|
{
|
|||
|
|
throw new Exception("请上传立项附件!");
|
|||
|
|
}
|
|||
|
|
if (WFFiles == null || !WFFiles.Any())
|
|||
|
|
{
|
|||
|
|
throw new Exception("请上传审批附件!");
|
|||
|
|
}
|
|||
|
|
string UserName = string.Empty;
|
|||
|
|
if (entity.TaskID != Guid.Empty)
|
|||
|
|
{
|
|||
|
|
taskEnd = NotificationTaskService.GetEntityTask(entity.TaskID, "TI012_SHOWPRINT");
|
|||
|
|
UserName = taskEnd.USER_NAME;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UserName = GetEntity<T_FM_USER>(entity.MANAGER_ID.Value)?.NAME;
|
|||
|
|
|
|||
|
|
#region TI014 项目结题验收
|
|||
|
|
|
|||
|
|
modelProjectCheck = new T_TI_PROJECT_CHECK();
|
|||
|
|
modelProjectCheck.ID = Guid.NewGuid();
|
|||
|
|
modelProjectCheck.DEPARTMENT_ID = entity.DEPARTMENT_ID;
|
|||
|
|
modelProjectCheck.USER_ID = entity.USER_ID;
|
|||
|
|
modelProjectCheck.PROJECT_ID = entity.ID;
|
|||
|
|
modelProjectCheck.ORG_ID = entity.ORG_ID;
|
|||
|
|
modelProjectCheck.MONEY = entity.MONEY;
|
|||
|
|
modelProjectCheck.DEPARTMENT_ID = entity.DEPARTMENT_ID;
|
|||
|
|
modelProjectCheck.USER_ID = entity.USER_ID;
|
|||
|
|
//modelProjectCheck.RESULT = 0;
|
|||
|
|
|
|||
|
|
|
|||
|
|
taskCheck = NotificationTaskService.InsertUserNoticeTaskModel("项目结题验收", modelProjectCheck.ID, entity.ORG_ID.Value, entity.MANAGER_ID.Value, UserName, DateTime.Now, 0, "TI014", BaseData.Domain.Enums.FMTASKTYPE.TI_CHECK);
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.UnifiedCommit(() =>
|
|||
|
|
{
|
|||
|
|
if (entity != null)
|
|||
|
|
UpdateEntityNoCommit(entity); //保存主表 NoCommit
|
|||
|
|
if (Ranges != null && Ranges.Any())//所属范围
|
|||
|
|
BantchSaveEntityNoCommit(Ranges);
|
|||
|
|
if (Sources != null && Sources.Any())//项目来源
|
|||
|
|
BantchSaveEntityNoCommit(Sources);
|
|||
|
|
if (files != null && files.Any())//立项附件
|
|||
|
|
BantchSaveEntityNoCommit(files);
|
|||
|
|
if (WFFiles != null && WFFiles.Any())//审批附件
|
|||
|
|
BantchSaveEntityNoCommit(WFFiles);
|
|||
|
|
if (taskEnd != null)//结束待办
|
|||
|
|
UpdateEntityNoCommit(taskEnd);
|
|||
|
|
if (taskCheck != null)//项目结题验收
|
|||
|
|
UpdateEntityNoCommit(taskCheck);
|
|||
|
|
if (modelProjectCheck != null)//项目结题验收
|
|||
|
|
UpdateEntityNoCommit(modelProjectCheck);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获得单条实体数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="filter">过滤实体</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost, Route("GetCheck")]
|
|||
|
|
public JsonActionResult<T_TI_PROJECT> GetCheck([FromBody] KeywordFilter filter)
|
|||
|
|
{
|
|||
|
|
//Func<T_TI_PROJECT, bool> expression = e => e.ID == new Guid(filter.Keyword);
|
|||
|
|
//return SafeExecute(() => GetEntity<T_TI_PROJECT>(e=>e.ID== new Guid(filter.Keyword)));
|
|||
|
|
return SafeExecute<T_TI_PROJECT>(() =>
|
|||
|
|
{
|
|||
|
|
Guid id = new Guid(filter.Keyword);
|
|||
|
|
return GetEntity<T_TI_PROJECT>(e => e.ID == id, filter, null);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|