586 lines
31 KiB
C#
586 lines
31 KiB
C#
using APT.BaseData.Domain.Entities;
|
|
using APT.BaseData.Domain.Entities.FM;
|
|
using APT.BaseData.Domain.Enums;
|
|
using APT.BaseData.Domain.IServices;
|
|
using APT.BaseData.Domain.IServices.FM;
|
|
using APT.Infrastructure.Core;
|
|
using APT.MS.Domain.Entities.BS;
|
|
using APT.MS.Domain.Entities.HM;
|
|
using APT.MS.Domain.Entities.SC.BI;
|
|
using APT.MS.Domain.Enums;
|
|
using APT.Utility;
|
|
using APT.WebApi.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
|
|
namespace APT.BS.WebApi.Controllers.Api
|
|
{
|
|
[Route("api/BS/BSRiskSubmitContent")]
|
|
public partial class BSRiskSubmitContentController : AuthorizeApiController<T_BS_RISK_SUBMIT_CONTENT>
|
|
{
|
|
IFMFlowPermitService MFlowPermitService { get; set; }
|
|
IFMNotificationTaskService NotificationTaskService { get; set; }
|
|
IPFCodeRuleService CodeRuleService { get; set; }
|
|
IPFApproveCallBackService ApproveCallBackService { get; set; }
|
|
public BSRiskSubmitContentController(IFMNotificationTaskService notificationTaskService, IFMFlowPermitService mFlowPermitService, IPFCodeRuleService codeRuleService, IPFApproveCallBackService approveCallBackService)
|
|
{
|
|
NotificationTaskService = notificationTaskService;
|
|
MFlowPermitService = mFlowPermitService;
|
|
CodeRuleService = codeRuleService;
|
|
ApproveCallBackService = approveCallBackService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获得单条实体数据
|
|
/// </summary>
|
|
/// <param name="filter">过滤实体</param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("GetDevlp")]
|
|
public JsonActionResult<T_BS_RISK_SUBMIT_CONTENT> GetDevlp([FromBody] KeywordFilter filter)
|
|
{
|
|
return SafeExecute(() =>
|
|
{
|
|
var model = GetEntity<T_BS_RISK_SUBMIT_CONTENT>(null, filter, null);
|
|
if (model.CREATER_ID.HasValue)
|
|
{
|
|
var userUp = GetEntity<T_FM_USER>(model.CREATER_ID.Value);
|
|
model.CREATE_NAME = userUp.NAME;
|
|
}
|
|
return model;
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序分页查询数据
|
|
/// </summary>
|
|
/// <param name="pageFilter">分页过滤实体</param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("OrderPagedDevlp")]
|
|
public PagedActionResult<T_BS_RISK_SUBMIT_CONTENT> OrderPagedDevlp([FromBody] KeywordPageFilter pageFilter)
|
|
{
|
|
return SafeGetPagedData(delegate (PagedActionResult<T_BS_RISK_SUBMIT_CONTENT> result)
|
|
{
|
|
//如果 上报组织 C_DEPARTMENT_ID 有值 不要走数据权限 按上报人的组织来搜索数据
|
|
Guid C_DEPARTMENT_ID = Guid.Empty;
|
|
Guid CREATER_ID = Guid.Empty;
|
|
if (pageFilter.FilterGroup.Groups != null && pageFilter.FilterGroup.Groups.Any())
|
|
{
|
|
var Groups = pageFilter.FilterGroup.Groups.ToList();
|
|
ICollection<FilterRule> GroupsRules = null;
|
|
foreach (var Group in Groups)
|
|
{
|
|
if (Group.Rules != null && Group.Rules.Any())
|
|
{
|
|
GroupsRules = Group.Rules.ToList();
|
|
foreach (var item in GroupsRules)
|
|
{
|
|
if (item.Field == "C_DEPARTMENT_ID")
|
|
{
|
|
if (item.Value != null)
|
|
{
|
|
try
|
|
{
|
|
C_DEPARTMENT_ID = new Guid(item.Value.ToString());
|
|
}
|
|
catch { }
|
|
}
|
|
GroupsRules.Remove(item);
|
|
Group.Rules = GroupsRules;
|
|
break;
|
|
}
|
|
}
|
|
if (C_DEPARTMENT_ID != Guid.Empty)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
foreach (var Group in Groups)
|
|
{
|
|
if (Group.Rules != null && Group.Rules.Any())
|
|
{
|
|
GroupsRules = Group.Rules.ToList();
|
|
foreach (var item in GroupsRules)
|
|
{
|
|
if (item.Field == "CREATER_ID")
|
|
{
|
|
if (item.Value != null)
|
|
{
|
|
try
|
|
{
|
|
CREATER_ID = new Guid(item.Value.ToString());
|
|
}
|
|
catch { }
|
|
}
|
|
GroupsRules.Remove(item);
|
|
Group.Rules = GroupsRules;
|
|
break;
|
|
}
|
|
}
|
|
if (CREATER_ID != Guid.Empty)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
PagedActionResult<T_BS_RISK_SUBMIT_CONTENT> orderPageEntities = null;
|
|
Expression<Func<T_BS_RISK_SUBMIT_CONTENT, bool>> expression = e => e.Nav_Submit.SUBMIT_TYPE != 10;
|
|
IEnumerable<T_FM_USER> listUsers = null;
|
|
if (CREATER_ID != Guid.Empty)
|
|
{
|
|
pageFilter.IgnoreDataRule = true;
|
|
expression = expression.And(e => e.CREATER_ID.HasValue && CREATER_ID == e.CREATER_ID.Value);
|
|
}
|
|
if (C_DEPARTMENT_ID != Guid.Empty && CREATER_ID == Guid.Empty)//如果选了人 就不按组织结构查找了
|
|
{
|
|
pageFilter.IgnoreDataRule = true;
|
|
listUsers = GetEntities<T_FM_USER>(e => e.DEPARTMENT_ID.HasValue && e.DEPARTMENT_ID.Value == C_DEPARTMENT_ID, null, null);
|
|
IEnumerable<Guid> IUserId = listUsers.Select(e => e.ID);
|
|
if (IUserId != null && IUserId.Any())
|
|
{
|
|
expression = expression.And(e => e.CREATER_ID.HasValue && IUserId.Contains(e.CREATER_ID.Value));
|
|
}
|
|
}
|
|
orderPageEntities = GetOrderPageEntities(expression, pageFilter, null);
|
|
if (orderPageEntities.TotalCount > 0)
|
|
{
|
|
var listUserID = orderPageEntities.Data.Where(e => e.CREATER_ID.HasValue).Select(e => e.CREATER_ID.Value).Distinct();
|
|
if (listUsers == null)
|
|
{
|
|
listUsers = GetEntities<T_FM_USER>(e => listUserID.Contains(e.ID), null, "Nav_Department");
|
|
}
|
|
else
|
|
{
|
|
var dep = GetEntity<T_FM_DEPARTMENT>(C_DEPARTMENT_ID);
|
|
foreach (var item in listUsers)
|
|
{
|
|
item.Nav_Department = dep;
|
|
}
|
|
}
|
|
T_FM_USER userModel = null;
|
|
foreach (var item in orderPageEntities.Data)
|
|
{
|
|
if (item.CREATER_ID.HasValue)
|
|
{
|
|
userModel = listUsers.FirstOrDefault(e => e.ID == item.CREATER_ID.Value);
|
|
if (userModel != null)
|
|
{
|
|
item.CREATE_NAME = userModel?.NAME;
|
|
item.Nav_Department = userModel.Nav_Department;
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(item.CREATE_NAME))
|
|
{
|
|
item.CREATE_NAME = "";
|
|
item.Nav_Department = new T_FM_DEPARTMENT();
|
|
}
|
|
}
|
|
}
|
|
|
|
result.Data = orderPageEntities.Data;
|
|
result.TotalCount = orderPageEntities.TotalCount;
|
|
});
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获得单条实体数据
|
|
/// </summary>
|
|
/// <param name="filter">过滤实体</param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("GetInfoAdapt")]
|
|
public JsonActionResult<T_BS_RISK_SUBMIT_CONTENT> GetInfoAdapt([FromBody] KeywordFilter filter)
|
|
{
|
|
return SafeExecute(() =>
|
|
{
|
|
var model = GetEntity<T_BS_RISK_SUBMIT_CONTENT>(null, filter, null);
|
|
|
|
#region 默认加载信息
|
|
|
|
if (model.CHECK_MAIN_ID.HasValue)
|
|
{
|
|
if (model.Nav_CheckMain == null)
|
|
{
|
|
model.Nav_CheckMain = GetEntity<T_BS_CHECK_MAIN>(model.CHECK_MAIN_ID.Value);
|
|
}
|
|
//新问题 新增时会把 新增的检查信息 赋值
|
|
model.CHECKOBJECT = (BSMineTypeEnum)model.Nav_CheckMain.CHECKOBJECT;
|
|
if (!model.LastDateSystem.HasValue)
|
|
{
|
|
int delayDays = GetDealyDays(model.QUESTION_LEVEL);
|
|
model.LastDateSystem = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")).AddDays(delayDays);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//检查区域 根据登录者所在生产单元
|
|
//检查类型 检查层级 默认 上次手动上报 登陆者 此区域 的值
|
|
if (APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID.HasValue && model.Nav_Submit != null && !model.Nav_Submit.CHECKOBJECT.HasValue)
|
|
{
|
|
var depUnit = GetEntities<T_FM_DEPARTMENT_PRODUCTION_UNIT>(e => e.DEPARTMENT_ID == APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID.Value, null, "Nav_Enums");
|
|
if (depUnit != null && depUnit.Count() == 1)
|
|
{
|
|
var modelUnil = depUnit.ToList()[0];
|
|
if (modelUnil.Nav_Enums != null)
|
|
{
|
|
model.Nav_Submit.CHECKOBJECT = (BSMineTypeEnum)modelUnil.Nav_Enums.VALUE;
|
|
model.CHECKOBJECT = model.Nav_Submit.CHECKOBJECT;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (model.Nav_Submit != null && !model.Nav_Submit.CHECK_TYPE_ID.HasValue && APT.Infrastructure.Api.AppContext.CurrentSession.UserID.HasValue)
|
|
{
|
|
KeywordPageFilter fiB = new KeywordPageFilter();
|
|
fiB.OrgId = model.ORG_ID;
|
|
fiB.Order = DbOrder.DESC;
|
|
fiB.PageIndex = 1;
|
|
fiB.Limit = 1;
|
|
fiB.Sort = "CREATE_TIME";
|
|
fiB.IgnoreDataRule = true;
|
|
|
|
PagedActionResult<T_BS_RISK_SUBMIT> orderPageEntities = GetOrderPageEntities<T_BS_RISK_SUBMIT>(e => e.USER_ID.HasValue && e.SUBMIT_TYPE == 20 && e.SUBMIT_STATUS.HasValue && e.SUBMIT_STATUS.Value >= 20 && e.CHECK_TYPE_ID.HasValue && e.CHECK_TYPE_LEVEL_ID.HasValue && e.USER_ID.Value == APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value, fiB);
|
|
|
|
//var info = this.GetEntities<T_BS_CHECK_QUESTION>(null, pageFilter, null).Select(e => new T_BS_CHECK_QUESTION { ID = e.ID, DEMAND = e.DEMAND, DESCREPTION = "" }).Distinct(e => e.DEMAND).ToList();
|
|
//var listOrder = GetEntities<T_BS_RISK_SUBMIT>(e => e.USER_ID.HasValue && e.SUBMIT_TYPE == 20 && e.SUBMIT_STATUS.HasValue && e.SUBMIT_STATUS.Value >= 20 && e.CHECK_TYPE_ID.HasValue && e.CHECK_TYPE_LEVEL_ID.HasValue && e.USER_ID.Value == APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value, fiB, null).Skip(1).Take(1);
|
|
|
|
if (orderPageEntities.TotalCount > 0)
|
|
{
|
|
var subNew = orderPageEntities.Data.ToList()[0];
|
|
model.Nav_Submit.CHECK_TYPE_ID = subNew.CHECK_TYPE_ID;
|
|
model.Nav_Submit.Nav_CheckType = GetEntity<T_BS_CHECK_TYPE>(subNew.CHECK_TYPE_ID.Value);
|
|
model.Nav_Submit.CHECK_TYPE_LEVEL_ID = subNew.CHECK_TYPE_LEVEL_ID;
|
|
model.Nav_Submit.Nav_CheckTypeLevel = GetEntity<T_BS_CHECK_TYPE_LEVEL>(subNew.CHECK_TYPE_LEVEL_ID.Value, "Nav_Enums");
|
|
model.CHECK_TYPE_ID = model.Nav_Submit.CHECK_TYPE_ID;
|
|
model.CHECK_TYPE_LEVEL_ID = model.Nav_Submit.CHECK_TYPE_LEVEL_ID;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
model.CHECKOBJECT = model.Nav_Submit.CHECKOBJECT;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
if (APT.Utility.DataHelper.GetRequestType(Request.Headers) == 2)
|
|
{
|
|
if (model.CHECKOBJECT.HasValue)
|
|
{
|
|
model.CHECKOBJECT_DESCRIPTION = model.CHECKOBJECT.Value.GetDescription();
|
|
}
|
|
if (model.QUESTION_LEVEL > 0)
|
|
{
|
|
model.QUESTION_LEVEL_SHOW = ((BSQuestionLevelEnum)model.QUESTION_LEVEL).GetDescription();
|
|
}
|
|
}
|
|
|
|
#region 页面合并 BS079 不要了 直接在 BS078 处理 现默认值加载
|
|
if (!model.CHECK_MAIN_ID.HasValue)
|
|
{
|
|
model.Nav_CheckMain = new T_BS_CHECK_MAIN();
|
|
if (model.CHECKOBJECT.HasValue)
|
|
model.Nav_CheckMain.CHECKOBJECT = (int)model.CHECKOBJECT.Value;
|
|
if (model.CHECK_TYPE_ID.HasValue)
|
|
{
|
|
model.Nav_CheckMain.CHECK_TYPE_ID = model.CHECK_TYPE_ID;
|
|
model.Nav_CheckMain.Nav_CheckType = model.Nav_Submit.Nav_CheckType;
|
|
}
|
|
if (model.CHECK_TYPE_LEVEL_ID.HasValue)
|
|
{
|
|
model.Nav_CheckMain.CHECK_TYPE_LEVEL_ID = model.CHECK_TYPE_LEVEL_ID;
|
|
model.Nav_CheckMain.Nav_CheckTypeLevel = model.Nav_Submit.Nav_CheckTypeLevel;
|
|
}
|
|
|
|
model.Nav_CheckMain.ORG_ID = model.ORG_ID;
|
|
model.Nav_CheckMain.SERIOUS_RISK = (int)BSSeriousRiskEnum.否;
|
|
model.Nav_CheckMain.ENABLE_STATUS = (int)FMEnableStatusEnum.禁用;
|
|
model.Nav_CheckMain.NUM = 1;
|
|
model.Nav_CheckMain.ISRISK = false;
|
|
model.CHECK_MAIN_ID = model.Nav_CheckMain.ID;
|
|
|
|
}
|
|
#endregion
|
|
|
|
return model;
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取 系统整改期限
|
|
/// </summary>
|
|
/// <param name="QUESTION_LEVEL"></param>
|
|
/// <returns></returns>
|
|
private int GetDealyDays(int QUESTION_LEVEL)
|
|
{
|
|
int delayDays = 0;
|
|
var delays = GetEntity<T_BS_RISK_LEVEL_DELAY_DAYS>(e => e.QUESTION_LEVEL == QUESTION_LEVEL);
|
|
if (delays != null)
|
|
{
|
|
delayDays = delays.MAX_DELAY_DAYS;
|
|
}
|
|
else
|
|
{
|
|
switch (QUESTION_LEVEL)
|
|
{
|
|
case (int)BSQuestionLevelEnum.重大:
|
|
delayDays = (int)BSDelayDaysEnum.重大;
|
|
break;
|
|
case (int)BSQuestionLevelEnum.A:
|
|
delayDays = (int)BSDelayDaysEnum.A;
|
|
break;
|
|
case (int)BSQuestionLevelEnum.B:
|
|
delayDays = (int)BSDelayDaysEnum.B;
|
|
break;
|
|
case (int)BSQuestionLevelEnum.C:
|
|
delayDays = (int)BSDelayDaysEnum.C;
|
|
break;
|
|
case (int)BSQuestionLevelEnum.D:
|
|
delayDays = (int)BSDelayDaysEnum.D;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return delayDays;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 手动隐患上报数据删除
|
|
/// </summary>
|
|
/// <param name="id">主键ID</param>
|
|
/// <returns></returns>
|
|
[HttpGet, Route("Delete")]
|
|
public JsonActionResult<bool> Delete(string id)
|
|
{
|
|
return SafeExecute(delegate
|
|
{
|
|
try
|
|
{
|
|
Guid CONTENTID = new Guid(id);
|
|
List<T_FM_NOTIFICATION_TASK> listTask = new List<T_FM_NOTIFICATION_TASK>();
|
|
List<T_BS_RISK_SUBMIT_CONTENT_REASON> listReason = null;
|
|
T_PF_APPROVE ApproveCheckAudit = null;
|
|
IEnumerable<T_PF_APPROVE_DETAIL> listApproveDetail = null;
|
|
T_BS_RISK_SUBMIT modelRiskDel = null;
|
|
List<T_BS_RISK_SUBMIT_FILE> Nav_FilesDel = null;
|
|
List<T_BS_RISK_SUBMIT_CONTENT_FILE> files = null;
|
|
var content = GetEntity<T_BS_RISK_SUBMIT_CONTENT>(CONTENTID, "Nav_ListRiskQuestionReason", "Nav_Files");
|
|
T_BS_RISK_SUBMIT_CONTENT_DEAL contentDeal = null;
|
|
if (content == null)
|
|
{
|
|
//BS043
|
|
contentDeal = GetEntity<T_BS_RISK_SUBMIT_CONTENT_DEAL>(CONTENTID, "Nav_Files", "Nav_FilesAfter");
|
|
content = GetEntity<T_BS_RISK_SUBMIT_CONTENT>(e => e.ID == contentDeal.RISK_SUBMIT_CONTENT_ID, "Nav_ListRiskQuestionReason", "Nav_Files");
|
|
}
|
|
|
|
listReason = content.Nav_ListRiskQuestionReason;
|
|
//content.Nav_ListRiskQuestionReason = null;
|
|
files = content.Nav_Files;
|
|
//content.Nav_Files = null;
|
|
|
|
//指定责任单位等
|
|
listTask.AddRange(GetEntities<T_FM_NOTIFICATION_TASK>(e => e.SOURCE_DATA_ID.HasValue && e.SOURCE_DATA_ID == content.ID, null, null));//指定责任单位
|
|
if (content.APPROVE_ID.HasValue && content.APPROVE_ID != Guid.Empty)
|
|
{
|
|
ApproveCheckAudit = GetEntity<T_PF_APPROVE>(content.APPROVE_ID.Value);
|
|
listApproveDetail = GetEntities<T_PF_APPROVE_DETAIL>(e => e.APPROVE_ID == ApproveCheckAudit.ID, null, null);
|
|
listTask.AddRange(GetEntities<T_FM_NOTIFICATION_TASK>(e => e.SOURCE_DATA_ID.HasValue && e.SOURCE_DATA_ID == ApproveCheckAudit.ID, null, null));
|
|
}
|
|
|
|
var contentOther = GetEntity<T_BS_RISK_SUBMIT_CONTENT>(e => e.RISK_SUBMIT_ID == content.RISK_SUBMIT_ID && e.ID != CONTENTID);
|
|
if (contentOther == null)
|
|
{
|
|
modelRiskDel = GetEntity<T_BS_RISK_SUBMIT>(content.RISK_SUBMIT_ID.Value, "Nav_Files");
|
|
Nav_FilesDel = modelRiskDel.Nav_Files;
|
|
}
|
|
ICollection<T_BS_SAFE_CHECK_DETAIL_USER> listCheckDetailUser = null;
|
|
ICollection<T_BS_SAFE_CHECK_DETAIL_QUESTION> listCheckDetailQuestion = null;
|
|
ICollection<T_BS_SAFE_CHECK_DETAIL_LAW> listLaw = null;
|
|
ICollection<T_BS_SAFE_CHECK_DETAIL_REASON> listCheckDetailReason = null;
|
|
ICollection<T_BS_SAFE_CHECK_DETAIL_FILE> files_check = null;
|
|
T_BS_SAFE_CHECK_DETAIL modelDetail = null;
|
|
|
|
if (modelRiskDel != null && modelRiskDel.CHECK_ID.HasValue)
|
|
{
|
|
modelDetail = GetEntity<T_BS_SAFE_CHECK_DETAIL>(content.SAFE_CHECK_ID.Value, "Nav_ListCheckDetailUser", "Nav_ListCheckDetailQuestion", "Nav_ListLaw", "Nav_ListCheckDetailReason", "Nav_Files");
|
|
files_check = modelDetail.Nav_Files;
|
|
listCheckDetailReason = modelDetail.Nav_ListCheckDetailReason;
|
|
listCheckDetailQuestion = modelDetail.Nav_ListCheckDetailQuestion;
|
|
listCheckDetailUser = modelDetail.Nav_ListCheckDetailUser;
|
|
listLaw = modelDetail.Nav_ListLaw;
|
|
}
|
|
|
|
T_BS_RISK_SUBMIT_NOTICE_PERSON modelNoticePerson = null;
|
|
//T_BS_RISK_SUBMIT_NOTICE modelNotice = null;
|
|
IEnumerable<T_BS_RISK_SUBMIT_NOTICE> listModelNotice = null;
|
|
bool isDelNotice = true;
|
|
if (content.RISK_SUBMIT_NOTICE_PERSON_ID.HasValue && content.RISK_SUBMIT_NOTICE_PERSON_ID != Guid.Empty)
|
|
{
|
|
var contentCheck = GetEntity<T_BS_RISK_SUBMIT_CONTENT>(e => e.RISK_SUBMIT_NOTICE_PERSON_ID == content.RISK_SUBMIT_NOTICE_PERSON_ID && e.ID != content.ID);
|
|
if (contentCheck == null)
|
|
{
|
|
//通知只有一单
|
|
modelNoticePerson = GetEntity<T_BS_RISK_SUBMIT_NOTICE_PERSON>(content.RISK_SUBMIT_NOTICE_PERSON_ID.Value);
|
|
if (modelRiskDel != null && modelNoticePerson.RISK_SUBMIT_NOTICE_ID.HasValue)
|
|
{
|
|
listModelNotice = GetEntities<T_BS_RISK_SUBMIT_NOTICE>(e => e.RISK_SUBMIT_ID.HasValue && e.RISK_SUBMIT_ID.Value == modelNoticePerson.RISK_SUBMIT_ID.Value, null);
|
|
}
|
|
|
|
//整改落实 确认等
|
|
listTask.AddRange(GetEntities<T_FM_NOTIFICATION_TASK>(e => e.SOURCE_DATA_ID.HasValue && e.SOURCE_DATA_ID == modelNoticePerson.ID, null, null));
|
|
}
|
|
else
|
|
{
|
|
isDelNotice = false;
|
|
}
|
|
//else
|
|
//{
|
|
// //多单的不能删除
|
|
// if (contentCheck.RISK_SUBMIT_NOTICE_ID.HasValue)
|
|
// {
|
|
// var listNoticePerson = GetEntities<T_BS_RISK_SUBMIT_NOTICE_PERSON>(e => e.RISK_SUBMIT_NOTICE_ID == contentCheck.RISK_SUBMIT_NOTICE_ID.Value, null, null);
|
|
// if (listNoticePerson != null && listNoticePerson.Any())
|
|
// {
|
|
// if (listNoticePerson.Count() == 1)
|
|
// {
|
|
// modelNoticePerson = listNoticePerson.ToList()[0];
|
|
// listModelNotice = GetEntities<T_BS_RISK_SUBMIT_NOTICE>(e => e.ID == contentCheck.RISK_SUBMIT_NOTICE_ID.Value, null, null);
|
|
// }
|
|
// else
|
|
// {
|
|
// if (contentCheck.RISK_SUBMIT_NOTICE_PERSON_ID.HasValue)
|
|
// {
|
|
// modelNoticePerson = listNoticePerson.First(e => e.ID == contentCheck.RISK_SUBMIT_NOTICE_PERSON_ID.Value);
|
|
// }
|
|
// }
|
|
// if (modelNoticePerson != null && modelNoticePerson.RISK_SUBMIT_ID.HasValue)
|
|
// {
|
|
// listModelNotice = GetEntities<T_BS_RISK_SUBMIT_NOTICE>(e => e.RISK_SUBMIT_ID.HasValue && e.RISK_SUBMIT_ID.Value == modelNoticePerson.RISK_SUBMIT_ID.Value, null);
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
}
|
|
if (isDelNotice && listModelNotice == null && content.RISK_SUBMIT_NOTICE_ID.HasValue)
|
|
{
|
|
listModelNotice = GetEntities<T_BS_RISK_SUBMIT_NOTICE>(e => e.ID == content.RISK_SUBMIT_NOTICE_ID.Value, null, null);
|
|
}
|
|
IEnumerable<T_BS_RISK_SUBMIT_CONTENT_DEAL_FILE> listFile = null;
|
|
IEnumerable<T_BS_RISK_SUBMIT_CONTENT_DEAL_AFTER_FILE> listAfterFile = null;
|
|
if (contentDeal == null)
|
|
{
|
|
contentDeal = GetEntity<T_BS_RISK_SUBMIT_CONTENT_DEAL>(e => e.RISK_SUBMIT_CONTENT_ID == content.ID, "Nav_Files", "Nav_FilesAfter");
|
|
}
|
|
T_PF_APPROVE ApproveDeal = null;
|
|
IEnumerable<T_PF_APPROVE_DETAIL> listApproveDetailDeal = null;
|
|
if (contentDeal != null)
|
|
{
|
|
listFile = contentDeal.Nav_Files;
|
|
//contentDeal.Nav_Files = null;
|
|
listAfterFile = contentDeal.Nav_FilesAfter;
|
|
//contentDeal.Nav_FilesAfter = null;
|
|
listTask.AddRange(GetEntities<T_FM_NOTIFICATION_TASK>(e => e.SOURCE_DATA_ID.HasValue && e.SOURCE_DATA_ID == contentDeal.ID, null, null));
|
|
|
|
if (contentDeal.APPROVE_ID.HasValue && contentDeal.APPROVE_ID != Guid.Empty)
|
|
{
|
|
ApproveDeal = GetEntity<T_PF_APPROVE>(contentDeal.APPROVE_ID.Value);
|
|
listApproveDetailDeal = GetEntities<T_PF_APPROVE_DETAIL>(e => e.APPROVE_ID == contentDeal.APPROVE_ID.Value, null, null);
|
|
listTask.AddRange(GetEntities<T_FM_NOTIFICATION_TASK>(e => e.SOURCE_DATA_ID.HasValue && e.SOURCE_DATA_ID == contentDeal.APPROVE_ID.Value, null, null));
|
|
}
|
|
}
|
|
|
|
//null 去除
|
|
int TCount = listTask.Count - 1;
|
|
for (int i = TCount; i > -1; i--)
|
|
{
|
|
if (listTask[i] == null)
|
|
{
|
|
listTask.Remove(listTask[i]);
|
|
}
|
|
}
|
|
IEnumerable<T_BI_NOTIFICATION_TASK_NEW> taskBI = null;
|
|
var listTaskID = listTask.Select(e => e.ID);
|
|
if (listTaskID != null && listTaskID.Any())
|
|
{
|
|
taskBI = GetEntities<T_BI_NOTIFICATION_TASK_NEW>(e => listTaskID.Contains(e.ID), null, null);
|
|
}
|
|
if (modelNoticePerson != null)
|
|
{
|
|
var listC = GetEntities<T_BS_RISK_SUBMIT_CONTENT>(e => e.RISK_SUBMIT_NOTICE_PERSON_ID == modelNoticePerson.ID, null, null);
|
|
if (listC != null && listC.Count() > 1)
|
|
{
|
|
modelNoticePerson = null;
|
|
}
|
|
}
|
|
this.UnifiedCommit(() =>
|
|
{
|
|
if (listTask != null && listTask.Count > 0)//待办
|
|
DeleteEntityNoCommit(listTask);
|
|
if (taskBI != null && taskBI.Count() > 0)//待办
|
|
DeleteEntityNoCommit(taskBI);
|
|
if (listApproveDetailDeal != null && listApproveDetailDeal.Count() > 0)//整改记录 审批详情
|
|
DeleteEntityNoCommit(listApproveDetailDeal);
|
|
if (ApproveDeal != null)//整改记录 审批
|
|
DeleteEntityNoCommit(ApproveDeal);
|
|
|
|
if (listFile != null && listFile.Count() > 0)//整改记录 附件 前
|
|
DeleteEntityNoCommit(listFile);
|
|
if (listAfterFile != null && listAfterFile.Count() > 0)//整改记录 附件 后
|
|
DeleteEntityNoCommit(listAfterFile);
|
|
if (contentDeal != null)//整改记录
|
|
DeleteEntityNoCommit(contentDeal);
|
|
|
|
if (files != null && files.Count() > 0)//上报明细 附件
|
|
DeleteEntityNoCommit(files);
|
|
if (listReason != null && listReason.Count() > 0)//上报明细 附件
|
|
DeleteEntityNoCommit(listReason);
|
|
if (modelNoticePerson != null)//上报通知
|
|
DeleteEntityNoCommit(modelNoticePerson);
|
|
if (listModelNotice != null && listModelNotice.Count() > 0)//上报通知
|
|
DeleteEntityNoCommit(listModelNotice);
|
|
if (content != null)//上报明细
|
|
DeleteEntityNoCommit(content);
|
|
|
|
if (Nav_FilesDel != null && Nav_FilesDel.Count > 0)//上报单附件
|
|
DeleteEntityNoCommit(Nav_FilesDel);
|
|
if (modelRiskDel != null)//上报单
|
|
DeleteEntityNoCommit(modelRiskDel);
|
|
|
|
if (listCheckDetailUser != null && listCheckDetailUser.Count() > 0)//检查人
|
|
DeleteEntityNoCommit(listCheckDetailUser);
|
|
if (listCheckDetailQuestion != null && listCheckDetailQuestion.Count() > 0)//检查问题
|
|
DeleteEntityNoCommit(listCheckDetailQuestion);
|
|
if (listLaw != null && listLaw.Count() > 0)//检查依据
|
|
DeleteEntityNoCommit(listLaw);
|
|
if (files_check != null && files_check.Count() > 0)//检查文件
|
|
DeleteEntityNoCommit(files_check);
|
|
if (listCheckDetailReason != null && listCheckDetailReason.Count() > 0)//问题原因
|
|
DeleteEntityNoCommit(listCheckDetailReason);
|
|
if (modelDetail != null)//检查项
|
|
DeleteEntityNoCommit(modelDetail);
|
|
});
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (ex is Microsoft.EntityFrameworkCore.DbUpdateException)
|
|
{
|
|
throw new Exception("该资料已被用,不允许执行此操作");
|
|
}
|
|
|
|
if (ex is DomainException && ex.Message.IndexOf("DbUpdateException", StringComparison.OrdinalIgnoreCase) > -1)
|
|
{
|
|
throw new Exception("该资料已被用,不允许执行此操作");
|
|
}
|
|
throw new Exception(ex.Message);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|