提交 49f69a8f authored 作者: 马晨俊's avatar 马晨俊

mcj:更新规则查询数据结构

上级 d0663e41
...@@ -2,7 +2,6 @@ package com.zjty.inspect.service; ...@@ -2,7 +2,6 @@ package com.zjty.inspect.service;
import com.zjty.inspect.entity.Rule; import com.zjty.inspect.entity.Rule;
import com.zjty.inspect.entity.RuleQo; import com.zjty.inspect.entity.RuleQo;
import com.zjty.inspect.entity.RuleVo;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import java.util.List; import java.util.List;
...@@ -39,7 +38,7 @@ public interface RuleService { ...@@ -39,7 +38,7 @@ public interface RuleService {
* 查询所有规则 * 查询所有规则
* @return 规则 * @return 规则
*/ */
List<Rule> findAll(); List<RuleQo> findAll();
List<Rule> findByName(String name); List<Rule> findByName(String name);
......
package com.zjty.inspect.service.impl; package com.zjty.inspect.service.impl;
import com.zjty.inspect.dao.TechnologyDao;
import com.zjty.inspect.dao.RuleDao; import com.zjty.inspect.dao.RuleDao;
import com.zjty.inspect.entity.ExcelDataVo; import com.zjty.inspect.entity.ExcelDataVo;
import com.zjty.inspect.entity.Technology;
import com.zjty.inspect.entity.Rule; import com.zjty.inspect.entity.Rule;
import com.zjty.inspect.entity.RuleQo; import com.zjty.inspect.entity.RuleQo;
import com.zjty.inspect.service.RuleService; import com.zjty.inspect.service.RuleService;
...@@ -23,7 +21,6 @@ import javax.persistence.criteria.CriteriaQuery; ...@@ -23,7 +21,6 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 规则库 * 规则库
...@@ -154,12 +151,41 @@ public class RuleServiceImpl implements RuleService { ...@@ -154,12 +151,41 @@ public class RuleServiceImpl implements RuleService {
/** /**
* 查询所有规则 * 查询所有规则
* 规则唯一 关键字+后缀+技术id
* target:xx,suffix:js:tech:gjfgj
* target:xx,suffix:html:tech:gjfgj
* target:xx,suffix:css:tech:gjfgj
* *
* target:xx,suffix:html,css,js:tech:gjfgj
* @return RuleVoList * @return RuleVoList
*/ */
@Override @Override
public List<Rule> findAll() { public List<RuleQo> findAll() {
return ruleDao.findAll(); HashMap<String, RuleQo> hashMap = new HashMap<>();
ArrayList<Rule> list = new ArrayList<>();
List<Rule> rules = ruleDao.findAll();
for (Rule rule : rules) {
if(!hashMap.containsKey(rule.getTarget()+rule.getTechnologyId())){
RuleQo ruleQo = new RuleQo();
ruleQo.setId(rule.getId());
ruleQo.setTarget(rule.getTarget());
ruleQo.setTechnologyId(rule.getTechnologyId());
ruleQo.setTechnologyName(rule.getTechnologyName());
ArrayList<String> suffix = new ArrayList<>();
suffix.add(rule.getSuffix());
ruleQo.setSuffix(suffix);
hashMap.put(rule.getTarget()+rule.getTechnologyId(),ruleQo);
}else{
RuleQo ruleQo = hashMap.get(rule.getTarget() + rule.getTechnologyId());
ruleQo.getSuffix().add(rule.getSuffix());
if(ruleQo.getSuffix().size()>1){
System.out.println(rule.getTarget()+rule.getTechnologyId());
System.out.println(ruleQo.getSuffix());
}
}
}
return new ArrayList<>(hashMap.values());
} }
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论