子公司从总部定期同步法律法规信息
This commit is contained in:
parent
25054ec6f2
commit
78f03f78c3
@ -3,12 +3,14 @@ using APT.BaseData.Domain.IServices.BD;
|
||||
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.BD;
|
||||
using APT.BaseData.Services.Services.BS;
|
||||
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;
|
||||
@ -59,6 +61,7 @@ namespace APT.RB.WebApi.App_Start
|
||||
builder.RegisterType<FMSyncLogDetailService>().As<IFMSyncLogDetailService>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<FMNoticeService>().As<IFMNoticeService>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<BSOperateLogService>().As<IBSOperateLogService>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<OPTenantDBConnService>().As<IOPTenantDBConnService>().InstancePerLifetimeScope();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,10 +4,13 @@ using APT.BaseData.Domain.Enums;
|
||||
using APT.BaseData.Domain.Enums.PF;
|
||||
using APT.BaseData.Domain.IServices;
|
||||
using APT.BaseData.Domain.IServices.FM;
|
||||
using APT.BaseData.Domain.IServices.OP;
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.Migrations;
|
||||
using APT.MS.Domain.Entities.AE;
|
||||
using APT.MS.Domain.Entities.BS;
|
||||
using APT.MS.Domain.Entities.HM;
|
||||
using APT.MS.Domain.Entities.LR;
|
||||
using APT.MS.Domain.Entities.PF;
|
||||
using APT.MS.Domain.Entities.SC;
|
||||
using APT.MS.Domain.Entities.TL;
|
||||
@ -35,13 +38,15 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
IPFSysLogService SysLogService { get; set; }
|
||||
ISCMTMeetingService SCMTMeetingService { get; set; }
|
||||
IFMSyncLogDetailService SyncLogDetailService { get; set; }
|
||||
public SCController(IFMNotificationTaskService notificationTaskService, IPFSysLogService sysLogService, IFMUserService userService, ISCMTMeetingService scMTMeetingService, IFMSyncLogDetailService syncLogDetailService)
|
||||
IOPTenantDBConnService OPTenantDBConnService { get; set; }
|
||||
public SCController(IFMNotificationTaskService notificationTaskService, IPFSysLogService sysLogService, IFMUserService userService, ISCMTMeetingService scMTMeetingService, IFMSyncLogDetailService syncLogDetailService, IOPTenantDBConnService oPTenantDBConnService)
|
||||
{
|
||||
NotificationTaskService = notificationTaskService;
|
||||
UserService = userService;
|
||||
SysLogService = sysLogService;
|
||||
SCMTMeetingService = scMTMeetingService;
|
||||
SyncLogDetailService = syncLogDetailService;
|
||||
OPTenantDBConnService = oPTenantDBConnService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -2215,5 +2220,275 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
//}
|
||||
|
||||
|
||||
#region 法律法规库 从集团同步信息 子公司配跑批 总部不能配跑批 或者总部此跑批禁用
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 法律法规库 从集团同步信息
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("LawSyncToSub")]
|
||||
public JsonActionResult<bool> LawSyncToSub([FromBody] KeywordFilter filter)
|
||||
{
|
||||
return SafeExecute<bool>(() =>
|
||||
{
|
||||
#region 根据跑批 获取 待同步的 法律法规信息 listSync
|
||||
|
||||
Guid GuiDHead = new Guid(FilePathHead.JY.GetDescription());
|
||||
IEnumerable<T_LR_LAW> listSync = null;
|
||||
var task = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);
|
||||
DateTime dtMin = DateTime.Now;
|
||||
if (!string.IsNullOrEmpty(filter.Parameter1))
|
||||
{
|
||||
try
|
||||
{
|
||||
dtMin = Convert.ToDateTime(filter.Parameter1);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dtMin = DateTime.Now;
|
||||
}
|
||||
}
|
||||
if (task.SYNC_UNIT.HasValue)//秒 = 0, //分 = 1, //时 = 2, //天 = 3,
|
||||
{
|
||||
switch (task.SYNC_UNIT)
|
||||
{
|
||||
case 0:
|
||||
dtMin = dtMin.AddSeconds(-1 * task.PERIODIC_TIME);
|
||||
break;
|
||||
case 1:
|
||||
dtMin = dtMin.AddMinutes(-1 * task.PERIODIC_TIME);
|
||||
break;
|
||||
case 2:
|
||||
dtMin = dtMin.AddHours(-1 * task.PERIODIC_TIME);
|
||||
break;
|
||||
case 3:
|
||||
dtMin = dtMin.AddDays(-1 * task.PERIODIC_TIME);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
string strConn = OPTenantDBConnService.GetConnByORGID(GuiDHead);
|
||||
try
|
||||
{
|
||||
using (var context = new MigrationContext(strConn))
|
||||
{
|
||||
listSync = context.GetEntities<T_LR_LAW>(e => e.CREATE_TIME >= dtMin || e.CREATE_TIME >= dtMin, null, new string[] { "Nav_LawType", "Nav_LawVersion.Nav_Files.Nav_ImgFile.Nav_File" });
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
if (listSync == null || listSync.Count() < 1)
|
||||
return true;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Guid AdminID = new Guid("11111111-1111-1111-1111-111111111111");
|
||||
Guid? OrgID = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId;
|
||||
DateTime dtNow = DateTime.Now.Date;
|
||||
|
||||
#region LR/LRLaw SyncToLocal
|
||||
|
||||
var listLawID = listSync.Select(e => e.ID);
|
||||
T_LR_LAW_VERSION modelVersion = null;
|
||||
IEnumerable<T_LR_LAW_VERSION> listLawVersionData = GetEntities<T_LR_LAW_VERSION>(e => listLawID.Contains(e.LAW_ID), null, null).ToList(); //判断修改 主要是 状态
|
||||
|
||||
/////数据组装和查验
|
||||
List<T_LR_LAW_TYPE> Nav_LawType = new List<T_LR_LAW_TYPE>();
|
||||
List<T_LR_LAW_VERSION> Nav_LawVersion = new List<T_LR_LAW_VERSION>();
|
||||
List<T_LR_LAW_VERSION_FILE> Nav_Files = new List<T_LR_LAW_VERSION_FILE>();
|
||||
List<T_PF_IMG_FILE> Nav_ImgFile = new List<T_PF_IMG_FILE>();
|
||||
List<T_PF_FILE> Nav_File = new List<T_PF_FILE>();
|
||||
|
||||
#region 全部拆到组合中去再统一处理
|
||||
|
||||
foreach (var item in listSync)
|
||||
{
|
||||
if (!Nav_LawType.Contains(item.Nav_LawType))
|
||||
Nav_LawType.Add(item.Nav_LawType);
|
||||
if (item.Nav_LawVersion != null && item.Nav_LawVersion.Count() > 0)
|
||||
Nav_LawVersion.AddRange(item.Nav_LawVersion);
|
||||
}
|
||||
|
||||
foreach (var item in Nav_LawVersion)
|
||||
{
|
||||
if (item.Nav_Files != null && item.Nav_Files.Count() > 0)
|
||||
Nav_Files.AddRange(item.Nav_Files);
|
||||
}
|
||||
foreach (var item in Nav_Files)
|
||||
{
|
||||
if (item.Nav_ImgFile != null)
|
||||
Nav_ImgFile.Add(item.Nav_ImgFile);
|
||||
}
|
||||
foreach (var item in Nav_ImgFile)
|
||||
{
|
||||
if (item.Nav_File != null)
|
||||
Nav_File.Add(item.Nav_File);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 组装 现有数据
|
||||
|
||||
if (listLawVersionData != null && listLawVersionData.Count() > 0)
|
||||
{
|
||||
//数据库查询 没有的拉进来
|
||||
foreach (var item in listLawVersionData)
|
||||
{
|
||||
modelVersion = Nav_LawVersion.FirstOrDefault(e => e.ID == item.ID);
|
||||
if (modelVersion != null)
|
||||
continue;
|
||||
Nav_LawVersion.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 数据统一处理 CREATE_TIME MODIFY_TIME MODIFIER_ID 等
|
||||
|
||||
if (Nav_LawVersion != null && Nav_LawVersion.Any())
|
||||
{
|
||||
var listVersionOK = Nav_LawVersion.Where(e => e.VERSION_STATUS == BSLawStatusEnum.现行).OrderBy(e => e.LAW_ID).ThenByDescending(e => e.ENTER_TIME).ToList();
|
||||
if (listVersionOK != null && listVersionOK.Count > 0)
|
||||
{
|
||||
for (int i = 1; i < listVersionOK.Count; i++)
|
||||
{
|
||||
if (listVersionOK[i].LAW_ID == listVersionOK[i - 1].LAW_ID)
|
||||
{
|
||||
listVersionOK[i].VERSION_STATUS = BSLawStatusEnum.废止;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (listSync != null && listSync.Count() > 0)
|
||||
{
|
||||
foreach (var item in listSync)
|
||||
{
|
||||
item.Nav_LawType = null;
|
||||
item.Nav_LawVersion = null;
|
||||
item.Nav_User = null;
|
||||
if (item.ORG_ID == GuiDHead)
|
||||
{
|
||||
item.ORG_ID = OrgID;
|
||||
item.CREATER_ID = AdminID;
|
||||
item.CREATE_TIME = dtNow;
|
||||
item.USER_ID = AdminID;
|
||||
}
|
||||
item.MODIFY_TIME = dtNow;
|
||||
item.MODIFIER_ID = AdminID;
|
||||
}
|
||||
}
|
||||
|
||||
if (Nav_LawType != null && Nav_LawType.Count() > 0)
|
||||
{
|
||||
foreach (var item in Nav_LawType)
|
||||
{
|
||||
if (item.ORG_ID == GuiDHead)
|
||||
{
|
||||
item.ORG_ID = OrgID;
|
||||
item.CREATER_ID = AdminID;
|
||||
item.CREATE_TIME = dtNow;
|
||||
}
|
||||
item.MODIFY_TIME = dtNow;
|
||||
item.MODIFIER_ID = AdminID;
|
||||
}
|
||||
}
|
||||
|
||||
if (Nav_LawVersion != null && Nav_LawVersion.Count() > 0)
|
||||
{
|
||||
foreach (var item in Nav_LawVersion)
|
||||
{
|
||||
item.Nav_Files = null;
|
||||
if (item.ORG_ID == GuiDHead)
|
||||
{
|
||||
item.ORG_ID = OrgID;
|
||||
item.CREATER_ID = AdminID;
|
||||
item.CREATE_TIME = dtNow;
|
||||
}
|
||||
item.MODIFY_TIME = dtNow;
|
||||
item.MODIFIER_ID = AdminID;
|
||||
}
|
||||
}
|
||||
|
||||
if (Nav_Files != null && Nav_Files.Count() > 0)
|
||||
{
|
||||
foreach (var item in Nav_Files)
|
||||
{
|
||||
item.Nav_ImgFile = null;
|
||||
if (item.ORG_ID == GuiDHead)
|
||||
{
|
||||
item.ORG_ID = OrgID;
|
||||
item.CREATER_ID = AdminID;
|
||||
item.CREATE_TIME = dtNow;
|
||||
}
|
||||
item.MODIFY_TIME = dtNow;
|
||||
item.MODIFIER_ID = AdminID;
|
||||
}
|
||||
}
|
||||
|
||||
if (Nav_ImgFile != null && Nav_ImgFile.Count() > 0)
|
||||
{
|
||||
foreach (var item in Nav_ImgFile)
|
||||
{
|
||||
if (item.ORG_ID == GuiDHead)
|
||||
{
|
||||
item.ORG_ID = OrgID;
|
||||
item.CREATER_ID = AdminID;
|
||||
item.CREATE_TIME = dtNow;
|
||||
}
|
||||
item.MODIFY_TIME = dtNow;
|
||||
item.MODIFIER_ID = AdminID;
|
||||
}
|
||||
}
|
||||
|
||||
if (Nav_File != null && Nav_File.Count() > 0)
|
||||
{
|
||||
foreach (var item in Nav_File)
|
||||
{
|
||||
if (item.ORG_ID == GuiDHead)
|
||||
{
|
||||
item.ORG_ID = OrgID;
|
||||
item.CREATER_ID = AdminID;
|
||||
item.CREATE_TIME = dtNow;
|
||||
}
|
||||
item.MODIFY_TIME = dtNow;
|
||||
item.MODIFIER_ID = AdminID;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 数据处理
|
||||
|
||||
UnifiedCommit(() =>
|
||||
{
|
||||
if (listSync != null && listSync.Any())
|
||||
BantchSaveEntityNoCommit(listSync);
|
||||
if (Nav_LawType != null && Nav_LawType.Any())
|
||||
BantchSaveEntityNoCommit(Nav_LawType);
|
||||
if (Nav_LawVersion != null && Nav_LawVersion.Any())
|
||||
BantchSaveEntityNoCommit(Nav_LawVersion);
|
||||
if (Nav_Files != null && Nav_Files.Any())
|
||||
BantchSaveEntityNoCommit(Nav_Files);
|
||||
if (Nav_ImgFile != null && Nav_ImgFile.Any())
|
||||
BantchSaveEntityNoCommit(Nav_ImgFile);
|
||||
if (Nav_File != null && Nav_File.Any())
|
||||
BantchSaveEntityNoCommit(Nav_File);
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,6 +151,8 @@ namespace APT.LR.WebApi.Controllers.Api
|
||||
}
|
||||
}
|
||||
|
||||
entity.MODIFY_TIME = DateTime.Now;//作为数据同步的判断标记符
|
||||
|
||||
UnifiedCommit(() =>
|
||||
{
|
||||
UpdateEntityNoCommit(entity);
|
||||
@ -376,6 +378,8 @@ namespace APT.LR.WebApi.Controllers.Api
|
||||
return SafeGetPagedData(delegate (PagedActionResult<T_LR_LAW> result)
|
||||
{
|
||||
string strConn = OPTenantDBConnService.GetConnByORGID(new Guid(FilePathHead.JY.GetDescription()));
|
||||
try
|
||||
{
|
||||
using (var context = new MigrationContext(strConn))
|
||||
{
|
||||
Expression<Func<T_LR_LAW, bool>> expression = e => !e.IS_DELETED;
|
||||
@ -448,6 +452,8 @@ namespace APT.LR.WebApi.Controllers.Api
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user