|
@@ -14,6 +14,7 @@ import com.jpsoft.smart.modules.common.utils.LApiUtil;
|
|
|
import com.jpsoft.smart.modules.common.utils.OSSUtil;
|
|
|
import com.jpsoft.smart.modules.constant.LApiConstant;
|
|
|
import com.jpsoft.smart.modules.lapi.dto.DataServersDTO;
|
|
|
+import com.jpsoft.smart.modules.lapi.dto.ServerAddrDTO;
|
|
|
import com.jpsoft.smart.modules.lapi.request.LapiRequest;
|
|
|
import com.jpsoft.smart.modules.lapi.service.ILapiService;
|
|
|
import com.jpsoft.smart.modules.lapi.vo.*;
|
|
@@ -996,5 +997,53 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void updateDeviceData(List<String> deviceNoList, String newAddress, String newPort) throws Exception {
|
|
|
+
|
|
|
+
|
|
|
+ if (deviceNoList.size() <= 0) {
|
|
|
+ throw new Exception("设备为空");
|
|
|
+ }
|
|
|
+ for (String deviceNo : deviceNoList) {
|
|
|
+ try {
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(deviceNo);
|
|
|
+ DataServersDTO dataServersDTO = getDeviceDateServer(deviceNo);
|
|
|
+
|
|
|
+ if (dataServersDTO != null) {
|
|
|
+ ServerAddrDTO serverAddrDTO = dataServersDTO.getServerAddr();
|
|
|
+ /*if (StringUtils.isNotBlank(newDeviceNo)) {
|
|
|
+ dataServersDTO.setTollgateID(newDeviceNo);
|
|
|
+ }*/
|
|
|
+ if (StringUtils.isNotBlank(newAddress)) {
|
|
|
+ serverAddrDTO.setAddress(newAddress);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(newPort)) {
|
|
|
+ serverAddrDTO.setPort(Integer.valueOf(newPort));
|
|
|
+ }
|
|
|
+ dataServersDTO.setServerAddr(serverAddrDTO);
|
|
|
+
|
|
|
+ List<DataServersDTO> dataServersDTOList = new ArrayList<>();
|
|
|
+ dataServersDTOList.add(dataServersDTO);
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("Num", 1);
|
|
|
+ map.put("DataServerList", dataServersDTOList);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceNo, LApiConstant.DATASERVERS, HttpMethod.PUT, map);
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
+
|
|
|
+ if (dataJson.getString("ResponseString").equals("Succeed") && dataJson.getString("StatusString").equals("Succeed")) {
|
|
|
+ // deviceInfo.setDeviceNo(newDeviceNo);
|
|
|
+ deviceInfo.setUpdateTime(new Date());
|
|
|
+ deviceInfoService.update(deviceInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|