124 lines
4.4 KiB
C#
124 lines
4.4 KiB
C#
using BLL;
|
||
using System;
|
||
using System.Linq;
|
||
using System.Web.Http;
|
||
|
||
namespace WebAPI.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 图型分信息
|
||
/// </summary>
|
||
public class ChartAnalysisController : ApiController
|
||
{
|
||
#region 根据类型获取图型数据
|
||
/// <summary>
|
||
/// 根据类型获取图型数据
|
||
/// </summary>
|
||
/// <param name="projectId">项目ID</param>
|
||
/// <param name="type">1:按单位;2:按类型</param>
|
||
/// <param name="startDate">开始时间</param>
|
||
/// <param name="endDate">结束时间</param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getChartAnalysisByType(string projectId, string type,string startDate,string endDate)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
responeData.data = BLL.APIChartAnalysisService.getChartAnalysisByType(projectId, type, startDate, endDate);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
|
||
|
||
|
||
|
||
#region 根据项目ID 获取整改单数据
|
||
/// <summary>
|
||
/// 根据项目ID 获取整改单数据
|
||
/// </summary>
|
||
/// <param name="projectId">项目ID</param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getHSSERectifyNoticesChartAnalysis(string projectId)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
int allCount = 0, uCount = 0, cCount = 0;
|
||
double rate = 1;
|
||
var getRectifyNotices = from x in db.Check_RectifyNotices
|
||
where x.States != Const.State_0 && x.States != null && x.ProjectId == projectId
|
||
select x;
|
||
if (!string.IsNullOrEmpty(projectId) && projectId != "")
|
||
{
|
||
getRectifyNotices = getRectifyNotices.Where(x => x.ProjectId == projectId);
|
||
}
|
||
//// 整改总数
|
||
allCount = getRectifyNotices.Count();
|
||
if (allCount > 0)
|
||
{
|
||
//// 已闭环
|
||
cCount = getRectifyNotices.Where(x => x.States == "5").Count();
|
||
uCount = allCount - cCount;
|
||
rate = Math.Round(uCount * 1.0 / allCount * 100, 1);
|
||
}
|
||
|
||
responeData.data = new { allCount, uCount, rate };
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据项目ID 获取资质预警数据
|
||
/// <summary>
|
||
/// 根据项目ID 获取整改单数据
|
||
/// </summary>
|
||
/// <param name="projectId">项目ID</param>
|
||
/// <returns></returns>
|
||
public Model.ResponeData getHSSEPersonQualityChartAnalysis(string projectId)
|
||
{
|
||
var responeData = new Model.ResponeData();
|
||
try
|
||
{
|
||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||
{
|
||
int allCount = 0;
|
||
var getPersonQualitys = from x in db.QualityAudit_PersonQuality
|
||
join y in db.SitePerson_Person on x.PersonId equals y.PersonId
|
||
where (projectId == null || projectId == "" || y.ProjectId == projectId)
|
||
&& x.LimitDate.HasValue && x.LimitDate < DateTime.Now
|
||
select x;
|
||
//// 预警人数
|
||
allCount = getPersonQualitys.Count();
|
||
responeData.data = new { allCount };
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responeData.code = 0;
|
||
responeData.message = ex.Message;
|
||
}
|
||
|
||
return responeData;
|
||
}
|
||
#endregion
|
||
|
||
}
|
||
}
|