Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
warehouse-management
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ascend
warehouse-management
Commits
ae755bcf
Commit
ae755bcf
authored
May 17, 2021
by
Alex Pinto
Browse files
Options
Browse Files
Download
Plain Diff
fixed merge conflicts
parents
121ccfc2
fae92463
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
164 additions
and
68 deletions
+164
-68
.DS_Store
.DS_Store
+0
-0
.gitignore
.gitignore
+1
-0
README.md
README.md
+29
-14
pom.xml
pom.xml
+11
-10
WarehouseApplication.java
...om/ascendfinalproject/warehouse/WarehouseApplication.java
+0
-11
KafkaConfig.java
.../com/ascendfinalproject/warehouse/config/KafkaConfig.java
+5
-2
SwaggerConfig.java
...om/ascendfinalproject/warehouse/config/SwaggerConfig.java
+37
-0
WebFluxConfig.java
...om/ascendfinalproject/warehouse/config/WebFluxConfig.java
+24
-0
WarehouseController.java
...nalproject/warehouse/controllers/WarehouseController.java
+5
-5
Sender.java
...com/ascendfinalproject/warehouse/kafkaservice/Sender.java
+15
-15
Address.java
...java/com/ascendfinalproject/warehouse/models/Address.java
+3
-4
Item.java
...in/java/com/ascendfinalproject/warehouse/models/Item.java
+6
-5
Session.java
...java/com/ascendfinalproject/warehouse/models/Session.java
+2
-1
User.java
...in/java/com/ascendfinalproject/warehouse/models/User.java
+20
-0
application.properties
src/main/resources/application.properties
+6
-1
No files found.
.DS_Store
deleted
100644 → 0
View file @
121ccfc2
File deleted
.gitignore
View file @
ae755bcf
...
...
@@ -3,6 +3,7 @@ target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
.DS_Store
### STS ###
.apt_generated
...
...
README.md
View file @
ae755bcf
...
...
@@ -17,27 +17,42 @@
---
## Details
#### Schema
### Schemas
#### Warehouse Order
```
{
_id: String
orderId: String
status: String "unfulfilled" (default) > "fulfilled"/"cancelled"
orderObject?: (will have it on initial Kafka message, not sure if we need to store this)
id: String,
orderId: String,
status: String "RECEIVED" (default) > "FULFILLED"/"CANCELLED",
createdAt: Date,
modifiedAt: Date,
orderItems: List<Item>,
address: String,
}
```
#### Workflow
-
Warehouse Management (WM) expects an Order object (?) from Order Management (OM) on order placement in Kafka.
-
On receipt of an Order object, WM will create a warehouse order entry in database with a status of "unfulfilled."
#### Item
```
{
itemId: String,
itemName: String,
itemQuantity: int,
itemPrice: float,
itemSku: int,
}
```
### Workflow
-
Warehouse Management (WM) expects an Order object from Order Management (OM) on order creation in Kafka.
-
On receipt of an Order object, WM will create a warehouse order entry in database with a status of
**"RECEIVED"**
.
-
In the WM UI, a warehouse manager will have the ability to fulfill or cancel unfulfilled orders.
-
When an order is marked
**"
fulfilled"**
or
**"cancelled
"**
, a Kafka message will be sent to be consumed.
-
When an order is marked
**"
FULFILLED"**
or
**"CANCELLED
"**
, a Kafka message will be sent to be consumed.
###
#
UI
-
Login
-
Order
status update screen mark orders as fulfilled or cancelled
-
Order
s
earch
-
Order
information page
### UI
-
Login
/Logout
-
Order
Status and Update orders as
**"FULFILLED"**
or
**"CANCELLED"**
-
Order
Filter and S
earch
-
Order
Details
#### API Documentation
https://documenter.getpostman.com/view/7402212/TzRNGATe
pom.xml
View file @
ae755bcf
...
...
@@ -93,16 +93,17 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-validation
</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger2</artifactId>-->
<!-- <version>2.7.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger-ui</artifactId>-->
<!-- <version>2.7.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
3.0.0
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-boot-starter
</artifactId>
<version>
3.0.0
</version>
</dependency>
</dependencies>
...
...
src/main/java/com/ascendfinalproject/warehouse/WarehouseApplication.java
View file @
ae755bcf
...
...
@@ -3,24 +3,13 @@ package com.ascendfinalproject.warehouse;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.annotation.Bean
;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication
//@EnableSwagger2
public
class
WarehouseApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
WarehouseApplication
.
class
,
args
);
}
// @Bean
// public Docket productApi() {
// return new Docket(DocumentationType.SWAGGER_2).select()
// .apis(RequestHandlerSelectors.basePackage("com.ascendfinalproject.warehouse")).build();
// }
}
src/main/java/com/ascendfinalproject/warehouse/config/KafkaConfig.java
View file @
ae755bcf
...
...
@@ -32,6 +32,9 @@ public class KafkaConfig {
@Value
(
"${kafka.consumer.group-id}"
)
private
String
groupId
;
@Value
(
"${kafka.topic.input}"
)
private
String
omsTopic
;
@Bean
public
Map
<
String
,
Object
>
consumerFactory
()
{
...
...
@@ -44,10 +47,10 @@ public class KafkaConfig {
}
@Bean
public
KafkaReceiver
<
String
,
String
>
kafkaEventReceiver
(
@Value
(
"${kafka.topic.input}"
)
String
topic
)
{
public
KafkaReceiver
<
String
,
String
>
kafkaEventReceiver
()
{
ReceiverOptions
<
String
,
String
>
receiverOptions
=
ReceiverOptions
.
create
(
consumerFactory
());
receiverOptions
.
maxCommitAttempts
(
5
);
return
KafkaReceiver
.
create
(
receiverOptions
.
addAssignListener
(
Collection:
:
iterator
).
subscription
(
Collections
.
singleton
(
t
opic
)));
return
KafkaReceiver
.
create
(
receiverOptions
.
addAssignListener
(
Collection:
:
iterator
).
subscription
(
Collections
.
singleton
(
omsT
opic
)));
}
...
...
src/main/java/com/ascendfinalproject/warehouse/config/SwaggerConfig.java
0 → 100644
View file @
ae755bcf
package
com
.
ascendfinalproject
.
warehouse
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
@Configuration
@EnableSwagger2
public
class
SwaggerConfig
{
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
"Order Management PRO"
)
.
build
();
}
@Bean
public
Docket
api
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
useDefaultResponseMessages
(
false
)
.
select
()
.
apis
(
RequestHandlerSelectors
.
any
())
.
paths
(
PathSelectors
.
any
())
.
build
()
.
apiInfo
(
apiInfo
());
}
}
src/main/java/com/ascendfinalproject/warehouse/config/WebFluxConfig.java
0 → 100644
View file @
ae755bcf
package
com
.
ascendfinalproject
.
warehouse
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.reactive.config.EnableWebFlux
;
import
org.springframework.web.reactive.config.ResourceHandlerRegistry
;
import
org.springframework.web.reactive.config.WebFluxConfigurer
;
@Configuration
@EnableWebFlux
public
class
WebFluxConfig
implements
WebFluxConfigurer
{
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
registry
.
addResourceHandler
(
"/swagger-ui.html**"
)
.
addResourceLocations
(
"classpath:/META-INF/resources/"
);
registry
.
addResourceHandler
(
"/webjars/**"
)
.
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
);
}
}
src/main/java/com/ascendfinalproject/warehouse/controllers/WarehouseController.java
View file @
ae755bcf
...
...
@@ -42,11 +42,11 @@ public class WarehouseController {
.
defaultIfEmpty
(
ResponseEntity
.
status
(
HttpStatus
.
NOT_FOUND
).
body
(
null
));
}
@CrossOrigin
@PostMapping
(
value
=
"/kafkaOrders"
)
public
void
createOrderKafka
(
@Valid
@RequestBody
WarehouseOrderRequest
order
)
{
sender
.
sendOrder
(
order
);
}
//
@CrossOrigin
//
@PostMapping(value = "/kafkaOrders")
//
public void createOrderKafka(@Valid @RequestBody WarehouseOrderRequest order) {
//
sender.sendOrder(order);
//
}
@CrossOrigin
@PostMapping
(
value
=
"/orders"
)
...
...
src/main/java/com/ascendfinalproject/warehouse/kafkaservice/Sender.java
View file @
ae755bcf
...
...
@@ -23,21 +23,21 @@ public class Sender {
private
KafkaSender
<
String
,
WarehouseOrderResponse
>
kafkaUpdateEventProducer
;
private
static
final
String
TOPIC
=
"
warehouse_management
"
;
private
static
final
String
OMS
=
"
order_management
"
;
public
void
sendOrder
(
WarehouseOrderRequest
currentOrder
)
{
ProducerRecord
<
String
,
WarehouseOrderRequest
>
record
=
new
ProducerRecord
<>(
OMS
,
currentOrder
);
Flux
<
SenderResult
<
WarehouseOrderRequest
>>
sendToKafka
=
kafkaOMSProducer
.
send
(
Mono
.
just
(
SenderRecord
.
create
(
record
,
currentOrder
)))
.
doOnError
(
throwable
->
System
.
out
.
println
(
throwable
))
.
doOnNext
(
t
->
{
if
(
null
!=
t
.
exception
())
{
System
.
out
.
println
(
"it works!"
);
}
});
sendToKafka
.
doOnError
(
throwable
->
log
.
error
(
"error"
)).
subscribe
();
}
private
static
final
String
TOPIC
=
"
WMOS_ORDER_UPDATE
"
;
private
static
final
String
OMS
=
"
OMS_ORDER_UPDATE
"
;
//
public void sendOrder(WarehouseOrderRequest currentOrder) {
// ProducerRecord<String, WarehouseOrderRequest> record = new ProducerRecord<>(TOPIC
, currentOrder);
//
Flux<SenderResult<WarehouseOrderRequest>> sendToKafka = kafkaOMSProducer.send(Mono.just(SenderRecord.create(record, currentOrder)))
//
.doOnError(throwable -> System.out.println(throwable))
//
.doOnNext(t -> {
//
if (null != t.exception()) {
//
System.out.println("it works!");
//
}
//
});
//
sendToKafka.doOnError(throwable -> log.error("error")).subscribe();
//
}
public
void
sendUpdatedOrder
(
WarehouseOrderResponse
currentOrder
)
{
ProducerRecord
<
String
,
WarehouseOrderResponse
>
record
=
new
ProducerRecord
<>(
TOPIC
,
currentOrder
);
...
...
src/main/java/com/ascendfinalproject/warehouse/models/Address.java
View file @
ae755bcf
...
...
@@ -9,15 +9,14 @@ import lombok.ToString;
@ToString
public
class
Address
{
public
Address
()
{
}
private
String
street
;
private
String
city
;
private
String
state
;
private
String
zip
;
public
Address
()
{
}
public
Address
(
String
street
,
String
city
,
String
state
,
String
zip
)
{
this
.
street
=
street
;
this
.
city
=
city
;
...
...
src/main/java/com/ascendfinalproject/warehouse/models/Item.java
View file @
ae755bcf
...
...
@@ -14,10 +14,13 @@ public class Item {
private
String
itemId
;
private
String
itemName
;
private
int
itemQuantity
;
private
double
itemPrice
;
private
int
itemSku
;
private
float
itemPrice
;
private
String
itemSku
;
public
Item
(
String
itemId
,
String
itemName
,
int
itemQuantity
,
double
itemPrice
,
int
itemSku
)
{
public
Item
()
{
}
public
Item
(
String
itemId
,
String
itemName
,
int
itemQuantity
,
float
itemPrice
,
String
itemSku
)
{
this
.
itemId
=
itemId
;
this
.
itemName
=
itemName
;
this
.
itemQuantity
=
itemQuantity
;
...
...
@@ -25,7 +28,5 @@ public class Item {
this
.
itemSku
=
itemSku
;
}
public
Item
()
{
}
}
src/main/java/com/ascendfinalproject/warehouse/models/Session.java
View file @
ae755bcf
...
...
@@ -8,6 +8,7 @@ import org.springframework.data.annotation.Id;
@Setter
public
class
Session
{
@Id
private
String
token
;
private
User
user
;
}
src/main/java/com/ascendfinalproject/warehouse/models/User.java
0 → 100644
View file @
ae755bcf
package
com
.
ascendfinalproject
.
warehouse
.
models
;
import
lombok.Getter
;
import
lombok.Setter
;
@Getter
@Setter
public
class
User
{
private
String
email
;
private
String
familyName
;
private
String
givenName
;
private
String
googleId
;
private
String
imageUrl
;
private
String
name
;
public
User
()
{
}
}
src/main/resources/application.properties
View file @
ae755bcf
...
...
@@ -8,4 +8,9 @@ server.port=8080
kafka.producer.bootstrap-servers
:
localhost:9092
kafka.producer.acks
:
all
kafka.consumer.group-id
:
WAREHOUSE_MANAGEMENT
kafka.topic.input
:
order_management
\ No newline at end of file
kafka.topic.input
:
OMS_ORDER_UPDATE
#kafka.topic.input: OMS_ORDER_UPDATE
server.port
=
8081
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment