|
|
@@ -5,7 +5,9 @@ import com.zhongshu.iot.client.model.iot.IotTemplate2DeviceSearch;
|
|
|
import com.zhongshu.iot.server.core.dao.base.BaseImpl;
|
|
|
import com.zhongshu.iot.server.core.dao.iot.extend.IotTemplate2DeviceDaoExtend;
|
|
|
import com.zhongshu.iot.server.core.domain.iot.IotTemplate2Device;
|
|
|
+import com.zhongshu.iot.server.core.util.CommonUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
@@ -18,7 +20,6 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* @Author TRX
|
|
|
@@ -38,8 +39,15 @@ public class IotTemplate2DeviceDaoImpl extends BaseImpl implements IotTemplate2D
|
|
|
public Page<IotTemplate2Device> page(Pageable pageable, IotTemplate2DeviceSearch param) {
|
|
|
Criteria criteria = buildCriteriaAboutTime(param);
|
|
|
|
|
|
+ if (param.getIsMustDeviceIds() != null && param.getIsMustDeviceIds()) {
|
|
|
+ if (ObjectUtils.isEmpty(param.getMustDeviceIds())) {
|
|
|
+ return CommonUtil.buildEmptyPage(pageable, IotTemplate2Device.class);
|
|
|
+ }
|
|
|
+ criteria.and("deviceId").in(param.getMustDeviceIds());
|
|
|
+ }
|
|
|
+
|
|
|
if (StringUtils.isNotEmpty(param.getIotTemplateId())) {
|
|
|
- criteria.and("iotTemplateId").is(param.getIotTemplateId());
|
|
|
+ criteria.and("templateId").is(param.getIotTemplateId());
|
|
|
}
|
|
|
|
|
|
if (param.getDeviceType() != null) {
|
|
|
@@ -48,24 +56,9 @@ public class IotTemplate2DeviceDaoImpl extends BaseImpl implements IotTemplate2D
|
|
|
|
|
|
// 模糊搜索
|
|
|
List<Criteria> criterias = new ArrayList<>();
|
|
|
- if (StringUtils.isNotEmpty(param.getDeviceId())) {
|
|
|
- Pattern pattern = Pattern.compile("^.*" + param.getDeviceId() + ".*$");
|
|
|
- criterias.add(Criteria.where("deviceId").is(pattern));
|
|
|
- }
|
|
|
if (!CollectionUtils.isEmpty(criterias)) {
|
|
|
criteria.andOperator(criterias.toArray(new Criteria[]{}));
|
|
|
}
|
|
|
-
|
|
|
- // 关键字搜索
|
|
|
-// if (StringUtils.isNotEmpty(param.getKeyWord())) {
|
|
|
-// Pattern pattern = Pattern.compile("^.*" + param.getKeyWord() + ".*$");
|
|
|
-// criteria.orOperator(
|
|
|
-// Criteria.where("name").regex(pattern),
|
|
|
-// Criteria.where("identifier").regex(pattern),
|
|
|
-// Criteria.where("iotTopic").regex(pattern)
|
|
|
-// );
|
|
|
-// }
|
|
|
-
|
|
|
Sort sort = buildSort(param);
|
|
|
Query query = Query.query(criteria);
|
|
|
query.with(sort);
|