|
|
|
@ -1,9 +1,7 @@
|
|
|
|
|
package com.xydl.cac.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.IcdFileConfig;
|
|
|
|
|
import com.xydl.cac.entity.IcdFileConfigInst;
|
|
|
|
|
import com.xydl.cac.repository.IcdFileConfigInstRepository;
|
|
|
|
|
import com.xydl.cac.repository.IcdFileConfigRepository;
|
|
|
|
|
import com.xydl.cac.entity.*;
|
|
|
|
|
import com.xydl.cac.repository.*;
|
|
|
|
|
import com.xydl.cac.service.IcdFileConfigService;
|
|
|
|
|
import com.xydl.cac.util.IcdXmlUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -17,6 +15,7 @@ import javax.annotation.Resource;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
@ -24,60 +23,93 @@ import java.util.List;
|
|
|
|
|
public class IcdFileConfigServiceImpl implements IcdFileConfigService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IcdFileConfigRepository repository;
|
|
|
|
|
IcdConfigTypeRepository repository;
|
|
|
|
|
@Resource
|
|
|
|
|
IcdFileConfigInstRepository instRepository;
|
|
|
|
|
IcdConfigTypeAttRepository attRepository;
|
|
|
|
|
@Resource
|
|
|
|
|
IcdConfigTypeInstRepository instRepository;
|
|
|
|
|
@Resource
|
|
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void upload(String xml) throws Exception {
|
|
|
|
|
LinkedHashMap<String, IcdFileConfig> result = IcdXmlUtil.loadIcdType(xml);
|
|
|
|
|
Collection<IcdFileConfig> configList = result.values();
|
|
|
|
|
for (IcdFileConfig config : configList) {
|
|
|
|
|
List<IcdFileConfig> list = repository.findByIedNameAndLdeviceInstAndLnClassAndDoName(
|
|
|
|
|
config.getIedName(), config.getLdeviceInst(), config.getLnClass(), config.getDoName());
|
|
|
|
|
LinkedHashMap<String, IcdConfigType> result = IcdXmlUtil.loadIcdType(xml);
|
|
|
|
|
Collection<IcdConfigType> configList = result.values();
|
|
|
|
|
for (IcdConfigType config : configList) {
|
|
|
|
|
List<IcdConfigType> list = repository.findByIedNameAndLdeviceInstAndLnClass(
|
|
|
|
|
config.getIedName(), config.getLdeviceInst(), config.getLnClass());
|
|
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
repository.save(config);
|
|
|
|
|
List<IcdFileConfigInst> instList = config.getInstList();
|
|
|
|
|
for (IcdFileConfigInst item : instList) {
|
|
|
|
|
item.setConfigId(config.getId());
|
|
|
|
|
|
|
|
|
|
if (config.getAttMap() != null) {
|
|
|
|
|
Collection<IcdConfigTypeAtt> attList = config.getAttMap().values();
|
|
|
|
|
for (IcdConfigTypeAtt item : attList) {
|
|
|
|
|
item.setIcdConfigTypeId(config.getId());
|
|
|
|
|
}
|
|
|
|
|
attRepository.saveAll(attList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.getInstMap() != null) {
|
|
|
|
|
Collection<IcdConfigTypeInst> instList = config.getInstMap().values();
|
|
|
|
|
for (IcdConfigTypeInst item : instList) {
|
|
|
|
|
item.setIcdConfigTypeId(config.getId());
|
|
|
|
|
}
|
|
|
|
|
instRepository.saveAll(instList);
|
|
|
|
|
}
|
|
|
|
|
instRepository.saveAll(instList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> iedList() {
|
|
|
|
|
String sql = "SELECT DISTINCT ied_name FROM icd_file_config";
|
|
|
|
|
String sql = "SELECT DISTINCT ied_name FROM icd_config_type";
|
|
|
|
|
List<String> list = jdbcTemplate.queryForList(sql, String.class);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<IcdFileConfig> list(String iedName) throws Exception {
|
|
|
|
|
List<IcdFileConfig> result;
|
|
|
|
|
public List<IcdConfigType> list(String iedName) throws Exception {
|
|
|
|
|
List<IcdConfigType> result;
|
|
|
|
|
if (StringUtils.isNotBlank(iedName)) {
|
|
|
|
|
result = repository.findByIedName(iedName);
|
|
|
|
|
} else {
|
|
|
|
|
result = repository.findAll();
|
|
|
|
|
}
|
|
|
|
|
for (IcdFileConfig item : result) {
|
|
|
|
|
List<IcdFileConfigInst> list = instRepository.findByConfigId(item.getId());
|
|
|
|
|
item.setInstList(list);
|
|
|
|
|
for (IcdConfigType item : result) {
|
|
|
|
|
List<IcdConfigTypeAtt> atts = attRepository.findByIcdConfigTypeId(item.getId());
|
|
|
|
|
item.setAttList(atts);
|
|
|
|
|
List<IcdConfigTypeInst> insts = instRepository.findByIcdConfigTypeId(item.getId());
|
|
|
|
|
item.setInstList(insts);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void update(IcdFileConfig item) {
|
|
|
|
|
repository.save(item);
|
|
|
|
|
public void update(IcdConfigType item) throws Exception {
|
|
|
|
|
Optional<IcdConfigType> optional = repository.findById(item.getId());
|
|
|
|
|
if (!optional.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该项");
|
|
|
|
|
}
|
|
|
|
|
IcdConfigType r = optional.get();
|
|
|
|
|
r.setTableName(item.getTableName());
|
|
|
|
|
repository.save(r);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateAtt(IcdConfigTypeAtt item) throws Exception {
|
|
|
|
|
Optional<IcdConfigTypeAtt> optional = attRepository.findById(item.getId());
|
|
|
|
|
if (!optional.isPresent()) {
|
|
|
|
|
throw new Exception("未找到该项");
|
|
|
|
|
}
|
|
|
|
|
IcdConfigTypeAtt r = optional.get();
|
|
|
|
|
r.setColName(item.getColName());
|
|
|
|
|
attRepository.save(r);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void delete(Integer id) {
|
|
|
|
|
instRepository.deleteByConfigId(id);
|
|
|
|
|
instRepository.deleteByIcdConfigTypeId(id);
|
|
|
|
|
attRepository.deleteByIcdConfigTypeId(id);
|
|
|
|
|
repository.deleteById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|