From 138692e94b7bba100c25b1b969da5eb1a80307f0 Mon Sep 17 00:00:00 2001
From: 10191 <506754232@qq.com>
Date: Thu, 28 Mar 2024 10:20:29 +0800
Subject: [PATCH 1/2] 111
---
SGGL/BLL/API/HSSE/APIHazardListService.cs | 398 +++++++++++++++++-
.../APIItem/HSSE/HazardListSelectedItem.cs | 45 ++
SGGL/Model/APIItem/HSSE/ReEvaluator.cs | 141 +++++++
.../APIItem/HSSE/RoutingInspectionItem.cs | 185 ++++++++
SGGL/Model/Model.csproj | 2 +
.../Controllers/HSSE/HazardListController.cs | 185 ++++++++
6 files changed, 952 insertions(+), 4 deletions(-)
create mode 100644 SGGL/Model/APIItem/HSSE/ReEvaluator.cs
create mode 100644 SGGL/Model/APIItem/HSSE/RoutingInspectionItem.cs
diff --git a/SGGL/BLL/API/HSSE/APIHazardListService.cs b/SGGL/BLL/API/HSSE/APIHazardListService.cs
index 616fcdf5..cdb376ee 100644
--- a/SGGL/BLL/API/HSSE/APIHazardListService.cs
+++ b/SGGL/BLL/API/HSSE/APIHazardListService.cs
@@ -31,7 +31,7 @@ namespace BLL
CompileManName = db.Sys_User.First(u => u.UserId == x.CompileMan).UserName,
CompileDate = string.Format("{0:yyyy-MM-dd}", x.CompileDate),
WorkStageIds = x.WorkStage,
- WorkStageNames = WorkStageService.getWorkStageNamesWorkStageIdsForApi(x.WorkStage),
+ WorkStageNames = WorkStageService.getWorkStageNamesWorkStageIds(x.WorkStage),
Contents = x.Contents,
WorkAreaName = x.WorkAreaName,
IdentificationDate = string.Format("{0:yyyy-MM-dd}", x.IdentificationDate),
@@ -68,7 +68,7 @@ namespace BLL
CompileManName = db.Sys_User.First(u => u.UserId == x.CompileMan).UserName,
CompileDate = string.Format("{0:yyyy-MM-dd}", x.CompileDate),
WorkStageIds = x.WorkStage,
- WorkStageNames = WorkStageService.getWorkStageNamesWorkStageIdsForApi(x.WorkStage),
+ WorkStageNames = WorkStageService.getWorkStageNamesWorkStageIds(x.WorkStage),
Contents = x.Contents,
WorkAreaName = x.WorkAreaName,
IdentificationDate = string.Format("{0:yyyy-MM-dd}", x.IdentificationDate),
@@ -98,7 +98,7 @@ namespace BLL
select new Model.HazardListSelectedItem
{
HazardId = x.HazardId,
- WorkStageName = WorkStageService.getWorkStageNamesWorkStageIdsForApi(x.WorkStage),
+ WorkStageName = WorkStageService.getWorkStageNamesWorkStageIds(x.WorkStage),
SupHazardListTypeName = db.Technique_HazardListType.First(z => z.HazardListTypeId == y.SupHazardListTypeId).HazardListTypeName,
HazardListTypeName = y.HazardListTypeName,
HazardCode = y.HazardListTypeCode,
@@ -116,6 +116,396 @@ namespace BLL
return getHazardList.ToList();
}
}
- #endregion
+ #endregion
+
+ #region 获取风险等级列表信息
+ ///
+ /// 获取风险等级列表信息
+ ///
+ ///
+ public static List getRiskLevel()
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ {
+ var getRiskLevel = from x in db.Base_RiskLevel
+ orderby x.RiskLevel
+ select new Model.BaseInfoItem
+ {
+ BaseInfoId = x.RiskLevelId,
+ BaseInfoCode = (x.RiskLevel ?? 0).ToString(),
+ BaseInfoName = x.RiskLevelName,
+ };
+ return getRiskLevel.ToList();
+ }
+ }
+ #endregion
+
+ #region 根据HazardListId获取危险源辨识评价明细信息
+ ///
+ /// 根据HazardListId获取危险源辨识评价明细信息
+ ///
+ ///
+ ///
+ public static List getHazardItemInfo(string hazardSelectedItemId)
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ {
+ var getHazardList = from x in db.Hazard_HazardSelectedItem
+ join y in db.Technique_HazardListType on x.HazardListTypeId equals y.HazardListTypeId
+ where x.HazardSelectedItemId == hazardSelectedItemId
+ orderby x.HazardListTypeId descending
+ select new Model.HazardListSelectedItem
+ {
+ HazardSelectedItemId = hazardSelectedItemId,
+ HazardId = x.HazardId,
+ WorkStageName = WorkStageService.getWorkStageNamesWorkStageIds(x.WorkStage),
+ SupHazardListTypeName = db.Technique_HazardListType.First(z => z.HazardListTypeId == y.SupHazardListTypeId).HazardListTypeName,
+ HazardListTypeName = y.HazardListTypeName,
+ HazardCode = y.HazardListTypeCode,
+ HazardItems = x.HazardItems,
+ DefectsType = x.DefectsType,
+ MayLeadAccidents = x.MayLeadAccidents,
+ HelperMethod = x.HelperMethod,
+ HazardJudge_L = x.HazardJudge_L,
+ HazardJudge_E = x.HazardJudge_E,
+ HazardJudge_C = x.HazardJudge_C,
+ HazardJudge_D = x.HazardJudge_D,
+ HazardLevel = x.HazardLevel,
+ ControlMeasures = x.ControlMeasures,
+ DutyPersonId = x.DutyPerson,
+ DutyPersonName = UserService.getUserNamesUserIds(x.DutyPerson),
+ PatrolPlanId = (from z in db.Hazard_PatrolPlan where z.HazardSelectedItemId == hazardSelectedItemId && z.CheckDate == null select z.PatrolPlanId).FirstOrDefault(),
+ Position = x.Position,
+ };
+ return getHazardList.ToList();
+ }
+ }
+ #endregion
+
+ #region 保存风险巡检记录明细项
+ ///
+ /// 保存风险巡检记录明细项
+ ///
+ ///
+ public static string SaveRoutingInspection(Model.RoutingInspectionItem newDetail)
+ {
+ string message = string.Empty;
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ {
+ var oldP = db.Hazard_PatrolPlan.FirstOrDefault(x => x.HazardSelectedItemId == newDetail.HazardSelectedItemId && x.CheckDate == null);
+ if (oldP != null)
+ {
+ Model.Hazard_RoutingInspection newRoutingInspection = new Model.Hazard_RoutingInspection
+ {
+ RoutingInspectionId = SQLHelper.GetNewID(),
+ HazardSelectedItemId = newDetail.HazardSelectedItemId,
+ PatrolManId = newDetail.PatrolManId,
+ PatrolTime = Funs.GetNewDateTimeOrNow(newDetail.PatrolTime),
+ PatrolResult = Convert.ToInt32(newDetail.PatrolResult),
+ OldRiskLevel = db.Hazard_PatrolPlan.FirstOrDefault(x => x.HazardSelectedItemId == newDetail.HazardSelectedItemId && x.CheckDate == null).HazardLevel,
+ ControlMeasures = newDetail.ControlMeasures,
+ DealReason = newDetail.DealReason,
+ RiskManId = newDetail.RiskManId,
+ PatrolPlanId = db.Hazard_PatrolPlan.FirstOrDefault(x => x.HazardSelectedItemId == newDetail.HazardSelectedItemId && x.CheckDate == null).PatrolPlanId,
+ };
+ Model.Hazard_PatrolPlan p = BLL.Hazard_PatrolPlanService.GetPatrolPlanByPatrolPlanId(newRoutingInspection.PatrolPlanId);
+ db.Hazard_RoutingInspection.InsertOnSubmit(newRoutingInspection);
+ db.SubmitChanges();
+ ////保存附件
+ if (!string.IsNullOrEmpty(newDetail.AttachUrl))
+ {
+ UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(newDetail.AttachUrl, 10, null), newDetail.AttachUrl, Const.ProjectRiskControlMenuId, newRoutingInspection.RoutingInspectionId);
+ }
+ else
+ {
+ CommonService.DeleteAttachFileById(Const.ProjectRiskControlMenuId, newRoutingInspection.RoutingInspectionId);
+ }
+ p.CheckDate = newRoutingInspection.PatrolTime;
+ p.State = "1"; //已巡检
+ if (newRoutingInspection.PatrolTime > p.LimitCheckDate)
+ {
+ p.State = "2"; //超期巡检
+ }
+ BLL.Hazard_PatrolPlanService.UpdatePatrolPlan(p);
+ var ps = BLL.Hazard_PatrolPlanService.GetBeforePatrolPlansByCheckDate(newDetail.HazardSelectedItemId, p.CheckDate.Value);
+ Model.Hazard_HazardSelectedItem selectedItem = BLL.Hazard_HazardSelectedItemService.GetHazardSelectedItemByHazardSelectedItemId(p.HazardSelectedItemId);
+ foreach (var item in ps)
+ {
+ item.CheckDate = p.CheckDate;
+ item.State = "3"; //超期未巡检
+ BLL.Hazard_PatrolPlanService.UpdatePatrolPlan(item);
+ }
+ string str = string.Empty;
+ if (newDetail.PatrolResult == "0") //原状态
+ {
+ //巡检计划
+ Model.Hazard_PatrolPlan plan = new Model.Hazard_PatrolPlan();
+ plan.PatrolPlanId = SQLHelper.GetNewID();
+ plan.HazardSelectedItemId = newDetail.HazardSelectedItemId;
+ plan.HazardLevel = p.HazardLevel;
+ plan.DutyPerson = newDetail.RiskManId;
+ plan.Days = p.Days;
+ plan.CheckStartDate = p.CheckStartDate;
+ plan.LimitCheckDate = p.LimitCheckDate.Value.AddDays(p.Days.Value);
+ plan.State = "0";
+ Model.Hazard_PatrolPlan oldPlan = BLL.Hazard_PatrolPlanService.GetPatrolPlanByHazardSelectedItemIdAndLimitCheckDate(newDetail.HazardSelectedItemId, plan.LimitCheckDate);
+ if (oldPlan == null)
+ {
+ BLL.Hazard_PatrolPlanService.AddPatrolPlan(plan);
+ }
+ }
+ else if (newDetail.PatrolResult == "1") //二次评估
+ {
+ //二次评价记录
+ Model.Hazard_RiskEvaluationRecord record = new Model.Hazard_RiskEvaluationRecord();
+ record.LECItemRecordId = SQLHelper.GetNewID();
+ record.DataId = newDetail.HazardSelectedItemId;
+ record.DataType = "Project";
+ record.Evaluatorld = newDetail.RiskManId;
+ BLL.RiskEvaluationRecordService.AddRiskEvaluationRecord(record);
+ if (newDetail.RiskManId == newDetail.CurrUserId)
+ {
+ str = "1|" + newDetail.HazardSelectedItemId + "|" + record.LECItemRecordId;
+ }
+ }
+ else if (newDetail.PatrolResult == "2") //下整改单
+ {
+ //巡检计划
+ Model.Hazard_PatrolPlan plan = new Model.Hazard_PatrolPlan();
+ plan.PatrolPlanId = SQLHelper.GetNewID();
+ plan.HazardSelectedItemId = newDetail.HazardSelectedItemId;
+ plan.HazardLevel = p.HazardLevel;
+ plan.DutyPerson = newDetail.RiskManId;
+ plan.Days = p.Days;
+ plan.CheckStartDate = p.CheckStartDate;
+ plan.LimitCheckDate = p.LimitCheckDate.Value.AddDays(p.Days.Value);
+ plan.State = "0";
+ Model.Hazard_PatrolPlan oldPlan = BLL.Hazard_PatrolPlanService.GetPatrolPlanByHazardSelectedItemIdAndLimitCheckDate(newDetail.HazardSelectedItemId, plan.LimitCheckDate);
+ if (oldPlan == null)
+ {
+ BLL.Hazard_PatrolPlanService.AddPatrolPlan(plan);
+ }
+ str = "2|" + newDetail.HazardSelectedItemId;
+ }
+ else if (newDetail.PatrolResult == "-1") //消除
+ {
+ selectedItem.IsStart = false;
+ selectedItem.State = "0";
+ BLL.Hazard_HazardSelectedItemService.UpdateHazardSelectedItem(selectedItem);
+ }
+ }
+ else
+ {
+ message = "尚未生成巡检计划!";
+ }
+ }
+ return message;
+ }
+ #endregion
+
+ #region 根据主键ID获取二次评估详细信息
+ ///
+ /// 根据主键ID获取二次评估详细信息
+ ///
+ ///
+ ///
+ public static List getReEvaluatorInfo(string LECItemRecordId)
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ {
+ var getHazardList = from x in db.Hazard_RiskEvaluationRecord
+ where x.LECItemRecordId == LECItemRecordId
+ orderby x.DataId descending
+ select new Model.ReEvaluator
+ {
+ LECItemRecordId = LECItemRecordId,
+ HazardSelectedItemId = x.DataId,
+ Evaluatorld = x.Evaluatorld,
+ };
+ return getHazardList.ToList();
+ }
+ }
+ #endregion
+
+ #region 保存二次评估明细项
+ ///
+ /// 保存二次评估明细项
+ ///
+ ///
+ public static void SaveReEvaluator(Model.ReEvaluator newDetail)
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ {
+ Model.Hazard_HazardSelectedItem item = BLL.Hazard_HazardSelectedItemService.GetHazardSelectedItemByHazardSelectedItemId(newDetail.HazardSelectedItemId);
+ if (item != null)
+ {
+ item.HazardJudge_L = newDetail.HazardJudge_L;
+ item.HazardJudge_E = newDetail.HazardJudge_E;
+ item.HazardJudge_C = newDetail.HazardJudge_C;
+ item.HazardJudge_D = newDetail.HazardJudge_D;
+ item.HazardLevel = newDetail.HazardLevel;
+ item.ControlMeasures = newDetail.ControlMeasures;
+ item.IsStart = newDetail.IsStart;
+ item.CheckStartDate = Funs.GetNewDateTime(newDetail.CheckStartDate);
+ if (!string.IsNullOrEmpty(newDetail.DutyPerson))
+ {
+ item.DutyPerson = newDetail.DutyPerson;
+ }
+ item.PlanExistDate = Funs.GetNewDateTime(newDetail.PlanExistDate);
+ item.State = "1"; //存在
+ if (!string.IsNullOrEmpty(newDetail.Position))
+ {
+ item.Position = newDetail.Position;
+ }
+ BLL.Hazard_HazardSelectedItemService.UpdateHazardSelectedItem(item);
+ }
+
+ var oldRecord = BLL.RiskEvaluationRecordService.GetRiskEvaluationRecordByDataIdAndEvaluatorDate(newDetail.HazardSelectedItemId);
+ if (oldRecord != null)
+ {
+ oldRecord.EvaluatorDate = DateTime.Now;
+ oldRecord.L = item.HazardJudge_L;
+ oldRecord.E = item.HazardJudge_E;
+ oldRecord.C = item.HazardJudge_C;
+ oldRecord.D = item.HazardJudge_D;
+ oldRecord.RiskLevel = item.HazardLevel;
+ oldRecord.ControlMeasures = item.ControlMeasures;
+ oldRecord.Remark = item.Remark;
+ BLL.RiskEvaluationRecordService.UpdateRiskEvaluationRecord(oldRecord);
+ }
+ else
+ {
+ Model.Hazard_RiskEvaluationRecord record = new Model.Hazard_RiskEvaluationRecord();
+ record.LECItemRecordId = SQLHelper.GetNewID();
+ record.DataId = item.HazardSelectedItemId;
+ record.DataType = "Project";
+ record.Evaluatorld = newDetail.CurrUserId;
+ record.EvaluatorDate = DateTime.Now;
+ record.L = item.HazardJudge_L;
+ record.E = item.HazardJudge_E;
+ record.C = item.HazardJudge_C;
+ record.D = item.HazardJudge_D;
+ record.RiskLevel = item.HazardLevel;
+ record.ControlMeasures = item.ControlMeasures;
+ record.Remark = item.Remark;
+ BLL.RiskEvaluationRecordService.AddRiskEvaluationRecord(record);
+ }
+ if (item.IsStart == true)
+ {
+ string[] personIds = newDetail.DutyPerson.Split(',');
+ foreach (var personId in personIds)
+ {
+ //巡检计划
+ Model.Hazard_PatrolPlan plan = new Model.Hazard_PatrolPlan();
+ plan.PatrolPlanId = SQLHelper.GetNewID();
+ plan.HazardSelectedItemId = newDetail.HazardSelectedItemId;
+ plan.HazardLevel = item.HazardLevel;
+ plan.DutyPerson = personId;
+ Model.Base_RiskLevel level = BLL.RiskLevelService.GetRiskLevel(item.HazardLevel);
+ if (level != null)
+ {
+ plan.Days = level.Days;
+ }
+ plan.CheckStartDate = item.CheckStartDate;
+ plan.LimitCheckDate = item.CheckStartDate.Value.AddDays(level.Days.Value);
+ plan.State = "0";
+ BLL.Hazard_PatrolPlanService.AddPatrolPlan(plan);
+ }
+ }
+ }
+ }
+ #endregion
+
+ #region 根据projectId获取危险源辨识评价列表
+ ///
+ /// 根据projectId获取危险源辨识评价列表
+ ///
+ ///
+ ///
+ ///
+ public static List getRoutingInspectionList(string projectId)
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ {
+ var getHazardList = from x in db.Hazard_RoutingInspection
+ join y in db.Hazard_HazardSelectedItem on x.HazardSelectedItemId equals y.HazardSelectedItemId
+ join z in db.Hazard_HazardList on y.HazardListId equals z.HazardListId
+ where z.ProjectId == projectId
+ orderby x.PatrolTime descending
+ select new Model.RoutingInspectionItem
+ {
+ RoutingInspectionId = x.RoutingInspectionId,
+ WorkAreaName = z.WorkAreaName,
+ WorkStageNames = WorkStageService.getWorkStageNamesWorkStageIds(z.WorkStage),
+ HazardListType = db.Technique_HazardListType.First(e => e.HazardListTypeId == y.HazardListTypeId).HazardListTypeName,
+ HazardItems = y.HazardItems,
+ PatrolManName = db.Sys_User.First(e => e.UserId == x.PatrolManId).UserName,
+ PatrolTime = string.Format("{0:yyyy-MM-dd}", x.PatrolTime),
+ OldRiskLevelName = db.Base_RiskLevel.First(e => e.RiskLevelId == x.OldRiskLevel).RiskLevelName,
+ RiskLevelName = db.Base_RiskLevel.First(e => e.RiskLevelId == y.HazardLevel).RiskLevelName,
+ PatrolResultStr = ConvertPatrolResultStr(x.PatrolResult),
+ };
+ return getHazardList.ToList();
+ }
+ }
+
+ private static string ConvertPatrolResultStr(int? PatrolResult)
+ {
+ if (PatrolResult != null)
+ {
+ if (PatrolResult == 0)
+ {
+ return "原状态";
+ }
+ else if (PatrolResult == 1)
+ {
+ return "二次评估";
+ }
+ else if (PatrolResult == 2)
+ {
+ return "下整改单";
+ }
+ else
+ {
+ return "消除";
+ }
+ }
+ return "";
+ }
+ #endregion
+
+ #region 根据主键ID获取已生成的风险巡检记录信息
+ ///
+ /// 根据主键ID获取已生成的风险巡检记录信息
+ ///
+ ///
+ ///
+ public static List getRoutingInspection(string routingInspectionId)
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ {
+ var getHazardList = from x in db.Hazard_RoutingInspection
+ join y in db.Hazard_HazardSelectedItem on x.HazardSelectedItemId equals y.HazardSelectedItemId
+ where x.RoutingInspectionId == routingInspectionId
+ orderby x.PatrolTime descending
+ select new Model.RoutingInspectionItem
+ {
+ RoutingInspectionId = x.RoutingInspectionId,
+ HazardCode = db.Technique_HazardList.First(z => z.HazardId == y.HazardId).HazardCode,
+ HazardSelectedItemId = x.HazardSelectedItemId,
+ HazardItems = y.HazardItems,
+ DefectsType = y.DefectsType,
+ MayLeadAccidents = y.MayLeadAccidents,
+ PatrolManId = db.Sys_User.First(z => z.UserId == x.PatrolManId).UserName,
+ PatrolTime = string.Format("{0:yyyy-MM-dd}", x.PatrolTime),
+ PatrolResult = x.PatrolResult.ToString(),
+ ControlMeasures = x.ControlMeasures,
+ DealReason = x.DealReason,
+ RiskManId = db.Sys_User.First(z => z.UserId == x.RiskManId).UserName,
+ };
+ return getHazardList.ToList();
+ }
+ }
+ #endregion
}
}
diff --git a/SGGL/Model/APIItem/HSSE/HazardListSelectedItem.cs b/SGGL/Model/APIItem/HSSE/HazardListSelectedItem.cs
index e97add40..9b1583f7 100644
--- a/SGGL/Model/APIItem/HSSE/HazardListSelectedItem.cs
+++ b/SGGL/Model/APIItem/HSSE/HazardListSelectedItem.cs
@@ -10,6 +10,15 @@ namespace Model
///
public class HazardListSelectedItem
{
+ ///
+ /// 主键
+ ///
+ public string HazardSelectedItemId
+ {
+ get;
+ set;
+ }
+
///
/// 主键
///
@@ -140,5 +149,41 @@ namespace Model
get;
set;
}
+
+ ///
+ /// 风险责任人Id
+ ///
+ public string DutyPersonId
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// 风险责任人姓名
+ ///
+ public string DutyPersonName
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// 风险巡检计划Id
+ ///
+ public string PatrolPlanId
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// 详细位置描述
+ ///
+ public string Position
+ {
+ get;
+ set;
+ }
}
}
diff --git a/SGGL/Model/APIItem/HSSE/ReEvaluator.cs b/SGGL/Model/APIItem/HSSE/ReEvaluator.cs
new file mode 100644
index 00000000..725005f4
--- /dev/null
+++ b/SGGL/Model/APIItem/HSSE/ReEvaluator.cs
@@ -0,0 +1,141 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Model
+{
+ ///
+ /// 二次评估信息项
+ ///
+ public class ReEvaluator
+ {
+ ///
+ /// ID
+ ///
+ public string LECItemRecordId
+ {
+ get;
+ set;
+ }
+ ///
+ /// 风险ID
+ ///
+ public string HazardSelectedItemId
+ {
+ get;
+ set;
+ }
+ ///
+ /// 当前用户id
+ ///
+ public string Evaluatorld
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// 作业条件危险性评价(L)
+ ///
+ public decimal? HazardJudge_L
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// 作业条件危险性评价(E)
+ ///
+ public decimal? HazardJudge_E
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// 作业条件危险性评价(C)
+ ///
+ public decimal? HazardJudge_C
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// 作业条件危险性评价(D)
+ ///
+ public decimal? HazardJudge_D
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// 风险等级Id
+ ///
+ public string HazardLevel
+ {
+ get;
+ set;
+ }
+ ///
+ /// 控制措施
+ ///
+ public string ControlMeasures
+ {
+ get;
+ set;
+ }
+ ///
+ /// 是否启动巡检
+ ///
+ public bool IsStart
+ {
+ get;
+ set;
+ }
+ ///
+ /// 巡检启动时间
+ ///
+ public string CheckStartDate
+ {
+ get;
+ set;
+ }
+ ///
+ /// 风险责任人Id
+ ///
+ public string DutyPerson
+ {
+ get;
+ set;
+ }
+ ///
+ /// 预计存在时间
+ ///
+ public string PlanExistDate
+ {
+ get;
+ set;
+ }
+ ///
+ /// 当前用户Id
+ ///
+ public string CurrUserId
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// 详细位置描述
+ ///
+ public string Position
+ {
+ get;
+ set;
+ }
+ }
+}
diff --git a/SGGL/Model/APIItem/HSSE/RoutingInspectionItem.cs b/SGGL/Model/APIItem/HSSE/RoutingInspectionItem.cs
new file mode 100644
index 00000000..a3bb8f3a
--- /dev/null
+++ b/SGGL/Model/APIItem/HSSE/RoutingInspectionItem.cs
@@ -0,0 +1,185 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Model
+{
+ ///
+ /// 风险巡检记录信息项
+ ///
+ public class RoutingInspectionItem
+ {
+ ///
+ /// ID
+ ///
+ public string RoutingInspectionId
+ {
+ get;
+ set;
+ }
+ ///
+ /// 风险ID
+ ///
+ public string HazardSelectedItemId
+ {
+ get;
+ set;
+ }
+ ///
+ /// 巡检人id
+ ///
+ public string PatrolManId
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// 巡检时间
+ ///
+ public string PatrolTime
+ {
+ get;
+ set;
+ }
+ ///
+ /// 巡检结果(0~原状态,1~二次评估,2~下整改单,-1~消除)
+ ///
+ public string PatrolResult
+ {
+ get;
+ set;
+ }
+ ///
+ /// 控制措施
+ ///
+ public string ControlMeasures
+ {
+ get;
+ set;
+ }
+ ///
+ /// 巡检处理原因描述
+ ///
+ public string DealReason
+ {
+ get;
+ set;
+ }
+ ///
+ /// 风险责任人Id
+ ///
+ public string RiskManId
+ {
+ get;
+ set;
+ }
+ ///
+ /// 附件
+ ///
+ public string AttachUrl
+ {
+ get;
+ set;
+ }
+ ///
+ /// 当前用户Id
+ ///
+ public string CurrUserId
+ {
+ get;
+ set;
+ }
+ ///
+ /// 单位工程
+ ///
+ public string WorkAreaName
+ {
+ get;
+ set;
+ }
+ ///
+ /// 工作阶段
+ ///
+ public string WorkStageNames
+ {
+ get;
+ set;
+ }
+ ///
+ /// 危险源项
+ ///
+ public string HazardListType
+ {
+ get;
+ set;
+ }
+ ///
+ /// 危险源代码
+ ///
+ public string HazardCode
+ {
+ get;
+ set;
+ }
+ ///
+ /// 缺陷类型
+ ///
+ public string DefectsType
+ {
+ get;
+ set;
+ }
+ ///
+ /// 可能导致的事故
+ ///
+ public string MayLeadAccidents
+ {
+ get;
+ set;
+ }
+ ///
+ /// 危险因素明细
+ ///
+ public string HazardItems
+ {
+ get;
+ set;
+ }
+ ///
+ /// 巡检人
+ ///
+ public string PatrolManName
+ {
+ get;
+ set;
+ }
+ ///
+ /// 原等级
+ ///
+ public string OldRiskLevelName
+ {
+ get;
+ set;
+ }
+ ///
+ /// 现等级
+ ///
+ public string RiskLevelName
+ {
+ get;
+ set;
+ }
+ ///
+ /// 巡检结果
+ ///
+ public string PatrolResultStr
+ {
+ get;
+ set;
+ }
+ }
+}
+
diff --git a/SGGL/Model/Model.csproj b/SGGL/Model/Model.csproj
index e600aafb..5535cd01 100644
--- a/SGGL/Model/Model.csproj
+++ b/SGGL/Model/Model.csproj
@@ -110,6 +110,8 @@
+
+
diff --git a/SGGL/WebAPI/Controllers/HSSE/HazardListController.cs b/SGGL/WebAPI/Controllers/HSSE/HazardListController.cs
index 60fa814c..87f1114a 100644
--- a/SGGL/WebAPI/Controllers/HSSE/HazardListController.cs
+++ b/SGGL/WebAPI/Controllers/HSSE/HazardListController.cs
@@ -68,5 +68,190 @@ namespace WebAPI.Controllers
return responeData;
}
#endregion
+
+
+
+ #region 获取风险等级列表
+ ///
+ /// 获取风险等级列表
+ ///
+ ///
+ public Model.ResponeData getRiskLevel()
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ ////风险等级列表信息
+ var getRiskLevel = APIHazardListService.getRiskLevel();
+ responeData.data = new { getRiskLevel };
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+
+ return responeData;
+ }
+ #endregion
+
+ #region 根据主键ID获取风险详细
+ ///
+ /// 根据主键ID获取风险详细
+ ///
+ ///
+ ///
+ public Model.ResponeData getHazardItemById(string hazardSelectedItemId)
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ ////危险源辨识与评价明细信息
+ var getHazardSelectedInfo = APIHazardListService.getHazardItemInfo(hazardSelectedItemId);
+ responeData.data = new { getHazardSelectedInfo };
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+
+ return responeData;
+ }
+ #endregion
+
+ #region 保存风险巡检记录
+ ///
+ /// 保存风险巡检记录
+ ///
+ /// 风险巡检记录
+ ///
+ [HttpPost]
+ public Model.ResponeData SaveRoutingInspection([FromBody] Model.RoutingInspectionItem newItem)
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ responeData.message = APIHazardListService.SaveRoutingInspection(newItem);
+ if (!string.IsNullOrEmpty(responeData.message))
+ {
+ responeData.code = 0;
+ }
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+
+ return responeData;
+ }
+ #endregion
+
+ #region 根据主键ID获取二次评估详细
+ ///
+ /// 根据主键ID获取二次评估详细
+ ///
+ ///
+ ///
+ public Model.ResponeData getReEvaluatorById(string LECItemRecordId)
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ var getHazardSelectedInfo = APIHazardListService.getReEvaluatorInfo(LECItemRecordId);
+ responeData.data = new { getHazardSelectedInfo };
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+
+ return responeData;
+ }
+ #endregion
+
+ #region 保存二次评估
+ ///
+ /// 保存二次评估
+ ///
+ /// 二次评估
+ ///
+ [HttpPost]
+ public Model.ResponeData SaveReEvaluator([FromBody] Model.ReEvaluator newItem)
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ APIHazardListService.SaveReEvaluator(newItem);
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+
+ return responeData;
+ }
+ #endregion
+
+ #region 根据projectId获取风险巡检记录列表
+ ///
+ /// 根据projectId获取风险巡检记录列表
+ ///
+ ///
+ ///
+ ///
+ public Model.ResponeData getRoutingInspectionList(string projectId, int pageIndex)
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ var getDataList = APIHazardListService.getRoutingInspectionList(projectId);
+ int pageCount = getDataList.Count();
+ if (pageCount > 0 && pageIndex > 0)
+ {
+ getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
+ }
+ responeData.data = new { pageCount, getDataList };
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+ return responeData;
+ }
+ #endregion
+
+ #region 根据主键ID获取已生成的风险巡检记录
+ ///
+ /// 根据主键ID获取已生成的风险巡检记录
+ ///
+ ///
+ ///
+ public Model.ResponeData getRoutingInspectionById(string routingInspectionId)
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ ////危险源辨识与评价明细信息
+ var getHazardSelectedInfo = APIHazardListService.getRoutingInspection(routingInspectionId);
+ responeData.data = new { getHazardSelectedInfo };
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+
+ return responeData;
+ }
+ #endregion
+
+
+
+
}
}
From 49283a7433315e3bdf16a19cf9978a50c2d28b5f Mon Sep 17 00:00:00 2001
From: 10191 <506754232@qq.com>
Date: Sun, 31 Mar 2024 11:01:00 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E8=80=83=E8=AF=95=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
SGGL/BLL/HSSE/EduTrain/TestRecordService.cs | 54 +++++++++----------
.../Controllers/HSSE/TestPlanController.cs | 45 +++++++++++-----
.../Controllers/HSSE/TestRecordController.cs | 2 +-
.../HSSE/TrainingPlanController.cs | 31 ++++++++---
.../HSSE/TrainingTaskController.cs | 2 +-
5 files changed, 84 insertions(+), 50 deletions(-)
diff --git a/SGGL/BLL/HSSE/EduTrain/TestRecordService.cs b/SGGL/BLL/HSSE/EduTrain/TestRecordService.cs
index 7336dfea..588e40ae 100644
--- a/SGGL/BLL/HSSE/EduTrain/TestRecordService.cs
+++ b/SGGL/BLL/HSSE/EduTrain/TestRecordService.cs
@@ -52,38 +52,38 @@ namespace BLL
db.Training_TestRecord.InsertOnSubmit(newTestRecord);
db.SubmitChanges();
- }
- public static void AddTestRecordForApi(Model.Training_TestRecord testRecord)
+ }
+ public static void AddTestRecordForApi(Model.Training_TestRecord testRecord)
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
- using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
- {
- Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
- {
- TestRecordId = testRecord.TestRecordId,
- ProjectId = testRecord.ProjectId,
- TestPlanId = testRecord.TestPlanId,
- TestManId = testRecord.TestManId,
- TestType = testRecord.TestType,
- };
+ Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
+ {
+ TestRecordId = testRecord.TestRecordId,
+ ProjectId = testRecord.ProjectId,
+ TestPlanId = testRecord.TestPlanId,
+ TestManId = testRecord.TestManId,
+ TestType = testRecord.TestType,
+ };
- if (string.IsNullOrEmpty(newTestRecord.TestType))
- {
- var getTrainTypeName = (from x in db.Training_TestPlan
- join y in db.Training_Plan on x.PlanId equals y.PlanId
- join z in db.Base_TrainType on y.TrainTypeId equals z.TrainTypeId
- where x.TestPlanId == testRecord.TestPlanId
- select z).FirstOrDefault();
+ if (string.IsNullOrEmpty(newTestRecord.TestType))
+ {
+ var getTrainTypeName = (from x in db.Training_TestPlan
+ join y in db.Training_Plan on x.PlanId equals y.PlanId
+ join z in db.Base_TrainType on y.TrainTypeId equals z.TrainTypeId
+ where x.TestPlanId == testRecord.TestPlanId
+ select z).FirstOrDefault();
- if (getTrainTypeName != null)
- {
- testRecord.TestType = getTrainTypeName.TrainTypeName;
- }
- }
+ if (getTrainTypeName != null)
+ {
+ testRecord.TestType = getTrainTypeName.TrainTypeName;
+ }
+ }
- db.Training_TestRecord.InsertOnSubmit(newTestRecord);
- db.SubmitChanges();
- }
+ db.Training_TestRecord.InsertOnSubmit(newTestRecord);
+ db.SubmitChanges();
}
+ }
///
/// 修改考试记录信息
///
diff --git a/SGGL/WebAPI/Controllers/HSSE/TestPlanController.cs b/SGGL/WebAPI/Controllers/HSSE/TestPlanController.cs
index 53a7b4b4..e970f786 100644
--- a/SGGL/WebAPI/Controllers/HSSE/TestPlanController.cs
+++ b/SGGL/WebAPI/Controllers/HSSE/TestPlanController.cs
@@ -79,24 +79,41 @@ namespace WebAPI.Controllers
var responeData = new Model.ResponeData();
try
{
- var getTasks = new Model.SGGLDB(Funs.ConnString).Training_Task.FirstOrDefault(x => x.PlanId == trainingPlanId);
- if (getTasks != null)
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
- if (CommonService.IsMainUnitOrAdmin(userId))
+ var getTasks =db.Training_Task.FirstOrDefault(x => x.PlanId == trainingPlanId);
+ if (getTasks != null)
{
- responeData.data = APITestPlanService.SaveTestPlanByTrainingPlanId(trainingPlanId, userId);
+ bool result = false;
+ if (userId == Const.sysglyId || userId == Const.hfnbdId)
+ {
+ result = true;
+ }
+ else
+ {
+ var user = db.Sys_User.FirstOrDefault(e => e.UserId == userId);
+ if (user != null && user.UnitId == Const.UnitId_CD)
+ {
+ result = true;
+ }
+ }
+ if ( result)
+ //if (CommonService.IsMainUnitOrAdmin(userId))
+ {
+ responeData.data = APITestPlanService.SaveTestPlanByTrainingPlanId(trainingPlanId, userId);
+ }
+ else
+ {
+ responeData.code = 0;
+ responeData.message = "非本单位用户,不能生成考试计划!";
+ }
}
else
{
responeData.code = 0;
- responeData.message = "非本单位用户,不能生成考试计划!";
+ responeData.message = "培训计划下没有培训人员,不能生成考试计划!";
}
}
- else
- {
- responeData.code = 0;
- responeData.message = "培训计划下没有培训人员,不能生成考试计划!";
- }
}
catch (Exception ex)
{
@@ -201,11 +218,11 @@ namespace WebAPI.Controllers
Model.SitePerson_Person person;
if (user != null)
{
- person = Funs.DB.SitePerson_Person.FirstOrDefault(e => (e.PersonId == personId || e.IdentityCard == user.IdentityCard) && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
+ person = db.SitePerson_Person.FirstOrDefault(e => (e.PersonId == personId || e.IdentityCard == user.IdentityCard) && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
}
else
{
- person = Funs.DB.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
+ person = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
}
if (person != null || user != null)
@@ -246,7 +263,7 @@ namespace WebAPI.Controllers
TestPlanId = getTestPlan.TestPlanId,
TestManId = personId,
};
- TestRecordService.AddTestRecord(newTestRecord);
+ TestRecordService.AddTestRecordForApi(newTestRecord);
responeData.code = 3;
responeData.message = "您已加入考试计划!";
}
@@ -265,7 +282,7 @@ namespace WebAPI.Controllers
TestPlanId = getTestPlan.TestPlanId,
TestManId = personId,
};
- TestRecordService.AddTestRecord(newTestRecord);
+ TestRecordService.AddTestRecordForApi(newTestRecord);
responeData.code = 3;
responeData.message = "您已加入考试计划!";
}
diff --git a/SGGL/WebAPI/Controllers/HSSE/TestRecordController.cs b/SGGL/WebAPI/Controllers/HSSE/TestRecordController.cs
index 6216a58d..05560f08 100644
--- a/SGGL/WebAPI/Controllers/HSSE/TestRecordController.cs
+++ b/SGGL/WebAPI/Controllers/HSSE/TestRecordController.cs
@@ -164,7 +164,7 @@ namespace WebAPI.Controllers
var responeData = new Model.ResponeData();
try
{
- personId = PersonService.GetPersonIdByUserId(personId);
+ personId = PersonService.GetPersonIdByUserIdForApi(personId);
var getDataLists = APITestRecordService.getTrainingTestRecordListByProjectIdPersonId(projectId, personId);
int pageCount = getDataLists.Count;
if (pageCount > 0 && pageIndex > 0)
diff --git a/SGGL/WebAPI/Controllers/HSSE/TrainingPlanController.cs b/SGGL/WebAPI/Controllers/HSSE/TrainingPlanController.cs
index c79ec021..2ea94610 100644
--- a/SGGL/WebAPI/Controllers/HSSE/TrainingPlanController.cs
+++ b/SGGL/WebAPI/Controllers/HSSE/TrainingPlanController.cs
@@ -101,14 +101,31 @@ namespace WebAPI.Controllers
var responeData = new Model.ResponeData();
try
{
- if (CommonService.IsMainUnitOrAdmin(trainingPlan.DesignerId))
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
- APITrainingPlanService.SaveTrainingPlan(trainingPlan);
- }
- else
- {
- responeData.code = 0;
- responeData.message = "非本单位用户,不能制定培训计划!";
+ bool result = false;
+ if (trainingPlan.DesignerId == Const.sysglyId || trainingPlan.DesignerId == Const.hfnbdId)
+ {
+ result = true;
+ }
+ else
+ {
+ var user = db.Sys_User.FirstOrDefault(e => e.UserId == trainingPlan.DesignerId);
+ if (user != null && user.UnitId == Const.UnitId_CD)
+ {
+ result = true;
+ }
+ }
+ if (result)
+ // if (CommonService.IsMainUnitOrAdmin(trainingPlan.DesignerId))
+ {
+ APITrainingPlanService.SaveTrainingPlan(trainingPlan);
+ }
+ else
+ {
+ responeData.code = 0;
+ responeData.message = "非本单位用户,不能制定培训计划!";
+ }
}
}
catch (Exception ex)
diff --git a/SGGL/WebAPI/Controllers/HSSE/TrainingTaskController.cs b/SGGL/WebAPI/Controllers/HSSE/TrainingTaskController.cs
index 3df33a61..0c10ebf7 100644
--- a/SGGL/WebAPI/Controllers/HSSE/TrainingTaskController.cs
+++ b/SGGL/WebAPI/Controllers/HSSE/TrainingTaskController.cs
@@ -86,7 +86,7 @@ namespace WebAPI.Controllers
var responeData = new Model.ResponeData();
try
{
- string newPersonId = PersonService.GetPersonIdByUserId(personId);
+ string newPersonId = PersonService.GetPersonIdByUserIdForApi(personId);
responeData.message = APITrainingTaskService.getTrainingTaskByPlanIdPersonIdCondition(planId, newPersonId);
if (string.IsNullOrEmpty(responeData.message))
{