reporting optimiert

This commit is contained in:
Ralph Soika 2021-11-26 11:56:45 +01:00
parent 86e9938bde
commit eb9713fe01
3 changed files with 77 additions and 67 deletions

View file

@ -2,12 +2,15 @@ package com.alexanderlogistics;
import java.io.Serializable; import java.io.Serializable;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.YearMonth;
import java.time.ZoneId;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.context.SessionScoped; import javax.enterprise.context.SessionScoped;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -25,7 +28,7 @@ import org.imixs.workflow.engine.index.SearchService;
* *
*/ */
@Named @Named
@SessionScoped @ConversationScoped
public class AnalyseSachpruefungController implements Serializable { public class AnalyseSachpruefungController implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -36,8 +39,7 @@ public class AnalyseSachpruefungController implements Serializable {
@Inject @Inject
SearchService searchService; SearchService searchService;
Category sachpruefung; Category sachpruefung;
Category verteilung; Category verteilung;
@ -46,6 +48,14 @@ public class AnalyseSachpruefungController implements Serializable {
public ItemCollection getFilter() { public ItemCollection getFilter() {
if (filter == null) { if (filter == null) {
filter = new ItemCollection(); filter = new ItemCollection();
// compute start stop based on current month
YearMonth startYearMonth = YearMonth.now();
java.time.LocalDate startOfMonthDate = startYearMonth.atDay(1);
java.time.LocalDate endOfMonthDate = startYearMonth.atEndOfMonth();
filter.setItemValue("start",
java.util.Date.from(startOfMonthDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()));
filter.setItemValue("stop",
java.util.Date.from(endOfMonthDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()));
} }
return filter; return filter;
} }
@ -54,8 +64,6 @@ public class AnalyseSachpruefungController implements Serializable {
this.filter = filter; this.filter = filter;
} }
public Category getSachpruefung() { public Category getSachpruefung() {
return sachpruefung; return sachpruefung;
} }
@ -64,19 +72,28 @@ public class AnalyseSachpruefungController implements Serializable {
return verteilung; return verteilung;
} }
public int totalCountByCategory(Category cat) {
int result = 0;
Collection<Integer> allCounts = cat.getLabels().values();
result = allCounts.stream().reduce(0, Integer::sum);
return result;
}
/** /**
* Fuert verschiedene Queries aus um eine Analyse der Sachprufung durchzuführen. * Fuert verschiedene Queries aus um eine Analyse der Sachprufung durchzuführen.
*/ */
public void analyse() { public void analyse() {
logger.info("start analyse...."); logger.info("start analyse....");
verteilung=null; verteilung = null;
sachpruefung=null; sachpruefung = null;
Date start = filter.getItemValueDate("start"); Date start = filter.getItemValueDate("start");
Date stop = filter.getItemValueDate("stop"); Date stop = filter.getItemValueDate("stop");
logger.info("...daterange=" + start + " - "+stop); logger.info("...daterange=" + start + " - " + stop);
// serach date range? // serach date range?
String sDateFrom = "191401070000"; // because * did not work here String sDateFrom = "191401070000"; // because * did not work here
String sDateTo = "211401070000"; String sDateTo = "211401070000";
@ -94,39 +111,28 @@ public class AnalyseSachpruefungController implements Serializable {
sDateTo = dateformat.format(cal.getTime()); sDateTo = dateformat.format(cal.getTime());
} }
// query Verteilung
String query = "(type:workitem OR type:workitemarchive) "; String query = "(type:workitem OR type:workitemarchive) ";
if (start != null || stop != null) { if (start != null || stop != null) {
query += "AND ($created:[" + sDateFrom + " TO " + sDateTo + "]) "; query += "AND (taxonomy.verteilung.stop:[" + sDateFrom + " TO " + sDateTo + "]) ";
}
logger.info(query);
List<Category> taxResult = searchService.getTaxonomyByQuery(query, "taxonomy.verteilung.stop.by");
if (taxResult.size() > 0) {
verteilung = taxResult.get(0);
} }
// query Sachprüfung
query = "(type:workitem OR type:workitemarchive) ";
if (start != null || stop != null) {
query += "AND (taxonomy.sachpruefung.stop:[" + sDateFrom + " TO " + sDateTo + "]) ";
}
logger.info(query); logger.info(query);
List<Category> taxResult = searchService.getTaxonomyByQuery(query, "taxonomy.verteilung.stop.by", taxResult = searchService.getTaxonomyByQuery(query, "taxonomy.sachpruefung.stop.by");
"taxonomy.sachpruefung.stop.by");
if (taxResult.size() > 0) { if (taxResult.size() > 0) {
sachpruefung = taxResult.get(0);
for (Category cat : taxResult) {
logger.info("category: " + cat.getName() + " = " + cat.getCount());
if (cat.getName().contains("verteilung")) {
verteilung=cat;
}
if (cat.getName().contains("sachpruefung")) {
sachpruefung=cat;
}
Map<String, Integer> labelMap = cat.getLabels();
for (String id : labelMap.keySet()) {
logger.info(".....sub-category: " + id + " = " + labelMap.get(id));
}
}
} }
} }
@ -136,8 +142,8 @@ public class AnalyseSachpruefungController implements Serializable {
*/ */
public void reset() { public void reset() {
filter = new ItemCollection(); filter = new ItemCollection();
sachpruefung=null; sachpruefung = null;
verteilung=null; verteilung = null;
logger.fine("reset"); logger.fine("reset");
} }

View file

@ -4,7 +4,7 @@
lucence.indexDir=${imixs-office.IndexDir} lucence.indexDir=${imixs-office.IndexDir}
index.fields=txtsearchstring,txtSubject,txtname,txtEmail,txtUserName,namCreator,txtworkflowgroup,txtworkflowstatus,txtWorkflowAbstract,txtWorkflowSummary,txtworkflowhistory,txtspacename,txtprocessname,_subject,_description,_name,_projectnumber,_projectname,_ordernumber,_contractnumber,datDueDate,txtcommentlog,htmldescription,htmldocumentation,dms,dms_names,_childitems,$file.names,_VENDOR_NAME index.fields=txtsearchstring,txtSubject,txtname,txtEmail,txtUserName,namCreator,txtworkflowgroup,txtworkflowstatus,txtWorkflowAbstract,txtWorkflowSummary,txtworkflowhistory,txtspacename,txtprocessname,_subject,_description,_name,_projectnumber,_projectname,_ordernumber,_contractnumber,datDueDate,txtcommentlog,htmldescription,htmldocumentation,dms,dms_names,_childitems,$file.names,_VENDOR_NAME
index.fields.analyze=txtUsername index.fields.analyze=txtUsername
index.fields.noanalyze=type,$UniqueIDRef,$created,$modified,$ModelVersion,namCreator,$ProcessID,datDate,txtWorkflowGroup,txtemail, datdate, datfrom, datto, numsequencenumber,dms_count,invoice.number,invoice.duedate index.fields.noanalyze=type,$UniqueIDRef,$created,$modified,$ModelVersion,namCreator,$ProcessID,datDate,txtWorkflowGroup,txtemail, datdate, datfrom, datto, numsequencenumber,dms_count,invoice.number,invoice.duedate,taxonomy.verteilung.stop,taxonomy.sachpruefung.stop,,taxonomy.verteilung.start,taxonomy.sachpruefung.start
index.fields.store=process.name,txtProcessName,txtWorkflowImageURL index.fields.store=process.name,txtProcessName,txtWorkflowImageURL
index.fields.category=space.name,space.ref,taxonomy.verteilung.stop.by,taxonomy.sachpruefung.stop.by index.fields.category=space.name,space.ref,taxonomy.verteilung.stop.by,taxonomy.sachpruefung.stop.by
office.search.noanalyze=invoice.number office.search.noanalyze=invoice.number

View file

@ -24,6 +24,13 @@
}); });
function updatePanel(data) {
if (data.status === 'success') {
// select with wildcard operator
$('[id$=import_form_id]').imixsLayout();
}
}
/*]]>*/ /*]]>*/
</script> </script>
</ui:define> </ui:define>
@ -49,7 +56,13 @@
<div class="imixs-form-panel"> <div class="imixs-form-panel">
<div class="ui-state-highlight ui-corner-all"
style="margin-bottom: 10px; padding: .5em;">
<p>Der folgende Report zeigt an, wieviele <i>Verteilungen</i> bzw.
<i>Sachprüfungen</i> in einem bestimmten Zeitraum durchgeführt
wurden. Der Report dient dazu die Verteilung der Aufgaben in den jweiligen Teams zu
Optimieren.</p>
</div>
<div class="imixs-form-section-3"> <div class="imixs-form-section-3">
<dl> <dl>
<dt> <dt>
@ -84,6 +97,15 @@
</div> </div>
<h:commandButton
actionListener="#{analyseSachpruefungController.analyse()}"
action="/pages/admin/analyse_sachpruefung"
value="Report starten">
<f:ajax render="result_panel" execute="@form"
onevent="updatePanel" />
</h:commandButton>
<h:commandButton value="#{message.close}" action="notes" />
</div> </div>
@ -94,16 +116,12 @@
id="result_panel"> id="result_panel">
<hr /> <hr />
<div class="row"> <div class="row">
<div class="col-4" style="padding-left: 0;"> <div class="col-4" style="padding-left: 0;">
<ui:fragment <ui:fragment
rendered="#{analyseSachpruefungController.verteilung!=null}"> rendered="#{analyseSachpruefungController.verteilung!=null}">
<h2>Verteilung zur Prüfung
(#{analyseSachpruefungController.totalCountByCategory(analyseSachpruefungController.verteilung)})</h2>
<h2>Verteilung zur Prüfung</h2>
<table class="monitoring-datatable"> <table class="monitoring-datatable">
<tr> <tr>
<th>Mitarbeiter</th> <th>Mitarbeiter</th>
@ -113,21 +131,19 @@
items="#{analyseSachpruefungController.verteilung.labels}" items="#{analyseSachpruefungController.verteilung.labels}"
var="entry"> var="entry">
<tr> <tr>
<td>#{entry.key}</td> <td>#{userController.getUserName(entry.key)}</td>
<td style="text-align: center;">#{entry.value}</td> <td style="text-align: center;">#{entry.value}</td>
</tr> </tr>
</c:forEach> </c:forEach>
</table> </table>
</ui:fragment> </ui:fragment>
</div> </div>
<div class="col-4"> <div class="col-4">
<ui:fragment <ui:fragment
rendered="#{analyseSachpruefungController.sachpruefung!=null}"> rendered="#{analyseSachpruefungController.sachpruefung!=null}">
<h2>Sachprüfung
<h2>Sachprüfung</h2> (#{analyseSachpruefungController.totalCountByCategory(analyseSachpruefungController.sachpruefung)})</h2>
<table class="monitoring-datatable"> <table class="monitoring-datatable">
<tr> <tr>
<th>Mitarbeiter</th> <th>Mitarbeiter</th>
@ -137,7 +153,7 @@
items="#{analyseSachpruefungController.sachpruefung.labels}" items="#{analyseSachpruefungController.sachpruefung.labels}"
var="entry"> var="entry">
<tr> <tr>
<td>#{entry.key}</td> <td>#{userController.getUserName(entry.key)}</td>
<td style="text-align: center;">#{entry.value}</td> <td style="text-align: center;">#{entry.value}</td>
</tr> </tr>
</c:forEach> </c:forEach>
@ -160,19 +176,7 @@
<div class="imixs-footer"> <div class="imixs-footer"></div>
<h:commandButton
actionListener="#{analyseSachpruefungController.analyse()}"
action="/pages/admin/analyse_sachpruefung" value="Report starten">
<f:ajax render="result_panel" execute="@form" />
</h:commandButton>
<h:commandButton value="#{message.close}" action="notes" />
</div>
</h:form> </h:form>
</f:view> </f:view>
</ui:define> </ui:define>