Files
xinjiang/SGGL/BLL/HSSE/HiddenInspection/HSSE_Hazard_HazardRegisterService.cs
T
2026-04-08 14:03:39 +08:00

217 lines
9.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Web.UI.WebControls;
namespace BLL
{
public static class HSSE_Hazard_HazardRegisterService
{
/// <summary>
/// 根据危险观察登记主键获取危险观察登记信息
/// </summary>
/// <param name="hazardRegisterId">危险观察登记主键</param>
/// <returns>危险观察登记信息</returns>
public static Model.HSSE_Hazard_HazardRegister GetHazardRegisterByHazardRegisterId(string hazardRegisterId)
{
return Funs.DB.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == hazardRegisterId);
}
public static Model.HSSE_Hazard_HazardRegister GetHazardRegisterByCheckItemDetailId(string CheckItemDetailId)
{
return Funs.DB.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == CheckItemDetailId || x.CheckItemDetailId == CheckItemDetailId);
}
/// <summary>
/// 获取项目风险列表
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
public static List<Model.HSSE_Hazard_HazardRegister> GetHazardRegisterListByProjectId(string projectId)
{
return (from x in Funs.DB.HSSE_Hazard_HazardRegister where x.ProjectId == projectId select x).ToList();
}
/// <summary>
/// 增加危险观察登记信息
/// </summary>
/// <param name="model">危险观察登记实体</param>
public static void AddHazardRegister(Model.HSSE_Hazard_HazardRegister model)
{
Model.CNPCDB db = Funs.DB;
Model.HSSE_Hazard_HazardRegister newModel = new Model.HSSE_Hazard_HazardRegister();
newModel.HazardRegisterId = model.HazardRegisterId;
newModel.HazardCode = model.HazardCode;
newModel.RegisterDate = DateTime.Now;
newModel.RegisterDef = model.RegisterDef;
newModel.RegisterTypesId = model.RegisterTypesId;
newModel.CheckCycle = model.CheckCycle;
newModel.Rectification = model.Rectification;
newModel.Place = model.Place;
newModel.ResponsibleUnit = model.ResponsibleUnit;
newModel.Observer = model.Observer;
newModel.RectifiedDate = model.RectifiedDate;
newModel.AttachUrl = model.AttachUrl;
newModel.ProjectId = model.ProjectId;
newModel.States = model.States;
newModel.IsEffective = model.IsEffective;
newModel.ResponsibleMan = model.ResponsibleMan;
newModel.CheckSpecialId = model.CheckSpecialId;
newModel.CheckManId = model.CheckManId;
newModel.CheckTime = model.CheckTime;
newModel.RectificationPeriod = model.RectificationPeriod;
newModel.ImageUrl = model.ImageUrl;
newModel.RectificationImageUrl = model.RectificationImageUrl;
newModel.RectificationTime = model.RectificationTime;
newModel.ConfirmMan = model.ConfirmMan;
newModel.ConfirmDate = model.ConfirmDate;
newModel.HandleIdea = model.HandleIdea;
newModel.CutPayment = model.CutPayment;
newModel.ProblemTypes = model.ProblemTypes;
newModel.DIC_ID = model.DIC_ID;
newModel.Risk_Level = model.Risk_Level;
newModel.Requirements = model.Requirements;
newModel.ControlId = model.ControlId;
newModel.CheckItemDetailId = model.CheckItemDetailId;
newModel.CompanyTrainingItemId = model.CompanyTrainingItemId;
db.HSSE_Hazard_HazardRegister.InsertOnSubmit(newModel);
db.SubmitChanges();
}
/// <summary>
/// 修改危险观察登记信息
/// </summary>
/// <param name="model">危险观察登记实体</param>
public static void UpdateHazardRegister(Model.HSSE_Hazard_HazardRegister model)
{
Model.CNPCDB db = Funs.DB;
Model.HSSE_Hazard_HazardRegister newModel = db.HSSE_Hazard_HazardRegister.FirstOrDefault(e => e.HazardRegisterId == model.HazardRegisterId);
if (newModel != null)
{
newModel.HazardCode = model.HazardCode;
newModel.RegisterDef = model.RegisterDef;
newModel.Rectification = model.Rectification;
newModel.Place = model.Place;
newModel.ResponsibleUnit = model.ResponsibleUnit;
newModel.Observer = model.Observer;
newModel.RectifiedDate = model.RectifiedDate;
newModel.AttachUrl = model.AttachUrl;
newModel.ProjectId = model.ProjectId;
newModel.States = model.States;
newModel.IsEffective = model.IsEffective;
newModel.ResponsibleMan = model.ResponsibleMan;
newModel.CheckManId = model.CheckManId;
//newModel.CheckTime = model.CheckTime;
newModel.RectificationPeriod = model.RectificationPeriod;
newModel.ImageUrl = model.ImageUrl;
newModel.RectificationImageUrl = model.RectificationImageUrl;
newModel.RectificationTime = model.RectificationTime;
newModel.ConfirmMan = model.ConfirmMan;
newModel.ConfirmDate = model.ConfirmDate;
newModel.HandleIdea = model.HandleIdea;
newModel.CutPayment = model.CutPayment;
newModel.ProblemTypes = model.ProblemTypes;
newModel.DIC_ID = model.DIC_ID;
newModel.CheckItemDetailId = model.CheckItemDetailId;
newModel.RegisterTypesId = model.RegisterTypesId;
newModel.Risk_Level = model.Risk_Level;
newModel.Requirements = model.Requirements;
newModel.CompanyTrainingItemId = model.CompanyTrainingItemId;
//把附件表的路径复制过来
Model.AttachFile file = BLL.AttachFileService.GetAttachFile(model.HazardRegisterId, Const.HSSE_HiddenRectificationListMenuId);
if (file != null)
{
newModel.ImageUrl = file.AttachUrl;
}
Model.AttachFile fileR = BLL.AttachFileService.GetAttachFile(model.HazardRegisterId + "-R", Const.HSSE_HiddenRectificationListMenuId);
if (fileR != null)
{
newModel.RectificationImageUrl = fileR.AttachUrl;
}
db.SubmitChanges();
}
}
/// <summary>
/// 根据危险观察登记主键删除一个危险观察登记信息
/// </summary>
/// <param name="hazardRegisterId">危险观察登记主键</param>
public static void DeleteHazardRegisterByHazardRegisterId(string hazardRegisterId)
{
Model.CNPCDB db = Funs.DB;
Model.HSSE_Hazard_HazardRegister model = db.HSSE_Hazard_HazardRegister.FirstOrDefault(e => e.HazardRegisterId == hazardRegisterId);
if (model != null)
{
try
{
BLL.UploadFileService.DeleteFile(Funs.RootPath, model.ImageUrl);//删除整改前图片
BLL.UploadFileService.DeleteFile(Funs.RootPath, model.RectificationImageUrl);//删除整改后图片
}
catch (Exception)
{
}
db.HSSE_Hazard_HazardRegister.DeleteOnSubmit(model);
db.SubmitChanges();
}
}
/// <summary>
/// 对单位分组查询危险观察登记信息并
/// </summary>
/// <returns>危险观察登记信息</returns>
public static ListItem[] GetResponsibleUnitList(string projectId)
{
var q = (from x in Funs.DB.HSSE_Hazard_HazardRegister where x.ProjectId == projectId group x by x.ResponsibleUnit into x select new { ResponsibleUnit = x.Key }).ToList();
ListItem[] list = new ListItem[q.Count()];
for (int i = 0; i < q.Count(); i++)
{
list[i] = new ListItem(BLL.UnitService.GetUnitByUnitId(q[i].ResponsibleUnit).UnitName ?? "", q[i].ResponsibleUnit.ToString());
}
return list;
}
/// <summary>
/// 获取危险观察登记状态集合
/// </summary>
/// <returns>危险观察登记状态集合</returns>
public static List<Model.HandleStep> GetStatesList()
{
List<Model.HandleStep> handleSteps = new List<Model.HandleStep>();
Model.HandleStep handleStep1 = new Model.HandleStep();
handleStep1.Id = "1";
handleStep1.Name = "待整改";
handleSteps.Add(handleStep1);
Model.HandleStep handleStep2 = new Model.HandleStep();
handleStep2.Id = "2";
handleStep2.Name = "已整改";
handleSteps.Add(handleStep2);
Model.HandleStep handleStep3 = new Model.HandleStep();
handleStep3.Id = "3";
handleStep3.Name = "已闭环";
handleSteps.Add(handleStep3);
Model.HandleStep handleStep4 = new Model.HandleStep();
handleStep4.Id = "4";
handleStep4.Name = "已作废";
handleSteps.Add(handleStep4);
return handleSteps;
}
/// <summary>
/// 根据时间段获取巡检信息集合
/// </summary>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <param name="projectId"></param>
/// <returns></returns>
public static int GetCountByCheckTime(DateTime startTime, DateTime endTime, string projectId)
{
return (from x in Funs.DB.HSSE_Hazard_HazardRegister where x.CheckTime >= startTime && x.CheckTime < endTime && x.ProjectId == projectId select x).Count();
}
}
}