diff --git a/src/main/java/com/chint/application/services/OrderApplicationService.java b/src/main/java/com/chint/application/services/OrderApplicationService.java index b41ff68b..4a83f786 100644 --- a/src/main/java/com/chint/application/services/OrderApplicationService.java +++ b/src/main/java/com/chint/application/services/OrderApplicationService.java @@ -190,7 +190,7 @@ public class OrderApplicationService { leg.setRouteId(routeOrder.getRouteId()); ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); - if (routeOrder.getApproveOrderNo().getActualOrderNo() != null && addLegData.getIfApprove() == 1) { + if (routeOrder.getApproveOrderNo().getActualOrderNo() != null && addLegData.getIfApprove() != null && addLegData.getIfApprove() == 1) { //这里加入一个待审批事件 if (checkIfNeedApprove(routeOrder)) { leg.addEvent(LegApprovalEvent.prepare()); diff --git a/src/main/java/com/chint/domain/aggregates/system/FsscSystem.java b/src/main/java/com/chint/domain/aggregates/system/FsscSystem.java index 0884e391..a070e397 100644 --- a/src/main/java/com/chint/domain/aggregates/system/FsscSystem.java +++ b/src/main/java/com/chint/domain/aggregates/system/FsscSystem.java @@ -4,10 +4,16 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serial; +import java.io.Serializable; + @Data @NoArgsConstructor -public class FsscSystem { +public class FsscSystem implements Serializable { + + @Serial + private static final long serialVersionUID = 8890173691234912036L; private String systemName; private String systemCode; private String redirectUrl; diff --git a/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java index 38170168..120e3c0f 100644 --- a/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java @@ -84,6 +84,9 @@ public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepos @Override public List findByIdIn(List ids) { + if (ids == null || ids.isEmpty()) { + return List.of(); + } List fromCacheByIdIn = cacheSystemOrganizationRepository.getFromCacheByIdIn(ids); List fromCacheOrg = fromCacheByIdIn.stream() .filter(Objects::nonNull) @@ -167,7 +170,12 @@ public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepos @Override public Optional findByOrgCodeContainingOrOrgNameContaining(String orgCode, String orgName) { - return Optional.ofNullable(cacheSystemOrganizationRepository.cacheOrgCodeById(orgCode, null)) + Optional cacheOrgCodeById = Optional + .ofNullable(cacheSystemOrganizationRepository.cacheOrgCodeById(orgCode, null)); + if (cacheOrgCodeById.isEmpty()) { + cacheSystemOrganizationRepository.cacheEvictOrgCodeById(orgCode); + } + Optional systemOrganizationOptional = cacheOrgCodeById .flatMap(id -> Optional.ofNullable(cacheSystemOrganizationRepository.cacheById(id, null))) .or(() -> Stream.of( jdbcSystemOrganizationRepository.findByOrgCode(orgCode).stream().findFirst(), @@ -176,6 +184,10 @@ public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepos .filter(Optional::isPresent) .map(Optional::get) .findFirst()); + if(cacheOrgCodeById.isEmpty() && systemOrganizationOptional.isPresent()) { + updateSystemOrganizationCache(systemOrganizationOptional.get()); + } + return systemOrganizationOptional; } diff --git a/src/main/java/com/chint/infrastructure/repository/UserRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/UserRepositoryImpl.java index 5f710fd4..49e29798 100644 --- a/src/main/java/com/chint/infrastructure/repository/UserRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/UserRepositoryImpl.java @@ -78,8 +78,8 @@ public class UserRepositoryImpl extends AbstractGenericRepository im @Override public User findByUserEmployeeNo(String employeeNo) { - return this.findByField("EmployeeNo", employeeNo) - .orElseThrow(() -> new CommandException("Employee Not Found")); + Optional employee = this.findByField("EmployeeNo", employeeNo); + return employee.orElse(null); } @Override diff --git a/src/main/java/com/chint/infrastructure/repository/cache/CacheSystemOrganizationRepository.java b/src/main/java/com/chint/infrastructure/repository/cache/CacheSystemOrganizationRepository.java index 5b7564e0..344a07bb 100644 --- a/src/main/java/com/chint/infrastructure/repository/cache/CacheSystemOrganizationRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/cache/CacheSystemOrganizationRepository.java @@ -5,9 +5,11 @@ import com.chint.domain.aggregates.system.SystemOrganization; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; +import org.springframework.cache.support.NullValue; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; +import java.util.ArrayList; import java.util.List; import java.util.Objects;