张世豪
2025-12-09 32524195d474b74e48916867b2a6c2f022a40d98
src/set/Sets.java
@@ -30,6 +30,7 @@
    
    // 设置项组件
    private JLabel mowerIdLabel;
    private JLabel baseStationIdLabel;
    private JLabel handheldMarkerLabel;
    private JLabel simCardNumberLabel;
    private JLabel baseStationSimLabel;
@@ -38,6 +39,7 @@
    private JLabel idleTrailDurationLabel;
    
    private JButton mowerIdEditBtn;
    private JButton baseStationIdEditBtn;
    private JButton handheldEditBtn;
    private JButton checkUpdateBtn;
    private JButton systemDebugButton;
@@ -105,6 +107,11 @@
            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);
@@ -135,7 +142,8 @@
        // APP版本
        JPanel appVersionPanel = createAppVersionPanel();
        
        addRowWithSpacing(panel, mowerIdPanel);
    addRowWithSpacing(panel, mowerIdPanel);
    addRowWithSpacing(panel, baseStationIdPanel);
        addRowWithSpacing(panel, handheldPanel);
    addRowWithSpacing(panel, simCardPanel);
    addRowWithSpacing(panel, baseStationSimPanel);
@@ -432,6 +440,10 @@
            mowerIdLabel.setText(setData.getMowerId() != null ? setData.getMowerId() : "未设置");
        }
        if (baseStationIdLabel != null) {
            baseStationIdLabel.setText(resolveBaseStationId());
        }
        if (handheldMarkerLabel != null) {
            handheldMarkerLabel.setText(setData.getHandheldMarkerId() != null ? setData.getHandheldMarkerId() : "未设置");
        }
@@ -477,12 +489,31 @@
        }
        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) {
@@ -559,6 +590,45 @@
        }
    }
    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) {