|
|
|
@ -1,9 +1,10 @@
|
|
|
|
|
package com.xydl.cac.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.NSensor;
|
|
|
|
|
import com.xydl.cac.entity.Unit;
|
|
|
|
|
import com.xydl.cac.entity.Warning;
|
|
|
|
|
import com.xydl.cac.exception.BusinessException;
|
|
|
|
|
import com.xydl.cac.model.ConditionModel;
|
|
|
|
|
import com.xydl.cac.repository.UnitRepository;
|
|
|
|
|
import com.xydl.cac.repository.WarningRepository;
|
|
|
|
|
import com.xydl.cac.service.WarningService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -26,6 +27,8 @@ public class WarningServiceImpl implements WarningService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
WarningRepository repository;
|
|
|
|
|
@Resource
|
|
|
|
|
UnitRepository unitRepository;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Page<Warning> list(ConditionModel condition) throws Exception {
|
|
|
|
@ -48,9 +51,22 @@ public class WarningServiceImpl implements WarningService {
|
|
|
|
|
return predicate;
|
|
|
|
|
};
|
|
|
|
|
Page<Warning> result = repository.findAll(specification, request);
|
|
|
|
|
this.fillOtherNames(result.getContent());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillOtherNames(List<Warning> list) {
|
|
|
|
|
List<Unit> unitList = unitRepository.findAll();
|
|
|
|
|
for (Warning item : list) {
|
|
|
|
|
for (Unit unit : unitList) {
|
|
|
|
|
if (unit.getField().equals(item.getField())) {
|
|
|
|
|
item.setUnit(unit.getUnit());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Warning> listAll(ConditionModel condition) throws Exception {
|
|
|
|
|
Specification<Warning> specification = (root, query, builder) -> {
|
|
|
|
@ -70,7 +86,9 @@ public class WarningServiceImpl implements WarningService {
|
|
|
|
|
query.orderBy(builder.desc(root.get("warnTime")));
|
|
|
|
|
return predicate;
|
|
|
|
|
};
|
|
|
|
|
return repository.findAll(specification);
|
|
|
|
|
List<Warning> list = repository.findAll(specification);
|
|
|
|
|
this.fillOtherNames(list);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|