| | |
| | | |
| | | // 设置项组件 |
| | | private JLabel mowerIdLabel; |
| | | private JLabel baseStationIdLabel; |
| | | private JLabel handheldMarkerLabel; |
| | | private JLabel simCardNumberLabel; |
| | | private JLabel baseStationSimLabel; |
| | |
| | | private JLabel idleTrailDurationLabel; |
| | | |
| | | private JButton mowerIdEditBtn; |
| | | private JButton baseStationIdEditBtn; |
| | | private JButton handheldEditBtn; |
| | | private JButton checkUpdateBtn; |
| | | private JButton systemDebugButton; |
| | |
| | | setData.getMowerId() != null ? setData.getMowerId() : "未设置", true); |
| | | mowerIdLabel = (JLabel) mowerIdPanel.getClientProperty("valueLabel"); |
| | | mowerIdEditBtn = (JButton) mowerIdPanel.getClientProperty("editButton"); |
| | | |
| | | JPanel baseStationIdPanel = createSettingItemPanel("差分基准站编号", |
| | | resolveBaseStationId(), true); |
| | | baseStationIdLabel = (JLabel) baseStationIdPanel.getClientProperty("valueLabel"); |
| | | baseStationIdEditBtn = (JButton) baseStationIdPanel.getClientProperty("editButton"); |
| | | |
| | | JPanel handheldPanel = createSettingItemPanel("便携打点器编号", |
| | | setData.getHandheldMarkerId() != null ? setData.getHandheldMarkerId() : "未设置", true); |
| | |
| | | // APP版本 |
| | | JPanel appVersionPanel = createAppVersionPanel(); |
| | | |
| | | addRowWithSpacing(panel, mowerIdPanel); |
| | | addRowWithSpacing(panel, mowerIdPanel); |
| | | addRowWithSpacing(panel, baseStationIdPanel); |
| | | addRowWithSpacing(panel, handheldPanel); |
| | | addRowWithSpacing(panel, simCardPanel); |
| | | addRowWithSpacing(panel, baseStationSimPanel); |
| | |
| | | mowerIdLabel.setText(setData.getMowerId() != null ? setData.getMowerId() : "未设置"); |
| | | } |
| | | |
| | | if (baseStationIdLabel != null) { |
| | | baseStationIdLabel.setText(resolveBaseStationId()); |
| | | } |
| | | |
| | | if (handheldMarkerLabel != null) { |
| | | handheldMarkerLabel.setText(setData.getHandheldMarkerId() != null ? setData.getHandheldMarkerId() : "未设置"); |
| | | } |
| | |
| | | } |
| | | return trimmed; |
| | | } |
| | | |
| | | private String resolveBaseStationId() { |
| | | if (baseStation == null) { |
| | | return "未设置"; |
| | | } |
| | | String value = baseStation.getDeviceId(); |
| | | if (value == null) { |
| | | return "未设置"; |
| | | } |
| | | String trimmed = value.trim(); |
| | | if (trimmed.isEmpty() || "-1".equals(trimmed)) { |
| | | return "未设置"; |
| | | } |
| | | return trimmed; |
| | | } |
| | | |
| | | private void setupEventHandlers() { |
| | | // 割草机编号编辑按钮事件 |
| | | if (mowerIdEditBtn != null) { |
| | | mowerIdEditBtn.addActionListener(e -> editMowerId()); |
| | | } |
| | | |
| | | if (baseStationIdEditBtn != null) { |
| | | baseStationIdEditBtn.addActionListener(e -> editBaseStationId()); |
| | | } |
| | | |
| | | // 检查更新按钮事件 |
| | | if (checkUpdateBtn != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | private void editBaseStationId() { |
| | | String currentValue = "未设置".equals(resolveBaseStationId()) ? "" : resolveBaseStationId(); |
| | | String newValue = (String) JOptionPane.showInputDialog(this, |
| | | "请输入差分基准站编号:", |
| | | "修改差分基准站编号", |
| | | JOptionPane.QUESTION_MESSAGE, |
| | | null, |
| | | null, |
| | | currentValue); |
| | | |
| | | if (newValue == null) { |
| | | return; |
| | | } |
| | | |
| | | newValue = newValue.trim(); |
| | | if (newValue.isEmpty()) { |
| | | JOptionPane.showMessageDialog(this, "差分基准站编号不能为空", "提示", JOptionPane.WARNING_MESSAGE); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | baseStation.updateByDeviceId(newValue, |
| | | baseStation.getInstallationCoordinates(), |
| | | baseStation.getIotSimCardNumber(), |
| | | baseStation.getDeviceActivationTime(), |
| | | baseStation.getDataUpdateTime()); |
| | | baseStation.load(); |
| | | if (baseStationIdLabel != null) { |
| | | baseStationIdLabel.setText(resolveBaseStationId()); |
| | | } |
| | | JOptionPane.showMessageDialog(this, "差分基准站编号更新成功", "成功", JOptionPane.INFORMATION_MESSAGE); |
| | | } catch (IllegalArgumentException ex) { |
| | | JOptionPane.showMessageDialog(this, ex.getMessage(), "输入错误", JOptionPane.WARNING_MESSAGE); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | JOptionPane.showMessageDialog(this, "差分基准站编号更新失败", "错误", JOptionPane.ERROR_MESSAGE); |
| | | } |
| | | } |
| | | |
| | | private void editIdleTrailDuration() { |
| | | int currentSeconds = setData != null ? setData.getIdleTrailDurationSeconds() : Setsys.DEFAULT_IDLE_TRAIL_DURATION_SECONDS; |
| | | if (currentSeconds <= 0) { |