using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using BLL;
namespace WebAPI.Controllers
{
///
/// 危险源辨识与评价
///
public class HazardListController : ApiController
{
#region 根据主键ID获取危险源辨识与评价详细
///
/// 根据主键ID获取危险源辨识与评价详细
///
///
///
public Model.ResponeData getHazardListInfoById(string hazardListId)
{
var responeData = new Model.ResponeData();
try
{
////危险源辨识与评价主表信息
var getHazardInfo = APIHazardListService.getHazardListInfoByHazardListId(hazardListId);
////危险源辨识与评价明细信息
var getHazardSelectedInfo = APIHazardListService.getHazardListSelectedInfo(hazardListId);
responeData.data = new { getHazardInfo, getHazardSelectedInfo };
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region 根据projectId获取危险源辨识评价列表
///
/// 根据projectId、unitid获取施工方案信息
///
///
///
///
public Model.ResponeData getHazardList(string projectId, int pageIndex)
{
var responeData = new Model.ResponeData();
try
{
var getDataList = APIHazardListService.getHazardListList(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 获取风险等级列表
///
/// 获取风险等级列表
///
///
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
}
}