Skip to content

Commit

Permalink
update fw-commons
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangtien2k3 committed Aug 27, 2024
1 parent c080136 commit 8b2dc88
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,53 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@SpringBootApplication
public class KeycloakApplication {

public static void main(String[] args) {
SpringApplication.run(KeycloakApplication.class, args);
}

Map<String, Object> parentValues = new HashMap<>();
List<String> failedParentIds = new ArrayList<>();

try {
parentValues = listSubOrder.stream()
.map(Orders::getParentBpId)
.distinct()
.filter(Objects::nonNull)
.collect(Collectors.toMap(
parentBpId -> parentBpId,
parentBpId -> {
try {
return runtineService.getVariable(parentBpId, finalNameVariable);
} catch (Exception e) {
// Nếu có lỗi khi lấy biến, thêm parentBpId vào danh sách lỗi
failedParentIds.add(parentBpId);
return null; // Giá trị null sẽ bị filter sau đó
}
}
));

// Lọc bỏ các entry có giá trị null (tức là những đơn hàng cha không hoạt động)
parentValues.entrySet().removeIf(entry -> entry.getValue() == null);

// Nếu có bất kỳ parentBpId nào không lấy được biến, ném lỗi tại đây
if (!failedParentIds.isEmpty()) {
String failedIds = String.join(", ", failedParentIds);
Logger.error("Failed to retrieve variables for parent BpIds: {}", failedIds);
throw new LogicException("SUBOR00004", "value.name.variable.nut?");
}

} catch (Exception e) {
Logger.error("An unexpected error occurred: {}", e.getMessage(), e);
throw new LogicException("SUBOR00004", "value.name.variable.nut?");
}

}

0 comments on commit 8b2dc88

Please sign in to comment.