企业信息登记表,重大隐患销号表

This commit is contained in:
何美荣 2026-04-03 11:55:48 +08:00
parent 34a71fe3f7
commit 5b165e3a92
11 changed files with 139738 additions and 5 deletions

View File

@ -7649,6 +7649,9 @@ namespace APT.BaseData.Services.DomainServices
break; break;
case "SK/SKHiddenDangerRectifyDelayApply/BackUpdateNew": case "SK/SKHiddenDangerRectifyDelayApply/BackUpdateNew":
result = BackUpdate_SKHiddenDangerRectifyDelayApply(entityInt, modelApp, listAppDetail, taskFinish, listTaskNext, isLast, isApprovel); result = BackUpdate_SKHiddenDangerRectifyDelayApply(entityInt, modelApp, listAppDetail, taskFinish, listTaskNext, isLast, isApprovel);
break;
case "SK/SKMajorAccidentHazardManage/BackUpdateNew":
result = BackUpdate_SKMajorAccidentHazardManage(entityInt, modelApp, listAppDetail, taskFinish, listTaskNext, isLast, isApprovel);
break; break;
case "SK/SKDoublePreventMechanism/BackUpdateNew": case "SK/SKDoublePreventMechanism/BackUpdateNew":
result = BackUpdate_SKDoublePreventMechanism(entityInt, modelApp, listAppDetail, taskFinish, listTaskNext, isLast, isApprovel); result = BackUpdate_SKDoublePreventMechanism(entityInt, modelApp, listAppDetail, taskFinish, listTaskNext, isLast, isApprovel);
@ -12283,6 +12286,33 @@ namespace APT.BaseData.Services.DomainServices
{ {
var entity = this.GetEntity<T_SK_HIDDEN_DANGER_RECTIFY_RECORD>(modelApp != null ? modelApp.DATA_ID : entityInt.DATA_ID); var entity = this.GetEntity<T_SK_HIDDEN_DANGER_RECTIFY_RECORD>(modelApp != null ? modelApp.DATA_ID : entityInt.DATA_ID);
entity.STATUS = PFStandardStatus.Archived; entity.STATUS = PFStandardStatus.Archived;
//如果是重大隐患,触发销号表给安全总监
var user = this.GetEntity<T_FM_USER>(t => t.ENABLE_STATUS == 0 && t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME.Contains("安全总监"));
T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE major = null;
T_FM_NOTIFICATION_TASK notice = null;
if (entity.HIDDEN_LEVEL == SKHiddenLevel.Major && user != null)
{
//先查下销号表是否已经触发过
major = this.GetEntity<T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE>(t => t.HIDDEN_DANGER_RECTIFY_RECORD_ID == entity.ID);
if (major != null)
{
//直接触发原来那张销号表
major.STATUS = PFStandardStatus.Draft;
}
else
{
//否则新增
major.ORG_ID = entity.ORG_ID;
major.STATUS = PFStandardStatus.Draft;
major.HIDDEN_DANGER_RECTIFY_RECORD_ID = entity.ID;
major.APPLY_USER_ID = user.ID;
major.APPLY_DEPARTMENT_ID = user.DEPARTMENT_ID;
major.CODE = "YHXH" + DateTime.Now.ToShortDateString().Replace("/", "") + new Random().Next(1, 999);
major.HIDDEN_DESCRIPTION = entity.HIDDEN_DESCRIPTION;
}
notice = NotificationTaskService.InsertUserNoticeTaskModel("重大事故隐患治理销号表"+ DateTime.Now.ToShortDateString().Replace("/", ""), major.ID, major.ORG_ID, user.ID, user.NAME, DateTime.Now,
DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum., "SK091");
}
UnifiedCommit(() => UnifiedCommit(() =>
{ {
if (modelApp != null) if (modelApp != null)
@ -12294,7 +12324,11 @@ namespace APT.BaseData.Services.DomainServices
if (listTaskNext != null && listTaskNext.Count > 0) if (listTaskNext != null && listTaskNext.Count > 0)
BantchSaveEntityNoCommit(listTaskNext); BantchSaveEntityNoCommit(listTaskNext);
if (entity != null) if (entity != null)
this.UpdateEntityNoCommit(entity); this.UpdateEntityNoCommit(entity);
if (major != null)
this.UpdateEntityNoCommit(major);
if (notice != null)
this.UpdateEntityNoCommit(notice);
}); });
} }
return true; return true;
@ -12364,8 +12398,56 @@ namespace APT.BaseData.Services.DomainServices
}); });
} }
return true; return true;
} }
private bool BackUpdate_SKMajorAccidentHazardManage(T_PF_APPROVE entityInt, T_PF_APPROVE modelApp, List<T_PF_APPROVE_DETAIL> listAppDetail, T_FM_NOTIFICATION_TASK taskFinish, List<T_FM_NOTIFICATION_TASK> listTaskNext, bool isLast = false, bool isApprovel = true)
{
#region
if (modelApp == null && isApprovel)
{
string taskCodeCheck = String.Empty;
bool result = GetApproject2(entityInt, ref modelApp, ref listAppDetail, ref taskFinish, ref taskCodeCheck, ref isLast, ref listTaskNext);
if (!result)
{
throw new Exception("审批失败!");
}
}
#endregion
if (!isLast && isApprovel)
{
this.UnifiedCommit(() =>
{
if (modelApp != null)
UpdateEntityNoCommit(modelApp); //保存主表
if (listAppDetail != null && listAppDetail.Count > 0)//添加组合数据 修改的安全库、隐患库
BantchSaveEntityNoCommit(listAppDetail);
if (taskFinish != null)
UpdateEntityNoCommit(taskFinish);
if (listTaskNext != null && listTaskNext.Count > 0)
BantchSaveEntityNoCommit(listTaskNext);
});
}
else
{
var entity = this.GetEntity<T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE>(modelApp != null ? modelApp.DATA_ID : entityInt.DATA_ID);
entity.STATUS = PFStandardStatus.Archived;
UnifiedCommit(() =>
{
if (modelApp != null)
UpdateEntityNoCommit(modelApp); //保存主表
if (listAppDetail != null && listAppDetail.Count > 0)//添加组合数据 修改的安全库、隐患库
BantchSaveEntityNoCommit(listAppDetail);
if (taskFinish != null)
UpdateEntityNoCommit(taskFinish);
if (listTaskNext != null && listTaskNext.Count > 0)
BantchSaveEntityNoCommit(listTaskNext);
if (entity != null)
this.UpdateEntityNoCommit(entity);
});
}
return true;
}
private bool BackUpdate_SKDoublePreventMechanism(T_PF_APPROVE entityInt, T_PF_APPROVE modelApp, List<T_PF_APPROVE_DETAIL> listAppDetail, T_FM_NOTIFICATION_TASK taskFinish, List<T_FM_NOTIFICATION_TASK> listTaskNext, bool isLast = false, bool isApprovel = true) private bool BackUpdate_SKDoublePreventMechanism(T_PF_APPROVE entityInt, T_PF_APPROVE modelApp, List<T_PF_APPROVE_DETAIL> listAppDetail, T_FM_NOTIFICATION_TASK taskFinish, List<T_FM_NOTIFICATION_TASK> listTaskNext, bool isLast = false, bool isApprovel = true)
{ {
#region #region

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,87 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace APT.Data.Migrations.Migrations
{
public partial class hmr2026040301 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "STATUS",
table: "T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<Guid>(
name: "APPLY_DEPARTMENT_ID",
table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "APPLY_USER_ID",
table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_APPLY_DEPARTMENT_ID",
table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION",
column: "APPLY_DEPARTMENT_ID");
migrationBuilder.CreateIndex(
name: "IX_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_APPLY_USER_ID",
table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION",
column: "APPLY_USER_ID");
migrationBuilder.AddForeignKey(
name: "FK_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_T_FM_DEPARTMENT_APPLY_DEPARTMENT_ID",
table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION",
column: "APPLY_DEPARTMENT_ID",
principalTable: "T_FM_DEPARTMENT",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_T_FM_USER_APPLY_USER_ID",
table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION",
column: "APPLY_USER_ID",
principalTable: "T_FM_USER",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_T_FM_DEPARTMENT_APPLY_DEPARTMENT_ID",
table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION");
migrationBuilder.DropForeignKey(
name: "FK_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_T_FM_USER_APPLY_USER_ID",
table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION");
migrationBuilder.DropIndex(
name: "IX_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_APPLY_DEPARTMENT_ID",
table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION");
migrationBuilder.DropIndex(
name: "IX_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_APPLY_USER_ID",
table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION");
migrationBuilder.DropColumn(
name: "STATUS",
table: "T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE");
migrationBuilder.DropColumn(
name: "APPLY_DEPARTMENT_ID",
table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION");
migrationBuilder.DropColumn(
name: "APPLY_USER_ID",
table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION");
}
}
}

View File

@ -32951,6 +32951,12 @@ namespace APT.Data.Migrations.Migrations
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");
b.Property<Guid?>("APPLY_DEPARTMENT_ID")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("APPLY_USER_ID")
.HasColumnType("uniqueidentifier");
b.Property<decimal?>("AREA") b.Property<decimal?>("AREA")
.HasColumnType("decimal(18,2)"); .HasColumnType("decimal(18,2)");
@ -33039,6 +33045,10 @@ namespace APT.Data.Migrations.Migrations
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("APPLY_DEPARTMENT_ID");
b.HasIndex("APPLY_USER_ID");
b.HasIndex("ORG_ID"); b.HasIndex("ORG_ID");
b.ToTable("T_FO_ENTERPRISE_INFORMATION_REGISTRATION"); b.ToTable("T_FO_ENTERPRISE_INFORMATION_REGISTRATION");
@ -84301,6 +84311,9 @@ namespace APT.Data.Migrations.Migrations
b.Property<int?>("REVIEW_RESULT") b.Property<int?>("REVIEW_RESULT")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("STATUS")
.HasColumnType("int");
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("APPLY_DEPARTMENT_ID"); b.HasIndex("APPLY_DEPARTMENT_ID");
@ -110129,12 +110142,26 @@ namespace APT.Data.Migrations.Migrations
modelBuilder.Entity("APT.MS.Domain.Entities.FO.T_FO_ENTERPRISE_INFORMATION_REGISTRATION", b => modelBuilder.Entity("APT.MS.Domain.Entities.FO.T_FO_ENTERPRISE_INFORMATION_REGISTRATION", b =>
{ {
b.HasOne("APT.BaseData.Domain.Entities.FM.T_FM_DEPARTMENT", "Nav_ApplyDepartment")
.WithMany()
.HasForeignKey("APPLY_DEPARTMENT_ID")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("APT.BaseData.Domain.Entities.FM.T_FM_USER", "Nav_ApplyUser")
.WithMany()
.HasForeignKey("APPLY_USER_ID")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("APT.Infrastructure.Core.T_FM_ORGANIZATION", "Nav_Org") b.HasOne("APT.Infrastructure.Core.T_FM_ORGANIZATION", "Nav_Org")
.WithMany() .WithMany()
.HasForeignKey("ORG_ID") .HasForeignKey("ORG_ID")
.OnDelete(DeleteBehavior.Restrict) .OnDelete(DeleteBehavior.Restrict)
.IsRequired(); .IsRequired();
b.Navigation("Nav_ApplyDepartment");
b.Navigation("Nav_ApplyUser");
b.Navigation("Nav_Org"); b.Navigation("Nav_Org");
}); });

View File

@ -1234,7 +1234,9 @@ builder.HasOne(t => t.Nav_User).WithMany().HasForeignKey(t => t.USER_ID).OnDelet
public override void Configure(EntityTypeBuilder<T_FO_ENTERPRISE_INFORMATION_REGISTRATION> builder) public override void Configure(EntityTypeBuilder<T_FO_ENTERPRISE_INFORMATION_REGISTRATION> builder)
{ {
base.Configure(builder); base.Configure(builder);
builder.Property(t => t.COMPANY_NAME).HasMaxLength(50); builder.HasOne(t => t.Nav_ApplyUser).WithMany().HasForeignKey(t => t.APPLY_USER_ID).OnDelete(DeleteBehavior.Restrict);
builder.HasOne(t => t.Nav_ApplyDepartment).WithMany().HasForeignKey(t => t.APPLY_DEPARTMENT_ID).OnDelete(DeleteBehavior.Restrict);
builder.Property(t => t.COMPANY_NAME).HasMaxLength(50);
builder.Property(t => t.IDENTIFY_CODE).HasMaxLength(50); builder.Property(t => t.IDENTIFY_CODE).HasMaxLength(50);
builder.Property(t => t.USER_NAME).HasMaxLength(50); builder.Property(t => t.USER_NAME).HasMaxLength(50);
builder.Property(t => t.NAME).HasMaxLength(50); builder.Property(t => t.NAME).HasMaxLength(50);
@ -14566,6 +14568,8 @@ builder.HasOne(t => t.Nav_ChargeUser).WithMany().HasForeignKey(t => t.CHARGE_USE
builder.Property(t => t.REVIEW_DESCRIPTION).HasMaxLength(500); builder.Property(t => t.REVIEW_DESCRIPTION).HasMaxLength(500);
builder.HasOne(t => t.Nav_MonitorDepart).WithMany().HasForeignKey(t => t.MONITOR_DEPART_ID).OnDelete(DeleteBehavior.Restrict); builder.HasOne(t => t.Nav_MonitorDepart).WithMany().HasForeignKey(t => t.MONITOR_DEPART_ID).OnDelete(DeleteBehavior.Restrict);
builder.Property(t => t.MONITOR_OPINION).HasMaxLength(500); builder.Property(t => t.MONITOR_OPINION).HasMaxLength(500);
builder.Ignore(t => t.CONTEXT);
builder.Ignore(t => t.PUBLISH);
} }
} }
#endregion #endregion

View File

@ -1,4 +1,5 @@
using APT.BaseData.Domain.Enums.PF; using APT.BaseData.Domain.Entities.FM;
using APT.BaseData.Domain.Enums.PF;
using APT.Infrastructure.Core; using APT.Infrastructure.Core;
using APT.MS.Domain.Enums; using APT.MS.Domain.Enums;
using APT.MS.Domain.Enums.SK; using APT.MS.Domain.Enums.SK;
@ -12,6 +13,19 @@ namespace APT.MS.Domain.Entities.FO
[Description("企业信息登记表")] [Description("企业信息登记表")]
public class T_FO_ENTERPRISE_INFORMATION_REGISTRATION : MesEntityBase public class T_FO_ENTERPRISE_INFORMATION_REGISTRATION : MesEntityBase
{ {
[Description("发起人")]
[DataFieldForeignKey("Nav_ApplyUser")]
public Guid? APPLY_USER_ID { get; set; }
[Description("导航属性:发起人")]
public T_FM_USER Nav_ApplyUser { get; set; }
[Description("发起部门")]
[DataFieldForeignKey("Nav_ApplyDepartment")]
public Guid? APPLY_DEPARTMENT_ID { get; set; }
[Description("导航属性:发起部门")]
public T_FM_DEPARTMENT Nav_ApplyDepartment { get; set; }
[Description("公司名称")] [Description("公司名称")]
[FormFieldTable] [FormFieldTable]
[FormFieldEdit] [FormFieldEdit]

View File

@ -1,4 +1,5 @@
using APT.BaseData.Domain.Entities.FM; using APT.BaseData.Domain.Entities.FM;
using APT.BaseData.Domain.Enums.PF;
using APT.Infrastructure.Core; using APT.Infrastructure.Core;
using APT.MS.Domain.Entities.FO; using APT.MS.Domain.Entities.FO;
using APT.MS.Domain.Enums; using APT.MS.Domain.Enums;
@ -90,5 +91,17 @@ namespace APT.MS.Domain.Entities.SK
[Description("监管部门意见")] [Description("监管部门意见")]
[DataFieldLength(500)] [DataFieldLength(500)]
public string MONITOR_OPINION { get; set; } public string MONITOR_OPINION { get; set; }
[Description("状态")]
[EnumName("PFStandardStatus")]
public PFStandardStatus STATUS { get; set; }
[Description("驳回意见")]
[DataFieldIngore]
public string CONTEXT { get; set; }
[Description("是否发布")]
[DataFieldIngore]
public string PUBLISH { get; set; }
} }
} }

View File

@ -0,0 +1,168 @@
using APT.Infrastructure.Core;
using APT.MS.Domain.Entities.FO;
using APT.Utility;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
namespace APT.FO.WebApi.Controllers
{
/// <summary>
/// 企业信息登记表
/// </summary>
[Route("api/FO/FOEnterpriseInformationRegistration")]
public partial class EnterpriseInformationRegistrationController : AuthorizeApiController<T_FO_ENTERPRISE_INFORMATION_REGISTRATION>
{
[HttpPost, Route("GetEdit")]
public JsonActionResult<T_FO_ENTERPRISE_INFORMATION_REGISTRATION> GetEdit([FromBody] KeywordFilter filter)
{
return SafeExecute(() =>
{
var id = filter.FilterGroup.Rules.FirstOrDefault(t => t.Field == "ID").Value.ToString();
if (string.IsNullOrEmpty(id))
this.ThrowError("060010");
var entity = this.GetEntity<T_FO_ENTERPRISE_INFORMATION_REGISTRATION>(id, "Nav_ApplyUser", "Nav_ApplyDepartment", "Nav_ProUnits.Nav_ProUnit", "Nav_WorkFiles.Nav_ImgFile.Nav_File",
"Nav_AllowFiles.Nav_ImgFile.Nav_File", "Nav_SafeFiles.Nav_ImgFile.Nav_File", "Nav_Files.Nav_ImgFile.Nav_File");
return entity;
});
}
/// <summary>
/// 新增修改
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[HttpPost, Route("FullUpdate")]
public JsonActionResult<bool> FullUpdate([FromBody] T_FO_ENTERPRISE_INFORMATION_REGISTRATION entity)
{
return SafeExecute<bool>(() =>
{
var loginUserId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
var departmentId = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID;
entity.APPLY_USER_ID = loginUserId;
entity.APPLY_DEPARTMENT_ID = departmentId;
var proUnits = entity.Nav_ProUnits;
if (proUnits != null && proUnits.Any())
{
proUnits = proUnits.Where(t => !t.IS_DELETED).ToList();
}
entity.Nav_ProUnits = null;
var proUnitIds = this.GetEntities<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_UNIT>(t => t.ENTERPRISE_INFORMATION_REGISTRATION_ID == entity.ID, new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
var proUnitList = new List<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_UNIT>();
if (proUnits != null && proUnits.Any())
{
foreach (var unit in proUnits)
{
T_FO_ENTERPRISE_INFORMATION_REGISTRATION_UNIT item = new T_FO_ENTERPRISE_INFORMATION_REGISTRATION_UNIT();
item.ORG_ID = entity.ORG_ID;
item.ENTERPRISE_INFORMATION_REGISTRATION_ID = entity.ID;
item.PRODUCTION_UNIT_ID = unit.PRODUCTION_UNIT_ID;
proUnitList.Add(item);
}
}
var workFiles = entity.Nav_WorkFiles;
if (workFiles != null && workFiles.Any())
{
workFiles = workFiles.Where(t => !t.IS_DELETED).ToList();
}
entity.Nav_WorkFiles = null;
var workFileIds = this.GetEntities<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_WORKFILE>(t => t.ENTERPRISE_INFORMATION_REGISTRATION_ID == entity.ID, new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
var workFileList = new List<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_WORKFILE>();
if (workFiles != null && workFiles.Any())
{
foreach (var file in workFiles)
{
T_FO_ENTERPRISE_INFORMATION_REGISTRATION_WORKFILE item = new T_FO_ENTERPRISE_INFORMATION_REGISTRATION_WORKFILE();
item.ORG_ID = entity.ORG_ID;
item.ENTERPRISE_INFORMATION_REGISTRATION_ID = entity.ID;
item.IMG_FILE_ID = file.IMG_FILE_ID;
workFileList.Add(item);
}
}
var allowFiles = entity.Nav_AllowFiles;
if (allowFiles != null && allowFiles.Any())
{
allowFiles = allowFiles.Where(t => !t.IS_DELETED).ToList();
}
entity.Nav_AllowFiles = null;
var allowFileIds = this.GetEntities<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_ALLOWFILE>(t => t.ENTERPRISE_INFORMATION_REGISTRATION_ID == entity.ID, new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
var allowFileList = new List<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_ALLOWFILE>();
if (allowFiles != null && allowFiles.Any())
{
foreach (var file in allowFiles)
{
T_FO_ENTERPRISE_INFORMATION_REGISTRATION_ALLOWFILE item = new T_FO_ENTERPRISE_INFORMATION_REGISTRATION_ALLOWFILE();
item.ORG_ID = entity.ORG_ID;
item.ENTERPRISE_INFORMATION_REGISTRATION_ID = entity.ID;
item.IMG_FILE_ID = file.IMG_FILE_ID;
allowFileList.Add(item);
}
}
var safeFiles = entity.Nav_SafeFiles;
if (safeFiles != null && safeFiles.Any())
{
safeFiles = safeFiles.Where(t => !t.IS_DELETED).ToList();
}
entity.Nav_SafeFiles = null;
var safeFileIds = this.GetEntities<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_SAFEFILE>(t => t.ENTERPRISE_INFORMATION_REGISTRATION_ID == entity.ID, new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
var safeFileList = new List<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_SAFEFILE>();
if (safeFiles != null && safeFiles.Any())
{
foreach (var file in safeFiles)
{
T_FO_ENTERPRISE_INFORMATION_REGISTRATION_SAFEFILE item = new T_FO_ENTERPRISE_INFORMATION_REGISTRATION_SAFEFILE();
item.ORG_ID = entity.ORG_ID;
item.ENTERPRISE_INFORMATION_REGISTRATION_ID = entity.ID;
item.IMG_FILE_ID = file.IMG_FILE_ID;
safeFileList.Add(item);
}
}
var files = entity.Nav_Files;
if (files != null && files.Any())
{
files = files.Where(t => !t.IS_DELETED).ToList();
}
entity.Nav_Files = null;
var fileIds = this.GetEntities<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_FILE>(t => t.ENTERPRISE_INFORMATION_REGISTRATION_ID == entity.ID, new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
var fileList = new List<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_FILE>();
if (files != null && files.Any())
{
foreach (var file in files)
{
T_FO_ENTERPRISE_INFORMATION_REGISTRATION_FILE item = new T_FO_ENTERPRISE_INFORMATION_REGISTRATION_FILE();
item.ORG_ID = entity.ORG_ID;
item.ENTERPRISE_INFORMATION_REGISTRATION_ID = entity.ID;
item.IMG_FILE_ID = file.IMG_FILE_ID;
fileList.Add(item);
}
}
this.UnifiedCommit(() =>
{
if (proUnitIds != null && proUnitIds.Any())
this.BantchDeleteEntityNoCommit<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_UNIT>(proUnitIds);
if (workFileIds != null && workFileIds.Any())
this.BantchDeleteEntityNoCommit<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_WORKFILE>(workFileIds);
if (allowFileIds != null && allowFileIds.Any())
this.BantchDeleteEntityNoCommit<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_ALLOWFILE>(allowFileIds);
if (safeFileIds != null && safeFileIds.Any())
this.BantchDeleteEntityNoCommit<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_SAFEFILE>(safeFileIds);
if (fileIds != null && fileIds.Any())
this.BantchDeleteEntityNoCommit<T_FO_ENTERPRISE_INFORMATION_REGISTRATION_FILE>(fileIds);
if (entity != null)
UpdateEntityNoCommit(entity);
if (proUnitList != null && proUnitList.Any())
this.BantchSaveEntityNoCommit(proUnitList);
if (workFileList != null && workFileList.Any())
this.BantchSaveEntityNoCommit(workFileList);
if (allowFileList != null && allowFileList.Any())
this.BantchSaveEntityNoCommit(allowFileList);
if (safeFileList != null && safeFileList.Any())
this.BantchSaveEntityNoCommit(safeFileList);
if (fileList != null && fileList.Any())
this.BantchSaveEntityNoCommit(fileList);
});
return true;
});
}
}
}

View File

@ -2183,6 +2183,68 @@ namespace APT.PP.WebApi.Controllers.Api.PP
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
} }
return true;
});
}
/// <summary>
/// 企业信息登记表营业期限、采矿许可证有效期、安全生产许可证有效期到期前3个月触发今日提醒给安全总监
/// </summary>
/// <param name="pageFilter"></param>
/// <returns></returns>
[HttpPost, Route("EnterpriseInfoSync")]
public JsonActionResult<bool> EnterpriseInfoSync([FromBody] KeywordFilter filter)
{
return SafeExecute<bool>(() =>
{
try
{
var notices = new List<T_FM_NOTIFICATION_TASK>();
var dt = DateTime.Now;
if (filter.Parameter1 != null)
{
dt = DateTime.Parse(filter.Parameter1);
}
var dtThree = dt.AddMonths(-3);//前三个月
//找安全总监
var user = this.GetEntity<T_FM_USER>(t => t.ENABLE_STATUS == 0 && t.Nav_ApproveRole!=null && t.Nav_ApproveRole.NAME.Contains("安全总监"));
//找营业期限或者采矿许可证有效期或者安全生产许可证有效期到期前3个月的数据
var infos = this.GetEntities<T_FO_ENTERPRISE_INFORMATION_REGISTRATION>(t =>(t.WORK_DATE!=null&& t.WORK_DATE < dtThree) || (t.ALLOW_DATE != null && t.ALLOW_DATE < dtThree) || (t.SAFE_ALLOW_DATE != null && t.SAFE_ALLOW_DATE < dtThree), new BaseFilter(filter.OrgId), "Nav_Users");
if (user != null && infos != null && infos.Any() && dt.Hour == 8)//每小时跑批只在8点触发
{
foreach (var item in infos)
{
var msg = item.COMPANY_NAME+item.IDENTIFY_CODE+"";
if (item.WORK_DATE != null && item.WORK_DATE < dtThree)
{
msg = msg + "营业期限还有三个月到期,请及时处理;";
}
if (item.ALLOW_DATE != null && item.ALLOW_DATE < dtThree)
{
msg = msg + "采矿许可证还有三个月到期,请及时处理;";
}
if (item.SAFE_ALLOW_DATE != null && item.SAFE_ALLOW_DATE < dtThree)
{
msg = msg + "安全生产许可证还有三个月到期,请及时处理。";
}
var notice = NotificationTaskService.InsertUserNoticeTaskModel(msg, item.ID, item.ORG_ID, user.ID, user.NAME, DateTime.Now,
DateTime.Now.AddDays(2), (int)FMNoticeTypeEnum., "PF135");
notices.Add(notice);
}
}
UnifiedCommit(() =>
{
if (notices != null && notices.Any())
BantchSaveEntityNoCommit(notices);
});
}
catch (Exception ex)
{
if (!string.IsNullOrEmpty(ex.StackTrace))
throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
else
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
}
return true; return true;
}); });
} }

View File

@ -59,7 +59,7 @@ namespace APT.SK.WebApi.Controllers
throw new Exception("不合格验收意见必须填写"); throw new Exception("不合格验收意见必须填写");
} }
T_FM_NOTIFICATION_TASK finishNotice = null; T_FM_NOTIFICATION_TASK finishNotice = null;
if (entity.STATUS != PFStandardStatus.Draft) if (entity.STATUS != PFStandardStatus.Draft && entity.STATUS != PFStandardStatus.Rejected)
{ {
var taskId = entity.TaskID; var taskId = entity.TaskID;
if (taskId == Guid.Empty) if (taskId == Guid.Empty)
@ -529,6 +529,12 @@ namespace APT.SK.WebApi.Controllers
if (result != null && result.STATUS == PFStandardStatus.Rejected) if (result != null && result.STATUS == PFStandardStatus.Rejected)
{ {
result.CONTEXT = ApproveCallBackService.RejectContent(result.ID); result.CONTEXT = ApproveCallBackService.RejectContent(result.ID);
//查是否销号表驳回过来的
var major = this.GetEntity<T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE>(t => t.HIDDEN_DANGER_RECTIFY_RECORD_ID == result.ID);
if (major != null && major.STATUS == PFStandardStatus.Rejected)
{
result.CONTEXT = "不同意销号,请重新整改!";
}
} }
return result; return result;
}); });

View File

@ -0,0 +1,274 @@
using APT.BaseData.Domain.Entities;
using APT.BaseData.Domain.Entities.FM;
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.Services.DomainServices;
using APT.Infrastructure.Core;
using APT.MS.Domain.Entities.FO;
using APT.MS.Domain.Entities.SK;
using APT.MS.Domain.Enums;
using APT.MS.Domain.Enums.SK;
using APT.Utility;
using InfluxData.Net.InfluxDb.Models.Responses;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
namespace APT.SK.WebApi.Controllers.Api
{
/// <summary>
/// 重大事故隐患治理销号表
/// </summary>
[Route("api/SK/SKMajorAccidentHazardManage")]
public partial class MajorAccidentHazardManageController : AuthorizeApiController<T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE>
{
IPFApproveCallBackService ApproveCallBackService { get; set; }
IFMNotificationTaskService NotificationTaskService { get; set; }
IPFCodeRuleService CodeRuleService { get; set; }
IFMFlowPermitService MFlowPermitService { get; set; }
public MajorAccidentHazardManageController(IFMNotificationTaskService notificationTaskService, IFMFlowPermitService mFlowPermitService, IPFCodeRuleService codeRuleService, IPFApproveCallBackService approveCallBackService)
{
NotificationTaskService = notificationTaskService;
MFlowPermitService = mFlowPermitService;
CodeRuleService = codeRuleService;
ApproveCallBackService = approveCallBackService;
}
[HttpPost, Route("FullUpdate")]
public JsonActionResult<bool> FullUpdate([FromBody] T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE entity)
{
return SafeExecute<bool>(() =>
{
var userId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
var departId = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID;
if (entity.APPLY_USER_ID == null)
entity.APPLY_USER_ID = userId;
if (entity.APPLY_DEPARTMENT_ID == null)
entity.APPLY_DEPARTMENT_ID = departId;
if (entity.REVIEW_RESULT == null)
{
throw new Exception("复查结论必须填写!");
}
T_FM_NOTIFICATION_TASK finishNotice = null;
if (entity.STATUS != PFStandardStatus.Draft && entity.STATUS != PFStandardStatus.Rejected)
{
var taskId = entity.TaskID;
if (taskId == Guid.Empty)
{
var taskTemp = GetEntity<T_FM_NOTIFICATION_TASK>(i => i.SOURCE_DATA_ID == entity.ID && i.USER_ID == userId
&& i.NOTICE_STATUS == FMNoticeStatusEnum..GetInt() && i.SOURCE_FORMCODE == "SK091");
if (taskTemp != null)
{
taskTemp.NOTICE_STATUS = 1;
taskTemp.SOURCE_FORMCODE = "SK091_SHOWPRINT";
finishNotice = taskTemp;
}
}
if (taskId != Guid.Empty)
{
finishNotice = NotificationTaskService.FOGetTaskFinishModel(taskId, entity.ID, "SK091_SHOWPRINT");
}
UpdateEntity(finishNotice);
throw new Exception("你已提交,请勿重复提交!");
}
if (string.IsNullOrEmpty(entity.CODE))
entity.CODE = "YHXH" + DateTime.Now.ToShortDateString().Replace("/", "") + new Random().Next(1, 999);
var users = entity.Nav_Users;
entity.Nav_Users = null;
var files = entity.Nav_Files;
entity.Nav_Files = null;
var userIds = this.GetEntities<T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE_USER>(t => t.MAJOR_ACCIDENT_HAZARD_MANAGE_ID == entity.ID, new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
var userList = new List<T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE_USER>();
var fileIds = this.GetEntities<T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE_FILE>(t => t.MAJOR_ACCIDENT_HAZARD_MANAGE_ID == entity.ID, new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
var fileList = new List<T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE_FILE>();
if (users != null && users.Any())
{
foreach (var user in users.Where(t=>!t.IS_DELETED))
{
T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE_USER item = new T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE_USER();
item.ORG_ID = entity.ORG_ID;
item.MAJOR_ACCIDENT_HAZARD_MANAGE_ID = entity.ID;
item.USER_ID = user.USER_ID;
userList.Add(item);
}
}
if (files != null && files.Any())
{
foreach (var file in files)
{
T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE_FILE item = new T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE_FILE();
item.ORG_ID = entity.ORG_ID;
item.MAJOR_ACCIDENT_HAZARD_MANAGE_ID = entity.ID;
item.IMG_FILE_ID = file.IMG_FILE_ID;
fileList.Add(item);
}
}
List<T_FM_NOTIFICATION_TASK> notices = new List<T_FM_NOTIFICATION_TASK>();
T_FM_NOTIFICATION_TASK task = null;
T_SK_HIDDEN_DANGER_RECTIFY_RECORD record = null;
if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
{
//同意销号触发审批
if (entity.REVIEW_RESULT == SKReviewResultEnum.OK)
{
//触发审批
entity.STATUS = PFStandardStatus.Approving;
//取审批流水码
var sysFilter = new SystemCodeFilter();
sysFilter.CodeType = (int)PFCodeRuleType.;
sysFilter.Count = 1;
sysFilter.OrgId = entity.ORG_ID;
var codes = CodeRuleService.NewGenSerial(sysFilter);
var serialCode = codes.Split(new char[] { ',' });
MFlowPermitService.InsertApprove(serialCode[0], "SK091", "", entity.ID, "SK091_SHOWPRINT", entity.TaskID, true, () =>
{
if (entity != null)
UpdateEntityNoCommit(entity);
if (userList != null && userList.Any())
BantchSaveEntityNoCommit(userList);
if (fileList != null && fileList.Any())
BantchSaveEntityNoCommit(fileList);
}, null, null, null, null, null, "SK091_SHOWPRINT", null);
return true;
}
else
{
//置为驳回
entity.STATUS = PFStandardStatus.Rejected;
//隐患整改记录从“归档”状况转为“驳回”(原来的内容带过去,驳回意见显示:不同意销号,请重新整改!),(整改后重新走责任人确认、验收人验收和审批流,归档后再触发销号表)
record = this.GetEntity<T_SK_HIDDEN_DANGER_RECTIFY_RECORD>(t => t.ID == entity.HIDDEN_DANGER_RECTIFY_RECORD_ID);
if (record != null)
{
record.STATUS = PFStandardStatus.Rejected;
if (record.IMPLEMENT_USER_ID != null)
{
var user = this.GetEntity<T_FM_USER>(t => t.ID == record.IMPLEMENT_USER_ID);
if (user!=null)
{
//同时触发给整改落实人重新整改
var sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("隐患整改记录表" + record.CODE+"不同意销号,点击重新整改", record.ID, record.ORG_ID, user.ID, user.NAME, DateTime.Now,
DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum., "SK022");
notices.Add(sendNotice);
}
}
if (record.RECITIFY_USER_ID != null)
{
var user = this.GetEntity<T_FM_USER>(t => t.ID == record.RECITIFY_USER_ID);
if (user != null)
{
//并发送今日提醒给整改责任人“隐患整改记录表单编号为***,经重大事故隐患治理复查不同意销号,请监督重新整改!”
var sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("隐患整改记录表单编号为"+ record.CODE +",经重大事故隐患治理复查不同意销号,请监督重新整改!", record.ID, record.ORG_ID, user.ID, user.NAME, DateTime.Now,
DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum., "PF135");
notices.Add(sendNotice);
}
}
}
}
if (entity.TaskID != Guid.Empty)
{
task = NotificationTaskService.GetTaskFinishModel(entity.TaskID);
task.SOURCE_FORMCODE = "SK091_SHOWPRINT";
}
}
this.UnifiedCommit(() =>
{
if (task != null)
UpdateEntityNoCommit(task);
if (entity != null)
UpdateEntityNoCommit(entity);
if (userList != null && userList.Any())
BantchSaveEntityNoCommit(userList);
if (fileList != null && fileList.Any())
BantchSaveEntityNoCommit(fileList);
if (notices != null && notices.Any())
BantchSaveEntityNoCommit(notices);
});
return true;
});
}
/// <summary>
/// 获得单条实体数据
/// </summary>
/// <param name="filter">过滤实体</param>
/// <returns></returns>
[HttpPost, Route("SKGet")]
public JsonActionResult<T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE> SKGet([FromBody] KeywordFilter filter)
{
return SafeExecute(() =>
{
var id = filter.FilterGroup.Rules.FirstOrDefault(t => t.Field == "ID").Value.ToString();
if (string.IsNullOrEmpty(id))
this.ThrowError("060010");
filter.IgnoreDataRule = true;
var result = this.GetEntity<T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE>(id, new string[] { "Nav_ApplyUser", "Nav_ApplyDepartment","Nav_RectifyRecord","Nav_Users.Nav_User","Nav_MonitorDepart", "Nav_Files.Nav_ImgFile"});
if (result != null && result.STATUS == PFStandardStatus.Rejected)
{
result.CONTEXT = ApproveCallBackService.RejectContent(result.ID);
}
return result;
});
}
/// <summary>
/// 回调函数
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost, Route("BackUpdateNew")]
public JsonActionResult<bool> BackUpdateNew([FromBody] T_PF_APPROVE entity)
{
return SafeExecute(() =>
{
return ApproveCallBackService.CallBackNew("SK/SKMajorAccidentHazardManage/BackUpdateNew", entity);
});
}
/// <summary>
/// 驳回
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost, Route("RejectUpdate")]
public JsonActionResult<bool> RejectUpdate([FromBody] T_PF_APPROVE model)
{
return SafeExecute(() =>
{
//公共 获取审批流信息
T_PF_APPROVE modelApp = null;
List<T_PF_APPROVE_DETAIL> listAppDetail = null;
T_FM_NOTIFICATION_TASK taskFinish = null;
string Msg = string.Empty;
bool ResultGetInfo = ApproveCallBackService.GetApproject(model, ref modelApp, ref listAppDetail, ref taskFinish, ref Msg);
if (!ResultGetInfo)
throw new Exception("驳回失败!");
if (modelApp == null || listAppDetail == null)
throw new Exception("获取驳回信息失败!");
var entity = this.GetEntity<T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE>(model.DATA_ID, new string[] { "Nav_ApplyUser" });
entity.STATUS = PFStandardStatus.Rejected;
T_FM_NOTIFICATION_TASK notice = new T_FM_NOTIFICATION_TASK();
if (entity.APPLY_USER_ID != null)
{
//发消息
notice = NotificationTaskService.InsertUserNoticeTaskModel("重大事故隐患治理销号表审批被驳回", entity.ID, entity.ORG_ID, (Guid)entity.APPLY_USER_ID, entity.Nav_ApplyUser?.NAME, DateTime.Now,
DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum., "SK091");
}
UnifiedCommit(() =>
{
if (entity != null)
this.UpdateEntityNoCommit(entity);
if (notice != null)
this.UpdateEntityNoCommit(notice);
if (modelApp != null)
UpdateEntityNoCommit(modelApp);
if (listAppDetail != null && listAppDetail.Count > 0)
BantchUpdateEntityNoCommit(listAppDetail);
if (taskFinish != null)
UpdateEntityNoCommit(taskFinish);
});
return true;
});
}
}
}