提交 98239ddb authored 作者: 孙洁清's avatar 孙洁清

sjq修改的

上级 e5369d6f
...@@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Query; ...@@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Query;
public interface EvaluationDao extends JpaRepository<Evaluation,String>, JpaSpecificationExecutor<Evaluation> { public interface EvaluationDao extends JpaRepository<Evaluation,String>, JpaSpecificationExecutor<Evaluation> {
Evaluation findByUsernameAndIdNot(String username,String id); Evaluation findByUsernameAndIdNot(String username,String id);
Evaluation findByUsername(String username); Evaluation findByUsername(String username);
@Query(value = "SELECT * FROM evaluation WHERE username=:username AND create_time = (SELECT MAX(create_time) FROM evaluation WHERE username=:username)",nativeQuery = true) @Query(value = "SELECT * FROM master_evaluation WHERE username=:username AND create_time = (SELECT MAX(create_time) FROM evaluation WHERE username=:username)",nativeQuery = true)
Evaluation findByUsernameAndMaxCreateDate(String username); Evaluation findByUsernameAndMaxCreateDate(String username);
......
...@@ -27,6 +27,7 @@ public interface RuleDao extends JpaRepository<Rule,String>,JpaSpecificationExec ...@@ -27,6 +27,7 @@ public interface RuleDao extends JpaRepository<Rule,String>,JpaSpecificationExec
List<Rule> findAllByTarget(String target); List<Rule> findAllByTarget(String target);
Rule findByTarget(String target); Rule findByTarget(String target);
List<Rule> findByTargetIgnoreCase(String target);
Rule findByTargetAndIdNot(String target,String id); Rule findByTargetAndIdNot(String target,String id);
List<Rule> findByTargetAndSuffixEqualsAndTechnologyIdEquals(String target,String suffix,String technologyId); List<Rule> findByTargetAndSuffixEqualsAndTechnologyIdEquals(String target,String suffix,String technologyId);
......
...@@ -20,6 +20,7 @@ import org.apache.tomcat.util.buf.Utf8Encoder; ...@@ -20,6 +20,7 @@ import org.apache.tomcat.util.buf.Utf8Encoder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
...@@ -462,8 +463,8 @@ public class Inspector { ...@@ -462,8 +463,8 @@ public class Inspector {
if (!ruleSuffixFilePathMap.containsKey(rule.getSuffix())) { if (!ruleSuffixFilePathMap.containsKey(rule.getSuffix())) {
ruleSuffixFilePathMap.put(rule.getSuffix(), new ArrayList<>()); ruleSuffixFilePathMap.put(rule.getSuffix(), new ArrayList<>());
} }
if (!ruleMap.containsKey(rule.getTarget() + ":" + rule.getSuffix())) { if (!ruleMap.containsKey(rule.getTarget().toLowerCase() + ":" + rule.getSuffix())) {
ruleMap.put(rule.getTarget() + ":" + rule.getSuffix(), rule); ruleMap.put(rule.getTarget().toLowerCase() + ":" + rule.getSuffix(), rule);
} }
} }
} }
...@@ -487,9 +488,11 @@ public class Inspector { ...@@ -487,9 +488,11 @@ public class Inspector {
private HashMap<String, List<Warn>> getWarnMap() { private HashMap<String, List<Warn>> getWarnMap() {
List<Technology> technologies = technologyDao.findAll(); List<Technology> technologies = technologyDao.findAll();
if(!CollectionUtils.isEmpty(technologies)) {
HashMap<String, Technology> techMap = new HashMap<>(); HashMap<String, Technology> techMap = new HashMap<>();
for (Technology technology : technologies) { for (Technology technology : technologies) {
if (!techMap.containsKey(technology.getId())) { if(techMap.get(technology.getId())==null){
techMap.put(technology.getId(), technology); techMap.put(technology.getId(), technology);
} }
} }
...@@ -499,11 +502,18 @@ public class Inspector { ...@@ -499,11 +502,18 @@ public class Inspector {
if (!warnMap.containsKey(warn.getTechnologyName())) { if (!warnMap.containsKey(warn.getTechnologyName())) {
ArrayList<Warn> warns1 = new ArrayList<>(); ArrayList<Warn> warns1 = new ArrayList<>();
warns1.add(warn); warns1.add(warn);
if (techMap.get(warn.getTechnologyId()).getTechnologyName() != null) {
warnMap.put(techMap.get(warn.getTechnologyId()).getTechnologyName(), warns1); warnMap.put(techMap.get(warn.getTechnologyId()).getTechnologyName(), warns1);
}
} else { } else {
if (warn.getTechnologyName() != null) {
if (warnMap.get(warn.getTechnologyName()) == null) {
warnMap.put(warn.getTechnologyName(), new ArrayList<>());
}
warnMap.get(warn.getTechnologyName()).add(warn); warnMap.get(warn.getTechnologyName()).add(warn);
} }
} }
}
for (Technology technology : technologies) { for (Technology technology : technologies) {
if (!warnMap.containsKey(technology.getTechnologyName())) { if (!warnMap.containsKey(technology.getTechnologyName())) {
ArrayList<Warn> warns1 = new ArrayList<>(); ArrayList<Warn> warns1 = new ArrayList<>();
...@@ -512,6 +522,8 @@ public class Inspector { ...@@ -512,6 +522,8 @@ public class Inspector {
} }
return warnMap; return warnMap;
} }
return null;
}
/** /**
* @param stringBuilder string缓冲区 * @param stringBuilder string缓冲区
...@@ -540,13 +552,13 @@ public class Inspector { ...@@ -540,13 +552,13 @@ public class Inspector {
rule1.setTarget(dependency.getArtifactId()); rule1.setTarget(dependency.getArtifactId());
rule1.setSuffix("*"); rule1.setSuffix("*");
rule1.setId(UUIDUtil.getUUID()); rule1.setId(UUIDUtil.getUUID());
if (!ruleMap.containsKey(dependency.getGroupId() + ":" + rule.getSuffix())) { if (!ruleMap.containsKey(dependency.getGroupId().toLowerCase() + ":" + rule.getSuffix())) {
rules.add(rule); rules.add(rule);
ruleMap.put(dependency.getGroupId() + ":" + rule.getSuffix(), rule); ruleMap.put(dependency.getGroupId().toLowerCase() + ":" + rule.getSuffix(), rule);
} }
if (!ruleMap.containsKey(dependency.getArtifactId() + ":" + rule1.getSuffix())) { if (!ruleMap.containsKey(dependency.getArtifactId().toLowerCase() + ":" + rule1.getSuffix())) {
rules.add(rule1); rules.add(rule1);
ruleMap.put(dependency.getArtifactId() + ":" + rule1.getSuffix(), rule1); ruleMap.put(dependency.getArtifactId().toLowerCase() + ":" + rule1.getSuffix(), rule1);
} }
} }
...@@ -569,7 +581,7 @@ public class Inspector { ...@@ -569,7 +581,7 @@ public class Inspector {
continue; continue;
} }
//匹配字符串 //匹配字符串
int index = KmpUtil.kmpMatch(data, rule.getTarget()); int index = KmpUtil.kmpMatch(data.toLowerCase(), rule.getTarget().toLowerCase());
//当index>0时代表data中有当前规则 //当index>0时代表data中有当前规则
if (index > -1) { if (index > -1) {
//判断当前规则是否是不支持规则 //判断当前规则是否是不支持规则
...@@ -663,7 +675,7 @@ public class Inspector { ...@@ -663,7 +675,7 @@ public class Inspector {
if (!ruleMap.containsKey(patten.toLowerCase() + ":" + rule.getSuffix())) { if (!ruleMap.containsKey(patten.toLowerCase() + ":" + rule.getSuffix())) {
rules.add(rule); rules.add(rule);
ruleMap.put(patten + ":" + rule.getSuffix(), rule); ruleMap.put(patten.toLowerCase() + ":" + rule.getSuffix(), rule);
} }
//设置当前依赖为可支持 //设置当前依赖为可支持
pomDependency.setSupport(1); pomDependency.setSupport(1);
...@@ -679,7 +691,6 @@ public class Inspector { ...@@ -679,7 +691,6 @@ public class Inspector {
try { try {
// List<String> allLines = Files.readAllLines(file); // List<String> allLines = Files.readAllLines(file);
String s = file.toAbsolutePath().toString(); String s = file.toAbsolutePath().toString();
log.info("文件路径:{}",s);
long allLines = FileUtil.readFileNumber(new File(s)); long allLines = FileUtil.readFileNumber(new File(s));
fileLine += allLines; fileLine += allLines;
} catch (Exception e) { } catch (Exception e) {
......
...@@ -18,6 +18,7 @@ import org.springframework.data.jpa.domain.Specification; ...@@ -18,6 +18,7 @@ import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -79,8 +80,11 @@ public class RuleServiceImpl implements RuleService { ...@@ -79,8 +80,11 @@ public class RuleServiceImpl implements RuleService {
if (StringUtils.isEmpty(rule.getTarget())) { if (StringUtils.isEmpty(rule.getTarget())) {
return null; return null;
} }
Rule rule1 = ruleDao.findByTarget(rule.getTarget()); if(rule.getTarget().length()<4){
if (rule1 == null) { return null;
}
List<Rule> rules = ruleDao.findByTargetIgnoreCase(rule.getTarget());
if (CollectionUtils.isEmpty(rules)) {
rule.setId(UUIDUtil.getUUID()); rule.setId(UUIDUtil.getUUID());
Rule save = ruleDao.save(rule); Rule save = ruleDao.save(rule);
return save; return save;
...@@ -95,6 +99,7 @@ public class RuleServiceImpl implements RuleService { ...@@ -95,6 +99,7 @@ public class RuleServiceImpl implements RuleService {
*/ */
@Override @Override
public void addRule(RuleQo ruleQo) { public void addRule(RuleQo ruleQo) {
if(ruleQo.getTarget().length()>3) {
List<String> suffixes = ruleQo.getSuffix(); List<String> suffixes = ruleQo.getSuffix();
for (String suffix : suffixes) { for (String suffix : suffixes) {
List<Rule> rule1 = ruleDao.findByTargetAndSuffixEqualsAndTechnologyIdEquals(ruleQo.getTarget(), suffix, ruleQo.getTechnologyId()); List<Rule> rule1 = ruleDao.findByTargetAndSuffixEqualsAndTechnologyIdEquals(ruleQo.getTarget(), suffix, ruleQo.getTechnologyId());
...@@ -111,7 +116,7 @@ public class RuleServiceImpl implements RuleService { ...@@ -111,7 +116,7 @@ public class RuleServiceImpl implements RuleService {
} }
RuleCollection ruleCollection = dataQo2RuleCollection(ruleQo); RuleCollection ruleCollection = dataQo2RuleCollection(ruleQo);
ruleCollectionDao.save(ruleCollection); ruleCollectionDao.save(ruleCollection);
}
} }
...@@ -119,14 +124,21 @@ public class RuleServiceImpl implements RuleService { ...@@ -119,14 +124,21 @@ public class RuleServiceImpl implements RuleService {
@Override @Override
public void addListRulePlus(List<Rule> rules) { public void addListRulePlus(List<Rule> rules) {
for (Rule rule : rules) { for (Rule rule : rules) {
addRulePlus(rule); addRulePlus(rule);
} }
} }
@Override @Override
public void addRule(List<Rule> rules) { public void addRule(List<Rule> rules) {
ruleDao.saveAll(rules); List<Rule> ruleList=new ArrayList<>();
List<RuleCollection> ruleCollections = dataList2RuleCollection(rules); for (Rule rule : rules) {
if(rule.getTarget().length()>3){
ruleList.add(rule);
}
}
ruleDao.saveAll(ruleList);
List<RuleCollection> ruleCollections = dataList2RuleCollection(ruleList);
ruleCollectionDao.saveAll(ruleCollections); ruleCollectionDao.saveAll(ruleCollections);
} }
...@@ -199,6 +211,7 @@ public class RuleServiceImpl implements RuleService { ...@@ -199,6 +211,7 @@ public class RuleServiceImpl implements RuleService {
@Override @Override
public void upRule(RuleQo ruleQo) { public void upRule(RuleQo ruleQo) {
if(ruleQo.getTarget().length()>3) {
RuleQo oldRule = ruleQo.getOldRule(); RuleQo oldRule = ruleQo.getOldRule();
List<Rule> rules = ruleDao.findAllByTechnologyIdEqualsAndTargetEquals(oldRule.getTechnologyId(), oldRule.getTarget()); List<Rule> rules = ruleDao.findAllByTechnologyIdEqualsAndTargetEquals(oldRule.getTechnologyId(), oldRule.getTarget());
RuleCollection ruleCollection = ruleCollectionDao.findAllByTechnologyIdEqualsAndTargetEquals(oldRule.getTechnologyId(), oldRule.getTarget()); RuleCollection ruleCollection = ruleCollectionDao.findAllByTechnologyIdEqualsAndTargetEquals(oldRule.getTechnologyId(), oldRule.getTarget());
...@@ -210,9 +223,11 @@ public class RuleServiceImpl implements RuleService { ...@@ -210,9 +223,11 @@ public class RuleServiceImpl implements RuleService {
} }
addRule(ruleQo); addRule(ruleQo);
} }
}
@Override @Override
public void upRulePlus(Rule rule) { public void upRulePlus(Rule rule) {
if(rule.getTarget().length()>3) {
Rule rule1 = ruleDao.findByTargetAndIdNot(rule.getTarget(), rule.getId()); Rule rule1 = ruleDao.findByTargetAndIdNot(rule.getTarget(), rule.getId());
if (rule1 == null) { if (rule1 == null) {
ruleDao.save(rule); ruleDao.save(rule);
...@@ -220,6 +235,7 @@ public class RuleServiceImpl implements RuleService { ...@@ -220,6 +235,7 @@ public class RuleServiceImpl implements RuleService {
ruleDao.deleteById(rule.getId()); ruleDao.deleteById(rule.getId());
} }
} }
}
@Override @Override
public void deleteRulePlus(String id) { public void deleteRulePlus(String id) {
......
...@@ -38,11 +38,9 @@ public class FileUtil { ...@@ -38,11 +38,9 @@ public class FileUtil {
while (lnr.readLine() != null){ while (lnr.readLine() != null){
linenumber++; linenumber++;
} }
log.info("Total number of lines : " + linenumber);
lnr.close(); lnr.close();
return linenumber; return linenumber;
}else{ }else{
log.info("File does not exists!"+linenumber);
return linenumber; return linenumber;
} }
}catch(IOException e){ }catch(IOException e){
......
...@@ -68,7 +68,8 @@ spring.freemarker.template-loader-path=classpath:/templates/ ...@@ -68,7 +68,8 @@ spring.freemarker.template-loader-path=classpath:/templates/
##Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09 ##Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09
#spring.redis.password= #spring.redis.password=
#宁波项目服务器ip #宁波项目服务器ip
address=120.55.57.35 #address=120.55.57.35
address=127.0.0.1
# 核心线程池大小、最大线程数、空闲活跃时间、队列容量 # 核心线程池大小、最大线程数、空闲活跃时间、队列容量
thread.pool.corePoolSize=10 thread.pool.corePoolSize=10
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论