|
|
|
@ -14,11 +14,13 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -59,6 +61,7 @@ public class NSensorServiceImpl implements NSensorService {
|
|
|
|
|
for (Zsb zsb : zsbList) {
|
|
|
|
|
if (zsb.getId().equals(sensor.getZsbId())) {
|
|
|
|
|
sensor.setZsbName(zsb.getMc());
|
|
|
|
|
sensor.setJgName(zsb.getJgName());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -78,13 +81,21 @@ public class NSensorServiceImpl implements NSensorService {
|
|
|
|
|
sensor.setTypeName(modevType.getMc());
|
|
|
|
|
Zsb zsb = zsbService.detail(sensor.getZsbId());
|
|
|
|
|
sensor.setZsbName(zsb.getMc());
|
|
|
|
|
sensor.setJgName(zsb.getJgName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Page<NSensor> list(int pageNum, int pageSize) throws Exception {
|
|
|
|
|
public Page<NSensor> list(Integer typeId, int pageNum, int pageSize) throws Exception {
|
|
|
|
|
PageRequest request = PageRequest.of(pageNum, pageSize);
|
|
|
|
|
Page<NSensor> result = repository.findAll(request);
|
|
|
|
|
Specification<NSensor> specification = (root, query, builder) -> {
|
|
|
|
|
Predicate predicate = builder.conjunction();
|
|
|
|
|
if (typeId != null) {
|
|
|
|
|
predicate.getExpressions().add(builder.equal(root.get("typeId"), typeId));
|
|
|
|
|
}
|
|
|
|
|
return predicate;
|
|
|
|
|
};
|
|
|
|
|
Page<NSensor> result = repository.findAll(specification, request);
|
|
|
|
|
this.fillOtherNames(result.getContent());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|