Merge remote-tracking branch 'origin/master'
| | |
| | | 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 lombok.Data; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * |
| | | * @TableName air_data |
| | | */ |
| | | @TableName(value ="air_data") |
| | | @Data |
| | | public class AirData implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | //æå±ç¯æ |
| | | private String belongTo; |
| | | //æ¥å
¥æ¶é´ |
| | | /** |
| | | * 设å¤mac |
| | | */ |
| | | private String deviceMac; |
| | | |
| | | /** |
| | | * 设å¤åå· |
| | | */ |
| | | private String deviceType; |
| | | |
| | | /** |
| | | * 模åé¢çç¶ææ å¿ |
| | | */ |
| | | private String moduleWarmUpStatusFlag; |
| | | |
| | | /** |
| | | * æ¸©åº¦å¼ |
| | | */ |
| | | private Double temperature; |
| | | |
| | | /** |
| | | * æ¹¿åº¦å¼ |
| | | */ |
| | | private Double humidity; |
| | | |
| | | /** |
| | | * é£é |
| | | */ |
| | | private Double windSpeed; |
| | | |
| | | /** |
| | | * é£å |
| | | */ |
| | | private Double windDirection; |
| | | |
| | | /** |
| | | * 大æ°å |
| | | */ |
| | | private Integer pressure; |
| | | |
| | | /** |
| | | * å
强 |
| | | */ |
| | | private Integer lightIntensity; |
| | | |
| | | /** |
| | | * åªé³ |
| | | */ |
| | | private Integer noise; |
| | | |
| | | /** |
| | | * PM2.5 |
| | | */ |
| | | private Integer pm25; |
| | | |
| | | /** |
| | | * PM10 |
| | | */ |
| | | private Integer pm10; |
| | | |
| | | /** |
| | | * æ»æ¬æµ®é¢ç²ç©ï¼TSPï¼ |
| | | */ |
| | | private Integer tsp; |
| | | |
| | | /** |
| | | * SO2äºæ°§åç¡«ç¸å¯¹å¼ |
| | | */ |
| | | private Integer so2; |
| | | |
| | | /** |
| | | * ç²éç¸å¯¹å¼ |
| | | */ |
| | | private Integer ech2o; |
| | | |
| | | /** |
| | | * NO2äºæ°§åæ°® |
| | | */ |
| | | private Integer no2; |
| | | |
| | | /** |
| | | * TVOC |
| | | */ |
| | | private Integer tvoc; |
| | | |
| | | /** |
| | | * CO䏿°§å碳 |
| | | */ |
| | | private Integer co; |
| | | |
| | | /** |
| | | * äºæ°§å碳 |
| | | */ |
| | | private Integer co2; |
| | | |
| | | /** |
| | | * O3èæ°§ |
| | | */ |
| | | private Integer o3; |
| | | |
| | | /** |
| | | * Fæ°åç© |
| | | */ |
| | | private Integer fluoride; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private LocalDateTime createTime; |
| | | //温度 |
| | | private String temperature; |
| | | //湿度 |
| | | private String humidity; |
| | | //PM2.5 |
| | | private String PM25; |
| | | //亮度 |
| | | private int brightness; |
| | | //PM10 |
| | | private String PM10; |
| | | //ç²é |
| | | private String formaldehyde; |
| | | //äºæ°§å碳CO2 |
| | | private String CO2; |
| | | //室å
ææºæ°æç©è´¨ |
| | | private int tVoc; |
| | | //é£é |
| | | private String windSpeed; |
| | | //䏿¥æ¶é´ |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private LocalDateTime updateTime; |
| | | } |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * è·¯ç¯ä»»å¡è¡¨ |
| | | * @TableName light_task |
| | | */ |
| | | @TableName(value ="light_task") |
| | | @Data |
| | | public class LightTask implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long taskId; |
| | | |
| | | /** |
| | | * 客æ·id |
| | | */ |
| | | private Long clientId; |
| | | |
| | | /** |
| | | * ä»»å¡åç§° |
| | | */ |
| | | private String taskName; |
| | | |
| | | /** |
| | | * 1æåã0å¯ç¨ |
| | | */ |
| | | private Integer pause; |
| | | |
| | | /** |
| | | * ææå ï¼ä½è¿ç®ä¿åï¼1代表ææä¸ï¼2ææäºï¼4ææä¸ï¼8ææåï¼16ææäºï¼32ææå
ï¼64æææ¥ |
| | | */ |
| | | private Integer week; |
| | | |
| | | /** |
| | | * å¼ç¯å½ä»¤ |
| | | */ |
| | | private String openOrder; |
| | | |
| | | /** |
| | | * å
³éç¯å½ä»¤ |
| | | */ |
| | | private String closeOrder; |
| | | |
| | | /** |
| | | * ç¯æ§å½ä»¤ |
| | | */ |
| | | private String controlOrder; |
| | | |
| | | /** |
| | | * åå»ºç¨æ· |
| | | */ |
| | | private String createUser; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private LocalDateTime updateTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * è·¯ç¯ä»»å¡åç¯æå
³ç³»è¡¨ |
| | | * @TableName light_task_pole_relation |
| | | */ |
| | | @TableName(value ="light_task_pole_relation") |
| | | @Data |
| | | public class LightTaskPoleRelation implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * ä»»å¡id |
| | | */ |
| | | private Long taskId; |
| | | |
| | | /** |
| | | * ç¯æid |
| | | */ |
| | | private Long poleId; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private LocalDateTime updateTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * è·¯ç¯ä»»å¡å®æ¶å¨è¡¨ |
| | | * @TableName light_task_quartz |
| | | */ |
| | | @TableName(value ="light_task_quartz") |
| | | @Data |
| | | public class LightTaskQuartz implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * ä»»å¡id |
| | | */ |
| | | private Long taskId; |
| | | |
| | | /** |
| | | * 宿¶å¨åç§° |
| | | */ |
| | | private String quartzName; |
| | | |
| | | /** |
| | | * 宿¶å¨cron |
| | | */ |
| | | private String cronExpression; |
| | | |
| | | /** |
| | | * 1æåã0å¯ç¨ |
| | | */ |
| | | private Integer pause; |
| | | |
| | | /** |
| | | * 宿¶å¨å½ä»¤å¸§ |
| | | */ |
| | | private String framePayload; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private LocalDateTime updateTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * è·¯ç¯ä»»å¡å®æ¶å¨æ§è¡æ¥å¿è¡¨ |
| | | * @TableName light_task_quartz_log |
| | | */ |
| | | @TableName(value ="light_task_quartz_log") |
| | | @Data |
| | | public class LightTaskQuartzLog implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * ä»»å¡id |
| | | */ |
| | | private Long taskId; |
| | | |
| | | /** |
| | | * 宿¶å¨id |
| | | */ |
| | | private Long quartzId; |
| | | |
| | | /** |
| | | * ä»»å¡åç§° |
| | | */ |
| | | private String taskName; |
| | | |
| | | /** |
| | | * 宿¶å¨cron |
| | | */ |
| | | private String cronExpression; |
| | | |
| | | /** |
| | | * 帧è´è· |
| | | */ |
| | | private String framePayload; |
| | | |
| | | /** |
| | | * è¯·æ±æ¶é´ |
| | | */ |
| | | private Long time; |
| | | |
| | | /** |
| | | * é误æ¥å¿ |
| | | */ |
| | | private String exceptionDetail; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | private LocalDateTime createTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.enums; |
| | | |
| | | /** |
| | | * æææä¸¾ç±» |
| | | * |
| | | * @author chenjiantian |
| | | */ |
| | | public enum WeekEnums { |
| | | |
| | | /** |
| | | * TUESDAY |
| | | */ |
| | | MONDAY(1), |
| | | /** |
| | | * TUESDAY |
| | | */ |
| | | TUESDAY(2), |
| | | /** |
| | | * WEDNESDAY |
| | | */ |
| | | WEDNESDAY(4), |
| | | /** |
| | | * THURSDAY |
| | | */ |
| | | THURSDAY(8), |
| | | /** |
| | | * FRIDAY |
| | | */ |
| | | FRIDAY(16), |
| | | /** |
| | | * SATURDAY |
| | | */ |
| | | SATURDAY(32), |
| | | /** |
| | | * SUNDAY |
| | | */ |
| | | SUNDAY(64), |
| | | ; |
| | | |
| | | private final Integer code; |
| | | |
| | | WeekEnums(Integer code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | |
| | | public Integer getCode() { |
| | | return code; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.common.domain.BaseMapper; |
| | | import com.sandu.ximon.dao.domain.AirData; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.sandu.ximon.dao.domain.Monitor; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Entity com.sandu.ximon.dao.domain.AirData |
| | | */ |
| | | @Mapper |
| | | public interface AirDataMapper extends BaseMapper<AirData> { |
| | | List<String> listAirEquipmentMAC(); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.ximon.dao.domain.LightTask; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Entity com.sandu.ximon.dao.domain.LightTask |
| | | */ |
| | | @Mapper |
| | | public interface LightTaskMapper extends BaseMapper<LightTask> { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.ximon.dao.domain.LightTaskPoleRelation; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Entity com.sandu.ximon.dao.domain.LightTaskPoleRelation |
| | | */ |
| | | @Mapper |
| | | public interface LightTaskPoleRelationMapper extends BaseMapper<LightTaskPoleRelation> { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.ximon.dao.domain.LightTaskQuartzLog; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Entity com.sandu.ximon.dao.domain.LightTaskQuartzLog |
| | | */ |
| | | @Mapper |
| | | public interface LightTaskQuartzLogMapper extends BaseMapper<LightTaskQuartzLog> { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.ximon.dao.domain.LightTaskQuartz; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Entity com.sandu.ximon.dao.domain.LightTaskQuartz |
| | | */ |
| | | @Mapper |
| | | public interface LightTaskQuartzMapper extends BaseMapper<LightTaskQuartz> { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.AirData"> |
| | | <id property="id" column="id" jdbcType="BIGINT"/> |
| | | <result property="belongTo" column="belong_to" jdbcType="VARCHAR"/> |
| | | <result property="deviceMac" column="device_mac" jdbcType="VARCHAR"/> |
| | | <result property="deviceType" column="device_type" jdbcType="VARCHAR"/> |
| | | <result property="moduleWarmUpStatusFlag" column="module_warm_up_status_flag" jdbcType="VARCHAR"/> |
| | | <result property="temperature" column="temperature" jdbcType="DOUBLE"/> |
| | | <result property="humidity" column="humidity" jdbcType="DOUBLE"/> |
| | | <result property="windSpeed" column="wind_speed" jdbcType="DOUBLE"/> |
| | | <result property="windDirection" column="wind_direction" jdbcType="DOUBLE"/> |
| | | <result property="pressure" column="pressure" jdbcType="INTEGER"/> |
| | | <result property="lightIntensity" column="light_intensity" jdbcType="INTEGER"/> |
| | | <result property="noise" column="noise" jdbcType="INTEGER"/> |
| | | <result property="pm25" column="pm25" jdbcType="INTEGER"/> |
| | | <result property="pm10" column="pm10" jdbcType="INTEGER"/> |
| | | <result property="tsp" column="tsp" jdbcType="INTEGER"/> |
| | | <result property="so2" column="so2" jdbcType="INTEGER"/> |
| | | <result property="ech2o" column="ech2o" jdbcType="INTEGER"/> |
| | | <result property="no2" column="no2" jdbcType="INTEGER"/> |
| | | <result property="tvoc" column="tvoc" jdbcType="INTEGER"/> |
| | | <result property="co" column="co" jdbcType="INTEGER"/> |
| | | <result property="co2" column="co2" jdbcType="INTEGER"/> |
| | | <result property="o3" column="o3" jdbcType="INTEGER"/> |
| | | <result property="fluoride" column="fluoride" jdbcType="INTEGER"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="temperature" column="temperature" jdbcType="VARCHAR"/> |
| | | <result property="humidity" column="humidity" jdbcType="VARCHAR"/> |
| | | <result property="PM25" column="p_m25" jdbcType="VARCHAR"/> |
| | | <result property="brightness" column="brightness" jdbcType="INTEGER"/> |
| | | <result property="PM10" column="p_m10" jdbcType="VARCHAR"/> |
| | | <result property="formaldehyde" column="formaldehyde" jdbcType="VARCHAR"/> |
| | | <result property="CO2" column="c_o2" jdbcType="VARCHAR"/> |
| | | <result property="tVoc" column="t_voc" jdbcType="INTEGER"/> |
| | | <result property="windSpeed" column="wind_speed" jdbcType="VARCHAR"/> |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <select id="listAirEquipmentMAC" resultType="java.lang.String"> |
| | | SELECT DISTINCT |
| | | device_mac |
| | | FROM |
| | | air_data |
| | | </select> |
| | | |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.sandu.ximon.dao.mapper.LightTaskMapper"> |
| | | |
| | | <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightTask"> |
| | | <id property="taskId" column="task_id" jdbcType="BIGINT"/> |
| | | <result property="clientId" column="client_id" jdbcType="BIGINT"/> |
| | | <result property="taskName" column="task_name" jdbcType="VARCHAR"/> |
| | | <result property="pause" column="pause" jdbcType="TINYINT"/> |
| | | <result property="week" column="week" jdbcType="TINYINT"/> |
| | | <result property="openOrder" column="open_order" jdbcType="VARCHAR"/> |
| | | <result property="closeOrder" column="close_order" jdbcType="VARCHAR"/> |
| | | <result property="controlOrder" column="control_order" jdbcType="VARCHAR"/> |
| | | <result property="createUser" column="create_user" jdbcType="VARCHAR"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | task_id,client_id,task_name, |
| | | pause,week,open_order, |
| | | close_order,control_order,create_user, |
| | | create_time,update_time |
| | | </sql> |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.sandu.ximon.dao.mapper.LightTaskPoleRelationMapper"> |
| | | |
| | | <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightTaskPoleRelation"> |
| | | <id property="id" column="id" jdbcType="BIGINT"/> |
| | | <result property="taskId" column="task_id" jdbcType="BIGINT"/> |
| | | <result property="poleId" column="pole_id" jdbcType="BIGINT"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | id,task_id,pole_id, |
| | | create_time,update_time |
| | | </sql> |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.sandu.ximon.dao.mapper.LightTaskQuartzLogMapper"> |
| | | |
| | | <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightTaskQuartzLog"> |
| | | <id property="id" column="id" jdbcType="BIGINT"/> |
| | | <result property="taskId" column="task_id" jdbcType="BIGINT"/> |
| | | <result property="quartzId" column="quartz_id" jdbcType="BIGINT"/> |
| | | <result property="taskName" column="task_name" jdbcType="VARCHAR"/> |
| | | <result property="cronExpression" column="cron_expression" jdbcType="VARCHAR"/> |
| | | <result property="framePayload" column="frame_payload" jdbcType="VARCHAR"/> |
| | | <result property="time" column="time" jdbcType="BIGINT"/> |
| | | <result property="exceptionDetail" column="exception_detail" jdbcType="VARCHAR"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | id,task_id,quartz_id, |
| | | task_name,cron_expression,frame_payload, |
| | | time,exception_detail,create_time |
| | | </sql> |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.sandu.ximon.dao.mapper.LightTaskQuartzMapper"> |
| | | |
| | | <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightTaskQuartz"> |
| | | <id property="id" column="id" jdbcType="BIGINT"/> |
| | | <result property="taskId" column="task_id" jdbcType="BIGINT"/> |
| | | <result property="quartzName" column="quartz_name" jdbcType="VARCHAR"/> |
| | | <result property="cronExpression" column="cron_expression" jdbcType="VARCHAR"/> |
| | | <result property="pause" column="pause" jdbcType="TINYINT"/> |
| | | <result property="framePayload" column="frame_payload" jdbcType="VARCHAR"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | id,task_id,quartz_name, |
| | | cron_expression,pause,frame_payload, |
| | | create_time,update_time |
| | | </sql> |
| | | </mapper> |
| | |
| | | |
| | | /** |
| | | * @author yadong.zhang (yadong.zhang0415(a)gmail.com) |
| | | * @website https://www.zhyd.me |
| | | * @version 1.0 |
| | | * @website https://www.zhyd.me |
| | | * @date 2018/4/16 16:26 |
| | | * @since 1.0 |
| | | */ |
| | | public enum ResponseStatusEnums { |
| | | /** æä½æå*/ |
| | | /** |
| | | * æä½æå |
| | | */ |
| | | SUCCESS(20000, "success"), |
| | | FAIL(40000, "fail"), |
| | | |
| | | BAD_CREDENTIALS(40001, "ç¨æ·åæå¯ç 䏿£ç¡®"), |
| | | DISABLE_ACCOUNT(40002, "该账å·å·²è¢«ç¦æ¢ä½¿ç¨"), |
| | | /** token ç¸å
³ */ |
| | | TOKEN_INVALID(40011, "token失æ"), |
| | | /** |
| | | * token ç¸å
³ |
| | | */ |
| | | TOKEN_INVALID(40011, "tokenæ æ"), |
| | | TOKEN_EXPIRED(40012, "tokenè¿æ"), |
| | | TOKEN_NONE(40013, "token为空"), |
| | | SINGLE_LOGIN(40014, "该账å·å¨å
¶ä»è®¾å¤ç»å½,è¯·éæ°ç»å½"), |
| | | TENANT_NONE(40015, "ç§æ·id为空"), |
| | | TENANT_ERROR(40016, "ç§æ·å¼åºé"), |
| | | TENANT_EXPIRED(40017, "ç§æ·ä¼åå·²è¿æ"), |
| | | |
| | | FORBIDDEN(40030, "没æç¸å
³æé"), |
| | | |
| | | WECHAT_LOGIN_UNREGISTERED(40041, "è¯¥ä¸æ¹è´¦å·æªæ³¨åï¼è¯·å°æ³¨åçé¢"), |
| | | WECHAT_LOGIN_SET_PASSWORD(40042, "ææºä¸ºé¦æ¬¡ç»å½ï¼è¯·è®¾ç½®ç»å½å¯ç "), |
| | | |
| | | /** æå¡å¨å¼å¸¸ */ |
| | | /** |
| | | * æå¡å¨å¼å¸¸ |
| | | */ |
| | | SERVER_ERROR(50000, "apiæ¥å£åºé"), |
| | | ; |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.common.quartz; |
| | | |
| | | import org.quartz.JobExecutionContext; |
| | | import org.springframework.scheduling.quartz.QuartzJobBean; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/15 10:28 |
| | | */ |
| | | public class ExecutionJob extends QuartzJobBean { |
| | | |
| | | @Override |
| | | protected void executeInternal(JobExecutionContext context) { |
| | | System.out.println("æ§è¡ä»»å¡"); |
| | | System.out.println(Thread.currentThread().toString()); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.common.quartz.config; |
| | | |
| | | import com.sandu.common.quartz.service.QuartzService; |
| | | import org.quartz.Scheduler; |
| | | import org.quartz.spi.TriggerFiredBundle; |
| | | import org.springframework.beans.factory.config.AutowireCapableBeanFactory; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.scheduling.quartz.AdaptableJobFactory; |
| | | import org.springframework.scheduling.quartz.SchedulerFactoryBean; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/15 10:48 |
| | | */ |
| | | @Configuration |
| | | @ConditionalOnClass(QuartzService.class) |
| | | public class QuartzConfig { |
| | | |
| | | /** |
| | | * è§£å³Job䏿³¨å
¥Spring Bean为nullçé®é¢ |
| | | */ |
| | | @Component("quartzJobFactory") |
| | | public static class QuartzJobFactory extends AdaptableJobFactory { |
| | | |
| | | private final AutowireCapableBeanFactory capableBeanFactory; |
| | | |
| | | public QuartzJobFactory(AutowireCapableBeanFactory capableBeanFactory) { |
| | | this.capableBeanFactory = capableBeanFactory; |
| | | } |
| | | |
| | | @Override |
| | | protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { |
| | | |
| | | //è°ç¨ç¶ç±»çæ¹æ³ |
| | | Object jobInstance = super.createJobInstance(bundle); |
| | | capableBeanFactory.autowireBean(jobInstance); |
| | | return jobInstance; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 注å
¥schedulerå°spring |
| | | * @param quartzJobFactory / |
| | | * @return Scheduler |
| | | * @throws Exception / |
| | | */ |
| | | @Bean(name = "scheduler") |
| | | public Scheduler scheduler(QuartzJobFactory quartzJobFactory) throws Exception { |
| | | SchedulerFactoryBean factoryBean = new SchedulerFactoryBean(); |
| | | factoryBean.setJobFactory(quartzJobFactory); |
| | | factoryBean.afterPropertiesSet(); |
| | | Scheduler scheduler = factoryBean.getScheduler(); |
| | | scheduler.start(); |
| | | return scheduler; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.common.quartz.service; |
| | | |
| | | import org.springframework.scheduling.quartz.QuartzJobBean; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/15 10:36 |
| | | */ |
| | | public interface QuartzService { |
| | | |
| | | /** |
| | | * å¢å ä¸ä¸ªä»»å¡job |
| | | * |
| | | * @param jobClass å®ç°çä»»å¡ç±» |
| | | * @param jobId ä»»å¡å¯ä¸id |
| | | * @param cron cronè¡¨è¾¾å¼ |
| | | * @param jobData åæ° |
| | | */ |
| | | void addJob(Class<? extends QuartzJobBean> jobClass, Long jobId, String cron, Map<String, Object> jobData); |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¸ä¸ªä»»å¡job |
| | | * |
| | | * @param jobClass å®ç°çä»»å¡ç±» |
| | | * @param jobId ä»»å¡å¯ä¸id |
| | | * @param cron cronè¡¨è¾¾å¼ |
| | | * @param jobData åæ° |
| | | */ |
| | | void updateJobCron(Class<? extends QuartzJobBean> jobClass, Long jobId, String cron, Map<String, Object> jobData); |
| | | |
| | | /** |
| | | * å é¤ä¸ä¸ªä»»å¡job |
| | | * |
| | | * @param jobClass å®ç°çä»»å¡ç±» |
| | | * @param jobId 宿¶ä»»å¡id |
| | | */ |
| | | void deleteJob(Class<? extends QuartzJobBean> jobClass, Long jobId); |
| | | |
| | | /** |
| | | * æåä¸ä¸ªä»»å¡job |
| | | * |
| | | * @param jobClass å®ç°çä»»å¡ç±» |
| | | * @param jobId 宿¶ä»»å¡id |
| | | */ |
| | | void pauseJob(Class<? extends QuartzJobBean> jobClass, Long jobId); |
| | | |
| | | /** |
| | | * æ¢å¤ä¸ä¸ªä»»å¡job |
| | | * |
| | | * @param jobClass å®ç°çä»»å¡ç±» |
| | | * @param jobId ä»»å¡å¯ä¸id |
| | | * @param cron cronè¡¨è¾¾å¼ |
| | | * @param jobData åæ° |
| | | */ |
| | | void resumeJob(Class<? extends QuartzJobBean> jobClass, Long jobId, String cron, Map<String, Object> jobData); |
| | | |
| | | /** |
| | | * ç«å³æ§è¡ä¸ä¸ªä»»å¡job |
| | | * |
| | | * @param jobClass å®ç°çä»»å¡ç±» |
| | | * @param jobId ä»»å¡å¯ä¸id |
| | | * @param cron cronè¡¨è¾¾å¼ |
| | | * @param jobData åæ° |
| | | */ |
| | | void runJobNow(Class<? extends QuartzJobBean> jobClass, Long jobId, String cron, Map<String, Object> jobData); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.common.quartz.service; |
| | | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.quartz.*; |
| | | import org.quartz.impl.triggers.CronTriggerImpl; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.scheduling.quartz.QuartzJobBean; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/15 10:39 |
| | | * quartz job管çç±» |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | @ConditionalOnProperty(prefix = "sandu.quartz", name = "enable", havingValue = "true") |
| | | public class QuartzServiceImpl implements QuartzService { |
| | | |
| | | @Resource(name = "scheduler") |
| | | private Scheduler scheduler; |
| | | |
| | | @Override |
| | | public void addJob(Class<? extends QuartzJobBean> jobClass, Long jobId, String cron, Map<String, Object> jobData) { |
| | | try { |
| | | String simpleName = jobClass.getSimpleName(); |
| | | JobDetail jobDetail = JobBuilder.newJob(jobClass) |
| | | .withIdentity(simpleName + jobId) |
| | | .build(); |
| | | CronTrigger cronTrigger = TriggerBuilder.newTrigger() |
| | | .withIdentity(simpleName + jobId) |
| | | .startNow() |
| | | .withSchedule(CronScheduleBuilder.cronSchedule(cron)) |
| | | .build(); |
| | | cronTrigger.getJobDataMap().putAll(jobData); |
| | | ((CronTriggerImpl) cronTrigger).setStartTime(new Date()); |
| | | scheduler.scheduleJob(jobDetail, cronTrigger); |
| | | |
| | | log.info("æ·»å 宿¶å¨{}", simpleName + jobId); |
| | | } catch (SchedulerException e) { |
| | | log.error("åå»ºå®æ¶ä»»å¡å¤±è´¥", e); |
| | | throw new BusinessException("åå»ºå®æ¶ä»»å¡å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void updateJobCron(Class<? extends QuartzJobBean> jobClass, Long jobId, String cron, Map<String, Object> jobData) { |
| | | try { |
| | | TriggerKey triggerKey = TriggerKey.triggerKey(jobClass.getSimpleName() + jobId); |
| | | CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey); |
| | | if (trigger == null) { |
| | | addJob(jobClass, jobId, cron, jobData); |
| | | trigger = (CronTrigger) scheduler.getTrigger(triggerKey); |
| | | } |
| | | CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cron); |
| | | trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build(); |
| | | trigger.getJobDataMap().putAll(jobData); |
| | | |
| | | scheduler.rescheduleJob(triggerKey, trigger); |
| | | } catch (SchedulerException e) { |
| | | log.error("æ´æ°å®æ¶ä»»å¡å¤±è´¥", e); |
| | | throw new BusinessException("æ´æ°å®æ¶ä»»å¡å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deleteJob(Class<? extends QuartzJobBean> jobClass, Long jobId) { |
| | | try { |
| | | JobKey jobKey = JobKey.jobKey(jobClass.getSimpleName() + jobId); |
| | | scheduler.pauseJob(jobKey); |
| | | scheduler.deleteJob(jobKey); |
| | | log.info("å é¤å®æ¶å¨{}", jobClass.getSimpleName() + jobId); |
| | | } catch (SchedulerException e) { |
| | | log.error("å é¤å®æ¶ä»»å¡å¤±è´¥", e); |
| | | throw new BusinessException("å é¤å®æ¶ä»»å¡å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void pauseJob(Class<? extends QuartzJobBean> jobClass, Long jobId) { |
| | | try { |
| | | JobKey jobKey = JobKey.jobKey(jobClass.getSimpleName() + jobId); |
| | | scheduler.pauseJob(jobKey); |
| | | } catch (Exception e) { |
| | | log.error("宿¶ä»»å¡æå失败", e); |
| | | throw new BusinessException("宿¶ä»»å¡æå失败"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void resumeJob(Class<? extends QuartzJobBean> jobClass, Long jobId, String cron, Map<String, Object> jobData) { |
| | | try { |
| | | TriggerKey triggerKey = TriggerKey.triggerKey(jobClass.getSimpleName() + jobId); |
| | | CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey); |
| | | // 妿ä¸åå¨åå建ä¸ä¸ªå®æ¶ä»»å¡ |
| | | if (trigger == null) { |
| | | addJob(jobClass, jobId, cron, jobData); |
| | | } |
| | | JobKey jobKey = JobKey.jobKey(jobClass.getSimpleName() + jobId); |
| | | scheduler.resumeJob(jobKey); |
| | | } catch (Exception e) { |
| | | log.error("æ¢å¤å®æ¶ä»»å¡å¤±è´¥", e); |
| | | throw new BusinessException("æ¢å¤å®æ¶ä»»å¡å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void runJobNow(Class<? extends QuartzJobBean> jobClass, Long jobId, String cron, Map<String, Object> jobData) { |
| | | try { |
| | | TriggerKey triggerKey = TriggerKey.triggerKey(jobClass.getSimpleName() + jobId); |
| | | CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey); |
| | | // 妿ä¸åå¨åå建ä¸ä¸ªå®æ¶ä»»å¡ |
| | | if (trigger == null) { |
| | | addJob(jobClass, jobId, cron, jobData); |
| | | } |
| | | JobDataMap dataMap = new JobDataMap(); |
| | | dataMap.putAll(jobData); |
| | | JobKey jobKey = JobKey.jobKey(jobClass.getSimpleName() + jobId); |
| | | scheduler.triggerJob(jobKey, dataMap); |
| | | } catch (Exception e) { |
| | | log.error("宿¶ä»»å¡æ§è¡å¤±è´¥", e); |
| | | throw new BusinessException("宿¶ä»»å¡æ§è¡å¤±è´¥"); |
| | | } |
| | | } |
| | | } |
| | |
| | | SecurityProperties properties = SpringContextHolder.getBean(SecurityProperties.class); |
| | | |
| | | if (!StringUtils.hasText(token)) { |
| | | writeResponse(response, ResponseUtil.error(ResponseStatusEnums.TOKEN_NONE.getCode(), ResponseStatusEnums.TOKEN_NONE.getMessage())); |
| | | writeResponse(response, ResponseUtil.error(ResponseStatusEnums.TOKEN_INVALID.getCode(), ResponseStatusEnums.TOKEN_INVALID.getMessage())); |
| | | return; |
| | | } |
| | | |
| | |
| | | active: dev |
| | | # active: "@profileActive@" |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.config; |
| | | |
| | | import com.sandu.ximon.admin.service.LightTaskQuartzService; |
| | | import com.sandu.ximon.dao.domain.LightTaskQuartz; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.boot.ApplicationArguments; |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/16 11:55 |
| | | */ |
| | | @AllArgsConstructor |
| | | @Component |
| | | public class JobRunner implements ApplicationRunner { |
| | | |
| | | private final LightTaskQuartzService lightTaskQuartzService; |
| | | |
| | | @Override |
| | | public void run(ApplicationArguments args) throws Exception { |
| | | System.out.println("--------------------注å
¥è·¯ç¯å®æ¶ä»»å¡---------------------"); |
| | | List<LightTaskQuartz> list = lightTaskQuartzService.list(); |
| | | lightTaskQuartzService.runLightTaskQuartz(list); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.constant; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/16 11:42 |
| | | */ |
| | | public class Constants { |
| | | |
| | | // ç¯å®æ¶å½ä»¤é¿åº¦ |
| | | public final static int LIGHT_TIMER_ORDER_LENGTH = 8; |
| | | } |
| | |
| | | @Slf4j |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("v1/admin") |
| | | @RequestMapping("/v1/admin") |
| | | public class AdminController { |
| | | |
| | | private final SecurityProperties properties; |
| | |
| | | } |
| | | |
| | | /** |
| | | * æ¨¡ç³æ¥è¯¢ |
| | | * |
| | | * æ¥è¯¢å¤§æ°è®¾å¤MACå°å |
| | | * @return |
| | | */ |
| | | @GetMapping("/listAirDataByKeyword/{keyword}") |
| | | public ResponseVO<Object> listAirDataByKeyword(@PathVariable String keyword) { |
| | | List<AirData> list = airDataService.listAirDataByKeyword(keyword); |
| | | @GetMapping("/listAirEquipmentMAC") |
| | | public ResponseVO<Object> listAirEquipmentMAC() { |
| | | List<String> list = airDataService.listAirEquipmentMAC(); |
| | | return ResponseUtil.successPage(list); |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.dto.LightDataDto; |
| | | import com.sandu.ximon.admin.service.LightReportDataService; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * è·¯ç¯ç¸å
³æ§å¶ç±» |
| | | * |
| | | * @author chenjiantian |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/v1/light") |
| | | public class LightController { |
| | | |
| | | private final LightReportDataService lightReportDataService; |
| | | |
| | | |
| | | @GetMapping("/list") |
| | | public ResponseVO<Object> listLight(BaseConditionVO conditionVO, @RequestParam(required = false) String keyword) { |
| | | List<LightDataDto> list = lightReportDataService.listLight(conditionVO.getPageNo(),conditionVO.getPageSize(),keyword); |
| | | return ResponseUtil.success(list); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.param.LightTaskDelParam; |
| | | import com.sandu.ximon.admin.param.LightTaskParam; |
| | | import com.sandu.ximon.admin.service.LightTaskService; |
| | | import com.sandu.ximon.dao.domain.LightTask; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * è·¯ç¯ä»»å¡ç¸å
³æ§å¶ç±» |
| | | * |
| | | * @author chenjiantian |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/v1/light/task") |
| | | public class LightTaskController { |
| | | |
| | | private final LightTaskService lightTaskService; |
| | | |
| | | |
| | | @PostMapping("/add") |
| | | public ResponseVO<Object> addLightTask(@RequestBody @Validated LightTaskParam param) { |
| | | boolean result = lightTaskService.addLightTask(param); |
| | | if (result) { |
| | | return ResponseUtil.success("æ°å¢æå"); |
| | | } else { |
| | | return ResponseUtil.fail("æ°å¢å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | public ResponseVO<Object> listLightTask(BaseConditionVO conditionVO, @RequestParam(required = false) String keyword) { |
| | | List<LightTask> taskList = lightTaskService.listLightTask(conditionVO.getPageNo(), conditionVO.getPageSize(), keyword); |
| | | return ResponseUtil.successPage(taskList); |
| | | } |
| | | |
| | | @PostMapping("/del") |
| | | public ResponseVO<Object> delLightTask(@RequestBody @Validated LightTaskDelParam param) { |
| | | boolean result = lightTaskService.delLightTask(param.getTaskIdList()); |
| | | if (result) { |
| | | return ResponseUtil.success("å 餿å"); |
| | | } else { |
| | | return ResponseUtil.fail("å é¤å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/update/{taskId}") |
| | | public ResponseVO<Object> updateLightTask(@PathVariable Long taskId, @RequestBody @Validated LightTaskParam param) { |
| | | boolean result = lightTaskService.updateLightTask(taskId,param); |
| | | if (result) { |
| | | return ResponseUtil.success("ç¼è¾æå"); |
| | | } else { |
| | | return ResponseUtil.fail("ç¼è¾å¤±è´¥"); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/14 14:36 |
| | | */ |
| | | @Data |
| | | public class LightDataDto { |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/15 18:07 |
| | | * å个路ç¯ä»»å¡å½ä»¤çå
容 |
| | | */ |
| | | @Data |
| | | public class SingleLightOrderDto { |
| | | |
| | | private int hour; |
| | | private int minute; |
| | | /** |
| | | * 0-100 |
| | | */ |
| | | private int brightness; |
| | | } |
| | |
| | | package com.sandu.ximon.admin.manager.iot.amqp; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.sandu.ximon.admin.manager.iot.amqp.processor.AirDataProcessor; |
| | | import com.sandu.ximon.admin.manager.iot.amqp.processor.LightDataProcessor; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.*; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | |
| | | log.info(frame.toString()); |
| | | if (frame.getOrderType().equals(A5OrderEnum.RESPONSE_LIGHT_DATA.getCode())) { |
| | | // åç¯æ°æ®ä¸æ¥å¤ç |
| | | LightDataProcessor.getInstance().process(productKey,deviceName,frame); |
| | | LightDataProcessor.getInstance().process(productKey, deviceName, frame); |
| | | } else if (frame.getOrderType().equals(A5OrderEnum.RESPONSE_C3_DATA.getCode())) { |
| | | // C3å
çµæ¡©ä¸æ¥å¤ç |
| | | c3ChargingReportAnalysis(productKey, deviceName, frame); |
| | | } else if (frame.getOrderType().equals(A5OrderEnum.RESPONSE_ATMOSPHERE_DATA.getCode())) { |
| | | // å¤§æ°æ°æ®æä»¤ä¸æ¥ |
| | | atmosphereAnalysis(productKey, deviceName, frame); |
| | | AirDataProcessor.getInstance().process(productKey, deviceName, frame); |
| | | // atmosphereAnalysis(productKey, deviceName, frame); |
| | | } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.amqp.processor; |
| | | |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5AtmosphereReportEnum; |
| | | import com.sandu.ximon.admin.service.AirDataService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * @author ZZQ |
| | | * @date 2021/12/14 |
| | | * å¤§æ°æ°æ®ä¸æ¥å¤ç |
| | | */ |
| | | @Slf4j |
| | | public class AirDataProcessor implements IMessageProcessor { |
| | | |
| | | private AirDataProcessor() { |
| | | } |
| | | |
| | | public static AirDataProcessor getInstance() { |
| | | return AirDataProcessor.AirDataProcessorHolder.INSTANCE; |
| | | } |
| | | |
| | | private static class AirDataProcessorHolder { |
| | | |
| | | private static final AirDataProcessor INSTANCE = new AirDataProcessor(); |
| | | } |
| | | |
| | | @Override |
| | | public void process(String productKey, String deviceName, CommonFrame frame) { |
| | | String functionCode = frame.getPayload().substring(2, 4); |
| | | if (A5AtmosphereReportEnum.HeartBeat_Data.getCode().equals(functionCode)) { |
| | | log.info("å¿è·³ç¸åº"); |
| | | A5AtmosphereHeartbeatReportInnerFrame heartbeatReportInnerFrame = new A5AtmosphereHeartbeatReportInnerFrame().transformFrame(frame.getPayload()); |
| | | log.info(heartbeatReportInnerFrame.toString()); |
| | | |
| | | SpringContextHolder.getBean(AirDataService.class).saveReportData(deviceName, heartbeatReportInnerFrame.getHeartBeatDataPackage()); |
| | | |
| | | // SpringContextHolder.getBean(LightService.class).saveLight(deviceName,heartbeatReportInnerFrame.getHeartBeatDataPackage()); |
| | | |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame.inner.request; |
| | | |
| | | import cn.hutool.core.util.HexUtil; |
| | | import com.sandu.ximon.admin.dto.SingleLightOrderDto; |
| | | 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; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.SupplementUtils; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/6 14:46 |
| | | * A5->01->23 |
| | | * 宿¶æ§ç¯ |
| | | * 0x00ï¼å
³ç¯ |
| | | * å
¶å®ï¼å¼ç¯&亮度å¼" |
| | | */ |
| | | public class A5LightTimerReqInnerFrame implements IRequestInnerFrame { |
| | | |
| | | private final String payload; |
| | | private final String functionCode = A5LightDataEnum.LightTimer.getCode(); |
| | | private final String payloadLength; |
| | | |
| | | /** |
| | | * @param framePayload å¤ä¸ªè·¯ç¯å®æ¶æä»¤ï¼ |
| | | */ |
| | | public A5LightTimerReqInnerFrame(String framePayload) { |
| | | String destinationAddress = "FFFF"; |
| | | payload = destinationAddress + framePayload; |
| | | this.payloadLength = SupplementUtils.suppleZero(Integer.toHexString((payload.length() / 2)).toUpperCase(), 4); |
| | | } |
| | | |
| | | @Override |
| | | public String getEncodeFrame() { |
| | | String frame = functionCode + payloadLength + payload; |
| | | return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(frame.toUpperCase()); |
| | | } |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame.inner.response; |
| | | |
| | | 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 chenjiantian |
| | | * @date 2021/12/6 14:46 |
| | | * A5-81-23ç¯å®æ¶ä»»å¡ åºç |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A5LightTimerRespInnerFrame extends BaseResponseInnerFrame<A5LightTimerRespInnerFrame> { |
| | | |
| | | /** |
| | | * ç®æ å°å 2 |
| | | */ |
| | | private String destinationAddress; |
| | | /** |
| | | * ååºç¶æ 1 |
| | | */ |
| | | private String responseStatus; |
| | | |
| | | @Override |
| | | public A5LightTimerRespInnerFrame transformFrame(String hex) { |
| | | 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)); |
| | | |
| | | setDestinationAddress(hex.substring(8, 12)); |
| | | |
| | | setResponseStatus(hex.substring(12, 14)); |
| | | setCrc32(hex.substring(14, 22)); |
| | | // æ ¡éªCRC32 |
| | | String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + getResponseStatus(); |
| | | this.setValidate(CRC32Utils.validateFrame(frame, getCrc32())); |
| | | return this; |
| | | } |
| | | } |
| | |
| | | // å
ææ§å¶ |
| | | LightSensorControl("04"), |
| | | |
| | | //è®¾ç½®å®æ¶æ§ç¯åæ° |
| | | LightTimer("23"), |
| | | // æ¸
é¤åç¯ç´¯è®¡æ°æ® |
| | | LightReset("25"); |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 |
| | | * è·¯ç¯ä»»å¡ |
| | | */ |
| | | @Data |
| | | public class LightTaskDelParam { |
| | | |
| | | @NotEmpty(message = "ä»»å¡idä¸è½ä¸ºç©º") |
| | | private List<Long> taskIdList; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 |
| | | * è·¯ç¯ä»»å¡ |
| | | */ |
| | | @Data |
| | | public class LightTaskParam { |
| | | |
| | | public static final int REQUEST_ORDER_LENGTH = 7; |
| | | /** |
| | | * ä»»å¡åç§° |
| | | */ |
| | | @NotEmpty(message = "ä»»å¡åç§°ä¸è½ä¸ºç©º") |
| | | private String taskName; |
| | | |
| | | /** |
| | | * ææå ï¼ä½è¿ç®ä¿åï¼1代表ææä¸ï¼2ææäºï¼4ææä¸ï¼8ææåï¼16ææäºï¼32ææå
ï¼64æææ¥ |
| | | */ |
| | | @NotNull(message = "ææä¸è½ä¸ºç©º") |
| | | private Integer week; |
| | | |
| | | |
| | | /** |
| | | * å¼ç¯å½ä»¤ |
| | | */ |
| | | @Length(min = REQUEST_ORDER_LENGTH, max = REQUEST_ORDER_LENGTH, message = "å¼ç¯å½ä»¤é¿åº¦é误") |
| | | private String openOrder; |
| | | |
| | | /** |
| | | * å
³éç¯å½ä»¤ |
| | | */ |
| | | @Length(min = REQUEST_ORDER_LENGTH, max = REQUEST_ORDER_LENGTH, message = "å
³ç¯å½ä»¤é¿åº¦é误") |
| | | private String closeOrder; |
| | | /** |
| | | * ç¯æ§å½ä»¤ |
| | | */ |
| | | private String controlOrder; |
| | | |
| | | private List<Long> poleIdList; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.quartz; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.common.util.ThrowableUtil; |
| | | import com.sandu.ximon.admin.service.*; |
| | | import com.sandu.ximon.dao.domain.LightTaskQuartz; |
| | | import com.sandu.ximon.dao.domain.LightTaskQuartzLog; |
| | | import org.quartz.JobExecutionContext; |
| | | import org.quartz.JobExecutionException; |
| | | import org.springframework.scheduling.quartz.QuartzJobBean; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/15 10:28 |
| | | * è®¾ç½®å®æ¶æ§ç¯ç宿¶ä»»å¡ |
| | | */ |
| | | public class LightTimerJob extends QuartzJobBean { |
| | | |
| | | @Override |
| | | protected void executeInternal(JobExecutionContext context) throws JobExecutionException { |
| | | System.out.println("æ§è¡ä»»å¡" + Thread.currentThread().toString()); |
| | | long quartzId = context.getMergedJobDataMap().getLong("quartzId"); |
| | | String taskName = context.getMergedJobDataMap().getString("taskName"); |
| | | long taskId = context.getMergedJobDataMap().getLong("taskId"); |
| | | String cron = context.getMergedJobDataMap().getString("cron"); |
| | | |
| | | LightTaskQuartzLog log = new LightTaskQuartzLog(); |
| | | log.setCronExpression(cron); |
| | | log.setTaskId(taskId); |
| | | log.setTaskName(taskName); |
| | | log.setQuartzId(quartzId); |
| | | |
| | | PoleService poleService = SpringContextHolder.getBean(PoleService.class); |
| | | LightTaskPoleRelationService lightTaskPoleRelationService = SpringContextHolder.getBean(LightTaskPoleRelationService.class); |
| | | LightTaskQuartzService lightTaskQuartzService = SpringContextHolder.getBean(LightTaskQuartzService.class); |
| | | LightTaskService lightTaskService = SpringContextHolder.getBean(LightTaskService.class); |
| | | LightTaskQuartzLogService lightTaskQuartzLogService = SpringContextHolder.getBean(LightTaskQuartzLogService.class); |
| | | |
| | | long startTime = System.currentTimeMillis(); |
| | | try { |
| | | // ä»»å¡ç»å®çç¯æ |
| | | List<Long> poleIdList = lightTaskPoleRelationService.listPoleIdByTaskId(taskId); |
| | | // ç¯æç设å¤ç |
| | | List<String> deviceCodeList = poleService.listDeviceCodeByIds(poleIdList); |
| | | |
| | | if (CollectionUtil.isNotEmpty(deviceCodeList)) { |
| | | LightTaskQuartz lightTaskQuartz = lightTaskQuartzService.getById(quartzId); |
| | | if (lightTaskQuartz != null) { |
| | | for (String deviceCode : deviceCodeList) { |
| | | // 宿¶ç»æ¯ä¸ªè®¾å¤ååéç¯æ§è¯·æ± |
| | | lightTaskService.sendTimeRRpc(lightTaskQuartz.getFramePayload(), deviceCode); |
| | | } |
| | | log.setFramePayload(lightTaskQuartz.getFramePayload()); |
| | | } |
| | | } |
| | | long times = System.currentTimeMillis() - startTime; |
| | | log.setTime(times); |
| | | } catch (Exception e) { |
| | | log.setExceptionDetail(ThrowableUtil.getStackTrace(e)); |
| | | long times = System.currentTimeMillis() - startTime; |
| | | log.setTime(times); |
| | | } finally { |
| | | lightTaskQuartzLogService.save(log); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.dao.domain.AirData; |
| | | import com.sandu.ximon.dao.domain.Monitor; |
| | | import com.sandu.ximon.dao.mapper.AirDataMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class AirDataService extends BaseServiceImpl<AirDataMapper, AirData> { |
| | | private final AirDataMapper airDataMapper; |
| | | |
| | | /** |
| | | * ä¿å䏿¥å¤§æ°å¿è·³æ°æ® |
| | | * |
| | | * @return æ¯å¦æå |
| | | */ |
| | | public boolean saveReportData(String deviceName, A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage) { |
| | | |
| | | AirData airData = new AirData(); |
| | | BeanUtils.copyProperties(heartBeatDataPackage, airData); |
| | | airData.setDeviceMac(deviceName); |
| | | |
| | | return save(airData); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢å
¨é¨å¤§æ°è®¾å¤ |
| | |
| | | } |
| | | |
| | | /** |
| | | * æ¨¡ç³æ¥è¯¢ |
| | | * æ¥è¯¢å¤§æ°è®¾å¤MACå°å |
| | | */ |
| | | public List<AirData> listAirDataByKeyword(String keyword) { |
| | | |
| | | LambdaQueryWrapper<AirData> wrapper = Wrappers.lambdaQuery(AirData.class); |
| | | if(keyword != null){ |
| | | wrapper.like(AirData::getBelongTo,keyword); |
| | | } |
| | | List<AirData> airDataList = list(wrapper); |
| | | return airDataList; |
| | | public List<String> listAirEquipmentMAC() { |
| | | return airDataMapper.listAirEquipmentMAC(); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.dto.LightDataDto; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.dao.domain.LightReportData; |
| | | import com.sandu.ximon.dao.mapper.LightReportDataMapper; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | |
| | | |
| | | return save(lightReportData); |
| | | } |
| | | |
| | | /** |
| | | * è·åè·¯ç¯å表 |
| | | * @return è¿åç»åæ°æ®dto |
| | | */ |
| | | public List<LightDataDto> listLight(int pageNo, int pageSize, String keyword) { |
| | | PageHelper.startPage(pageNo,pageSize); |
| | | |
| | | return null; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.dao.domain.LightTaskPoleRelation; |
| | | import com.sandu.ximon.dao.mapper.LightTaskPoleRelationMapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/16 14:15 |
| | | */ |
| | | @Service |
| | | public class LightTaskPoleRelationService extends BaseServiceImpl<LightTaskPoleRelationMapper, LightTaskPoleRelation> { |
| | | |
| | | /** |
| | | * æ¹éä¿åä»»å¡åç¯æçå
³ç³» |
| | | * |
| | | * @param taskId ä»»å¡id |
| | | * @param poleIdList ç¯æid |
| | | * @return è¿åæ¯å¦æå |
| | | */ |
| | | public boolean updateLightTaskPoleRelation(Long taskId, List<Long> poleIdList) { |
| | | remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).eq(LightTaskPoleRelation::getTaskId, taskId)); |
| | | if (CollectionUtil.isEmpty(poleIdList)) { |
| | | return true; |
| | | } |
| | | List<LightTaskPoleRelation> batchSave = new ArrayList<>(); |
| | | for (Long poleId : poleIdList) { |
| | | LightTaskPoleRelation lightTaskPoleRelation = new LightTaskPoleRelation(); |
| | | lightTaskPoleRelation.setPoleId(poleId); |
| | | lightTaskPoleRelation.setTaskId(taskId); |
| | | batchSave.add(lightTaskPoleRelation); |
| | | } |
| | | |
| | | return saveBatch(batchSave); |
| | | } |
| | | |
| | | public List<Long> listPoleIdByTaskId(Long taskId) { |
| | | if (taskId == null) { |
| | | return null; |
| | | } |
| | | return list(Wrappers.lambdaQuery(LightTaskPoleRelation.class).eq(LightTaskPoleRelation::getTaskId, taskId).select(LightTaskPoleRelation::getPoleId)) |
| | | .stream().map(LightTaskPoleRelation::getPoleId).collect(Collectors.toList()); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.dao.domain.LightTaskQuartzLog; |
| | | import com.sandu.ximon.dao.mapper.LightTaskQuartzLogMapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/16 15:12 |
| | | */ |
| | | @Service |
| | | public class LightTaskQuartzLogService extends BaseServiceImpl<LightTaskQuartzLogMapper,LightTaskQuartzLog> { |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | 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.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.quartz.ExecutionJob; |
| | | import com.sandu.common.quartz.service.QuartzService; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.constant.Constants; |
| | | import com.sandu.ximon.admin.dto.SingleLightOrderDto; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.SupplementUtils; |
| | | import com.sandu.ximon.admin.param.LightTaskParam; |
| | | import com.sandu.ximon.admin.quartz.LightTimerJob; |
| | | import com.sandu.ximon.admin.utils.TaskOrderUtil; |
| | | import com.sandu.ximon.dao.domain.LightTask; |
| | | import com.sandu.ximon.dao.domain.LightTaskQuartz; |
| | | import com.sandu.ximon.dao.mapper.LightTaskQuartzMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/15 17:46 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class LightTaskQuartzService extends BaseServiceImpl<LightTaskQuartzMapper, LightTaskQuartz> { |
| | | |
| | | @Resource |
| | | private QuartzService quartzService; |
| | | |
| | | /** |
| | | * æ·»å 宿¶å¨ä»»å¡ |
| | | * |
| | | * @param lightTask è·¯ç¯ä»»å¡å®ä½ç±»ï¼ä¸ä¸ªè·¯ç¯ä»»å¡æå¤ä¸ªå®æ¶å¨ä»»å¡ |
| | | */ |
| | | public List<LightTaskQuartz> addLightTaskQuartz(LightTask lightTask) { |
| | | List<LightTaskQuartz> list = buildLightTaskQuartzList(lightTask); |
| | | |
| | | boolean saveBatch = saveBatch(list); |
| | | if (!saveBatch) { |
| | | throw new BusinessException("ä¿å宿¶ä»»å¡å¤±è´¥"); |
| | | } |
| | | |
| | | runLightTaskQuartz(list); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®è·¯ç¯ä»»å¡ä¿¡æ¯çæè·¯ç¯å®æ¶å¨å表 |
| | | * @param lightTask è·¯ç¯ä»»å¡ä¿¡æ¯ |
| | | * @return è·¯ç¯å®æ¶å¨å表 |
| | | */ |
| | | private List<LightTaskQuartz> buildLightTaskQuartzList(LightTask lightTask) { |
| | | List<LightTaskQuartz> list = new ArrayList<>(); |
| | | |
| | | // æ·»å å¼ç¯å®æ¶å¨ |
| | | SingleLightOrderDto openLightOrder = TaskOrderUtil.parseLightOrder(lightTask.getOpenOrder()); |
| | | SingleLightOrderDto closeLightOrder = TaskOrderUtil.parseLightOrder(lightTask.getCloseOrder()); |
| | | String[] controlOrderArray = StrUtil.split(lightTask.getControlOrder(), LightTaskParam.REQUEST_ORDER_LENGTH); |
| | | Integer[] weekArrays = TaskOrderUtil.parseLightWeek(lightTask.getWeek()); |
| | | if (openLightOrder == null || closeLightOrder == null) { |
| | | throw new BusinessException("è§£æåç¯å½ä»¤å¤±è´¥"); |
| | | } |
| | | if (ArrayUtil.isEmpty(weekArrays)) { |
| | | throw new BusinessException("请设置ææ"); |
| | | } |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | String weekHex = SupplementUtils.suppleZero(HexUtil.toHex(lightTask.getWeek()), 2); |
| | | |
| | | // æ¼æ¥å¼ç¯å½ä»¤ |
| | | sb.append(weekHex); |
| | | sb.append(SupplementUtils.suppleZero(HexUtil.toHex(openLightOrder.getHour()), 2)); |
| | | sb.append(SupplementUtils.suppleZero(HexUtil.toHex(openLightOrder.getMinute()), 2)); |
| | | sb.append(SupplementUtils.suppleZero(HexUtil.toHex(openLightOrder.getBrightness()), 2)); |
| | | |
| | | // æ¼æ¥å
³ç¯å½ä»¤ |
| | | sb.append(weekHex); |
| | | sb.append(SupplementUtils.suppleZero(HexUtil.toHex(closeLightOrder.getHour()), 2)); |
| | | sb.append(SupplementUtils.suppleZero(HexUtil.toHex(closeLightOrder.getMinute()), 2)); |
| | | sb.append(SupplementUtils.suppleZero(HexUtil.toHex(closeLightOrder.getBrightness()), 2)); |
| | | |
| | | // æ°å¢å¼ç¯å®æ¶å¨ |
| | | LightTaskQuartz openLightTaskQuartz = new LightTaskQuartz(); |
| | | openLightTaskQuartz.setTaskId(lightTask.getTaskId()); |
| | | openLightTaskQuartz.setCronExpression(TaskOrderUtil.getHourAndMinuteOnGivenDaysOfWeek(openLightOrder.getHour(), openLightOrder.getMinute(), weekArrays)); |
| | | openLightTaskQuartz.setQuartzName(lightTask.getTaskName()); |
| | | list.add(openLightTaskQuartz); |
| | | |
| | | // æ°å¢å
³ç¯ç¯å®æ¶å¨ |
| | | LightTaskQuartz closeLightTaskQuartz = new LightTaskQuartz(); |
| | | closeLightTaskQuartz.setTaskId(lightTask.getTaskId()); |
| | | closeLightTaskQuartz.setCronExpression(TaskOrderUtil.getHourAndMinuteOnGivenDaysOfWeek(closeLightOrder.getHour(), closeLightOrder.getMinute(), weekArrays)); |
| | | closeLightTaskQuartz.setQuartzName(lightTask.getTaskName()); |
| | | list.add(closeLightTaskQuartz); |
| | | |
| | | // æ¼æ¥äº®åº¦æ§ç¯å½ä»¤ |
| | | for (String controlOrderStr : controlOrderArray) { |
| | | SingleLightOrderDto controlLightOrder = TaskOrderUtil.parseLightOrder(controlOrderStr); |
| | | if (controlLightOrder != null) { |
| | | sb.append(weekHex); |
| | | sb.append(SupplementUtils.suppleZero(HexUtil.toHex(controlLightOrder.getHour()), 2)); |
| | | sb.append(SupplementUtils.suppleZero(HexUtil.toHex(controlLightOrder.getMinute()), 2)); |
| | | sb.append(SupplementUtils.suppleZero(HexUtil.toHex(controlLightOrder.getBrightness()), 2)); |
| | | |
| | | LightTaskQuartz controlLightTaskQuartz = new LightTaskQuartz(); |
| | | controlLightTaskQuartz.setTaskId(lightTask.getTaskId()); |
| | | controlLightTaskQuartz.setCronExpression(TaskOrderUtil.getHourAndMinuteOnGivenDaysOfWeek(controlLightOrder.getHour(), controlLightOrder.getMinute(), weekArrays)); |
| | | controlLightTaskQuartz.setQuartzName(lightTask.getTaskName()); |
| | | list.add(controlLightTaskQuartz); |
| | | } |
| | | } |
| | | |
| | | String lightOrder = sb.toString(); |
| | | |
| | | for (LightTaskQuartz lightTaskQuartz : list) { |
| | | lightTaskQuartz.setFramePayload(lightOrder); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * æ§è¡å®æ¶å¨ä»»å¡ |
| | | * @param list 宿¶å¨å表 |
| | | */ |
| | | public void runLightTaskQuartz(List<LightTaskQuartz> list){ |
| | | for (LightTaskQuartz taskQuartz : list) { |
| | | Map<String, Object> build = MapUtil.<String, Object>builder() |
| | | .put("taskId", taskQuartz.getTaskId()) |
| | | .put("taskName", taskQuartz.getQuartzName()) |
| | | .put("quartzId", taskQuartz.getId()) |
| | | .put("cron", taskQuartz.getCronExpression()).build(); |
| | | quartzService.addJob(LightTimerJob.class, taskQuartz.getId(), taskQuartz.getCronExpression(), build); |
| | | } |
| | | } |
| | | |
| | | public List<LightTaskQuartz> updateLightTaskQuartz(LightTask lightTask) { |
| | | |
| | | Long taskId = lightTask.getTaskId(); |
| | | // å 餿§ä»»å¡ |
| | | removeLightTaskQuartz(CollectionUtil.toList(taskId)); |
| | | |
| | | List<LightTaskQuartz> list = addLightTaskQuartz(lightTask); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | public boolean removeLightTaskQuartz(List<Long> taskIdList) { |
| | | List<Long> delTaskQuartzIdList = list(Wrappers.lambdaQuery(LightTaskQuartz.class).in(LightTaskQuartz::getTaskId, taskIdList).select(LightTaskQuartz::getId)) |
| | | .stream().map(LightTaskQuartz::getId).collect(Collectors.toList()); |
| | | for (Long delTaskQuartzId : delTaskQuartzIdList) { |
| | | quartzService.deleteJob(LightTimerJob.class,delTaskQuartzId); |
| | | } |
| | | |
| | | return removeByIds(delTaskQuartzIdList); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | 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.request.A5LightTimerReqInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.response.A5LightTimerRespInnerFrame; |
| | | 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.LightTaskParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.dao.domain.LightTask; |
| | | import com.sandu.ximon.dao.domain.LightTaskPoleRelation; |
| | | import com.sandu.ximon.dao.domain.LightTaskQuartz; |
| | | import com.sandu.ximon.dao.mapper.LightTaskMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/15 16:33 |
| | | * è·¯ç¯ä»»å¡æä½ |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class LightTaskService extends BaseServiceImpl<LightTaskMapper, LightTask> { |
| | | |
| | | |
| | | private final LightTaskQuartzService lightTaskQuartzService; |
| | | private final PoleService poleService; |
| | | private final LightTaskPoleRelationService lightTaskPoleRelationService; |
| | | |
| | | /** |
| | | * æ°å¢è·¯ç¯ä»»å¡ |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean addLightTask(LightTaskParam param) { |
| | | if (StrUtil.length(param.getControlOrder()) % LightTaskParam.REQUEST_ORDER_LENGTH != 0) { |
| | | throw new BusinessException("ç¯æ§å½ä»¤æ ¼å¼ä¸æ£ç¡®"); |
| | | } |
| | | LightTask lightTask = new LightTask(); |
| | | lightTask.setClientId(SecurityUtils.getClientId()); |
| | | lightTask.setTaskName(param.getTaskName()); |
| | | lightTask.setWeek(param.getWeek()); |
| | | lightTask.setCloseOrder(param.getCloseOrder()); |
| | | lightTask.setOpenOrder(param.getOpenOrder()); |
| | | lightTask.setControlOrder(param.getControlOrder()); |
| | | lightTask.setCreateUser(SecurityUtils.getUsername()); |
| | | if (!save(lightTask)) { |
| | | throw new BusinessException("ä¿åè·¯ç¯ä»»å¡å¤±è´¥"); |
| | | } |
| | | List<LightTaskQuartz> list = lightTaskQuartzService.addLightTaskQuartz(lightTask); |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | throw new BusinessException("æ·»å 宿¶ä»»å¡å¤±è´¥"); |
| | | } |
| | | // æ·»å ç»å®ç¯æ |
| | | if (!lightTaskPoleRelationService.updateLightTaskPoleRelation(lightTask.getTaskId(), param.getPoleIdList())) { |
| | | throw new BusinessException("ç»å®ç¯æå¤±è´¥"); |
| | | } |
| | | |
| | | List<Long> poleIdList = param.getPoleIdList(); |
| | | if (CollectionUtil.isNotEmpty(poleIdList)) { |
| | | List<String> deviceCodeList = poleService.listDeviceCodeByIds(poleIdList); |
| | | if (CollectionUtil.isEmpty(deviceCodeList)) { |
| | | throw new BusinessException("æ¾ä¸å°ç¯æmacï¼æ æ³åé宿¶ä»»å¡"); |
| | | } |
| | | // è·å宿¶ç¯æ§å½ä»¤ |
| | | String framePayload = list.get(0).getFramePayload(); |
| | | |
| | | // rrpc åç宿¶å½ä»¤ |
| | | for (String deviceCode : deviceCodeList) { |
| | | sendTimeRRpc(framePayload, deviceCode); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * åéç¯æ§è¯·æ± |
| | | * |
| | | * @param framePayload ç¯æ§åæ° |
| | | * @param deviceCode 设å¤å |
| | | * @return è¿å帧 |
| | | */ |
| | | public A5LightTimerRespInnerFrame sendTimeRRpc(String framePayload, String deviceCode) { |
| | | IRequestFrame requestFrame = FrameBuilder.builderA5().innerFrame(new A5LightTimerReqInnerFrame(framePayload)) |
| | | .orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode()).build(); |
| | | WrapResponseCommonFrame<A5LightTimerRespInnerFrame> responseCommonFrame = MainBoardInvokeSyncService.getInstance() |
| | | .sendRRPC(deviceCode, requestFrame, A5LightTimerRespInnerFrame.class); |
| | | System.out.println("åéç»æ"); |
| | | A5LightTimerRespInnerFrame responseInnerFrame = responseCommonFrame.getResponseInnerFrame(); |
| | | System.out.println(responseInnerFrame.getResponseStatus()); |
| | | return responseInnerFrame; |
| | | } |
| | | |
| | | public List<LightTask> listLightTask(int pageNo, int pageSize, String keyword) { |
| | | LambdaQueryWrapper<LightTask> wrapper = Wrappers.lambdaQuery(LightTask.class); |
| | | if (StrUtil.isNotBlank(keyword)) { |
| | | wrapper.like(LightTask::getTaskName, keyword); |
| | | } |
| | | Long clientId = SecurityUtils.getClientId(); |
| | | if (clientId != null) { |
| | | wrapper.eq(LightTask::getClientId, clientId); |
| | | } |
| | | |
| | | PageHelper.startPage(pageNo, pageSize); |
| | | return list(wrapper); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateLightTask(Long taskId, LightTaskParam param) { |
| | | if (StrUtil.length(param.getControlOrder()) % LightTaskParam.REQUEST_ORDER_LENGTH != 0) { |
| | | throw new BusinessException("ç¯æ§å½ä»¤æ ¼å¼ä¸æ£ç¡®"); |
| | | } |
| | | LightTask lightTask = getById(taskId); |
| | | if (lightTask == null) { |
| | | throw new BusinessException("æ¾ä¸å°è·¯ç¯ä»»å¡"); |
| | | } |
| | | |
| | | lightTask.setTaskName(param.getTaskName()); |
| | | lightTask.setWeek(param.getWeek()); |
| | | lightTask.setControlOrder(param.getControlOrder()); |
| | | lightTask.setOpenOrder(param.getOpenOrder()); |
| | | lightTask.setCloseOrder(param.getCloseOrder()); |
| | | lightTask.setUpdateTime(LocalDateTime.now()); |
| | | |
| | | if (!updateById(lightTask)) { |
| | | throw new BusinessException("ç¼è¾ä»»å¡å¤±è´¥"); |
| | | } |
| | | |
| | | List<LightTaskQuartz> list = lightTaskQuartzService.updateLightTaskQuartz(lightTask); |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | throw new BusinessException("ç¼è¾å®æ¶ä»»å¡å¤±è´¥"); |
| | | } |
| | | |
| | | // æ·»å ç»å®ç¯æ |
| | | if (!lightTaskPoleRelationService.updateLightTaskPoleRelation(lightTask.getTaskId(), param.getPoleIdList())) { |
| | | throw new BusinessException("ç»å®ç¯æå¤±è´¥"); |
| | | } |
| | | List<Long> poleIdList = param.getPoleIdList(); |
| | | if (CollectionUtil.isNotEmpty(poleIdList)) { |
| | | List<String> deviceCodeList = poleService.listDeviceCodeByIds(poleIdList); |
| | | if (CollectionUtil.isEmpty(deviceCodeList)) { |
| | | throw new BusinessException("æ¾ä¸å°ç¯æmacï¼æ æ³åé宿¶ä»»å¡"); |
| | | } |
| | | // è·å宿¶ç¯æ§å½ä»¤ |
| | | String framePayload = list.get(0).getFramePayload(); |
| | | |
| | | // rrpc åç宿¶å½ä»¤ |
| | | for (String deviceCode : deviceCodeList) { |
| | | sendTimeRRpc(framePayload, deviceCode); |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean delLightTask(List<Long> taskIdList) { |
| | | List<LightTask> lightTaskList = listByIds(taskIdList); |
| | | if (CollectionUtil.isEmpty(lightTaskList)) { |
| | | throw new BusinessException("æ¾ä¸å°ä»»å¡ä¿¡æ¯"); |
| | | } |
| | | |
| | | // å é¤ä»»å¡ |
| | | if (!removeByIds(taskIdList)) { |
| | | throw new BusinessException("å é¤ä»»å¡å¤±è´¥"); |
| | | } |
| | | |
| | | // å é¤ç»å®ç¯æ |
| | | if (!lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getTaskId, taskIdList))) { |
| | | throw new BusinessException("å é¤ç»å®ç¯æå¤±è´¥"); |
| | | } |
| | | |
| | | // å é¤å®æ¶å¨ |
| | | if (!lightTaskQuartzService.removeLightTaskQuartz(taskIdList)) { |
| | | throw new BusinessException("å é¤å®æ¶å¨å¤±è´¥"); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | } |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.aliyuncs.iot.model.v20180120.BatchGetDeviceStateResponse; |
| | | import com.aliyuncs.iot.model.v20180120.QueryDeviceDetailResponse; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * ç¯æç¸å
³ |
| | |
| | | /** |
| | | * çæç¯æç¼å· |
| | | */ |
| | | private Long generatePoleCode() { |
| | | public Long generatePoleCode() { |
| | | StringBuilder sb = new StringBuilder(); |
| | | String date = new SimpleDateFormat("yyMMdd").format(new Date()); |
| | | sb.append(date); |
| | |
| | | } |
| | | return setMac; |
| | | } |
| | | |
| | | public List<String> listDeviceCodeByIds(List<Long> poleIdList) { |
| | | if(CollectionUtil.isEmpty(poleIdList)){ |
| | | return null; |
| | | } |
| | | return list(Wrappers.lambdaQuery(Pole.class).in(Pole::getId, poleIdList).select(Pole::getDeviceCode)) |
| | | .stream().map(Pole::getDeviceCode).filter(StrUtil::isNotEmpty).collect(Collectors.toList()); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.utils; |
| | | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.NumberUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.sandu.ximon.admin.constant.Constants; |
| | | import com.sandu.ximon.admin.dto.SingleLightOrderDto; |
| | | import com.sandu.ximon.dao.enums.WeekEnums; |
| | | import org.quartz.DateBuilder; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/15 18:06 |
| | | * ä»»å¡å½ä»¤å·¥å
·ç±» |
| | | */ |
| | | public class TaskOrderUtil { |
| | | |
| | | public static SingleLightOrderDto parseLightOrder(String lightOrder) { |
| | | if (StrUtil.length(lightOrder) != 7) { |
| | | return null; |
| | | } |
| | | SingleLightOrderDto singleLightOrderDto = new SingleLightOrderDto(); |
| | | singleLightOrderDto.setHour(NumberUtil.parseInt(lightOrder.substring(0, 2))); |
| | | singleLightOrderDto.setMinute(NumberUtil.parseInt(lightOrder.substring(2, 4))); |
| | | singleLightOrderDto.setBrightness(NumberUtil.parseInt(lightOrder.substring(4, 7))); |
| | | return singleLightOrderDto; |
| | | } |
| | | |
| | | public static Integer[] parseLightWeek(Integer week) { |
| | | if (week == null) { |
| | | return null; |
| | | } |
| | | List<Integer> list = new ArrayList<>(); |
| | | if((WeekEnums.SUNDAY.getCode() & week) > 0){ |
| | | list.add(DateBuilder.SUNDAY); |
| | | } |
| | | if((WeekEnums.MONDAY.getCode() & week) > 0){ |
| | | list.add(DateBuilder.MONDAY); |
| | | } |
| | | if((WeekEnums.TUESDAY.getCode() & week) > 0){ |
| | | list.add(DateBuilder.TUESDAY); |
| | | } |
| | | if((WeekEnums.WEDNESDAY.getCode() & week) > 0){ |
| | | list.add(DateBuilder.WEDNESDAY); |
| | | } |
| | | if((WeekEnums.THURSDAY.getCode() & week) > 0){ |
| | | list.add(DateBuilder.THURSDAY); |
| | | } |
| | | if((WeekEnums.FRIDAY.getCode() & week) > 0){ |
| | | list.add(DateBuilder.FRIDAY); |
| | | } |
| | | if((WeekEnums.SATURDAY.getCode() & week) > 0){ |
| | | list.add(DateBuilder.SATURDAY); |
| | | } |
| | | return list.toArray(new Integer[0]); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç»å®çæ¶åå¨çæcron |
| | | * @param hour æ¶ |
| | | * @param minute å |
| | | * @param daysOfWeek 1è¡¨ç¤ºçæ¯æææ¥ï¼7è¡¨ç¤ºçææå
|
| | | * @return cron |
| | | */ |
| | | public static String getHourAndMinuteOnGivenDaysOfWeek(int hour, int minute, Integer... daysOfWeek) { |
| | | StringBuilder cronExpression = new StringBuilder(String.format("0 %d %d ? * %d", minute, hour, |
| | | daysOfWeek[0])); |
| | | |
| | | for (int i = 1; i < daysOfWeek.length; i++) { |
| | | cronExpression.append(",").append(daysOfWeek[i]); |
| | | } |
| | | return cronExpression.toString(); |
| | | } |
| | | } |
| | |
| | | storage: local |
| | | common: |
| | | urlPrefix: http://localhost:8080/file/ |
| | | quartz: |
| | | enable: true |
| | | |
| | | |
| | |
| | | package com.sandu.ximon.admin; |
| | | |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.sandu.ximon.admin.service.PoleService; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.quartz.*; |
| | | import org.quartz.impl.StdSchedulerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | |
| | | @SpringBootTest |
| | | class AdminApplicationTests { |
| | | |
| | | @Autowired |
| | | private PasswordEncoder passwordEncoder; |
| | | @Test |
| | | void contextLoads() { |
| | | System.out.println(passwordEncoder.encode("666666")); |
| | | } |
| | | @Autowired |
| | | private PasswordEncoder passwordEncoder; |
| | | @Autowired |
| | | private PoleService poleService; |
| | | |
| | | @Test |
| | | void contextLoads() { |
| | | //ae8b5aa26a3ae31612eec1d1f6ffbce9 |
| | | String encode = SecureUtil.md5("66666"); |
| | | String encode2 = passwordEncoder.encode(encode); |
| | | System.out.println(encode); |
| | | System.out.println(encode2); |
| | | } |
| | | |
| | | @Test |
| | | void poleService() { |
| | | System.out.println(poleService.generatePoleCode()); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin; |
| | | |
| | | import cn.hutool.core.collection.ListUtil; |
| | | import com.sandu.common.quartz.service.QuartzServiceImpl; |
| | | import com.sandu.ximon.admin.param.LightTaskParam; |
| | | import com.sandu.ximon.admin.service.LightTaskService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @SpringBootTest |
| | | @Slf4j |
| | | class QuartzTests { |
| | | |
| | | @Resource |
| | | private QuartzServiceImpl quartzService; |
| | | @Resource |
| | | private LightTaskService lightTaskService; |
| | | |
| | | @Test |
| | | void addLightTask() { |
| | | LightTaskParam lightTaskParam = new LightTaskParam(); |
| | | lightTaskParam.setTaskName("æ¥å¸¸ä»»å¡"); |
| | | lightTaskParam.setPoleIdList(ListUtil.toList(1L)); |
| | | lightTaskParam.setWeek(126); |
| | | lightTaskParam.setOpenOrder("1630100"); |
| | | lightTaskParam.setCloseOrder("0600000"); |
| | | lightTaskParam.setControlOrder("00000500300020"); |
| | | System.out.println(lightTaskService.addLightTask(lightTaskParam)); |
| | | } |
| | | |
| | | |
| | | } |