Finish IntegrazioneFoodProcess
This commit is contained in:
@@ -186,7 +186,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jackson-provider</artifactId>
|
||||
<artifactId>resteasy-jackson2-provider</artifactId>
|
||||
<version>${resteasy.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package it.integry.FoodProcess.api;
|
||||
|
||||
import javax.ws.rs.client.ClientRequestContext;
|
||||
import javax.ws.rs.client.ClientRequestFilter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AddApiKeyHeaderRequestFilter implements ClientRequestFilter {
|
||||
private final String apiKey;
|
||||
|
||||
public AddApiKeyHeaderRequestFilter(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filter(ClientRequestContext clientRequestContext) throws IOException {
|
||||
clientRequestContext.getHeaders().add("X-Api-Key", apiKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package it.integry.FoodProcess.api;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import it.integry.FoodProcess.dto.response.ErrorResponse;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.client.ClientRequestContext;
|
||||
import javax.ws.rs.client.ClientResponseContext;
|
||||
import javax.ws.rs.client.ClientResponseFilter;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ErrorMessageResponseFilter implements ClientResponseFilter {
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
|
||||
if (responseContext.getStatus() != Response.Status.OK.getStatusCode()) {
|
||||
if (responseContext.hasEntity()) {
|
||||
ErrorResponse error = objectMapper.readValue(responseContext.getEntityStream(), ErrorResponse.class);
|
||||
String message = error.getErrorMessage();
|
||||
|
||||
Response.Status status = Response.Status.fromStatusCode(responseContext.getStatus());
|
||||
WebApplicationException webAppException;
|
||||
switch (status) {
|
||||
case BAD_REQUEST:
|
||||
webAppException = new BadRequestException(message);
|
||||
break;
|
||||
case UNAUTHORIZED:
|
||||
webAppException = new NotAuthorizedException(message, Response.status(Response.Status.UNAUTHORIZED).build());
|
||||
break;
|
||||
case FORBIDDEN:
|
||||
webAppException = new ForbiddenException(message);
|
||||
break;
|
||||
case NOT_FOUND:
|
||||
webAppException = new NotFoundException(message);
|
||||
break;
|
||||
case METHOD_NOT_ALLOWED:
|
||||
webAppException = new NotAllowedException(message);
|
||||
break;
|
||||
case NOT_ACCEPTABLE:
|
||||
webAppException = new NotAcceptableException(message);
|
||||
break;
|
||||
case UNSUPPORTED_MEDIA_TYPE:
|
||||
webAppException = new NotSupportedException(message);
|
||||
break;
|
||||
case INTERNAL_SERVER_ERROR:
|
||||
webAppException = new InternalServerErrorException(message);
|
||||
break;
|
||||
case SERVICE_UNAVAILABLE:
|
||||
webAppException = new ServiceUnavailableException(message);
|
||||
break;
|
||||
default:
|
||||
webAppException = new WebApplicationException(message);
|
||||
}
|
||||
|
||||
throw webAppException;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package it.integry.FoodProcess.api;
|
||||
|
||||
import it.integry.FoodProcess.dto.*;
|
||||
import it.integry.FoodProcess.dto.response.*;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
|
||||
public interface FoodProcessClient {
|
||||
// Orders
|
||||
|
||||
@GET
|
||||
@Path("/getorderstatuses")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
List<OrderStatusResponse> getOrderStatuses(@QueryParam("order_ids") List<String> orderIds);
|
||||
|
||||
@POST
|
||||
@Path("/importorders")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
ImportOrdersResponse importOrders(ImportOrdersRequest importOrdersRequest);
|
||||
|
||||
// Master data
|
||||
|
||||
@GET
|
||||
@Path("/getarticles")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
List<Article> getArticles();
|
||||
|
||||
@POST
|
||||
@Path("/importarticles")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
ImportArticlesResponse importArticles(ImportArticlesRequest importArticlesRequest);
|
||||
|
||||
@GET
|
||||
@Path("/getbusinesspartners")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
List<BusinessPartner> getBusinessPartners();
|
||||
|
||||
@POST
|
||||
@Path("/importbusinesspartners")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
ImportBusinessPartnersResponse importBusinessPartners(ImportBusinessPartnersRequest importBusinessPartnersRequest);
|
||||
|
||||
@GET
|
||||
@Path("/getpackagingmaterials")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
List<PackagingMaterial> getPackagingMaterials();
|
||||
|
||||
@POST
|
||||
@Path("/importpackagingmaterials")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
ImportPackagingMaterialsResponse importPackagingMaterials(ImportPackagingMaterialsRequest importPackagingMaterialsRequest);
|
||||
|
||||
@GET
|
||||
@Path("/getrawmaterials")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
List<RawMaterial> getRawMaterials();
|
||||
|
||||
@POST
|
||||
@Path("/importrawmaterials")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
ImportRawMaterialsResponse importRawMaterials(ImportRawMaterialsRequest importRawMaterialsRequest);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package it.integry.FoodProcess.api;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@Provider
|
||||
public class JacksonProvider extends ResteasyJackson2Provider {
|
||||
@Override
|
||||
public void writeTo(Object value, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException {
|
||||
ObjectMapper mapper = locateMapper(type, MediaType.APPLICATION_JSON_TYPE);
|
||||
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
super.writeTo(value, type, genericType, annotations, mediaType, httpHeaders, entityStream);
|
||||
}
|
||||
}
|
||||
116
ems-core/src/main/java/it/integry/FoodProcess/dto/Article.java
Normal file
116
ems-core/src/main/java/it/integry/FoodProcess/dto/Article.java
Normal file
@@ -0,0 +1,116 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Article {
|
||||
@SqlField
|
||||
private String id;
|
||||
|
||||
@SqlField
|
||||
private String code;
|
||||
|
||||
@SqlField
|
||||
private String name;
|
||||
|
||||
@JsonProperty("raw_materials")
|
||||
private List<ArticleRawMaterial> rawMaterials;
|
||||
|
||||
@JsonProperty("packaging_material_id")
|
||||
private String packagingMaterialId;
|
||||
|
||||
@JsonProperty("packaging_material_code")
|
||||
private String packagingMaterialCode;
|
||||
|
||||
@JsonProperty("packaging_material_name")
|
||||
private String packagingMaterialName;
|
||||
|
||||
@SqlField
|
||||
private String note;
|
||||
|
||||
@JsonProperty("is_archived")
|
||||
private boolean isArchived;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Article setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public Article setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Article setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<ArticleRawMaterial> getRawMaterials() {
|
||||
return rawMaterials;
|
||||
}
|
||||
|
||||
public Article setRawMaterials(List<ArticleRawMaterial> rawMaterials) {
|
||||
this.rawMaterials = rawMaterials;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPackagingMaterialId() {
|
||||
return packagingMaterialId;
|
||||
}
|
||||
|
||||
public Article setPackagingMaterialId(String packagingMaterialId) {
|
||||
this.packagingMaterialId = packagingMaterialId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPackagingMaterialCode() {
|
||||
return packagingMaterialCode;
|
||||
}
|
||||
|
||||
public Article setPackagingMaterialCode(String packagingMaterialCode) {
|
||||
this.packagingMaterialCode = packagingMaterialCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPackagingMaterialName() {
|
||||
return packagingMaterialName;
|
||||
}
|
||||
|
||||
public Article setPackagingMaterialName(String packagingMaterialName) {
|
||||
this.packagingMaterialName = packagingMaterialName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public Article setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsArchived() {
|
||||
return isArchived;
|
||||
}
|
||||
|
||||
public Article setIsArchived(boolean isArchived) {
|
||||
this.isArchived = isArchived;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ArticleRawMaterial {
|
||||
private String id;
|
||||
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
|
||||
@JsonProperty("weight_kg")
|
||||
private Double weightKg;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ArticleRawMaterial setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public ArticleRawMaterial setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ArticleRawMaterial setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Double getWeightKg() {
|
||||
return weightKg;
|
||||
}
|
||||
|
||||
public ArticleRawMaterial setWeightKg(Double weightKg) {
|
||||
this.weightKg = weightKg;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
public class BusinessPartner {
|
||||
@SqlField
|
||||
private String id;
|
||||
|
||||
@SqlField
|
||||
private String code;
|
||||
|
||||
@SqlField
|
||||
private String name;
|
||||
|
||||
@SqlField
|
||||
@JsonProperty("is_customer")
|
||||
private boolean isCustomer;
|
||||
|
||||
@SqlField
|
||||
@JsonProperty("is_supplier")
|
||||
private boolean isSupplier;
|
||||
|
||||
@SqlField
|
||||
private String note;
|
||||
|
||||
@SqlField
|
||||
@JsonProperty("is_archived")
|
||||
private boolean isArchived;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public BusinessPartner setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public BusinessPartner setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public BusinessPartner setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsCustomer() {
|
||||
return isCustomer;
|
||||
}
|
||||
|
||||
public BusinessPartner setIsCustomer(boolean isCustomer) {
|
||||
this.isCustomer = isCustomer;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsSupplier() {
|
||||
return isSupplier;
|
||||
}
|
||||
|
||||
public BusinessPartner setIsSupplier(boolean isSupplier) {
|
||||
this.isSupplier = isSupplier;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public BusinessPartner setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsArchived() {
|
||||
return isArchived;
|
||||
}
|
||||
|
||||
public BusinessPartner setIsArchived(boolean isArchived) {
|
||||
this.isArchived = isArchived;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImportArticlesRequest {
|
||||
private List<Article> articles;
|
||||
|
||||
public List<Article> getArticles() {
|
||||
return articles;
|
||||
}
|
||||
|
||||
public ImportArticlesRequest setArticles(List<Article> articles) {
|
||||
this.articles = articles;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImportBusinessPartnersRequest {
|
||||
@JsonProperty("business_partners")
|
||||
private List<BusinessPartner> businessPartners;
|
||||
|
||||
public List<BusinessPartner> getBusinessPartners() {
|
||||
return businessPartners;
|
||||
}
|
||||
|
||||
public ImportBusinessPartnersRequest setBusinessPartners(List<BusinessPartner> businessPartners) {
|
||||
this.businessPartners = businessPartners;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImportOrdersRequest {
|
||||
private List<RequestOrder> orders;
|
||||
|
||||
public List<RequestOrder> getOrders() {
|
||||
return orders;
|
||||
}
|
||||
|
||||
public ImportOrdersRequest setOrders(List<RequestOrder> orders) {
|
||||
this.orders = orders;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImportPackagingMaterialsRequest {
|
||||
@JsonProperty("packaging_materials")
|
||||
private List<PackagingMaterial> packagingMaterials;
|
||||
|
||||
public List<PackagingMaterial> getPackagingMaterials() {
|
||||
return packagingMaterials;
|
||||
}
|
||||
|
||||
public ImportPackagingMaterialsRequest setPackagingMaterials(List<PackagingMaterial> packagingMaterials) {
|
||||
this.packagingMaterials = packagingMaterials;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImportRawMaterialsRequest {
|
||||
@JsonProperty("raw_materials")
|
||||
private List<RawMaterial> rawMaterials;
|
||||
|
||||
public List<RawMaterial> getRawMaterials() {
|
||||
return rawMaterials;
|
||||
}
|
||||
|
||||
public ImportRawMaterialsRequest setRawMaterials(List<RawMaterial> rawMaterials) {
|
||||
this.rawMaterials = rawMaterials;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class PackagingMaterial {
|
||||
private String id;
|
||||
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
|
||||
private PackagingMaterialType type;
|
||||
|
||||
@JsonProperty("weight_kg")
|
||||
private Double weightKg;
|
||||
|
||||
@JsonProperty("length_mm")
|
||||
private Double lengthMm;
|
||||
|
||||
@JsonProperty("width_mm")
|
||||
private Double widthMm;
|
||||
|
||||
@JsonProperty("height_mm")
|
||||
private Double heightMm;
|
||||
|
||||
private String note;
|
||||
|
||||
@JsonProperty("is_archived")
|
||||
private boolean isArchived;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public PackagingMaterial setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public PackagingMaterial setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public PackagingMaterial setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PackagingMaterialType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public PackagingMaterial setType(PackagingMaterialType type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Double getWeightKg() {
|
||||
return weightKg;
|
||||
}
|
||||
|
||||
public PackagingMaterial setWeightKg(Double weightKg) {
|
||||
this.weightKg = weightKg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Double getLengthMm() {
|
||||
return lengthMm;
|
||||
}
|
||||
|
||||
public PackagingMaterial setLengthMm(Double lengthMm) {
|
||||
this.lengthMm = lengthMm;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Double getWidthMm() {
|
||||
return widthMm;
|
||||
}
|
||||
|
||||
public PackagingMaterial setWidthMm(Double widthMm) {
|
||||
this.widthMm = widthMm;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Double getHeightMm() {
|
||||
return heightMm;
|
||||
}
|
||||
|
||||
public PackagingMaterial setHeightMm(Double heightMm) {
|
||||
this.heightMm = heightMm;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public PackagingMaterial setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsArchived() {
|
||||
return isArchived;
|
||||
}
|
||||
|
||||
public PackagingMaterial setIsArchived(boolean isArchived) {
|
||||
this.isArchived = isArchived;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
public enum PackagingMaterialType {
|
||||
PUNNET,
|
||||
TRAY,
|
||||
BAG,
|
||||
CARTON,
|
||||
CRATE,
|
||||
PALLET
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RawMaterial {
|
||||
private String id;
|
||||
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
|
||||
private String note;
|
||||
|
||||
@JsonProperty("is_archived")
|
||||
private boolean isArchived;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public RawMaterial setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public RawMaterial setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public RawMaterial setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public RawMaterial setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsArchived() {
|
||||
return isArchived;
|
||||
}
|
||||
|
||||
public RawMaterial setIsArchived(boolean isArchived) {
|
||||
this.isArchived = isArchived;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class RequestOrder {
|
||||
private String id;
|
||||
|
||||
private String type;
|
||||
|
||||
@JsonProperty("article_id")
|
||||
private String articleId;
|
||||
|
||||
@JsonProperty("article_code")
|
||||
private String articleCode;
|
||||
|
||||
@JsonProperty("customer_id")
|
||||
private String customerId;
|
||||
|
||||
@JsonProperty("customer_code")
|
||||
private String customerCode;
|
||||
|
||||
@JsonProperty("secondary_packaging_material_id")
|
||||
private String secondaryPackagingMaterialId;
|
||||
|
||||
@JsonProperty("secondary_packaging_material_code")
|
||||
private String secondaryPackagingMaterialCode;
|
||||
|
||||
@JsonProperty("tertiary_packaging_material_id")
|
||||
private String tertiaryPackagingMaterialId;
|
||||
|
||||
@JsonProperty("tertiary_packaging_material_code")
|
||||
private String tertiaryPackagingMaterialCode;
|
||||
|
||||
@JsonProperty("units_per_secondary_packaging")
|
||||
private int unitsPerSecondaryPackaging;
|
||||
|
||||
@JsonProperty("units_per_pallet_layer")
|
||||
private int unitsPerPalletLayer;
|
||||
|
||||
@JsonProperty("pallet_layer_quantity")
|
||||
private int palletLayerQuantity;
|
||||
|
||||
@JsonProperty("target_quantity")
|
||||
private double targetQuantity;
|
||||
|
||||
@JsonProperty("target_quantity_unit")
|
||||
private TargetQuantityUnit targetQuantityUnit;
|
||||
|
||||
@JsonProperty("scheduled_for")
|
||||
private LocalDateTime scheduledFor;
|
||||
|
||||
@JsonProperty("to_be_completed_until")
|
||||
private LocalDateTime toBeCompletedUntil;
|
||||
|
||||
@JsonProperty("best_before_date")
|
||||
private LocalDate bestBeforeDate;
|
||||
|
||||
@JsonProperty("production_lot")
|
||||
private String productionLot;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public RequestOrder setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public RequestOrder setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getArticleId() {
|
||||
return articleId;
|
||||
}
|
||||
|
||||
public RequestOrder setArticleId(String articleId) {
|
||||
this.articleId = articleId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getArticleCode() {
|
||||
return articleCode;
|
||||
}
|
||||
|
||||
public RequestOrder setArticleCode(String articleCode) {
|
||||
this.articleCode = articleCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public RequestOrder setCustomerId(String customerId) {
|
||||
this.customerId = customerId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCustomerCode() {
|
||||
return customerCode;
|
||||
}
|
||||
|
||||
public RequestOrder setCustomerCode(String customerCode) {
|
||||
this.customerCode = customerCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSecondaryPackagingMaterialId() {
|
||||
return secondaryPackagingMaterialId;
|
||||
}
|
||||
|
||||
public RequestOrder setSecondaryPackagingMaterialId(String secondaryPackagingMaterialId) {
|
||||
this.secondaryPackagingMaterialId = secondaryPackagingMaterialId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSecondaryPackagingMaterialCode() {
|
||||
return secondaryPackagingMaterialCode;
|
||||
}
|
||||
|
||||
public RequestOrder setSecondaryPackagingMaterialCode(String secondaryPackagingMaterialCode) {
|
||||
this.secondaryPackagingMaterialCode = secondaryPackagingMaterialCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTertiaryPackagingMaterialId() {
|
||||
return tertiaryPackagingMaterialId;
|
||||
}
|
||||
|
||||
public RequestOrder setTertiaryPackagingMaterialId(String tertiaryPackagingMaterialId) {
|
||||
this.tertiaryPackagingMaterialId = tertiaryPackagingMaterialId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTertiaryPackagingMaterialCode() {
|
||||
return tertiaryPackagingMaterialCode;
|
||||
}
|
||||
|
||||
public RequestOrder setTertiaryPackagingMaterialCode(String tertiaryPackagingMaterialCode) {
|
||||
this.tertiaryPackagingMaterialCode = tertiaryPackagingMaterialCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getUnitsPerSecondaryPackaging() {
|
||||
return unitsPerSecondaryPackaging;
|
||||
}
|
||||
|
||||
public RequestOrder setUnitsPerSecondaryPackaging(int unitsPerSecondaryPackaging) {
|
||||
this.unitsPerSecondaryPackaging = unitsPerSecondaryPackaging;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getUnitsPerPalletLayer() {
|
||||
return unitsPerPalletLayer;
|
||||
}
|
||||
|
||||
public RequestOrder setUnitsPerPalletLayer(int unitsPerPalletLayer) {
|
||||
this.unitsPerPalletLayer = unitsPerPalletLayer;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getPalletLayerQuantity() {
|
||||
return palletLayerQuantity;
|
||||
}
|
||||
|
||||
public RequestOrder setPalletLayerQuantity(int palletLayerQuantity) {
|
||||
this.palletLayerQuantity = palletLayerQuantity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getTargetQuantity() {
|
||||
return targetQuantity;
|
||||
}
|
||||
|
||||
public RequestOrder setTargetQuantity(double targetQuantity) {
|
||||
this.targetQuantity = targetQuantity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TargetQuantityUnit getTargetQuantityUnit() {
|
||||
return targetQuantityUnit;
|
||||
}
|
||||
|
||||
public RequestOrder setTargetQuantityUnit(TargetQuantityUnit targetQuantityUnit) {
|
||||
this.targetQuantityUnit = targetQuantityUnit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getScheduledFor() {
|
||||
return scheduledFor;
|
||||
}
|
||||
|
||||
public RequestOrder setScheduledFor(LocalDateTime scheduledFor) {
|
||||
this.scheduledFor = scheduledFor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getToBeCompletedUntil() {
|
||||
return toBeCompletedUntil;
|
||||
}
|
||||
|
||||
public RequestOrder setToBeCompletedUntil(LocalDateTime toBeCompletedUntil) {
|
||||
this.toBeCompletedUntil = toBeCompletedUntil;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDate getBestBeforeDate() {
|
||||
return bestBeforeDate;
|
||||
}
|
||||
|
||||
public RequestOrder setBestBeforeDate(LocalDate bestBeforeDate) {
|
||||
this.bestBeforeDate = bestBeforeDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProductionLot() {
|
||||
return productionLot;
|
||||
}
|
||||
|
||||
public RequestOrder setProductionLot(String productionLot) {
|
||||
this.productionLot = productionLot;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package it.integry.FoodProcess.dto;
|
||||
|
||||
public enum TargetQuantityUnit {
|
||||
PIECE,
|
||||
SECONDARY_PACKAGING,
|
||||
TERTIARY_PACKAGING,
|
||||
KILOGRAM
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ErrorResponse {
|
||||
@JsonProperty("error_message")
|
||||
private String errorMessage;
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public ErrorResponse setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ImportArticleStatus extends ResponseStatus {
|
||||
@JsonProperty("article_id")
|
||||
private String articleId;
|
||||
|
||||
public String getArticleId() {
|
||||
return articleId;
|
||||
}
|
||||
|
||||
public ImportArticleStatus setArticleId(String articleId) {
|
||||
this.articleId = articleId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImportArticlesResponse {
|
||||
private List<ImportArticleStatus> statuses;
|
||||
|
||||
public List<ImportArticleStatus> getStatuses() {
|
||||
return statuses;
|
||||
}
|
||||
|
||||
public ImportArticlesResponse setStatuses(List<ImportArticleStatus> statuses) {
|
||||
this.statuses = statuses;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ImportBusinessPartnerStatus extends ResponseStatus {
|
||||
@JsonProperty("business_partner_id")
|
||||
private String businessPartnerId;
|
||||
|
||||
public String getBusinessPartnerId() {
|
||||
return businessPartnerId;
|
||||
}
|
||||
|
||||
public ImportBusinessPartnerStatus setBusinessPartnerId(String businessPartnerId) {
|
||||
this.businessPartnerId = businessPartnerId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImportBusinessPartnersResponse {
|
||||
private List<ImportBusinessPartnerStatus> statuses;
|
||||
|
||||
public List<ImportBusinessPartnerStatus> getStatuses() {
|
||||
return statuses;
|
||||
}
|
||||
|
||||
public ImportBusinessPartnersResponse setStatuses(List<ImportBusinessPartnerStatus> statuses) {
|
||||
this.statuses = statuses;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ImportOrderStatus extends ResponseStatus {
|
||||
@JsonProperty("order_id")
|
||||
private String orderId;
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public ImportOrderStatus setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImportOrdersResponse {
|
||||
private List<ImportOrderStatus> statuses;
|
||||
|
||||
public List<ImportOrderStatus> getStatuses() {
|
||||
return statuses;
|
||||
}
|
||||
|
||||
public ImportOrdersResponse setStatuses(List<ImportOrderStatus> statuses) {
|
||||
this.statuses = statuses;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ImportPackagingMaterialStatus extends ResponseStatus {
|
||||
@JsonProperty("packaging_material_id")
|
||||
private String packagingMaterialId;
|
||||
|
||||
public String getPackagingMaterialId() {
|
||||
return packagingMaterialId;
|
||||
}
|
||||
|
||||
public ImportPackagingMaterialStatus setPackagingMaterialId(String packagingMaterialId) {
|
||||
this.packagingMaterialId = packagingMaterialId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImportPackagingMaterialsResponse {
|
||||
private List<ImportPackagingMaterialStatus> statuses;
|
||||
|
||||
public List<ImportPackagingMaterialStatus> getStatuses() {
|
||||
return statuses;
|
||||
}
|
||||
|
||||
public ImportPackagingMaterialsResponse setStatuses(List<ImportPackagingMaterialStatus> statuses) {
|
||||
this.statuses = statuses;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ImportRawMaterialStatus extends ResponseStatus {
|
||||
@JsonProperty("raw_material_id")
|
||||
private String rawMaterialId;
|
||||
|
||||
public String getRawMaterialId() {
|
||||
return rawMaterialId;
|
||||
}
|
||||
|
||||
public ImportRawMaterialStatus setRawMaterialId(String rawMaterialId) {
|
||||
this.rawMaterialId = rawMaterialId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImportRawMaterialsResponse {
|
||||
private List<ImportRawMaterialStatus> statuses;
|
||||
|
||||
public List<ImportRawMaterialStatus> getStatuses() {
|
||||
return statuses;
|
||||
}
|
||||
|
||||
public ImportRawMaterialsResponse setStatuses(List<ImportRawMaterialStatus> statuses) {
|
||||
this.statuses = statuses;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
public enum OrderStatus {
|
||||
NEW,
|
||||
ASSIGNED,
|
||||
ACTIVE,
|
||||
CLOSED,
|
||||
CANCELED
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class OrderStatusResponse {
|
||||
@JsonProperty("order_id")
|
||||
private String orderId;
|
||||
|
||||
@JsonProperty("order_status")
|
||||
private OrderStatus orderStatus;
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public OrderStatusResponse setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrderStatus getOrderStatus() {
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
public OrderStatusResponse setOrderStatus(OrderStatus orderStatus) {
|
||||
this.orderStatus = orderStatus;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package it.integry.FoodProcess.dto.response;
|
||||
|
||||
public class ResponseStatus {
|
||||
private boolean success;
|
||||
private String message;
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public ResponseStatus setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public ResponseStatus setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package it.integry.FoodProcess.service;
|
||||
|
||||
import it.integry.FoodProcess.api.AddApiKeyHeaderRequestFilter;
|
||||
import it.integry.FoodProcess.api.ErrorMessageResponseFilter;
|
||||
import it.integry.FoodProcess.api.FoodProcessClient;
|
||||
import it.integry.FoodProcess.api.JacksonProvider;
|
||||
import it.integry.FoodProcess.dto.Article;
|
||||
import it.integry.FoodProcess.dto.ImportArticlesRequest;
|
||||
import it.integry.FoodProcess.dto.response.ImportArticlesResponse;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.entity.MtbAart;
|
||||
import it.integry.ems_model.entity.MtbAartAnag;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
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.UtilityList;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
|
||||
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
|
||||
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class FoodProcessRestService {
|
||||
private final Pattern ID_REGEX = Pattern.compile("^[0-9A-Fa-f]{1,}$");
|
||||
|
||||
private final SetupGest setupGest;
|
||||
private final MultiDBTransactionManager multiDBTransactionManager;
|
||||
private final EntityProcessor entityProcessor;
|
||||
|
||||
public FoodProcessRestService(SetupGest setupGest, MultiDBTransactionManager multiDBTransactionManager, EntityProcessor entityProcessor) {
|
||||
this.setupGest = setupGest;
|
||||
this.multiDBTransactionManager = multiDBTransactionManager;
|
||||
this.entityProcessor = entityProcessor;
|
||||
}
|
||||
|
||||
public FoodProcessClient makeInstance() throws Exception {
|
||||
String endpoint = setupGest.getSetup("FOODPROCESS", "SETUP", "ENDPOINT");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(endpoint)) {
|
||||
throw new Exception("Endpoint per il servizio di FoodProcess non configurato.\nImpostarlo in FOODPROCESS->SETUP->ENDPOINT.");
|
||||
}
|
||||
|
||||
String apiKey = setupGest.getSetup("FOODPROCESS", "SETUP", "API_KEY");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(apiKey)) {
|
||||
throw new Exception("Api key per il servizio di FoodProcess non configurato.\nImpostarlo in FOODPROCESS->SETUP->API_KEY.");
|
||||
}
|
||||
|
||||
ResteasyClient client = new ResteasyClientBuilder().build();
|
||||
|
||||
client.register(new JacksonProvider());
|
||||
client.register(new ErrorMessageResponseFilter());
|
||||
client.register(new AddApiKeyHeaderRequestFilter(apiKey));
|
||||
|
||||
ResteasyWebTarget target = client.target(endpoint);
|
||||
|
||||
return target.proxy(FoodProcessClient.class);
|
||||
}
|
||||
|
||||
public Object importArticles(ImportArticlesRequest importArticlesRequest) throws Exception {
|
||||
if (UtilityList.isNullOrEmpty(importArticlesRequest.getArticles())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String codAnagTopControl = setupGest.getSetup("FOODPROCESS", "SETUP", "TOPCONTROL_CODANAG");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codAnagTopControl)) {
|
||||
throw new Exception("Cod. anag. di Top Control non configurato.\nImpostarlo in FOODPROCESS->SETUP->TOPCONTROL_CODANAG.");
|
||||
}
|
||||
|
||||
FoodProcessClient client = makeInstance();
|
||||
|
||||
List<Article> foodProcessArticles = client.getArticles();
|
||||
|
||||
List<MtbAart> entityList = new ArrayList<>();
|
||||
|
||||
for (Article article : importArticlesRequest.getArticles()) {
|
||||
if (UtilityString.isNullOrEmpty(article.getId()) || !ID_REGEX.matcher(article.getId()).matches()) {
|
||||
String sql;
|
||||
MtbAartAnag mtbAartAnag = null;
|
||||
|
||||
// Cerco negli articoli loro
|
||||
Optional<Article> optionalFoodProcessArticle = foodProcessArticles.stream()
|
||||
.filter(x -> !x.getIsArchived())
|
||||
.filter(x -> x.getCode().equalsIgnoreCase(article.getCode()))
|
||||
.findFirst();
|
||||
|
||||
if (optionalFoodProcessArticle.isPresent()) {
|
||||
Article foodProcessArticle = optionalFoodProcessArticle.get();
|
||||
|
||||
mtbAartAnag = new MtbAartAnag()
|
||||
.setCodAnag(codAnagTopControl)
|
||||
.setCodMartAnag(foodProcessArticle.getId())
|
||||
.setCodMart(article.getId());
|
||||
|
||||
mtbAartAnag.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
}
|
||||
|
||||
// Cerco id in nostra anagrafica
|
||||
if (mtbAartAnag == null && !UtilityString.isNullOrEmpty(article.getId())) {
|
||||
sql = Query.format(
|
||||
"SELECT id, cod_mart_anag\n" +
|
||||
"FROM mtb_aart_anag\n" +
|
||||
"WHERE cod_anag = %s\n" +
|
||||
" AND cod_mart = %s",
|
||||
codAnagTopControl,
|
||||
article.getId()
|
||||
);
|
||||
|
||||
mtbAartAnag = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbAartAnag.class);
|
||||
}
|
||||
|
||||
// Articolo nuovo, creo un nuovo id
|
||||
if (mtbAartAnag == null) {
|
||||
sql = Query.format(
|
||||
"SELECT CAST(ISNULL(MAX(cod_mart_anag), 0) + 1 AS VARCHAR) AS cod_mart_anag\n" +
|
||||
"FROM mtb_aart_anag\n" +
|
||||
"WHERE cod_anag = %s",
|
||||
codAnagTopControl
|
||||
);
|
||||
|
||||
String codMartAnag = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
mtbAartAnag = new MtbAartAnag()
|
||||
.setCodAnag(codAnagTopControl)
|
||||
.setCodMartAnag(codMartAnag);
|
||||
|
||||
mtbAartAnag.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
}
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(mtbAartAnag)) {
|
||||
if (!mtbAartAnag.getOperation().equals(OperationType.SELECT_OBJECT)) {
|
||||
MtbAart mtbAart = entityList.stream()
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(article.getId()))
|
||||
.findFirst()
|
||||
.orElseGet(() -> {
|
||||
MtbAart newMtbAart = new MtbAart()
|
||||
.setCodMart(article.getId())
|
||||
.setMtbAartAnag(new ArrayList<>());
|
||||
|
||||
newMtbAart.setOperation(OperationType.NO_OP);
|
||||
|
||||
entityList.add(newMtbAart);
|
||||
|
||||
return newMtbAart;
|
||||
});
|
||||
|
||||
mtbAart.getMtbAartAnag().add(mtbAartAnag);
|
||||
}
|
||||
|
||||
article.setId(mtbAartAnag.getCodMartAnag());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(entityList)) {
|
||||
entityProcessor.processEntityList(entityList, false);
|
||||
|
||||
UtilityEntity.throwEntitiesException(entityList);
|
||||
}
|
||||
|
||||
return client.importArticles(importArticlesRequest);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.WooCommerce.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import org.codehaus.jackson.annotate.JsonProperty;
|
||||
|
||||
public class AttributeDTO {
|
||||
@SqlField("attributo")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package it.integry.WooCommerce.dto.order;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import it.integry.WooCommerce.enums.OrderStatus;
|
||||
import org.codehaus.jackson.JsonNode;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240626120358 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("FOODPROCESS", "SETUP", "ENDPOINT", null,
|
||||
"Endpoint in formato http://[topcontrol-server]:7744 delle api di FoodProcess", null);
|
||||
createSetup("FOODPROCESS", "SETUP", "API_KEY", null,
|
||||
"Api key per autenticarsi con l'api di FoodProcess", null);
|
||||
|
||||
createSetupQuery(
|
||||
"COD_ANAG_FORN",
|
||||
"COD. FORNITORE",
|
||||
"SELECT gtb_anag.cod_anag + '|' + gtb_anag.cod_anag + ' - ' + gtb_anag.rag_soc\n" +
|
||||
"FROM gtb_anag\n" +
|
||||
" INNER JOIN atb_forn ON gtb_anag.cod_anag = atb_forn.cod_anag AND atb_forn.flag_stato = 'A'\n" +
|
||||
"ORDER BY rag_soc"
|
||||
);
|
||||
|
||||
createSetup("FOODPROCESS", "SETUP", "TOPCONTROL_CODANAG", null,
|
||||
"Cod. anag di Top Control per gestione id", "COD_ANAG_FORN");
|
||||
|
||||
createSetupQuery(
|
||||
"SOTTOGRUPPO",
|
||||
"COD. SOTTOGRUPPO",
|
||||
"SELECT cod_mgrp + '~' + cod_msgr AS value,\n" +
|
||||
" descrizione\n" +
|
||||
"FROM mtb_sgrp"
|
||||
);
|
||||
|
||||
createSetup("PVM", "PIANIFICAZIONE_PRODUZIONE_ORTO", "COD_MSGR_PACKAGING", null,
|
||||
"Cod. sottogruppi che indica il packaging nella distinta", "SOTTOGRUPPO", true);
|
||||
|
||||
createSetup("PVM", "PIANIFICAZIONE_PRODUZIONE_ORTO", "COD_MSGR_SECONDARY_PACKAGING", null,
|
||||
"Cod. sottogruppi che indica il secondary packaging nella distinta", "SOTTOGRUPPO", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1176,7 +1176,7 @@ public class SalesRules extends QueryRules {
|
||||
}
|
||||
|
||||
int indexOfLastPosizione = viaggiGiorno.indexOf(viaggiGiorno.stream()
|
||||
.filter(viaggio -> !viaggio.getIdViaggio().equalsIgnoreCase(vtbViaggi.getIdViaggio()) && viaggio.getPosizione() == vtbViaggi.getPosizione()).findFirst().orElse(null));
|
||||
.filter(viaggio -> !viaggio.getIdViaggio().equalsIgnoreCase(vtbViaggi.getIdViaggio()) && Objects.equals(viaggio.getPosizione(), vtbViaggi.getPosizione())).findFirst().orElse(null));
|
||||
|
||||
if (indexOfLastPosizione != -1) {
|
||||
viaggiGiorno.add(indexOfLastPosizione, vtbViaggi);
|
||||
|
||||
@@ -1173,8 +1173,9 @@ public class MtbAart extends EntityBase {
|
||||
return mtbAartAnag;
|
||||
}
|
||||
|
||||
public void setMtbAartAnag(List<MtbAartAnag> mtbAartAnag) {
|
||||
public MtbAart setMtbAartAnag(List<MtbAartAnag> mtbAartAnag) {
|
||||
this.mtbAartAnag = mtbAartAnag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<MtbSpes> getMtbSpes() {
|
||||
|
||||
@@ -58,26 +58,6 @@ public class MtbAartAnag extends EntityBase {
|
||||
@SqlField(value = "note", maxLength = 255, nullable = true)
|
||||
private String note;
|
||||
|
||||
public MtbAartAnag() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getCodAnag() {
|
||||
return codAnag;
|
||||
}
|
||||
|
||||
public void setCodAnag(String codAnag) {
|
||||
this.codAnag = codAnag;
|
||||
}
|
||||
|
||||
public String getCodMartAnag() {
|
||||
return codMartAnag;
|
||||
}
|
||||
|
||||
public void setCodMartAnag(String codMartAnag) {
|
||||
this.codMartAnag = codMartAnag;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -87,75 +67,102 @@ public class MtbAartAnag extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodAnag() {
|
||||
return codAnag;
|
||||
}
|
||||
|
||||
public MtbAartAnag setCodAnag(String codAnag) {
|
||||
this.codAnag = codAnag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMartAnag() {
|
||||
return codMartAnag;
|
||||
}
|
||||
|
||||
public MtbAartAnag setCodMartAnag(String codMartAnag) {
|
||||
this.codMartAnag = codMartAnag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public void setCodMart(String codMart) {
|
||||
public MtbAartAnag setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodCol() {
|
||||
return codCol;
|
||||
}
|
||||
|
||||
public void setCodCol(String codCol) {
|
||||
public MtbAartAnag setCodCol(String codCol) {
|
||||
this.codCol = codCol;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodTagl() {
|
||||
return codTagl;
|
||||
}
|
||||
|
||||
public void setCodTagl(String codTagl) {
|
||||
public MtbAartAnag setCodTagl(String codTagl) {
|
||||
this.codTagl = codTagl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescArtAnag() {
|
||||
return descArtAnag;
|
||||
}
|
||||
|
||||
public void setDescArtAnag(String descArtAnag) {
|
||||
public MtbAartAnag setDescArtAnag(String descArtAnag) {
|
||||
this.descArtAnag = descArtAnag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBarCode() {
|
||||
return barCode;
|
||||
}
|
||||
|
||||
public void setBarCode(String barCode) {
|
||||
public MtbAartAnag setBarCode(String barCode) {
|
||||
this.barCode = barCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodGrpBolla() {
|
||||
return codGrpBolla;
|
||||
}
|
||||
|
||||
public void setCodGrpBolla(String codGrpBolla) {
|
||||
public MtbAartAnag setCodGrpBolla(String codGrpBolla) {
|
||||
this.codGrpBolla = codGrpBolla;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getColliPedana() {
|
||||
return colliPedana;
|
||||
}
|
||||
|
||||
public void setColliPedana(BigDecimal colliPedana) {
|
||||
public MtbAartAnag setColliPedana(BigDecimal colliPedana) {
|
||||
this.colliPedana = colliPedana;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getGgShelflife() {
|
||||
return ggShelflife;
|
||||
}
|
||||
|
||||
public void setGgShelflife(Integer ggShelflife) {
|
||||
public MtbAartAnag setGgShelflife(Integer ggShelflife) {
|
||||
this.ggShelflife = ggShelflife;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
public MtbAartAnag setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package it.integry.ems_model.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.ems_model.annotation.ImportFromParent;
|
||||
import it.integry.ems_model.annotation.PK;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.annotation.Table;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.codehaus.jackson.annotate.JsonTypeName;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
import it.integry.ems_model.annotation.FK;
|
||||
|
||||
@PropertyReactive
|
||||
@Table(WtbDeviceTokenTopic.ENTITY)
|
||||
|
||||
@@ -69,12 +69,18 @@ public class UtilityBigDecimal {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static BigDecimal isNull(BigDecimal inputToCheck, BigDecimal alternativeInput){
|
||||
return inputToCheck == null ? alternativeInput : inputToCheck;
|
||||
}
|
||||
|
||||
public static BigDecimal isNullOrZero(BigDecimal inputToCheck, BigDecimal alternativeInput) {
|
||||
if (inputToCheck == null || inputToCheck.compareTo(BigDecimal.ZERO) == 0) {
|
||||
return alternativeInput;
|
||||
} else {
|
||||
return inputToCheck;
|
||||
}
|
||||
}
|
||||
|
||||
public static BigDecimal getLowerBetween(BigDecimal input1, BigDecimal input2) {
|
||||
if (input1 == null) return input2;
|
||||
if (input2 == null) return input1;
|
||||
|
||||
@@ -105,7 +105,7 @@ public class UtilityString {
|
||||
put("^\\d{1,2}\\s[a-z]{3}\\s\\d{4}\\s\\d{1,2}:\\d{2}:\\d{2}$", "dd MMM yyyy HH:mm:ss");
|
||||
put("^\\d{1,2}\\s[a-z]{4,}\\s\\d{4}\\s\\d{1,2}:\\d{2}:\\d{2}$", "dd MMMM yyyy HH:mm:ss");
|
||||
|
||||
put("^\\d{4}-\\d{1,2}-\\d{1,2}[T]\\d{1,2}:\\d{2}:\\d{2}$", "yyyy-MM-ddTHH:mm:ss");
|
||||
put("^\\d{4}-\\d{1,2}-\\d{1,2}[t]\\d{1,2}:\\d{2}:\\d{2}$", "yyyy-MM-dd'T'HH:mm:ss");
|
||||
|
||||
put("^\\d{4}-\\d{1,2}-\\d{1,2}t\\d{1,2}:\\d{2}:\\d{2}.\\d{1,3}z$", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||
put("^(\\d{4})-(\\d{2})-(\\d{2})t(\\d{2}):(\\d{2}):(\\d{2})((\\+|-)(\\d{2}):(\\d{2}))$", "yyyy-MM-dd'T'HH:mm:ss");
|
||||
|
||||
@@ -175,30 +175,6 @@
|
||||
<version>3.14.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>${httpclient.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- REST CLIENT -->
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
<version>${resteasy.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
<version>${resteasy.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Servlet & jstl -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package it.integry.ems.activity.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.StbActivity;
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -26,6 +26,8 @@ public class CrmCompletaOrd {
|
||||
public CrmCliente cliente;
|
||||
public CrmDestinazione destinazione;
|
||||
public CrmCommessa commessa;
|
||||
public String processActivityId;
|
||||
public List<CrmAttivita> crmAttivita = null;
|
||||
public List<CrmPersRif> persRif;
|
||||
public List<CrmSpese> spese;
|
||||
BigDecimal acconto;
|
||||
@@ -122,6 +124,24 @@ public class CrmCompletaOrd {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProcessActivityId() {
|
||||
return processActivityId;
|
||||
}
|
||||
|
||||
public CrmCompletaOrd setProcessActivityId(String processActivityId) {
|
||||
this.processActivityId = processActivityId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<CrmAttivita> getCrmAttivita() {
|
||||
return crmAttivita;
|
||||
}
|
||||
|
||||
@JsonProperty("CRMAttivita")
|
||||
public void setCrmAttivita(List<CrmAttivita> crmAttivita) {
|
||||
this.crmAttivita = crmAttivita;
|
||||
}
|
||||
|
||||
public List<CrmPersRif> getPersRif() {
|
||||
return persRif;
|
||||
}
|
||||
|
||||
@@ -202,11 +202,11 @@ public class CrmService {
|
||||
String codVage = this.getCodVageFromCodJflav(creaContatto.getCrmCommessa().getCodJflav());
|
||||
|
||||
String idOfferta = null;
|
||||
if (flagNewIdOfferta.equals("S")){
|
||||
if (flagNewIdOfferta.equals("S")) {
|
||||
String nuovoContatto = "S";
|
||||
String isConfermaOrdine = "0";
|
||||
idOfferta = (String) CommonRules.getSingleValue(multiDBTransactionManager.getPrimaryConnection(), "select dbo.f_suggestCodeIDOfferta('" + codJcom + "|" + isConfermaOrdine + "|" + nuovoContatto + "', 40)");
|
||||
}else{
|
||||
} else {
|
||||
String part1 = UtilityString.substring(codJcom, 2);
|
||||
String part2 = UtilityString.substring(codJcom, 2, codJcom.length());
|
||||
idOfferta = part1 + "P" + part2 + "-00";
|
||||
@@ -227,7 +227,7 @@ public class CrmService {
|
||||
ptbPrevt.setCambio(BigDecimal.ONE);
|
||||
ptbPrevt.setCodVage(codVage);
|
||||
ptbPrevt.setStatoOfferta("CONTATTO");
|
||||
if (note.getBytes() != null){
|
||||
if (note.getBytes() != null) {
|
||||
ptbPrevt.setOggetto(Base64.encodeBase64String(note.getBytes()));
|
||||
}
|
||||
if (pathFolderPrevt.compareTo("") != 0 && nameFileCheckList.compareTo("") != 0) {
|
||||
@@ -585,6 +585,7 @@ public class CrmService {
|
||||
BigDecimal acconto = completaOrd.getAcconto();
|
||||
String activityTypeId = completaOrd.getActivityTypeId();
|
||||
String flagTipologia = completaOrd.getFlagTipologia();
|
||||
String processActivityId = completaOrd.getProcessActivityId();
|
||||
|
||||
CrmCliente crmCliente = completaOrd.getCliente();
|
||||
|
||||
@@ -736,6 +737,48 @@ public class CrmService {
|
||||
entityProcessor.processEntity(jtbComt, true, multiDBTransactionManager);
|
||||
entityBaseList.add(jtbComt);
|
||||
codJcom = jtbComt.getCodJcom();
|
||||
|
||||
if (!completaOrd.getCrmAttivita().isEmpty()) {
|
||||
for (int i = 0; i < completaOrd.getCrmAttivita().size(); i++) {
|
||||
CrmAttivita crmAttivita = completaOrd.getCrmAttivita().get(i);
|
||||
|
||||
StbActivity stbActivity = new StbActivity();
|
||||
stbActivity.setOperation(OperationType.INSERT);
|
||||
if (processActivityId != null) {
|
||||
stbActivity.setParentActivityId(processActivityId);
|
||||
}
|
||||
stbActivity.setTipoAnag(tipoAnag);
|
||||
stbActivity.setCodAnag(codAnag);
|
||||
stbActivity.setCodJcom(codJcom);
|
||||
stbActivity.setActivityTypeId(crmAttivita.getActivityTypeId());
|
||||
stbActivity.setActivityDescription(crmAttivita.getActivityDescription());
|
||||
stbActivity.setActivityResultId(crmAttivita.getActivityResultId());
|
||||
stbActivity.setNote(crmAttivita.getNote());
|
||||
stbActivity.setFlagTipologia(crmAttivita.getFlagTipologia());
|
||||
stbActivity.setUserName(crmAttivita.getUserName());
|
||||
stbActivity.setUserCreator(crmAttivita.getUserCreator());
|
||||
stbActivity.setUserModifier(crmAttivita.getUserModifier());
|
||||
stbActivity.setOraModAct(crmAttivita.getOraModAct());
|
||||
stbActivity.setOraViewAct(crmAttivita.getOraViewAct());
|
||||
stbActivity.setEstimatedDate(crmAttivita.getEstimatedTime());
|
||||
stbActivity.setEstimatedTime(crmAttivita.getEstimatedTime());
|
||||
stbActivity.setEstimatedEnddate(crmAttivita.getEstimatedEndtime());
|
||||
stbActivity.setEstimatedEndtime(crmAttivita.getEstimatedEndtime());
|
||||
stbActivity.setEffectiveDate(crmAttivita.getEffectiveTime());
|
||||
stbActivity.setEffectiveTime(crmAttivita.getEffectiveTime());
|
||||
stbActivity.setEffectiveEnddate(crmAttivita.getEffectiveEndtime());
|
||||
stbActivity.setEffectiveEndtime(crmAttivita.getEffectiveEndtime());
|
||||
|
||||
entityProcessor.processEntity(stbActivity, true, multiDBTransactionManager);
|
||||
if (i == 0 && processActivityId == null) {
|
||||
// Se si tratta della prima attività e non è specificato il processActivityId (activity_id del processo) allora
|
||||
// vuol dire che si sta creando un nuovo contatto e quindi verrà creato sia il processo che l'attività semplice
|
||||
processActivityId = stbActivity.getActivityId();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Exception("I dati del processo e/o dell'attività da creare inesistenti");
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Dati di commessa da creare inesistenti");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
package it.integry.ems.production.Import.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import it.integry.FoodProcess.dto.Article;
|
||||
import it.integry.FoodProcess.dto.ArticleRawMaterial;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
public class ArticleData extends Article {
|
||||
@SqlField
|
||||
private String id;
|
||||
|
||||
@SqlField
|
||||
private String code;
|
||||
|
||||
@SqlField
|
||||
private String name;
|
||||
|
||||
@JsonProperty("raw_materials")
|
||||
private List<ArticleRawMaterial> rawMaterials;
|
||||
|
||||
@JsonProperty("packaging_material_id")
|
||||
private String packagingMaterialId;
|
||||
|
||||
@JsonProperty("packaging_material_code")
|
||||
private String packagingMaterialCode;
|
||||
|
||||
@JsonProperty("packaging_material_name")
|
||||
private String packagingMaterialName;
|
||||
|
||||
@SqlField
|
||||
private String note;
|
||||
|
||||
@JsonProperty("is_archived")
|
||||
private boolean isArchived;
|
||||
|
||||
@SqlField("unt_mis")
|
||||
private String untMis;
|
||||
|
||||
@SqlField("unt_mis2")
|
||||
private String untMis2;
|
||||
|
||||
@SqlField("rap_conv2")
|
||||
private BigDecimal rapConv2;
|
||||
|
||||
@SqlField("unt_mis3")
|
||||
private String untMis3;
|
||||
|
||||
@SqlField("rap_conv3")
|
||||
private BigDecimal rapConv3;
|
||||
|
||||
@SqlField("qta_cnf")
|
||||
private BigDecimal qtaCnf;
|
||||
|
||||
@SqlField("colli_strato")
|
||||
private BigDecimal colliStrato;
|
||||
|
||||
@SqlField("colli_pedana")
|
||||
private BigDecimal colliPedana;
|
||||
|
||||
@SqlField("cod_tcol_ul")
|
||||
private String codTcolUL;
|
||||
|
||||
public Article toArticle() {
|
||||
return new Article()
|
||||
.setId(this.getId())
|
||||
.setCode(this.getCode())
|
||||
.setName(this.getName())
|
||||
.setRawMaterials(this.getRawMaterials())
|
||||
.setPackagingMaterialId(this.getPackagingMaterialId())
|
||||
.setPackagingMaterialCode(this.getPackagingMaterialCode())
|
||||
.setPackagingMaterialName(this.getPackagingMaterialName())
|
||||
.setNote(this.getNote())
|
||||
.setIsArchived(this.getIsArchived());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleRawMaterial> getRawMaterials() {
|
||||
return rawMaterials;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article setRawMaterials(List<ArticleRawMaterial> rawMaterials) {
|
||||
this.rawMaterials = rawMaterials;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPackagingMaterialId() {
|
||||
return packagingMaterialId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article setPackagingMaterialId(String packagingMaterialId) {
|
||||
this.packagingMaterialId = packagingMaterialId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPackagingMaterialCode() {
|
||||
return packagingMaterialCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article setPackagingMaterialCode(String packagingMaterialCode) {
|
||||
this.packagingMaterialCode = packagingMaterialCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPackagingMaterialName() {
|
||||
return packagingMaterialName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArticleData setPackagingMaterialName(String packagingMaterialName) {
|
||||
this.packagingMaterialName = packagingMaterialName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsArchived() {
|
||||
return isArchived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article setIsArchived(boolean isArchived) {
|
||||
this.isArchived = isArchived;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUntMis() {
|
||||
return untMis;
|
||||
}
|
||||
|
||||
public ArticleData setUntMis(String untMis) {
|
||||
this.untMis = untMis;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUntMis2() {
|
||||
return untMis2;
|
||||
}
|
||||
|
||||
public ArticleData setUntMis2(String untMis2) {
|
||||
this.untMis2 = untMis2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getRapConv2() {
|
||||
return rapConv2;
|
||||
}
|
||||
|
||||
public ArticleData setRapConv2(BigDecimal rapConv2) {
|
||||
this.rapConv2 = rapConv2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUntMis3() {
|
||||
return untMis3;
|
||||
}
|
||||
|
||||
public ArticleData setUntMis3(String untMis3) {
|
||||
this.untMis3 = untMis3;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getRapConv3() {
|
||||
return rapConv3;
|
||||
}
|
||||
|
||||
public ArticleData setRapConv3(BigDecimal rapConv3) {
|
||||
this.rapConv3 = rapConv3;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaCnf() {
|
||||
return qtaCnf;
|
||||
}
|
||||
|
||||
public ArticleData setQtaCnf(BigDecimal qtaCnf) {
|
||||
this.qtaCnf = qtaCnf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getColliStrato() {
|
||||
return colliStrato;
|
||||
}
|
||||
|
||||
public ArticleData setColliStrato(BigDecimal colliStrato) {
|
||||
this.colliStrato = colliStrato;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getColliPedana() {
|
||||
return colliPedana;
|
||||
}
|
||||
|
||||
public ArticleData setColliPedana(BigDecimal colliPedana) {
|
||||
this.colliPedana = colliPedana;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodTcolUL() {
|
||||
return codTcolUL;
|
||||
}
|
||||
|
||||
public ArticleData setCodTcolUL(String codTcolUL) {
|
||||
this.codTcolUL = codTcolUL;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package it.integry.ems.production.Import.dto;
|
||||
|
||||
import it.integry.FoodProcess.dto.BusinessPartner;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
public class BusinessPartnerData extends BusinessPartner {
|
||||
@SqlField
|
||||
private String id;
|
||||
|
||||
@SqlField
|
||||
private String code;
|
||||
|
||||
@SqlField
|
||||
private String name;
|
||||
|
||||
@SqlField("cod_jcom")
|
||||
private String codJcom;
|
||||
|
||||
public BusinessPartner toBusinessPartner() {
|
||||
return new BusinessPartner()
|
||||
.setId(this.getId())
|
||||
.setCode(this.getCode())
|
||||
.setName(this.getName())
|
||||
.setIsCustomer(this.getIsCustomer())
|
||||
.setIsSupplier(this.getIsSupplier())
|
||||
.setNote(this.getNote())
|
||||
.setIsArchived(this.getIsArchived());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BusinessPartnerData setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BusinessPartnerData setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BusinessPartnerData setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodJcom() {
|
||||
return codJcom;
|
||||
}
|
||||
|
||||
public BusinessPartnerData setCodJcom(String codJcom) {
|
||||
this.codJcom = codJcom;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package it.integry.ems.production.Import.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import it.integry.FoodProcess.dto.PackagingMaterial;
|
||||
import it.integry.FoodProcess.dto.PackagingMaterialType;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
public class PackagingMaterialData extends PackagingMaterial {
|
||||
@SqlField
|
||||
private String id;
|
||||
|
||||
@SqlField
|
||||
private String code;
|
||||
|
||||
@SqlField
|
||||
private String name;
|
||||
|
||||
@SqlField
|
||||
private PackagingMaterialType type;
|
||||
|
||||
@SqlField("weight_kg")
|
||||
@JsonProperty("weight_kg")
|
||||
private Double weightKg;
|
||||
|
||||
@SqlField("length_mm")
|
||||
@JsonProperty("length_mm")
|
||||
private Double lengthMm;
|
||||
|
||||
@SqlField("width_mm")
|
||||
@JsonProperty("width_mm")
|
||||
private Double widthMm;
|
||||
|
||||
@SqlField("height_mm")
|
||||
@JsonProperty("height_mm")
|
||||
private Double heightMm;
|
||||
|
||||
@SqlField
|
||||
private String note;
|
||||
|
||||
@SqlField("is_archived")
|
||||
@JsonProperty("is_archived")
|
||||
private boolean isArchived;
|
||||
|
||||
@SqlField("cod_prod")
|
||||
private String codProd;
|
||||
|
||||
public PackagingMaterial toPackagingMaterial() {
|
||||
return new PackagingMaterial()
|
||||
.setId(this.getId())
|
||||
.setCode(this.getCode())
|
||||
.setName(this.getName())
|
||||
.setType(this.getType())
|
||||
.setWeightKg(this.getWeightKg())
|
||||
.setLengthMm(this.getLengthMm())
|
||||
.setWidthMm(this.getWidthMm())
|
||||
.setHeightMm(this.getHeightMm())
|
||||
.setNote(this.getNote())
|
||||
.setIsArchived(this.getIsArchived());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackagingMaterial setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackagingMaterial setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackagingMaterial setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackagingMaterialType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackagingMaterial setType(PackagingMaterialType type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getWeightKg() {
|
||||
return weightKg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackagingMaterial setWeightKg(Double weightKg) {
|
||||
this.weightKg = weightKg;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getLengthMm() {
|
||||
return lengthMm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackagingMaterial setLengthMm(Double lengthMm) {
|
||||
this.lengthMm = lengthMm;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getWidthMm() {
|
||||
return widthMm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackagingMaterial setWidthMm(Double widthMm) {
|
||||
this.widthMm = widthMm;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getHeightMm() {
|
||||
return heightMm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackagingMaterial setHeightMm(Double heightMm) {
|
||||
this.heightMm = heightMm;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackagingMaterial setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsArchived() {
|
||||
return isArchived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackagingMaterial setIsArchived(boolean isArchived) {
|
||||
this.isArchived = isArchived;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodProd() {
|
||||
return codProd;
|
||||
}
|
||||
|
||||
public PackagingMaterialData setCodProd(String codProd) {
|
||||
this.codProd = codProd;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package it.integry.ems.production.Import.dto;
|
||||
|
||||
import it.integry.FoodProcess.dto.RawMaterial;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class RawMaterialData extends RawMaterial {
|
||||
@SqlField
|
||||
private String id;
|
||||
|
||||
@SqlField
|
||||
private String code;
|
||||
|
||||
@SqlField
|
||||
private String name;
|
||||
|
||||
@SqlField
|
||||
private String note;
|
||||
|
||||
@SqlField("cod_prod")
|
||||
private String codProd;
|
||||
|
||||
public RawMaterial toRawMaterial() {
|
||||
return new RawMaterial()
|
||||
.setId(this.getId())
|
||||
.setCode(this.getCode())
|
||||
.setName(this.getName())
|
||||
.setNote(this.getNote());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public RawMaterialData setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public RawMaterialData setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public RawMaterialData setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public RawMaterialData setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodProd() {
|
||||
return codProd;
|
||||
}
|
||||
|
||||
public RawMaterialData setCodProd(String codProd) {
|
||||
this.codProd = codProd;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,15 @@ package it.integry.ems.production.Import.service;
|
||||
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.FoodProcess.api.FoodProcessClient;
|
||||
import it.integry.FoodProcess.service.FoodProcessRestService;
|
||||
import it.integry.FoodProcess.dto.*;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.exception.MissingDataException;
|
||||
import it.integry.ems.production.Import.dto.ArticleData;
|
||||
import it.integry.ems.production.Import.dto.BusinessPartnerData;
|
||||
import it.integry.ems.production.Import.dto.PackagingMaterialData;
|
||||
import it.integry.ems.production.Import.dto.RawMaterialData;
|
||||
import it.integry.ems.production.dto.OrdLavDTO;
|
||||
import it.integry.ems.production.dto.SaveProductionPlanDTO;
|
||||
import it.integry.ems.production.dto.SaveProductionPlanPartiteDTO;
|
||||
@@ -18,10 +26,7 @@ import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
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.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -34,6 +39,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
@@ -46,6 +52,8 @@ public class ProductionPlanService {
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
@Autowired
|
||||
private FoodProcessRestService foodProcessRestService;
|
||||
|
||||
public static Integer getNextNumOrd(Connection conn, String gestione, Date dataOrd, String gestioneRif) throws Exception {
|
||||
Integer numOrd = OrderRules.completeNumOrd(conn, gestione, dataOrd, gestioneRif);
|
||||
@@ -143,8 +151,8 @@ public class ProductionPlanService {
|
||||
|
||||
//ArrayNode arrayNode = objectMapper.createArrayNode();
|
||||
String codAnag = "", codJcom = "", idArtEqui = "", idArtEqui2 = "", codAnagProd = "", codAnagOld = "", codVdesOld = "", descrizioneEstesaProd = "";
|
||||
Integer numOrdProd = new Integer(0);
|
||||
Integer numOrdLav = new Integer(0);
|
||||
Integer numOrdProd;
|
||||
Integer numOrdLav;
|
||||
Connection connection = multiDBTransactionManager.getPrimaryConnection();
|
||||
|
||||
HashMap<String, String> setupSection = setupGest.getSetupSection(connection, "w_lpianoprod_rc", "SETUP");
|
||||
@@ -1130,5 +1138,328 @@ public class ProductionPlanService {
|
||||
}
|
||||
}
|
||||
|
||||
public Object esportazioneOrdFoodProcess(List<DtbOrdrPianProd> dtbOrdrPianProdList) throws Exception {
|
||||
if (UtilityList.isNullOrEmpty(dtbOrdrPianProdList)) {
|
||||
throw new MissingDataException("esportazioneOrdFoodProcess");
|
||||
}
|
||||
|
||||
String setupCodMsgrPackaging = setupGest.getSetup("PVM", "PIANIFICAZIONE_PRODUZIONE_ORTO", "COD_MSGR_PACKAGING");
|
||||
String setupCodMsgrSecondaryPackaging = setupGest.getSetup("PVM", "PIANIFICAZIONE_PRODUZIONE_ORTO", "COD_MSGR_SECONDARY_PACKAGING");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(setupCodMsgrPackaging) || UtilityString.isNullOrEmpty(setupCodMsgrSecondaryPackaging)) {
|
||||
throw new Exception("Cod. msgr per packaging non configurato.\nVerificare in PVM->PIANIFICAZIONE_PRODUZIONE_ORTO.");
|
||||
}
|
||||
|
||||
String[] codMsgrPackaging = setupCodMsgrPackaging.split("\\|");
|
||||
String[] codMsgrSecondaryPackaging = setupCodMsgrSecondaryPackaging.split("\\|");
|
||||
|
||||
FoodProcessClient foodProcessClient = foodProcessRestService.makeInstance();
|
||||
|
||||
List<Object> returnData = new ArrayList<>();
|
||||
String sql;
|
||||
|
||||
// Import clienti
|
||||
|
||||
List<String> listCodJcom = dtbOrdrPianProdList.stream()
|
||||
.map(DtbOrdrPianProd::getCodJcom)
|
||||
.filter(codJcom -> !UtilityString.isNullOrEmpty(codJcom))
|
||||
.distinct().collect(Collectors.toList());
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(listCodJcom)) {
|
||||
sql = String.format(
|
||||
"SELECT ga.cod_anag AS id,\n" +
|
||||
" ga.cod_anag AS code,\n" +
|
||||
" ga.rag_soc AS name,\n" +
|
||||
" cod_jcom\n" +
|
||||
"FROM jtb_comt\n" +
|
||||
" INNER JOIN gtb_anag ga ON jtb_comt.cod_anag = ga.cod_anag\n" +
|
||||
"WHERE cod_jcom IN (%s)",
|
||||
UtilityQuery.concatStringFieldsWithSeparator(listCodJcom, ",")
|
||||
);
|
||||
} else {
|
||||
String codJfasSede = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "PVM", "PIANIFICAZIONE_PRODUZIONE_ORTO", "COD_JFAS");
|
||||
|
||||
sql = Query.format(
|
||||
"SELECT ga.cod_anag AS id,\n" +
|
||||
" ga.cod_anag AS code,\n" +
|
||||
" ga.rag_soc AS name\n" +
|
||||
"FROM gtb_anag ga\n" +
|
||||
" INNER JOIN mtb_depo md ON ga.cod_anag = md.cod_anag AND md.cod_jfas = %s",
|
||||
codJfasSede
|
||||
);
|
||||
}
|
||||
|
||||
List<BusinessPartnerData> businessPartners = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, BusinessPartnerData.class);
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(businessPartners)) {
|
||||
businessPartners.forEach(businessPartner -> businessPartner.setIsCustomer(true));
|
||||
|
||||
ImportBusinessPartnersRequest importBusinessPartnersRequest = new ImportBusinessPartnersRequest()
|
||||
.setBusinessPartners(businessPartners.stream().map(BusinessPartnerData::toBusinessPartner).collect(Collectors.toList()));
|
||||
|
||||
returnData.add(foodProcessClient.importBusinessPartners(importBusinessPartnersRequest));
|
||||
}
|
||||
|
||||
// Import materiali
|
||||
|
||||
sql = String.format(
|
||||
"SELECT ma.cod_mart AS id,\n" +
|
||||
" ma.cod_mart AS code,\n" +
|
||||
" ma.descrizione AS name,\n" +
|
||||
" ma.note,\n" +
|
||||
" jdm.cod_prod\n" +
|
||||
"FROM mtb_aart ma\n" +
|
||||
" INNER JOIN jtb_dist_mate jdm ON ma.cod_mart = jdm.cod_mart AND jdm.cod_prod IN (%s)\n" +
|
||||
" INNER JOIN mtb_grup mg ON ma.cod_mgrp = mg.cod_mgrp\n" +
|
||||
"WHERE mg.tipo_mgrp = 'MP'",
|
||||
UtilityQuery.concatStringFieldsWithSeparator(dtbOrdrPianProdList.stream().map(DtbOrdrPianProd::getCodProd).distinct().collect(Collectors.toList()), ",")
|
||||
);
|
||||
|
||||
List<RawMaterialData> rawMaterials = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, RawMaterialData.class);
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(rawMaterials)) {
|
||||
ImportRawMaterialsRequest importRawMaterialsRequest = new ImportRawMaterialsRequest()
|
||||
.setRawMaterials(Stream.of(rawMaterials)
|
||||
.distinctBy(RawMaterialData::getId)
|
||||
.map(RawMaterialData::toRawMaterial)
|
||||
.toList()
|
||||
);
|
||||
|
||||
returnData.add(foodProcessClient.importRawMaterials(importRawMaterialsRequest));
|
||||
}
|
||||
|
||||
// Import packaging
|
||||
|
||||
sql = String.format(
|
||||
"SELECT ma.cod_mart AS id,\n" +
|
||||
" ma.cod_mart AS code,\n" +
|
||||
" ma.descrizione AS name,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN ms.descrizione = 'BUSTE' THEN 'BAG'\n" +
|
||||
" WHEN ms.descrizione = 'CESTINI' THEN 'PUNNET'\n" +
|
||||
" END AS type,\n" +
|
||||
// " ma.tara_kg AS weight_kg,\n" +
|
||||
" ma.note,\n" +
|
||||
" jdm.cod_prod\n" +
|
||||
"FROM mtb_aart ma\n" +
|
||||
" INNER JOIN jtb_dist_mate jdm ON ma.cod_mart = jdm.cod_mart AND jdm.cod_prod IN (%s)\n" +
|
||||
" INNER JOIN mtb_sgrp ms ON ma.cod_mgrp = ms.cod_mgrp AND ma.cod_msgr = ms.cod_msgr\n" +
|
||||
"WHERE ma.cod_mgrp + '~' + ma.cod_msgr IN (%s)",
|
||||
UtilityQuery.concatStringFieldsWithSeparator(dtbOrdrPianProdList.stream().map(DtbOrdrPianProd::getCodProd).distinct().collect(Collectors.toList()), ","),
|
||||
UtilityQuery.concatStringFieldsWithSeparator(Arrays.asList(codMsgrPackaging), ",")
|
||||
);
|
||||
|
||||
List<PackagingMaterialData> packagingMaterials = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, PackagingMaterialData.class);
|
||||
|
||||
ImportPackagingMaterialsRequest importPackagingMaterialsRequest = new ImportPackagingMaterialsRequest()
|
||||
.setPackagingMaterials(new ArrayList<>());
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(packagingMaterials)) {
|
||||
importPackagingMaterialsRequest.getPackagingMaterials()
|
||||
.addAll(packagingMaterials.stream().map(PackagingMaterialData::toPackagingMaterial).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
// Import secondary packaging
|
||||
|
||||
sql = String.format(
|
||||
"SELECT ma.cod_mart AS id,\n" +
|
||||
" ma.cod_mart AS code,\n" +
|
||||
" ma.descrizione AS name,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN ms.descrizione IN ('COLLI LEGNO', 'COLLI PLASTICA') THEN 'CRATE'\n" +
|
||||
" WHEN ms.descrizione = 'COLLI CARTONE' THEN 'CARTON'\n" +
|
||||
" END AS type,\n" +
|
||||
// " ma.tara_kg AS weight_kg,\n" +
|
||||
" ma.note,\n" +
|
||||
" jdm.cod_prod\n" +
|
||||
"FROM mtb_aart ma\n" +
|
||||
" INNER JOIN jtb_dist_mate jdm ON ma.cod_mart = jdm.cod_mart AND jdm.cod_prod IN (%s)\n" +
|
||||
" INNER JOIN mtb_sgrp ms ON ma.cod_mgrp = ms.cod_mgrp AND ma.cod_msgr = ms.cod_msgr\n" +
|
||||
"WHERE ma.cod_mgrp + '~' + ma.cod_msgr IN (%s)",
|
||||
UtilityQuery.concatStringFieldsWithSeparator(dtbOrdrPianProdList.stream().map(DtbOrdrPianProd::getCodProd).distinct().collect(Collectors.toList()), ","),
|
||||
UtilityQuery.concatStringFieldsWithSeparator(Arrays.asList(codMsgrSecondaryPackaging), ",")
|
||||
);
|
||||
|
||||
List<PackagingMaterialData> secondaryPackagingMaterials = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, PackagingMaterialData.class);
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(secondaryPackagingMaterials)) {
|
||||
importPackagingMaterialsRequest.getPackagingMaterials()
|
||||
.addAll(secondaryPackagingMaterials.stream().map(PackagingMaterialData::toPackagingMaterial).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
// Import tertiary packaging
|
||||
|
||||
sql = String.format(
|
||||
"SELECT ISNULL(mt.cod_tcol, mt_art.cod_tcol) AS id,\n" +
|
||||
" ISNULL(mt.cod_tcol, mt_art.cod_tcol) AS code,\n" +
|
||||
" ISNULL(mt.descrizione, mt_art.descrizione) AS name,\n" +
|
||||
" 'PALLET' AS type,\n" +
|
||||
" ISNULL(mt.peso_kg, mt_art.peso_kg) AS weight_kg,\n" +
|
||||
" ma.cod_mart AS cod_prod\n" +
|
||||
"FROM mtb_aart ma\n" +
|
||||
" LEFT OUTER JOIN mtb_tcol mt ON mt.cod_tcol IN (%s)\n" +
|
||||
" LEFT OUTER JOIN mtb_tcol mt_art ON ma.cod_tcol_UL = mt_art.cod_tcol\n" +
|
||||
"WHERE ma.cod_mart IN (%s)",
|
||||
UtilityQuery.concatStringFieldsWithSeparator(dtbOrdrPianProdList.stream().map(DtbOrdrPianProd::getCodTcol).distinct().collect(Collectors.toList()), ","),
|
||||
UtilityQuery.concatStringFieldsWithSeparator(dtbOrdrPianProdList.stream().map(DtbOrdrPianProd::getCodProd).distinct().collect(Collectors.toList()), ",")
|
||||
);
|
||||
|
||||
List<PackagingMaterialData> tertiaryPackagingMaterials = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, PackagingMaterialData.class);
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(tertiaryPackagingMaterials)) {
|
||||
importPackagingMaterialsRequest.getPackagingMaterials()
|
||||
.addAll(tertiaryPackagingMaterials.stream().map(PackagingMaterialData::toPackagingMaterial).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
if (!importPackagingMaterialsRequest.getPackagingMaterials().isEmpty()) {
|
||||
returnData.add(foodProcessClient.importPackagingMaterials(importPackagingMaterialsRequest));
|
||||
}
|
||||
|
||||
// Import articoli
|
||||
|
||||
sql = String.format(
|
||||
"SELECT ma.cod_mart AS id,\n" +
|
||||
" ma.cod_mart AS code,\n" +
|
||||
" ma.descrizione AS name,\n" +
|
||||
" ma.note,\n" +
|
||||
" ma.unt_mis,\n" +
|
||||
" ma.unt_mis2,\n" +
|
||||
" ma.rap_conv2,\n" +
|
||||
" ma.unt_mis3,\n" +
|
||||
" ma.rap_conv3,\n" +
|
||||
" ma.qta_cnf,\n" +
|
||||
" ma.colli_strato,\n" +
|
||||
" ma.colli_pedana,\n" +
|
||||
" ma.cod_tcol_UL\n" +
|
||||
"FROM mtb_aart ma\n" +
|
||||
"WHERE ma.cod_mart IN (%s)",
|
||||
UtilityQuery.concatStringFieldsWithSeparator(dtbOrdrPianProdList.stream().map(DtbOrdrPianProd::getCodProd).distinct().collect(Collectors.toList()), ",")
|
||||
);
|
||||
|
||||
List<ArticleData> articles = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ArticleData.class);
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(articles)) {
|
||||
articles.forEach(article -> {
|
||||
article.setCode(article.getCode().replace("-", ""));
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(rawMaterials)) {
|
||||
double weightKg;
|
||||
|
||||
if (UtilityString.isNullOrEmpty(article.getUntMis2())) {
|
||||
weightKg = article.getRapConv3().doubleValue();
|
||||
} else if (article.getUntMis2().equalsIgnoreCase("PZ")) {
|
||||
weightKg = article.getRapConv2().doubleValue();
|
||||
} else {
|
||||
weightKg = 0D;
|
||||
}
|
||||
|
||||
long countMaterial = rawMaterials.stream()
|
||||
.filter(rawMaterial -> rawMaterial.getCodProd().equalsIgnoreCase(article.getId()))
|
||||
.count();
|
||||
|
||||
List<ArticleRawMaterial> articleRawMaterials = rawMaterials.stream()
|
||||
.filter(rawMaterial -> rawMaterial.getCodProd().equalsIgnoreCase(article.getId()))
|
||||
.map(rawMaterialData -> new ArticleRawMaterial()
|
||||
.setId(rawMaterialData.getId())
|
||||
.setWeightKg(weightKg / (countMaterial == 0 ? 1 : countMaterial)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
article.setRawMaterials(articleRawMaterials);
|
||||
}
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(packagingMaterials)) {
|
||||
packagingMaterials.stream()
|
||||
.filter(packagingMaterialData -> packagingMaterialData.getCodProd().equalsIgnoreCase(article.getId()))
|
||||
.findFirst()
|
||||
.ifPresent(packagingMaterialData -> article.setPackagingMaterialId(packagingMaterialData.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
ImportArticlesRequest importArticlesRequest = new ImportArticlesRequest()
|
||||
.setArticles(articles.stream().map(ArticleData::toArticle).collect(Collectors.toList()));
|
||||
|
||||
returnData.add(foodProcessRestService.importArticles(importArticlesRequest));
|
||||
}
|
||||
|
||||
// Import ordini
|
||||
|
||||
List<RequestOrder> orders = dtbOrdrPianProdList.stream()
|
||||
.map(dtbOrdrPianProd -> {
|
||||
RequestOrder requestOrder = new RequestOrder()
|
||||
.setId(String.format(
|
||||
"%sA%dA%s",
|
||||
UtilityDate.formatDate(dtbOrdrPianProd.getDataOrd(), "yy"),
|
||||
dtbOrdrPianProd.getNumOrd(),
|
||||
dtbOrdrPianProd.getCodJfas().substring(1)
|
||||
))
|
||||
.setType("PRODUCTION")
|
||||
.setArticleCode(dtbOrdrPianProd.getCodProd().replace("-", ""))
|
||||
// .setTargetQuantity(dtbOrdrPianProd.getQtaOrd().doubleValue())
|
||||
// .setTargetQuantityUnit(TargetQuantityUnit.PIECE)
|
||||
.setProductionLot(dtbOrdrPianProd.getPartitaMag());
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(businessPartners)) {
|
||||
businessPartners.stream()
|
||||
.filter(businessPartnerData -> UtilityString.isNullOrEmpty(businessPartnerData.getCodJcom()) ||
|
||||
businessPartnerData.getCodJcom().equalsIgnoreCase(dtbOrdrPianProd.getCodJcom()))
|
||||
.findFirst()
|
||||
.ifPresent(businessPartnerData -> requestOrder.setCustomerId(businessPartnerData.getId()));
|
||||
}
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(articles)) {
|
||||
articles.stream()
|
||||
.filter(article -> article.getId().equalsIgnoreCase(dtbOrdrPianProd.getCodProd()))
|
||||
.findFirst()
|
||||
.ifPresent(article -> {
|
||||
BigDecimal rapConv;
|
||||
|
||||
if (UtilityString.isNullOrEmpty(article.getUntMis2())) {
|
||||
rapConv = article.getRapConv3();
|
||||
} else if (article.getUntMis2().equalsIgnoreCase("PZ")) {
|
||||
rapConv = article.getRapConv2();
|
||||
} else {
|
||||
rapConv = BigDecimal.ONE;
|
||||
}
|
||||
|
||||
requestOrder
|
||||
.setUnitsPerSecondaryPackaging(article.getQtaCnf()
|
||||
.divide(rapConv, RoundingMode.HALF_EVEN).intValue())
|
||||
.setUnitsPerPalletLayer(UtilityBigDecimal.isNullOrZero(article.getColliStrato(), BigDecimal.ONE).intValue())
|
||||
.setPalletLayerQuantity(article.getColliPedana()
|
||||
.divide(BigDecimal.valueOf(requestOrder.getUnitsPerPalletLayer()), RoundingMode.HALF_EVEN).intValue())
|
||||
.setTargetQuantity(dtbOrdrPianProd.getQtaOrd()
|
||||
.divide(UtilityBigDecimal.isNull(article.getQtaCnf(), BigDecimal.ONE), RoundingMode.HALF_EVEN)
|
||||
.divide(UtilityBigDecimal.isNull(article.getColliPedana(), BigDecimal.ONE), RoundingMode.HALF_EVEN)
|
||||
.doubleValue()
|
||||
)
|
||||
.setTargetQuantityUnit(TargetQuantityUnit.TERTIARY_PACKAGING);
|
||||
});
|
||||
}
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(secondaryPackagingMaterials)) {
|
||||
secondaryPackagingMaterials.stream()
|
||||
.filter(packagingMaterialData -> packagingMaterialData.getCodProd().equalsIgnoreCase(dtbOrdrPianProd.getCodProd()))
|
||||
.findFirst()
|
||||
.ifPresent(packagingMaterialData -> requestOrder.setSecondaryPackagingMaterialId(packagingMaterialData.getId()));
|
||||
}
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(tertiaryPackagingMaterials)) {
|
||||
tertiaryPackagingMaterials.stream()
|
||||
.filter(packagingMaterialData -> packagingMaterialData.getCodProd().equalsIgnoreCase(dtbOrdrPianProd.getCodProd()))
|
||||
.findFirst()
|
||||
.ifPresent(packagingMaterialData -> requestOrder.setTertiaryPackagingMaterialId(packagingMaterialData.getId()));
|
||||
}
|
||||
|
||||
return requestOrder;
|
||||
}
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
ImportOrdersRequest importOrdersRequest = new ImportOrdersRequest()
|
||||
.setOrders(orders);
|
||||
|
||||
returnData.add(foodProcessClient.importOrders(importOrdersRequest));
|
||||
|
||||
return returnData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.DtbOrdrPianProd;
|
||||
import it.integry.ems_model.entity.JtbRLavt;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -72,7 +73,7 @@ public class HRProductionController {
|
||||
@RequestMapping(value = EmsRestConstants.PATH_SAVE_PRODUCTION_PLAN + "2", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse saveProductionPlan(@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody List<SaveProductionPlanDTO> saveProductionPlanDTOS) throws Exception {
|
||||
@RequestBody List<SaveProductionPlanDTO> saveProductionPlanDTOS) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(productionPlanService.saveProductionPlan(saveProductionPlanDTOS));
|
||||
}
|
||||
|
||||
@@ -128,6 +129,11 @@ public class HRProductionController {
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "esportazioneOrdFoodProcess", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse esportazioneOrdFoodProcess(@RequestBody List<DtbOrdrPianProd> dtbOrdrPianProdList) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(productionPlanService.esportazioneOrdFoodProcess(dtbOrdrPianProdList));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package it.integry.ems.production.dto;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import it.integry.ems.retail.wms.generic.dto.RettificaULDTO;
|
||||
import org.codehaus.jackson.annotate.JsonProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -37,7 +37,7 @@
|
||||
<spring.version>5.3.34</spring.version>
|
||||
<security.version>5.8.12</security.version>
|
||||
<jackson.version>2.17.0</jackson.version>
|
||||
<resteasy.version>3.0.12.Final</resteasy.version>
|
||||
<resteasy.version>3.15.6.Final</resteasy.version>
|
||||
<swagger.version>3.0.0</swagger.version>
|
||||
<ems.war.name>ems</ems.war.name>
|
||||
<brt.tracknumber.listener.enabled>true</brt.tracknumber.listener.enabled>
|
||||
|
||||
Reference in New Issue
Block a user