diff --git a/SGGL/BLL/API/HSSE/APIHazardRegisterService.cs b/SGGL/BLL/API/HSSE/APIHazardRegisterService.cs index 80ffdeb4..a95f69c2 100644 --- a/SGGL/BLL/API/HSSE/APIHazardRegisterService.cs +++ b/SGGL/BLL/API/HSSE/APIHazardRegisterService.cs @@ -40,7 +40,47 @@ namespace BLL return ObjectMapperManager.DefaultInstance.GetMapper, List>().Map(hazardRegisters.ToList()); } } + 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; + } + } /// /// 保存HazardRegister /// @@ -90,7 +130,7 @@ namespace BLL { newHazardRegister.HazardRegisterId = SQLHelper.GetNewID(); } - db.HSSE_Hazard_HazardRegister.InsertOnSubmit(newHazardRegister); + db.HSSE_Hazard_HazardRegister.InsertOnSubmit(newHazardRegister); } else { @@ -107,8 +147,8 @@ namespace BLL isUpdate.HandleIdea = newHazardRegister.HandleIdea; isUpdate.SafeSupervisionIsOK = newHazardRegister.SafeSupervisionIsOK; } - isUpdate.RectificationPeriod = newHazardRegister.RectificationPeriod; - isUpdate.States = newHazardRegister.States; + isUpdate.RectificationPeriod = newHazardRegister.RectificationPeriod; + isUpdate.States = newHazardRegister.States; isUpdate.Risk_Level = newHazardRegister.Risk_Level; } db.SubmitChanges(); diff --git a/SGGL/Model/APIItem/HSSE/HazardRegisterItem.cs b/SGGL/Model/APIItem/HSSE/HazardRegisterItem.cs index 4214a541..9801c92c 100644 --- a/SGGL/Model/APIItem/HSSE/HazardRegisterItem.cs +++ b/SGGL/Model/APIItem/HSSE/HazardRegisterItem.cs @@ -324,6 +324,45 @@ namespace Model /// 风险等级 /// public string Risk_Level + { + 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; diff --git a/SGGL/WebAPI/Controllers/HSSE/HazardRegisterController.cs b/SGGL/WebAPI/Controllers/HSSE/HazardRegisterController.cs index ac18b0e0..0dcb58ee 100644 --- a/SGGL/WebAPI/Controllers/HSSE/HazardRegisterController.cs +++ b/SGGL/WebAPI/Controllers/HSSE/HazardRegisterController.cs @@ -22,7 +22,7 @@ namespace WebAPI.Controllers var responeData = new Model.ResponeData(); try { - responeData.data = BLL.APIHazardRegisterService.getHazardRegisterByHazardRegisterId(hazardRegisterId); + responeData.data = BLL.APIHazardRegisterService.getHazardRegisterByHazardRegisterId(hazardRegisterId); } catch (Exception ex) { @@ -39,7 +39,7 @@ namespace WebAPI.Controllers /// 根据projectId、states获取风险信息 /// /// - /// + /// /// 页码 /// public Model.ResponeData getHazardRegisterByProjectIdStates(string projectId, string states, int pageIndex) @@ -70,6 +70,7 @@ namespace WebAPI.Controllers /// 根据projectId获取各状态风险数 /// /// + /// 0 日常巡检 1 常规巡检 /// public Model.ResponeData getHazardRegisterCount(string projectId) { @@ -108,11 +109,57 @@ namespace WebAPI.Controllers /// [HttpPost] public Model.ResponeData SaveHazardRegister([FromBody] Model.HazardRegisterItem hazardRegister) - { + { var responeData = new Model.ResponeData(); try { - BLL.APIHazardRegisterService.SaveHazardRegister(hazardRegister); + BLL.APIHazardRegisterService.SaveHazardRegister(hazardRegister); + } + catch (Exception ex) + { + responeData.code = 0; + responeData.message = ex.Message; + } + + 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) { diff --git a/SGGL/WebAPI/Filter/TestPermissionAttribute.cs b/SGGL/WebAPI/Filter/TestPermissionAttribute.cs index ccebb203..ddbfcac7 100644 --- a/SGGL/WebAPI/Filter/TestPermissionAttribute.cs +++ b/SGGL/WebAPI/Filter/TestPermissionAttribute.cs @@ -76,6 +76,7 @@ namespace WebAPI.Filter { if (BLL.Funs.DBList.ContainsKey(System.Threading.Thread.CurrentThread.ManagedThreadId)) { + BLL.Funs.DBList[System.Threading.Thread.CurrentThread.ManagedThreadId].Dispose(); BLL.Funs.DBList.Remove(System.Threading.Thread.CurrentThread.ManagedThreadId); }