| | |
| | | } |
| | | while (rs.next()) { |
| | | LocationTag locationTag = new LocationTag(); |
| | | locationTag.setId((int) rs.getLong("id")); |
| | | locationTag.setId((int) rs.getLong("id")); |
| | | locationTag.setDeviceNumber(rs.getString("device_id")); |
| | | locationTag.setDeviceName(rs.getString("device_name")); |
| | | locationTag.setDeviceVersion(rs.getString("device_version")); |
| | |
| | | locationTag.setMotionlessEndTime(rs.getString("stationary_end_time")); |
| | | locationTag.setMotionlessDuration(rs.getString("stationary_duration")); |
| | | locationTag.setValidSatelliteSignal(rs.getString("tag_valid_satellite_signal")); |
| | | locationTag.setCompany(rs.getString("company")); |
| | | String company=rs.getString("company"); |
| | | if (company == null || company.trim().isEmpty() || company.equals("-1") ) { |
| | | company = "Unknown"; |
| | | } |
| | | locationTag.setCompany(company); |
| | | locationTag.setSleepTime(rs.getString("sleep_time")); |
| | | locationTag.setVibrationTime(rs.getString("vibration_time")); |
| | | locationTag.setFrequency(rs.getString("frequency")); |
| | |
| | | locationTag.setInteractionType(rs.getString("Interaction_Type")); |
| | | locationTag.setIpAddress(rs.getString("ipAddress")); |
| | | locationTag.setIpPort(rs.getString("Interaction_Type")); |
| | | |
| | | locationTag.setId((int) rs.getLong("id")); |
| | | |
| | | String deviceNumber = rs.getString("device_id"); |
| | | if (deviceNumber == null || deviceNumber.trim().isEmpty() || deviceNumber.equals("-1")) { |
| | | deviceNumber = "Unknown"; |
| | | } |
| | | locationTag.setDeviceNumber(deviceNumber); |
| | | |
| | | String deviceName = rs.getString("device_name"); |
| | | if (deviceName == null || deviceName.trim().isEmpty() || deviceName.equals("-1")) { |
| | | deviceName = "Unknown"; |
| | | } |
| | | locationTag.setDeviceName(deviceName); |
| | | |
| | | String deviceVersion = rs.getString("device_version"); |
| | | if (deviceVersion == null || deviceVersion.trim().isEmpty() || deviceVersion.equals("-1")) { |
| | | deviceVersion = "Unknown"; |
| | | } |
| | | locationTag.setDeviceVersion(deviceVersion); |
| | | |
| | | String deviceCardNumber = rs.getString("device_card_number"); |
| | | if (deviceCardNumber == null || deviceCardNumber.trim().isEmpty() || deviceCardNumber.equals("-1")) { |
| | | deviceCardNumber = "Unknown"; |
| | | } |
| | | locationTag.setDeviceCardNumber(deviceCardNumber); |
| | | |
| | | String deviceType = rs.getString("device_type"); |
| | | if (deviceType == null || deviceType.trim().isEmpty() || deviceType.equals("-1")) { |
| | | deviceType = "Unknown"; |
| | | } |
| | | locationTag.setDeviceType(deviceType); |
| | | |
| | | String team = rs.getString("affiliated_class"); |
| | | if (team == null || team.trim().isEmpty() || team.equals("-1")) { |
| | | team = "Unknown"; |
| | | } |
| | | locationTag.setTeam(team); |
| | | |
| | | String group = rs.getString("affiliated_group"); |
| | | if (group == null || group.trim().isEmpty() || group.equals("-1")) { |
| | | group = "Unknown"; |
| | | } |
| | | locationTag.setGroup(group); |
| | | |
| | | String department = rs.getString("department"); |
| | | if (department == null || department.trim().isEmpty() || department.equals("-1")) { |
| | | department = "Unknown"; |
| | | } |
| | | locationTag.setDepartment(department); |
| | | |
| | | String iconAddress = rs.getString("icon_url"); |
| | | if (iconAddress == null || iconAddress.trim().isEmpty() || iconAddress.equals("-1")) { |
| | | iconAddress = "Unknown"; |
| | | } |
| | | locationTag.setIconAddress(iconAddress); |
| | | |
| | | String gender = rs.getString("gender"); |
| | | if (gender == null || gender.trim().isEmpty() || gender.equals("-1")) { |
| | | gender = "Unknown"; |
| | | } |
| | | locationTag.setGender(gender); |
| | | |
| | | String ethnicity = rs.getString("ethnic_group"); |
| | | if (ethnicity == null || ethnicity.trim().isEmpty() || ethnicity.equals("-1")) { |
| | | ethnicity = "Unknown"; |
| | | } |
| | | locationTag.setEthnicity(ethnicity); |
| | | |
| | | String communicationAddress = rs.getString("communication_address"); |
| | | if (communicationAddress == null || communicationAddress.trim().isEmpty() || communicationAddress.equals("-1")) { |
| | | communicationAddress = "Unknown"; |
| | | } |
| | | locationTag.setCommunicationAddress(communicationAddress); |
| | | |
| | | String boundPhone = rs.getString("bound_phone"); |
| | | if (boundPhone == null || boundPhone.trim().isEmpty() || boundPhone.equals("-1")) { |
| | | boundPhone = "Unknown"; |
| | | } |
| | | locationTag.setBoundPhone(boundPhone); |
| | | |
| | | String idNumber = rs.getString("id_card_number"); |
| | | if (idNumber == null || idNumber.trim().isEmpty() || idNumber.equals("-1")) { |
| | | idNumber = "Unknown"; |
| | | } |
| | | locationTag.setIdNumber(idNumber); |
| | | |
| | | String position = rs.getString("personnel_position"); |
| | | if (position == null || position.trim().isEmpty() || position.equals("-1")) { |
| | | position = "Unknown"; |
| | | } |
| | | locationTag.setPosition(position); |
| | | |
| | | String boundPlateNumber = rs.getString("bound_license_plate"); |
| | | if (boundPlateNumber == null || boundPlateNumber.trim().isEmpty() || boundPlateNumber.equals("-1")) { |
| | | boundPlateNumber = "Unknown"; |
| | | } |
| | | locationTag.setBoundPlateNumber(boundPlateNumber); |
| | | |
| | | String faceAddress = rs.getString("face_image_url"); |
| | | if (faceAddress == null || faceAddress.trim().isEmpty() || faceAddress.equals("-1")) { |
| | | faceAddress = "Unknown"; |
| | | } |
| | | locationTag.setFaceAddress(faceAddress); |
| | | |
| | | String heartRate = rs.getString("heart_rate"); |
| | | if (heartRate == null || heartRate.trim().isEmpty() || heartRate.equals("-1")) { |
| | | heartRate = "Unknown"; |
| | | } |
| | | locationTag.setHeartRate(heartRate); |
| | | |
| | | String bloodPressure = rs.getString("blood_pressure"); |
| | | if (bloodPressure == null || bloodPressure.trim().isEmpty() || bloodPressure.equals("-1")) { |
| | | bloodPressure = "Unknown"; |
| | | } |
| | | locationTag.setBloodPressure(bloodPressure); |
| | | |
| | | String bloodOxygen = rs.getString("blood_oxygen"); |
| | | if (bloodOxygen == null || bloodOxygen.trim().isEmpty() || bloodOxygen.equals("-1")) { |
| | | bloodOxygen = "Unknown"; |
| | | } |
| | | locationTag.setBloodOxygen(bloodOxygen); |
| | | |
| | | String temperature = rs.getString("body_temperature"); |
| | | if (temperature == null || temperature.trim().isEmpty() || temperature.equals("-1")) { |
| | | temperature = "Unknown"; |
| | | } |
| | | locationTag.setTemperature(temperature); |
| | | |
| | | String sosStatus = rs.getString("sos_status"); |
| | | if (sosStatus == null || sosStatus.trim().isEmpty() || sosStatus.equals("-1")) { |
| | | sosStatus = "Unknown"; |
| | | } |
| | | locationTag.setSosStatus(sosStatus); |
| | | |
| | | String motionStatus = rs.getString("motion_status"); |
| | | if (motionStatus == null || motionStatus.trim().isEmpty() || motionStatus.equals("-1")) { |
| | | motionStatus = "Unknown"; |
| | | } |
| | | locationTag.setMotionStatus(motionStatus); |
| | | |
| | | String onlineStatus = rs.getString("online_status"); |
| | | if (onlineStatus == null || onlineStatus.trim().isEmpty() || onlineStatus.equals("-1")) { |
| | | onlineStatus = "Unknown"; |
| | | } |
| | | locationTag.setOnlineStatus(onlineStatus); |
| | | |
| | | String searchStatus = rs.getString("search_status"); |
| | | if (searchStatus == null || searchStatus.trim().isEmpty() || searchStatus.equals("-1")) { |
| | | searchStatus = "Unknown"; |
| | | } |
| | | locationTag.setSearchStatus(searchStatus); |
| | | |
| | | String batteryStatus = rs.getString("battery_status"); |
| | | if (batteryStatus == null || batteryStatus.trim().isEmpty() || batteryStatus.equals("-1")) { |
| | | batteryStatus = "Unknown"; |
| | | } |
| | | locationTag.setBatteryStatus(batteryStatus); |
| | | |
| | | String deviceBattery = rs.getString("device_battery"); |
| | | if (deviceBattery == null || deviceBattery.trim().isEmpty() || deviceBattery.equals("-1")) { |
| | | deviceBattery = "Unknown"; |
| | | } |
| | | locationTag.setDeviceBattery(deviceBattery); |
| | | |
| | | String removalStatus = rs.getString("removal_status"); |
| | | if (removalStatus == null || removalStatus.trim().isEmpty() || removalStatus.equals("-1")) { |
| | | removalStatus = "Unknown"; |
| | | } |
| | | locationTag.setRemovalStatus(removalStatus); |
| | | |
| | | String collisionStatus = rs.getString("collision_status"); |
| | | if (collisionStatus == null || collisionStatus.trim().isEmpty() || collisionStatus.equals("-1")) { |
| | | collisionStatus = "Unknown"; |
| | | } |
| | | locationTag.setCollisionStatus(collisionStatus); |
| | | |
| | | String elevationStatus = rs.getString("climbing_status"); |
| | | if (elevationStatus == null || elevationStatus.trim().isEmpty() || elevationStatus.equals("-1")) { |
| | | elevationStatus = "Unknown"; |
| | | } |
| | | locationTag.setElevationStatus(elevationStatus); |
| | | |
| | | String gatheringCount = rs.getString("gathering_count"); |
| | | if (gatheringCount == null || gatheringCount.trim().isEmpty() || gatheringCount.equals("-1")) { |
| | | gatheringCount = "Unknown"; |
| | | } |
| | | locationTag.setGatheringCount(gatheringCount); |
| | | |
| | | String proximityAlarm = rs.getString("proximity_alarm"); |
| | | if (proximityAlarm == null || proximityAlarm.trim().isEmpty() || proximityAlarm.equals("-1")) { |
| | | proximityAlarm = "Unknown"; |
| | | } |
| | | locationTag.setProximityAlarm(proximityAlarm); |
| | | |
| | | String area = rs.getString("current_area"); |
| | | if (area == null || area.trim().isEmpty() || area.equals("-1")) { |
| | | area = "Unknown"; |
| | | } |
| | | locationTag.setArea(area); |
| | | |
| | | String xCoordinate = rs.getString("x_coordinate"); |
| | | if (xCoordinate == null || xCoordinate.trim().isEmpty() || xCoordinate.equals("-1")) { |
| | | xCoordinate = "Unknown"; |
| | | } |
| | | locationTag.setXCoordinate(xCoordinate); |
| | | |
| | | String yCoordinate = rs.getString("y_coordinate"); |
| | | if (yCoordinate == null || yCoordinate.trim().isEmpty() || yCoordinate.equals("-1")) { |
| | | yCoordinate = "Unknown"; |
| | | } |
| | | locationTag.setYCoordinate(yCoordinate); |
| | | |
| | | String zCoordinate = rs.getString("z_coordinate"); |
| | | if (zCoordinate == null || zCoordinate.trim().isEmpty() || zCoordinate.equals("-1")) { |
| | | zCoordinate = "Unknown"; |
| | | } |
| | | locationTag.setZCoordinate(zCoordinate); |
| | | |
| | | String floor = rs.getString("current_floor"); |
| | | if (floor == null || floor.trim().isEmpty() || floor.equals("-1")) { |
| | | floor = "Unknown"; |
| | | } |
| | | locationTag.setFloor(floor); |
| | | |
| | | String speed = rs.getString("movement_speed"); |
| | | if (speed == null || speed.trim().isEmpty() || speed.equals("-1")) { |
| | | speed = "Unknown"; |
| | | } |
| | | locationTag.setSpeed(speed); |
| | | |
| | | String locationSource = rs.getString("position_source"); |
| | | if (locationSource == null || locationSource.trim().isEmpty() || locationSource.equals("-1")) { |
| | | locationSource = "Unknown"; |
| | | } |
| | | locationTag.setLocationSource(locationSource); |
| | | |
| | | String lastUwbSignalTime = rs.getString("last_uwb_signal_time"); |
| | | if (lastUwbSignalTime == null || lastUwbSignalTime.trim().isEmpty() || lastUwbSignalTime.equals("-1")) { |
| | | lastUwbSignalTime = "Unknown"; |
| | | } |
| | | locationTag.setLastUwbSignalTime(lastUwbSignalTime); |
| | | |
| | | String lastSatelliteSignalTime = rs.getString("last_satellite_signal_time"); |
| | | if (lastSatelliteSignalTime == null || lastSatelliteSignalTime.trim().isEmpty() || lastSatelliteSignalTime.equals("-1")) { |
| | | lastSatelliteSignalTime = "Unknown"; |
| | | } |
| | | |
| | | locationTag.setAutoUpgraded("Unknown"); |
| | | locationTag.setIsSatelliteDevice("-1"); |
| | | locationTag.setRTKsource("Unknown"); |
| | | locationTags.add(locationTag); |
| | | tagMap.put(locationTag.getDeviceNumber(), locationTag); // 添加到映射 |
| | | } |
| | |
| | | case "interactionType": tag.setInteractionType(value); break; |
| | | case "ipAddress": tag.setIpAddress(value); break; |
| | | case "ipPort": tag.setIpPort(value); break; |
| | | case "gnGgaDataTime": tag.setGnGgaDataTime(value); break; |
| | | case "isSatelliteDevice": tag.setIsSatelliteDevice(value);break; |
| | | case "RTKsource": tag.setRTKsource(value);break; |
| | | default: |
| | | throw new IllegalArgumentException("无效属性: " + propertyName); |
| | | } |
| | |
| | | } |
| | | return tagMap.size(); |
| | | } |
| | | |
| | | /** |
| | | * 根据单个属性查询LocationTag对象 |
| | | * @param propertyName 属性名(deviceNumber/deviceVersion/company) |
| | | * @param propertyValue 属性值 |
| | | * @return 满足条件的LocationTag对象列表 |
| | | */ |
| | | public static List<LocationTag> getLocationTagsByProperty(String propertyName, String propertyValue) { |
| | | if (tagMap == null || tagMap.isEmpty()) { |
| | | try { |
| | | getlocationTags(); // 初始化数据 |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | return Collections.emptyList(); |
| | | } |
| | | } |
| | | |
| | | List<LocationTag> result = new ArrayList<>(); |
| | | |
| | | for (LocationTag tag : tagMap.values()) { |
| | | switch (propertyName) { |
| | | case "deviceNumber": |
| | | if (propertyValue.equals(tag.getDeviceNumber())) { |
| | | result.add(tag); |
| | | } |
| | | break; |
| | | case "deviceVersion": |
| | | if (propertyValue.equals(tag.getDeviceVersion())) { |
| | | result.add(tag); |
| | | } |
| | | break; |
| | | case "company": |
| | | if (propertyValue.equals(tag.getCompany())) { |
| | | result.add(tag); |
| | | } |
| | | break; |
| | | default: |
| | | throw new IllegalArgumentException("不支持的属性: " + propertyName); |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | } |