Merge branch 'master' of http://121.41.2.71:3000/wyw/mh_jy_safe
This commit is contained in:
commit
495843846d
@ -259,13 +259,13 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
var departments = GetEntities<T_FM_DEPARTMENT>(t => !t.IS_DELETED && t.ENABLE_STATUS == 0, baseFilter);
|
||||
baseFilter.SelectField = new string[] { "ID", "DEPARTMENT_ID" };
|
||||
var teams = GetEntities<T_FM_TEAM>(t => !t.IS_DELETED && t.ENABLE_STATUS == 0, baseFilter);
|
||||
baseFilter.SelectField = new string[] { "TEAM_ID", "Nav_Team.NAME", "PRE_MEETING_STATUS", "DEPARTMENT_ID", "OVERTIME", "CREATE_TIME" }; //指定字段,包括导航属性
|
||||
baseFilter.SelectField = new string[] { "TEAM_ID", "Nav_Team.NAME", "PRE_MEETING_STATUS", "DEPARTMENT_ID", "OVERTIME", "CREATE_TIME", "Nav_User.DEPARTMENT_ID" }; //指定字段,包括导航属性
|
||||
var preShiftMeetingTemp = GetEntities<T_FO_PRE_SHIFT_MEETING_RECORD>(i => i.CREATE_TIME >= startTime && i.IS_DELETED == false, baseFilter).ToList();
|
||||
baseFilter.SelectField = new string[] { "CLASS_TEAM_ID", "Nav_Team.NAME", "SHIFT_STATUS", "DEPARTMENT_ID", "OVERTIME", "CREATE_TIME" }; //指定字段,包括导航属性
|
||||
baseFilter.SelectField = new string[] { "CLASS_TEAM_ID", "Nav_Team.NAME", "SHIFT_STATUS", "DEPARTMENT_ID", "OVERTIME", "CREATE_TIME", "Nav_Editor.DEPARTMENT_ID" }; //指定字段,包括导航属性
|
||||
var currentShiftTemp = GetEntities<T_FO_CURRENT_CLASS_RECORD>(i => i.CREATE_TIME >= startTime && i.IS_DELETED == false, baseFilter).ToList();
|
||||
baseFilter.SelectField = new string[] { "TEAM_ID", "Nav_Team.NAME", "SHIFT_STATUS", "DEPARTMENT_ID", "OVERTIME", "CREATE_TIME" }; //指定字段,包括导航属性
|
||||
var changeShiftTemp = GetEntities<T_FO_CHANGE_SHIFT_RECORD>(i => i.CREATE_TIME >= startTime && i.IS_DELETED == false, baseFilter).ToList();
|
||||
baseFilter.SelectField = new string[] { "TEAM_ID", "Nav_Taem.NAME", "TA_STATUS", "Nav_Taem.DEPARTMENT_ID", "OVERTIME", "CREATE_TIME" }; //指定字段,包括导航属性
|
||||
baseFilter.SelectField = new string[] { "TEAM_ID", "Nav_Taem.NAME", "TA_STATUS", "Nav_Taem.DEPARTMENT_ID", "OVERTIME", "CREATE_TIME" , "Nav_MainUser.DEPARTMENT_ID" }; //指定字段,包括导航属性
|
||||
var teamActivityTemp = GetEntities<T_FO_TEAM_ACTIVITY>(i => i.CREATE_TIME >= startTime && i.IS_DELETED == false, baseFilter).ToList();
|
||||
for (DateTime i = startTime; i <= endTime; i = i.AddMonths(i.Month - i.Month + 1).AddDays(1 - i.Day))
|
||||
{
|
||||
@ -275,7 +275,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
{
|
||||
if (item.TEAM_ID == null)
|
||||
{
|
||||
item.TEAM_ID = item.DEPARTMENT_ID;
|
||||
item.TEAM_ID = item.Nav_User?.DEPARTMENT_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -371,7 +371,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
{
|
||||
if (item.CLASS_TEAM_ID == null)
|
||||
{
|
||||
item.CLASS_TEAM_ID = item.DEPARTMENT_ID;
|
||||
item.CLASS_TEAM_ID = item.Nav_Editor?.DEPARTMENT_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -576,7 +576,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
{
|
||||
if (item.TEAM_ID == null)
|
||||
{
|
||||
item.TEAM_ID = item.DEPARTMENT_ID;
|
||||
item.TEAM_ID = item.Nav_MainUser?.DEPARTMENT_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -2310,10 +2310,10 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
DateTime dtNow = DateTime.Now;
|
||||
List<T_FM_DEPARTMENT> listDepCJ = new List<T_FM_DEPARTMENT>();
|
||||
List<T_FM_DEPARTMENT> listDepBZ = new List<T_FM_DEPARTMENT>();
|
||||
List<T_FM_DEPARTMENT> listDepBM = new List<T_FM_DEPARTMENT>();
|
||||
listDepBM = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 10).OrderBy(e => e.NUM).ToList();
|
||||
listDepCJ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 15).OrderBy(e => e.NUM).ToList();
|
||||
listDepBZ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 20).OrderBy(e => e.NUM).ToList();
|
||||
//List<T_FM_DEPARTMENT> listDepBM = new List<T_FM_DEPARTMENT>();
|
||||
//listDepBM = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 10 || e.DEPARTMENT_STATUS == 2).OrderBy(e => e.NUM).ToList();
|
||||
listDepCJ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 10 || e.DEPARTMENT_STATUS == 2).OrderBy(e => e.NUM).ToList();
|
||||
listDepBZ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 15 ||e.DEPARTMENT_TYPE == 20).OrderBy(e => e.NUM).ToList();
|
||||
//T_FM_ENUMS enums = null;
|
||||
var loginDepart = this.GetEntity<T_FM_DEPARTMENT>(t => t.ID == APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID);
|
||||
#region 月度 12 个月 安全检查、检查类型 数量
|
||||
@ -2438,11 +2438,6 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
//if (listCheckTypeID[j] != IDZH)
|
||||
//{
|
||||
var listPerChearchPer = listPerChearch.Where(e => e.CHECK_TYPE_ID == listCheckTypeID[j]);//各个检查
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// listPerChearchPer = listPerChearch.Where(e => e.YEAR == year && e.MONTH == Month && listGUID.Contains(e.SOURCEID));//综合检查
|
||||
//}
|
||||
|
||||
if (listPerChearchPer == null || !listPerChearchPer.Any())
|
||||
{
|
||||
@ -2497,15 +2492,22 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
//}
|
||||
foreach (var item in listDepCJ)
|
||||
{
|
||||
var parentIds = listDepBZ.Where(e => e.PARENT_ID.HasValue && e.PARENT_ID.Value == item.ID).Select(t => t.ID).ToList();
|
||||
var alls = checkNotices.Where(t => t.APPLY_DEPARTMENT_ID == item.ID || parentIds.Contains((Guid)t.APPLY_DEPARTMENT_ID)).ToList();
|
||||
List<Guid> parentIds = new List<Guid>();
|
||||
parentIds.Add(item.ID);
|
||||
List<Guid> allIds = new List<Guid>();
|
||||
GetDepartmentIds(orgId.Value, parentIds, ref allIds);
|
||||
var parentIdsx = listDep1MineType.Where(e => allIds.Contains(e.ID) && e.ID != item.ID).Select(t => t.ID).ToList();
|
||||
var alls = checkNotices.Where(t => t.APPLY_DEPARTMENT_ID == item.ID || parentIdsx.Contains((Guid)t.APPLY_DEPARTMENT_ID)).ToList();
|
||||
if (alls.Count() > 0)
|
||||
{
|
||||
var idsx=alls.Where(e => e.APPLY_DEPARTMENT_ID != item.ID).Select(m => m.APPLY_DEPARTMENT_ID).Distinct().ToList();
|
||||
modelCountDep = new DetailSafeCheckCountDepartment();
|
||||
modelCountDep.listName = listName;
|
||||
modelCountDep.PARENT_ID = item.PARENT_ID.Value;
|
||||
modelCountDep.Department_ID = item.ID;
|
||||
modelCountDep.NUM = item.NUM;
|
||||
//modelCountDep.listChild = listDep1MineType.Where(e=>idsx.Contains(e.ID)).OrderBy(e => e.NUM).ToList();
|
||||
//modelCountDep.RowCount = modelCountDep.listChild.Count();
|
||||
//modelCountDep.RowCount = listDepBZ.Where(e => e.PARENT_ID.HasValue && e.PARENT_ID.Value == item.ID).Count();
|
||||
modelCountDep.DepartmentName = item.NAME;
|
||||
modelCountDep.DepartmentType = item.DEPARTMENT_TYPE;
|
||||
@ -2558,10 +2560,11 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
// item.RowCount = item.listChild.Count();
|
||||
//}
|
||||
//if (item.DepartmentType == 15)
|
||||
{
|
||||
item.listChild = listCheckDepCountBZ.Where(e => e.PARENT_ID == item.Department_ID).OrderBy(e => e.NUM).ToList();
|
||||
var parentIds = listCheckDepCountBZ.Where(e => e.PARENT_ID == item.Department_ID).Select(t => t.Department_ID);
|
||||
|
||||
item.listChild = listCheckDepCountBZ.Where(e => e.PARENT_ID == item.Department_ID || parentIds.Contains(e.PARENT_ID)).OrderBy(e => e.NUM).ToList();
|
||||
item.RowCount = item.listChild.Count();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -2622,8 +2625,8 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
List<T_FM_DEPARTMENT> listDepCJ = new List<T_FM_DEPARTMENT>();
|
||||
List<T_FM_DEPARTMENT> listDepBZ = new List<T_FM_DEPARTMENT>();
|
||||
|
||||
listDepCJ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 15).OrderBy(e => e.NUM).ToList();
|
||||
listDepBZ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 20).OrderBy(e => e.NUM).ToList();
|
||||
listDepCJ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 10 || e.DEPARTMENT_STATUS==2).OrderBy(e => e.NUM).ToList();
|
||||
listDepBZ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 15 || e.DEPARTMENT_TYPE == 20).OrderBy(e => e.NUM).ToList();
|
||||
|
||||
|
||||
#region //月度 隐患整改情况
|
||||
@ -2811,8 +2814,14 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
int All = 0;
|
||||
foreach (var item in listDepCJ)
|
||||
{
|
||||
var classIds = listDepBZ.Where(e => e.PARENT_ID.HasValue && e.PARENT_ID.Value == item.ID).Select(t => t.ID);
|
||||
var alls = hiddens.Where(t => t.APPLY_DEPARTMENT_ID == item.ID || classIds.Contains((Guid)t.APPLY_DEPARTMENT_ID));
|
||||
List<Guid> parentIds = new List<Guid>();
|
||||
parentIds.Add(item.ID);
|
||||
List<Guid> allIds = new List<Guid>();
|
||||
GetDepartmentIds(orgId.Value, parentIds, ref allIds);
|
||||
var parentIdsx = listDep1MineType.Where(e => allIds.Contains(e.ID) && e.ID != item.ID).Select(t => t.ID).ToList();
|
||||
var alls = hiddens.Where(t => t.APPLY_DEPARTMENT_ID == item.ID || parentIdsx.Contains((Guid)t.APPLY_DEPARTMENT_ID)).ToList();
|
||||
//var classIds = listDepBZ.Where(e => e.PARENT_ID.HasValue && e.PARENT_ID.Value == item.ID).Select(t => t.ID);
|
||||
//var alls = hiddens.Where(t => t.APPLY_DEPARTMENT_ID == item.ID || classIds.Contains((Guid)t.APPLY_DEPARTMENT_ID));
|
||||
if (alls.Count() > 0)
|
||||
{
|
||||
modelCountDep = new DetailSafeCheckCountDepartment();
|
||||
@ -2873,8 +2882,8 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
|
||||
}
|
||||
//listCheckDepCountCJ = listCheckDepCountCJ.Where(t => t.TotalCount != 0).ToList();
|
||||
var departIds = listCheckDepCountCJ.Select(t => t.Department_ID).Distinct().ToList();
|
||||
listDepBZ = listDepBZ.Where(t => t.PARENT_ID != null && departIds.Contains((Guid)t.PARENT_ID)).ToList();
|
||||
//var departIds = listCheckDepCountCJ.Select(t => t.Department_ID).Distinct().ToList();
|
||||
//listDepBZ = listDepBZ.Where(t => t.PARENT_ID != null && departIds.Contains((Guid)t.PARENT_ID)).ToList();
|
||||
foreach (var item in listDepBZ)
|
||||
{
|
||||
var alls = hiddens.Where(t => t.APPLY_DEPARTMENT_ID == item.ID);
|
||||
@ -2939,18 +2948,20 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
//listCheckDepCountBZ = listCheckDepCountBZ.Where(t => t.TotalCount != 0).ToList();
|
||||
foreach (var item in listCheckDepCountCJ)
|
||||
{
|
||||
item.listChild = listCheckDepCountBZ.Where(e => e.PARENT_ID == item.Department_ID).OrderBy(e => e.NUM).ToList();
|
||||
item.listCount = new List<int>();
|
||||
var onTime = item.listChild.Sum(t => t.OnCount) + item.OnCount;
|
||||
item.listCount.Add(onTime);
|
||||
var overTime = item.listChild.Sum(t => t.OverCount) + item.OverCount;
|
||||
item.listCount.Add(overTime);
|
||||
var noTime = item.listChild.Sum(t => t.NoCount) + item.NoCount;
|
||||
item.listCount.Add(noTime);
|
||||
var val = onTime + overTime;
|
||||
var count = item.TotalCount;
|
||||
var rate = count == 0 ? 0 : (int)(10000.00 * val / count);
|
||||
item.listCount.Add(rate);
|
||||
var parentIds = listCheckDepCountBZ.Where(e => e.PARENT_ID == item.Department_ID).Select(t => t.Department_ID);
|
||||
item.listChild = listCheckDepCountBZ.Where(e => e.PARENT_ID == item.Department_ID || parentIds.Contains(e.PARENT_ID)).OrderBy(e => e.NUM).ToList();
|
||||
//item.listChild = listCheckDepCountBZ.Where(e => e.PARENT_ID == item.Department_ID).OrderBy(e => e.NUM).ToList();
|
||||
//item.listCount = new List<int>();
|
||||
//var onTime = item.listChild.Sum(t => t.OnCount) + item.OnCount;
|
||||
//item.listCount.Add(onTime);
|
||||
//var overTime = item.listChild.Sum(t => t.OverCount) + item.OverCount;
|
||||
//item.listCount.Add(overTime);
|
||||
//var noTime = item.listChild.Sum(t => t.NoCount) + item.NoCount;
|
||||
//item.listCount.Add(noTime);
|
||||
//var val = onTime + overTime;
|
||||
//var count = item.TotalCount;
|
||||
//var rate = count == 0 ? 0 : (int)(10000.00 * val / count);
|
||||
//item.listCount.Add(rate);
|
||||
item.RowCount = item.listChild.Count();
|
||||
}
|
||||
|
||||
@ -3007,6 +3018,24 @@ namespace APT.SC.WebApi.Controllers.Api.BI
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回所有下级部门节点
|
||||
/// </summary>
|
||||
/// <param name="orgId"></param>
|
||||
/// <param name="listDepIDInt"></param>
|
||||
/// <param name="departmentIdPs"></param>
|
||||
public void GetDepartmentIds(Guid orgId, List<Guid> listDepIDInt, ref List<Guid> departmentIdPs)
|
||||
{
|
||||
var listDep = GetEntities<T_FM_DEPARTMENT>(e => !e.IS_DELETED && e.PARENT_ID.HasValue && listDepIDInt.Contains(e.PARENT_ID.Value), new BaseFilter(orgId));
|
||||
|
||||
if (listDep != null && listDep.Any())
|
||||
{
|
||||
listDepIDInt = listDep.Select(e => e.ID).ToList();
|
||||
departmentIdPs.AddRange(listDepIDInt);
|
||||
GetDepartmentIds(orgId, listDepIDInt, ref departmentIdPs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -9700,11 +9700,21 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
DateTime startTime = Convert.ToDateTime(filter.Parameter2);
|
||||
completions = completions.Where(t => t.MONTH >= startTime).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
var startTime = Convert.ToDateTime(DateTime.Now.Year + "-" + DateTime.Now.Month + "-01 00:00:00");
|
||||
completions = completions.Where(t => t.MONTH >= startTime).ToList();
|
||||
}
|
||||
if (!string.IsNullOrEmpty(filter.Parameter3))
|
||||
{
|
||||
DateTime endTime = Convert.ToDateTime(filter.Parameter3);
|
||||
completions = completions.Where(t => t.MONTH <= endTime).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
var endTime = Convert.ToDateTime(DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + " 23:59:59");
|
||||
completions = completions.Where(t => t.MONTH <= endTime).ToList();
|
||||
}
|
||||
//if (teamIds != null && teamIds.Any())
|
||||
{
|
||||
completionLists = completions.Where(m => m.TEAM_ID != null).GroupBy(t => new { t.TEAM_ID, t.TEAM_NAME }).Select(group => new GroupbyDepartmentId
|
||||
@ -9771,28 +9781,14 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
dynamic ret = new System.Dynamic.ExpandoObject();
|
||||
var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId.Value;
|
||||
//var mineType = 30;
|
||||
var departmentIds = new List<Guid>();
|
||||
List<GroupbyDepartmentCompletion> completionLists = new List<GroupbyDepartmentCompletion>();
|
||||
List<T_FM_DEPARTMENT_COMPLETION> completionSorts = new List<T_FM_DEPARTMENT_COMPLETION>();
|
||||
//if (string.IsNullOrEmpty(filter.Keyword))
|
||||
// return ret;
|
||||
//var departmentInfo = this.GetEntities<T_FM_DEPARTMENT>(t => t.PRODUCTION_UNIT_ID == Guid.Parse(filter.Keyword.ToString()), new BaseFilter(orgId));
|
||||
var completions = GetEntities<T_FM_DEPARTMENT_COMPLETION>(t => !t.IS_DELETED, new BaseFilter(orgId)).ToList();
|
||||
var deptIds = completions.Where(t => t.DEPARTMENT_ID != null).Select(t => (Guid)t.DEPARTMENT_ID).Distinct().ToList();
|
||||
departmentIds.AddRange(deptIds);
|
||||
var shopIds = completions.Where(t => t.SHOP_DEPARTMENT_ID != null).Select(t => (Guid)t.SHOP_DEPARTMENT_ID).Distinct().ToList();
|
||||
departmentIds.AddRange(shopIds);
|
||||
var classIds = completions.Where(t => t.TEAM_ID != null).Select(t => (Guid)t.TEAM_ID).Distinct().ToList();
|
||||
departmentIds.AddRange(classIds);
|
||||
var departmentInfo = this.GetEntities<T_FM_DEPARTMENT>(t => t.ENABLE_STATUS == 0 && t.CATEGORY == FMCATEGORY.ACTURE, new BaseFilter(orgId), "Nav_Parent");
|
||||
if (departmentIds != null && departmentIds.Any())
|
||||
{
|
||||
departmentInfo = departmentInfo.Where(t => departmentIds.Contains(t.ID)).ToList();
|
||||
}
|
||||
if (departmentInfo == null || !departmentInfo.Any())
|
||||
return ret;
|
||||
else
|
||||
departmentIds = departmentInfo.Select(t => t.ID).Distinct().ToList();
|
||||
var departmentInfos = this.GetEntities<T_FM_DEPARTMENT>(t => t.ENABLE_STATUS == 0 && t.CATEGORY == FMCATEGORY.ACTURE, new BaseFilter(orgId), "Nav_Parent");
|
||||
|
||||
//List<T_FM_DEPARTMENT> listDepBM = new List<T_FM_DEPARTMENT>();
|
||||
//List<T_FM_DEPARTMENT> listDepCJ = new List<T_FM_DEPARTMENT>();
|
||||
//List<T_FM_DEPARTMENT> listDepBZ = new List<T_FM_DEPARTMENT>();
|
||||
@ -9827,19 +9823,7 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
}
|
||||
ret.rateData = completionSorts.OrderBy(t => t.MONTH).ToList();
|
||||
}
|
||||
completionLists = completions.Where(t=>t.TEAM_ID!=null).GroupBy(t => new { t.TEAM_ID, t.TEAM_NAME }).Select(group => new GroupbyDepartmentCompletion
|
||||
{
|
||||
shopId = group.FirstOrDefault(i => i.TEAM_ID == group.Key.TEAM_ID)?.DEPARTMENT_ID,
|
||||
shopName = group.FirstOrDefault(i => i.TEAM_ID == group.Key.TEAM_ID)?.DEPARTMENT_NAME,
|
||||
teamId = group.Key.TEAM_ID,
|
||||
teamName = group.Key.TEAM_NAME,
|
||||
teamDoneCount = group.Where(i => i.TEAM_ID == group.Key.TEAM_ID).Sum(m => m.FINISH_COUNT),
|
||||
teamOntimeCount = group.Where(i => i.TEAM_ID == group.Key.TEAM_ID).Sum(m => m.ONTIME_COUNT),
|
||||
teamUndoneCount = group.Where(i => i.TEAM_ID == group.Key.TEAM_ID).Sum(m => m.WAITTING_COUNT),
|
||||
teamTotalCount = group.Where(i => i.TEAM_ID == group.Key.TEAM_ID).Sum(m => m.TOTAL_COUNT),
|
||||
}).ToList();
|
||||
|
||||
//completionLists = completions.Where(t => t.TEAM_ID != null).GroupBy(t => new { t.TEAM_ID, t.TEAM_NAME }).Select(group => new GroupbyDepartmentCompletion
|
||||
//completionLists = completions.Where(t=>t.TEAM_ID!=null).GroupBy(t => new { t.TEAM_ID, t.TEAM_NAME }).Select(group => new GroupbyDepartmentCompletion
|
||||
//{
|
||||
// shopId = group.FirstOrDefault(i => i.TEAM_ID == group.Key.TEAM_ID)?.DEPARTMENT_ID,
|
||||
// shopName = group.FirstOrDefault(i => i.TEAM_ID == group.Key.TEAM_ID)?.DEPARTMENT_NAME,
|
||||
@ -9850,79 +9834,69 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
// teamUndoneCount = group.Where(i => i.TEAM_ID == group.Key.TEAM_ID).Sum(m => m.WAITTING_COUNT),
|
||||
// teamTotalCount = group.Where(i => i.TEAM_ID == group.Key.TEAM_ID).Sum(m => m.TOTAL_COUNT),
|
||||
//}).ToList();
|
||||
//var shopCompletionLists = completions.Where(t => t.SHOP_DEPARTMENT_ID != null).GroupBy(t => new { t.SHOP_DEPARTMENT_ID, t.SHOP_DEPARTMENT_NAME }).Select(group => new GroupbyDepartmentCompletion
|
||||
//{
|
||||
//var departmentInfos = this.GetEntities<T_FM_DEPARTMENT>(t => t.ENABLE_STATUS == 0 && t.CATEGORY == FMCATEGORY.ACTURE, new BaseFilter(orgId));
|
||||
|
||||
// shopId = group.FirstOrDefault(i => i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID)?.DEPARTMENT_ID,
|
||||
// shopName = group.FirstOrDefault(i => i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID)?.DEPARTMENT_NAME,
|
||||
// teamId = group.Key.SHOP_DEPARTMENT_ID,
|
||||
// teamName = group.Key.SHOP_DEPARTMENT_NAME,
|
||||
// teamDoneCount = group.Where(i => i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID && i.TEAM_ID == null).Sum(m => m.FINISH_COUNT),
|
||||
// teamOntimeCount = group.Where(i => i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID && i.TEAM_ID == null).Sum(m => m.ONTIME_COUNT),
|
||||
// teamUndoneCount = group.Where(i => i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID && i.TEAM_ID == null).Sum(m => m.WAITTING_COUNT),
|
||||
// teamTotalCount = group.Where(i => i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID && i.TEAM_ID == null).Sum(m => m.TOTAL_COUNT),
|
||||
//}).ToList();
|
||||
//completionLists.AddRange(shopCompletionLists);
|
||||
//var deptCompletionLists = completions.Where(t => t.DEPARTMENT_ID != null).GroupBy(t => new { t.DEPARTMENT_ID, t.DEPARTMENT_NAME }).Select(group => new GroupbyDepartmentCompletion
|
||||
//var departmentIds = departmentInfos.Where(t => t.DEPARTMENT_TYPE == 10 || t.DEPARTMENT_STATUS == 2).ToList();
|
||||
//if (departmentIds != null && departmentIds.Any())
|
||||
//{
|
||||
// shopId = group.Key.DEPARTMENT_ID,
|
||||
// shopName = group.Key.DEPARTMENT_NAME,
|
||||
// teamId = group.Key.DEPARTMENT_ID,
|
||||
// teamName = group.Key.DEPARTMENT_NAME,
|
||||
// shopDoneCount = group.Where(i => i.DEPARTMENT_ID == group.Key.DEPARTMENT_ID).Sum(m => m.FINISH_COUNT),
|
||||
// shopOntimeCount = group.Where(i => i.DEPARTMENT_ID == group.Key.DEPARTMENT_ID).Sum(m => m.ONTIME_COUNT),
|
||||
// shopTotalCount = group.Where(i => i.DEPARTMENT_ID == group.Key.DEPARTMENT_ID).Sum(m => m.TOTAL_COUNT),
|
||||
//}).ToList();
|
||||
//completionLists.AddRange(deptCompletionLists);
|
||||
//foreach (var item in listDepBM)
|
||||
//{
|
||||
// var modelCountDep = new GroupbyDepartmentCompletion();
|
||||
// modelCountDep.shopId = item.ID;
|
||||
// modelCountDep.shopName = item.NAME;
|
||||
// modelCountDep.teamId = item.ID;
|
||||
// modelCountDep.teamName = item.NAME;
|
||||
// modelCountDep.shopDoneCount = completions.Where(e => (e.DEPARTMENT_ID.HasValue && e.DEPARTMENT_ID.Value == item.ID) || (e.SHOP_DEPARTMENT_ID.HasValue && e.SHOP_DEPARTMENT_ID == item.ID)).Sum(m=>m.FINISH_COUNT);
|
||||
// modelCountDep.shopOntimeCount = completions.Where(e => (e.DEPARTMENT_ID.HasValue && e.DEPARTMENT_ID.Value == item.ID) ||(e.SHOP_DEPARTMENT_ID.HasValue && e.SHOP_DEPARTMENT_ID == item.ID)).Sum(m => m.FINISH_COUNT);
|
||||
// modelCountDep.shopTotalCount = completions.Where(e => (e.DEPARTMENT_ID.HasValue && e.DEPARTMENT_ID.Value == item.ID) || (e.SHOP_DEPARTMENT_ID.HasValue && e.SHOP_DEPARTMENT_ID == item.ID)).Sum(m => m.TOTAL_COUNT);
|
||||
// if (modelCountDep.shopTotalCount != 0)
|
||||
// foreach (var item in departmentIds)
|
||||
// {
|
||||
// completionLists.Add(modelCountDep);
|
||||
// }
|
||||
// completionLists.Add(modelCountDep);
|
||||
// var cjIds = departmentInfo.Where(e => e.PARENT_ID.HasValue && e.PARENT_ID.Value == item.ID).Select(t => t.ID).ToList();
|
||||
// var tempbzIds = departmentInfo.Where(e => e.PARENT_ID.HasValue && cjIds.Contains(e.PARENT_ID.Value)).Select(t => t.ID).ToList();
|
||||
// cjIds.AddRange(tempbzIds);
|
||||
// if (cjIds.Distinct().Any())
|
||||
// {
|
||||
// foreach (var item2 in cjIds)
|
||||
// {
|
||||
// var first = departmentInfo.FirstOrDefault(t => t.ID == item2);
|
||||
// var modelCountDepChild = new GroupbyDepartmentCompletion();
|
||||
// modelCountDepChild.shopId = item.ID;
|
||||
// modelCountDepChild.shopName = item.NAME;
|
||||
// modelCountDepChild.teamId = item2;
|
||||
// modelCountDepChild.teamName = first?.NAME;
|
||||
// if (first.DEPARTMENT_TYPE == 15)
|
||||
// {
|
||||
// modelCountDepChild.teamDoneCount = completions.Where(e => e.SHOP_DEPARTMENT_ID.HasValue && e.SHOP_DEPARTMENT_ID.Value == item2).Sum(m => m.FINISH_COUNT);
|
||||
// modelCountDepChild.teamOntimeCount = completions.Where(e => e.SHOP_DEPARTMENT_ID.HasValue && e.SHOP_DEPARTMENT_ID.Value == item2).Sum(m => m.FINISH_COUNT);
|
||||
// modelCountDepChild.teamTotalCount = completions.Where(e => e.SHOP_DEPARTMENT_ID.HasValue && e.SHOP_DEPARTMENT_ID.Value == item2).Sum(m => m.TOTAL_COUNT);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// modelCountDepChild.teamDoneCount = completions.Where(e => e.TEAM_ID.HasValue && e.TEAM_ID.Value == item2).Sum(m => m.FINISH_COUNT);
|
||||
// modelCountDepChild.teamOntimeCount = completions.Where(e => e.TEAM_ID.HasValue && e.TEAM_ID.Value == item2).Sum(m => m.FINISH_COUNT);
|
||||
// modelCountDepChild.teamTotalCount = completions.Where(e => e.TEAM_ID.HasValue && e.TEAM_ID.Value == item2).Sum(m => m.TOTAL_COUNT);
|
||||
|
||||
// }
|
||||
// if (modelCountDepChild.teamTotalCount != 0)
|
||||
// {
|
||||
// completionLists.Add(modelCountDepChild);
|
||||
// }
|
||||
// }
|
||||
// List<Guid> parentIds = new List<Guid>();
|
||||
// parentIds.Add(item.ID);
|
||||
// List<Guid> allIds = new List<Guid>();
|
||||
// GetDepartmentIds(orgId, parentIds, ref allIds);
|
||||
// var coms = completions.Where(t => t.TEAM_ID != null && allIds.Contains((Guid)t.TEAM_ID)).ToList();
|
||||
// GroupbyDepartmentCompletion completionSort = new GroupbyDepartmentCompletion();
|
||||
// completionSort.shopId = item.ID;
|
||||
// completionSort.shopName = item.NAME;
|
||||
// completionSort.teamDoneCount = coms.Sum(m => m.FINISH_COUNT);
|
||||
// completionSort.teamOntimeCount = coms.Sum(m => m.ONTIME_COUNT);
|
||||
// completionSort.teamTotalCount = coms.Sum(m => m.TOTAL_COUNT);
|
||||
// completionSort.teamUndoneCount = coms.Sum(m => m.WAITTING_COUNT);
|
||||
// if(completionSort.teamTotalCount!=0)
|
||||
// completionLists.Add(completionSort);
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
var classIds = departmentInfos.Where(t => t.DEPARTMENT_TYPE == 15 || t.DEPARTMENT_TYPE == 20).ToList();
|
||||
if (classIds != null && classIds.Any())
|
||||
{
|
||||
foreach (var item in classIds)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.NAME))
|
||||
{
|
||||
var coms = completions.Where(t => t.DEPARTMENT_ID != null && t.DEPARTMENT_ID == item.ID).ToList();
|
||||
GroupbyDepartmentCompletion completionSort = new GroupbyDepartmentCompletion();
|
||||
completionSort.teamId = item.ID;
|
||||
completionSort.teamName = item.NAME;
|
||||
var parentInfo = departmentInfos.FirstOrDefault(t => t.ID == item.PARENT_ID);
|
||||
if (parentInfo != null)
|
||||
{
|
||||
if (parentInfo.DEPARTMENT_TYPE == 15)
|
||||
{
|
||||
var parentUp = departmentInfos.FirstOrDefault(t => t.ID == parentInfo.PARENT_ID);
|
||||
if (parentUp != null)
|
||||
{
|
||||
completionSort.shopId = parentUp.ID;
|
||||
completionSort.shopName = parentUp.NAME;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
completionSort.shopId = parentInfo.ID;
|
||||
completionSort.shopName = parentInfo.NAME;
|
||||
}
|
||||
}
|
||||
completionSort.teamDoneCount = coms.Sum(m => m.FINISH_COUNT);
|
||||
completionSort.teamOntimeCount = coms.Sum(m => m.ONTIME_COUNT);
|
||||
completionSort.teamTotalCount = coms.Sum(m => m.TOTAL_COUNT);
|
||||
completionSort.teamUndoneCount = coms.Sum(m => m.WAITTING_COUNT);
|
||||
if (completionSort.teamTotalCount != 0)
|
||||
completionLists.Add(completionSort);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (completionLists != null && completionLists.Any())
|
||||
{
|
||||
@ -10076,8 +10050,8 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("GetJobCompletionSort")]
|
||||
public JsonActionResult<List<T_FM_WORK_TICKET_COMPLETION>> GetJobCompletionSort([FromBody] KeywordFilter filter)
|
||||
[HttpPost, Route("GetJobCompletionSortX")]
|
||||
public JsonActionResult<List<T_FM_WORK_TICKET_COMPLETION>> GetJobCompletionSortX([FromBody] KeywordFilter filter)
|
||||
{
|
||||
return SafeExecute<List<T_FM_WORK_TICKET_COMPLETION>>(() =>
|
||||
{
|
||||
@ -10262,7 +10236,217 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
return completionSorts1;
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 首页工作票完成数前八(部门级)
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("GetJobCompletionSort")]
|
||||
public JsonActionResult<List<T_FM_WORK_TICKET_COMPLETION>> GetJobCompletionSort([FromBody] KeywordFilter filter)
|
||||
{
|
||||
return SafeExecute<List<T_FM_WORK_TICKET_COMPLETION>>(() =>
|
||||
{
|
||||
var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId.Value;
|
||||
List<T_FM_WORK_TICKET_COMPLETION> completionSorts = new List<T_FM_WORK_TICKET_COMPLETION>();
|
||||
//if (string.IsNullOrEmpty(filter.Keyword))
|
||||
// return completionSorts;
|
||||
//int MineType = 0;
|
||||
//try
|
||||
//{
|
||||
// MineType = int.Parse(filter.Keyword.ToString());
|
||||
//}
|
||||
//catch
|
||||
//{
|
||||
// MineType = 30;
|
||||
//}
|
||||
#region 判断 从Redis中获取数据 有就直接返回到前端 没有就按原来的进行搜索 最后再判断存入Redis中
|
||||
|
||||
var redisCode = string.Format(RedisCacheKey.HomeJobCompletion, APT.Infrastructure.Api.AppContext.CurrentSession.OrgId);
|
||||
DateTime dtNow = DateTime.Now;
|
||||
bool isRedisConfig = true;
|
||||
var redisConfig = APT.Infrastructure.Api.ConfigurationManager.AppSettings["RedisFormConfig"];
|
||||
List<HomeResultMineType> listHomeRedis = null;
|
||||
if (!string.IsNullOrEmpty(redisConfig))
|
||||
isRedisConfig = bool.Parse(redisConfig);
|
||||
|
||||
if (isRedisConfig && CsRedisManager.KeyExists(redisCode))
|
||||
listHomeRedis = CsRedisManager.StringGet<List<HomeResultMineType>>(redisCode);
|
||||
|
||||
if (listHomeRedis != null && listHomeRedis.Count() > 0)
|
||||
{
|
||||
foreach (var item in listHomeRedis)
|
||||
{
|
||||
//if (item.MineType == MineType)
|
||||
{
|
||||
if (dtNow.ToString("yyyyMMddHH") == item.yyyyMMddHH)
|
||||
{
|
||||
completionSorts = item.result;
|
||||
}
|
||||
else
|
||||
{
|
||||
listHomeRedis.Remove(item);//Key不匹配 过期数据删除
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//redis获取到了数据
|
||||
if (completionSorts != null && completionSorts.Count() > 0)
|
||||
{
|
||||
return completionSorts;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取数据
|
||||
|
||||
|
||||
List<T_FM_WORK_TICKET_COMPLETION> completions = new List<T_FM_WORK_TICKET_COMPLETION>();
|
||||
BaseFilter baseFilter = new BaseFilter(filter.GetOrgId());
|
||||
baseFilter.IgnoreDataRule = true;
|
||||
var startTime = Convert.ToDateTime(DateTime.Now.Year + "-" + DateTime.Now.Month + "-01 00:00:00");
|
||||
var endTime = Convert.ToDateTime(DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + " 23:59:59");
|
||||
baseFilter.SelectField = new string[] { "ID", "NAME", "DEPARTMENT_TYPE", "Nav_Parent.NAME", "Nav_Parent.Nav_Parent", "PARENT_ID" };
|
||||
var departments = GetEntities<T_FM_DEPARTMENT>(t => !t.IS_DELETED, baseFilter);
|
||||
baseFilter.SelectField = new string[] { "ID", "IS_PUBLISH", "DEPARTMENT_ID", "CREATE_TIME", "IS_OVERTIME", "APPLY_USER_ID" }; //指定字段,包括导航属性
|
||||
var jobInfos = GetEntities<T_FO_CRUCIAL_LICENSE_JOB>(i => i.CREATE_TIME >= startTime && i.IS_DELETED == false && i.APPLY_USER_ID != null, baseFilter).ToList();
|
||||
var jobIds = jobInfos.Select(t => t.ID).ToList();
|
||||
baseFilter.SelectField = new string[] { "ID", "STATUS", "APPLY_DEPARTMENT_ID", "CREATE_TIME", "IS_OVERTIME" };
|
||||
var fireJobInfos = GetEntities<T_FO_FIRE_JOB>(i => i.CREATE_TIME >= startTime && i.IS_DELETED == false && i.APPLY_DEPARTMENT_ID != null, baseFilter).ToList();
|
||||
var fireJobIds = fireJobInfos.Select(t => t.ID).ToList();
|
||||
jobIds.AddRange(fireJobIds);
|
||||
baseFilter.SelectField = new string[] { "ID", "NOTICE_STATUS", "CREATE_TIME", "SOURCE_DATA_ID" }; //指定字段,包括导航属性
|
||||
var tasks = this.GetEntities<T_FM_NOTIFICATION_TASK>(t => t.IS_DELETED == false && t.CREATE_TIME >= startTime && t.NOTICE_STATUS == 2 && jobIds.Contains((Guid)t.SOURCE_DATA_ID), baseFilter).ToList();
|
||||
var userIds = jobInfos.Select(t => t.APPLY_USER_ID).Distinct().ToList();
|
||||
baseFilter.SelectField = new string[] { "ID", "DEPARTMENT_ID" }; //指定字段,包括导航属性
|
||||
var userInfos = GetEntities<T_FM_USER>(i => userIds.Contains(i.ID), baseFilter).ToList();
|
||||
List<JobInfo> jobs = new List<JobInfo>();
|
||||
foreach (var item in jobInfos)
|
||||
{
|
||||
var task = tasks.FirstOrDefault(t => t.SOURCE_DATA_ID == item.ID);
|
||||
if (task == null)
|
||||
item.IS_OVERTIME = 0;
|
||||
else
|
||||
item.IS_OVERTIME = 1;
|
||||
var user = userInfos.FirstOrDefault(t => t.ID == item.APPLY_USER_ID);
|
||||
JobInfo job = new JobInfo();
|
||||
job.CREATE_TIME = item.CREATE_TIME;
|
||||
job.IS_OVERTIME = item.IS_OVERTIME;
|
||||
job.DEPARTMENT_ID = user?.DEPARTMENT_ID;
|
||||
job.IS_PUBLISH = item.IS_PUBLISH;
|
||||
jobs.Add(job);
|
||||
}
|
||||
foreach (var item in fireJobInfos)
|
||||
{
|
||||
var task = tasks.FirstOrDefault(t => t.SOURCE_DATA_ID == item.ID);
|
||||
if (task == null)
|
||||
item.IS_OVERTIME = 0;
|
||||
else
|
||||
item.IS_OVERTIME = 1;
|
||||
JobInfo job = new JobInfo();
|
||||
job.CREATE_TIME = item.CREATE_TIME;
|
||||
job.IS_OVERTIME = item.IS_OVERTIME;
|
||||
job.DEPARTMENT_ID = item.APPLY_DEPARTMENT_ID;
|
||||
job.IS_PUBLISH = item.STATUS == PFStandardStatus.Archived ? 5 : 0;
|
||||
jobs.Add(job);
|
||||
}
|
||||
//var shopIds = completions.Where(t => t.SHOP_DEPARTMENT_ID != null).Select(t => (Guid)t.SHOP_DEPARTMENT_ID).ToList();
|
||||
//departmentIds.AddRange(shopIds);
|
||||
//var classIds = completions.Where(t => t.TEAM_ID != null).Select(t => (Guid)t.TEAM_ID).ToList();
|
||||
//departmentIds.AddRange(classIds);
|
||||
var departmentInfos = this.GetEntities<T_FM_DEPARTMENT>(t => t.ENABLE_STATUS == 0 && t.CATEGORY == FMCATEGORY.ACTURE, new BaseFilter(orgId));
|
||||
var departmentIds = departmentInfos.Where(t => t.DEPARTMENT_TYPE == 10 || t.DEPARTMENT_STATUS == 2).ToList();
|
||||
if (departmentIds != null && departmentIds.Any())
|
||||
{
|
||||
foreach (var item in departmentIds)
|
||||
{
|
||||
List<Guid> parentIds = new List<Guid>();
|
||||
parentIds.Add(item.ID);
|
||||
List<Guid> allIds = new List<Guid>();
|
||||
GetDepartmentIds(orgId, parentIds, ref allIds);
|
||||
var coms = jobs.Where(t => t.DEPARTMENT_ID != null && allIds.Contains((Guid)t.DEPARTMENT_ID)).ToList();
|
||||
T_FM_WORK_TICKET_COMPLETION completionSort = new T_FM_WORK_TICKET_COMPLETION();
|
||||
completionSort.TEAM_ID = item.ID;
|
||||
completionSort.TEAM_NAME = item.NAME;
|
||||
completionSort.FINISH_COUNT = coms.Count(t=>t.IS_PUBLISH == 5);
|
||||
completionSort.OVER_FINISH_COUNT = coms.Count(t => t.IS_PUBLISH == 5 && t.IS_OVERTIME == 1);
|
||||
completionSort.TOTAL_COUNT = coms.Count();
|
||||
completionSort.WAITTING_COUNT = coms.Count(t => t.IS_PUBLISH != 5);
|
||||
if (completionSort.TOTAL_COUNT == 0)
|
||||
{
|
||||
completionSort.CALC = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
var tempCalc = ((double)completionSort.FINISH_COUNT + (double)completionSort.OVER_FINISH_COUNT) / (double)completionSort.TOTAL_COUNT;
|
||||
completionSort.CALC = tempCalc;
|
||||
completionSorts.Add(completionSort);
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (completionLists != null && completionLists.Any())
|
||||
//{
|
||||
// foreach (var item in completionLists)
|
||||
// {
|
||||
// T_FM_WORK_TICKET_COMPLETION completionSort = new T_FM_WORK_TICKET_COMPLETION();
|
||||
// completionSort.TEAM_ID = item.departmentId;
|
||||
// completionSort.TEAM_NAME = item.departmentName;
|
||||
// completionSort.FINISH_COUNT = item.doneCount;
|
||||
// completionSort.OVER_FINISH_COUNT = item.timeOverCount;
|
||||
// completionSort.TOTAL_COUNT = item.TotalCount;
|
||||
// completionSort.WAITTING_COUNT = item.TotalCount - item.doneCount - item.timeOverCount;
|
||||
// completionSorts.Add(completionSort);
|
||||
// }
|
||||
//}
|
||||
//foreach (var item in completionSorts)
|
||||
//{
|
||||
// if (item.TOTAL_COUNT == 0)
|
||||
// {
|
||||
// item.CALC = 0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var tempCalc = ((double)item.FINISH_COUNT + (double)item.OVER_FINISH_COUNT) / (double)item.TOTAL_COUNT;
|
||||
// item.CALC = tempCalc;
|
||||
// }
|
||||
//}
|
||||
List<T_FM_WORK_TICKET_COMPLETION> completionSorts1 = completionSorts.OrderByDescending(t => t.CALC).Take(8).ToList();
|
||||
int i = 1;
|
||||
foreach (var item in completionSorts1)
|
||||
{
|
||||
item.NUM = i;
|
||||
i++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 搜索结果 判断存入Redis中
|
||||
|
||||
if (isRedisConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (listHomeRedis == null)
|
||||
listHomeRedis = new List<HomeResultMineType>();
|
||||
|
||||
listHomeRedis.Add(new HomeResultMineType()
|
||||
{
|
||||
//MineType = MineType,
|
||||
yyyyMMddHH = dtNow.ToString("yyyyMMddHH"),
|
||||
result = completionSorts1
|
||||
});
|
||||
|
||||
CsRedisManager.StringSet<List<HomeResultMineType>>(redisCode, listHomeRedis);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
return completionSorts1;
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 首页工作票完成数前八(车间级)
|
||||
/// </summary>
|
||||
@ -10338,8 +10522,8 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("GetJobCompletionDetail")]
|
||||
public JsonActionResult<dynamic> GetJobCompletionDetail([FromBody] KeywordFilter filter)
|
||||
[HttpPost, Route("GetJobCompletionDetailX")]
|
||||
public JsonActionResult<dynamic> GetJobCompletionDetailX([FromBody] KeywordFilter filter)
|
||||
{
|
||||
return SafeExecute<dynamic>(() =>
|
||||
{
|
||||
@ -10499,6 +10683,278 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 首页工作票完成数前八(详情页)
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("GetJobCompletionDetail")]
|
||||
public JsonActionResult<dynamic> GetJobCompletionDetail([FromBody] KeywordFilter filter)
|
||||
{
|
||||
return SafeExecute<dynamic>(() =>
|
||||
{
|
||||
dynamic ret = new System.Dynamic.ExpandoObject();
|
||||
var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId.Value;
|
||||
//var mineType = 30;
|
||||
List<GroupbyDepartmentCompletion> completionLists = new List<GroupbyDepartmentCompletion>();
|
||||
List<T_FM_WORK_TICKET_COMPLETION> completionSorts = new List<T_FM_WORK_TICKET_COMPLETION>();
|
||||
List<T_FM_WORK_TICKET_COMPLETION> completions = new List<T_FM_WORK_TICKET_COMPLETION>();
|
||||
BaseFilter baseFilter = new BaseFilter(filter.GetOrgId());
|
||||
baseFilter.IgnoreDataRule = true;
|
||||
var startTime = Convert.ToDateTime(DateTime.Now.AddMonths(-11).Year + "-" + DateTime.Now.AddMonths(-11).Month + "-01 00:00:00");
|
||||
var endTime = Convert.ToDateTime(DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + " 23:59:59");
|
||||
baseFilter.SelectField = new string[] { "ID", "NAME", "DEPARTMENT_TYPE", "Nav_Parent.NAME", "Nav_Parent.Nav_Parent", "PARENT_ID" };
|
||||
var departments = GetEntities<T_FM_DEPARTMENT>(t => !t.IS_DELETED, baseFilter);
|
||||
baseFilter.SelectField = new string[] { "ID", "IS_PUBLISH", "DEPARTMENT_ID", "CREATE_TIME", "IS_OVERTIME", "APPLY_USER_ID" }; //指定字段,包括导航属性
|
||||
var jobInfos = GetEntities<T_FO_CRUCIAL_LICENSE_JOB>(i => i.CREATE_TIME >= startTime && i.IS_DELETED == false && i.APPLY_USER_ID != null, baseFilter).ToList();
|
||||
var jobIds = jobInfos.Select(t => t.ID).ToList();
|
||||
baseFilter.SelectField = new string[] { "ID", "STATUS", "APPLY_DEPARTMENT_ID", "CREATE_TIME", "IS_OVERTIME" };
|
||||
var fireJobInfos = GetEntities<T_FO_FIRE_JOB>(i => i.CREATE_TIME >= startTime && i.IS_DELETED == false && i.APPLY_DEPARTMENT_ID != null, baseFilter).ToList();
|
||||
var fireJobIds = fireJobInfos.Select(t => t.ID).ToList();
|
||||
jobIds.AddRange(fireJobIds);
|
||||
baseFilter.SelectField = new string[] { "ID", "NOTICE_STATUS", "CREATE_TIME", "SOURCE_DATA_ID" }; //指定字段,包括导航属性
|
||||
var tasks = this.GetEntities<T_FM_NOTIFICATION_TASK>(t => t.IS_DELETED == false && t.CREATE_TIME >= startTime && t.NOTICE_STATUS == 2 && jobIds.Contains((Guid)t.SOURCE_DATA_ID), baseFilter).ToList();
|
||||
var userIds = jobInfos.Select(t => t.APPLY_USER_ID).Distinct().ToList();
|
||||
baseFilter.SelectField = new string[] { "ID", "DEPARTMENT_ID" }; //指定字段,包括导航属性
|
||||
var userInfos = GetEntities<T_FM_USER>(i => userIds.Contains(i.ID), baseFilter).ToList();
|
||||
List<JobInfo> jobs = new List<JobInfo>();
|
||||
foreach (var item in jobInfos)
|
||||
{
|
||||
var task = tasks.FirstOrDefault(t => t.SOURCE_DATA_ID == item.ID);
|
||||
if (task == null)
|
||||
item.IS_OVERTIME = 0;
|
||||
else
|
||||
item.IS_OVERTIME = 1;
|
||||
var user = userInfos.FirstOrDefault(t => t.ID == item.APPLY_USER_ID);
|
||||
JobInfo job = new JobInfo();
|
||||
job.CREATE_TIME = item.CREATE_TIME;
|
||||
job.IS_OVERTIME = item.IS_OVERTIME;
|
||||
job.DEPARTMENT_ID = user?.DEPARTMENT_ID;
|
||||
job.IS_PUBLISH = item.IS_PUBLISH;
|
||||
jobs.Add(job);
|
||||
}
|
||||
foreach (var item in fireJobInfos)
|
||||
{
|
||||
var task = tasks.FirstOrDefault(t => t.SOURCE_DATA_ID == item.ID);
|
||||
if (task == null)
|
||||
item.IS_OVERTIME = 0;
|
||||
else
|
||||
item.IS_OVERTIME = 1;
|
||||
JobInfo job = new JobInfo();
|
||||
job.CREATE_TIME = item.CREATE_TIME;
|
||||
job.IS_OVERTIME = item.IS_OVERTIME;
|
||||
job.DEPARTMENT_ID = item.APPLY_DEPARTMENT_ID;
|
||||
job.IS_PUBLISH = item.STATUS == PFStandardStatus.Archived ? 5 : 0;
|
||||
jobs.Add(job);
|
||||
}
|
||||
for (DateTime i = startTime; i <= endTime; i = i.AddMonths(i.Month - i.Month + 1).AddDays(1 - i.Day))
|
||||
{
|
||||
var monthEnd = Convert.ToDateTime(i.AddMonths(i.Month - i.Month + 1).AddDays(1 - i.Day - 1).ToString().Replace("0:00:00", "23:59:59"));
|
||||
var preTemp = jobs.Where(t => t.CREATE_TIME >= i && t.CREATE_TIME <= monthEnd).ToList();
|
||||
var results = preTemp.GroupBy(m => m.DEPARTMENT_ID).
|
||||
Select(group => new
|
||||
{
|
||||
departmetId = group.Key,
|
||||
totalCount = group.Count(),
|
||||
finishCount = group.Where(i => i.IS_PUBLISH == 5).Count(),
|
||||
waitingCount = group.Where(i => i.IS_PUBLISH != 5).Count(),
|
||||
onTimeCount = group.Where(i => i.IS_OVERTIME == 0 && i.IS_PUBLISH == 5).Count(),
|
||||
overFinishCount = group.Where(i => i.IS_OVERTIME == 1 && i.IS_PUBLISH == 5).Count()
|
||||
}).ToList();
|
||||
if (results.Any())
|
||||
{
|
||||
foreach (var item in results)
|
||||
{
|
||||
T_FM_WORK_TICKET_COMPLETION completion = new T_FM_WORK_TICKET_COMPLETION();
|
||||
completion.MONTH = i;
|
||||
completion.MONTHStr = i.Year + "年" + i.Month + "月";
|
||||
completion.TOTAL_COUNT = item.totalCount;
|
||||
completion.FINISH_COUNT = item.finishCount;
|
||||
completion.OVER_FINISH_COUNT = item.overFinishCount;
|
||||
completion.WAITTING_COUNT = item.waitingCount;
|
||||
completion.ONTIME_COUNT = item.onTimeCount;
|
||||
completion.ORG_ID = filter.GetOrgId();
|
||||
completion.START_TIME = i;
|
||||
completion.END_TIME = monthEnd;
|
||||
var departInfo = departments.FirstOrDefault(t => t.ID == item.departmetId);
|
||||
if (departInfo != null)
|
||||
{
|
||||
//completion.DEPARTMENT_ID = departInfo?.PARENT_ID;
|
||||
//completion.DEPARTMENT_NAME = departInfo?.Nav_Parent?.NAME;
|
||||
completion.TEAM_ID = item.departmetId;
|
||||
completion.TEAM_NAME = departInfo?.NAME;
|
||||
}
|
||||
completions.Add(completion);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
T_FM_WORK_TICKET_COMPLETION completion = new T_FM_WORK_TICKET_COMPLETION();
|
||||
completion.MONTH = i;
|
||||
completion.MONTHStr = i.Year + "年" + i.Month + "月";
|
||||
completion.TOTAL_COUNT = 0;
|
||||
completion.FINISH_COUNT = 0;
|
||||
completion.OVER_FINISH_COUNT = 0;
|
||||
completion.WAITTING_COUNT = 0;
|
||||
completion.ONTIME_COUNT = 0;
|
||||
completion.ORG_ID = filter.GetOrgId();
|
||||
completion.START_TIME = i;
|
||||
completion.END_TIME = monthEnd;
|
||||
completions.Add(completion);
|
||||
}
|
||||
}
|
||||
if (completions != null && completions.Any())
|
||||
{
|
||||
completionSorts = completions.GroupBy(t => new { t.MONTH, t.MONTHStr }).Select(group => new T_FM_WORK_TICKET_COMPLETION
|
||||
{
|
||||
MONTH = group.Key.MONTH,
|
||||
MONTHStr = group.Key.MONTH.Year + "-" + group.Key.MONTH.Month,
|
||||
FINISH_COUNT = group.Where(i => i.MONTH == group.Key.MONTH).Sum(m => m.FINISH_COUNT),
|
||||
ONTIME_COUNT = group.Where(i => i.MONTH == group.Key.MONTH).Sum(m => m.ONTIME_COUNT),
|
||||
TOTAL_COUNT = group.Where(i => i.MONTH == group.Key.MONTH).Sum(m => m.TOTAL_COUNT),
|
||||
}).ToList();
|
||||
var departmentInfos = this.GetEntities<T_FM_DEPARTMENT>(t => t.ENABLE_STATUS == 0 && t.CATEGORY == FMCATEGORY.ACTURE, new BaseFilter(orgId));
|
||||
//var departmentIds = departmentInfos.Where(t => t.DEPARTMENT_TYPE == 10 || t.DEPARTMENT_STATUS == 2).ToList();
|
||||
//if (departmentIds != null && departmentIds.Any())
|
||||
//{
|
||||
// foreach (var item in departmentIds)
|
||||
// {
|
||||
// List<Guid> parentIds = new List<Guid>();
|
||||
// parentIds.Add(item.ID);
|
||||
// List<Guid> allIds = new List<Guid>();
|
||||
// GetDepartmentIds(orgId, parentIds, ref allIds);
|
||||
// var coms = jobs.Where(t => t.DEPARTMENT_ID != null && allIds.Contains((Guid)t.DEPARTMENT_ID)).ToList();
|
||||
// GroupbyDepartmentCompletion completionSort = new GroupbyDepartmentCompletion();
|
||||
// completionSort.shopId = item.ID;
|
||||
// completionSort.shopName = item.NAME;
|
||||
// completionSort.teamDoneCount = coms.Count(t => t.IS_PUBLISH == 5);
|
||||
// completionSort.teamOntimeCount = coms.Count(t => t.IS_PUBLISH == 5 && t.IS_OVERTIME == 0);
|
||||
// completionSort.teamTotalCount = coms.Count();
|
||||
// completionSort.teamUndoneCount = coms.Count(t => t.IS_PUBLISH != 5);
|
||||
// if (completionSort.teamTotalCount!=0)
|
||||
// completionLists.Add(completionSort);
|
||||
// }
|
||||
//}
|
||||
var classIds = departmentInfos.Where(t => t.DEPARTMENT_TYPE == 15 || t.DEPARTMENT_TYPE == 20).ToList();
|
||||
if (classIds != null && classIds.Any())
|
||||
{
|
||||
foreach (var item in classIds)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.NAME))
|
||||
{
|
||||
var coms = jobs.Where(t => t.DEPARTMENT_ID != null && t.DEPARTMENT_ID == item.ID).ToList();
|
||||
GroupbyDepartmentCompletion completionSort = new GroupbyDepartmentCompletion();
|
||||
completionSort.teamId = item.ID;
|
||||
completionSort.teamName = item.NAME;
|
||||
var parentInfo = departmentInfos.FirstOrDefault(t => t.ID == item.PARENT_ID);
|
||||
if (parentInfo != null)
|
||||
{
|
||||
if (parentInfo.DEPARTMENT_TYPE == 15)
|
||||
{
|
||||
var parentUp = departmentInfos.FirstOrDefault(t => t.ID == parentInfo.PARENT_ID);
|
||||
if (parentUp != null)
|
||||
{
|
||||
completionSort.shopId = parentUp.ID;
|
||||
completionSort.shopName = parentUp.NAME;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
completionSort.shopId = parentInfo.ID;
|
||||
completionSort.shopName = parentInfo.NAME;
|
||||
}
|
||||
}
|
||||
completionSort.teamDoneCount = coms.Count(t => t.IS_PUBLISH == 5);
|
||||
completionSort.teamOntimeCount = coms.Count(t => t.IS_PUBLISH == 5 && t.IS_OVERTIME == 0);
|
||||
completionSort.teamTotalCount = coms.Count();
|
||||
completionSort.teamUndoneCount = coms.Count(t => t.IS_PUBLISH != 5);
|
||||
if (completionSort.teamTotalCount != 0)
|
||||
completionLists.Add(completionSort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (completionSorts != null && completionSorts.Any())
|
||||
{
|
||||
foreach (var item in completionSorts)
|
||||
{
|
||||
if (item.TOTAL_COUNT == 0)
|
||||
{
|
||||
item.FINISH_RATE = 0;
|
||||
item.NORMAL_FINISH_RATE = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.FINISH_RATE = Math.Round((double)item.FINISH_COUNT / (double)item.TOTAL_COUNT * 100, 2);
|
||||
item.NORMAL_FINISH_RATE = Math.Round((double)item.ONTIME_COUNT / (double)item.TOTAL_COUNT * 100, 2);
|
||||
}
|
||||
}
|
||||
ret.rateData = completionSorts.OrderBy(t => t.MONTH).ToList();
|
||||
}
|
||||
List<GroupbyDepartmentCompletion> result = new List<GroupbyDepartmentCompletion>();
|
||||
if (completionLists != null && completionLists.Any())
|
||||
{
|
||||
foreach (var item in completionLists)
|
||||
{
|
||||
//if (string.IsNullOrEmpty(item.teamName) ||(item.teamName == item.shopName && item.teamTotalCount == 0))
|
||||
{
|
||||
|
||||
// item.teamId = item.shopId;
|
||||
// item.teamName = item.shopName;
|
||||
// item.teamDoneCount = completionLists.Where(i => i.shopId == item.shopId && i.teamId == null).Sum(m => m.shopDoneCount);
|
||||
// item.teamOntimeCount = completionLists.Where(i => i.shopId == item.shopId && i.teamId == null).Sum(m => m.shopOntimeCount);
|
||||
// item.teamTotalCount = completionLists.Where(i => i.shopId == item.shopId && i.teamId == null).Sum(m => m.shopTotalCount);
|
||||
}
|
||||
//else
|
||||
{
|
||||
//if (string.IsNullOrEmpty(item.teamName))
|
||||
//{
|
||||
// item.teamName = item.shopName;
|
||||
//}
|
||||
item.shopDoneCount = completionLists.Where(i => i.shopId == item.shopId).Sum(m => m.teamDoneCount);
|
||||
item.shopOntimeCount = completionLists.Where(i => i.shopId == item.shopId).Sum(m => m.teamOntimeCount);
|
||||
item.shopTotalCount = completionLists.Where(i => i.shopId == item.shopId).Sum(m => m.teamTotalCount);
|
||||
|
||||
//if (item.deptTotalCount == 0)
|
||||
//{
|
||||
// item.deptDoneRate = 0;
|
||||
// item.deptOverDoneRate = 0;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// item.deptDoneRate = Math.Round((double)item.deptDoneCount / (double)item.deptTotalCount * 100, 2);
|
||||
// item.deptOverDoneRate = Math.Round((double)item.deptOntimeCount / (double)item.deptTotalCount * 100, 2);
|
||||
//}
|
||||
if (item.shopTotalCount == 0)
|
||||
{
|
||||
item.shopDoneRate = 0;
|
||||
item.shopOverDoneRate = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.shopDoneRate = Math.Round((double)item.shopDoneCount / (double)item.shopTotalCount * 100, 2);
|
||||
item.shopOverDoneRate = Math.Round((double)item.shopOntimeCount / (double)item.shopTotalCount * 100, 2);
|
||||
}
|
||||
if (item.teamTotalCount == 0)
|
||||
{
|
||||
item.teamDoneRate = 0;
|
||||
item.teamOverDoneRate = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.teamDoneRate = Math.Round((double)item.teamDoneCount / (double)item.teamTotalCount * 100, 2);
|
||||
item.teamOverDoneRate = Math.Round((double)item.teamOntimeCount / (double)item.teamTotalCount * 100, 2);
|
||||
}
|
||||
result.Add(item);
|
||||
}
|
||||
|
||||
}
|
||||
ret.retData = result.OrderBy(t => t.shopName).ThenByDescending(m => m.teamOverDoneRate).ToList();
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 作业完成率前八(除班组级)
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
@ -11649,5 +12105,12 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public class JobInfo
|
||||
{
|
||||
public Guid? DEPARTMENT_ID { get; set; }
|
||||
public int IS_PUBLISH { get; set; }
|
||||
public int IS_OVERTIME { get; set; }
|
||||
public DateTime? CREATE_TIME { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user