|
@@ -10,6 +10,11 @@ import com.usky.common.core.bean.CommonPage;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
|
+import com.usky.demo.RemoteTsdbProxyService;
|
|
|
+import com.usky.demo.domain.DataTypeEnum;
|
|
|
+import com.usky.demo.domain.Fields;
|
|
|
+import com.usky.demo.domain.FieldsVO;
|
|
|
+import com.usky.demo.domain.SuperTableDTO;
|
|
|
import com.usky.iot.domain.DmpProductAttribute;
|
|
|
import com.usky.iot.domain.DmpProductInfo;
|
|
|
import com.usky.iot.mapper.DmpProductAttributeMapper;
|
|
@@ -19,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.rmi.Remote;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
@@ -34,7 +40,10 @@ import java.util.Optional;
|
|
|
*/
|
|
|
@Service
|
|
|
public class DmpProductAttributeServiceImpl extends AbstractCrudService<DmpProductAttributeMapper, DmpProductAttribute> implements DmpProductAttributeService {
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private RemoteTsdbProxyService remoteTsdbProxyService;
|
|
|
+ @Autowired
|
|
|
+ private DmpProductAttributeMapper dmpProductAttributeMapper;
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
@@ -47,6 +56,26 @@ public class DmpProductAttributeServiceImpl extends AbstractCrudService<DmpProdu
|
|
|
dmpProductAttribute.setCreatedTime(new Date());
|
|
|
dmpProductAttribute.setTenantId(SecurityUtils.getTenantId());
|
|
|
this.save(dmpProductAttribute);
|
|
|
+
|
|
|
+ SuperTableDTO superTableDTO = new SuperTableDTO();
|
|
|
+ String superTableName = "super_"+dmpProductAttributeMapper.getSuperTableName(dmpProductAttribute.getProductId());
|
|
|
+ superTableDTO.setSuperTableName(superTableName);
|
|
|
+
|
|
|
+ int data_type = dmpProductAttribute.getDataType();
|
|
|
+ String dataType = "";
|
|
|
+ if(data_type == 1){
|
|
|
+ dataType = "INT";
|
|
|
+ }else if(data_type == 2){
|
|
|
+ dataType = "VARCHAR";
|
|
|
+ }else if(data_type == 3){
|
|
|
+ dataType = "BOOL";
|
|
|
+ }else if(data_type == 4) {
|
|
|
+ dataType = "DOUBLE";
|
|
|
+ }
|
|
|
+ FieldsVO fieldsVO = new FieldsVO(dmpProductAttribute.getAttributeCode(), dataType, dmpProductAttribute.getAttributeLength());
|
|
|
+ superTableDTO.setFields(FieldsVO.toFields(fieldsVO));
|
|
|
+ //超级表新增字段
|
|
|
+ remoteTsdbProxyService.addSuperTableColumn(superTableDTO);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -58,6 +87,28 @@ public class DmpProductAttributeServiceImpl extends AbstractCrudService<DmpProdu
|
|
|
throw new BusinessException("新增产品属性信息'" + dmpProductAttribute.getAttributeName() + "'失败,产品信息已存在");
|
|
|
}
|
|
|
this.updateById(dmpProductAttribute);
|
|
|
+
|
|
|
+ SuperTableDTO superTableDTO = new SuperTableDTO();
|
|
|
+ String superTableName = "super_"+dmpProductAttributeMapper.getSuperTableName(dmpProductAttribute.getProductId());
|
|
|
+ superTableDTO.setSuperTableName(superTableName);
|
|
|
+
|
|
|
+ int data_type = dmpProductAttribute.getDataType();
|
|
|
+ String dataType = "";
|
|
|
+ if(data_type == 1){
|
|
|
+ dataType = "INT";
|
|
|
+ }else if(data_type == 2){
|
|
|
+ dataType = "VARCHAR";
|
|
|
+ }else if(data_type == 3){
|
|
|
+ dataType = "BOOL";
|
|
|
+ }else if(data_type == 4) {
|
|
|
+ dataType = "DOUBLE";
|
|
|
+ }
|
|
|
+ FieldsVO fieldsVO = new FieldsVO(dmpProductAttribute.getAttributeCode(), dataType, dmpProductAttribute.getAttributeLength());
|
|
|
+ superTableDTO.setFields(FieldsVO.toFields(fieldsVO));
|
|
|
+ //超级表删除字段
|
|
|
+ remoteTsdbProxyService.dropSuperTableColumn(superTableDTO);
|
|
|
+ //超级表新增字段
|
|
|
+ remoteTsdbProxyService.addSuperTableColumn(superTableDTO);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -89,6 +140,16 @@ public class DmpProductAttributeServiceImpl extends AbstractCrudService<DmpProdu
|
|
|
DmpProductAttribute dmpProductAttribute = this.getById(id);
|
|
|
Optional.ofNullable(dmpProductAttribute).orElseThrow(() -> new BusinessException("产品不存在"));
|
|
|
dmpProductAttribute.setDeleteFlag(1);
|
|
|
+
|
|
|
+ SuperTableDTO superTableDTO = new SuperTableDTO();
|
|
|
+ String superTableName = "super_"+dmpProductAttributeMapper.getSuperTableName(dmpProductAttribute.getProductId());
|
|
|
+ superTableDTO.setSuperTableName(superTableName);
|
|
|
+
|
|
|
+ FieldsVO fieldsVO = new FieldsVO(dmpProductAttribute.getAttributeCode(), "", dmpProductAttribute.getAttributeLength());
|
|
|
+ superTableDTO.setFields(FieldsVO.toFields(fieldsVO));
|
|
|
+ //超级表删除字段
|
|
|
+ remoteTsdbProxyService.dropSuperTableColumn(superTableDTO);
|
|
|
+
|
|
|
return this.updateById(dmpProductAttribute);
|
|
|
}
|
|
|
|