You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
5.3 KiB
94 lines
5.3 KiB
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\common\AepSdk\Apis\Aep_product_management;
|
|
use think\Db;
|
|
use think\Exception;
|
|
use think\db\exception\DataNotFoundException;
|
|
use think\db\exception\ModelNotFoundException;
|
|
use think\exception\DbException;
|
|
|
|
class Product extends Base
|
|
{
|
|
|
|
/**
|
|
* 获取产品信息列表
|
|
* @return false|string
|
|
* @throws DataNotFoundException
|
|
* @throws DbException
|
|
* @throws ModelNotFoundException
|
|
* @throws Exception
|
|
*/
|
|
public function queryProductList()
|
|
{
|
|
$app_key = config('iot.app_key');
|
|
$app_secret = config('iot.app_secret');
|
|
|
|
$result = Aep_product_management::QueryProductList($app_key, $app_secret);
|
|
|
|
$jsonDataDe = json_decode($result, true);
|
|
|
|
$tableName = 'bs_product';
|
|
|
|
if ($jsonDataDe['code'] === 0) {
|
|
|
|
$list = $jsonDataDe['result']['list'];
|
|
|
|
$idArr = [];
|
|
foreach ($list as $item) {
|
|
|
|
$productId = $item['productId'];
|
|
|
|
$query = Db::table($tableName)->where('productId', $productId)->find();
|
|
|
|
$data = [
|
|
'productId' => $productId, // 产品ID
|
|
'productName' => $item['productName'], // 产品名称
|
|
'tenantId' => $item['tenantId'], // 租户ID
|
|
'productDesc' => $item['productDesc'], // 产品描述
|
|
// 'productType' => $item['productType'], // Integer,产品类别
|
|
// 'secondaryType' => $item['secondaryType'], // Integer 二级分类名称
|
|
// 'thirdType' => $item['thirdType'], // Integer,三级分类
|
|
'productProtocol' => $item['productProtocol'], // Integer,产品协议:1.T-LINK协议 2.MQTT协议 3.LWM2M协议 4.TUP协议 5.HTTP协议 6.JT/T808 7.TCP协议 8.私有TCP(网关子设备协议) 9.私有UDP(网关子设备协议) 10.网关产品MQTT(网关产品协议) 11.南向云
|
|
// 'authType' => $item['authType'], // Integer,认证方式 1:特征串认证,2:sm9认证,3:dtls双向认证,4:IMEI认证,5:SIMID认证,6:sm2认证
|
|
// 'payloadFormat' => $item['payloadFormat'], // Integer,消息类型 1:json,2:紧凑二进制
|
|
'createTime' => $item['createTime'], // 创建时间
|
|
'updateTime' => $item['updateTime'], // 更新时间
|
|
'networkType' => $item['networkType'], // Integer,网络类型:1.wifi2.移动蜂窝数据3.NB-IoT4.以太网
|
|
// 'endpointFormat' => $item['endpointFormat'], // Integer,Endpoint格式:1.IMEI 2.URN:IMEI:############### 3.URN:IMEI-IMSI: ###############-###############
|
|
// 'powerModel' => $item['powerModel'], // Integer,省电模式:1.PSM 2.DRX 3.eDRX
|
|
'apiKey' => $item['apiKey'], // MasterKey
|
|
'deviceCount' => $item['deviceCount'], // Integer,设备总数
|
|
'productTypeValue' => $item['productTypeValue'], // 产品分类名称
|
|
'secondaryTypeValue' => $item['secondaryTypeValue'], // 二级分类名称
|
|
'thirdTypeValue' => $item['thirdTypeValue'], // 三级分类名称
|
|
'encryptionType' => $item['encryptionType'], // 加密认证方式 0:一机一密,1:一型一密
|
|
// 'rootCert' => $item['rootCert'], // T-Link证书认证根证书
|
|
'createBy' => $item['createBy'], // 创建者
|
|
'updateBy' => $item['updateBy'], // 更新者
|
|
// 'tupDeviceModel' => $item['tupDeviceModel'], // tup设备类型
|
|
// 'tupDeviceType' => $item['tupDeviceType'], // tup设备型号
|
|
'accessType' => $item['accessType'], // 接入类型: 1.设备直连,2.网关接入,3.南向云接入,4.视图云接入
|
|
'nodeType' => $item['nodeType'], // 节点类型:1设备 ,2.网关
|
|
'tupIsThrough' => $item['tupIsThrough'], // 是否透传:0.透传,1不透传
|
|
'dataEncryption' => $item['dataEncryption'], // 数据加密方式 1:sm1,2:sm2,3:sm4,4:dtls,5:明文
|
|
// 'lwm2mEdrxTime' => $item['lwm2mEdrxTime'], // eDRX模式时间窗
|
|
// 'categoryId' => $item['categoryId'], // 社区协议设备分类
|
|
// 'categoryName' => $item['categoryName'], // 社区协议设备分类名称
|
|
// 'msgParserMode' => $item['msgParserMode'], // 脚本解析方式:1.js脚本解析
|
|
];
|
|
|
|
$idArr = $this->queryUpdate($tableName, $query, $data, $idArr);
|
|
}
|
|
|
|
# 修改状态为停用
|
|
$this->updateStatus($tableName, $idArr);
|
|
|
|
return $this->jsonError($jsonDataDe['msg']);
|
|
} else {
|
|
return $this->jsonError($jsonDataDe['msg'] ?: '数据获取失败');
|
|
}
|
|
}
|
|
|
|
}
|