This commit is contained in:
parent
27bb19742a
commit
4a2135d733
|
|
@ -88,7 +88,11 @@ public abstract class AbstractElasticSearchIndexStrategy implements ElasticSearc
|
|||
|
||||
public CreateIndexRequest createIndexRequest(ElasticSearchIndexMetadata metadata) {
|
||||
CreateIndexRequest request = new CreateIndexRequest(wrapIndex(metadata.getIndex()));
|
||||
request.mapping(Collections.singletonMap("properties", createElasticProperties(metadata.getProperties())));
|
||||
request.settings(properties.toSettings());
|
||||
Map<String, Object> mappingConfig = new HashMap<>();
|
||||
mappingConfig.put("properties", createElasticProperties(metadata.getProperties()));
|
||||
mappingConfig.put("dynamic_templates", createDynamicTemplates());
|
||||
request.mapping(mappingConfig);
|
||||
return request;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -329,12 +329,7 @@ class VertxMqttConnection implements MqttConnection {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" +
|
||||
"topic=" + getTopic() +
|
||||
",messageId=" + getMessageId() +
|
||||
",qos=" + getQosLevel() +
|
||||
",payload=" + message.payload().toString(StandardCharsets.UTF_8) +
|
||||
'}';
|
||||
return print();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import reactor.core.publisher.Mono;
|
|||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Index;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.sql.JDBCType;
|
||||
|
|
@ -25,7 +26,9 @@ import java.util.Map;
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(name = "dev_device_instance")
|
||||
@Table(name = "dev_device_instance", indexes = {
|
||||
@Index(name = "idx_dev_product_id", columnList = "product_id"),
|
||||
})
|
||||
public class DeviceInstanceEntity extends GenericEntity<String> implements RecordCreationEntity {
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class DeviceDetail {
|
|||
private String metadata;
|
||||
|
||||
//设备配置信息
|
||||
private Map<String, Object> configuration;
|
||||
private Map<String, Object> configuration = new HashMap<>();
|
||||
|
||||
//标签
|
||||
private List<DeviceTagEntity> tags = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -1,17 +1,12 @@
|
|||
package org.jetlinks.community.device.service.term;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.hswebframework.ezorm.core.param.Term;
|
||||
import org.hswebframework.ezorm.rdb.metadata.RDBColumnMetadata;
|
||||
import org.hswebframework.ezorm.rdb.operator.builder.fragments.EmptySqlFragments;
|
||||
import org.hswebframework.ezorm.rdb.operator.builder.fragments.PrepareSqlFragments;
|
||||
import org.hswebframework.ezorm.rdb.operator.builder.fragments.SqlFragments;
|
||||
import org.hswebframework.ezorm.rdb.operator.builder.fragments.term.AbstractTermFragmentBuilder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* where("id$dev-tag$location","重庆")
|
||||
*/
|
||||
|
|
@ -21,30 +16,41 @@ public class DeviceTagTerm extends AbstractTermFragmentBuilder {
|
|||
super("dev-tag", "根据设备标签查询设备");
|
||||
}
|
||||
|
||||
|
||||
private void acceptTerm(PrepareSqlFragments fragments, String terms) {
|
||||
//json
|
||||
if (terms.startsWith("[")) {
|
||||
//
|
||||
}
|
||||
String[] tags = terms.split("[,]");
|
||||
int len = 0;
|
||||
fragments.addSql("and (");
|
||||
|
||||
for (String tag : tags) {
|
||||
String[] kv = tag.split("[:]");
|
||||
if (kv.length != 2) {
|
||||
continue;
|
||||
}
|
||||
if (len++ > 0) {
|
||||
fragments.addSql("or");
|
||||
}
|
||||
fragments.addSql("(d.key = ? and d.value like ?)").addParameter(kv[0], kv[1]);
|
||||
}
|
||||
fragments.addSql(")");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlFragments createFragments(String columnFullName, RDBColumnMetadata column, Term term) {
|
||||
List<Object> values = convertList(column, term);
|
||||
if (values.isEmpty()) {
|
||||
return EmptySqlFragments.INSTANCE;
|
||||
}
|
||||
String val = String.valueOf(term.getValue());
|
||||
|
||||
PrepareSqlFragments fragments = PrepareSqlFragments.of();
|
||||
|
||||
List<String> opts = term.getOptions();
|
||||
fragments.addSql("exists(select 1 from dev_device_tags d where d.device_id =", columnFullName);
|
||||
|
||||
fragments.addSql("exists(select 1 from dev_device_tags d where d.device_id = ", columnFullName);
|
||||
acceptTerm(fragments,val);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(opts)) {
|
||||
fragments.addSql("and d.key=?").addParameter(opts.get(0));
|
||||
}
|
||||
if (values.size() == 1) {
|
||||
fragments.addSql("and d.value like ?)")
|
||||
.addParameter(values);
|
||||
} else {
|
||||
fragments.addSql("and d.value in(",
|
||||
values.stream().map(r -> "?").collect(Collectors.joining(",")), "))")
|
||||
.addParameter(values);
|
||||
}
|
||||
fragments.addSql(")");
|
||||
|
||||
return fragments;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -357,7 +357,7 @@ public class DeviceInstanceController implements
|
|||
DeviceInstanceEntity entity = FastBeanCopier.copy(info, new DeviceInstanceEntity());
|
||||
entity.setProductId(productId);
|
||||
if (StringUtils.isEmpty(entity.getId())) {
|
||||
throw new BusinessException("设备ID不能为空");
|
||||
throw new BusinessException("第" + info.getRowNumber() + 1 + "行:设备ID不能为空");
|
||||
}
|
||||
return Tuples.of(entity, info.getTags());
|
||||
})
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ public class DeviceExcelInfo {
|
|||
|
||||
private List<DeviceTagEntity> tags = new ArrayList<>();
|
||||
|
||||
private long rowNumber;
|
||||
|
||||
|
||||
public void tag(String key, String name, Object value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ public class DeviceWrapper extends RowWrapper<DeviceExcelInfo> {
|
|||
} else {
|
||||
deviceExcelInfo.with(headerMapping.getOrDefault(headerText, headerText), cell.value().orElse(null));
|
||||
}
|
||||
deviceExcelInfo.setRowNumber(cell.getRowIndex());
|
||||
|
||||
return deviceExcelInfo;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue