三级安全教育 单添加 父级ID 即使数据重复也不会多次添加 下一级三级安全教育记录单数据
This commit is contained in:
parent
f29a5ed071
commit
1c78b649d0
139652
APT.Data.Migrations/Migrations/20260511035652_wyw2026051101.Designer.cs
generated
Normal file
139652
APT.Data.Migrations/Migrations/20260511035652_wyw2026051101.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace APT.Data.Migrations.Migrations
|
||||
{
|
||||
public partial class wyw2026051101 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "PARENT_ID",
|
||||
table: "T_SE_NEW_USERS",
|
||||
type: "uniqueidentifier",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PARENT_ID",
|
||||
table: "T_SE_NEW_USERS");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73320,6 +73320,9 @@ namespace APT.Data.Migrations.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("PARENT_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime?>("START_TIME")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
|
||||
@ -145,5 +145,10 @@ namespace APT.MS.Domain.Entities.SE
|
||||
/// </summary>
|
||||
[Description("培训老师")]
|
||||
public ICollection<T_SE_NEW_USERS_TEACHER> Nav_Teachers { get; set; }
|
||||
/// <summary>
|
||||
/// 父项ID
|
||||
/// </summary>
|
||||
[Description("父项ID")]
|
||||
public Guid? PARENT_ID { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,6 +45,7 @@ namespace APT.SC.WebApi.Controllers.Api.SE
|
||||
List<T_SE_NEW_USER_DETAIL_FILE> detailFiles = new List<T_SE_NEW_USER_DETAIL_FILE>();
|
||||
T_FM_NOTIFICATION_TASK finishNotice = null;
|
||||
var Nav_NewUserDetail = entity.Nav_NewUserDetail;
|
||||
entity.Nav_NewUserDetail = null;
|
||||
var Nav_Files = entity.Nav_Files;
|
||||
entity.Nav_Files = null;
|
||||
var Nav_Teachers = entity.Nav_Teachers;
|
||||
@ -306,7 +307,14 @@ namespace APT.SC.WebApi.Controllers.Api.SE
|
||||
BantchUpdateEntity_noneBase(listRoleDel);
|
||||
if (listUT != null && listUT.Any())
|
||||
BantchUpdateEntity_noneBase(listUT);
|
||||
//if (entity.IS_DELETED)
|
||||
//{
|
||||
BantchUpdateEntity_noneBase(new List<T_SE_NEW_USERS>() { entity });
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// UpdateEntityNoCommit(entity);
|
||||
//}
|
||||
});
|
||||
|
||||
if (listUserDel != null && listUserDel.Count() > 0)
|
||||
@ -966,86 +974,89 @@ namespace APT.SC.WebApi.Controllers.Api.SE
|
||||
}
|
||||
if (sendUser != null)
|
||||
{
|
||||
newEduCard = new T_SE_NEW_USERS();
|
||||
newEduCard.ID = Guid.NewGuid();
|
||||
newEduCard.ORG_ID = orgId;
|
||||
newEduCard.USER_ID = sendUser.ID;
|
||||
newEduCard.DEPARTMENT_ID = sendUser.DEPARTMENT_ID;
|
||||
newEduCard.CONTENT_ID = train_contents.ID;
|
||||
newEduCard.TRAIN_STATUS = currSattus;
|
||||
var commonDeptartmentUsers = userDetails.Where(t => t.NEXT_DEPARTMENT_ID == currDetailT.NEXT_DEPARTMENT_ID);
|
||||
var commonUserIds = commonDeptartmentUsers.Select(t => t.USER_ID);
|
||||
var userFilter = new BaseFilter(orgId);
|
||||
userFilter.Include = new string[] { "Nav_Person" };
|
||||
|
||||
var listDeps = GetEntities<T_FM_DEPARTMENT>(e => e.ENABLE_STATUS == 0 && !e.IS_DELETED, null);
|
||||
T_FM_DEPARTMENT modelDep = null;
|
||||
foreach (var user in commonDeptartmentUsers)
|
||||
newEduCard = GetEntity<T_SE_NEW_USERS>(e => e.PARENT_ID.HasValue && e.PARENT_ID.Value == EDU_CARD_ID);
|
||||
if (newEduCard == null || newEduCard.ID == Guid.Empty)
|
||||
{
|
||||
T_SE_NEW_USER_DETAIL userDetail = new T_SE_NEW_USER_DETAIL();
|
||||
userDetail.ID = Guid.NewGuid();
|
||||
userDetail.CODE = user.CODE;
|
||||
userDetail.EDU_CARD_ID = newEduCard.ID;
|
||||
userDetail.USER_ID = user.USER_ID;
|
||||
userDetail.ID_CARD_NUMBER = user.ID_CARD_NUMBER;
|
||||
userDetail.ORG_ID = newEduCard.ORG_ID;
|
||||
userDetail.IN_TIME = user.CREATE_TIME;
|
||||
userDetail.USER_POST_ID = user.USER_POST_ID;
|
||||
userDetail.USER_DEPARTMENT_ID = user.USER_DEPARTMENT_ID;
|
||||
//userDetail.EXAMINATION_RESULTS = SEExaminationResultsEnum.合格;//260228 不能直接上来就合格
|
||||
newEduCard = new T_SE_NEW_USERS();
|
||||
newEduCard.ID = Guid.NewGuid();
|
||||
newEduCard.ORG_ID = orgId;
|
||||
newEduCard.USER_ID = sendUser.ID;
|
||||
newEduCard.DEPARTMENT_ID = sendUser.DEPARTMENT_ID;
|
||||
newEduCard.CONTENT_ID = train_contents.ID;
|
||||
newEduCard.TRAIN_STATUS = currSattus;
|
||||
var commonDeptartmentUsers = userDetails.Where(t => t.NEXT_DEPARTMENT_ID == currDetailT.NEXT_DEPARTMENT_ID);
|
||||
var commonUserIds = commonDeptartmentUsers.Select(t => t.USER_ID);
|
||||
var userFilter = new BaseFilter(orgId);
|
||||
userFilter.Include = new string[] { "Nav_Person" };
|
||||
|
||||
#region NEXT_DEPARTMENT_ID
|
||||
|
||||
if (user.USER_DEPARTMENT_ID.HasValue && currSattus != SEThreeLevelSafeTrainType.班组级)
|
||||
var listDeps = GetEntities<T_FM_DEPARTMENT>(e => e.ENABLE_STATUS == 0 && !e.IS_DELETED, null);
|
||||
T_FM_DEPARTMENT modelDep = null;
|
||||
foreach (var user in commonDeptartmentUsers)
|
||||
{
|
||||
//userDetail.NEXT_DEPARTMENT_ID=
|
||||
modelDep = listDeps.FirstOrDefault(e => e.ID == user.USER_DEPARTMENT_ID.Value);
|
||||
if (modelDep.DEPARTMENT_TYPE == 5)
|
||||
T_SE_NEW_USER_DETAIL userDetail = new T_SE_NEW_USER_DETAIL();
|
||||
userDetail.ID = Guid.NewGuid();
|
||||
userDetail.CODE = user.CODE;
|
||||
userDetail.EDU_CARD_ID = newEduCard.ID;
|
||||
userDetail.USER_ID = user.USER_ID;
|
||||
userDetail.ID_CARD_NUMBER = user.ID_CARD_NUMBER;
|
||||
userDetail.ORG_ID = newEduCard.ORG_ID;
|
||||
userDetail.IN_TIME = user.CREATE_TIME;
|
||||
userDetail.USER_POST_ID = user.USER_POST_ID;
|
||||
userDetail.USER_DEPARTMENT_ID = user.USER_DEPARTMENT_ID;
|
||||
//userDetail.EXAMINATION_RESULTS = SEExaminationResultsEnum.合格;//260228 不能直接上来就合格
|
||||
|
||||
#region NEXT_DEPARTMENT_ID
|
||||
|
||||
if (user.USER_DEPARTMENT_ID.HasValue && currSattus != SEThreeLevelSafeTrainType.班组级)
|
||||
{
|
||||
//公司领导
|
||||
}
|
||||
else if (modelDep.DEPARTMENT_TYPE == 10)
|
||||
{
|
||||
//部门人员
|
||||
if (modelDep.DEPARTMENT_STATUS == 1)//FMDepartmentStatus 职能部门 = 0, 生产部门 = 1, 安全部门 = 2,
|
||||
//userDetail.NEXT_DEPARTMENT_ID=
|
||||
modelDep = listDeps.FirstOrDefault(e => e.ID == user.USER_DEPARTMENT_ID.Value);
|
||||
if (modelDep.DEPARTMENT_TYPE == 5)
|
||||
{
|
||||
userDetail.NEXT_DEPARTMENT_ID = modelDep.ID;
|
||||
//公司领导
|
||||
}
|
||||
else
|
||||
else if (modelDep.DEPARTMENT_TYPE == 10)
|
||||
{
|
||||
modelDep = listDeps.FirstOrDefault(e => e.DEPARTMENT_STATUS == 2);
|
||||
if (modelDep != null)
|
||||
//部门人员
|
||||
if (modelDep.DEPARTMENT_STATUS == 1)//FMDepartmentStatus 职能部门 = 0, 生产部门 = 1, 安全部门 = 2,
|
||||
{
|
||||
userDetail.NEXT_DEPARTMENT_ID = modelDep.ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
modelDep = listDeps.FirstOrDefault(e => e.DEPARTMENT_STATUS == 2);
|
||||
if (modelDep != null)
|
||||
{
|
||||
userDetail.NEXT_DEPARTMENT_ID = modelDep.ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (modelDep.DEPARTMENT_TYPE == 15)
|
||||
{
|
||||
userDetail.NEXT_DEPARTMENT_ID = modelDep.PARENT_ID;//给组织对应上级组织
|
||||
}
|
||||
else if (modelDep.DEPARTMENT_TYPE == 20)
|
||||
{
|
||||
//班主 对应组织 的父级的父级
|
||||
if (modelDep.PARENT_ID.HasValue)
|
||||
else if (modelDep.DEPARTMENT_TYPE == 15)
|
||||
{
|
||||
modelDep = listDeps.FirstOrDefault(e => e.ID == modelDep.PARENT_ID.Value);
|
||||
userDetail.NEXT_DEPARTMENT_ID = modelDep.PARENT_ID;//给组织对应上级组织
|
||||
}
|
||||
if (modelDep != null)
|
||||
else if (modelDep.DEPARTMENT_TYPE == 20)
|
||||
{
|
||||
userDetail.NEXT_DEPARTMENT_ID = modelDep.PARENT_ID;
|
||||
//班主 对应组织 的父级的父级
|
||||
if (modelDep.PARENT_ID.HasValue)
|
||||
{
|
||||
modelDep = listDeps.FirstOrDefault(e => e.ID == modelDep.PARENT_ID.Value);
|
||||
}
|
||||
if (modelDep != null)
|
||||
{
|
||||
userDetail.NEXT_DEPARTMENT_ID = modelDep.PARENT_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
userDetailList.Add(userDetail);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
userDetailList.Add(userDetail);
|
||||
var endTime = DateTime.Now.AddDays(10);
|
||||
var newEndTime = new DateTime(endTime.Year, endTime.Month, endTime.Day, 23, 59, 59);
|
||||
sendNotice = NotificationTaskService.InsertUserNoticeTaskModel(DateTime.Now.ToShortDateString() + "-三级安全培训-" + newEduCard.TRAIN_STATUS.GetDescription(), newEduCard.ID, orgId, sendUser.ID, sendUser.NAME, DateTime.Now, newEndTime, 1, "SE062");
|
||||
}
|
||||
var endTime = DateTime.Now.AddDays(10);
|
||||
var newEndTime = new DateTime(endTime.Year, endTime.Month, endTime.Day, 23, 59, 59);
|
||||
sendNotice = NotificationTaskService.InsertUserNoticeTaskModel(DateTime.Now.ToShortDateString() + "-三级安全培训-" + newEduCard.TRAIN_STATUS.GetDescription(), newEduCard.ID, orgId, sendUser.ID, sendUser.NAME, DateTime.Now, newEndTime, 1, "SE062");
|
||||
}
|
||||
var isAllDone = userDetails.Count(t => t.STATUS == 0);
|
||||
if (isAllDone == 0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user