2025-04-07 17:43:30 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using EmitMapper;
|
|
|
|
|
|
using FineUIPro;
|
|
|
|
|
|
using Microsoft.SqlServer.Dts.Runtime;
|
|
|
|
|
|
using Model;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BLL
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class APIHazardRegisterService
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据HazardRegisterId获取风险巡检信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="hazardRegisterId"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static Model.HazardRegisterItem getHazardRegisterByHazardRegisterId(string hazardRegisterId)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
|
|
|
|
|
{
|
|
|
|
|
|
var getHazardRegister = db.View_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == hazardRegisterId);
|
|
|
|
|
|
return ObjectMapperManager.DefaultInstance.GetMapper<Model.View_Hazard_HazardRegister, Model.HazardRegisterItem>().Map(getHazardRegister);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据projectId、states获取风险信息(状态 1:待整改;2:已整改,待确认;3:已确认,即已闭环;4:已作废)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="projectId"></param>
|
|
|
|
|
|
/// <param name="states"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static List<Model.HazardRegisterItem> getHazardRegisterByProjectIdStates(string projectId, string states, int pageIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
|
|
|
|
|
{
|
|
|
|
|
|
var hazardRegisters = (from x in db.View_Hazard_HazardRegister
|
|
|
|
|
|
where (x.ProjectId == projectId || projectId == null) && (x.States == states || states == null)
|
|
|
|
|
|
orderby x.CheckTime descending
|
|
|
|
|
|
select x).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
|
|
|
|
|
return ObjectMapperManager.DefaultInstance.GetMapper<List<Model.View_Hazard_HazardRegister>, List<Model.HazardRegisterItem>>().Map(hazardRegisters.ToList());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 安全巡检
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pageIndex"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static List<Model.HazardRegisterItem> getHazardRegisterByProjectIdStates(int pageIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
string unitName=null, unitId=null;
|
|
|
|
|
|
var getUnit = CommonService.GetIsThisUnit();
|
|
|
|
|
|
if (getUnit != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
unitId = getUnit.UnitId;
|
|
|
|
|
|
unitName = getUnit.UnitName;
|
|
|
|
|
|
}
|
|
|
|
|
|
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
|
|
|
|
|
{
|
|
|
|
|
|
var hazardRegisters = (from x in db.HSSE_Hazard_HazardRegister
|
|
|
|
|
|
join y in db.Base_Project on x.ProjectId equals y.ProjectId
|
|
|
|
|
|
join u in db.Base_Unit on x.ResponsibleUnit equals u.UnitId
|
|
|
|
|
|
join user in db.Sys_User on x.ResponsibleMan equals user.UserId
|
|
|
|
|
|
where x.ProjectId != null && x.States != null
|
|
|
|
|
|
select new Model.HazardRegisterItem
|
|
|
|
|
|
{
|
|
|
|
|
|
HazardRegisterId=x.HazardRegisterId,
|
|
|
|
|
|
ProjectId=x.ProjectId,
|
|
|
|
|
|
ProjectName=y.ProjectName,
|
|
|
|
|
|
ProjectAddress=y.ProjectAddress,
|
|
|
|
|
|
UnitId=unitId,
|
|
|
|
|
|
UnitName=unitName,
|
|
|
|
|
|
PUnitId=y.UnitId,
|
|
|
|
|
|
PUnitName= db.Base_Unit.First(U => y.UnitId == U.UnitId).UnitName,
|
|
|
|
|
|
States =x.States,
|
|
|
|
|
|
WorkAreaName=db.WBS_UnitWork.First(w=>x.Place == w.UnitWorkId).UnitWorkName,
|
|
|
|
|
|
CheckTime = x.CheckTime,
|
|
|
|
|
|
RegisterDef = x.RegisterDef,
|
|
|
|
|
|
RegisterTypesName=db.HSSE_Hazard_HazardRegisterTypes.First(T=>x.RegisterTypesId== T.RegisterTypesId).RegisterTypesName,
|
|
|
|
|
|
Rectification=x.Rectification,
|
|
|
|
|
|
ResponsibilityUnitName =db.Base_Unit.First(U=>x.ResponsibleUnit==U.UnitId).UnitName,
|
|
|
|
|
|
ResponsibilityManName= db.Sys_User.First(User => x.ResponsibleMan ==User.UserId).UserName,
|
|
|
|
|
|
RectificationTime=x.RectificationTime,
|
|
|
|
|
|
Risk_Level = x.Risk_Level,
|
|
|
|
|
|
|
|
|
|
|
|
}).OrderBy(x=>x.CheckTime).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
|
|
|
|
|
return hazardRegisters;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存HazardRegister
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="userInfo"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static void SaveHazardRegister(Model.HazardRegisterItem hazardRegister)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
|
|
|
|
|
{
|
|
|
|
|
|
Model.HSSE_Hazard_HazardRegister newHazardRegister = new Model.HSSE_Hazard_HazardRegister
|
|
|
|
|
|
{
|
|
|
|
|
|
HazardRegisterId = hazardRegister.HazardRegisterId,
|
|
|
|
|
|
HazardCode = hazardRegister.HazardCode,
|
|
|
|
|
|
RegisterDef = hazardRegister.RegisterDef,
|
|
|
|
|
|
Rectification = hazardRegister.Rectification,
|
|
|
|
|
|
Place = hazardRegister.Place,
|
|
|
|
|
|
ResponsibleUnit = hazardRegister.ResponsibleUnit,
|
|
|
|
|
|
ProjectId = hazardRegister.ProjectId,
|
|
|
|
|
|
States = hazardRegister.States,
|
|
|
|
|
|
IsEffective = "1",
|
|
|
|
|
|
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,
|
|
|
|
|
|
RegisterTypesId = hazardRegister.RegisterTypesId,
|
|
|
|
|
|
CheckCycle = hazardRegister.CheckCycle,
|
|
|
|
|
|
SafeSupervisionIsOK = hazardRegister.SafeSupervisionIsOK,
|
|
|
|
|
|
IsWx = "Y",
|
|
|
|
|
|
CCManIds = hazardRegister.CCManIds,
|
|
|
|
|
|
Requirements = hazardRegister.Requirements,
|
2026-03-24 17:47:53 +08:00
|
|
|
|
Risk_Level = hazardRegister.Risk_Level,
|
|
|
|
|
|
PunishPerson = hazardRegister.PunishPerson,
|
2025-04-07 17:43:30 +08:00
|
|
|
|
};
|
|
|
|
|
|
var isUpdate = db.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == newHazardRegister.HazardRegisterId);
|
|
|
|
|
|
if (isUpdate == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
newHazardRegister.RegisterDate = DateTime.Now;
|
|
|
|
|
|
newHazardRegister.CheckTime = DateTime.Now;
|
|
|
|
|
|
if (string.IsNullOrEmpty(newHazardRegister.HazardRegisterId))
|
|
|
|
|
|
{
|
|
|
|
|
|
newHazardRegister.HazardRegisterId = SQLHelper.GetNewID();
|
|
|
|
|
|
}
|
|
|
|
|
|
db.HSSE_Hazard_HazardRegister.InsertOnSubmit(newHazardRegister);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (newHazardRegister.States == "2")
|
|
|
|
|
|
{
|
|
|
|
|
|
isUpdate.RectificationTime = DateTime.Now;
|
|
|
|
|
|
isUpdate.Rectification = newHazardRegister.Rectification;
|
|
|
|
|
|
isUpdate.RectificationImageUrl = newHazardRegister.RectificationImageUrl;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
isUpdate.ConfirmDate = DateTime.Now;
|
|
|
|
|
|
isUpdate.ConfirmMan = newHazardRegister.ConfirmMan;
|
|
|
|
|
|
isUpdate.HandleIdea = newHazardRegister.HandleIdea;
|
|
|
|
|
|
isUpdate.SafeSupervisionIsOK = newHazardRegister.SafeSupervisionIsOK;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
isUpdate.States = newHazardRegister.States;
|
|
|
|
|
|
isUpdate.Risk_Level = newHazardRegister.Risk_Level;
|
|
|
|
|
|
}
|
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
|
if (hazardRegister.States == Const.State_1)
|
|
|
|
|
|
{
|
|
|
|
|
|
APICommonService.SendSubscribeMessage(hazardRegister.ResponsibleMan, "安全巡检问题待整改", hazardRegister.CheckManName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", hazardRegister.CheckTime));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (hazardRegister.States == Const.State_2)
|
|
|
|
|
|
{
|
|
|
|
|
|
APICommonService.SendSubscribeMessage(hazardRegister.CheckManId, "安全巡检待复查验收", hazardRegister.ResponsibilityManName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", hazardRegister.RectificationTime));
|
2026-03-24 17:47:53 +08:00
|
|
|
|
|
|
|
|
|
|
//推送总包
|
|
|
|
|
|
var porject = BLL.ProjectService.GetProjectByProjectId(hazardRegister.ProjectId);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(porject.SubjectUnit) && !string.IsNullOrWhiteSpace(porject.SubjectProject))
|
|
|
|
|
|
{
|
|
|
|
|
|
var register = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByHazardRegisterId(hazardRegister.HazardRegisterId);
|
|
|
|
|
|
if (register != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (register.DataSource == "1")
|
|
|
|
|
|
{
|
|
|
|
|
|
//推送到总包
|
|
|
|
|
|
APIHazardRegisterSyncService.pushHazardRegisterLists(register.ProjectId, register.HazardRegisterId);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (hazardRegister.States == Const.State_3)
|
|
|
|
|
|
{
|
|
|
|
|
|
//闭环后通过的并且有处罚人的数据添加到奖罚管理中
|
|
|
|
|
|
if (!string.IsNullOrEmpty(hazardRegister.PunishPerson))
|
|
|
|
|
|
{
|
|
|
|
|
|
Model.Check_RewardAndPunish RewardAndPunish = new Model.Check_RewardAndPunish();
|
|
|
|
|
|
RewardAndPunish.RewardAndPunishID = SQLHelper.GetNewID(typeof(Model.Check_RewardAndPunish));
|
|
|
|
|
|
RewardAndPunish.ProjectId = hazardRegister.ProjectId;
|
|
|
|
|
|
RewardAndPunish.Type = 2;
|
|
|
|
|
|
RewardAndPunish.ResponseUnit = hazardRegister.ResponsibleUnit;
|
|
|
|
|
|
RewardAndPunish.Date = hazardRegister.CheckTime;
|
|
|
|
|
|
RewardAndPunish.Description = hazardRegister.RegisterDef;
|
|
|
|
|
|
RewardAndPunish.CreateMan = hazardRegister.CheckManId;
|
|
|
|
|
|
RewardAndPunish.RewardAndPunishCode = BLL.RewardAndPunishService.getCode("1","CF");
|
|
|
|
|
|
RewardAndPunish.RewardAndPunishMan = hazardRegister.PunishPerson;
|
|
|
|
|
|
RewardAndPunish.TeamGroupId =
|
|
|
|
|
|
BLL.PersonService.GetPersonById(hazardRegister.PunishPerson).TeamGroupId;
|
|
|
|
|
|
RewardAndPunish.DataSource = "1";
|
|
|
|
|
|
RewardAndPunish.SysTemType = "1";
|
|
|
|
|
|
RewardAndPunish.HazardRegisterId = hazardRegister.HazardRegisterId;
|
|
|
|
|
|
BLL.RewardAndPunishService.AddRewardAndPunish(RewardAndPunish);
|
|
|
|
|
|
}
|
2025-04-07 17:43:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|