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.PF; 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/BSRiskSubmitDelayApply")] public partial class BSRiskSubmitDelayApplyController : AuthorizeApiController { IFMFlowPermitService MFlowPermitService { get; set; } IFMNotificationTaskService NotificationTaskService { get; set; } IPFCodeRuleService CodeRuleService { get; set; } IPFApproveCallBackService ApproveCallBackService { get; set; } IFMDepartmentService DepartmentService { get; set; } IBSOperateLogService OperateLogService { get; set; } public BSRiskSubmitDelayApplyController(IFMNotificationTaskService notificationTaskService, IFMFlowPermitService mFlowPermitService, IPFCodeRuleService codeRuleService, IPFApproveCallBackService approveCallBackService, IFMDepartmentService departmentService, IBSOperateLogService operateLogService) { NotificationTaskService = notificationTaskService; MFlowPermitService = mFlowPermitService; CodeRuleService = codeRuleService; ApproveCallBackService = approveCallBackService; DepartmentService = departmentService; OperateLogService = operateLogService; } /// /// 排序分页查询数据 /// /// 分页过滤实体 /// [HttpPost, Route("OrderPagedSubContent")] public PagedActionResult OrderPagedArea([FromBody] KeywordPageFilter pageFilter) { return SafeGetPagedData((result) => { DateTime dtNowDate = DateTime.Now.Date; Guid LoginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value; //今天 审批退回 可以申请延期 // 实际整改人是登录者 未删除 截止时间小与当前日期 //非延期申请 落实整改人已经查阅整改通知 //延期申请 已退回 Expression> expression = e => e.ACTUAL_DEAL_USER_ID.HasValue && e.ACTUAL_DEAL_USER_ID == LoginID && !e.IS_DELETED && e.LastDateUser.HasValue && e.LastDateUser.Value >= dtNowDate && (((!e.ISBACK.HasValue || !e.ISBACK.Value) && e.RiskContentState == (int)RiskContentState.ActualDealCheck) || (e.ISBACK.HasValue && e.ISBACK.Value && e.RiskContentState == (int)RiskContentState.OKNotBack) ); //Expression> expression = e => e.ACTUAL_DEAL_USER_ID.HasValue && e.ACTUAL_DEAL_USER_ID == LoginID && !e.IS_DELETED;//测试数据 var info = this.GetEntities(expression, null, new string[] { "Nav_UserActualDeal.Nav_Department", "Nav_Question" }).ToList(); result.TotalCount = info.Count; result.Data = info.Skip((pageFilter.PageIndex - 1) * pageFilter.Limit).Take(pageFilter.Limit).OrderByDescending(e => e.CREATE_TIME).ToList(); }); } /// /// 排序分页查询数据 /// /// 分页过滤实体 /// [HttpPost, Route("OrderPagedNoticePerson")] public PagedActionResult OrderPagedNoticePerson([FromBody] KeywordPageFilter pageFilter) { return SafeGetPagedData((result) => { DateTime dtNowDate = DateTime.Now.Date; Guid LoginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value; //今天 审批退回 可以申请延期 // 实际整改人是登录者 未删除 截止时间小与当前日期 //非延期申请 落实整改人已经查阅整改通知 //延期申请 已退回 //Expression> expression = e => e.ACTUAL_DEAL_USER_ID.HasValue && e.ACTUAL_DEAL_USER_ID == LoginID && !e.IS_DELETED && e.LastDateUser.HasValue && e.LastDateUser.Value >= dtNowDate //&& (((!e.ISBACK.HasValue || !e.ISBACK.Value) && e.RiskContentState == (int)RiskContentState.ActualDealCheck) || (e.ISBACK.HasValue && e.ISBACK.Value && e.RiskContentState == (int)RiskContentState.OKNotBack) //); //var info = this.GetEntities(expression, null, new string[] { "Nav_SubmitNoticePerson" }).Select(e => new T_BS_RISK_SUBMIT_NOTICE_PERSON {ID = e.Nav_SubmitNoticePerson.ID,NAME= e.Nav_SubmitNoticePerson.NAME, QUESTION_LEVEL=e.Nav_SubmitNoticePerson.QUESTION_LEVEL }).Distinct().ToList().Distinct(); //result.TotalCount = info.Count(); //result.Data = info.Skip((pageFilter.PageIndex - 1) * pageFilter.Limit).Take(pageFilter.Limit).OrderByDescending(e => e.CREATE_TIME).ToList(); // Func expression = e => e.ACTUAL_DEAL_USER_ID.HasValue && e.ACTUAL_DEAL_USER_ID == LoginID && !e.IS_DELETED && e.LastDateUser.HasValue && e.LastDateUser.Value >= dtNowDate //&& (((!e.ISBACK.HasValue || !e.ISBACK.Value) && e.RiskContentState == (int)RiskContentState.ActualDealCheck) || (e.ISBACK.HasValue && e.ISBACK.Value && e.RiskContentState == (int)RiskContentState.OKNotBack) //); pageFilter.IgnoreDataRule = true; var info = GetEntities(e => e.Nav_ListRiskSubmitContent.FirstOrDefault(e => e.ACTUAL_DEAL_USER_ID.HasValue && e.ACTUAL_DEAL_USER_ID.Value == LoginID && !e.IS_DELETED && e.LastDateUser.HasValue && e.LastDateUser.Value >= dtNowDate && (e.RiskContentState == (int)RiskContentState.ActualDealCheck || e.RiskContentState == (int)RiskContentState.DealTemp || e.RiskContentState == (int)RiskContentState.OKNotBack)) != null, pageFilter, new string[] { "Nav_ListRiskSubmitContent" }).Distinct(); result.TotalCount = info.Count(); result.Data = info.Skip((pageFilter.PageIndex - 1) * pageFilter.Limit).Take(pageFilter.Limit).OrderByDescending(e => e.CODE).ToList(); //app调用 添加显示 if (result.TotalCount > 0 && DataHelper.GetRequestType(Request.Headers) == 2) { result.Data.ForEach(e => { if (e.QUESTION_LEVEL > 0) { e.QUESTION_LEVEL_SHOW = ((BSQuestionLevelEnum)e.QUESTION_LEVEL).GetDescription(); } }); } }); } //public JsonActionResult> OrderEntities([FromBody] KeywordFilter filter) //{ // return WitOrderEntities(null, filter); //} /// /// 排序分页查询数据 /// /// 分页过滤实体 /// [HttpPost, Route("GetNoticePersonCanDelayContent")] public PagedActionResult GetNoticePersonCanDelayContent([FromBody] KeywordFilter filter) { return SafeGetPagedData((result) => { if (!string.IsNullOrEmpty(filter.Keyword)) { //今天 审批退回 可以申请延期 Guid NoticePersonID = new Guid(filter.Keyword); DateTime dtNowDate = DateTime.Now.Date; Guid LoginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value; var info = GetEntities(e => e.RISK_SUBMIT_NOTICE_PERSON_ID == NoticePersonID && e.ACTUAL_DEAL_USER_ID.HasValue && e.ACTUAL_DEAL_USER_ID.Value == LoginID && !e.IS_DELETED && e.LastDateUser.HasValue && e.LastDateUser.Value >= dtNowDate && (e.RiskContentState == (int)RiskContentState.ActualDealCheck || e.RiskContentState == (int)RiskContentState.OKNotBack), null, null).ToList(); var listContID = info.Select(e => e.ID); var listDelay = GetEntities(e => listContID.Contains(e.Nav_SubmitContent.ID), null, new string[] { "Nav_SubmitContent" }).Select(e => e.Nav_SubmitContent); List listContentDelayID = new List(); if (listDelay != null && listDelay.Count() > 0) { listContentDelayID.AddRange(listDelay.Select(e => e.ID)); } List listInfo = new List(); for (int i = 0; i < info.Count; i++) { if (listContentDelayID.Count > 0) { if (listContentDelayID.Contains(info[i].ID)) { continue; } } T_BS_RISK_SUBMIT_DELAY_APPLY_DETAIL temp = new T_BS_RISK_SUBMIT_DELAY_APPLY_DETAIL(); temp.RISK_SUBMIT_CONTENT_ID = info[i].ID; temp.RISK_SUBMIT_NOTICE_PERSON_ID = info[i].RISK_SUBMIT_NOTICE_PERSON_ID.Value; temp.QUESTION_LEVEL = info[i].QUESTION_LEVEL; temp.CHECK_QUESTION_ID = info[i].CHECK_QUESTION_ID.Value; temp.LastDate = info[i].LastDateUser; temp.Nav_SubmitContent = info[i]; listInfo.Add(temp); } result.Data = listInfo; } }); } /// /// 更新 审批流参考 EvaluvationPlanController AddFullUpdate /// /// /// [HttpPost, Route("FullUpdate")] public JsonActionResult FullUpdate([FromBody] T_BS_RISK_SUBMIT_DELAY_APPLY entity) { return SafeExecute(() => { //参考的审批流 api / HM / HMEvaluationPlan/ AddFullUpdate //审批信息必须有 后续可能自动匹配 //必须要有检查明细 每项的检查人员必须有2个或以上的人员 var listApply = entity.Nav_ListApplyDetail; if (listApply == null || listApply.Count < 1) { throw new Exception("延期整改明细不能为空!"); } var listApplyDetail = listApply.ToList().FindAll(x => !x.IS_DELETED); if (listApplyDetail == null || listApplyDetail.Count < 1) { throw new Exception("延期整改明细不能为空!"); } //var listApplyDetail = entity.Nav_ListApplyDetail.ToList(); entity.NAME = entity.NAME.Replace("隐患整改通知:", ""); List listContentID = new List(); int rowIndex = 1; for (int i = listApplyDetail.Count - 1; i > -1; i--) { if (listApplyDetail[i].RISK_SUBMIT_DELAY_APPLY_ID == Guid.Empty && listApplyDetail[i].IS_DELETED) { listApplyDetail.Remove(listApplyDetail[i]); } } if (listApplyDetail.Count < 1) { throw new Exception("延期整改明细不能为空!"); } foreach (var item in listApplyDetail) { if (entity.OPERARTETYPE != (int)OperateType.Temp) { //if (string.IsNullOrEmpty(item.Nav_SubmitContent.DESCREPTION)) //{ // throw new Exception("行【" + rowIndex + "】检查问题描述不能为空!"); //} if (item.RISK_SUBMIT_CONTENT_ID == Guid.Empty) { throw new Exception("行【" + rowIndex + "】检查问题描述不能为空!"); } if (string.IsNullOrEmpty(item.REASON)) { throw new Exception("行【" + rowIndex + "】延期理由不能为空!"); } if (string.IsNullOrEmpty(item.TEMPDEMAND) && item.QUESTION_LEVEL == (int)BSQuestionLevelEnum.重大) { throw new Exception("行【" + rowIndex + "】重大隐患临时整改建议与措施不能为空!"); } if (item.LastDateApply == null) { throw new Exception("行【" + rowIndex + "】延期后整改期限不能为空!"); } else { item.LastDateApply = item.LastDateApply.Value.Date.AddDays(1).AddSeconds(-1); } if (item.LastDateApply < item.LastDate) { throw new Exception("行【" + rowIndex + "】申请延期整改期限不能小于整改期限!"); } if (item.LastDateApply < DateTime.Now.Date) { throw new Exception("行【" + rowIndex + "】申请延期整改期限不能小于当前日期!"); } } item.LastDateApply = item.LastDateApply.Value.Date.AddDays(1).AddSeconds(-1); item.RISK_SUBMIT_DELAY_APPLY_ID = entity.ID; item.ORG_ID = entity.ORG_ID; item.NAME = entity.NAME + rowIndex; item.CODE = entity.CODE + "_" + rowIndex; listContentID.Add(item.RISK_SUBMIT_CONTENT_ID); rowIndex++; } entity.NAME = "延期申请:" + entity.NAME.Replace("延期申请:", ""); var listContent = GetEntities(e => listContentID.Contains(e.ID), null, new string[] { "Nav_UserDeal", "Nav_DepartmentDeal" }).ToList(); foreach (var item in listContent) { if (item.LastDateUser < DateTime.Now.Date) { throw new Exception("该隐患已经超过整改期限,不能延期整改!"); } } //var content = GetEntity(entity.RISK_SUBMIT_CONTENT_ID, new string[] { "Nav_UserDeal" }); //if (content.LastDateUser < DateTime.Now.Date) //{ // throw new Exception("该隐患已经超过整改期限,不能延期整改!"); //} //var modelCheck = GetEntity(e => e.ID != entity.ID && e.RISK_SUBMIT_CONTENT_ID == entity.RISK_SUBMIT_CONTENT_ID); //if (modelCheck != null) //{ // if (modelCheck.APPROVE_ID == null) // { // throw new Exception("该隐患内容有延期申请草稿,请修改该草稿信息!"); // } // else // { // throw new Exception("该隐患内容已经申请过延期,操作失败!"); // } //} //var listCheckDetail = GetEntities(e => listContentID.Contains(e.RISK_SUBMIT_CONTENT_ID), null, new string[] { "Nav_SubmitContent", "Nav_Apply" }); //if (listCheckDetail != null && listCheckDetail.Count() > 0) //{ // List listName = new List(); // foreach (var item in listCheckDetail) // { // listName.Add(item.Nav_SubmitContent.NAME); // } // throw new Exception(string.Join(',', listName) + "有申请记录!"); //} Guid LoginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value; entity.Nav_ListApplyDetail = null; entity.APPLY_DEPARTMENT_ID = GetEntity(LoginID).DEPARTMENT_ID.Value; entity.USER_ID = LoginID; if (entity.OPERARTETYPE == (int)OperateType.Temp) { this.UnifiedCommit(() => { //保存草稿 UpdateEntity(entity); BantchSaveEntityNoCommit(listApplyDetail);//延期申请明细 }); } else { //List listDetail = entity.Nav_ListApplyDetail.ToList(); foreach (var item in listApplyDetail) { if (item.Nav_SubmitContent == null) { item.Nav_SubmitContent = GetEntity(item.RISK_SUBMIT_CONTENT_ID); } if (item.Nav_SubmitContent.ACTUAL_DEAL_USER_ID != LoginID) { throw new Exception("操作失败,不允许操作他人的延期申请!"); } } ////entity.CREATER_ID != APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value //if (entity.Nav_SubmitContent.ACTUAL_DEAL_USER_ID != APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value) //{ // throw new Exception("操作失败,不允许操作他人的延期申请!"); //} //保存并通知 var sysFilter = new SystemCodeFilter(); sysFilter.CodeType = (int)PFCodeRuleType.审批流编码; sysFilter.Count = 1; sysFilter.OrgId = entity.ORG_ID; var serialCode = CodeRuleService.NewGenSerial(sysFilter); string parms = string.Empty; if (entity.QUESTION_LEVEL == 10 || entity.QUESTION_LEVEL == 20) { parms = entity.QUESTION_LEVEL.ToString(); } else { parms = "30_40_50"; } //延期申请 状态修改 foreach (var item in listContent) { item.RiskContentState = (int)RiskContentState.ReportedDelayApply; } Dictionary dicApproveUser = new Dictionary();//自定义审批流人员信息 Dictionary dicApproveDepartMent = new Dictionary();//自定义审批流人员所在部门 //1 整改责任人 //2 整改部门负责人 (隐患通知责任人所在部门级别的负责人) //3 发起部门负责人 //var CreateUser = GetEntity(listContent[0].CREATER_ID.Value, new string[] { "Nav_Department" }); var CreateUser = GetEntity(LoginID, new string[] { "Nav_Department" });//发起部门 是延期整改发起部门? dicApproveUser.Add(1, listContent[0].Nav_UserDeal); dicApproveDepartMent.Add(2, listContent[0].Nav_DepartmentDeal.ID); var userModelNotice = listContent[0].Nav_User; if (userModelNotice == null) { userModelNotice = GetEntity(listContent[0].USER_ID.Value); } var userModel = GetDepartMentLevelMaster(userModelNotice);//隐患通知责任人 if (userModel != null && !string.IsNullOrEmpty(userModel.NAME)) { dicApproveUser.Add(3, userModel);//隐患通知责任人 所在的部门级别负责人 } else { dicApproveUser.Add(3, userModelNotice); } entity.APPROVE_ID = Guid.NewGuid(); var listDataIdSub = listContent.Select(e => e.ID).ToList(); MFlowPermitService.InsertApprove(serialCode, "BS046", parms, entity.ID, "BS046_SHOWPRINT", entity.TaskID, true, () => { if (entity != null) UpdateEntityNoCommit(entity); //保存主表 NoCommit //UpdateEntityNoCommit(content); //延期申请提交 BantchSaveEntityNoCommit(listApplyDetail);//延期申请明细 BantchSaveEntityNoCommit(listContent);//延期申请提交 }, entity.APPROVE_ID, null, dicApproveUser, dicApproveDepartMent, null, null, null, null, FMTASKTYPE.BS_RiskUp_DealApply, null, null, (int)OPERATEPOINT_Enums.RiskDelayApply, entity.RISK_SUBMIT_ID, null, null, listDataIdSub); } return true; }); } /// /// 获取人员所在部门级负责人 /// /// /// private T_FM_USER GetDepartMentLevelMaster(T_FM_USER modelUser) { T_FM_USER user = new T_FM_USER(); var modelDep = GetEntity(modelUser.DEPARTMENT_ID.Value); if (modelDep.DEPARTMENT_TYPE != (int)FMDepartmentType.Department) { do { modelDep = GetEntity(e => e.ID == modelDep.PARENT_ID); } while (modelDep.DEPARTMENT_TYPE != (int)FMDepartmentType.Department && modelDep.PARENT_ID.HasValue); } if (modelDep.DEPARTMENT_TYPE == (int)FMDepartmentType.Department) { var approveRol = GetEntity(e => e.DEPARTMENT_TYPE == (int)FMDepartmentType.Department && e.NAME.Contains("负责人")); if (approveRol != null) { user = GetEntity(e => e.APPROVE_ROLE_ID == approveRol.ID && e.DEPARTMENT_ID == modelDep.ID); } } return user; } /// /// 延期申请 完成 修改状态、最后完成时间 给验收人发送通知 /// api/BS/BSRiskSubmit/DealEnd /// /// /// [HttpGet, Route("DealEnd")] public JsonActionResult DealEnd(string id) { return SafeExecute(() => { return ApproveCallBackService.CallBack("BS/BSRiskSubmitDelayApply/DealEnd", id); }); } /// /// 获得单条实体数据 (好像没用到) /// /// 过滤实体 /// [HttpPost, Route("GetAll")] public JsonActionResult GetAll([FromBody] KeywordFilter filter) { return SafeExecute(() => { var mobelResult = this.GetEntity(null, filter); if (mobelResult == null) { Guid ID = Guid.Empty; var rules = filter.FilterGroup.Rules; if (rules != null) { List listRule = rules.ToList(); foreach (var item in listRule) { if (item.Field == "ID") { ID = new Guid(item.Value.ToString()); } } } var modelTemp = this.GetEntity(ID, new string[] { "Nav_SubmitContent" }); if (modelTemp != null) { mobelResult = new T_BS_RISK_SUBMIT_DELAY_APPLY(); mobelResult.USER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value; mobelResult.QUESTION_LEVEL = modelTemp.QUESTION_LEVEL; //mobelResult.LastDate = modelTemp.Nav_SubmitContent.LastDateUser;//1 mobelResult.RISK_SUBMIT_ID = modelTemp.RISK_SUBMIT_ID.Value; mobelResult.RISK_SUBMIT_CONTENT_ID = modelTemp.RISK_SUBMIT_CONTENT_ID.Value; //mobelResult.APPLY_DEPARTMENT_ID = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID.Value; //mobelResult.DEMAND= mobelTemp. //mobelResult.LastDateApply= } } else { //如果 状态为延期中 //并且 审核人 为登录者 审批时间为空 if (mobelResult.OPERARTETYPE == (int)OperateType.Check) { Guid LoginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value; var detail = mobelResult.Nav_ListApplyDetail; if (detail.Count() > 0) { var detailLogin = detail.ToList().FindAll(e => e.Nav_SubmitContent.RiskContentState == (int)RiskContentState.ReportedDelay && e.CHCEKUSERID == LoginID && e.CHCEKTIME == null); if (detailLogin != null && detailLogin.Count > 0) { mobelResult.Nav_ListApplyDetail = detailLogin; } } } else { if (mobelResult.Nav_Approve != null && mobelResult.Nav_Approve.Nav_ApproveDetails != null && mobelResult.Nav_Approve.Nav_ApproveDetails.Count() > 0) { mobelResult.Nav_Approve.Nav_ApproveDetails = mobelResult.Nav_Approve.Nav_ApproveDetails.OrderBy(e => e.NUM).ToList(); } } } //QUESTION_LEVEL_SHOW if (mobelResult != null && mobelResult.QUESTION_LEVEL > 0 && DataHelper.GetRequestType(Request.Headers) == 2) { try { mobelResult.QUESTION_LEVEL_SHOW = ((BSQuestionLevelEnum)mobelResult.QUESTION_LEVEL).GetDescription(); } catch { } } return mobelResult; }); } /// /// 整改落实人 确认整改通知单 系统发送整改单给整改落实人 /// /// /// [HttpPost, Route("CheckDetail")] public JsonActionResult CheckDetail([FromBody] KeywordFilter filter) { return SafeExecute(() => { var DataID = new Guid(filter.Keyword); var TaskID = new Guid(filter.Parameter1); List listDetailID = filter.Parameter2.Split(',', StringSplitOptions.RemoveEmptyEntries).ToList(); List listDetailGuid = new List(); foreach (var item in listDetailID) { listDetailGuid.Add(new Guid(item)); } Guid LoginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value; //var details = GetEntities(e => e.RISK_SUBMIT_DELAY_APPLY_ID == DataID && !e.IS_DELETED && e.CHCEKUSERID == LoginID, null, null).ToList(); var details = GetEntities(e => listDetailGuid.Contains(e.ID) && e.CHCEKTIME == null, null, null).ToList(); T_FM_NOTIFICATION_TASK task = this.GetEntity(TaskID); task.TASK_DT = DateTime.Now; if (task.TASK_ENDDT >= task.TASK_DT) task.NOTICE_STATUS = FMNoticeStatusEnum.正常已办.GetInt(); else task.NOTICE_STATUS = FMNoticeStatusEnum.超期办理.GetInt(); List listOperateLog = new List(); for (int i = 0; i < details.Count; i++) { details[i].CHCEKTIME = DateTime.Now; //设置审批时间 listOperateLog.AddRange(OperateLogService.GetListOperateLog(OPERATEPOINT_Enums.RiskDelayApplyCheck, Guid.Empty, LoginID, null, null, null, filter.OrgId, details[i].RISK_SUBMIT_CONTENT_ID, null, false, task.TASK_ENDDT));//修改操作日志 } this.UnifiedCommit(() => { BantchUpdateEntityNoCommit(details); if (task != null)//代办消息 清除 UpdateEntityNoCommit(task, "NOTICE_STATUS", "TASK_DT", "MODIFIER_ID"); if (listOperateLog != null && listOperateLog.Any()) BantchSaveEntityNoCommit(listOperateLog); }); return true; }); } /// /// /// /// /// [HttpGet, Route("BatchDeleteFull")] public JsonActionResult BatchDeleteFull(string ids) { return SafeExecute(() => { if (string.IsNullOrEmpty(ids)) { return false; } List aryList = (from i in ids.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries) select new Guid(i)).ToList(); var applyDetail = GetEntities(e => aryList.Contains(e.RISK_SUBMIT_DELAY_APPLY_ID), null, new string[] { "Nav_Apply.Nav_Approve.Nav_ApproveDetails", "Nav_SubmitContent" }).ToList(); if (applyDetail != null && applyDetail.Count > 0) { Guid loginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value; List ids = applyDetail.Select(e => e.ID).ToList(); List idsApply = new List();//ApplyID List content = new List(); //List listApprove = null; List listApproveId = new List(); List listApproveDetailId = new List(); List approveDetail = new List(); for (int i = 0; i < applyDetail.Count; i++) { applyDetail[i].Nav_SubmitContent.RiskContentState = (int)RiskContentState.ActualDealCheck; content.Add(applyDetail[i].Nav_SubmitContent); if (!idsApply.Contains(applyDetail[i].Nav_Apply.ID)) { idsApply.Add(applyDetail[i].Nav_Apply.ID); if (applyDetail[i].Nav_Apply.CREATER_ID != loginID) { throw new Exception("只能删除自己的延期申请!"); } listApproveId.Add(applyDetail[i].Nav_Apply.Nav_Approve.ID); if (!applyDetail[i].Nav_Apply.Nav_Approve.Nav_ApproveDetails.OrderBy(e => e.NUM).ToList()[0].IS_CURRENT) { throw new Exception("只能删除未审批过的延期申请!"); } listApproveDetailId.AddRange(applyDetail[i].Nav_Apply.Nav_Approve.Nav_ApproveDetails.Select(e => e.ID)); } } var listTask = GetEntities(e => e.SOURCE_DATA_ID.HasValue && listApproveId.Contains(e.SOURCE_DATA_ID.Value), null, null); this.UnifiedCommit(() => { BantchDeleteEntityNoCommit(ids); //删除延期申请明细 BantchDeleteEntityNoCommit(idsApply);//删除延期申请单 BantchDeleteEntityNoCommit(listApproveId); BantchDeleteEntityNoCommit(listApproveDetailId); BantchDeleteEntityNoCommit(listTask.Select(e => e.ID).ToList()); BantchUpdateEntityNoCommit(content);//修改状态 }); } return true; }); } /// /// 根据主键删除数据 /// /// 主键ID /// [HttpGet, Route("DeleteFull")] public JsonActionResult DeleteFull(string id) { return SafeExecute(() => { if (string.IsNullOrEmpty(id)) { return false; } Guid ApplyID = new Guid(id); var applyDetail = GetEntities(e => e.RISK_SUBMIT_DELAY_APPLY_ID == ApplyID, null, new string[] { "Nav_Apply.Nav_Approve.Nav_ApproveDetails", "Nav_SubmitContent" }).ToList(); if (applyDetail != null && applyDetail.Count > 0) { if (applyDetail[0].Nav_Apply.CREATER_ID != APT.Infrastructure.Api.AppContext.CurrentSession.UserID) { throw new Exception("只能删除自己的延期申请!"); } List ids = applyDetail.Select(e => e.ID).ToList(); List content = new List(); for (int i = 0; i < applyDetail.Count; i++) { applyDetail[i].Nav_SubmitContent.RiskContentState = (int)RiskContentState.ActualDealCheck; content.Add(applyDetail[i].Nav_SubmitContent); } var appDetail = applyDetail[0].Nav_Apply.Nav_Approve.Nav_ApproveDetails.OrderBy(e => e.NUM).ToList(); if (!appDetail[0].IS_CURRENT) { throw new Exception("该延期申请已经审批过,操作失败!"); } List listDetailID = appDetail.Select(e => e.ID).ToList(); var task = GetEntity(e => e.SOURCE_DATA_ID.HasValue && e.SOURCE_DATA_ID == applyDetail[0].Nav_Apply.ID); this.UnifiedCommit(() => { BantchDeleteEntityNoCommit(ids); //删除延期申请明细 DeleteEntityNoCommit(applyDetail[0].Nav_Apply);//删除延期申请单 DeleteEntityNoCommit(applyDetail[0].Nav_Apply.Nav_Approve);//审批流 BantchDeleteEntityNoCommit(listDetailID);//审批流明细 DeleteEntityNoCommit(task);//任务 BantchUpdateEntityNoCommit(content);//修改状态 }); } return true; }); } /// /// 延期申请 /// /// 分页过滤实体 /// [HttpPost, Route("OrderPaged")] public PagedActionResult ContentDetailOrderPaged([FromBody] KeywordPageFilter pageFilter) { return SafeGetPagedData(delegate (PagedActionResult result) { List departmentIds = new List() { APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID.Value }; DepartmentService.GetDepartmentIds(pageFilter.OrgId.Value, new List() { APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID.Value }, ref departmentIds); var loginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value; Expression> expression = e => !e.IS_DELETED && (e.USER_ID == loginID || departmentIds.Contains(e.APPLY_DEPARTMENT_ID)); PagedActionResult orderPageEntities = GetOrderPageEntities(expression, pageFilter, null); result.Data = orderPageEntities.Data; result.TotalCount = orderPageEntities.TotalCount; }); } /// /// 延期申请 完成 修改状态、最后完成时间 给验收人发送通知 /// api/BS/BSRiskSubmit/DealEnd /// /// /// [HttpPost, Route("DealEndNew")] public JsonActionResult DealEndNew([FromBody] T_PF_APPROVE entity) { return SafeExecute(() => { return ApproveCallBackService.CallBackNew("BS/BSRiskSubmitDelayApply/DealEndNew", entity); }); } /// /// 延期整改申请 驳回 /// /// /// [HttpPost, Route("DealBack")] public JsonActionResult DealBack([FromBody] T_PF_APPROVE entity) { return SafeExecute(() => { //公共 获取审批流信息 T_PF_APPROVE modelApp = null; List listAppDetail = null; T_FM_NOTIFICATION_TASK taskFinish = null; string Msg = string.Empty; bool ResultGetInfo = ApproveCallBackService.GetApproject(entity, ref modelApp, ref listAppDetail, ref taskFinish, ref Msg); if (!ResultGetInfo) throw new Exception("驳回失败!"); if (modelApp == null || listAppDetail == null) throw new Exception("获取驳回信息失败!"); #region 驳回主体 审批 如果就不让驳回 暂不处理(本来想处理方案就是直接关闭) T_BS_RISK_SUBMIT_DELAY_APPLY apply = GetEntity(entity.DATA_ID, "Nav_User"); apply.OPERARTETYPE = (int)OperateType.Back; #endregion T_FM_NOTIFICATION_TASK taskBack = NotificationTaskService.InsertUserNoticeTaskModel("延期整改申请驳回", entity.DATA_ID, entity.ORG_ID, apply.USER_ID, apply.Nav_User.NAME, DateTime.Now, DateTime.Now.AddHours(12), (int)FMNoticeTypeEnum.消息, "BS046"); UnifiedCommit(() => { if (modelApp != null) UpdateEntityNoCommit(modelApp); if (listAppDetail != null && listAppDetail.Count > 0) BantchUpdateEntityNoCommit(listAppDetail); if (taskFinish != null) UpdateEntityNoCommit(taskFinish); if (taskBack != null) UpdateEntityNoCommit(taskBack); }); return true; }); } } }