352 lines
16 KiB
C#
352 lines
16 KiB
C#
using FineUIPro;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
public static class HSSE_Hazard_HazardRegisterService
|
|
{
|
|
#region 获取安全巡检列表信息
|
|
/// <summary>
|
|
/// 记录数
|
|
/// </summary>
|
|
public static int count
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 定义变量
|
|
/// </summary>
|
|
private static IQueryable<Model.View_Hazard_HazardRegisterList> getDataLists = from x in Funs.DB.View_Hazard_HazardRegisterList
|
|
where x.ProblemTypes == "1"
|
|
select x;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="projetcId"></param>
|
|
/// <param name="checkMan"></param>
|
|
/// <param name="type"></param>
|
|
/// <param name="workAreaName"></param>
|
|
/// <param name="responsibilityUnitName"></param>
|
|
/// <param name="startTime"></param>
|
|
/// <param name="endTime"></param>
|
|
/// <param name="startRectificationTime"></param>
|
|
/// <param name="endRectificationTime"></param>
|
|
/// <param name="states"></param>
|
|
/// <param name="personId"></param>
|
|
/// <param name="unitId"></param>
|
|
/// <param name="Grid1"></param>
|
|
/// <returns></returns>
|
|
public static IEnumerable getListData(string projectId, string checkMan, string type, string workAreaName, string responsibilityUnitName, DateTime? startTime, DateTime? endTime, DateTime? startRectificationTime, DateTime? endRectificationTime
|
|
, string states, string personId, string unitId, Grid Grid1)
|
|
{
|
|
var db= Funs.DB;
|
|
IQueryable<Model.View_Hazard_HazardRegisterList> getDataList = from x in db.View_Hazard_HazardRegisterList
|
|
where x.ProblemTypes == "1"
|
|
select x;
|
|
if (!string.IsNullOrEmpty(projectId))
|
|
{
|
|
getDataList = getDataList.Where(e => e.ProjectId == projectId);
|
|
}
|
|
if (!string.IsNullOrEmpty(checkMan))
|
|
{
|
|
getDataList = getDataList.Where(e => e.CheckManName.Contains(checkMan));
|
|
}
|
|
if (!string.IsNullOrEmpty(type))
|
|
{
|
|
getDataList = getDataList.Where(e => e.RegisterTypesName.Contains(type));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(workAreaName))
|
|
{
|
|
getDataList = getDataList.Where(e => e.WorkAreaName.Contains(workAreaName));
|
|
}
|
|
if (!string.IsNullOrEmpty(responsibilityUnitName))
|
|
{
|
|
getDataList = getDataList.Where(e => e.ResponsibilityUnitName.Contains(responsibilityUnitName));
|
|
}
|
|
if (startTime.HasValue)
|
|
{
|
|
getDataList = getDataList.Where(e => e.CheckTime >= startTime);
|
|
}
|
|
if (endTime.HasValue)
|
|
{
|
|
getDataList = getDataList.Where(e => e.CheckTime <= endTime);
|
|
}
|
|
|
|
if (startRectificationTime.HasValue)
|
|
{
|
|
getDataList = getDataList.Where(e => e.RectificationTime >= startRectificationTime);
|
|
}
|
|
if (endRectificationTime.HasValue)
|
|
{
|
|
getDataList = getDataList.Where(e => e.RectificationTime <= endRectificationTime);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(states) && states != Const._Null)
|
|
{
|
|
getDataList = getDataList.Where(e => e.States.Contains(states));
|
|
}
|
|
|
|
if (!CommonService.IsMainUnitOrAdmin(personId))
|
|
{
|
|
getDataList = getDataList.Where(e => e.ResponsibleUnit == unitId || e.SendUnitId == unitId);
|
|
}
|
|
|
|
count = getDataList.Count();
|
|
if (count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
getDataList = SortConditionHelper.SortingAndPaging(getDataList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
|
return (from x in getDataList
|
|
select new
|
|
{
|
|
x.HazardRegisterId,
|
|
x.CheckTime,
|
|
x.RegisterDef,
|
|
x.RegisterTypes2Name,
|
|
x.RegisterTypesName,
|
|
x.RegisterTypes3Name,
|
|
x.HazardValue,
|
|
x.RegisterTypes4Name,
|
|
x.WorkAreaName,
|
|
x.ResponsibilityUnitName,
|
|
x.ResponsibilityManName,
|
|
x.Rectification,
|
|
x.RectificationPeriod,
|
|
//x.CCManNames,
|
|
x.RectificationTime,
|
|
x.CheckManName,
|
|
x.RegisterDate,
|
|
x.StatesStr,
|
|
}).ToList();
|
|
}
|
|
#endregion
|
|
|
|
/// <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);
|
|
}
|
|
|
|
/// <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="hazardRegister">危险观察登记实体</param>
|
|
public static void AddHazardRegister(Model.HSSE_Hazard_HazardRegister hazardRegister)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HSSE_Hazard_HazardRegister newHazardRegister = new Model.HSSE_Hazard_HazardRegister
|
|
{
|
|
HazardRegisterId = hazardRegister.HazardRegisterId,
|
|
HazardCode = hazardRegister.HazardCode,
|
|
RegisterDate = DateTime.Now,
|
|
RegisterDef = hazardRegister.RegisterDef,
|
|
RegisterTypesId = hazardRegister.RegisterTypesId,
|
|
CheckCycle = hazardRegister.CheckCycle,
|
|
Rectification = hazardRegister.Rectification,
|
|
Place = hazardRegister.Place,
|
|
ResponsibleUnit = hazardRegister.ResponsibleUnit,
|
|
Observer = hazardRegister.Observer,
|
|
RectifiedDate = hazardRegister.RectifiedDate,
|
|
AttachUrl = hazardRegister.AttachUrl,
|
|
ProjectId = hazardRegister.ProjectId,
|
|
States = hazardRegister.States,
|
|
IsEffective = hazardRegister.IsEffective,
|
|
ResponsibleMan = hazardRegister.ResponsibleMan,
|
|
CheckManId = hazardRegister.CheckManId,
|
|
CheckTime = hazardRegister.CheckTime,
|
|
RectificationPeriod = hazardRegister.RectificationPeriod,
|
|
ImageUrl = hazardRegister.ImageUrl,
|
|
RectificationImageUrl = hazardRegister.RectificationImageUrl,
|
|
RectificationTime = hazardRegister.RectificationTime,
|
|
ConfirmMan = hazardRegister.ConfirmMan,
|
|
ConfirmDate = hazardRegister.ConfirmDate,
|
|
HandleIdea = hazardRegister.HandleIdea,
|
|
CutPayment = hazardRegister.CutPayment,
|
|
ProblemTypes = hazardRegister.ProblemTypes,
|
|
DIC_ID = hazardRegister.DIC_ID,
|
|
|
|
HazardValue = hazardRegister.HazardValue,
|
|
RegisterTypes2Id = hazardRegister.RegisterTypes2Id,
|
|
RegisterTypes3Id = hazardRegister.RegisterTypes3Id,
|
|
RegisterTypes4Id = hazardRegister.RegisterTypes4Id,
|
|
CCManIds = hazardRegister.CCManIds,
|
|
|
|
WorkPackageId = hazardRegister.WorkPackageId,
|
|
WorkPackageName = hazardRegister.WorkPackageName,
|
|
ControlId = hazardRegister.ControlId,
|
|
};
|
|
db.HSSE_Hazard_HazardRegister.InsertOnSubmit(newHazardRegister);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改危险观察登记信息
|
|
/// </summary>
|
|
/// <param name="hazardRegister">危险观察登记实体</param>
|
|
public static void UpdateHazardRegister(Model.HSSE_Hazard_HazardRegister hazardRegister)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HSSE_Hazard_HazardRegister newHazardRegister = db.HSSE_Hazard_HazardRegister.FirstOrDefault(e => e.HazardRegisterId == hazardRegister.HazardRegisterId);
|
|
if (newHazardRegister != null)
|
|
{
|
|
newHazardRegister.HazardCode = hazardRegister.HazardCode;
|
|
newHazardRegister.RegisterDef = hazardRegister.RegisterDef;
|
|
newHazardRegister.Rectification = hazardRegister.Rectification;
|
|
newHazardRegister.Place = hazardRegister.Place;
|
|
newHazardRegister.ResponsibleUnit = hazardRegister.ResponsibleUnit;
|
|
newHazardRegister.Observer = hazardRegister.Observer;
|
|
newHazardRegister.RectifiedDate = hazardRegister.RectifiedDate;
|
|
newHazardRegister.AttachUrl = hazardRegister.AttachUrl;
|
|
newHazardRegister.ProjectId = hazardRegister.ProjectId;
|
|
newHazardRegister.States = hazardRegister.States;
|
|
newHazardRegister.IsEffective = hazardRegister.IsEffective;
|
|
newHazardRegister.ResponsibleMan = hazardRegister.ResponsibleMan;
|
|
newHazardRegister.CheckManId = hazardRegister.CheckManId;
|
|
//newHazardRegister.CheckTime = hazardRegister.CheckTime;
|
|
newHazardRegister.RectificationPeriod = hazardRegister.RectificationPeriod;
|
|
newHazardRegister.ImageUrl = hazardRegister.ImageUrl;
|
|
newHazardRegister.RectificationImageUrl = hazardRegister.RectificationImageUrl;
|
|
newHazardRegister.RectificationTime = hazardRegister.RectificationTime;
|
|
newHazardRegister.ConfirmMan = hazardRegister.ConfirmMan;
|
|
newHazardRegister.ConfirmDate = hazardRegister.ConfirmDate;
|
|
newHazardRegister.HandleIdea = hazardRegister.HandleIdea;
|
|
newHazardRegister.CutPayment = hazardRegister.CutPayment;
|
|
newHazardRegister.ProblemTypes = hazardRegister.ProblemTypes;
|
|
newHazardRegister.DIC_ID = hazardRegister.DIC_ID;
|
|
newHazardRegister.HazardValue = hazardRegister.HazardValue;
|
|
newHazardRegister.RegisterTypes2Id = hazardRegister.RegisterTypes2Id;
|
|
newHazardRegister.RegisterTypes3Id = hazardRegister.RegisterTypes3Id;
|
|
newHazardRegister.RegisterTypes4Id = hazardRegister.RegisterTypes4Id;
|
|
newHazardRegister.CCManIds = hazardRegister.CCManIds;
|
|
newHazardRegister.IsUpdate = null;
|
|
newHazardRegister.WorkPackageId = newHazardRegister.WorkPackageId;
|
|
newHazardRegister.WorkPackageName = newHazardRegister.WorkPackageName;
|
|
//把附件表的路径复制过来
|
|
Model.AttachFile file = BLL.AttachFileService.GetAttachFile(hazardRegister.HazardRegisterId, Const.HSSE_HiddenRectificationListMenuId);
|
|
if (file != null)
|
|
{
|
|
newHazardRegister.ImageUrl = file.AttachUrl;
|
|
}
|
|
Model.AttachFile fileR = BLL.AttachFileService.GetAttachFile(hazardRegister.HazardRegisterId + "-R", Const.HSSE_HiddenRectificationListMenuId);
|
|
if (fileR != null)
|
|
{
|
|
newHazardRegister.RectificationImageUrl = fileR.AttachUrl;
|
|
}
|
|
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据危险观察登记主键删除一个危险观察登记信息
|
|
/// </summary>
|
|
/// <param name="hazardRegisterId">危险观察登记主键</param>
|
|
public static void DeleteHazardRegisterByHazardRegisterId(string hazardRegisterId)
|
|
{
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var hazardRegister = db.HSSE_Hazard_HazardRegister.FirstOrDefault(e => e.HazardRegisterId == hazardRegisterId);
|
|
if (hazardRegister != null)
|
|
{
|
|
try
|
|
{
|
|
BLL.UploadFileService.DeleteFile(Funs.RootPath, hazardRegister.ImageUrl);//删除整改前图片
|
|
BLL.UploadFileService.DeleteFile(Funs.RootPath, hazardRegister.RectificationImageUrl);//删除整改后图片
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
db.HSSE_Hazard_HazardRegister.DeleteOnSubmit(hazardRegister);
|
|
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="hazardRegisterId">危险观察登记主键</param>
|
|
public static void DeleteHazardRegisterByCheckSpecialId(string checkSpecialId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
List<Model.HSSE_Hazard_HazardRegister> hazardRegisters = db.HSSE_Hazard_HazardRegister.Where(e => e.CheckSpecialId == checkSpecialId).ToList();
|
|
if (hazardRegisters.Count > 0)
|
|
{
|
|
foreach (var hazardRegister in hazardRegisters)
|
|
{
|
|
if (hazardRegister.IsUpdate != true)
|
|
{
|
|
BLL.UploadFileService.DeleteFile(Funs.RootPath, hazardRegister.ImageUrl);//删除整改前图片
|
|
BLL.UploadFileService.DeleteFile(Funs.RootPath, hazardRegister.RectificationImageUrl);//删除整改后图片
|
|
db.HSSE_Hazard_HazardRegister.DeleteOnSubmit(hazardRegister);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|