diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/api/logic/dto/SuccessfullRequestDto.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/api/logic/dto/SuccessfulRequestDto.java similarity index 94% rename from backend/src/main/java/org/eclipse/tractusx/puris/backend/common/api/logic/dto/SuccessfullRequestDto.java rename to backend/src/main/java/org/eclipse/tractusx/puris/backend/common/api/logic/dto/SuccessfulRequestDto.java index 9cb7cd3f..4195dba9 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/api/logic/dto/SuccessfullRequestDto.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/api/logic/dto/SuccessfulRequestDto.java @@ -30,8 +30,8 @@ @ToString @NoArgsConstructor @AllArgsConstructor -public class SuccessfullRequestDto { +public class SuccessfulRequestDto { - @JsonProperty("request-id") + @JsonProperty("requestId") private UUID requestId; } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/ProductStockRequestApiController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/ProductStockRequestApiController.java index eca4b2ea..6cb0bba3 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/ProductStockRequestApiController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/ProductStockRequestApiController.java @@ -25,13 +25,12 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; -import org.eclipse.tractusx.puris.backend.common.api.controller.exception.RequestIdAlreadyUsedException; import org.eclipse.tractusx.puris.backend.common.api.domain.model.MessageHeader; import org.eclipse.tractusx.puris.backend.common.api.domain.model.ProductStockRequest; import org.eclipse.tractusx.puris.backend.common.api.domain.model.datatype.DT_RequestStateEnum; import org.eclipse.tractusx.puris.backend.common.api.logic.dto.MessageHeaderDto; import org.eclipse.tractusx.puris.backend.common.api.logic.dto.RequestDto; -import org.eclipse.tractusx.puris.backend.common.api.logic.dto.SuccessfullRequestDto; +import org.eclipse.tractusx.puris.backend.common.api.logic.dto.SuccessfulRequestDto; import org.eclipse.tractusx.puris.backend.common.api.logic.service.RequestApiService; import org.eclipse.tractusx.puris.backend.common.api.logic.service.RequestService; import org.eclipse.tractusx.puris.backend.common.edc.logic.service.EdcAdapterService; @@ -129,7 +128,7 @@ public ResponseEntity postRequest(@RequestBody String requestBody) { respondAsyncThread.start(); // if the request has been correctly taken over, return 202 - return ResponseEntity.status(HttpStatusCode.valueOf(202)).body(new SuccessfullRequestDto(requestId)); + return ResponseEntity.status(HttpStatusCode.valueOf(202)).body(new SuccessfulRequestDto(requestId)); } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/ProductStockResponseApiController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/ProductStockResponseApiController.java index 8b9acb11..eda21b77 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/ProductStockResponseApiController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/ProductStockResponseApiController.java @@ -25,7 +25,7 @@ import org.eclipse.tractusx.puris.backend.common.api.domain.model.ProductStockRequest; import org.eclipse.tractusx.puris.backend.common.api.domain.model.datatype.DT_RequestStateEnum; -import org.eclipse.tractusx.puris.backend.common.api.logic.dto.SuccessfullRequestDto; +import org.eclipse.tractusx.puris.backend.common.api.logic.dto.SuccessfulRequestDto; import org.eclipse.tractusx.puris.backend.common.api.logic.service.RequestService; import org.eclipse.tractusx.puris.backend.common.api.logic.service.ResponseApiService; import org.eclipse.tractusx.puris.backend.stock.logic.adapter.ApiMarshallingService; @@ -39,7 +39,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; @@ -98,7 +97,7 @@ public ResponseEntity postResponse(@RequestBody String body) { responseApiService.consumeResponse(productStockResponseDto); // if the request has been correctly taken over, return 202 - return ResponseEntity.status(HttpStatusCode.valueOf(202)).body(new SuccessfullRequestDto(requestId)); + return ResponseEntity.status(HttpStatusCode.valueOf(202)).body(new SuccessfulRequestDto(requestId)); } } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/PartnerProductStockService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/PartnerProductStockService.java index bf03b8fc..825fb2a0 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/PartnerProductStockService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/PartnerProductStockService.java @@ -38,6 +38,6 @@ public interface PartnerProductStockService { PartnerProductStock update(PartnerProductStock partnerProductStock); - List findAllByMaterialUuidAndPartnerUuid(UUID partnerUuid, - UUID materialUuid); + List findAllByMaterialUuidAndPartnerUuid(UUID materialUuid, + UUID partnerUuid); } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/PartnerProductStockServiceImpl.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/PartnerProductStockServiceImpl.java index a0169db0..40a8b284 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/PartnerProductStockServiceImpl.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/PartnerProductStockServiceImpl.java @@ -64,7 +64,7 @@ public PartnerProductStock update(PartnerProductStock partnerProductStock) { } @Override - public List findAllByMaterialUuidAndPartnerUuid(UUID partnerUuid, UUID materialUuid) { + public List findAllByMaterialUuidAndPartnerUuid(UUID materialUuid, UUID partnerUuid) { return partnerProductStockRepository.findAllByMaterial_UuidAndTypeAndSupplierPartner_Uuid(materialUuid, DT_StockTypeEnum.PRODUCT, partnerUuid); } } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ProductStockResponseApiServiceImpl.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ProductStockResponseApiServiceImpl.java index 2b6e47f3..ec23ab3c 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ProductStockResponseApiServiceImpl.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ProductStockResponseApiServiceImpl.java @@ -81,9 +81,9 @@ public void consumeResponse(ResponseDto responseDto) { // or whether an update is sufficient. List existingPartnerProductStocks = partnerProductStockService.findAllByMaterialUuidAndPartnerUuid( - partnerProductStockDto.getSupplierPartner().getUuid(), - partnerProductStockDto.getMaterial().getUuid() - ); + partnerProductStockDto.getMaterial().getUuid(), + partnerProductStockDto.getSupplierPartner().getUuid() + ); // currently we only accept a one to one mapping of partner - material - stock -site // therefore the can only be one PartnerProductStock @@ -104,8 +104,12 @@ public void consumeResponse(ResponseDto responseDto) { log.info(String.format("Created Partner ProductStock from SAMM: %s", createdPartnerProductStock)); } else { + // update quantity only + PartnerProductStock existingPartnerProductStock = existingPartnerProductStocks.get(0); + existingPartnerProductStock.setQuantity(partnerProductStockDto.getQuantity()); + PartnerProductStock updatedPartnerProductStock = - partnerProductStockService.update(existingPartnerProductStocks.get(0)); + partnerProductStockService.update(existingPartnerProductStock); log.info(String.format("Updated Partner ProductStock from SAMM: %s", updatedPartnerProductStock)); } diff --git a/frontend/.env b/frontend/.env index 15dd2485..370ef96a 100644 --- a/frontend/.env +++ b/frontend/.env @@ -7,4 +7,4 @@ VITE_ENDPOINT_MATERIAL_STOCKS=stockView/material-stocks VITE_ENDPOINT_PRODUCT_STOCKS=stockView/product-stocks VITE_ENDPOINT_CUSTOMER=stockView/customer?materialUuid= VITE_ENDPOINT_PARTNER_PRODUCT_STOCKS=stockView/partner-product-stocks -VITE_ENDPOINT_UPDATE_PARTNER_PRODUCT_STOCK=stockView/update-partner-product-stock?materialUuid= +VITE_ENDPOINT_UPDATE_PARTNER_PRODUCT_STOCK=stockView/update-partner-product-stock?ownMaterialNumber= diff --git a/frontend/src/views/StockView.vue b/frontend/src/views/StockView.vue index 360c8c6e..a79cbe49 100644 --- a/frontend/src/views/StockView.vue +++ b/frontend/src/views/StockView.vue @@ -180,12 +180,12 @@ export default { methods: { addOrUpdateStock(changedStock) { if (changedStock.type === "Material") { - var existingMaterialStock = this.bdMaterialStocks.filter( + var existingMaterialStocks = this.bdMaterialStocks.filter( (stock) => (stock.material.uuid === changedStock.materialId) ); - if (existingMaterialStock.length === 1) { // Update existing material stock - var existingMaterialStock = existingMaterialStock[0]; + if (existingMaterialStocks.length === 1) { // Update existing material stock + var existingMaterialStock = existingMaterialStocks[0]; existingMaterialStock.quantity = changedStock.quantity; this.putData(this.backendURL + this.endpointMaterialStocks, existingMaterialStock); diff --git a/frontend/src/views/stock/PartnerStockSFC.vue b/frontend/src/views/stock/PartnerStockSFC.vue index 2cc18ea9..a8b91c68 100644 --- a/frontend/src/views/stock/PartnerStockSFC.vue +++ b/frontend/src/views/stock/PartnerStockSFC.vue @@ -97,7 +97,7 @@ export default { .catch(err => console.log(err)); }, updateMaterialOrProduct() { - fetch(this.backendURL + this.endpointUpdatePartnerProductStock + this.materialUuid) + fetch(this.backendURL + this.endpointUpdatePartnerProductStock + this.selectedMaterialOrProductId) .then(res => res.json()) .then(data => console.log(data)) .catch(err => console.log(err)); diff --git a/frontend/src/views/stock/StockTableSFC.vue b/frontend/src/views/stock/StockTableSFC.vue index 65eaa98a..ae4a5751 100644 --- a/frontend/src/views/stock/StockTableSFC.vue +++ b/frontend/src/views/stock/StockTableSFC.vue @@ -74,6 +74,7 @@ export default { return { selectedStockId: "", selectedStockUuid: "", + materialNumberCustomer : "" }; }, methods: {