271 lines
11 KiB
C#
271 lines
11 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.TL;
|
|
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/TL/TLBack")]
|
|
public class TLBackController : AuthorizeApiController<T_TL_BACK>
|
|
{
|
|
IFMFlowPermitService MFlowPermitService { get; set; }
|
|
IFMNotificationTaskService NotificationTaskService { get; set; }
|
|
IPFApproveCallBackService ApproveCallBackService { get; set; }
|
|
public TLBackController(IFMFlowPermitService mFlowPermitService, IFMNotificationTaskService notificationTaskService, IPFApproveCallBackService approveCallBackService)
|
|
{
|
|
MFlowPermitService = mFlowPermitService;
|
|
NotificationTaskService = notificationTaskService;
|
|
ApproveCallBackService = approveCallBackService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 附件上传
|
|
/// 设计文件专家评审意见
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("FullUpdate")]
|
|
public JsonActionResult<bool> FullUpdate([FromBody] T_TL_BACK entity)
|
|
{
|
|
return SafeExecute<bool>(() =>
|
|
{
|
|
var files = entity.Nav_Files;//附件
|
|
entity.Nav_Files = null;
|
|
var listBackRequire = entity.Nav_ListBackRequire;
|
|
entity.Nav_ListBackRequire = null;
|
|
var IListDetail = entity.Nav_ListDetail;
|
|
entity.Nav_ListDetail = null;
|
|
List<T_TL_BACK_DETAIL_USER> listDetailUser = new List<T_TL_BACK_DETAIL_USER>();
|
|
|
|
if (entity.USER_ID == Guid.Empty)
|
|
{
|
|
entity.USER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value;
|
|
entity.DEPARTMENT_ID = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID;
|
|
|
|
}
|
|
if (entity.USER_ID != APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value)
|
|
{
|
|
throw new Exception("只能操作自己提交的记录!");
|
|
}
|
|
|
|
if (entity.STATUS == PFStandardStatus.Approving)//Archived
|
|
{
|
|
if (listBackRequire == null || !listBackRequire.Any())
|
|
{
|
|
throw new Exception("请选择制定要求!");
|
|
}
|
|
|
|
//if (files == null || !files.Any())
|
|
//{
|
|
// throw new Exception("请上传安全设施竣工验收记录!");
|
|
//}
|
|
|
|
if (IListDetail == null || !IListDetail.Any())
|
|
{
|
|
throw new Exception("请添加回采明细!");
|
|
}
|
|
else
|
|
{
|
|
IListDetail = IListDetail.OrderBy(e => e.DATE).ToList();
|
|
}
|
|
int index = 0;
|
|
int indexU = 0;
|
|
foreach (var item in IListDetail)
|
|
{
|
|
index++;
|
|
if (item.DATE == null)
|
|
{
|
|
throw new Exception("请选择行【" + index.ToString() + "】回采日期!");
|
|
}
|
|
if (item.DATESTART == null)
|
|
{
|
|
throw new Exception("请选择行【" + index.ToString() + "】回采开始时间!");
|
|
}
|
|
if (item.DATEEND == null)
|
|
{
|
|
throw new Exception("请选择行【" + index.ToString() + "】回采结束时间!");
|
|
}
|
|
|
|
if (item.Nav_ListDetailUser == null || !item.Nav_ListDetailUser.Any())
|
|
{
|
|
throw new Exception("请选择行【" + (index + 1).ToString() + "】值班人员!");
|
|
}
|
|
item.NUM = index;
|
|
if (item.DATE.Value.Date != item.DATESTART.Value.Date)
|
|
{
|
|
item.DATESTART = Convert.ToDateTime(item.DATE.Value.ToString("yyyy-MM-dd") + item.DATESTART.Value.ToString(" HH:mm:ss"));
|
|
}
|
|
if (item.DATE.Value.Date != item.DATEEND.Value.Date)
|
|
{
|
|
item.DATEEND = Convert.ToDateTime(item.DATE.Value.ToString("yyyy-MM-dd") + item.DATEEND.Value.ToString(" HH:mm:ss"));
|
|
}
|
|
|
|
indexU = 0;
|
|
foreach (var itemU in item.Nav_ListDetailUser)
|
|
{
|
|
if (indexU == 0)
|
|
{
|
|
itemU.ISMAINCHECK = true;
|
|
}
|
|
else
|
|
{
|
|
itemU.ISMAINCHECK = false;
|
|
}
|
|
itemU.BACK_ID = entity.ID;
|
|
indexU++;
|
|
}
|
|
listDetailUser.AddRange(item.Nav_ListDetailUser);
|
|
}
|
|
}
|
|
if (listBackRequire != null && listBackRequire.Any())
|
|
{
|
|
listBackRequire.ForEach(e => e.Nav_Require = null);
|
|
}
|
|
entity.Nav_Tailing = null;
|
|
if (entity.STATUS == PFStandardStatus.Draft)
|
|
{
|
|
this.UnifiedCommit(() =>
|
|
{
|
|
if (entity != null)
|
|
UpdateEntityNoCommit(entity);
|
|
if (files != null && files.Any())//附件
|
|
BantchSaveEntityNoCommit(files);
|
|
if (listBackRequire != null && listBackRequire.Any())//制定要求
|
|
BantchSaveEntityNoCommit(listBackRequire);
|
|
|
|
if (IListDetail != null && IListDetail.Any())//制定要求
|
|
BantchSaveEntityNoCommit(IListDetail);
|
|
if (listDetailUser != null && listDetailUser.Any())//制定要求
|
|
BantchSaveEntityNoCommit(listDetailUser);
|
|
});
|
|
}
|
|
else
|
|
{
|
|
if (entity.APPROVE_ID.HasValue)
|
|
{
|
|
throw new Exception("数据异常,该回踩计划已经审批过,请联系管理员!");
|
|
}
|
|
entity.APPROVE_ID = Guid.NewGuid();
|
|
//审批流
|
|
//TL014
|
|
string ApproveCode = "TL" + DateTime.Now.ToString("yyyyMMddHHmmsshh");
|
|
MFlowPermitService.InsertApprove(ApproveCode, "TL014", null, entity.ID, "TL014_SHOWPRINT", null, true, () =>
|
|
{
|
|
if (entity != null)
|
|
UpdateEntityNoCommit(entity);
|
|
if (files != null && files.Any())//附件
|
|
BantchSaveEntityNoCommit(files);
|
|
if (listBackRequire != null && listBackRequire.Any())//制定要求
|
|
BantchSaveEntityNoCommit(listBackRequire);
|
|
|
|
if (IListDetail != null && IListDetail.Any())//制定要求
|
|
BantchSaveEntityNoCommit(IListDetail);
|
|
if (listDetailUser != null && listDetailUser.Any())//制定要求
|
|
BantchSaveEntityNoCommit(listDetailUser);
|
|
}, entity.APPROVE_ID, null, null, null, null, "TL014_SHOWPRINT", null, null, BaseData.Domain.Enums.FMTASKTYPE.Default);//, entity.LIMITDATETIME
|
|
}
|
|
return true;
|
|
});
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 回采计划审批流
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("BackUpdate")]
|
|
public JsonActionResult<bool> CheckAuditEndNew([FromBody] T_PF_APPROVE entity)
|
|
{
|
|
return SafeExecute<bool>(() =>
|
|
{
|
|
return ApproveCallBackService.CallBackNew("TL/TLBack/BackUpdate", entity);
|
|
});
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 确定 通知
|
|
/// </summary>
|
|
/// <param name="filter"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("sendCheck")]
|
|
public JsonActionResult<bool> SendCheck([FromBody] KeywordFilter filter)
|
|
{
|
|
return SafeExecute<bool>(() =>
|
|
{
|
|
Guid taskID = Guid.Empty;
|
|
if (!string.IsNullOrEmpty(filter.Parameter1))
|
|
{
|
|
taskID = new Guid(filter.Parameter1);
|
|
}
|
|
T_FM_NOTIFICATION_TASK taskEnd = null;
|
|
if (taskID == Guid.Empty)
|
|
{
|
|
throw new Exception("获取传参有误,请刷新后再确认!");
|
|
}
|
|
else
|
|
{
|
|
taskEnd = NotificationTaskService.GetEntityTask(taskID);
|
|
}
|
|
|
|
Guid id = Guid.Empty;
|
|
try
|
|
{
|
|
id = new Guid(filter.Keyword);
|
|
}
|
|
catch
|
|
{
|
|
throw new Exception("获取传参有误,请刷新后再确认!");
|
|
}
|
|
|
|
var listDetailUser = GetEntities<T_TL_BACK_DETAIL_USER>(e => e.BACK_ID == id && !e.ISCHECK, null, null);
|
|
|
|
if (listDetailUser == null || !listDetailUser.Any())
|
|
{
|
|
throw new Exception("未获取到待确认回踩计划信息,操作失败!");
|
|
}
|
|
|
|
var listUserLogin = listDetailUser.Where(e => e.USER_ID == APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value);
|
|
if (listUserLogin == null || !listUserLogin.Any())
|
|
{
|
|
throw new Exception("暂未获取到该登陆者的待确认回踩计划信息!");
|
|
}
|
|
|
|
foreach (var item in listUserLogin)
|
|
{
|
|
item.ISCHECK = true;
|
|
}
|
|
|
|
T_TL_BACK entity = null;
|
|
var listUserOther = listDetailUser.Where(e => e.USER_ID != APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value);
|
|
if (listUserOther == null || !listUserOther.Any())//大家都已经确认
|
|
{
|
|
entity = GetEntity<T_TL_BACK>(id);
|
|
entity.STATUS = PFStandardStatus.Archived;
|
|
}
|
|
|
|
this.UnifiedCommit(() =>
|
|
{
|
|
if (listUserLogin != null && listUserLogin.Any())
|
|
BantchSaveEntityNoCommit(listUserLogin);
|
|
if (entity != null)
|
|
UpdateEntityNoCommit(entity);
|
|
if (taskEnd != null)
|
|
UpdateEntityNoCommit(taskEnd);
|
|
});
|
|
|
|
return true;
|
|
});
|
|
}
|
|
}
|
|
} |