|
|
|
@ -25,6 +25,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@ -287,6 +288,7 @@ public class NSensorServiceImpl implements NSensorService {
|
|
|
|
|
int success = 0;
|
|
|
|
|
int skip = 0;
|
|
|
|
|
List<Modev> list = modevRepository.findAll();
|
|
|
|
|
List<String> warnList = new ArrayList<>();
|
|
|
|
|
for (Modev item : list) {
|
|
|
|
|
NSensor sensor = item.transform();
|
|
|
|
|
List<I2relation> i2relations = i2relationRepository.findByEqmid(item.getId());
|
|
|
|
@ -295,16 +297,26 @@ public class NSensorServiceImpl implements NSensorService {
|
|
|
|
|
sensor.setEquipmentId(i2relation.getEquipmentid());
|
|
|
|
|
sensor.setSensorCode(i2relation.getSensorid());
|
|
|
|
|
sensor.setPhase(i2relation.getPhase());
|
|
|
|
|
if (i2relations.size() > 1) {
|
|
|
|
|
String str = "eqmid=" + item.getId() + "的I2relation数据存在多条,需要人工再次校对编号和相位";
|
|
|
|
|
warnList.add(str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<NSensor> slist = repository.findByDevId(sensor.getDevId());
|
|
|
|
|
if (CollectionUtils.isEmpty(slist)) {
|
|
|
|
|
this.add(sensor);
|
|
|
|
|
success++;
|
|
|
|
|
} else {
|
|
|
|
|
String str = "eqmid=" + item.getId() + "的已存在跳过";
|
|
|
|
|
warnList.add(str);
|
|
|
|
|
skip++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "成功导入" + success + "个,跳过" + skip + "个";
|
|
|
|
|
String str = "成功导入" + success + "个,跳过" + skip + "个。";
|
|
|
|
|
if (warnList.size() > 0) {
|
|
|
|
|
str = str + warnList.stream().collect(Collectors.joining(";"));
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|