|
|
@@ -13,6 +13,7 @@ import com.middle.platform.manage.api.pojo.TopicVo;
|
|
|
import com.middle.platform.manage.biz.constant.Constant;
|
|
|
import com.middle.platform.manage.biz.constant.UrlTypeEnum;
|
|
|
import com.middle.platform.manage.biz.domain.req.IotProductPara;
|
|
|
+import com.middle.platform.manage.biz.domain.req.IotProductUpdate;
|
|
|
import com.middle.platform.manage.biz.domain.req.ProductPage;
|
|
|
import com.middle.platform.manage.biz.domain.vo.IotProductDetailVo;
|
|
|
import com.middle.platform.manage.biz.domain.vo.IotProductVo;
|
|
|
@@ -70,7 +71,7 @@ public class IotProductService {
|
|
|
iotProductVos.forEach(u -> {
|
|
|
Optional.ofNullable(userApi.queryUser(u.getCreateBy())).ifPresent(userCache -> u.setCreateByLabel(userCache.getName()));
|
|
|
Optional.ofNullable(userApi.queryUser(u.getUpdateBy())).ifPresent(userCache -> u.setUpdateByLabel(userCache.getName()));
|
|
|
- Optional.ofNullable(dictApi.query(DictType.NODE_TYPE, String.valueOf(u.getNodeType()))).ifPresent(cache -> u.setNodeTypeLabel(cache.getLabel()));
|
|
|
+ Optional.ofNullable(dictApi.query(DictType.NODE_TYPE, u.getNodeType())).ifPresent(cache -> u.setNodeTypeLabel(cache.getLabel()));
|
|
|
});
|
|
|
return new PageRes<>(pageInfo, iotProductVos);
|
|
|
}
|
|
|
@@ -84,7 +85,7 @@ public class IotProductService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Object save(IotProductPara iotProductPara) {
|
|
|
IotProduct iotProduct = new IotProduct();
|
|
|
- iotProduct.setCode(OrderUtil.get(Constant.PRODUCT_PREFIX + String.format("%02d", iotProductPara.getNodeType())));
|
|
|
+ iotProduct.setCode(OrderUtil.get(Constant.PRODUCT_PREFIX + String.format("%02d", Integer.valueOf(iotProductPara.getNodeType()))));
|
|
|
iotProduct.setName(iotProductPara.getName());
|
|
|
iotProduct.setSecret(IdUtil.nanoId());
|
|
|
iotProduct.setNodeType(iotProductPara.getNodeType());
|
|
|
@@ -101,7 +102,32 @@ public class IotProductService {
|
|
|
iotUrlService.save(iotProduct);
|
|
|
/*创建产品*/
|
|
|
tdApi.createProduct(iotProduct.getCode());
|
|
|
- return null;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增产品
|
|
|
+ *
|
|
|
+ * @param iotProductPara
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Object update(IotProductUpdate iotProductPara) {
|
|
|
+ if (Objects.isNull(iotProductPara.getId())) {
|
|
|
+ throw new BusinessException("id不能为空");
|
|
|
+ }
|
|
|
+ IotProduct iotProduct = new IotProduct();
|
|
|
+ iotProduct.setId(iotProductPara.getId());
|
|
|
+ iotProduct.setName(iotProductPara.getName());
|
|
|
+ iotProduct.setNodeType(iotProductPara.getNodeType());
|
|
|
+ iotProduct.setNetworkType(iotProductPara.getNetworkType());
|
|
|
+ iotProduct.setVendors(iotProductPara.getVendors());
|
|
|
+ iotProduct.setAuthType(iotProductPara.getAuthType());
|
|
|
+ iotProduct.setTag(iotProductPara.getTag());
|
|
|
+ iotProduct.setSize(0);
|
|
|
+ iotProduct.setRemark(iotProductPara.getRemark());
|
|
|
+ iotProductMapper.updateById(iotProduct);
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -146,12 +172,12 @@ public class IotProductService {
|
|
|
}
|
|
|
IotProductDetailVo iotProductDetailVo = new IotProductDetailVo();
|
|
|
BeanUtils.copyProperties(iotProduct, iotProductDetailVo);
|
|
|
- Optional.ofNullable(dictApi.query(DictType.AUTH_TYPE, String.valueOf(iotProductDetailVo.getAuthType()))).ifPresent(cache -> iotProductDetailVo.setAuthTypeLabel(cache.getLabel()));
|
|
|
- Optional.ofNullable(dictApi.query(DictType.NODE_TYPE, String.valueOf(iotProductDetailVo.getNodeType()))).ifPresent(cache -> iotProductDetailVo.setNodeTypeLabel(cache.getLabel()));
|
|
|
- Optional.ofNullable(dictApi.query(DictType.NETWORK_TYPE, String.valueOf(iotProductDetailVo.getNetworkType()))).ifPresent(cache -> iotProductDetailVo.setNetworkTypeLabel(cache.getLabel()));
|
|
|
- Optional.ofNullable(dictApi.query(DictType.REPORT_PROTOCOL_TYPE, String.valueOf(iotProductDetailVo.getReportProtocol()))).ifPresent(cache -> iotProductDetailVo.setReportProtocolLabel(cache.getLabel()));
|
|
|
- Optional.ofNullable(dictApi.query(DictType.VENDORS_TYPE, String.valueOf(iotProductDetailVo.getVendors()))).ifPresent(cache -> iotProductDetailVo.setVendorsLabel(cache.getLabel()));
|
|
|
- Optional.ofNullable(dictApi.query(DictType.DATA_FORMAT_TYPE, String.valueOf(iotProductDetailVo.getDataFormat()))).ifPresent(cache -> iotProductDetailVo.setDataFormatLabel(cache.getLabel()));
|
|
|
+ Optional.ofNullable(dictApi.query(DictType.AUTH_TYPE, iotProductDetailVo.getAuthType())).ifPresent(cache -> iotProductDetailVo.setAuthTypeLabel(cache.getLabel()));
|
|
|
+ Optional.ofNullable(dictApi.query(DictType.NODE_TYPE, iotProductDetailVo.getNodeType())).ifPresent(cache -> iotProductDetailVo.setNodeTypeLabel(cache.getLabel()));
|
|
|
+ Optional.ofNullable(dictApi.query(DictType.NETWORK_TYPE, iotProductDetailVo.getNetworkType())).ifPresent(cache -> iotProductDetailVo.setNetworkTypeLabel(cache.getLabel()));
|
|
|
+ Optional.ofNullable(dictApi.query(DictType.REPORT_PROTOCOL_TYPE, iotProductDetailVo.getReportProtocol())).ifPresent(cache -> iotProductDetailVo.setReportProtocolLabel(cache.getLabel()));
|
|
|
+ Optional.ofNullable(dictApi.query(DictType.VENDORS_TYPE, iotProductDetailVo.getVendors())).ifPresent(cache -> iotProductDetailVo.setVendorsLabel(cache.getLabel()));
|
|
|
+ Optional.ofNullable(dictApi.query(DictType.DATA_FORMAT_TYPE, iotProductDetailVo.getDataFormat())).ifPresent(cache -> iotProductDetailVo.setDataFormatLabel(cache.getLabel()));
|
|
|
Optional.ofNullable(userApi.queryUser(iotProductDetailVo.getCreateBy())).ifPresent(userCache -> iotProductDetailVo.setCreateByLabel(userCache.getName()));
|
|
|
Optional.ofNullable(userApi.queryUser(iotProductDetailVo.getUpdateBy())).ifPresent(userCache -> iotProductDetailVo.setUpdateByLabel(userCache.getName()));
|
|
|
return iotProductDetailVo;
|