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

sjq修改的

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