This commit is contained in:
2022-02-28 20:30:31 +00:00
parent 98f8d26eb8
commit fc0d1bd7e1
8 changed files with 84 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
//#define AYSHOWQUERYINFO #define AYSHOWQUERYINFO
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@@ -13,11 +13,11 @@ namespace AyaNova.KPI
{ {
switch (name) switch (name)
{ {
//CoreBizObject add here if it will be "picked" on any other form
case "WorkOrderItemLaborQuantitySummary": case "WorkOrderItemLaborQuantitySummary":
return new WorkOrderItemLaborQuantitySummary() as IAyaKPI; return new WorkOrderItemLaborQuantitySummary() as IAyaKPI;
case "WorkOrderUnscheduledOpenList":
//@##### WARNING: BE SURE TO ADD NEW TYPES BELOW OR USERS WON"T BE ABLE TO EDIT THE TEMPLATE FOR THEM return new WorkOrderUnscheduledOpenList() as IAyaKPI;
default: default:
throw new System.NotImplementedException($"KPI {name} NOT IMPLEMENTED"); throw new System.NotImplementedException($"KPI {name} NOT IMPLEMENTED");
@@ -32,6 +32,7 @@ namespace AyaNova.KPI
List<string> ret = new List<string>(); List<string> ret = new List<string>();
ret.Add("WorkOrderItemLaborQuantitySummary"); ret.Add("WorkOrderItemLaborQuantitySummary");
ret.Add("WorkOrderUnscheduledOpenList");
return ret; return ret;
} }

View File

@@ -1,4 +1,4 @@
//#define AYSHOWKPIQUERYINFO #define AYSHOWKPIQUERYINFO
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@@ -0,0 +1,74 @@
using AyaNova.Biz;
using Newtonsoft.Json.Linq;
using AyaNova.DataList;
using System.Collections.Generic;
namespace AyaNova.KPI
{
internal class WorkOrderUnscheduledOpenList : IAyaKPI
{
private string _metaQuery = null;
private string _dataQuery = null;
private string _errorMessage = null;
public AuthorizationRoles AllowedRoles { get => AuthorizationRoles.Tech | AuthorizationRoles.TechRestricted; }
public string MetaQuery => _metaQuery;
public string DataQuery => _dataQuery;
public string ErrorMessage => _errorMessage;
public void BuildQuery(KPIRequestOptions options, long userId)
{
//build data and meta queries
//validate criteria exists
if (!options.Criteria.ContainsKey("timeSpan"))
{
_errorMessage = "Missing 'timeSpan' criteria";
return;
}
if (!options.Criteria.ContainsKey("interval"))
{
_errorMessage = "Missing 'interval' criteria";
return;
}
var timeSpan = (string)options.Criteria["timeSpan"];
var interval = (string)options.Criteria["interval"];
var wotags = options.Criteria["wotags"].ToObject<List<string>>();
var woitemtags = options.Criteria["woitemtags"].ToObject<List<string>>();
var dateWhere = DataListSqlFilterCriteriaBuilder.DataFilterToColumnCriteria("aworkorderitemlabor.servicestopdate", UiFieldDataType.DateTime, "no-operator", timeSpan, options.ClientTimeStamp);
//optional tags
string woTagsWhere = null;
if (wotags.Count > 0)
woTagsWhere = " AND " + DataListSqlFilterCriteriaBuilder.TagDataFilterToColumnCriteria("aworkorder.tags", DataListFilterComparisonOperator.Contains, string.Join(",", wotags));
string woItemTagsWhere = null;
if (woitemtags.Count > 0)
woItemTagsWhere = " AND " + DataListSqlFilterCriteriaBuilder.TagDataFilterToColumnCriteria("aworkorderitem.tags", DataListFilterComparisonOperator.Contains, string.Join(",", woitemtags));
_dataQuery = @$"SELECT row_to_json(t) as res from (
select SUM(AWORKORDERITEMLABOR.serviceratequantity) y, date_trunc('{interval}',AWORKORDERITEMLABOR.servicestopdate) x
FROM AWORKORDER
LEFT JOIN AWORKORDERITEM ON AWORKORDER.ID = AWORKORDERITEM.WORKORDERID
LEFT JOIN AWORKORDERITEMLABOR ON AWORKORDERITEM.ID = AWORKORDERITEMLABOR.WORKORDERITEMID
WHERE AWORKORDERITEMLABOR.userid = {userId} AND {dateWhere} {woTagsWhere} {woItemTagsWhere}
GROUP BY x
ORDER BY x ASC
) t";
_metaQuery = string.Empty;
// @"SELECT row_to_json(t) as res from (
// select name from auser where id = 10
// ) t";
}
}//eoc
}//eons

View File

@@ -226,6 +226,7 @@
"DarkMode": "Dunkler Modus", "DarkMode": "Dunkler Modus",
"Dashboard": "Dashboard", "Dashboard": "Dashboard",
"DashboardNotAssigned": "Not assigned", "DashboardNotAssigned": "Not assigned",
"DashboardNotScheduled": "Außerplanmäßig",
"DashboardOverdue": "Overdue", "DashboardOverdue": "Overdue",
"DashboardReminders": "Reminders", "DashboardReminders": "Reminders",
"DashboardScheduled": "Scheduled", "DashboardScheduled": "Scheduled",

View File

@@ -226,6 +226,7 @@
"DarkMode": "Dark mode", "DarkMode": "Dark mode",
"Dashboard": "Dashboard", "Dashboard": "Dashboard",
"DashboardNotAssigned": "Not assigned", "DashboardNotAssigned": "Not assigned",
"DashboardNotScheduled": "Not scheduled",
"DashboardOverdue": "Overdue", "DashboardOverdue": "Overdue",
"DashboardReminders": "Reminders", "DashboardReminders": "Reminders",
"DashboardScheduled": "Scheduled", "DashboardScheduled": "Scheduled",

View File

@@ -226,6 +226,7 @@
"DarkMode": "Modo oscuro", "DarkMode": "Modo oscuro",
"Dashboard": "Panel", "Dashboard": "Panel",
"DashboardNotAssigned": "Not assigned", "DashboardNotAssigned": "Not assigned",
"DashboardNotScheduled": "No programado",
"DashboardOverdue": "Overdue", "DashboardOverdue": "Overdue",
"DashboardReminders": "Reminders", "DashboardReminders": "Reminders",
"DashboardScheduled": "Scheduled", "DashboardScheduled": "Scheduled",

View File

@@ -226,6 +226,7 @@
"DarkMode": "Mode Sombre", "DarkMode": "Mode Sombre",
"Dashboard": "Tableau de bord", "Dashboard": "Tableau de bord",
"DashboardNotAssigned": "Not assigned", "DashboardNotAssigned": "Not assigned",
"DashboardNotScheduled": "Non planifié",
"DashboardOverdue": "Overdue", "DashboardOverdue": "Overdue",
"DashboardReminders": "Reminders", "DashboardReminders": "Reminders",
"DashboardScheduled": "Scheduled", "DashboardScheduled": "Scheduled",