首页工作票
This commit is contained in:
parent
d44d3c46e2
commit
28971e678f
@ -960,7 +960,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
completion.END_TIME = monthEnd;
|
||||
if (departInfo != null)
|
||||
{
|
||||
if (departInfo.DEPARTMENT_TYPE == 10)
|
||||
if (departInfo.DEPARTMENT_TYPE == 10|| departInfo.DEPARTMENT_TYPE == 5)
|
||||
{
|
||||
completion.DEPARTMENT_ID = item.departmetId;
|
||||
completion.DEPARTMENT_NAME = departInfo?.NAME;
|
||||
|
||||
@ -108,7 +108,14 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
public string ISOVER_CREATE { get; set; }
|
||||
}
|
||||
public class GroupbyDepartmentCompletion
|
||||
{
|
||||
{
|
||||
public Guid? deptId { get; set; }
|
||||
public string deptName { get; set; }
|
||||
public int deptTotalCount { get; set; }
|
||||
public int deptDoneCount { get; set; }
|
||||
public int deptOntimeCount { get; set; }
|
||||
public double deptDoneRate { get; set; }
|
||||
public double deptOverDoneRate { get; set; }
|
||||
public Guid? shopId { get; set; }
|
||||
public string shopName { get; set; }
|
||||
public int shopTotalCount { get; set; }
|
||||
@ -10022,24 +10029,40 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
|
||||
var departmentIds = new List<Guid>();
|
||||
List<GroupbyDepartmentId> completionLists = new List<GroupbyDepartmentId>();
|
||||
var loginDepart = this.GetEntity<T_FM_DEPARTMENT>(t => t.ID == APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID);
|
||||
//var loginDepart = this.GetEntity<T_FM_DEPARTMENT>(t => t.ID == APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID);
|
||||
var completions = GetEntities<T_FM_WORK_TICKET_COMPLETION>(t => !t.IS_DELETED, new BaseFilter(orgId)).ToList();
|
||||
var deptIds = completions.Where(t => t.DEPARTMENT_ID != null).Select(t => (Guid)t.DEPARTMENT_ID).ToList();
|
||||
departmentIds.AddRange(deptIds);
|
||||
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 departmentInfo = this.GetEntities<T_FM_DEPARTMENT>(t => t.ENABLE_STATUS == 0 && t.CATEGORY == FMCATEGORY.ACTURE, new BaseFilter(orgId));
|
||||
if (loginDepart != null)
|
||||
if (departmentIds != null && departmentIds.Any())
|
||||
{
|
||||
departmentInfo = departmentInfo.Where(t => t.PRODUCTION_UNIT_ID == loginDepart.PRODUCTION_UNIT_ID).ToList();
|
||||
//departmentInfo = departmentInfo.Where(t => t.PRODUCTION_UNIT_ID == loginDepart.PRODUCTION_UNIT_ID).ToList();
|
||||
departmentInfo = departmentInfo.Where(t => departmentIds.Contains(t.ID)).ToList();
|
||||
}
|
||||
if (departmentInfo == null || !departmentInfo.Any())
|
||||
return completionSorts;
|
||||
else
|
||||
departmentIds = departmentInfo.Select(t => t.ID).ToList();
|
||||
var completions = GetEntities<T_FM_WORK_TICKET_COMPLETION>(t => !t.IS_DELETED, new BaseFilter(orgId)).ToList();
|
||||
|
||||
if (departmentIds != null && departmentIds.Any())
|
||||
{
|
||||
foreach (var item in departmentIds)
|
||||
{
|
||||
{
|
||||
var depart = departmentInfo.FirstOrDefault(m => m.ID == item);
|
||||
GroupbyDepartmentId de = new GroupbyDepartmentId();
|
||||
var com = completions.Where(m => m.TEAM_ID != null && m.TEAM_ID == item).ToList();
|
||||
var depart = departmentInfo.FirstOrDefault(m => m.ID == item);
|
||||
if (depart.DEPARTMENT_TYPE == 10 || depart.DEPARTMENT_TYPE == 5)
|
||||
{
|
||||
com = completions.Where(m => m.DEPARTMENT_ID != null && m.DEPARTMENT_ID == item).ToList();
|
||||
}
|
||||
if (depart.DEPARTMENT_TYPE == 15)
|
||||
{
|
||||
com = completions.Where(m => m.SHOP_DEPARTMENT_ID != null && m.SHOP_DEPARTMENT_ID == item).ToList();
|
||||
}
|
||||
if (com.Count() == 0)
|
||||
{
|
||||
de.departmentId = item;
|
||||
@ -10219,17 +10242,24 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
List<T_FM_WORK_TICKET_COMPLETION> completionSorts = new List<T_FM_WORK_TICKET_COMPLETION>();
|
||||
//if (string.IsNullOrEmpty(filter.Keyword))
|
||||
// return ret;
|
||||
var loginDepart = this.GetEntity<T_FM_DEPARTMENT>(t => t.ID == APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID);
|
||||
var departmentInfo = this.GetEntities<T_FM_DEPARTMENT>(t => t.ENABLE_STATUS == 0 && t.CATEGORY == FMCATEGORY.ACTURE, new BaseFilter(orgId));
|
||||
if (loginDepart != null)
|
||||
var completions = GetEntities<T_FM_WORK_TICKET_COMPLETION>(t => !t.IS_DELETED, new BaseFilter(orgId)).ToList();
|
||||
var deptIds = completions.Where(t => t.DEPARTMENT_ID != null).Select(t => (Guid)t.DEPARTMENT_ID).ToList();
|
||||
departmentIds.AddRange(deptIds);
|
||||
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 departmentInfo = this.GetEntities<T_FM_DEPARTMENT>(t => t.ENABLE_STATUS == 0 && t.CATEGORY == FMCATEGORY.ACTURE, new BaseFilter(orgId));
|
||||
//var loginDepart = departmentInfo.FirstOrDefault(t => t.ID == APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID);
|
||||
if (departmentIds != null && departmentIds.Any())
|
||||
{
|
||||
departmentInfo = departmentInfo.Where(t => t.PRODUCTION_UNIT_ID == loginDepart.PRODUCTION_UNIT_ID).ToList();
|
||||
departmentInfo = departmentInfo.Where(t => departmentIds.Contains(t.ID)).ToList();
|
||||
}
|
||||
if (departmentInfo == null || !departmentInfo.Any())
|
||||
return ret;
|
||||
else
|
||||
departmentIds = departmentInfo.Select(t => t.ID).ToList();
|
||||
var completions = GetEntities<T_FM_WORK_TICKET_COMPLETION>(t => !t.IS_DELETED && t.TEAM_ID != null && departmentIds.Contains(t.TEAM_ID.Value), new BaseFilter(orgId)).ToList();
|
||||
|
||||
if (completions != null && completions.Any())
|
||||
{
|
||||
completionSorts = completions.GroupBy(t => new { t.MONTH, t.MONTHStr }).Select(group => new T_FM_WORK_TICKET_COMPLETION
|
||||
@ -10240,16 +10270,18 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
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();
|
||||
completionLists = completions.GroupBy(t => new { t.TEAM_ID, t.TEAM_NAME, t.SHOP_DEPARTMENT_ID, t.SHOP_DEPARTMENT_NAME }).Select(group => new GroupbyDepartmentCompletion
|
||||
{
|
||||
completionLists = completions.GroupBy(t => new {t.DEPARTMENT_ID,t.DEPARTMENT_NAME, t.TEAM_ID, t.TEAM_NAME, t.SHOP_DEPARTMENT_ID, t.SHOP_DEPARTMENT_NAME }).Select(group => new GroupbyDepartmentCompletion
|
||||
{
|
||||
deptId = group.Key.DEPARTMENT_ID,
|
||||
deptName = group.Key.DEPARTMENT_NAME,
|
||||
shopId = group.Key.SHOP_DEPARTMENT_ID,
|
||||
shopName = group.Key.SHOP_DEPARTMENT_NAME,
|
||||
teamId = group.Key.TEAM_ID,
|
||||
teamName = group.Key.TEAM_NAME,
|
||||
teamDoneCount = group.Where(i => i.TEAM_ID == group.Key.TEAM_ID && i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID).Sum(m => m.FINISH_COUNT),
|
||||
teamOntimeCount = group.Where(i => i.TEAM_ID == group.Key.TEAM_ID && i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID).Sum(m => m.ONTIME_COUNT),
|
||||
teamUndoneCount = group.Where(i => i.TEAM_ID == group.Key.TEAM_ID && i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID).Sum(m => m.WAITTING_COUNT),
|
||||
teamTotalCount = group.Where(i => i.TEAM_ID == group.Key.TEAM_ID && i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID).Sum(m => m.TOTAL_COUNT),
|
||||
teamDoneCount = group.Where(i =>i.DEPARTMENT_ID == group.Key.DEPARTMENT_ID && i.TEAM_ID == group.Key.TEAM_ID && i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID).Sum(m => m.FINISH_COUNT),
|
||||
teamOntimeCount = group.Where(i => i.DEPARTMENT_ID == group.Key.DEPARTMENT_ID && i.TEAM_ID == group.Key.TEAM_ID && i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID).Sum(m => m.ONTIME_COUNT),
|
||||
teamUndoneCount = group.Where(i => i.DEPARTMENT_ID == group.Key.DEPARTMENT_ID && i.TEAM_ID == group.Key.TEAM_ID && i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID).Sum(m => m.WAITTING_COUNT),
|
||||
teamTotalCount = group.Where(i => i.DEPARTMENT_ID == group.Key.DEPARTMENT_ID && i.TEAM_ID == group.Key.TEAM_ID && i.SHOP_DEPARTMENT_ID == group.Key.SHOP_DEPARTMENT_ID).Sum(m => m.TOTAL_COUNT),
|
||||
}).ToList();
|
||||
}
|
||||
if (completionSorts != null && completionSorts.Any())
|
||||
@ -10272,10 +10304,23 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
if (completionLists != null && completionLists.Any())
|
||||
{
|
||||
foreach (var item in completionLists)
|
||||
{
|
||||
{
|
||||
item.deptDoneCount = completionLists.Where(i => i.deptId == item.deptId).Sum(m => m.teamDoneCount);
|
||||
item.deptOntimeCount = completionLists.Where(i => i.deptId == item.deptId).Sum(m => m.teamOntimeCount);
|
||||
item.deptTotalCount = completionLists.Where(i => i.deptId == item.deptId).Sum(m => m.teamTotalCount);
|
||||
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);
|
||||
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;
|
||||
@ -10297,7 +10342,7 @@ namespace APT.SC.WebApi.Controllers.Api.BIController
|
||||
item.teamOverDoneRate = Math.Round((double)item.teamOntimeCount / (double)item.teamTotalCount * 100, 2);
|
||||
}
|
||||
}
|
||||
ret.retData = completionLists.OrderBy(t => t.shopName).ThenByDescending(m => m.teamOverDoneRate).ToList();
|
||||
ret.retData = completionLists.OrderBy(t => t.deptName).ThenBy(t => t.shopName).ThenByDescending(m => m.teamOverDoneRate).ToList();
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user