diff --git a/APT.MS.Domain/Enums/SC/SEEnum.cs b/APT.MS.Domain/Enums/SC/SEEnum.cs index c0be214..87bd994 100644 --- a/APT.MS.Domain/Enums/SC/SEEnum.cs +++ b/APT.MS.Domain/Enums/SC/SEEnum.cs @@ -134,6 +134,7 @@ namespace APT.MS.Domain.Enums public enum SETrainRecordStatus { + 已取消 = -1, 草稿 = 0, 签到中 = 1, 审阅中 = 2, diff --git a/APT.MicroApi/APT.PF.WebApi/Controllers/Api/LoginController.cs b/APT.MicroApi/APT.PF.WebApi/Controllers/Api/LoginController.cs index 15fb08e..9dad580 100644 --- a/APT.MicroApi/APT.PF.WebApi/Controllers/Api/LoginController.cs +++ b/APT.MicroApi/APT.PF.WebApi/Controllers/Api/LoginController.cs @@ -216,7 +216,7 @@ namespace APT.PF.WebApiControllers.Api.PF string userId = filter == null ? string.Empty : filter.Keyword; int platformType = filter == null ? (int)PFPlatTypeEnum.后台 : string.IsNullOrEmpty(filter.Parameter3) ? (int)PFPlatTypeEnum.后台 : Convert.ToInt32(filter.Parameter3); - Guid orgId = filter.OrgId??Guid.Empty; + Guid orgId = filter.OrgId ?? Guid.Empty; #region 登录优化 orgId @@ -580,7 +580,7 @@ namespace APT.PF.WebApiControllers.Api.PF // sysLogService.AddLoginLog(result.User.ID, platformType); //else // sysLogService.AddLoginLogByApp(result.User.ID, platformType, filter); - if (result.User.NAME != "管理员") + if (!result.User.NAME.Contains("管理员"))// if (result.User.NAME != "管理员") { T_BI_LOGIN_RECORD loginRecord = new T_BI_LOGIN_RECORD { diff --git a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SEController.cs b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SEController.cs index 322f6a7..d2a8b92 100644 --- a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SEController.cs +++ b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SEController.cs @@ -2058,7 +2058,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP List allSendUserIds = null; List allSendUserNames = null; List sendNotice = null; - + List listUserDoAuto = null; foreach (var item in iListR) { try @@ -2103,19 +2103,34 @@ namespace APT.PP.WebApi.Controllers.Api.PP { if (listDon.Contains(e.USER_ID)) { - e.NOTICE_STATUS = 0; + e.NOTICE_STATUS = 1; e.TASK_DT = DateTime.Now; } }); + listUserDoAuto = new List(); + listUserDoAuto = iListTemp.Where(e => listDon.Contains(e.USER_ID)).ToList(); + foreach (var itemAuto in listUserDoAuto) + { + itemAuto.OK = true; + itemAuto.STATUS = SETrainRecordUserStatusEnum.参与; + itemAuto.DT_SIGN = DateTime.Now; + } + } + else + { + listUserDoAuto = null; } item.DT_SSEND_SIGN = DateTime.Now; item.STATUS = SETrainRecordStatus.签到中; + UnifiedCommit(() => { UpdateEntityNoCommit(modelTr); UpdateEntityNoCommit(item); if (sendNotice != null && sendNotice.Any()) BantchSaveEntityNoCommit(sendNotice); + if (listUserDoAuto != null && listUserDoAuto.Any()) + BantchSaveEntityNoCommit(listUserDoAuto); }); } catch { } diff --git a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIController.cs b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIController.cs index c21caa2..4db80ac 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIController.cs @@ -801,7 +801,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI #region 3 var productionUnits = this.GetEntities(t => t.IS_DELETED == false, new BaseFilter(filter.OrgId)); - var productIds = productionUnits.OrderBy(m=>m.ID).Select(t => t.ID).ToList(); + var productIds = productionUnits.OrderBy(m => m.ID).Select(t => t.ID).ToList(); PerformanceModel modelMineType = new PerformanceModel(); foreach (var id in productIds) { @@ -842,13 +842,13 @@ namespace APT.SC.WebApi.Controllers.Api.BI #region 5 //抓管控层级子表 riskFilter.SelectField = new string[] { "ENTERPRISE_LIBRARY_ID", "DEPARTMENT_TYPE", "DEPARTMENT_ID", "USER_ID", "APPROVE_ROLE_ID", "ID" }; - var libMeasures = GetEntities(t => t.IS_DELETED ==false, riskFilter); + var libMeasures = GetEntities(t => t.IS_DELETED == false, riskFilter); var departIds = libMeasures.Select(t => t.DEPARTMENT_ID).Distinct().ToList(); var distinctDepartment = departments.Where(t => departIds.Contains(t.ID)).ToList(); PerformanceModel modelZRDY = new PerformanceModel(); foreach (var department in distinctDepartment) { - var libIds = libMeasures.Where(t => t.DEPARTMENT_ID == department.ID).Select(m=>m.ENTERPRISE_LIBRARY_ID).Distinct().ToList(); + var libIds = libMeasures.Where(t => t.DEPARTMENT_ID == department.ID).Select(m => m.ENTERPRISE_LIBRARY_ID).Distinct().ToList(); var countLevel1 = allrisk.Count(t => libIds.Contains(t.ID) && t.EVALUATE_LEVEL == SKEvaluateLevelEnum.重大风险); var countLevel2 = allrisk.Count(t => libIds.Contains(t.ID) && t.EVALUATE_LEVEL == SKEvaluateLevelEnum.较大风险); var countLevel3 = allrisk.Count(t => libIds.Contains(t.ID) && t.EVALUATE_LEVEL == SKEvaluateLevelEnum.一般风险); @@ -1125,7 +1125,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 安全培训教育统计分析 /// - /// 返回系统用户数 + /// 返回系统用户数 /// [HttpPost, Route("getSafeTrainData")] public JsonActionResult getSafeTrainData([FromBody] KeywordFilter filter) @@ -1135,13 +1135,11 @@ namespace APT.SC.WebApi.Controllers.Api.BI var riskFilter = new BaseFilter(filter.GetOrgId()); riskFilter.Include = new string[] { "Nav_Notify.Nav_TrainUserList", "Nav_Users", "Nav_Notify" }; DateTime time = DateTime.Parse(filter.Parameter1); - DateTime currYear = DateTime.Parse(time.Year + " 01-01"); + DateTime currYear = DateTime.Parse(time.Year + " 01-01 00:00:00"); var startTime = time.AddDays(1 - time.Day); var endTime = time.AddDays(1 - time.Day).AddMonths(1); - var records = GetEntities(t => t.CREATE_TIME > currYear, riskFilter); - var testCount = GetCount(t => t.IS_DELETED == false, new BaseFilter(filter.GetOrgId())); - var threeLevelCount = GetCount(t => t.IS_DELETED == false, new BaseFilter(filter.GetOrgId())); - var currMonthrecords = records.Where(t => t.CREATE_TIME > startTime && t.CREATE_TIME < endTime).OrderBy(t => t.Nav_Notify.TRAIN_START_TIME); + var records = GetEntities(t => t.CREATE_TIME >= currYear && !t.IS_DELETED && t.STATUS != SETrainRecordStatus.已取消, riskFilter); + var currMonthrecords = records.Where(t => t.CREATE_TIME > startTime && t.CREATE_TIME < endTime).OrderByDescending(t => t.Nav_Notify.TRAIN_START_TIME);//.OrderBy var recordids = currMonthrecords.Select(t => t.ID); var examFilter = new BaseFilter(filter.GetOrgId()); examFilter.SelectField = new string[] { "USER_ID", "RECORD_ID", "SCORE" }; @@ -1152,38 +1150,67 @@ namespace APT.SC.WebApi.Controllers.Api.BI var effects = GetEntities(t => notifyIds.Contains((Guid)t.SURVEY_ID), effectFilter); List trainRecords = new List(); + int countPer = 0; + int countPass = 0; foreach (var item in currMonthrecords) { trainRecords trainRecord = new trainRecords(); trainRecord.NAME = item.Nav_Notify.NAME; - trainRecord.TIMERANGE = item.Nav_Notify.TRAIN_START_TIME + "-" + item.Nav_Notify.TRAIN_END_TIME; - trainRecord.SHOULD_TRAINER = item.Nav_Notify.Nav_TrainUserList.Count(); - trainRecord.ACTUAL_TRAINER = item.Nav_Users.Count(); + if (item.Nav_Notify.TRAIN_START_TIME.HasValue && item.Nav_Notify.TRAIN_END_TIME.HasValue && item.Nav_Notify.TRAIN_START_TIME.Value.Date == item.Nav_Notify.TRAIN_END_TIME.Value.Date) + { + trainRecord.TIMERANGE = item.Nav_Notify.TRAIN_START_TIME + " - " + item.Nav_Notify.TRAIN_END_TIME.Value.ToString("HH:mm:ss"); + } + else + { + trainRecord.TIMERANGE = item.Nav_Notify.TRAIN_START_TIME + "-" + item.Nav_Notify.TRAIN_END_TIME; + } + trainRecord.SHOULD_TRAINER = item.Nav_Notify.Nav_TrainUserList.Where(e => !e.IS_DELETED).Count();// + trainRecord.ACTUAL_TRAINER = item.Nav_Users.Where(e => !e.IS_DELETED && e.OK).Count();//有签到 //trainRecord.METHOD = item.Nav_Notify.Nav_TrainCheckType.NAME; //if (item.Nav_Notify.Nav_TrainCheckType.NAME == "笔试") - trainRecord.METHOD = item.Nav_Notify.CHECKTYPE.GetDescription(); - if (item.Nav_Notify.CHECKTYPE == PlanCheckType.InOnLine) - { - var currExams = exams.Where(t => t.RECORD_ID == item.ID); - var currCount = currExams.Count(); - if (currCount > 0) - { - var passExams = currExams.Where(t => t.SCORE >= 80); - var passCount = passExams.Count(); - var rate = (passCount * 1.0 / currCount); - trainRecord.PASS_RATE = rate.ToString(); - } - else - { - trainRecord.PASS_RATE = "0"; - } - } - else - { - trainRecord.PASS_RATE = "1"; - } + trainRecord.METHOD = item.Nav_Notify.CHECKTYPE.GetDescription(); + + + #region 考试通过率 //T_SE_TRAIN_RECORD_USER SEExaminationResultsEnum? EXAMINATION_RESULTS { get; set; } + + countPer = item.Nav_Users.Where(e => !e.IS_DELETED).Count(); + countPass = item.Nav_Users.Where(e => !e.IS_DELETED && e.EXAMINATION_RESULTS.HasValue && e.EXAMINATION_RESULTS.Value == SEExaminationResultsEnum.合格).Count(); + if (countPer == 0) + { + trainRecord.PASS_RATE = "1"; + } + else + { + trainRecord.PASS_RATE = (countPass * 1.00 / countPer).ToString(); + } + + //if (item.Nav_Notify.CHECKTYPE == PlanCheckType.InOnLine) + //{ + // var currExams = exams.Where(t => t.RECORD_ID == item.ID); + // //var currCount = currExams.Count(); + // var currCount = trainRecord.ACTUAL_TRAINER;//分母应该是 有参加培训的人数 + // if (currCount > 0) + // { + // var passExams = currExams.Where(t => t.SCORE >= 80); + // var passCount = passExams.Count(); + // var rate = (passCount * 1.0 / currCount); + // trainRecord.PASS_RATE = rate.ToString(); + // var ccc = (3 * 1.00 / 10).ToString(); + // } + // else + // { + // trainRecord.PASS_RATE = "0"; + // } + //} + //else + //{ + // trainRecord.PASS_RATE = "1"; + //} + + #endregion + if (item.Nav_Notify.NEED_EVALUATION == SETrainNeedSuvey.是) { var effect = effects.FirstOrDefault(t => t.SURVEY_ID == item.NOTIFY_ID); @@ -1198,7 +1225,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI sumTotal += num1; sumTotal += num2; } - trainRecord.EFFORT_RATE = (sumTotal / effectResult.Count()).ToString(); + trainRecord.EFFORT_RATE = (1.00 * sumTotal / effectResult.Count()).ToString(); } else { @@ -1207,7 +1234,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI } else { - trainRecord.EFFORT_RATE = "100"; + trainRecord.EFFORT_RATE = "-"; } trainRecords.Add(trainRecord); @@ -1220,17 +1247,17 @@ namespace APT.SC.WebApi.Controllers.Api.BI DateTime endTime1 = new DateTime(today.Year, i, 1).AddMonths(1).AddSeconds(-1); dateCountModel riskDate = new dateCountModel(); riskDate.DATE = startTime1; - riskDate.COUNT = records.Count(t => t.CREATE_TIME > startTime1 && t.CREATE_TIME < endTime1); + riskDate.COUNT = records.Count(t => t.CREATE_TIME >= startTime1 && t.CREATE_TIME <= endTime1); item3s.Add(riskDate); } safeTrainData safeTrainData = new safeTrainData(); safeTrainData.NUM1 = 1; safeTrainData.NUM2 = records.Count(); - safeTrainData.NUM3 = threeLevelCount; + safeTrainData.NUM3 = GetCount(t => t.IS_DELETED == false, new BaseFilter(filter.GetOrgId())); safeTrainData.NUM4 = 13; safeTrainData.NUM5 = 14; safeTrainData.NUM6 = 15; - safeTrainData.NUM7 = testCount; + safeTrainData.NUM7 = GetCount(t => t.IS_DELETED == false, new BaseFilter(filter.GetOrgId())); safeTrainData.trainRecords = trainRecords; safeTrainData.dateCountModel = item3s; return safeTrainData; 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 3f4285d..962a096 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/2SETrainSurveyController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/2SETrainSurveyController.cs @@ -58,9 +58,9 @@ namespace APT.SC.WebApi.Controllers.Api.SE { throw new Exception("截止时间至少比发起时间要大于一天"); } - if (Demands == null || !Demands.Any() || Demands.Count() < 1) + if (Demands == null || !Demands.Any() || Demands.Count() < 1 || Demands.Where(e => !e.IS_DELETED).Count() < 1) { - throw new Exception("请添加培训人员信息!"); + throw new Exception("请添加调查人员信息!"); } if (entity.LAUNCH_USER_ID == Guid.Empty) { diff --git a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/5SETTrainNotifyController.cs b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/5SETTrainNotifyController.cs index e4e62cc..fb01ce9 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/5SETTrainNotifyController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/5SETTrainNotifyController.cs @@ -242,6 +242,16 @@ namespace APT.SC.WebApi.Controllers.Api.SE userFilter.Include = new string[] { "Nav_Person.Nav_Post", "Nav_Department" }; IEnumerable userNames = GetEntities(t => sendUserAll.Contains(t.ID), userFilter); + //List listAuto = new List(); + //if (entity.RECORD_USER_ID.HasValue && sendUsers.Contains(entity.RECORD_USER_ID.Value)) + //{ + // listAuto.Add(entity.RECORD_USER_ID.Value); + //} + //if (entity.USER_ID_TEACHER.HasValue && !listAuto.Contains(entity.USER_ID_TEACHER.Value)) + //{ + // listAuto.Add(entity.USER_ID_TEACHER.Value); + //} + T_FM_USER userCheck = null; foreach (var user in Nav_TrainUserList) { @@ -275,6 +285,11 @@ namespace APT.SC.WebApi.Controllers.Api.SE user.DEPARTMENT_NAME = userCheck.Nav_Department?.NAME; user.POST_NAME = userCheck.Nav_Person?.Nav_Post?.NAME; + + //if (listAuto != null && listAuto.Count > 0 && listAuto.Contains(user.USER_ID)) + //{ + // user.IS_LEAVE = SETrainYesNoEnum.参加; + //} } foreach (var user in sendUsers) { @@ -289,6 +304,19 @@ namespace APT.SC.WebApi.Controllers.Api.SE } sendNoticeTask = NotificationTaskService.InsertUserNoticeTaskModels("培训通知-" + entity.NAME + "-确认", entity.ID, entity.ORG_ID, sendUsers, allSendUserNames, DateTime.Now, DateTime.Now.AddDays(1), (int)FMNoticeTypeEnum.消息, "SE013_SHOWPRINT"); + + //if (listAuto != null && listAuto.Count > 0) + //{ + // foreach (var item in sendNoticeTask) + // { + // if (listAuto.Contains(item.USER_ID)) + // { + // item.NOTICE_STATUS = 1; + // item.TASK_DT = DateTime.Now; + // item.MODIFIER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID; + // } + // } + //} } else { diff --git a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/6SETrainRecordController.cs b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/6SETrainRecordController.cs index a4e7666..8d1b836 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/6SETrainRecordController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/6SETrainRecordController.cs @@ -169,6 +169,7 @@ namespace APT.SC.WebApi.Controllers.Api.SE entity.ISSTOPSIGN = true;//停止签到 entity.MODIFY_TIME = DateTime.Now; + entity.STATUS = SETrainRecordStatus.已取消; UnifiedCommit(() => { UpdateEntityNoCommit(entity);