Merge remote-tracking branch 'origin/develop' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -16,16 +16,13 @@ import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.types.TypeDbObject;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
import it.integry.ems_model.utility.dto.PaginatedDTO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
import java.sql.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
@@ -449,7 +446,8 @@ public class UtilityDB {
|
||||
|
||||
@NotNull
|
||||
public static List<HashMap<String, Object>> executeSimpleQuery(Connection conn, String querySql) throws SQLException {
|
||||
try (PreparedStatement ps = conn.prepareStatement(querySql); ResultSet rs = ps.executeQuery()) {
|
||||
try (PreparedStatement ps = conn.prepareStatement(querySql);
|
||||
ResultSet rs = ps.executeQuery()) {
|
||||
|
||||
return ResultSetMapper.mapResultSetToHashMap(rs);
|
||||
}
|
||||
@@ -506,6 +504,26 @@ public class UtilityDB {
|
||||
return executeSimpleQueryDTO(conn, querySql, clazz, null);
|
||||
}
|
||||
|
||||
public static <T> PaginatedDTO<T> executePaginatedQueryDTO(Connection conn, String querySql, Class<T> clazz, int page, int pageSize) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||
final String paginatedQuery = UtilityQuery.generatePaginatedSelect(querySql, page, pageSize);
|
||||
|
||||
final List<HashMap<String, Object>> result = executeSimpleQuery(conn, paginatedQuery);
|
||||
|
||||
int totalCount = 0;
|
||||
if (!result.isEmpty()) {
|
||||
totalCount = UtilityHashMap.getValueIfExists(result.get(0), "rows_count");
|
||||
}
|
||||
|
||||
final List<T> resultList = UtilityHashMap.mapListToObjects(result, clazz);
|
||||
|
||||
|
||||
PaginatedDTO<T> paginatedDTO = new PaginatedDTO<>();
|
||||
paginatedDTO.setData(resultList)
|
||||
.setTotalCount(totalCount);
|
||||
|
||||
return paginatedDTO;
|
||||
}
|
||||
|
||||
public static <T> void executeSimpleQueryDTOAsync(Connection conn, String querySql, Class<T> clazz, RunnableArgs<T> onElementRetrieved) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||
try (SQLServerStatement ps = (SQLServerStatement) conn.createStatement()) {
|
||||
ps.setResponseBuffering("adaptive");
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
package it.integry.ems_model.utility;
|
||||
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.utility.dto.FilterDTO;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class UtilityFilter {
|
||||
|
||||
public static <T>void convertFilterDtoFieldsToSqlFields(FilterDTO filterDTO, Class<T> clazz) {
|
||||
List<Field> fields = new ArrayList<>();
|
||||
UtilityReflection.getAllFields(fields, clazz);
|
||||
|
||||
fields = fields.stream()
|
||||
.filter(x -> x.getAnnotation(SqlField.class) != null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
internalConvertFilterDtoFieldToSqlField(filterDTO, fields);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void internalConvertFilterDtoFieldToSqlField(FilterDTO filter, List<Field> fields) {
|
||||
for (FilterDTO childFilter : filter.getFilters()) {
|
||||
if(childFilter.getField() == null) {
|
||||
internalConvertFilterDtoFieldToSqlField(childFilter, fields);
|
||||
return;
|
||||
}
|
||||
|
||||
final Field javaField = fields.stream()
|
||||
.filter(x -> x.getName().equalsIgnoreCase(childFilter.getField()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
childFilter.setField(javaField.getAnnotation(SqlField.class).value());
|
||||
}
|
||||
}
|
||||
|
||||
public static String processFilters(FilterDTO filter) {
|
||||
FilterDTO[] filters = filter.getFilters();
|
||||
String logic = filter.getLogic();
|
||||
|
||||
String sql = Arrays.stream(filters)
|
||||
.map(subFilter -> {
|
||||
String where;
|
||||
|
||||
|
||||
if (subFilter.getFilters() != null && subFilter.getFilters().length > 0) {
|
||||
where = processFilters(subFilter);
|
||||
return where;
|
||||
}
|
||||
|
||||
String value = (String) subFilter.getValue();
|
||||
|
||||
try {
|
||||
if (value.matches("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.*")) {
|
||||
LocalDateTime date = LocalDateTime.parse(value, DateTimeFormatter.ISO_DATE_TIME);
|
||||
value = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
} else if (value.matches("\\d{4}-\\d{2}-\\d{2}")) {
|
||||
LocalDateTime date = LocalDateTime.parse(value + "T00:00:00");
|
||||
value = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
String operator = subFilter.getOperator();
|
||||
switch (operator) {
|
||||
case "eq":
|
||||
where = "{field} = {value}";
|
||||
break;
|
||||
case "neq":
|
||||
where = "{field} <> {value}";
|
||||
break;
|
||||
case "isnull":
|
||||
where = "{field} is null";
|
||||
break;
|
||||
case "isnotnull":
|
||||
where = "{field} is not null";
|
||||
break;
|
||||
case "gte":
|
||||
where = "{field} >= {value}";
|
||||
break;
|
||||
case "gt":
|
||||
where = "{field} > {value}";
|
||||
break;
|
||||
case "lt":
|
||||
where = "{field} < {value}";
|
||||
break;
|
||||
case "lte":
|
||||
where = "{field} <= {value}";
|
||||
break;
|
||||
case "isempty":
|
||||
where = "{field} = ''";
|
||||
break;
|
||||
case "isnotempty":
|
||||
where = "{field} <> ''";
|
||||
break;
|
||||
case "startswith":
|
||||
where = "{field} like {value}";
|
||||
value += "%";
|
||||
break;
|
||||
case "contains":
|
||||
where = "{field} like {value}";
|
||||
value = "%" + value + "%";
|
||||
break;
|
||||
case "doesnotcontain":
|
||||
where = "{field} not like {value}";
|
||||
value = "%" + value + "%";
|
||||
break;
|
||||
case "endswith":
|
||||
where = "{field} like {value}";
|
||||
value = "%" + value;
|
||||
break;
|
||||
case "isnullorempty":
|
||||
where = "{field} is null or {field} = ''";
|
||||
break;
|
||||
case "isnotnullorempty":
|
||||
where = "{field} is not null and {field} <> ''";
|
||||
break;
|
||||
case "inday":
|
||||
where = "{field} >= {value} + ' 00:00' and {field} <= {value} + ' 23:59'";
|
||||
break;
|
||||
default:
|
||||
where = "1 = 1";
|
||||
}
|
||||
|
||||
|
||||
value = value.replace("'", "''");
|
||||
|
||||
return where.replace("{field}", subFilter.getField())
|
||||
.replace("{value}", UtilityDB.valueToString(value));
|
||||
})
|
||||
.collect(Collectors.joining(" " + logic + " "));
|
||||
|
||||
return "(" + sql + ")";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,16 @@
|
||||
package it.integry.ems_model.utility;
|
||||
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class UtilityHashMap {
|
||||
|
||||
public static boolean isPresent(HashMap<?, ?> map) {
|
||||
return map != null && !map.isEmpty();
|
||||
}
|
||||
@@ -26,4 +32,64 @@ public class UtilityHashMap {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public static <T> List<T> mapListToObjects(List<HashMap<String, Object>> dataList, Class<T> clazz) {
|
||||
List<T> result = new ArrayList<>();
|
||||
try {
|
||||
for (HashMap<String, Object> dataMap : dataList) {
|
||||
// Crea una nuova istanza della classe
|
||||
T instance = clazz.getDeclaredConstructor().newInstance();
|
||||
|
||||
// Ottieni tutti i campi della classe
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
|
||||
for (Field field : fields) {
|
||||
// Rendi accessibile il campo
|
||||
field.setAccessible(true);
|
||||
|
||||
SqlField sqlField = field.getAnnotation(SqlField.class);
|
||||
// Mappa il valore della HashMap al campo se esiste
|
||||
|
||||
if((sqlField != null && dataMap.containsKey(sqlField.value())) || dataMap.containsKey(field.getName())) {
|
||||
String fieldName = sqlField != null ? sqlField.value() : field.getName();
|
||||
|
||||
Object value = dataMap.get(fieldName);
|
||||
|
||||
// Controlla il tipo e assegna il valore
|
||||
if (value != null && field.getType().isAssignableFrom(value.getClass())) {
|
||||
field.set(instance, value);
|
||||
} else if (value != null) {
|
||||
// Prova una conversione automatica per tipi compatibili
|
||||
field.set(instance, convertValue(value, field.getType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Aggiungi l'istanza alla lista risultante
|
||||
result.add(instance);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Errore durante la mappatura dei dati alla classe " + clazz.getName(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Metodo ausiliario per conversioni di tipi
|
||||
private static Object convertValue(Object value, Class<?> targetType) {
|
||||
if (targetType == int.class || targetType == Integer.class) {
|
||||
return Integer.parseInt(value.toString());
|
||||
} else if (targetType == long.class || targetType == Long.class) {
|
||||
return Long.parseLong(value.toString());
|
||||
} else if (targetType == double.class || targetType == Double.class) {
|
||||
return Double.parseDouble(value.toString());
|
||||
} else if (targetType == float.class || targetType == Float.class) {
|
||||
return Float.parseFloat(value.toString());
|
||||
} else if (targetType == boolean.class || targetType == Boolean.class) {
|
||||
return Boolean.parseBoolean(value.toString());
|
||||
} else if (targetType == String.class) {
|
||||
return value.toString();
|
||||
}
|
||||
return null; // Aggiungi altre conversioni se necessario
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package it.integry.ems_model.utility;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -9,9 +10,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.time.LocalDate;
|
||||
@@ -23,6 +21,22 @@ import java.util.List;
|
||||
|
||||
public class UtilityQuery {
|
||||
|
||||
public static String generatePaginatedSelect(String query, int pageNumber, int pageSize) {
|
||||
String sql = "WITH TempResult AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS row_number, " +
|
||||
" * " +
|
||||
" FROM ( " + query + " ) t), " +
|
||||
" TempCount AS (SELECT COUNT(*) AS rows_count " +
|
||||
" FROM TempResult) " +
|
||||
"SELECT TempResult.*, " +
|
||||
" TempCount.* " +
|
||||
"FROM TempResult, " +
|
||||
" TempCount " +
|
||||
"ORDER BY row_number " +
|
||||
"OFFSET (" + pageNumber + " - 1) * " + pageSize + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
|
||||
|
||||
return sql;
|
||||
}
|
||||
|
||||
public static String concatFieldListInWhereCond(List<HashMap<String, Object>> inputData) {
|
||||
StringBuilder sbWhereCond = new StringBuilder();
|
||||
|
||||
@@ -139,9 +153,9 @@ public class UtilityQuery {
|
||||
|
||||
|
||||
if (k < inputData.size() - 1) {
|
||||
sbQuery.append("\n");
|
||||
sbQuery.append(" ");
|
||||
sbQuery.append("UNION");
|
||||
sbQuery.append("\n");
|
||||
sbQuery.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,9 +186,9 @@ public class UtilityQuery {
|
||||
|
||||
|
||||
if (k < inputData.size() - 1) {
|
||||
sbQuery.append("\n");
|
||||
sbQuery.append(" ");
|
||||
sbQuery.append("UNION");
|
||||
sbQuery.append("\n");
|
||||
sbQuery.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,9 +213,9 @@ public class UtilityQuery {
|
||||
values.add(value.toString());
|
||||
}
|
||||
|
||||
return "SELECT DISTINCT *\n" +
|
||||
"FROM (\n" +
|
||||
" VALUES " + StringUtils.join(values, ",") + "\n" +
|
||||
return "SELECT DISTINCT * " +
|
||||
"FROM ( " +
|
||||
" VALUES " + StringUtils.join(values, ",") + " " +
|
||||
") AS " + tableName + "(" + StringUtils.join(columns, ",") + ")";
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package it.integry.ems_model.utility.dto;
|
||||
|
||||
public class FilterDTO {
|
||||
private String field;
|
||||
private FilterDTO[] filters;
|
||||
private String logic;
|
||||
private String operator;
|
||||
private Object value;
|
||||
|
||||
public String getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public FilterDTO setField(String field) {
|
||||
this.field = field;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterDTO[] getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
public FilterDTO setFilters(FilterDTO[] filters) {
|
||||
this.filters = filters;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getLogic() {
|
||||
return logic;
|
||||
}
|
||||
|
||||
public FilterDTO setLogic(String logic) {
|
||||
this.logic = logic;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public FilterDTO setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public FilterDTO setValue(Object value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package it.integry.ems_model.utility.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PaginatedDTO<T> {
|
||||
|
||||
private List<T> data;
|
||||
private int totalCount;
|
||||
|
||||
public List<T> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public PaginatedDTO<T> setData(List<T> data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public PaginatedDTO<T> setTotalCount(int totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,7 @@
|
||||
<classPatterns>
|
||||
<classPattern>it.integry.ems.product.dto.*</classPattern>
|
||||
<classPattern>it.integry.ems.production.dto.*</classPattern>
|
||||
<classPattern>it.integry.ems.retail.wms.generic.dto.articolo.*</classPattern>
|
||||
</classPatterns>
|
||||
<excludeClasses>
|
||||
<excludeClass>it.integry.ems_model.base.EntityInterface</excludeClass>
|
||||
|
||||
@@ -53,6 +53,6 @@ public class GiacenzaController {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestParam String codMdep) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(giacenzaService.retrieveGiacenza(codMdep));
|
||||
return ServiceRestResponse.createPositiveResponse(giacenzaService.retrieveGiacenza(codMdep, true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,7 +552,7 @@ public class PvmServiceSave {
|
||||
|
||||
List<GiacenzaDTO> giacenzaPv = new ArrayList<>();
|
||||
if (saveGiacenza) {
|
||||
giacenzaPv = giacenzaService.retrieveGiacenza(codMdep);
|
||||
giacenzaPv = giacenzaService.retrieveGiacenza(codMdep, false);
|
||||
}
|
||||
|
||||
MtbColt collo = new MtbColt();
|
||||
|
||||
@@ -513,7 +513,7 @@ public class GiacenzaService {
|
||||
}
|
||||
}
|
||||
|
||||
public List<GiacenzaDTO> retrieveGiacenza(String codMdep) throws Exception {
|
||||
public List<GiacenzaDTO> retrieveGiacenza(String codMdep, boolean readOrdini) throws Exception {
|
||||
|
||||
String sql = Query.format(
|
||||
"SELECT cod_mdep FROM stb_gest_setup_depo WHERE gest_name = %s AND section = %s AND key_section = %S AND value = %S",
|
||||
@@ -677,117 +677,120 @@ public class GiacenzaService {
|
||||
String listiniAcquisto = setupGest.getSetup("DATI_AZIENDA", "GIACENZA_DA_INV", "LISTINI_ACQUISTO");
|
||||
List<String> listini = Arrays.asList(listiniAcquisto.split("\\|"));
|
||||
|
||||
sql = "WITH incoming_stock_documenti AS (\n" +
|
||||
"/*\n" +
|
||||
"Estrazione dei documenti (bolle web) di merce consegnata\n" +
|
||||
"*/\n" +
|
||||
"\n" +
|
||||
" SELECT wdtb_doct.cod_mdep,\n" +
|
||||
" wdtb_docr.cod_mart,\n" +
|
||||
" wdtb_docr.data_ord,\n" +
|
||||
" wdtb_docr.num_ord,\n" +
|
||||
" riga_ord,\n" +
|
||||
" wdtb_doct.cod_anag,\n" +
|
||||
" wdtb_docr.qta_doc * wdtb_docr.rap_conv AS qta_doc,\n" +
|
||||
" wdtb_doct.flag_elaborato\n" +
|
||||
" FROM wdtb_doct\n" +
|
||||
" INNER JOIN wdtb_docr\n" +
|
||||
" ON wdtb_doct.cod_anag = wdtb_docr.cod_anag AND wdtb_doct.cod_dtip = wdtb_docr.cod_dtip AND\n" +
|
||||
" wdtb_doct.data_doc = wdtb_docr.data_doc AND wdtb_doct.ser_doc = wdtb_docr.ser_doc AND\n" +
|
||||
" wdtb_doct.num_doc = wdtb_docr.num_doc\n" +
|
||||
" WHERE wdtb_doct.data_ins >= dateadd(DAY, - 21, CAST(getdate() AS DATE))\n" +
|
||||
" AND wdtb_doct.cod_mdep = " + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" , incoming_stock_ordini AS (\n" +
|
||||
"/*\n" +
|
||||
"Estrazione degli ordini d'acquisto in consegna\n" +
|
||||
"*/\n" +
|
||||
" SELECT r.cod_mdep,\n" +
|
||||
" r.cod_mart,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN r.data_cons = r.data_ord\n" +
|
||||
" THEN CAST(getdate() AS DATE)\n" +
|
||||
" ELSE r.data_cons\n" +
|
||||
" END AS data_cons,\n" +
|
||||
" r.qta_ord,\n" +
|
||||
" r.data_ord,\n" +
|
||||
" r.riga_ord,\n" +
|
||||
" r.num_ord,\n" +
|
||||
" cod_anag\n" +
|
||||
" FROM dtb_ordt t\n" +
|
||||
" INNER JOIN dtb_ordr r\n" +
|
||||
" ON t.gestione = r.gestione\n" +
|
||||
" AND t.data_ord = r.data_ord\n" +
|
||||
" AND t.num_ord = r.num_ord\n" +
|
||||
" WHERE\n" +
|
||||
" -- ordini acquisto\n" +
|
||||
" t.gestione = 'A'\n" +
|
||||
" -- ordini non annullati\n" +
|
||||
" AND t.flag_annulla = 'N'\n" +
|
||||
" -- ordii non sospesi\n" +
|
||||
" AND t.flag_sospeso = 'N'\n" +
|
||||
" AND (\n" +
|
||||
" -- ordini futuri\n" +
|
||||
" (r.data_cons >= CAST(getdate() AS DATE))\n" +
|
||||
" OR\n" +
|
||||
" -- ordini fuori piano logistico (r.data_cons = r.data_ord), inevasi e fatti negli ultimi 3 giorni\n" +
|
||||
" (\n" +
|
||||
" r.data_cons = r.data_ord\n" +
|
||||
" AND flag_evaso = 'I'\n" +
|
||||
" AND r.data_ord >= dateadd(DAY, - 3, CAST(getdate() AS DATE))\n" +
|
||||
" )\n" +
|
||||
" )\n" +
|
||||
" -- prendiamo i soli ordini del SECCO, sarà da modificare quando inizieranno ad ordinare anche altri (es. APULD)\n" +
|
||||
" AND t.listino IN (" + UtilityDB.listValueToString(listini) + ")\n" +
|
||||
" -- ordine non ancora evaso\n" +
|
||||
" AND flag_evaso <> 'E'\n" +
|
||||
" -- filtro solamente un Pdv\n" +
|
||||
" AND r.cod_mdep = " + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" , incoming_stock_doc_consegnati AS (\n" +
|
||||
"/*\n" +
|
||||
"Estrazione dei documenti consegnati\n" +
|
||||
"*/\n" +
|
||||
" SELECT DISTINCT wdtb_docr.num_ord, wdtb_docr.data_ord, wdtb_doct.cod_anag\n" +
|
||||
" FROM wdtb_doct\n" +
|
||||
" INNER JOIN wdtb_docr\n" +
|
||||
" ON wdtb_doct.cod_anag = wdtb_docr.cod_anag AND wdtb_doct.cod_dtip = wdtb_docr.cod_dtip AND\n" +
|
||||
" wdtb_doct.data_doc = wdtb_docr.data_doc AND wdtb_doct.ser_doc = wdtb_docr.ser_doc AND\n" +
|
||||
" wdtb_doct.num_doc = wdtb_docr.num_doc\n" +
|
||||
" WHERE wdtb_doct.data_ins >= dateadd(DAY, - 7, CAST(getdate() AS DATE))\n" +
|
||||
" AND wdtb_doct.flag_elaborato = 'N')\n" +
|
||||
"\n" +
|
||||
"-- Step 4) Unione delle estrazioni precedenti [MySQL]\n" +
|
||||
"\n" +
|
||||
"SELECT ISNULL(d.cod_mdep, o.cod_mdep) AS store_code,\n" +
|
||||
" ISNULL(d.cod_mart, o.cod_mart) AS art_code,\n" +
|
||||
" data_cons,\n" +
|
||||
" SUM(ISNULL(qta_doc, qta_ord)) AS incoming_stock\n" +
|
||||
"FROM incoming_stock_ordini o\n" +
|
||||
" FULL OUTER JOIN incoming_stock_documenti d\n" +
|
||||
" ON o.cod_mdep = d.cod_mdep AND o.cod_mart = d.cod_mart AND o.data_ord = d.data_ord AND\n" +
|
||||
" o.num_ord = d.num_ord AND o.cod_anag = d.cod_anag AND o.riga_ord = d.riga_ord\n" +
|
||||
" LEFT JOIN incoming_stock_doc_consegnati k\n" +
|
||||
" ON o.num_ord = k.num_ord AND o.cod_anag = k.cod_anag AND o.data_ord = k.data_ord\n" +
|
||||
"WHERE (flag_elaborato = 'I' OR flag_elaborato IS NULL)\n" +
|
||||
" AND ((d.cod_mart IS NOT NULL) OR (d.cod_mart IS NULL AND k.num_ord IS NULL))\n" +
|
||||
"GROUP BY ISNULL(d.cod_mdep, o.cod_mdep), ISNULL(d.cod_mart, o.cod_mart), data_cons, k.num_ord\n";
|
||||
if (readOrdini ) {
|
||||
|
||||
List<HashMap<String, Object>> merceInArrivo = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
sql = "WITH incoming_stock_documenti AS (\n" +
|
||||
"/*\n" +
|
||||
"Estrazione dei documenti (bolle web) di merce consegnata\n" +
|
||||
"*/\n" +
|
||||
"\n" +
|
||||
" SELECT wdtb_doct.cod_mdep,\n" +
|
||||
" wdtb_docr.cod_mart,\n" +
|
||||
" wdtb_docr.data_ord,\n" +
|
||||
" wdtb_docr.num_ord,\n" +
|
||||
" riga_ord,\n" +
|
||||
" wdtb_doct.cod_anag,\n" +
|
||||
" wdtb_docr.qta_doc * wdtb_docr.rap_conv AS qta_doc,\n" +
|
||||
" wdtb_doct.flag_elaborato\n" +
|
||||
" FROM wdtb_doct\n" +
|
||||
" INNER JOIN wdtb_docr\n" +
|
||||
" ON wdtb_doct.cod_anag = wdtb_docr.cod_anag AND wdtb_doct.cod_dtip = wdtb_docr.cod_dtip AND\n" +
|
||||
" wdtb_doct.data_doc = wdtb_docr.data_doc AND wdtb_doct.ser_doc = wdtb_docr.ser_doc AND\n" +
|
||||
" wdtb_doct.num_doc = wdtb_docr.num_doc\n" +
|
||||
" WHERE wdtb_doct.data_ins >= dateadd(DAY, - 21, CAST(getdate() AS DATE))\n" +
|
||||
" AND wdtb_doct.cod_mdep = " + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" , incoming_stock_ordini AS (\n" +
|
||||
"/*\n" +
|
||||
"Estrazione degli ordini d'acquisto in consegna\n" +
|
||||
"*/\n" +
|
||||
" SELECT r.cod_mdep,\n" +
|
||||
" r.cod_mart,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN r.data_cons = r.data_ord\n" +
|
||||
" THEN CAST(getdate() AS DATE)\n" +
|
||||
" ELSE r.data_cons\n" +
|
||||
" END AS data_cons,\n" +
|
||||
" r.qta_ord,\n" +
|
||||
" r.data_ord,\n" +
|
||||
" r.riga_ord,\n" +
|
||||
" r.num_ord,\n" +
|
||||
" cod_anag\n" +
|
||||
" FROM dtb_ordt t\n" +
|
||||
" INNER JOIN dtb_ordr r\n" +
|
||||
" ON t.gestione = r.gestione\n" +
|
||||
" AND t.data_ord = r.data_ord\n" +
|
||||
" AND t.num_ord = r.num_ord\n" +
|
||||
" WHERE\n" +
|
||||
" -- ordini acquisto\n" +
|
||||
" t.gestione = 'A'\n" +
|
||||
" -- ordini non annullati\n" +
|
||||
" AND t.flag_annulla = 'N'\n" +
|
||||
" -- ordii non sospesi\n" +
|
||||
" AND t.flag_sospeso = 'N'\n" +
|
||||
" AND (\n" +
|
||||
" -- ordini futuri\n" +
|
||||
" (r.data_cons >= CAST(getdate() AS DATE))\n" +
|
||||
" OR\n" +
|
||||
" -- ordini fuori piano logistico (r.data_cons = r.data_ord), inevasi e fatti negli ultimi 3 giorni\n" +
|
||||
" (\n" +
|
||||
" r.data_cons = r.data_ord\n" +
|
||||
" AND flag_evaso = 'I'\n" +
|
||||
" AND r.data_ord >= dateadd(DAY, - 3, CAST(getdate() AS DATE))\n" +
|
||||
" )\n" +
|
||||
" )\n" +
|
||||
" -- prendiamo i soli ordini del SECCO, sarà da modificare quando inizieranno ad ordinare anche altri (es. APULD)\n" +
|
||||
" AND t.listino IN (" + UtilityDB.listValueToString(listini) + ")\n" +
|
||||
" -- ordine non ancora evaso\n" +
|
||||
" AND flag_evaso <> 'E'\n" +
|
||||
" -- filtro solamente un Pdv\n" +
|
||||
" AND r.cod_mdep = " + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" , incoming_stock_doc_consegnati AS (\n" +
|
||||
"/*\n" +
|
||||
"Estrazione dei documenti consegnati\n" +
|
||||
"*/\n" +
|
||||
" SELECT DISTINCT wdtb_docr.num_ord, wdtb_docr.data_ord, wdtb_doct.cod_anag\n" +
|
||||
" FROM wdtb_doct\n" +
|
||||
" INNER JOIN wdtb_docr\n" +
|
||||
" ON wdtb_doct.cod_anag = wdtb_docr.cod_anag AND wdtb_doct.cod_dtip = wdtb_docr.cod_dtip AND\n" +
|
||||
" wdtb_doct.data_doc = wdtb_docr.data_doc AND wdtb_doct.ser_doc = wdtb_docr.ser_doc AND\n" +
|
||||
" wdtb_doct.num_doc = wdtb_docr.num_doc\n" +
|
||||
" WHERE wdtb_doct.data_ins >= dateadd(DAY, - 7, CAST(getdate() AS DATE))\n" +
|
||||
" AND wdtb_doct.flag_elaborato = 'N')\n" +
|
||||
"\n" +
|
||||
"-- Step 4) Unione delle estrazioni precedenti [MySQL]\n" +
|
||||
"\n" +
|
||||
"SELECT ISNULL(d.cod_mdep, o.cod_mdep) AS store_code,\n" +
|
||||
" ISNULL(d.cod_mart, o.cod_mart) AS art_code,\n" +
|
||||
" data_cons,\n" +
|
||||
" SUM(ISNULL(qta_doc, qta_ord)) AS incoming_stock\n" +
|
||||
"FROM incoming_stock_ordini o\n" +
|
||||
" FULL OUTER JOIN incoming_stock_documenti d\n" +
|
||||
" ON o.cod_mdep = d.cod_mdep AND o.cod_mart = d.cod_mart AND o.data_ord = d.data_ord AND\n" +
|
||||
" o.num_ord = d.num_ord AND o.cod_anag = d.cod_anag AND o.riga_ord = d.riga_ord\n" +
|
||||
" LEFT JOIN incoming_stock_doc_consegnati k\n" +
|
||||
" ON o.num_ord = k.num_ord AND o.cod_anag = k.cod_anag AND o.data_ord = k.data_ord\n" +
|
||||
"WHERE (flag_elaborato = 'I' OR flag_elaborato IS NULL)\n" +
|
||||
" AND ((d.cod_mart IS NOT NULL) OR (d.cod_mart IS NULL AND k.num_ord IS NULL))\n" +
|
||||
"GROUP BY ISNULL(d.cod_mdep, o.cod_mdep), ISNULL(d.cod_mart, o.cod_mart), data_cons, k.num_ord\n";
|
||||
|
||||
if (listGiacenza != null) {
|
||||
List<HashMap<String, Object>> merceInArrivo = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
merceInArrivo
|
||||
.forEach(merce -> {
|
||||
String storeCode = (String) merce.get("store_code");
|
||||
String artCode = (String) merce.get("art_code");
|
||||
BigDecimal incomingStock = (BigDecimal) merce.get("incoming_stock");
|
||||
if (listGiacenza != null) {
|
||||
|
||||
listGiacenza.stream()
|
||||
.filter(x -> x.getCodMart().equals(artCode) && x.getCodMdep().equals(storeCode))
|
||||
.findFirst()
|
||||
.ifPresent(x -> {
|
||||
x.setIncomingStock(incomingStock);
|
||||
});
|
||||
});
|
||||
merceInArrivo
|
||||
.forEach(merce -> {
|
||||
String storeCode = (String) merce.get("store_code");
|
||||
String artCode = (String) merce.get("art_code");
|
||||
BigDecimal incomingStock = (BigDecimal) merce.get("incoming_stock");
|
||||
|
||||
listGiacenza.stream()
|
||||
.filter(x -> x.getCodMart().equals(artCode) && x.getCodMdep().equals(storeCode))
|
||||
.findFirst()
|
||||
.ifPresent(x -> {
|
||||
x.setIncomingStock(incomingStock);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return listGiacenza;
|
||||
|
||||
@@ -4,6 +4,10 @@ import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.product.importaz.service.ProductServices;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.retail.wms.generic.dto.*;
|
||||
import it.integry.ems.retail.wms.generic.dto.articolo.RetrieveArticoloRequestDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.articolo.RetrieveArticoloResponseDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.articolo.SaveArticoloRequestDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.articolo.SaveArticoloResponseDTO;
|
||||
import it.integry.ems.retail.wms.generic.service.WMSArticoloService;
|
||||
import it.integry.ems.user.UserSession;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -84,13 +88,25 @@ public class WMSArticoloController {
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "", method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse retrieve(@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestBody RetrieveArticoloRequestDTO retrieveArticoloRequest) throws Exception {
|
||||
|
||||
final RetrieveArticoloResponseDTO response = wmsArticoloService.retrieveArts(retrieveArticoloRequest.getFilter(), retrieveArticoloRequest.getPage(), retrieveArticoloRequest.getPageSize());
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(response);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "saveArticolo", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse saveArticolo(@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestBody SaveArticoloDTO saveArticoloDTO) throws Exception {
|
||||
@RequestBody SaveArticoloRequestDTO saveArticoloRequestDTO) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(wmsArticoloService.saveArticolo(saveArticoloDTO));
|
||||
SaveArticoloResponseDTO response = new SaveArticoloResponseDTO()
|
||||
.setCodMart(wmsArticoloService.saveArticolo(saveArticoloRequestDTO.getArtToSave()));
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package it.integry.ems.retail.wms.generic.dto.Ordine;
|
||||
package it.integry.ems.retail.wms.generic.dto.ordine;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import it.integry.ems.adapter.JsonDateAdapterSerializer;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package it.integry.ems.retail.wms.generic.dto.Ordine;
|
||||
package it.integry.ems.retail.wms.generic.dto.ordine;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import it.integry.ems.adapter.JsonDateAdapterSerializer;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package it.integry.ems.retail.wms.generic.dto.Ordine;
|
||||
package it.integry.ems.retail.wms.generic.dto.ordine;
|
||||
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package it.integry.ems.retail.wms.generic.dto.Ordine;
|
||||
package it.integry.ems.retail.wms.generic.dto.ordine;
|
||||
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package it.integry.ems.retail.wms.generic.dto.Ordine;
|
||||
package it.integry.ems.retail.wms.generic.dto.ordine;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
@@ -1,42 +1,295 @@
|
||||
package it.integry.ems.retail.wms.generic.dto;
|
||||
package it.integry.ems.retail.wms.generic.dto.articolo;
|
||||
|
||||
import it.integry.ems_model.annotation.MapToTable;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.entity.MtbAart;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
public class SaveArticoloDTO {
|
||||
public class ArticoloDTO {
|
||||
|
||||
@SqlField("mtb_aart.cod_mart")
|
||||
private String codMart;
|
||||
|
||||
@SqlField("mtb_aart.descrizione")
|
||||
private String descrizione;
|
||||
|
||||
@SqlField("mtb_aart.unt_mis")
|
||||
private String untMis;
|
||||
private String barCode;
|
||||
|
||||
@SqlField("barcode")
|
||||
private String barcode;
|
||||
|
||||
@SqlField("mtb_aart.qta_cnf")
|
||||
private BigDecimal qtaCnf;
|
||||
|
||||
@SqlField("mtb_aart.cod_aliq")
|
||||
private String codAliq;
|
||||
private String articoloComposto;
|
||||
private String descrizioneEstesa;
|
||||
private String note;
|
||||
private String posizione;
|
||||
|
||||
@SqlField("mtb_aart.cod_mgrp")
|
||||
private String codMgrp;
|
||||
|
||||
@SqlField("mtb_aart.cod_msfa")
|
||||
private String codMsfa;
|
||||
|
||||
@SqlField("mtb_aart.cod_msgr")
|
||||
private String codMsgr;
|
||||
private String codMstp;
|
||||
private String codMtip;
|
||||
private Boolean flagStato;
|
||||
private String codBarreImb;
|
||||
private boolean flagStato;
|
||||
|
||||
@SqlField("cod_barre_imb")
|
||||
private String barcodeImballo;
|
||||
private String diacod;
|
||||
private Boolean flagQtaCnfFissa;
|
||||
private boolean flagQtaCnfFissa;
|
||||
private String idArtEqui;
|
||||
private Boolean flagKit;
|
||||
private boolean flagKit;
|
||||
private String precode;
|
||||
|
||||
public MtbAart getMtbAart(){
|
||||
@SqlField("mtb_grup.descrizione")
|
||||
private String gruppo;
|
||||
|
||||
@SqlField("mtb_sgrp.descrizione")
|
||||
private String sottoGruppo;
|
||||
|
||||
@SqlField("mtb_sfam.descrizione")
|
||||
private String sottoFamiglia;
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public ArticoloDTO setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescrizione() {
|
||||
return descrizione;
|
||||
}
|
||||
|
||||
public ArticoloDTO setDescrizione(String descrizione) {
|
||||
this.descrizione = descrizione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUntMis() {
|
||||
return untMis;
|
||||
}
|
||||
|
||||
public ArticoloDTO setUntMis(String untMis) {
|
||||
this.untMis = untMis;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBarcode() {
|
||||
return barcode;
|
||||
}
|
||||
|
||||
public ArticoloDTO setBarcode(String barcode) {
|
||||
this.barcode = barcode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaCnf() {
|
||||
return qtaCnf;
|
||||
}
|
||||
|
||||
public ArticoloDTO setQtaCnf(BigDecimal qtaCnf) {
|
||||
this.qtaCnf = qtaCnf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodAliq() {
|
||||
return codAliq;
|
||||
}
|
||||
|
||||
public ArticoloDTO setCodAliq(String codAliq) {
|
||||
this.codAliq = codAliq;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getArticoloComposto() {
|
||||
return articoloComposto;
|
||||
}
|
||||
|
||||
public ArticoloDTO setArticoloComposto(String articoloComposto) {
|
||||
this.articoloComposto = articoloComposto;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescrizioneEstesa() {
|
||||
return descrizioneEstesa;
|
||||
}
|
||||
|
||||
public ArticoloDTO setDescrizioneEstesa(String descrizioneEstesa) {
|
||||
this.descrizioneEstesa = descrizioneEstesa;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public ArticoloDTO setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPosizione() {
|
||||
return posizione;
|
||||
}
|
||||
|
||||
public ArticoloDTO setPosizione(String posizione) {
|
||||
this.posizione = posizione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMgrp() {
|
||||
return codMgrp;
|
||||
}
|
||||
|
||||
public ArticoloDTO setCodMgrp(String codMgrp) {
|
||||
this.codMgrp = codMgrp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMsfa() {
|
||||
return codMsfa;
|
||||
}
|
||||
|
||||
public ArticoloDTO setCodMsfa(String codMsfa) {
|
||||
this.codMsfa = codMsfa;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMsgr() {
|
||||
return codMsgr;
|
||||
}
|
||||
|
||||
public ArticoloDTO setCodMsgr(String codMsgr) {
|
||||
this.codMsgr = codMsgr;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMstp() {
|
||||
return codMstp;
|
||||
}
|
||||
|
||||
public ArticoloDTO setCodMstp(String codMstp) {
|
||||
this.codMstp = codMstp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMtip() {
|
||||
return codMtip;
|
||||
}
|
||||
|
||||
public ArticoloDTO setCodMtip(String codMtip) {
|
||||
this.codMtip = codMtip;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isFlagStato() {
|
||||
return flagStato;
|
||||
}
|
||||
|
||||
public ArticoloDTO setFlagStato(boolean flagStato) {
|
||||
this.flagStato = flagStato;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBarcodeImballo() {
|
||||
return barcodeImballo;
|
||||
}
|
||||
|
||||
public ArticoloDTO setBarcodeImballo(String barcodeImballo) {
|
||||
this.barcodeImballo = barcodeImballo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDiacod() {
|
||||
return diacod;
|
||||
}
|
||||
|
||||
public ArticoloDTO setDiacod(String diacod) {
|
||||
this.diacod = diacod;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isFlagQtaCnfFissa() {
|
||||
return flagQtaCnfFissa;
|
||||
}
|
||||
|
||||
public ArticoloDTO setFlagQtaCnfFissa(boolean flagQtaCnfFissa) {
|
||||
this.flagQtaCnfFissa = flagQtaCnfFissa;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getIdArtEqui() {
|
||||
return idArtEqui;
|
||||
}
|
||||
|
||||
public ArticoloDTO setIdArtEqui(String idArtEqui) {
|
||||
this.idArtEqui = idArtEqui;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isFlagKit() {
|
||||
return flagKit;
|
||||
}
|
||||
|
||||
public ArticoloDTO setFlagKit(boolean flagKit) {
|
||||
this.flagKit = flagKit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPrecode() {
|
||||
return precode;
|
||||
}
|
||||
|
||||
public ArticoloDTO setPrecode(String precode) {
|
||||
this.precode = precode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getGruppo() {
|
||||
return gruppo;
|
||||
}
|
||||
|
||||
public ArticoloDTO setGruppo(String gruppo) {
|
||||
this.gruppo = gruppo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSottoGruppo() {
|
||||
return sottoGruppo;
|
||||
}
|
||||
|
||||
public ArticoloDTO setSottoGruppo(String sottoGruppo) {
|
||||
this.sottoGruppo = sottoGruppo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSottoFamiglia() {
|
||||
return sottoFamiglia;
|
||||
}
|
||||
|
||||
public ArticoloDTO setSottoFamiglia(String sottoFamiglia) {
|
||||
this.sottoFamiglia = sottoFamiglia;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MtbAart toMtbAart(){
|
||||
MtbAart articolo = new MtbAart();
|
||||
articolo
|
||||
.setCodMart(codMart)
|
||||
.setDescrizione(descrizione)
|
||||
.setUntMis(untMis)
|
||||
.setBarCode(barCode)
|
||||
.setBarCode(barcode)
|
||||
.setQtaCnf(qtaCnf)
|
||||
.setCodAliq(codAliq)
|
||||
.setArticoloComposto(articoloComposto)
|
||||
@@ -49,7 +302,7 @@ public class SaveArticoloDTO {
|
||||
.setCodMstp(codMstp)
|
||||
.setCodMtip(codMtip)
|
||||
.setFlagStato(flagStato ? "A" : "I")
|
||||
.setCodBarreImb(codBarreImb)
|
||||
.setCodBarreImb(barcodeImballo)
|
||||
.setDiacod(diacod)
|
||||
.setFlagQtaCnfFissa(flagQtaCnfFissa ? "S" : "N")
|
||||
.setIdArtEqui(idArtEqui)
|
||||
@@ -57,221 +310,4 @@ public class SaveArticoloDTO {
|
||||
|
||||
return articolo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescrizione() {
|
||||
return descrizione;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setDescrizione(String descrizione) {
|
||||
this.descrizione = descrizione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUntMis() {
|
||||
return untMis;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setUntMis(String untMis) {
|
||||
this.untMis = untMis;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBarCode() {
|
||||
return barCode;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setBarCode(String barCode) {
|
||||
this.barCode = barCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaCnf() {
|
||||
return qtaCnf;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setQtaCnf(BigDecimal qtaCnf) {
|
||||
this.qtaCnf = qtaCnf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodAliq() {
|
||||
return codAliq;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setCodAliq(String codAliq) {
|
||||
this.codAliq = codAliq;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getArticoloComposto() {
|
||||
return articoloComposto;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setArticoloComposto(String articoloComposto) {
|
||||
this.articoloComposto = articoloComposto;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescrizioneEstesa() {
|
||||
return descrizioneEstesa;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setDescrizioneEstesa(String descrizioneEstesa) {
|
||||
this.descrizioneEstesa = descrizioneEstesa;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPosizione() {
|
||||
return posizione;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setPosizione(String posizione) {
|
||||
this.posizione = posizione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMgrp() {
|
||||
return codMgrp;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setCodMgrp(String codMgrp) {
|
||||
this.codMgrp = codMgrp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMsfa() {
|
||||
return codMsfa;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setCodMsfa(String codMsfa) {
|
||||
this.codMsfa = codMsfa;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMsgr() {
|
||||
return codMsgr;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setCodMsgr(String codMsgr) {
|
||||
this.codMsgr = codMsgr;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMstp() {
|
||||
return codMstp;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setCodMstp(String codMstp) {
|
||||
this.codMstp = codMstp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMtip() {
|
||||
return codMtip;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setCodMtip(String codMtip) {
|
||||
this.codMtip = codMtip;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getFlagStato() {
|
||||
return flagStato;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setFlagStato(Boolean flagStato) {
|
||||
this.flagStato = flagStato;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setFlagStato(String flagStato) {
|
||||
this.flagStato = flagStato != null && flagStato.equalsIgnoreCase("A");
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodBarreImb() {
|
||||
return codBarreImb;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setCodBarreImb(String codBarreImb) {
|
||||
this.codBarreImb = codBarreImb;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDiacod() {
|
||||
return diacod;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setDiacod(String diacod) {
|
||||
this.diacod = diacod;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getFlagQtaCnfFissa() {
|
||||
return flagQtaCnfFissa;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setFlagQtaCnfFissa(Boolean flagQtaCnfFissa) {
|
||||
this.flagQtaCnfFissa = flagQtaCnfFissa;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setFlagQtaCnfFissa(String flagQtaCnfFissa) {
|
||||
this.flagQtaCnfFissa = flagQtaCnfFissa != null && flagQtaCnfFissa.equalsIgnoreCase("S");
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getIdArtEqui() {
|
||||
return idArtEqui;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setIdArtEqui(String idArtEqui) {
|
||||
this.idArtEqui = idArtEqui;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getFlagKit() {
|
||||
return flagKit;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setFlagKit(Boolean flagKit) {
|
||||
this.flagKit = flagKit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setFlagKit(String flagKit) {
|
||||
this.flagKit = flagKit != null && flagKit.equalsIgnoreCase("S");
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPrecode() {
|
||||
return precode;
|
||||
}
|
||||
|
||||
public SaveArticoloDTO setPrecode(String precode) {
|
||||
this.precode = precode;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package it.integry.ems.retail.wms.generic.dto.articolo;
|
||||
|
||||
public class RequestArticoloFilterDTO {
|
||||
|
||||
private String tipoGruppo;
|
||||
|
||||
|
||||
|
||||
public String getTipoGruppo() {
|
||||
return tipoGruppo;
|
||||
}
|
||||
|
||||
public RequestArticoloFilterDTO setTipoGruppo(String tipoGruppo) {
|
||||
this.tipoGruppo = tipoGruppo;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package it.integry.ems.retail.wms.generic.dto.articolo;
|
||||
|
||||
import it.integry.ems_model.utility.dto.FilterDTO;
|
||||
|
||||
public class RetrieveArticoloRequestDTO {
|
||||
|
||||
private FilterDTO filter;
|
||||
private int page;
|
||||
private int pageSize;
|
||||
|
||||
|
||||
public FilterDTO getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public RetrieveArticoloRequestDTO setFilter(FilterDTO filter) {
|
||||
this.filter = filter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public RetrieveArticoloRequestDTO setPage(int page) {
|
||||
this.page = page;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public RetrieveArticoloRequestDTO setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package it.integry.ems.retail.wms.generic.dto.articolo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RetrieveArticoloResponseDTO {
|
||||
|
||||
private List<ArticoloDTO> data;
|
||||
private long total;
|
||||
|
||||
public List<ArticoloDTO> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public RetrieveArticoloResponseDTO setData(List<ArticoloDTO> data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public RetrieveArticoloResponseDTO setTotal(long total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package it.integry.ems.retail.wms.generic.dto.articolo;
|
||||
|
||||
public class SaveArticoloRequestDTO {
|
||||
|
||||
public ArticoloDTO artToSave;
|
||||
|
||||
public ArticoloDTO getArtToSave() {
|
||||
return artToSave;
|
||||
}
|
||||
|
||||
public SaveArticoloRequestDTO setArtToSave(ArticoloDTO artToSave) {
|
||||
this.artToSave = artToSave;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package it.integry.ems.retail.wms.generic.dto.articolo;
|
||||
|
||||
public class SaveArticoloResponseDTO {
|
||||
|
||||
private String codMart;
|
||||
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public SaveArticoloResponseDTO setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,21 @@ package it.integry.ems.retail.wms.generic.service;
|
||||
|
||||
import it.integry.ems.exception.MissingDataException;
|
||||
import it.integry.ems.product.importaz.service.ProductServices;
|
||||
import it.integry.ems.retail.wms.generic.dto.SaveArticoloDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.SearchArticoloByBarcodeOrCodMartResponseDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.SearchArticoloByCodArtFornOrDescrizioneRequestDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.SearchArticoloByCodArtFornOrDescrizioneResponseDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.articolo.ArticoloDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.articolo.RetrieveArticoloResponseDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.entity.MtbAart;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityFilter;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.ems_model.utility.dto.FilterDTO;
|
||||
import it.integry.ems_model.utility.dto.PaginatedDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -47,11 +51,11 @@ public class WMSArticoloService {
|
||||
}
|
||||
|
||||
public List<SearchArticoloByBarcodeOrCodMartResponseDTO> searchByCodMartOrBarcode(String codMdep, String codMartOrBarcode) throws Exception {
|
||||
String sql = "SELECT DISTINCT mtb_aart.*,\n" +
|
||||
" qta_esistente,\n" +
|
||||
" qta_imp_cli + qta_imp_lav AS qta_impegnata,\n" +
|
||||
" num_esistente AS num_cnf_esistente,\n" +
|
||||
" num_imp_cli + num_imp_lav AS num_cnf_impegnata\n" +
|
||||
String sql = "SELECT DISTINCT mtb_aart.*, " +
|
||||
" qta_esistente, " +
|
||||
" qta_imp_cli + qta_imp_lav AS qta_impegnata, " +
|
||||
" num_esistente AS num_cnf_esistente, " +
|
||||
" num_imp_cli + num_imp_lav AS num_cnf_impegnata " +
|
||||
"FROM mtb_aart" +
|
||||
" LEFT OUTER JOIN mvw_barcode on mtb_aart.cod_mart = mvw_barcode.cod_mart " +
|
||||
" LEFT OUTER JOIN mtb_part mp on mtb_aart.cod_mart = mp.cod_mart " +
|
||||
@@ -93,31 +97,68 @@ public class WMSArticoloService {
|
||||
|
||||
}
|
||||
|
||||
public SaveArticoloDTO saveArticolo(SaveArticoloDTO saveArticoloDTO)throws Exception {
|
||||
if (saveArticoloDTO == null)
|
||||
|
||||
public RetrieveArticoloResponseDTO retrieveArts(FilterDTO filter, int page, int pageSize) throws Exception {
|
||||
|
||||
|
||||
String query = "SELECT mtb_aart.cod_mart AS [mtb_aart.cod_mart], " +
|
||||
" mtb_aart.descrizione AS [mtb_aart.descrizione], " +
|
||||
" mtb_aart.unt_mis AS [mtb_aart.unt_mis], " +
|
||||
" mtb_aart.cod_mgrp AS [mtb_aart.cod_mgrp], " +
|
||||
" mtb_aart.cod_msgr AS [mtb_aart.cod_msgr], " +
|
||||
" mtb_aart.cod_msfa AS [mtb_aart.cod_msfa], " +
|
||||
" mtb_aart.qta_cnf AS [mtb_aart.qta_cnf], " +
|
||||
" mtb_aart.cod_aliq AS [mtb_aart.cod_aliq], " +
|
||||
" bar_code AS [barcode], " +
|
||||
" cod_barre_imb AS [cod_barre_imb], " +
|
||||
" mtb_grup.descrizione AS [mtb_grup.descrizione], " +
|
||||
" mtb_sgrp.descrizione AS [mtb_sgrp.descrizione], " +
|
||||
" mtb_sfam.descrizione AS [mtb_sfam.descrizione] " +
|
||||
"FROM mtb_aart " +
|
||||
" INNER JOIN mtb_grup ON mtb_aart.cod_mgrp = mtb_grup.cod_mgrp " +
|
||||
" LEFT OUTER JOIN mtb_sgrp ON mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp AND mtb_aart.cod_msgr = mtb_sgrp.cod_msgr " +
|
||||
" LEFT OUTER JOIN mtb_sfam ON mtb_aart.cod_mgrp = mtb_sfam.cod_mgrp AND mtb_aart.cod_msgr = mtb_sfam.cod_msgr AND " +
|
||||
" mtb_aart.cod_msfa = mtb_sfam.cod_msfa ";
|
||||
|
||||
if (filter != null && filter.getFilters().length > 0) {
|
||||
UtilityFilter.convertFilterDtoFieldsToSqlFields(filter, ArticoloDTO.class);
|
||||
|
||||
String filterString = UtilityFilter.processFilters(filter);
|
||||
query += " WHERE " + filterString;
|
||||
}
|
||||
|
||||
|
||||
final PaginatedDTO<ArticoloDTO> articoloDTOPaginatedDTO = UtilityDB.executePaginatedQueryDTO(multiDBTransactionManager.getPrimaryConnection(), query, ArticoloDTO.class, page, pageSize);
|
||||
|
||||
return new RetrieveArticoloResponseDTO()
|
||||
.setData(articoloDTOPaginatedDTO.getData())
|
||||
.setTotal(articoloDTOPaginatedDTO.getTotalCount());
|
||||
}
|
||||
|
||||
|
||||
public String saveArticolo(ArticoloDTO articolo) throws Exception {
|
||||
if (articolo == null)
|
||||
throw new MissingDataException("saveArticolo");
|
||||
|
||||
MtbAart articolo = saveArticoloDTO.getMtbAart();
|
||||
articolo.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
if (UtilityString.isNullOrEmpty(articolo.getCodMart())){
|
||||
articolo.setCodMart(suggestCodMart(articolo, saveArticoloDTO.getPrecode()));
|
||||
MtbAart mtbAart = articolo.toMtbAart();
|
||||
mtbAart.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(mtbAart.getCodMart())) {
|
||||
mtbAart.setCodMart(suggestCodMart(mtbAart, articolo.getPrecode()));
|
||||
}
|
||||
entityProcessor.processEntity(articolo,true,multiDBTransactionManager);
|
||||
return saveArticoloDTO;
|
||||
|
||||
entityProcessor.processEntity(mtbAart, true, multiDBTransactionManager);
|
||||
return mtbAart.getCodMart();
|
||||
|
||||
}
|
||||
|
||||
private String suggestCodMartRicambi(String codMgrp, String codMsgr, String codMsfa) throws Exception {
|
||||
String sql = Query.format("select dbo.f_suggestCodeCodMartRicambi(%s,%s,%s) ", codMgrp,codMsgr,codMsfa);
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(),sql);
|
||||
}
|
||||
private String suggestCodMart(MtbAart mtbAart, String precode) throws Exception {
|
||||
|
||||
String sql = Query.format("select dbo.f_suggestCodeCodMart(%s) ", precode);
|
||||
if (mtbAart.getCodMgrp().equalsIgnoreCase("T")){
|
||||
sql = Query.format("select dbo.f_suggestCodeCodMartRicambi(%s,%s,%s) ", mtbAart.getCodMgrp(),mtbAart.getCodMsgr(),mtbAart.getCodMsfa());
|
||||
if (mtbAart.getCodMgrp().equalsIgnoreCase("T")) {
|
||||
sql = Query.format("select dbo.f_suggestCodeCodMartRicambi(%s,%s,%s) ", mtbAart.getCodMgrp(), mtbAart.getCodMsgr(), mtbAart.getCodMsfa());
|
||||
}
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(),sql);
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ import it.integry.ems.retail.pvmRetail.dto.PickingObjectDTO;
|
||||
import it.integry.ems.retail.wms.exceptions.InvalidGestioneLUException;
|
||||
import it.integry.ems.retail.wms.exceptions.InvalidQtaCnfException;
|
||||
import it.integry.ems.retail.wms.generic.dto.*;
|
||||
import it.integry.ems.retail.wms.generic.dto.Ordine.SM2MtbAartDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.Ordine.SM2OrdineBancaleDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.Ordine.SM2OrdineSingoloDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.ordine.SM2MtbAartDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.ordine.SM2OrdineBancaleDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.ordine.SM2OrdineSingoloDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.picking_list.*;
|
||||
import it.integry.ems.rules.completing.PackagesRules;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
|
||||
Reference in New Issue
Block a user