Do sestav žádosti o služební cestu a vyúčtování vstupuje podpis

uživatele a podpis schvalovatele. 
closes #132
multitenant
Josef Rokos 10 years ago
parent d108f4a070
commit 74586f9820

@ -1,44 +0,0 @@
package info.bukova.isspst.reporting;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
public class DefinitionFiller {
@Autowired
ReportDefinition definition;
@SuppressWarnings("unchecked")
private void setData(Object data) {
if (data instanceof List) {
definition.setDataSet((List<Object>)data);
} else {
definition.setSingleObject(data);
}
}
public void fillDefinition(Report report, Object data) {
definition.clear();
definition.setReport(report);
setData(data);
}
public void fillDefinition(Report report, Object data, Map<String, Object> params) {
fillDefinition(report, data);
definition.setParams(params);
}
public void fillDefinition(Report report, Object data, String[] columns) {
fillDefinition(report, data);
definition.setFieldsToPrint(Arrays.asList(columns));
}
public void fillDefinition(Report report, Object data, String[] columns, Map<String, Object> params) {
fillDefinition(report, data, params);
definition.setFieldsToPrint(Arrays.asList(columns));
}
}

@ -0,0 +1,54 @@
package info.bukova.isspst.reporting;
import info.bukova.isspst.data.AuthItem;
import info.bukova.isspst.data.TripBill;
import info.bukova.isspst.data.User;
import info.bukova.isspst.data.UserSettingsData;
import info.bukova.isspst.services.requirement.TripRequirementService;
import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.storage.FileStorage;
import org.springframework.beans.factory.annotation.Autowired;
public class ParamFiller {
@Autowired
private ReportDefinition definition;
@Autowired
private UserService userService;
@Autowired
private FileStorage storage;
@Autowired
private TripRequirementService tripReqService;
public void fill() {
if (definition.getDataSet() == null || definition.getDataSet().isEmpty()) {
return;
}
if ((definition.getDataSet().get(0) instanceof TripBill)
&& definition.getReport().isSingleRecord()) {
if (userService.getUserSettings().getSignatureFile() != null
&& !userService.getUserSettings().getSignatureFile().isEmpty()) {
definition.setParam("P_USER_SIGNATURE", storage.serverPath(userService.getUserSettings().getSignatureFile()));
}
TripBill tb = (TripBill)definition.getDataSet().get(0);
tripReqService.loadAuthItems(tb.getRequirement());
AuthItem lastAuth = tb.getRequirement().getAuthorization().get(tb.getRequirement().getAuthorization().size() - 1);
definition.setParam("P_APPROVE_DATE", lastAuth.getAuthDate());
User u = lastAuth.getApprover();
UserSettingsData approverSettings = userService.getUserSettings(u);
if (approverSettings != null
&& approverSettings.getSignatureFile() != null
&& !approverSettings.getSignatureFile().isEmpty()) {
definition.setParam("P_APPROVER_SIGNATURE", storage.serverPath(approverSettings.getSignatureFile()));
}
}
}
}

@ -6,6 +6,8 @@ import java.io.OutputStream;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -17,7 +19,10 @@ public class ReportController {
private ReportDefinition reportDefinition; private ReportDefinition reportDefinition;
@Autowired @Autowired
private GeneratorFactory factory; private GeneratorFactory factory;
@Autowired
private ParamFiller paramFiller;
private static final String ERROR_MESSAGE = "<html><body><b>Generator returned no data!</b><br/>%s</body></html>"; private static final String ERROR_MESSAGE = "<html><body><b>Generator returned no data!</b><br/>%s</body></html>";
private final static Logger logger = LoggerFactory.getLogger(ReportController.class);
private void writeError(OutputStream stream, Throwable e) { private void writeError(OutputStream stream, Throwable e) {
writeError(stream, e.toString()); writeError(stream, e.toString());
@ -45,6 +50,7 @@ public class ReportController {
throw new ReportException("Definition is null"); throw new ReportException("Definition is null");
} }
paramFiller.fill();
Generator gen = factory.createGenerator(reportDefinition); Generator gen = factory.createGenerator(reportDefinition);
byte[] data = gen.generate(); byte[] data = gen.generate();
response.setContentType(contentType); response.setContentType(contentType);
@ -54,13 +60,13 @@ public class ReportController {
os.flush(); os.flush();
os.close(); os.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error("I/O error: " + e.getMessage());
} catch (ReportException e) { } catch (ReportException e) {
logger.error("Report generation error: " + e.getMessage());
writeError(os, e); writeError(os, e);
} finally { } finally {
if (os != null) { if (os != null) {
try { try {
os.flush();
os.close(); os.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="tripBill" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f59e8277-a431-4cdc-abaa-c82c1cf193af"> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="tripBill" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f59e8277-a431-4cdc-abaa-c82c1cf193af">
<property name="ireport.zoom" value="2.0"/> <property name="ireport.zoom" value="2.0"/>
<property name="ireport.x" value="593"/> <property name="ireport.x" value="214"/>
<property name="ireport.y" value="432"/> <property name="ireport.y" value="422"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["/home/pepa/Dokumenty/dev/java/isspst/"]]></defaultValueExpression> <defaultValueExpression><![CDATA["/home/pepa/Dokumenty/dev/java/isspst/"]]></defaultValueExpression>
</parameter> </parameter>
<parameter name="P_USER_SIGNATURE" class="java.lang.String"/>
<queryString> <queryString>
<![CDATA[]]> <![CDATA[]]>
</queryString> </queryString>
@ -360,6 +361,19 @@ tuzemské pracovní cesty]]></text>
<textElement textAlignment="Right" verticalAlignment="Middle"/> <textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{requirement.downPayment}]]></textFieldExpression> <textFieldExpression><![CDATA[$F{requirement.downPayment}]]></textFieldExpression>
</textField> </textField>
<image>
<reportElement uuid="0a136d64-9565-4ed7-9baa-3b68aa98eada" x="406" y="120" width="147" height="24">
<printWhenExpression><![CDATA[$P{P_USER_SIGNATURE} != null]]></printWhenExpression>
</reportElement>
<imageExpression><![CDATA[$P{P_USER_SIGNATURE}]]></imageExpression>
</image>
<textField pattern="dd. MM. yyyy">
<reportElement uuid="bf1013d3-8037-4f6f-9c23-6e1d801afbeb" x="306" y="132" width="100" height="13"/>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[new Date()]]></textFieldExpression>
</textField>
</band> </band>
</summary> </summary>
</jasperReport> </jasperReport>

@ -2,7 +2,7 @@
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="tripRequirement" pageWidth="612" pageHeight="792" columnWidth="572" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0b7fa2d2-d452-4a1f-b1c0-2d8e16a22525"> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="tripRequirement" pageWidth="612" pageHeight="792" columnWidth="572" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0b7fa2d2-d452-4a1f-b1c0-2d8e16a22525">
<property name="ireport.zoom" value="1.5"/> <property name="ireport.zoom" value="1.5"/>
<property name="ireport.x" value="0"/> <property name="ireport.x" value="0"/>
<property name="ireport.y" value="96"/> <property name="ireport.y" value="128"/>
<style name="table"> <style name="table">
<box> <box>
<pen lineWidth="1.0" lineColor="#000000"/> <pen lineWidth="1.0" lineColor="#000000"/>
@ -32,6 +32,9 @@
</field> </field>
</subDataset> </subDataset>
<subDataset name="dataset1" uuid="2030e480-17f9-4ac5-a8f1-7499b269f3b4"/> <subDataset name="dataset1" uuid="2030e480-17f9-4ac5-a8f1-7499b269f3b4"/>
<parameter name="P_USER_SIGNATURE" class="java.lang.String"/>
<parameter name="P_APPROVE_DATE" class="java.util.Date"/>
<parameter name="P_APPROVER_SIGNATURE" class="java.lang.String"/>
<field name="requirement" class="info.bukova.isspst.data.TripRequirement"/> <field name="requirement" class="info.bukova.isspst.data.TripRequirement"/>
<field name="ownedBy" class="info.bukova.isspst.data.User"/> <field name="ownedBy" class="info.bukova.isspst.data.User"/>
<field name="requirement.reqDate" class="java.util.Date"/> <field name="requirement.reqDate" class="java.util.Date"/>
@ -307,6 +310,23 @@ L - letadlo, P - pěšky, T - taxi]]></text>
<textElement textAlignment="Right"/> <textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{requirement.downPayment}]]></textFieldExpression> <textFieldExpression><![CDATA[$F{requirement.downPayment}]]></textFieldExpression>
</textField> </textField>
<image>
<reportElement uuid="954e517f-5d23-4166-b776-7c31b4409ddd" x="378" y="71" width="183" height="50">
<printWhenExpression><![CDATA[$P{P_USER_SIGNATURE} != null]]></printWhenExpression>
</reportElement>
<imageExpression><![CDATA[$P{P_USER_SIGNATURE}]]></imageExpression>
</image>
<textField pattern="dd. MM. yyyy" isBlankWhenNull="true">
<reportElement uuid="97daa8a7-dab0-4104-babb-c3889faac21a" x="301" y="399" width="77" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$P{P_APPROVE_DATE}]]></textFieldExpression>
</textField>
<image>
<reportElement uuid="baf922bc-b6fb-4dbf-abc9-250f448baef3" x="378" y="368" width="183" height="50">
<printWhenExpression><![CDATA[$P{P_APPROVER_SIGNATURE} != null]]></printWhenExpression>
</reportElement>
<imageExpression><![CDATA[$P{P_APPROVER_SIGNATURE}]]></imageExpression>
</image>
</band> </band>
</detail> </detail>
</jasperReport> </jasperReport>

@ -159,16 +159,16 @@
<aop:scoped-proxy/> <aop:scoped-proxy/>
</bean> </bean>
<bean id="paramFiller" class="info.bukova.isspst.reporting.ParamFiller"/>
<bean id="genFactory" class="info.bukova.isspst.reporting.GeneratorFactory"/>
<!-- File storage --> <!-- File storage -->
<bean id="storage" class="info.bukova.isspst.storage.LocalFileStorage"> <bean id="storage" class="info.bukova.isspst.storage.LocalFileStorage">
<property name="context" ref="servletContext"/> <property name="context" ref="servletContext"/>
<property name="rootPath" value="/WEB-INF/upload"/> <property name="rootPath" value="/WEB-INF/upload"/>
</bean> </bean>
<bean id="definitionFiller" class="info.bukova.isspst.reporting.DefinitionFiller"/>
<bean id="genFactory" class="info.bukova.isspst.reporting.GeneratorFactory"/>
<!-- Session data --> <!-- Session data -->
<bean id="sessionData" class="info.bukova.isspst.SessionData" scope="session"> <bean id="sessionData" class="info.bukova.isspst.SessionData" scope="session">
<aop:scoped-proxy/> <aop:scoped-proxy/>

Loading…
Cancel
Save