feat:监测设备查询全部增加typeId

dev
郭承 8 months ago
parent a86f937481
commit a3f0ebb5be

@ -62,8 +62,9 @@ public class NSensorController extends BasicController {
@GetMapping("listAll")
@ApiOperation("查询全部")
public Response<List<NSensor>> listAll(@ApiParam("主设备id") @RequestParam(value = "zsbid", required = false) Integer zsbid) throws Exception {
List<NSensor> result = service.listAll(zsbid);
public Response<List<NSensor>> listAll(@ApiParam("主设备id") @RequestParam(value = "zsbid", required = false) Integer zsbid,
@ApiParam("类型") @RequestParam(value = "typeId", required = false) Integer typeId) throws Exception {
List<NSensor> result = service.listAll(zsbid , typeId);
return Response.success(result);
}
@ -190,7 +191,7 @@ public class NSensorController extends BasicController {
public void exportLatest(@ApiParam("主设备id") @RequestParam(value = "zsbid", required = false) Integer zsbid, HttpServletResponse response) throws Exception {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
List<NSensor> result = service.listAll(zsbid);
List<NSensor> result = service.listAll(zsbid , null);
Map<Integer, List<NSensor>> map = new HashMap<>();
for (NSensor nSensor : result) {

@ -11,7 +11,7 @@ import java.util.List;
import java.util.Map;
public interface NSensorService {
List<NSensor> listAll(Integer zsbid) throws Exception;
List<NSensor> listAll(Integer zsbid, Integer typeId) throws Exception;
Page<NSensor> list(Integer typeId, int pageNum, int pageSize) throws Exception;

@ -51,13 +51,18 @@ public class NSensorServiceImpl implements NSensorService {
I2relationRepository i2relationRepository;
@Override
public List<NSensor> listAll(Integer zsbid) throws Exception {
List<NSensor> list;
if (zsbid == null) {
list = repository.findAll();
} else {
list = repository.findByZsbId(zsbid);
}
public List<NSensor> listAll(Integer zsbid, Integer typeId) throws Exception {
Specification<NSensor> specification = (root, query, builder) -> {
Predicate predicate = builder.conjunction();
if (zsbid != null) {
predicate.getExpressions().add(builder.equal(root.get("zsbId"), zsbid));
}
if (typeId != null) {
predicate.getExpressions().add(builder.equal(root.get("typeId"), typeId));
}
return predicate;
};
List<NSensor> list = repository.findAll(specification);
this.fillOtherNames(list);
return list;
}

Loading…
Cancel
Save