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