Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -25,17 +25,6 @@ public class JsonConfig implements WebMvcConfigurer {
|
||||
public ResponseJSONObjectMapper jacksonResponseObjectMapper() {
|
||||
final ResponseJSONObjectMapper objectMapper = new ResponseJSONObjectMapper();
|
||||
|
||||
SimpleModule simpleModule = new SimpleModule();
|
||||
simpleModule = objectMapper.addDefaultAdapters(simpleModule);
|
||||
|
||||
objectMapper.registerModule(simpleModule);
|
||||
objectMapper.setupEntityModules();
|
||||
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false);
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false);
|
||||
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@ import it.integry.ems.Import.base.EntityImportResponse;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.download.DownloadFileHandlerService;
|
||||
import it.integry.ems.download.dto.DownloadFileDto;
|
||||
import it.integry.ems.dto.CreateZipDTO;
|
||||
import it.integry.ems.dto.EntityHierarchy;
|
||||
import it.integry.ems.exception.MissingDataException;
|
||||
import it.integry.ems.export.base.EntityExportResponse;
|
||||
import it.integry.ems.export.base.EntityExportedFile;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
@@ -57,7 +59,9 @@ import org.springframework.web.util.HtmlUtils;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
@@ -69,6 +73,7 @@ import java.util.Date;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@RestController
|
||||
@Scope("request")
|
||||
@@ -1086,6 +1091,11 @@ public class EmsController {
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "createZipFromFiles", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse createZipFromFiles(@RequestBody CreateZipDTO createZipDTO) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(emsServices.createZipFromFiles(createZipDTO));
|
||||
}
|
||||
|
||||
// @RequestMapping(value = EmsRestConstants.PATH_UPLOAD_STB_EMAIL_CONTENT, method = RequestMethod.POST)
|
||||
// public ServiceRestResponse uploadStbFileAttachment(HttpServletRequest request, HttpServletResponse response,
|
||||
|
||||
108
ems-core/src/main/java/it/integry/ems/dto/CreateZipDTO.java
Normal file
108
ems-core/src/main/java/it/integry/ems/dto/CreateZipDTO.java
Normal file
@@ -0,0 +1,108 @@
|
||||
package it.integry.ems.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import it.integry.ems.report.dto.JasperDTO;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.MtbUntMis;
|
||||
import it.integry.ems_model.entity.StbActivityFile;
|
||||
import it.integry.ems_model.entity._enum.IBaseEnum;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateZipDTO {
|
||||
private List<String> listIdAttach;
|
||||
|
||||
private List<StbActivityFile> listStbActivityFile;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private SaveMode saveMode = SaveMode.STB_FILES_ATTACHED;
|
||||
|
||||
private EntityBase entityToSaveTo;
|
||||
|
||||
public List<String> getListIdAttach() {
|
||||
return listIdAttach;
|
||||
}
|
||||
|
||||
public CreateZipDTO setListIdAttach(List<String> listIdAttach) {
|
||||
this.listIdAttach = listIdAttach;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<StbActivityFile> getListStbActivityFile() {
|
||||
return listStbActivityFile;
|
||||
}
|
||||
|
||||
public CreateZipDTO setListStbActivityFile(List<StbActivityFile> listStbActivityFile) {
|
||||
this.listStbActivityFile = listStbActivityFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public CreateZipDTO setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SaveMode getSaveMode() {
|
||||
return saveMode;
|
||||
}
|
||||
|
||||
public CreateZipDTO setSaveMode(SaveMode saveMode) {
|
||||
this.saveMode = saveMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityBase getEntityToSaveTo() {
|
||||
return entityToSaveTo;
|
||||
}
|
||||
|
||||
public CreateZipDTO setEntityToSaveTo(EntityBase entityToSaveTo) {
|
||||
this.entityToSaveTo = entityToSaveTo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public enum SaveMode implements IBaseEnum<SaveMode> {
|
||||
STB_FILES_ATTACHED((short) 0),
|
||||
STB_ACTIVITY_FILE((short) 1);
|
||||
|
||||
private final short value;
|
||||
|
||||
SaveMode(final short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static SaveMode from(Object value) {
|
||||
short castValue = (short) value;
|
||||
for (SaveMode b : SaveMode.values()) {
|
||||
if (b.value == castValue)
|
||||
return b;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public short getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaveMode fromInternal(Object val) {
|
||||
return from(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.exception;
|
||||
|
||||
public class MissingDataException extends Exception {
|
||||
public MissingDataException(String method) {
|
||||
super("Dati mancanti in " + method);
|
||||
public MissingDataException(String error) {
|
||||
super("Dati mancanti: " + error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ public abstract class BaseEntityExporter implements IEntityExporter {
|
||||
}
|
||||
}
|
||||
|
||||
if (counterTotalSend > 0 && counterFailedSend != 0 && retException != null) {
|
||||
if (counterTotalSend > 0 && counterFailedSend != counterTotalSend && retException != null) {
|
||||
//Se gli invii precedenti sono andati bene usciamo
|
||||
throw retException;
|
||||
}
|
||||
|
||||
@@ -89,9 +89,9 @@ public class RequestDataDTO {
|
||||
}
|
||||
|
||||
if (shouldIncludeNulls()) {
|
||||
jsonObjectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
} else {
|
||||
jsonObjectMapper.setSerializationInclusion(JsonInclude.Include.USE_DEFAULTS);
|
||||
} else {
|
||||
jsonObjectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public class ResponseJSONObjectMapper extends ObjectMapper {
|
||||
if (onlyPkMaster && child != null)
|
||||
return;
|
||||
|
||||
if (pk != null || child != null || (sqlField != null && sqlField.isReturned())) {
|
||||
if (pk != null || child != null || (sqlField != null && sqlField.isReturned()) || !onlyPkMaster) {
|
||||
|
||||
writer.serializeAsField(pojo, jgen, provider);
|
||||
}
|
||||
@@ -134,16 +134,23 @@ public class ResponseJSONObjectMapper extends ObjectMapper {
|
||||
|
||||
setFilterProvider(filters);
|
||||
|
||||
setSerializationInclusion(Include.NON_NULL);
|
||||
|
||||
// escape dei caratteri non standard
|
||||
configure(JsonGenerator.Feature.ESCAPE_NON_ASCII, true);
|
||||
SimpleModule simpleModule = new SimpleModule();
|
||||
simpleModule = addDefaultAdapters(simpleModule);
|
||||
|
||||
setupEntityModules(simpleModule);
|
||||
registerModule(simpleModule);
|
||||
|
||||
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false);
|
||||
configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
|
||||
configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false);
|
||||
// configure(JsonGenerator.Feature.ESCAPE_NON_ASCII, true); // escape dei caratteri non standard
|
||||
|
||||
setSerializationInclusion(Include.NON_NULL);
|
||||
}
|
||||
|
||||
public void setupEntityModules() {
|
||||
SimpleModule moduleSubType = new SimpleModule();
|
||||
public void setupEntityModules(SimpleModule module) {
|
||||
|
||||
Reflections reflections = new Reflections("it.integry");
|
||||
final List<AbstractMap.SimpleEntry<String, Class<? extends EntityBase>>> classList = reflections.get(SubTypes.of(EntityBase.class, ComposedEntityBase.class).asClass())
|
||||
@@ -158,10 +165,10 @@ public class ResponseJSONObjectMapper extends ObjectMapper {
|
||||
for (AbstractMap.SimpleEntry<String, Class<? extends EntityBase>> classData : classList) {
|
||||
EntitySubTypeHolder.getMapType().put(classData.getKey(), classData.getValue());
|
||||
|
||||
moduleSubType.addAbstractTypeMapping(EntityBase.class, classData.getValue());
|
||||
registerSubtypes(classData.getValue());
|
||||
module.addAbstractTypeMapping(EntityBase.class, classData.getValue());
|
||||
}
|
||||
registerModule(moduleSubType);
|
||||
|
||||
registerSubtypes(classList.stream().map(AbstractMap.SimpleEntry::getValue).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240530174017 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("PVM", "RILEVAZIONI_STEUP", "REPORT_NAME", null, "Report name per la stampa dell'ispezione", false, "REPORT_NAME", false, false, false, false, false, null, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240531101351 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("f_suggestCodeEan14", "CREATE FUNCTION dbo.f_suggestCodeEan14\n" +
|
||||
"(\n" +
|
||||
" @partialcode varchar(13)\n" +
|
||||
")\n" +
|
||||
"RETURNS varchar(14)\n" +
|
||||
"AS\n" +
|
||||
"BEGIN\n" +
|
||||
" declare @ean14 varchar(14)\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" select @ean14 = cast(min(rowID) as varchar) + @partialcode\n" +
|
||||
" from (\n" +
|
||||
" select *\n" +
|
||||
" from stb_counter\n" +
|
||||
" where rowId between 1 and 9 and \n" +
|
||||
" not exists (select * from mvw_barcode where cod_barre like '%'+@partialcode+'%' and len(cod_barre) = 14 and isNumeric(left(cod_barre,1))=1 and left(cod_barre,1)=rowId) ) t\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" select @ean14 = @ean14 + cast([dbo].[getCheckDigitITF14](@ean14) as varchar)\n" +
|
||||
"\n" +
|
||||
" -- Return the result of the function\n" +
|
||||
" RETURN @ean14\n" +
|
||||
"\n" +
|
||||
"END");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240531160821 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement(
|
||||
"UPDATE stb_gest_setup_query \n" +
|
||||
"SET query_default = 'SELECT stb_files_attached.id_attach,\n" +
|
||||
" stb_files_attached.file_name,\n" +
|
||||
" stb_files_attached.user_name,\n" +
|
||||
" stb_files_attached.description,\n" +
|
||||
" stb_files_attached.datetime_attach,\n" +
|
||||
" stb_files_attached.file_size\n" +
|
||||
"FROM stb_files_attached\n" +
|
||||
" LEFT OUTER JOIN mrl_partita_mag_attached ON stb_files_attached.id_attach = mrl_partita_mag_attached.id_attach\n" +
|
||||
" LEFT OUTER JOIN drl_ord_attached ON stb_files_attached.id_attach = drl_ord_attached.id_attach\n" +
|
||||
" LEFT OUTER JOIN drl_doc_attached ON stb_files_attached.id_attach = drl_doc_attached.id_attach\n" +
|
||||
"WHERE data_doc IS NULL\n" +
|
||||
" AND num_doc IS NULL\n" +
|
||||
" AND parent_id_attach IS NULL\n" +
|
||||
" AND mrl_partita_mag_attached.id_attach IS NULL\n" +
|
||||
" AND mrl_partita_mag_attached.id_attach IS NULL\n" +
|
||||
" AND mrl_partita_mag_attached.id_attach IS NULL\n" +
|
||||
" AND flag_lock = ''n''\n" +
|
||||
" AND file_size > 0\n" +
|
||||
"ORDER BY stb_files_attached.file_name'\n" +
|
||||
"where cod_query = 'ATTACH_LIBERI'\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240603124310 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'", false);
|
||||
createSetup("DATI_AZIENDA", "SETUP", "VIEW_REPORT_ONLY_ADMIN", "N", "Visualizza il report del riepilogo attività solo agli utenti amministratore.", false, "SI_NO", false, false, false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
|
||||
if (isCustomer(IntegryCustomer.Carelli))
|
||||
updateSetupValue("DATI_AZIENDA", "SETUP", "VIEW_REPORT_ONLY_ADMIN", "S");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240603182627 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("CountAllegatiCommessa", "CREATE FUNCTION [dbo].[CountAllegatiCommessa](@codJcom VARCHAR(10), @userName VARCHAR(40))\n" +
|
||||
" RETURNS INTEGER\n" +
|
||||
" AS\n" +
|
||||
" BEGIN\n" +
|
||||
" DECLARE @countAllegati INTEGER\n" +
|
||||
"\n" +
|
||||
" SELECT @countAllegati = SUM(cnt)\n" +
|
||||
" FROM (SELECT COUNT(file_name) AS cnt\n" +
|
||||
" FROM stb_activity_file\n" +
|
||||
" WHERE id IN (SELECT stb_activity.activity_id\n" +
|
||||
" FROM jtb_comt\n" +
|
||||
" INNER JOIN stb_activity ON jtb_comt.cod_jcom = stb_activity.cod_jcom AND\n" +
|
||||
" stb_activity.parent_activity_id IS NULL\n" +
|
||||
" INNER JOIN stb_activity_type\n" +
|
||||
" ON stb_activity.activity_type_id =\n" +
|
||||
" stb_activity_type.activity_type_id AND\n" +
|
||||
" stb_activity_type.flag_tipologia = 'P'\n" +
|
||||
" WHERE jtb_comt.cod_jcom = @codJcom)\n" +
|
||||
"\n" +
|
||||
" UNION ALL\n" +
|
||||
"\n" +
|
||||
" SELECT COUNT(stb_activity_file.file_name) AS cnt\n" +
|
||||
" FROM stb_activity\n" +
|
||||
" INNER JOIN stb_activity_file ON stb_activity.activity_id = stb_activity_file.id\n" +
|
||||
" WHERE stb_activity.cod_jcom = @codJcom\n" +
|
||||
" AND activity_type_id IN (SELECT activity_type_id\n" +
|
||||
" FROM srl_activity_type_user\n" +
|
||||
" INNER JOIN jrl_flav_users\n" +
|
||||
" ON srl_activity_type_user.user_name = jrl_flav_users.user_name\n" +
|
||||
" INNER JOIN wtb_users\n" +
|
||||
" ON wtb_users.User_name =\n" +
|
||||
" jrl_flav_users.user_name AND\n" +
|
||||
" wtb_users.user_name = @userName)\n" +
|
||||
" AND @userName IN (stb_activity.user_creator, stb_activity.user_name)\n" +
|
||||
"\n" +
|
||||
" UNION ALL\n" +
|
||||
"\n" +
|
||||
" SELECT COUNT(filename) AS cnt\n" +
|
||||
" FROM dtb_doc_pdf\n" +
|
||||
" INNER JOIN\n" +
|
||||
" (SELECT dtb_doct.num_doc,\n" +
|
||||
" dtb_doct.data_doc,\n" +
|
||||
" dtb_doct.cod_dtip,\n" +
|
||||
" dtb_doct.cod_anag,\n" +
|
||||
" dtb_doct.ser_doc,\n" +
|
||||
" dtb_doct.cod_jcom,\n" +
|
||||
" dtb_doct.gestione,\n" +
|
||||
" MAX(versione) AS versione,\n" +
|
||||
" dtb_ordt.data_ord,\n" +
|
||||
" dtb_ordt.num_ord,\n" +
|
||||
" dtb_ordt.num_ord_provv\n" +
|
||||
" FROM dtb_doc_pdf\n" +
|
||||
" INNER JOIN dtb_doct\n" +
|
||||
" ON dtb_doct.data_doc = dtb_doc_pdf.data_doc AND\n" +
|
||||
" dtb_doct.num_doc = dtb_doc_pdf.num_doc AND\n" +
|
||||
" dtb_doct.cod_dtip = dtb_doc_pdf.cod_dtip AND\n" +
|
||||
" dtb_doct.cod_anag = dtb_doc_pdf.cod_anag AND\n" +
|
||||
" dtb_doct.ser_doc = dtb_doc_pdf.ser_doc\n" +
|
||||
" INNER JOIN dtb_docr ON dtb_doct.data_doc = dtb_docr.data_doc AND\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc AND\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc AND\n" +
|
||||
" dtb_doct.cod_dtip = dtb_docr.cod_dtip AND\n" +
|
||||
" dtb_doct.cod_anag = dtb_docr.cod_anag\n" +
|
||||
" LEFT OUTER JOIN dtb_ordt\n" +
|
||||
" ON dtb_doct.gestione = dtb_ordt.gestione AND\n" +
|
||||
" dtb_doct.data_ord = dtb_ordt.data_ord AND\n" +
|
||||
" dtb_doct.num_ord = dtb_ordt.num_ord\n" +
|
||||
" WHERE (filecontent IS NOT NULL OR ref_uuid IS NOT NULL)\n" +
|
||||
" GROUP BY dtb_doct.num_doc, dtb_doct.data_doc, dtb_doct.cod_dtip,\n" +
|
||||
" dtb_doct.cod_anag, dtb_doct.ser_doc,\n" +
|
||||
" dtb_doct.cod_jcom, dtb_doct.gestione, dtb_ordt.data_ord,\n" +
|
||||
" dtb_ordt.num_ord, dtb_ordt.num_ord_provv) t\n" +
|
||||
" ON dtb_doc_pdf.num_doc = t.num_doc AND\n" +
|
||||
" dtb_doc_pdf.data_doc = t.data_doc AND\n" +
|
||||
" dtb_doc_pdf.cod_dtip = t.cod_dtip AND\n" +
|
||||
" dtb_doc_pdf.cod_anag = t.cod_anag AND\n" +
|
||||
" dtb_doc_pdf.ser_doc = t.ser_doc AND\n" +
|
||||
" dtb_doc_pdf.versione = t.versione\n" +
|
||||
" WHERE cod_jcom = @codJcom\n" +
|
||||
"\n" +
|
||||
" UNION ALL\n" +
|
||||
"\n" +
|
||||
" SELECT COUNT(stb_files_attached.file_name) AS cnt\n" +
|
||||
" FROM stb_files_attached,\n" +
|
||||
" drl_ord_attached,\n" +
|
||||
" dtb_ordt\n" +
|
||||
" WHERE stb_files_attached.id_attach = drl_ord_attached.id_attach\n" +
|
||||
" AND drl_ord_attached.gestione = dtb_ordt.gestione\n" +
|
||||
" AND drl_ord_attached.data_ord = dtb_ordt.data_ord\n" +
|
||||
" AND drl_ord_attached.num_ord = dtb_ordt.num_ord\n" +
|
||||
" AND dtb_ordt.cod_jcom = @codJcom\n" +
|
||||
"\n" +
|
||||
" UNION ALL\n" +
|
||||
"\n" +
|
||||
" SELECT COUNT(stb_files_attached.file_name) AS cnt\n" +
|
||||
" FROM stb_files_attached,\n" +
|
||||
" drl_doc_attached,\n" +
|
||||
" dtb_docr\n" +
|
||||
" WHERE stb_files_attached.id_attach = drl_doc_attached.id_attach\n" +
|
||||
" AND drl_doc_attached.cod_anag = dtb_docr.cod_anag\n" +
|
||||
" AND drl_doc_attached.cod_dtip = dtb_docr.cod_dtip\n" +
|
||||
" AND drl_doc_attached.data_doc = dtb_docr.data_doc\n" +
|
||||
" AND drl_doc_attached.ser_doc = dtb_docr.ser_doc\n" +
|
||||
" AND drl_doc_attached.num_doc = dtb_docr.num_doc\n" +
|
||||
" AND dtb_docr.cod_jcom = @codJcom) t\n" +
|
||||
"\n" +
|
||||
" RETURN @countAllegati\n" +
|
||||
" END");
|
||||
|
||||
String value = null;
|
||||
|
||||
if (isCustomer(IntegryCustomer.Materica)) {
|
||||
executeStatement("INSERT INTO stb_activity_type (activity_type_id, estimated_duration, cod_jfas, user_name, flag_tipologia,\n" +
|
||||
" flag_attiva, link_gest, flag_sal, flag_set_alarm, flag_generate_mov,\n" +
|
||||
" flag_view_calendar)\n" +
|
||||
"VALUES (N'ESPORTAZIONE', 0.10000, N'COM', NULL, N'A', N'S', NULL, N'N', N'N', N'S', 0)");
|
||||
|
||||
value = "ESPORTAZIONE";
|
||||
}
|
||||
|
||||
createSetup("PVM", "CONTATTI_COMMESSE", "TIPO_ATTIVITA_ARCHIVIO", value,
|
||||
"Tipo di attività da assegnare alla creazione di archivi commessa", "ACTIVITY_TYPE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240604142533 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("getlistinoVendita", "CREATE FUNCTION [dbo].[getListinoVendita](@datavalidita DATETIME, @codvlis VARCHAR(5), @codmart VARCHAR(15))\n" +
|
||||
" RETURNS TABLE AS\n" +
|
||||
" RETURN\n" +
|
||||
" SELECT vtb_list.cod_vlis,\n" +
|
||||
" vtb_list.descrizione,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN tmp_list.max_lisv IS NULL THEN NULL\n" +
|
||||
" ELSE CONVERT(DATETIME, LEFT(tmp_list.max_lisv, 10)) END AS data_iniz,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN tmp_list.max_lisv IS NULL THEN NULL\n" +
|
||||
" ELSE CONVERT(INT, RIGHT(tmp_list.max_lisv, 4)) END AS versione,\n" +
|
||||
" vtb_list.cod_divi,\n" +
|
||||
" vtb_list.cambio,\n" +
|
||||
" vtb_list.flag_arr_prz_iva,\n" +
|
||||
" vtb_list.arr_ric,\n" +
|
||||
" vtb_list.flag_list_iva_inclusa,\n" +
|
||||
" vtb_list.flag_lisv_margine,\n" +
|
||||
" vtb_list.flag_add_trasp,\n" +
|
||||
" tmp_list.cod_mart AS 'cod_mart',\n" +
|
||||
" mtb_lisv_data.unt_mis_ven AS unt_mis_ven,\n" +
|
||||
" ISNULL(mtb_lisv_data.rap_conv, 1) AS rap_conv,\n" +
|
||||
" ISNULL(mtb_lisv_data.prz_base, 0) AS prz_base,\n" +
|
||||
" ISNULL(mtb_lisv_data.ricarica, 0) AS ricarico,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_lisv_data.prz_vend IS NOT NULL AND mtb_lisv_data.prz_vend <> 0 THEN\n" +
|
||||
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||
" ISNULL(mtb_lisv_data.prz_vend, 0) * 100, 2)\n" +
|
||||
" ELSE 0 END AS margine_eff,\n" +
|
||||
" --dbo.f_calcMargineEffettivo(IsNull(mtb_lisv_data.prz_base, 0), IsNull(mtb_lisv_data.prz_vend, 0), mtb_aart.perc_sfrido) as margine_eff,\n" +
|
||||
" --dbo.f_calcRicaricoEffettivo(IsNull(mtb_lisv_data.prz_base, 0), IsNull(mtb_lisv_data.prz_vend, 0), mtb_aart.perc_sfrido) ricarico_eff, \n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_lisv_data.prz_base IS NOT NULL AND mtb_lisv_data.prz_base <> 0 THEN\n" +
|
||||
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100)) * 100, 2)\n" +
|
||||
" ELSE 0 END AS ricarico_eff,\n" +
|
||||
"\n" +
|
||||
" ISNULL(mtb_lisv_data.magg_prz_vend, 0) AS magg_prz_vend,\n" +
|
||||
" ISNULL(mtb_lisv_data.prz_vend, 0) AS prz_vend,\n" +
|
||||
" ISNULL(mtb_lisv_data.prz_vend_iva, 0) AS prz_vend_iva,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_sco1, 0) AS perc_sco1,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_sco2, 0) AS perc_sco2,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_sco3, 0) AS perc_sco3,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_sco4, 0) AS perc_sco4,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_prov, 0) AS perc_prov,\n" +
|
||||
" ISNULL(mtb_lisv_data.fisso_prov, 0) AS fisso_prov,\n" +
|
||||
" ISNULL(mtb_lisv_data.posizione, '') AS posizione,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_gest, 0) AS perc_gest,\n" +
|
||||
" ISNULL(mtb_lisv_data.val_gest, 0) AS val_gest,\n" +
|
||||
" mtb_lisv_data.data_agg_prz AS data_agg_prz,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_ispe, 0) AS perc_ispe,\n" +
|
||||
" ISNULL(mtb_lisv_data.val_ispe, 0) AS val_ispe,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_promo, 0) AS perc_promo,\n" +
|
||||
" ISNULL(mtb_lisv_data.val_promo, 0) AS val_promo,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_oneri, 0) AS perc_oneri,\n" +
|
||||
" ISNULL(mtb_lisv_data.val_oneri, 0) AS val_oneri,\n" +
|
||||
" mtb_lisv_data.tipo_variazione AS tipo_variazione,\n" +
|
||||
" mtb_lisv_data.note AS note,\n" +
|
||||
" mtb_lisv_data.aggiornato_da AS aggiornato_da,\n" +
|
||||
" mtb_lisv_data.prz_vend * (1 - mtb_lisv_data.perc_sco1 / 100) * (1 - mtb_lisv_data.perc_sco2 / 100) *\n" +
|
||||
" (1 - mtb_lisv_data.perc_sco3 / 100) *\n" +
|
||||
" (1 - mtb_lisv_data.perc_sco4 / 100) AS prz_vend_netto,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN ISNULL(mtb_lisv_data.colli_pedana, 0) <> 0 THEN mtb_lisv_data.colli_pedana\n" +
|
||||
" ELSE mtb_aart.colli_pedana END AS colli_pedana,\n" +
|
||||
" mtb_lisv_data.cod_tcol_ul AS cod_tcol_ul,\n" +
|
||||
" mtb_lisv_data.cod_tcol_ui AS cod_tcol_ui,\n" +
|
||||
" ISNULL(mtb_lisv_data.prz_vend_sug, 0) AS prz_vend_sug,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN ISNULL(mtb_lisv_data.qta_cnf, 0) <> 0\n" +
|
||||
" AND dbo.getGestSetup('VTB_LIST', 'SETUP', 'QTA_CNF_LISTINO') = 'S' \n" +
|
||||
" THEN mtb_lisv_data.qta_cnf\n" +
|
||||
" ELSE mtb_aart.qta_cnf END AS qta_cnf,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN ISNULL(mtb_lisv_data.colli_strato, 0) <> 0 THEN mtb_lisv_data.colli_strato\n" +
|
||||
" ELSE mtb_aart.colli_strato END AS colli_strato,\n" +
|
||||
" mtb_lisv_data.descrizione_html AS descrizione_html,\n" +
|
||||
" mtb_lisv_data.colli_pedana AS colli_pedana_lisv,\n" +
|
||||
" mtb_lisv_data.qta_cnf AS qta_cnf_lisv,\n" +
|
||||
" mtb_lisv_data.colli_strato AS colli_strato_lisv,\n" +
|
||||
" mtb_lisv_data.sconto_cartoni,\n" +
|
||||
" mtb_lisv_data.sconto_strato,\n" +
|
||||
" mtb_lisv_data.sconto_pedane,\n" +
|
||||
" vtb_list.flag_attivo,\n" +
|
||||
" vtb_list_data.note AS note_testata,\n" +
|
||||
" ISNULL(mtb_lisv_data.flag_prz_bloccato, 'N') AS flag_prz_bloccato,\n" +
|
||||
" vtb_list_data.porto AS porto,\n" +
|
||||
" mtb_lisv_data.system_note,\n" +
|
||||
" mtb_lisv.add_val_spese,\n" +
|
||||
" mtb_lisv.add_ric_spese,\n" +
|
||||
" mtb_lisv.add_sco_spese\n" +
|
||||
" FROM (SELECT vtb_list.cod_vlis AS cod_vlis,\n" +
|
||||
" mtb_lisv_data.cod_mart,\n" +
|
||||
" MAX(CASE\n" +
|
||||
" WHEN vtb_list_data.versione IS NULL THEN NULL\n" +
|
||||
" ELSE CONVERT(VARCHAR(10), vtb_list_data.data_iniz, 111) + ' ' +\n" +
|
||||
" REPLICATE('0', 5 - LEN(vtb_list_data.versione)) +\n" +
|
||||
" CONVERT(VARCHAR(5), vtb_list_data.versione) END) AS max_lisv,\n" +
|
||||
" vtb_list.cod_vlis AS 'cod_vlis_rif'\n" +
|
||||
" FROM vtb_list\n" +
|
||||
" INNER JOIN mtb_lisv_data ON vtb_list.cod_vlis = mtb_lisv_data.cod_vlis\n" +
|
||||
" LEFT OUTER JOIN vtb_list_data ON mtb_lisv_data.cod_vlis = vtb_list_data.cod_vlis AND\n" +
|
||||
" mtb_lisv_data.versione = vtb_list_data.versione AND\n" +
|
||||
" vtb_list_data.cod_promo IS NULL AND\n" +
|
||||
" vtb_list_data.data_iniz <= ISNULL(@datavalidita, GETDATE())\n" +
|
||||
" WHERE vtb_list.cod_vlis_rif IS NULL\n" +
|
||||
" GROUP BY vtb_list.cod_vlis,\n" +
|
||||
" mtb_lisv_data.cod_mart\n" +
|
||||
" UNION\n" +
|
||||
" SELECT vtb_list.cod_vlis AS cod_vlis,\n" +
|
||||
" mtb_lisv_data.cod_mart,\n" +
|
||||
" MAX(CASE\n" +
|
||||
" WHEN vtb_list_data.versione IS NULL THEN NULL\n" +
|
||||
" ELSE CONVERT(VARCHAR(10), vtb_list_data.data_iniz, 111) + ' ' +\n" +
|
||||
" REPLICATE('0', 5 - LEN(vtb_list_data.versione_rif)) +\n" +
|
||||
" CONVERT(VARCHAR(5), vtb_list_data.versione_rif) END) AS max_lisv,\n" +
|
||||
" vtb_list.cod_vlis_rif AS 'cod_vlis_rif'\n" +
|
||||
" FROM vtb_list\n" +
|
||||
" INNER JOIN vtb_list_data ON vtb_list.cod_vlis = vtb_list_data.cod_vlis\n" +
|
||||
" INNER JOIN vtb_list_data vtb_list_data_rif\n" +
|
||||
" ON vtb_list_data.versione_rif = vtb_list_data_rif.versione AND\n" +
|
||||
" vtb_list_data.cod_vlis_rif = vtb_list_data_rif.cod_vlis\n" +
|
||||
" INNER JOIN mtb_lisv_data ON vtb_list_data_rif.cod_vlis = mtb_lisv_data.cod_vlis AND\n" +
|
||||
" vtb_list_data_rif.versione = mtb_lisv_data.versione\n" +
|
||||
"\n" +
|
||||
" WHERE vtb_list_data.data_iniz <= ISNULL(@datavalidita, GETDATE())\n" +
|
||||
" AND vtb_list.cod_vlis_rif IS NOT NULL\n" +
|
||||
" GROUP BY vtb_list.cod_vlis,\n" +
|
||||
" mtb_lisv_data.cod_mart,\n" +
|
||||
" vtb_list.cod_vlis_rif) tmp_list\n" +
|
||||
" INNER JOIN vtb_list ON vtb_list.cod_vlis = tmp_list.cod_vlis\n" +
|
||||
" INNER JOIN mtb_lisv\n" +
|
||||
" ON tmp_list.cod_vlis_rif = mtb_lisv.cod_vlis AND tmp_list.cod_mart = mtb_lisv.cod_mart\n" +
|
||||
" INNER JOIN mtb_aart ON tmp_list.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN mtb_lisv_data ON tmp_list.cod_vlis_rif = mtb_lisv_data.cod_vlis AND\n" +
|
||||
" tmp_list.cod_mart = mtb_lisv_data.cod_mart AND\n" +
|
||||
" CONVERT(INT, RIGHT(tmp_list.max_lisv, 5)) = mtb_lisv_data.versione\n" +
|
||||
" LEFT OUTER JOIN vtb_list_data ON tmp_list.cod_vlis = vtb_list_data.cod_vlis AND\n" +
|
||||
" CONVERT(INT, RIGHT(tmp_list.max_lisv, 5)) = vtb_list_data.versione\n" +
|
||||
"\n" +
|
||||
" WHERE (@codmart IS NULL OR tmp_list.cod_mart = @codmart)\n" +
|
||||
" AND (@codvlis IS NULL OR tmp_list.cod_vlis = @codvlis)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240604154542 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("ordify_getScontiCliente", "CREATE FUNCTION [dbo].[ordify_getScontiCliente](@dataValidita datetime, @codVage varchar(5), @codAnag varchar(5), @codVdes varchar(5),\n" +
|
||||
" @codMart varchar(15))\n" +
|
||||
" RETURNS TABLE\n" +
|
||||
" AS\n" +
|
||||
" RETURN\n" +
|
||||
" (\n" +
|
||||
"\n" +
|
||||
" with promo as (\n" +
|
||||
" select vtb_promo.cod_promo,\n" +
|
||||
" vtb_promo.descrizione,\n" +
|
||||
" vtb_promo.flag_sconto_contrattuale,\n" +
|
||||
" vtb_promo.data_iniz_sell_in,\n" +
|
||||
" vtb_promo.data_fine_sell_in,\n" +
|
||||
" vtb_promo.flag_tipo_promo,\n" +
|
||||
" vtb_promo.um_vend,\n" +
|
||||
" vtb_promo.qta_vend,\n" +
|
||||
" vtb_promo.um_omaggio,\n" +
|
||||
" vtb_promo.qta_omaggio,\n" +
|
||||
" vtb_promo.prz_bloccato\n" +
|
||||
" from vtb_promo\n" +
|
||||
" where vtb_promo.flag_attivo = 'S'\n" +
|
||||
" AND ISNULL(@dataValidita, dbo.f_convertDatetimeToDate(GETDATE())) BETWEEN vtb_promo.data_iniz_sell_in AND vtb_promo.data_fine_sell_in\n" +
|
||||
" and vtb_promo.cod_promo not in (select cod_promo from vtb_list_data WHERE cod_promo is not null)),\n" +
|
||||
" clienti AS (\n" +
|
||||
" select vtb_promo_clienti.*\n" +
|
||||
" from vtb_promo_clienti\n" +
|
||||
" inner join vtb_clie on vtb_promo_clienti.cod_anag = vtb_clie.cod_anag\n" +
|
||||
" inner join vtb_dest on vtb_promo_clienti.cod_anag = vtb_dest.cod_anag and\n" +
|
||||
" vtb_promo_clienti.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
" where (@codAnag is null or vtb_promo_clienti.cod_anag = @codAnag)\n" +
|
||||
" AND (@codVdes is null or vtb_promo_clienti.cod_vdes = @codVdes)\n" +
|
||||
" AND (@codVage is null or IsNull(vtb_dest.cod_vage, vtb_clie.cod_vage) = @codVage)\n" +
|
||||
" AND vtb_clie.flag_stato = 'A'\n" +
|
||||
" AND vtb_dest.flag_attivo = 'S'),\n" +
|
||||
" articoli as (\n" +
|
||||
" select vtb_promo_articoli.*\n" +
|
||||
" from vtb_promo_articoli\n" +
|
||||
" inner join mtb_aart on vtb_promo_articoli.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" where (@codMart is null or vtb_promo_articoli.cod_mart = @codMart)\n" +
|
||||
" AND mtb_aart.flag_stato = 'A'),\n" +
|
||||
" promo_sconti as (\n" +
|
||||
" select vtb_promo_sconti.cod_promo,\n" +
|
||||
" promo.descrizione,\n" +
|
||||
" promo.um_vend,\n" +
|
||||
" promo.um_omaggio,\n" +
|
||||
" vtb_promo_sconti.da_qta,\n" +
|
||||
" vtb_promo_sconti.a_qta,\n" +
|
||||
" case\n" +
|
||||
" when promo.flag_sconto_contrattuale = 'S' THEN perc_sco1\n" +
|
||||
" else null end as perc_sco1,\n" +
|
||||
" case\n" +
|
||||
" when promo.flag_sconto_contrattuale = 'S' THEN perc_sco2\n" +
|
||||
" else null end as perc_sco2,\n" +
|
||||
" case\n" +
|
||||
" when promo.flag_sconto_contrattuale = 'S' THEN perc_sco3\n" +
|
||||
" else null end as perc_sco3,\n" +
|
||||
" case\n" +
|
||||
" when promo.flag_sconto_contrattuale = 'S' THEN NULL\n" +
|
||||
" else perc_sco4 end as perc_sco4,\n" +
|
||||
" null as prz_bloccato,\n" +
|
||||
" Cast(case when promo.flag_tipo_promo = 'M' THEN 1 ELSE 0 END as bit) as is_omaggio,\n" +
|
||||
" promo.qta_omaggio,\n" +
|
||||
" promo.flag_tipo_promo,\n" +
|
||||
" promo.flag_sconto_contrattuale\n" +
|
||||
" from promo\n" +
|
||||
" inner join vtb_promo_sconti on promo.cod_promo = vtb_promo_sconti.cod_promo\n" +
|
||||
" where promo.flag_tipo_promo = 'E'\n" +
|
||||
" union all\n" +
|
||||
" select promo.cod_promo,\n" +
|
||||
" promo.descrizione,\n" +
|
||||
" promo.um_vend as um_vend,\n" +
|
||||
" promo.um_omaggio,\n" +
|
||||
" promo.qta_vend as da_qta,\n" +
|
||||
" 0 as a_qta,\n" +
|
||||
" null as perc_sco1,\n" +
|
||||
" null as perc_sco2,\n" +
|
||||
" null as perc_sco3,\n" +
|
||||
" null as perc_sco4,\n" +
|
||||
" promo.prz_bloccato as prz_bloccato,\n" +
|
||||
" Cast(case when promo.flag_tipo_promo = 'M' THEN 1 ELSE 0 END as bit) as is_omaggio,\n" +
|
||||
" promo.qta_omaggio,\n" +
|
||||
" promo.flag_tipo_promo,\n" +
|
||||
" promo.flag_sconto_contrattuale\n" +
|
||||
" from promo\n" +
|
||||
" where promo.flag_tipo_promo <> 'E'\n" +
|
||||
" )\n" +
|
||||
"\n" +
|
||||
" select clienti.cod_anag,\n" +
|
||||
" clienti.cod_vdes,\n" +
|
||||
" articoli.cod_mart,\n" +
|
||||
" promo_sconti.*\n" +
|
||||
" from promo_sconti\n" +
|
||||
" inner join clienti on promo_sconti.cod_promo = clienti.cod_promo\n" +
|
||||
" inner join articoli on promo_sconti.cod_promo = articoli.cod_promo \n" +
|
||||
" )");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240604155916 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("ordify_getScontiCliente", "CREATE FUNCTION [dbo].[ordify_getScontiCliente](@dataValidita datetime, @userName varchar(40), @codMart varchar(15))\n" +
|
||||
" RETURNS TABLE\n" +
|
||||
" AS\n" +
|
||||
" RETURN\n" +
|
||||
" (\n" +
|
||||
"\n" +
|
||||
" with promo as (\n" +
|
||||
" select vtb_promo.cod_promo,\n" +
|
||||
" vtb_promo.descrizione,\n" +
|
||||
" vtb_promo.flag_sconto_contrattuale,\n" +
|
||||
" vtb_promo.data_iniz_sell_in,\n" +
|
||||
" vtb_promo.data_fine_sell_in,\n" +
|
||||
" vtb_promo.flag_tipo_promo,\n" +
|
||||
" vtb_promo.um_vend,\n" +
|
||||
" vtb_promo.qta_vend,\n" +
|
||||
" vtb_promo.um_omaggio,\n" +
|
||||
" vtb_promo.qta_omaggio,\n" +
|
||||
" vtb_promo.prz_bloccato\n" +
|
||||
" from vtb_promo\n" +
|
||||
" where vtb_promo.flag_attivo = 'S'\n" +
|
||||
" AND ISNULL(@dataValidita, dbo.f_convertDatetimeToDate(GETDATE())) BETWEEN vtb_promo.data_iniz_sell_in AND vtb_promo.data_fine_sell_in\n" +
|
||||
" and vtb_promo.cod_promo not in (select cod_promo from vtb_list_data WHERE cod_promo is not null)),\n" +
|
||||
" clienti AS (\n" +
|
||||
" select vtb_promo_clienti.*\n" +
|
||||
" from vtb_promo_clienti\n" +
|
||||
" inner join vtb_clie on vtb_promo_clienti.cod_anag = vtb_clie.cod_anag\n" +
|
||||
" inner join vtb_dest on vtb_promo_clienti.cod_anag = vtb_dest.cod_anag and\n" +
|
||||
" vtb_promo_clienti.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
" inner join dbo.ordify_getElencoClienti(@userName) clienti on clienti.cod_anag = vtb_promo_clienti.cod_anag AND clienti.cod_vdes = vtb_promo_clienti.cod_vdes\n" +
|
||||
" where vtb_clie.flag_stato = 'A'\n" +
|
||||
" AND vtb_dest.flag_attivo = 'S'),\n" +
|
||||
" articoli as (\n" +
|
||||
" select vtb_promo_articoli.*\n" +
|
||||
" from vtb_promo_articoli\n" +
|
||||
" inner join mtb_aart on vtb_promo_articoli.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" where (@codMart is null or vtb_promo_articoli.cod_mart = @codMart)\n" +
|
||||
" AND mtb_aart.flag_stato = 'A'),\n" +
|
||||
" promo_sconti as (\n" +
|
||||
" select vtb_promo_sconti.cod_promo,\n" +
|
||||
" promo.descrizione,\n" +
|
||||
" promo.um_vend,\n" +
|
||||
" promo.um_omaggio,\n" +
|
||||
" vtb_promo_sconti.da_qta,\n" +
|
||||
" vtb_promo_sconti.a_qta,\n" +
|
||||
" case\n" +
|
||||
" when promo.flag_sconto_contrattuale = 'S' THEN perc_sco1\n" +
|
||||
" else null end as perc_sco1,\n" +
|
||||
" case\n" +
|
||||
" when promo.flag_sconto_contrattuale = 'S' THEN perc_sco2\n" +
|
||||
" else null end as perc_sco2,\n" +
|
||||
" case\n" +
|
||||
" when promo.flag_sconto_contrattuale = 'S' THEN perc_sco3\n" +
|
||||
" else null end as perc_sco3,\n" +
|
||||
" case\n" +
|
||||
" when promo.flag_sconto_contrattuale = 'S' THEN NULL\n" +
|
||||
" else perc_sco4 end as perc_sco4,\n" +
|
||||
" null as prz_bloccato,\n" +
|
||||
" Cast(case when promo.flag_tipo_promo = 'M' THEN 1 ELSE 0 END as bit) as is_omaggio,\n" +
|
||||
" promo.qta_omaggio,\n" +
|
||||
" promo.flag_tipo_promo,\n" +
|
||||
" promo.flag_sconto_contrattuale\n" +
|
||||
" from promo\n" +
|
||||
" inner join vtb_promo_sconti on promo.cod_promo = vtb_promo_sconti.cod_promo\n" +
|
||||
" where promo.flag_tipo_promo = 'E'\n" +
|
||||
" union all\n" +
|
||||
" select promo.cod_promo,\n" +
|
||||
" promo.descrizione,\n" +
|
||||
" promo.um_vend as um_vend,\n" +
|
||||
" promo.um_omaggio,\n" +
|
||||
" promo.qta_vend as da_qta,\n" +
|
||||
" 0 as a_qta,\n" +
|
||||
" null as perc_sco1,\n" +
|
||||
" null as perc_sco2,\n" +
|
||||
" null as perc_sco3,\n" +
|
||||
" null as perc_sco4,\n" +
|
||||
" promo.prz_bloccato as prz_bloccato,\n" +
|
||||
" Cast(case when promo.flag_tipo_promo = 'M' THEN 1 ELSE 0 END as bit) as is_omaggio,\n" +
|
||||
" promo.qta_omaggio,\n" +
|
||||
" promo.flag_tipo_promo,\n" +
|
||||
" promo.flag_sconto_contrattuale\n" +
|
||||
" from promo\n" +
|
||||
" where promo.flag_tipo_promo <> 'E'\n" +
|
||||
" )\n" +
|
||||
"\n" +
|
||||
" select clienti.cod_anag,\n" +
|
||||
" clienti.cod_vdes,\n" +
|
||||
" articoli.cod_mart,\n" +
|
||||
" promo_sconti.*\n" +
|
||||
" from promo_sconti\n" +
|
||||
" inner join clienti on promo_sconti.cod_promo = clienti.cod_promo\n" +
|
||||
" inner join articoli on promo_sconti.cod_promo = articoli.cod_promo \n" +
|
||||
" )");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240604180731 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement(
|
||||
"ALTER TABLE [dbo].[vtb_list_data] DROP CONSTRAINT [fk_vtb_list_data_cod_vlis_rif_cod_vlis]",
|
||||
"ALTER TABLE [dbo].[vtb_list_data] WITH CHECK ADD CONSTRAINT [fk_vtb_list_data_cod_vlis_rif_cod_vlis] FOREIGN KEY([cod_vlis_rif], [versione_rif]) " +
|
||||
"REFERENCES [dbo].[vtb_list_data] ([cod_vlis], [versione])",
|
||||
"ALTER TABLE [dbo].[vtb_list_data] CHECK CONSTRAINT [fk_vtb_list_data_cod_vlis_rif_cod_vlis]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,8 +2,15 @@ package it.integry.ems.schedule.new_cron_job.dto.operations;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseScheduledOperationDTO;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.utils.URLEncodedUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@JsonInclude
|
||||
public class ServiceCallAutomatedOperationDTO extends BaseScheduledOperationDTO {
|
||||
|
||||
@@ -47,6 +54,11 @@ public class ServiceCallAutomatedOperationDTO extends BaseScheduledOperationDTO
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<NameValuePair> parseQueryParams() {
|
||||
if(UtilityString.isNullOrEmpty(getQueryParams())) return new ArrayList<>();
|
||||
return URLEncodedUtils.parse(getQueryParams(), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public String getQueryParams() {
|
||||
return queryParams;
|
||||
}
|
||||
|
||||
@@ -1,44 +1,25 @@
|
||||
package it.integry.ems.schedule.new_cron_job.dto.operations.runners;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.schedule.new_cron_job.dto.operations.CheckB2BAutomatedOperationDTO;
|
||||
import it.integry.ems.service.HttpRestWrapper;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.utility.UtilityServer;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
public class CheckB2BScheduledOperationRunner extends BaseScheduledOperationRunner<CheckB2BAutomatedOperationDTO> {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
String port = UtilityServer.getLocalServerPort();
|
||||
final HttpRestWrapper httpRestWrapper = ContextLoader.getCurrentWebApplicationContext().getBean(HttpRestWrapper.class);
|
||||
|
||||
String baseUrl = "http://localhost:" + port + "/ems-api/"
|
||||
+ EmsRestConstants.PATH_READ_FPX_INBOX + "?"
|
||||
+ CommonConstants.PROFILE_DB + "=" + getDtoInstance().getProfileDb();
|
||||
|
||||
StringBuilder responseBody = new StringBuilder();
|
||||
HttpRestWrapper.callGeneric(
|
||||
baseUrl,
|
||||
final Object internalGetResponse = httpRestWrapper.callInternalMethod(getDtoInstance().getProfileDb(),
|
||||
EmsRestConstants.PATH_READ_FPX_INBOX,
|
||||
getDtoInstance().getUsername(),
|
||||
getDtoInstance().getPassword(),
|
||||
RequestMethod.POST,
|
||||
null,
|
||||
ContentType.APPLICATION_JSON,
|
||||
responseBody);
|
||||
null);
|
||||
|
||||
String responseJson = responseBody.toString();
|
||||
|
||||
ResponseJSONObjectMapper mapper = new ResponseJSONObjectMapper();
|
||||
|
||||
ServiceRestResponse serviceRestResponse = mapper.readValue(responseJson, ServiceRestResponse.class);
|
||||
|
||||
if (serviceRestResponse.getEsito().equals(EsitoType.KO)) {
|
||||
logger.error(String.format("Eccezione %s generata dall'operazione %s", serviceRestResponse.getErrorMessage(), this.getDtoInstance().getName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,90 +1,26 @@
|
||||
package it.integry.ems.schedule.new_cron_job.dto.operations.runners;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.schedule.new_cron_job.dto.operations.ServiceCallAutomatedOperationDTO;
|
||||
import it.integry.ems.service.HttpRestWrapper;
|
||||
import it.integry.ems_model.utility.UtilityServer;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
import javax.ws.rs.client.Entity;
|
||||
|
||||
public class ServiceCallScheduledOperationRunner extends BaseScheduledOperationRunner<ServiceCallAutomatedOperationDTO> {
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
String port = UtilityServer.getLocalServerPort();
|
||||
String baseUrl = "http://localhost:" + port + "/ems-api/"
|
||||
+ getDtoInstance().getMethodName() + "?"
|
||||
+ CommonConstants.PROFILE_DB + "=" + getDtoInstance().getProfileDb()
|
||||
+ (getDtoInstance().getQueryParams() != null ? ("&" + getDtoInstance().getQueryParams()) : "");
|
||||
|
||||
StringBuilder responseBody = new StringBuilder();
|
||||
final HttpRestWrapper httpRestWrapper = ContextLoader.getCurrentWebApplicationContext().getBean(HttpRestWrapper.class);
|
||||
|
||||
int status;
|
||||
|
||||
RequestMethod methodType = getDtoInstance().getMethodType();
|
||||
|
||||
if (methodType == null) {
|
||||
methodType = RequestMethod.POST;
|
||||
}
|
||||
|
||||
switch (methodType) {
|
||||
case GET:
|
||||
status = HttpRestWrapper.callGenericGet(
|
||||
baseUrl,
|
||||
final Object internalGetResponse = httpRestWrapper.callInternalMethod(getDtoInstance().getProfileDb(),
|
||||
getDtoInstance().getMethodName(),
|
||||
getDtoInstance().getUsername(),
|
||||
getDtoInstance().getPassword(),
|
||||
responseBody,
|
||||
null
|
||||
getDtoInstance().getMethodType(),
|
||||
getDtoInstance().parseQueryParams(),
|
||||
Entity.json(getDtoInstance().getBody())
|
||||
);
|
||||
|
||||
break;
|
||||
default:
|
||||
case POST:
|
||||
status = HttpRestWrapper.callGeneric(
|
||||
baseUrl,
|
||||
getDtoInstance().getUsername(),
|
||||
getDtoInstance().getPassword(),
|
||||
getDtoInstance().getBody(),
|
||||
ContentType.APPLICATION_JSON,
|
||||
responseBody
|
||||
);
|
||||
|
||||
break;
|
||||
case PUT:
|
||||
status = HttpRestWrapper.callGeneric(
|
||||
baseUrl,
|
||||
getDtoInstance().getUsername(),
|
||||
getDtoInstance().getPassword(),
|
||||
getDtoInstance().getBody(),
|
||||
ContentType.APPLICATION_JSON,
|
||||
responseBody,
|
||||
null,
|
||||
RequestMethod.PUT
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
String responseJson = responseBody.toString();
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(responseJson)) {
|
||||
ResponseJSONObjectMapper mapper = new ResponseJSONObjectMapper();
|
||||
|
||||
ServiceRestResponse serviceRestResponse = mapper.readValue(responseJson, ServiceRestResponse.class);
|
||||
|
||||
if (serviceRestResponse.getEsito() != null && serviceRestResponse.getEsito().equals(EsitoType.KO)) {
|
||||
logger.error(String.format("Eccezione %s generata dall'operazione %s", serviceRestResponse.getErrorMessage(), this.getDtoInstance().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
if (status != 200) {
|
||||
throw new Exception("Il servizio ha restituito lo status code " + status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,10 +13,8 @@ import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.Import.enums.EntityImportType;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.dto.ApplicationInfoDTO;
|
||||
import it.integry.ems.dto.DatabaseEngineInfoDTO;
|
||||
import it.integry.ems.dto.DatabaseInfoDTO;
|
||||
import it.integry.ems.dto.EntityHierarchy;
|
||||
import it.integry.ems.dto.*;
|
||||
import it.integry.ems.exception.MissingDataException;
|
||||
import it.integry.ems.export.base.EntityExportResponse;
|
||||
import it.integry.ems.export.base.EntityExporterUtility;
|
||||
import it.integry.ems.export.base.IEntityExporter;
|
||||
@@ -38,22 +36,18 @@ import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems.utility.UtilityDirs;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems.utility.UtilityFile;
|
||||
import it.integry.ems_model.annotation.Master;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.Azienda;
|
||||
import it.integry.ems_model.entity.MrlPartitaMagAttached;
|
||||
import it.integry.ems_model.entity.StbFilesAttached;
|
||||
import it.integry.ems_model.entity.WtbUsersInfo;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.exception.EntityException;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import it.integry.security.utility.RestUtil;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@@ -78,7 +72,10 @@ import java.lang.management.RuntimeMXBean;
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
@@ -373,7 +370,7 @@ public class EmsServices {
|
||||
if (tmpResult != null) {
|
||||
finalResult.addAll(tmpResult);
|
||||
anyError = Stream.of(tmpResult)
|
||||
.filter(x-> x !=null)
|
||||
.filter(x -> x != null)
|
||||
.anyMatch(x -> x.getException() != null);
|
||||
}
|
||||
|
||||
@@ -479,14 +476,8 @@ public class EmsServices {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (headless) {
|
||||
List<EntityBase> entityBases = new ArrayList<EntityBase>();
|
||||
EntityBase entityBase = new EntityBase() {
|
||||
};
|
||||
EntityException newEx = new EntityException(ex.getMessage());
|
||||
newEx.setStackTrace(ex.getStackTrace());
|
||||
entityBase.setException(newEx);
|
||||
entityBases.add(entityBase);
|
||||
mailService.sendErrorMailByGestNameSection(multiDBTransactionManager, "EXPORT_" + type, format, "Esportazione entity", entityBases, null, null, null);
|
||||
mailService.sendErrorMailByGestNameSection(multiDBTransactionManager, "EXPORT_" + type, format,
|
||||
"Esportazione entity", null, null, null, Collections.singletonList(ex));
|
||||
throw ex;
|
||||
} else {
|
||||
throw ex;
|
||||
@@ -590,6 +581,137 @@ public class EmsServices {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String createZipFromFiles(CreateZipDTO createZipDTO) throws Exception {
|
||||
if (createZipDTO == null) {
|
||||
throw new MissingDataException("createZipFromFiles");
|
||||
}
|
||||
|
||||
String downloadUrl = null;
|
||||
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ZipOutputStream zos = new ZipOutputStream(baos)) {
|
||||
if (createZipDTO.getListIdAttach() != null && !createZipDTO.getListIdAttach().isEmpty()) {
|
||||
List<StbFilesAttached> filesAttachedList = createZipDTO.getListIdAttach().stream()
|
||||
.map(idAttach -> {
|
||||
StbFilesAttached stbFilesAttached = new StbFilesAttached()
|
||||
.setIdAttach(idAttach);
|
||||
|
||||
stbFilesAttached.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
return stbFilesAttached;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<EntityBase> entityBases = Collections.unmodifiableList(entityProcessor.processEntityList(filesAttachedList, true));
|
||||
|
||||
UtilityEntity.throwEntitiesException(entityBases);
|
||||
|
||||
filesAttachedList = UtilityEntity.toCustomEntity(entityBases);
|
||||
|
||||
for (StbFilesAttached stbFilesAttached : filesAttachedList) {
|
||||
UtilityZip.addFileToArchive(zos, stbFilesAttached.getFileName(), stbFilesAttached.getContent());
|
||||
}
|
||||
}
|
||||
|
||||
if (createZipDTO.getListStbActivityFile() != null && !createZipDTO.getListStbActivityFile().isEmpty()) {
|
||||
List<StbActivityFile> activityFiles = createZipDTO.getListStbActivityFile().stream()
|
||||
.filter(stbActivityFile -> !UtilityString.isNullOrEmpty(stbActivityFile.getFileName()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<StbActivityFile> listStbActivityFileIds = createZipDTO.getListStbActivityFile().stream()
|
||||
.filter(stbActivityFile -> UtilityString.isNullOrEmpty(stbActivityFile.getFileName()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!listStbActivityFileIds.isEmpty()) {
|
||||
for (StbActivityFile stbActivityFile : listStbActivityFileIds) {
|
||||
String sql = Query.format(
|
||||
"SELECT file_name FROM stb_activity_file WHERE id = %s",
|
||||
stbActivityFile.getId()
|
||||
);
|
||||
|
||||
List<String> fileNames = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
for (String fileName : fileNames) {
|
||||
StbActivityFile stbActivityFileWithFilename = new StbActivityFile()
|
||||
.setId(stbActivityFile.getId())
|
||||
.setFileName(fileName);
|
||||
|
||||
activityFiles.add(stbActivityFileWithFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
activityFiles = activityFiles.stream()
|
||||
.peek(activityFile -> activityFile.setOperation(OperationType.SELECT_OBJECT))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<EntityBase> entityBases = entityProcessor.processEntityList(activityFiles, true);
|
||||
|
||||
UtilityEntity.throwEntitiesException(entityBases);
|
||||
|
||||
activityFiles = UtilityEntity.toCustomEntity(entityBases);
|
||||
|
||||
for (StbActivityFile stbActivityFile : activityFiles) {
|
||||
UtilityZip.addFileToArchive(zos, stbActivityFile.getFileName(), stbActivityFile.getContent());
|
||||
}
|
||||
}
|
||||
|
||||
if (baos.size() > 0) {
|
||||
zos.close();
|
||||
|
||||
String fileName = UtilityString.isNull(createZipDTO.getFileName(), UtilityLocalDate.formatDate(LocalDateTime.now(), "dd-MM-yyyy HH:mm:ss")) + ".zip";
|
||||
|
||||
switch (createZipDTO.getSaveMode()) {
|
||||
case STB_FILES_ATTACHED:
|
||||
StbFilesAttached zipFile = this.uploadStbFilesAttached(
|
||||
null,
|
||||
fileName,
|
||||
baos.toByteArray(),
|
||||
null, null, null, null);
|
||||
|
||||
if (zipFile != null) {
|
||||
downloadUrl = String.format("%s/%s/%s", EmsRestConstants.PATH_DOWNLOAD_STB_FILE_ATTACHMENT, zipFile.getIdAttach(), zipFile.getFileName());
|
||||
}
|
||||
|
||||
break;
|
||||
case STB_ACTIVITY_FILE:
|
||||
StbActivity stbActivity = createZipDTO.getEntityToSaveTo() instanceof StbActivity ? (StbActivity) createZipDTO.getEntityToSaveTo() : null;
|
||||
|
||||
if (stbActivity == null) {
|
||||
throw new MissingDataException("Dati mancanti in createZipFromFiles");
|
||||
}
|
||||
|
||||
StbActivityFile activityFile = new StbActivityFile()
|
||||
.setFileName(fileName)
|
||||
.setLastUpd(new Date())
|
||||
.setOriginalSize(baos.size())
|
||||
.setContent(baos.toByteArray());
|
||||
|
||||
activityFile.setOperation(OperationType.INSERT);
|
||||
|
||||
stbActivity.setStbActivityFile(new ArrayList<>());
|
||||
|
||||
stbActivity.getStbActivityFile().add(activityFile);
|
||||
|
||||
stbActivity.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
entityProcessor.processEntity(stbActivity, multiDBTransactionManager);
|
||||
|
||||
if (stbActivity.getActivityId() != null) {
|
||||
downloadUrl = String.format("%s/%s/%s", EmsRestConstants.PATH_DOWNLOAD_STB_ACTIVITY_FILE_ATTACHMENT, stbActivity.getActivityId(), fileName);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Unknown save mode " + createZipDTO.getSaveMode());
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Nessun file creato in createZipFromFiles");
|
||||
}
|
||||
}
|
||||
|
||||
return downloadUrl;
|
||||
}
|
||||
|
||||
public void cleanDirectories() throws Exception {
|
||||
//Mi leggo tutte le configurazioni che hanno i GG_CANC_FILE abilitati
|
||||
|
||||
@@ -3,11 +3,15 @@ package it.integry.ems.service;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.exception.InternalRestCallException;
|
||||
import it.integry.ems_model.utility.UtilityServer;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.security.utility.RestUtil;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -53,6 +57,59 @@ public class HttpRestWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Object callInternalMethod(String profileDb, String service, String username, RequestMethod requestMethod, List<NameValuePair> queryParams, Entity<?> bodyEntity) throws Exception {
|
||||
final String endPoint = String.format("http://localhost:%s/ems-api/", UtilityServer.getLocalServerPort());
|
||||
|
||||
final Client client = ClientBuilder.newClient();
|
||||
WebTarget resource = client.target(endPoint)
|
||||
.path(service);
|
||||
|
||||
if (queryParams != null) {
|
||||
for (NameValuePair queryParam : queryParams) {
|
||||
resource = resource.queryParam(queryParam.getName(), queryParam.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
final Invocation.Builder requestBuilder = resource
|
||||
.queryParam(CommonConstants.PROFILE_DB, profileDb)
|
||||
.request()
|
||||
//.header("Authorization", "Basic " + auth)
|
||||
.header("username", username);
|
||||
|
||||
Response response = null;
|
||||
|
||||
switch (requestMethod) {
|
||||
default:
|
||||
case POST:
|
||||
response = requestBuilder.post(bodyEntity);
|
||||
break;
|
||||
|
||||
case GET:
|
||||
response = requestBuilder.get();
|
||||
break;
|
||||
|
||||
case PUT:
|
||||
response = requestBuilder.put(bodyEntity);
|
||||
break;
|
||||
}
|
||||
|
||||
int status = response.getStatus();
|
||||
|
||||
if (status != 200)
|
||||
throw new InternalRestCallException(status);
|
||||
|
||||
String stringResponse = response.readEntity(String.class);
|
||||
|
||||
final ServiceRestResponse serviceRestResponse = jsonObjectMapper.readValue(stringResponse, ServiceRestResponse.class);
|
||||
|
||||
if (serviceRestResponse.getEsito() == EsitoType.OK || serviceRestResponse.getEsito() == EsitoType.WARNING) {
|
||||
return serviceRestResponse.getJsonObject();
|
||||
} else {
|
||||
throw new InternalRestCallException(status, serviceRestResponse.getErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static int callGenericGet(String url, String username, String password, StringBuilder bodyResponse, HashMap<String, String> queryParams) throws NoSuchAlgorithmException, KeyManagementException {
|
||||
final Client client = makeDefaultConfig();
|
||||
WebTarget webTarget = client.target(url);
|
||||
|
||||
@@ -275,12 +275,11 @@ public class MailService {
|
||||
}
|
||||
|
||||
|
||||
public void sendErrorMailByGestNameSection(MultiDBTransactionManager multiDBTransactionManager, String emailDestination, String gestName, String section,
|
||||
String mailTitle, List<EntityBase> entitiesList, byte[] fileInput, String fileName, List<AnomalieDTO> anomalie) throws Exception {
|
||||
public void sendErrorMailByGestNameSection(MultiDBTransactionManager multiDBTransactionManager, String gestName, String section,
|
||||
String mailTitle, List<EntityBase> entitiesList, List<EmailFileAttachment> attachments, List<AnomalieDTO> anomalie, List<Exception> customExceptions) throws Exception {
|
||||
|
||||
|
||||
List<EmailFileAttachment> attachments = new ArrayList<>();
|
||||
attachments.add(new EmailFileAttachment(fileName, fileInput));
|
||||
// GET DESTINATION
|
||||
String emailDestination = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), gestName, section, "EMAIL_FOR_LOG");
|
||||
|
||||
sendErrorMail(multiDBTransactionManager, emailDestination,
|
||||
mailTitle,
|
||||
@@ -288,7 +287,7 @@ public class MailService {
|
||||
entitiesList,
|
||||
attachments,
|
||||
anomalie,
|
||||
null);
|
||||
customExceptions);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.sql.Connection;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
@@ -48,6 +49,9 @@ public class AsyncHistoryManager {
|
||||
@Autowired
|
||||
private ResponseJSONObjectMapper jsonObjectMapper;
|
||||
|
||||
@Autowired
|
||||
protected EntityPropertyHolder entityHolder;
|
||||
|
||||
//Implement check list like distribuzione
|
||||
private final AtomicReference<List<ExportHistoryGroupDTO>> currentlyInExecutionG = new AtomicReference<>(new ArrayList<>());
|
||||
|
||||
@@ -147,9 +151,31 @@ public class AsyncHistoryManager {
|
||||
// exportHistoryItem.getToProcessQueue().add(JSON.toJSONString(data));
|
||||
|
||||
data.setOperation(OperationType.INSERT);
|
||||
data.setOnlyPkMaster(false);
|
||||
|
||||
final List<Field> childs = entityHolder.getEntityChildFields(data.getClass());
|
||||
|
||||
for (Field entityChildField : childs) {
|
||||
try {
|
||||
Object entityChildRef = entityChildField.get(data);
|
||||
if(entityChildRef == null) continue;
|
||||
|
||||
if (entityChildRef instanceof List) {
|
||||
for (EntityBase entityChild : (List<EntityBase>) entityChildRef) {
|
||||
entityChild.setOnlyPkMaster(false);
|
||||
}
|
||||
} else
|
||||
((EntityBase) entityChildRef).setOnlyPkMaster(false);
|
||||
} catch (IllegalAccessException e) {
|
||||
logger.error("Sync", e);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
exportHistoryGroup.getToProcessQueue().add(new AbstractMap.SimpleEntry<>(exportHistoryItem.getPublication().getEntityName(), jsonObjectMapper.writeValueAsString(data)));
|
||||
exportHistoryGroup.getToProcessQueue().add(
|
||||
new AbstractMap.SimpleEntry<>(
|
||||
exportHistoryItem.getPublication().getEntityName(),
|
||||
jsonObjectMapper.writeValueAsString(data)));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.settings.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.StbPublicationsDetail;
|
||||
import it.integry.ems_model.entity.StbTransactionLog;
|
||||
@@ -50,10 +49,10 @@ public class AsyncManager {
|
||||
|
||||
@PostContextConstruct
|
||||
public void init() {
|
||||
if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
||||
// if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
||||
looperService.add(this::internalCachePublicationsSetup, 5 * 60 * 1000, "sync-setup-cache");
|
||||
looperService.add(this::consumeToBeSavedQueue, 20 * 1000, "sync-flush-data");
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
private void internalCachePublicationsSetup() {
|
||||
|
||||
@@ -945,7 +945,22 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
long publicationId = AsyncManager.getPublicationIdIfExists(dbName, this);
|
||||
|
||||
if (publicationId > 0) {
|
||||
transactionGroupId = AsyncManager.saveNewTransaction(connection, dbName, this, publicationId, transactionGroupId);
|
||||
EntityBase clonedEntity = (EntityBase) deepClone();
|
||||
clonedEntity.setOnlyPkMaster(false);
|
||||
|
||||
final List<Field> childs = entityHolder.getEntityChildFields(getClass());
|
||||
|
||||
for (Field entityChildField : childs) {
|
||||
Object entityChildRef = entityChildField.get(clonedEntity);
|
||||
if (entityChildRef instanceof List) {
|
||||
for (EntityBase entityChild : (List<EntityBase>) entityChildRef) {
|
||||
entityChild.setOnlyPkMaster(false);
|
||||
}
|
||||
} else
|
||||
((EntityBase) entityChildRef).setOnlyPkMaster(false);
|
||||
}
|
||||
|
||||
transactionGroupId = AsyncManager.saveNewTransaction(connection, dbName, clonedEntity, publicationId, transactionGroupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class VtbList extends EntityBase {
|
||||
@SqlField(value = "flag_add_trasp", maxLength = 1, nullable = false, defaultObjectValue = "1")
|
||||
private Boolean flagAddTrasp;
|
||||
|
||||
@JsonProperty("versione_rif")
|
||||
@JsonProperty("versioneRif")
|
||||
private Integer versioneRif;
|
||||
|
||||
@Priority(101)
|
||||
|
||||
@@ -14,6 +14,12 @@ public class EntityException extends Exception {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public EntityException(Exception innerException) {
|
||||
super(innerException.getMessage());
|
||||
|
||||
this.mInnerException = innerException;
|
||||
}
|
||||
|
||||
public EntityException(Exception e, EntityBase entity, String query) {
|
||||
super("Impossibile salvare la entity " + entity.getTableName() + ".\n " +
|
||||
e.getMessage() + "\n" +
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package it.integry.ems_model.exception;
|
||||
|
||||
public class InternalRestCallException extends Exception {
|
||||
|
||||
private final int statusCode;
|
||||
|
||||
public InternalRestCallException(int statusCode) {
|
||||
super("Errore durante la chiamata (Status " + statusCode + ")");
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
public InternalRestCallException(int statusCode, String cause) {
|
||||
super(cause + " (Status " + statusCode + ")");
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
}
|
||||
@@ -91,4 +91,14 @@ public class UtilityZip {
|
||||
|
||||
return zipOutputStream;
|
||||
}
|
||||
|
||||
public static void addFileToArchive(ZipOutputStream zipOutputStream, String fileName, byte[] content) throws IOException {
|
||||
ZipEntry zipEntry = new ZipEntry(fileName);
|
||||
|
||||
zipEntry.setSize(content.length);
|
||||
|
||||
zipOutputStream.putNextEntry(zipEntry);
|
||||
zipOutputStream.write(content);
|
||||
zipOutputStream.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -821,8 +821,8 @@ public class ActivityService {
|
||||
" stb_activity.result_description AS 'descr_esito',\n" +
|
||||
" ISNULL(stb_activity.priorita, 0) AS 'priorita',\n" +
|
||||
" stb_activity.activity_type_id AS 'tipo_attivita',\n" +
|
||||
" stb_activity.ora_ins_act AS 'data_inserimento',\n" +
|
||||
"\t\t\t\t\t\t stb_activity.ora_mod_act AS 'ultima_modifica',\n" +
|
||||
" IsNull(stb_activity.ora_ins_act, stb_activity.data_ins_act) AS 'data_inserimento',\n" +
|
||||
" stb_activity.ora_mod_act AS 'ultima_modifica',\n" +
|
||||
" stb_activity.persona_rif AS 'richiedente',\n" +
|
||||
" stb_activity.estimated_enddate,\n" +
|
||||
" stb_activity.cod_mart AS cod_mart,\n" +
|
||||
|
||||
@@ -17,11 +17,7 @@ public class EmsCustomRestConstants {
|
||||
public static final String PATH_TOSCA_MIGRATE_UL_TRASFERITE = "migrateUlTrasferite";
|
||||
|
||||
|
||||
/**
|
||||
* LICOR
|
||||
*/
|
||||
|
||||
public static final String PATH_LICOR_CHIUSURA_ORDINE_CONFEZIONATI = "confezionati/ordine/termina";
|
||||
public static final String PATH_LICOR_RETTIFICA_PRODUZIONE = "produzione/rettifica";
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,22 +31,6 @@ public class LicorProductionController {
|
||||
public MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
|
||||
@RequestMapping(value = EmsCustomRestConstants.PATH_LICOR_CHIUSURA_ORDINE_CONFEZIONATI, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse chiusuraLavorazione(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestBody ChiusuraLavorazioneConfezionatoDTO chiusuraLavorazioneDTO) throws Exception {
|
||||
ServiceRestResponse response;
|
||||
try {
|
||||
licorMesProductionService.chiusuraLavorazioneConfezionato(chiusuraLavorazioneDTO);
|
||||
response = ServiceRestResponse.createPositiveResponse();
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsCustomRestConstants.PATH_LICOR_RETTIFICA_PRODUZIONE, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse rettificaProduzione(HttpServletRequest request,
|
||||
|
||||
@@ -60,9 +60,6 @@ public class LicorProductionService {
|
||||
@Autowired
|
||||
private LoadColliService loadColliService;
|
||||
|
||||
public void chiusuraLavorazioneConfezionato(ChiusuraLavorazioneConfezionatoDTO chiusuraLavorazioneDTO) throws Exception {
|
||||
return;
|
||||
}
|
||||
|
||||
private void oldchiusuraconfezionato(ChiusuraLavorazioneConfezionatoDTO chiusuraLavorazioneDTO) throws Exception {
|
||||
if (chiusuraLavorazioneDTO.getDatiCarico() == null) {
|
||||
|
||||
@@ -409,15 +409,9 @@ public class DocumentController {
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_READ_FPX_INBOX, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse readMail(@RequestParam(CommonConstants.PROFILE_DB) String configuration) {
|
||||
ServiceRestResponse serviceRestResponse = ServiceRestResponse.createPositiveResponse();
|
||||
try {
|
||||
ServiceRestResponse readMail(@RequestParam(CommonConstants.PROFILE_DB) String configuration) throws Exception {
|
||||
digitalInvoiceMailService.readMailInbox();
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
serviceRestResponse = ServiceRestResponse.createNegativeResponse(ex);
|
||||
}
|
||||
return serviceRestResponse;
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_FPX_TO_PDF, method = RequestMethod.POST)
|
||||
@@ -512,6 +506,7 @@ public class DocumentController {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_CAMBIO_TIPO_DOC, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
List<ServiceRestResponse> cambioTipoDoc(HttpServletRequest request,
|
||||
@@ -540,7 +535,7 @@ public class DocumentController {
|
||||
public @ResponseBody
|
||||
ServiceRestResponse cambioTipoDocPlan(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration ) throws Exception {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration) throws Exception {
|
||||
|
||||
try {
|
||||
cambioTipoDocPlanService.cambioTipoDoc();
|
||||
@@ -796,10 +791,9 @@ public class DocumentController {
|
||||
@RequestParam(defaultValue = "false") boolean requestThumbnail) {
|
||||
|
||||
try {
|
||||
String completeFileName = request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/") + 1);
|
||||
StbActivityFile stbActivityFile = new StbActivityFile()
|
||||
.setId(id)
|
||||
.setFileName(completeFileName);
|
||||
.setFileName(fileName);
|
||||
stbActivityFile.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
stbActivityFile = entityProcessor.processEntity(stbActivityFile, multiDBTransactionManager);
|
||||
|
||||
@@ -126,7 +126,7 @@ public class TrasformaPrevServices {
|
||||
if (headless) {
|
||||
logger.error("Trasformazione preventivi: ", firstError.get().getException());
|
||||
try {
|
||||
mailService.sendErrorMailByGestNameSection(multiDBTransactionManager, to, gestName, section, "Trasformazione preventivi",
|
||||
mailService.sendErrorMail(multiDBTransactionManager, to, "Trasformazione preventivi", String.format("%s %s", gestName, section),
|
||||
Collections.singletonList(firstError.get()), null, null, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -27,53 +27,30 @@ public class InventarioController {
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_VERIFICA_INVENTARIO, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
List<ServiceRestResponse> verificaInventario(HttpServletRequest request,
|
||||
ServiceRestResponse verificaInventario(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody VerificaInventarioDTO param) {
|
||||
@RequestBody VerificaInventarioDTO param) throws Exception {
|
||||
|
||||
List<ServiceRestResponse> listResponse = new ArrayList<ServiceRestResponse>();
|
||||
try {
|
||||
listResponse = inventarioService.verificaInventario(param);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
listResponse.add(new ServiceRestResponse(EsitoType.KO, configuration, e));
|
||||
}
|
||||
return listResponse;
|
||||
return ServiceRestResponse.createEntityPositiveResponse(inventarioService.verificaInventario(param));
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_COSTO_INVENTARIO, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse assegnaCostoInventario(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody VerificaInventarioDTO inventario) {
|
||||
@RequestBody VerificaInventarioDTO inventario) throws Exception {
|
||||
|
||||
|
||||
try {
|
||||
return new ServiceRestResponse(EsitoType.OK, inventarioService.assegnaCostoInventario(inventario), configuration);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return new ServiceRestResponse(EsitoType.KO, configuration, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_REGISTRA_INVENTARIO, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
List<ServiceRestResponse> registraDocumentoDaInventario(HttpServletRequest request,
|
||||
ServiceRestResponse registraDocumentoDaInventario(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody DocDaInventarioDTO datiDoc) {
|
||||
@RequestBody DocDaInventarioDTO datiDoc) throws Exception{
|
||||
|
||||
List<ServiceRestResponse> listResponse = new ArrayList<ServiceRestResponse>();
|
||||
try {
|
||||
|
||||
listResponse = inventarioService.registraInventario(datiDoc);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
listResponse.add(new ServiceRestResponse(EsitoType.KO, configuration, e));
|
||||
return ServiceRestResponse.createEntityPositiveResponse(inventarioService.registraInventario(datiDoc));
|
||||
}
|
||||
return listResponse;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.rules.completing.CommonRules;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.DtbDocr;
|
||||
@@ -21,6 +22,7 @@ import it.integry.ems_model.types.ApplicationName;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityDate;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -35,6 +37,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@@ -50,35 +53,26 @@ public class InventarioService {
|
||||
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
public List<ServiceRestResponse> verificaInventario(VerificaInventarioDTO parameter) throws Exception {
|
||||
List<ServiceRestResponse> respList = new ArrayList<ServiceRestResponse>();
|
||||
|
||||
public EntityBase verificaInventario(VerificaInventarioDTO parameter) throws Exception {
|
||||
Logger logger = LogManager.getLogger();
|
||||
String query;
|
||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||
Statement cmd = conn.createStatement();
|
||||
ResultSet res;
|
||||
|
||||
//completa DTO per la verifica dell'inventario
|
||||
//TipoGiacenza
|
||||
if (parameter.getTipoGiacenza().compareTo("") == 0) {
|
||||
if (parameter.getTipoGiacenza().equalsIgnoreCase("")) {
|
||||
parameter.setTipoGiacenza("DB");
|
||||
}
|
||||
|
||||
//DataInizio Giacenza
|
||||
if (!parameter.isGiacenzaDB()) {
|
||||
//ACQUISISCE LA DATA DI INIZIO PER IL CALOCLO DELLA GIACENZA DA ULTIMO INVENTARIO
|
||||
if (!UtilityString.isNullOrEmpty(parameter.getWhereCondInvPrec())) {
|
||||
|
||||
if (!parameter.isGiacenzaDB() && !UtilityString.isNullOrEmpty(parameter.getWhereCondInvPrec())) {
|
||||
query =
|
||||
"SELECT DateAdd(dd, (case when flag_operazione = 1 then 1 else 0 end), mtb_invent.data_inventario) as data_iniz_giac " +
|
||||
" FROM mtb_invent ";
|
||||
query = UtilityDB.addwhereCond(query, parameter.getWhereCondInvPrec(), false);
|
||||
res = cmd.executeQuery(query);
|
||||
while (res.next()) {
|
||||
parameter.setDataInizGiacenza(res.getDate("data_iniz_giac"));
|
||||
}
|
||||
res.close();
|
||||
}
|
||||
Date dataInizGiac = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
|
||||
parameter.setDataInizGiacenza(dataInizGiac);
|
||||
}
|
||||
|
||||
//Data Fine Giacenza
|
||||
@@ -95,7 +89,7 @@ public class InventarioService {
|
||||
}
|
||||
|
||||
// VERIFICA SE SI TRATTA DI UN INVENTARIO PER UBICAZIONE
|
||||
String gestisciUbicazione = setupGest.getSetup(conn, "w_minvent_rc", "UBICAZIONE", "GESTISCI");
|
||||
String gestisciUbicazione = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "w_minvent_rc", "UBICAZIONE", "GESTISCI");
|
||||
if (UtilityString.isNullOrEmpty(gestisciUbicazione)) {
|
||||
gestisciUbicazione = "N";
|
||||
}
|
||||
@@ -108,68 +102,35 @@ public class InventarioService {
|
||||
+ " WHERE id_inventario = " + parameter.getIdInventario() + " AND "
|
||||
+ " cod_mdep = " + UtilityDB.valueToString(parameter.getCodMdep());
|
||||
|
||||
res = cmd.executeQuery(query);
|
||||
if (res.next()) {
|
||||
String filtroInv = UtilityString.streNull(res.getString(1));
|
||||
String filtroInv = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(),query);
|
||||
if (!UtilityString.isNullOrEmpty(filtroInv)){
|
||||
String whereCondFiltro = getWhereCondFiltro(filtroInv);
|
||||
parameter.setWhereCondFiltro(whereCondFiltro);
|
||||
logger.debug("Filtro Inventario" + filtroInv);
|
||||
}
|
||||
res.close();
|
||||
} else {
|
||||
query = "SELECT count(*) "
|
||||
+ " FROM mtb_invenr "
|
||||
+ " WHERE id_inventario = " + parameter.getIdInventario() + " AND "
|
||||
+ " cod_mdep = " + UtilityDB.valueToString(parameter.getCodMdep());
|
||||
|
||||
res = cmd.executeQuery(query);
|
||||
if (res.next()) {
|
||||
Integer countRow = res.getInt(1);
|
||||
Integer countRow = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(),query);
|
||||
if (countRow == 0) {
|
||||
throw new Exception("Impossibile verificare l'inventario, non ci sono righe.");
|
||||
}
|
||||
}
|
||||
res.close();
|
||||
}
|
||||
|
||||
|
||||
// verifica assegnazione del costo in Verifica inventario
|
||||
// Potrebbe non essere più necessario, test su (ICAM)
|
||||
String assCostoInVerifica = setupGest.getSetup(conn, "w_minvent_rc", "SETUP", "ASS_COSTO_IN_VERIFICA");
|
||||
String assCostoInVerifica = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "w_minvent_rc", "SETUP", "ASS_COSTO_IN_VERIFICA");
|
||||
if (UtilityString.isNullOrEmpty(assCostoInVerifica)) {
|
||||
assCostoInVerifica = "N";
|
||||
}
|
||||
parameter.setAssCostoInVerifica(assCostoInVerifica == "S");
|
||||
|
||||
List<EntityBase> entityList = new ArrayList<EntityBase>();
|
||||
|
||||
//cancella righe Inventario
|
||||
/*
|
||||
String queryDeleteRow = "DELETE FROM mtb_invenr " +
|
||||
" WHERE id_inventario = " + parameter.getIdInventario() + " AND " +
|
||||
" cod_mdep = " + UtilityDB.valueToString(parameter.getCodMdep());
|
||||
MtbInvenr mtbInvenr = new MtbInvenr();
|
||||
mtbInvenr.setOperation(OperationType.DELETE);
|
||||
mtbInvenr.setNativeSql(queryDeleteRow);
|
||||
entityList.add(mtbInvenr); */
|
||||
|
||||
MtbInvent mtbInvent = chkStockList(parameter);
|
||||
entityList.add(mtbInvent);
|
||||
|
||||
String profileDB = multiDBTransactionManager.getPrimaryDatasource().getProfile();
|
||||
List<EntityBase> entityListReturn = entityProcessor.processEntityList(entityList, true);
|
||||
|
||||
for (EntityBase entity : entityListReturn) {
|
||||
if (entity != null) {
|
||||
if (entity.getException() != null) {
|
||||
respList.add(new ServiceRestResponse(EsitoType.KO, entity.getException().getMessage()));
|
||||
} else {
|
||||
respList.add(new ServiceRestResponse(EsitoType.OK, entity, profileDB));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return respList;
|
||||
entityProcessor.processEntity(mtbInvent, multiDBTransactionManager);
|
||||
return mtbInvent;
|
||||
}
|
||||
|
||||
private MtbInvent chkStockList(VerificaInventarioDTO datiInv) throws Exception {
|
||||
@@ -963,16 +924,7 @@ public class InventarioService {
|
||||
}
|
||||
return query;
|
||||
}
|
||||
public List<ServiceRestResponse> registraInventario(DocDaInventarioDTO datiDoc) throws Exception {
|
||||
List<ServiceRestResponse> respList = new ArrayList<ServiceRestResponse>();
|
||||
String query, gestione = "", codMdep = "";
|
||||
Integer idInventario = new Integer("0");
|
||||
BigDecimal segno = new BigDecimal(0);
|
||||
DtbDoct dtbDoct;
|
||||
List<DtbDocr> righe;
|
||||
ResultSet res;
|
||||
Statement cmd = multiDBTransactionManager.getPrimaryConnection().createStatement();
|
||||
|
||||
public List<EntityBase> registraInventario(DocDaInventarioDTO datiDoc) throws Exception {
|
||||
String whereCondInv = datiDoc.getWhereCondInv();
|
||||
if (UtilityString.isNullOrEmpty(whereCondInv)) {
|
||||
throw new Exception("Impossibile leggere le condizioni di where");
|
||||
@@ -987,19 +939,16 @@ public class InventarioService {
|
||||
throw new Exception("Impossibile registrare l'inventario. Codice tipo documento non configurato");
|
||||
}
|
||||
|
||||
query = "SELECT gestione, " +
|
||||
" (segno_qta_car - segno_qta_scar) as segno " +
|
||||
String query = "SELECT gestione, " +
|
||||
" Cast((segno_qta_car - segno_qta_scar) as numeric) as segno " +
|
||||
" FROM dtb_tipi " +
|
||||
" WHERE cod_dtip = " + UtilityDB.valueToString(codDtip);
|
||||
|
||||
res = cmd.executeQuery(query);
|
||||
if (res.next()) {
|
||||
gestione = res.getString("gestione");
|
||||
segno = res.getBigDecimal("segno");
|
||||
}
|
||||
res.close();
|
||||
HashMap<String, Object> datiTipoDoc = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
|
||||
String gestione = UtilityHashMap.getValueIfExists(datiTipoDoc, "gestione");
|
||||
BigDecimal segno = UtilityHashMap.getValueIfExists(datiTipoDoc, "segno");
|
||||
|
||||
String codAnagDepo = null, codVdesDepo = null;
|
||||
//Acquisizone chiave inventario
|
||||
query = " SELECT mtb_invent.cod_mdep, " +
|
||||
" mtb_invent.id_inventario, " +
|
||||
@@ -1009,24 +958,19 @@ public class InventarioService {
|
||||
" mtb_depo.cod_vdes " +
|
||||
" FROM mtb_invent inner join mtb_depo on mtb_invent.cod_mdep = mtb_depo.cod_mdep ";
|
||||
query = UtilityDB.addwhereCond(query, whereCondInv, false);
|
||||
res = cmd.executeQuery(query);
|
||||
Date dataVerInv = null, dataRegMax = null;
|
||||
if (res.next()) {
|
||||
codMdep = res.getString("cod_mdep");
|
||||
idInventario = res.getInt("id_inventario");
|
||||
dataVerInv = res.getTimestamp("data_ver");
|
||||
dataRegMax = res.getDate("data_reg");
|
||||
codAnagDepo = res.getString("cod_anag");
|
||||
codVdesDepo = res.getString("cod_vdes");
|
||||
}
|
||||
res.close();
|
||||
|
||||
Date dataDoc = datiDoc.getDataDoc();
|
||||
if (dataDoc == null) {
|
||||
dataDoc = dataRegMax;
|
||||
}
|
||||
HashMap<String, Object> datiInv = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
|
||||
String codAnag = null, codVdes = null;
|
||||
String codMdep = UtilityHashMap.getValueIfExists(datiInv,"cod_mdep");
|
||||
Integer idInventario = UtilityHashMap.getValueIfExists(datiInv,"id_inventario");
|
||||
Date dataVerInv = UtilityHashMap.getValueIfExists(datiInv,"data_ver");
|
||||
Date dataRegMax = UtilityHashMap.getValueIfExists(datiInv,"data_reg");
|
||||
String codAnagDepo = UtilityHashMap.getValueIfExists(datiInv,"cod_anag");
|
||||
String codVdesDepo = UtilityHashMap.getValueIfExists(datiInv,"cod_vdes");
|
||||
|
||||
Date dataDoc = UtilityDate.isNull(datiDoc.getDataDoc(), dataRegMax);
|
||||
|
||||
String codAnag, codVdes;
|
||||
if (UtilityString.isNullOrEmpty(datiDoc.getCodAnag())) {
|
||||
codAnag = codAnagDepo;
|
||||
codVdes = codVdesDepo;
|
||||
@@ -1057,18 +1001,17 @@ public class InventarioService {
|
||||
throw new Exception("Attenzione sono stati inseriti/modificati dei documenti dopo la verifica dell'inventario. Prima di registrare questo inventario rifare la verifica.");
|
||||
}
|
||||
|
||||
dtbDoct = new DtbDoct();
|
||||
dtbDoct.setGestione(gestione);
|
||||
dtbDoct.setCodMdep(codMdep);
|
||||
dtbDoct.setCodDtip(codDtip);
|
||||
dtbDoct.setCodAnag(codAnag);
|
||||
dtbDoct.setCodVdes(codVdes);
|
||||
dtbDoct.setDataDoc(dataDoc);
|
||||
dtbDoct.setSerDoc(datiDoc.getSerDoc());
|
||||
dtbDoct.setDataReg(dataDoc);
|
||||
DtbDoct dtbDoct = new DtbDoct()
|
||||
.setGestione(gestione)
|
||||
.setCodMdep(codMdep)
|
||||
.setCodDtip(codDtip)
|
||||
.setCodAnag(codAnag)
|
||||
.setCodVdes(codVdes)
|
||||
.setDataDoc(dataDoc)
|
||||
.setSerDoc(datiDoc.getSerDoc())
|
||||
.setDataReg(dataDoc);
|
||||
dtbDoct.setOperation(OperationType.INSERT);
|
||||
righe = new ArrayList<DtbDocr>();
|
||||
dtbDoct.setDtbDocr(righe);
|
||||
dtbDoct.setDtbDocr(new ArrayList<>());
|
||||
|
||||
query = " SELECT mtb_invent.cod_mdep, " +
|
||||
" mtb_invent.id_inventario, " +
|
||||
@@ -1083,34 +1026,35 @@ public class InventarioService {
|
||||
" FROM mtb_invent INNER JOIN mtb_invenr ON mtb_invent.id_inventario = mtb_invenr.id_inventario and " +
|
||||
" mtb_invent.cod_mdep = mtb_invenr.cod_mdep " +
|
||||
" LEFT OUTER JOIN mtb_aart ON mtb_invenr.cod_mart = mtb_aart.cod_mart " +
|
||||
" WHERE mtb_invent.id_inventario = mtb_invenr.id_inventario and " +
|
||||
" mtb_invent.cod_mdep = mtb_invenr.cod_mdep and " +
|
||||
" ( mtb_invenr.qta_inv - mtb_invenr.giacenza_db <> 0 OR " +
|
||||
" WHERE ( mtb_invenr.qta_inv - mtb_invenr.giacenza_db <> 0 OR " +
|
||||
" ( IsNull(mtb_aart.flag_qta_cnf_fissa, 'S') = 'N' AND mtb_invenr.num_conf - mtb_invenr.giacenza_conf <> 0)) ";
|
||||
query = UtilityDB.addwhereCond(query, whereCondInv, false);
|
||||
|
||||
res = cmd.executeQuery(query);
|
||||
while (res.next()) {
|
||||
codMdep = res.getString("cod_mdep");
|
||||
idInventario = res.getInt("id_inventario");
|
||||
String codMart = res.getString("cod_mart");
|
||||
String partitaMag = res.getString("partita_mag");
|
||||
String codCol = res.getString("cod_col");
|
||||
String codTagl = res.getString("cod_tagl");
|
||||
BigDecimal qtaDoc = res.getBigDecimal("qta_doc");
|
||||
BigDecimal costoInv = res.getBigDecimal("costo_inv");
|
||||
BigDecimal numConf = res.getBigDecimal("num_conf");
|
||||
String tipoGiacenza = res.getString("tipo_giacenza");
|
||||
List<HashMap<String, Object>> righeInv = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
|
||||
|
||||
for(HashMap<String, Object> riga: righeInv) {
|
||||
codMdep = UtilityHashMap.getValueIfExists(riga, "cod_mdep");
|
||||
idInventario = UtilityHashMap.getValueIfExists(riga, "id_inventario");
|
||||
String codMart = UtilityHashMap.getValueIfExists(riga, "cod_mart");
|
||||
String partitaMag = UtilityHashMap.getValueIfExists(riga, "partita_mag");
|
||||
String codCol = UtilityHashMap.getValueIfExists(riga, "cod_col");
|
||||
String codTagl = UtilityHashMap.getValueIfExists(riga, "cod_tagl");
|
||||
BigDecimal qtaDoc = UtilityHashMap.getValueIfExists(riga, "qta_doc");
|
||||
BigDecimal costoInv = UtilityHashMap.getValueIfExists(riga, "costo_inv");
|
||||
BigDecimal numConf = UtilityHashMap.getValueIfExists(riga, "num_conf");
|
||||
String tipoGiacenza = UtilityHashMap.getValueIfExists(riga, "tipo_giacenza");
|
||||
qtaDoc = qtaDoc.multiply(segno);
|
||||
if (numConf != null) numConf = numConf.multiply(segno);
|
||||
|
||||
DtbDocr dtbDocr = new DtbDocr();
|
||||
dtbDocr.setCodMart(codMart);
|
||||
dtbDocr.setPartitaMag(partitaMag);
|
||||
dtbDocr.setCodCol(codCol);
|
||||
dtbDocr.setCodTagl(codTagl);
|
||||
dtbDocr.setQtaDoc(qtaDoc);
|
||||
dtbDocr.setNumCnf(numConf);
|
||||
DtbDocr dtbDocr =
|
||||
new DtbDocr()
|
||||
.setCodMart(codMart)
|
||||
.setPartitaMag(partitaMag)
|
||||
.setCodCol(codCol)
|
||||
.setCodTagl(codTagl)
|
||||
.setQtaDoc(qtaDoc)
|
||||
.setNumCnf(numConf);
|
||||
if (numConf != null && numConf.compareTo(BigDecimal.ZERO) == 0) {
|
||||
dtbDocr.setQtaCnf(null);
|
||||
}
|
||||
@@ -1129,26 +1073,22 @@ public class InventarioService {
|
||||
dtbDocr.setValUnt(costoInv);
|
||||
}
|
||||
dtbDocr.setOperation(OperationType.INSERT);
|
||||
righe.add(dtbDocr);
|
||||
dtbDoct.getDtbDocr().add(dtbDocr);
|
||||
|
||||
}
|
||||
res.close();
|
||||
if (righe.isEmpty())
|
||||
if (dtbDoct.getDtbDocr().isEmpty())
|
||||
throw new Exception("Nessuna riga da registrare ");
|
||||
|
||||
//SALVATAGGIO
|
||||
List<EntityBase> entityList = new ArrayList<EntityBase>();
|
||||
entityList.add(dtbDoct);
|
||||
|
||||
String profileDb = multiDBTransactionManager.getPrimaryDatasource().getProfile();
|
||||
|
||||
List<EntityBase> entities = entityProcessor.processEntityList(entityList, false);
|
||||
entityProcessor.processEntity(dtbDoct, multiDBTransactionManager);
|
||||
|
||||
UtilityEntity.throwEntityException(dtbDoct);
|
||||
|
||||
List<EntityBase> entityBaseList = new ArrayList<>();
|
||||
entityBaseList.add(dtbDoct);
|
||||
|
||||
for (EntityBase entity : entities) {
|
||||
if (entity.getException() != null) {
|
||||
respList.add(new ServiceRestResponse(EsitoType.KO, entity.getException().getMessage()));
|
||||
} else if (entity instanceof DtbDoct) {
|
||||
DtbDoct docInv = (DtbDoct) entity;
|
||||
|
||||
MtbInvent mtbInvent = new MtbInvent();
|
||||
mtbInvent.setOperation(OperationType.UPDATE);
|
||||
@@ -1157,23 +1097,19 @@ public class InventarioService {
|
||||
mtbInvent.setFlagStato("2");
|
||||
mtbInvent.setRegistratoDa(requestDataDTO.getUsername());
|
||||
mtbInvent.setDataReg(new Date());
|
||||
mtbInvent.setCodAnag(docInv.getCodAnag());
|
||||
mtbInvent.setCodDtip(docInv.getCodDtip());
|
||||
mtbInvent.setDataDoc(docInv.getDataDoc());
|
||||
mtbInvent.setSerDoc(docInv.getSerDoc());
|
||||
mtbInvent.setNumDoc(docInv.getNumDoc());
|
||||
mtbInvent.setCodAnag(dtbDoct.getCodAnag());
|
||||
mtbInvent.setCodDtip(dtbDoct.getCodDtip());
|
||||
mtbInvent.setDataDoc(dtbDoct.getDataDoc());
|
||||
mtbInvent.setSerDoc(dtbDoct.getSerDoc());
|
||||
mtbInvent.setNumDoc(dtbDoct.getNumDoc());
|
||||
|
||||
entityProcessor.processEntity(mtbInvent, true, false, requestDataDTO.getUsername(), multiDBTransactionManager);
|
||||
if (mtbInvent.getException() != null) {
|
||||
respList.add(new ServiceRestResponse(EsitoType.KO, mtbInvent.getException().getMessage()));
|
||||
} else {
|
||||
respList.add(new ServiceRestResponse(EsitoType.OK, mtbInvent, profileDb));
|
||||
respList.add(new ServiceRestResponse(EsitoType.OK, docInv, profileDb));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return respList;
|
||||
UtilityEntity.throwEntityException(mtbInvent);
|
||||
|
||||
entityBaseList.add(mtbInvent);
|
||||
|
||||
return entityBaseList;
|
||||
}
|
||||
|
||||
public MtbInvent assegnaCostoInventario(VerificaInventarioDTO inventario) throws Exception {
|
||||
|
||||
@@ -237,7 +237,7 @@ public class Slim2kLogisticService {
|
||||
respList.add(new ServiceRestResponse(EsitoType.KO, entity.getException().getMessage()));
|
||||
|
||||
mailService.sendErrorMailByGestNameSection(multiDBTransactionManager, type, format, null,
|
||||
Collections.singletonList(entity), null, null, null);
|
||||
Collections.singletonList(entity), (byte[]) null, null, null);
|
||||
} else {
|
||||
respList.add(new ServiceRestResponse(EsitoType.OK, entity, multiDBTransactionManager.getPrimaryDatasource().getProfile()));
|
||||
}
|
||||
@@ -498,7 +498,7 @@ public class Slim2kLogisticService {
|
||||
|
||||
if (!entitiesWithErrors.isEmpty()) {
|
||||
mailService.sendErrorMailByGestNameSection(multiDBTransactionManager, type, format, null,
|
||||
entitiesWithErrors, null, null, null);
|
||||
entitiesWithErrors, (byte[]) null, null, null);
|
||||
}
|
||||
|
||||
for (EntityBase entity : colli) {
|
||||
|
||||
@@ -96,6 +96,7 @@ public class ImportListiniAcquistoService {
|
||||
mtbLisaData
|
||||
.setDataIniz(dataVariazione)
|
||||
.setPrzAcq(przAcqNew)
|
||||
.setModificatoDa("EMS")
|
||||
.setOperation(OperationType.INSERT);
|
||||
|
||||
listNew.add(mtbLisaData);
|
||||
|
||||
@@ -305,7 +305,7 @@ public class OrtoFruttaProductionService {
|
||||
}
|
||||
|
||||
|
||||
if (!UtilityBigDecimal.isNullOrZero(dto.getQtaCol())) {
|
||||
// if (!UtilityBigDecimal.isNullOrZero(dto.getQtaCol())) {
|
||||
List<MtbColt> lista = new ArrayList<>();
|
||||
lista.add(collo);
|
||||
LoadColliDTO loadColliDTO = new LoadColliDTO();
|
||||
@@ -320,7 +320,7 @@ public class OrtoFruttaProductionService {
|
||||
docLav = loadColliService.createDocFromColli(multiDBTransactionManager, loadColliDTO);
|
||||
entityProcessor.processEntity(docLav,true, multiDBTransactionManager);
|
||||
UtilityEntity.throwEntityException(docLav);
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
//alla creazione della bolla (DDT) creare documento di acquisto e scarico di materiale alla pianta
|
||||
|
||||
@@ -425,7 +425,7 @@ public class ProductionOrderDataHandlerService {
|
||||
" dtb_ord_steps.flag_step_attivo = 'S' " +
|
||||
whereCondFlagEvaso +
|
||||
whereCondCodJfas +
|
||||
" AND " + whereCond +
|
||||
" AND " + (UtilityString.isNullOrEmpty(whereCond) ? "1 = 1" : whereCond) + "\n" +
|
||||
" AND max_step_by_num_fase = max_step" +
|
||||
" GROUP BY dtb_ordr.data_ord, " +
|
||||
" dtb_ordr.num_ord, " +
|
||||
|
||||
@@ -16,6 +16,8 @@ import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
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.stereotype.Service;
|
||||
@@ -38,6 +40,7 @@ import java.util.stream.Stream;
|
||||
@Service
|
||||
@Scope(value = "request")
|
||||
public class SystemMigrationService {
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
@@ -280,6 +283,8 @@ public class SystemMigrationService {
|
||||
final String migrationsJavaPath = baseProjectPath + "java\\it\\integry\\ems\\migration\\model\\";
|
||||
final String migrationsJavaFile = migrationsJavaPath + migrationClassName + ".java";
|
||||
writeContentToFile(migrationsJavaFile, classBuilder.toString(), true);
|
||||
|
||||
logger.info(String.format("Created migration file: %s", migrationClassName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user