|
|
|
@ -6,7 +6,6 @@ import com.xydl.cac.model.ConditionModel;
|
|
|
|
|
import com.xydl.cac.model.OnePage;
|
|
|
|
|
import com.xydl.cac.model.SensorDetail;
|
|
|
|
|
import com.xydl.cac.model.SensorUpdateModel;
|
|
|
|
|
import com.xydl.cac.repository.NPointRepository;
|
|
|
|
|
import com.xydl.cac.repository.NSensorRepository;
|
|
|
|
|
import com.xydl.cac.service.*;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -20,7 +19,6 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import static com.xydl.cac.entity.constants.Constants.YaoCe;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
@ -29,8 +27,6 @@ public class NSensorServiceImpl implements NSensorService {
|
|
|
|
|
@Resource
|
|
|
|
|
NSensorRepository repository;
|
|
|
|
|
@Resource
|
|
|
|
|
NPointRepository pointRepository;
|
|
|
|
|
@Resource
|
|
|
|
|
UnitService unitService;
|
|
|
|
|
@Resource
|
|
|
|
|
DataService dataService;
|
|
|
|
@ -38,6 +34,8 @@ public class NSensorServiceImpl implements NSensorService {
|
|
|
|
|
ZsbService zsbService;
|
|
|
|
|
@Resource
|
|
|
|
|
ModevTypeService modevTypeService;
|
|
|
|
|
@Resource
|
|
|
|
|
ModevTypePointService modevTypePointService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<NSensor> listAll(Integer zsbid) throws Exception {
|
|
|
|
@ -135,18 +133,18 @@ public class NSensorServiceImpl implements NSensorService {
|
|
|
|
|
if (StringUtils.isBlank(sensor.getTableName())) {
|
|
|
|
|
throw new BusinessException("该装置类型" + sensor.getTypeName() + "缺少table_name信息");
|
|
|
|
|
}
|
|
|
|
|
List<NPoint> points = pointRepository.findBySensorIdAndType(sensor.getId(), YaoCe);
|
|
|
|
|
List<ModevTypePoint> points = modevTypePointService.listAll(sensor.getTypeId());
|
|
|
|
|
if (CollectionUtils.isEmpty(points)) {
|
|
|
|
|
throw new BusinessException("该装置缺少属性点表信息");
|
|
|
|
|
throw new BusinessException("该装置类型" + sensor.getTypeName() + "未配置属性点信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SensorDetail<Map<String, Object>> result = this.getData(sensor, points, model);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SensorDetail<Map<String, Object>> getData(NSensor sensor, List<NPoint> points, ConditionModel model) {
|
|
|
|
|
List<NPoint> pointList = new ArrayList<>();
|
|
|
|
|
for (NPoint point : points) {
|
|
|
|
|
public SensorDetail<Map<String, Object>> getData(NSensor sensor, List<ModevTypePoint> points, ConditionModel model) {
|
|
|
|
|
List<ModevTypePoint> pointList = new ArrayList<>();
|
|
|
|
|
for (ModevTypePoint point : points) {
|
|
|
|
|
if (StringUtils.isNotBlank(point.getField())) {
|
|
|
|
|
point.setUnit(unitService.findUnitInCache(point.getField()));
|
|
|
|
|
pointList.add(point);
|
|
|
|
@ -158,7 +156,7 @@ public class NSensorServiceImpl implements NSensorService {
|
|
|
|
|
OnePage<Map<String, Object>> page = dataService.getDate(sensor, pointList, model);
|
|
|
|
|
result.initFrom(page);
|
|
|
|
|
|
|
|
|
|
for (NPoint point : pointList) {
|
|
|
|
|
for (ModevTypePoint point : pointList) {
|
|
|
|
|
List<Object> dataList = new ArrayList<>();
|
|
|
|
|
for (Map<String, Object> item : result.getContent()) {
|
|
|
|
|
Object value = item.get(point.getField());
|
|
|
|
@ -181,25 +179,6 @@ public class NSensorServiceImpl implements NSensorService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void importFrom(Collection<NSensor> collection) {
|
|
|
|
|
for (NSensor item : collection) {
|
|
|
|
|
this.importOne(item);
|
|
|
|
|
|
|
|
|
|
List<NPoint> points = item.getPoints();
|
|
|
|
|
if (points != null) {
|
|
|
|
|
for (NPoint point : points) {
|
|
|
|
|
point.setSensorId(item.getId());
|
|
|
|
|
List<NPoint> plist = pointRepository.findBySensorIdAndField(item.getId(), point.getField());
|
|
|
|
|
if (!CollectionUtils.isEmpty(plist)) {
|
|
|
|
|
point.setId(plist.get(0).getId());
|
|
|
|
|
}
|
|
|
|
|
pointRepository.save(point);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void importOne(NSensor item) {
|
|
|
|
|
List<NSensor> list = repository.findBySensorCode(item.getSensorCode());
|
|
|
|
|