|
@@ -385,6 +385,13 @@ public class DeviceService {
|
|
|
if (StringUtils.isEmpty(companyId)){
|
|
|
return false;
|
|
|
}
|
|
|
+ QueryWrapper<CareOrganization> queryWrapper1 = new QueryWrapper<>();
|
|
|
+ queryWrapper1.lambda().eq(CareOrganization::getCompanyId,companyId);
|
|
|
+ CareOrganization careOrganization = this.careOrganizationService.getOne(queryWrapper1);
|
|
|
+ if (careOrganization == null){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
// 通过synDevUrl获取data
|
|
|
JSONObject jsonObject = HttpUtil.httpGet(synDevUrl + "?companyId=" + companyId);
|
|
|
int code = jsonObject.getInt("code");
|
|
@@ -392,25 +399,27 @@ public class DeviceService {
|
|
|
JSONArray data = jsonObject.getJSONArray("data");
|
|
|
Iterator it = data.iterator();
|
|
|
|
|
|
+ List<CareDevice> list = new ArrayList<>();
|
|
|
while (it.hasNext()) {
|
|
|
JSONObject obj = (JSONObject) it.next();
|
|
|
-
|
|
|
- QueryWrapper<CareOrganization> queryWrapper1 = new QueryWrapper<>();
|
|
|
- queryWrapper1.lambda().eq(CareOrganization::getCompanyId,companyId);
|
|
|
- CareOrganization careOrganization = this.careOrganizationService.getOne(queryWrapper1);
|
|
|
if(careOrganization != null) {
|
|
|
CareDevice careDevice = new CareDevice();
|
|
|
careDevice.setDevCode(obj.getStr("mdid"));
|
|
|
careDevice.setOrgId(careOrganization.getId());
|
|
|
careDevice.setTopic("/companyId/" + careDevice.getDevCode() + "/event");
|
|
|
careDevice.setTopicInstall("/companyId/" + careDevice.getDevCode() + "/control");
|
|
|
- careDeviceService.synDev(careDevice);
|
|
|
+ list.add(careDevice);
|
|
|
} else {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ careDeviceService.synDev(list);
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- return true;
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|