|
@@ -399,22 +399,33 @@ public class DeviceService {
|
|
|
Iterator it = data.iterator();
|
|
|
|
|
|
List<CareDevice> list = new ArrayList<>();
|
|
|
+ boolean flag = false;
|
|
|
while (it.hasNext()) {
|
|
|
JSONObject obj = (JSONObject) it.next();
|
|
|
- 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");
|
|
|
- list.add(careDevice);
|
|
|
- } else {
|
|
|
+ String devCode = obj.getStr("mdid");
|
|
|
+ if(StringUtils.isEmpty(devCode)){
|
|
|
continue;
|
|
|
}
|
|
|
+ CareDevice careDevice = new CareDevice();
|
|
|
+ careDevice.setDevCode(devCode);
|
|
|
+ careDevice.setOrgId(careOrganization.getId());
|
|
|
+ careDevice.setTopic("/" + companyId + "/" + devCode + "/event");
|
|
|
+ careDevice.setTopicInstall("/" + companyId + "/" + devCode + "/control");
|
|
|
+ list.add(careDevice);
|
|
|
+ if(list.size() % 500 == 0){
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ careDeviceService.synDev(list);
|
|
|
+ flag = true;
|
|
|
+ list.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if (!list.isEmpty()) {
|
|
|
careDeviceService.synDev(list);
|
|
|
- } else {
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!flag) {
|
|
|
throw new BDException("同步数据为空");
|
|
|
}
|
|
|
|