|
@@ -16,6 +16,8 @@ import com.bz.smart_city.dto.LoginUser;
|
|
|
import com.bz.smart_city.dto.MeterSyncDto;
|
|
|
import com.bz.smart_city.dto.MeterSyncInputDto;
|
|
|
import com.bz.smart_city.dto.pay.PayBaseConfigDto;
|
|
|
+import com.bz.smart_city.dto.pay.SynDeviceResult;
|
|
|
+import com.bz.smart_city.dto.pay.SynDeviceStatus;
|
|
|
import com.bz.smart_city.entity.Customer;
|
|
|
import com.bz.smart_city.entity.Device;
|
|
|
import com.bz.smart_city.entity.SyncValveResult;
|
|
@@ -36,8 +38,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by ZJY on 2020-09-28 10:22
|
|
@@ -166,7 +167,6 @@ public class DeviceSyncServiceImpl implements DeviceSyncService, InitializingBea
|
|
|
deviceMapper.updateSync(meterSyncDto);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -177,10 +177,69 @@ public class DeviceSyncServiceImpl implements DeviceSyncService, InitializingBea
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ getDeviceSatus(siteId,customerId);
|
|
|
|
|
|
+ }
|
|
|
|
|
|
+ //获取设备状态
|
|
|
+ public void getDeviceSatus(Integer siteId, Integer customerId){
|
|
|
+ try {
|
|
|
+ log.info(String.format("设备状态同步siteId:%s,customerId:%s",siteId,customerId));
|
|
|
+ //取客户编号
|
|
|
+ String customerNo= "";
|
|
|
+ Customer customer= customerMapper.findById(customerId);
|
|
|
+ if(customer != null && customer.getCustomerNo() != null){
|
|
|
+ customerNo = customer.getCustomerNo();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ return;
|
|
|
+
|
|
|
+ String url = SyncUrl+"/api/platform/getDeviceStatus";
|
|
|
+ int loadNumber = 1000; //批量数量
|
|
|
+ List<Device> deviceList = deviceMapper.findList(siteId,customerId);
|
|
|
+ if(deviceList != null && deviceList.size() > 0){
|
|
|
+ int count = deviceList.size();
|
|
|
+ int number = (count/loadNumber) ;
|
|
|
+
|
|
|
+ for(int i=0;i<=number;i++){
|
|
|
+ int leng = loadNumber;
|
|
|
+ if(i*loadNumber + loadNumber > count)
|
|
|
+ leng = count - i*loadNumber;
|
|
|
+
|
|
|
+ if(leng >0){
|
|
|
+ List<Device> subDeviceList = new ArrayList<>();
|
|
|
+ subDeviceList.addAll(deviceList.subList(i*loadNumber ,i*loadNumber+leng));
|
|
|
+ SynDeviceStatus synDeviceStatus = new SynDeviceStatus();
|
|
|
+ synDeviceStatus.setCustomerNo(customerNo);
|
|
|
+ synDeviceStatus.setElectronicMeterNos(new ArrayList());
|
|
|
+ for (int k = 0;k < leng ;k++){
|
|
|
+ synDeviceStatus.getElectronicMeterNos().add(subDeviceList.get(k).getWaterMeterNo());
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ String json= JSON.toJSON(synDeviceStatus).toString();
|
|
|
+ String result = HttpClientUtils.doPostWithJson(url,json);
|
|
|
+ JSONObject jsonObject= JSON.parseObject(result);
|
|
|
+ Integer status= jsonObject.getInteger("status");
|
|
|
+ if(status.equals(0)){
|
|
|
+ JSONArray datas = jsonObject.getJSONArray("data");
|
|
|
+ List<SynDeviceResult> syncValveResultList = datas.toJavaList(SynDeviceResult.class);
|
|
|
+
|
|
|
+ for (SynDeviceResult SynResutl:syncValveResultList){
|
|
|
+ MeterSyncDto meterSyncDto = new MeterSyncDto();
|
|
|
+ meterSyncDto.setWaterMeterNo(SynResutl.getElectronicMeterNo());
|
|
|
+ meterSyncDto.setDays(SynResutl.getDays());
|
|
|
+ meterSyncDto.setDeviceStatus(SynResutl.getDeviceStatus());
|
|
|
+ deviceMapper.updateSyncDeviceStatus(meterSyncDto);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ ;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|