修复差标
This commit is contained in:
parent
eb6e65c4f7
commit
99c88317c0
|
@ -10,8 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
|
@ -23,35 +22,22 @@ public class JTCompanyDomainService {
|
|||
@Autowired
|
||||
private SystemCodeRepository systemCodeRepository;
|
||||
|
||||
private Set<JTCompany> companyBlackList = new HashSet<>();
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// 在Bean创建后加载黑名单到内存中
|
||||
log.info("加载集团公司名单");
|
||||
companyBlackList.addAll(jtCompanyRepository.findAll());
|
||||
jtCompanyRepository.findAll();
|
||||
}
|
||||
|
||||
|
||||
public boolean ifCompanyInJT(String companyName, String companyCode) {
|
||||
List<JTCompany> all = jtCompanyRepository.findAll();
|
||||
if (companyName != null) {
|
||||
boolean contains = companyBlackList.stream().map(JTCompany::getCompanyName).toList().contains(companyName);
|
||||
//如果找不到的话, 再次查询数据进行一次查找
|
||||
if (!contains) {
|
||||
companyBlackList.addAll(jtCompanyRepository.findAll());
|
||||
contains = companyBlackList.stream().map(JTCompany::getCompanyName).toList().contains(companyName);
|
||||
}
|
||||
return contains;
|
||||
return all.stream().map(JTCompany::getCompanyName).toList().contains(companyName);
|
||||
}
|
||||
if (companyCode != null) {
|
||||
boolean contains = companyBlackList.stream().map(JTCompany::getCompanyCode).toList().contains(companyCode);
|
||||
//如果找不到的话, 再次查询数据进行一次查找
|
||||
if (!contains) {
|
||||
companyBlackList.addAll(jtCompanyRepository.findAll());
|
||||
contains = companyBlackList.stream().map(JTCompany::getCompanyCode).toList().contains(companyCode);
|
||||
}
|
||||
return contains;
|
||||
return all.stream().map(JTCompany::getCompanyCode).toList().contains(companyCode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ public class JTCompanyRepositoryImpl implements JTCompanyRepository {
|
|||
@Autowired
|
||||
private JdbcJTCompanyRepositoryImpl jdbcJTCompanyRepository;
|
||||
|
||||
@Cacheable(value = "JTCompanyAll")
|
||||
@Override
|
||||
public List<JTCompany> findAll() {
|
||||
return jdbcJTCompanyRepository.findBySystemCodeId(1L);
|
||||
|
|
Loading…
Reference in New Issue