fix:修复因缓存出现的bug
This commit is contained in:
parent
fe764bc2ab
commit
6a76da4f15
|
@ -190,7 +190,7 @@ public class OrderApplicationService {
|
||||||
|
|
||||||
leg.setRouteId(routeOrder.getRouteId());
|
leg.setRouteId(routeOrder.getRouteId());
|
||||||
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
|
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)) {
|
if (checkIfNeedApprove(routeOrder)) {
|
||||||
leg.addEvent(LegApprovalEvent.prepare());
|
leg.addEvent(LegApprovalEvent.prepare());
|
||||||
|
|
|
@ -4,10 +4,16 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class FsscSystem {
|
public class FsscSystem implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 8890173691234912036L;
|
||||||
private String systemName;
|
private String systemName;
|
||||||
private String systemCode;
|
private String systemCode;
|
||||||
private String redirectUrl;
|
private String redirectUrl;
|
||||||
|
|
|
@ -84,6 +84,9 @@ public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepos
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SystemOrganization> findByIdIn(List<Long> ids) {
|
public List<SystemOrganization> findByIdIn(List<Long> ids) {
|
||||||
|
if (ids == null || ids.isEmpty()) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
List<SystemOrganization> fromCacheByIdIn = cacheSystemOrganizationRepository.getFromCacheByIdIn(ids);
|
List<SystemOrganization> fromCacheByIdIn = cacheSystemOrganizationRepository.getFromCacheByIdIn(ids);
|
||||||
List<Long> fromCacheOrg = fromCacheByIdIn.stream()
|
List<Long> fromCacheOrg = fromCacheByIdIn.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
|
@ -167,7 +170,12 @@ public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepos
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SystemOrganization> findByOrgCodeContainingOrOrgNameContaining(String orgCode, String orgName) {
|
public Optional<SystemOrganization> findByOrgCodeContainingOrOrgNameContaining(String orgCode, String orgName) {
|
||||||
return Optional.ofNullable(cacheSystemOrganizationRepository.cacheOrgCodeById(orgCode, null))
|
Optional<Long> cacheOrgCodeById = Optional
|
||||||
|
.ofNullable(cacheSystemOrganizationRepository.cacheOrgCodeById(orgCode, null));
|
||||||
|
if (cacheOrgCodeById.isEmpty()) {
|
||||||
|
cacheSystemOrganizationRepository.cacheEvictOrgCodeById(orgCode);
|
||||||
|
}
|
||||||
|
Optional<SystemOrganization> systemOrganizationOptional = cacheOrgCodeById
|
||||||
.flatMap(id -> Optional.ofNullable(cacheSystemOrganizationRepository.cacheById(id, null)))
|
.flatMap(id -> Optional.ofNullable(cacheSystemOrganizationRepository.cacheById(id, null)))
|
||||||
.or(() -> Stream.of(
|
.or(() -> Stream.of(
|
||||||
jdbcSystemOrganizationRepository.findByOrgCode(orgCode).stream().findFirst(),
|
jdbcSystemOrganizationRepository.findByOrgCode(orgCode).stream().findFirst(),
|
||||||
|
@ -176,6 +184,10 @@ public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepos
|
||||||
.filter(Optional::isPresent)
|
.filter(Optional::isPresent)
|
||||||
.map(Optional::get)
|
.map(Optional::get)
|
||||||
.findFirst());
|
.findFirst());
|
||||||
|
if(cacheOrgCodeById.isEmpty() && systemOrganizationOptional.isPresent()) {
|
||||||
|
updateSystemOrganizationCache(systemOrganizationOptional.get());
|
||||||
|
}
|
||||||
|
return systemOrganizationOptional;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,8 @@ public class UserRepositoryImpl extends AbstractGenericRepository<User, Long> im
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User findByUserEmployeeNo(String employeeNo) {
|
public User findByUserEmployeeNo(String employeeNo) {
|
||||||
return this.findByField("EmployeeNo", employeeNo)
|
Optional<User> employee = this.findByField("EmployeeNo", employeeNo);
|
||||||
.orElseThrow(() -> new CommandException("Employee Not Found"));
|
return employee.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,9 +5,11 @@ import com.chint.domain.aggregates.system.SystemOrganization;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.cache.support.NullValue;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue