494 lines
16 KiB
C#
494 lines
16 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Collections;
|
|||
|
using Model;
|
|||
|
using static BLL.SafetyResponsibilitiesService;
|
|||
|
|
|||
|
namespace BLL.OfficeCheck.Inspect;
|
|||
|
|
|||
|
public class Inspect_InspectionService
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 添加安全专项检查
|
|||
|
/// </summary>
|
|||
|
/// <param name="Inspection"></param>
|
|||
|
public static void AddInspection(Model.Inspect_Inspection Inspection)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
Model.Inspect_Inspection newInspection = new Model.Inspect_Inspection
|
|||
|
{
|
|||
|
InspectionId = Inspection.InspectionId,
|
|||
|
InspectionCode = Inspection.InspectionCode,
|
|||
|
ProjectId = Inspection.ProjectId,
|
|||
|
PersonResponsible = Inspection.PersonResponsible,
|
|||
|
InspectTime = Inspection.InspectTime,
|
|||
|
Description = Inspection.Description,
|
|||
|
States = Inspection.States,
|
|||
|
InspectMan = Inspection.InspectMan,
|
|||
|
InspectType = Inspection.InspectType,
|
|||
|
InspectItemSetId = Inspection.InspectItemSetId,
|
|||
|
ProjectStates = Inspection.ProjectStates,
|
|||
|
CreateMan = Inspection.CreateMan,
|
|||
|
CreateTime = Inspection.CreateTime,
|
|||
|
|
|||
|
};
|
|||
|
db.Inspect_Inspection.InsertOnSubmit(newInspection);
|
|||
|
db.SubmitChanges();
|
|||
|
// ////增加一条编码记录
|
|||
|
// BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.SafetyInspectionMenuId,
|
|||
|
// Inspection.ProjectId, null, Inspection.InspectionId, new DateTime());
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 添加安全专项明细检查
|
|||
|
/// </summary>
|
|||
|
/// <param name="Inspection"></param>
|
|||
|
public static void AddInspectionItem(Model.Inspect_InspectionItem InspectionItem)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
Model.Inspect_InspectionItem newInspectionItem = new Model.Inspect_InspectionItem
|
|||
|
{
|
|||
|
InspectionItemId = InspectionItem.InspectionItemId,
|
|||
|
InspectionId = InspectionItem.InspectionId,
|
|||
|
InspectionItemCode = InspectionItem.InspectionItemCode,
|
|||
|
ProjectId = InspectionItem.ProjectId,
|
|||
|
InspectionDescribe = InspectionItem.InspectionDescribe,
|
|||
|
PhotoUrl = InspectionItem.PhotoUrl,
|
|||
|
VideoUrl = InspectionItem.VideoUrl,
|
|||
|
EvaluateResults = InspectionItem.EvaluateResults,
|
|||
|
TimeLimited = InspectionItem.TimeLimited,
|
|||
|
RectificationDescription = InspectionItem.RectificationDescription,
|
|||
|
RectificationResults = InspectionItem.RectificationResults,
|
|||
|
States = InspectionItem.States,
|
|||
|
CompileMan = InspectionItem.CompileMan,
|
|||
|
CompileTime = InspectionItem.CompileTime,
|
|||
|
|
|||
|
};
|
|||
|
db.Inspect_InspectionItem.InsertOnSubmit(newInspectionItem);
|
|||
|
db.SubmitChanges();
|
|||
|
// ////增加一条编码记录
|
|||
|
// BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.ProjectSafetyInspectionMenuId,
|
|||
|
// InspectionItem.ProjectId, null, InspectionItem.InspectionItemId, new DateTime());
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据专项检查ID获取专项明细信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="CheckSpecialName"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static Model.Inspect_InspectionItem GetInspectItemsById(string InspectionItemId)
|
|||
|
{
|
|||
|
return Funs.DB.Inspect_InspectionItem.FirstOrDefault(e => e.InspectionItemId == InspectionItemId);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据专项检查ID获取专项信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="CheckSpecialName"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static Model.Inspect_Inspection GetInspectionByInspectionId(string InspectionId)
|
|||
|
{
|
|||
|
return Funs.DB.Inspect_Inspection.FirstOrDefault(e => e.InspectionId == InspectionId);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 修改安全专项检查
|
|||
|
/// </summary>
|
|||
|
/// <param name="Inspection"></param>
|
|||
|
public static void UpdateInspection(Model.Inspect_Inspection Inspection)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
Model.Inspect_Inspection newInspection =
|
|||
|
db.Inspect_Inspection.FirstOrDefault(e => e.InspectionId == Inspection.InspectionId);
|
|||
|
if (newInspection != null)
|
|||
|
{
|
|||
|
newInspection.InspectionCode = Inspection.InspectionCode;
|
|||
|
//newInspection.ProjectId = Inspection.ProjectId;
|
|||
|
newInspection.PersonResponsible = Inspection.PersonResponsible;
|
|||
|
newInspection.InspectTime = Inspection.InspectTime;
|
|||
|
newInspection.Description = Inspection.Description;
|
|||
|
newInspection.States = Inspection.States;
|
|||
|
newInspection.InspectMan = Inspection.InspectMan;
|
|||
|
newInspection.InspectType = Inspection.InspectType;
|
|||
|
newInspection.InspectItemSetId = Inspection.InspectItemSetId;
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 修改安全专项检查明细
|
|||
|
/// </summary>
|
|||
|
/// <param name="Inspection"></param>
|
|||
|
public static void UpdateInspectionItem(Model.Inspect_InspectionItem InspectionItem)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
Model.Inspect_InspectionItem newInspectionItem =
|
|||
|
db.Inspect_InspectionItem.FirstOrDefault(e => e.InspectionItemId == InspectionItem.InspectionItemId);
|
|||
|
if (newInspectionItem != null)
|
|||
|
{
|
|||
|
newInspectionItem.InspectionItemCode = InspectionItem.InspectionItemCode;
|
|||
|
//newInspection.ProjectId = Inspection.ProjectId;
|
|||
|
newInspectionItem.InspectionDescribe = InspectionItem.InspectionDescribe;
|
|||
|
newInspectionItem.PhotoUrl = InspectionItem.PhotoUrl;
|
|||
|
newInspectionItem.VideoUrl = InspectionItem.VideoUrl;
|
|||
|
newInspectionItem.EvaluateResults = InspectionItem.EvaluateResults;
|
|||
|
newInspectionItem.TimeLimited = InspectionItem.TimeLimited;
|
|||
|
newInspectionItem.RectificationDescription = InspectionItem.RectificationDescription;
|
|||
|
newInspectionItem.RectificationResults = InspectionItem.RectificationResults;
|
|||
|
newInspectionItem.States = InspectionItem.States;
|
|||
|
newInspectionItem.CompileMan = InspectionItem.CompileMan;
|
|||
|
newInspectionItem.CompileTime = InspectionItem.CompileTime;
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据专项检查ID删除对应专项检查记录信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="superviseCheckReportId"></param>
|
|||
|
public static void DeleteInspectionById(string InspectionId)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
var q = (from x in db.Inspect_Inspection where x.InspectionId == InspectionId select x).FirstOrDefault();
|
|||
|
if (q != null)
|
|||
|
{
|
|||
|
///删除编码表记录
|
|||
|
BLL.CodeRecordsService.DeleteCodeRecordsByDataId(q.InspectionId);
|
|||
|
////删除附件表
|
|||
|
BLL.CommonService.DeleteAttachFileById(q.InspectionId);
|
|||
|
////删除审核流程表
|
|||
|
BLL.CommonService.DeleteFlowOperateByID(q.InspectionId);
|
|||
|
//删除明细
|
|||
|
var list = (from x in db.Inspect_InspectionItem where x.InspectionId == InspectionId select x).ToList();
|
|||
|
list.ForEach(e => { db.Inspect_InspectionItem.DeleteOnSubmit(e); });
|
|||
|
db.Inspect_Inspection.DeleteOnSubmit(q);
|
|||
|
}
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 根据专项明细ID删除对应信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="superviseCheckReportId"></param>
|
|||
|
public static void DeleteInspectItemsById(string InspectionItemId)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
var q = (from x in db.Inspect_InspectionItem where x.InspectionItemId == InspectionItemId select x).FirstOrDefault();
|
|||
|
if (q != null)
|
|||
|
{
|
|||
|
db.Inspect_InspectionItem.DeleteOnSubmit(q);
|
|||
|
}
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 根据专项检查ID删除对应专项检查明细记录信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="superviseCheckReportId"></param>
|
|||
|
public static void DeleteInspectionItemsByInspectionId(string InspectionId)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
var list = (from x in db.Inspect_InspectionItem where x.InspectionId == InspectionId select x).ToList();
|
|||
|
list.ForEach(e => { db.Inspect_InspectionItem.DeleteOnSubmit(e); });
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取专检集合
|
|||
|
/// </summary>
|
|||
|
/// <param name="SafetyResponsibilitiesId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static List<InspectionDto> GetInspectionList(string? ProjectId,string States,string? PersonResponsible,int PageNumber, int PageSize)
|
|||
|
{
|
|||
|
|
|||
|
var getDataLists = (from x in Funs.DB.Inspect_Inspection
|
|||
|
join user in Funs.DB.Sys_User on x.InspectMan equals user.UserId into userJoin1
|
|||
|
from subUser1 in userJoin1.DefaultIfEmpty()
|
|||
|
join user in Funs.DB.Sys_User on x.CreateMan equals user.UserId into userJoin2
|
|||
|
from subUser2 in userJoin2.DefaultIfEmpty()
|
|||
|
join user in Funs.DB.Sys_User on x.PersonResponsible equals user.UserId into userJoin3
|
|||
|
from subUser3 in userJoin3.DefaultIfEmpty()
|
|||
|
join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into project
|
|||
|
from pro in project.DefaultIfEmpty()
|
|||
|
select new InspectionDto
|
|||
|
{
|
|||
|
InspectionId = x.InspectionId,
|
|||
|
InspectionCode = x.InspectionCode,
|
|||
|
ProjectId = x.ProjectId,
|
|||
|
ProjectName = pro.ProjectName,
|
|||
|
PersonResponsible = x.PersonResponsible,
|
|||
|
PersonResponsibleName = subUser3.UserName,
|
|||
|
InspectTime = x.InspectTime,
|
|||
|
Description = x.Description,
|
|||
|
States = x.States,
|
|||
|
InspectMan = subUser1.UserName,
|
|||
|
InspectManId = x.InspectMan,
|
|||
|
InspectType = x.InspectType,
|
|||
|
InspectItemSetId = x.InspectItemSetId,
|
|||
|
CreateMan = subUser2.UserName,
|
|||
|
CreateTime = x.CreateTime,
|
|||
|
});
|
|||
|
if (!string.IsNullOrEmpty(ProjectId))
|
|||
|
{
|
|||
|
getDataLists = getDataLists.Where(q => q.ProjectId == ProjectId);
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(States))
|
|||
|
{
|
|||
|
getDataLists = getDataLists.Where(q => q.States == States);
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(PersonResponsible))
|
|||
|
{
|
|||
|
getDataLists = getDataLists.Where(q => q.PersonResponsible == PersonResponsible);
|
|||
|
}
|
|||
|
|
|||
|
if (PageNumber > 0 && PageSize > 0)
|
|||
|
{
|
|||
|
getDataLists = getDataLists.Skip((PageNumber - 1) * PageSize).Take(PageSize);
|
|||
|
}
|
|||
|
return getDataLists.ToList();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取专检明细集合
|
|||
|
/// </summary>
|
|||
|
/// <param name="SafetyResponsibilitiesId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static List<InspectionItemDto> GetInspectionItemList(string InspectionId, int PageNumber, int PageSize)
|
|||
|
{
|
|||
|
|
|||
|
List<InspectionItemDto> getDataLists = (from x in Funs.DB.Inspect_InspectionItem
|
|||
|
join user in Funs.DB.Sys_User on x.CompileMan equals user.UserId into userJoin1
|
|||
|
from subUser1 in userJoin1.DefaultIfEmpty()
|
|||
|
join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into project
|
|||
|
from pro in project.DefaultIfEmpty()
|
|||
|
where x.InspectionId == InspectionId
|
|||
|
select new InspectionItemDto
|
|||
|
{
|
|||
|
InspectionItemId = x.InspectionItemId,
|
|||
|
InspectionId = x.InspectionId,
|
|||
|
InspectionItemCode = x.InspectionItemCode,
|
|||
|
ProjectId = x.ProjectId,
|
|||
|
ProjectName = pro.ProjectName,
|
|||
|
InspectionDescribe = x.InspectionDescribe,
|
|||
|
PhotoUrl = x.PhotoUrl,
|
|||
|
VideoUrl = x.VideoUrl,
|
|||
|
EvaluateResults = x.EvaluateResults,
|
|||
|
TimeLimited = x.TimeLimited,
|
|||
|
RectificationDescription = x.RectificationDescription,
|
|||
|
RectificationResults = x.RectificationResults,
|
|||
|
States = x.States,
|
|||
|
CompileMan = subUser1.UserName,
|
|||
|
CompileTime = x.CompileTime,
|
|||
|
}).ToList();
|
|||
|
if (PageNumber > 0 && PageSize > 0)
|
|||
|
{
|
|||
|
getDataLists = getDataLists.Skip((PageNumber - 1) * PageSize).Take(PageSize).ToList();
|
|||
|
}
|
|||
|
return getDataLists;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据专项检查ID获取专项明细检查信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="CheckSpecialName"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static List<Model.Inspect_InspectionItem> GetInspectItemsByInspectionId(string InspectionId)
|
|||
|
{
|
|||
|
var list = (from x in Funs.DB.Inspect_InspectionItem
|
|||
|
where x.InspectionId == InspectionId
|
|||
|
select x).ToList();
|
|||
|
return list;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public class InspectionDto
|
|||
|
{
|
|||
|
|
|||
|
public string InspectionId
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string InspectionCode
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string ProjectId
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
public string ProjectName
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string PersonResponsible
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
public string PersonResponsibleName
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public System.Nullable<System.DateTime> InspectTime
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string Description
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string States
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string InspectMan
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string InspectManId
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string InspectType
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
public string InspectItemSetId
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
public string CreateMan
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
public System.Nullable<System.DateTime> CreateTime
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public class InspectionItemDto
|
|||
|
{
|
|||
|
|
|||
|
public string InspectionItemId
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string InspectionId
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string InspectionItemCode
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string ProjectId
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
public string ProjectName
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string InspectionDescribe
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string PhotoUrl
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string VideoUrl
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public string EvaluateResults
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
public System.Nullable<System.DateTime> TimeLimited
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
public string RectificationDescription
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
public string RectificationResults
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
public string States
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
public string CompileMan
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
public System.Nullable<System.DateTime> CompileTime
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|