安全检查报表
This commit is contained in:
parent
68543a387e
commit
3a7436176e
@ -1,21 +1,23 @@
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using APT.Infrastructure.Core;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using APT.Infrastructure.Api;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using APT.BaseData.Domain.ApiModel;
|
||||
using Ubiety.Dns.Core;
|
||||
using System.Security.AccessControl;
|
||||
using APT.MS.Domain.Entities.FO;
|
||||
using APT.BaseData.Domain.ApiModel;
|
||||
using APT.BaseData.Domain.Entities;
|
||||
using APT.MS.Domain.Enums;
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using APT.Infrastructure.Api;
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.MS.Domain.Entities.BI;
|
||||
using static APT.MS.Domain.Enums.BI.BIEnums;
|
||||
using APT.Utility;
|
||||
using APT.MS.Domain.Entities.BS;
|
||||
using APT.MS.Domain.Entities.FO;
|
||||
using APT.MS.Domain.Entities.SK;
|
||||
using APT.MS.Domain.Enums;
|
||||
using APT.MS.Domain.Enums.SK;
|
||||
using APT.Utility;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Security.AccessControl;
|
||||
using Ubiety.Dns.Core;
|
||||
using static APT.MS.Domain.Enums.BI.BIEnums;
|
||||
|
||||
namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
{
|
||||
@ -107,8 +109,8 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("GetBI056Main")]
|
||||
public JsonActionResult<ModelBI056Main> GetBI056Main([FromBody] KeywordFilter filter)
|
||||
[HttpPost, Route("GetBI056MainOld")]
|
||||
public JsonActionResult<ModelBI056Main> GetBI056MainOld([FromBody] KeywordFilter filter)
|
||||
{
|
||||
return SafeExecute<ModelBI056Main>(() =>
|
||||
{
|
||||
@ -372,8 +374,242 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
|
||||
return result;
|
||||
});
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 显示
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("GetBI056Main")]
|
||||
public JsonActionResult<ModelBI056Main> GetBI056Main([FromBody] KeywordFilter filter)
|
||||
{
|
||||
return SafeExecute<ModelBI056Main>(() =>
|
||||
{
|
||||
ModelBI056Main result = new ModelBI056Main();
|
||||
DateTime dtStart = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-01-01 00:00:00");
|
||||
DateTime? dtEnd = null;
|
||||
|
||||
#region enmusLevel=> lisLevelOrder enmusMineType=>lisMineTypeOrder
|
||||
|
||||
// var enmus = GetEntities<T_FM_ENUMS>(e => !e.IS_DELETED, null, null);
|
||||
var enmus = GetEntities<T_FM_USER_PRODUCTION_UNIT_SET>(e => !e.IS_DELETED, null, null);
|
||||
if (enmus == null || !enmus.Any())
|
||||
throw new Exception("获取生产单元信息失败!");
|
||||
List<string> lisLevelOrder = new List<string>();
|
||||
List<string> lisMineTypeOrder = new List<string>();
|
||||
foreach (SKDepartmentTypeEnum level in Enum.GetValues(typeof(SKDepartmentTypeEnum)))
|
||||
{
|
||||
lisLevelOrder.Add(level.GetDescription());
|
||||
}
|
||||
var enmusMineType = enmus.ToList();
|
||||
foreach (var item in enmusMineType)
|
||||
{
|
||||
lisMineTypeOrder.Add(item.NAME);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 改良版 listSafeCheck 所有的符合条件的检查信息
|
||||
|
||||
Expression<Func<T_SK_SECURITY_INSPECTION_NOTICE, bool>> expression = e => !e.IS_DELETED && e.APPLY_USER_ID.HasValue && e.CHECK_TIME.HasValue && dtStart <= e.CHECK_TIME.Value;
|
||||
|
||||
if (dtEnd.HasValue)
|
||||
expression = expression.And(e => e.CHECK_TIME.HasValue && dtEnd.Value >= e.CHECK_TIME.Value);
|
||||
|
||||
BaseFilter filterSearch = new BaseFilter(filter.OrgId);
|
||||
filterSearch.IgnoreDataRule = true;
|
||||
//filterSearch.Include.Add("Nav_CheckTypeLevel");
|
||||
filterSearch.SelectField = new List<string>() { "ID", "APPLY_USER_ID", "PRODUCTION_UNIT_ID", "CHECK_TYPE_ID", "IS_DELETED", "CHECK_TIME", "DEPARTMENT_TYPE" };
|
||||
//var listSafeCheck = GetEntities(expression, null, "Nav_CheckTypeLevel");
|
||||
var listSafeCheck = GetEntities(expression, filterSearch, null);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 1_1 改良版
|
||||
|
||||
List<List<int>> listCheckCount = new List<List<int>>();
|
||||
List<int> listCheckLevelCount = null;
|
||||
foreach (SKDepartmentTypeEnum item in Enum.GetValues(typeof(SKDepartmentTypeEnum)))
|
||||
{
|
||||
//mineTypeName: ["露天矿", "选矿厂", "尾矿库", "职能部门"],
|
||||
//legendName: ["公司级", "部门级", "车间级", "班组级"],
|
||||
//checkCount: [[3, 3, 3, 3], [12, 12, 12, 6], [24, 24, 24, 12], [90, 90, 120, 36]],
|
||||
|
||||
listCheckLevelCount = new List<int>();
|
||||
//选矿 10, 尾矿 20, 矿山 30, 地下矿 40,
|
||||
foreach (var itemMine in enmusMineType)
|
||||
{
|
||||
int count = listSafeCheck.Where(e => e.PRODUCTION_UNIT_ID == itemMine.ID && e.DEPARTMENT_TYPE == item).Count();
|
||||
listCheckLevelCount.Add(count);
|
||||
}
|
||||
listCheckCount.Add(listCheckLevelCount);
|
||||
}
|
||||
|
||||
//数据组装
|
||||
result.Count1_1 = listCheckCount;
|
||||
result.lisMineTypeOrder = lisMineTypeOrder;
|
||||
result.lisLevelOrder = lisLevelOrder;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 3_1 改良版
|
||||
|
||||
|
||||
List<List<int>> listCheckTypeCount = new List<List<int>>();
|
||||
List<int> listCheckTypeCountPer = null;
|
||||
|
||||
var listCheckType = GetEntities<T_SK_CHECK_TYPE>(e => !e.IS_DELETED, null).OrderBy(e => e.PRODUCTION_UNIT_ID).ThenBy(e => e.NUM);
|
||||
List<string> listCheckTypeName = new List<string>();
|
||||
List<Guid> listCheckTypeID = new List<Guid>();
|
||||
List<Guid> listSum = new List<Guid>();
|
||||
Guid guidParent = Guid.Empty;
|
||||
foreach (var item in listCheckType)
|
||||
{
|
||||
listCheckTypeName.Add(item.NAME);
|
||||
listCheckTypeID.Add(item.ID);
|
||||
}
|
||||
listSum.Add(guidParent);//有些人直接定义 综合检查
|
||||
|
||||
foreach (var item in enmusMineType)
|
||||
{
|
||||
listCheckTypeCountPer = new List<int>();
|
||||
|
||||
foreach (var itemCheckType in listCheckTypeID)
|
||||
{
|
||||
int count = listSafeCheck.Where(e => e.PRODUCTION_UNIT_ID == item.ID && e.CHECK_TYPE_ID == itemCheckType).Count();
|
||||
listCheckTypeCountPer.Add(count);
|
||||
}
|
||||
listCheckTypeCount.Add(listCheckTypeCountPer);
|
||||
}
|
||||
|
||||
//数据组装
|
||||
result.Count3_1 = listCheckTypeCount;
|
||||
result.lisCheckTypeName = listCheckTypeName;
|
||||
#endregion
|
||||
|
||||
#region 隐患 1_2 2_1 2_2 3_2
|
||||
|
||||
Expression<Func<T_SK_HIDDEN_DANGER_RECTIFY_RECORD, bool>> expression2_2 = e => !e.IS_DELETED && e.CREATE_TIME.HasValue && e.CREATE_TIME.Value >= dtStart && !e.IS_DELETED;// && (e.RiskContentState.Value == 60 || e.RiskContentState.Value == 80)&& e.DESCREPTION != null
|
||||
if (dtEnd.HasValue)
|
||||
expression2_2 = expression2_2.And(e => e.CREATE_TIME.HasValue && dtEnd.Value >= e.CREATE_TIME.Value);
|
||||
|
||||
var listContent = GetEntities(expression2_2, null, "Nav_Question");
|
||||
|
||||
#region 1_2 各生产单元 隐患数
|
||||
|
||||
List<int> listRiskMineCount1_2 = new List<int>();
|
||||
foreach (var item in enmusMineType)
|
||||
{
|
||||
listRiskMineCount1_2.Add(listContent.Where(e => e.PRODUCTION_UNIT_ID.HasValue && e.PRODUCTION_UNIT_ID ==item.ID).Count());
|
||||
}
|
||||
result.listRiskMineCount1_2 = listRiskMineCount1_2;
|
||||
#endregion
|
||||
|
||||
#region 2_1 月度 已完成 未完成 整改率
|
||||
|
||||
List<int> listMonth = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12 };
|
||||
if (dtStart.Year > DateTime.Now.Year)
|
||||
{
|
||||
listMonth.Clear();
|
||||
}
|
||||
else if (dtStart.Year == DateTime.Now.Year)
|
||||
{
|
||||
listMonth = listMonth.Where(e => e <= DateTime.Now.Month).OrderBy(e => e).ToList();
|
||||
}
|
||||
|
||||
List<int> listFinish2_1 = new List<int>();
|
||||
List<int> listNotFinish2_1 = new List<int>();
|
||||
List<decimal> listFinish2_1Percent = new List<decimal>();
|
||||
foreach (var item in listMonth)
|
||||
{
|
||||
listFinish2_1.Add(listContent.Where(e => e.CREATE_TIME.HasValue && e.CREATE_TIME.Value.Month == item && e.STATUS == BaseData.Domain.Enums.PF.PFStandardStatus.Archived).Count());
|
||||
listNotFinish2_1.Add(listContent.Where(e => e.PRODUCTION_UNIT_ID.HasValue && e.CREATE_TIME.HasValue && e.CREATE_TIME.Value.Month == item && e.STATUS != BaseData.Domain.Enums.PF.PFStandardStatus.Archived).Count());//只是上报 没有检查范围 不计算在内 不然与后面的弹窗不对等
|
||||
}
|
||||
for (int i = 0; i < listMonth.Count; i++)
|
||||
{
|
||||
if (listNotFinish2_1[i] == 0)
|
||||
{
|
||||
listFinish2_1Percent.Add(100);
|
||||
}
|
||||
else if (listFinish2_1[i] == 0)
|
||||
{
|
||||
listFinish2_1Percent.Add(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
listFinish2_1Percent.Add((decimal)Math.Round((listFinish2_1[i] * 100.0 / (listNotFinish2_1[i] + listFinish2_1[i])), 2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//result.listMonth = listMonth;
|
||||
result.listFinish2_1 = listFinish2_1;
|
||||
result.listNotFinish2_1 = listNotFinish2_1;
|
||||
result.listFinish2_1Percent = listFinish2_1Percent;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 2_2 隐患Top
|
||||
var query = listContent.Where(e => e.Nav_Question != null).GroupBy(e => e.Nav_Question.DESCREPTION).Select(e => new
|
||||
{
|
||||
DESCREPTION = e.Key,
|
||||
Count = e.Count()
|
||||
}).OrderByDescending(e => e.Count).Take(6);//.Where(e => e.DESCREPTION != null) 名称不能为null
|
||||
|
||||
if (query != null && query.Any())
|
||||
{
|
||||
List<string> ListDescreption2_2 = new List<string>();
|
||||
List<int> Count2_2 = new List<int>();
|
||||
foreach (var item in query)
|
||||
{
|
||||
Count2_2.Add(item.Count);
|
||||
ListDescreption2_2.Add(item.DESCREPTION);
|
||||
}
|
||||
result.Count2_2 = Count2_2;
|
||||
result.ListDescreption2_2 = ListDescreption2_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Count2_2 = new List<int>();
|
||||
result.ListDescreption2_2 = new List<string>();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 3_2 检查类型隐患统计
|
||||
|
||||
List<List<int>> listRiskMoneCheckType = new List<List<int>>();
|
||||
foreach (var item in enmusMineType)
|
||||
{
|
||||
listCheckTypeCountPer = new List<int>();
|
||||
foreach (var itemCheckType in listCheckTypeID)
|
||||
{
|
||||
//检查类型
|
||||
if (itemCheckType == guidParent)
|
||||
{
|
||||
int count = listContent.Where(e => e.CHECK_TYPE_ID.HasValue && e.PRODUCTION_UNIT_ID.HasValue && e.PRODUCTION_UNIT_ID== item.ID && listSum.Contains(e.CHECK_TYPE_ID.Value)).Count();
|
||||
listCheckTypeCountPer.Add(count);
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = listContent.Where(e => e.CHECK_TYPE_ID.HasValue && e.PRODUCTION_UNIT_ID.HasValue && e.PRODUCTION_UNIT_ID == item.ID && e.CHECK_TYPE_ID == itemCheckType).Count();
|
||||
listCheckTypeCountPer.Add(count);
|
||||
}
|
||||
}
|
||||
listRiskMoneCheckType.Add(listCheckTypeCountPer);
|
||||
}
|
||||
result.Count3_2 = listRiskMoneCheckType;
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
return result;
|
||||
});
|
||||
}
|
||||
//#region 旧版直接查询 count
|
||||
|
||||
///// <summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user