diff --git a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SEController.cs b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SEController.cs index b757506..a498911 100644 --- a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SEController.cs +++ b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SEController.cs @@ -139,22 +139,53 @@ namespace APT.PP.WebApi.Controllers.Api.PP { return SafeExecute(() => { + + DateTime dtNow = DateTime.Now; + var Parameter1 = filter.Parameter1; + if (!string.IsNullOrEmpty(filter.Parameter1)) + { + try + { + //接收来自页面的参数 + DateTime deParm = Convert.ToDateTime(filter.Parameter1); + dtNow = deParm; + } + catch { } + } + try { #region SE安全教育培训 //触发教育培训调查汇总 - CheckTrainEffectSuveyEvaluation(filter); + CheckTrainEffectSuveyEvaluation(filter, dtNow); //安全意识调查结束部门汇总 - CheckSafeSuveyDepartReport(filter); + CheckSafeSuveyDepartReport(filter, dtNow); //安全意识调查所有结束公司汇总 - CheckSafeSuveyCompanyReport(filter); + CheckSafeSuveyCompanyReport(filter, dtNow); //培训需求调查结束汇总 - CheckTrainSuveyFinishByDepartment(filter); + CheckTrainSuveyFinishByDepartment(filter, dtNow); #endregion #region LR法律法规 //触发需求分析,通知安环部负责人安全生产法律法规获取清单 - NoticeEndDemandDistinguish(filter); + NoticeEndDemandDistinguish(filter, dtNow); #endregion + + if (!string.IsNullOrEmpty(filter.Parameter1)) + { + //去除参数 + var task = GetEntity(filter.Keyword); + if (task != null) + { + //不能新增去年的 + task.CURR_TASK_START_TIME = DateTime.Now;//上次同步结束时间 + task.UPDATE_SUCCES_TIME = DateTime.Now;//上次同步结束时间 + task.SYNC_PARAM = "";//清空参数 + UnifiedCommit(() => + { + UpdateEntityNoCommit(task); + }); + } + } } catch (Exception ex) { @@ -573,9 +604,10 @@ namespace APT.PP.WebApi.Controllers.Api.PP /// 通知安环部所有人员和各个部门安全员相关的安全生产法律法规需求分析表 /// /// + /// /// [HttpGet, Route("NoticeEndDemandDistinguish")] - public JsonActionResult NoticeEndDemandDistinguish([FromBody] KeywordFilter filter) + public JsonActionResult NoticeEndDemandDistinguish(KeywordFilter filter, DateTime nowTime) { return SafeExecute(() => { @@ -593,7 +625,6 @@ namespace APT.PP.WebApi.Controllers.Api.PP List lrDemandUsers = new List(); List sendNotices = null; T_LR_LEGAL_LIST legalList = null; - DateTime nowTime = DateTime.Now; BaseFilter baseFilter = new BaseFilter(filter.GetOrgId()); var config = GetEntity(null, baseFilter); if (config != null) @@ -1233,12 +1264,11 @@ namespace APT.PP.WebApi.Controllers.Api.PP /// /// /// - public JsonActionResult CheckSafeSuveyDepartReport([FromBody] KeywordFilter filter) + public JsonActionResult CheckSafeSuveyDepartReport(KeywordFilter filter, DateTime dt) { return SafeExecute(() => { - //各部门截止时间后生成部门统计报表发送发起人 - var dt = DateTime.Now; + //各部门截止时间后生成部门统计报表发送发起人 BaseFilter baseFilter = new BaseFilter(filter.GetOrgId()); baseFilter.Include = new string[] { "Nav_LaunchUser" }; var surveys = GetEntities( @@ -1274,12 +1304,11 @@ namespace APT.PP.WebApi.Controllers.Api.PP return true; }); } - private JsonActionResult CheckTrainSuveyFinishByDepartment([FromBody] KeywordFilter filter) + private JsonActionResult CheckTrainSuveyFinishByDepartment(KeywordFilter filter, DateTime dt) { return SafeExecute(() => { //各部门截止时间后生成部门统计报表发送发起人 - var dt = DateTime.Now; BaseFilter baseFilter = new BaseFilter(filter.GetOrgId()); baseFilter.Include = new string[] { "Nav_LaunchUser" }; var surveys = GetEntities(t => t.LAUNCH_TIME.Value.Year == dt.Year && @@ -1300,13 +1329,31 @@ namespace APT.PP.WebApi.Controllers.Api.PP allSendUserNames.Add(survey.Nav_LaunchUser.NAME); survey.STATUS = SETrainSurveyStatus.汇总中; survey.Nav_LaunchUser = null; - UpdateEntity(survey); + //UpdateEntity(survey);//待测试会不会有bug } var sendNotices = NotificationTaskService.InsertUserNoticeTaskModels(allSendTitles, allSendDataIds, filter.GetOrgId(), allSendUserIds, allSendUserNames, DateTime.Now, DateTime.Now.AddDays(1), (int)FMFormTypeEnum.计划任务通知, "SE007_SHOWPRINT"); + + var listDemandID = GetEntities(e => allSendDataIds.Contains(e.SURVEY_ID), null, null).Select(e => e.ID); + IEnumerable listTaskStop = null; + if (listDemandID != null && listDemandID.Count() > 0) + { + listTaskStop = GetEntities(e => e.NOTICE_STATUS == 0 && e.SOURCE_FORMCODE == "SE007_INPUTPAGE" && e.SOURCE_DATA_ID.HasValue && listDemandID.Contains(e.SOURCE_DATA_ID.Value), null, null); + listTaskStop.ForEach(e => + { + e.NOTICE_STATUS = 4; // 未处理 = 0,正常已办 = 1, 超期办理 = 2, 已阅 = 3, 超时无需办理 = 4, 关闭 = 9 + e.TASK_DT = dt; + }); + } + + //待测试会不会有bug BantchSaveEntityNoCommit(surveys); 检查 LAUNCH_USER_ID 报错? UnifiedCommit(() => { + if (surveys != null && surveys.Count() > 0) + BantchSaveEntityNoCommit(surveys); if (sendNotices.Any()) BantchAddEntityNoCommit(sendNotices); + if (listTaskStop != null && listTaskStop.Count() > 0) + BantchSaveEntityNoCommit(listTaskStop); }); return true; }); @@ -1631,10 +1678,9 @@ namespace APT.PP.WebApi.Controllers.Api.PP /// /// - private void CheckSafeSuveyCompanyReport([FromBody] KeywordFilter filter) + private void CheckSafeSuveyCompanyReport(KeywordFilter filter, DateTime dt) { - //安全意识调查全部完成后发送给安环部负责人 - var dt = DateTime.Now; + //安全意识调查全部完成后发送给安环部负责人 var surveysAll = GetEntities(t => t.LAUNCH_TIME.Value.Year == dt.Year && t.STATUS == SESafeSurveyStatus.完成 && !t.COMPNAY_REPORT && t.TASK_ID != null, new BaseFilter(filter.GetOrgId())).ToList(); if (surveysAll == null || surveysAll.Count == 0) @@ -1791,14 +1837,13 @@ namespace APT.PP.WebApi.Controllers.Api.PP /// /// 每天5点触发教育培训调查汇总 /// - /// + /// /// - public JsonActionResult CheckTrainEffectSuveyEvaluation([FromBody] KeywordFilter filter) + public JsonActionResult CheckTrainEffectSuveyEvaluation(KeywordFilter filter, DateTime dt) { return SafeExecute(() => { //截止时间后生成,发送给培训通知的发起人及安环部负责人 - var dt = DateTime.Now; var minDate = dt.AddDays(-10); var maxDate = dt; diff --git a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/1SESafeSurveyController.cs b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/1SESafeSurveyController.cs index ffafa4a..27b8a48 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/1SESafeSurveyController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/1SESafeSurveyController.cs @@ -370,11 +370,18 @@ namespace APT.SC.WebApi.Controllers.Api.SE { item.SCORE = score; } - var noticeTask = NotificationTaskService.GetTaskFinishModel((Guid)entity.TaskID); + + T_FM_NOTIFICATION_TASK noticeTask = null; + if (entity.TaskID.HasValue && entity.TaskID != Guid.Empty) + { + noticeTask = NotificationTaskService.GetTaskFinishModel((Guid)entity.TaskID); + } + UnifiedCommit(() => { BantchSaveEntityNoCommit(entity.Nav_Papers); - UpdateEntityNoCommit(noticeTask); + if (noticeTask != null) + UpdateEntityNoCommit(noticeTask); }); return true; }); diff --git a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/2SETrainSurveyController.cs b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/2SETrainSurveyController.cs index 2504b32..0302e44 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/2SETrainSurveyController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/2SETrainSurveyController.cs @@ -202,7 +202,7 @@ namespace APT.SC.WebApi.Controllers.Api.SE /// /// 保存 /// - /// + /// /// [HttpPost, Route("SubmitUserDemand")] public JsonActionResult SubmitUserDemand([FromBody] T_SE_TRAIN_SURVEY_LIST_DEMAND entity) @@ -214,6 +214,7 @@ namespace APT.SC.WebApi.Controllers.Api.SE throw new Exception("已提交的数据不可更改"); } T_FM_NOTIFICATION_TASK finishNotice = null; + T_FM_NOTIFICATION_TASK sendNotices = null; var items = entity.Nav_Items; entity.Nav_Items = null; foreach (var item in items) @@ -243,6 +244,14 @@ namespace APT.SC.WebApi.Controllers.Api.SE } entity.OK = 1; finishNotice = NotificationTaskService.GetTaskFinishModel(entity.TaskID); + + //如果是最后一个人 并且当前时间不到结束时间 直接走汇总功能 + var check = GetEntity(e => e.SURVEY_ID == survry.ID && e.OK == 0); + if (check == null) + { + var user = GetEntity(survry.LAUNCH_USER_ID); + sendNotices = NotificationTaskService.InsertUserNoticeTaskModel("培训需求调查汇总-" + survry.NAME, survry.ID, survry.ORG_ID, survry.LAUNCH_USER_ID, user.NAME, DateTime.Now, 0, "SE007_SHOWPRINT", FMTASKTYPE.Default); + } } UnifiedCommit(() => @@ -251,6 +260,8 @@ namespace APT.SC.WebApi.Controllers.Api.SE BantchSaveEntityNoCommit(items); if (finishNotice != null) UpdateEntityNoCommit(finishNotice); + if (sendNotices != null) + UpdateEntityNoCommit(sendNotices); }); return true; }); @@ -320,7 +331,7 @@ namespace APT.SC.WebApi.Controllers.Api.SE [HttpPost, Route("OrderPaged")] public PagedActionResult OrderPaged([FromBody] BasePageFilter filter) { - var result = WitOrderPaged(t=>t.TASK_ID!=null, filter); + var result = WitOrderPaged(t => t.TASK_ID != null, filter); return result; }