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.text.SimpleDateFormat;
import java.time.YearMonth;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
@ -25,7 +28,7 @@ import org.imixs.workflow.engine.index.SearchService;
*
*/
@Named
@SessionScoped
@ConversationScoped
public class AnalyseSachpruefungController implements Serializable {
private static final long serialVersionUID = 1L;
@ -36,8 +39,7 @@ public class AnalyseSachpruefungController implements Serializable {
@Inject
SearchService searchService;
Category sachpruefung;
Category verteilung;
@ -46,6 +48,14 @@ public class AnalyseSachpruefungController implements Serializable {
public ItemCollection getFilter() {
if (filter == null) {
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;
}
@ -54,8 +64,6 @@ public class AnalyseSachpruefungController implements Serializable {
this.filter = filter;
}
public Category getSachpruefung() {
return sachpruefung;
}
@ -64,19 +72,28 @@ public class AnalyseSachpruefungController implements Serializable {
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.
*/
public void analyse() {
logger.info("start analyse....");
verteilung=null;
sachpruefung=null;
verteilung = null;
sachpruefung = null;
Date start = filter.getItemValueDate("start");
Date stop = filter.getItemValueDate("stop");
logger.info("...daterange=" + start + " - "+stop);
logger.info("...daterange=" + start + " - " + stop);
// serach date range?
String sDateFrom = "191401070000"; // because * did not work here
String sDateTo = "211401070000";
@ -94,39 +111,28 @@ public class AnalyseSachpruefungController implements Serializable {
sDateTo = dateformat.format(cal.getTime());
}
// query Verteilung
String query = "(type:workitem OR type:workitemarchive) ";
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);
List<Category> taxResult = searchService.getTaxonomyByQuery(query, "taxonomy.verteilung.stop.by",
"taxonomy.sachpruefung.stop.by");
taxResult = searchService.getTaxonomyByQuery(query, "taxonomy.sachpruefung.stop.by");
if (taxResult.size() > 0) {
for (Category cat : taxResult) {
logger.info("category: " + cat.getName() + " = " + cat.getCount());
if (cat.getName().contains("verteilung")) {
verteilung=cat;
}
sachpruefung = taxResult.get(0);
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() {
filter = new ItemCollection();
sachpruefung=null;
verteilung=null;
sachpruefung = null;
verteilung = null;
logger.fine("reset");
}

View file

@ -4,7 +4,7 @@
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.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.category=space.name,space.ref,taxonomy.verteilung.stop.by,taxonomy.sachpruefung.stop.by
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>
</ui:define>
@ -49,7 +56,13 @@
<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">
<dl>
<dt>
@ -84,6 +97,15 @@
</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>
@ -94,16 +116,12 @@
id="result_panel">
<hr />
<div class="row">
<div class="col-4" style="padding-left: 0;">
<ui:fragment
rendered="#{analyseSachpruefungController.verteilung!=null}">
<h2>Verteilung zur Prüfung</h2>
<h2>Verteilung zur Prüfung
(#{analyseSachpruefungController.totalCountByCategory(analyseSachpruefungController.verteilung)})</h2>
<table class="monitoring-datatable">
<tr>
<th>Mitarbeiter</th>
@ -113,21 +131,19 @@
items="#{analyseSachpruefungController.verteilung.labels}"
var="entry">
<tr>
<td>#{entry.key}</td>
<td>#{userController.getUserName(entry.key)}</td>
<td style="text-align: center;">#{entry.value}</td>
</tr>
</c:forEach>
</table>
</ui:fragment>
</div>
<div class="col-4">
<ui:fragment
rendered="#{analyseSachpruefungController.sachpruefung!=null}">
<h2>Sachprüfung</h2>
<h2>Sachprüfung
(#{analyseSachpruefungController.totalCountByCategory(analyseSachpruefungController.sachpruefung)})</h2>
<table class="monitoring-datatable">
<tr>
<th>Mitarbeiter</th>
@ -137,7 +153,7 @@
items="#{analyseSachpruefungController.sachpruefung.labels}"
var="entry">
<tr>
<td>#{entry.key}</td>
<td>#{userController.getUserName(entry.key)}</td>
<td style="text-align: center;">#{entry.value}</td>
</tr>
</c:forEach>
@ -160,19 +176,7 @@
<div class="imixs-footer">
<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>
<div class="imixs-footer"></div>
</h:form>
</f:view>
</ui:define>