This commit is contained in:
何美荣 2025-10-23 11:14:40 +08:00
commit 66986befb9
17 changed files with 258966 additions and 210 deletions

View File

@ -300,5 +300,10 @@
/// 首页 BI/BIStatiscialAnalysisController/GetJobCompletionSort Key
/// </summary>
public const string HomeJobCompletion = "HomeJobCompletion_{0}";
/// <summary>
/// 所有数据库链接
/// </summary>
public const string ConnAll = "OPConn";
}
}

View File

@ -51,5 +51,14 @@ namespace APT.MS.Domain.Entities.PF
public Guid? ROLE_ID { get; set; }
[Description("导航属性:审批角色")]
public virtual T_FM_ROLE Nav_Role { get; set; }
/// <summary>
/// 是否总部
/// </summary>
[Description("是否总部")]
[FormFieldTable]
[FormFieldQuery]
[FormFieldEdit]
public bool ISHEAD { get; set; }=false;
}
}

View File

@ -76,5 +76,14 @@ namespace APT.BaseData.Domain.Entities
/// </summary>
[Description("是否取消")]
public bool ISCANCEL { get; set; }
/// <summary>
/// 是否总部
/// </summary>
[Description("是否总部")]
[FormFieldTable]
[FormFieldQuery]
[FormFieldEdit]
public bool ISHEAD { get; set; } = false;
}
}

View File

@ -15,5 +15,12 @@ namespace APT.BaseData.Domain.IServices.OP
/// <param name="ORG_IDBeside"></param>
/// <returns></returns>
Dictionary<Guid, string> GetConnDictionary(Guid? ORG_IDBeside);
/// <summary>
/// 获取 ORG_ID的数据库链接
/// </summary>
/// <param name="ORG_ID">过滤值</param>
/// <returns></returns>
string GetConnByORGID(Guid ORG_ID);
}
}

View File

@ -1,8 +1,10 @@
using APT.BaseData.Domain.Entities.FM;
using APT.BaseData.Domain.ApiModel.Platform;
using APT.BaseData.Domain.Entities.FM;
using APT.BaseData.Domain.Entities.OP;
using APT.BaseData.Domain.Enums.OP;
using APT.BaseData.Domain.IServices.OP;
using APT.Infrastructure.Api;
using APT.Infrastructure.Api.Redis;
using APT.Infrastructure.Core;
using APT.Migrations;
using Newtonsoft.Json;
@ -23,42 +25,144 @@ namespace APT.BaseData.Services.Services.OP
/// <summary>
/// 获取 除 ORG_IDBeside 之外对应的数据库链接字典 ORG_ID DB_CONN
/// </summary>
/// <param name="ORG_IDBeside"></param>
/// <param name="ORG_IDBeside">过滤值 没有就不过滤</param>
/// <returns></returns>
public Dictionary<Guid, string> GetConnDictionary(Guid? ORG_IDBeside)
{
Dictionary<Guid, string> dicORGCONN = new Dictionary<Guid, string>();
string conn = string.Empty;
IEnumerable<T_OP_TENANT> listTent = null;
using (var context = new MigrationContext())
{
Expression<Func<T_OP_TENANT, bool>> expression = e => e.DB_CONN_ID.HasValue;
if (ORG_IDBeside.HasValue)
{
expression = expression.And(e => e.ID != ORG_IDBeside);
}
//从Redis中获取所有数据库链接值
listTent = context.GetEntities(expression, null, null);
List<Guid> listConnID = listTent.Select(e => e.DB_CONN_ID.Value).ToList();
var listDbConn = context.GetEntities<T_OP_TENANT_DB_CONN>(e => listConnID.Contains(e.ID), null, null);
if (listDbConn != null && listDbConn.Count() > 0)
bool isRedisConfig = true;
var redisConfig = APT.Infrastructure.Api.ConfigurationManager.AppSettings["RedisFormConfig"];
if (!string.IsNullOrEmpty(redisConfig))
isRedisConfig = bool.Parse(redisConfig);
if (isRedisConfig)
{
if (CsRedisManager.KeyExists(RedisCacheKey.ConnAll))
dicORGCONN = CsRedisManager.StringGet<Dictionary<Guid, string>>(RedisCacheKey.ConnAll);
}
#region Redis没找到
if (dicORGCONN == null || dicORGCONN.Count < 1)
{
string conn = string.Empty;
IEnumerable<T_OP_TENANT> listTent = null;
using (var context = new MigrationContext())
{
var env = ConfigurationManager.AppSettings["Env"];
foreach (var item in listDbConn)
Expression<Func<T_OP_TENANT, bool>> expression = e => e.DB_CONN_ID.HasValue;
listTent = context.GetEntities(expression, null, null);
List<Guid> listConnID = listTent.Select(e => e.DB_CONN_ID.Value).ToList();
var listDbConn = context.GetEntities<T_OP_TENANT_DB_CONN>(e => listConnID.Contains(e.ID), null, null);
if (listDbConn != null && listDbConn.Count() > 0)
{
conn = item.DB_CONN;
if (env == ((int)EnvType.).ToString())
var env = ConfigurationManager.AppSettings["Env"];
foreach (var item in listDbConn)
{
conn = item.DB_CONN_WAN;
conn = item.DB_CONN;
if (env == ((int)EnvType.).ToString())
{
conn = item.DB_CONN_WAN;
}
if (!dicORGCONN.ContainsKey(item.ID))
{
dicORGCONN.Add(listTent.First(e => e.DB_CONN_ID == item.ID).ID, conn);
}
}
if (!dicORGCONN.ContainsKey(item.ID))
if (isRedisConfig && dicORGCONN.Count > 0)
{
dicORGCONN.Add(listTent.First(e => e.DB_CONN_ID == item.ID).ID, conn);
try
{
CsRedisManager.StringSet<Dictionary<Guid, string>>(RedisCacheKey.ConnAll, dicORGCONN);//所有数据库链接 存入 Redis
}
catch { }
}
}
}
}
#endregion
if (dicORGCONN != null && dicORGCONN.Count > 0)
{
if (ORG_IDBeside.HasValue)
{
Dictionary<Guid, string> dicORGCONN1 = new Dictionary<Guid, string>();
foreach (var item in dicORGCONN)
{
if (item.Key == ORG_IDBeside.Value)
continue;
dicORGCONN1.Add(item.Key, item.Value);
}
dicORGCONN = dicORGCONN1;
}
}
return dicORGCONN;
}
/// <summary>
/// 获取 ORG_ID的数据库链接
/// </summary>
/// <param name="ORG_ID">过滤值</param>
/// <returns></returns>
public string GetConnByORGID(Guid ORG_ID)
{
Dictionary<Guid, string> dicORGCONN = new Dictionary<Guid, string>();
//从Redis中获取所有数据库链接值
bool isRedisConfig = true;
var redisConfig = APT.Infrastructure.Api.ConfigurationManager.AppSettings["RedisFormConfig"];
if (!string.IsNullOrEmpty(redisConfig))
isRedisConfig = bool.Parse(redisConfig);
if (isRedisConfig)
{
if (CsRedisManager.KeyExists(RedisCacheKey.ConnAll))
dicORGCONN = CsRedisManager.StringGet<Dictionary<Guid, string>>(RedisCacheKey.ConnAll);
}
#region Redis没找到
if (dicORGCONN == null || dicORGCONN.Count < 1)
{
string conn = string.Empty;
IEnumerable<T_OP_TENANT> listTent = null;
using (var context = new MigrationContext())
{
Expression<Func<T_OP_TENANT, bool>> expression = e => e.DB_CONN_ID.HasValue;
listTent = context.GetEntities(expression, null, null);
List<Guid> listConnID = listTent.Select(e => e.DB_CONN_ID.Value).ToList();
var listDbConn = context.GetEntities<T_OP_TENANT_DB_CONN>(e => listConnID.Contains(e.ID), null, null);
if (listDbConn != null && listDbConn.Count() > 0)
{
var env = ConfigurationManager.AppSettings["Env"];
foreach (var item in listDbConn)
{
conn = item.DB_CONN;
if (env == ((int)EnvType.).ToString())
{
conn = item.DB_CONN_WAN;
}
if (!dicORGCONN.ContainsKey(item.ID))
{
dicORGCONN.Add(listTent.First(e => e.DB_CONN_ID == item.ID).ID, conn);
}
}
if (isRedisConfig && dicORGCONN.Count > 0)
{
try
{
CsRedisManager.StringSet<Dictionary<Guid, string>>(RedisCacheKey.ConnAll, dicORGCONN);//所有数据库链接 存入 Redis
}
catch { }
}
}
}
}
#endregion
if (dicORGCONN != null && dicORGCONN.Count > 0 && dicORGCONN.ContainsKey(ORG_ID))
{
return dicORGCONN[ORG_ID];
}
return "";
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace APT.Data.Migrations.Migrations
{
public partial class wyw2025102101 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "ISHEAD",
table: "T_PF_APPROVAL_ROLE",
type: "bit",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ISHEAD",
table: "T_PF_APPROVAL_ROLE");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace APT.Data.Migrations.Migrations
{
public partial class wyw2025102201 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "ISHEAD",
table: "T_PF_APPROVE_DETAIL",
type: "bit",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ISHEAD",
table: "T_PF_APPROVE_DETAIL");
}
}
}

View File

@ -11691,6 +11691,9 @@ namespace APT.Data.Migrations.Migrations
b.Property<bool>("ISCANCEL")
.HasColumnType("bit");
b.Property<bool>("ISHEAD")
.HasColumnType("bit");
b.Property<bool>("IS_ALLOW_UPDATE")
.HasColumnType("bit");
@ -53823,6 +53826,9 @@ namespace APT.Data.Migrations.Migrations
b.Property<Guid?>("FORM_ID")
.HasColumnType("uniqueidentifier");
b.Property<bool>("ISHEAD")
.HasColumnType("bit");
b.Property<bool>("IS_DELETED")
.HasColumnType("bit");

View File

@ -2,10 +2,12 @@
using APT.BaseData.Domain.IServices.BS;
using APT.BaseData.Domain.IServices.EX;
using APT.BaseData.Domain.IServices.FM;
using APT.BaseData.Domain.IServices.OP;
using APT.BaseData.Domain.IServices.Platform;
using APT.BaseData.Services.DomainServices;
using APT.BaseData.Services.Services.EX;
using APT.BaseData.Services.Services.FM;
using APT.BaseData.Services.Services.OP;
using APT.BaseData.Services.Services.Platform;
using APT.BaseData.Services.Sys;
using Autofac;
@ -53,6 +55,7 @@ namespace APT.FM.WebApi.App_Start
builder.RegisterType<PFApproveCallBackSEService>().As<IPFApproveCallBackSEService>().InstancePerLifetimeScope();
builder.RegisterType<FMNotificationTaskService>().As<IFMNotificationTaskService>().InstancePerLifetimeScope();
builder.RegisterType<PFApproveCallBackService>().As<IPFApproveCallBackService>().InstancePerLifetimeScope();
builder.RegisterType<OPTenantDBConnService>().As<IOPTenantDBConnService>().InstancePerLifetimeScope();
}
}
}

View File

@ -54,7 +54,10 @@ namespace APT.FM.WebApi.Controllers.Api
order2.Field = "TASK_STARTDT";
order2.Order = DbOrder.DESC;
pageFilter.Orders.Add(order2);
pageFilter.OrgId = null;
pageFilter.IgnoreOrgRule = true;
var bear = new BaseFilter();
bear.IgnoreOrgRule = true;
var todoCount = GetCount<T_FM_NOTIFICATION_TASK>(s => s.USER_ID == userId && s.NOTICE_STATUS == 0 && s.NOTICE_TYPE != 2 && s.NOTICE_TYPE != 7 && s.TASK_ENDDT >= DateTime.Now.AddMonths(-3), bear);
var todayNewCount = GetCount<T_FM_NOTIFICATION_TASK>(s => s.USER_ID == userId && s.NOTICE_STATUS == 0 && (s.NOTICE_TYPE == 2 || s.NOTICE_TYPE == 7), bear);//&& s.TASK_STARTDT > shortToday
var doneCount = GetCount<T_FM_NOTIFICATION_TASK>(s => s.USER_ID == userId && (s.NOTICE_STATUS == 1 || s.NOTICE_STATUS == 2) && s.NOTICE_TYPE != 2 && s.NOTICE_TYPE != 7, bear);

View File

@ -34,6 +34,7 @@ using System.Security.Cryptography;
using APT.MS.Domain.Entities.SC.PT;
using Microsoft.Extensions.DependencyModel;
using APT.MS.Domain.Entities.SK;
using APT.BaseData.Domain.IServices.OP;
namespace APT.FM.WebApi.Controllers.Api.FM
{
@ -47,15 +48,18 @@ namespace APT.FM.WebApi.Controllers.Api.FM
IFMUserService UserService { get; set; }
IFMDepartmentService DepartmentService { get; set; }
IFMNotificationTaskService NotificationTaskService { get; set; }
IOPTenantDBConnService OPTenantDBConnService { get; set; }
/// <summary>
///
/// </summary>
/// <param name="personnelService"></param>
public UserController(IFMUserService personnelService, IFMDepartmentService departmentService, IFMNotificationTaskService notificationTaskService)
public UserController(IFMUserService personnelService, IFMDepartmentService departmentService, IFMNotificationTaskService notificationTaskService, IOPTenantDBConnService opTenantDBConnService)
{
UserService = personnelService;
DepartmentService = departmentService;
NotificationTaskService = notificationTaskService;
OPTenantDBConnService = opTenantDBConnService;
}
/// <summary>
@ -483,110 +487,125 @@ namespace APT.FM.WebApi.Controllers.Api.FM
T_OG_SAFE_PDT_SIGNED_POST signPost = null;
T_PT_ASSESSMENT_PLAN_AUDIT_TEMP_DETAIL library = null;
T_FM_NOTIFICATION_TASK noticeToday = null;
if (string.IsNullOrEmpty(entity.CODE))
{
throw new Exception("工号不允许为空!");
}
if (entity.CODE.Length <= 3)
this.ThrowError("050003");
if (string.IsNullOrEmpty(entity.NAME))
{
throw new Exception("姓名不允许为空!");
}
if (entity.Nav_Person.POST_ID == null)
{
throw new Exception("岗位不允许为空!");
}
if (!isAdd.Any())
{
if (entity.CODE.Length <= 3)
this.ThrowError("050003");
userList = this.GetEntities<T_FM_USER>(t => (t.CODE == entity.CODE || t.APPROVE_ROLE_ID == entity.APPROVE_ROLE_ID) && t.ORG_ID == entity.ORG_ID, null, "Nav_Department").ToList();
var isRepeat = userList.FirstOrDefault(t => t.CODE == entity.CODE);
if (isRepeat != null)
this.ThrowError("050001");
if (entity.ORG_ID != Guid.Parse("b043b28b-bbc3-c452-6052-4fba1457abfa"))
{
#region
eduCard = new T_SE_THREE_LEVEL_SAFE_EDU_CARD();
eduCard.ID = Guid.NewGuid();
eduCard.ID_CARD_NUMBER = entity.ID_CARD;
eduCard.IN_TIME = entity.ENTRYTIME;
eduCard.USER_ID = entity.ID;
eduCard.DEPARTMENT_ID = entity.DEPARTMENT_ID;
eduCard.LAUNCH_TIME = DateTime.Now;
eduCard.ORG_ID = entity.ORG_ID;
eduCard.POST_ID = entity.Nav_Person.POST_ID;
eduCard.STATUS = SEThreeLevelSafeTrainStatus.;
eduCard.LAUNCH_USER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
eduCard.LAUNCH_DEPARTMENT_ID = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID;
next_train_record = new T_SE_THREE_LEVEL_SAFE_TRAIN_RECORD
{
ID = Guid.NewGuid(),
EDU_CARD_ID = eduCard.ID,
ORG_ID = eduCard.ORG_ID,
THREE_LEVEL_SAFE_TRAIN_TYPE = SEThreeLevelSafeTrainType.
};
var train_contents = GetEntity<T_SE_THREE_LEVEL_SAFE_CONTENT>(t => t.THREE_LEVEL_SAFE_TRAIN_TYPE == (SEThreeLevelSafeTrainType)eduCard.STATUS.GetInt());
next_train_record.CONTENT_ID = train_contents.ID;
var postName = GetEntity<T_FM_USER_POST>(eduCard.POST_ID ?? Guid.Empty)?.NAME;
var sendUser = GetEntity<T_FM_USER>(t => t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME == "安环部安全员" && t.IS_DELETED == false && t.ENABLE_STATUS == 0);
if (sendUser != null)
{
var endTime = entity.ENTRYTIME.AddMonths(1);
var newEndTime = new DateTime(endTime.Year, endTime.Month, endTime.Day, 23, 59, 59);
sendNotice.Add(NotificationTaskService.InsertUserNoticeTaskModel("三级安全培训记录-" + entity.NAME + "-" + eduCard.STATUS.GetDescription(), next_train_record.ID, entity.ORG_ID, sendUser.ID, sendUser.NAME, DateTime.Now, newEndTime, 1, "SE042"));
}
#region //
#region //新增人员增加三级安全教育
//eduCard = new T_SE_THREE_LEVEL_SAFE_EDU_CARD();
//eduCard.ID = Guid.NewGuid();
//eduCard.ID_CARD_NUMBER = entity.ID_CARD;
//eduCard.IN_TIME = entity.ENTRYTIME;
//eduCard.USER_ID = entity.ID;
//eduCard.DEPARTMENT_ID = entity.DEPARTMENT_ID;
//eduCard.LAUNCH_TIME = DateTime.Now;
//eduCard.ORG_ID = entity.ORG_ID;
//eduCard.POST_ID = entity.Nav_Person.POST_ID;
//eduCard.STATUS = SEThreeLevelSafeTrainStatus.公司培训;
//eduCard.LAUNCH_USER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
//eduCard.LAUNCH_DEPARTMENT_ID = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID;
//next_train_record = new T_SE_THREE_LEVEL_SAFE_TRAIN_RECORD
//{
// ID = Guid.NewGuid(),
// EDU_CARD_ID = eduCard.ID,
// ORG_ID = eduCard.ORG_ID,
// THREE_LEVEL_SAFE_TRAIN_TYPE = SEThreeLevelSafeTrainType.公司级
//};
//var train_contents = GetEntity<T_SE_THREE_LEVEL_SAFE_CONTENT>(t => t.THREE_LEVEL_SAFE_TRAIN_TYPE == (SEThreeLevelSafeTrainType)eduCard.STATUS.GetInt());
//next_train_record.CONTENT_ID = train_contents.ID;
//var postName = GetEntity<T_FM_USER_POST>(eduCard.POST_ID ?? Guid.Empty)?.NAME;
//var sendUser = GetEntity<T_FM_USER>(t => t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME == "安环部安全员" && t.IS_DELETED == false && t.ENABLE_STATUS == 0);
//if (sendUser != null)
//{
// var endTime = entity.ENTRYTIME.AddMonths(1);
// var newEndTime = new DateTime(endTime.Year, endTime.Month, endTime.Day, 23, 59, 59);
// sendNotice.Add(NotificationTaskService.InsertUserNoticeTaskModel("三级安全培训记录-" + entity.NAME + "-" + eduCard.STATUS.GetDescription(), next_train_record.ID, entity.ORG_ID, sendUser.ID, sendUser.NAME, DateTime.Now, newEndTime, 1, "SE042"));
//}
#endregion
#region
var post = GetEntity<T_SC_DEPARTMENT_POST>(t => t.Nav_Dept.DEPARTMENT_ID == entity.DEPARTMENT_ID && t.DEPOST_ID == entity.Nav_Person.POST_ID, new string[] { "Nav_Dept.Nav_Post" });
if (post != null)
{
var standardCreate = GetEntity<T_SC_STANDARD_CREATE>(t => t.POST_ID == post.Nav_Dept.POST_ID && t.STATUS == SCSystemEditStatus. && t.FILE_STATUS == SCSystemFileStatus.);
if (standardCreate != null)
{
var chargeUser = GetEntity<T_FM_USER>(t => t.DEPARTMENT_ID == post.Nav_Dept.Nav_Post.DEPARTMENT_ID && t.Nav_Person.POST_ID == post.Nav_Dept.Nav_Post.DEPOST_ID && t.ENABLE_STATUS == 0);
if (chargeUser != null)
{
signRecord = new T_OG_SAFE_PDT_SIGNED
{
ID = Guid.NewGuid(),
ORG_ID = entity.ORG_ID,
STATUS = (int)PFStandardStatus.Draft,
TRIGGER_TYPE = OGPersonalSignedTriggerType.,
//TRIGGER_TYPE = OGPersonalSignedTriggerType.手动新增,
STANDARD_ID = standardCreate.ID,
FILE_CONTENT = standardCreate.FILE_CONTENT,
DEPARTMENT_ID = entity.DEPARTMENT_ID,
ANNUAL = DateTime.Now.Year
};
if (chargeUser != null)
{
signRecord.CHARGE_USER_ID = chargeUser.ID;
}
signPost = new T_OG_SAFE_PDT_SIGNED_POST
{
SAFE_PDT_SIGNED_ID = signRecord.ID,
ID = Guid.NewGuid(),
ORG_ID = entity.ORG_ID,
USER_ID = entity.ID,
POST_ID = entity.Nav_Person.POST_ID,
CHARGE_USER_ID = signRecord.CHARGE_USER_ID
};
sendNotice.Add(NotificationTaskService.InsertUserNoticeTaskModel(DateTime.Now.ToShortDateString() + "安全生产责任制个人签订表", signRecord.ID, entity.ORG_ID, entity.ID, entity.NAME, DateTime.Now, DateTime.Now.AddDays(7), 1, "OG001_SHOWPRINT"));
}
}
}
else
{
if (sendUser != null)
{
sendNotice.Add(NotificationTaskService.InsertUserNoticeTaskModel("请为《" + postName + "》绑定责任制岗位并上传责任状", entity.ID, entity.ORG_ID, sendUser.ID, sendUser.NAME, DateTime.Now, DateTime.Now.AddDays(7), (int)FMNoticeTypeEnum., "PF135"));
}
}
#region //新增人员触发安全生产责任制
//var post = GetEntity<T_SC_DEPARTMENT_POST>(t => t.Nav_Dept.DEPARTMENT_ID == entity.DEPARTMENT_ID && t.DEPOST_ID == entity.Nav_Person.POST_ID, new string[] { "Nav_Dept.Nav_Post" });
//if (post != null)
//{
// var standardCreate = GetEntity<T_SC_STANDARD_CREATE>(t => t.POST_ID == post.Nav_Dept.POST_ID && t.STATUS == SCSystemEditStatus.已归档 && t.FILE_STATUS == SCSystemFileStatus.有效);
// if (standardCreate != null)
// {
// var chargeUser = GetEntity<T_FM_USER>(t => t.DEPARTMENT_ID == post.Nav_Dept.Nav_Post.DEPARTMENT_ID && t.Nav_Person.POST_ID == post.Nav_Dept.Nav_Post.DEPOST_ID && t.ENABLE_STATUS == 0);
// if (chargeUser != null)
// {
// signRecord = new T_OG_SAFE_PDT_SIGNED
// {
// ID = Guid.NewGuid(),
// ORG_ID = entity.ORG_ID,
// STATUS = (int)PFStandardStatus.Draft,
// TRIGGER_TYPE = OGPersonalSignedTriggerType.新员工触发,
// //TRIGGER_TYPE = OGPersonalSignedTriggerType.手动新增,
// STANDARD_ID = standardCreate.ID,
// FILE_CONTENT = standardCreate.FILE_CONTENT,
// DEPARTMENT_ID = entity.DEPARTMENT_ID,
// ANNUAL = DateTime.Now.Year
// };
// if (chargeUser != null)
// {
// signRecord.CHARGE_USER_ID = chargeUser.ID;
// }
// signPost = new T_OG_SAFE_PDT_SIGNED_POST
// {
// SAFE_PDT_SIGNED_ID = signRecord.ID,
// ID = Guid.NewGuid(),
// ORG_ID = entity.ORG_ID,
// USER_ID = entity.ID,
// POST_ID = entity.Nav_Person.POST_ID,
// CHARGE_USER_ID = signRecord.CHARGE_USER_ID
// };
// sendNotice.Add(NotificationTaskService.InsertUserNoticeTaskModel(DateTime.Now.ToShortDateString() + "安全生产责任制个人签订表", signRecord.ID, entity.ORG_ID, entity.ID, entity.NAME, DateTime.Now, DateTime.Now.AddDays(7), 1, "OG001_SHOWPRINT"));
// }
// }
//}
//else
//{
// if (sendUser != null)
// {
// sendNotice.Add(NotificationTaskService.InsertUserNoticeTaskModel("请为《" + postName + "》绑定责任制岗位并上传责任状", entity.ID, entity.ORG_ID, sendUser.ID, sendUser.NAME, DateTime.Now, DateTime.Now.AddDays(7), (int)FMNoticeTypeEnum.今日提醒, "PF135"));
// }
//}
#endregion
#endregion
}
#region ops表
using (var context = new MigrationContext(ConfigurationManager.ConnectionStrings["default"]))
{
var tennant = context.GetEntity<T_OP_TENANT>(t => t.ID == entity.ORG_ID, new string[] { "CODE" }).CODE;
T_OP_ALLUSER alluser = new T_OP_ALLUSER();
alluser.ID = entity.ID;
alluser.CODE = entity.CODE;
alluser.TENANT = tennant;
alluser.ORG_ID = entity.ORG_ID;
alluser.PHONE = entity.PHONE;
context.AddEntity(alluser);
context.SaveChanges();
}
#endregion
//#region 增加新增人员到ops表
//using (var context = new MigrationContext(ConfigurationManager.ConnectionStrings["default"]))
//{
// var tennant = context.GetEntity<T_OP_TENANT>(t => t.ID == entity.ORG_ID, new string[] { "CODE" }).CODE;
// T_OP_ALLUSER alluser = new T_OP_ALLUSER();
// alluser.ID = entity.ID;
// alluser.CODE = entity.CODE;
// alluser.TENANT = tennant;
// alluser.ORG_ID = entity.ORG_ID;
// alluser.PHONE = entity.PHONE;
// context.AddEntity(alluser);
// context.SaveChanges();
//}
//#endregion
#region //wyw 密码初始化 Xyy+code姓名拼音首字母(第一个大写) + 工号(取数字)
@ -728,8 +747,8 @@ namespace APT.FM.WebApi.Controllers.Api.FM
}
if (roleInfo.DEPARTMENT_TYPE != 3 && roleInfo.DEPARTMENT_TYPE != departmentInfo.DEPARTMENT_TYPE)
{
var param = Enum.GetName(typeof(FMDepartmentType), departmentInfo.DEPARTMENT_TYPE);
var param2 = Enum.GetName(typeof(FMDepartmentType), roleInfo.DEPARTMENT_TYPE);
var param = ((FMDepartmentType)departmentInfo.DEPARTMENT_TYPE).GetDescription();
var param2 = ((FMDepartmentType)roleInfo.DEPARTMENT_TYPE).GetDescription();
throw new Exception(departmentInfo.NAME + "是" + param + "," + roleInfo.NAME + "是" + param2 + ",组织层级不一致");
}
}
@ -737,10 +756,6 @@ namespace APT.FM.WebApi.Controllers.Api.FM
}
else
this.ThrowError("060001");
if (entity.Nav_Person.POST_ID == null)
{
throw new Exception("岗位不允许为空!");
}
//else
//{
// //查双控库是否有该辨识岗位,没有的话触发今日提醒给安全员
@ -928,6 +943,38 @@ namespace APT.FM.WebApi.Controllers.Api.FM
}
}
var isHead = HeadHelper.GetIsHead(this.Request.Headers);
Dictionary<Guid, string> dicConn = null;
if (isHead)
{
dicConn = OPTenantDBConnService.GetConnDictionary(entity.ORG_ID);
if (dicConn == null)
{
throw new Exception("获取子公司链接失败,请关闭页面刷新后再试");
}
}
#region
if (!isAdd.Any())
{
using (var context = new MigrationContext(ConfigurationManager.ConnectionStrings["default"]))
{
var tennant = context.GetEntity<T_OP_TENANT>(t => t.ID == entity.ORG_ID, new string[] { "CODE" }).CODE;
T_OP_ALLUSER alluser = new T_OP_ALLUSER();
alluser.ID = entity.ID;
alluser.CODE = entity.CODE;
alluser.TENANT = tennant;
alluser.ORG_ID = entity.ORG_ID;
alluser.PHONE = entity.PHONE;
context.AddEntity(alluser);
context.SaveChanges();
}
}
#endregion
UnifiedCommit(() =>
{
if (person != null)
@ -985,6 +1032,68 @@ namespace APT.FM.WebApi.Controllers.Api.FM
if (noticeToday != null)
this.UpdateEntityNoCommit(noticeToday);
});
#region wyw
if (isHead)
{
entity.Nav_Department = null;
entity.Nav_BelongRoles = null;
entity.Nav_BelongRoleGroups = null;
entity.Nav_BelongUserGroups = null;
entity.Nav_UserPhotoFiles = null;
entity.Nav_UserSignFiles = null;
entity.TEAM_ID = null;
entity.Nav_ApproveRole = null;
entity.PROJECT_ID = null;
entity.PRINTER_ID = null;
person.Nav_DepartMent = null;
person.Nav_Post = null;
person.POST_ID = null;
person.Nav_TeamPersons = null;
person.Nav_PersonWorks = null;
person.Nav_PersonSkills = null;
person.Nav_PersonIDCardFiles = null;
person.Nav_PersonEducationFiles = null;
person.Nav_PersonCertificateFiles = null;
int EditC = 0;
foreach (var item in dicConn)
{
try
{
entity.ORG_ID = item.Key;
person.ORG_ID = item.Key;
using (var context = new MigrationContext(item.Value))
{
EditC = context.GetCount<T_FM_USER>(e => e.ID == entity.ID);
entity.DEPARTMENT_ID = context.GetEntity<T_FM_DEPARTMENT>(e => e.PARENT_ID == null && !e.IS_DELETED && e.DEPARTMENT_TYPE == 5, null).ID;
person.DEPARTMENT_ID = entity.DEPARTMENT_ID;
if (EditC > 0)
{
context.UpdateEntity(entity);
context.UpdateEntity(person);
context.SaveChanges();
}
else
{
context.AddEntity(person);
context.AddEntity(entity);
context.SaveChanges();
}
}
}
catch (Exception ex)
{
}
}
}
#endregion
return true;
});
}

View File

@ -2,7 +2,9 @@
using APT.BaseData.Domain.Entities.FM;
using APT.BaseData.Domain.Entities.PF;
using APT.BaseData.Domain.Enums;
using APT.BaseData.Domain.IServices.OP;
using APT.Infrastructure.Core;
using APT.Migrations;
using APT.MS.Domain.Entities.BS;
using APT.MS.Domain.Entities.HM;
using APT.MS.Domain.Entities.PF;
@ -13,6 +15,7 @@ using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Transactions;
namespace APT.PF.WebApi.Controllers.Api
{
@ -22,6 +25,13 @@ namespace APT.PF.WebApi.Controllers.Api
[Route("api/PF/PFApprovalRole")]
public partial class ApprovalRoleController : AuthorizeApiController<T_PF_APPROVAL_ROLE>
{
IOPTenantDBConnService OPTenantDBConnService { get; set; }
public ApprovalRoleController(IOPTenantDBConnService opTenantDBConnService)
{
OPTenantDBConnService = opTenantDBConnService;
}
/// <summary>
/// 更新或新增数据
/// </summary>
@ -31,73 +41,139 @@ namespace APT.PF.WebApi.Controllers.Api
public JsonActionResult<bool> FullUpdate([FromBody] T_PF_APPROVAL_ROLE entity)
{
return SafeExecute<bool>(() =>
{
var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId;
//var roleCodes = this.GetEntities<T_PF_APPROVAL_ROLE>(t => true, new BaseFilter(orgId)).Select(x => x.NAME).ToList();
//if (roleCodes.Contains(entity.NAME))
// throw new Exception("系统已存在审批角色编码为" + entity.NAME + "的数据,请勿重复!");
var departs = entity.Nav_ApproveDeparts;
entity.Nav_ApproveDeparts = null;
if (departs != null && departs.Any())
{
departs = departs.Where(t => !t.IS_DELETED).ToList();
}
if (departs != null && departs.Any())
{
departs.ForEach(t =>
{
t.ORG_ID = orgId;
t.APPROVAL_ROLE_ID = entity.ID;
t.Nav_Department = null;
});
}
List<T_PF_APPROVE_OPERATION_ROLE> listRoles = new List<T_PF_APPROVE_OPERATION_ROLE>();
var roles = entity.Nav_ApproveRoles;
entity.Nav_ApproveRoles = null;
if (roles == null)
{
var approveRole = this.GetEntity<T_FM_ROLE>(t => t.ENABLE_STATUS == 0 && t.NAME.Contains("负责人"));
if (approveRole != null)
{
var role = new T_PF_APPROVE_OPERATION_ROLE();
role.ORG_ID = orgId;
role.APPROVAL_ROLE_ID = entity.ID;
role.ROLE_ID = approveRole.ID;
listRoles.Add(role);
}
}
List <Guid> deleteIds = new List<Guid>();
if (entity.ROLE_ID != null)
{
var datas = this.GetEntities<T_PF_APPROVE_OPERATION_ROLE>(t => t.APPROVAL_ROLE_ID == entity.ID, new BaseFilter(orgId));
if (datas.Any())
{
var ids=datas.Select(t => t.ID).ToList();
deleteIds.AddRange(ids);
}
var role = new T_PF_APPROVE_OPERATION_ROLE();
role.ORG_ID = orgId;
role.APPROVAL_ROLE_ID = entity.ID;
role.ROLE_ID = entity.ROLE_ID;
listRoles.Add(role);
}
if (listRoles.Any())
{
listRoles = listRoles.Distinct(t => t.ROLE_ID).ToList();
}
UnifiedCommit(() =>
{
if (entity != null)
UpdateEntityNoCommit(entity); //保存主表
if (departs != null && departs.Any())
BantchSaveEntityNoCommit(departs); //保存子表
if (listRoles != null && listRoles.Any())
BantchSaveEntityNoCommit(listRoles); //保存子表
if (deleteIds != null && deleteIds.Any())
BantchDeleteEntityNoCommit<T_PF_APPROVE_OPERATION_ROLE>(deleteIds); //保存子表
});
return true;
});
{
var isHead = HeadHelper.GetIsHead(this.Request.Headers);
if (entity.ISHEAD && !isHead)
{
throw new Exception("子公司不能修改总公司角色信息!");
}
var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId;
//var roleCodes = this.GetEntities<T_PF_APPROVAL_ROLE>(t => true, new BaseFilter(orgId)).Select(x => x.NAME).ToList();
//if (roleCodes.Contains(entity.NAME))
// throw new Exception("系统已存在审批角色编码为" + entity.NAME + "的数据,请勿重复!");
var departs = entity.Nav_ApproveDeparts;
entity.Nav_ApproveDeparts = null;
if (departs != null && departs.Any())
{
departs = departs.Where(t => !t.IS_DELETED).ToList();
}
if (departs != null && departs.Any())
{
departs.ForEach(t =>
{
t.ORG_ID = orgId;
t.APPROVAL_ROLE_ID = entity.ID;
t.Nav_Department = null;
});
}
List<T_PF_APPROVE_OPERATION_ROLE> listRoles = new List<T_PF_APPROVE_OPERATION_ROLE>();
var roles = entity.Nav_ApproveRoles;
entity.Nav_ApproveRoles = null;
if (roles == null)
{
var approveRole = this.GetEntity<T_FM_ROLE>(t => t.ENABLE_STATUS == 0 && t.NAME.Contains("负责人"));
if (approveRole != null)
{
var role = new T_PF_APPROVE_OPERATION_ROLE();
role.ORG_ID = orgId;
role.APPROVAL_ROLE_ID = entity.ID;
role.ROLE_ID = approveRole.ID;
listRoles.Add(role);
}
}
List<Guid> deleteIds = new List<Guid>();
if (entity.ROLE_ID != null)
{
var datas = this.GetEntities<T_PF_APPROVE_OPERATION_ROLE>(t => t.APPROVAL_ROLE_ID == entity.ID, new BaseFilter(orgId));
if (datas.Any())
{
var ids = datas.Select(t => t.ID).ToList();
deleteIds.AddRange(ids);
}
var role = new T_PF_APPROVE_OPERATION_ROLE();
role.ORG_ID = orgId;
role.APPROVAL_ROLE_ID = entity.ID;
role.ROLE_ID = entity.ROLE_ID;
listRoles.Add(role);
}
if (listRoles.Any())
{
listRoles = listRoles.Distinct(t => t.ROLE_ID).ToList();
}
Dictionary<Guid, string> dicConn = null;
if (isHead)
{
dicConn = OPTenantDBConnService.GetConnDictionary(entity.ORG_ID);
if (dicConn == null)
{
throw new Exception("获取子公司链接失败,请关闭页面刷新后再试");
}
}
UnifiedCommit(() =>
{
if (entity != null)
UpdateEntityNoCommit(entity); //保存主表
if (departs != null && departs.Any())
BantchSaveEntityNoCommit(departs); //保存子表
if (listRoles != null && listRoles.Any())
BantchSaveEntityNoCommit(listRoles); //保存子表
if (deleteIds != null && deleteIds.Any())
BantchDeleteEntityNoCommit<T_PF_APPROVE_OPERATION_ROLE>(deleteIds); //保存子表
});
//如果是总部 同时同步到各个子公司
if (isHead)
{
entity.ISHEAD = true;
entity.ROLE_ID = null;
entity.Nav_Role = null;
entity.Nav_ApproveRoles = null;
int EditC = 0;
//using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
//{
// try
// {
foreach (var item in dicConn)
{
try
{
entity.ORG_ID = item.Key;
using (var context = new MigrationContext(item.Value))
{
EditC = context.GetCount<T_PF_APPROVAL_ROLE>(e => e.ID == entity.ID);
if (EditC > 0)
{
context.UpdateEntity(entity);
context.SaveChanges();
//context.SaveChangesAsync();
}
else
{
context.AddEntity(entity);
context.SaveChanges();
//context.AddAsync(entity);
//context.SaveChangesAsync();
}
}
}
catch (Exception ex)
{
}
}
// //// 所有操作成功,提交事务
// scope.Complete();
// }
// catch (Exception ex)
// {
// // 发生异常自动回滚无需手动调用scope 释放时未 Complete 则回滚)
// throw;
// }
//}
}
return true;
});
}
/// <summary>
/// 批量添加节点

View File

@ -31,6 +31,7 @@
using APT.BaseData.Services.Services.FM;
using APT.BaseData.Services.Sys;
using APT.MS.Domain.Entities.FO;
using APT.BaseData.Domain.IServices.OP;
[Route("api/PF/PFApprove")]
public partial class ApproveController : AuthorizeApiController<T_PF_APPROVE>
@ -43,8 +44,9 @@
IFMDepartmentService DepartmentService { get; set; }
IFMUserService UserService { get; set; }
IOPTenantDBConnService OPTenantDBConnService { get; set; }
public ApproveController(IFMNotificationTaskService notificationTaskService, IPFSysLogService sysLogService, IRepository repository, IPFCodeRuleService codeRuleService, IFMDepartmentService departmentService, IFMUserService userService)
public ApproveController(IFMNotificationTaskService notificationTaskService, IPFSysLogService sysLogService, IRepository repository, IPFCodeRuleService codeRuleService, IFMDepartmentService departmentService, IFMUserService userService, IOPTenantDBConnService oPTenantDBConnService)
{
NotificationTaskService = notificationTaskService;
SysLogService = sysLogService;
@ -52,6 +54,7 @@
CodeRuleService = codeRuleService;
DepartmentService = departmentService;
UserService = userService;
OPTenantDBConnService = oPTenantDBConnService;
}
/// <summary>
/// 更新或新增数据
@ -173,7 +176,7 @@
// //MethodInfo callbackMethd1 = callBackInterface1.GetMethod("MeetingMinutesBack", BindingFlags.Public | BindingFlags.Instance); // Error lies
// //callbackMethd1.Invoke(this, new object[] { dbApprove.DATA_ID.ToString() });
//}
//查询审批的表单数据
var form = this.GetEntity<T_PF_FORM>(i => i.CODE == dbApprove.APPROVE_CODE, new BaseFilter(dbApprove.ORG_ID));
var tableName = form?.TABLE_NAME;
@ -334,8 +337,8 @@
case "关键许可工作票(二级审批)":
case "关键许可工作票(三级审批)":
case "关键许可工作票(四级审批)":
var job = this.GetEntity<T_FO_CRUCIAL_LICENSE_JOB>(t=>t.ID == entity.DATA_ID, "Nav_OperationStep");
NoticeTitle = job != null && job.Nav_OperationStep != null ? entity.NAME+"-"+job.Nav_OperationStep?.NAME + "待审批" : NoticeTitle;
var job = this.GetEntity<T_FO_CRUCIAL_LICENSE_JOB>(t => t.ID == entity.DATA_ID, "Nav_OperationStep");
NoticeTitle = job != null && job.Nav_OperationStep != null ? entity.NAME + "-" + job.Nav_OperationStep?.NAME + "待审批" : NoticeTitle;
endTime = Convert.ToDateTime(DateTime.Now.AddDays(1).ToString("D").ToString()).AddSeconds(-1);
break;
default: break;
@ -437,13 +440,13 @@
var details = dbApprove.Nav_ApproveDetails;
dbApprove.Nav_ApproveDetails = null;
details.ForEach(i => i.Nav_Approve = null);
if (task != null)
this.UpdateEntityNoCommit(task);
this.UpdateEntityNoCommit(dbApprove);
this.BantchUpdateEntityNoCommit(details);
//if (methodInfoEnd != null)
// methodInfoEnd.MakeGenericMethod(new Type[] { dbTypeEnd }).Invoke(this, new object[] { dbApprove.DATA_ID.ToString() });
if (task != null)
this.UpdateEntityNoCommit(task);
this.UpdateEntityNoCommit(dbApprove);
this.BantchUpdateEntityNoCommit(details);
//if (methodInfoEnd != null)
// methodInfoEnd.MakeGenericMethod(new Type[] { dbTypeEnd }).Invoke(this, new object[] { dbApprove.DATA_ID.ToString() });
}
private void ChangeApproveStatus(T_PF_APPROVE dbApprove, T_FM_NOTIFICATION_TASK task)//, Type dbTypeEnd = null, MethodInfo methodInfoEnd = null
{
@ -645,18 +648,42 @@
[HttpPost, Route("FullGet")]
public JsonActionResult<T_PF_APPROVE> FullGet([FromBody] KeywordFilter filter)
{
var result = WitEntity(null, filter);
if (result.Data != null)
return SafeExecute(() =>
{
if (result.Data.APPROVE_TEMP_ID != null)
T_PF_APPROVE result = null;
if (!string.IsNullOrEmpty(filter.Parameter1) && filter.OrgId.HasValue && filter.Parameter1 != filter.OrgId.Value.ToString())
{
var approveTemp = this.GetEntity<T_PF_APPROVE_TEMP>(t => t.ID == result.Data.APPROVE_TEMP_ID);
if (approveTemp != null)
result.Data.REJECT_INTERFACE = approveTemp.REJECT_INTERFACE;
//集团人员 通过 首页点击 获取对应的数据库链接 返回结果
//这边怎么调用 原生的 GetEntity 方法
string conn = OPTenantDBConnService.GetConnByORGID(new Guid(filter.Parameter1));
//var service = APT.Infrastructure.Api.ServiceLocator.Instance.GetService<IFMNotificatoinService>();
filter.IgnoreOrgRule = true;
//filter.OrgId = null;
filter.SpecifyDbConn = conn;
filter.SpecifyTenant = "0005";
//var ccc = service.GetEntities<T_PF_APPROVE>(e => !e.IS_DELETED, filter, null);
var aaa = GetEntities<T_PF_APPROVE>(e => !e.IS_DELETED, filter, null);
}
result.Data.Nav_ApproveDetails = result.Data.Nav_ApproveDetails.OrderBy(t => t.NUM).ThenBy(m => m.MODIFY_TIME).ToList();
}
return result;
else
{
result = GetEntity<T_PF_APPROVE>(null, filter, null);
if (result != null)
{
if (result.APPROVE_TEMP_ID != null)
{
var approveTemp = this.GetEntity<T_PF_APPROVE_TEMP>(t => t.ID == result.APPROVE_TEMP_ID);
if (approveTemp != null)
result.REJECT_INTERFACE = approveTemp.REJECT_INTERFACE;
}
result.Nav_ApproveDetails = result.Nav_ApproveDetails.OrderBy(t => t.NUM).ThenBy(m => m.MODIFY_TIME).ToList();
}
}
return result;
});
}
/// <summary>
@ -959,7 +986,7 @@
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
private bool BackUpdate_FOJobCrucialLicense(string id,Action action)
private bool BackUpdate_FOJobCrucialLicense(string id, Action action)
{
//var entity = this.GetEntity<T_FO_CRUCIAL_LICENSE_JOB>(id, false, "Nav_OperationStep", "Nav_ApplyUser", "Nav_CrucialLicensePerson");
var entity = this.GetEntity<T_FO_CRUCIAL_LICENSE_JOB>(id, new string[] { "Nav_OperationStep", "Nav_ApplyUser", "Nav_CrucialLicensePerson" });// wyw
@ -1055,7 +1082,7 @@
});
return true;
}
private bool BackUpdate_FOJobEventRecord(string id,Action action)
private bool BackUpdate_FOJobEventRecord(string id, Action action)
{
var entity = this.GetEntity<T_FO_JOB_EVENT_RECORD>(id, "Nav_Details");
entity.FORM_STATUS = (int)FOTeamActivityState.;

22
APT.Utility/HeadHelper.cs Normal file
View File

@ -0,0 +1,22 @@
using APT.Infrastructure.Core;
using Microsoft.AspNetCore.Http;
namespace APT.Utility
{
public class HeadHelper
{
/// <summary>
/// 地球半径
/// </summary>
public const string HeadtelnetCode = "0003";
public static bool GetIsHead(IHeaderDictionary Headers)
{
if (Headers != null && Headers.ContainsKey("Tenant") && Headers["Tenant"] == HeadtelnetCode)
{
return true;
}
return false;
}
}
}

View File

@ -24,5 +24,6 @@ namespace APT.Utility
public string MineType { get; set; }
public string[] DataRule { get; set; }
public bool IsHead { get; set; }
}
}