2021与蓝度共同重构项目,服务端
MercuryZ
2022-10-18 ea94079e74182be590b9fff356c97f522d9a7828
Merge remote-tracking branch 'origin/master'

# Conflicts:
# ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java
已修改65个文件
已添加18个文件
3834 ■■■■ 文件已修改
dao/src/main/java/com/sandu/ximon/dao/domain/AirDataNongGeng.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/AirEquipmentNongGeng.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/LightEnergyData.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/LightReportError.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/LightTask.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/enums/AirNongGengEnums.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/enums/MenuEnum.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/mapper/AirDataNongGengMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/mapper/AirEquipmentNongGengMapper.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/mapper/LedPlayerEntityMapper.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/mapper/LightEnergyDataMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/mapper/LightReportErrorMapper.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/AirDataNongGengMapper.xml 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/AirEquipmentNongGengMapper.xml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/LedPlayerEntityMapper.xml 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/LightEnergyDataMapper.xml 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/LightReportErrorMapper.xml 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/config/BroadcastAPI.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/config/BroadcastIP.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/config/VnnoxConstant.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/AirDataNongGengController.java 63 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/AirEquipmentNongGengController.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/ErrorMsgController.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/IPBroadcastController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/LightController.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/LightTaskController.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/RemoteUpdateController.java 133 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/VnnoxController.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/dto/LightTaskDto.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/dto/RemoteUpdateTypeDto.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/dto/TerminalDto.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/amqp/processor/AirDataProcessor.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/amqp/processor/LightDataProcessor.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/report/A5AtmosphereNewHeartbeatReportInnerFrame.java 135 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/report/A5LightOperationReportInnerFrame.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/request/A5LightCleanErrorCodeInnerFrame.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/request/A5LightSetCalendarReqInnerFrame.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/request/AtmosphereNewReqInnerFrame.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/enums/A5LightDataEnum.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/enums/RemoteUpdateTypeEnum.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/mainboard/MainBoardInvokeSyncService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/util/CRCUtils.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/util/CRCValidate.java 210 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/util/SupplementUtils.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/param/LightSetCalendarParam.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/param/LightTaskDelParam.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/param/LightTaskParam.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/param/RemotePrarm.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/redis/DeviceRedisKey.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/schedule/LightTimeSynchronizationSchedule.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirDataNongGengService.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirEquipmentNongGengService.java 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirEquipmentService.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3mReportErrorService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/ClientService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/DeviceStatusCountService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/ErrorMsgService.java 57 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeService.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedPlayerEntityService.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportErrorService.java 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java 402 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java 404 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/MonitorService.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlatformFileService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleLightemitService.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java 533 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/RoleService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java 53 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/XiXunPlayerService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/utils/TerminalAPIUtils.java 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/utils/VnnoxAPIUtil.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/DeviceOnLineCountVO.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/LightTaskInfoVO.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/LightTaskRelationVO.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/LightTaskVO.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/OnLineCountVO.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/RedisDeviceStatus.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/RemoteUpgradeProgress.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/resources/application-local.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/resources/application-prod.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/resources/application.yml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/AirDataNongGeng.java
@@ -5,8 +5,8 @@
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import lombok.Data;
/**
@@ -30,82 +30,102 @@
    /**
     * å™ªå£°
     */
    private BigDecimal noise;
    private String noise;
    /**
     * ç¡«åŒ–æ°¢
     */
    private BigDecimal hydrogenSulfide;
    private String hydrogenSulfide;
    /**
     * SO2 æµ“度
     */
    private BigDecimal so2;
    private String so2;
    /**
     * NO2 æµ“度
     */
    private BigDecimal no2;
    private String no2;
    /**
     * CO æµ“度
     */
    private BigDecimal co;
    private String co;
    /**
     * o3 æµ“度
     */
    private BigDecimal o3;
    private String o3;
    /**
     * pm2.5 æµ“度
     */
    private BigDecimal pm2point5;
    private String pm2point5;
    /**
     * pm10
     */
    private BigDecimal pm10;
    private String pm10;
    /**
     * ç©ºæ°”温度
     */
    private BigDecimal airTemperature;
    private String airTemperature;
    /**
     * ç©ºæ°”湿度
     */
    private BigDecimal airHumidity;
    private String airHumidity;
    /**
     * å¤§æ°”压强
     */
    private BigDecimal airPressure;
    private String airPressure;
    /**
     * é£Žå‘
     */
    private BigDecimal windDirection;
    private String windDirection;
    /**
     * é£Žé€Ÿ
     */
    private BigDecimal windSpeed;
    private String windSpeed;
    /**
     * ååˆ†é’Ÿé›¨é‡
     */
    private BigDecimal tenRainfallMin;
    private String tenRainfallMin;
    /**
     * è¾å°„
     */
    private BigDecimal radiation;
    private String radiation;
    /**
     * å…‰ç…§
     */
    private BigDecimal illumination;
    private String illumination;
    /**
     * ç´«å¤–线
     */
    private String ultraviolet;
    /**
     * co2 äºŒæ°§åŒ–碳
     */
    private String co2;
    /**
     * æ°§æ°”
     */
    private String o2;
    /**
     * è®¾å¤‡ç±»åž‹
     */
    private String type;
    /**
     * åˆ›å»ºæ—¶é—´
dao/src/main/java/com/sandu/ximon/dao/domain/AirEquipmentNongGeng.java
@@ -1,23 +1,22 @@
package com.sandu.ximon.dao.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
 *
 * @TableName air_equipment_nong_geng
 */
@TableName(value = "air_equipment_nong_geng")
@TableName(value ="air_equipment_nong_geng")
@Data
public class AirEquipmentNongGeng implements Serializable {
    /**
     *
     *
     */
    @TableId
    private Long id;
@@ -28,6 +27,11 @@
    private String mac;
    /**
     * è®¾å¤‡ç±»åž‹  0常规型气象站  1辐射型气象站  2大气污染物气象站
     */
    private String type;
    /**
     * æŽ¥å…¥æ—¶é—´
     */
    private LocalDateTime createTime;
dao/src/main/java/com/sandu/ximon/dao/domain/LightEnergyData.java
@@ -4,21 +4,19 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Data;
/**
 * å•灯任务能耗/节能率表
 *
 * @TableName light_energy_data
 */
@TableName(value = "light_energy_data")
@TableName(value ="light_energy_data")
@Data
public class LightEnergyData implements Serializable {
    /**
     *
     *
     */
    @TableId(type = IdType.AUTO)
    private Long id;
@@ -49,6 +47,11 @@
    private Long poleId;
    /**
     * ç¯å¤´åœ°å€
     */
    private String lightAdderss;
    /**
     * ç”¨æˆ·id
     */
    private Long userId;
dao/src/main/java/com/sandu/ximon/dao/domain/LightReportError.java
@@ -6,10 +6,11 @@
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import lombok.Data;
/**
 * ç¯ä¸ŠæŠ¥æ•…障码表
 * å•灯故障数据列表
 * @TableName light_report_error
 */
@TableName(value ="light_report_error")
@@ -22,9 +23,14 @@
    private Long lightReportErrorId;
    /**
     * è®¾å¤‡mac
     * mac
     */
    private String deviceCode;
    /**
     * ç¯å¤´åœ°å€
     */
    private String lightAddress;
    /**
     * æ•…障码
@@ -32,7 +38,7 @@
    private Integer errorCode;
    /**
     * åˆ›å»ºæ—¶é—´
     *
     */
    private LocalDateTime createTime;
dao/src/main/java/com/sandu/ximon/dao/domain/LightTask.java
@@ -9,6 +9,7 @@
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
 * è·¯ç¯ä»»åŠ¡è¡¨
@@ -42,11 +43,13 @@
    /**
     * 1暂停、0启用
     */
    @JsonIgnore
    private Integer pause;
    /**
     * æ˜ŸæœŸå‡ ï¼Œä½è¿ç®—保存,1代表星期一,2星期二,4星期三,8星期四,16星期五,32星期六,64星期日
     */
    @JsonIgnore
    private Integer week;
    /**
@@ -91,4 +94,8 @@
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private List<Integer> weekList;
}
dao/src/main/java/com/sandu/ximon/dao/enums/AirNongGengEnums.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,110 @@
package com.sandu.ximon.dao.enums;
/**
 * @author LiuHaoNan
 * @date 2022/10/9
 * å¤§æ°”设备分类枚举
 */
public class AirNongGengEnums {
    /**
     * RY-G/W
     */
    public static final String RY_GW = "1";
    /**
     * RY-CPM2510
     */
    public static final String RY_CPM2510 = "2";
    /**
     * RY-CPM2516
     */
    public static final String RY_CPM2516 = "3";
    /**
     * RY-CPM2512
     */
    public static final String RY_CPM2512 = "4";
    /**
     * HCD6815
     */
    public static final String HCD_6815 = "5";
    /**
     * HCD6816Z
     */
    public static final String HCD_6816Z_1 = "6";
    /**
     * HCD6817Z
     */
    public static final String HCD_6817Z = "7";
    /**
     * HCD6816Z
     */
    public static final String HCD_6816Z_2 = "8";
    /**
     *HCD6817
     */
    public static final String HCD_6817 = "9";
    /**
     * HCD6817B
     */
    public static final String HCD_6817B = "10";
    /**
     * HCD6818A
     */
    public static final String HCD_6818A = "16";
    /**
     * HCD6818N
     */
    public static final String HCD_6818N = "18";
    /**
     * HCD6818D
     */
    public static final String HCD_6818D = "19";
    /**
     * HCD6818B
     */
    public static final String HCD_6818B = "11";
    /**
     * HCD6818E
     */
    public static final String HCD_6818E = "12";
    /**
     * HCD6818C
     */
    public static final String HCD_6818C = "13";
    /**
     * HCD6818
     */
    public static final String HCD_6818 = "14";
    /**
     * HCD6820
     */
    public static final String HCD_6820 = "15";
    /**
     * HCD6820(高配版)
     */
    public static final String HCD_6820_Pro = "17";
    /**
     * HCD6818V型网格化空气质量变送器(户外型)
     */
    public static final String HCD_6818V_Out = "20";
}
dao/src/main/java/com/sandu/ximon/dao/enums/MenuEnum.java
@@ -26,6 +26,7 @@
    GROUP_LIST("分组列表"),
    LIGHT_TASK_LIST("路灯任务列表"),
    LIGHT_DATA("单灯监控数据"),
    LIGHT_SETCALENDAR("单灯设置日历"),
    LIGHT_ERROR_LIST("单灯故障列表"),
    LED_LIST("LED屏列表"),
    LED_PROGRAM_LIST("节目列表"),
@@ -73,6 +74,7 @@
    AIR_QUERYVERSION("查询软硬件版本"),
    AIR_REBOOT("软重启"),
    AIR_DATA_UPDATE("手动更新大气数据"),
    AIR_SET_TYPE("设置农耕设备类型"),
    BANNER_ADD("添加微信logo"),
    BANNER_UPDATE("编辑微信logo"),
    BANNER_DETAIL("获取微信logo详情"),
@@ -231,10 +233,7 @@
    C3_REFUND("充电桩退款"),
    CHARGE_UPDATE("编辑费率"),
    ORDER_LIST("订单列表"),
    CHARGE_LIST("获取费率")
    ;
    CHARGE_LIST("获取费率");
    private final String code;
dao/src/main/java/com/sandu/ximon/dao/mapper/AirDataNongGengMapper.java
@@ -1,14 +1,16 @@
package com.sandu.ximon.dao.mapper;
import com.sandu.ximon.dao.bo.AirDataBo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sandu.ximon.dao.bo.AirDataNongGengBo;
import com.sandu.ximon.dao.domain.AirDataNongGeng;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
 * @author Administrator
 * @description é’ˆå¯¹è¡¨ã€air_data_nong_geng(农耕大气监测数据)】的数据库操作Mapper
 * @createDate 2022-10-14 15:01:06
 * @Entity com.sandu.ximon.dao.domain.AirDataNongGeng
 */
@Mapper
dao/src/main/java/com/sandu/ximon/dao/mapper/AirEquipmentNongGengMapper.java
@@ -1,13 +1,16 @@
package com.sandu.ximon.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sandu.ximon.dao.bo.AirEquipmentNongGengBo;
import com.sandu.ximon.dao.domain.AirEquipmentNongGeng;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
 * @author Administrator
 * @description é’ˆå¯¹è¡¨ã€air_equipment_nong_geng】的数据库操作Mapper
 * @createDate 2022-10-10 09:58:08
 * @Entity com.sandu.ximon.dao.domain.AirEquipmentNongGeng
 */
@Mapper
dao/src/main/java/com/sandu/ximon/dao/mapper/LedPlayerEntityMapper.java
@@ -15,7 +15,22 @@
    boolean saveLed(LedPlayerEntity ledPlayerEntity);
    List<LedPlayerEntity> ledPlayerEntityList(String keyword, Long userid);
    /**
     * ç”¨äºŽé™¤åˆ—表展示以外的(新增了分组操作  ä¸ºä¸å½±å“å…¶ä»–  æ–°å¢žledListByGroupId)
     * @param keyword
     * @param userId
     * @return
     */
    List<LedPlayerEntity> ledPlayerEntityList(String keyword, Long userId);
    /**
     * ç”¨äºŽåˆ—表展示
     * @param keyword
     * @param userId
     * @param groupId
     * @return
     */
    List<LedPlayerEntity> ledListByGroupId(String keyword, Long userId,Long groupId);
    List<LedPlayerEntity> ledPlayerEntityListOnBinding(String keyword, Long userid);
dao/src/main/java/com/sandu/ximon/dao/mapper/LightEnergyDataMapper.java
@@ -9,7 +9,7 @@
/**
 * @author Administrator
 * @description é’ˆå¯¹è¡¨ã€light_energy_data(单灯任务能耗/节能率表)】的数据库操作Mapper
 * @createDate 2022-05-20 14:21:29
 * @createDate 2022-09-23 11:13:50
 * @Entity com.sandu.ximon.dao.domain.LightEnergyData
 */
@Mapper
dao/src/main/java/com/sandu/ximon/dao/mapper/LightReportErrorMapper.java
@@ -1,13 +1,16 @@
package com.sandu.ximon.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sandu.ximon.dao.bo.LightReportErrorBo;
import com.sandu.ximon.dao.domain.LightReportError;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
 * @author Administrator
 * @description é’ˆå¯¹è¡¨ã€light_report_error(单灯故障数据列表)】的数据库操作Mapper
 * @createDate 2022-09-28 14:58:29
 * @Entity com.sandu.ximon.dao.domain.LightReportError
 */
@Mapper
dao/src/main/resources/mapper/AirDataNongGengMapper.xml
@@ -5,25 +5,29 @@
<mapper namespace="com.sandu.ximon.dao.mapper.AirDataNongGengMapper">
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.AirDataNongGeng">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="mac" column="mac" jdbcType="VARCHAR"/>
        <result property="noise" column="noise" jdbcType="DECIMAL"/>
        <result property="hydrogenSulfide" column="hydrogen_sulfide" jdbcType="DECIMAL"/>
        <result property="so2" column="so2" jdbcType="DECIMAL"/>
        <result property="no2" column="no2" jdbcType="DECIMAL"/>
        <result property="co" column="co" jdbcType="DECIMAL"/>
        <result property="o3" column="o3" jdbcType="DECIMAL"/>
        <result property="pm2point5" column="pm2point5" jdbcType="DECIMAL"/>
        <result property="pm10" column="pm10" jdbcType="DECIMAL"/>
        <result property="airTemperature" column="air_temperature" jdbcType="DECIMAL"/>
        <result property="airHumidity" column="air_humidity" jdbcType="DECIMAL"/>
        <result property="airPressure" column="air_pressure" jdbcType="DECIMAL"/>
        <result property="windDirection" column="wind_direction" jdbcType="DECIMAL"/>
        <result property="windSpeed" column="wind_speed" jdbcType="DECIMAL"/>
        <result property="tenRainfallMin" column="ten_rainfall_min" jdbcType="DECIMAL"/>
        <result property="radiation" column="radiation" jdbcType="DECIMAL"/>
        <result property="illumination" column="illumination" jdbcType="DECIMAL"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <id property="id" column="id" jdbcType="BIGINT"/>
            <result property="mac" column="mac" jdbcType="VARCHAR"/>
            <result property="noise" column="noise" jdbcType="VARCHAR"/>
            <result property="hydrogenSulfide" column="hydrogen_sulfide" jdbcType="VARCHAR"/>
            <result property="so2" column="so2" jdbcType="VARCHAR"/>
            <result property="no2" column="no2" jdbcType="VARCHAR"/>
            <result property="co" column="co" jdbcType="VARCHAR"/>
            <result property="o3" column="o3" jdbcType="VARCHAR"/>
            <result property="pm2point5" column="pm2point5" jdbcType="VARCHAR"/>
            <result property="pm10" column="pm10" jdbcType="VARCHAR"/>
            <result property="airTemperature" column="air_temperature" jdbcType="VARCHAR"/>
            <result property="airHumidity" column="air_humidity" jdbcType="VARCHAR"/>
            <result property="airPressure" column="air_pressure" jdbcType="VARCHAR"/>
            <result property="windDirection" column="wind_direction" jdbcType="VARCHAR"/>
            <result property="windSpeed" column="wind_speed" jdbcType="VARCHAR"/>
            <result property="tenRainfallMin" column="ten_rainfall_min" jdbcType="VARCHAR"/>
            <result property="radiation" column="radiation" jdbcType="VARCHAR"/>
            <result property="illumination" column="illumination" jdbcType="VARCHAR"/>
            <result property="ultraviolet" column="ultraviolet" jdbcType="VARCHAR"/>
            <result property="co2" column="co2" jdbcType="VARCHAR"/>
            <result property="o2" column="o2" jdbcType="VARCHAR"/>
            <result property="type" column="type" jdbcType="VARCHAR"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">
@@ -33,7 +37,8 @@
        pm10,air_temperature,air_humidity,
        air_pressure,wind_direction,wind_speed,
        ten_rainfall_min,radiation,illumination,
        create_time
        ultraviolet,co2,o2,
        type,create_time
    </sql>
    <select id="listAirId" resultType="java.lang.Long">
        SELECT
dao/src/main/resources/mapper/AirEquipmentNongGengMapper.xml
@@ -5,13 +5,15 @@
<mapper namespace="com.sandu.ximon.dao.mapper.AirEquipmentNongGengMapper">
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.AirEquipmentNongGeng">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="mac" column="mac" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <id property="id" column="id" jdbcType="BIGINT"/>
            <result property="mac" column="mac" jdbcType="VARCHAR"/>
            <result property="type" column="type" jdbcType="VARCHAR"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">
        id,mac,create_time
        id,mac,type,
        create_time
    </sql>
    <select id="listAirEquipmentByIds" resultType="com.sandu.ximon.dao.bo.AirEquipmentNongGengBo">
        SELECT
dao/src/main/resources/mapper/LedPlayerEntityMapper.xml
@@ -26,7 +26,8 @@
    <select id="ledPlayerEntityList" resultType="com.sandu.ximon.dao.domain.LedPlayerEntity">
        SELECT
        t1.*, t2.pole_id,
        t1.*,
        t2.pole_id,
        t3.pole_name
        FROM
        led t1
@@ -34,13 +35,14 @@
        AND t2.device_type = 1
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
        <where>
            1=1
            <if test="keyword != null and keyword != ''">
                AND t1.name LIKE CONCAT(CONCAT('%', #{keyword}), '%')
                OR t1.sn LIKE CONCAT(CONCAT('%', #{keyword}), '%')
                OR t1.id LIKE CONCAT(CONCAT('%', #{keyword}), '%')
            </if>
            <if test="userid != null">
                AND (t3.user_id = #{userid} OR t3.client_id = #{userid})
            <if test="userId != null">
                AND (t3.user_id = #{userId} OR t3.client_id = #{userId})
            </if>
        </where>
    </select>
@@ -79,6 +81,34 @@
            AND (t2.user_id = #{clientId} OR t2.client_id = #{clientId})
        </if>
    </select>
    <select id="ledListByGroupId" resultType="com.sandu.ximon.dao.domain.LedPlayerEntity">
        SELECT
        t1.*,
        t2.pole_id,
        t3.pole_name
        FROM
        led t1
        LEFT JOIN pole_binding t2 ON t1.sn = t2.device_code
        AND t2.device_type = 1
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
        LEFT JOIN led_nova_group_relation t4 ON t4.nova_id = t1.id
        LEFT JOIN led_nova_group t5 ON t5.group_id = t4.nova_group_id
        <where>
            1=1
            <if test="groupId != null">
                AND t5.group_id=#{groupId}
            </if>
            <if test="keyword != null and keyword != ''">
                AND t1.name LIKE CONCAT(CONCAT('%', #{keyword}), '%')
                OR t1.sn LIKE CONCAT(CONCAT('%', #{keyword}), '%')
                OR t1.id LIKE CONCAT(CONCAT('%', #{keyword}), '%')
            </if>
            <if test="userId != null">
                AND (t3.user_id = #{userId} OR t3.client_id = #{userId})
            </if>
        </where>
        GROUP BY t1.id
    </select>
</mapper>
dao/src/main/resources/mapper/LightEnergyDataMapper.xml
@@ -5,21 +5,21 @@
<mapper namespace="com.sandu.ximon.dao.mapper.LightEnergyDataMapper">
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightEnergyData">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="taskId" column="task_id" jdbcType="BIGINT"/>
        <result property="ytdTime" column="ytd_time" jdbcType="VARCHAR"/>
        <result property="energy" column="energy" jdbcType="DOUBLE"/>
        <result property="energySaving" column="energy_saving" jdbcType="DOUBLE"/>
        <result property="poleId" column="pole_id" jdbcType="BIGINT"/>
        <result property="userId" column="user_id" jdbcType="BIGINT"/>
        <result property="clientId" column="client_id" jdbcType="BIGINT"/>
            <id property="id" column="id" jdbcType="BIGINT"/>
            <result property="taskId" column="task_id" jdbcType="BIGINT"/>
            <result property="ytdTime" column="ytd_time" jdbcType="VARCHAR"/>
            <result property="energy" column="energy" jdbcType="DECIMAL"/>
            <result property="energySaving" column="energy_saving" jdbcType="DECIMAL"/>
            <result property="poleId" column="pole_id" jdbcType="BIGINT"/>
            <result property="lightAdderss" column="light_adderss" jdbcType="VARCHAR"/>
            <result property="userId" column="user_id" jdbcType="BIGINT"/>
            <result property="clientId" column="client_id" jdbcType="BIGINT"/>
    </resultMap>
    <sql id="Base_Column_List">
        id
        ,task_id,ytd_time,
        energy,energy_saving,user_id,
        client_id
        id,task_id,ytd_time,
        energy,energy_saving,pole_id,
        light_adderss,user_id,client_id
    </sql>
    <select id="getEnergyList" resultType="com.sandu.ximon.dao.domain.LightEnergyData">
        SELECT
dao/src/main/resources/mapper/LightReportErrorMapper.xml
@@ -7,6 +7,7 @@
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightReportError">
        <id property="lightReportErrorId" column="light_report_error_id" jdbcType="BIGINT"/>
        <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
        <result property="lightAddress" column="light_address" jdbcType="VARCHAR"/>
        <result property="errorCode" column="error_code" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
@@ -26,6 +27,7 @@
        AND t2.device_type = 0
        LEFT JOIN pole t3 ON t3.id = t2.pole_id
        <where>
            t1.error_code != 0
            <if test="keyword != null and keyword != ''">
                AND (
                t3.id LIKE CONCAT('%', #{keyword},'%')
@@ -45,16 +47,17 @@
    <select id="listError" resultType="com.sandu.ximon.dao.bo.LightReportErrorBo"
            parameterType="java.lang.Long">
        SELECT
            t1.*
        t1.*
        FROM
            light_report_error t1
                LEFT JOIN pole t3 ON t1.device_code = t3.device_code
        light_report_error t1
        LEFT JOIN pole t3 ON t1.device_code = t3.device_code
        WHERE
            <if test="userid != null">
                t3.client_id = #{userId} OR t3.user_id = #{userId}
                </if>
            t1.light_report_error_id IN ( SELECT t.max_id FROM ( SELECT Max( light_report_error.light_report_error_id ) AS max_id FROM light_report_error GROUP BY light_report_error.device_code ) AS t )
        <if test="userid != null">
            t3.client_id = #{userId} OR t3.user_id = #{userId}
        </if>
        t1.light_report_error_id IN ( SELECT t.max_id FROM ( SELECT Max( light_report_error.light_report_error_id ) AS
        max_id FROM light_report_error GROUP BY light_report_error.device_code ) AS t )
        ORDER BY
            t1.create_time DESC
        t1.create_time DESC
    </select>
</mapper>
ximon-admin/src/main/java/com/sandu/ximon/admin/config/BroadcastAPI.java
@@ -1,7 +1,7 @@
package com.sandu.ximon.admin.config;
/**
 * éŸ³æŸ±api
 * éŸ³æŸ±api地址
 */
public enum BroadcastAPI {
@@ -31,18 +31,18 @@
    ADD_REGION("/add_region"),
    GET_REGION_LIST("/get_region_list");
    ;
    private static final String SERVER = "http://47.106.172.9:8000";
    BroadcastAPI(String url){
    //    private String service;
//
//    private static  String SERVER = "http://47.106.172.9:8000";
    BroadcastAPI(String url) {
        this.url = url;
    }
    private String url;
    public String getUrl() {
        return SERVER + url;
        return BroadcastIP.getServerIP() + url;
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/config/BroadcastIP.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
package com.sandu.ximon.admin.config;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
 * @author LiuHaoNan
 * @date 2022/9/26
 */
@Component
public class BroadcastIP implements InitializingBean {
    private static  String SERVER;
    @Value("${broadcastApi.serviceUrl}")
    private String server;
    @Override
    public void afterPropertiesSet() throws Exception {
        SERVER = server;
    }
    public static String getServerIP() {
        return SERVER;
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/config/VnnoxConstant.java
@@ -32,15 +32,18 @@
    private String screenShotNotifyUrl;
    @Value("${nova-conf.status-notify-url}")
    private String statusNotifyUrl;
    @Value("${nova-conf.username}")
    private String userName;
    @Value("${nova-conf.password}")
    private String passWord;
    public static String NOTIFY_URL;
    public static String SCREEN_SHOT_NOTIFY_URL;
    public static String STATUS_NOTIFY_URL;
    public static String STATUS_NOTIFY_URL1;
    public static final String username = "zhxm";
    public static final String password = "xm2512209.";
    public static String username;
    public static String password;
    public static final Gson GSON = new Gson();
@@ -52,7 +55,10 @@
        SCREEN_SHOT_NOTIFY_URL = screenShotNotifyUrl;
        STATUS_NOTIFY_URL = statusNotifyUrl;
        System.out.println(STATUS_NOTIFY_URL);
        username = userName;
        password = passWord;
    }
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/AirDataNongGengController.java
@@ -5,68 +5,25 @@
 * @date 2022/4/24 17:36
 */
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.manager.iot.amqp.processor.AirDataProcessor;
import com.sandu.ximon.admin.manager.iot.frame.A5Frame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.AtmosphereNewReqInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
import com.sandu.ximon.admin.security.PermissionConfig;
import com.sandu.ximon.admin.service.AirDataNongGengService;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.dao.bo.AirDataNongGengBo;
import com.sandu.ximon.dao.enums.MenuEnum;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * å¤§æ°”数据
 */
@RestController
@AllArgsConstructor
@Slf4j
@RequestMapping("/v1/admin/airdata_nonggeng")
public class AirDataNongGengController {
    private PermissionConfig permissionConfig;
    private final AirDataNongGengService airDataNongGengService;
    @PostMapping("/updateAirEquipmentInfo")
    public ResponseVO<Object> updataAirEquipmentInfo(@RequestBody List<String> listMac) {
        AtmosphereNewReqInnerFrame atmosphereNewReqInnerFrame = new AtmosphereNewReqInnerFrame();
        A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode(), atmosphereNewReqInnerFrame);
        System.out.println(a5Frame + "          --------a5Frame");
        List<String> success = new ArrayList<>();
        List<String> failed = new ArrayList<>();
        listMac.parallelStream().forEach(macStr -> {
            try {
                CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(macStr, a5Frame);
                StoreOperationRecordsUtils.storeInnerFrameData(macStr, "大气设备-心跳包", a5Frame, commonFrame);
                System.out.println(commonFrame + "         -----------commonFrame");
                AirDataProcessor.getInstance().process("a1JsfPG4iKW", macStr, commonFrame);
                if (commonFrame != null) {
                    success.add(macStr);
                } else {
                    failed.add(macStr);
                }
            } catch (Exception e) {
                failed.add(macStr);
            }
        });
        Map<String, List> resultMap = new HashMap<>();
        resultMap.put("success", success);
        resultMap.put("failed", failed);
        return ResponseUtil.success(resultMap);
    }
    /**
     * æŸ¥è¯¢å¤§æ°”数据模糊查询
@@ -74,12 +31,12 @@
     * @param keyword å…³é”®å­—
     * @return
     */
    @GetMapping("/listAirData")
    public ResponseVO<Object> listAirDataByKeyword(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
        if (!permissionConfig.check(MenuEnum.AIR_DATA__NONG_GENG_LIST.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        List<AirDataNongGengBo> list = airDataNongGengService.listAirDataByKeyword(baseConditionVO, keyword);
        return ResponseUtil.successPage(list);
    }
//    @GetMapping("/listAirData")
//    public ResponseVO<Object> listAirDataByKeyword(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
//        if (!permissionConfig.check(MenuEnum.AIR_DATA__NONG_GENG_LIST.getCode())) {
//            return ResponseUtil.fail("缺少对应用户权限");
//        }
//        List<AirDataNongGengBo> list = airDataNongGengService.listAirDataByKeyword(baseConditionVO, keyword);
//        return ResponseUtil.successPage(list);
//    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/AirEquipmentNongGengController.java
@@ -6,6 +6,7 @@
import com.sandu.ximon.admin.security.PermissionConfig;
import com.sandu.ximon.admin.service.AirEquipmentNongGengService;
import com.sandu.ximon.dao.bo.AirEquipmentNongGengBo;
import com.sandu.ximon.dao.domain.AirEquipmentNongGeng;
import com.sandu.ximon.dao.enums.MenuEnum;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
@@ -53,4 +54,35 @@
    public ResponseVO<Object> getAirEquipment(@PathVariable String mac) {
        return ResponseUtil.success(airEquipmentNongGengService.getAirEquipment(mac));
    }
    /**
     * è®¾ç½®å¿ƒè·³åŒ…间隔时间
     *
     * @param mac
     * @param time
     * @return
     */
    @GetMapping("/setHeartBeatTime")
    public ResponseVO<Object> setHeartBeatTime(@RequestParam(value = "mac", required = false) String mac,
                                               @RequestParam(value = "time", required = false) Integer time) {
        if (!permissionConfig.check(MenuEnum.AIR_HEARTBEATTIME.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        return ResponseUtil.success(airEquipmentNongGengService.setHeartBeatTime(mac, time));
    }
    /**
     * è®¾ç½®å¤§æ°”设备农耕设备类型
     *
     * @return
     */
    @PostMapping("/setType")
    public ResponseVO<Object> setAirEquipmentType(@RequestBody AirEquipmentNongGeng param) {
        //参数使用枚举传值
        if (!permissionConfig.check(MenuEnum.AIR_SET_TYPE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        return ResponseUtil.success(airEquipmentNongGengService.setAirEquipmentType(param));
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/ErrorMsgController.java
@@ -5,7 +5,6 @@
import com.sandu.common.security.annotation.AnonymousAccess;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.service.ErrorMsgService;
import com.sandu.ximon.admin.utils.RedisUtils;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -23,9 +22,21 @@
    private final ErrorMsgService errorMsgService;
    @AnonymousAccess
    @GetMapping("/listMsg")
    public ResponseVO<Object> list(BaseConditionVO conditionVO){
    @GetMapping("/lightListMsg")
    public ResponseVO<Object> lightListMsg(BaseConditionVO conditionVO) {
        return ResponseUtil.success(errorMsgService.lightListMsg(conditionVO));
    }
      return ResponseUtil.success(errorMsgService.listMsg(conditionVO));
    @AnonymousAccess
    @GetMapping("/C3ListMsg")
    public ResponseVO<Object> C3ListMsg(BaseConditionVO conditionVO) {
        return ResponseUtil.success(errorMsgService.C3ListMsg(conditionVO));
    }
    @AnonymousAccess
    @GetMapping("/atmosphereListMsg")
    public ResponseVO<Object> atmosphereListMsg(BaseConditionVO conditionVO) {
        return ResponseUtil.success(errorMsgService.atmosphereListMsg(conditionVO));
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/IPBroadcastController.java
@@ -2,6 +2,7 @@
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.security.annotation.AnonymousAccess;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.param.BroadcastTerminalV2Param;
import com.sandu.ximon.admin.param.ReceiveParam;
@@ -83,4 +84,11 @@
            return ResponseUtil.success("修改音量失败!");
        }
    }
    @AnonymousAccess
    @PostMapping("/getInfo")
    public ResponseVO<Object> getInfo() {
       return ResponseUtil.success(IpVolumeService.getInfo());
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/LightController.java
@@ -3,10 +3,11 @@
import com.sandu.common.domain.CommonPage;
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.security.annotation.AnonymousAccess;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.param.LightControlParam;
import com.sandu.ximon.admin.param.LightPowerSettingParam;
import com.sandu.ximon.admin.param.LightRemarkParam;
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.param.*;
import com.sandu.ximon.admin.schedule.LightTimeSynchronizationSchedule;
import com.sandu.ximon.admin.security.PermissionConfig;
import com.sandu.ximon.admin.service.LightEnergyDataService;
import com.sandu.ximon.admin.service.LightReportDataService;
@@ -178,4 +179,24 @@
        return ResponseUtil.success(reportDataList);
    }
    /**
     * è®¾ç½®æ—¥åŽ†ï¼ˆåŒå¿ƒè·³åŒ…ä¸­çš„6字节日期时间)
     */
    @PostMapping("/SetCalendar")
    public ResponseVO<Object> SetCalendar(@RequestBody @Validated LightSetCalendarParam lightSetCalendarParam) {
        if (!permissionConfig.check(MenuEnum.LIGHT_SETCALENDAR.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        return ResponseUtil.success(lightService.SetCalendar(lightSetCalendarParam.getLightId(), lightSetCalendarParam.getAddress()));
    }
    @AnonymousAccess
    @GetMapping("/test")
    public ResponseVO<Object> test() {
        SpringContextHolder.getBean(LightTimeSynchronizationSchedule.class).UserSubjectRefund();
        return ResponseUtil.success(null);
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/LightTaskController.java
@@ -17,7 +17,6 @@
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * è·¯ç¯ä»»åŠ¡ç›¸å…³æŽ§åˆ¶ç±»
@@ -58,7 +57,7 @@
        if (!permissionConfig.check(MenuEnum.LIGHT_TASK_DELETE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        String result = lightTaskService.delLightTask(param.getTaskIdList());
        String result = lightTaskService.delLightTask(param.getTaskId());
        return ResponseUtil.success(result);
    }
@@ -80,22 +79,21 @@
     * @param
     * @return
     */
    @PostMapping("/clear")
    public ResponseVO<Object> clearLightTask(@RequestBody List<Long> poleIds) {
        if (!permissionConfig.check(MenuEnum.LIGHT_TASK_UPDATE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        boolean result = lightTaskService.clearLightTask(poleIds);
        return ResponseUtil.success(result);
    }
//    @PostMapping("/clear")
//    public ResponseVO<Object> clearLightTask(@RequestBody List<Long> poleIds) {
//        if (!permissionConfig.check(MenuEnum.LIGHT_TASK_UPDATE.getCode())) {
//            return ResponseUtil.fail("缺少对应用户权限");
//        }
//        boolean result = lightTaskService.clearLightTask(poleIds);
//        return ResponseUtil.success(result);
//    }
    @GetMapping("/{taskId}")
    public ResponseVO<Object> detailLightTask(@PathVariable Long taskId) {
        if (!permissionConfig.check(MenuEnum.LIGHT_TASK_DETAIL.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        Map<Object, Object> objectObjectMap = lightTaskService.detailLightTask(taskId);
        return ResponseUtil.success(objectObjectMap);
        return ResponseUtil.success(lightTaskService.detailLightTask(taskId));
    }
    /**
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
@@ -14,6 +14,7 @@
import com.sandu.ximon.admin.dto.DeviceStatusDto;
import com.sandu.ximon.admin.param.*;
import com.sandu.ximon.admin.security.PermissionConfig;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.service.AirEquipmentService;
import com.sandu.ximon.admin.service.IpVolumeService;
import com.sandu.ximon.admin.service.MonitorService;
@@ -119,6 +120,7 @@
    /**
     * åœ¨çº¿æ•°é‡
     */
//    @AnonymousAccess
    @GetMapping("/online")
    public ResponseVO<Object> online() {
        return ResponseUtil.success(poleService.poleCount());
@@ -296,9 +298,9 @@
    @AnonymousAccess
    @PostMapping("/isRegisterByCode")
    public ResponseVO<Object> getStatusByCode() {
/*//        if (!permissionConfig.check(MenuEnum.GET_STATE_BY_DEVICECODE.getCode())) {
//            return ResponseUtil.fail("缺少对应用户权限");
//        }*/
        if (!permissionConfig.check(MenuEnum.GET_STATE_BY_DEVICECODE.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        ArrayList<String> deviceCodeList = new ArrayList<>();
        deviceCodeList.add("baseDevice01");
        deviceCodeList.add("baseDevice02");
@@ -414,4 +416,12 @@
        return ResponseUtil.success(poleService.pushAirDataToXiXun(poleId));
    }
    @AnonymousAccess
    @PostMapping("/setRedis")
    public ResponseVO<Object> pushAirDataToXiXun() {
        poleService.setRedis();
        return ResponseUtil.success("更新状态完成");
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/RemoteUpdateController.java
@@ -1,18 +1,28 @@
package com.sandu.ximon.admin.controller;
import com.alibaba.fastjson.JSON;
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.dto.RemoteFileDto;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.RemoteUpdateTypeEnum;
import com.sandu.ximon.admin.param.RemotePrarm;
import com.sandu.ximon.admin.param.RemoteUpdateParam;
import com.sandu.ximon.admin.security.PermissionConfig;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.service.RemoteUpdateService;
import com.sandu.ximon.admin.utils.RedisUtils;
import com.sandu.ximon.admin.vo.RemoteUpgradeProgress;
import com.sandu.ximon.dao.enums.MenuEnum;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
/**
 * å›ºä»¶å‡çº§Controller
@@ -83,28 +93,50 @@
        }
        String orderType;
        boolean UpdateFlag = false;
        String deviceType;
        switch (remotePrarm.getDeviceType()) {
            case "MQTT串口":
            case "CAT1":
                orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode();
                break;
            case "大气":
                orderType = A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode();
                break;
            case "C3充电桩":
                orderType = A5OrderEnum.REQUEST_C3_DATA.getCode();
                break;
            case "杆体倾斜":
                orderType = A5OrderEnum.REQUEST_POLE_MONITOR_DATA.getCode();
                break;
            default:
                throw new BusinessException("升级硬件设备类型指令有误,请确认!");
        if(remotePrarm.getDeviceType()==null){
            throw new BusinessException("升级硬件设备类型指令有误,请确认!");
        }
        if (RemoteUpdateTypeEnum.MQTT_MAIN.equals(remotePrarm.getDeviceType())) {
            //MQTT主板
            orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.MQTT_MAIN;
        } else if (RemoteUpdateTypeEnum.MQTT_CORE.equals(remotePrarm.getDeviceType())) {
            //MQTT核心板
            orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.MQTT_CORE;
        } else if (RemoteUpdateTypeEnum.LIGHT.equals(remotePrarm.getDeviceType())) {
            //单灯模块
            orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.LIGHT;
        } else if (RemoteUpdateTypeEnum.C3_CHARGING.equals(remotePrarm.getDeviceType())) {
            //C3充电桩模块
            orderType = A5OrderEnum.REQUEST_C3_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.C3_CHARGING;
        } else if (RemoteUpdateTypeEnum.CAT1_MAIN.equals(remotePrarm.getDeviceType())) {
            //Cat.1主板
            orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.CAT1_MAIN;
        } else if (RemoteUpdateTypeEnum.LIGHT_POLE_HELING.equals(remotePrarm.getDeviceType())) {
            //灯杆倾斜模块
            orderType = A5OrderEnum.REQUEST_POLE_MONITOR_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.LIGHT_POLE_HELING;
        } else if (RemoteUpdateTypeEnum.AIR_EQUIPMENT.equals(remotePrarm.getDeviceType())) {
            //大气设备模块
            orderType = A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.AIR_EQUIPMENT;
        } else {
            throw new BusinessException("升级硬件设备类型指令有误,请确认!");
        }
        //启动远程升级命令
        boolean startRemoteUpdateFlag = remoteUpdateService.StartRemoteUpdate(orderType, remotePrarm.getMac(), remotePrarm.getHardwareVersion()
                , remotePrarm.getSoftwareVersion(), remotePrarm.getUpdateFlag());
        //存入升级进度
        RemoteUpgradeProgress progress = new RemoteUpgradeProgress();
        RedisUtils.getBean().set(deviceType + ":" + SecurityUtils.getUserId() + remotePrarm.getMac(), JSON.toJSON(progress));
        if (startRemoteUpdateFlag) {
            //服务器下发升级文件信息
            //"C:\\Users\\Administrator\\Desktop\\test\\MQTT-过滤大气版本1-09-20220310.bin"
@@ -112,14 +144,21 @@
            if (remoteFileDto != null) {
                System.out.println(remoteFileDto.getList().size());
                progress.setTotalProgress(remoteFileDto.getList().size() + 1);
                for (int i = 0; i < remoteFileDto.getList().size(); i++) {
                    //升级包数据
                    remoteUpdateService.UpdateData(orderType, remotePrarm.getMac(), i, remoteFileDto.getList().get(i));
                    progress.setCurrentProgress(i + 1);
                    if (i != remoteFileDto.getList().size()) {
                        RedisUtils.getBean().set(deviceType + ":" + SecurityUtils.getUserId() + remotePrarm.getMac(), JSON.toJSON(progress));
                    }
                }
                //服务器下发查询漏包帧
                boolean searchLoseDataFlag = remoteUpdateService.SearchLoseData(orderType, remotePrarm.getMac(), remoteFileDto, 0);
                if (searchLoseDataFlag) {
                    //无漏包情况  æ›´æ–°æœ€åŽè¿›åº¦ä¸º100%  å¦åˆ™æœ€é«˜å¡åœ¨99%
                    RedisUtils.getBean().set(deviceType + ":" + SecurityUtils.getUserId() + remotePrarm.getMac(), JSON.toJSON(progress));
                    //服务器下发结束升级帧
                    boolean finishUpdateFlag = remoteUpdateService.FinishUpdate(orderType, remotePrarm.getMac());
                    UpdateFlag = finishUpdateFlag;
@@ -127,6 +166,7 @@
            }
        }
        RedisUtils.getBean().delete(deviceType + ":" + SecurityUtils.getUserId() + remotePrarm.getMac());
        if (UpdateFlag) {
            return ResponseUtil.success("升级成功!");
        } else {
@@ -134,6 +174,67 @@
        }
    }
    @PostMapping("/getRemoteUpgradeProgress")
    public ResponseVO<Object> getRemoteUpgradeProgress(@RequestBody RemotePrarm remotePrarm) {
//        if (!permissionConfig.check(MenuEnum.REMOTE_UPDATE_START.getCode())) {
//            return ResponseUtil.fail("缺少对应用户权限");
//        }
        String orderType;
        String deviceType;
        if(remotePrarm.getDeviceType()==null){
            throw new BusinessException("升级硬件设备类型指令有误,请确认!");
        }
        if (RemoteUpdateTypeEnum.MQTT_MAIN.equals(remotePrarm.getDeviceType())) {
            //MQTT主板
            orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.MQTT_MAIN;
        } else if (RemoteUpdateTypeEnum.MQTT_CORE.equals(remotePrarm.getDeviceType())) {
            //MQTT核心板
            orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.MQTT_CORE;
        } else if (RemoteUpdateTypeEnum.LIGHT.equals(remotePrarm.getDeviceType())) {
            //单灯模块
            orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.LIGHT;
        } else if (RemoteUpdateTypeEnum.C3_CHARGING.equals(remotePrarm.getDeviceType())) {
            //C3充电桩模块
            orderType = A5OrderEnum.REQUEST_C3_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.C3_CHARGING;
        } else if (RemoteUpdateTypeEnum.CAT1_MAIN.equals(remotePrarm.getDeviceType())) {
            //Cat.1主板
            orderType = A5OrderEnum.REQUEST_LIGHT_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.CAT1_MAIN;
        } else if (RemoteUpdateTypeEnum.LIGHT_POLE_HELING.equals(remotePrarm.getDeviceType())) {
            //灯杆倾斜模块
            orderType = A5OrderEnum.REQUEST_POLE_MONITOR_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.LIGHT_POLE_HELING;
        } else if (RemoteUpdateTypeEnum.AIR_EQUIPMENT.equals(remotePrarm.getDeviceType())) {
            //大气设备模块
            orderType = A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode();
            deviceType=RemoteUpdateTypeEnum.AIR_EQUIPMENT;
        } else {
            throw new BusinessException("升级硬件设备类型指令有误,请确认!");
        }
        RemoteUpgradeProgress progress = new RemoteUpgradeProgress();
        String s = RedisUtils.getBean().get(deviceType + ":" + SecurityUtils.getUserId() + remotePrarm.getMac());
        if (s != null) {
            RemoteUpgradeProgress temp = JSON.parseObject(s, RemoteUpgradeProgress.class);
            BeanUtils.copyProperties(temp, progress);
        }
        Map map = new HashMap<>();
        if (progress.getTotalProgress() != 0) {
            //说明开始升级成功  å­˜åœ¨éž0进度
            BigDecimal divide = BigDecimal.valueOf(progress.getCurrentProgress()).divide(BigDecimal.valueOf(progress.getTotalProgress()), 2, BigDecimal.ROUND_HALF_UP);
            map.put("progress", divide);
            return ResponseUtil.success(map);
        } else {
            map.put("progress", BigDecimal.valueOf(0.0));
            return ResponseUtil.success(map);
        }
    }
    /**
     * æŸ¥è¯¢å›ºä»¶ç‰ˆæœ¬å·
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/VnnoxController.java
@@ -189,19 +189,27 @@
    @GetMapping("/list")
    public ResponseVO<Object> list(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword, @RequestParam(value = "order", required = false) Integer order, @RequestParam(value = "seq", required = false) Integer seq) {
    public ResponseVO<Object> list(BaseConditionVO baseConditionVO,
                                   @RequestParam(value = "keyword", required = false) String keyword,
                                   @RequestParam(value = "order", required = false) Integer order,
                                   @RequestParam(value = "seq", required = false) Integer seq,
                                   @RequestParam(value = "groupId", required = false) Long groupId) {
        if (!permissionConfig.check(MenuEnum.LED_LIST.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        return ResponseUtil.successPage(ledPlayerEntityService.ledPlayerEntityList(baseConditionVO, keyword, order, seq));
        return ResponseUtil.successPage(ledPlayerEntityService.ledPlayerEntityList(baseConditionVO, keyword, order, seq, groupId));
    }
    @GetMapping("/onLineList")
    public ResponseVO<Object> onLineList(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword, @RequestParam(value = "order", required = false) Integer order, @RequestParam(value = "seq", required = false) Integer seq) {
    public ResponseVO<Object> onLineList(BaseConditionVO baseConditionVO,
                                         @RequestParam(value = "keyword", required = false) String keyword,
                                         @RequestParam(value = "order", required = false) Integer order,
                                         @RequestParam(value = "seq", required = false) Integer seq,
                                         @RequestParam(value = "groupId", required = false) Long groupId) {
        if (!permissionConfig.check(MenuEnum.LED_LIST.getCode())) {
            return ResponseUtil.fail("缺少对应用户权限");
        }
        List<LedPlayerEntity> list = ledPlayerEntityService.ledPlayerEntityList(baseConditionVO, keyword, order, seq);
        List<LedPlayerEntity> list = ledPlayerEntityService.ledPlayerEntityList(baseConditionVO, keyword, order, seq, groupId);
        List<LedPlayerEntity> entities = vnnoxService.setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(list));
        List<LedPlayerEntity> online = new ArrayList<>();
        for (LedPlayerEntity ledPlayer : entities) {
ximon-admin/src/main/java/com/sandu/ximon/admin/dto/LightTaskDto.java
@@ -22,10 +22,10 @@
    /**
     * ç¯å¤´1是否执行
     */
    private Boolean light1 = false;
//    private Boolean light1 = false;
    /**
     * ç¯å¤´2是否执行
     */
    private Boolean light2 = false;
//    private Boolean light2 = false;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/dto/RemoteUpdateTypeDto.java
@@ -11,6 +11,7 @@
    private String fileTypeName;
    private String val;
    public RemoteUpdateTypeDto(String fileTypeName) {
        this.fileTypeName = fileTypeName;
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/dto/TerminalDto.java
@@ -15,6 +15,8 @@
    //  ç»ˆç«¯ IP åœ°å€
    private String ip;
    //  ç»ˆç«¯éŸ³é‡(1-100)
    private Integer volume;
    //  ç»ˆç«¯éŸ³é‡(1-100)
    private Integer volumn;
    //  ç»ˆç«¯ç™»é™†çš„默认音量
    private Integer defaultVolumn;
@@ -35,4 +37,6 @@
    //  å‘¼å«ç­–ç•¥ ID,要终端有呼叫功能支持
    private Integer strategy_id;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/amqp/processor/AirDataProcessor.java
@@ -31,21 +31,26 @@
    @Override
    public void process(String productKey, String deviceName, CommonFrame frame) {
        /**
         * connectType用于判断主动上报的数据是属于旧大气设备还是农耕大气设备
         * å†œè€•心跳包主动上报系统地址(MQTT请求方式):01   åŠŸèƒ½ç ï¼š03
         */
        String connectType = frame.getPayload().substring(0, 2);
        String functionCode = frame.getPayload().substring(2, 4);
        if (A5AtmosphereReportEnum.HeartBeat_Data.getCode().equals(functionCode)) {
            log.info("心跳相应——大气数据");
            A5AtmosphereHeartbeatReportInnerFrame heartbeatReportInnerFrame = new A5AtmosphereHeartbeatReportInnerFrame().transformFrame(frame.getPayload());
            if(heartbeatReportInnerFrame != null){
            if (heartbeatReportInnerFrame != null) {
                log.info(heartbeatReportInnerFrame.toString());
                SpringContextHolder.getBean(AirDataService.class).saveReportData(deviceName, heartbeatReportInnerFrame.getHeartBeatDataPackage());
            }
        } else if (A5AtmosphereReportEnum.HeartBeat_Data_Nong_Geng.getCode().equals(functionCode)) {
        } else if (A5AtmosphereReportEnum.HeartBeat_Data_Nong_Geng.getCode().equals(functionCode) && "01".equals(connectType)) {
            log.info("心跳相应——大气数据(农耕)");
            A5AtmosphereNewHeartbeatReportInnerFrame heartbeatReportInnerFrame = new A5AtmosphereNewHeartbeatReportInnerFrame().transformFrame(frame.getPayload());
            if (heartbeatReportInnerFrame != null && heartbeatReportInnerFrame.isValidate()) {
                log.info(heartbeatReportInnerFrame.toString());
                SpringContextHolder.getBean(AirDataNongGengService.class).saveReportData(deviceName, heartbeatReportInnerFrame.getHeartBeatDataPackage());
            }else{
            } else {
                System.out.println("数据校验异常!");
            }
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/amqp/processor/LightDataProcessor.java
@@ -49,17 +49,26 @@
            }
        } else if (A5LightReportEnum.Time_Synchronized.getCode().equals(functionCode)) {
//            log.info("请求时间同步");
            log.info("请求时间同步");
            A5LightTimeSyncReportInnerFrame syncRespInnerFrame = new A5LightTimeSyncReportInnerFrame().transformFrame(frame.getPayload());
//            log.info(syncRespInnerFrame.toString());
            log.info(syncRespInnerFrame.toString());
            if (syncRespInnerFrame.isValidate()) {
                SpringContextHolder.getBean(LightService.class).timeSynchronizationInitiative(deviceName, syncRespInnerFrame.getDestinationAddress());
            }
        } else if (A5LightReportEnum.Error_Code.getCode().equals(functionCode)) {
            log.info("故障码上报");
            A5LightErrorCodeReportInnerFrame codeRespInnerFrame = new A5LightErrorCodeReportInnerFrame().transformFrame(frame.getPayload());
            log.info(codeRespInnerFrame.isValidate() + "是否通过校验");
            log.info(codeRespInnerFrame.getErrorCode() + "故障码");
            if (codeRespInnerFrame.isValidate() && (codeRespInnerFrame.getErrorCode() != 0)) {
            if (codeRespInnerFrame.isValidate()) {
                SpringContextHolder.getBean(LightReportErrorService.class).saveReportError(deviceName, codeRespInnerFrame);
            }
            //0000  è¡¨ç¤ºæ²¡æœ‰æ•…障,发送清除故障指令
            if (codeRespInnerFrame.getErrorCode() == 0) {
                System.out.println("清除故障操作!");
                SpringContextHolder.getBean(LightReportErrorService.class).cleanErrorCode(deviceName, codeRespInnerFrame.getDestinationAddress());
            }
        }
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/report/A5AtmosphereNewHeartbeatReportInnerFrame.java
@@ -5,6 +5,7 @@
import com.sandu.ximon.admin.manager.iot.frame.inner.IResponseInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC16Utils;
import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils;
import com.sandu.ximon.admin.manager.iot.rrpc.util.CRCUtils;
import lombok.Data;
import java.math.BigDecimal;
@@ -15,7 +16,7 @@
 */
@Data
public class A5AtmosphereNewHeartbeatReportInnerFrame extends BaseResponseInnerFrame<A5AtmosphereNewHeartbeatReportInnerFrame> {
    //ff03200241000000000000000000000009000a198a186327b8000c000000000000000b8c35c1cad6bf
    //010326FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1B341022277F000D05B5000000015DDD0000FFFF000070C9    ä¸»åŠ¨ä¸ŠæŠ¥å¿ƒè·³åŒ…
    private HeartBeatDataPackage heartBeatDataPackage;
    @Override
@@ -26,7 +27,7 @@
        }
        //校验
        hex = hex.replaceAll(" ", "");
        if (hex.length() < 74) {
        if (hex.length() != 86) {
            return null;
        }
@@ -44,9 +45,9 @@
        setHeartBeatDataPackage(heartBeatDataPackage);
        setCrc16(hex.substring(hex.length() - 4));
        //  æ ¡éªŒCRC32
        //  æ ¡éªŒCRC16
        String frame = hex.substring(0, hex.length() - 4);
        this.setValidate(getCrc16().equals(CRC16Utils.getCRC16(frame)));
        this.setValidate(getCrc16().equals(CRCUtils.getCRC16(frame)));
        return this;
    }
@@ -84,47 +85,137 @@
        private BigDecimal radiation;
        //("光照")
        private BigDecimal illumination;
        //紫外指数
        private BigDecimal ultraviolet;
        //CO2
        private BigDecimal co2;
        //负氧离子
        private BigDecimal o2;
        @Override
        public HeartBeatDataPackage transformFrame(String hex) {
            //ff   03  20   0241000000000000000000000009000a198a186327b8000c000000000000000b8c35c1ca(参考值)
            // 0241 0000  0000 0000 0000 0000 0009  000a  198a  1863  27b8  000c  0000  0000  0000  000b  8c35  c1ca
//            010326FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1B341022277F000D05B5000000015DDD0000FFFF000070C9    ä¸»åŠ¨ä¸ŠæŠ¥å¿ƒè·³åŒ…
//            01:系统地址
//            03:功能码
//            26:数据段字 èŠ‚æ•°é‡
//            FFFF:噪声-------》
//            FFFF:硫化氢-------》
//            FFFF:SO2 æµ“度-------》
//            FFFF:NO2 æµ“度-------》
//            FFFF:CO æµ“度-------》
//            FFFF:O3 æµ“度-------》
//            FFFF:PM2.5 æµ“度-------》
//            FFFF:PM10 æµ“度-------》
//            1B34:空气温度-------》29.64℃
//            1022:空气湿度-------》41.30%
//            277F:大气压强-------》101.11hPa
//            000D:风速-------》0.13m/s
//            05B5:风向-------》146.1°
//            0000:连续雨量-------》0mm
//            0001:辐射-------》1W/㎡
//            5DDD:光照-------》240.29Klux
//            0000:紫外指数-------》
//            FFFF:CO2-------》
//            0000:负氧离子-------》
//            70C9:CRC16 æ ¡éªŒä½
            //噪声
            this.noise = BigDecimal.valueOf(parseVal(hex, 6, 10) / 10.0);
            if (isValidData(hex, 6, 10)) {
                this.noise = new BigDecimal(parseVal(hex, 6, 10)).divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP);
            }
            //硫化氢
            this.hydrogenSulfide = BigDecimal.valueOf(parseVal(hex, 10, 14) / 1.0);
            if (isValidData(hex, 10, 14)) {
                this.hydrogenSulfide = new BigDecimal(parseVal(hex, 10, 14));
            }
            //SO2 æµ“度
            this.so2 = BigDecimal.valueOf(parseVal(hex, 14, 18) / 1.0);
            if (isValidData(hex, 14, 18)) {
                this.so2 = new BigDecimal(parseVal(hex, 14, 18));
            }
            //NO2 æµ“度
            this.no2 = BigDecimal.valueOf(parseVal(hex, 18, 22) / 1.0);
            if (isValidData(hex, 18, 22)) {
                this.no2 = new BigDecimal(parseVal(hex, 18, 22));
            }
            //CO æµ“度
            this.co = BigDecimal.valueOf(parseVal(hex, 22, 26) / 1.0);
            if (isValidData(hex, 22, 26)) {
                this.co = new BigDecimal(parseVal(hex, 22, 26));
            }
            //O3 æµ“度
            this.o3 = BigDecimal.valueOf(parseVal(hex, 26, 30) / 1.0);
            if (isValidData(hex, 26, 30)) {
                this.o3 = new BigDecimal(parseVal(hex, 26, 30));
            }
            //PM2.5 æµ“度
            this.pm2point5 = BigDecimal.valueOf(parseVal(hex, 30, 34) / 1.0);
            if (isValidData(hex, 30, 34)) {
                this.pm2point5 = new BigDecimal(parseVal(hex, 30, 34));
            }
            //PM10 æµ“度
            this.pm10 = BigDecimal.valueOf(parseVal(hex, 34, 38) / 1.0);
            if (isValidData(hex, 34, 38)) {
                this.pm10 = new BigDecimal(parseVal(hex, 34, 38));
            }
            //空气温度
            this.airTemperature = BigDecimal.valueOf(parseVal(hex, 38, 42) / 100.0 - 40);
            if (isValidData(hex, 38, 42)) {
                this.airTemperature = new BigDecimal(parseVal(hex, 38, 42)).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP).subtract(new BigDecimal(40));
            }
            //空气湿度
            this.airHumidity = BigDecimal.valueOf(parseVal(hex, 42, 46) / 100.0);
            if (isValidData(hex, 42, 46)) {
                this.airHumidity = new BigDecimal(parseVal(hex, 42, 46)).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
            }
            //大气压强
            this.airPressure = BigDecimal.valueOf(parseVal(hex, 46, 50) / 10.0);
            if (isValidData(hex, 46, 50)) {
                this.airPressure = new BigDecimal(parseVal(hex, 46, 50)).divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP);
            }
            //风速
            this.windSpeed = BigDecimal.valueOf(parseVal(hex, 50, 54) / 100.0);
            if (isValidData(hex, 50, 54)) {
                this.windSpeed = new BigDecimal(parseVal(hex, 50, 54)).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
            }
            //风向
            this.windDirection = BigDecimal.valueOf(parseVal(hex, 54, 58) / 10.0);
            if (isValidData(hex, 54, 58)) {
                this.windDirection = new BigDecimal(parseVal(hex, 54, 58)).divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP);
            }
            //10 åˆ†é’Ÿé›¨é‡
            this.tenRainfallMin = BigDecimal.valueOf(parseVal(hex, 58, 62) / 10.0);
            if (isValidData(hex, 58, 62)) {
                this.tenRainfallMin = new BigDecimal(parseVal(hex, 58, 62)).divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP);
            }
            //辐射
            this.radiation = BigDecimal.valueOf(parseVal(hex, 62, 66) / 1.0);
            if (isValidData(hex, 62, 66)) {
                this.radiation = new BigDecimal(parseVal(hex, 62, 66));
            }
            //光照
            this.illumination = BigDecimal.valueOf(parseVal(hex, 66, 70) / 100.0);
            if (isValidData(hex, 66, 70)) {
                this.illumination = new BigDecimal(parseVal(hex, 66, 70)).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
            }
            //紫外指数
            if (isValidData(hex, 70, 74)) {
                this.ultraviolet = new BigDecimal(parseVal(hex, 70, 74)).divide(new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP);
            }
            //CO2
            if (isValidData(hex, 74, 78)) {
                this.co2 = new BigDecimal(parseVal(hex, 74, 78));
            }
            //负氧离子
            if (isValidData(hex, 78, 82)) {
                this.o2 = BigDecimal.valueOf(parseVal(hex, 78, 82) * 10.0);
                this.o2 = new BigDecimal(parseVal(hex, 78, 82)).multiply(new BigDecimal(1));
            }
            return this;
        }
        /**
         * åˆ¤æ–­è¯¥å¤§æ°”设备是否有对应的感应器
         *
         * @param value
         * @param startIndex
         * @param endIndex
         * @return
         */
        private boolean isValidData(String value, int startIndex, int endIndex) {
            //FFFF是代表这个设备不支持这个数据项。0000是表示支持但是数据为零
            if ("FFFF".equals(value.substring(startIndex, endIndex))) {
                return false;
            } else {
                return true;
            }
        }
        private Integer parseVal(String frame, int start, int end) {
            return Integer.parseInt(frame.substring(start, end), 16);
        }
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/report/A5LightOperationReportInnerFrame.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,68 @@
package com.sandu.ximon.admin.manager.iot.frame.inner.report;
import cn.hutool.core.util.StrUtil;
import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils;
import lombok.Data;
import lombok.ToString;
/**
 * @author ZZQ
 * @date 2022/3/14 16:36
 * å•灯操作指令响应帧
 */
@Data
@ToString(callSuper = true)
public class A5LightOperationReportInnerFrame extends BaseResponseInnerFrame<A5LightOperationReportInnerFrame> {
    //MAC地址
    private String address;
    private String state;
    @Override
    public A5LightOperationReportInnerFrame transformFrame(String hex) {        //  é•¿åº¦ä¸ä¸€è‡´æ—¶ï¼Œè¿”回null
        if (StrUtil.isBlank(hex)) {
            return null;
        }
        // MQTT通信方式(1)
        setConnectType(hex.substring(0, 2));
        //  åŠŸèƒ½ç (1)
        setFunctionCode(hex.substring(2, 4));
        //  è´Ÿè·é•¿åº¦(2)
        setPayloadLength(hex.substring(4, 8));
        //MAC地址
        setAddress(hex.substring(8, 12));
        //硬件交互响应结果
        setState(returnState(hex.substring(12, 14)));
        setCrc32(hex.substring(hex.length() - 8));
        //  æ ¡éªŒCRC32
        String frame = hex.substring(2, hex.length() - 8);
        this.setValidate(CRC32Utils.validateFrame(frame, getCrc32()));
        return this;
    }
    public String returnState(String stateCode) {
        String State = "";
        switch (stateCode) {
            case "00":
                State = "操作成功";
                break;
            case "01":
                State = "校验码错误";
                break;
            case "02":
                State = "长度错误";
                break;
            case "03":
                State = "写Flash失败错误";
                break;
            case "FF":
                State = "其他错误";
                break;
            default:
                State = "未知错误";
        }
        return State;
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/request/A5LightCleanErrorCodeInnerFrame.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
package com.sandu.ximon.admin.manager.iot.frame.inner.request;
import com.sandu.ximon.admin.manager.iot.frame.inner.IRequestInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5LightDataEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.MQTTConnectTypeEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils;
/**
 * A5->01->29 æ•…障码上报清除
 */
public class A5LightCleanErrorCodeInnerFrame implements IRequestInnerFrame {
    //灯头地址
    private String payload;
    public A5LightCleanErrorCodeInnerFrame(String address) {
        this.payload = address;
    }
    @Override
    public String getEncodeFrame() {
        String functionCode = A5LightDataEnum.LightCleanErrorCode.getCode();
        String payloadLength = "0002";
        String frame = functionCode + payloadLength + payload;
        return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(frame.toUpperCase());
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/request/A5LightSetCalendarReqInnerFrame.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,35 @@
package com.sandu.ximon.admin.manager.iot.frame.inner.request;
import com.sandu.ximon.admin.manager.iot.frame.inner.IRequestInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5LightDataEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.C3ChargingEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.MQTTConnectTypeEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils;
/**
 * å•灯设置日历
 *
 * @author ZZQ
 * @date 2022/3/3 16:43
 */
public class A5LightSetCalendarReqInnerFrame implements IRequestInnerFrame {
    private final String payload;
    public A5LightSetCalendarReqInnerFrame(String lightAddress, int year, int month, int day, int hour, int min, int sec) {
        payload = lightAddress + hex10To16(year) + hex10To16(month) + hex10To16(day) + hex10To16(hour) + hex10To16(min) + hex10To16(sec);
    }
    @Override
    public String getEncodeFrame() {
        String functionCode = A5LightDataEnum.SetCalendar.getCode();
        String payloadLength = "0008";
        String frame = functionCode + payloadLength + payload;
        return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(frame.toUpperCase());
//        return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(payload.toUpperCase());
    }
    private String hex10To16(int value) {
        return String.format("%02X", value);
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/frame/inner/request/AtmosphereNewReqInnerFrame.java
@@ -23,10 +23,10 @@
    @Override
    public String getEncodeFrame() {
        String functionCode = NewAtmoFunctionCode.NewQueryHeartBeat.getCode();
        String payloadLength = "0000";
        String payload = "0010";
        String sensorAddress = "0000";
        String sensorNums = "0013";
        String frame = MQTTConnectTypeEnum.NONG_GENG_SYSTEM_ADDRESS.getCode() + functionCode + payloadLength + payload;
        String frame = MQTTConnectTypeEnum.NONG_GENG_SYSTEM_ADDRESS.getCode() + functionCode + sensorAddress + sensorNums;
        return frame.toUpperCase() + CRC16Utils.getCRC16(frame.toUpperCase());
    }
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/enums/A5LightDataEnum.java
@@ -14,10 +14,15 @@
    //  å…‰æ„ŸæŽ§åˆ¶
    LightSensorControl("04"),
    //设置定时控灯参数
    LightTimer("23"),
    // æ¸…除单灯累计数据
    LightReset("25"),
    //故障码上报清除
    LightCleanErrorCode("29"),
    //设置日历(同心跳包中的6字节日期时间)
    SetCalendar("28"),
    LIGHT_HEART_BEAT("LightReportData:light_heart_beat/");
    A5LightDataEnum(String code) {
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/enums/RemoteUpdateTypeEnum.java
@@ -10,46 +10,36 @@
 * @author ZZQ
 * @date 2022/4/12 11:39
 */
public enum RemoteUpdateTypeEnum {
public class RemoteUpdateTypeEnum {
    //“MQTT主板”、“MQTT核心板”、“单灯模块”、“C3充电桩模块”、“Cat.1主板”,“灯杆倾斜模块”和“大气设备模块”这7个类型
    //  MQTT主板
    MQTT_MAIN("0"),
    public static String MQTT_MAIN = "MQTT主板";
    //  MQTT核心板
    MQTT_CORE("1"),
    public static String MQTT_CORE = "MQTT核心板";
    //  å•灯模块
    LIGHT("2"),
    public static String LIGHT = "单灯模块";
    //  C3充电桩模块
    C3_CHARGING("3");
    private String code;
    public String getCode() {
        return code;
    }
    RemoteUpdateTypeEnum(String code) {
        this.code = code;
    }
    public static String C3_CHARGING = "C3充电桩模块";
    //  Cat.1主板
    public static String CAT1_MAIN = "Cat.1主板";
    //  ç¯æ†å€¾æ–œæ¨¡å—
    public static String LIGHT_POLE_HELING = "灯杆倾斜模块";
    //  å¤§æ°”设备模块
    public static String AIR_EQUIPMENT = "大气设备模块";
    public static List<RemoteUpdateTypeDto> getAllType() {
        List<RemoteUpdateTypeDto> list = new ArrayList<>();
        for (RemoteUpdateTypeEnum r : RemoteUpdateTypeEnum.values()) {
            RemoteUpdateTypeDto remoteUpdateTypeEntity = new RemoteUpdateTypeDto();
            remoteUpdateTypeEntity.setVal(r.getCode());
            remoteUpdateTypeEntity.setFileTypeName(map.get(r.getCode()));
            list.add(remoteUpdateTypeEntity);
        }
        list.add(new RemoteUpdateTypeDto(MQTT_MAIN));
        list.add(new RemoteUpdateTypeDto(MQTT_CORE));
        list.add(new RemoteUpdateTypeDto(LIGHT));
        list.add(new RemoteUpdateTypeDto(C3_CHARGING));
        list.add(new RemoteUpdateTypeDto(CAT1_MAIN));
        list.add(new RemoteUpdateTypeDto(LIGHT_POLE_HELING));
        list.add(new RemoteUpdateTypeDto(AIR_EQUIPMENT));
        return list;
    }
    private static ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>() {
        {
            put("0", "MQTT核心板");
            put("1", "Cat.1主板");
            put("2", "C3充电桩模块");
            put("3", "大气设备模块");
            put("4", "杆体倾斜模块");
        }
    };
}
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/mainboard/MainBoardInvokeSyncService.java
@@ -1,22 +1,10 @@
package com.sandu.ximon.admin.manager.iot.rrpc.mainboard;
import com.alibaba.fastjson.JSON;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.iot.model.v20180120.InvokeThingServiceResponse;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.sandu.common.execption.BusinessException;
import com.sandu.ximon.admin.manager.iot.amqp.MqttMainBoardConfig;
import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.BaseInvokeSyncService;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.InvokeParam;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.WrapResponseCommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.util.FrameUtils;
import org.springframework.beans.BeanUtils;
import java.util.Map;
/**
 * @author chenjiantian
@@ -26,7 +14,7 @@
public class MainBoardInvokeSyncService extends BaseInvokeSyncService {
    private static volatile DefaultAcsClient client = null;
    private final static String PRODUCT_KEY = "a1JsfPG4iKW";
    private final static String PRODUCT_KEY = "a1JsfPG4iKW"; //todo   æå–到配置文件
    @Override
    public String getProductKey() {
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/util/CRCUtils.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,24 @@
package com.sandu.ximon.admin.manager.iot.rrpc.util;
public class CRCUtils {
    /**
     * è®¡ç®—CRC16/Modbus校验码  é«˜ä½åœ¨å‰,低位在后
     *
     * @param hex åå…­è¿›åˆ¶å­—符串
     * @return CRC16校验码
     */
    public static String getCRC16 (String hex) {
        byte[] tx_buff = SupplementUtils.hexStringToBytes(hex);
        int[] result = CRCValidate.calculateCRC(tx_buff, 0, tx_buff.length);
        String hex1 = Integer.toHexString(result[1]);
        String hex2 = Integer.toHexString(result[0]);
        if (hex1.length()<2) {
            hex1 = "0" + hex1;
        }
        if (hex2.length()<2) {
            hex2 = "0" + hex2;
        }
        return ( hex2 + hex1 ).toUpperCase();
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/util/CRCValidate.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,210 @@
package com.sandu.ximon.admin.manager.iot.rrpc.util;
/**
 * Created by 11833 on 2018/1/5.
 */
public class CRCValidate {
    private static final String TAG="CRCValidate";
    /**
     *  è®¡ç®—CRC
     * */
    public static final int[] calculateCRC(byte[] data, int offset, int len) {
        int[] crc = { 0xFF, 0xFF };
        int nextByte = 0;
        int uIndex;
        for (int i = offset; i < len && i < data.length; i++) {
            nextByte = 0xFF & ((int) data[i]);
            uIndex = crc[0] ^ nextByte;
            crc[0] = crc[1] ^ auchCRCHi[uIndex];
            crc[1] = auchCRCLo[uIndex];
        }
        return crc;
    }// calculateCRC
    /**
     * é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·ä¸€ä½CRC??锟斤拷锟斤拷位锟斤拷锟?
     * é”Ÿæ–¤æ‹·ä¸€é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·è¦é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿçµ™uff
     * é”Ÿæ–¤æ‹·ä¸€é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·å§‹ä½é”Ÿæ–¤æ‹·
     * é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿå§é•¿é”Ÿæ–¤æ‹·
     *
     * */
    public static final int calculateSingleCRC(byte[] data, int offset, int len) {
        int crc = data[offset];
        /* pass through message buffer */
        for (int i = offset+1; i < (offset+len) && i < data.length; i++) {
            crc = crc ^ ((int) data[i]); // *puchMsg++; /* calculate the CRC */
        }
        return crc;
    }
    /**
     * /锟斤拷锟斤拷CRC?? é”Ÿæ–¤æ‹·ä¸€é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·è¦é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”ŸçµšalcStr
     * // "01 10 00 5e 00 02 04 11 12 13 14"锟矫碉拷crc="df 19"
     */
    public static final String calculateStringCRC(String calcStr) {
        String crcStr = null;
        if (SupplementUtils.isHex(calcStr)) {
            byte[] data = SupplementUtils.hexStringToBytes(calcStr);
            int[] crcIntArr = CRCValidate.calculateCRC(data, 0, data.length);
            byte[] crcByteArr1 = { 0, (byte) crcIntArr[0] };
            byte[] crcByteArr2 = { 0, (byte) crcIntArr[1] };
//            String crcStr1 = HexStrConvertUtil.bytesToHexString(crcByteArr1).substring(2);
//            String crcStr2 = HexStrConvertUtil.bytesToHexString(crcByteArr2).substring(2);
//            crcStr = crcStr1 + " " + crcStr2;
        }
        return crcStr.toLowerCase();
    }
    /* Table of CRC values for high-order byte */
    private final static short[] auchCRCHi = {
            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
            0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
            0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
            0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
            0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
            0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
            0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
            0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
            0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
            0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
            0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
            0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
            0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40
    };
    /* Table of CRC values for low-order byte */
    private final static short[] auchCRCLo = {
            0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06,
            0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD,
            0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09,
            0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A,
            0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4,
            0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,
            0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3,
            0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4,
            0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A,
            0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29,
            0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED,
            0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,
            0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60,
            0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67,
            0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F,
            0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68,
            0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E,
            0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,
            0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71,
            0x70, 0xB0, 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92,
            0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C,
            0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B,
            0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B,
            0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,
            0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42,
            0x43, 0x83, 0x41, 0x81, 0x80, 0x40
    };
    /*
     * é”Ÿå«è®¹æ‹·CRC值锟角凤拷锟斤拷确--CRC校锟斤拷
     */
    public static Boolean isCRCConfig(byte[] buff) {
        int offset = 0;
        int len = buff.length - 2;
        // é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·å‰é”Ÿæ–¤æ‹·æ¨¡é”Ÿæ–¤æ‹·é”Ÿè¡—凤拷锟街革拷睢拷锟斤拷荩锟斤拷锟斤拷锟叫o拷锟斤拷耄╋拷锟?
        // é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·CRC值,(锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷要锟斤拷锟斤拷锟絙uff é”Ÿæ–¤æ‹·ä¸€é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·å§‹ä½ é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿæ–¤æ‹·é”Ÿå§é•¿é”Ÿæ–¤æ‹·)
        int[] crc = CRCValidate.calculateCRC(buff, offset, len);
        // é”Ÿé¥ºæ–¤æ‹·buff锟斤拷锟斤拷锟斤拷锟轿籆RC锟斤拷锟角凤拷锟斤拷诩锟斤拷锟斤拷锟斤拷锟斤拷CRC锟斤拷
        return (byte) crc[0] == buff[buff.length - 2] & (byte) crc[1] == buff[buff.length - 1];
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/manager/iot/rrpc/util/SupplementUtils.java
@@ -76,4 +76,18 @@
    }
    public static boolean isHex(String str) {
        boolean isHexFlg = true;
        int i = 0;
        char c;
        for (i = 0; i < str.length(); i++) {
            c = str.charAt(i);
            if (!(((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F')) || ((c >= 'a') && (c <= 'f')) || (c == ' '))) {
                isHexFlg = false;
                break;
            }
        }
        return isHexFlg;
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/param/LightSetCalendarParam.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
package com.sandu.ximon.admin.param;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
 * @author ZZQ
 * @date 2022/3/3 18:07
 */
@Data
public class LightSetCalendarParam {
    @NotNull(message = "单灯ID不能为空")
    private Long lightId;
    /**
     * ç¯å¤´åœ°å€
     */
    private String address;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/param/LightTaskDelParam.java
@@ -1,11 +1,8 @@
package com.sandu.ximon.admin.param;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
 * @author chenjiantian
@@ -14,7 +11,7 @@
@Data
public class LightTaskDelParam {
    @NotEmpty(message = "任务id不能为空")
    private List<Long> taskIdList;
    @NotNull(message = "任务id不能为空")
    private Long taskId;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/param/LightTaskParam.java
@@ -5,7 +5,6 @@
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
@@ -51,4 +50,7 @@
    private String lightAddress;
    private List<Long> poleIdList;
    private Long taskId;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/param/RemotePrarm.java
@@ -22,7 +22,7 @@
    private String mac;
    /**
     * è®¾å¤‡ç±»åž‹ï¼Œå•灯/大气/C3充电桩/杆体倾斜
     * â€œMQTT主板”、“MQTT核心板”、“单灯模块”、“C3充电桩模块”、“Cat.1主板”,“灯杆倾斜模块”和“大气设备模块”这7个类型
     */
    @NotEmpty
    private String deviceType;
ximon-admin/src/main/java/com/sandu/ximon/admin/redis/DeviceRedisKey.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,48 @@
package com.sandu.ximon.admin.redis;
/**
 * @author LiuHaoNan
 * @date 2022/9/26
 */
public class DeviceRedisKey {
    /**
     * éŸ³æŸ±
     */
    public static final String IP_BROADCAST = "volume:";
    /**
     * æ‘„像头
     */
    public static final String MONITOR = "monitor:";
    /**
     * å•灯
     */
    public static final String LIGHT_DEVICE = "lightDevice:";
    /**
     * å……电桩
     */
    public static final String C3M = "c3m:";
    /**
     * å¤§æ°”
     */
    public static final String AIR = "air:";
    /**
     * å†œè€•
     */
    public static final String AIR_NONGGENG = "airNongGeng:";
    /**
     * ç†™æ±›
     */
    public static final String XIXUN = "led_xixun:";
    /**
     * è¯ºç“¦
     */
    public static final String NOVA = "led_nova:";
}
ximon-admin/src/main/java/com/sandu/ximon/admin/schedule/LightTimeSynchronizationSchedule.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,87 @@
package com.sandu.ximon.admin.schedule;
import com.alibaba.fastjson.JSONObject;
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.service.LightService;
import com.sandu.ximon.admin.service.LightTaskPoleRelationService;
import com.sandu.ximon.dao.domain.Light;
import com.sandu.ximon.dao.domain.LightTask;
import com.sandu.ximon.dao.domain.LightTaskPoleRelation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
/**
 * å•灯同步时间定时
 */
@Component
@Slf4j
@AllArgsConstructor
@EnableScheduling
public class LightTimeSynchronizationSchedule {
    private final LightService lightService;
    private final LightTaskPoleRelationService lightTaskPoleRelationService;
    //每天02:00 å¼€å§‹æ‰§è¡Œ
    @Scheduled(cron = "0 0 2 * * ? ")
    public void UserSubjectRefund() {
        //所有单灯数据
        List<Light> lightList = lightService.list();
        //单灯任务
        List<LightTaskPoleRelation> lightTaskPoleRelationList =
                lightTaskPoleRelationService.list();
        /**
         * åŽ»é™¤æ— æ•ˆæ•°æ®
         */
        lightTaskPoleRelationList = lightTaskPoleRelationList.stream().filter(bean -> bean.getDeviceScheduled() != null).collect(Collectors.toList());
        Map<String, LightTask> map = new HashMap<>();
        for (LightTaskPoleRelation bean : lightTaskPoleRelationList) {
            LightTask lightTask = JSONObject.parseObject(bean.getDeviceScheduled(), LightTask.class);
            map.put(bean.getDeviceCode() + bean.getLightAddress(), lightTask);
        }
        for (Light light : lightList) {
            //TODO
            if (!light.getDeviceCode().equals("32313243305007ff8711ffff")) {
                continue;
            }
            if (map.get(light.getDeviceCode() + "0001") != null) {
                /**
                 * å‚æ•°1:单灯信息
                 * å‚æ•°2:单灯任务
                 */
                lightService.timeSynchronization(light, "0001", map.get(light.getDeviceCode() + "0001"));
            } else {
                /**
                 * å‚æ•°1:单灯信息
                 * å‚æ•°2:任务为null
                 */
                lightService.timeSynchronization(light, "0001", null);
            }
            if (map.get(light.getDeviceCode() + "0002") != null) {
                /**
                 * å‚æ•°1:单灯信息
                 * å‚æ•°2:单灯任务
                 */
                lightService.timeSynchronization(light, "0002", map.get(light.getDeviceCode() + "0002"));
            } else {
                /**
                 * å‚æ•°1:单灯信息
                 * å‚æ•°2:任务为null
                 */
                lightService.timeSynchronization(light, "0002", null);
            }
        }
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirDataNongGengService.java
@@ -1,26 +1,15 @@
package com.sandu.ximon.admin.service;
import cn.hutool.core.collection.CollUtil;
import com.github.pagehelper.PageHelper;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereNewHeartbeatReportInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.AtmoFunctionCode;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.RedisUtils;
import com.sandu.ximon.dao.bo.AirDataBo;
import com.sandu.ximon.dao.bo.AirDataNongGengBo;
import com.sandu.ximon.dao.domain.AirData;
import com.sandu.ximon.dao.domain.AirDataNongGeng;
import com.sandu.ximon.dao.domain.AirEquipment;
import com.sandu.ximon.dao.domain.AirEquipmentNongGeng;
import com.sandu.ximon.dao.mapper.AirDataNongGengMapper;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * å¤§æ°”数据,农耕硬件
@@ -41,7 +30,45 @@
    public boolean saveReportData(String deviceName, A5AtmosphereNewHeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage) {
        AirDataNongGeng airDataNongGeng = new AirDataNongGeng();
        BeanUtils.copyProperties(heartBeatDataPackage, airDataNongGeng);
        //("噪声")
        airDataNongGeng.setNoise(heartBeatDataPackage.getNoise() == null ? null : heartBeatDataPackage.getNoise() + "dB");
        //("硫化氢")
        airDataNongGeng.setHydrogenSulfide(heartBeatDataPackage.getHydrogenSulfide() == null ? null : heartBeatDataPackage.getHydrogenSulfide() + "");
        //("SO2 æµ“度")
        airDataNongGeng.setSo2(heartBeatDataPackage.getSo2() == null ? null : heartBeatDataPackage.getSo2() + "ppb");
        //("NO2 æµ“度")
        airDataNongGeng.setNo2(heartBeatDataPackage.getNo2() == null ? null : heartBeatDataPackage.getNo2() + "ppb");
        //("CO æµ“度")
        airDataNongGeng.setCo(heartBeatDataPackage.getCo() == null ? null : heartBeatDataPackage.getCo() + "ppb");
        //("O3 æµ“度")
        airDataNongGeng.setO3(heartBeatDataPackage.getO3() == null ? null : heartBeatDataPackage.getO3() + "ppb");
        //("PM2.5 æµ“度")
        airDataNongGeng.setPm2point5(heartBeatDataPackage.getPm2point5() == null ? null : heartBeatDataPackage.getPm2point5() + "ug/m³");
        //("PM10 æµ“度")
        airDataNongGeng.setPm10(heartBeatDataPackage.getPm10() == null ? null : heartBeatDataPackage.getPm10() + "ug/m³");
        //("空气温度")
        airDataNongGeng.setAirTemperature(heartBeatDataPackage.getAirTemperature() == null ? null : heartBeatDataPackage.getAirTemperature() + "℃");
        //("空气湿度")
        airDataNongGeng.setAirHumidity(heartBeatDataPackage.getAirHumidity() == null ? null : heartBeatDataPackage.getAirHumidity() + "%");
        //("大气压强")
        airDataNongGeng.setAirPressure(heartBeatDataPackage.getAirPressure() == null ? null : heartBeatDataPackage.getAirPressure() + "hPa");
        //("风速")
        airDataNongGeng.setWindSpeed(heartBeatDataPackage.getWindSpeed() == null ? null : heartBeatDataPackage.getWindSpeed() + "m/s");
        //("风向")
        airDataNongGeng.setWindDirection(heartBeatDataPackage.getWindDirection() == null ? null : heartBeatDataPackage.getWindDirection() + "°");
        //("10 åˆ†é’Ÿé›¨é‡")
        airDataNongGeng.setTenRainfallMin(heartBeatDataPackage.getTenRainfallMin() == null ? null : heartBeatDataPackage.getTenRainfallMin() + "mm");
        //("辐射")
        airDataNongGeng.setRadiation(heartBeatDataPackage.getRadiation() == null ? null : heartBeatDataPackage.getRadiation() + "0W/㎡");
        //("光照")
        airDataNongGeng.setIllumination(heartBeatDataPackage.getIllumination() == null ? null : heartBeatDataPackage.getIllumination() + "Klux");
        //紫外指数
        airDataNongGeng.setUltraviolet(heartBeatDataPackage.getUltraviolet() == null ? null : heartBeatDataPackage.getUltraviolet() + "");
        //CO2
        airDataNongGeng.setCo2(heartBeatDataPackage.getCo2() == null ? null : heartBeatDataPackage.getCo2() + "0ppm");
        //负氧离子
        airDataNongGeng.setO2(heartBeatDataPackage.getO2() == null ? null : heartBeatDataPackage.getO2() + "个");
        airDataNongGeng.setMac(deviceName);
        //将设备信息添加到大气设备表
@@ -58,22 +85,24 @@
        return save(airDataNongGeng);
    }
    /**
     * æŸ¥è¯¢å¤§æ°”数据(模糊查询)
     */
    public List<AirDataNongGengBo> listAirDataByKeyword(BaseConditionVO baseConditionVO, String keyword) {
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        List<Long> listAirId;
        if (SecurityUtils.getClientId() == null) {
            listAirId = baseMapper.listAirId(keyword, null);
        } else {
            listAirId = baseMapper.listAirId(keyword, SecurityUtils.getUserId());
        }
        if (CollUtil.isEmpty(listAirId)) {
            return CollUtil.newArrayList();
        }
        List<AirDataNongGengBo> airDataBos = baseMapper.listAirDataByIds(listAirId);
        return airDataBos;
    }
//
//    /**
//     * æŸ¥è¯¢å¤§æ°”数据(模糊查询)
//     */
//    public List<AirDataNongGengBo> listAirDataByKeyword(BaseConditionVO baseConditionVO, String keyword) {
//        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
//        List<Long> listAirId;
//        if (SecurityUtils.getClientId() == null) {
//            listAirId = baseMapper.listAirId(keyword, null);
//        } else {
//            listAirId = baseMapper.listAirId(keyword, SecurityUtils.getUserId());
//        }
//        if (CollUtil.isEmpty(listAirId)) {
//            return CollUtil.newArrayList();
//        }
//        List<AirDataNongGengBo> airDataBos = baseMapper.listAirDataByIds(listAirId);
//        return airDataBos;
//
//    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirEquipmentNongGengService.java
@@ -5,15 +5,24 @@
import com.sandu.common.execption.BusinessException;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.manager.iot.frame.A5Frame;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereOperationReportInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.AtmosphereSetHeartBeatTimeReqInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.AtmoFunctionCode;
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.RedisUtils;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.admin.utils.StringUtil;
import com.sandu.ximon.dao.bo.AirEquipmentNongGengBo;
import com.sandu.ximon.dao.domain.AirEquipmentNongGeng;
import com.sandu.ximon.dao.mapper.AirEquipmentNongGengMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
@@ -36,7 +45,6 @@
    public void addAirEquipment(AirEquipmentNongGeng airEquipmentNongGeng) {
        AirEquipmentNongGeng one = getOne(Wrappers.lambdaQuery(AirEquipmentNongGeng.class).eq(AirEquipmentNongGeng::getMac, airEquipmentNongGeng.getMac()));
        if (one == null) {
            //TODO
            save(airEquipmentNongGeng);
            /**
             * æ·»åŠ å†œè€•å¤§æ°”è®¾å¤‡ æ—¥å¿—记录开始
@@ -67,7 +75,14 @@
            airEquipmentBos = airEquipmentNongGengMapper.listAirEquipmentByIds(keyword, SecurityUtils.getUserId());
        }
        return airEquipmentBos;
        if (SecurityUtils.getClientId() == null) {
            airEquipmentBos = airEquipmentNongGengMapper.listAirEquipmentByIds(keyword, null);
        } else {
            airEquipmentBos = airEquipmentNongGengMapper.listAirEquipmentByIds(keyword, SecurityUtils.getUserId());
        }
        return null;
//        return airEquipmentBos;
    }
    /**
@@ -82,6 +97,7 @@
        }
        return airEquipmentBos;
//        return null;
    }
    /**
@@ -116,6 +132,9 @@
     */
    public AirEquipmentNongGeng getAirEquipment(String mac) {
        AirEquipmentNongGeng one = getOne(Wrappers.lambdaQuery(AirEquipmentNongGeng.class).eq(AirEquipmentNongGeng::getMac, mac));
        if (one == null) {
            throw new BusinessException("大气设备不存在!");
        }
        if (RedisUtils.getBean().get(AtmoFunctionCode.AIR_HEARTBEAT_NONG_GENG_STATE.getCode() + mac) != null) {
            one.setState(1);
        } else {
@@ -123,4 +142,66 @@
        }
        return one;
    }
    /**
     * è®¾ç½®å¤§æ°”设备心跳包间隔时间
     *
     * @param mac
     * @param time
     */
    public String setHeartBeatTime(String mac, Integer time) {
        if (StringUtil.strIsNullOrEmpty(mac)) {
            throw new BusinessException("灯杆mac参数错误!");
        }
        if (time == null) {
            throw new BusinessException("心跳包间隔时间不能为空!");
        }
        if (time < 30) {
            throw new BusinessException("心跳包间隔时间不能少于30s!");
        }
        AirEquipmentNongGeng airEquipmentNongGeng = SpringContextHolder.getBean(AirEquipmentNongGengService.class).
                getOne(Wrappers.lambdaQuery(AirEquipmentNongGeng.class).eq(AirEquipmentNongGeng::getMac, mac).last("limit 1"));
        if (airEquipmentNongGeng == null) {
            throw new BusinessException("大气设备不存在!");
        }
        AtmosphereSetHeartBeatTimeReqInnerFrame atmosphereSetHeartBeatTimeReqInnerFrame = new AtmosphereSetHeartBeatTimeReqInnerFrame(time);
        A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_ATMOSPHERE_DATA.getCode(), atmosphereSetHeartBeatTimeReqInnerFrame);
        System.out.println(a5Frame + "          --------a5Frame");
        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(mac, a5Frame);
        System.out.println(commonFrame + "         -----------commonFrame");
        A5AtmosphereOperationReportInnerFrame a5AtmosphereOperationReportInnerFrame
                = new A5AtmosphereOperationReportInnerFrame().transformFrame(commonFrame.getPayload());
        if (a5AtmosphereOperationReportInnerFrame != null && a5AtmosphereOperationReportInnerFrame.isValidate()) {
            return a5AtmosphereOperationReportInnerFrame.getState();
        } else {
            throw new BusinessException("数据校验异常!");
        }
    }
    /**
     * è®¾ç½®ç±»åž‹
     *
     * @param param
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean setAirEquipmentType(AirEquipmentNongGeng param) {
        if (param.getType() == null || param.getId() == null || param.getType().isEmpty()) {
            throw new BusinessException("设备id或类型不能为空");
        }
        if (!"0".equals(param.getType()) && !"1".equals(param.getType()) && !"2".equals(param.getType())) {
            throw new BusinessException("设备类型不正确");
        }
        AirEquipmentNongGeng byId = getById(param.getId());
        if (byId == null) {
            throw new BusinessException("设备id错误或设备不存在!");
        }
        byId.setType(param.getType());
        return updateById(byId);
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/AirEquipmentService.java
@@ -1,5 +1,6 @@
package com.sandu.ximon.admin.service;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.sandu.common.execption.BusinessException;
@@ -16,11 +17,13 @@
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.AtmoFunctionCode;
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
import com.sandu.ximon.admin.redis.DeviceRedisKey;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.RedisUtils;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.admin.utils.StringUtil;
import com.sandu.ximon.admin.vo.EquipmentInfomation;
import com.sandu.ximon.admin.vo.RedisDeviceStatus;
import com.sandu.ximon.dao.bo.AirEquipmentBo;
import com.sandu.ximon.dao.domain.AirEquipment;
import com.sandu.ximon.dao.mapper.AirEquipmentMapper;
@@ -35,6 +38,7 @@
public class AirEquipmentService extends BaseServiceImpl<AirEquipmentMapper, AirEquipment> {
    private final AirEquipmentMapper airEquipmentMapper;
    private final RedisUtils redisUtils;
    /**
@@ -352,4 +356,25 @@
            throw new BusinessException("数据校验异常!");
        }
    }
    /**
     * å‘Redis中存入设备状态
     */
    public void setCacheData() {
        list().forEach(
                device -> {
                    RedisDeviceStatus deviceStatus = new RedisDeviceStatus();
                    deviceStatus.setDeviceId(device.getAirMac());
                    if (RedisUtils.getBean().get(AtmoFunctionCode.AIR_HEARTBEAT_STATE.getCode() + device.getAirMac()) != null) {
                        deviceStatus.setStatus(0);
                    } else {
                        deviceStatus.setStatus(1);
                    }
                    redisUtils.set(DeviceRedisKey.AIR + device.getAirMac(), JSON.toJSONString(deviceStatus));
//                    redisUtils.delete(DeviceRedisKey.AIR + device.getAirMac());
                }
        );
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java
@@ -21,9 +21,11 @@
import com.sandu.ximon.admin.manager.iot.rrpc.util.SupplementUtils;
import com.sandu.ximon.admin.param.C3ChargingAddParam;
import com.sandu.ximon.admin.param.C3ChargingParam;
import com.sandu.ximon.admin.redis.DeviceRedisKey;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.*;
import com.sandu.ximon.admin.vo.EquipmentInfomation;
import com.sandu.ximon.admin.vo.RedisDeviceStatus;
import com.sandu.ximon.dao.bo.C3ChargingBo;
import com.sandu.ximon.dao.domain.*;
import com.sandu.ximon.dao.enums.OrderByEnums;
@@ -53,6 +55,7 @@
    private final C3mChargingChargeService c3mChargingChargeService;
    private final PoleBindingService bindingService;
    private final PoleService poleService;
    private final RedisUtils redisUtils;
    /**
     * ä¿å­˜ä¸ŠæŠ¥C3充电设备心跳数据
@@ -142,7 +145,7 @@
        System.out.println("设置费率开始");
        C3mCharging c3mCharging1 = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, mcuUdid).last("limit 1"));
        List<C3mChargingCharge> list = c3mChargingChargeService.list(Wrappers.lambdaQuery(C3mChargingCharge.class).eq(C3mChargingCharge::getC3Id, c3mCharging1.getC3Id()));
        if (list == null || list.size() == 0) {//费率表中没有此充电桩数据时  æ·»åŠ é»˜è®¤è´¹çŽ‡
        if (list.size() == 0) {//费率表中没有此充电桩数据时  æ·»åŠ é»˜è®¤è´¹çŽ‡
            c3mChargingChargeService.initCharge((c3mCharging1.getC3Id()).intValue());
        }
        String rateState = setRate(newC3Mac, list, true);
@@ -1163,4 +1166,32 @@
    }
    /**
     * å‘Redis中存入设备状态
     */
//    public void setCacheData() {
//        list().forEach(
//                device -> {
//                    RedisDeviceStatus deviceStatus = new RedisDeviceStatus();
//                    deviceStatus.setDeviceId(device.getC3Id().toString());
//                    if (device != null) {
//                        A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = ReadTheHeartbeatPackage(device.getC3Id(), false);
//                        if (beatDataPackage != null) {
//                            //在线状态 1.空闲 2.充电中 3.充电中断,等待服务器确认 4.充电结束,等待服务器确认 5.有故障 6.与充电桩对接中
//                            if (Integer.valueOf(beatDataPackage.getStatusBit()) == 5) {
//                                deviceStatus.setStatus(2);
//                            } else {
//                                deviceStatus.setStatus(0);
//                            }
//
//                        } else {
//                            deviceStatus.setStatus(1);
//                        }
//                    }
//                    redisUtils.set(DeviceRedisKey.C3M + device.getC3Id(), JSON.toJSONString(deviceStatus));
////                    redisUtils.delete(DeviceRedisKey.C3M + device.getC3Id());
//                }
//        );
//
//    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3mReportErrorService.java
@@ -1,6 +1,7 @@
package com.sandu.ximon.admin.service;
import com.github.pagehelper.PageHelper;
import com.sandu.common.domain.CommonPage;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3ErrorCodeReportInnerFrame;
ximon-admin/src/main/java/com/sandu/ximon/admin/service/ClientService.java
@@ -257,9 +257,23 @@
            poles.forEach(
                    pole -> {
                        pole.setClientId(-1L);
                        pole.setUserId(-1L);
                    }
            );
            //删除用户后需要自动解绑该用户的设备
            //灯杆id集合
            List<Long> collect = poles.stream().map(p -> p.getId()).collect(Collectors.toList());
            List<Long> collect1 = poles.stream().map(Pole::getId).collect(Collectors.toList());
            //删除绑定关系
            SpringContextHolder.getBean(PoleBindingService.class)
                    .remove(Wrappers.lambdaQuery(PoleBinding.class)
                            .in(PoleBinding::getPoleId, collect));
            //更改灯杆归属
            flag = SpringContextHolder.getBean(PoleService.class).updateBatchById(poles);
            //删除失败回滚数据
            if (!flag) {
                throw new BusinessException("删除用户失败!");
ximon-admin/src/main/java/com/sandu/ximon/admin/service/DeviceStatusCountService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,33 @@
package com.sandu.ximon.admin.service;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
 * @author LiuHaoNan
 * @date 2022/9/27
 */
@Service
@AllArgsConstructor
public class DeviceStatusCountService implements Runnable {
    private final WaterQualityEquipmentService waterQualityEquipmentService;
    private final AirEquipmentNongGengService airEquipmentNongGengService;
    private final LightPoleHeelingService poleHeelingService;
    private final AirEquipmentService airEquipmentService;
    private final LedPlayerEntityService ledNovaService;
    private final PoleLightemitService ledXixunService;
    private final C3ChargingService c3ChargingService;
    private final IpVolumeService ipVolumeService;
    private final MonitorService monitorService;
    private final LightService lightService;
    @Override
    public void run() {
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/ErrorMsgService.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sandu.common.domain.CommonPage;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.ximon.admin.dto.ErrorMsgDto;
import com.sandu.ximon.dao.bo.C3ReportErrorBo;
@@ -30,12 +31,18 @@
    private final C3ChargingService c3ChargingService;
    public List<ErrorMsgDto> listMsg(BaseConditionVO baseConditionVO) {
        List<ErrorMsgDto> errorMsgDtos = new ArrayList<>();
    /**
     * å•灯
     *
     * @param baseConditionVO
     * @return
     */
    public CommonPage lightListMsg(BaseConditionVO baseConditionVO) {
        List<ErrorMsgDto> errorMsgDtoList = new ArrayList<>();
        //单灯故障数据
        List<LightReportErrorBo> lightReportErrors = lightReportErrorService.queryErrorCode(baseConditionVO);
        if (!lightReportErrors.isEmpty()) {
            for (LightReportErrorBo lightReportError : lightReportErrors) {
        CommonPage commonPage = lightReportErrorService.queryErrorCode(baseConditionVO);
        if (!commonPage.getList().isEmpty()) {
            for (LightReportErrorBo lightReportError : (List<LightReportErrorBo>) commonPage.getList()) {
                ErrorMsgDto errorMsgDto = new ErrorMsgDto();
                errorMsgDto.setMac(lightReportError.getDeviceCode());
                errorMsgDto.setErrorCode(lightReportError.getErrorCode());
@@ -43,17 +50,32 @@
                errorMsgDto.setErrorTime(lightReportError.getCreateTime());
                errorMsgDto.setDeviceType(1);
                Light one = lightService.getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, lightReportError.getDeviceCode()));
                System.out.println(lightReportError.getDeviceCode() + " ---code ");
                if (one != null) {
                    errorMsgDto.setDeviceJson(JSON.toJSONString(one));
                } else {
                    errorMsgDto.setDeviceJson("系统未找到设备数据");
                }
                errorMsgDtos.add(errorMsgDto);
                errorMsgDtoList.add(errorMsgDto);
            }
        }
        commonPage.setList(errorMsgDtoList);
        return commonPage;
    }
    /**
     * å……电桩
     *
     * @param baseConditionVO
     * @return
     */
    public List<ErrorMsgDto> C3ListMsg(BaseConditionVO baseConditionVO) {
        List<ErrorMsgDto> errorMsgDtoList = new ArrayList<>();
        //充电桩故障数据
        List<C3ReportErrorBo> c3ReportErrorBos = c3mReportErrorService.listReportError(baseConditionVO);
        if (!c3ReportErrorBos.isEmpty()) {
            c3ReportErrorBos.forEach(c3ReportError -> {
            List<C3ReportErrorBo> list = c3ReportErrorBos;
            list.forEach(c3ReportError -> {
                ErrorMsgDto errorMsgDto = new ErrorMsgDto();
                errorMsgDto.setMac(c3ReportError.getC3Mac());
                errorMsgDto.setErrorDesc(c3ReportError.getErrorMsg());
@@ -62,18 +84,23 @@
                C3mCharging one = c3ChargingService.getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3ReportError.getC3Mac()));
                if (one != null) {
                    errorMsgDto.setDeviceJson(JSON.toJSONString(one));
                }else {
                    errorMsgDto.setDeviceJson("系统未找到设备数据");
                }
                errorMsgDtos.add(errorMsgDto);
                errorMsgDtoList.add(errorMsgDto);
            });
        }
        //大气故障数据  todo æš‚æ— 
        //对errorMsgDtos按创建时间倒叙
        errorMsgDtos.sort((a, b) -> b.getErrorTime().compareTo(a.getErrorTime()));
        //手动分页  baseConditionVO.getPageNo() å½“前页 baseConditionVO.getPageSize() æ¯é¡µæ¡æ•°
        return errorMsgDtos.subList((baseConditionVO.getPageNo() - 1) * baseConditionVO.getPageSize(), baseConditionVO.getPageNo() * baseConditionVO.getPageSize());
        return errorMsgDtoList;
    }
    /**
     * å¤§æ°”
     *
     * @param baseConditionVO
     * @return
     */
    public List<ErrorMsgDto> atmosphereListMsg(BaseConditionVO baseConditionVO) {
        return new ArrayList<>();
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeService.java
@@ -1,17 +1,21 @@
package com.sandu.ximon.admin.service;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.dto.TerminalDto;
import com.sandu.ximon.admin.param.BroadcastTerminalV2Param;
import com.sandu.ximon.admin.redis.DeviceRedisKey;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.RedisUtils;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.admin.utils.TerminalAPIUtils;
import com.sandu.ximon.admin.vo.EquipmentInfomation;
import com.sandu.ximon.admin.dto.TerminalDto;
import com.sandu.ximon.admin.vo.RedisDeviceStatus;
import com.sandu.ximon.dao.bo.BroadcastTerminalV2EntityBo;
import com.sandu.ximon.dao.domain.BroadcastTerminalV2Entity;
import com.sandu.ximon.dao.enums.AdministratorEnums;
@@ -29,6 +33,8 @@
    @Autowired
    private IPBroadcastMapper broadcastTerminalV2EntityMapper;
    @Autowired
    private RedisUtils redisUtils;
    /**
     * åŒæ­¥ç»ˆç«¯
@@ -174,7 +180,6 @@
     */
    public List<BroadcastTerminalV2EntityBo> getBroadcastTerminalListOnHome() {
        List<BroadcastTerminalV2EntityBo> broadcastTerminalV2EntityBos;
        List<BroadcastTerminalV2EntityBo> broadcastTerminalV2EntityBos_final = new ArrayList<>();
        if (SecurityUtils.getClientId() == null) {
            broadcastTerminalV2EntityBos = broadcastTerminalV2EntityMapper.getBroadcastTerminalList(null, null, 2);
@@ -196,7 +201,7 @@
                if (bean.getId().equals(terminalDto.getId())) {
                    bean.setStatus(terminalDto.getStatus());
                    bean.setIp(terminalDto.getIp());
                    bean.setVolumn(terminalDto.getVolumn());
                    bean.setVolumn(terminalDto.getVolume());
                    bean.setDefaultVolumn(terminalDto.getDefaultVolumn());
                    bean.setPower(terminalDto.getPower());
                    bean.setDefaultPower(terminalDto.getDefaultPower());
@@ -332,4 +337,45 @@
         */
        return flag;
    }
    public static Object getInfo() {
        return TerminalAPIUtils.getTerminalInfo(25);
    }
    /**
     * å‘Redis中存入设备状态
     */
    public void setCacheData() {
        //服务器所有音柱信息
        List<TerminalDto> list = TerminalAPIUtils.getTerminalList();
        list.forEach(
                device -> {
                    RedisDeviceStatus deviceStatus = new RedisDeviceStatus();
                    deviceStatus.setDeviceId(device.getId().toString());
                    if (device != null) {
                        //空闲 1、   å·¥ä½œä¸­ 2 æˆ–者 4、     æ–­çº¿ 0,    æŠ¥ é”™ 8
                        switch (device.getStatus()) {
                            case 1:
                            case 2:
                            case 4:
                                deviceStatus.setStatus(0);
                                break;
                            case 0:
                                deviceStatus.setStatus(1);
                                break;
                            case 8:
                                deviceStatus.setStatus(0);
                                break;
                            default:
                                deviceStatus.setStatus(1);
                        }
                    }
                    redisUtils.set(DeviceRedisKey.IP_BROADCAST + device.getId(), JSON.toJSONString(deviceStatus));
//                    redisUtils.delete(DeviceRedisKey.IP_BROADCAST + device.getId());
                }
        );
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedPlayerEntityService.java
@@ -125,7 +125,7 @@
     * @param seq
     * @return
     */
    public List<LedPlayerEntity> ledPlayerEntityList(BaseConditionVO baseConditionVO, String keyword, Integer order, Integer seq) {
    public List<LedPlayerEntity> ledPlayerEntityList(BaseConditionVO baseConditionVO, String keyword, Integer order, Integer seq, Long groupId) {
        //排序字段
        String orderByResult = OrderByEnums.VNNOX_ID.getCode();
        //正序、倒叙
@@ -163,9 +163,9 @@
        List<LedPlayerEntity> list;
        //超管
        if (SecurityUtils.getClientId() == null) {
            list = ledPlayerEntityMapper.ledPlayerEntityList(keyword, null);
            list = ledPlayerEntityMapper.ledListByGroupId(keyword, null, groupId);
        } else {
            list = ledPlayerEntityMapper.ledPlayerEntityList(keyword, SecurityUtils.getUserId());
            list = ledPlayerEntityMapper.ledListByGroupId(keyword, SecurityUtils.getUserId(), groupId);
        }
        return SpringContextHolder.getBean(VnnoxService.class).setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(list));
    }
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportErrorService.java
@@ -1,22 +1,37 @@
package com.sandu.ximon.admin.service;
import com.github.pagehelper.PageHelper;
import com.sandu.common.domain.CommonPage;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.manager.iot.frame.A5Frame;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3QueryReportInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightErrorCodeReportInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightOperationReportInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightCleanErrorCodeInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.C3QueryAddressReqInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.LightErrorEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.ListPagingUtils;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.dao.bo.LightReportErrorBo;
import com.sandu.ximon.dao.domain.LightReportError;
import com.sandu.ximon.dao.mapper.LightReportErrorMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
 * @author chenjiantian
 * @date 2021/12/17 17:47
 */
@Slf4j
@Service
public class LightReportErrorService extends BaseServiceImpl<LightReportErrorMapper, LightReportError> {
@@ -24,6 +39,7 @@
        LightReportError lightReportError = new LightReportError();
        lightReportError.setDeviceCode(deviceName);
        lightReportError.setErrorCode(codeRespInnerFrame.getErrorCode());
        lightReportError.setLightAddress(codeRespInnerFrame.getDestinationAddress());
        save(lightReportError);
    }
@@ -56,11 +72,12 @@
     *
     * @return
     */
    public List<LightReportErrorBo> queryErrorCode(BaseConditionVO baseConditionVO) {
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
    public CommonPage queryErrorCode(BaseConditionVO baseConditionVO) {
        List<LightReportErrorBo> lightReportErrorBos = baseMapper.listError(SecurityUtils.getClientId());
        for (LightReportErrorBo lightReportErrorBo : lightReportErrorBos) {
        lightReportErrorBos = lightReportErrorBos.stream().filter(bean -> bean.getErrorCode() != 0).collect(Collectors.toList());
        CommonPage commonPage = ListPagingUtils.pages(lightReportErrorBos, baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        for (LightReportErrorBo lightReportErrorBo : (List<LightReportErrorBo>) commonPage.getList()) {
            Integer errorCode = lightReportErrorBo.getErrorCode();
            StringBuilder sb = new StringBuilder();
            LightErrorEnum[] values = LightErrorEnum.values();
@@ -71,7 +88,29 @@
            }
            lightReportErrorBo.setErrorMsg(sb.toString());
        }
        return lightReportErrorBos;
        return commonPage;
    }
    /**
     * æ¸…除故障码
     *
     * @param deviceName
     * @param address
     */
    public void cleanErrorCode(String deviceName, String address) {
        A5LightCleanErrorCodeInnerFrame a5LightCleanErrorCodeInnerFram = new A5LightCleanErrorCodeInnerFrame(address);
        A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_LIGHT_DATA.getCode(), a5LightCleanErrorCodeInnerFram);
        System.out.println(a5Frame + "            -----a5Frame");
        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, a5Frame);
        StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "单灯帧-单灯故障清除", a5Frame, commonFrame);
        System.out.println(commonFrame + "            -----commonFrame");
        A5LightOperationReportInnerFrame operationReportInnerFrame = new A5LightOperationReportInnerFrame().transformFrame(commonFrame.getPayload());
        if (operationReportInnerFrame.isValidate()) {
            log.error("清除故障码成功,code:" + deviceName + ",灯头地址:" + address);
        }
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightService.java
@@ -3,6 +3,8 @@
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.HexUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.iot.model.v20180120.BatchGetDeviceStateResponse;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
@@ -14,25 +16,28 @@
import com.sandu.ximon.admin.dto.LightTaskDto;
import com.sandu.ximon.admin.manager.iot.frame.A5Frame;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightHeartbeatReportInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightOperationReportInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightBrightnessReqInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightSetCalendarReqInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.response.A5LightBrightnessRespInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.WrapResponseCommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
import com.sandu.ximon.admin.param.LightControlParam;
import com.sandu.ximon.admin.param.LightPowerSettingParam;
import com.sandu.ximon.admin.param.LightRemarkParam;
import com.sandu.ximon.admin.redis.DeviceRedisKey;
import com.sandu.ximon.admin.redis.LightKey;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.RedisUtils;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.admin.vo.ControlLightCommandVO;
import com.sandu.ximon.admin.vo.EquipmentInfomation;
import com.sandu.ximon.admin.vo.RedisDeviceStatus;
import com.sandu.ximon.dao.bo.LightBo;
import com.sandu.ximon.dao.bo.PoleTaskLightPowerBo;
import com.sandu.ximon.dao.domain.Light;
import com.sandu.ximon.dao.domain.LightReportData;
import com.sandu.ximon.dao.domain.Pole;
import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.domain.*;
import com.sandu.ximon.dao.enums.DeviceRespStatusEnums;
import com.sandu.ximon.dao.enums.OrderByEnums;
import com.sandu.ximon.dao.mapper.LightMapper;
@@ -43,8 +48,6 @@
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@@ -62,6 +65,7 @@
    private final LightReportDataService lightReportDataService;
    private final PoleBindingService bindingService;
    private final PoleService poleService;
    private final RedisUtils redisUtils;
    /**
     * å½•入当前设备码的路灯数据
@@ -198,13 +202,17 @@
     */
    public Light getLight(String deviceCode) {
        Light one = getOne(Wrappers.<Light>lambdaQuery().eq(Light::getDeviceCode, deviceCode));
        Object o = redisService.get(LightKey.REPORT_MAC.key(deviceCode));
        if (o != null) {
            one.setOnlineStatus(1);
        if (one == null) {
            return null;
        } else {
            one.setOnlineStatus(0);
            Object o = redisService.get(LightKey.REPORT_MAC.key(deviceCode));
            if (o != null) {
                one.setOnlineStatus(1);
            } else {
                one.setOnlineStatus(0);
            }
            return one;
        }
        return one;
    }
    /**
@@ -304,151 +312,6 @@
         */
        return resultList;
    }
    /**
     * å•灯节能率
     *
     * @return
     */
    public List controlEnergySaving() {
        //获取到正在执行的任务列表
        List<LightTaskDto> lightTaskDtos = SpringContextHolder.getBean(LightTaskService.class).listTask();
        LocalDateTime now = LocalDateTime.now();
        List<LightTaskDto> list1 = new ArrayList<>();
        List<LightTaskDto> list2 = new ArrayList<>();
        List<LightTaskDto> list3 = new ArrayList<>();
        List<LightTaskDto> list4 = new ArrayList<>();
        List<LightTaskDto> list5 = new ArrayList<>();
        List<LightTaskDto> list6 = new ArrayList<>();
        List<LightTaskDto> list7 = new ArrayList<>();
        for (LightTaskDto lightTaskDto : lightTaskDtos) {
            List<Integer> weekList = lightTaskDto.getWeekList();
            for (Integer one : weekList) {
                switch (one) {
                    case 1:
                        list1.add(lightTaskDto);
                        break;
                    case 2:
                        list2.add(lightTaskDto);
                        break;
                    case 4:
                        list3.add(lightTaskDto);
                        break;
                    case 8:
                        list4.add(lightTaskDto);
                        break;
                    case 16:
                        list5.add(lightTaskDto);
                        break;
                    case 32:
                        list6.add(lightTaskDto);
                        break;
                    case 64:
                        list7.add(lightTaskDto);
                        break;
                    default:
                }
            }
        }
        //获取当前星期几 1-7
        int currentWeekValue = now.getDayOfWeek().getValue();
        Map map;
        List<Map> temp = new ArrayList<>();
        //获取日期 ç²¾ç¡®åˆ°å¤©
        LocalDateTime localDateTime = now.with(LocalTime.MIN);
        for (int i = 1; i < 8; i++) {
            currentWeekValue--;
            if (currentWeekValue < 1) {
                currentWeekValue = 7;
            }
            map = new LinkedHashMap();
            map.put("time", localDateTime.minusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
            map.put("value", getlist(currentWeekValue));
            temp.add(map);
        }
        return temp;
    }
    /**
     * å•灯能耗
     *
     * @return
     */
    public List controlEnergy() {
        //获取到正在执行的任务列表
        List<LightTaskDto> lightTaskDtos = SpringContextHolder.getBean(LightTaskService.class).listTask();
        LocalDateTime now = LocalDateTime.now();
        List<LightTaskDto> list1 = new ArrayList<>();
        List<LightTaskDto> list2 = new ArrayList<>();
        List<LightTaskDto> list3 = new ArrayList<>();
        List<LightTaskDto> list4 = new ArrayList<>();
        List<LightTaskDto> list5 = new ArrayList<>();
        List<LightTaskDto> list6 = new ArrayList<>();
        List<LightTaskDto> list7 = new ArrayList<>();
        for (LightTaskDto lightTaskDto : lightTaskDtos) {
            List<Integer> weekList = lightTaskDto.getWeekList();
            System.out.println(weekList + "===========================");
            for (Integer one : weekList) {
                switch (one) {
                    case 1:
                        list1.add(lightTaskDto);
                        break;
                    case 2:
                        list2.add(lightTaskDto);
                        break;
                    case 4:
                        list3.add(lightTaskDto);
                        break;
                    case 8:
                        list4.add(lightTaskDto);
                        break;
                    case 16:
                        list5.add(lightTaskDto);
                        break;
                    case 32:
                        list6.add(lightTaskDto);
                        break;
                    case 64:
                        list7.add(lightTaskDto);
                        break;
                    default:
                }
            }
        }
        Integer currentWeekValue = now.getDayOfWeek().getValue();
        Map map;
        List<Map> temp = new ArrayList<>();
        //获取当前日期  æ ¼å¼ä¸ºyyyy-MM-dd
        LocalDateTime localDateTime = now.with(LocalTime.MIN);
        for (int i = 1; i < 8; i++) {
            currentWeekValue--;
            if (currentWeekValue < 1) {
                currentWeekValue = 7;
            }
            map = new LinkedHashMap();
            map.put("time", localDateTime.minusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
            map.put("value", getlistEnergy(currentWeekValue));
            temp.add(map);
        }
        return temp;
    }
@@ -636,7 +499,7 @@
     *
     * @return
     */
    public BigDecimal jisuan(LightTaskDto Task) {
    public BigDecimal jisuan(LightTaskDto Task, LightTaskPoleRelation bean) {
        final BigDecimal[] bigDecimalResult = {new BigDecimal(0.00)};
        /**
         * èŠ‚èƒ½çŽ‡è®¡ç®—å¼€å§‹
@@ -758,9 +621,10 @@
     * ä¸€å¤©çš„能耗
     *
     * @param
     * @param bean
     * @return
     */
    public BigDecimal jisuanEnergy(LightTaskDto Task) {
    public BigDecimal jisuanEnergy(LightTaskDto Task, LightTaskPoleRelation bean) {
        //存放能耗
        final BigDecimal[] bigEnergy = {new BigDecimal(0.00)};
@@ -779,9 +643,21 @@
        }
        /**
         * èŠ‚èƒ½çŽ‡è®¡ç®—å¼€å§‹
         * èƒ½è€—计算开始
         */
        List<PoleTaskLightPowerBo> poleTaskLightPowerBos = SpringContextHolder.getBean(LightTaskMapper.class).listLightTaskByTaskId(Task.getTaskId());
//        List<PoleTaskLightPowerBo> poleTaskLightPowerBos = SpringContextHolder.getBean(LightTaskMapper.class).listLightTaskByTaskId(Task.getTaskId());
        List<PoleTaskLightPowerBo> poleTaskLightPowerBos = new ArrayList<>();
        PoleTaskLightPowerBo poleTaskLightPowerBo = new PoleTaskLightPowerBo();
        Light one = getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, bean.getDeviceCode()));
        if (one != null) {
            if ("0001".equals(bean.getLightAddress())) {
                poleTaskLightPowerBo.setPower1(one.getPower1());
            } else {
                poleTaskLightPowerBo.setPower2(one.getPower2());
            }
        }
        poleTaskLightPowerBos.add(poleTaskLightPowerBo);
        ControlLightCommandVO startTime = parseSwitchLightCommand(Task.getOpenOrder());
        ControlLightCommandVO endTime = parseSwitchLightCommand(Task.getCloseOrder());
        //获取到单灯任务的节能率
@@ -1009,14 +885,14 @@
    /**
     * èŽ·å–ç”¨æˆ·æ‰€æœ‰çš„è®¾å¤‡ç 
     */
    public CommonPage<String> listDeviceCode(int pageNo, int pageSize, String keyword, String deviceCode,String orderBy) {
    public CommonPage<String> listDeviceCode(int pageNo, int pageSize, String keyword, String deviceCode, String orderBy) {
        List<String> list;
        if (SecurityUtils.getClientId() != null) {
            PageHelper.startPage(pageNo, pageSize);
            list = baseMapper.listCode(SecurityUtils.getUserId(), keyword, deviceCode);
        } else {
            PageHelper.startPage(pageNo, pageSize,orderBy);
            PageHelper.startPage(pageNo, pageSize, orderBy);
            list = baseMapper.listCode(null, keyword, deviceCode);
        }
@@ -1053,4 +929,206 @@
        });
        return updateBatchById(lights);
    }
    /**
     * å‘Redis中存入设备状态
     */
    public void setCacheData() {
        List<String> collect = list().stream().map(Light::getDeviceCode).collect(Collectors.toList());
//        collect.forEach(
//                code -> {
//                    redisUtils.delete(DeviceRedisKey.LIGHT_DEVICE + code);
//                }
//        );
        List<List<String>> split = CollectionUtil.split(collect, 100);
        List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = new ArrayList<>();
        List<RedisDeviceStatus> statusList = new ArrayList<>();
        for (List<String> splist : split) {
            deviceStatuses = MainBoardInvokeSyncService.getInstance().batchGetDeviceState(splist);
            if (deviceStatuses != null) {
                for (BatchGetDeviceStateResponse.DeviceStatus deviceStatus : deviceStatuses) {
                    RedisDeviceStatus device = new RedisDeviceStatus();
                    device.setDeviceId(deviceStatus.getDeviceName());
                    if ("ONLINE".equals(deviceStatus.getStatus())) {
                        device.setStatus(0);
                    } else if ("OFFLINE".equals(deviceStatus.getStatus())) {
                        device.setStatus(1);
                    } else if ("UNACTIVE".equals(deviceStatus.getStatus())) {
                        device.setStatus(0);
                    } else if ("DISABLE".equals(deviceStatus.getStatus())) {
                        device.setStatus(0);
                    } else {
                        device.setStatus(2);
                    }
                    statusList.add(device);
                }
            }
        }
        statusList.forEach(status -> {
            redisUtils.set(DeviceRedisKey.LIGHT_DEVICE + status.getDeviceId(), JSON.toJSONString(status));
        });
    }
    /**
     * è®¾ç½®æ—¥åŽ†ï¼ˆåŒå¿ƒè·³åŒ…ä¸­çš„6字节日期时间)
     *
     * @return
     */
    public String SetCalendar(Long lightId, String address) {
        Calendar cal = Calendar.getInstance();
        //获取当前时间
        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH);
        int day = cal.get(Calendar.DATE);
        int hour = cal.get(Calendar.HOUR_OF_DAY);
        int min = cal.get(Calendar.MINUTE);
        int sec = cal.get(Calendar.SECOND);
        if (!"0001".equals(address) && !"0002".equals(address)) {
            throw new BusinessException("灯头地址错误!");
        }
        Light one = getById(lightId);
        if (one == null) {
            System.out.println("单灯不存在!");
        }
        A5LightSetCalendarReqInnerFrame setCalendarReqInnerFrame =
                new A5LightSetCalendarReqInnerFrame(address, year % 100, month + 1, day, hour, min, sec);
        A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_LIGHT_DATA.getCode(), setCalendarReqInnerFrame);
        System.out.println(a5Frame + "            -----a5Frame");
        CommonFrame commonFrame;
        commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getDeviceCode(), a5Frame);
        StoreOperationRecordsUtils.storeInnerFrameData(one.getDeviceCode(), "单灯帧-设置日历", a5Frame, commonFrame);
        System.out.println(commonFrame + "            -----commonFrame");
        A5LightOperationReportInnerFrame operationReportInnerFrame = new A5LightOperationReportInnerFrame().transformFrame(commonFrame.getPayload());
        if (operationReportInnerFrame.isValidate()) {
            return operationReportInnerFrame.getState();
        } else {
            throw new BusinessException("数据校验错误,请重新请求");
        }
    }
    /**
     * å•灯主动同步时间请求
     */
    public void timeSynchronizationInitiative(String deviceCode, String lightAddress) {
        //单灯信息
        Light light = getLight(deviceCode);
        if (light == null) {
            log.error("单灯主动同步时间请求异常,单灯信息不存在!");
            return;
        }
        //单灯任务信息
        LightTaskPoleRelation lightTaskPoleRelation = SpringContextHolder.getBean(LightTaskPoleRelationService.class)
                .getOne(Wrappers.lambdaQuery(LightTaskPoleRelation.class)
                        .eq(LightTaskPoleRelation::getDeviceCode, deviceCode).eq(LightTaskPoleRelation::getLightAddress, lightAddress));
        LightTask lightTask = null;
        //灯头没有任务
        if (lightTaskPoleRelation != null) {
            if (lightTaskPoleRelation.getDeviceScheduled() != null) {
                lightTask = JSONObject.parseObject(lightTaskPoleRelation.getDeviceScheduled(), LightTask.class);
            }
        }
        timeSynchronization(light, lightAddress, lightTask);
    }
    /**
     * å•灯时间同步
     *
     * @param light     å•灯信息实体
     * @param lightTask å•灯任务实体(为空标识单灯没有定时任务)
     */
    public void timeSynchronization(Light light, String lightAddress, LightTask lightTask) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                //获取当前时间时、分
                Calendar cal = Calendar.getInstance();
                if (lightTask != null) {
                    String closeOrder = lightTask.getCloseOrder();
                    String openOrder = lightTask.getOpenOrder();
                    String controlOrder = lightTask.getControlOrder() == null ? null : lightTask.getControlOrder();
                    List<String> timeList = new ArrayList<>();
                    timeList.add(openOrder.substring(0, 4));
                    timeList.add(closeOrder.substring(0, 4));
                    if (controlOrder != null && controlOrder.length() % 7 == 0) {
                        for (int i = 0; i < controlOrder.length() / 7; i++) {
                            timeList.add(controlOrder.substring(i * 7, i * 7 + 4));
                        }
                    } else {
                        log.error("控灯指令不正确,数据长度不为7的倍数!");
                        return;
                    }
                    //时间排序
                    timeList = timeList.stream().sorted().collect(Collectors.toList());
                    int count = 0;
                    boolean haveTime = false;
                    while (!haveTime && count <= 144) {
                        haveTime = judgeTime(cal, timeList);
                        cal.add(Calendar.MINUTE, 10);
                        count++;
                    }
                    if (haveTime) {
                        try {
                            long longTime = cal.getTimeInMillis() - System.currentTimeMillis();
                            log.error("睡眠时间(毫秒):" + longTime);
                            Thread.sleep(longTime);
                            SetCalendar(light.getLightId(), lightAddress);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    } else {
                        log.error("灯杆ID为:" + light.getLightId() + ",灯头地址为:" + lightAddress + "没有找到可同步的时间,请检查任务!");
                    }
                } else {
                    SetCalendar(light.getLightId(), lightAddress);
                }
            }
        }).start();
    }
    /**
     * åˆ¤æ–­æ—¶é—´æ˜¯å¦å¯ä»¥æ‰§è¡ŒåŒæ­¥æŒ‡ä»¤
     *
     * @param time
     * @param timeList
     * @return true å¯ä»¥æ‰§è¡Œ  ,false  ä¸å¯æ‰§è¡Œ
     */
    private boolean judgeTime(Calendar time, List<String> timeList) {
        int hour = time.get(Calendar.HOUR_OF_DAY);
        int min = time.get(Calendar.MINUTE);
        int allMin = hour * 60 + min;
        for (String value : timeList) {
            int targetHour = Integer.valueOf(value.substring(0, 2));
            int targetMin = Integer.valueOf(value.substring(2, 4));
            int allTargetMin = targetHour * 60 + targetMin;
            if (allMin >= allTargetMin - 10 && allMin <= allTargetMin + 10) {
                return false;
            } else {
                continue;
            }
        }
        return true;
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java
@@ -2,11 +2,10 @@
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.HexUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.Page;
@@ -30,8 +29,9 @@
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.admin.utils.TaskOrderUtil;
import com.sandu.ximon.dao.bo.LightTaskPoleRelationBo;
import com.sandu.ximon.dao.bo.LightTaskStatusAndPole;
import com.sandu.ximon.admin.vo.LightTaskInfoVO;
import com.sandu.ximon.admin.vo.LightTaskRelationVO;
import com.sandu.ximon.admin.vo.LightTaskVO;
import com.sandu.ximon.dao.domain.LightEnergyData;
import com.sandu.ximon.dao.domain.LightTask;
import com.sandu.ximon.dao.domain.LightTaskPoleRelation;
@@ -39,7 +39,6 @@
import com.sandu.ximon.dao.enums.DeviceRespStatusEnums;
import com.sandu.ximon.dao.enums.OrderByEnums;
import com.sandu.ximon.dao.mapper.LightTaskMapper;
import com.sandu.ximon.dao.mapper.LightTaskPoleRelationMapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
@@ -84,7 +83,6 @@
        if (!"0001".equals(param.getLightAddress()) && !"0002".equals(param.getLightAddress())) {
            throw new BusinessException("灯头地址格式不正确");
        }
//        LightTask lightTask = getById(null);
        int week = 0;
@@ -95,7 +93,7 @@
        LightTask newLightTask = new LightTask();
        newLightTask.setTaskName(param.getTaskName());
        newLightTask.setClientId(clientService.getClientId());
        newLightTask.setClientId(clientService.getClientId(SecurityUtils.getUserId()));
        newLightTask.setUserId(SecurityUtils.getUserId());
        newLightTask.setWeek(week);
@@ -145,24 +143,18 @@
        newPoleMap.forEach(
                commend -> {
                    //开关灯时间
//                    String s = newLightTask.getOpenOrder() + newLightTask.getCloseOrder();
//                    if (newLightTask.getControlOrder() != null) {
//                        //控灯时间
//                        s = s + newLightTask.getControlOrder();
//                    }
//                    // æ›´æ–°ç³»ç»Ÿå®šæ—¶
//                    commend.setSysScheduled(s);
                    commend.setSysScheduled(JSON.toJSONString(newLightTask));
                    System.out.println(commend.getIssueStatus() + "状态");
                    if (commend.getIssueStatus() == 0) {
                        //下发成功  æ›´æ–°ç³»ç»Ÿå®šæ—¶å’Œç¡¬ä»¶å®šæ—¶
                        commend.setDeviceScheduled(JSONObject.toJSONString(newLightTask));
                        commend.setDeviceScheduled(JSON.toJSONString(newLightTask));
                    } else {
                        //下发失败  æ›´æ–°ç³»ç»Ÿå®šæ—¶  ä¿ç•™ç¡¬ä»¶å®šæ—¶ ç¡¬ä»¶å®šæ—¶
//                        commend.setSysScheduled(s);
                        oldLightTaskStatusAndPoles.forEach(task -> {
                            if (task.getLightAddress().equals(commend.getLightAddress()) && task.getDeviceCode().equals(commend.getDeviceCode())) {
                                //同一个灯头
                                LightTask oldTask = getById(task.getTaskId());
                                commend.setDeviceScheduled(JSONObject.toJSONString(oldTask));
                                commend.setDeviceScheduled(task.getDeviceScheduled());
                            }
                        });
@@ -184,7 +176,7 @@
        //删除旧的关系
        lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class)
                .eq(LightTaskPoleRelation::getLightAddress, newLightTask.getLightAdress()).in(LightTaskPoleRelation::getPoleId, poleIdList));
                .in(LightTaskPoleRelation::getPoleId, poleIdList).eq(LightTaskPoleRelation::getLightAddress, newLightTask.getLightAdress()));
        boolean b = true;
        //保存任务关系
@@ -214,6 +206,9 @@
        if (StrUtil.length(param.getControlOrder()) % LightTaskParam.REQUEST_ORDER_LENGTH != 0) {
            throw new BusinessException("灯控命令格式不正确");
        }
        if (!"0001".equals(param.getLightAddress()) && !"0002".equals(param.getLightAddress())) {
            throw new BusinessException("灯头地址格式不正确");
        }
        LightTask newLightTask = getById(taskId);
        if (newLightTask == null) {
            throw new BusinessException("找不到路灯任务");
@@ -225,10 +220,9 @@
            week |= w;
        }
//        LightTask newLightTask = new LightTask();
        newLightTask.setTaskName(param.getTaskName());
        newLightTask.setClientId(clientService.getClientId());
        newLightTask.setClientId(clientService.getClientId(SecurityUtils.getUserId()));
        newLightTask.setUserId(SecurityUtils.getUserId());
        newLightTask.setWeek(week);
@@ -341,32 +335,47 @@
        all.addAll(newPoleFail);
        all.addAll(oldPoleSuccess);
        all.addAll(oldPoleFail);
        all.addAll(closePoleSuccess);
        all.addAll(closePoleFail);
        if (closePoleFail.size() != 0) {
            List<LightTaskPoleRelation> colesFail = new ArrayList<>();
            //原来任务中本身就下发失败的任务  å³ç¡¬ä»¶å®šæ—¶ä¸ºç©º    ç¼–辑后进行关灯操作   å¯ç›´æŽ¥å‰”除任务关系
            closePoleFail.forEach(
                    close -> {
                        relations.forEach(
                                task -> {
                                    System.out.println(task.getLightAddress().equals(close.getLightAddress()) + "   addressResult");
                                    System.out.println(close.getLightAddress() + "   close.getLightAddress()");
                                    if (task.getLightAddress().equals(close.getLightAddress()) && task.getDeviceCode().equals(close.getDeviceCode())
                                            && task.getDeviceScheduled() != null && !task.getDeviceScheduled().isEmpty()) {
                                        colesFail.add(close);
                                    }
                                }
                        );
                        all.addAll(colesFail);
                    }
            );
        }
        if (!all.isEmpty()) {
            List<LightTaskPoleRelation> finalOldRelation = relations;
            all.forEach(
                    commend -> {
                        commend.setTaskId(newLightTask.getTaskId());
                        //开关灯时间
                        String s = newLightTask.getOpenOrder() + newLightTask.getCloseOrder();
                        if (newLightTask.getControlOrder() != null) {
                            //控灯时间
                            s = s + newLightTask.getControlOrder();
                        }
                        // æ›´æ–°ç³»ç»Ÿå®šæ—¶
                        commend.setSysScheduled(s);
                        commend.setSysScheduled(JSON.toJSONString(newLightTask));
                        commend.setTaskId(taskId);
                        // å…ˆè®¾ç½®ç¡¬ä»¶å®šæ—¶ä¸ºä¸Šæ¬¡çš„硬件定时   ä¸è®ºæˆåŠŸå¤±è´¥
                        String finalS = s;
                        finalOldRelation.forEach(task -> {
                            if (task.getLightAddress().equals(commend.getLightAddress()) && task.getDeviceCode().equals(commend.getDeviceCode())) {
                                //同一个灯头
                                commend.setDeviceScheduled(task.getDeviceScheduled());
                                if (commend.getIssueStatus() == 0) {
                                    //下发成功  æ›´æ–°ç³»ç»Ÿå®šæ—¶å’Œç¡¬ä»¶å®šæ—¶
                                    commend.setDeviceScheduled(finalS);
                                    commend.setDeviceScheduled(JSON.toJSONString(newLightTask));
                                }
                            }
                        });
@@ -377,10 +386,14 @@
        //编辑前后所有的灯杆ID集合
        poleIdList.addAll(oldList);
        if (!poleIdList.isEmpty()) {
            lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, poleIdList));
        //去重
        List<Long> collect = poleIdList.stream().distinct().collect(Collectors.toList());
        if (!collect.isEmpty()) {
            lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class)
                    .in(LightTaskPoleRelation::getPoleId, collect).eq(LightTaskPoleRelation::getLightAddress, newLightTask.getLightAdress()));
        }
        if (!all.isEmpty()) {
            b = lightTaskPoleRelationService.saveBatch(all);
@@ -551,48 +564,6 @@
            lightTaskPoleRelation.setTaskId(lightTask.getTaskId());
            // rrpc å‘生定时命令
//            if ("FFFF".equals(lightAddress)) {
//                LightTaskPoleRelation lightTaskPoleRelation01 = new LightTaskPoleRelation();
//                lightTaskPoleRelation01.setPoleId(pole.getId());
//                lightTaskPoleRelation01.setTaskId(lightTask.getTaskId());
//                lightTaskPoleRelation01.setLightAddress("0001");
//
//                LightTaskPoleRelation lightTaskPoleRelation02 = new LightTaskPoleRelation();
//                lightTaskPoleRelation02.setPoleId(pole.getId());
//                lightTaskPoleRelation02.setTaskId(lightTask.getTaskId());
//                lightTaskPoleRelation02.setLightAddress("0002");
//
//                // ç¯å¤´1 rrpc å‘生定时命令
//                try {
//                    A5LightTimerRespInnerFrame a5LightTimerRespInnerFrame01 = sendTimeRRpc(framePayload, pole.getDeviceCode(), "0001");
//                    //灯头1
//                    if (a5LightTimerRespInnerFrame01 == null) {
//                        lightTaskPoleRelation01.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode());
//                    } else {
//                        lightTaskPoleRelation01.setIssueStatus(HexUtil.hexToInt(a5LightTimerRespInnerFrame01.getResponseStatus()));
//                    }
//
//                } catch (BusinessException e) {
//                    lightTaskPoleRelation01.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode());
//                }
//
//                //  ç¯å¤´2 rrpc å‘生定时命令
//                try {
//                    A5LightTimerRespInnerFrame a5LightTimerRespInnerFrame02 = sendTimeRRpc(framePayload, pole.getDeviceCode(), "0002");
//                    //灯头2
//                    if (a5LightTimerRespInnerFrame02 == null) {
//                        lightTaskPoleRelation02.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode());
//                    } else {
//                        lightTaskPoleRelation02.setIssueStatus(HexUtil.hexToInt(a5LightTimerRespInnerFrame02.getResponseStatus()));
//                    }
//
//                } catch (BusinessException e) {
//                    lightTaskPoleRelation02.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode());
//                }
//
//                lightTaskPoleRelationList.add(lightTaskPoleRelation01);
//                lightTaskPoleRelationList.add(lightTaskPoleRelation02);
//            } else {
            lightTaskPoleRelation.setDeviceCode(pole.getDeviceCode());
            lightTaskPoleRelation.setLightAddress(lightAddress);
            // rrpc å‘生定时命令
@@ -649,52 +620,6 @@
            // rrpc å‘生定时命令
//            if ("FFFF".equals(lightAddress)) {
//                LightTaskPoleRelation lightTaskPoleRelation01 = new LightTaskPoleRelation();
//                lightTaskPoleRelation01.setPoleId(pole.getId());
//                lightTaskPoleRelation01.setLightAddress("0001");
//
//                LightTaskPoleRelation lightTaskPoleRelation02 = new LightTaskPoleRelation();
//                lightTaskPoleRelation02.setPoleId(pole.getId());
//                lightTaskPoleRelation02.setLightAddress("0002");
//
//                // ç¯å¤´1 rrpc å‘生定时命令
//                try {
//                    A5LightTimerRespInnerFrame a5LightTimerRespInnerFrame01 = sendTimeRRpc(framePayload, pole.getDeviceCode(), "0001");
//                    //灯头1
//                    if (a5LightTimerRespInnerFrame01 == null) {
//                        lightTaskPoleRelation01.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode());
//                        fail.add(lightTaskPoleRelation01);
//                    } else {
//                        lightTaskPoleRelation01.setIssueStatus(HexUtil.hexToInt(a5LightTimerRespInnerFrame01.getResponseStatus()));
//                        success.add(lightTaskPoleRelation01);
//                    }
//
//                } catch (BusinessException e) {
//                    lightTaskPoleRelation01.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode());
//                    fail.add(lightTaskPoleRelation01);
//                }
//
//                //  ç¯å¤´2 rrpc å‘生定时命令
//                try {
//                    A5LightTimerRespInnerFrame a5LightTimerRespInnerFrame02 = sendTimeRRpc(framePayload, pole.getDeviceCode(), "0002");
//                    //灯头2
//                    if (a5LightTimerRespInnerFrame02 == null) {
//                        lightTaskPoleRelation02.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode());
//                        fail.add(lightTaskPoleRelation02);
//                    } else {
//                        lightTaskPoleRelation02.setIssueStatus(HexUtil.hexToInt(a5LightTimerRespInnerFrame02.getResponseStatus()));
//                        success.add(lightTaskPoleRelation02);
//                    }
//
//                } catch (BusinessException e) {
//                    lightTaskPoleRelation02.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode());
//                    fail.add(lightTaskPoleRelation02);
//                }
//
//                lightTaskPoleRelationList.add(lightTaskPoleRelation01);
//                lightTaskPoleRelationList.add(lightTaskPoleRelation02);
//            } else {
            lightTaskPoleRelation.setLightAddress(lightAddress);
            lightTaskPoleRelation.setDeviceCode(pole.getDeviceCode());
            // rrpc å‘生定时命令
@@ -714,7 +639,6 @@
            lightTaskPoleRelationList.add(lightTaskPoleRelation);
        }
//        }
        map.put("success", success);
        map.put("fail", fail);
        map.put("all", lightTaskPoleRelationList);
@@ -724,65 +648,110 @@
    @Transactional(rollbackFor = Exception.class)
    public String delLightTask(List<Long> taskIdList) {
        List<LightTask> lightTaskList = listByIds(taskIdList);
        if (CollectionUtil.isEmpty(lightTaskList)) {
    public String delLightTask(Long taskId) {
        LightTask byId = getById(taskId);
        if (byId == null) {
            throw new BusinessException("找不到任务信息");
        }
        //取出任务关系
        List<LightTaskPoleRelation> relations = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getTaskId, taskIdList));
        List<LightTaskPoleRelation> relations = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class).eq(LightTaskPoleRelation::getTaskId, taskId));
        //取出灯杆id
        List<Long> poleIds = relations.stream().map(LightTaskPoleRelation::getPoleId).distinct().collect(Collectors.toList());
        //下发清除任务指令
//        boolean b = clearLightTask(lightTaskIds);
        Map<String, List<LightTaskPoleRelation>> ffff = sendControllerFrame(poleIds, "", "FFFF");
        /**
         * åˆ é™¤æŽ§ç¯ä»»åŠ¡æ—¥å¿—è®°å½•å¼€å§‹
         */
        String content = "{控灯任务id:" + taskIdList + " }";
        StoreOperationRecordsUtils.storeOperationData(null, null, "删除控灯任务", content);
        /**
         * åˆ é™¤æŽ§ç¯ä»»åŠ¡æ—¥å¿—è®°å½•ç»“æŸ
         */
        if (ffff.get("fail").size() == 0) {
            //全部清除成功  åˆ é™¤å…¨éƒ¨ä»»åŠ¡å…³ç³»
            lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getTaskId, taskIdList));
            //删除任务
            removeByIds(taskIdList);
            return "任务删除成功";
        if (poleIds != null && poleIds.size() > 0) {
            //存在任务关系   ä¸‹å‘清除任务指令
            Map<String, List<LightTaskPoleRelation>> ffff = sendControllerFrame(poleIds, "", byId.getLightAdress());
            /**
             * åˆ é™¤æŽ§ç¯ä»»åŠ¡æ—¥å¿—è®°å½•å¼€å§‹
             */
            String content = "{控灯任务id:" + taskId + " }";
            StoreOperationRecordsUtils.storeOperationData(null, null, "删除控灯任务", content);
            /**
             * åˆ é™¤æŽ§ç¯ä»»åŠ¡æ—¥å¿—è®°å½•ç»“æŸ
             */
            if (ffff.get("fail").size() == 0) {
                //全部清除成功  åˆ é™¤å…¨éƒ¨ä»»åŠ¡å…³ç³»
                lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).eq(LightTaskPoleRelation::getTaskId, taskId));
                //删除任务
                removeById(taskId);
                return "任务删除成功";
            } else if (ffff.get("success").size() != ffff.get("all").size()) {
                //部分成功  åˆ é™¤æˆåŠŸéƒ¨åˆ†çš„å…³ç³»  ä¿ç•™ä»»åŠ¡
                List<LightTaskPoleRelation> relations1 = ffff.get("success");
                if (relations1 != null && relations1.size() > 0) {
                    relations1.forEach(lightTaskPoleRelation -> {
                        lightTaskPoleRelationService.remove(Wrappers.lambdaUpdate(LightTaskPoleRelation.class)
                                .eq(LightTaskPoleRelation::getPoleId, lightTaskPoleRelation.getPoleId()).eq(LightTaskPoleRelation::getTaskId, taskId));
                    });
                }
                return "部分任务删除成功,清除任务失败的任务及数据保留!";
            } else if (ffff.get("fail").size() == ffff.get("all").size()) {
                //全部失败  ä¿ç•™ä»»åŠ¡
                return "任务删除失败 ,请检查硬件设备!";
            } else {
                return "任务删除失败,未知错误类型!";
            }
        } else {
            //部分清除成功   åˆ é™¤æˆåŠŸéƒ¨åˆ†çš„ä»»åŠ¡å…³ç³»
            ffff.get("success").forEach(lightTaskPoleRelation -> {
                lightTaskPoleRelationService.remove(Wrappers.lambdaUpdate(LightTaskPoleRelation.class)
                        .eq(LightTaskPoleRelation::getPoleId, lightTaskPoleRelation.getPoleId()).eq(LightTaskPoleRelation::getTaskId, lightTaskPoleRelation.getTaskId()));
            });
            //删除任务
            lightTaskList.forEach(
                    taskId -> {
                        List<LightTaskPoleRelation> poleRelations = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class).eq(LightTaskPoleRelation::getTaskId, taskId));
                        if (poleRelations.size() == 0) {
                            //不存在任务关系   åˆ é™¤ä»»åŠ¡
                            removeById(taskId);
                        }
                    }
            );
            return "部分任务删除成功,清除任务失败的任务及数据保留";
            //不存在任务关系    ç©ºä»»åŠ¡ç›´æŽ¥åˆ é™¤
            removeById(taskId);
            return "任务删除成功";
        }
    }
    /**
     * ä»»åŠ¡è¯¦æƒ…
     */
    public Map<Object, Object> detailLightTask(Long taskId) {
    public Object detailLightTask(Long taskId) {
        LightTask lightTask = getById(taskId);
        if (lightTask == null) {
            throw new BusinessException("找不到任务");
        }
        List<LightTaskStatusAndPole> lightTaskStatusAndPoles = lightTaskPoleRelationService.listPoleAndStatusIdByTaskId(taskId);
        return MapUtil.builder().put("task", lightTask).put("poles", lightTaskStatusAndPoles).build();
        LightTaskInfoVO vo = new LightTaskInfoVO();
//        LightTaskDto lightTaskDto = new LightTaskDto();
//        BeanUtils.copyProperties(lightTask, lightTaskDto);
        lightTask.setWeekList(TaskOrderUtil.parseLightWeek2List(lightTask.getWeek()));
        vo.setLightTask(lightTask);
        List<LightTaskRelationVO> relations = new ArrayList<>();
        List<LightTaskPoleRelation> taskPoleRelations = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class)
                .eq(LightTaskPoleRelation::getTaskId, taskId));
        if (taskPoleRelations != null && !taskPoleRelations.isEmpty()) {
            taskPoleRelations.forEach(
                    relation -> {
                        LightTaskRelationVO lightTaskRelationVO = new LightTaskRelationVO();
                        lightTaskRelationVO.setLightAddress(relation.getLightAddress());
                        lightTaskRelationVO.setIssueStatus(relation.getIssueStatus());
                        lightTaskRelationVO.setPoleId(relation.getPoleId());
                        Pole byId = poleService.getById(relation.getPoleId());
                        if (byId != null) {
                            lightTaskRelationVO.setPoleName(byId.getPoleName());
                        }
                        LightTaskVO sys = JSONObject.parseObject(relation.getSysScheduled(), LightTaskVO.class);
                        sys.setWeekList(TaskOrderUtil.parseLightWeek2List(sys.getWeek()));
                        lightTaskRelationVO.setSysScheduled(sys);
                        LightTaskVO device = JSONObject.parseObject(relation.getDeviceScheduled(), LightTaskVO.class);
                        if (device != null) {
                            device.setWeekList(TaskOrderUtil.parseLightWeek2List(device.getWeek()));
                            lightTaskRelationVO.setDeviceScheduled(device);
                        }
                        relations.add(lightTaskRelationVO);
                    }
            );
            vo.setRelations(relations);
        }
//        List<LightTaskStatusAndPole> lightTaskStatusAndPoles = lightTaskPoleRelationService.listPoleAndStatusIdByTaskId(taskId);
//        return MapUtil.builder().put("task", lightTask).put("poles", lightTaskStatusAndPoles).build();
        return vo;
    }
    /**
@@ -837,11 +806,21 @@
     * ä¸‹å‘单个灯杆的任务
     */
    public boolean issueLightTask(LightTaskIssueParam param) {
        LightTask lightTask = getById(param.getTaskId());
        LightTaskPoleRelation relation = lightTaskPoleRelationService.getOne(Wrappers.lambdaQuery(LightTaskPoleRelation.class)
                .eq(LightTaskPoleRelation::getPoleId, param.getPoleId()).eq(LightTaskPoleRelation::getTaskId, param.getTaskId()));
        if (relation == null) {
            throw new BusinessException("找不到任务关系,无法补发");
        }
        LightTask lightTask = JSONObject.parseObject(relation.getSysScheduled(), LightTask.class);
//        LightTask lightTask = getById(param.getTaskId());
        if (lightTask == null) {
            throw new BusinessException("找不到任务");
        }
        //转换帧指令
        String framePayload = buildControlFramePayload(lightTask.getOpenOrder(), lightTask.getCloseOrder(), lightTask.getControlOrder(), lightTask.getWeek());
        //发送rrpc  å¾—到发送结果
        List<LightTaskPoleRelation> lightTaskPoleRelationList = sendControllerFrame(lightTask, ListUtil.toList(param.getPoleId()), framePayload, lightTask.getLightAdress());
        /**
@@ -860,11 +839,17 @@
        if (CollectionUtil.isNotEmpty(lightTaskPoleRelationList)) {
            return lightTaskPoleRelationService.update(lightTaskPoleRelationList.get(0), Wrappers.lambdaUpdate(LightTaskPoleRelation.class).eq(LightTaskPoleRelation::getPoleId, param.getPoleId()).eq(LightTaskPoleRelation::getTaskId, param.getTaskId()));
            LightTaskPoleRelation lightTaskPoleRelation = lightTaskPoleRelationList.get(0);
            if (lightTaskPoleRelation.getIssueStatus() == 0) {
                //下发成功  æ›´æ–°ç¡¬ä»¶å®šæ—¶  è¿”回成功
                relation.setDeviceScheduled(JSON.toJSONString(lightTaskPoleRelation));
                lightTaskPoleRelationService.updateById(relation);
                return true;
            } else {
                return false;
            }
        }
        return true;
        return false;
    }
@@ -872,46 +857,31 @@
     * è®¡ç®—功率及能耗
     */
    public void energy() {
        List<LightTask> lightTasks = list(Wrappers.lambdaQuery(LightTask.class));
        List<Long> taskIdList = new ArrayList<>();
        for (LightTask bean : lightTasks) {
            taskIdList.add(bean.getTaskId());
        }
        if (taskIdList.size() != 0) {
            List<LightTaskPoleRelationBo> list = SpringContextHolder.getBean(LightTaskPoleRelationMapper.class).test(taskIdList);
            for (LightTaskPoleRelationBo bean : list) {
        //所有存在任务的灯杆关系
        List<LightTaskPoleRelation> list = lightTaskPoleRelationService.list();
        for (LightTaskPoleRelation bean : list) {
            if (bean.getDeviceScheduled() != null) {
                //存在硬件任务
                LightTask lightTask = JSONObject.parseObject(bean.getDeviceScheduled(), LightTask.class);
                LightTaskDto lightTaskDto = new LightTaskDto();
                BeanUtils.copyProperties(bean, lightTaskDto);
                lightTaskDto.setWeekList(TaskOrderUtil.parseLightWeek2List(bean.getWeek()));
                BeanUtils.copyProperties(lightTask, lightTaskDto);
                lightTaskDto.setWeekList(TaskOrderUtil.parseLightWeek2List(lightTask.getWeek()));
                BigDecimal energySaving;
                BigDecimal energy;
                //获取昨天的星期数
                LocalDateTime now = LocalDateTime.now();
                LocalDateTime yesterday = now.minusDays(1);
                int week = yesterday.getDayOfWeek().getValue();
                if (!list.isEmpty()) {
                    //有绑定灯杆  è¿›è¡Œè®¡ç®—
                    if (lightTaskDto.getWeekList().contains(week)) {
                        //任务有该星期数  è®¡ç®—
                        energySaving = SpringContextHolder.getBean(LightService.class).jisuan(lightTaskDto);
                        energy = SpringContextHolder.getBean(LightService.class).jisuanEnergy(lightTaskDto);
                    } else {
                        //任务无该星期数  è¿”回
                        energySaving = new BigDecimal(1);
                        energy = BigDecimal.ZERO;
                    }
                    for (int i = 0; i < list.size(); i++) {
                        LightTaskPoleRelation relation = list.get(i);
                        if (relation.getIssueStatus() != 0) {
                            //任务下发失败  è¿”回
                            energySaving = new BigDecimal(1);
                            energy = BigDecimal.ZERO;
                        }
                    }
                if (lightTaskDto.getWeekList().contains(week)) {
                    //任务有该星期数  è®¡ç®—
                    energySaving = SpringContextHolder.getBean(LightService.class).jisuan(lightTaskDto, bean);
                    energy = SpringContextHolder.getBean(LightService.class).jisuanEnergy(lightTaskDto, bean);
                    System.out.println("能耗: " + energy + ", èŠ‚èƒ½çŽ‡: " + energySaving);
                } else {
                    //未绑定灯杆  ç›´æŽ¥è¿”回
                    //任务无该星期数  è¿”回
                    energySaving = new BigDecimal(1);
                    energy = BigDecimal.ZERO;
                }
@@ -920,19 +890,22 @@
                 * å­˜å‚¨æ•°æ®
                 */
                System.out.println("能耗: " + energy + ", èŠ‚èƒ½çŽ‡: " + energySaving);
                LightEnergyData lightEnergyData = new LightEnergyData();
                lightEnergyData.setTaskId(bean.getTaskId());
                lightEnergyData.setTaskId(lightTask.getTaskId());
                lightEnergyData.setYtdTime(yesterday.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
                lightEnergyData.setEnergySaving(energySaving);
                lightEnergyData.setEnergy(energy);
                lightEnergyData.setUserId(bean.getUserId());
                lightEnergyData.setClientId(bean.getClientId());
                lightEnergyData.setLightAdderss(lightTask.getLightAdress());
                lightEnergyData.setUserId(lightTask.getUserId());
                lightEnergyData.setClientId(lightTask.getClientId());
                lightEnergyData.setPoleId(bean.getPoleId());
                //保存能耗数据到数据库
                lightEnergyDataService.save(lightEnergyData);
            }
        }
    }
    public boolean clearLightTask(List<Long> poleIds) {
@@ -951,22 +924,29 @@
        String lightAddress = param.getLightAddress();
        List<Long> poleIdList = param.getPoleIdList();
        List<LightTaskPoleRelation> lightTaskPoleRelations = lightTaskPoleRelationService.list(Wrappers.lambdaQuery(LightTaskPoleRelation.class)
                .in(LightTaskPoleRelation::getPoleId, poleIdList).eq(LightTaskPoleRelation::getLightAddress, param.getLightAddress()));
                .in(LightTaskPoleRelation::getPoleId, poleIdList).eq(LightTaskPoleRelation::getLightAddress, lightAddress));
        //重复的任务id
        List<Long> taskIds = lightTaskPoleRelations.stream().map(LightTaskPoleRelation::getTaskId).collect(Collectors.toList());
        List<Long> poleIds = lightTaskPoleRelations.stream().map(LightTaskPoleRelation::getPoleId).collect(Collectors.toList());
        //poleIds中重复元素只保留一个
        //重复的灯杆id
        List<Long> oldPoleIds = lightTaskPoleRelations.stream().map(LightTaskPoleRelation::getPoleId).collect(Collectors.toList());
        //未重复的灯杆id
        List<Long> finalOldPoleIds = oldPoleIds;
        //取出存在于poleIdList而不在oldPoleIds中的灯杆
        List<Long> newPoleIds = poleIdList.stream().filter(id -> !finalOldPoleIds.contains(id)).collect(Collectors.toList());
        //重复元素只保留一个
        taskIds = taskIds.stream().distinct().collect(Collectors.toList());
        poleIds = poleIds.stream().distinct().collect(Collectors.toList());
        oldPoleIds = oldPoleIds.stream().distinct().collect(Collectors.toList());
        newPoleIds = newPoleIds.stream().distinct().collect(Collectors.toList());
        Map map = new HashMap();
        if (!lightTaskPoleRelations.isEmpty()) {
            map.put("request", "false");
            map.put("msg", "任务中存在已有任务的单灯," + "任务id为{" + taskIds + "}, "
                    + "灯杆id为{" + poleIds + "}");
//            throw new BusinessException("任务中存在已有任务的单灯," + "任务id为{" + taskIds + "}, "
//                    + "灯杆id为{" + poleIds + "}");
            map.put("result", "false");
            map.put("newPoleIds", newPoleIds);
            map.put("oldPoleIds", oldPoleIds);
            map.put("taskIds", taskIds);
        } else {
            map.put("request", "true");
            map.put("result", "true");
            map.put("msg", "任务中无重复灯杆地址");
        }
        return map;
ximon-admin/src/main/java/com/sandu/ximon/admin/service/MonitorService.java
@@ -12,10 +12,13 @@
import com.sandu.ximon.admin.dto.YSY_AccessTokenDto;
import com.sandu.ximon.admin.dto.YSY_MonitorDto;
import com.sandu.ximon.admin.param.MonitorParam;
import com.sandu.ximon.admin.redis.DeviceRedisKey;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.ListPagingUtils;
import com.sandu.ximon.admin.utils.RedisUtils;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.admin.vo.EquipmentInfomation;
import com.sandu.ximon.admin.vo.RedisDeviceStatus;
import com.sandu.ximon.dao.bo.MonitorBo;
import com.sandu.ximon.dao.domain.Monitor;
import com.sandu.ximon.dao.domain.PoleBinding;
@@ -23,6 +26,7 @@
import com.sandu.ximon.dao.enums.PoleBindingEnums;
import com.sandu.ximon.dao.mapper.MonitorMapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@@ -33,6 +37,7 @@
@Service
@AllArgsConstructor
@Slf4j
public class MonitorService extends BaseServiceImpl<MonitorMapper, Monitor> {
    private final MonitorMapper monitorMapper;
    //萤石云AppKey
@@ -55,6 +60,8 @@
    private final PoleBindingService poleBindingService;
    private final RedisUtils redisUtils;
    /**
     * æ‘„像头列表模糊查询
@@ -203,7 +210,17 @@
        paramMap.put("appKey", AppKey);
        paramMap.put("appSecret", Secret);
        String s = HttpUtil.post(YSY_URL + ACCESSTOKEN_URL, paramMap);
        if (!s.startsWith("{") || !s.endsWith("}")) {
            log.error("获取摄像头token失败,格式有误!");
        }
        YSY_AccessTokenDto accessTokenDto = JSON.parseObject(s, YSY_AccessTokenDto.class);
        //二次获取
        if(accessTokenDto == null){
            log.error("获取摄像头token失败,格式有误!");
            s = HttpUtil.post(YSY_URL + ACCESSTOKEN_URL, paramMap);
            accessTokenDto = JSON.parseObject(s, YSY_AccessTokenDto.class);
        }
        return accessTokenDto.getData().getAccessToken();
    }
@@ -460,4 +477,33 @@
    }
    /**
     * å‘Redis中存入设备状态
     */
    public void setCacheData() {
        list().forEach(
                device -> {
                    RedisDeviceStatus deviceStatus = new RedisDeviceStatus();
                    deviceStatus.setDeviceId(device.getDeviceSerial());
                    if (device != null) {
                        EquipmentInfomation monitorInfo = getMonitorInfo(device.getDeviceSerial());
                        if (monitorInfo != null) {
                            if ("在线".equals(monitorInfo.getEquipmentState())) {
                                deviceStatus.setStatus(0);
                            } else {
                                deviceStatus.setStatus(1);
                            }
                        } else {
                            deviceStatus.setStatus(1);
                        }
                    }
                    redisUtils.set(DeviceRedisKey.MONITOR + device.getDeviceSerial(), JSON.toJSONString(deviceStatus));
//                    redisUtils.delete(DeviceRedisKey.MONITOR + device.getDeviceSerial());
                }
        );
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PlatformFileService.java
@@ -14,7 +14,10 @@
import com.sandu.ximon.admin.param.PlatformFilePermissionParam;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.dao.bo.PlatformFileListBo;
import com.sandu.ximon.dao.domain.*;
import com.sandu.ximon.dao.domain.Admin;
import com.sandu.ximon.dao.domain.Client;
import com.sandu.ximon.dao.domain.PlatformFile;
import com.sandu.ximon.dao.domain.PlatformFileUser;
import com.sandu.ximon.dao.enums.AdministratorEnums;
import com.sandu.ximon.dao.mapper.PlatformFileMapper;
import lombok.AllArgsConstructor;
@@ -90,7 +93,7 @@
            throw new BusinessException("删除时参数不能为空!");
        }
        List<PlatformFile> platformFiles = listByIds(param.getFileIds());
        if (platformFiles == null && platformFiles.size() == 0) {
        if (platformFiles == null || platformFiles.size() == 0) {
            throw new BusinessException("未找到文件!");
        }
@@ -122,7 +125,7 @@
                    .list(Wrappers.lambdaQuery(PlatformFileUser.class).eq(PlatformFileUser::getUserId, SecurityUtils.getUserId()));
            List<Long> fileIdList = platformFileUsers.stream().map(PlatformFileUser::getFileId).collect(Collectors.toList());
            if(fileIdList.size() == 0){
            if (fileIdList.size() == 0) {
                fileIdList.add(-1L);
            }
            PageHelper.startPage(vo.getPageNo(), vo.getPageSize());
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleLightemitService.java
@@ -10,9 +10,11 @@
import com.sandu.ximon.admin.config.RealtimeServerBean;
import com.sandu.ximon.admin.entity.*;
import com.sandu.ximon.admin.param.PoleBindingParam;
import com.sandu.ximon.admin.redis.DeviceRedisKey;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.*;
import com.sandu.ximon.admin.vo.EquipmentInfomation;
import com.sandu.ximon.admin.vo.RedisDeviceStatus;
import com.sandu.ximon.dao.domain.Pole;
import com.sandu.ximon.dao.domain.PoleLightemitEntity;
import com.sandu.ximon.dao.enums.OrderByEnums;
@@ -53,6 +55,9 @@
    @Autowired
    LedSFileService xiXunFileService;
    @Autowired
    RedisUtils redisUtils;
    @PostConstruct
    public void init() {
@@ -562,4 +567,25 @@
        Map map = JSON.parseObject(requestBody, Map.class);
        return map;
    }
    /**
     * å‘Redis中存入设备状态
     */
    public void setCacheData() {
        list().forEach(
                xiXun -> {
                    RedisDeviceStatus deviceStatus = new RedisDeviceStatus();
                    deviceStatus.setDeviceId(xiXun.getLightemitControlCode());
                    boolean ledOnLine = lightemitUtils.getLedOnLine(xiXun.getLightemitControlCode());
                    if (ledOnLine) {
                        deviceStatus.setStatus(0);
                    } else {
                        deviceStatus.setStatus(1);
                    }
                    redisUtils.set(DeviceRedisKey.XIXUN + xiXun.getLightemitControlCode(), JSON.toJSONString(deviceStatus));
//                    redisUtils.delete(DeviceRedisKey.XIXUN + xiXun.getLightemitControlCode());
                }
        );
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -2,6 +2,7 @@
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.aliyuncs.iot.model.v20180120.BatchGetDeviceStateResponse;
import com.aliyuncs.iot.model.v20180120.QueryDeviceDetailResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -18,40 +19,45 @@
import com.sandu.ximon.admin.manager.iot.frame.FrameBuilder;
import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3HeartbeatReportInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.A1TernaryCodeReqInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightResetReqInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.EmptyRequestInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1DeviceMacRespInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1TernaryCodeRespInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A1OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A2OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.DeviceStateEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.*;
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
import com.sandu.ximon.admin.param.PoleBindingParam;
import com.sandu.ximon.admin.param.PoleParam;
import com.sandu.ximon.admin.param.PoleStatesParam;
import com.sandu.ximon.admin.param.PushAirDataToNovaParam;
import com.sandu.ximon.admin.redis.DeviceRedisKey;
import com.sandu.ximon.admin.redis.LightKey;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.LightemitUtils;
import com.sandu.ximon.admin.utils.ListPagingUtils;
import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.admin.utils.*;
import com.sandu.ximon.admin.utils.response.VnnoxResult;
import com.sandu.ximon.admin.vo.DeviceOnLineCountVO;
import com.sandu.ximon.admin.vo.OnLineCountVO;
import com.sandu.ximon.admin.vo.PoleBindVO;
import com.sandu.ximon.admin.vo.RedisDeviceStatus;
import com.sandu.ximon.dao.bo.*;
import com.sandu.ximon.dao.domain.*;
import com.sandu.ximon.dao.enums.OrderByEnums;
import com.sandu.ximon.dao.mapper.PoleMapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@@ -69,6 +75,8 @@
    private final PoleGroupRelationService groupRelationService;
    private final ClientService clientService;
    private final PoleMapper poleMapper;
    private final RedisUtils redisUtils;
    private final CountDownLatchUtil countDownLatchUtil;
    public boolean addPole(PoleParam param) {
        Pole pole = new Pole();
@@ -166,7 +174,7 @@
     *
     * @return
     */
    public Map<String, Integer> poleCount() {
    public Map<String, Integer> poleCount1() {
        Map<String, Integer> result = new HashMap<>();
        LambdaQueryWrapper<Pole> wrapper;
        if (SecurityUtils.getClientId() == null) {
@@ -223,6 +231,361 @@
        return result;
    }
    /**
     * ç»Ÿè®¡åœ¨çº¿ç¯æ†æ•°é‡
     *
     * @return
     */
    public OnLineCountVO poleCount() {
        System.out.println("请求时间: " + LocalDateTime.now());
        OnLineCountVO onLineCountVO = new OnLineCountVO();
        CountDownLatch countDownLatch = new CountDownLatch(9);//todo
        //获取一个7位随机数
        String str = RandomStringUtils.randomAlphanumeric(7);
        countDownLatchUtil.push(str, countDownLatch);
        //诺瓦
        List<LedPlayerEntity> ledPlayerEntities = SpringContextHolder.getBean(LedPlayerEntityService.class).ledPlayerEntityListOnHome();
        new Thread(new Runnable() {
            @Override
            public void run() {
                AtomicInteger onLine = new AtomicInteger(0);
                AtomicInteger offLine = new AtomicInteger(0);
                //ip音柱
                DeviceOnLineCountVO ledNova = new DeviceOnLineCountVO();
                ledPlayerEntities.forEach(
                        Volume -> {
                            String s = redisUtils.get(DeviceRedisKey.NOVA + Volume.getId());
                            if (s != null) {
                                RedisDeviceStatus redisDeviceStatus = JSON.parseObject(s, RedisDeviceStatus.class);
                                if (redisDeviceStatus.getStatus() == 0) {
                                    //在线
                                    onLine.getAndIncrement();
                                } else {
                                    //离线
                                    offLine.getAndIncrement();
                                }
                            } else {
                                offLine.getAndIncrement();
                            }
                        }
                );
                ledNova.setTotalCount(ledPlayerEntities.size());
                ledNova.setOnlineCount(onLine.get());
                ledNova.setOfflineCount(offLine.get());
                onLineCountVO.setLedNova(ledNova);
                System.out.println("诺瓦执行时间: " + LocalDateTime.now());
                countDownLatchUtil.countDown(str);
            }
        }).start();
        //音柱
        List<BroadcastTerminalV2EntityBo> broadcastTerminalList = SpringContextHolder.getBean(IpVolumeService.class).getBroadcastTerminalListOnHome();
        new Thread(new Runnable() {
            @Override
            public void run() {
                AtomicInteger onLine = new AtomicInteger(0);
                AtomicInteger offLine = new AtomicInteger(0);
                //ip音柱
                DeviceOnLineCountVO ipVolume = new DeviceOnLineCountVO();
                broadcastTerminalList.forEach(
                        Volume -> {
                            String s = redisUtils.get(DeviceRedisKey.IP_BROADCAST + Volume.getId());
                            if (s != null) {
                                RedisDeviceStatus redisDeviceStatus = JSON.parseObject(s, RedisDeviceStatus.class);
                                if (redisDeviceStatus.getStatus() == 0) {
                                    //在线
                                    onLine.getAndIncrement();
                                } else {
                                    //离线
                                    offLine.getAndIncrement();
                                }
                            } else {
                                offLine.getAndIncrement();
                            }
                        }
                );
                ipVolume.setTotalCount(broadcastTerminalList.size());
                ipVolume.setOnlineCount(onLine.get());
                ipVolume.setOfflineCount(offLine.get());
                onLineCountVO.setBroadcast(ipVolume);
                System.out.println("音柱执行时间: " + LocalDateTime.now());
                countDownLatchUtil.countDown(str);
            }
        }).start();
        //摄像头
        List<MonitorBo> monitorBos = SpringContextHolder.getBean(MonitorService.class).listMonitorOnHome();
        new Thread(new Runnable() {
            @Override
            public void run() {
                AtomicInteger onLine = new AtomicInteger(0);
                AtomicInteger offLine = new AtomicInteger(0);
                DeviceOnLineCountVO Monitor = new DeviceOnLineCountVO();
                monitorBos.forEach(
                        device -> {
                            String s = redisUtils.get(DeviceRedisKey.MONITOR + device.getDeviceSerial());
                            if (s != null) {
                                RedisDeviceStatus redisDeviceStatus = JSON.parseObject(s, RedisDeviceStatus.class);
                                if (redisDeviceStatus.getStatus() == 0) {
                                    //在线
                                    onLine.getAndIncrement();
                                } else {
                                    //离线
                                    offLine.getAndIncrement();
                                }
                            } else {
                                offLine.getAndIncrement();
                            }
                        }
                );
                Monitor.setTotalCount(monitorBos.size());
                Monitor.setOnlineCount(onLine.get());
                Monitor.setOfflineCount(offLine.get());
                onLineCountVO.setMonitor(Monitor);
                System.out.println("摄像头执行时间: " + LocalDateTime.now());
                countDownLatchUtil.countDown(str);
            }
        }).start();
        //单灯
        List<LightBo> lights = SpringContextHolder.getBean(LightService.class).listLightOnHome();
        BaseConditionVO baseConditionVO = new BaseConditionVO();
        baseConditionVO.setPageNo(1);
        baseConditionVO.setPageSize(999);
        System.out.println("单灯故障统计时间: " + LocalDateTime.now());
        CommonPage commonPage = SpringContextHolder.getBean(LightReportErrorService.class).queryErrorCode(baseConditionVO);
        System.out.println("单灯故障统计时间: " + LocalDateTime.now());
        new Thread(new Runnable() {
            @Override
            public void run() {
                AtomicInteger onLine = new AtomicInteger(0);
                AtomicInteger offLine = new AtomicInteger(0);
                AtomicInteger error = new AtomicInteger(commonPage.getList().size());
                DeviceOnLineCountVO light = new DeviceOnLineCountVO();
                lights.forEach(
                        device -> {
                            String s = redisUtils.get(DeviceRedisKey.LIGHT_DEVICE + device.getDeviceCode());
                            if (s != null) {
                                RedisDeviceStatus redisDeviceStatus = JSON.parseObject(s, RedisDeviceStatus.class);
                                if (redisDeviceStatus.getStatus() == 0) {
                                    //在线
                                    onLine.getAndIncrement();
                                } else {
                                    //离线
                                    offLine.getAndIncrement();
                                }
                            } else {
                                offLine.getAndIncrement();
                            }
                        }
                );
                light.setTotalCount(lights.size());
                light.setOnlineCount(onLine.get());
                light.setOfflineCount(offLine.get());
                light.setErrorCount(error.get());
                onLineCountVO.setLight(light);
                System.out.println("单灯执行时间: " + LocalDateTime.now());
                countDownLatchUtil.countDown(str);
            }
        }).start();
        //充电桩
        List<C3ChargingBo> c3mChargings = SpringContextHolder.getBean(C3ChargingService.class).getC3ChargingList();
        new Thread(new Runnable() {
            @Override
            public void run() {
                AtomicInteger onLine = new AtomicInteger(0);
                AtomicInteger offLine = new AtomicInteger(0);
                AtomicInteger error = new AtomicInteger(0);
                DeviceOnLineCountVO c3m = new DeviceOnLineCountVO();
                c3mChargings.forEach(
                        device -> {
                            String s = redisUtils.get(C3mRedisConstant.C3_STATUS.getCode() + device.getC3Mac());
                            RedisDeviceStatus redisDeviceStatus = new RedisDeviceStatus();
                            redisDeviceStatus.setDeviceId(device.getC3Id().toString());
                            if (s != null) {
                                A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage = JSON.parseObject(s, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage.class);
                                //  å……电桩口状态位  1.空闲 2.充电中 3.充电中断,等待服务器确认 4.充电结束,等待服务器确认 5.有故障 6.与充电桩对接中
                                if ("5".equals(heartBeatDataPackage.getStatusBit())) {
                                    //故障
                                    onLine.getAndIncrement();
                                    error.getAndIncrement();
                                } else {
                                    //在线
                                    onLine.getAndIncrement();
                                }
                            } else {
                                //离线
                                offLine.getAndIncrement();
                            }
                        }
                );
                c3m.setTotalCount(c3mChargings.size());
                c3m.setOnlineCount(onLine.get());
                c3m.setOfflineCount(offLine.get());
                c3m.setErrorCount(error.get());
                onLineCountVO.setC3m(c3m);
                System.out.println("充电桩执行时间: " + LocalDateTime.now());
                countDownLatchUtil.countDown(str);
            }
        }).start();
        //大气
        List<AirEquipmentBo> airEquipments = SpringContextHolder.getBean(AirEquipmentService.class).listAirEquipmentOnHome();
        new Thread(new Runnable() {
            @Override
            public void run() {
                AtomicInteger onLine = new AtomicInteger(0);
                AtomicInteger offLine = new AtomicInteger(0);
                AtomicInteger error = new AtomicInteger(0);
                DeviceOnLineCountVO air = new DeviceOnLineCountVO();
                airEquipments.forEach(
                        device -> {
                            String s = redisUtils.get(DeviceRedisKey.AIR + device.getAirMac());
                            if (s != null) {
                                RedisDeviceStatus redisDeviceStatus = JSON.parseObject(s, RedisDeviceStatus.class);
                                if (redisDeviceStatus.getStatus() == 0) {
                                    //在线
                                    onLine.getAndIncrement();
                                } else if (redisDeviceStatus.getStatus() == 1) {
                                    //离线
                                    offLine.getAndIncrement();
                                } else {
                                    error.getAndIncrement();
                                }
                            } else {
                                error.getAndIncrement();
                            }
                        }
                );
                air.setTotalCount(airEquipments.size());
                air.setOnlineCount(onLine.get());
                air.setOfflineCount(offLine.get());
                air.setErrorCount(error.get());
                onLineCountVO.setAirEquipment(air);
                System.out.println("大气执行时间: " + LocalDateTime.now());
                countDownLatchUtil.countDown(str);
            }
        }).start();
        //大气(农耕)
//        List<AirEquipmentNongGengBo> airEquipmentNongGengBos = SpringContextHolder.getBean(AirEquipmentNongGengService.class).listAirEquipmentOnHome();
//        result.put("AirEquipmentNongGengTotalCount", airEquipmentNongGengBos.size());
        //æ°´è´¨
        List<WaterQualityEquipmentBo> waterQualityEquipments = SpringContextHolder.getBean(WaterQualityEquipmentService.class).listWaterQualityEquipmentByKeyword(null, null);
        new Thread(new Runnable() {
            @Override
            public void run() {
                DeviceOnLineCountVO water = new DeviceOnLineCountVO();
                water.setTotalCount(waterQualityEquipments.size());
                water.setOnlineCount(waterQualityEquipments.size());
                water.setOfflineCount(0);
                water.setErrorCount(0);
                onLineCountVO.setWaterEquipment(water);
                System.out.println("水质执行时间: " + LocalDateTime.now());
                countDownLatchUtil.countDown(str);
            }
        }).start();
        //灯杆倾斜
        List<LightPoleHeelingEquipmentBo> lightPoleHeelingEquipmentBos = SpringContextHolder.getBean(LightPoleHeelingEquipmentService.class).LightPoleHeelingEquipmentListOnHome();
        new Thread(new Runnable() {
            @Override
            public void run() {
                DeviceOnLineCountVO PoleHeeling = new DeviceOnLineCountVO();
                PoleHeeling.setTotalCount(lightPoleHeelingEquipmentBos.size());
                PoleHeeling.setOnlineCount(lightPoleHeelingEquipmentBos.size());
                PoleHeeling.setOfflineCount(0);
                PoleHeeling.setErrorCount(0);
                onLineCountVO.setLightPoleHeeling(PoleHeeling);
                System.out.println("灯杆倾斜执行时间: " + LocalDateTime.now());
                countDownLatchUtil.countDown(str);
            }
        }).start();
        //熙讯
        List<PoleLightemitEntity> xiXuns = SpringContextHolder.getBean(PoleLightemitService.class).listLedOnHome();
        new Thread(new Runnable() {
            @Override
            public void run() {
                AtomicInteger onLine = new AtomicInteger(0);
                AtomicInteger offLine = new AtomicInteger(0);
                DeviceOnLineCountVO xixunLed = new DeviceOnLineCountVO();
                xiXuns.forEach(
                        device -> {
                            String s = redisUtils.get(DeviceRedisKey.XIXUN + device.getLightemitControlCode());
                            if (s != null) {
                                RedisDeviceStatus redisDeviceStatus = JSON.parseObject(s, RedisDeviceStatus.class);
                                if (redisDeviceStatus.getStatus() == 0) {
                                    //在线
                                    onLine.getAndIncrement();
                                } else {
                                    //离线
                                    offLine.getAndIncrement();
                                }
                            } else {
                                offLine.getAndIncrement();
                            }
                        }
                );
                xixunLed.setTotalCount(xiXuns.size());
                xixunLed.setOnlineCount(onLine.get());
                xixunLed.setOfflineCount(offLine.get());
                onLineCountVO.setLedXiXun(xixunLed);
                System.out.println("熙汛执行时间: " + LocalDateTime.now());
                countDownLatchUtil.countDown(str);
            }
        }).start();
        try {
            countDownLatch.await(20000, TimeUnit.MILLISECONDS);
            countDownLatchUtil.remove(str);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("响应时间: " + LocalDateTime.now());
        return onLineCountVO;
    }
    public CommonPage queryAllStatesAndList(Integer pageNo, Integer pageSize, PoleStatesParam param, Integer order, Integer seq) {
        if (param == null) {
@@ -364,24 +727,24 @@
     * @param param
     * @return
     */
    public List<Pole> isBind(List<Pole> list, PoleStatesParam param) {
        List<Pole> bindList = new ArrayList<>();//已绑定客户
        List<Pole> unbindList = new ArrayList<>();//未绑定客户
        list.forEach(bindwarpper -> {
//                Long clientId = bindwarpper.getClientId();
            if (bindwarpper.getClientId() == null) {//判断是否绑定
                unbindList.add(bindwarpper);
            } else {
                bindList.add(bindwarpper);
            }
        });
        if (param.getBingStates() == 0) {
            return bindList;
        } else if (param.getBingStates() == 1) {
            return unbindList;
        }
        return list;
    }
//    public List<Pole> isBind(List<Pole> list, PoleStatesParam param) {
//        List<Pole> bindList = new ArrayList<>();//已绑定客户
//        List<Pole> unbindList = new ArrayList<>();//未绑定客户
//        list.forEach(bindwarpper -> {
////                Long clientId = bindwarpper.getClientId();
//            if (bindwarpper.getClientId() == null) {//判断是否绑定
//                unbindList.add(bindwarpper);
//            } else {
//                bindList.add(bindwarpper);
//            }
//        });
//        if (param.getBingStates() == 0) {
//            return bindList;
//        } else if (param.getBingStates() == 1) {
//            return unbindList;
//        }
//        return list;
//    }
    public List<Pole> isTrue(List<Pole> list, PoleStatesParam param) {
        //实体灯杆
@@ -519,7 +882,7 @@
        }
        String deviceName = byId.getDeviceCode();
        if (deviceName.isEmpty()) {
            throw new BusinessException("该灯杆Mca为空");
            throw new BusinessException("该灯杆Mac为空");
        }
        IRequestFrame build = FrameBuilder.builderA5().orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode()).innerFrame(new A5LightResetReqInnerFrame()).build();
        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, build);
@@ -746,7 +1109,11 @@
            if (pole == null) {
                throw new BusinessException("灯杆不存在");
            }
            //一级客户   -1   userId
            //二级客户   ä¸Šçº§å®¢æˆ·id  userId
            pole.setClientId(-1L);
            pole.setUserId(-1L);
            r = updateById(pole);
            if (!r) {
@@ -760,22 +1127,15 @@
    public List<Pole> getOwnerPole(BaseConditionVO baseConditionVO, String keyword, Long cilentId) {
        LambdaQueryWrapper<Pole> eq;
//        if(SecurityUtils.getClientId()!=null){
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        if (clientService.findClientId(cilentId)) {
            eq = Wrappers.lambdaQuery(Pole.class).eq(Pole::getUserId, cilentId);
            eq = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, cilentId);
        } else {
            PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
            eq = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, cilentId).or(pole -> {
                pole.eq(Pole::getUserId, cilentId);
            });
        }
//        }else {
//            PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
//            eq = Wrappers.lambdaQuery(Pole.class);
//        }
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        if (!keyword.isEmpty()) {
            eq.like(Pole::getPoleName, keyword).or(code -> {
                code.like(Pole::getPoleCode, keyword);
@@ -783,6 +1143,7 @@
                deviceCode.like(Pole::getDeviceCode, keyword);
            });
        }
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        List<Pole> list;
        list = list(eq);
        setCount(list);
@@ -939,7 +1300,7 @@
     * æŽ¨é€å¤§æ°”监测数据到novaLED
     */
    public VnnoxResult pushAirDataToNova(PushAirDataToNovaParam param) {
        Long poleId=param.getPoleId();
        Long poleId = param.getPoleId();
        Pole pole = getById(poleId);
        PoleBinding air = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 3));
        PoleBinding nova = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 1));
@@ -957,8 +1318,104 @@
        A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage data = SpringContextHolder.getBean(AirDataService.class).getDataByPoleid(poleId);
        //推送数据
//        return SpringContextHolder.getBean(VnnoxService.class).publishWaterData(LED.getPlayerId(),param.getDuration(), data);
        return SpringContextHolder.getBean(VnnoxService.class).WaterData(LED.getPlayerId(),param.getDuration(), data);
        return SpringContextHolder.getBean(VnnoxService.class).WaterData(LED.getPlayerId(), param.getDuration(), data);
    }
    /**
     * ç»Ÿè®¡è®¾å¤‡çŠ¶æ€å­˜å…¥redis
     */
    public void setRedis() {
        //  redisStatusKeyTimeout为空  ä»£è¡¨ä¸Šæ¬¡è°ƒç”¨åœ¨15分钟前
        if (redisUtils.get("redisStatusKeyTimeout") != null) {
            //不为空  è¯´æ˜ŽçŸ­æ—¶é—´å†…调用过  ç›´æŽ¥è¿”回
            System.out.println("15分钟内已经更新过数据");
            return;
        }
        //设置触发条件    å­˜å…¥Redis  15分钟超时   15分钟内再次调用直接返回
        redisUtils.set("redisStatusKeyTimeout", System.currentTimeMillis(), 60 * 15);
        CountDownLatch countDownLatch = new CountDownLatch(7);//todo
        //获取一个7位随机数
        String str = RandomStringUtils.randomAlphanumeric(7);
        countDownLatchUtil.push(str, countDownLatch);
        new Thread(new Runnable() {
            @Override
            public void run() {
                SpringContextHolder.getBean(IpVolumeService.class).setCacheData();
                countDownLatchUtil.countDown(str);
                System.out.println("音柱执行");
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                SpringContextHolder.getBean(MonitorService.class).setCacheData();
                countDownLatchUtil.countDown(str);
                System.out.println("摄像头执行");
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                SpringContextHolder.getBean(LightService.class).setCacheData();
                countDownLatchUtil.countDown(str);
                System.out.println("单灯执行");
            }
        }).start();
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                SpringContextHolder.getBean(C3ChargingService.class).setCacheData();
//                countDownLatchUtil.countDown(str);
//                System.out.println("充电桩执行");
//            }
//        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                SpringContextHolder.getBean(AirEquipmentService.class).setCacheData();
                countDownLatchUtil.countDown(str);
                System.out.println("大气执行");
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                SpringContextHolder.getBean(PoleLightemitService.class).setCacheData();
                countDownLatchUtil.countDown(str);
                System.out.println("熙汛执行");
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                SpringContextHolder.getBean(VnnoxService.class).setCacheData();
                countDownLatchUtil.countDown(str);
                System.out.println("诺瓦执行");        //todo è¯ºç“¦æ•…障暂无
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                SpringContextHolder.getBean(PoleLightemitService.class).setCacheData();
                countDownLatchUtil.countDown(str);
                System.out.println("熙汛执行");
            }
        }).start();
        try {
            countDownLatch.await(12000, TimeUnit.MILLISECONDS);
            countDownLatchUtil.remove(str);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/RoleService.java
@@ -56,8 +56,8 @@
            throw new BusinessException("当前用户没有角色");
        }
        List<Long> roleIdList = roles.stream().map(Role::getId).collect(Collectors.toList());
        List<Long> menuIdList = roleMenuRelationService.list(Wrappers.lambdaQuery(RoleMenuRelation.class).in(RoleMenuRelation::getRoleId, roleIdList).select(RoleMenuRelation::getMenuId))
                .stream().map(RoleMenuRelation::getMenuId).distinct().collect(Collectors.toList());
        List<Long> menuIdList = roleMenuRelationService.list(Wrappers.lambdaQuery(RoleMenuRelation.class).in(RoleMenuRelation::getRoleId, roleIdList)
                        .select(RoleMenuRelation::getMenuId)).stream().map(RoleMenuRelation::getMenuId).distinct().collect(Collectors.toList());
        Set<String> menuPermissions = new HashSet<>();
        // èœå•权限
ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java
@@ -1,10 +1,12 @@
package com.sandu.ximon.admin.service;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.config.VnnoxConstant;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame;
import com.sandu.ximon.admin.redis.DeviceRedisKey;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.*;
import com.sandu.ximon.admin.utils.request.VnnoxScreenStatusType;
@@ -12,10 +14,7 @@
import com.sandu.ximon.admin.utils.response.VnnoxPlayerResponse;
import com.sandu.ximon.admin.utils.response.VnnoxResult;
import com.sandu.ximon.admin.utils.response.VnnoxResultResponse;
import com.sandu.ximon.admin.vo.NovaAStateInfoVO;
import com.sandu.ximon.admin.vo.NovaPushResultVO;
import com.sandu.ximon.admin.vo.NovaScreenShorUrlVO;
import com.sandu.ximon.admin.vo.NovaWeatherVO;
import com.sandu.ximon.admin.vo.*;
import com.sandu.ximon.dao.domain.LedPlayerEntity;
import com.sandu.ximon.dao.domain.LedPlayerInfoEntity;
import com.sandu.ximon.dao.domain.LedV2RegisterResultEntity;
@@ -505,7 +504,9 @@
        List<String> temp = new ArrayList<>();
        for (LedPlayerEntity item : ledList) {
            String playerId = item.getPlayerId();
            if (redisUtils.get(VnnoxConstant.REDIS_VOL + playerId) == null || redisUtils.get(VnnoxConstant.REDIS_BRIGHTNESS + playerId) == null) {
            if (redisUtils.get(VnnoxConstant.REDIS_VOL + playerId) == null
                    || redisUtils.get(VnnoxConstant.REDIS_BRIGHTNESS + playerId) == null
                    || redisUtils.get(VnnoxConstant.REDIS_SCREEN_STATUS + playerId) == null) {
                temp.add(item.getPlayerId());
            }
        }
@@ -522,9 +523,9 @@
            for (LedPlayerEntity playerEntity : list) {
                String playerId = playerEntity.getPlayerId();
                LedPlayerInfoEntity cache = new LedPlayerInfoEntity();
                //  è®¾ç½®å±å¹•状态
                //  è®¾ç½®å±å¹•状态  æ›´æ–°çŠ¶æ€ä¹‹åŽè¿˜æ‹¿ä¸åˆ°æ•°æ®è¯´æ˜Žè®¾å¤‡æœ‰é—®é¢˜æˆ–ä¸åœ¨çº¿  è®¾ç½®é»˜è®¤ä¸ºé»‘屏
                String result = redisUtils.get(VnnoxConstant.REDIS_SCREEN_STATUS + playerId);
                Integer screenStatus = 1;
                Integer screenStatus = 0;
                if (null != result) {
                    screenStatus = Integer.parseInt(result);
                }
@@ -699,11 +700,7 @@
                    novaAStateInfoVO.setTimeValue(timeValue);
                    break;
                case "screenPowerStatus":
                    if ("CLOSE".equals(screenPowerStatus)) {
                        novaAStateInfoVO.setScreenPowerStatus("0");
                    } else {
                        novaAStateInfoVO.setScreenPowerStatus("1");
                    }
                    novaAStateInfoVO.setScreenPowerStatus(screenPowerStatus);
                    break;
                case "syncPlayStatus":
                    novaAStateInfoVO.setSyncPlayStatus(syncPlayStatus);
@@ -722,6 +719,38 @@
                    vnnoxAPIUtil.getAsyncStatus(playerIdList, stateValue);
                }
        );
    }
    /**
     * å‘Redis中存入设备状态
     */
    public void setCacheData() {
        List<List<LedPlayerEntity>> split = CollectionUtil.split(ledPlayerEntityService.list(), 100);
        List<LedPlayerEntity> ledList = new ArrayList<>();
        split.forEach(
                list -> {
                    List<LedPlayerEntity> ledPlayerEntities = vnnoxAPIUtil.syncCurrentInfo(list);
                    ledList.addAll(ledPlayerEntities);
                }
        );
        ledList.forEach(
                device -> {
                    RedisDeviceStatus deviceStatus = new RedisDeviceStatus();
                    deviceStatus.setDeviceId(device.getPlayerId());
                    if (device.getOnlineStatus() == 0) {
                        deviceStatus.setStatus(1);
                    } else if (device.getOnlineStatus() == 1) {
                        deviceStatus.setStatus(0);
                    } else {
                        deviceStatus.setStatus(1);
                    }
                    redisUtils.set(DeviceRedisKey.NOVA + device.getPlayerId(), JSON.toJSONString(deviceStatus));
//                    redisUtils.delete(DeviceRedisKey.IP_BROADCAST + device.getId());
                }
        );
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/XiXunPlayerService.java
@@ -366,7 +366,6 @@
        Integer screenHeight = Integer.parseInt(lightemitUtils.getScreenHeight(lightemitControlCode));
        String size = String.valueOf(screenHeight / 18);
        //字幕主体拼接
        //TODO
        String body =
                "<head><style type=\"text/css\">body{background-color:#000;}</style></head>" +
                        "<p style=\"font-size:" + size + "px;line-height:17px;color:#fff\">" +
@@ -409,19 +408,6 @@
                    lightemitUtils.clearPlayerTask(lightemitControlCode);
                    //推送最后命令
                    lightemitUtils.sendLastCommand(lightemitControlCode);
                    /**
                     * ç†™æ±›å¤§æ°”数据推送日志记录开始
                     //                     */
//                    String content = "{设备code:" + lightemitControlCode
//                            + ", æŽ¨é€å†…容:" + body
//                            + " }";
//                    List<String> listCode = new ArrayList<>();
//                    listCode.add(lightemitControlCode);
//                    StoreOperationRecordsUtils.storeOperationData(listCode, null, "熙汛大气数据推送", content);
                    /**
                     * ç†™æ±›å¤§æ°”数据推送日志记录结束
                     */
                }
            }, 60 * 1000);
        }
ximon-admin/src/main/java/com/sandu/ximon/admin/utils/TerminalAPIUtils.java
@@ -3,14 +3,12 @@
import com.alibaba.fastjson.JSON;
import com.sandu.common.execption.BusinessException;
import com.sandu.ximon.admin.config.BroadcastAPI;
import com.sandu.ximon.admin.dto.TerminalDto;
import com.sandu.ximon.admin.utils.request.CommonRequestParams;
import com.sandu.ximon.admin.utils.response.CommonResponseVO;
import com.sandu.ximon.admin.utils.response.DataResponseVO;
import com.sandu.ximon.admin.vo.ListDataResponseVO;
import com.sandu.ximon.admin.dto.TerminalDto;
import com.sandu.ximon.admin.vo.TerminalVO;
import jodd.bean.BeanCopy;
import jodd.bean.BeanUtil;
import org.springframework.beans.BeanUtils;
import java.util.ArrayList;
@@ -25,13 +23,7 @@
     * @return
     */
    public static TerminalDto getTerminalInfo(Integer terminalId) {
        DataResponseVO responseVO = JSON.parseObject(
                BroadcastPostUtils.Post(
                        new CommonRequestParams().put("id", terminalId).getParams(),
                        BroadcastAPI.GET_TERMINAL.getUrl(),
                        CharUtils.GBK),
                DataResponseVO.class
        );
        DataResponseVO responseVO = JSON.parseObject(BroadcastPostUtils.Post(new CommonRequestParams().put("id", terminalId).getParams(), BroadcastAPI.GET_TERMINAL.getUrl(), CharUtils.GBK), DataResponseVO.class);
        TerminalVO bean = responseVO.convert(TerminalVO.class);
@@ -49,13 +41,7 @@
     * èŽ·å–ç»ˆç«¯æœåŠ¡å™¨å¯¹è±¡åˆ—è¡¨
     */
    public static List<TerminalDto> getTerminalList() {
        ListDataResponseVO responseVO = JSON.parseObject(
                BroadcastPostUtils.Post(
                        new CommonRequestParams().getParams(),
                        BroadcastAPI.GET_TERMINAL_LIST.getUrl(),
                        CharUtils.GBK),
                ListDataResponseVO.class
        );
        ListDataResponseVO responseVO = JSON.parseObject(BroadcastPostUtils.Post(new CommonRequestParams().getParams(), BroadcastAPI.GET_TERMINAL_LIST.getUrl(), CharUtils.GBK), ListDataResponseVO.class);
        List<TerminalDto> list = new ArrayList<>();
        if (responseVO.covertTerminalList() != null) {
@@ -81,16 +67,7 @@
     * @return
     */
    public static boolean updateTerminal(Integer terminalId, TerminalVO terminalVO, Long userId) {
        CommonResponseVO responseVO = JSON.parseObject(
                BroadcastPostUtils.Post(
                        new CommonRequestParams()
                                .put("id", terminalId)
                                .put("data", JSON.toJSONString(terminalVO))
                                .getParams(),
                        BroadcastAPI.UPDATE_TERMINAL.getUrl(),
                        CharUtils.GBK),
                CommonResponseVO.class
        );
        CommonResponseVO responseVO = JSON.parseObject(BroadcastPostUtils.Post(new CommonRequestParams().put("id", terminalId).put("data", JSON.toJSONString(terminalVO)).getParams(), BroadcastAPI.UPDATE_TERMINAL.getUrl(), CharUtils.GBK), CommonResponseVO.class);
        if (responseVO.isOK()) {
//            log("修改播放终端(id:"+terminalId+", name:"+terminalVO.getName()+")",userId,null);
            return true;
@@ -107,15 +84,7 @@
     * @return
     */
    public static boolean delTerminal(Integer terminalId, Long userId) {
        CommonResponseVO responseVO = JSON.parseObject(
                BroadcastPostUtils.Post(
                        new CommonRequestParams()
                                .put("id", terminalId)
                                .getParams(),
                        BroadcastAPI.DEL_TERMINAL.getUrl(),
                        CharUtils.GBK),
                CommonResponseVO.class
        );
        CommonResponseVO responseVO = JSON.parseObject(BroadcastPostUtils.Post(new CommonRequestParams().put("id", terminalId).getParams(), BroadcastAPI.DEL_TERMINAL.getUrl(), CharUtils.GBK), CommonResponseVO.class);
        if (responseVO.isOK()) {
//            log("删除播放终端(id:"+terminalId+")",userId,null);
            return true;
@@ -136,17 +105,10 @@
            throw new BusinessException("IP音柱硬件设备不存在");
        }
        terminalInfo.setDefaultVolumn(defaultVolumn);
        terminalInfo.setVolumn(defaultVolumn);
        CommonResponseVO responseVO = JSON.parseObject(
                BroadcastPostUtils.Post(
                        new CommonRequestParams()
                                .put("id", terminalId)
                                .put("data", terminalInfo)
                                .getParams(),
                        BroadcastAPI.UPDATE_TERMINAL.getUrl(),
                        CharUtils.GBK),
                CommonResponseVO.class
        );
        terminalInfo.setVolume(defaultVolumn);
        CommonResponseVO responseVO = JSON.parseObject(BroadcastPostUtils.Post(new CommonRequestParams().put("id", terminalId).put("data", terminalInfo).getParams(), BroadcastAPI.UPDATE_TERMINAL.getUrl(), CharUtils.GBK), CommonResponseVO.class);
        System.out.println(responseVO + " response");
        if (responseVO.isOK()) {
            return true;
        }
ximon-admin/src/main/java/com/sandu/ximon/admin/utils/VnnoxAPIUtil.java
@@ -304,6 +304,7 @@
        List<String> commands = new ArrayList<>();
        commands.add("volumeValue");
        commands.add("brightnessValue");
        commands.add("screenPowerStatus");
        VnnoxBaseRequest request = new VnnoxBaseRequest();
        request.setPlayerIds(playerId);
        request.setCommands(commands);
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/DeviceOnLineCountVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
package com.sandu.ximon.admin.vo;
import lombok.Data;
/**
 * @author LiuHaoNan
 * @date 2022/9/27
 * è®¾å¤‡æ•°é‡ç»Ÿè®¡
 */
@Data
public class DeviceOnLineCountVO {
    /**
     * è®¾å¤‡æ€»æ•°é‡
     */
    private Integer totalCount;
    /**
     * åœ¨çº¿æ•°é‡
     */
    private Integer onlineCount;
    /**
     * ç¦»çº¿æ•°é‡
     */
    private Integer offlineCount = 0;
    /**
     * æ•…障数量
     */
    private Integer errorCount = 0;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/LightTaskInfoVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package com.sandu.ximon.admin.vo;
import com.sandu.ximon.dao.domain.LightTask;
import lombok.Data;
import java.util.List;
/**
 * @author LiuHaoNan
 * @date 2022/9/23
 */
@Data
public class LightTaskInfoVO {
    /**
     * ä»»åŠ¡
     */
    private LightTask lightTask;
    private List<LightTaskRelationVO> relations;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/LightTaskRelationVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,33 @@
package com.sandu.ximon.admin.vo;
import lombok.Data;
/**
 * @author LiuHaoNan
 * @date 2022/9/23
 */
@Data
public class LightTaskRelationVO {
    private Long poleId;
    private String poleName;
    private String lightAddress;
    /**
     * ä»»åŠ¡ä¸‹å‘çŠ¶æ€ï¼Œ0成功,1校验码错误,2长度错误,3写flash错误,255其他错误
     */
    private Integer issueStatus;
    /**
     * ç³»ç»Ÿå®šæ—¶
     */
    private LightTaskVO sysScheduled;
    /**
     * ç¡¬ä»¶å®šæ—¶
     */
    private LightTaskVO deviceScheduled;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/LightTaskVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,53 @@
package com.sandu.ximon.admin.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.util.List;
/**
 * @author LiuHaoNan
 * @date 2022/9/23
 */
@Data
public class LightTaskVO {
    private Long taskId;
    /**
     * ä»»åŠ¡åç§°
     */
    private String taskName;
    /**
     * æ˜ŸæœŸå‡ ï¼Œä½è¿ç®—保存,1代表星期一,2星期二,4星期三,8星期四,16星期五,32星期六,64星期日
     */
    @JsonIgnore
    private Integer week;
    private List<Integer> weekList;
    /**
     * å¼€ç¯å‘½ä»¤
     */
    private String openOrder;
    /**
     * å…³é—­ç¯å‘½ä»¤
     */
    private String closeOrder;
    /**
     * ç¯æŽ§å‘½ä»¤
     */
    private String controlOrder;
    /**
     * æŽ§ç¯åœ°å€
     */
    private String lightAdress;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/OnLineCountVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,62 @@
package com.sandu.ximon.admin.vo;
import lombok.Data;
/**
 * @author LiuHaoNan
 * @date 2022/9/27
 * é¦–页数量统计实体
 */
@Data
public class OnLineCountVO {
    /**
     * è¯ºç“¦
     */
    private DeviceOnLineCountVO ledNova;
    /**
     * éŸ³æŸ±
     */
    private DeviceOnLineCountVO broadcast;
    /**
     * æ‘„像头
     */
    private DeviceOnLineCountVO monitor;
    /**
     * å•灯
     */
    private DeviceOnLineCountVO light;
    /**
     * å……电桩
     */
    private DeviceOnLineCountVO c3m;
    /**
     * å¤§æ°”
     */
    private DeviceOnLineCountVO airEquipment;
    /**
     * å†œè€•
     */
    private DeviceOnLineCountVO airEquipmentNongGeng;
    /**
     * æ°´è´¨
     */
    private DeviceOnLineCountVO waterEquipment;
    /**
     * ç¯æ†å€¾æ–œ
     */
    private DeviceOnLineCountVO LightPoleHeeling;
    /**
     * ç†™æ±›
     */
    private DeviceOnLineCountVO ledXiXun;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/RedisDeviceStatus.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
package com.sandu.ximon.admin.vo;
import lombok.Data;
/**
 * @author LiuHaoNan
 * @date 2022/9/26
 * Redis中的设备状态实体
 */
@Data
public class RedisDeviceStatus {
    private String deviceId;
    /**
     * è®¾å¤‡çŠ¶æ€  0在线  1离线  2故障
     */
    private Integer status;
}
ximon-admin/src/main/java/com/sandu/ximon/admin/vo/RemoteUpgradeProgress.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
package com.sandu.ximon.admin.vo;
import lombok.Data;
/**
 * è¿œç¨‹å‡çº§   å‡çº§è¿›åº¦
 */
@Data
public class RemoteUpgradeProgress {
    /**
     * å½“前进度
     */
    private int currentProgress = 0;
    /**
     * æ€»è¿›åº¦
     */
    private int totalProgress = 0;
}
ximon-admin/src/main/resources/application-local.yml
@@ -39,7 +39,7 @@
    enable: true
listenter:
  isOpen: false
  isOpen: true
minio:
  endpoint: 47.106.172.9
@@ -65,4 +65,4 @@
nova-conf:   #诺瓦回调
  notify-url: http://112.74.63.130:20017/serv/vnnox/progress
  screen-shot-notify-url: http://112.74.63.130:20017/serv/vnnox/screenshot
  status-notify-url: http://112.74.63.130:20017/serv/vnnox/asyncStatus
  status-notify-url: http://112.74.63.130:20017/serv/vnnox/asyncStatus
ximon-admin/src/main/resources/application-prod.yml
@@ -1,4 +1,4 @@
# ç”Ÿäº§é…ç½®æ–‡ä»¶ ä¸»æœº  39.103.154.108
# ç”Ÿäº§é…ç½®æ–‡ä»¶ ä¸»æœº  39.103.154.108   127.0.0.1
server:
    port: 20018
spring:
ximon-admin/src/main/resources/application.yml
@@ -1,6 +1,6 @@
spring:
  profiles:
       active: prod
    active: prod
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8
@@ -22,17 +22,12 @@
logging:
  file:
    path: logs
wx:
  pay:
    appId: dsd #微信公众号或者小程序等的appid
    mchId: dsdsd #微信支付商户号
    mchKey: dsd #微信支付商户密钥
# led屏幕服务器地址(更改需要同时更改)
realtime-server:
#  command: http://101.132.131.91:8081/payload/
#  url: http://101.132.131.91:8081/
  #  command: http://101.132.131.91:8081/payload/
  #  url: http://101.132.131.91:8081/
  command: http://112.74.63.130:20018/command/
  url: http://112.74.63.130:20018/
@@ -48,3 +43,14 @@
  secretKey: zhxm2512209
  secure: false
#音柱服务器地址
broadcastApi:
  serviceUrl: http://47.106.172.9:8000
nova-conf: #诺瓦账号密码
  username: zhxm
  password: xm2512209.
#主板rrpc通信PRODUCT_KEY
#rrpc:
#  key: a1JsfPG4iKW