1、检查计划配置 代码转移
1、添加 接收人
2、除外组织
3、检查区域
4、计划配置表单 配置修改
5、配置保存方法处理
2、跑批触发任务 修改
3、检查任务制定 获取数据源 方法修改
4、检查任务制定 检查人员自动匹配规则 【判断加载
This commit is contained in:
parent
5d3e6758d7
commit
42496cf7cd
62144
APT.Data.Migrations/Migrations/20240927062720_wyw2024092703.Designer.cs
generated
Normal file
62144
APT.Data.Migrations/Migrations/20240927062720_wyw2024092703.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
165
APT.Data.Migrations/Migrations/20240927062720_wyw2024092703.cs
Normal file
165
APT.Data.Migrations/Migrations/20240927062720_wyw2024092703.cs
Normal file
@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace APT.Data.Migrations.Migrations
|
||||
{
|
||||
public partial class wyw2024092703 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "USER_ID_SEND",
|
||||
table: "T_BS_PLAN_SET",
|
||||
type: "uniqueidentifier",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "T_BS_PLAN_SET_AREA",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
PLANSET_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
AREA_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
IS_DELETED = table.Column<bool>(type: "bit", nullable: false),
|
||||
ORG_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
ENTITY_ORG_TPYE = table.Column<int>(type: "int", nullable: false),
|
||||
FORM_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
FLOW_STATUS = table.Column<int>(type: "int", nullable: false),
|
||||
FLOW_SEND_STATUS = table.Column<int>(type: "int", nullable: false),
|
||||
FLOW_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
CREATE_TIME = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
MODIFY_TIME = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
CREATER_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
MODIFIER_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_T_BS_PLAN_SET_AREA", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_T_BS_PLAN_SET_AREA_T_BS_PLAN_SET_PLANSET_ID",
|
||||
column: x => x.PLANSET_ID,
|
||||
principalTable: "T_BS_PLAN_SET",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_T_BS_PLAN_SET_AREA_T_FM_ORGANIZATION_ORG_ID",
|
||||
column: x => x.ORG_ID,
|
||||
principalTable: "T_FM_ORGANIZATION",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_T_BS_PLAN_SET_AREA_T_HM_RISK_AREA_AREA_ID",
|
||||
column: x => x.AREA_ID,
|
||||
principalTable: "T_HM_RISK_AREA",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "T_BS_PLAN_SET_DEPARTMENT_OUT",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
PLANSET_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
DEPARTMENT_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
IS_DELETED = table.Column<bool>(type: "bit", nullable: false),
|
||||
ORG_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
ENTITY_ORG_TPYE = table.Column<int>(type: "int", nullable: false),
|
||||
FORM_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
FLOW_STATUS = table.Column<int>(type: "int", nullable: false),
|
||||
FLOW_SEND_STATUS = table.Column<int>(type: "int", nullable: false),
|
||||
FLOW_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
CREATE_TIME = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
MODIFY_TIME = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
CREATER_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
MODIFIER_ID = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_T_BS_PLAN_SET_DEPARTMENT_OUT", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_T_BS_PLAN_SET_DEPARTMENT_OUT_T_BS_PLAN_SET_PLANSET_ID",
|
||||
column: x => x.PLANSET_ID,
|
||||
principalTable: "T_BS_PLAN_SET",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_T_BS_PLAN_SET_DEPARTMENT_OUT_T_FM_DEPARTMENT_DEPARTMENT_ID",
|
||||
column: x => x.DEPARTMENT_ID,
|
||||
principalTable: "T_FM_DEPARTMENT",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_T_BS_PLAN_SET_DEPARTMENT_OUT_T_FM_ORGANIZATION_ORG_ID",
|
||||
column: x => x.ORG_ID,
|
||||
principalTable: "T_FM_ORGANIZATION",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_T_BS_PLAN_SET_USER_ID_SEND",
|
||||
table: "T_BS_PLAN_SET",
|
||||
column: "USER_ID_SEND");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_T_BS_PLAN_SET_AREA_AREA_ID",
|
||||
table: "T_BS_PLAN_SET_AREA",
|
||||
column: "AREA_ID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_T_BS_PLAN_SET_AREA_ORG_ID",
|
||||
table: "T_BS_PLAN_SET_AREA",
|
||||
column: "ORG_ID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_T_BS_PLAN_SET_AREA_PLANSET_ID",
|
||||
table: "T_BS_PLAN_SET_AREA",
|
||||
column: "PLANSET_ID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_T_BS_PLAN_SET_DEPARTMENT_OUT_DEPARTMENT_ID",
|
||||
table: "T_BS_PLAN_SET_DEPARTMENT_OUT",
|
||||
column: "DEPARTMENT_ID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_T_BS_PLAN_SET_DEPARTMENT_OUT_ORG_ID",
|
||||
table: "T_BS_PLAN_SET_DEPARTMENT_OUT",
|
||||
column: "ORG_ID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_T_BS_PLAN_SET_DEPARTMENT_OUT_PLANSET_ID",
|
||||
table: "T_BS_PLAN_SET_DEPARTMENT_OUT",
|
||||
column: "PLANSET_ID");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_T_BS_PLAN_SET_T_FM_USER_USER_ID_SEND",
|
||||
table: "T_BS_PLAN_SET",
|
||||
column: "USER_ID_SEND",
|
||||
principalTable: "T_FM_USER",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_T_BS_PLAN_SET_T_FM_USER_USER_ID_SEND",
|
||||
table: "T_BS_PLAN_SET");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "T_BS_PLAN_SET_AREA");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "T_BS_PLAN_SET_DEPARTMENT_OUT");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_T_BS_PLAN_SET_USER_ID_SEND",
|
||||
table: "T_BS_PLAN_SET");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "USER_ID_SEND",
|
||||
table: "T_BS_PLAN_SET");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19120,6 +19120,9 @@ namespace APT.Data.Migrations.Migrations
|
||||
b.Property<DateTime>("RUNSETTIME")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid?>("USER_ID_SEND")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<int?>("WEEKDATA")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -19131,9 +19134,125 @@ namespace APT.Data.Migrations.Migrations
|
||||
|
||||
b.HasIndex("ORG_ID");
|
||||
|
||||
b.HasIndex("USER_ID_SEND");
|
||||
|
||||
b.ToTable("T_BS_PLAN_SET");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("APT.MS.Domain.Entities.BS.T_BS_PLAN_SET_AREA", b =>
|
||||
{
|
||||
b.Property<Guid>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid>("AREA_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("CREATER_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime?>("CREATE_TIME")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ENTITY_ORG_TPYE")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid?>("FLOW_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<int>("FLOW_SEND_STATUS")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("FLOW_STATUS")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid?>("FORM_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<bool>("IS_DELETED")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<Guid?>("MODIFIER_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime?>("MODIFY_TIME")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid?>("ORG_ID")
|
||||
.IsRequired()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid>("PLANSET_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("AREA_ID");
|
||||
|
||||
b.HasIndex("ORG_ID");
|
||||
|
||||
b.HasIndex("PLANSET_ID");
|
||||
|
||||
b.ToTable("T_BS_PLAN_SET_AREA");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("APT.MS.Domain.Entities.BS.T_BS_PLAN_SET_DEPARTMENT_OUT", b =>
|
||||
{
|
||||
b.Property<Guid>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("CREATER_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime?>("CREATE_TIME")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("DEPARTMENT_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<int>("ENTITY_ORG_TPYE")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid?>("FLOW_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<int>("FLOW_SEND_STATUS")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("FLOW_STATUS")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid?>("FORM_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<bool>("IS_DELETED")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<Guid?>("MODIFIER_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime?>("MODIFY_TIME")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid?>("ORG_ID")
|
||||
.IsRequired()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid>("PLANSET_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DEPARTMENT_ID");
|
||||
|
||||
b.HasIndex("ORG_ID");
|
||||
|
||||
b.HasIndex("PLANSET_ID");
|
||||
|
||||
b.ToTable("T_BS_PLAN_SET_DEPARTMENT_OUT");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("APT.MS.Domain.Entities.BS.T_BS_PLAN_SET_DEP_OBJECT", b =>
|
||||
{
|
||||
b.Property<Guid>("ID")
|
||||
@ -50300,11 +50419,72 @@ namespace APT.Data.Migrations.Migrations
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("APT.BaseData.Domain.Entities.FM.T_FM_USER", "Nav_UserSend")
|
||||
.WithMany()
|
||||
.HasForeignKey("USER_ID_SEND")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.Navigation("Nav_CheckType");
|
||||
|
||||
b.Navigation("Nav_CheckTypeLevel");
|
||||
|
||||
b.Navigation("Nav_Org");
|
||||
|
||||
b.Navigation("Nav_UserSend");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("APT.MS.Domain.Entities.BS.T_BS_PLAN_SET_AREA", b =>
|
||||
{
|
||||
b.HasOne("APT.MS.Domain.Entities.HM.T_HM_RISK_AREA", "Nav_Area")
|
||||
.WithMany()
|
||||
.HasForeignKey("AREA_ID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("APT.Infrastructure.Core.T_FM_ORGANIZATION", "Nav_Org")
|
||||
.WithMany()
|
||||
.HasForeignKey("ORG_ID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("APT.MS.Domain.Entities.BS.T_BS_PLAN_SET", "Nav_PlanSet")
|
||||
.WithMany("Nav_ListArea")
|
||||
.HasForeignKey("PLANSET_ID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Nav_Area");
|
||||
|
||||
b.Navigation("Nav_Org");
|
||||
|
||||
b.Navigation("Nav_PlanSet");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("APT.MS.Domain.Entities.BS.T_BS_PLAN_SET_DEPARTMENT_OUT", b =>
|
||||
{
|
||||
b.HasOne("APT.BaseData.Domain.Entities.FM.T_FM_DEPARTMENT", "Nav_Department")
|
||||
.WithMany()
|
||||
.HasForeignKey("DEPARTMENT_ID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("APT.Infrastructure.Core.T_FM_ORGANIZATION", "Nav_Org")
|
||||
.WithMany()
|
||||
.HasForeignKey("ORG_ID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("APT.MS.Domain.Entities.BS.T_BS_PLAN_SET", "Nav_PlanSet")
|
||||
.WithMany("Nav_ListDepOut")
|
||||
.HasForeignKey("PLANSET_ID")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Nav_Department");
|
||||
|
||||
b.Navigation("Nav_Org");
|
||||
|
||||
b.Navigation("Nav_PlanSet");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("APT.MS.Domain.Entities.BS.T_BS_PLAN_SET_DEP_OBJECT", b =>
|
||||
@ -61141,6 +61321,10 @@ namespace APT.Data.Migrations.Migrations
|
||||
|
||||
modelBuilder.Entity("APT.MS.Domain.Entities.BS.T_BS_PLAN_SET", b =>
|
||||
{
|
||||
b.Navigation("Nav_ListArea");
|
||||
|
||||
b.Navigation("Nav_ListDepOut");
|
||||
|
||||
b.Navigation("Nav_ListSetDepObject");
|
||||
|
||||
b.Navigation("Nav_ListSetObject");
|
||||
|
||||
@ -281,6 +281,29 @@ builder.HasOne(t => t.Nav_Department).WithMany().HasForeignKey(t => t.DEPARTMENT
|
||||
builder.HasOne(t => t.Nav_CheckType).WithMany().HasForeignKey(t => t.CHECK_TYPE_ID).OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne(t => t.Nav_CheckTypeLevel).WithMany().HasForeignKey(t => t.CHECK_TYPE_LEVEL_ID).OnDelete(DeleteBehavior.Restrict);
|
||||
builder.Property(t => t.RUNDATA).HasMaxLength(500);
|
||||
builder.HasOne(t => t.Nav_UserSend).WithMany().HasForeignKey(t => t.USER_ID_SEND).OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region PlanSetArea
|
||||
public partial class BSPlanSetAreaMap :APTEntityBaseMap<T_BS_PLAN_SET_AREA>
|
||||
{
|
||||
public override void Configure(EntityTypeBuilder<T_BS_PLAN_SET_AREA> builder)
|
||||
{
|
||||
base.Configure(builder);
|
||||
builder.HasOne(t => t.Nav_PlanSet).WithMany(t=>t.Nav_ListArea).HasForeignKey(t => t.PLANSET_ID).OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne(t => t.Nav_Area).WithMany().HasForeignKey(t => t.AREA_ID).OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region PlanSetDepartmentOut
|
||||
public partial class BSPlanSetDepartmentOutMap :APTEntityBaseMap<T_BS_PLAN_SET_DEPARTMENT_OUT>
|
||||
{
|
||||
public override void Configure(EntityTypeBuilder<T_BS_PLAN_SET_DEPARTMENT_OUT> builder)
|
||||
{
|
||||
base.Configure(builder);
|
||||
builder.HasOne(t => t.Nav_PlanSet).WithMany(t=>t.Nav_ListDepOut).HasForeignKey(t => t.PLANSET_ID).OnDelete(DeleteBehavior.Restrict);
|
||||
builder.HasOne(t => t.Nav_Department).WithMany().HasForeignKey(t => t.DEPARTMENT_ID).OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -131,5 +131,31 @@ namespace APT.MS.Domain.Entities.BS
|
||||
/// </summary>
|
||||
[Description("检查部门范围")]
|
||||
public virtual ICollection<T_BS_PLAN_SET_DEP_OBJECT> Nav_ListSetDepObject { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排除组织
|
||||
/// </summary>
|
||||
[Description("排除组织")]
|
||||
public virtual ICollection<T_BS_PLAN_SET_DEPARTMENT_OUT> Nav_ListDepOut { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 检查区域
|
||||
/// </summary>
|
||||
[Description("检查区域")]
|
||||
public virtual ICollection<T_BS_PLAN_SET_AREA> Nav_ListArea { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 接收人
|
||||
/// </summary>
|
||||
[Description("接收人")]
|
||||
[DataFieldForeignKey("Nav_UserSend")]
|
||||
public Guid? USER_ID_SEND { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 接收人
|
||||
/// </summary>
|
||||
[Description("接收人")]
|
||||
public virtual T_FM_USER Nav_UserSend { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
45
APT.MS.Domain/Entities/BS/T_BS_PLAN_SET_AREA.cs
Normal file
45
APT.MS.Domain/Entities/BS/T_BS_PLAN_SET_AREA.cs
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.MS.Domain.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace APT.MS.Domain.Entities.BS
|
||||
{
|
||||
/// <summary>
|
||||
/// 制定任务区域
|
||||
/// </summary>
|
||||
[Description("制定任务区域")]
|
||||
public class T_BS_PLAN_SET_AREA : MesEntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 制定任务
|
||||
/// </summary>
|
||||
[Description("制定任务")]
|
||||
[DataFieldForeignKey("Nav_PlanSet", "Nav_ListArea")]
|
||||
public Guid PLANSET_ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 导航:制定任务
|
||||
/// </summary>
|
||||
[Description("导航:制定任务")]
|
||||
public virtual T_BS_PLAN_SET Nav_PlanSet { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检查区域
|
||||
/// </summary>
|
||||
[Description("检查区域")]
|
||||
[DataFieldForeignKey("Nav_Area")]
|
||||
public Guid AREA_ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 检查区域
|
||||
/// </summary>
|
||||
[Description("检查区域")]
|
||||
public virtual HM.T_HM_RISK_AREA Nav_Area { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
45
APT.MS.Domain/Entities/BS/T_BS_PLAN_SET_DEPARTMENT_OUT.cs
Normal file
45
APT.MS.Domain/Entities/BS/T_BS_PLAN_SET_DEPARTMENT_OUT.cs
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.MS.Domain.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace APT.MS.Domain.Entities.BS
|
||||
{
|
||||
/// <summary>
|
||||
/// 制定任务排除组织
|
||||
/// </summary>
|
||||
[Description("制定任务排除组织")]
|
||||
public class T_BS_PLAN_SET_DEPARTMENT_OUT : MesEntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 制定任务
|
||||
/// </summary>
|
||||
[Description("制定任务")]
|
||||
[DataFieldForeignKey("Nav_PlanSet", "Nav_ListDepOut")]
|
||||
public Guid PLANSET_ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 导航:制定任务
|
||||
/// </summary>
|
||||
[Description("导航:制定任务")]
|
||||
public virtual T_BS_PLAN_SET Nav_PlanSet { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 责任部门(未包含下属组织 如果需要再做)
|
||||
/// </summary>
|
||||
[Description("责任部门")]
|
||||
[DataFieldForeignKey("Nav_Department")]
|
||||
public Guid DEPARTMENT_ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 责任部门(未包含下属组织 如果需要再做)
|
||||
/// </summary>
|
||||
[Description("责任部门")]
|
||||
public virtual T_FM_DEPARTMENT Nav_Department { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@ -81,18 +81,64 @@ namespace APT.BS.WebApi.Controllers.Api
|
||||
var ListSetDepObject = entity.Nav_ListSetDepObject;
|
||||
entity.Nav_ListSetDepObject = null;
|
||||
int rowIndex = 1;
|
||||
if (ListSetDepObject != null && ListSetDepObject.Any())
|
||||
foreach (var item in ListSetDepObject)
|
||||
{
|
||||
foreach (var item in ListSetDepObject)
|
||||
if (!item.DEPARTMENT_ID.HasValue)
|
||||
{
|
||||
item.CHECKOBJECT = BSMineTypeEnum.Mine;
|
||||
if (!item.DEPARTMENT_ID.HasValue)
|
||||
throw new Exception("请设置部门,行:" + rowIndex + "!");
|
||||
}
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
var listDepOut = entity.Nav_ListDepOut;
|
||||
entity.Nav_ListDepOut = null;
|
||||
if (listDepOut != null && listDepOut.Any())
|
||||
{
|
||||
foreach (var item in listDepOut)
|
||||
item.Nav_Department = null;
|
||||
}
|
||||
|
||||
var listArea = entity.Nav_ListArea;
|
||||
entity.Nav_ListArea = null;
|
||||
if (listArea != null && listArea.Any())
|
||||
{
|
||||
foreach (var item in listArea)
|
||||
item.Nav_Area = null;
|
||||
}
|
||||
if (entity.Nav_UserSend != null)
|
||||
entity.Nav_UserSend = null;
|
||||
if (entity.USER_ID_SEND.HasValue)
|
||||
{
|
||||
if (ListSetDepObject != null && ListSetDepObject.Any())
|
||||
{
|
||||
if (ListSetDepObject.Count > 1)
|
||||
{
|
||||
throw new Exception("请设置部门,行:" + rowIndex + "!");
|
||||
throw new Exception("有设置接收人时,【部门范围】最多只能设置一条信息!");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var item in ListSetDepObject)
|
||||
{
|
||||
item.CHECKOBJECT = BSMineTypeEnum.Mine;
|
||||
if (!item.DEPARTMENT_ID.HasValue)
|
||||
{
|
||||
throw new Exception("请设置部门,行:" + rowIndex + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
rowIndex++;
|
||||
}
|
||||
}
|
||||
//if (ListSetDepObject != null && ListSetDepObject.Any())
|
||||
//{
|
||||
// foreach (var item in ListSetDepObject)
|
||||
// {
|
||||
// if (!item.DEPARTMENT_ID.HasValue)
|
||||
// {
|
||||
// throw new Exception("请设置部门,行:" + rowIndex + "!");
|
||||
// }
|
||||
// rowIndex++;
|
||||
// }
|
||||
//}
|
||||
this.UnifiedCommit(() =>
|
||||
{
|
||||
if (entity != null)
|
||||
@ -101,6 +147,10 @@ namespace APT.BS.WebApi.Controllers.Api
|
||||
BantchSaveEntityNoCommit(ListSetObject);
|
||||
if (ListSetDepObject != null && ListSetDepObject.Any())
|
||||
BantchSaveEntityNoCommit(ListSetDepObject);
|
||||
if (listDepOut != null && listDepOut.Any())
|
||||
BantchSaveEntityNoCommit(listDepOut);
|
||||
if (listArea != null && listArea.Any())
|
||||
BantchSaveEntityNoCommit(listArea);
|
||||
});
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -119,6 +119,9 @@ namespace APT.BS.WebApi.Controllers.Api
|
||||
listInclude.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
listInclude.Add("Nav_ListCheckRiskArea.Nav_RiskArea");//后台开放了区域配置
|
||||
|
||||
filter.Include = listInclude;
|
||||
|
||||
T_BS_SAFE_CHECK safecheck = new T_BS_SAFE_CHECK();
|
||||
@ -126,9 +129,11 @@ namespace APT.BS.WebApi.Controllers.Api
|
||||
{
|
||||
safecheck = GetEntity<T_BS_SAFE_CHECK>(null, filter);
|
||||
}
|
||||
catch
|
||||
catch { }
|
||||
|
||||
if (safecheck == null)
|
||||
{
|
||||
return safecheck;
|
||||
safecheck = new T_BS_SAFE_CHECK();
|
||||
}
|
||||
|
||||
#region 主体的很多属性只需要显示名称 例:区域 项目等
|
||||
@ -161,9 +166,15 @@ namespace APT.BS.WebApi.Controllers.Api
|
||||
{
|
||||
isFirstEdit = true;
|
||||
}
|
||||
IEnumerable<Guid> listAreaIDLimit = null;
|
||||
if (isFirstEdit)
|
||||
{
|
||||
safecheck.Nav_ListCheckRiskArea = new List<T_BS_SAFE_CHECK_RISK_AREA>();
|
||||
if (safecheck.Nav_ListCheckRiskArea == null || !safecheck.Nav_ListCheckRiskArea.Any())
|
||||
safecheck.Nav_ListCheckRiskArea = new List<T_BS_SAFE_CHECK_RISK_AREA>();
|
||||
else
|
||||
{
|
||||
listAreaIDLimit = safecheck.Nav_ListCheckRiskArea.Select(e => e.RISK_AREA_ID);
|
||||
}
|
||||
safecheck.Nav_ListCheckProject = new List<T_BS_SAFE_CHECK_PROJECT>();
|
||||
//safecheck.Nav_ListCheckProjectCategory = new List<T_BS_SAFE_CHECK_PROJECT_CATEGORY>();
|
||||
safecheck.Nav_Files = new List<T_BS_SAFE_CHECK_FILE>();
|
||||
@ -245,11 +256,15 @@ namespace APT.BS.WebApi.Controllers.Api
|
||||
|
||||
//wyw1114-1 && e.DEPARTMENT_ID.HasValue
|
||||
//&& e.CHECK_PROJECT_ID.HasValue && e.CHECK_PROJECT_CATEGORY_ID.HasValue wyw 2023-05-15
|
||||
Expression<Func<T_BS_CHECK_MAIN, bool>> expression = e => !e.IS_DELETED && e.ENABLE_STATUS == 0 && e.CHECK_QUESTION_ID.HasValue && e.CHECK_TYPE_ID.HasValue && e.CHECK_PROJECT_ID.HasValue && e.CHECK_TYPE_ID == safecheck.CHECK_TYPE_ID && e.CHECK_TYPE_LEVEL_ID == safecheck.CHECK_TYPE_LEVEL_ID && e.Nav_ListMainDep.Any();//&& e.CHECK_PROJECT_CATEGORY_ID.HasValue
|
||||
Expression<Func<T_BS_CHECK_MAIN, bool>> expression = e => !e.IS_DELETED && e.ENABLE_STATUS == 0 && e.CHECK_QUESTION_ID.HasValue && e.CHECK_TYPE_ID.HasValue && e.CHECK_PROJECT_ID.HasValue && e.CHECK_PROJECT_CATEGORY_ID.HasValue && e.CHECK_TYPE_ID == safecheck.CHECK_TYPE_ID && e.CHECK_TYPE_LEVEL_ID == safecheck.CHECK_TYPE_LEVEL_ID && e.Nav_ListMainDep.Any();
|
||||
if (safecheck.CHECKOBJECT != 0)
|
||||
{
|
||||
expression = expression.And(e => e.CHECKOBJECT == safecheck.CHECKOBJECT);
|
||||
}
|
||||
if (listAreaIDLimit != null)
|
||||
{
|
||||
expression = expression.And(e => e.RISK_AREA_ID.HasValue && listAreaIDLimit.Contains(e.RISK_AREA_ID.Value));
|
||||
}
|
||||
|
||||
//wyw1114-1
|
||||
var listCheckMain = GetEntities(expression, null, new string[] { "Nav_RiskArea", "Nav_CheckProject", "Nav_CheckProjectCategory", "Nav_ListMainDep" }).OrderBy(e => e.RISK_AREA_ID).ThenBy(e => e.NUM);
|
||||
@ -395,6 +410,136 @@ namespace APT.BS.WebApi.Controllers.Api
|
||||
//safecheck.Nav_ListCheckProjectCategory = listProjCate;
|
||||
}
|
||||
//}
|
||||
|
||||
#region 自学习 资决策 自动加载检查人员
|
||||
|
||||
//此人 此单 前面 2 天 检查信息都一样 人员也一样 自动加载检查人员
|
||||
|
||||
if (safecheck.PLAN_SET_ID.HasValue && safecheck.DEPARTMENTID.HasValue)
|
||||
{
|
||||
BasePageFilter basePageFilter = new BasePageFilter(1, 2);
|
||||
basePageFilter.IgnoreDataRule = true;
|
||||
basePageFilter.Limit = 2;
|
||||
basePageFilter.OrgId = safecheck.ORG_ID;
|
||||
basePageFilter.Sort = "MODIFY_TIME";
|
||||
basePageFilter.Order = DbOrder.DESC;
|
||||
basePageFilter.SelectField = new string[] { "ID", "CheckUsers" };
|
||||
var results = GetOrderPageEntities<T_BS_SAFE_CHECK>(e => !e.IS_DELETED && e.CHECKTIME.HasValue && e.PLAN_SET_ID.HasValue && e.CheckUsers != null && e.PLAN_SET_ID.Value == safecheck.PLAN_SET_ID.Value && e.DEPARTMENTID.HasValue && e.DEPARTMENTID.Value == safecheck.DEPARTMENTID.Value && e.STATUSPLAN > 10, basePageFilter, null);
|
||||
if (results != null && results.Data.Any() && results.Data.Count() == 2)
|
||||
{
|
||||
List<Guid> listCheckID = results.Data.Select(e => e.ID).ToList();
|
||||
List<string> listCheckUserNames = results.Data.Select(e => e.CheckUsers).ToList();
|
||||
bool isSame = false;
|
||||
bool isAllLoad = false;//是否全部加载
|
||||
if (listCheckUserNames[0] == listCheckUserNames[1])
|
||||
{
|
||||
isSame = true;
|
||||
try
|
||||
{
|
||||
if (listCheckUserNames[0].Contains(',') && listCheckUserNames[0].Split(',', StringSplitOptions.RemoveEmptyEntries).Length == 2)
|
||||
{
|
||||
isAllLoad = true;//两个人
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] arryName1 = listCheckUserNames[0].Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] arryName2 = listCheckUserNames[1].Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (arryName1.Length == arryName2.Length)
|
||||
{
|
||||
var difftArr = arryName1.Where(e => !arryName2.Contains(e)).ToArray();
|
||||
if (difftArr == null || !difftArr.Any())
|
||||
{
|
||||
isSame = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isSame)
|
||||
{
|
||||
safecheck.CheckUsers = listCheckUserNames[0];
|
||||
|
||||
//判断做填充
|
||||
BaseFilter baseFilter = new BaseFilter(safecheck.ORG_ID);
|
||||
|
||||
baseFilter.SelectField = new string[] { "ID", "RISK_AREA_ID", "CHECK_CONTENTS_ID" };
|
||||
var listDetailsOld = GetEntities<T_BS_SAFE_CHECK_DETAIL>(e => e.SAFE_CHECK_ID == listCheckID[0], baseFilter);
|
||||
|
||||
baseFilter.SelectField = new string[] { "SAFE_CHECK_DETAIL_ID", "USER_ID", "ISMAINCHECK" };
|
||||
var listDetailUsersOld = GetEntities<T_BS_SAFE_CHECK_DETAIL_USER>(e => e.SAFE_CHECK_ID == listCheckID[0] && !e.IS_DELETED, baseFilter);
|
||||
var userIDs = listDetailUsersOld.Select(e => e.USER_ID).Distinct();
|
||||
baseFilter.SelectField = new string[] { "ID", "NAME", "CODE" };
|
||||
var listUsers = GetEntities<T_FM_USER>(e => userIDs.Contains(e.ID), baseFilter);
|
||||
T_FM_USER tUser = null;
|
||||
//检查区域
|
||||
T_BS_SAFE_CHECK_DETAIL modelDetailCheck = null;
|
||||
IOrderedEnumerable<T_BS_SAFE_CHECK_DETAIL_USER> listDetailUser = null;
|
||||
IOrderedEnumerable<T_BS_SAFE_CHECK_DETAIL_USER> listDetailUserAll = null;
|
||||
if (isAllLoad)
|
||||
{
|
||||
var detailID = listDetailUsersOld.ToList()[0].SAFE_CHECK_DETAIL_ID;
|
||||
listDetailUserAll = listDetailUsersOld.Where(e => e.SAFE_CHECK_DETAIL_ID == detailID).OrderByDescending(e => e.ISMAINCHECK).ThenBy(e => e.USER_ID);
|
||||
}
|
||||
|
||||
foreach (var item in safecheck.Nav_ListSafeCheckDetail)
|
||||
{
|
||||
if (isAllLoad)
|
||||
{
|
||||
if (item.Nav_ListCheckDetailUser == null)
|
||||
{
|
||||
item.Nav_ListCheckDetailUser = new List<T_BS_SAFE_CHECK_DETAIL_USER>();
|
||||
}
|
||||
foreach (var itemU in listDetailUserAll)
|
||||
{
|
||||
tUser = listUsers.FirstOrDefault(e => e.ID == itemU.USER_ID);
|
||||
item.Nav_ListCheckDetailUser.Add(new T_BS_SAFE_CHECK_DETAIL_USER()
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
ISMAINCHECK = itemU.ISMAINCHECK,
|
||||
//SAFE_CHECK_ID = safecheck.ID,
|
||||
SAFE_CHECK_DETAIL_ID = itemU.ID,
|
||||
USER_ID = itemU.USER_ID,
|
||||
Nav_User = tUser,
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
modelDetailCheck = listDetailsOld.FirstOrDefault(e => e.RISK_AREA_ID == item.RISK_AREA_ID && e.CHECK_CONTENTS_ID == item.CHECK_CONTENTS_ID);
|
||||
if (modelDetailCheck == null)
|
||||
continue;
|
||||
listDetailUser = listDetailUsersOld.Where(e => e.SAFE_CHECK_DETAIL_ID == modelDetailCheck.ID).OrderByDescending(e => e.ISMAINCHECK).ThenBy(e => e.USER_ID);
|
||||
foreach (var itemU in listDetailUser)
|
||||
{
|
||||
tUser = listUsers.FirstOrDefault(e => e.ID == itemU.USER_ID);
|
||||
if (tUser == null || tUser.IS_DELETED || tUser.ENABLE_STATUS == 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item.Nav_ListCheckDetailUser == null)
|
||||
{
|
||||
item.Nav_ListCheckDetailUser = new List<T_BS_SAFE_CHECK_DETAIL_USER>();
|
||||
}
|
||||
item.Nav_ListCheckDetailUser.Add(new T_BS_SAFE_CHECK_DETAIL_USER()
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
ISMAINCHECK = itemU.ISMAINCHECK,
|
||||
//SAFE_CHECK_ID = safecheck.ID,
|
||||
SAFE_CHECK_DETAIL_ID = itemU.ID,
|
||||
USER_ID = itemU.USER_ID,
|
||||
Nav_User = tUser,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
if (safecheck != null && safecheck.CHECKOBJECT.HasValue && DataHelper.GetRequestType(Request.Headers) == 2)
|
||||
{
|
||||
|
||||
@ -2229,6 +2229,216 @@ using APT.BaseData.Domain.ApiModel.PF;
|
||||
return WitEntity(null, filter);
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region PlanSetArea-制定任务区域
|
||||
/// <summary>
|
||||
/// 制定任务区域
|
||||
/// </summary>
|
||||
[Route("api/BS/PlanSetArea")]
|
||||
public partial class PlanSetAreaController : AuthorizeApiController<T_BS_PLAN_SET_AREA>
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询所有数据
|
||||
/// </summary>
|
||||
/// <param name="filter">过滤实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("Entities")]
|
||||
public JsonActionResult<IEnumerable<T_BS_PLAN_SET_AREA>> Entities([FromBody]KeywordFilter filter)
|
||||
{
|
||||
return WitEntities(null, filter);
|
||||
}
|
||||
/// <summary>
|
||||
/// 排序查询所有数据
|
||||
/// </summary>
|
||||
/// <param name="filter">过滤实体</param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpPost, Route("OrderEntities")]
|
||||
public JsonActionResult<IEnumerable<T_BS_PLAN_SET_AREA>> OrderEntities([FromBody]KeywordFilter filter)
|
||||
{
|
||||
return WitOrderEntities(null, filter);
|
||||
}
|
||||
/// <summary>
|
||||
/// 分页查询数据
|
||||
/// </summary>
|
||||
/// <param name="pageFilter">分页过滤实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("Paged")]
|
||||
public PagedActionResult<T_BS_PLAN_SET_AREA> Paged([FromBody]KeywordPageFilter pageFilter)
|
||||
{
|
||||
return WitPaged(null, pageFilter);
|
||||
}
|
||||
/// <summary>
|
||||
/// 排序分页查询数据
|
||||
/// </summary>
|
||||
/// <param name="pageFilter">分页过滤实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("OrderPaged")]
|
||||
public PagedActionResult<T_BS_PLAN_SET_AREA> OrderPaged([FromBody]KeywordPageFilter pageFilter)
|
||||
{
|
||||
return WitOrderPaged(null, pageFilter);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据主键删除数据
|
||||
/// </summary>
|
||||
/// <param name="id">主键ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet, Route("Delete")]
|
||||
public JsonActionResult<bool> Delete(string id)
|
||||
{
|
||||
return WitRealDelete(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新或新增数据
|
||||
/// </summary>
|
||||
/// <param name="entity">对象实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("Update")]
|
||||
public JsonActionResult<bool> Update([FromBody]T_BS_PLAN_SET_AREA entity)
|
||||
{
|
||||
return WitUpdate(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新
|
||||
/// </summary>
|
||||
/// <param name="entity">对象实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("BatchUpdate")]
|
||||
public JsonActionResult<bool> BatchUpdate([FromBody] BatchUpdateModel<T_BS_PLAN_SET_AREA> entity)
|
||||
{
|
||||
return WitBantchUpdate(entity?.Data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除数据
|
||||
/// </summary>
|
||||
/// <param name="ids">id字符串(id用逗号分隔)</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet, Route("BatchDelete")]
|
||||
public JsonActionResult<bool> BatchDelete(string ids)
|
||||
{
|
||||
return WitRealBatchDelete(ids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得单条实体数据
|
||||
/// </summary>
|
||||
/// <param name="filter">过滤实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("Get")]
|
||||
public JsonActionResult<T_BS_PLAN_SET_AREA> Get([FromBody] KeywordFilter filter)
|
||||
{
|
||||
return WitEntity(null, filter);
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region PlanSetDepartmentOut-制定任务排除组织
|
||||
/// <summary>
|
||||
/// 制定任务排除组织
|
||||
/// </summary>
|
||||
[Route("api/BS/PlanSetDepartmentOut")]
|
||||
public partial class PlanSetDepartmentOutController : AuthorizeApiController<T_BS_PLAN_SET_DEPARTMENT_OUT>
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询所有数据
|
||||
/// </summary>
|
||||
/// <param name="filter">过滤实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("Entities")]
|
||||
public JsonActionResult<IEnumerable<T_BS_PLAN_SET_DEPARTMENT_OUT>> Entities([FromBody]KeywordFilter filter)
|
||||
{
|
||||
return WitEntities(null, filter);
|
||||
}
|
||||
/// <summary>
|
||||
/// 排序查询所有数据
|
||||
/// </summary>
|
||||
/// <param name="filter">过滤实体</param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpPost, Route("OrderEntities")]
|
||||
public JsonActionResult<IEnumerable<T_BS_PLAN_SET_DEPARTMENT_OUT>> OrderEntities([FromBody]KeywordFilter filter)
|
||||
{
|
||||
return WitOrderEntities(null, filter);
|
||||
}
|
||||
/// <summary>
|
||||
/// 分页查询数据
|
||||
/// </summary>
|
||||
/// <param name="pageFilter">分页过滤实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("Paged")]
|
||||
public PagedActionResult<T_BS_PLAN_SET_DEPARTMENT_OUT> Paged([FromBody]KeywordPageFilter pageFilter)
|
||||
{
|
||||
return WitPaged(null, pageFilter);
|
||||
}
|
||||
/// <summary>
|
||||
/// 排序分页查询数据
|
||||
/// </summary>
|
||||
/// <param name="pageFilter">分页过滤实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("OrderPaged")]
|
||||
public PagedActionResult<T_BS_PLAN_SET_DEPARTMENT_OUT> OrderPaged([FromBody]KeywordPageFilter pageFilter)
|
||||
{
|
||||
return WitOrderPaged(null, pageFilter);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据主键删除数据
|
||||
/// </summary>
|
||||
/// <param name="id">主键ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet, Route("Delete")]
|
||||
public JsonActionResult<bool> Delete(string id)
|
||||
{
|
||||
return WitRealDelete(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新或新增数据
|
||||
/// </summary>
|
||||
/// <param name="entity">对象实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("Update")]
|
||||
public JsonActionResult<bool> Update([FromBody]T_BS_PLAN_SET_DEPARTMENT_OUT entity)
|
||||
{
|
||||
return WitUpdate(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新
|
||||
/// </summary>
|
||||
/// <param name="entity">对象实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("BatchUpdate")]
|
||||
public JsonActionResult<bool> BatchUpdate([FromBody] BatchUpdateModel<T_BS_PLAN_SET_DEPARTMENT_OUT> entity)
|
||||
{
|
||||
return WitBantchUpdate(entity?.Data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除数据
|
||||
/// </summary>
|
||||
/// <param name="ids">id字符串(id用逗号分隔)</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet, Route("BatchDelete")]
|
||||
public JsonActionResult<bool> BatchDelete(string ids)
|
||||
{
|
||||
return WitRealBatchDelete(ids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得单条实体数据
|
||||
/// </summary>
|
||||
/// <param name="filter">过滤实体</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("Get")]
|
||||
public JsonActionResult<T_BS_PLAN_SET_DEPARTMENT_OUT> Get([FromBody] KeywordFilter filter)
|
||||
{
|
||||
return WitEntity(null, filter);
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region PlanSetDepObject-制定任务部门触发范围
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
"AllConnApiUrl": "http://localhost:3116/api/OP/TenantInfo/GetAllDbConn",
|
||||
"ConnDataKey": "MHKSAQ1212010101",
|
||||
"TenantConnKey": "MHSMS"
|
||||
"Img_Local": "D:\\uploadFile\\"
|
||||
},
|
||||
"RedisConfig": {
|
||||
"RedisConnectionString": "172.21.157.142:6379,password=mhsaferedis,defaultDatabase=15",
|
||||
|
||||
@ -20,7 +20,9 @@
|
||||
"AllConnApiUrl": "http://localhost:3116/api/OP/TenantInfo/GetAllDbConn",
|
||||
"ConnDataKey": "MHKSAQ1212010101",
|
||||
"Env": "1", //1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD>Ĭ<EFBFBD><EFBFBD>0 <EFBFBD>ڻ<EFBFBD>IP
|
||||
"TenantConnKey": "PDEV1212"
|
||||
"TenantConnKey": "PDEV1212",
|
||||
"Img_Local": "C:\\release\\img\\",
|
||||
"File_DownLoad": "downLoad\\"
|
||||
},
|
||||
"RedisConfig": {
|
||||
"RedisConnectionString": "120.25.146.51:6379,password=mhsaferedis,defaultDatabase=15",
|
||||
|
||||
@ -20,7 +20,9 @@
|
||||
"ConnApiUrl": "http://172.26.13.0:3116/api/OP/TenantInfo/GetDbConn",
|
||||
"AllConnApiUrl": "http://172.26.13.0:3116/api/OP/TenantInfo/GetAllDbConn",
|
||||
"ConnDataKey": "MHKSAQ1212010101",
|
||||
"TenantConnKey": "MHSMS"
|
||||
"TenantConnKey": "MHSMS",
|
||||
"Img_Local": "C:\\release\\img\\",
|
||||
"File_DownLoad": "downLoad\\"
|
||||
},
|
||||
"RedisConfig": {
|
||||
"RedisConnectionString": "172.26.13.0:6379,password=mhsaferedis,defaultDatabase=15",
|
||||
|
||||
@ -14,7 +14,9 @@
|
||||
"ConnApiUrl": "http://localhost:3116/api/OP/TenantInfo/GetDbConn",
|
||||
"AllConnApiUrl": "http://localhost:3116/api/OP/TenantInfo/GetAllDbConn",
|
||||
"ConnDataKey": "MHKSAQ1212010101",
|
||||
"TenantConnKey": "MHSMS"
|
||||
"TenantConnKey": "MHSMS",
|
||||
"Img_Local": "C:\\release\\img\\",
|
||||
"File_DownLoad": "downLoad\\"
|
||||
},
|
||||
"RedisConfig": {
|
||||
"RedisConnectionString": "47.122.43.22:6379,password=mhsaferedis,defaultDatabase=15",
|
||||
|
||||
@ -18,7 +18,9 @@
|
||||
"WebSocketPort": "3140",
|
||||
"ConnApiUrl": "http://localhost:3116/api/OP/TenantInfo/GetDbConn",
|
||||
"ConnDataKey": "MHKSAQ1212010101",
|
||||
"TenantConnKey": "MHSMS"
|
||||
"TenantConnKey": "MHSMS",
|
||||
"Img_Local": "D:\\uploadFile\\",
|
||||
"File_DownLoad": "downLoad\\"
|
||||
},
|
||||
"RedisConfig": {
|
||||
"RedisConnectionString": "120.25.146.51:6379",
|
||||
|
||||
@ -127,7 +127,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
filter.Parameter1 = " ENABLE_STATUS = false ";
|
||||
Expression<Func<T_BS_PLAN_SET, bool>> expression = e => e.IS_DELETED == false && e.ENABLE_STATUS == 0;
|
||||
|
||||
List<T_BS_PLAN_SET> listPlanSet = this.GetOrderEntities<T_BS_PLAN_SET>(expression, filter, new string[] { "Nav_CheckType", "Nav_CheckTypeLevel.Nav_Enums", "Nav_ListSetObject", "Nav_ListSetDepObject" }).ToList();
|
||||
List<T_BS_PLAN_SET> listPlanSet = this.GetOrderEntities(expression, filter, new string[] { "Nav_CheckType", "Nav_CheckTypeLevel.Nav_Enums", "Nav_ListSetObject", "Nav_ListSetDepObject", "Nav_ListDepOut", "Nav_ListArea" }).ToList();
|
||||
|
||||
List<T_BS_PLAN_SET> listPlanSetRund = new List<T_BS_PLAN_SET>();
|
||||
|
||||
@ -258,36 +258,37 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
T_PF_APPROVAL_ROLE modelRoleHead = null;
|
||||
T_PF_APPROVAL_ROLE modelRoleSafe = null;
|
||||
|
||||
#region 审批角色判断是否完善
|
||||
#region // 审批角色判断是否完善
|
||||
|
||||
List<int> listCheckObj = listPlanSetRund.Select(e => e.PLANCHECKOBJECT).Distinct().ToList();
|
||||
if (listCheckObj.Contains(5))
|
||||
{
|
||||
modelRoleHead = GetEntity<T_PF_APPROVAL_ROLE>(e => e.NAME.Contains("负责人"));
|
||||
if (modelRoleHead == null || modelRoleHead.ID == Guid.Empty)
|
||||
{
|
||||
try
|
||||
{
|
||||
//没有找到安全员 //没有找到安全员 没用往下继续执行的必要 // 班组给班长发送待办 需要继续执行
|
||||
SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "BS002", "未找到审批角色【安全员】", null, null);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
//List<int> listCheckObj = listPlanSetRund.Select(e => e.PLANCHECKOBJECT).Distinct().ToList();
|
||||
//if (listCheckObj.Contains(5))
|
||||
//{
|
||||
// modelRoleHead = GetEntity<T_PF_APPROVAL_ROLE>(e => e.NAME.Contains("负责人"));
|
||||
// //if (modelRoleHead == null || modelRoleHead.ID == Guid.Empty)
|
||||
// //{
|
||||
// // try
|
||||
// // {
|
||||
// // //没有找到安全员 //没有找到安全员 没用往下继续执行的必要 // 班组给班长发送待办 需要继续执行
|
||||
// // SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "BS002", "未找到审批角色【负责人】", null, null);
|
||||
// // }
|
||||
// // catch { }
|
||||
// //}
|
||||
//}
|
||||
|
||||
if (listCheckObj.Contains(10))
|
||||
{
|
||||
modelRoleSafe = GetEntity<T_PF_APPROVAL_ROLE>(e => e.NAME.Contains("安全员"));
|
||||
if (modelRoleSafe == null || modelRoleSafe.ID == Guid.Empty)
|
||||
{
|
||||
try
|
||||
{
|
||||
//没有找到安全员 //没有找到安全员 没用往下继续执行的必要 // 班组给班长发送待办 需要继续执行
|
||||
SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "BS002", "未找到审批角色【安全员】", null, null);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
//if (listCheckObj.Contains(10))
|
||||
//{
|
||||
// modelRoleSafe = GetEntity<T_PF_APPROVAL_ROLE>(e => e.NAME.Contains("安全员"));
|
||||
|
||||
// //if (modelRoleSafe == null || modelRoleSafe.ID == Guid.Empty)
|
||||
// //{
|
||||
// // try
|
||||
// // {
|
||||
// // //没有找到安全员 //没有找到安全员 没用往下继续执行的必要 // 班组给班长发送待办 需要继续执行
|
||||
// // SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "BS002", "未找到审批角色【安全员】", null, null);
|
||||
// // }
|
||||
// // catch { }
|
||||
// //}
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 跑批添加数据
|
||||
@ -300,6 +301,8 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
T_BS_SAFE_CHECK modelCheck = null;
|
||||
|
||||
List<T_BS_SAFE_CHECK> listSafeCheckAdd = new List<T_BS_SAFE_CHECK>(); //需要插入数据库的安检记录
|
||||
List<T_BS_SAFE_CHECK_RISK_AREA> listArea = new List<T_BS_SAFE_CHECK_RISK_AREA>();
|
||||
T_BS_SAFE_CHECK_RISK_AREA modelArea = null;
|
||||
List<T_FM_USER> listFMUserNotice = null;//每项设置的通知人员(中间表)
|
||||
List<T_FM_DEPARTMENT> listDepartment = null;
|
||||
|
||||
@ -324,6 +327,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
List<int> listCheckObject = new List<int>();
|
||||
T_BS_PLAN_SET_OBJECT checkObject = null;
|
||||
T_BS_PLAN_SET_DEP_OBJECT checkDetObject = null;
|
||||
IEnumerable<Guid> listDepIDOut = null;
|
||||
|
||||
T_FM_DEPARTMENT depTemp = null;
|
||||
for (int i = 0; i < listPlanSetRund.Count; i++)
|
||||
@ -358,370 +362,439 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
|
||||
listFMUserNotice = new List<T_FM_USER>();
|
||||
List<DateTime> listEndTime = new List<DateTime>();
|
||||
|
||||
if (listPlanSetRund[i].Nav_ListDepOut != null && listPlanSetRund[i].Nav_ListDepOut.Any())
|
||||
listDepIDOut = listPlanSetRund[i].Nav_ListDepOut.Select(e => e.DEPARTMENT_ID);
|
||||
else
|
||||
listDepIDOut = null;
|
||||
|
||||
#region 获取通知人员
|
||||
|
||||
if (listPlanSetRund[i].PLANCHECKOBJECT == 5)//负责人
|
||||
if (listPlanSetRund[i].USER_ID_SEND.HasValue)
|
||||
{
|
||||
|
||||
//T_FM_DEPARTMENT 部门表
|
||||
//导航属性:安全员":ICollection<T_FM_DEPARTMENT_SAFEUSER> Nav_SafeUser
|
||||
//部门类型: [EnumName("HMLevleEnum")] int DEPARTMENT_TYPE
|
||||
//找到 公司 部门 车间 班组 级别 对应安全员
|
||||
DEPARTMENT_TYPE = listPlanSetRund[i].Nav_CheckTypeLevel.Nav_Enums.VALUE;//检查等级 和部门等级匹配
|
||||
|
||||
//公司级 检查 给安环部发送通知
|
||||
//其余等级的安全检查 针对生产部门
|
||||
|
||||
//需要做全检查的所有部门
|
||||
List<T_FM_DEPARTMENT> listDepartMent = null;
|
||||
Expression<Func<T_FM_DEPARTMENT, bool>> expressionDepartMent = e => !e.IS_DELETED && e.ENABLE_STATUS == 0;
|
||||
|
||||
if (listPlanSetRund[i].Nav_CheckTypeLevel.Nav_Enums.VALUE == 3)//公司级
|
||||
#region 新配置的 有指定特定人员
|
||||
DateTime dtPlanSetEndTime = NotificationTaskService.GetTaskEndTime(FMTASKTYPE.BS_SafeCheck_Make, filter.OrgId.Value, dtNow, listPlanSetRund[i].PLANCHECKFREQUENCY, null);
|
||||
T_FM_USER noticeModel = GetEntity<T_FM_USER>(listPlanSetRund[i].USER_ID_SEND.Value);
|
||||
if (noticeModel == null || noticeModel.IS_DELETED || noticeModel.ENABLE_STATUS == 1)
|
||||
{
|
||||
//安环部 部门负责人
|
||||
expressionDepartMent = expressionDepartMent.And(e => e.DEPARTMENT_STATUS == (int)FMDepartmentStatus.安全部门);
|
||||
listDepartMent = GetEntities<T_FM_DEPARTMENT>(expressionDepartMent, null, "Nav_ProdutionUnit.Nav_Enums").ToList();
|
||||
//找不到人 或者人状态不对
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
//生产部门
|
||||
expressionDepartMent = expressionDepartMent.And(e => e.DEPARTMENT_TYPE == DEPARTMENT_TYPE && e.DEPARTMENT_STATUS == (int)FMDepartmentStatus.生产部门);
|
||||
listDepartMent = GetEntities<T_FM_DEPARTMENT>(expressionDepartMent, null, "Nav_ProdutionUnit.Nav_Enums").ToList();
|
||||
|
||||
}
|
||||
|
||||
List<Guid> ListDepartMentID = new List<Guid>();
|
||||
if (listDepartMent.Count > 0)
|
||||
{
|
||||
ListDepartMentID = listDepartMent.Select(e => e.ID).ToList();
|
||||
}
|
||||
if (ListDepartMentID.Count < 1)
|
||||
{
|
||||
//没有找到部门
|
||||
|
||||
}
|
||||
|
||||
//modelRoleSafe 公司级 公司级安全员 部门级 安全员 车间级安全员 车间级 安全员
|
||||
//modelRoleSafe.DEPARTMENT_TYPE
|
||||
modelRoleHead = GetEntity<T_PF_APPROVAL_ROLE>(e => e.NAME.Contains("负责人") && e.DEPARTMENT_TYPE == DEPARTMENT_TYPE);
|
||||
if (modelRoleHead == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
//部门未找到安全员
|
||||
SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "BS002", "部门未找到到审批角色【负责人】", "DEPARTMENT_TYPE:【" + DEPARTMENT_TYPE.ToString() + "】", " T_BS_PLAN_SETID:【" + listPlanSetRund[i].ID + "】");
|
||||
}
|
||||
catch { }
|
||||
continue;
|
||||
}
|
||||
|
||||
//部门中审批角色:安全员
|
||||
List<T_FM_USER> listUSER = GetEntities<T_FM_USER>(e => e.DEPARTMENT_ID.HasValue && ListDepartMentID.Contains(e.DEPARTMENT_ID.Value) && e.Nav_ApproveRole != null && e.Nav_ApproveRole.ID == modelRoleHead.ID, null, new string[] { "Nav_ApproveRole" }).ToList();
|
||||
//&& e.Nav_ApproveRole.DEPARTMENT_TYPE == DEPARTMENT_TYPE 公司级的时候 安环部负责
|
||||
|
||||
|
||||
//查找对应设置的部门/车间/班组
|
||||
//List<T_FM_DEPARTMENT> listDepartMent = this.GetOrderEntities<T_FM_DEPARTMENT>(e => !e.IS_DELETED && e.DEPARTMENT_TYPE == DEPARTMENT_TYPE && e.ENABLE_STATUS == 0, null, new string[] { "Nav_SafeUser", "Nav_SafeUser.Nav_User" }).ToList();
|
||||
|
||||
|
||||
|
||||
#region 旧方法
|
||||
|
||||
//DateTime dtPlanSetEndTime = dtNow;
|
||||
//#region 获取 检查设置 最后时间
|
||||
//switch (listPlanSetRund[i].PLANCHECKFREQUENCY)
|
||||
//{
|
||||
// case 20: //每周
|
||||
// //周一 1 周二 2 周日 0
|
||||
// int weekDay = (int)dtNow.DayOfWeek;
|
||||
// //周一开始时间
|
||||
// DateTime dtWeekDayStart = dtNow.Date.AddDays(-1 * (weekDay == 0 ? 6 : (weekDay - 1)));
|
||||
// //本周最后时间点
|
||||
// dtPlanSetEndTime = dtWeekDayStart.AddDays(8).AddSeconds(-1);
|
||||
// break;
|
||||
// case 30:
|
||||
// //本月 最后一天
|
||||
// dtPlanSetEndTime = Convert.ToDateTime(dtNow.Year + "-" + dtNow.Month + "-01 00:00:00").AddMonths(1).AddSeconds(-1);//本月最后时间 本月初一 加一月 减 减 1秒
|
||||
// break;
|
||||
// case 40://每季度 本季度最后一天
|
||||
// int month = dtNow.Month < 4 ? 4 : (dtNow.Month < 7 ? 7 : (dtNow.Month < 10 ? 10 : 1));
|
||||
// if (month == 4 || month == 7 || month == 10)
|
||||
// {
|
||||
// dtPlanSetEndTime = Convert.ToDateTime(dtNow.Year + "-" + month + "-01 00:00:00").AddSeconds(-1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dtPlanSetEndTime = Convert.ToDateTime((dtNow.Year + 1) + "-12-31 23:59:59");
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// case 5:
|
||||
// case 10:
|
||||
// dtPlanSetEndTime = dtNow.Date.AddDays(1).AddSeconds(-1);//当天
|
||||
// break;
|
||||
//}
|
||||
//#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
DateTime dtPlanSetEndTime = NotificationTaskService.GetTaskEndTime(FMTASKTYPE.BS_SafeCheck_Make, filter.OrgId.Value, dtNow, listPlanSetRund[i].PLANCHECKFREQUENCY, null);
|
||||
|
||||
|
||||
for (int j = 0; j < listDepartMent.Count; j++)
|
||||
{
|
||||
T_FM_USER noticeModel = listUSER.Find(e => e.DEPARTMENT_ID == listDepartMent[j].ID);//如果部门有多个安全员 随机获取一个
|
||||
if (noticeModel == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
//部门未找到安全员
|
||||
SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "BS002", "部门未找到到审批角色【负责人】", "T_FM_DEPARTMENTID:【" + listDepartMent[j].ID.ToString() + "】", " T_BS_PLAN_SETID:【" + listPlanSetRund[i].ID + "】");
|
||||
}
|
||||
catch { }
|
||||
|
||||
continue; //未设置安全员信息
|
||||
}
|
||||
listFMUserNotice.Add(noticeModel);
|
||||
listDepartment.Add(listDepartMent[j]);
|
||||
listEndTime.Add(dtPlanSetEndTime);//添加结束时间
|
||||
|
||||
}
|
||||
}
|
||||
//找到对应的 添加代办 安全员 10 班长 20,
|
||||
else if (listPlanSetRund[i].PLANCHECKOBJECT == 10)//安全员(负责人)
|
||||
{
|
||||
if (listPlanSetRund == null)
|
||||
{
|
||||
//没有安全员 循环执行前已写日志
|
||||
continue;
|
||||
}
|
||||
//T_FM_DEPARTMENT 部门表
|
||||
//导航属性:安全员":ICollection<T_FM_DEPARTMENT_SAFEUSER> Nav_SafeUser
|
||||
//部门类型: [EnumName("HMLevleEnum")] int DEPARTMENT_TYPE
|
||||
//找到 公司 部门 车间 班组 级别 对应安全员
|
||||
DEPARTMENT_TYPE = listPlanSetRund[i].Nav_CheckTypeLevel.Nav_Enums.VALUE;//检查等级 和部门等级匹配
|
||||
|
||||
//公司级 检查 给安环部发送通知
|
||||
//其余等级的安全检查 针对生产部门
|
||||
|
||||
//需要做全检查的所有部门
|
||||
List<T_FM_DEPARTMENT> listDepartMent = null;
|
||||
Expression<Func<T_FM_DEPARTMENT, bool>> expressionDepartMent = e => !e.IS_DELETED && e.ENABLE_STATUS == 0;
|
||||
|
||||
if (listPlanSetRund[i].Nav_CheckTypeLevel.Nav_Enums.VALUE == 3)//公司级
|
||||
{
|
||||
//安环部 部门负责人
|
||||
expressionDepartMent = expressionDepartMent.And(e => e.DEPARTMENT_STATUS == (int)FMDepartmentStatus.安全部门);
|
||||
listDepartMent = GetEntities<T_FM_DEPARTMENT>(expressionDepartMent, null, "Nav_ProdutionUnit.Nav_Enums").ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
//生产部门
|
||||
expressionDepartMent = expressionDepartMent.And(e => e.DEPARTMENT_TYPE == DEPARTMENT_TYPE && e.DEPARTMENT_STATUS == (int)FMDepartmentStatus.生产部门);
|
||||
listDepartMent = GetEntities<T_FM_DEPARTMENT>(expressionDepartMent, null, "Nav_ProdutionUnit.Nav_Enums").ToList();
|
||||
|
||||
}
|
||||
|
||||
List<Guid> ListDepartMentID = new List<Guid>();
|
||||
if (listDepartMent.Count > 0)
|
||||
{
|
||||
ListDepartMentID = listDepartMent.Select(e => e.ID).ToList();
|
||||
}
|
||||
if (ListDepartMentID.Count < 1)
|
||||
{
|
||||
//没有找到部门
|
||||
|
||||
}
|
||||
//modelRoleSafe 公司级 公司级安全员 部门级 安全员 车间级安全员 车间级 安全员
|
||||
|
||||
//modelRoleSafe.DEPARTMENT_TYPE
|
||||
modelRoleSafe = GetEntity<T_PF_APPROVAL_ROLE>(e => e.NAME.Contains("安全员") && e.DEPARTMENT_TYPE == DEPARTMENT_TYPE);
|
||||
if (modelRoleSafe == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
//部门未找到安全员
|
||||
SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "BS002", "部门未找到到审批角色【安全员】", "DEPARTMENT_TYPE:【" + DEPARTMENT_TYPE.ToString() + "】", " T_BS_PLAN_SETID:【" + listPlanSetRund[i].ID + "】");
|
||||
}
|
||||
catch { }
|
||||
continue;
|
||||
}
|
||||
|
||||
//部门中审批角色:安全员
|
||||
List<T_FM_USER> listUSER = GetEntities<T_FM_USER>(e => e.DEPARTMENT_ID.HasValue && ListDepartMentID.Contains(e.DEPARTMENT_ID.Value) && e.Nav_ApproveRole != null && e.Nav_ApproveRole.ID == modelRoleSafe.ID, null, new string[] { "Nav_ApproveRole" }).ToList();
|
||||
//&& e.Nav_ApproveRole.DEPARTMENT_TYPE == DEPARTMENT_TYPE 公司级的时候 安环部负责
|
||||
|
||||
|
||||
//查找对应设置的部门/车间/班组
|
||||
//List<T_FM_DEPARTMENT> listDepartMent = this.GetOrderEntities<T_FM_DEPARTMENT>(e => !e.IS_DELETED && e.DEPARTMENT_TYPE == DEPARTMENT_TYPE && e.ENABLE_STATUS == 0, null, new string[] { "Nav_SafeUser", "Nav_SafeUser.Nav_User" }).ToList();
|
||||
#region 旧方法
|
||||
|
||||
//DateTime dtPlanSetEndTime = dtNow;
|
||||
|
||||
//#region 获取 检查设置 最后时间
|
||||
//// BSPLANCHECKFREQUENCYEnum
|
||||
//switch (listPlanSetRund[i].PLANCHECKFREQUENCY)
|
||||
//{
|
||||
// case 20: //每周
|
||||
// //周一 1 周二 2 周日 0
|
||||
// int weekDay = (int)dtNow.DayOfWeek;
|
||||
// //周一开始时间
|
||||
// DateTime dtWeekDayStart = dtNow.Date.AddDays(-1 * (weekDay == 0 ? 6 : (weekDay - 1)));
|
||||
// //本周最后时间点
|
||||
// dtPlanSetEndTime = dtWeekDayStart.AddDays(8).AddSeconds(-1);
|
||||
// break;
|
||||
// case 30:
|
||||
// //本月 最后一天
|
||||
// dtPlanSetEndTime = Convert.ToDateTime(dtNow.Year + "-" + dtNow.Month + "-01 00:00:00").AddMonths(1).AddSeconds(-1);//本月最后时间 本月初一 加一月 减 减 1秒
|
||||
// break;
|
||||
// case 40://每季度 本季度最后一天
|
||||
// int month = dtNow.Month < 4 ? 4 : (dtNow.Month < 7 ? 7 : (dtNow.Month < 10 ? 10 : 1));
|
||||
// if (month == 4 || month == 7 || month == 10)
|
||||
// {
|
||||
// dtPlanSetEndTime = Convert.ToDateTime(dtNow.Year + "-" + month + "-01 00:00:00").AddSeconds(-1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dtPlanSetEndTime = Convert.ToDateTime((dtNow.Year + 1) + "-12-31 23:59:59");
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// case 5:
|
||||
// case 10:
|
||||
// dtPlanSetEndTime = dtNow.Date.AddDays(1).AddSeconds(-1);//当天
|
||||
// break;
|
||||
//}
|
||||
//#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
DateTime dtPlanSetEndTime = NotificationTaskService.GetTaskEndTime(FMTASKTYPE.BS_SafeCheck_Make, filter.OrgId.Value, dtNow, listPlanSetRund[i].PLANCHECKFREQUENCY, null);
|
||||
|
||||
for (int j = 0; j < listDepartMent.Count; j++)
|
||||
{
|
||||
T_FM_USER noticeModel = listUSER.Find(e => e.DEPARTMENT_ID == listDepartMent[j].ID);//如果部门有多个安全员 随机获取一个
|
||||
if (noticeModel == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
//部门未找到安全员
|
||||
SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "BS002", "部门未找到到审批角色【安全员】", "T_FM_DEPARTMENTID:【" + listDepartMent[j].ID.ToString() + "】", " T_BS_PLAN_SETID:【" + listPlanSetRund[i].ID + "】");
|
||||
}
|
||||
catch { }
|
||||
|
||||
continue; //未设置安全员信息
|
||||
}
|
||||
listFMUserNotice.Add(noticeModel);
|
||||
listDepartment.Add(listDepartMent[j]);
|
||||
listEndTime.Add(dtPlanSetEndTime);//添加结束时间
|
||||
|
||||
}
|
||||
}
|
||||
else if (listPlanSetRund[i].PLANCHECKOBJECT == 20)//班长
|
||||
{
|
||||
//此代码不同步到 SPS
|
||||
if (listPlanSetRund[i].CHECKTIME.HasValue)
|
||||
{
|
||||
IEnumerable<Guid> listDepIDLimit = null;
|
||||
T_FM_DEPARTMENT modelDep = null;
|
||||
if (listPlanSetRund[i].Nav_ListSetDepObject != null && listPlanSetRund[i].Nav_ListSetDepObject.Any())
|
||||
{
|
||||
listDepIDLimit = listPlanSetRund[i].Nav_ListSetDepObject.Where(e => e.DEPARTMENT_ID.HasValue).Select(e => e.DEPARTMENT_ID.Value);
|
||||
}
|
||||
|
||||
IEnumerable<int> listMineTypeEnums = null;
|
||||
if (listPlanSetRund[i].Nav_ListSetObject != null && listPlanSetRund[i].Nav_ListSetObject.Any())
|
||||
{
|
||||
listMineTypeEnums = listPlanSetRund[i].Nav_ListSetObject.Select(e => (int)e.CHECKOBJECT);
|
||||
}
|
||||
//所有符合条件的班组组长
|
||||
//Nav_ListSetObject
|
||||
//Nav_ListSetDepObject
|
||||
|
||||
//找到 公司 部门 车间 班组 级别 对应安全员
|
||||
DEPARTMENT_TYPE = listPlanSetRund[i].Nav_CheckTypeLevel.Nav_Enums.VALUE;//检查等级 和部门等级匹配
|
||||
|
||||
//需要做全检查的所有部门
|
||||
List<T_FM_DEPARTMENT> listDepartMent = null;
|
||||
Expression<Func<T_FM_DEPARTMENT, bool>> expressionDepartMent = e => !e.IS_DELETED && e.ENABLE_STATUS == 0 && e.DEPARTMENT_TYPE == DEPARTMENT_TYPE && e.DEPARTMENT_STATUS == (int)FMDepartmentStatus.生产部门;
|
||||
|
||||
if (listDepIDLimit != null && listDepIDLimit.Any())
|
||||
{
|
||||
expressionDepartMent = expressionDepartMent.And(e => listDepIDLimit.Contains(e.ID));
|
||||
}
|
||||
if (listMineTypeEnums != null && listMineTypeEnums.Any())
|
||||
{
|
||||
expressionDepartMent = expressionDepartMent.And(e => e.Nav_ProdutionUnit.FirstOrDefault(e => listMineTypeEnums.Contains(e.Nav_Enums.VALUE)) != null);
|
||||
}
|
||||
//生产部门
|
||||
listDepartMent = GetEntities(expressionDepartMent, null, "Nav_ProdutionUnit.Nav_Enums").ToList();
|
||||
if (listDepartMent == null || !listDepartMent.Any())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IEnumerable<Guid> ListUserID = null;
|
||||
if (listDepartMent.Count > 0)
|
||||
{
|
||||
ListUserID = listDepartMent.Where(e => e.USER_ID.HasValue).Select(e => e.USER_ID.Value);
|
||||
}
|
||||
if (ListUserID == null || !ListUserID.Any())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
List<T_FM_USER> listUSER = GetEntities<T_FM_USER>(e => ListUserID.Contains(e.ID), null, null).ToList();
|
||||
DateTime deNowDateEnd = DateTime.Now.Date.AddDays(1).AddSeconds(-1);//今天最后1秒
|
||||
foreach (var item in listUSER)
|
||||
{
|
||||
depTemp = listDepartMent.FirstOrDefault(e => e.ID == item.DEPARTMENT_ID);
|
||||
if (depTemp != null)
|
||||
foreach (var item in listPlanSetRund[i].Nav_ListSetDepObject)
|
||||
{
|
||||
listDepartment.Add(depTemp);
|
||||
listFMUserNotice.Add(item);//班长
|
||||
listEndTime.Add(deNowDateEnd);
|
||||
if (modelDep == null && item.DEPARTMENT_ID.HasValue)
|
||||
modelDep = GetEntity<T_FM_DEPARTMENT>(item.DEPARTMENT_ID.Value, "Nav_ProdutionUnit.Nav_Enums");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//找到今天有上班的 班组 对应 班长
|
||||
//排班 T_FM_DEPARTMENT_SCHEDULING 班组T_FM_TEAM 班长CHARGE_PERSON_ID 人员Nav_ChargePerson 用户Nav_User
|
||||
|
||||
//listPlanSetRund[i].CHECKTIME "Nav_ProdutionUnit.Nav_Enums"
|
||||
List<T_FM_DEPARTMENT_SCHEDULING> listTeamScheduling = null;
|
||||
string[] pathScheduling = { "Nav_DepartMent", "Nav_Team.Nav_ChargePerson.Nav_User.Nav_Department.Nav_Enums" };//, "Nav_Team.Nav_ChargePerson.Nav_DepartMent"
|
||||
if (listPlanSetRund[i].CHECKTIME == null)
|
||||
{
|
||||
//没有检查时间 就当天 有排班
|
||||
listTeamScheduling = this.GetOrderEntities<T_FM_DEPARTMENT_SCHEDULING>(e => e.ENABLE_STATUS == 0 && e.DATE_TIME == dtFirst && e.START_TIME != e.END_TIME, null, pathScheduling).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
//有检查时间 就检查时间有排班
|
||||
ChcekDateTime = Convert.ToDateTime(dtFirst.ToString("yyyy-MM-dd") + listPlanSetRund[i].CHECKTIME.Value.ToString(" HH:mm:ss"));
|
||||
//e.Nav_DepartMent.DEPARTMENT_TYPE == 2
|
||||
listTeamScheduling = this.GetOrderEntities<T_FM_DEPARTMENT_SCHEDULING>(e => e.ENABLE_STATUS == 0 && e.DATE_TIME == dtFirst && e.START_TIME <= ChcekDateTime && e.END_TIME >= ChcekDateTime, null, pathScheduling).ToList();
|
||||
//listTeamScheduling = this.GetOrderEntities<T_FM_DEPARTMENT_SCHEDULING>(e => e.ENABLE_STATUS == 0 && e.DATE_TIME == dtFirst && e.START_TIME != e.END_TIME && e.START_TIME.Date == dtFirst.Date, null, pathScheduling).ToList();
|
||||
if (!noticeModel.DEPARTMENT_ID.HasValue)
|
||||
continue;
|
||||
modelDep = GetEntity<T_FM_DEPARTMENT>(noticeModel.DEPARTMENT_ID.Value, "Nav_ProdutionUnit.Nav_Enums");
|
||||
}
|
||||
if (modelDep == null)
|
||||
continue;
|
||||
|
||||
listFMUserNotice.Add(noticeModel);
|
||||
listDepartment.Add(modelDep);
|
||||
listEndTime.Add(dtPlanSetEndTime);//添加结束时间
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
#region 根据通知对象 获取人员信息 负责人 5 安全员 10 班长 20
|
||||
|
||||
if (listPlanSetRund[i].PLANCHECKOBJECT == 5)//负责人
|
||||
{
|
||||
|
||||
//T_FM_DEPARTMENT 部门表
|
||||
//导航属性:安全员":ICollection<T_FM_DEPARTMENT_SAFEUSER> Nav_SafeUser
|
||||
//部门类型: [EnumName("HMLevleEnum")] int DEPARTMENT_TYPE
|
||||
//找到 公司 部门 车间 班组 级别 对应安全员
|
||||
DEPARTMENT_TYPE = listPlanSetRund[i].Nav_CheckTypeLevel.Nav_Enums.VALUE;//检查等级 和部门等级匹配
|
||||
|
||||
//公司级 检查 给安环部发送通知
|
||||
//其余等级的安全检查 针对生产部门
|
||||
|
||||
//需要做全检查的所有部门
|
||||
List<T_FM_DEPARTMENT> listDepartMent = null;
|
||||
Expression<Func<T_FM_DEPARTMENT, bool>> expressionDepartMent = e => !e.IS_DELETED && e.ENABLE_STATUS == 0;
|
||||
if (listDepIDOut != null && listDepIDOut.Any())
|
||||
expressionDepartMent = expressionDepartMent.And(e => !listDepIDOut.Contains(e.ID));
|
||||
|
||||
if (listPlanSetRund[i].Nav_CheckTypeLevel.Nav_Enums.VALUE == 3)//公司级
|
||||
{
|
||||
//安环部 部门负责人
|
||||
expressionDepartMent = expressionDepartMent.And(e => e.DEPARTMENT_STATUS == (int)FMDepartmentStatus.安全部门);
|
||||
listDepartMent = GetEntities<T_FM_DEPARTMENT>(expressionDepartMent, null, "Nav_ProdutionUnit.Nav_Enums").ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
//生产部门
|
||||
expressionDepartMent = expressionDepartMent.And(e => e.DEPARTMENT_TYPE == DEPARTMENT_TYPE && e.DEPARTMENT_STATUS == (int)FMDepartmentStatus.生产部门);
|
||||
listDepartMent = GetEntities<T_FM_DEPARTMENT>(expressionDepartMent, null, "Nav_ProdutionUnit.Nav_Enums").ToList();
|
||||
|
||||
}
|
||||
|
||||
if (listTeamScheduling != null && listTeamScheduling.Count > 0)
|
||||
List<Guid> ListDepartMentID = new List<Guid>();
|
||||
if (listDepartMent.Count > 0)
|
||||
{
|
||||
for (int j = 0; j < listTeamScheduling.Count; j++)
|
||||
ListDepartMentID = listDepartMent.Select(e => e.ID).ToList();
|
||||
}
|
||||
if (ListDepartMentID.Count < 1)
|
||||
{
|
||||
//没有找到部门
|
||||
|
||||
}
|
||||
|
||||
//modelRoleSafe 公司级 公司级安全员 部门级 安全员 车间级安全员 车间级 安全员
|
||||
//modelRoleSafe.DEPARTMENT_TYPE
|
||||
modelRoleHead = GetEntity<T_PF_APPROVAL_ROLE>(e => e.NAME.Contains("负责人") && e.DEPARTMENT_TYPE == DEPARTMENT_TYPE);
|
||||
if (modelRoleHead == null)
|
||||
{
|
||||
//try
|
||||
//{
|
||||
// //部门未找到安全员
|
||||
// SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "BS002", "部门未找到到审批角色【负责人】", "DEPARTMENT_TYPE:【" + DEPARTMENT_TYPE.ToString() + "】", " T_BS_PLAN_SETID:【" + listPlanSetRund[i].ID + "】");
|
||||
//}
|
||||
//catch { }
|
||||
continue;
|
||||
}
|
||||
|
||||
//部门中审批角色:安全员
|
||||
List<T_FM_USER> listUSER = GetEntities<T_FM_USER>(e => e.DEPARTMENT_ID.HasValue && ListDepartMentID.Contains(e.DEPARTMENT_ID.Value) && e.Nav_ApproveRole != null && e.Nav_ApproveRole.ID == modelRoleHead.ID, null, new string[] { "Nav_ApproveRole" }).ToList();
|
||||
//&& e.Nav_ApproveRole.DEPARTMENT_TYPE == DEPARTMENT_TYPE 公司级的时候 安环部负责
|
||||
|
||||
|
||||
//查找对应设置的部门/车间/班组
|
||||
//List<T_FM_DEPARTMENT> listDepartMent = this.GetOrderEntities<T_FM_DEPARTMENT>(e => !e.IS_DELETED && e.DEPARTMENT_TYPE == DEPARTMENT_TYPE && e.ENABLE_STATUS == 0, null, new string[] { "Nav_SafeUser", "Nav_SafeUser.Nav_User" }).ToList();
|
||||
|
||||
|
||||
|
||||
#region //旧方法
|
||||
|
||||
//DateTime dtPlanSetEndTime = dtNow;
|
||||
//#region 获取 检查设置 最后时间
|
||||
//switch (listPlanSetRund[i].PLANCHECKFREQUENCY)
|
||||
//{
|
||||
// case 20: //每周
|
||||
// //周一 1 周二 2 周日 0
|
||||
// int weekDay = (int)dtNow.DayOfWeek;
|
||||
// //周一开始时间
|
||||
// DateTime dtWeekDayStart = dtNow.Date.AddDays(-1 * (weekDay == 0 ? 6 : (weekDay - 1)));
|
||||
// //本周最后时间点
|
||||
// dtPlanSetEndTime = dtWeekDayStart.AddDays(8).AddSeconds(-1);
|
||||
// break;
|
||||
// case 30:
|
||||
// //本月 最后一天
|
||||
// dtPlanSetEndTime = Convert.ToDateTime(dtNow.Year + "-" + dtNow.Month + "-01 00:00:00").AddMonths(1).AddSeconds(-1);//本月最后时间 本月初一 加一月 减 减 1秒
|
||||
// break;
|
||||
// case 40://每季度 本季度最后一天
|
||||
// int month = dtNow.Month < 4 ? 4 : (dtNow.Month < 7 ? 7 : (dtNow.Month < 10 ? 10 : 1));
|
||||
// if (month == 4 || month == 7 || month == 10)
|
||||
// {
|
||||
// dtPlanSetEndTime = Convert.ToDateTime(dtNow.Year + "-" + month + "-01 00:00:00").AddSeconds(-1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dtPlanSetEndTime = Convert.ToDateTime((dtNow.Year + 1) + "-12-31 23:59:59");
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// case 5:
|
||||
// case 10:
|
||||
// dtPlanSetEndTime = dtNow.Date.AddDays(1).AddSeconds(-1);//当天
|
||||
// break;
|
||||
//}
|
||||
//#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
DateTime dtPlanSetEndTime = NotificationTaskService.GetTaskEndTime(FMTASKTYPE.BS_SafeCheck_Make, filter.OrgId.Value, dtNow, listPlanSetRund[i].PLANCHECKFREQUENCY, null);
|
||||
|
||||
|
||||
for (int j = 0; j < listDepartMent.Count; j++)
|
||||
{
|
||||
T_FM_USER noticeModel = listUSER.Find(e => e.DEPARTMENT_ID == listDepartMent[j].ID);//如果部门有多个安全员 随机获取一个
|
||||
if (noticeModel == null)
|
||||
{
|
||||
chargePerson = listTeamScheduling[j].Nav_Team.Nav_ChargePerson;//班长
|
||||
//listDepartment.Add(listTeamScheduling[j].Nav_DepartMent);
|
||||
//try
|
||||
//{
|
||||
// //部门未找到安全员
|
||||
// SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "BS002", "部门未找到到审批角色【负责人】", "T_FM_DEPARTMENTID:【" + listDepartMent[j].ID.ToString() + "】", " T_BS_PLAN_SETID:【" + listPlanSetRund[i].ID + "】");
|
||||
//}
|
||||
//catch { }
|
||||
|
||||
listDepartment.Add(chargePerson.Nav_User.Nav_Department != null ? chargePerson.Nav_User.Nav_Department : listTeamScheduling[j].Nav_DepartMent); //班长所在部门 不然审批流不好找 BS034
|
||||
//listDepartment.Add(listTeamScheduling[j].Nav_DepartMent != null ? listTeamScheduling[j].Nav_DepartMent : chargePerson.Nav_DepartMent); //班长所在部门
|
||||
continue; //未设置安全员信息
|
||||
}
|
||||
listFMUserNotice.Add(noticeModel);
|
||||
listDepartment.Add(listDepartMent[j]);
|
||||
listEndTime.Add(dtPlanSetEndTime);//添加结束时间
|
||||
|
||||
listFMUserNotice.Add(chargePerson.Nav_User);//班长
|
||||
listEndTime.Add(listTeamScheduling[j].END_TIME);//默认当班结束时间
|
||||
}
|
||||
}
|
||||
//找到对应的 添加代办 安全员 10 班长 20,
|
||||
else if (listPlanSetRund[i].PLANCHECKOBJECT == 10)//安全员(负责人)
|
||||
{
|
||||
if (listPlanSetRund == null)
|
||||
{
|
||||
//没有安全员 循环执行前已写日志
|
||||
continue;
|
||||
}
|
||||
//T_FM_DEPARTMENT 部门表
|
||||
//导航属性:安全员":ICollection<T_FM_DEPARTMENT_SAFEUSER> Nav_SafeUser
|
||||
//部门类型: [EnumName("HMLevleEnum")] int DEPARTMENT_TYPE
|
||||
//找到 公司 部门 车间 班组 级别 对应安全员
|
||||
DEPARTMENT_TYPE = listPlanSetRund[i].Nav_CheckTypeLevel.Nav_Enums.VALUE;//检查等级 和部门等级匹配
|
||||
|
||||
//公司级 检查 给安环部发送通知
|
||||
//其余等级的安全检查 针对生产部门
|
||||
|
||||
//需要做全检查的所有部门
|
||||
List<T_FM_DEPARTMENT> listDepartMent = null;
|
||||
Expression<Func<T_FM_DEPARTMENT, bool>> expressionDepartMent = e => !e.IS_DELETED && e.ENABLE_STATUS == 0;
|
||||
if (listDepIDOut != null && listDepIDOut.Any())
|
||||
expressionDepartMent = expressionDepartMent.And(e => !listDepIDOut.Contains(e.ID));
|
||||
|
||||
if (listPlanSetRund[i].Nav_CheckTypeLevel.Nav_Enums.VALUE == 3)//公司级
|
||||
{
|
||||
//安环部 部门负责人
|
||||
expressionDepartMent = expressionDepartMent.And(e => e.DEPARTMENT_STATUS == (int)FMDepartmentStatus.安全部门);
|
||||
listDepartMent = GetEntities<T_FM_DEPARTMENT>(expressionDepartMent, null, "Nav_ProdutionUnit.Nav_Enums").ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
//生产部门
|
||||
expressionDepartMent = expressionDepartMent.And(e => e.DEPARTMENT_TYPE == DEPARTMENT_TYPE && e.DEPARTMENT_STATUS == (int)FMDepartmentStatus.生产部门);
|
||||
listDepartMent = GetEntities<T_FM_DEPARTMENT>(expressionDepartMent, null, "Nav_ProdutionUnit.Nav_Enums").ToList();
|
||||
|
||||
}
|
||||
|
||||
List<Guid> ListDepartMentID = new List<Guid>();
|
||||
if (listDepartMent.Count > 0)
|
||||
{
|
||||
ListDepartMentID = listDepartMent.Select(e => e.ID).ToList();
|
||||
}
|
||||
if (ListDepartMentID.Count < 1)
|
||||
{
|
||||
//没有找到部门
|
||||
|
||||
}
|
||||
//modelRoleSafe 公司级 公司级安全员 部门级 安全员 车间级安全员 车间级 安全员
|
||||
|
||||
//modelRoleSafe.DEPARTMENT_TYPE
|
||||
modelRoleSafe = GetEntity<T_PF_APPROVAL_ROLE>(e => e.NAME.Contains("安全员") && e.DEPARTMENT_TYPE == DEPARTMENT_TYPE);
|
||||
if (modelRoleSafe == null)
|
||||
{
|
||||
//try
|
||||
//{
|
||||
// //部门未找到安全员
|
||||
// SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "BS002", "部门未找到到审批角色【安全员】", "DEPARTMENT_TYPE:【" + DEPARTMENT_TYPE.ToString() + "】", " T_BS_PLAN_SETID:【" + listPlanSetRund[i].ID + "】");
|
||||
//}
|
||||
//catch { }
|
||||
continue;
|
||||
}
|
||||
|
||||
//部门中审批角色:安全员
|
||||
List<T_FM_USER> listUSER = GetEntities<T_FM_USER>(e => e.DEPARTMENT_ID.HasValue && ListDepartMentID.Contains(e.DEPARTMENT_ID.Value) && e.Nav_ApproveRole != null && e.Nav_ApproveRole.ID == modelRoleSafe.ID, null, new string[] { "Nav_ApproveRole" }).ToList();
|
||||
//&& e.Nav_ApproveRole.DEPARTMENT_TYPE == DEPARTMENT_TYPE 公司级的时候 安环部负责
|
||||
|
||||
|
||||
//查找对应设置的部门/车间/班组
|
||||
//List<T_FM_DEPARTMENT> listDepartMent = this.GetOrderEntities<T_FM_DEPARTMENT>(e => !e.IS_DELETED && e.DEPARTMENT_TYPE == DEPARTMENT_TYPE && e.ENABLE_STATUS == 0, null, new string[] { "Nav_SafeUser", "Nav_SafeUser.Nav_User" }).ToList();
|
||||
#region //旧方法
|
||||
|
||||
//DateTime dtPlanSetEndTime = dtNow;
|
||||
|
||||
//#region 获取 检查设置 最后时间
|
||||
//// BSPLANCHECKFREQUENCYEnum
|
||||
//switch (listPlanSetRund[i].PLANCHECKFREQUENCY)
|
||||
//{
|
||||
// case 20: //每周
|
||||
// //周一 1 周二 2 周日 0
|
||||
// int weekDay = (int)dtNow.DayOfWeek;
|
||||
// //周一开始时间
|
||||
// DateTime dtWeekDayStart = dtNow.Date.AddDays(-1 * (weekDay == 0 ? 6 : (weekDay - 1)));
|
||||
// //本周最后时间点
|
||||
// dtPlanSetEndTime = dtWeekDayStart.AddDays(8).AddSeconds(-1);
|
||||
// break;
|
||||
// case 30:
|
||||
// //本月 最后一天
|
||||
// dtPlanSetEndTime = Convert.ToDateTime(dtNow.Year + "-" + dtNow.Month + "-01 00:00:00").AddMonths(1).AddSeconds(-1);//本月最后时间 本月初一 加一月 减 减 1秒
|
||||
// break;
|
||||
// case 40://每季度 本季度最后一天
|
||||
// int month = dtNow.Month < 4 ? 4 : (dtNow.Month < 7 ? 7 : (dtNow.Month < 10 ? 10 : 1));
|
||||
// if (month == 4 || month == 7 || month == 10)
|
||||
// {
|
||||
// dtPlanSetEndTime = Convert.ToDateTime(dtNow.Year + "-" + month + "-01 00:00:00").AddSeconds(-1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dtPlanSetEndTime = Convert.ToDateTime((dtNow.Year + 1) + "-12-31 23:59:59");
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// case 5:
|
||||
// case 10:
|
||||
// dtPlanSetEndTime = dtNow.Date.AddDays(1).AddSeconds(-1);//当天
|
||||
// break;
|
||||
//}
|
||||
//#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
DateTime dtPlanSetEndTime = NotificationTaskService.GetTaskEndTime(FMTASKTYPE.BS_SafeCheck_Make, filter.OrgId.Value, dtNow, listPlanSetRund[i].PLANCHECKFREQUENCY, null);
|
||||
|
||||
for (int j = 0; j < listDepartMent.Count; j++)
|
||||
{
|
||||
T_FM_USER noticeModel = listUSER.Find(e => e.DEPARTMENT_ID == listDepartMent[j].ID);//如果部门有多个安全员 随机获取一个
|
||||
if (noticeModel == null)
|
||||
{
|
||||
//try
|
||||
//{
|
||||
// //部门未找到安全员
|
||||
// SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "BS002", "部门未找到到审批角色【安全员】", "T_FM_DEPARTMENTID:【" + listDepartMent[j].ID.ToString() + "】", " T_BS_PLAN_SETID:【" + listPlanSetRund[i].ID + "】");
|
||||
//}
|
||||
//catch { }
|
||||
|
||||
continue; //未设置安全员信息
|
||||
}
|
||||
listFMUserNotice.Add(noticeModel);
|
||||
listDepartment.Add(listDepartMent[j]);
|
||||
listEndTime.Add(dtPlanSetEndTime);//添加结束时间
|
||||
|
||||
}
|
||||
}
|
||||
else if (listPlanSetRund[i].PLANCHECKOBJECT == 20)//班长
|
||||
{
|
||||
//此代码不同步到 SPS
|
||||
if (listPlanSetRund[i].CHECKTIME.HasValue)
|
||||
{
|
||||
IEnumerable<Guid> listDepIDLimit = null;
|
||||
if (listPlanSetRund[i].Nav_ListSetDepObject != null && listPlanSetRund[i].Nav_ListSetDepObject.Any())
|
||||
{
|
||||
listDepIDLimit = listPlanSetRund[i].Nav_ListSetDepObject.Where(e => e.DEPARTMENT_ID.HasValue).Select(e => e.DEPARTMENT_ID.Value);
|
||||
}
|
||||
|
||||
IEnumerable<int> listMineTypeEnums = null;
|
||||
if (listPlanSetRund[i].Nav_ListSetObject != null && listPlanSetRund[i].Nav_ListSetObject.Any())
|
||||
{
|
||||
listMineTypeEnums = listPlanSetRund[i].Nav_ListSetObject.Select(e => (int)e.CHECKOBJECT);
|
||||
}
|
||||
//所有符合条件的班组组长
|
||||
//Nav_ListSetObject
|
||||
//Nav_ListSetDepObject
|
||||
|
||||
//找到 公司 部门 车间 班组 级别 对应安全员
|
||||
DEPARTMENT_TYPE = listPlanSetRund[i].Nav_CheckTypeLevel.Nav_Enums.VALUE;//检查等级 和部门等级匹配
|
||||
|
||||
//需要做全检查的所有部门
|
||||
List<T_FM_DEPARTMENT> listDepartMent = null;
|
||||
Expression<Func<T_FM_DEPARTMENT, bool>> expressionDepartMent = e => !e.IS_DELETED && e.ENABLE_STATUS == 0 && e.DEPARTMENT_TYPE == DEPARTMENT_TYPE && e.DEPARTMENT_STATUS == (int)FMDepartmentStatus.生产部门;
|
||||
|
||||
if (listDepIDLimit != null && listDepIDLimit.Any())
|
||||
{
|
||||
expressionDepartMent = expressionDepartMent.And(e => listDepIDLimit.Contains(e.ID));
|
||||
}
|
||||
if (listMineTypeEnums != null && listMineTypeEnums.Any())
|
||||
{
|
||||
expressionDepartMent = expressionDepartMent.And(e => e.Nav_ProdutionUnit.FirstOrDefault(e => listMineTypeEnums.Contains(e.Nav_Enums.VALUE)) != null);
|
||||
}
|
||||
if (listDepIDOut != null && listDepIDOut.Any())
|
||||
{
|
||||
expressionDepartMent = expressionDepartMent.And(e => !listDepIDOut.Contains(e.ID));
|
||||
}
|
||||
//生产部门
|
||||
listDepartMent = GetEntities(expressionDepartMent, null, "Nav_ProdutionUnit.Nav_Enums").ToList();
|
||||
if (listDepartMent == null || !listDepartMent.Any())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IEnumerable<Guid> ListUserID = null;
|
||||
if (listDepartMent.Count > 0)
|
||||
{
|
||||
ListUserID = listDepartMent.Where(e => e.USER_ID.HasValue).Select(e => e.USER_ID.Value);
|
||||
}
|
||||
if (ListUserID == null || !ListUserID.Any())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
List<T_FM_USER> listUSER = GetEntities<T_FM_USER>(e => ListUserID.Contains(e.ID), null, null).ToList();
|
||||
DateTime deNowDateEnd = DateTime.Now.Date.AddDays(1).AddSeconds(-1);//今天最后1秒
|
||||
foreach (var item in listUSER)
|
||||
{
|
||||
depTemp = listDepartMent.FirstOrDefault(e => e.ID == item.DEPARTMENT_ID);
|
||||
if (depTemp != null)
|
||||
{
|
||||
listDepartment.Add(depTemp);
|
||||
listFMUserNotice.Add(item);//班长
|
||||
listEndTime.Add(deNowDateEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//找到今天有上班的 班组 对应 班长
|
||||
//排班 T_FM_DEPARTMENT_SCHEDULING 班组T_FM_TEAM 班长CHARGE_PERSON_ID 人员Nav_ChargePerson 用户Nav_User
|
||||
|
||||
//listPlanSetRund[i].CHECKTIME "Nav_ProdutionUnit.Nav_Enums"
|
||||
List<T_FM_DEPARTMENT_SCHEDULING> listTeamScheduling = null;
|
||||
string[] pathScheduling = { "Nav_DepartMent", "Nav_Team.Nav_ChargePerson.Nav_User.Nav_Department.Nav_Enums" };//, "Nav_Team.Nav_ChargePerson.Nav_DepartMent"
|
||||
|
||||
Expression<Func<T_FM_DEPARTMENT_SCHEDULING, bool>> expressionSC = e => e.ENABLE_STATUS == 0;
|
||||
if (listDepIDOut != null && listDepIDOut.Any())
|
||||
{
|
||||
expressionSC = expressionSC.And(e => e.TEAM_ID.HasValue && e.Nav_Team.CHARGE_PERSON_ID.HasValue && e.Nav_Team.Nav_ChargePerson.Nav_User.DEPARTMENT_ID.HasValue && !listDepIDOut.Contains(e.Nav_Team.Nav_ChargePerson.Nav_User.DEPARTMENT_ID.Value));
|
||||
}
|
||||
|
||||
if (listPlanSetRund[i].CHECKTIME == null)
|
||||
{
|
||||
expressionSC = expressionSC.And(e => e.DATE_TIME == dtFirst && e.START_TIME != e.END_TIME);
|
||||
//没有检查时间 就当天 有排班
|
||||
listTeamScheduling = this.GetOrderEntities<T_FM_DEPARTMENT_SCHEDULING>(expressionSC, null, pathScheduling).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
//有检查时间 就检查时间有排班
|
||||
ChcekDateTime = Convert.ToDateTime(dtFirst.ToString("yyyy-MM-dd") + listPlanSetRund[i].CHECKTIME.Value.ToString(" HH:mm:ss"));
|
||||
expressionSC = expressionSC.And(e => e.DATE_TIME == dtFirst && e.START_TIME <= ChcekDateTime && e.END_TIME >= ChcekDateTime);
|
||||
//e.Nav_DepartMent.DEPARTMENT_TYPE == 2
|
||||
listTeamScheduling = this.GetOrderEntities<T_FM_DEPARTMENT_SCHEDULING>(expressionSC, null, pathScheduling).ToList();
|
||||
//listTeamScheduling = this.GetOrderEntities<T_FM_DEPARTMENT_SCHEDULING>(e => e.ENABLE_STATUS == 0 && e.DATE_TIME == dtFirst && e.START_TIME != e.END_TIME && e.START_TIME.Date == dtFirst.Date, null, pathScheduling).ToList();
|
||||
|
||||
}
|
||||
|
||||
if (listTeamScheduling != null && listTeamScheduling.Count > 0)
|
||||
{
|
||||
for (int j = 0; j < listTeamScheduling.Count; j++)
|
||||
{
|
||||
if (listTeamScheduling[j].Nav_Team.ENABLE_STATUS == 1)
|
||||
{
|
||||
continue;//是否触发任务
|
||||
}
|
||||
chargePerson = listTeamScheduling[j].Nav_Team.Nav_ChargePerson;//班长
|
||||
//listDepartment.Add(listTeamScheduling[j].Nav_DepartMent);
|
||||
|
||||
listDepartment.Add(chargePerson.Nav_User.Nav_Department != null ? chargePerson.Nav_User.Nav_Department : listTeamScheduling[j].Nav_DepartMent); //班长所在部门 不然审批流不好找 BS034
|
||||
//listDepartment.Add(listTeamScheduling[j].Nav_DepartMent != null ? listTeamScheduling[j].Nav_DepartMent : chargePerson.Nav_DepartMent); //班长所在部门
|
||||
|
||||
listFMUserNotice.Add(chargePerson.Nav_User);//班长
|
||||
listEndTime.Add(listTeamScheduling[j].END_TIME);//默认当班结束时间
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//else {//未找到通知对象 跳过 continue; }
|
||||
#endregion
|
||||
}
|
||||
//else {//未找到通知对象 跳过 continue; }
|
||||
if (listFMUserNotice.Count < 1)
|
||||
{
|
||||
//没有找到通知人员信息
|
||||
@ -735,10 +808,11 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
for (int j = 0; j < listFMUserNotice.Count; j++)
|
||||
{
|
||||
|
||||
#region 新版
|
||||
#region 获取生产单元
|
||||
|
||||
listCheckObject.Clear();
|
||||
CHECKOBJECT = 0;
|
||||
|
||||
foreach (var itemUnit in listDepartment[j].Nav_ProdutionUnit)
|
||||
{
|
||||
listCheckObject.Add(itemUnit.Nav_Enums.VALUE);
|
||||
@ -765,7 +839,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 过滤 检查范围 部门范围
|
||||
|
||||
if (listPlanSetRund[i].Nav_ListSetDepObject != null && listPlanSetRund[i].Nav_ListSetDepObject.Any())
|
||||
{
|
||||
@ -776,7 +850,6 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
CHECKOBJECT = (int)checkDetObject.CHECKOBJECT;
|
||||
}
|
||||
|
||||
|
||||
if (CHECKOBJECT == 0 && listDepartment[j].MineType.HasValue)
|
||||
{
|
||||
CHECKOBJECT = listDepartment[j].MineType.Value;
|
||||
@ -787,6 +860,10 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
continue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region model 添加
|
||||
|
||||
//添加代办
|
||||
T_BS_SAFE_CHECK modelRun = new T_BS_SAFE_CHECK();
|
||||
modelRun.ID = Guid.NewGuid();
|
||||
@ -802,7 +879,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
//modelRun.CHECKTIME = listPlanSetRund[i].CHECKTIME.HasValue ? Convert.ToDateTime(dtNow.ToString("yyyy-MM-dd ") + listPlanSetRund[i].CHECKTIME.Value.ToString("HH:mm:ss")) : DateTime.Now;
|
||||
|
||||
modelRun.CREATER_ID = listFMUserNotice[j].ID;//安全检查的创建人 就是通知人
|
||||
modelRun.CHECKOBJECT =(int) BSMineTypeEnum.Mine;// CHECKOBJECT;
|
||||
modelRun.CHECKOBJECT = (int)BSMineTypeEnum.Mine;// CHECKOBJECT;
|
||||
|
||||
modelRun.PLAN_SET_ID = listPlanSetRund[i].ID;
|
||||
modelRun.CREACTTYPE = CREACTTYPEEnum.System;// 10;//系统生成
|
||||
@ -823,12 +900,29 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
{
|
||||
modelRun.CODE = modelRun.CODE.Substring(0, 25);
|
||||
}
|
||||
|
||||
if (listPlanSetRund[i].Nav_ListArea != null && listPlanSetRund[i].Nav_ListArea.Any())
|
||||
{
|
||||
foreach (var item in listPlanSetRund[i].Nav_ListArea)
|
||||
{
|
||||
modelArea = new T_BS_SAFE_CHECK_RISK_AREA();
|
||||
modelArea.ID = Guid.NewGuid();
|
||||
modelArea.ORG_ID = filter.GetOrgId();
|
||||
modelArea.SAFE_CHECK_ID = modelRun.ID;
|
||||
modelArea.RISK_AREA_ID = item.AREA_ID;
|
||||
modelArea.CREATER_ID = modelRun.CREATER_ID;
|
||||
listArea.Add(modelArea);
|
||||
}
|
||||
}
|
||||
|
||||
listSafeCheckAdd.Add(modelRun);
|
||||
noticeDataIds.Add(modelRun.ID);
|
||||
noticeUserIds.Add(listFMUserNotice[j].ID);
|
||||
noticeUserNames.Add(listFMUserNotice[j].NAME);
|
||||
|
||||
noticeTitles.Add(modelRun.NAME + "-制定");//每天的 加上日期
|
||||
noticeTitles.Add(modelRun.NAME + "-制定");//每天的 加上日期
|
||||
|
||||
#endregion
|
||||
}
|
||||
////超时时间设置
|
||||
//if (listPlanSetRund[i].CHECKTIME.HasValue)
|
||||
@ -843,6 +937,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
|
||||
if (noticeTitles.Count > 0)
|
||||
{
|
||||
#region 安全检查数据
|
||||
if (task != null)
|
||||
{
|
||||
task.UPDATE_SUCCES_TIME = DateTime.Now;
|
||||
@ -854,6 +949,8 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
if (listSafeCheckAdd.Any())
|
||||
{
|
||||
this.BantchAddEntityNoCommit(listSafeCheckAdd);
|
||||
if (listArea != null && listArea.Any())
|
||||
BantchAddEntityNoCommit(listArea);
|
||||
if (task != null && !isUpdate)
|
||||
{
|
||||
UpdateEntityNoCommit(task);
|
||||
@ -862,6 +959,10 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
}
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
||||
#region AOP记录数据信息
|
||||
|
||||
if (HttpContext.Items.ContainsKey("Count"))
|
||||
{
|
||||
try
|
||||
@ -881,6 +982,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
// this.BantchAddEntityNoCommit(listSafeCheckAdd);
|
||||
// }
|
||||
//});
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
Loading…
Reference in New Issue
Block a user