diff --git a/DataBase/版本日志/SGGLDB_WH_2023-12-06.sql b/DataBase/版本日志/SGGLDB_WH_2023-12-06.sql
new file mode 100644
index 00000000..c34046e4
--- /dev/null
+++ b/DataBase/版本日志/SGGLDB_WH_2023-12-06.sql
@@ -0,0 +1,10 @@
+/****** Object: Index [NonClusteredIndex-20231205-165427] Script Date: 2023/12/5 16:55:24 ******/
+CREATE NONCLUSTERED INDEX [NonClusteredIndex-20231205-165427] ON [dbo].[HSSE_Hazard_HazardRegister]
+(
+ [ProjectId] ASC,
+ [states] ASC,
+ [CheckTime] ASC
+)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
+GO
+
+
diff --git a/SGGL/BLL/API/HSSE/APIHazardRegisterService.cs b/SGGL/BLL/API/HSSE/APIHazardRegisterService.cs
index a1c60a36..17fc0fe6 100644
--- a/SGGL/BLL/API/HSSE/APIHazardRegisterService.cs
+++ b/SGGL/BLL/API/HSSE/APIHazardRegisterService.cs
@@ -131,5 +131,53 @@ namespace BLL
}
}
}
+
+ ///
+ /// 安全巡检
+ ///
+ ///
+ ///
+ public static List getHazardRegisterByProjectIdStates(int pageIndex)
+ {
+ string unitName = null, unitId = null;
+ var getUnit = CommonService.GetIsThisUnit();
+ if (getUnit != null)
+ {
+ unitId = getUnit.UnitId;
+ unitName = getUnit.UnitName;
+ }
+ using (Model.SGGLDB db = new Model.SGGLDB(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;
+ }
+ }
+
}
}
diff --git a/SGGL/Model/APIItem/HSSE/HazardRegisterItem.cs b/SGGL/Model/APIItem/HSSE/HazardRegisterItem.cs
index d2764aa1..59a70647 100644
--- a/SGGL/Model/APIItem/HSSE/HazardRegisterItem.cs
+++ b/SGGL/Model/APIItem/HSSE/HazardRegisterItem.cs
@@ -31,6 +31,46 @@ namespace Model
get;
set;
}
+ ///
+ /// 单位ID
+ ///
+ public string UnitId
+ {
+ get;
+ set;
+ }
+ ///
+ /// 单位名称
+ ///
+ public string UnitName
+ {
+ get;
+ set;
+ }
+ ///
+ /// 项目单位ID
+ ///
+ public string PUnitId
+ {
+ get;
+ set;
+ }
+ ///
+ /// 项目单位名称
+ ///
+ public string PUnitName
+ {
+ get;
+ set;
+ }
+ ///
+ /// 项目名称
+ ///
+ public string ProjectAddress
+ {
+ get;
+ set;
+ }
///
/// 状态
@@ -320,5 +360,13 @@ namespace Model
get;
set;
}
+ ///
+ /// 风险等级
+ ///
+ public string Risk_Level
+ {
+ get;
+ set;
+ }
}
}
diff --git a/SGGL/WebAPI/Controllers/HSSE/HazardRegisterController.cs b/SGGL/WebAPI/Controllers/HSSE/HazardRegisterController.cs
index 89add30b..e35d9d68 100644
--- a/SGGL/WebAPI/Controllers/HSSE/HazardRegisterController.cs
+++ b/SGGL/WebAPI/Controllers/HSSE/HazardRegisterController.cs
@@ -125,5 +125,51 @@ namespace WebAPI.Controllers
return responeData;
}
#endregion
+
+ #region 获取总安全巡检
+ ///
+ /// 获取总安全巡检
+ ///
+ ///
+ public Model.ResponeData getHazardRegisterTotalCount()
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ //总数
+ responeData.data = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.ProjectId != null && x.States != null).Count();
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+
+ return responeData;
+ }
+ #endregion
+
+ #region 获取总安全巡检
+ ///
+ /// 获取总安全巡检
+ ///
+ /// 页码
+ ///
+ public Model.ResponeData getHazardRegisterByProjectIdStates(int pageIndex)
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ responeData.data = APIHazardRegisterService.getHazardRegisterByProjectIdStates(pageIndex);
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+
+ return responeData;
+ }
+ #endregion
}
}
diff --git a/SGGL/WebAPI/Filter/TestPermissionAttribute.cs b/SGGL/WebAPI/Filter/TestPermissionAttribute.cs
index fa9f6dcb..ad6c619c 100644
--- a/SGGL/WebAPI/Filter/TestPermissionAttribute.cs
+++ b/SGGL/WebAPI/Filter/TestPermissionAttribute.cs
@@ -23,9 +23,11 @@ namespace WebAPI.Filter
bool isOk = false;
actionContext.Request.Headers.TryGetValues("token", out IEnumerable token);
string strValues = actionContext.ActionDescriptor.ControllerDescriptor.ControllerName + "*" + ((ReflectedHttpActionDescriptor)actionContext.ActionDescriptor).ActionName;
+ bool isWithOut = false;
if (lists.FirstOrDefault(x => x == strValues) != null)
{
isOk = true;
+ isWithOut = true;
}
if (!isOk && token != null)
@@ -46,24 +48,29 @@ namespace WebAPI.Filter
}
// base.OnActionExecuting(actionContext);
if (isOk)
- { // 在调用 Action 方法之前执行的代码,可获取请求的接口名称和参数
- IDictionary arguments = actionContext.ActionArguments; // 获取参数
- foreach (KeyValuePair item in arguments)
+ {
+ if (!isWithOut)
{
- if (item.Key == "projectid" || item.Key == "ProjectId" || item.Key == "projectId" || item.Key == "Projectid")
- {
- var ProjectItems = APIProjectService.geProjectsByUserId(token.FirstOrDefault());
- List projects = new List();
- if (ProjectItems.Count > 0)
- {
- projects = ProjectItems.Select(x => x.ProjectId).ToList();
- }
- if (item.Value != null && !projects.Contains(item.Value.ToString()))
- {
- actionContext.Response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.OK,
- new { code = "0", message = "您没有该项目权限!" }, actionContext.ControllerContext.Configuration.Formatters.JsonFormatter);
- return;
+ // 在调用 Action 方法之前执行的代码,可获取请求的接口名称和参数
+ IDictionary arguments = actionContext.ActionArguments; // 获取参数
+ foreach (KeyValuePair item in arguments)
+ {
+ if (item.Key == "projectid" || item.Key == "ProjectId" || item.Key == "projectId" || item.Key == "Projectid")
+ {
+ var ProjectItems = APIProjectService.geProjectsByUserId(token.FirstOrDefault());
+ List projects = new List();
+ if (ProjectItems.Count > 0)
+ {
+ projects = ProjectItems.Select(x => x.ProjectId).ToList();
+ }
+ if (item.Value != null && !projects.Contains(item.Value.ToString()))
+ {
+
+ actionContext.Response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.OK,
+ new { code = "0", message = "您没有该项目权限!" }, actionContext.ControllerContext.Configuration.Formatters.JsonFormatter);
+ return;
+ }
}
}
}
@@ -79,7 +86,7 @@ namespace WebAPI.Filter
///
///
///
- public static List lists = new List { "User*postLoginOn", "get*token" };
+ public static List lists = new List { "User*postLoginOn", "get*token", "HazardRegister*getHazardRegisterTotalCount", "HazardRegister*getHazardRegisterByProjectIdStates" };
///
///
diff --git a/SGGL/WebAPI/WebAPI.csproj b/SGGL/WebAPI/WebAPI.csproj
index bdb6c5b9..1da74a06 100644
--- a/SGGL/WebAPI/WebAPI.csproj
+++ b/SGGL/WebAPI/WebAPI.csproj
@@ -322,9 +322,9 @@
True
True
- 7040
+ 0
/
- http://localhost:7040/
+ http://localhost:10684/
False
False