| | |
| | | package com.basic.security.utils; |
| | | |
| | | import android.os.SystemClock; |
| | | import android.text.TextUtils; |
| | | |
| | | import com.basic.security.base.BaseApplication; |
| | | import com.basic.security.manager.PersonManager; |
| | | import com.basic.security.manager.RemoteInDoorManager; |
| | | import com.basic.security.manager.RemoteOutdoorManager; |
| | | import com.basic.security.manager.PersonManager; |
| | | import com.basic.security.model.ModelAdapter; |
| | | import com.basic.security.model.Person; |
| | | import com.basic.security.model.PersonSocket; |
| | |
| | | |
| | | public static List<String> getRpcCallIp() { |
| | | List<String> ipList = new ArrayList<>(); |
| | | String ip = ""; |
| | | if (Constants.isIndoor) { |
| | | ipList = RemoteOutdoorManager.getOutdoorDeviceIp(); |
| | | } |
| | | if (Constants.isOutdoor) { |
| | | ipList = RemoteInDoorManager.getIndoorDeviceIp(); |
| | | } |
| | | return ipList; |
| | | List<String> finalList = new ArrayList<>(); |
| | | for (String ip : ipList) { |
| | | if (!TextUtils.isEmpty(ip)) { |
| | | finalList.add(ip); |
| | | } |
| | | } |
| | | // LogUtil.println("getRpcCallIp " + finalList); |
| | | return finalList; |
| | | } |
| | | |
| | | public static void rpcCallAsyncCommonSave(ModelAdapter modelAdapter) { |
| | |
| | | } |
| | | |
| | | public static void rpcCallAsync(ModelAdapter modelAdapter, String requestType) { |
| | | if (!Constants.isUseSocketRpc) { |
| | | return; |
| | | } |
| | | BaseApplication.getApplication().executorService.execute(() -> { |
| | | List<String> remoteIpList = getRpcCallIp(); |
| | | for (String remoteIp : remoteIpList) { |
| | |
| | | socketUtil.writeByteArray(modelMapByteArray); |
| | | } |
| | | Map<String, String> responseMap = socketUtil.readJsonAsMap(); |
| | | // System.out.println("SocketUtil.rpcCallSaveVisit " + responseMap + " " + requestType); |
| | | // System1.out.println("SocketUtil.rpcCallAsync " + responseMap + " " + requestType + " remoteIp=" + remoteIp + " " + Constants.personServerPort); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | |
| | | socketUtil.readFullByteArray(personByteArray); |
| | | Map<String, Object> personModel = (Map<String, Object>) ObjectUtil.toObject(personByteArray);//SerializationUtils.deserialize(personByteArray); |
| | | if (personModel != null) { |
| | | // System.out.println("SocketUtil.rpcCallFindPersonById " + personModel); |
| | | // System1.out.println("SocketUtil.rpcCallFindPersonById " + personModel); |
| | | ModelAdapter person = new ModelAdapter(); |
| | | person.model = personModel; |
| | | byte[] camera_image_path_byte_array = (byte[]) person.model.get(PersonSocket.camera_image_path_byte_array); |
| | |
| | | return person; |
| | | } |
| | | } else { |
| | | // System.out.println("SocketUtil.rpcCallFindPersonById"); |
| | | // System1.out.println("SocketUtil.rpcCallFindPersonById"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | IOUtils.write(fileBuffer, fileWriter); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | System.out.println("SocketUtil.rpcCallDownload camera_image_path=" + camera_image_path); |
| | | System1.out.println("SocketUtil.rpcCallDownload camera_image_path=" + camera_image_path); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | try { |
| | | element = parser.parse(json); |
| | | } catch (JsonParseException e) { |
| | | System.out.println("exception: " + e); |
| | | System1.out.println("exception: " + e); |
| | | isJSON = false; |
| | | } |
| | | if (isJSON && element != null) { |