git-svn-id: https://serverad.studio-ml.local/svn/repo/projects/IntegryManagmentSystem/trunk@1772 7169d44f-50de-5945-979c-d5cbc11e8a2d
This commit is contained in:
23
.gitattributes
vendored
23
.gitattributes
vendored
@@ -61,16 +61,24 @@ ems-core/src/main/java/it/integry/ems/resolver/SqlFieldHolder.java -text
|
|||||||
ems-core/src/main/java/it/integry/ems/rulescompleting/CommonRules.java -text
|
ems-core/src/main/java/it/integry/ems/rulescompleting/CommonRules.java -text
|
||||||
ems-core/src/main/java/it/integry/ems/rulescompleting/DroolsDataCompleting.java -text
|
ems-core/src/main/java/it/integry/ems/rulescompleting/DroolsDataCompleting.java -text
|
||||||
ems-core/src/main/java/it/integry/ems/rulescompleting/QueryRules.java -text
|
ems-core/src/main/java/it/integry/ems/rulescompleting/QueryRules.java -text
|
||||||
|
ems-core/src/main/java/it/integry/ems/service/EntityProcessor.java -text
|
||||||
ems-core/src/main/java/it/integry/ems/service/SetupGest.java -text
|
ems-core/src/main/java/it/integry/ems/service/SetupGest.java -text
|
||||||
|
ems-core/src/main/java/it/integry/ems/sync/ASyncManager.java -text
|
||||||
|
ems-core/src/main/java/it/integry/ems/sync/SyncManager.java -text
|
||||||
ems-core/src/main/java/it/integry/ems/types/EsitoType.java -text
|
ems-core/src/main/java/it/integry/ems/types/EsitoType.java -text
|
||||||
ems-core/src/main/java/it/integry/ems/types/OperationType.java -text
|
ems-core/src/main/java/it/integry/ems/types/OperationType.java -text
|
||||||
ems-core/src/main/java/it/integry/ems/types/SqlCond.java -text
|
ems-core/src/main/java/it/integry/ems/types/SqlCond.java -text
|
||||||
ems-core/src/main/java/it/integry/ems/util/EmsProperties.java -text
|
ems-core/src/main/java/it/integry/ems/util/EmsProperties.java -text
|
||||||
ems-core/src/main/java/it/integry/ems/util/HeaderRowCsvReader.java -text
|
ems-core/src/main/java/it/integry/ems/util/HeaderRowCsvReader.java -text
|
||||||
ems-core/src/main/java/it/integry/ems/util/JsonDateSerializer.java -text
|
ems-core/src/main/java/it/integry/ems/util/JsonDateSerializer.java -text
|
||||||
|
ems-core/src/main/java/it/integry/security/AuthenticationRequestWrapper.java -text
|
||||||
|
ems-core/src/main/java/it/integry/security/RestAuthenticationEntryPoint.java -text
|
||||||
ems-core/src/main/java/it/integry/security/RestCredentials.java -text
|
ems-core/src/main/java/it/integry/security/RestCredentials.java -text
|
||||||
ems-core/src/main/java/it/integry/security/RestToken.java -text
|
ems-core/src/main/java/it/integry/security/RestToken.java -text
|
||||||
ems-core/src/main/java/it/integry/security/RestUtil.java -text
|
ems-core/src/main/java/it/integry/security/RestUtil.java -text
|
||||||
|
ems-core/src/main/java/it/integry/security/filter/RestSecurityFilter.java -text
|
||||||
|
ems-core/src/main/java/it/integry/security/provider/RestAuthenticationProvider.java -text
|
||||||
|
ems-core/src/main/java/it/integry/security/provider/UserService.java -text
|
||||||
ems-core/src/main/resources/rules/general.drl -text
|
ems-core/src/main/resources/rules/general.drl -text
|
||||||
ems-core/src/main/webapp/META-INF/context.xml -text
|
ems-core/src/main/webapp/META-INF/context.xml -text
|
||||||
ems-core/src/main/webapp/WEB-INF/web.xml -text
|
ems-core/src/main/webapp/WEB-INF/web.xml -text
|
||||||
@@ -88,6 +96,7 @@ ems-logistic/.settings/org.eclipse.wst.common.project.facet.core.xml -text
|
|||||||
ems-logistic/.settings/org.eclipse.wst.validation.prefs -text
|
ems-logistic/.settings/org.eclipse.wst.validation.prefs -text
|
||||||
ems-logistic/pom.xml -text
|
ems-logistic/pom.xml -text
|
||||||
ems-logistic/src/main/java/it/integry/ems/logistic/completing/PackagesRules.java -text
|
ems-logistic/src/main/java/it/integry/ems/logistic/completing/PackagesRules.java -text
|
||||||
|
ems-logistic/src/main/java/it/integry/ems/logistic/controller/LogisticController.java -text
|
||||||
ems-logistic/src/main/java/it/integry/ems/logistic/packages/PackageImporter.java -text
|
ems-logistic/src/main/java/it/integry/ems/logistic/packages/PackageImporter.java -text
|
||||||
ems-logistic/src/main/java/it/integry/ems/logistic/packages/dialog/DialogPackageDTO.java -text
|
ems-logistic/src/main/java/it/integry/ems/logistic/packages/dialog/DialogPackageDTO.java -text
|
||||||
ems-logistic/src/main/java/it/integry/ems/logistic/service/LogisticService.java -text
|
ems-logistic/src/main/java/it/integry/ems/logistic/service/LogisticService.java -text
|
||||||
@@ -107,9 +116,11 @@ ems-retail/.settings/org.eclipse.wst.common.project.facet.core.xml -text
|
|||||||
ems-retail/.settings/org.eclipse.wst.validation.prefs -text
|
ems-retail/.settings/org.eclipse.wst.validation.prefs -text
|
||||||
ems-retail/pom.xml -text
|
ems-retail/pom.xml -text
|
||||||
ems-retail/src/main/java/it/integry/ems/retail/IReceiptsParser.java -text
|
ems-retail/src/main/java/it/integry/ems/retail/IReceiptsParser.java -text
|
||||||
|
ems-retail/src/main/java/it/integry/ems/retail/ReceiptsDialog.java -text
|
||||||
ems-retail/src/main/java/it/integry/ems/retail/ReceiptsFrontSt.java -text
|
ems-retail/src/main/java/it/integry/ems/retail/ReceiptsFrontSt.java -text
|
||||||
ems-retail/src/main/java/it/integry/ems/retail/ReceiptsParser.java -text
|
ems-retail/src/main/java/it/integry/ems/retail/ReceiptsParser.java -text
|
||||||
ems-retail/src/main/java/it/integry/ems/retail/completing/ReceiptRules.java -text
|
ems-retail/src/main/java/it/integry/ems/retail/completing/ReceiptRules.java -text
|
||||||
|
ems-retail/src/main/java/it/integry/ems/retail/controller/RetailController.java -text
|
||||||
ems-retail/src/main/java/it/integry/ems/retail/job/ReceiptsJob.java -text
|
ems-retail/src/main/java/it/integry/ems/retail/job/ReceiptsJob.java -text
|
||||||
ems-retail/src/main/java/it/integry/ems/retail/listener/ReceiptsFileListener.java -text
|
ems-retail/src/main/java/it/integry/ems/retail/listener/ReceiptsFileListener.java -text
|
||||||
ems-retail/src/main/java/it/integry/ems/retail/service/ReceiptsFolderReader.java -text
|
ems-retail/src/main/java/it/integry/ems/retail/service/ReceiptsFolderReader.java -text
|
||||||
@@ -134,17 +145,8 @@ ems-web/.settings/org.eclipse.wst.jsdt.ui.superType.name -text
|
|||||||
ems-web/.settings/org.eclipse.wst.validation.prefs -text
|
ems-web/.settings/org.eclipse.wst.validation.prefs -text
|
||||||
ems-web/pom.xml -text
|
ems-web/pom.xml -text
|
||||||
ems-web/src/main/java/it/integry/ems/controller/EmsController.java -text
|
ems-web/src/main/java/it/integry/ems/controller/EmsController.java -text
|
||||||
ems-web/src/main/java/it/integry/ems/controller/LogisticController.java -text
|
|
||||||
ems-web/src/main/java/it/integry/ems/json/JSONObjectMapper.java -text
|
ems-web/src/main/java/it/integry/ems/json/JSONObjectMapper.java -text
|
||||||
ems-web/src/main/java/it/integry/ems/service/EntityProcessor.java -text
|
ems-web/src/main/java/it/integry/ems/sync/jobs/OffLineSyncJob.java -text
|
||||||
ems-web/src/main/java/it/integry/ems/sync/ASyncManager.java -text
|
|
||||||
ems-web/src/main/java/it/integry/ems/sync/OffLineSyncJob.java -text
|
|
||||||
ems-web/src/main/java/it/integry/ems/sync/SyncManager.java -text
|
|
||||||
ems-web/src/main/java/it/integry/security/AuthenticationRequestWrapper.java -text
|
|
||||||
ems-web/src/main/java/it/integry/security/RestAuthenticationEntryPoint.java -text
|
|
||||||
ems-web/src/main/java/it/integry/security/filter/RestSecurityFilter.java -text
|
|
||||||
ems-web/src/main/java/it/integry/security/provider/RestAuthenticationProvider.java -text
|
|
||||||
ems-web/src/main/java/it/integry/security/provider/UserService.java -text
|
|
||||||
ems-web/src/main/resources/ems.properties -text
|
ems-web/src/main/resources/ems.properties -text
|
||||||
ems-web/src/main/resources/locales/messages.properties -text
|
ems-web/src/main/resources/locales/messages.properties -text
|
||||||
ems-web/src/main/resources/locales/messages_it.properties -text
|
ems-web/src/main/resources/locales/messages_it.properties -text
|
||||||
@@ -158,5 +160,6 @@ ems-web/src/main/webapp/WEB-INF/web.xml -text
|
|||||||
ems-web/src/main/webapp/index.jsp -text
|
ems-web/src/main/webapp/index.jsp -text
|
||||||
ems-web/src/test/java/it/integry/security/provider/TestLoginRestFul.java -text
|
ems-web/src/test/java/it/integry/security/provider/TestLoginRestFul.java -text
|
||||||
/pom.xml -text
|
/pom.xml -text
|
||||||
|
sql/rilascio_frontst.sql -text
|
||||||
sql/rilascio_scontrini_2015_05_05.sql -text
|
sql/rilascio_scontrini_2015_05_05.sql -text
|
||||||
sql/script.sql -text
|
sql/script.sql -text
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package it.integry.ems.controller;
|
package it.integry.ems.logistic.controller;
|
||||||
|
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.common.var.CommonConstants;
|
||||||
import it.integry.ems.base.EntityBase;
|
import it.integry.ems.base.EntityBase;
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
package it.integry.ems.retail;
|
||||||
|
|
||||||
|
import it.integry.common.utility.string.StringUtility;
|
||||||
|
import it.integry.ems.entity.Receipts;
|
||||||
|
import it.integry.ems.entity.ReceiptsPayments;
|
||||||
|
import it.integry.ems.entity.ReceiptsRows;
|
||||||
|
import it.integry.ems.service.SetupGest;
|
||||||
|
import it.integry.ems.types.OperationType;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ReceiptsDialog implements IReceiptsParser {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SetupGest setupGest;
|
||||||
|
|
||||||
|
public List<Receipts> parse(String fileName, Connection connection, String typeImport, String formatImport) throws Exception {
|
||||||
|
|
||||||
|
List<Receipts> list = new ArrayList<Receipts>();
|
||||||
|
|
||||||
|
Receipts receipts = null;
|
||||||
|
|
||||||
|
BufferedReader br = new BufferedReader(new FileReader(fileName));
|
||||||
|
String line = null;
|
||||||
|
int i=0,j=0;
|
||||||
|
try {
|
||||||
|
|
||||||
|
Object codAnag = setupGest.getImportSetup(connection, typeImport, formatImport, "COD_ANAG");
|
||||||
|
|
||||||
|
while((line = br.readLine()) != null){
|
||||||
|
String idRecord = line.substring(0, 1);
|
||||||
|
|
||||||
|
String codMdep = null;
|
||||||
|
String codCassa = null;
|
||||||
|
Date dateScontr = null;
|
||||||
|
if(("1").equals(idRecord)){
|
||||||
|
i=0;
|
||||||
|
j=0;
|
||||||
|
|
||||||
|
if(receipts != null)
|
||||||
|
list.add(receipts);
|
||||||
|
receipts = new Receipts();
|
||||||
|
receipts.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
codMdep = line.substring(1, 6).trim();
|
||||||
|
receipts.setCodMdep(codMdep);
|
||||||
|
codCassa = line.substring(6, 8).trim();
|
||||||
|
receipts.setCodCassa(codCassa);
|
||||||
|
receipts.setCodAnag(codAnag.toString());
|
||||||
|
String data =line.substring(8, 16).trim();
|
||||||
|
String ora = line.substring(16, 25).trim();
|
||||||
|
receipts.setIdScontr(new Integer(line.substring(25, 29).trim()));
|
||||||
|
receipts.setCodOper(line.substring(29, 33).trim());
|
||||||
|
receipts.setCausale(line.substring(33, 34).trim());
|
||||||
|
receipts.setCodFidelity(line.substring(34, 47).trim());
|
||||||
|
|
||||||
|
if ("P".equals(receipts.getCausale()) || "F".equals(receipts.getCausale())){
|
||||||
|
receipts.setCausale("C");
|
||||||
|
}
|
||||||
|
|
||||||
|
dateScontr = new SimpleDateFormat("yyyyMMdd HHmmssSSS").parse(data + " " + ora);
|
||||||
|
receipts.setDataScontr(dateScontr);
|
||||||
|
receipts.setDataDoc(dateScontr);
|
||||||
|
} else if(("2").equals(idRecord)){
|
||||||
|
if(receipts.getReceiptsRows() == null)
|
||||||
|
receipts.setReceiptsRows(new ArrayList<ReceiptsRows>());
|
||||||
|
ReceiptsRows row = new ReceiptsRows();
|
||||||
|
|
||||||
|
row.setCodMart(line.substring(1, 16).trim());
|
||||||
|
row.setBarCode(line.substring(16, 30).trim());
|
||||||
|
|
||||||
|
String reparto = StringUtility.leftPad(line.substring(30, 34).trim(), 3, '0');
|
||||||
|
row.setDescrizione(line.substring(34, 74).trim());
|
||||||
|
|
||||||
|
String segno = line.substring(74, 75).trim();
|
||||||
|
Double qta = new Double(line.substring(75, 82).trim())/new Double(1000);
|
||||||
|
row.setDataDoc(dateScontr);
|
||||||
|
|
||||||
|
Double valUnt = new Double(line.substring(82, 91).trim())/new Double(100);
|
||||||
|
Double importoRigaLordo = new Double(line.substring(91, 103).trim())/100000;
|
||||||
|
row.setValSco(new Double(line.substring(103, 112).trim())/new Double(100000));
|
||||||
|
row.setPromozione(line.substring(112, 121).trim());
|
||||||
|
|
||||||
|
row.setReparto(reparto);
|
||||||
|
|
||||||
|
row.setPromozione(line.substring(112, 121).trim());
|
||||||
|
|
||||||
|
if (importoRigaLordo != valUnt){
|
||||||
|
BigDecimal bd = new BigDecimal(importoRigaLordo/valUnt);
|
||||||
|
bd = bd.setScale(5, BigDecimal.ROUND_HALF_UP);
|
||||||
|
row.setQtaCnf(bd.doubleValue());
|
||||||
|
} else
|
||||||
|
row.setQtaCnf(new Double(line.substring(75, 82).trim())/new Double(1000));
|
||||||
|
|
||||||
|
String sql = "";
|
||||||
|
|
||||||
|
if("-".equals(segno))
|
||||||
|
qta = -qta;
|
||||||
|
|
||||||
|
|
||||||
|
ResultSet rs;
|
||||||
|
PreparedStatement ps;
|
||||||
|
if("".equals(row.getCodMart()) && "".equals(row.getBarCode())){
|
||||||
|
//VENDITE A REPARTO
|
||||||
|
qta = "-".equals(segno) ? new Double(-1) : new Double(1);
|
||||||
|
|
||||||
|
valUnt = importoRigaLordo;
|
||||||
|
sql = "SELECT cod_mart," +
|
||||||
|
" bar_code " +
|
||||||
|
" FROM mtb_aart " +
|
||||||
|
" WHERE cod_mart like 'D%' AND cod_mgrp = '"+ reparto + "'";
|
||||||
|
ps = connection.prepareStatement(sql);
|
||||||
|
rs = ps.executeQuery();
|
||||||
|
|
||||||
|
if(rs.next()){
|
||||||
|
row.setCodMart(rs.getString("cod_mart"));
|
||||||
|
row.setBarCode(rs.getString("bar_code"));
|
||||||
|
}rs.close();ps.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
//VERIFICA CODICE INTERNO
|
||||||
|
if(!"".equals(row.getCodMart()) && !"".equals(row.getBarCode())){
|
||||||
|
sql =
|
||||||
|
"SELECT mtb_aart.cod_mart " +
|
||||||
|
" FROM mtb_aart, " +
|
||||||
|
" mvw_barcode " +
|
||||||
|
" WHERE mtb_aart.cod_mart = mvw_barcode.cod_mart AND " +
|
||||||
|
" mtb_aart.cod_mart LIKE ('%" + row.getCodMart() + "%') AND " +
|
||||||
|
" mvw_barcode.cod_barre = '" + row.getBarCode() + "'";
|
||||||
|
ps = connection.prepareStatement(sql);
|
||||||
|
rs = ps.executeQuery();
|
||||||
|
|
||||||
|
if(rs.next()){
|
||||||
|
row.setCodMart(rs.getString("cod_mart"));
|
||||||
|
}rs.close();ps.close();
|
||||||
|
|
||||||
|
if ("".equals(row.getCodMart())) {
|
||||||
|
sql =
|
||||||
|
"SELECT mtb_aart.cod_mart " +
|
||||||
|
" FROM mtb_aart, " +
|
||||||
|
" mvw_barcode " +
|
||||||
|
" WHERE mtb_aart.cod_mart = mvw_barcode.cod_mart AND " +
|
||||||
|
" mvw_barcode.cod_barre = '" + row.getBarCode() + "'";
|
||||||
|
ps = connection.prepareStatement(sql);
|
||||||
|
rs = ps.executeQuery();
|
||||||
|
|
||||||
|
if(rs.next()){
|
||||||
|
row.setCodMart(rs.getString("cod_mart"));
|
||||||
|
}rs.close();ps.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
row.setPrzUntIva(valUnt);
|
||||||
|
row.setQtaDoc(qta);
|
||||||
|
|
||||||
|
row.setIdRiga(i + 1);
|
||||||
|
receipts.getReceiptsRows().add(row);
|
||||||
|
i++;
|
||||||
|
|
||||||
|
} else if(("3").equals(idRecord)){
|
||||||
|
if(receipts.getReceiptsPayments() == null)
|
||||||
|
receipts.setReceiptsPayments(new ArrayList<ReceiptsPayments>());
|
||||||
|
ReceiptsPayments payment = new ReceiptsPayments();
|
||||||
|
|
||||||
|
String segno = line.substring(3, 4).trim();
|
||||||
|
Double impPaga = new Double(line.substring(4, 13).trim())/new Double(100);
|
||||||
|
|
||||||
|
if(("-").equals(segno))
|
||||||
|
impPaga = -impPaga;
|
||||||
|
|
||||||
|
payment.setCodMdep(codMdep);
|
||||||
|
payment.setCodCassa(codCassa);
|
||||||
|
payment.setDataDoc(dateScontr);
|
||||||
|
payment.setTipoInca(line.substring(1, 3).trim());
|
||||||
|
|
||||||
|
BigDecimal bd = new BigDecimal(impPaga);
|
||||||
|
bd = bd.setScale(5, BigDecimal.ROUND_HALF_UP);
|
||||||
|
payment.setImpPaga(bd.doubleValue());
|
||||||
|
|
||||||
|
payment.setIdRiga(j + 1);
|
||||||
|
receipts.getReceiptsPayments().add(payment);
|
||||||
|
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
if(list.size() == 0)
|
||||||
|
list.add(receipts);
|
||||||
|
|
||||||
|
if (br != null) {
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@ package it.integry.ems.retail;
|
|||||||
import it.integry.ems.entity.Receipts;
|
import it.integry.ems.entity.Receipts;
|
||||||
import it.integry.ems.entity.ReceiptsPayments;
|
import it.integry.ems.entity.ReceiptsPayments;
|
||||||
import it.integry.ems.entity.ReceiptsRows;
|
import it.integry.ems.entity.ReceiptsRows;
|
||||||
import it.integry.ems.retail.util.CustomCsvBeanReader;
|
|
||||||
import it.integry.ems.service.SetupGest;
|
import it.integry.ems.service.SetupGest;
|
||||||
import it.integry.ems.types.OperationType;
|
import it.integry.ems.types.OperationType;
|
||||||
|
|
||||||
@@ -18,25 +17,25 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.supercsv.prefs.CsvPreference;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ReceiptsFrontSt implements IReceiptsParser{
|
public class ReceiptsFrontSt implements IReceiptsParser {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SetupGest setupGest;
|
private SetupGest setupGest;
|
||||||
|
|
||||||
public List<Receipts> parse(String fileName, Connection connection, String typeImport, String formatImport) throws Exception {
|
public List<Receipts> parse(String fileName, Connection connection, String typeImport, String formatImport) throws Exception {
|
||||||
CustomCsvBeanReader beanReader = null;
|
|
||||||
List<Receipts> list = new ArrayList<Receipts>();
|
List<Receipts> list = new ArrayList<Receipts>();
|
||||||
|
|
||||||
Receipts receipts = null;
|
Receipts receipts = null;
|
||||||
|
|
||||||
beanReader = new CustomCsvBeanReader(new FileReader(fileName), CsvPreference.TAB_PREFERENCE);
|
|
||||||
BufferedReader br = new BufferedReader(new FileReader(fileName));
|
BufferedReader br = new BufferedReader(new FileReader(fileName));
|
||||||
String line = null;
|
String line = null;
|
||||||
int i=0,j=0;
|
int i=0,j=0;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
Object codAnag = setupGest.getImportSetup(connection, typeImport, formatImport, "COD_ANAG");
|
||||||
|
|
||||||
while((line = br.readLine()) != null){
|
while((line = br.readLine()) != null){
|
||||||
|
|
||||||
String[] head;
|
String[] head;
|
||||||
@@ -47,8 +46,6 @@ public class ReceiptsFrontSt implements IReceiptsParser{
|
|||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
Date date = sdf.parse(head[3]);
|
Date date = sdf.parse(head[3]);
|
||||||
|
|
||||||
Object codAnag = setupGest.getImportSetup(connection, typeImport, formatImport, "COD_ANAG");
|
|
||||||
|
|
||||||
if(("1").equals(idRecord)){
|
if(("1").equals(idRecord)){
|
||||||
if(receipts != null)
|
if(receipts != null)
|
||||||
list.add(receipts);
|
list.add(receipts);
|
||||||
@@ -113,13 +110,11 @@ public class ReceiptsFrontSt implements IReceiptsParser{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
list.add(receipts);
|
if(list.size() == 0)
|
||||||
|
list.add(receipts);
|
||||||
if (br != null) {
|
if (br != null) {
|
||||||
br.close();
|
br.close();
|
||||||
}
|
}
|
||||||
if (beanReader != null) {
|
|
||||||
beanReader.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.supercsv.cellprocessor.Optional;
|
import org.supercsv.cellprocessor.Optional;
|
||||||
@@ -28,7 +30,7 @@ public class ReceiptsParser implements IReceiptsParser {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SetupGest setupGest;
|
private SetupGest setupGest;
|
||||||
|
|
||||||
public List<Receipts> parse(String fileName, Connection connection, String typeImport, String formatImport) throws Exception {
|
public List<Receipts> parse(String fileName, Connection connection, String typeImport, String formatImport) throws Exception {
|
||||||
CustomCsvBeanReader beanReader = null;
|
CustomCsvBeanReader beanReader = null;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
package it.integry.ems.retail.controller;
|
||||||
|
|
||||||
|
import it.integry.common.var.CommonConstants;
|
||||||
|
import it.integry.ems.base.ServiceRestResponse;
|
||||||
|
import it.integry.ems.config.Constants;
|
||||||
|
import it.integry.ems.datasource.DataSource;
|
||||||
|
import it.integry.ems.entity.Receipts;
|
||||||
|
import it.integry.ems.retail.IReceiptsParser;
|
||||||
|
import it.integry.ems.retail.ReceiptsDialog;
|
||||||
|
import it.integry.ems.retail.ReceiptsFrontSt;
|
||||||
|
import it.integry.ems.retail.ReceiptsParser;
|
||||||
|
import it.integry.ems.service.EntityProcessor;
|
||||||
|
import it.integry.ems.service.SetupGest;
|
||||||
|
import it.integry.ems.types.EsitoType;
|
||||||
|
import it.integry.ems.util.EmsProperties;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Scope(value="request")
|
||||||
|
@SuppressWarnings("finally")
|
||||||
|
public class RetailController {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntityProcessor entityProcessor;
|
||||||
|
@Autowired
|
||||||
|
private EmsProperties properties;
|
||||||
|
|
||||||
|
private IReceiptsParser parser = null;
|
||||||
|
|
||||||
|
private String section = null;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ReceiptsFrontSt receiptsFrontSt;
|
||||||
|
@Autowired
|
||||||
|
private ReceiptsParser receiptsParser;
|
||||||
|
@Autowired
|
||||||
|
private ReceiptsDialog receiptsDialog;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataSource ds;
|
||||||
|
@Autowired
|
||||||
|
private SetupGest setupGest;
|
||||||
|
|
||||||
|
@RequestMapping(value = Constants.PATH_PROCESS_ENTITY_IMPORT, method = RequestMethod.POST)
|
||||||
|
public @ResponseBody ServiceRestResponse processEntityImport(@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||||
|
@RequestParam(value=Constants.TYPE_IMPORT, required=false) String typeImport,
|
||||||
|
@RequestParam(value=Constants.FORMAT_IMPORT, required=false) String formatImport,
|
||||||
|
@RequestParam(value="filePath", required=false) String filePath) throws IOException{
|
||||||
|
ServiceRestResponse response = null;
|
||||||
|
Object pathDest = null;
|
||||||
|
try {
|
||||||
|
ds.initialize(configuration, properties.getGlobalConnectionIniPath());
|
||||||
|
Connection conn = ds.getConnection();
|
||||||
|
|
||||||
|
checkParser(conn, typeImport);
|
||||||
|
List<Receipts> receipts = parser.parse(filePath, conn, typeImport, section);
|
||||||
|
|
||||||
|
pathDest = setupGest.getImportSetup(ds.getConnection(), typeImport, section, "PATH_FILE_IMPORTED");
|
||||||
|
|
||||||
|
for (Receipts entity : receipts) {
|
||||||
|
entityProcessor.processEntity(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
response = new ServiceRestResponse(EsitoType.OK, null, configuration);
|
||||||
|
ds.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("ERRORE SU " + filePath + ", PROFILE:" +configuration + ", TYPE_IMPORT:" + typeImport + ", FORMAT_IMPORT:" + formatImport);
|
||||||
|
logger.error(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
response = new ServiceRestResponse(EsitoType.KO, e.getLocalizedMessage());
|
||||||
|
} finally {
|
||||||
|
File src = new File(filePath);
|
||||||
|
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
|
||||||
|
FileUtils.copyFile(src, new File(pathDest + "/" + fileName));
|
||||||
|
FileUtils.deleteQuietly(src);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkParser(Connection conn, String typeImport) throws Exception {
|
||||||
|
String sql = "SELECT section "
|
||||||
|
+"FROM ( SELECT DISTINCT section, "
|
||||||
|
+"(select value from stb_gest_setup setup WHERE stb_gest_setup.gest_name = setup.gest_name and stb_gest_setup.section = setup.section and key_section = 'ATTIVO' ) AS flag_attivo, "
|
||||||
|
+"(select value from stb_gest_setup setup WHERE stb_gest_setup.gest_name = setup.gest_name and stb_gest_setup.section = setup.section and key_section = 'IMPORT_NEW' ) as import_new "
|
||||||
|
+"FROM stb_gest_setup WHERE gest_name = 'IMPORT_"+typeImport+"' ) tmp "
|
||||||
|
+"WHERE tmp.flag_attivo = 'S' and tmp.import_new = 'S'";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(sql);
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
if(rs.next()){
|
||||||
|
section = rs.getString("section");
|
||||||
|
if("MMPOS_SERVICES".equals(section)){
|
||||||
|
parser = receiptsParser;
|
||||||
|
} else if("FRONT_ST".equals(section)){
|
||||||
|
parser = receiptsFrontSt;
|
||||||
|
} else if("DIALOGO".equals(section)){
|
||||||
|
parser = receiptsDialog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(parser == null)
|
||||||
|
throw new Exception("Parser scontrini non trovato");
|
||||||
|
rs.close();
|
||||||
|
ps.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,18 +5,12 @@ import it.integry.ems.base.EntityBase;
|
|||||||
import it.integry.ems.base.ServiceRestResponse;
|
import it.integry.ems.base.ServiceRestResponse;
|
||||||
import it.integry.ems.config.Constants;
|
import it.integry.ems.config.Constants;
|
||||||
import it.integry.ems.datasource.DataSource;
|
import it.integry.ems.datasource.DataSource;
|
||||||
import it.integry.ems.entity.Receipts;
|
|
||||||
import it.integry.ems.retail.IReceiptsParser;
|
|
||||||
import it.integry.ems.retail.ReceiptsFrontSt;
|
|
||||||
import it.integry.ems.retail.ReceiptsParser;
|
|
||||||
import it.integry.ems.service.EntityProcessor;
|
import it.integry.ems.service.EntityProcessor;
|
||||||
import it.integry.ems.service.SetupGest;
|
import it.integry.ems.service.SetupGest;
|
||||||
import it.integry.ems.types.EsitoType;
|
import it.integry.ems.types.EsitoType;
|
||||||
import it.integry.ems.util.EmsProperties;
|
import it.integry.ems.util.EmsProperties;
|
||||||
import it.integry.security.RestUtil;
|
import it.integry.security.RestUtil;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -34,7 +28,6 @@ import javax.ws.rs.client.Entity;
|
|||||||
import javax.ws.rs.client.WebTarget;
|
import javax.ws.rs.client.WebTarget;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -62,16 +55,7 @@ public class EmsController {
|
|||||||
private EntityProcessor entityProcessor;
|
private EntityProcessor entityProcessor;
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmsProperties properties;
|
private EmsProperties properties;
|
||||||
|
|
||||||
private IReceiptsParser parser = null;
|
|
||||||
|
|
||||||
private String section = null;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ReceiptsParser receiptsParser;
|
|
||||||
@Autowired
|
|
||||||
private ReceiptsFrontSt receiptsFrontSt;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataSource ds;
|
private DataSource ds;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -259,70 +243,4 @@ public class EmsController {
|
|||||||
return responseList;
|
return responseList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = Constants.PATH_PROCESS_ENTITY_IMPORT, method = RequestMethod.POST)
|
|
||||||
public @ResponseBody ServiceRestResponse processEntityImport(@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
|
||||||
@RequestParam(value=Constants.TYPE_IMPORT, required=false) String typeImport,
|
|
||||||
@RequestParam(value=Constants.FORMAT_IMPORT, required=false) String formatImport,
|
|
||||||
@RequestParam(value="filePath", required=false) String filePath) throws IOException{
|
|
||||||
ServiceRestResponse response = null;
|
|
||||||
Object pathDest = null;
|
|
||||||
try {
|
|
||||||
ds.initialize(configuration, properties.getGlobalConnectionIniPath());
|
|
||||||
|
|
||||||
Connection conn = ds.getConnection();
|
|
||||||
|
|
||||||
checkParser(conn, typeImport);
|
|
||||||
|
|
||||||
pathDest = setupGest.getImportSetup(ds.getConnection(), typeImport, section, "PATH_FILE_IMPORTED");
|
|
||||||
List<Receipts> receipts = parser.parse(filePath, conn, typeImport, section);
|
|
||||||
for (Receipts entity : receipts) {
|
|
||||||
entityProcessor.processEntity(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
File src = new File(filePath);
|
|
||||||
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
|
|
||||||
FileUtils.copyFile(src, new File(pathDest + "/" + fileName));
|
|
||||||
FileUtils.deleteQuietly(src);
|
|
||||||
*/
|
|
||||||
response = new ServiceRestResponse(EsitoType.OK, null, configuration);
|
|
||||||
ds.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("ERRORE SU " + filePath + ", PROFILE:" +configuration + ", TYPE_IMPORT:" + typeImport + ", FORMAT_IMPORT:" + formatImport);
|
|
||||||
logger.error(e.toString());
|
|
||||||
e.printStackTrace();
|
|
||||||
response = new ServiceRestResponse(EsitoType.KO, e.getLocalizedMessage());
|
|
||||||
} finally {
|
|
||||||
File src = new File(filePath);
|
|
||||||
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
|
|
||||||
FileUtils.copyFile(src, new File(pathDest + "/" + fileName));
|
|
||||||
FileUtils.deleteQuietly(src);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkParser(Connection conn, String typeImport) throws Exception {
|
|
||||||
String sql = "SELECT section "
|
|
||||||
+"FROM ( SELECT DISTINCT section, "
|
|
||||||
+"(select value from stb_gest_setup setup WHERE stb_gest_setup.gest_name = setup.gest_name and stb_gest_setup.section = setup.section and key_section = 'ATTIVO' ) AS flag_attivo, "
|
|
||||||
+"(select value from stb_gest_setup setup WHERE stb_gest_setup.gest_name = setup.gest_name and stb_gest_setup.section = setup.section and key_section = 'IMPORT_NEW' ) as import_new "
|
|
||||||
+"FROM stb_gest_setup WHERE gest_name = 'IMPORT_"+typeImport+"' ) tmp "
|
|
||||||
+"WHERE tmp.flag_attivo = 'S' and tmp.import_new = 'S'";
|
|
||||||
PreparedStatement ps = conn.prepareStatement(sql);
|
|
||||||
ResultSet rs = ps.executeQuery();
|
|
||||||
if(rs.next()){
|
|
||||||
section = rs.getString("section");
|
|
||||||
if("MMPOS_SERVICES".equals(section)){
|
|
||||||
parser = receiptsParser;
|
|
||||||
} else if("FRONT_ST".equals(section)){
|
|
||||||
parser = receiptsFrontSt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(parser == null)
|
|
||||||
throw new Exception("Parser scontrini non trovato");
|
|
||||||
rs.close();
|
|
||||||
ps.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package it.integry.ems.sync;
|
package it.integry.ems.sync.jobs;
|
||||||
|
|
||||||
import it.integry.ems.util.EmsProperties;
|
import it.integry.ems.util.EmsProperties;
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
<!-- SINCRONIZZAZIONI OFFLINE -->
|
<!-- SINCRONIZZAZIONI OFFLINE -->
|
||||||
|
|
||||||
<bean id="offlineSyncJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
|
<bean id="offlineSyncJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
|
||||||
<property name="jobClass" value="it.integry.ems.sync.OffLineSyncJob" />
|
<property name="jobClass" value="it.integry.ems.sync.jobs.OffLineSyncJob" />
|
||||||
<property name="durability" value="true" />
|
<property name="durability" value="true" />
|
||||||
<property name="jobDataAsMap">
|
<property name="jobDataAsMap">
|
||||||
<map>
|
<map>
|
||||||
|
|||||||
6
sql/rilascio_frontst.sql
Normal file
6
sql/rilascio_frontst.sql
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
select * from stb_gest_setup where gest_name='IMPORT_SCONTRINI' and section='FRONT_ST'
|
||||||
|
|
||||||
|
|
||||||
|
update stb_gest_setup set value = 'C0000' where gest_name='IMPORT_SCONTRINI' and section='FRONT_ST' and key_section='COD_ANAG'
|
||||||
|
update stb_gest_setup set value = 'S' where gest_name='IMPORT_SCONTRINI' and section='FRONT_ST' and key_section='IMPORT_NEW'
|
||||||
|
|
||||||
Reference in New Issue
Block a user