Skip to content

Commit

Permalink
[FIX] progressBit 로직 수정 및 pickItem시 progressBit 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jong-gil committed Dec 19, 2023
1 parent 653aa99 commit 8065fe9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.workerservice.service;

public interface WorkerService {
String pickItem(String pickerId, long itemId);
String pickItem(String pickerId, long itemId) throws Exception;
String changePosition(String pickerId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ public class WorkerServiceImpl implements WorkerService{
private final RedisTemplate<String, Object> redisTemplate;
private final ObjectMapper mapper;
private final KafkaProducer kafkaProducer;
private final RedisService redisService;

@Override
@Transactional
public String pickItem(String workerId, long itemId) {
public String pickItem(String workerId, long itemId) throws Exception {
ZSetOperations<String, Object> redisSortedSet = redisTemplate.opsForZSet();
StringBuilder sb = new StringBuilder("worker");

Expand Down Expand Up @@ -64,7 +65,7 @@ public String changePosition(String workerId) {
return "worker is NOT PRESENT";
}

private String process(long itemId, Object target, Object nextTarget, String workerId){
private String process(long itemId, Object target, Object nextTarget, String workerId) throws Exception {
WorkerRes targetPayload = mapper.convertValue(target, WorkerRes.class);
WorkerRes nextTargetPayload = mapper.convertValue(nextTarget, WorkerRes.class);

Expand All @@ -81,6 +82,8 @@ private String process(long itemId, Object target, Object nextTarget, String wor
.responseItemList(itemList)
.build();
kafkaProducer.pickedItem("PickerToRobot", pickedItem);
redisService.setProgressBit(Long.parseLong(workerId));

return itemId + "is Picked";
} // 다르다면 하나의 주문이 처리된 것 -> orderService로 complete 보냄
else {
Expand All @@ -98,6 +101,7 @@ private String process(long itemId, Object target, Object nextTarget, String wor
.orderStatus(true)
.build();
kafkaProducer.orderCompleted("PickerToOrder", orderCompleted);
redisService.setProgressBit(Long.parseLong(workerId));
return itemId + "is Picked"
+ "%n order no." + targetPayload.getOrderId() + "is Completed";
}
Expand Down

0 comments on commit 8065fe9

Please sign in to comment.