已修改15个文件
已添加66个文件
已删除1个文件
| | |
| | | <version>3.4.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>io.swagger</groupId> |
| | | <artifactId>swagger-annotations</artifactId> |
| | | <version>1.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.bo; |
| | | |
| | | import com.sandu.ximon.dao.domain.Plc; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author van |
| | | * @version 1.0 |
| | | * msgï¼ |
| | | * @date 2022/12/15 17:15 |
| | | */ |
| | | @Data |
| | | public class PlcBo extends Plc { |
| | | private Long poleId; |
| | | private String poleCode; |
| | | private String poleName; |
| | | private String taskName; |
| | | private LocalDateTime reportTime; |
| | | |
| | | private List<PlcTaskNameIdBo> taskNameIdBos; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.bo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.sandu.ximon.dao.domain.LightReportData; |
| | | import com.sandu.ximon.dao.domain.PlcReportData; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author van |
| | | */ |
| | | @Data |
| | | public class PlcReportDataBo extends PlcReportData { |
| | | |
| | | @ExcelProperty("ç¯æåç§°") |
| | | private String poleName; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.bo; |
| | | |
| | | import com.sandu.ximon.dao.domain.LightReportError; |
| | | import com.sandu.ximon.dao.domain.PlcReportError; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author van |
| | | */ |
| | | @Data |
| | | public class PlcReportErrorBo extends PlcReportError { |
| | | |
| | | private String poleName; |
| | | private String errorMsg; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.bo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author van |
| | | * @version 1.0 |
| | | * msgï¼ |
| | | * @date 2022/12/15 17:44 |
| | | */ |
| | | @Data |
| | | public class PlcTaskNameIdBo { |
| | | private Long taskId; |
| | | |
| | | private String taskName; |
| | | |
| | | private String plcAddress; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * plcè·¯ç¯è¡¨(Plc)表å®ä½ç±» |
| | | * |
| | | * @author van |
| | | * @since 2022-12-15 14:41:22 |
| | | */ |
| | | @TableName(value = "plc") |
| | | @Data |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | public class Plc implements Serializable{ |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | private Long plcId; |
| | | //设å¤è¯å«ç |
| | | private String deviceCode; |
| | | //夿³¨ä¿¡æ¯ |
| | | private String plcRemark; |
| | | //è·¯æ°ï¼é»è®¤3 |
| | | private Integer plcCount; |
| | | //ç¯å¤´1å¼å
³ç¶æï¼1 å¼ 0 å
³ |
| | | private Integer plcLight1; |
| | | //ç¯å¤´2å¼å
³ç¶æï¼1 å¼ 0 å
³ |
| | | private Integer plcLight2; |
| | | //ç¯å¤´3å¼å
³ç¶æï¼1 å¼ 0 å
³ |
| | | private Integer plcLight3; |
| | | //宿¶ä»»å¡å¼å
³ç¶æï¼1 å¼ 0 å
³ |
| | | private Integer plcTimingControl; |
| | | //å
æå¼å
³ç¶æï¼1 å¼ 0 å
³ |
| | | private Integer plcSensorControl; |
| | | //è½¯ä»¶çæ¬ |
| | | private String plcSoftwareVersion; |
| | | //ç¡¬ä»¶çæ¬ |
| | | private String plcHardwareVersion; |
| | | //IEMI |
| | | private String plcIemi; |
| | | //ICCID |
| | | private String plcIccid; |
| | | //å建æ¶é´ |
| | | private LocalDateTime plcCreateTime; |
| | | |
| | | private LocalDateTime plcUpdateTime; |
| | | |
| | | /** |
| | | * å¨çº¿ç¶æ 0ï¼ç¦»çº¿ 1ï¼å¨çº¿ |
| | | */ |
| | | @TableField(exist = false) |
| | | private Integer onlineStatus; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.domain; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.io.Serializable; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import lombok.Data; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.experimental.Accessors; |
| | | import lombok.EqualsAndHashCode; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | /** |
| | | * PLC䏿¥æ°æ®è¡¨(PlcReportData)表å®ä½ç±» |
| | | * |
| | | * @author van |
| | | * @since 2022-12-16 10:52:52 |
| | | */ |
| | | @ApiModel("PlcReportData") |
| | | @Data |
| | | @TableName("plc_report_data") |
| | | public class PlcReportData implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | //plcReportDataId |
| | | @ApiModelProperty("reportDataId") |
| | | @TableId(value = "report_data_id", type = IdType.AUTO) |
| | | private Long reportDataId; |
| | | //设å¤mac |
| | | @ApiModelProperty("设å¤mac") |
| | | @TableField(value = "device_code") |
| | | private String deviceCode; |
| | | //è®¾å¤æ¸©åº¦ |
| | | @ApiModelProperty("è®¾å¤æ¸©åº¦") |
| | | @TableField(value = "device_temperature") |
| | | private Double deviceTemperature; |
| | | //çµç½ç¸æ°(åãä¸ç¸) |
| | | @ApiModelProperty("çµç½ç¸æ°(åãä¸ç¸)") |
| | | private Long phase; |
| | | //Aç¸çµå |
| | | @ApiModelProperty("Aç¸çµå") |
| | | @TableField(value = "voltage_A") |
| | | private Double voltageA; |
| | | //Bç¸çµå |
| | | @ApiModelProperty("Bç¸çµå") |
| | | @TableField(value = "voltage_B") |
| | | private Double voltageB; |
| | | //Bç¸çµå |
| | | @ApiModelProperty("Cç¸çµå") |
| | | @TableField(value = "voltage_C") |
| | | private Double voltageC; |
| | | //Aç¸çµæµ |
| | | @ApiModelProperty("Aç¸çµæµ") |
| | | @TableField(value = "electric_current_A") |
| | | private Double electricCurrentA; |
| | | //Bç¸çµæµ |
| | | @ApiModelProperty("Bç¸çµæµ") |
| | | @TableField(value = "electric_current_B") |
| | | private Double electricCurrentB; |
| | | //Cç¸çµæµ |
| | | @ApiModelProperty("Cç¸çµæµ") |
| | | @TableField(value = "electric_current_C") |
| | | private Double electricCurrentC; |
| | | //åç¸æååç |
| | | @ApiModelProperty("åç¸æååç") |
| | | @TableField(value = "active_power_All") |
| | | private Double activePowerAll; |
| | | //Aç¸æååç |
| | | @ApiModelProperty("Aç¸æååç") |
| | | @TableField(value = "active_power_A") |
| | | private Double activePowerA; |
| | | //Bç¸æååç |
| | | @ApiModelProperty("Bç¸æååç") |
| | | @TableField(value = "active_power_B") |
| | | private Double activePowerB; |
| | | //Cç¸æååç |
| | | @ApiModelProperty("Cç¸æååç") |
| | | @TableField(value = "active_power_C") |
| | | private Double activePowerC; |
| | | //åç¸æ ååç |
| | | @ApiModelProperty("åç¸æ ååç") |
| | | @TableField(value = "reactive_power_All") |
| | | private Double reactivePowerAll; |
| | | //Aç¸æ ååç |
| | | @ApiModelProperty("Aç¸æ ååç") |
| | | @TableField(value = "reactive_power_A") |
| | | private Double reactivePowerA; |
| | | //Bç¸æ ååç |
| | | @ApiModelProperty("Bç¸æ ååç") |
| | | @TableField(value = "reactive_power_B") |
| | | private Double reactivePowerB; |
| | | //Cç¸æ ååç |
| | | @ApiModelProperty("Cç¸æ ååç") |
| | | @TableField(value = "reactive_power_C") |
| | | private Double reactivePowerC; |
| | | //åç¸è§å¨åç |
| | | @ApiModelProperty("åç¸è§å¨åç") |
| | | @TableField(value = "apparent_power_All") |
| | | private Double apparentPowerAll; |
| | | //Aç¸è§å¨åç |
| | | @ApiModelProperty("Aç¸è§å¨åç") |
| | | @TableField(value = "apparent_power_A") |
| | | private Double apparentPowerA; |
| | | //Bç¸è§å¨åç |
| | | @ApiModelProperty("Bç¸è§å¨åç") |
| | | @TableField(value = "apparent_power_B") |
| | | private Double apparentPowerB; |
| | | //Cç¸è§å¨åç |
| | | @ApiModelProperty("Cç¸è§å¨åç") |
| | | @TableField(value = "apparent_power_C") |
| | | private Double apparentPowerC; |
| | | //åç¸åçå ç´ |
| | | @ApiModelProperty("åç¸åçå ç´ ") |
| | | @TableField(value = "power_factor_All") |
| | | private Double powerFactorAll; |
| | | //Aç¸åçå ç´ |
| | | @ApiModelProperty("Aç¸åçå ç´ ") |
| | | @TableField(value = "power_factor_A") |
| | | private Double powerFactorA; |
| | | //Bç¸åçå ç´ |
| | | @ApiModelProperty("Bç¸åçå ç´ ") |
| | | @TableField(value = "power_factor_B") |
| | | private Double powerFactorB; |
| | | //Cç¸åçå ç´ |
| | | @ApiModelProperty("Cç¸åçå ç´ ") |
| | | @TableField(value = "power_factor_C") |
| | | private Double powerFactorC; |
| | | //æ£åæåæ»çµé |
| | | @ApiModelProperty("æ£åæåæ»çµé") |
| | | @TableField(value = "total_positive_using_power") |
| | | private Double totalPositiveUsingPower; |
| | | //ååæåæ»çµé |
| | | @ApiModelProperty("ååæåæ»çµé") |
| | | @TableField(value = "total_reverse_using_power") |
| | | private Double totalReverseUsingPower; |
| | | //å
å¼ºå¼ |
| | | @ApiModelProperty("å
强å¼") |
| | | @TableField(value = "light_intensity") |
| | | private Long lightIntensity; |
| | | //0æ¶æ§/1å
æ§ |
| | | @ApiModelProperty("0æ¶æ§/1å
æ§") |
| | | @TableField(value = "control_1") |
| | | private Long control1; |
| | | //0å
³/64å¼ |
| | | @ApiModelProperty("0å
³/64å¼") |
| | | @TableField(value = "status_1") |
| | | private Long status1; |
| | | //0æ¶æ§/1å
æ§ |
| | | @ApiModelProperty("0æ¶æ§/1å
æ§") |
| | | @TableField(value = "control_2") |
| | | private Long control2; |
| | | //0å
³/64å¼ |
| | | @ApiModelProperty("0å
³/64å¼") |
| | | @TableField(value = "status_2") |
| | | private Long status2; |
| | | //0æ¶æ§/1å
æ§ |
| | | @ApiModelProperty("0æ¶æ§/1å
æ§") |
| | | @TableField(value = "control_3") |
| | | private Long control3; |
| | | //0å
³/64å¼ |
| | | @ApiModelProperty("0å
³/64å¼") |
| | | @TableField(value = "status_3") |
| | | private Long status3; |
| | | //0æ¶æ§/1å
æ§ |
| | | @ApiModelProperty("0æ¶æ§/1å
æ§") |
| | | @TableField(value = "control_n") |
| | | private Long controlN; |
| | | //0å
³/64å¼ |
| | | @ApiModelProperty("0å
³/64å¼") |
| | | @TableField(value = "status_n") |
| | | private Long statusN; |
| | | //å建æ¶é´ |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @TableField(value = "create_time1") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @JsonIgnore |
| | | private LocalDateTime createTime1; |
| | | //updateTime1 |
| | | @ApiModelProperty("updateTime1") |
| | | @TableField(value = "update_time1") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @JsonIgnore |
| | | private LocalDateTime updateTime1; |
| | | |
| | | /** |
| | | * ç¨äºå段å±ç¤º |
| | | */ |
| | | @TableField(exist = false) |
| | | private String updateTime; |
| | | |
| | | /** |
| | | * ç¨äºå段å±ç¤º |
| | | */ |
| | | @TableField(exist = false) |
| | | private String createTime; |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.domain; |
| | | import java.util.Date; |
| | | |
| | | 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 com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * plcåç¯æ
éæ°æ®å表(PlcReportError)表å®ä½ç±» |
| | | * |
| | | * @author van |
| | | * @since 2022-12-17 14:38:59 |
| | | */ |
| | | @TableName(value ="plc_report_error") |
| | | @Data |
| | | public class PlcReportError implements Serializable { |
| | | @TableId(type = IdType.AUTO) |
| | | private Long plcReportErrorId; |
| | | |
| | | private String plcDeviceCode; |
| | | //plcå°å |
| | | @JsonIgnore |
| | | private String plcAddress; |
| | | |
| | | @JsonIgnore |
| | | private Long errorCode; |
| | | |
| | | @JsonIgnore |
| | | private Date createTime; |
| | | |
| | | private Date updateTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.domain; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | 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 com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * plcä»»å¡è¡¨(PlcTask)表å®ä½ç±» |
| | | * |
| | | * @author van |
| | | * @since 2022-12-19 16:42:56 |
| | | */ |
| | | @TableName(value = "plc_task") |
| | | @Data |
| | | public class PlcTask implements Serializable { |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | private Long taskId; |
| | | //ç¨æ·ID |
| | | private Long userId; |
| | | //客æ·id |
| | | private Long clientId; |
| | | //ä»»å¡åç§° |
| | | private String taskName; |
| | | //1æåã0å¯ç¨ |
| | | @JsonIgnore |
| | | private Integer pause; |
| | | //æ§ç¯å°å |
| | | private String plcAdress; |
| | | //ææå ï¼ä½è¿ç®ä¿åï¼1代表ææä¸ï¼2ææäºï¼4ææä¸ï¼8ææåï¼16ææäºï¼32ææå
ï¼64æææ¥ |
| | | @JsonIgnore |
| | | private Integer week; |
| | | //å¼ç¯å½ä»¤ |
| | | private String openOrder; |
| | | //å
³éç¯å½ä»¤ |
| | | private String closeOrder; |
| | | //ç¯æ§å½ä»¤ |
| | | private String controlOrder; |
| | | //åéç帧è´è· |
| | | @JsonIgnore |
| | | private String framePayload; |
| | | //åå»ºç¨æ· |
| | | private String createUser; |
| | | //å建æ¶é´ |
| | | private LocalDateTime createTime; |
| | | |
| | | private LocalDateTime updateTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | |
| | | @TableField(exist = false) |
| | | private List<Integer> weekList; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.domain; |
| | | import java.util.Date; |
| | | |
| | | 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 com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * plcä»»å¡åç¯æå
³ç³»è¡¨(PlcTaskPoleRelation)表å®ä½ç±» |
| | | * |
| | | * @author van |
| | | * @since 2022-12-19 16:52:25 |
| | | */ |
| | | @TableName(value = "plc_task_pole_relation") |
| | | @Data |
| | | public class PlcTaskPoleRelation implements Serializable{ |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | //ä»»å¡id |
| | | private Long taskId; |
| | | //ç¯æid |
| | | private Long poleId; |
| | | //plcå°å |
| | | private String plcAddress; |
| | | //ä»»å¡ä¸åç¶æï¼0æåï¼1æ ¡éªç é误ï¼2é¿åº¦é误ï¼3åflashé误ï¼255å
¶ä»é误 |
| | | private Integer issueStatus; |
| | | //mac |
| | | @JsonIgnore |
| | | private String deviceCode; |
| | | //ç³»ç»å®æ¶ |
| | | private String sysScheduled; |
| | | //ç¡¬ä»¶å®æ¶ |
| | | private String deviceScheduled; |
| | | //å建æ¶é´ |
| | | private Date createTime; |
| | | //æ´æ°æ¶é´ |
| | | private Date updateTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| | | |
| | |
| | | private String deviceCode; |
| | | |
| | | /** |
| | | * 设å¤ç±»åï¼0è·¯ç¯ï¼1诺ç¦ï¼2å
çµæ¡©ï¼3大æ°çæµï¼4æ°´è´¨çæµï¼5ip鳿±ï¼6lcdå¹¿åæºï¼7æå头ï¼8æä½å¾æµï¼9ä¸é®æå© ,10 ç讯 11大æ°åè |
| | | * 设å¤ç±»åï¼0è·¯ç¯ï¼1诺ç¦ï¼2å
çµæ¡©ï¼3大æ°çæµï¼ |
| | | * 4æ°´è´¨çæµï¼5ip鳿±ï¼6lcdå¹¿åæºï¼7æåå¤´ï¼ |
| | | * 8æä½å¾æµï¼9ä¸é®æå© ,10 ç讯 11大æ°åè |
| | | * 12æ¬å°è¯ºç¦ 13PLC |
| | | */ |
| | | private Integer deviceType; |
| | | |
| | |
| | | SYSTEM_SETTINGS("ç³»ç»è®¾ç½®"), |
| | | CLIENT_LIST("客æ·å表"), |
| | | LIGHT_LIST("è·¯ç¯å表"), |
| | | PLC_LIST("PLCå表"), |
| | | GROUP_LIST("åç»å表"), |
| | | LIGHT_TASK_LIST("è·¯ç¯ä»»å¡å表"), |
| | | PLC_TASK_LIST("PLCä»»å¡å表"), |
| | | LIGHT_DATA("åç¯çæ§æ°æ®"), |
| | | PLC_DATA("PLCçæ§æ°æ®"), |
| | | LIGHT_SETCALENDAR("åç¯è®¾ç½®æ¥å"), |
| | | LIGHT_ERROR_LIST("åç¯æ
éå表"), |
| | | PLC_ERROR_LIST("PLCæ
éå表"), |
| | | LED_LIST("LEDå±å表"), |
| | | LED_PROGRAM_LIST("èç®å表"), |
| | | PLAYPLAN_LIST("ææ¾è®¡åå表"), |
| | |
| | | LED_FILE_S_ADD("æ·»å çæ±æä»¶"), |
| | | LED_FILE_S_DELETE("å é¤çæ±æä»¶"), |
| | | LIGHT_REMARK("æ·»å åç¯å¤æ³¨"), |
| | | PLC_REMARK("æ·»å PLC夿³¨"), |
| | | LIGHT_EXPORT_LIST("导åºåç¯æ°æ®"), |
| | | LIGHT_CONTROL("åç¯æ§å¶"), |
| | | PLC_CONTROL("PLCæ§å¶"), |
| | | PLC_RESET("PLCæ¢å¤åºå设置"), |
| | | PLC_REBOOT("PLCéå¯"), |
| | | PLC_HEARTBEAT_PACKAGE_QUERY_TIME("PLCå¿è·³å
é´éæ¶é´"), |
| | | PLC_HEARTBEAT_PACKAGE_SET_TIME("设置PLCå¿è·³å
é´éæ¶é´"), |
| | | PLC_HEARTBEAT_PACKAGE("PLCå¿è·³å
"), |
| | | LIGHT_SET_POWER("设置åç¯åç"), |
| | | LIGHT_POLE_HEELING_HEARTBEAT_PACKAGE("ç¯æå¾æå¿è·³å
"), |
| | | LIGHT_POLE_HEELING_HEARTBEAT_PACKAGE_QUERY_TIME("ç¯æå¾æå¿è·³å
é´éæ¶é´"), |
| | |
| | | LIGHT_TASK_UPDATE("ç¼è¾è·¯ç¯ä»»å¡"), |
| | | LIGHT_TASK_DETAIL("è·¯ç¯ä»»å¡è¯¦æ
"), |
| | | LIGHT_TASK_ISSUE("ä¸åè·¯ç¯ä»»å¡"), |
| | | PLC_TASK_ADD("æ·»å PLCä»»å¡"), |
| | | PLC_TASK_DELETE("å é¤PLCä»»å¡"), |
| | | PLC_TASK_UPDATE("ç¼è¾PLCä»»å¡"), |
| | | PLC_TASK_DETAIL("PLC宿¶ä»»å¡è¡¥å"), |
| | | PLC_TASK_ISSUE("ä¸åPLCä»»å¡"), |
| | | MONITOR_DELETE("å 餿å头"), |
| | | MONITOR_ADD("æ·»å æå头"), |
| | | MONITOR_INFO("è·åæå头信æ¯"), |
| | |
| | | C3_REFUND("å
çµæ¡©é款"), |
| | | CHARGE_UPDATE("ç¼è¾è´¹ç"), |
| | | ORDER_LIST("订åå表"), |
| | | CHARGE_LIST("è·åè´¹ç"); |
| | | CHARGE_LIST("è·åè´¹ç"), |
| | | PLC_VERSION_QUERY("PLCçæ¬æ¥è¯¢"); |
| | | |
| | | |
| | | private final String code; |
| | |
| | | * åç¯æ°æ®å表 |
| | | */ |
| | | LIGHT_DATA_CREATE_TIME("t1.create_time"), |
| | | PLC_DATA_CREATE_TIME("t1.plc_create_time"), |
| | | |
| | | /** |
| | | * å
çµæ¡©å表 |
| | |
| | | * åè |
| | | */ |
| | | public static final String ATMOSPHERIC_NONG_GENG = "11"; |
| | | |
| | | /* |
| | | * plc |
| | | * */ |
| | | public static final String PLC = "13"; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.sandu.ximon.dao.bo.PlcBo; |
| | | import com.sandu.ximon.dao.domain.Plc; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * plcè·¯ç¯è¡¨(Plc)è¡¨æ°æ®åºè®¿é®å± |
| | | * |
| | | * @author van |
| | | * @since 2022-12-15 14:45:19 |
| | | */ |
| | | @Mapper |
| | | public interface PlcMapper extends BaseMapper<Plc> { |
| | | |
| | | /** |
| | | * æ¹éæ°å¢æ°æ®ï¼MyBatisåçforeachæ¹æ³ï¼ |
| | | * |
| | | * @param entities List<Plc> å®ä¾å¯¹è±¡å表 |
| | | * @return å½±åè¡æ° |
| | | */ |
| | | int insertBatch(@Param("entities") List<Plc> entities); |
| | | |
| | | /** |
| | | * æ¹éæ°å¢ææä¸»é®æ´æ°æ°æ®ï¼MyBatisåçforeachæ¹æ³ï¼ |
| | | * |
| | | * @param entities List<Plc> å®ä¾å¯¹è±¡å表 |
| | | * @return å½±åè¡æ° |
| | | * @throws org.springframework.jdbc.BadSqlGrammarException å
¥åæ¯ç©ºListçæ¶å伿SQLè¯å¥é误çå¼å¸¸ï¼è¯·èªè¡æ ¡éªå
¥å |
| | | */ |
| | | int insertOrUpdateBatch(@Param("entities") List<Plc> entities); |
| | | |
| | | List<PlcBo> listPlc(Long clientId, String keyword); |
| | | /** |
| | | * è·åç¨æ·ææ¥æçç¯æä¸çè·¯ç¯code |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | List<String> listCode(Long userId, String keyword, String deviceCode); |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.sandu.ximon.dao.domain.PlcReportData; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * PLC䏿¥æ°æ®è¡¨(PlcReportData)è¡¨æ°æ®åºè®¿é®å± |
| | | * |
| | | * @author van |
| | | * @since 2022-12-16 10:52:56 |
| | | */ |
| | | @Mapper |
| | | public interface PlcReportDataMapper extends BaseMapper<PlcReportData> { |
| | | |
| | | List<PlcReportData> getNewestReportByDeviceCode(List<String> deviceCodeList); |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.sandu.ximon.dao.bo.PlcReportErrorBo; |
| | | import com.sandu.ximon.dao.domain.PlcReportError; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * plcåç¯æ
éæ°æ®å表(PlcReportError)è¡¨æ°æ®åºè®¿é®å± |
| | | * |
| | | * @author van |
| | | * @since 2022-12-17 14:38:52 |
| | | */ |
| | | @Mapper |
| | | public interface PlcReportErrorMapper extends BaseMapper<PlcReportError> { |
| | | |
| | | List<PlcReportErrorBo> listReportError(String keyword, Long error_code, Long userid); |
| | | |
| | | List<PlcReportErrorBo> listError(Long userid); |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.sandu.ximon.dao.domain.LightTask; |
| | | import com.sandu.ximon.dao.domain.PlcTask; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * plcä»»å¡è¡¨(PlcTask)è¡¨æ°æ®åºè®¿é®å± |
| | | * |
| | | * @author van |
| | | * @since 2022-12-19 16:42:54 |
| | | */ |
| | | @Mapper |
| | | public interface PlcTaskMapper extends BaseMapper<PlcTask> { |
| | | |
| | | List<PlcTask> listPlcTask(Long userId); |
| | | |
| | | List<PlcTask> listTask(Long userId , String keyword, String orderBy); |
| | | |
| | | Integer successCount(Long taskId); |
| | | |
| | | Integer toTalCount(Long taskId); |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.sandu.ximon.dao.domain.PlcTaskPoleRelation; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * plcä»»å¡åç¯æå
³ç³»è¡¨(PlcTaskPoleRelation)è¡¨æ°æ®åºè®¿é®å± |
| | | * |
| | | * @author van |
| | | * @since 2022-12-19 16:52:24 |
| | | */ |
| | | @Mapper |
| | | public interface PlcTaskPoleRelationMapper extends BaseMapper<PlcTaskPoleRelation> { |
| | | |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.PlcMapper"> |
| | | |
| | | <resultMap type="com.sandu.ximon.dao.domain.Plc" id="BaseResultMap"> |
| | | <result property="plcId" column="plc_light_id" jdbcType="INTEGER"/> |
| | | <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/> |
| | | <result property="plcRemark" column="plc_remark" jdbcType="VARCHAR"/> |
| | | <result property="plcCount" column="plc_light_count" jdbcType="INTEGER"/> |
| | | <result property="plcLight1" column="plc_light1" jdbcType="INTEGER"/> |
| | | <result property="plcLight2" column="plc_light2" jdbcType="INTEGER"/> |
| | | <result property="plcLight3" column="plc_light3" jdbcType="INTEGER"/> |
| | | <result property="plcTimingControl" column="plc_timing_control" jdbcType="INTEGER"/> |
| | | <result property="plcSensorControl" column="plc_sensor_control" jdbcType="INTEGER"/> |
| | | <result property="plcSoftwareVersion" column="plc_software_version" jdbcType="VARCHAR"/> |
| | | <result property="plcHardwareVersion" column="plc_hardware_version" jdbcType="VARCHAR"/> |
| | | <result property="plcIemi" column="plc_IEMI" jdbcType="VARCHAR"/> |
| | | <result property="plcIccid" column="plc_ICCID" jdbcType="VARCHAR"/> |
| | | <result property="plcCreateTime" column="plc_create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="plcUpdateTime" column="plc_update_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <select id="listPlc" resultType="com.sandu.ximon.dao.bo.PlcBo"> |
| | | SELECT |
| | | t1.*, |
| | | t2.id AS pole_id, |
| | | t2.pole_code, |
| | | t2.pole_name, |
| | | t4.task_id AS task_id, |
| | | t4.task_name AS task_name, |
| | | t3.plc_address AS plc_address |
| | | FROM |
| | | plc t1 |
| | | LEFT JOIN pole_binding t5 ON t1.device_code = t5.device_code |
| | | LEFT JOIN pole t2 ON t2.id=t5.pole_id AND t5.device_type=13 |
| | | LEFT JOIN plc_task_pole_relation t3 ON t3.pole_id = t2.id |
| | | LEFT JOIN plc_task t4 ON t3.task_id = t4.task_id |
| | | <where> |
| | | <if test="clientId != null"> |
| | | AND (t2.user_id = #{clientId} OR t2.client_id = #{clientId}) |
| | | </if> |
| | | <if test="keyword != null and keyword != ''"> |
| | | AND ( |
| | | t1.device_code LIKE CONCAT('%', #{keyword},'%') |
| | | OR t2.pole_name LIKE CONCAT('%', #{keyword},'%') |
| | | ) |
| | | </if> |
| | | </where> |
| | | |
| | | </select> |
| | | |
| | | <select id="listCode" resultType="java.lang.String"> |
| | | SELECT |
| | | t1.device_code |
| | | FROM |
| | | plc t1 |
| | | LEFT JOIN pole t2 ON t1.device_code = t2.device_code |
| | | <where> |
| | | <if test="userId != null"> |
| | | AND (t2.user_id = #{userId} OR t2.client_id = #{userId}) |
| | | </if> |
| | | <if test="keyword != null and keyword != ''"> |
| | | AND ( |
| | | t1.device_code LIKE CONCAT('%', #{keyword},'%') |
| | | OR t2.pole_name LIKE CONCAT('%', #{keyword},'%') |
| | | ) |
| | | </if> |
| | | <if test="deviceCode != null and deviceCode!= ''"> |
| | | AND t1.device_code = #{deviceCode} |
| | | </if> |
| | | </where> |
| | | |
| | | </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.PlcReportDataMapper"> |
| | | |
| | | <resultMap type="com.sandu.ximon.dao.domain.PlcReportData" id="plcReportDataMap"> |
| | | <result property="reportDataId" column="report_data_id"/> |
| | | <result property="deviceCode" column="device_code"/> |
| | | <result property="deviceTemperature" column="device_temperature"/> |
| | | <result property="phase" column="phase"/> |
| | | <result property="voltageA" column="voltage_A"/> |
| | | <result property="voltageB" column="voltage_B"/> |
| | | <result property="voltageC" column="voltage_C"/> |
| | | <result property="electricCurrentA" column="electric_current_A"/> |
| | | <result property="electricCurrentB" column="electric_current_B"/> |
| | | <result property="electricCurrentC" column="electric_current_C"/> |
| | | <result property="activePowerAll" column="active_power_All"/> |
| | | <result property="activePowerA" column="active_power_A"/> |
| | | <result property="activePowerB" column="active_power_B"/> |
| | | <result property="activePowerC" column="active_power_C"/> |
| | | <result property="reactivePowerAll" column="reactive_power_All"/> |
| | | <result property="reactivePowerA" column="reactive_power_A"/> |
| | | <result property="reactivePowerB" column="reactive_power_B"/> |
| | | <result property="reactivePowerC" column="reactive_power_C"/> |
| | | <result property="apparentPowerAll" column="apparent_power_All"/> |
| | | <result property="apparentPowerA" column="apparent_power_A"/> |
| | | <result property="apparentPowerB" column="apparent_power_B"/> |
| | | <result property="apparentPowerC" column="apparent_power_C"/> |
| | | <result property="powerFactorAll" column="power_factor_All"/> |
| | | <result property="powerFactorA" column="power_factor_A"/> |
| | | <result property="powerFactorB" column="power_factor_B"/> |
| | | <result property="powerFactorC" column="power_factor_C"/> |
| | | <result property="totalPositiveUsingPower" column="total_positive_using_power"/> |
| | | <result property="totalReverseUsingPower" column="total_reverse_using_power"/> |
| | | <result property="lightIntensity" column="light_intensity"/> |
| | | <result property="control1" column="control_1"/> |
| | | <result property="status1" column="status_1"/> |
| | | <result property="control2" column="control_2"/> |
| | | <result property="status2" column="status_2"/> |
| | | <result property="control3" column="control_3"/> |
| | | <result property="status3" column="status_3"/> |
| | | <result property="controlN" column="control_n"/> |
| | | <result property="statusN" column="status_n"/> |
| | | <result property="createTime1" column="create_time1"/> |
| | | <result property="updateTime1" column="update_time1"/> |
| | | </resultMap> |
| | | <select id="getNewestReportByDeviceCode" resultMap="plcReportDataMap" |
| | | > |
| | | SELECT |
| | | t1.* |
| | | FROM |
| | | plc_report_data t1 |
| | | JOIN ( |
| | | SELECT |
| | | MAX( report_data_id ) AS report_data_id |
| | | FROM |
| | | plc_report_data |
| | | WHERE device_code IN |
| | | <foreach collection="deviceCodeList" open="(" close=")" separator="," item="deviceCode"> |
| | | #{deviceCode} |
| | | </foreach> |
| | | GROUP BY device_code |
| | | ) AS t2 USING ( report_data_id ) |
| | | |
| | | </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.PlcReportErrorMapper"> |
| | | |
| | | <resultMap type="com.sandu.ximon.dao.domain.PlcReportError" id="BaseResultMap"> |
| | | <result property="plcReportErrorId" column="plc_report_error_id" jdbcType="INTEGER"/> |
| | | <result property="plcDeviceCode" column="plc_device_code" jdbcType="VARCHAR"/> |
| | | <result property="plcAddress" column="plc_address" jdbcType="VARCHAR"/> |
| | | <result property="errorCode" column="error_code" jdbcType="BIGINT"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <resultMap id="listReportError" type="com.sandu.ximon.dao.bo.PlcReportErrorBo" extends="BaseResultMap"> |
| | | <result property="poleName" column="pole_name" jdbcType="VARCHAR"/> |
| | | </resultMap> |
| | | |
| | | <select id="listReportError" resultType="com.sandu.ximon.dao.bo.PlcReportErrorBo"> |
| | | SELECT |
| | | t1.*, |
| | | t3.pole_name, |
| | | t3.id |
| | | FROM |
| | | plc_report_error t1 |
| | | LEFT JOIN pole_binding t2 ON t1.plc_device_code = t2.device_code |
| | | AND t2.device_type = 13 |
| | | 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},'%') |
| | | OR t3.pole_name LIKE CONCAT('%', #{keyword},'%') |
| | | OR t1.plc_device_code LIKE CONCAT('%', #{keyword},'%') |
| | | ) |
| | | </if> |
| | | <if test="userid != null"> |
| | | AND (t3.user_id = #{userid} OR t3.client_id = #{userid}) |
| | | </if> |
| | | <if test="error_code != null"> |
| | | AND t1.error_code = #{error_code} |
| | | </if> |
| | | </where> |
| | | ORDER BY t1.plc_report_error_id DESC |
| | | |
| | | </select> |
| | | <select id="listError" resultType="com.sandu.ximon.dao.bo.PlcReportErrorBo" parameterType="java.lang.Long"> |
| | | SELECT |
| | | t1.* |
| | | FROM |
| | | plc_report_error t1 |
| | | LEFT JOIN pole t3 ON t1.plc_device_code = t3.device_code |
| | | WHERE |
| | | t1.plc_report_error_id IN ( SELECT t.max_id FROM ( SELECT Max( plc_report_error.plc_report_error_id ) AS |
| | | max_id FROM plc_report_error GROUP BY plc_report_error.plc_device_code ) AS t ) |
| | | <if test="userid != null"> |
| | | AND t3.client_id = #{userId} OR t3.user_id = #{userId} |
| | | </if> |
| | | ORDER BY |
| | | t1.create_time DESC |
| | | </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.PlcTaskMapper"> |
| | | |
| | | <resultMap type="com.sandu.ximon.dao.domain.PlcTask" id="PlcTaskMap"> |
| | | <result property="taskId" column="task_id" jdbcType="INTEGER"/> |
| | | <result property="userId" column="user_id" jdbcType="INTEGER"/> |
| | | <result property="clientId" column="client_id" jdbcType="INTEGER"/> |
| | | <result property="taskName" column="task_name" jdbcType="VARCHAR"/> |
| | | <result property="pause" column="pause" jdbcType="INTEGER"/> |
| | | <result property="plcAdress" column="plc_adress" jdbcType="VARCHAR"/> |
| | | <result property="week" column="week" jdbcType="INTEGER"/> |
| | | <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="framePayload" column="frame_payload" 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> |
| | | |
| | | <!-- æ¹éæå
¥ --> |
| | | <insert id="insertBatch" keyProperty="taskId" useGeneratedKeys="true"> |
| | | insert into xm_dev.plc_task(user_id, client_id, task_name, pause, plc_adress, week, open_order, close_order, control_order, frame_payload, create_user, create_time, update_time) |
| | | values |
| | | <foreach collection="entities" item="entity" separator=","> |
| | | (#{entity.userId}, #{entity.clientId}, #{entity.taskName}, #{entity.pause}, #{entity.plcAdress}, #{entity.week}, #{entity.openOrder}, #{entity.closeOrder}, #{entity.controlOrder}, #{entity.framePayload}, #{entity.createUser}, #{entity.createTime}, #{entity.updateTime}) |
| | | </foreach> |
| | | </insert> |
| | | <!-- æ¹éæå
¥ææä¸»é®æ´æ° --> |
| | | <insert id="insertOrUpdateBatch" keyProperty="taskId" useGeneratedKeys="true"> |
| | | insert into xm_dev.plc_task(user_id, client_id, task_name, pause, plc_adress, week, open_order, close_order, control_order, frame_payload, create_user, create_time, update_time) |
| | | values |
| | | <foreach collection="entities" item="entity" separator=","> |
| | | (#{entity.userId}, #{entity.clientId}, #{entity.taskName}, #{entity.pause}, #{entity.plcAdress}, #{entity.week}, #{entity.openOrder}, #{entity.closeOrder}, #{entity.controlOrder}, #{entity.framePayload}, #{entity.createUser}, #{entity.createTime}, #{entity.updateTime}) |
| | | </foreach> |
| | | on duplicate key update |
| | | user_id = values(user_id) , client_id = values(client_id) , task_name = values(task_name) , pause = values(pause) , plc_adress = values(plc_adress) , week = values(week) , open_order = values(open_order) , close_order = values(close_order) , control_order = values(control_order) , frame_payload = values(frame_payload) , create_user = values(create_user) , create_time = values(create_time) , update_time = values(update_time) </insert> |
| | | |
| | | <select id="listPlcTask" resultType="com.sandu.ximon.dao.domain.PlcTask" |
| | | parameterType="java.lang.Long"> |
| | | SELECT t1.* |
| | | FROM plc_task t1 |
| | | LEFT JOIN plc_task_pole_relation t2 ON t1.task_id = t2.task_id |
| | | LEFT JOIN pole t3 ON t2.pole_id = t3.id |
| | | WHERE t2.issue_status = 0 |
| | | <if test="userid != null"> |
| | | AND (t3.user_id = #{userid} OR t3.client_id = #{userid}) |
| | | </if> |
| | | |
| | | </select> |
| | | <select id="listTask" resultType="com.sandu.ximon.dao.domain.PlcTask"> |
| | | SELECT |
| | | t1.* |
| | | FROM |
| | | plc_task t1 |
| | | LEFT JOIN plc_task_pole_relation t2 ON t1.task_id = t2.task_id |
| | | LEFT JOIN pole t3 ON t3.id = t2.pole_id |
| | | LEFT JOIN pole_binding t4 ON t3.id = t4.pole_id |
| | | LEFT JOIN plc t5 ON t5.device_code = t4.device_code |
| | | WHERE |
| | | 1=1 |
| | | <if test="keyword != null and keyword != ''"> |
| | | AND ( t1.task_name LIKE CONCAT(CONCAT('%', #{keyword}), '%') OR t5.device_code LIKE CONCAT(CONCAT('%', |
| | | #{keyword}), '%')) |
| | | </if> |
| | | <if test="userId != null"> |
| | | AND ( t1.client_id =#{userId} OR t1.user_id =#{userId} ) |
| | | </if> |
| | | GROUP BY |
| | | task_id |
| | | ORDER BY |
| | | t1.${orderBy} |
| | | </select> |
| | | |
| | | <select id="successCount" resultType="java.lang.Integer"> |
| | | SELECT count(*) |
| | | FROM plc_task t1 |
| | | LEFT JOIN plc_task_pole_relation t2 ON t1.task_id = t2.task_id |
| | | WHERE t1.task_id = #{taskId} |
| | | </select> |
| | | |
| | | <select id="toTalCount" resultType="java.lang.Integer"> |
| | | SELECT count(*) |
| | | FROM plc_task t1 |
| | | LEFT JOIN plc_task_pole_relation t2 ON t1.task_id = t2.task_id |
| | | WHERE t1.task_id = #{taskId} |
| | | </select> |
| | | |
| | | </mapper> |
| | | |
| | |
| | | </root> |
| | | </springProfile> |
| | | |
| | | <springProfile name="xm_local"> |
| | | <root level="info" > |
| | | <appender-ref ref="STDOUT"/> |
| | | </root> |
| | | </springProfile> |
| | | <!-- ç产ç¯å¢. æ¥å¿çº§å«ä¸ºWARNä¸åæ¥å¿æä»¶--> |
| | | <springProfile name="prod,docker"> |
| | | <springProfile name="prod,docker,xm_lj"> |
| | | <root level="warn"> |
| | | <appender-ref ref="STDOUT"/> |
| | | <appender-ref ref="ASYNC"/> |
| | |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>io.swagger</groupId> |
| | | <artifactId>swagger-annotations</artifactId> |
| | | <version>1.6.2</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.api.ApiController; |
| | | import com.baomidou.mybatisplus.extension.api.R; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.sandu.common.domain.CommonPage; |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.param.LightControlParam; |
| | | import com.sandu.ximon.admin.param.LightRemarkParam; |
| | | import com.sandu.ximon.admin.param.PlcControlParam; |
| | | import com.sandu.ximon.admin.param.PlcRemarkParam; |
| | | import com.sandu.ximon.admin.security.PermissionConfig; |
| | | import com.sandu.ximon.admin.service.PlcReportDataService; |
| | | import com.sandu.ximon.admin.service.PlcReportErrorService; |
| | | import com.sandu.ximon.admin.service.PlcService; |
| | | import com.sandu.ximon.dao.bo.*; |
| | | import com.sandu.ximon.dao.domain.LightReportData; |
| | | import com.sandu.ximon.dao.domain.Plc; |
| | | import com.sandu.ximon.dao.domain.PlcReportData; |
| | | import com.sandu.ximon.dao.domain.PlcReportError; |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * plcè·¯ç¯è¡¨(Plc)表æ§å¶å± |
| | | * |
| | | * @author van |
| | | * @since 2022-12-15 14:45:18 |
| | | */ |
| | | @AllArgsConstructor |
| | | @RestController |
| | | @RequestMapping("plc") |
| | | public class PlcController { |
| | | |
| | | private final PlcService plcService; |
| | | |
| | | private final PlcReportDataService plcReportDataService; |
| | | |
| | | private final PlcReportErrorService plcReportErrorService; |
| | | private final PermissionConfig permissionConfig; |
| | | |
| | | @GetMapping("list") |
| | | public ResponseVO<Object> selectAll(BaseConditionVO conditionVO, |
| | | @RequestParam(value = "keyword", required = false) String keyword, |
| | | @RequestParam(value = "order", required = false) Integer order, |
| | | @RequestParam(value = "seq", required = false) Integer seq) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | List<PlcBo> plcBos = plcService.listPlc(conditionVO.getPageNo(), conditionVO.getPageSize(), keyword, order, seq); |
| | | |
| | | return ResponseUtil.successPage(plcBos); |
| | | } |
| | | |
| | | @PostMapping("/remark") |
| | | public ResponseVO<Object> addRemark(@RequestBody @Validated PlcRemarkParam param) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_REMARK.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | boolean result = plcService.addRemark(param); |
| | | if (result) { |
| | | return ResponseUtil.success("æ·»å æå"); |
| | | } else { |
| | | return ResponseUtil.fail("æ·»å 失败"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·å䏿¥æ°æ® |
| | | * |
| | | * @param conditionVO |
| | | * @return |
| | | */ |
| | | @GetMapping("/report/list") |
| | | public ResponseVO<Object> listReportData(BaseConditionVO conditionVO |
| | | , @RequestParam(value = "keyword", required = false) String keyword |
| | | , @RequestParam(value = "deviceCode", required = false) String deviceCode |
| | | , @RequestParam(value = "order", required = false) Integer order |
| | | ,@RequestParam(value = "seq", required = false) Integer seq) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_DATA.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | CommonPage commonPage = plcReportDataService.listReportData(conditionVO.getPageNo(), conditionVO.getPageSize(), keyword, deviceCode,order,seq); |
| | | List<PlcReportDataBo> plcReportDataBos = (List<PlcReportDataBo>) commonPage.getList(); |
| | | |
| | | if (plcReportDataBos == null) { |
| | | return ResponseUtil.success(CommonPage.restPage(new ArrayList<>())); |
| | | } |
| | | CommonPage commonPage1 = CommonPage.restPage(plcReportDataBos); |
| | | commonPage1.setTotal(commonPage.getTotal()); |
| | | commonPage1.setTotalPage(commonPage.getTotalPage()); |
| | | |
| | | return ResponseUtil.success(commonPage1); |
| | | } |
| | | |
| | | @GetMapping("/error/list") |
| | | public ResponseVO<Object> listReportError(BaseConditionVO conditionVO, @RequestParam(value = "keyword", required = false) String keyword |
| | | , @RequestParam(value = "errorCode", required = false) Long errorCode) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_ERROR_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | List<PlcReportErrorBo> list = plcReportErrorService.listReportError(conditionVO.getPageNo(), conditionVO.getPageSize(), keyword, errorCode); |
| | | return ResponseUtil.success(list); |
| | | } |
| | | |
| | | @GetMapping("/data/list") |
| | | public ResponseVO<Object> listData(BaseConditionVO conditionVO, @RequestParam(value = "deviceCode", required = false) String deviceCode) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_DATA.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | List<PlcReportData> reportDataList = plcReportDataService.getReportDataList(conditionVO, deviceCode); |
| | | |
| | | return ResponseUtil.success(reportDataList); |
| | | } |
| | | // 亮度æ§å¶ |
| | | @PostMapping("/control") |
| | | public ResponseVO<Object> controlBrightness(@RequestBody @Validated List<PlcControlParam> paramList) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_CONTROL.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | List<Map<String, Object>> list = plcService.controlBrightness(paramList); |
| | | return ResponseUtil.success(list); |
| | | } |
| | | |
| | | // 设置å¿è·³æ¶é´ |
| | | @PostMapping("/setHeartBeatTime") |
| | | public ResponseVO<Object> setHeartBeatTime(@RequestBody @Validated List<PlcControlParam> paramList) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_HEARTBEAT_PACKAGE_SET_TIME.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | List<Map<String, Object>> list = plcService.setHeartBeatTime(paramList); |
| | | return ResponseUtil.success(list); |
| | | } |
| | | |
| | | // æ¥è¯¢å¿è·³æ¶é´ |
| | | @PostMapping("/queryHeartBeatTime") |
| | | public ResponseVO<Object> queryHeartBeatTime(@RequestBody @Validated List<PlcControlParam> paramList) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_HEARTBEAT_PACKAGE_QUERY_TIME.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | List<Map<String, Object>> list = plcService.queryHeartBeatTime(paramList); |
| | | return ResponseUtil.success(list); |
| | | } |
| | | |
| | | // æ¥è¯¢å¿è·³ |
| | | @PostMapping("/queryHeartBeatData") |
| | | public ResponseVO<Object> queryHeartBeatData(@RequestBody @Validated List<PlcControlParam> paramList) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_HEARTBEAT_PACKAGE.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | List<Map<String, Object>> list = plcService.queryHeartBeatData(paramList); |
| | | return ResponseUtil.success(list); |
| | | } |
| | | |
| | | // æ¥è¯¢å¿è·³ |
| | | @PostMapping("/queryVersion") |
| | | public ResponseVO<Object> queryVersion(@RequestBody @Validated List<PlcControlParam> paramList) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_VERSION_QUERY.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | List<Map<String, Object>> list = plcService.queryVersion(paramList); |
| | | return ResponseUtil.success(list); |
| | | } |
| | | |
| | | // éå¯ |
| | | @PostMapping("/reboot") |
| | | public ResponseVO<Object> reboot(@RequestBody @Validated List<PlcControlParam> paramList) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_REBOOT.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | List<Map<String, Object>> list = plcService.reboot(paramList); |
| | | return ResponseUtil.success(list); |
| | | } |
| | | |
| | | // æ¢å¤åºå设置 |
| | | @PostMapping("/reset") |
| | | public ResponseVO<Object> reset(@RequestBody @Validated List<PlcControlParam> paramList) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_RESET.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | List<Map<String, Object>> list = plcService.reset(paramList); |
| | | return ResponseUtil.success(list); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | |
| | | |
| | | import cn.hutool.db.PageResult; |
| | | import com.baomidou.mybatisplus.extension.api.R; |
| | | import com.sandu.ximon.admin.service.PlcReportDataService; |
| | | import com.sandu.ximon.dao.domain.PlcReportData; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * PLC䏿¥æ°æ®è¡¨(PlcReportData)表æ§å¶å± |
| | | * |
| | | * @author van |
| | | * @since 2022-12-16 10:54:58 |
| | | */ |
| | | @Api(tags = "PLC䏿¥æ°æ®è¡¨(plcReportData)" , value = "PLC䏿¥æ°æ®è¡¨(PlcReportData)") |
| | | @RestController |
| | | @RequestMapping("/admin/plcReportData") |
| | | public class PlcReportDataController { |
| | | /** |
| | | * æå¡å¯¹è±¡ |
| | | */ |
| | | @Autowired |
| | | private PlcReportDataService plcReportDataService; |
| | | |
| | | |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.dto.LightTaskDto; |
| | | import com.sandu.ximon.admin.dto.PlcTaskDto; |
| | | import com.sandu.ximon.admin.param.*; |
| | | import com.sandu.ximon.admin.security.PermissionConfig; |
| | | import com.sandu.ximon.admin.service.LightEnergyDataService; |
| | | import com.sandu.ximon.admin.service.LightTaskService; |
| | | import com.sandu.ximon.admin.service.PlcTaskService; |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Plcä»»å¡ç¸å
³æ§å¶ç±» |
| | | * |
| | | * @author van |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/plc/task") |
| | | public class PlcTaskController { |
| | | |
| | | private final PlcTaskService plcTaskService; |
| | | private PermissionConfig permissionConfig; |
| | | |
| | | @PostMapping("/add") |
| | | public ResponseVO<Object> addPlcTask(@RequestBody @Validated PlcTaskParam param) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_TASK_ADD.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | return ResponseUtil.success(plcTaskService.AddPlcTask(param)); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/list") |
| | | public ResponseVO<Object> listPlcTask(BaseConditionVO conditionVO, |
| | | @RequestParam(value = "keyword", required = false) String keyword, |
| | | @RequestParam(value = "order", required = false) Integer order, |
| | | @RequestParam(value = "seq", required = false) Integer seq) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_TASK_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | List<PlcTaskDto> taskList = plcTaskService.listPlcTask(conditionVO, keyword, order, seq); |
| | | return ResponseUtil.successPage(taskList); |
| | | } |
| | | |
| | | @PostMapping("/del") |
| | | public ResponseVO<Object> delPlcTask(@RequestBody @Validated PlcTaskDelParam param) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_TASK_DELETE.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | String result = plcTaskService.delPlcTask(param.getTaskId()); |
| | | return ResponseUtil.success(result); |
| | | |
| | | } |
| | | |
| | | @PostMapping("/update/{taskId}") |
| | | public ResponseVO<Object> updatePlcTask(@PathVariable Long taskId, @RequestBody @Validated PlcTaskParam param) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_TASK_UPDATE.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | String result = plcTaskService.newUpdatePlcTask(taskId, param); |
| | | return ResponseUtil.success(result); |
| | | |
| | | } |
| | | |
| | | // |
| | | // /** |
| | | // * æ¸
é¤ä»»å¡ |
| | | // * |
| | | // * @param |
| | | // * @return |
| | | // */ |
| | | //// @PostMapping("/clear") |
| | | //// public ResponseVO<Object> clearLightTask(@RequestBody List<Long> poleIds) { |
| | | //// if (!permissionConfig.check(MenuEnum.PLC_TASK_UPDATE.getCode())) { |
| | | //// return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | //// } |
| | | //// boolean result = plcTaskService.clearLightTask(poleIds); |
| | | //// return ResponseUtil.success(result); |
| | | //// } |
| | | @GetMapping("/{taskId}") |
| | | public ResponseVO<Object> detailPlcTask(@PathVariable Long taskId) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_TASK_DETAIL.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | |
| | | return ResponseUtil.success(plcTaskService.detailPlcTask(taskId)); |
| | | } |
| | | |
| | | /** |
| | | * åç¯ä¸å |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @PostMapping("/issue") |
| | | public ResponseVO<Object> issueLightTask(@RequestBody @Validated PlcTaskIssueParam param) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_TASK_ISSUE.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | boolean result = plcTaskService.issuePlcTask(param); |
| | | if (result) { |
| | | return ResponseUtil.success("ä¸åæå"); |
| | | } else { |
| | | return ResponseUtil.fail("ä¸å失败"); |
| | | } |
| | | } |
| | | // |
| | | // |
| | | // @PostMapping("/energy") |
| | | // public ResponseVO<Object> energy() { |
| | | // |
| | | // |
| | | // plcTaskService.energy(); |
| | | // return ResponseUtil.success("lightEnergyDataService.energy(0)"); |
| | | // } |
| | | // |
| | | // |
| | | @PostMapping("/check") |
| | | public ResponseVO<Object> checkTask(@RequestBody PlcTaskParam param) { |
| | | if (!permissionConfig.check(MenuEnum.PLC_TASK_UPDATE.getCode())) { |
| | | return ResponseUtil.fail("缺å°å¯¹åºç¨æ·æé"); |
| | | } |
| | | if (!"0001".equals(param.getPlcAddress()) |
| | | && !"0002".equals(param.getPlcAddress()) |
| | | && !"0003".equals(param.getPlcAddress())) { |
| | | throw new BusinessException("ç¯å¤´å°åæ ¼å¼ä¸æ£ç¡®"); |
| | | } |
| | | return ResponseUtil.success(plcTaskService.checkTask(param)); |
| | | |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.api.ApiController; |
| | | import com.baomidou.mybatisplus.extension.api.R; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.sandu.ximon.admin.service.PlcTaskPoleRelationService; |
| | | import com.sandu.ximon.dao.domain.PlcTaskPoleRelation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * plcä»»å¡åç¯æå
³ç³»è¡¨(PlcTaskPoleRelation)表æ§å¶å± |
| | | * |
| | | * @author van |
| | | * @since 2022-12-19 16:54:14 |
| | | */ |
| | | @AllArgsConstructor |
| | | @RestController |
| | | @RequestMapping("plcTaskPoleRelation") |
| | | public class PlcTaskPoleRelationController extends ApiController { |
| | | /** |
| | | * æå¡å¯¹è±¡ |
| | | */ |
| | | private final PlcTaskPoleRelationService plcTaskPoleRelationService; |
| | | |
| | | /** |
| | | * å页æ¥è¯¢æææ°æ® |
| | | * |
| | | * @param page å页对象 |
| | | * @param plcTaskPoleRelation æ¥è¯¢å®ä½ |
| | | * @return æææ°æ® |
| | | */ |
| | | @GetMapping |
| | | public R selectAll(Page<PlcTaskPoleRelation> page, PlcTaskPoleRelation plcTaskPoleRelation) { |
| | | return success(this.plcTaskPoleRelationService.page(page, new QueryWrapper<>(plcTaskPoleRelation))); |
| | | } |
| | | |
| | | /** |
| | | * éè¿ä¸»é®æ¥è¯¢åæ¡æ°æ® |
| | | * |
| | | * @param id ä¸»é® |
| | | * @return åæ¡æ°æ® |
| | | */ |
| | | @GetMapping("{id}") |
| | | public R selectOne(@PathVariable Serializable id) { |
| | | return success(this.plcTaskPoleRelationService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢æ°æ® |
| | | * |
| | | * @param plcTaskPoleRelation å®ä½å¯¹è±¡ |
| | | * @return æ°å¢ç»æ |
| | | */ |
| | | @PostMapping |
| | | public R insert(@RequestBody PlcTaskPoleRelation plcTaskPoleRelation) { |
| | | return success(this.plcTaskPoleRelationService.save(plcTaskPoleRelation)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹æ°æ® |
| | | * |
| | | * @param plcTaskPoleRelation å®ä½å¯¹è±¡ |
| | | * @return ä¿®æ¹ç»æ |
| | | */ |
| | | @PutMapping |
| | | public R update(@RequestBody PlcTaskPoleRelation plcTaskPoleRelation) { |
| | | return success(this.plcTaskPoleRelationService.updateById(plcTaskPoleRelation)); |
| | | } |
| | | |
| | | /** |
| | | * å 餿°æ® |
| | | * |
| | | * @param idList 主é®ç»å |
| | | * @return å é¤ç»æ |
| | | */ |
| | | @DeleteMapping |
| | | public R delete(@RequestParam("idList") List<Long> idList) { |
| | | return success(this.plcTaskPoleRelationService.removeByIds(idList)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | boolean result = poleService.bindPole(poleId, param); |
| | | if (result) { |
| | | //设å¤ç±»åï¼0è·¯ç¯ï¼1noveï¼2å
çµæ¡©ï¼3大æ°çæµï¼4æ°´è´¨çæµï¼5ip鳿±ï¼6lcdå¹¿åæºï¼7æå头ï¼8æä½å¾æµï¼9ä¸é®æå©, 10ç讯, 11åè |
| | | //设å¤ç±»åï¼0è·¯ç¯ï¼1noveï¼2å
çµæ¡©ï¼3大æ°çæµï¼4æ°´è´¨çæµï¼5ip鳿±ï¼6lcdå¹¿åæºï¼7æå头ï¼8æä½å¾æµï¼ |
| | | // 9ä¸é®æå©, 10ç讯, 11åè,12æ¬å°è¯ºç¦ï¼13PLC |
| | | switch (param.getDeviceType().toString()) { |
| | | case PoleBindingEnums.LIGHT: |
| | | case PoleBindingEnums.PLC: |
| | | Pole pole = poleService.getById(poleId); |
| | | if (pole != null) { |
| | | pole.setPoleName(param.getDeviceName()); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.dto; |
| | | |
| | | import com.sandu.ximon.dao.domain.LightTask; |
| | | import com.sandu.ximon.dao.domain.PlcTask; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author van |
| | | */ |
| | | @Data |
| | | public class PlcTaskDto extends PlcTask { |
| | | |
| | | private List<Integer> weekList; |
| | | |
| | | /** |
| | | * åæ¥ç¶æ |
| | | */ |
| | | private String syncStatus; |
| | | |
| | | /** |
| | | * ç¯å¤´1æ¯å¦æ§è¡ |
| | | */ |
| | | // private Boolean light1 = false; |
| | | |
| | | /** |
| | | * ç¯å¤´2æ¯å¦æ§è¡ |
| | | */ |
| | | // private Boolean light2 = false; |
| | | } |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | 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.amqp.processor.PoleMonitorDataProcessor; |
| | | import com.sandu.ximon.admin.manager.iot.amqp.processor.c3ChargingProcessor; |
| | | import com.sandu.ximon.admin.manager.iot.amqp.processor.*; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3CommonReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3ErrorCodeReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3HeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonReportMessage; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.C3ChargingEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.C3mRedisConstant; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.*; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.FrameUtils; |
| | | import com.sandu.ximon.admin.service.C3ChargingService; |
| | | import com.sandu.ximon.admin.service.C3mOrderService; |
| | |
| | | |
| | | |
| | | protected final static ExecutorService EXECUTOR_SERVICE = new ThreadPoolExecutor( |
| | | Runtime.getRuntime().availableProcessors(), |
| | | Runtime.getRuntime().availableProcessors() * 2, 60, TimeUnit.SECONDS, |
| | | Runtime.getRuntime().availableProcessors() * 2, |
| | | Runtime.getRuntime().availableProcessors() * 4, 60, TimeUnit.SECONDS, |
| | | new LinkedBlockingQueue<>(50000), new NameTreadFactory()); |
| | | |
| | | static class NameTreadFactory implements ThreadFactory { |
| | |
| | | String topic = message.getStringProperty("topic"); |
| | | String messageId = message.getStringProperty("messageId"); |
| | | |
| | | log.info("æ¶å°è®¢é
" + topic + "," + messageId); |
| | | log.info(content); |
| | | // log.info("æ¶å°è®¢é
" + topic + "," + messageId); |
| | | // log.info(content); |
| | | |
| | | if (null != map.get("status")) { |
| | | // ä¸ä¸çº¿ä¸æ¥å¤ç |
| | |
| | | if (frame == null) { |
| | | return; |
| | | } |
| | | log.info("å¤ç订é
"); |
| | | log.info(frame.toString()); |
| | | // if (!deviceName.equals("3930364d485010ff803affff")){ |
| | | // return; |
| | | // } |
| | | log.info("å¤ç订é
:\nmac:{},frame:{}",deviceName,frame.toString()); |
| | | if (frame.getFunctionCode().equals("A5")){ |
| | | log.info("A5"); |
| | | if (frame.getOrderType().equals(A5OrderEnum.RESPONSE_LIGHT_DATA.getCode())) { |
| | | // åç¯æ°æ®ä¸æ¥å¤ç |
| | | LightDataProcessor.getInstance().process(productKey, deviceName, frame); |
| | |
| | | } else if (frame.getOrderType().equals(A5OrderEnum.RESPONSE_POLE_MONITOR_DATA.getCode())) { |
| | | PoleMonitorDataProcessor.getInstance().process(productKey, deviceName, frame); |
| | | } |
| | | } else if (frame.getFunctionCode().equals("A7")) { |
| | | log.info("A7"); |
| | | |
| | | if (frame.getOrderType().equals(A7OrderEnum.RESPONSE_PLC_DATA.getCode())){ |
| | | // PLC |
| | | PlcDataProcessor.getInstance().process(productKey, deviceName,frame); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.amqp.processor; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A7PlcErrorCodeReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A7PlcHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A7PlcManualLightSwitchReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A7PlcTimeSyncReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A7PlcReportEnum; |
| | | import com.sandu.ximon.admin.service.*; |
| | | import com.sandu.ximon.dao.domain.Plc; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * @author van |
| | | * PLCæ°æ®ä¸æ¥å¤ç |
| | | */ |
| | | @Slf4j |
| | | public class PlcDataProcessor implements IMessageProcessor { |
| | | |
| | | private PlcDataProcessor() { |
| | | } |
| | | |
| | | public static PlcDataProcessor getInstance() { |
| | | return PlcDataProcessorHolder.INSTANCE; |
| | | } |
| | | |
| | | private static class PlcDataProcessorHolder { |
| | | |
| | | private static final PlcDataProcessor INSTANCE = new PlcDataProcessor(); |
| | | } |
| | | |
| | | @Override |
| | | public void process(String productKey, String deviceName, CommonFrame frame) { |
| | | String functionCode = frame.getPayload().substring(2, 4); |
| | | if (A7PlcReportEnum.HeartBeat_Data.getCode().equals(functionCode)) { |
| | | log.error("å¿è·³ç¸åº"); |
| | | A7PlcHeartbeatReportInnerFrame heartbeatReportInnerFrame = new A7PlcHeartbeatReportInnerFrame().transformFrame(frame.getPayload()); |
| | | |
| | | // if ("3930364d485010ff803affff".equals(deviceName)) { |
| | | // System.out.println("å¿è·³å
: " + JSON.toJSONString(heartbeatReportInnerFrame)); |
| | | // System.out.println("crc32æ ¡éªç»æï¼"+heartbeatReportInnerFrame.isValidate()); |
| | | // } |
| | | if (heartbeatReportInnerFrame.isValidate()) { |
| | | SpringContextHolder.getBean(PlcReportDataService.class).saveReportData(deviceName, heartbeatReportInnerFrame.getHeartBeatDataPackage()); |
| | | //å¿è·³å
䏿¥ä¸ä¿å硬件设å¤ä¿¡æ¯ |
| | | // SpringContextHolder.getBean(LightService.class).saveLight(deviceName, heartbeatReportInnerFrame.getHeartBeatDataPackage()); |
| | | } |
| | | |
| | | } else if (A7PlcReportEnum.Time_Synchronized.getCode().equals(functionCode)) { |
| | | log.error("è¯·æ±æ¶é´åæ¥"); |
| | | A7PlcTimeSyncReportInnerFrame syncRespInnerFrame = new A7PlcTimeSyncReportInnerFrame().transformFrame(frame.getPayload()); |
| | | if (syncRespInnerFrame.isValidate()) { |
| | | SpringContextHolder.getBean(PlcService.class).timeSynchronizationInitiative(deviceName, syncRespInnerFrame.getDestinationAddress()); |
| | | } |
| | | |
| | | } else if (A7PlcReportEnum.Error_Code.getCode().equals(functionCode)) { |
| | | log.error("æ
éç 䏿¥"); |
| | | A7PlcErrorCodeReportInnerFrame codeRespInnerFrame = new A7PlcErrorCodeReportInnerFrame().transformFrame(frame.getPayload()); |
| | | log.error(codeRespInnerFrame.isValidate() + "æ¯å¦éè¿æ ¡éª"); |
| | | log.error(codeRespInnerFrame.getErrorCode() + "æ
éç "); |
| | | if (codeRespInnerFrame.isValidate()) { |
| | | SpringContextHolder.getBean(PlcReportErrorService.class).saveReportError(deviceName, codeRespInnerFrame); |
| | | } |
| | | // 0000 表示没ææ
éï¼å鿏
餿
éæä»¤ |
| | | if (codeRespInnerFrame.getErrorCode() == 0) { |
| | | System.out.println("æ¸
餿
éæä½!"); |
| | | SpringContextHolder.getBean(PlcReportErrorService.class).saveReportError(deviceName, codeRespInnerFrame); |
| | | SpringContextHolder.getBean(LightReportErrorService.class).cleanErrorCode(deviceName, codeRespInnerFrame.getDestinationAddress()); |
| | | } |
| | | } else if (A7PlcReportEnum.Manual_LightSwitch_Request.getCode().equals(functionCode)){ |
| | | A7PlcManualLightSwitchReportInnerFrame syncRespInnerFrame = new A7PlcManualLightSwitchReportInnerFrame().transformFrame(frame.getPayload()); |
| | | if (syncRespInnerFrame.isValidate()) { |
| | | Plc plc = SpringContextHolder.getBean(PlcService.class).getPlc(deviceName); |
| | | String responseStatus = syncRespInnerFrame.getResponseStatus(); |
| | | if (plc != null) { |
| | | // æå¨å¼å
³å¨ä½ä¸æ¥ã0x00-å
¨å
³ï¼0x64-å
¨å¼ |
| | | if (responseStatus.equals("00")){ |
| | | plc.setPlcLight1(0); |
| | | plc.setPlcLight2(0); |
| | | plc.setPlcLight3(0); |
| | | } else if (responseStatus.equals("64")) { |
| | | plc.setPlcLight1(1); |
| | | plc.setPlcLight2(1); |
| | | plc.setPlcLight3(1); |
| | | } |
| | | SpringContextHolder.getBean(PlcService.class).updateById(plc); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame; |
| | | |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.IRequestInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.FunctionCodeEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.MQTTConnectTypeEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.SupplementUtils; |
| | | |
| | | /** |
| | | * @author van |
| | | * A7 åè½å°è£
ç帧 |
| | | */ |
| | | public class A7Frame extends BaseRequestFrame { |
| | | |
| | | private String orderType; |
| | | private String payloadLength; |
| | | private String payload; |
| | | |
| | | public A7Frame(String orderType, IRequestInnerFrame innerFrame) { |
| | | this.orderType = orderType; |
| | | this.payloadLength = SupplementUtils.suppleZero(Integer.toHexString((innerFrame.getEncodeFrame().length() / 2)).toUpperCase(), 4); |
| | | this.payload = innerFrame.getEncodeFrame(); |
| | | } |
| | | |
| | | @Override |
| | | public String getConnectType() { |
| | | return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode(); |
| | | } |
| | | |
| | | @Override |
| | | public String getFunctionCode() { |
| | | return FunctionCodeEnum.PLC.getCode(); |
| | | } |
| | | |
| | | @Override |
| | | public String getOrderType() { |
| | | return orderType; |
| | | } |
| | | |
| | | @Override |
| | | public String getPayloadLength() { |
| | | return payloadLength; |
| | | } |
| | | |
| | | @Override |
| | | public String getPayload() { |
| | | return payload; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | // return "A5Frame{" + |
| | | // "orderType='" + orderType + '\'' + |
| | | // ", payloadLength='" + payloadLength + '\'' + |
| | | // ", payload='" + payload + '\'' + |
| | | // '}'; |
| | | return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() |
| | | + FunctionCodeEnum.PLC.getCode() |
| | | + orderType + payloadLength + payload; |
| | | } |
| | | } |
| | |
| | | public static FrameBuilder builderA5() { |
| | | return new FrameBuilder(FunctionCodeEnum.DATA_TRANSPORT_DATA.getCode()); |
| | | } |
| | | public static FrameBuilder builderA7() { |
| | | return new FrameBuilder(FunctionCodeEnum.PLC.getCode()); |
| | | } |
| | | |
| | | public FrameBuilder orderType(String orderType) { |
| | | this.orderType = orderType; |
| | |
| | | iRequestFrame = new A2Frame(orderType, innerFrame); |
| | | } else if (FunctionCodeEnum.DATA_TRANSPORT_DATA.getCode().equals(functionCode)) { |
| | | iRequestFrame = new A5Frame(orderType, innerFrame); |
| | | } else if (FunctionCodeEnum.PLC.getCode().equals(functionCode)) { |
| | | iRequestFrame = new A7Frame(orderType, innerFrame); |
| | | } else { |
| | | throw new RuntimeException("æ¾ä¸å°ç¬¦åæ¡ä»¶ç请æ±å¸§"); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame.inner.report; |
| | | |
| | | import cn.hutool.core.util.HexUtil; |
| | | 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 van |
| | | * A7-81-42 |
| | | * PLC䏿¥ampq æ
éç |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A7PlcErrorCodeReportInnerFrame extends BaseResponseInnerFrame<A7PlcErrorCodeReportInnerFrame> { |
| | | |
| | | /** |
| | | * ç®æ å°å 2 |
| | | */ |
| | | private String destinationAddress; |
| | | /** |
| | | * æ
éç |
| | | */ |
| | | private Long errorCode; |
| | | |
| | | @Override |
| | | public A7PlcErrorCodeReportInnerFrame transformFrame(String hex) { |
| | | if (StrUtil.isBlank(hex) || hex.length() != 36) { |
| | | System.out.println("hex is blank or length is not 32"); |
| | | 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)); |
| | | |
| | | String errorCodeHex = hex.substring(12, 28); |
| | | errorCode = HexUtil.hexToLong(errorCodeHex); |
| | | System.out.println("æ
éç ï¼" + errorCodeHex + " - " + errorCode); |
| | | |
| | | setCrc32(hex.substring(hex.length() - 8)); |
| | | // æ ¡éªCRC32 |
| | | String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + errorCodeHex; |
| | | this.setValidate(CRC32Utils.validateFrame(frame, getCrc32())); |
| | | return this; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame.inner.report; |
| | | |
| | | import cn.hutool.core.util.HexUtil; |
| | | import cn.hutool.core.util.NumberUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.IResponseInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | /** |
| | | * @author van |
| | | * A7-81-40 |
| | | * PLC读å¿è·³å
䏿¥ |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A7PlcHeartbeatReportInnerFrame extends BaseResponseInnerFrame<A7PlcHeartbeatReportInnerFrame> { |
| | | |
| | | // ç®æ å°å 2 |
| | | private String destinationAddress; |
| | | // å¿è·³å
æ°æ® 104 |
| | | private HeartBeatDataPackage heartBeatDataPackage; |
| | | |
| | | private String originFrame; |
| | | |
| | | @Override |
| | | public A7PlcHeartbeatReportInnerFrame 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)); |
| | | |
| | | setDestinationAddress(hex.substring(8, 12)); |
| | | |
| | | String heartBeatData = hex.substring(12, 172); |
| | | HeartBeatDataPackage heartBeatDataPackage = new HeartBeatDataPackage(); |
| | | heartBeatDataPackage.transformFrame(heartBeatData); |
| | | setHeartBeatDataPackage(heartBeatDataPackage); |
| | | |
| | | setCrc32(hex.substring( hex.length() - 8)); |
| | | // æ ¡éªCRC32 |
| | | String frame = hex.substring(2, hex.length() - 8); |
| | | this.setValidate(CRC32Utils.validateFrame(frame, getCrc32())); |
| | | return this; |
| | | } |
| | | |
| | | @Data |
| | | public static class HeartBeatDataPackage implements IResponseInnerFrame<HeartBeatDataPackage> { |
| | | // å¹´RTC 1 |
| | | private Integer year; |
| | | // æRTC 1 |
| | | private Integer month; |
| | | // æ¥RTC 1 |
| | | private Integer day; |
| | | // æ¶RTC 1 |
| | | private Integer hour; |
| | | // åRTC 1 |
| | | private Integer min; |
| | | // ç§RTC 1 |
| | | private Integer sec; |
| | | // è®¾å¤æ¸©åº¦ 2 1åèæ´æ°1åèå°æ° |
| | | private Double deviceTemperature; |
| | | //@ApiModelProperty("çµç½ç¸æ°(åãä¸ç¸)") |
| | | private Long phase; |
| | | //Aç¸çµå |
| | | //@ApiModelProperty("Aç¸çµå") |
| | | private Double voltageA; |
| | | //Bç¸çµå |
| | | //@ApiModelProperty("Bç¸çµå") |
| | | private Double voltageB; |
| | | //Bç¸çµå |
| | | //@ApiModelProperty("Bç¸çµå") |
| | | private Double voltageC; |
| | | //Aç¸çµæµ |
| | | //@ApiModelProperty("Aç¸çµæµ") |
| | | // @TableField(value = "electric_current_A") |
| | | private Double electricCurrentA; |
| | | //Bç¸çµæµ |
| | | //@ApiModelProperty("Bç¸çµæµ") |
| | | // @TableField(value = "electric_current_B") |
| | | private Double electricCurrentB; |
| | | //Cç¸çµæµ |
| | | //@ApiModelProperty("Cç¸çµæµ") |
| | | // @TableField(value = "electric_current_C") |
| | | private Double electricCurrentC; |
| | | //åç¸æååç |
| | | //@ApiModelProperty("åç¸æååç") |
| | | // @TableField(value = "active_power_All") |
| | | private Double activePowerAll; |
| | | //Aç¸æååç |
| | | //@ApiModelProperty("Aç¸æååç") |
| | | // @TableField(value = "active_power_A") |
| | | private Double activePowerA; |
| | | //Bç¸æååç |
| | | //@ApiModelProperty("Bç¸æååç") |
| | | // @TableField(value = "active_power_B") |
| | | private Double activePowerB; |
| | | //Cç¸æååç |
| | | //@ApiModelProperty("Cç¸æååç") |
| | | // @TableField(value = "active_power_C") |
| | | private Double activePowerC; |
| | | //åç¸æ ååç |
| | | //@ApiModelProperty("åç¸æ ååç") |
| | | // @TableField(value = "reactive_power_All") |
| | | private Double reactivePowerAll; |
| | | //Aç¸æ ååç |
| | | //@ApiModelProperty("Aç¸æ ååç") |
| | | // @TableField(value = "reactive_power_A") |
| | | private Double reactivePowerA; |
| | | //Bç¸æ ååç |
| | | //@ApiModelProperty("Bç¸æ ååç") |
| | | // @TableField(value = "reactive_power_B") |
| | | private Double reactivePowerB; |
| | | //Cç¸æ ååç |
| | | //@ApiModelProperty("Cç¸æ ååç") |
| | | // @TableField(value = "reactive_power_C") |
| | | private Double reactivePowerC; |
| | | //åç¸è§å¨åç |
| | | //@ApiModelProperty("åç¸è§å¨åç") |
| | | // @TableField(value = "apparent_power_All") |
| | | private Double apparentPowerAll; |
| | | //Aç¸è§å¨åç |
| | | //@ApiModelProperty("Aç¸è§å¨åç") |
| | | // @TableField(value = "apparent_power_A") |
| | | private Double apparentPowerA; |
| | | //Bç¸è§å¨åç |
| | | //@ApiModelProperty("Bç¸è§å¨åç") |
| | | // @TableField(value = "apparent_power_B") |
| | | private Double apparentPowerB; |
| | | //Cç¸è§å¨åç |
| | | //@ApiModelProperty("Cç¸è§å¨åç") |
| | | // @TableField(value = "apparent_power_C") |
| | | private Double apparentPowerC; |
| | | //åç¸åçå ç´ |
| | | //@ApiModelProperty("åç¸åçå ç´ ") |
| | | // @TableField(value = "power_factor_All") |
| | | private Double powerFactorAll; |
| | | //Aç¸åçå ç´ |
| | | //@ApiModelProperty("Aç¸åçå ç´ ") |
| | | // @TableField(value = "power_factor_A") |
| | | private Double powerFactorA; |
| | | //Bç¸åçå ç´ |
| | | //@ApiModelProperty("Bç¸åçå ç´ ") |
| | | // @TableField(value = "power_factor_B") |
| | | private Double powerFactorB; |
| | | //Cç¸åçå ç´ |
| | | //@ApiModelProperty("Cç¸åçå ç´ ") |
| | | // @TableField(value = "power_factor_C") |
| | | private Double powerFactorC; |
| | | //æ£åæåæ»çµé |
| | | //@ApiModelProperty("æ£åæåæ»çµé") |
| | | // @TableField(value = "total_positive_using_power") |
| | | private Double totalPositiveUsingPower; |
| | | //ååæåæ»çµé |
| | | //@ApiModelProperty("ååæåæ»çµé") |
| | | // @TableField(value = "total_reverse_using_power") |
| | | private Double totalReverseUsingPower; |
| | | //å
å¼ºå¼ |
| | | //@ApiModelProperty("å
强å¼") |
| | | // @TableField(value = "light_intensity") |
| | | private Long lightIntensity; |
| | | //0æ¶æ§/1å
æ§ |
| | | //@ApiModelProperty("0æ¶æ§/1å
æ§") |
| | | // @TableField(value = "control_1") |
| | | private Long control1; |
| | | //0å
³/64å¼ |
| | | //@ApiModelProperty("0å
³/64å¼") |
| | | // @TableField(value = "status_1") |
| | | private Long status1; |
| | | //0æ¶æ§/1å
æ§ |
| | | //@ApiModelProperty("0æ¶æ§/1å
æ§") |
| | | // @TableField(value = "control_2") |
| | | private Long control2; |
| | | //0å
³/64å¼ |
| | | //@ApiModelProperty("0å
³/64å¼") |
| | | // @TableField(value = "status_2") |
| | | private Long status2; |
| | | //0æ¶æ§/1å
æ§ |
| | | //@ApiModelProperty("0æ¶æ§/1å
æ§") |
| | | // @TableField(value = "control_3") |
| | | private Long control3; |
| | | //0å
³/64å¼ |
| | | //@ApiModelProperty("0å
³/64å¼") |
| | | // @TableField(value = "status_3") |
| | | private Long status3; |
| | | //0æ¶æ§/1å
æ§ |
| | | //@ApiModelProperty("0æ¶æ§/1å
æ§") |
| | | // @TableField(value = "control_n") |
| | | private Long controlN; |
| | | //0å
³/64å¼ |
| | | //@ApiModelProperty("0å
³/64å¼") |
| | | // @TableField(value = "status_n") |
| | | private Long statusN; |
| | | |
| | | // ä¿ç 14 |
| | | private String retain; |
| | | // å帧 |
| | | private String originFrame; |
| | | |
| | | @Override |
| | | public HeartBeatDataPackage transformFrame(String hex) { |
| | | this.originFrame = hex; |
| | | this.year = HexUtil.hexToInt(hex.substring(0, 2)); |
| | | this.month = HexUtil.hexToInt(hex.substring(2, 4)); |
| | | this.day = HexUtil.hexToInt(hex.substring(4, 6)); |
| | | this.hour = HexUtil.hexToInt(hex.substring(6, 8)); |
| | | this.min = HexUtil.hexToInt(hex.substring(8, 10)); |
| | | this.sec = HexUtil.hexToInt(hex.substring(10, 12)); |
| | | |
| | | // //éè¦æåå
è¿å¶è½¬äºè¿å¶ |
| | | this.deviceTemperature = NumberUtil.round(temperatureTransition(hex.substring(12, 16)), 2).doubleValue(); |
| | | this.phase = Long.valueOf(HexUtil.hexToInt(hex.substring(16, 18))); |
| | | this.voltageA = NumberUtil.round(HexUtil.hexToInt(hex.substring(18, 22)) * 0.1, 1).doubleValue(); |
| | | this.voltageB = NumberUtil.round(HexUtil.hexToInt(hex.substring(22, 26)) * 0.1, 1).doubleValue(); |
| | | this.voltageC = NumberUtil.round(HexUtil.hexToInt(hex.substring(26, 30)) * 0.1, 1).doubleValue(); |
| | | this.electricCurrentA = NumberUtil.round(HexUtil.hexToInt(hex.substring(30, 34)) * 0.01, 2).doubleValue(); |
| | | this.electricCurrentB = NumberUtil.round(HexUtil.hexToInt(hex.substring(34, 38)) * 0.01, 2).doubleValue(); |
| | | this.electricCurrentC = NumberUtil.round(HexUtil.hexToInt(hex.substring(38, 42)) * 0.01, 2).doubleValue(); |
| | | this.activePowerAll = NumberUtil.round(HexUtil.hexToInt(hex.substring(42, 46)) * 1.00, 2).doubleValue(); |
| | | this.activePowerA = NumberUtil.round(HexUtil.hexToInt(hex.substring(46, 50)) * 1.00, 2).doubleValue(); |
| | | this.activePowerB = NumberUtil.round(HexUtil.hexToInt(hex.substring(50, 54)) * 1.00, 2).doubleValue(); |
| | | this.activePowerC = NumberUtil.round(HexUtil.hexToInt(hex.substring(54, 58)) * 1.00, 2).doubleValue(); |
| | | this.reactivePowerAll = NumberUtil.round(HexUtil.hexToInt(hex.substring(58, 62)) * 1.00, 2).doubleValue(); |
| | | this.reactivePowerA = NumberUtil.round(HexUtil.hexToInt(hex.substring(62, 66)) * 1.00, 2).doubleValue(); |
| | | this.reactivePowerB = NumberUtil.round(HexUtil.hexToInt(hex.substring(66, 70)) * 1.00, 2).doubleValue(); |
| | | this.reactivePowerC = NumberUtil.round(HexUtil.hexToInt(hex.substring(70, 74)) * 1.00, 2).doubleValue(); |
| | | this.apparentPowerAll = NumberUtil.round(HexUtil.hexToInt(hex.substring(74, 78)) * 1.00, 2).doubleValue(); |
| | | this.apparentPowerA = NumberUtil.round(HexUtil.hexToInt(hex.substring(78, 82)) * 1.00, 2).doubleValue(); |
| | | this.apparentPowerB = NumberUtil.round(HexUtil.hexToInt(hex.substring(82, 86)) * 1.00, 2).doubleValue(); |
| | | this.apparentPowerC = NumberUtil.round(HexUtil.hexToInt(hex.substring(86, 90)) * 1.00, 2).doubleValue(); |
| | | this.powerFactorAll = NumberUtil.round(HexUtil.hexToInt(hex.substring(90, 94)) * 0.001, 3).doubleValue(); |
| | | this.powerFactorA = NumberUtil.round(HexUtil.hexToInt(hex.substring(94, 98)) * 0.001, 3).doubleValue(); |
| | | this.powerFactorB = NumberUtil.round(HexUtil.hexToInt(hex.substring(98, 102)) * 0.001, 3).doubleValue(); |
| | | this.powerFactorC = NumberUtil.round(HexUtil.hexToInt(hex.substring(102, 106)) * 0.001, 3).doubleValue(); |
| | | |
| | | this.totalPositiveUsingPower = NumberUtil.round(HexUtil.hexToLong(hex.substring(106, 114)) * 0.01, 2).doubleValue(); |
| | | this.totalReverseUsingPower = NumberUtil.round(HexUtil.hexToLong(hex.substring(114, 122)) * 0.01, 2).doubleValue(); |
| | | |
| | | this.lightIntensity = (long) HexUtil.hexToInt(hex.substring(122, 128)); |
| | | |
| | | |
| | | this.control1 = (long) HexUtil.hexToInt(hex.substring(128, 130)); |
| | | this.status1 = (long) HexUtil.hexToInt(hex.substring(130, 132)); |
| | | this.control2 = (long) HexUtil.hexToInt(hex.substring(132, 134)); |
| | | this.status2 = (long) HexUtil.hexToInt(hex.substring(134, 136)); |
| | | this.control3 = (long) HexUtil.hexToInt(hex.substring(136, 138)); |
| | | this.status3 = (long) HexUtil.hexToInt(hex.substring(138, 140)); |
| | | this.controlN = (long) HexUtil.hexToInt(hex.substring(140, 142)); |
| | | this.statusN = (long) HexUtil.hexToInt(hex.substring(142, 144)); |
| | | |
| | | this.retain = hex.substring(144, 160); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * å°16è¿å¶è½¬æ2è¿å¶ï¼è¿è¡è¡¥ç ï¼åç åºç¡ä¸+1ï¼ï¼å¾å°æ£ç¡®æ°å¼ |
| | | * ä¼ å
¥16è¿å¶ç温度ï¼ç±»å为String |
| | | * å¦F500 |
| | | */ |
| | | public static Double temperatureTransition(String temperature) { |
| | | |
| | | //å°ä¼ è¿æ¥ç16è¿å¶ç转为2è¿å¶ |
| | | String twoBinStr = hexStr2BinStr(temperature); |
| | | |
| | | if ("1".equals(twoBinStr.substring(0, 1))) { |
| | | //æé«ä½æ¯1ï¼ä¸ºè´æ°,å°16è¿å¶çè¿è¡è¡¥ç ï¼è¿å |
| | | int max = 0b1111111111111111; |
| | | double result = (max-HexUtil.hexToInt(temperature))*(-0.01); |
| | | return result; |
| | | |
| | | } else if ("0".equals(twoBinStr.substring(0, 1))) { |
| | | //æé«ä½æ¯0ï¼æ£æ°ï¼ç´æ¥è¿å |
| | | double result = (HexUtil.hexToInt(temperature))*(0.01); |
| | | return result; |
| | | |
| | | } |
| | | // |
| | | return 0.00; |
| | | } |
| | | /** |
| | | * 16è¿å¶å符串转为äºè¿å¶ |
| | | * */ |
| | | public static String hexStr2BinStr(String hexStr) |
| | | { |
| | | if (hexStr == null || hexStr.length() % 2 != 0) |
| | | { |
| | | return null; |
| | | } |
| | | String bString = "", tmp; |
| | | for (int i = 0; i < hexStr.length(); i++) |
| | | { |
| | | tmp = "0000" + Integer.toBinaryString(Integer.parseInt(hexStr.substring(i, i + 1), 16)); |
| | | bString += tmp.substring(tmp.length() - 4); |
| | | } |
| | | return bString; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 van |
| | | * A7-81-44 |
| | | * PLC æå¨å¼å
³å¨ä½ä¸æ¥ã0x00-å
¨å
³ï¼0x64-å
¨å¼ |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A7PlcManualLightSwitchReportInnerFrame extends BaseResponseInnerFrame<A7PlcManualLightSwitchReportInnerFrame> { |
| | | |
| | | /** |
| | | * ç®æ å°å 2 |
| | | */ |
| | | private String destinationAddress; |
| | | /** |
| | | * 0x00-å
¨å
³ï¼0x64-å
¨å¼ |
| | | */ |
| | | private String responseStatus; |
| | | |
| | | @Override |
| | | public A7PlcManualLightSwitchReportInnerFrame 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, hex.length() - 8)); |
| | | setCrc32(hex.substring(hex.length() - 8)); |
| | | // æ ¡éªCRC32 |
| | | String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + getResponseStatus(); |
| | | this.setValidate(CRC32Utils.validateFrame(frame, getCrc32())); |
| | | return this; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 van |
| | | * PLCæä½æä»¤ååºå¸§ |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A7PlcOperationReportInnerFrame extends BaseResponseInnerFrame<A7PlcOperationReportInnerFrame> { |
| | | //MACå°å |
| | | private String address; |
| | | |
| | | private String state; |
| | | |
| | | @Override |
| | | public A7PlcOperationReportInnerFrame 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; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 van |
| | | * A7-81-41 |
| | | * PLC 䏿¥ampq è¯·æ±æ¶é´åæ¥ |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A7PlcTimeSyncReportInnerFrame extends BaseResponseInnerFrame<A7PlcTimeSyncReportInnerFrame> { |
| | | |
| | | /** |
| | | * ç®æ å°å 2 |
| | | */ |
| | | private String destinationAddress; |
| | | /** |
| | | * 0x00ï¼è¯·æ±åæ¥ |
| | | */ |
| | | private String responseStatus; |
| | | |
| | | @Override |
| | | public A7PlcTimeSyncReportInnerFrame 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, hex.length() - 8)); |
| | | setCrc32(hex.substring(hex.length() - 8)); |
| | | // æ ¡éªCRC32 |
| | | String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + getResponseStatus(); |
| | | this.setValidate(CRC32Utils.validateFrame(frame, getCrc32())); |
| | | return this; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.SupplementUtils; |
| | | |
| | | /** |
| | | * @author van |
| | | * A5->01->01 |
| | | * "å¼/å
³ç¯(å³äº®åº¦å¼ï¼ |
| | | * 0x00ï¼å
³ç¯ |
| | | * å
¶å®ï¼å¼ç¯&亮度å¼" |
| | | */ |
| | | public class A7PlcBrightnessReqInnerFrame implements IRequestInnerFrame { |
| | | |
| | | private final String payload; |
| | | |
| | | /** |
| | | * @param lightLevel 亮度ç级 [0,100] |
| | | */ |
| | | public A7PlcBrightnessReqInnerFrame(Integer lightLevel, String lightAddress) { |
| | | String destinationAddress; |
| | | if (lightAddress == null || (!lightAddress.equals("0001") && !lightAddress.equals("0002")) && !lightAddress.equals("0003")) { |
| | | destinationAddress = "FFFF"; |
| | | } else { |
| | | destinationAddress = lightAddress; |
| | | } |
| | | // å°æ´å亮度转æ¢ä¸ºHex |
| | | if (lightLevel <= 0) { |
| | | lightLevel = 0; |
| | | } else { |
| | | lightLevel = 100; |
| | | } |
| | | payload = destinationAddress + SupplementUtils.suppleZero(Integer.toHexString(lightLevel).toUpperCase(), 2); |
| | | } |
| | | |
| | | @Override |
| | | public String getEncodeFrame() { |
| | | String functionCode = A5LightDataEnum.LightControl.getCode(); |
| | | String payloadLength = "0003"; |
| | | String frame = functionCode + payloadLength + payload; |
| | | return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(frame.toUpperCase()); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.A7PlcDataEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.MQTTConnectTypeEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils; |
| | | |
| | | /** |
| | | * A7->01->29 æ
éç 䏿¥æ¸
é¤ |
| | | */ |
| | | public class A7PlcCleanErrorCodeInnerFrame implements IRequestInnerFrame { |
| | | //ç¯å¤´å°å |
| | | private String payload; |
| | | |
| | | public A7PlcCleanErrorCodeInnerFrame(String address) { |
| | | this.payload = address; |
| | | } |
| | | |
| | | @Override |
| | | public String getEncodeFrame() { |
| | | String functionCode = A7PlcDataEnum.PlcCleanErrorCode.getCode(); |
| | | String payloadLength = "0002"; |
| | | String frame = functionCode + payloadLength + payload; |
| | | return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(frame.toUpperCase()); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.A7PlcDataEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.MQTTConnectTypeEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils; |
| | | |
| | | |
| | | /** |
| | | * PLCå¿è·³å
|
| | | */ |
| | | public class A7PlcQueryHeartBeatDataReqInnerFrame implements IRequestInnerFrame { |
| | | |
| | | |
| | | private final String payload; |
| | | |
| | | |
| | | public A7PlcQueryHeartBeatDataReqInnerFrame() { |
| | | |
| | | String destinationAddress = "FFFF"; |
| | | |
| | | payload = destinationAddress ; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getEncodeFrame() { |
| | | String functionCode = A7PlcDataEnum.ReadHeartBeatData.getCode(); |
| | | String payloadLength = "0002"; |
| | | String frame = functionCode + payloadLength + payload; |
| | | return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(frame.toUpperCase()); |
| | | |
| | | } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.A7PlcDataEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.MQTTConnectTypeEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils; |
| | | |
| | | |
| | | /** |
| | | * åç¯å¿è·³å
é´éæ¥è¯¢ |
| | | */ |
| | | public class A7PlcQueryHeartBeatTimeReqInnerFrame implements IRequestInnerFrame { |
| | | |
| | | |
| | | private final String payload; |
| | | |
| | | |
| | | public A7PlcQueryHeartBeatTimeReqInnerFrame() { |
| | | |
| | | String destinationAddress = "FFFF"; |
| | | |
| | | payload = destinationAddress ; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getEncodeFrame() { |
| | | String functionCode = A7PlcDataEnum.ReadHeartBeatTime.getCode(); |
| | | String payloadLength = "0002"; |
| | | String frame = functionCode + payloadLength + payload; |
| | | return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(frame.toUpperCase()); |
| | | |
| | | } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.A7PlcDataEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.MQTTConnectTypeEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils; |
| | | |
| | | |
| | | /** |
| | | * PLCçæ¬ |
| | | */ |
| | | public class A7PlcQueryVersionReqInnerFrame implements IRequestInnerFrame { |
| | | |
| | | |
| | | private final String payload; |
| | | |
| | | |
| | | public A7PlcQueryVersionReqInnerFrame() { |
| | | |
| | | String destinationAddress = "FFFF"; |
| | | |
| | | payload = destinationAddress ; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getEncodeFrame() { |
| | | String functionCode = A7PlcDataEnum.ReadVersion.getCode(); |
| | | String payloadLength = "0002"; |
| | | String frame = functionCode + payloadLength + payload; |
| | | return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(frame.toUpperCase()); |
| | | |
| | | } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.A7PlcDataEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.MQTTConnectTypeEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils; |
| | | |
| | | /** |
| | | * @author van |
| | | * A7->01->2A PLC软éå¯ |
| | | */ |
| | | public class A7PlcRebootReqInnerFrame implements IRequestInnerFrame { |
| | | @Override |
| | | public String getEncodeFrame() { |
| | | String functionCode = A7PlcDataEnum.PlcReboot.getCode(); |
| | | String payloadLength = "0002"; |
| | | String payload = "FFFF"; |
| | | String frame = functionCode + payloadLength + payload; |
| | | return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(frame.toUpperCase()); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.A7PlcDataEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.MQTTConnectTypeEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils; |
| | | |
| | | /** |
| | | * @author van |
| | | * A7->01->2A PLCæ¢å¤åºå设置 |
| | | */ |
| | | public class A7PlcResetReqInnerFrame implements IRequestInnerFrame { |
| | | @Override |
| | | public String getEncodeFrame() { |
| | | String functionCode = A7PlcDataEnum.PlcReset.getCode(); |
| | | String payloadLength = "0002"; |
| | | String payload = "FFFF"; |
| | | String frame = functionCode + payloadLength + payload; |
| | | return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(frame.toUpperCase()); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.A7PlcDataEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.MQTTConnectTypeEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils; |
| | | |
| | | /** |
| | | * PLC设置æ¥å |
| | | * @author van |
| | | */ |
| | | public class A7PlcSetCalendarReqInnerFrame implements IRequestInnerFrame { |
| | | private final String payload; |
| | | |
| | | public A7PlcSetCalendarReqInnerFrame(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 = A7PlcDataEnum.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); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame.inner.request; |
| | | |
| | | import cn.hutool.core.util.HexUtil; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.IRequestInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A7PlcDataEnum; |
| | | 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; |
| | | |
| | | |
| | | /** |
| | | * åç¯å¿è·³å
设置 |
| | | */ |
| | | public class A7PlcSettingHeartBeatTimeReqInnerFrame implements IRequestInnerFrame { |
| | | |
| | | |
| | | private final String payload; |
| | | |
| | | |
| | | public A7PlcSettingHeartBeatTimeReqInnerFrame(Integer sec) { |
| | | String secHex; |
| | | String destinationAddress = "FFFF"; |
| | | if(sec < HexUtil.hexToInt("FFFF")) { |
| | | secHex = HexUtil.toHex(sec); |
| | | }else { |
| | | secHex = "FFFF"; |
| | | } |
| | | |
| | | payload = destinationAddress + SupplementUtils.suppleZero(Integer.toHexString(sec).toUpperCase(), 4); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getEncodeFrame() { |
| | | String functionCode = A7PlcDataEnum.SetHeartBeatTime.getCode(); |
| | | String payloadLength = "0004"; |
| | | String frame = functionCode + payloadLength + payload; |
| | | return MQTTConnectTypeEnum.SYNCHRONIZATION.getCode() + frame.toUpperCase() + CRC32Utils.getCRC32(frame.toUpperCase()); |
| | | |
| | | } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.A7PlcDataEnum; |
| | | 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 van |
| | | * A7->01->23 |
| | | * 宿¶æ§ç¯ |
| | | * 0x00ï¼å
³ç¯ |
| | | * å
¶å®ï¼å¼ç¯&亮度å¼" |
| | | */ |
| | | public class A7PlcTimerReqInnerFrame implements IRequestInnerFrame { |
| | | |
| | | private final String payload; |
| | | private final String functionCode = A7PlcDataEnum.PlcTimer.getCode(); |
| | | private final String payloadLength; |
| | | |
| | | /** |
| | | * @param framePayload å¤ä¸ªè·¯ç¯å®æ¶æä»¤ï¼ |
| | | */ |
| | | public A7PlcTimerReqInnerFrame(String framePayload, String lightAddress) { |
| | | String destinationAddress; |
| | | if (lightAddress == null || (!lightAddress.equals("0001") && !lightAddress.equals("0002") && !lightAddress.equals("0003"))) { |
| | | destinationAddress = "FFFF"; |
| | | } else { |
| | | destinationAddress = lightAddress; |
| | | } |
| | | 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()); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | private String mac; |
| | | |
| | | /** |
| | | * 1åè 设å¤ç±»å 设å¤ç±»å00代表MQTT串å£ï¼01代表CAT1 |
| | | * 1åè 设å¤ç±»å 设å¤ç±»å00代表MQTT串å£ï¼01代表CAT1ï¼02代表PLC |
| | | */ |
| | | private String type; |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 van |
| | | * A7-81-01PLCæ§å¶ åºç |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A7PlcBrightnessRespInnerFrame extends BaseResponseInnerFrame<A7PlcBrightnessRespInnerFrame> { |
| | | |
| | | /** |
| | | * ç®æ å°å 2 |
| | | */ |
| | | private String destinationAddress; |
| | | /** |
| | | * PLCå¼å
³ç¶æ |
| | | */ |
| | | private String responseStatus; |
| | | |
| | | @Override |
| | | public A7PlcBrightnessRespInnerFrame 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; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame.inner.response; |
| | | |
| | | import cn.hutool.core.util.HexUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A7PlcHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.CRC32Utils; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | /** |
| | | * @author van |
| | | * A7-81-01PLCæ§å¶ åºç |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A7PlcQueryHeartBeatDataRespInnerFrame extends BaseResponseInnerFrame<A7PlcQueryHeartBeatDataRespInnerFrame> { |
| | | |
| | | /** |
| | | * ç®æ å°å 2 |
| | | */ |
| | | private String destinationAddress; |
| | | |
| | | private A7PlcHeartbeatReportInnerFrame heartbeatReportInnerFrame; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public A7PlcQueryHeartBeatDataRespInnerFrame 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)); |
| | | |
| | | setHeartbeatReportInnerFrame(new A7PlcHeartbeatReportInnerFrame().transformFrame(hex)); |
| | | |
| | | setCrc32(hex.substring(hex.length()-8)); |
| | | // æ ¡éªCRC32 |
| | | String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + hex.substring(12,hex.length()-8); |
| | | this.setValidate(CRC32Utils.validateFrame(frame, getCrc32())); |
| | | return this; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame.inner.response; |
| | | |
| | | import cn.hutool.core.util.HexUtil; |
| | | 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 van |
| | | * A7-81-01PLCæ§å¶ åºç |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A7PlcQueryHeartBeatTimeRespInnerFrame extends BaseResponseInnerFrame<A7PlcQueryHeartBeatTimeRespInnerFrame> { |
| | | |
| | | /** |
| | | * ç®æ å°å 2 |
| | | */ |
| | | private String destinationAddress; |
| | | |
| | | private String time; |
| | | |
| | | |
| | | @Override |
| | | public A7PlcQueryHeartBeatTimeRespInnerFrame 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)); |
| | | |
| | | setTime(String.valueOf(HexUtil.hexToInt(hex.substring(12, 16)))); |
| | | |
| | | setCrc32(hex.substring(16, 24)); |
| | | // æ ¡éªCRC32 |
| | | String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + getTime(); |
| | | this.setValidate(CRC32Utils.validateFrame(frame, getCrc32())); |
| | | return this; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame.inner.response; |
| | | |
| | | import cn.hutool.core.util.HexUtil; |
| | | 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 van |
| | | * A7-81-01PLCæ§å¶ åºç |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A7PlcQueryVersionRespInnerFrame extends BaseResponseInnerFrame<A7PlcQueryVersionRespInnerFrame> { |
| | | |
| | | /** |
| | | * ç®æ å°å 2 |
| | | */ |
| | | private String destinationAddress; |
| | | |
| | | |
| | | // ç¡¬ä»¶çæ¬ |
| | | private String hardwareVersion; |
| | | private Double hardwareVersionDouble; |
| | | // è½¯ä»¶çæ¬ |
| | | private String softwareVersion; |
| | | private Double softwareVersionDouble; |
| | | |
| | | @Override |
| | | public A7PlcQueryVersionRespInnerFrame 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)); |
| | | |
| | | this.hardwareVersion = hex.substring(12, 16); |
| | | this.hardwareVersionDouble = Double.parseDouble( |
| | | HexUtil.hexToInt(this.hardwareVersion.substring(0, 2)) |
| | | + "." + HexUtil.hexToInt(this.hardwareVersion.substring(2, 4)) |
| | | ); |
| | | this.softwareVersion = hex.substring(16,20); |
| | | this.softwareVersionDouble = Double.parseDouble( |
| | | HexUtil.hexToInt(this.softwareVersion.substring(0, 2)) |
| | | + "." + HexUtil.hexToInt(this.softwareVersion.substring(2, 4)) |
| | | ); |
| | | setCrc32(hex.substring(20, 28)); |
| | | // æ ¡éªCRC32 |
| | | String frame = getFunctionCode() + getPayloadLength() + getDestinationAddress() + getHardwareVersion() + getSoftwareVersion(); |
| | | this.setValidate(CRC32Utils.validateFrame(frame, getCrc32())); |
| | | return this; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 van |
| | | * A7-81-01PLCæ§å¶ åºç |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A7PlcResetRespInnerFrame extends BaseResponseInnerFrame<A7PlcResetRespInnerFrame> { |
| | | |
| | | /** |
| | | * ç®æ å°å 2 |
| | | */ |
| | | private String destinationAddress; |
| | | /** |
| | | * PLCå¼å
³ç¶æ |
| | | */ |
| | | private String responseStatus; |
| | | |
| | | @Override |
| | | public A7PlcResetRespInnerFrame 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; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 van |
| | | * A7-81-01PLCæ§å¶ åºç |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A7PlcRespInnerFrame extends BaseResponseInnerFrame<A7PlcRespInnerFrame> { |
| | | |
| | | /** |
| | | * ç®æ å°å 2 |
| | | */ |
| | | private String destinationAddress; |
| | | /** |
| | | * PLCå¼å
³ç¶æ |
| | | */ |
| | | private String responseStatus; |
| | | |
| | | @Override |
| | | public A7PlcRespInnerFrame 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; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 van |
| | | * A7-81-23ç¯å®æ¶ä»»å¡ åºç |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | public class A7PlcTimerRespInnerFrame extends BaseResponseInnerFrame<A7PlcTimerRespInnerFrame> { |
| | | |
| | | /** |
| | | * ç®æ å°å 2 |
| | | */ |
| | | private String destinationAddress; |
| | | /** |
| | | * ååºç¶æ 1 |
| | | */ |
| | | private String responseStatus; |
| | | |
| | | @Override |
| | | public A7PlcTimerRespInnerFrame 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; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.rrpc.enums; |
| | | |
| | | /** |
| | | * @author van |
| | | * 主å¤è®¾æ°æ®(A7)ä¸çå½ä»¤ |
| | | */ |
| | | public enum A7OrderEnum { |
| | | //-------------------------------------------- æå¡å¨ä¸å----------------------------------------------------// |
| | | /** |
| | | * 0x01:éä¸çº¿æ§å¨æ°æ®æä»¤ï¼åå·01ï¼ è´è·æ°æ®A |
| | | */ |
| | | REQUEST_PLC_DATA("01"), |
| | | |
| | | |
| | | |
| | | |
| | | //-------------------------------------------- 设å¤ä¸æ¥----------------------------------------------------// |
| | | // 0x01:éä¸çº¿æ§å¨æ°æ®æä»¤ï¼åå·01ï¼ è´è·æ°æ®A |
| | | RESPONSE_PLC_DATA("81"); |
| | | |
| | | |
| | | A7OrderEnum(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | private final String code; |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.rrpc.enums; |
| | | |
| | | /** |
| | | * @author van |
| | | * A7-01 Plcæ°æ®æä»¤ å表 |
| | | */ |
| | | public enum A7PlcDataEnum { |
| | | // åç¯æ§å¶ |
| | | PlcControl("01"), |
| | | // 宿¶æ§å¶ |
| | | TimingLightControl("02"), |
| | | // å
ææ§å¶ |
| | | PlcSensorControl("03"), |
| | | |
| | | // è¯»çæ¬ |
| | | ReadVersion("10"), |
| | | // 读å¿è·³å
æ¶é´ |
| | | ReadHeartBeatTime("11"), |
| | | // 读å¿è·³å
|
| | | ReadHeartBeatData("16"), |
| | | |
| | | SetHeartBeatTime("21"), |
| | | //è®¾ç½®å®æ¶æ§ç¯åæ° |
| | | PlcTimer("23"), |
| | | // éå¯ |
| | | Reboot("25"), |
| | | //设置æ¥åï¼åå¿è·³å
ä¸ç6åèæ¥ææ¶é´ï¼ |
| | | SetCalendar("28"), |
| | | //æ
éç 䏿¥æ¸
é¤ |
| | | PlcCleanErrorCode("29"), |
| | | |
| | | PlcReset("2A"), |
| | | PlcReboot("26"), |
| | | PLC_HEART_BEAT("PlcReportData:plc_heart_beat/"); |
| | | |
| | | A7PlcDataEnum(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | private final String code; |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.rrpc.enums; |
| | | |
| | | /** |
| | | * @author van |
| | | * A5-81 PLC主å¨ä¸æ¥ï¼ï¼amqpï¼ |
| | | */ |
| | | public enum A7PlcReportEnum { |
| | | // 䏿¥å¿è·³å
|
| | | HeartBeat_Data("40"), |
| | | // è¯·æ±æ¶é´åæ¥ |
| | | Time_Synchronized("41"), |
| | | // æ
éç |
| | | Error_Code("42"), |
| | | // æ¬å°å®æ¶/å
æ§å¼å
³ç¯å¨ä½ä¸æ¥ |
| | | Timing_LightSwitch_Report("43"), |
| | | // æå¨å¼å
³å¨ä½ä¸æ¥ã0x00-å
¨å
³ï¼0x64-å
¨å¼ |
| | | Manual_LightSwitch_Request("44"); |
| | | |
| | | |
| | | A7PlcReportEnum(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | private final String code; |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | } |
| | |
| | | /** |
| | | * å¤è®¾æ°æ® ç¨äºå¤è®¾æ°æ®ä¼ è¾ä½¿ç¨æ¥å£ |
| | | */ |
| | | DATA_TRANSPORT_DATA("A5"); |
| | | DATA_TRANSPORT_DATA("A5"), |
| | | |
| | | /** |
| | | * PLC |
| | | */ |
| | | PLC("A7"); |
| | | |
| | | private final String code; |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.rrpc.enums; |
| | | |
| | | /** |
| | | * @author van |
| | | * PLCéè¯¯ä¸æ¥ç |
| | | * "æ
éç ï¼ï¼ç¨äºè¿å¶è¡¨ç¤ºï¼ |
| | | * 0x00000000,0x00000000 äºè¿å¶å³ä¸º[bit64:bit0]ã |
| | | ä½ï¼ibtï¼ æ
éç å®ä¹ 夿³¨ |
| | | 0 ç½ç»ä¸ç¨³å®/4Gä¿¡å·å¼± |
| | | 1 è®¾å¤æ¸©åº¦è¿é« ï¼éå¼åºå®è®¾ä¸º80åº¦ï¼ |
| | | 2 éä¸çº¿æ§å¨EEPROMæ
é |
| | | 3 éä¸çº¿æ§å¨RTCæ
é |
| | | 4 Aç¸å¤±å |
| | | 5 Aç¸æ¬ å æ çµæµ |
| | | 6 Aç¸è¿å ç¼ºç¸ |
| | | 7 Aç¸å¤±æµ çµæµåå |
| | | 8 Aç¸è¿æµ |
| | | 9 Aç¸è¿è½½ |
| | | 10 Aç¸æ½®æµåå çµæµè¿ä½ |
| | | 11 Aç¸æç¸ |
| | | 12 Aç¸ææµ çµåè¿ä½ |
| | | 13 Aç¸æåçè´å¼ æ çµå |
| | | 14 Aç¸æ¼çµ ä¸ç¸å线å¼ï¼ç«é¶é´çæµ |
| | | 15 Bç¸å¤±å |
| | | 16 Bç¸æ¬ å |
| | | 17 Bç¸è¿å |
| | | 18 Bç¸å¤±æµ |
| | | 19 Bç¸è¿æµ |
| | | 20 Bç¸è¿è½½ |
| | | 21 Bç¸æ½®æµåå |
| | | 22 Bç¸æç¸ |
| | | 23 Bç¸ææµ |
| | | 24 Bç¸æåçè´å¼ |
| | | 25 Bç¸æ¼çµ |
| | | 26 Cç¸å¤±å |
| | | 27 Cç¸æ¬ å |
| | | 28 Cç¸è¿å |
| | | 29 Cç¸å¤±æµ |
| | | 30 Cç¸è¿æµ |
| | | 31 Cç¸è¿è½½ |
| | | 32 Cç¸æ½®æµåå |
| | | 33 Cç¸æç¸ |
| | | 34 Cç¸ææµ |
| | | 35 Cç¸æåçè´å¼ |
| | | 36 Cç¸æ¼çµ |
| | | 37 çµé计模åæ
é æ¨¡åèªèº«æ¥æ
é |
| | | 38 å
ä¼ æå¨æ
é æ æ°å¼/æ°å¼é误 |
| | | 39 éä¸çº¿æ§å¨æçµ |
| | | |
| | | 40 é
çµç®±é¨è¢«æå¼ |
| | | 41 第1è·¯å¼å
³éææ
é |
| | | 42 第2è·¯å¼å
³éææ
é |
| | | 43 第3è·¯å¼å
³éææ
é |
| | | 44 第4è·¯å¼å
³éææ
é |
| | | 45 第5è·¯å¼å
³éææ
é |
| | | 46 第6è·¯å¼å
³éææ
é |
| | | |
| | | "48 |
| | | . |
| | | . |
| | | . |
| | | . |
| | | 63" å¤ç¨ |
| | | */ |
| | | public enum PlcErrorEnum { |
| | | |
| | | |
| | | /* |
| | | 0 ç½ç»ä¸ç¨³å®/4Gä¿¡å·å¼± |
| | | 1 è®¾å¤æ¸©åº¦è¿é« ï¼éå¼åºå®è®¾ä¸º80åº¦ï¼ |
| | | 2 éä¸çº¿æ§å¨EEPROMæ
é |
| | | 3 éä¸çº¿æ§å¨RTCæ
é |
| | | 4 Aç¸å¤±å |
| | | 5 Aç¸æ¬ å æ çµæµ |
| | | 6 Aç¸è¿å ç¼ºç¸ |
| | | 7 Aç¸å¤±æµ çµæµåå |
| | | 8 Aç¸è¿æµ |
| | | 9 Aç¸è¿è½½*/ |
| | | E0(1,"ç½ç»ä¸ç¨³å®/4Gä¿¡å·å¼±"), |
| | | E1(2,"è®¾å¤æ¸©åº¦è¿é«"), |
| | | E2(2<<1,"éä¸çº¿æ§å¨EEPROMæ
é"), |
| | | E3(2<<2,"éä¸çº¿æ§å¨RTCæ
é"), |
| | | E4(2<<3,"Aç¸å¤±å"), |
| | | E5(2<<4,"Aç¸æ¬ å"), |
| | | E6(2<<5,"Aç¸è¿å"), |
| | | E7(2<<6,"Aç¸å¤±æµ"), |
| | | E8(2<<7,"Aç¸è¿æµ"), |
| | | E9(2<<8,"Aç¸è¿è½½"), |
| | | /* |
| | | 10 Aç¸æ½®æµåå çµæµè¿ä½ |
| | | 11 Aç¸æç¸ |
| | | 12 Aç¸ææµ çµåè¿ä½ |
| | | 13 Aç¸æåçè´å¼ æ çµå |
| | | 14 Aç¸æ¼çµ ä¸ç¸å线å¼ï¼ç«é¶é´çæµ |
| | | 15 Bç¸å¤±å |
| | | 16 Bç¸æ¬ å |
| | | 17 Bç¸è¿å |
| | | 18 Bç¸å¤±æµ |
| | | 19 Bç¸è¿æµ*/ |
| | | E10(2<<9,"Aç¸æ½®æµåå"), |
| | | E11(2<<10,"Aç¸æç¸"), |
| | | E12(2<<11,"Aç¸ææµ"), |
| | | E13(2<<12,"Aç¸æåçè´å¼"), |
| | | E14(2<<13,"Aç¸æ¼çµ"), |
| | | E15(2<<14,"Bç¸å¤±å"), |
| | | E16(2<<15,"Bç¸æ¬ å"), |
| | | E17(2<<16,"Bç¸è¿å"), |
| | | E18(2<<17,"Bç¸å¤±æµ"), |
| | | E19(2<<18,"Bç¸è¿æµ"), |
| | | /* |
| | | 20 Bç¸è¿è½½ |
| | | 21 Bç¸æ½®æµåå |
| | | 22 Bç¸æç¸ |
| | | 23 Bç¸ææµ |
| | | 24 Bç¸æåçè´å¼ |
| | | 25 Bç¸æ¼çµ |
| | | 26 Cç¸å¤±å |
| | | 27 Cç¸æ¬ å |
| | | 28 Cç¸è¿å |
| | | 29 Cç¸å¤±æµ |
| | | * */ |
| | | E20(2<<19,"Bç¸è¿è½½"), |
| | | E21(2<<20,"Bç¸æ½®æµåå"), |
| | | E22(2<<21,"Bç¸æç¸"), |
| | | E23(2<<22,"Bç¸ææµ"), |
| | | E24(2<<23,"Bç¸æåçè´å¼"), |
| | | E25(2<<24,"Bç¸æ¼çµ"), |
| | | E26(2<<25,"Cç¸å¤±å"), |
| | | E27(2<<26,"Cç¸æ¬ å"), |
| | | E28(2<<27,"Cç¸è¿å"), |
| | | E29(2<<28,"Cç¸å¤±æµ"), |
| | | /* |
| | | 30 Cç¸è¿æµ |
| | | 31 Cç¸è¿è½½ |
| | | 32 Cç¸æ½®æµåå |
| | | 33 Cç¸æç¸ |
| | | 34 Cç¸ææµ |
| | | 35 Cç¸æåçè´å¼ |
| | | 36 Cç¸æ¼çµ |
| | | 37 çµé计模åæ
é æ¨¡åèªèº«æ¥æ
é |
| | | 38 å
ä¼ æå¨æ
é æ æ°å¼/æ°å¼é误 |
| | | 39 éä¸çº¿æ§å¨æçµ |
| | | * */ |
| | | E30(2<<29,"Cç¸è¿æµ"), |
| | | E31(2<<30,"Cç¸è¿è½½"), |
| | | E32(2<<31,"Cç¸æ½®æµåå"), |
| | | E33(2<<32,"Cç¸æç¸"), |
| | | E34(2<<33,"Cç¸ææµ"), |
| | | E35(2<<34,"Cç¸æåçè´å¼"), |
| | | E36(2<<35,"Cç¸æ¼çµ"), |
| | | E37(2<<36,"çµé计模åæ
é"), |
| | | E38(2<<37,"å
ä¼ æå¨æ
é"), |
| | | E39(2<<38,"éä¸çº¿æ§å¨æçµ"), |
| | | /* |
| | | 40 é
çµç®±é¨è¢«æå¼ |
| | | 41 第1è·¯å¼å
³éææ
é |
| | | 42 第2è·¯å¼å
³éææ
é |
| | | 43 第3è·¯å¼å
³éææ
é |
| | | 44 第4è·¯å¼å
³éææ
é |
| | | 45 第5è·¯å¼å
³éææ
é |
| | | 46 第6è·¯å¼å
³éææ
é |
| | | |
| | | * */ |
| | | E40(2<<39,"é
çµç®±é¨è¢«æå¼"), |
| | | E41(2<<40,"第1è·¯å¼å
³éææ
é"), |
| | | E42(2<<41,"第2è·¯å¼å
³éææ
é"), |
| | | E43(2<<42,"第3è·¯å¼å
³éææ
é"), |
| | | E44(2<<43,"第4è·¯å¼å
³éææ
é"), |
| | | E45(2<<44,"第5è·¯å¼å
³éææ
é"), |
| | | E46(2<<45,"第6è·¯å¼å
³éææ
é"); |
| | | private final Integer code; |
| | | private final String message; |
| | | |
| | | PlcErrorEnum(Integer code, String message) { |
| | | this.code = code; |
| | | this.message = message; |
| | | } |
| | | |
| | | public String getMessage() { |
| | | return message; |
| | | } |
| | | |
| | | public Integer getCode() { |
| | | return code; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.Max; |
| | | import javax.validation.constraints.Min; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * @author van |
| | | * @version 1.0 |
| | | * msgï¼ |
| | | * @date 2022/12/16 11:55 |
| | | */ |
| | | @Data |
| | | public class PlcControlParam { |
| | | @NotBlank(message = "设å¤ç ä¸è½ä¸ºç©º") |
| | | private String deviceCode; |
| | | |
| | | //åç¯å¤´æ§å¶åæ° |
| | | private String plcAddress = "FFFF"; |
| | | |
| | | |
| | | @NotNull(message = "亮度ä¸è½ä¸ºç©º") |
| | | @Min(value = 0, message = "亮度æå°ä¸º0") |
| | | @Max(value = 100, message = "亮度æå¤§ä¸º100") |
| | | private Integer brightness; |
| | | |
| | | @Min(value = 0, message = "heartBeatTimeæå°ä¸º0") |
| | | @Max(value = 3600, message = "heartBeatTimeæå¤§ä¸º3600") |
| | | private Integer heartBeatTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * @author van |
| | | * @version 1.0 |
| | | * msgï¼ |
| | | * @date 2022/12/16 11:38 |
| | | */ |
| | | @Data |
| | | public class PlcRemarkParam { |
| | | @NotNull(message = "plcIdä¸è½ä¸ºç©º") |
| | | private Long plcId; |
| | | @NotEmpty(message = "夿³¨ä¸è½ä¸ºç©º") |
| | | private String plcRemark; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * @author van |
| | | * è·¯ç¯ä»»å¡ |
| | | */ |
| | | @Data |
| | | public class PlcTaskDelParam { |
| | | |
| | | @NotNull(message = "ä»»å¡idä¸è½ä¸ºç©º") |
| | | private Long taskId; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * @author van |
| | | * è·¯ç¯ä¸åä»»å¡ |
| | | */ |
| | | @Data |
| | | public class PlcTaskIssueParam { |
| | | |
| | | @NotNull(message = "ä»»å¡idä¸è½ä¸ºç©º") |
| | | private Long taskId; |
| | | |
| | | @NotNull(message = "ç¯æidä¸è½ä¸ºç©º") |
| | | private Long poleId; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.param; |
| | | |
| | | import lombok.Data; |
| | | import org.hibernate.validator.constraints.Length; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author van |
| | | * PLCä»»å¡ |
| | | */ |
| | | @Data |
| | | public class PlcTaskParam { |
| | | |
| | | public static final int REQUEST_ORDER_LENGTH = 7; |
| | | /** |
| | | * ä»»å¡åç§° |
| | | */ |
| | | @NotBlank(message = "ä»»å¡åç§°ä¸è½ä¸ºç©º") |
| | | private String taskName; |
| | | |
| | | /** |
| | | * ææå ï¼ä½è¿ç®ä¿åï¼1代表ææä¸ï¼2ææäºï¼4ææä¸ï¼8ææåï¼16ææäºï¼32ææå
ï¼64æææ¥ |
| | | */ |
| | | @NotEmpty(message = "ææä¸è½ä¸ºç©º") |
| | | private List<Integer> weekList; |
| | | |
| | | |
| | | /** |
| | | * å¼ç¯å½ä»¤ |
| | | */ |
| | | @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 String plcAddress; |
| | | |
| | | private List<Long> poleIdList; |
| | | |
| | | |
| | | private Long taskId; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.db.PageResult; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | 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.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A7PlcHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5LightDataEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A7PlcDataEnum; |
| | | import com.sandu.ximon.admin.utils.RedisUtils; |
| | | import com.sandu.ximon.dao.bo.LightReportDataBo; |
| | | import com.sandu.ximon.dao.bo.PlcReportDataBo; |
| | | import com.sandu.ximon.dao.domain.*; |
| | | import com.sandu.ximon.dao.enums.OrderByEnums; |
| | | import com.sandu.ximon.dao.mapper.PlcReportDataMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * PLC䏿¥æ°æ®è¡¨(PlcReportData)表æå¡æ¥å£ |
| | | * |
| | | * @author van |
| | | * @since 2022-12-16 10:54:58 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class PlcReportDataService extends BaseServiceImpl<PlcReportDataMapper,PlcReportData> { |
| | | |
| | | private final PlcReportDataMapper plcReportDataMapper; |
| | | |
| | | // PageResult getPage(Integer currentPage, Integer size, PlcReportData plcReportData); |
| | | |
| | | |
| | | /** |
| | | * ä¿å䏿¥çPLCå¿è·³æ°æ® |
| | | * |
| | | * @return æ¯å¦æå |
| | | */ |
| | | public boolean saveReportData(String deviceName, A7PlcHeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage) { |
| | | |
| | | String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); |
| | | |
| | | PlcReportData plcReportData = new PlcReportData(); |
| | | |
| | | if (plcReportData == null) { |
| | | plcReportData = new PlcReportData(); |
| | | plcReportData.setCreateTime(format); |
| | | } |
| | | plcReportData.setCreateTime(format); |
| | | BeanUtils.copyProperties(heartBeatDataPackage, plcReportData); |
| | | plcReportData.setDeviceCode(deviceName); |
| | | |
| | | plcReportData.setUpdateTime(format); |
| | | //PLCæ°æ®ä¿åå°ç¼åé |
| | | RedisUtils.getBean().set(A7PlcDataEnum.PLC_HEART_BEAT.getCode() + deviceName, plcReportData); |
| | | |
| | | return save(plcReportData); |
| | | |
| | | |
| | | } |
| | | |
| | | List<PlcReportData> getNewestReportByDeviceCode(List<String> deviceCodeList){ |
| | | return baseMapper.getNewestReportByDeviceCode(deviceCodeList); |
| | | } |
| | | /** |
| | | * è·å䏿¥æ°æ® |
| | | * |
| | | * @param keyword å
³é®è¯ |
| | | * @param deviceCode 设å¤ç |
| | | */ |
| | | public CommonPage listReportData(int pageNo, int pageSize, String keyword, String deviceCode, Integer order, Integer seq) { |
| | | |
| | | List<PlcReportDataBo> plcReportDataBos = new ArrayList<>(pageSize); |
| | | //æåºå段 |
| | | String orderByResult = "t1.plc_create_time"; |
| | | //æ£åºãåå |
| | | String orderBySeq = OrderByEnums.ASC.getCode(); |
| | | if (order != null) { |
| | | switch (order) { |
| | | case 1: |
| | | orderByResult = OrderByEnums.PLC_DATA_CREATE_TIME.getCode(); |
| | | break; |
| | | default: |
| | | } |
| | | } |
| | | if (seq != null) { |
| | | switch (seq) { |
| | | case 1: |
| | | orderBySeq = " ASC"; |
| | | break; |
| | | case 2: |
| | | orderBySeq = " DESC"; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | //æåºæ¹å¼ |
| | | String orderBy = orderByResult + " " + orderBySeq; |
| | | CommonPage<String> stringCommonPage = SpringContextHolder.getBean(PlcService.class).listDeviceCode(pageNo, pageSize, keyword, deviceCode, orderBy); |
| | | List<String> macList = stringCommonPage.getList(); |
| | | if (CollUtil.isEmpty(macList)) { |
| | | return new CommonPage(); |
| | | } |
| | | for (String macCode : macList) { |
| | | try { |
| | | PlcReportData plcReportData |
| | | = JSON.parseObject(RedisUtils.getBean().get(A7PlcDataEnum.PLC_HEART_BEAT.getCode() + macCode), PlcReportData.class); |
| | | |
| | | PlcReportDataBo plcReportDataBo = new PlcReportDataBo(); |
| | | if (plcReportData != null) { |
| | | BeanUtils.copyProperties(plcReportData, plcReportDataBo); |
| | | } |
| | | plcReportDataBo.setDeviceCode(macCode); |
| | | Pole pole = SpringContextHolder.getBean(PoleService.class).getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, macCode)); |
| | | if (pole != null) { |
| | | plcReportDataBo.setPoleName(pole.getPoleName()); |
| | | } |
| | | plcReportDataBos.add(plcReportDataBo); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | CommonPage commonPage = CommonPage.restPage(plcReportDataBos); |
| | | commonPage.setTotal(stringCommonPage.getTotal()); |
| | | commonPage.setTotalPage(stringCommonPage.getTotalPage()); |
| | | commonPage.setPageNum(pageNo); |
| | | |
| | | return commonPage; |
| | | } |
| | | |
| | | public List<PlcReportData> getReportDataList(BaseConditionVO conditionVO, String macCode) { |
| | | if (macCode.isEmpty()) { |
| | | throw new BusinessException("macä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | Plc plc = SpringContextHolder.getBean(PlcService.class) |
| | | .getOne(Wrappers.lambdaQuery(Plc.class).eq(Plc::getDeviceCode, macCode)); |
| | | if (plc == null) { |
| | | throw new BusinessException("ç³»ç»ä¸ä¸åå¨è¯¥plc"); |
| | | } |
| | | PageHelper.startPage(conditionVO.getPageNo(), conditionVO.getPageSize()); |
| | | List<PlcReportData> list = list(Wrappers.lambdaQuery(PlcReportData.class).eq(PlcReportData::getDeviceCode, macCode).orderByDesc(PlcReportData::getReportDataId)); |
| | | list.forEach( |
| | | plcReportData -> { |
| | | plcReportData.setCreateTime(plcReportData.getCreateTime1().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | plcReportData.setUpdateTime(plcReportData.getUpdateTime1().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | } |
| | | ); |
| | | return list; |
| | | } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.domain.CommonPage; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.BaseService; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.manager.iot.frame.A5Frame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.A7Frame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightOperationReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A7PlcErrorCodeReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A7PlcOperationReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightCleanErrorCodeInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.A7PlcCleanErrorCodeInnerFrame; |
| | | 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.A7OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.PlcErrorEnum; |
| | | 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.PlcReportErrorBo; |
| | | import com.sandu.ximon.dao.bo.PlcReportErrorBo; |
| | | import com.sandu.ximon.dao.domain.PlcReportError; |
| | | import com.sandu.ximon.dao.mapper.PlcReportErrorMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * plcåç¯æ
éæ°æ®å表(PlcReportError)表æå¡æ¥å£ |
| | | * |
| | | * @author van |
| | | * @since 2022-12-17 14:42:19 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class PlcReportErrorService extends BaseServiceImpl<PlcReportErrorMapper,PlcReportError> { |
| | | |
| | | |
| | | public void saveReportError(String deviceName, A7PlcErrorCodeReportInnerFrame codeRespInnerFrame) { |
| | | PlcReportError plcReportError = new PlcReportError(); |
| | | plcReportError.setPlcDeviceCode(deviceName); |
| | | plcReportError.setErrorCode(codeRespInnerFrame.getErrorCode()); |
| | | plcReportError.setPlcAddress(codeRespInnerFrame.getDestinationAddress()); |
| | | save(plcReportError); |
| | | } |
| | | |
| | | public List<PlcReportErrorBo> listReportError(int pageNo, int pageSize, String keyword, Long error_code) { |
| | | PageHelper.startPage(pageNo, pageSize); |
| | | List<PlcReportErrorBo> plcReportErrorBos; |
| | | //为nullçè¯æ¯è¶
管 |
| | | if (SecurityUtils.getClientId() == null) { |
| | | plcReportErrorBos = baseMapper.listReportError(keyword, error_code, null); |
| | | } else { |
| | | plcReportErrorBos = baseMapper.listReportError(keyword, error_code, SecurityUtils.getUserId()); |
| | | } |
| | | |
| | | for (PlcReportErrorBo lightReportErrorBo : plcReportErrorBos) { |
| | | Long errorCode = lightReportErrorBo.getErrorCode(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | PlcErrorEnum[] values = PlcErrorEnum.values(); |
| | | for (PlcErrorEnum value : values) { |
| | | if ((value.getCode() & errorCode) > 0) { |
| | | sb.append(value.getMessage() + ";"); |
| | | } |
| | | } |
| | | lightReportErrorBo.setErrorMsg(sb.toString()); |
| | | } |
| | | return plcReportErrorBos; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢æ
å¸¸æ°æ® |
| | | * |
| | | * @return |
| | | */ |
| | | public CommonPage queryErrorCode(BaseConditionVO baseConditionVO) { |
| | | List<PlcReportErrorBo> plcReportErrorBos = baseMapper.listError(SecurityUtils.getClientId()); |
| | | plcReportErrorBos = plcReportErrorBos.stream().filter(bean -> bean.getErrorCode() != 0).collect(Collectors.toList()); |
| | | CommonPage commonPage = ListPagingUtils.pages(plcReportErrorBos, baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | |
| | | for (PlcReportErrorBo lightReportErrorBo : (List<PlcReportErrorBo>) commonPage.getList()) { |
| | | Long errorCode = lightReportErrorBo.getErrorCode(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | PlcErrorEnum[] values = PlcErrorEnum.values(); |
| | | for (PlcErrorEnum value : values) { |
| | | if ((value.getCode() & errorCode) > 0) { |
| | | sb.append(value.getMessage()); |
| | | } |
| | | } |
| | | lightReportErrorBo.setErrorMsg(sb.toString()); |
| | | } |
| | | return commonPage; |
| | | } |
| | | |
| | | /** |
| | | * æ¸
餿
éç |
| | | * |
| | | * @param deviceName |
| | | * @param address |
| | | */ |
| | | public void cleanErrorCode(String deviceName, String address) { |
| | | A7PlcCleanErrorCodeInnerFrame a7PlcCleanErrorCodeInnerFrame = new A7PlcCleanErrorCodeInnerFrame(address); |
| | | |
| | | A7Frame a7Frame = new A7Frame(A7OrderEnum.REQUEST_PLC_DATA.getCode(), a7PlcCleanErrorCodeInnerFrame); |
| | | System.out.println(a7Frame + " -----a7Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, a7Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "PLC帧-æ
鿏
é¤", a7Frame, commonFrame); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | A7PlcOperationReportInnerFrame operationReportInnerFrame = new A7PlcOperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | log.error("æ¸
餿
éç æåï¼codeï¼" + deviceName + "ï¼ç¯å¤´å°åï¼" + address); |
| | | } |
| | | } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | 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.aliyuncs.iot.model.v20180120.BatchGetDeviceStateResponse; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.domain.CommonPage; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.redis.RedisService; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.manager.iot.frame.A7Frame; |
| | | 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.A7PlcOperationReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.request.*; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.response.*; |
| | | 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.A2OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A7OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService; |
| | | import com.sandu.ximon.admin.param.PlcControlParam; |
| | | import com.sandu.ximon.admin.param.PlcRemarkParam; |
| | | 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.dao.bo.PlcBo; |
| | | 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.PlcMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * plcè·¯ç¯è¡¨(Plc)表æå¡æ¥å£ |
| | | * |
| | | * @author van |
| | | * @since 2022-12-15 14:45:27 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | @AllArgsConstructor |
| | | public class PlcService extends BaseServiceImpl<PlcMapper,Plc> { |
| | | |
| | | private final RedisService redisService; |
| | | private final PlcReportDataService plcReportDataService; |
| | | private final PoleBindingService bindingService; |
| | | private final PoleService poleService; |
| | | private final RedisUtils redisUtils; |
| | | |
| | | public List<PlcBo> listPlc(int pageNo, int pageSize, String keyword, Integer order, Integer seq) { |
| | | Long clientId = SecurityUtils.getClientId(); |
| | | |
| | | //æåºå段 |
| | | String orderByResult = "plc_id"; |
| | | //æ£åºãåå |
| | | String orderBySeq = OrderByEnums.ASC.getCode(); |
| | | if (order != null) { |
| | | switch (order) { |
| | | case 1: |
| | | orderByResult = OrderByEnums.LIGHT_POLE_NAME.getCode(); |
| | | break; |
| | | case 2: |
| | | orderByResult = OrderByEnums.LIGHT_UPDATE_TIME.getCode(); |
| | | break; |
| | | case 3: |
| | | orderByResult = OrderByEnums.LIGHT_CREATE_TIME.getCode(); |
| | | break; |
| | | default: |
| | | } |
| | | } |
| | | if (seq != null) { |
| | | switch (seq) { |
| | | case 1: |
| | | orderBySeq = OrderByEnums.ASC.getCode(); |
| | | break; |
| | | case 2: |
| | | orderBySeq = OrderByEnums.DESC.getCode(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | //æåºæ¹å¼ |
| | | String orderBy = orderByResult + " " + orderBySeq; |
| | | |
| | | PageHelper.startPage(pageNo, pageSize, orderBy); |
| | | |
| | | List<PlcBo> listPlc = baseMapper.listPlc(clientId, keyword); |
| | | |
| | | // è·åæè¿ç䏿¥æ¶é´ |
| | | List<String> deviceCodeList = listPlc.stream().map(Plc::getDeviceCode).collect(Collectors.toList()); |
| | | //æålist |
| | | List<List<String>> split = CollectionUtil.split(deviceCodeList, 100); |
| | | |
| | | List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = null; |
| | | for (List<String> splist : split) { |
| | | deviceStatuses = MainBoardInvokeSyncService.getInstance().batchGetDeviceState(splist); |
| | | if (deviceStatuses != null) { |
| | | for (PlcBo plcBo : listPlc ) { |
| | | for (BatchGetDeviceStateResponse.DeviceStatus deviceStatus : deviceStatuses) { |
| | | |
| | | if (plcBo.getDeviceCode() != null && plcBo.getDeviceCode().equals(deviceStatus.getDeviceName())) { |
| | | if ("ONLINE".equals(deviceStatus.getStatus())) { |
| | | plcBo.setOnlineStatus(0); |
| | | } else if ("OFFLINE".equals(deviceStatus.getStatus())) { |
| | | plcBo.setOnlineStatus(1); |
| | | } else { |
| | | plcBo.setOnlineStatus(2); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (CollectionUtil.isNotEmpty(deviceCodeList)) { |
| | | List<PlcReportData> reportDataList = plcReportDataService.getNewestReportByDeviceCode(deviceCodeList); |
| | | for (PlcBo plcBo : listPlc) { |
| | | deviceCodeList.forEach(code -> { |
| | | PoleBinding bind = bindingService.getPoleIdByMac(code); |
| | | if (bind != null && plcBo.getDeviceCode().equals(bind.getDeviceCode())) { |
| | | Long poleId = bind.getPoleId(); |
| | | Pole pole = poleService.getById(poleId); |
| | | plcBo.setPoleId(pole.getId()); |
| | | plcBo.setPoleCode(pole.getDeviceCode()); |
| | | plcBo.setPoleName(pole.getPoleName()); |
| | | } |
| | | }); |
| | | for (PlcReportData plcReportData : reportDataList) { |
| | | if (StrUtil.equals(plcBo.getDeviceCode(), plcReportData.getDeviceCode())) { |
| | | plcBo.setReportTime(plcReportData.getCreateTime1()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return listPlc; |
| | | } |
| | | |
| | | /** |
| | | * è·åå个plcä¿¡æ¯ |
| | | * |
| | | * @param deviceCode 设å¤ç |
| | | * @return |
| | | */ |
| | | public Plc getPlc(String deviceCode) { |
| | | Plc one = getOne(Wrappers.<Plc>lambdaQuery().eq(Plc::getDeviceCode, deviceCode)); |
| | | if (one == null) { |
| | | return null; |
| | | } else { |
| | | Object o = redisService.get(LightKey.REPORT_MAC.key(deviceCode)); |
| | | if (o != null) { |
| | | one.setOnlineStatus(1); |
| | | } else { |
| | | one.setOnlineStatus(0); |
| | | } |
| | | return one; |
| | | } |
| | | } |
| | | |
| | | public boolean addRemark(PlcRemarkParam param) { |
| | | Plc plc = getById(param.getPlcId()); |
| | | if (plc == null) { |
| | | throw new BusinessException("æ¾ä¸å°PLC"); |
| | | } |
| | | Plc update = new Plc(); |
| | | update.setPlcId(param.getPlcId()); |
| | | update.setPlcRemark(param.getPlcRemark()); |
| | | return updateById(update); |
| | | } |
| | | |
| | | /** |
| | | * PLC亮度æ§å¶ |
| | | * |
| | | * @return com.sandu.ximon.dao.enums.DeviceRespStatusEnums |
| | | */ |
| | | public List<Map<String, Object>> controlBrightness(List<PlcControlParam> paramList) { |
| | | if (CollectionUtil.isEmpty(paramList)) { |
| | | throw new BusinessException("åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | for (PlcControlParam param : paramList) { |
| | | A7PlcBrightnessReqInnerFrame plcControlFrame = new A7PlcBrightnessReqInnerFrame(param.getBrightness(), param.getPlcAddress()); |
| | | A7Frame a7Frame = new A7Frame(A7OrderEnum.REQUEST_PLC_DATA.getCode(), plcControlFrame); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | map.put("deviceCode", param.getDeviceCode()); |
| | | WrapResponseCommonFrame<A7PlcBrightnessRespInnerFrame> frame |
| | | = MainBoardInvokeSyncService.getInstance().sendRRPC(param.getDeviceCode(), a7Frame, A7PlcBrightnessRespInnerFrame.class); |
| | | //å卿§å¶å¸§æä»¤ |
| | | StoreOperationRecordsUtils.storeInnerFrameData(param.getDeviceCode(), "PLC帧-亮度å¼å
³æ§å¶", a7Frame, frame); |
| | | |
| | | if (frame == null) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | continue; |
| | | } |
| | | String responseStatus = frame.getResponseInnerFrame().getResponseStatus(); |
| | | int status = HexUtil.hexToInt(responseStatus); |
| | | map.put("status", status); |
| | | resultList.add(map); |
| | | // æ´æ°äº®åº¦æåï¼ä¿®æ¹å°æ°æ®åº |
| | | if (DeviceRespStatusEnums.SUCCESS.getCode().equals(status)) { |
| | | Plc plc = new Plc(); |
| | | if (param.getPlcAddress().equals("0001")){ |
| | | plc.setPlcLight1(param.getBrightness()); |
| | | } |
| | | else if (param.getPlcAddress().equals("0002")){ |
| | | plc.setPlcLight2(param.getBrightness()); |
| | | } |
| | | else if (param.getPlcAddress().equals("0003")){ |
| | | plc.setPlcLight3(param.getBrightness()); |
| | | } |
| | | else if (param.getPlcAddress().equals("FFFF")){ |
| | | plc.setPlcLight1(param.getBrightness()); |
| | | plc.setPlcLight2(param.getBrightness()); |
| | | plc.setPlcLight3(param.getBrightness()); |
| | | |
| | | } |
| | | update(plc, Wrappers.lambdaUpdate(Plc.class).eq(Plc::getDeviceCode, param.getDeviceCode())); |
| | | |
| | | } |
| | | } catch (BusinessException e) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æå¡ç«¯æ¹éæ§ç¯æ¥å¿è®°å½å¼å§ |
| | | */ |
| | | String content = "{PLCæ§ç¯è¯·æ±ï¼" + paramList.toString() |
| | | + "ï¼ PLCæ§ç¯ç»æï¼" + resultList.toString() + "}"; |
| | | List<String> codeList = new ArrayList<>(); |
| | | for (PlcControlParam bean : paramList) { |
| | | codeList.add(bean.getDeviceCode()); |
| | | } |
| | | StoreOperationRecordsUtils.storeOperationData(codeList, null, "æå¡ç«¯æ¹éPLCæ§ç¯", content); |
| | | /** |
| | | * æå¡ç«¯æ¹éæ§ç¯æ¥å¿è®°å½ç»æ |
| | | */ |
| | | |
| | | return resultList; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * PLC设置å¿è·³æ¶é´ |
| | | * |
| | | * @return com.sandu.ximon.dao.enums.DeviceRespStatusEnums |
| | | */ |
| | | public List<Map<String, Object>> setHeartBeatTime(List<PlcControlParam> paramList) { |
| | | if (CollectionUtil.isEmpty(paramList)) { |
| | | throw new BusinessException("åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | for (PlcControlParam param : paramList) { |
| | | A7PlcSettingHeartBeatTimeReqInnerFrame plcControlFrame = new A7PlcSettingHeartBeatTimeReqInnerFrame(param.getHeartBeatTime()); |
| | | A7Frame a7Frame = new A7Frame(A7OrderEnum.REQUEST_PLC_DATA.getCode(), plcControlFrame); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | map.put("deviceCode", param.getDeviceCode()); |
| | | WrapResponseCommonFrame<A7PlcBrightnessRespInnerFrame> frame |
| | | = MainBoardInvokeSyncService.getInstance().sendRRPC(param.getDeviceCode(), a7Frame, A7PlcBrightnessRespInnerFrame.class); |
| | | //å卿§å¶å¸§æä»¤ |
| | | StoreOperationRecordsUtils.storeInnerFrameData(param.getDeviceCode(), "PLC帧-设置PLCå¿è·³å
é´éæ¶é´", a7Frame, frame); |
| | | |
| | | if (frame == null) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | continue; |
| | | } |
| | | String responseStatus = frame.getResponseInnerFrame().getResponseStatus(); |
| | | int status = HexUtil.hexToInt(responseStatus); |
| | | map.put("status", status); |
| | | resultList.add(map); |
| | | } catch (BusinessException e) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æå¡ç«¯æ¹éæ§ç¯æ¥å¿è®°å½å¼å§ |
| | | */ |
| | | String content = "{PLC设置å¿è·³æ¶é´ï¼" + paramList.toString() |
| | | + "ï¼ PLC设置å¿è·³æ¶é´ç»æï¼" + resultList.toString() + "}"; |
| | | List<String> codeList = new ArrayList<>(); |
| | | for (PlcControlParam bean : paramList) { |
| | | codeList.add(bean.getDeviceCode()); |
| | | } |
| | | StoreOperationRecordsUtils.storeOperationData(codeList, null, "PLC设置å¿è·³æ¶é´", content); |
| | | /** |
| | | * æå¡ç«¯æ¹éæ§ç¯æ¥å¿è®°å½ç»æ |
| | | */ |
| | | |
| | | return resultList; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * PLC æ¥è¯¢å¿è·³æ¶é´ |
| | | * |
| | | * @return com.sandu.ximon.dao.enums.DeviceRespStatusEnums |
| | | */ |
| | | public List<Map<String, Object>> queryHeartBeatTime(List<PlcControlParam> paramList) { |
| | | if (CollectionUtil.isEmpty(paramList)) { |
| | | throw new BusinessException("åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | for (PlcControlParam param : paramList) { |
| | | A7PlcQueryHeartBeatTimeReqInnerFrame plcControlFrame = new A7PlcQueryHeartBeatTimeReqInnerFrame(); |
| | | A7Frame a7Frame = new A7Frame(A7OrderEnum.REQUEST_PLC_DATA.getCode(), plcControlFrame); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | map.put("deviceCode", param.getDeviceCode()); |
| | | WrapResponseCommonFrame<A7PlcQueryHeartBeatTimeRespInnerFrame> frame |
| | | = MainBoardInvokeSyncService.getInstance().sendRRPC(param.getDeviceCode(), a7Frame, A7PlcQueryHeartBeatTimeRespInnerFrame.class); |
| | | //å卿§å¶å¸§æä»¤ |
| | | StoreOperationRecordsUtils.storeInnerFrameData(param.getDeviceCode(), "PLC帧-设置PLCå¿è·³å
é´éæ¶é´", a7Frame, frame); |
| | | |
| | | if (frame == null) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | continue; |
| | | } |
| | | String time = frame.getResponseInnerFrame().getTime(); |
| | | map.put("status", 0); |
| | | map.put("time",time); |
| | | resultList.add(map); |
| | | } catch (BusinessException e) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æå¡ç«¯æ¹éæ§ç¯æ¥å¿è®°å½å¼å§ |
| | | */ |
| | | String content = "{PLCæ¥è¯¢å¿è·³æ¶é´ï¼" + paramList.toString() |
| | | + "ï¼ PLCæ¥è¯¢å¿è·³æ¶é´ç»æï¼" + resultList.toString() + "}"; |
| | | List<String> codeList = new ArrayList<>(); |
| | | for (PlcControlParam bean : paramList) { |
| | | codeList.add(bean.getDeviceCode()); |
| | | } |
| | | StoreOperationRecordsUtils.storeOperationData(codeList, null, "PLCæ¥è¯¢å¿è·³æ¶é´", content); |
| | | /** |
| | | * æå¡ç«¯æ¹éæ§ç¯æ¥å¿è®°å½ç»æ |
| | | */ |
| | | |
| | | return resultList; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * PLC æ¥è¯¢å¿è·³å
|
| | | * |
| | | * @return com.sandu.ximon.dao.enums.DeviceRespStatusEnums |
| | | */ |
| | | public List<Map<String, Object>> queryHeartBeatData(List<PlcControlParam> paramList) { |
| | | if (CollectionUtil.isEmpty(paramList)) { |
| | | throw new BusinessException("åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | for (PlcControlParam param : paramList) { |
| | | A7PlcQueryHeartBeatDataReqInnerFrame plcControlFrame = new A7PlcQueryHeartBeatDataReqInnerFrame(); |
| | | A7Frame a7Frame = new A7Frame(A7OrderEnum.REQUEST_PLC_DATA.getCode(), plcControlFrame); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | map.put("deviceCode", param.getDeviceCode()); |
| | | WrapResponseCommonFrame<A7PlcQueryHeartBeatDataRespInnerFrame> frame |
| | | = MainBoardInvokeSyncService.getInstance().sendRRPC(param.getDeviceCode(), a7Frame, A7PlcQueryHeartBeatDataRespInnerFrame.class); |
| | | |
| | | if (frame == null) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | continue; |
| | | } |
| | | String data = JSON.toJSONString(frame.getResponseInnerFrame().getHeartbeatReportInnerFrame().getHeartBeatDataPackage()); |
| | | map.put("status", 0); |
| | | map.put("heartBeatData",data); |
| | | resultList.add(map); |
| | | } catch (BusinessException e) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | return resultList; |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * PLC æ¥è¯¢çæ¬ |
| | | * |
| | | * @return com.sandu.ximon.dao.enums.DeviceRespStatusEnums |
| | | */ |
| | | public List<Map<String, Object>> queryVersion(List<PlcControlParam> paramList) { |
| | | if (CollectionUtil.isEmpty(paramList)) { |
| | | throw new BusinessException("åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | for (PlcControlParam param : paramList) { |
| | | A7PlcQueryVersionReqInnerFrame plcControlFrame = new A7PlcQueryVersionReqInnerFrame(); |
| | | A7Frame a7Frame = new A7Frame(A7OrderEnum.REQUEST_PLC_DATA.getCode(), plcControlFrame); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | map.put("deviceCode", param.getDeviceCode()); |
| | | WrapResponseCommonFrame<A7PlcQueryVersionRespInnerFrame> frame |
| | | = MainBoardInvokeSyncService.getInstance().sendRRPC(param.getDeviceCode(), a7Frame, A7PlcQueryVersionRespInnerFrame.class); |
| | | |
| | | if (frame == null) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | continue; |
| | | } |
| | | map.put("status", 0); |
| | | map.put("hardwareVersion",frame.getResponseInnerFrame().getHardwareVersionDouble()); |
| | | map.put("softwareVersion",frame.getResponseInnerFrame().getSoftwareVersionDouble()); |
| | | |
| | | resultList.add(map); |
| | | } catch (BusinessException e) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | } |
| | | } |
| | | |
| | | return resultList; |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * PLCéå¯ |
| | | * |
| | | * @return com.sandu.ximon.dao.enums.DeviceRespStatusEnums |
| | | */ |
| | | public List<Map<String, Object>> reboot(List<PlcControlParam> paramList) { |
| | | if (CollectionUtil.isEmpty(paramList)) { |
| | | throw new BusinessException("åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | for (PlcControlParam param : paramList) { |
| | | A7PlcRebootReqInnerFrame plcControlFrame = new A7PlcRebootReqInnerFrame(); |
| | | A7Frame a7Frame = new A7Frame(A7OrderEnum.REQUEST_PLC_DATA.getCode(), plcControlFrame); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | map.put("deviceCode", param.getDeviceCode()); |
| | | WrapResponseCommonFrame<A7PlcBrightnessRespInnerFrame> frame |
| | | = MainBoardInvokeSyncService.getInstance().sendRRPC(param.getDeviceCode(), a7Frame, A7PlcBrightnessRespInnerFrame.class); |
| | | //å卿§å¶å¸§æä»¤ |
| | | StoreOperationRecordsUtils.storeInnerFrameData(param.getDeviceCode(), "PLC帧-设置PLCéå¯", a7Frame, frame); |
| | | |
| | | if (frame == null) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | continue; |
| | | } |
| | | String responseStatus = frame.getResponseInnerFrame().getResponseStatus(); |
| | | int status = HexUtil.hexToInt(responseStatus); |
| | | map.put("status", status); |
| | | resultList.add(map); |
| | | } catch (BusinessException e) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æå¡ç«¯æ¹éæ§ç¯æ¥å¿è®°å½å¼å§ |
| | | */ |
| | | String content = "{PLCéå¯ï¼" + paramList.toString() |
| | | + "ï¼ PLCéå¯ï¼" + resultList.toString() + "}"; |
| | | List<String> codeList = new ArrayList<>(); |
| | | for (PlcControlParam bean : paramList) { |
| | | codeList.add(bean.getDeviceCode()); |
| | | } |
| | | StoreOperationRecordsUtils.storeOperationData(codeList, null, "PLCéå¯", content); |
| | | /** |
| | | * æå¡ç«¯æ¹éæ§ç¯æ¥å¿è®°å½ç»æ |
| | | */ |
| | | |
| | | return resultList; |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * PLCæ¢å¤åºå设置 |
| | | * |
| | | * @return com.sandu.ximon.dao.enums.DeviceRespStatusEnums |
| | | */ |
| | | public List<Map<String, Object>> reset(List<PlcControlParam> paramList) { |
| | | if (CollectionUtil.isEmpty(paramList)) { |
| | | throw new BusinessException("åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | for (PlcControlParam param : paramList) { |
| | | A7PlcResetReqInnerFrame plcControlFrame = new A7PlcResetReqInnerFrame(); |
| | | A7Frame a7Frame = new A7Frame(A7OrderEnum.REQUEST_PLC_DATA.getCode(), plcControlFrame); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | map.put("deviceCode", param.getDeviceCode()); |
| | | WrapResponseCommonFrame<A7PlcResetRespInnerFrame> frame |
| | | = MainBoardInvokeSyncService.getInstance().sendRRPC(param.getDeviceCode(), a7Frame, A7PlcResetRespInnerFrame.class); |
| | | //å卿§å¶å¸§æä»¤ |
| | | StoreOperationRecordsUtils.storeInnerFrameData(param.getDeviceCode(), "PLC帧-设置PLCæ¢å¤åºå设置", a7Frame, frame); |
| | | |
| | | if (frame == null) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | continue; |
| | | } |
| | | |
| | | String responseStatus = frame.getResponseInnerFrame().getResponseStatus(); |
| | | int status = HexUtil.hexToInt(responseStatus); |
| | | |
| | | IRequestFrame iRequestFrame = FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame()).orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build(); |
| | | CommonFrame rebootFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(param.getDeviceCode(), iRequestFrame); |
| | | |
| | | boolean b = false; |
| | | |
| | | if (!"00".equals(rebootFrame.getPayload())) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | continue; |
| | | } |
| | | |
| | | map.put("status", status); |
| | | resultList.add(map); |
| | | } catch (BusinessException e) { |
| | | map.put("status", DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | resultList.add(map); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æå¡ç«¯æ¹éæ§ç¯æ¥å¿è®°å½å¼å§ |
| | | */ |
| | | String content = "{PLCæ¢å¤åºå设置ï¼" + paramList.toString() |
| | | + "ï¼ PLCæ¢å¤åºå设置ï¼" + resultList.toString() + "}"; |
| | | List<String> codeList = new ArrayList<>(); |
| | | for (PlcControlParam bean : paramList) { |
| | | codeList.add(bean.getDeviceCode()); |
| | | } |
| | | StoreOperationRecordsUtils.storeOperationData(codeList, null, "PLCæ¢å¤åºå设置", content); |
| | | /** |
| | | * æå¡ç«¯æ¹éæ§ç¯æ¥å¿è®°å½ç»æ |
| | | */ |
| | | |
| | | return resultList; |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è·åç¨æ·ææç设å¤ç |
| | | */ |
| | | 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); |
| | | list = baseMapper.listCode(null, keyword, deviceCode); |
| | | } |
| | | |
| | | return CommonPage.restPage(list); |
| | | } |
| | | |
| | | public void timeSynchronizationInitiative(String deviceCode, String destinationAddress) { |
| | | Plc plc = getPlc(deviceCode); |
| | | if (plc == null) { |
| | | log.error("PLC主å¨åæ¥æ¶é´è¯·æ±å¼å¸¸ï¼PLCä¿¡æ¯ä¸åå¨ï¼"); |
| | | return; |
| | | } |
| | | SetCalendar(plc.getPlcId(), destinationAddress); |
| | | |
| | | } |
| | | /** |
| | | * 设置æ¥åï¼åå¿è·³å
ä¸ç6åèæ¥ææ¶é´ï¼ |
| | | * |
| | | * @return |
| | | */ |
| | | public String SetCalendar(Long plcId, 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); |
| | | |
| | | |
| | | Plc one = getById(plcId); |
| | | if (one == null) { |
| | | System.out.println("plcä¸åå¨ï¼"); |
| | | } |
| | | |
| | | A7PlcSetCalendarReqInnerFrame setCalendarReqInnerFrame = |
| | | new A7PlcSetCalendarReqInnerFrame(address, year % 100, month + 1, day, hour, min, sec); |
| | | |
| | | A7Frame a7Frame = new A7Frame(A5OrderEnum.REQUEST_LIGHT_DATA.getCode(), setCalendarReqInnerFrame); |
| | | System.out.println(a7Frame + " -----A7Frame"); |
| | | |
| | | CommonFrame commonFrame; |
| | | |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getDeviceCode(), a7Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getDeviceCode(), "PLC帧-设置æ¥å", a7Frame, commonFrame); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A7PlcOperationReportInnerFrame operationReportInnerFrame = new A7PlcOperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | | throw new BusinessException("æ°æ®æ ¡éªé误ï¼è¯·éæ°è¯·æ±"); |
| | | } |
| | | } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.dao.domain.PlcTaskPoleRelation; |
| | | import com.sandu.ximon.dao.mapper.PlcTaskPoleRelationMapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * plcä»»å¡åç¯æå
³ç³»è¡¨(PlcTaskPoleRelation)表æå¡æ¥å£ |
| | | * |
| | | * @author van |
| | | * @since 2022-12-19 16:54:14 |
| | | */ |
| | | @Service |
| | | public class PlcTaskPoleRelationService extends BaseServiceImpl<PlcTaskPoleRelationMapper, PlcTaskPoleRelation> { |
| | | |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.collection.ListUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.HexUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.Page; |
| | | 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.PlcTaskDto; |
| | | import com.sandu.ximon.admin.dto.PlcTaskDto; |
| | | import com.sandu.ximon.admin.dto.SingleLightOrderDto; |
| | | 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.A7PlcTimerReqInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.response.A7PlcTimerRespInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.WrapResponseCommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A7OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.SupplementUtils; |
| | | import com.sandu.ximon.admin.param.PlcTaskIssueParam; |
| | | import com.sandu.ximon.admin.param.PlcTaskParam; |
| | | 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.admin.vo.*; |
| | | 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.PlcTaskMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * plcä»»å¡è¡¨(PlcTask)表æå¡æ¥å£ |
| | | * |
| | | * @author van |
| | | * @since 2022-12-19 16:53:41 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | @AllArgsConstructor |
| | | public class PlcTaskService extends BaseServiceImpl<PlcTaskMapper,PlcTask> { |
| | | |
| | | private final PoleService poleService; |
| | | |
| | | private final ClientService clientService; |
| | | |
| | | private final PlcTaskPoleRelationService plcTaskPoleRelationService; |
| | | |
| | | private final PlcTaskMapper plcTaskMapper; |
| | | |
| | | /** |
| | | * æ ¹æ®ä»»å¡ä¿¡æ¯è½¬æå¸§è´è· |
| | | * |
| | | * @return è·¯ç¯å®æ¶å¨å表 |
| | | */ |
| | | private String buildControlFramePayload(String openOrder, String closeOrder, String controlOrder, Integer week) { |
| | | |
| | | // æ·»å å¼ç¯å®æ¶å¨ |
| | | SingleLightOrderDto openLightOrder = TaskOrderUtil.parseLightOrder(openOrder); |
| | | SingleLightOrderDto closeLightOrder = TaskOrderUtil.parseLightOrder(closeOrder); |
| | | String[] controlOrderArray = StrUtil.split(controlOrder, PlcTaskParam.REQUEST_ORDER_LENGTH); |
| | | Integer[] weekArrays = TaskOrderUtil.parseLightCronWeek2List(week).toArray(new Integer[0]); |
| | | if (openLightOrder == null || closeLightOrder == null) { |
| | | throw new BusinessException("è§£æPLCå½ä»¤å¤±è´¥"); |
| | | } |
| | | if (ArrayUtil.isEmpty(weekArrays)) { |
| | | throw new BusinessException("请设置ææ"); |
| | | } |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | String weekHex = SupplementUtils.suppleZero(HexUtil.toHex(week), 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)); |
| | | |
| | | // æ¼æ¥äº®åº¦æ§ç¯å½ä»¤ |
| | | 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)); |
| | | } |
| | | } |
| | | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * ç¨äºä»»å¡æ°å¢,ä¸å |
| | | * |
| | | * @param plcTask |
| | | * @param poleIdList |
| | | * @param framePayload |
| | | * @param plcAddress |
| | | * @return |
| | | */ |
| | | private List<PlcTaskPoleRelation> sendControllerFrame(PlcTask plcTask, List<Long> poleIdList, String framePayload, String plcAddress) { |
| | | List<PlcTaskPoleRelation> plcTaskPoleRelationList = new ArrayList<>(); |
| | | //æå |
| | | List<PlcTaskPoleRelation> success = new ArrayList<>(); |
| | | //失败 |
| | | List<PlcTaskPoleRelation> fail = new ArrayList<>(); |
| | | |
| | | Map map = new HashMap(); |
| | | |
| | | List<Pole> poles = poleService.listByIds(poleIdList); |
| | | if (CollectionUtil.isEmpty(poles)) { |
| | | return null; |
| | | } |
| | | |
| | | for (Pole pole : poles) { |
| | | if (pole.getDeviceCode() == null || pole.getDeviceCode().equals("")) { |
| | | removeById(plcTask.getTaskId()); |
| | | throw new BusinessException("ç¼è¾çç¯ææåæä»»å¡çç¯æä¸åå¨mac,ä¸è½ä¸åä»»å¡ è¯·æ£æ¥ç¯ææ¯å¦åå¨PLC"); |
| | | } |
| | | PlcTaskPoleRelation plcTaskPoleRelation = new PlcTaskPoleRelation(); |
| | | plcTaskPoleRelation.setPoleId(pole.getId()); |
| | | plcTaskPoleRelation.setTaskId(plcTask.getTaskId()); |
| | | |
| | | // rrpc åç宿¶å½ä»¤ |
| | | plcTaskPoleRelation.setDeviceCode(pole.getDeviceCode()); |
| | | plcTaskPoleRelation.setPlcAddress(plcAddress); |
| | | // rrpc åç宿¶å½ä»¤ |
| | | try { |
| | | A7PlcTimerRespInnerFrame a7PlcTimerRespInnerFrame = sendTimeRRpc(framePayload, pole.getDeviceCode(), plcAddress); |
| | | if (a7PlcTimerRespInnerFrame == null) { |
| | | plcTaskPoleRelation.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | } else { |
| | | plcTaskPoleRelation.setIssueStatus(HexUtil.hexToInt(a7PlcTimerRespInnerFrame.getResponseStatus())); |
| | | } |
| | | } catch (BusinessException e) { |
| | | e.printStackTrace(); |
| | | plcTaskPoleRelation.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | } |
| | | plcTaskPoleRelationList.add(plcTaskPoleRelation); |
| | | } |
| | | |
| | | // } |
| | | return plcTaskPoleRelationList; |
| | | } |
| | | |
| | | /** |
| | | * åéç¯æ§è¯·æ± |
| | | * |
| | | * @param framePayload ç¯æ§åæ° |
| | | * @param deviceCode 设å¤å |
| | | * @return è¿å帧 |
| | | */ |
| | | public A7PlcTimerRespInnerFrame sendTimeRRpc(String framePayload, String deviceCode, String plcAddress) { |
| | | IRequestFrame requestFrame = FrameBuilder.builderA7().innerFrame(new A7PlcTimerReqInnerFrame(framePayload, plcAddress)).orderType(A7OrderEnum.REQUEST_PLC_DATA.getCode()).build(); |
| | | System.out.println(requestFrame + " --------requestFrame"); |
| | | |
| | | WrapResponseCommonFrame<A7PlcTimerRespInnerFrame> responseCommonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceCode, requestFrame, A7PlcTimerRespInnerFrame.class); |
| | | System.out.println(responseCommonFrame + " -----------responseCommonFrame"); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(deviceCode, "PLC帧-宿¶", requestFrame, responseCommonFrame); |
| | | return Optional.ofNullable(responseCommonFrame).map(WrapResponseCommonFrame::getResponseInnerFrame).orElse(null); |
| | | } |
| | | |
| | | /** |
| | | * ç¨äºä»»å¡ç¼è¾ |
| | | * |
| | | * @param poleIdList |
| | | * @param framePayload |
| | | * @param plcAddress |
| | | * @return |
| | | */ |
| | | private Map<String, List<PlcTaskPoleRelation>> sendControllerFrame(List<Long> poleIdList, String framePayload, String plcAddress) { |
| | | |
| | | System.out.println("framePayload:" + framePayload); |
| | | List<PlcTaskPoleRelation> plcTaskPoleRelationList = new ArrayList<>(); |
| | | //æå |
| | | List<PlcTaskPoleRelation> success = new ArrayList<>(); |
| | | //失败 |
| | | List<PlcTaskPoleRelation> fail = new ArrayList<>(); |
| | | |
| | | Map<String, List<PlcTaskPoleRelation>> map = new HashMap(); |
| | | |
| | | List<Pole> poles = poleService.listByIds(poleIdList); |
| | | if (CollectionUtil.isEmpty(poles)) { |
| | | return null; |
| | | } |
| | | |
| | | for (Pole pole : poles) { |
| | | if (pole.getDeviceCode() == null || pole.getDeviceCode().equals("")) { |
| | | throw new BusinessException("ç¼è¾çç¯ææåæä»»å¡çç¯æä¸åå¨mac,ä¸è½ä¸åä»»å¡ è¯·æ£æ¥ç¯ææ¯å¦åå¨PLC"); |
| | | } |
| | | PlcTaskPoleRelation plcTaskPoleRelation = new PlcTaskPoleRelation(); |
| | | plcTaskPoleRelation.setPoleId(pole.getId()); |
| | | //å
³ç³»è¡¨æå
¥ç¯å¤´å°å |
| | | plcTaskPoleRelation.setPlcAddress(plcAddress); |
| | | |
| | | |
| | | // rrpc åç宿¶å½ä»¤ |
| | | plcTaskPoleRelation.setPlcAddress(plcAddress); |
| | | plcTaskPoleRelation.setDeviceCode(pole.getDeviceCode()); |
| | | // rrpc åç宿¶å½ä»¤ |
| | | try { |
| | | A7PlcTimerRespInnerFrame a7PlcTimerRespInnerFrame = sendTimeRRpc(framePayload, pole.getDeviceCode(), plcAddress); |
| | | if (a7PlcTimerRespInnerFrame == null) { |
| | | plcTaskPoleRelation.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | fail.add(plcTaskPoleRelation); |
| | | } else { |
| | | plcTaskPoleRelation.setIssueStatus(HexUtil.hexToInt(a7PlcTimerRespInnerFrame.getResponseStatus())); |
| | | success.add(plcTaskPoleRelation); |
| | | } |
| | | } catch (BusinessException e) { |
| | | plcTaskPoleRelation.setIssueStatus(DeviceRespStatusEnums.OTHER_ERROR.getCode()); |
| | | fail.add(plcTaskPoleRelation); |
| | | } |
| | | plcTaskPoleRelationList.add(plcTaskPoleRelation); |
| | | } |
| | | |
| | | map.put("success", success); |
| | | map.put("fail", fail); |
| | | map.put("all", plcTaskPoleRelationList); |
| | | log.error("åéæ§å¶å¨å¸§ç»æï¼{}", map); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * æ°å¢ä»»å¡ |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String AddPlcTask(PlcTaskParam param) { |
| | | if (StrUtil.length(param.getControlOrder()) % PlcTaskParam.REQUEST_ORDER_LENGTH != 0) { |
| | | throw new BusinessException("ç¯æ§å½ä»¤æ ¼å¼ä¸æ£ç¡®"); |
| | | } |
| | | |
| | | if (!"0001".equals(param.getPlcAddress()) |
| | | && !"0002".equals(param.getPlcAddress()) |
| | | && !"0003".equals(param.getPlcAddress())) { |
| | | throw new BusinessException("ç¯å¤´å°åæ ¼å¼ä¸æ£ç¡®"); |
| | | } |
| | | |
| | | |
| | | int week = 0; |
| | | for (Integer w : param.getWeekList()) { |
| | | week |= w; |
| | | } |
| | | |
| | | PlcTask newPlcTask = new PlcTask(); |
| | | newPlcTask.setTaskName(param.getTaskName()); |
| | | |
| | | newPlcTask.setClientId(clientService.getClientId(SecurityUtils.getUserId())); |
| | | newPlcTask.setUserId(SecurityUtils.getUserId()); |
| | | |
| | | newPlcTask.setWeek(week); |
| | | newPlcTask.setCreateUser(SecurityUtils.getUsername()); |
| | | newPlcTask.setControlOrder(param.getControlOrder()); |
| | | newPlcTask.setOpenOrder(param.getOpenOrder()); |
| | | newPlcTask.setCloseOrder(param.getCloseOrder()); |
| | | newPlcTask.setPlcAdress(param.getPlcAddress()); |
| | | newPlcTask.setUpdateTime(LocalDateTime.now()); |
| | | newPlcTask.setFramePayload(buildControlFramePayload(param.getOpenOrder(), param.getCloseOrder(), param.getControlOrder(), week)); |
| | | |
| | | if (!save(newPlcTask)) { |
| | | throw new BusinessException("ä¿åPLCä»»å¡å¤±è´¥"); |
| | | } |
| | | |
| | | List<String> poleCodeList = new ArrayList<>(); |
| | | //ä¼ å
¥çç¯æidéå |
| | | List<Long> poleIdList = new ArrayList<>(); |
| | | //å»é |
| | | for (Long item : param.getPoleIdList()) { |
| | | if (!poleIdList.contains(item)) { |
| | | poleIdList.add(item); |
| | | } |
| | | } |
| | | |
| | | if (CollectionUtil.isNotEmpty(poleIdList)) { |
| | | List<Pole> poleList = SpringContextHolder.getBean(PoleService.class).listByIds(poleIdList); |
| | | if (CollectionUtil.isNotEmpty(poleList)) { |
| | | poleCodeList = poleList.stream().map(Pole::getDeviceCode).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | |
| | | String content = "{ä»»å¡IDï¼" + newPlcTask.getTaskId() + "ï¼ ä»»å¡åï¼" + newPlcTask.getTaskName() + "}ï¼{å
帧æä»¤" + newPlcTask.getFramePayload() + "ï¼ ç¯æIDï¼" + poleIdList.toString() + "ï¼ æ§å¶çç¯å¤´å°åï¼" + param.getPlcAddress() + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(poleCodeList, null, "æ°å¢PLCä»»å¡", content); |
| | | |
| | | //è®°å½è¿äºç¯æåå
çä»»å¡ |
| | | List<PlcTaskPoleRelation> oldPlcTaskStatusAndPoles = plcTaskPoleRelationService.list(Wrappers.lambdaQuery(PlcTaskPoleRelation.class) |
| | | .in(PlcTaskPoleRelation::getPoleId, poleIdList).eq(PlcTaskPoleRelation::getPlcAddress, param.getPlcAddress())); |
| | | |
| | | |
| | | List<PlcTaskPoleRelation> newPoleMap = new ArrayList<>(); |
| | | if (!poleIdList.isEmpty()) { |
| | | //æ°ç¯æä¸åæ°ä»»å¡ |
| | | newPoleMap = sendControllerFrame(newPlcTask, poleIdList, newPlcTask.getFramePayload(), param.getPlcAddress()); |
| | | |
| | | } |
| | | |
| | | newPoleMap.forEach( |
| | | commend -> { |
| | | //å¼å
³ç¯æ¶é´ |
| | | commend.setSysScheduled(JSON.toJSONString(newPlcTask)); |
| | | System.out.println(commend.getIssueStatus() + "ç¶æ"); |
| | | if (commend.getIssueStatus() == 0) { |
| | | //ä¸åæå æ´æ°ç³»ç»å®æ¶åç¡¬ä»¶å®æ¶ |
| | | commend.setDeviceScheduled(JSON.toJSONString(newPlcTask)); |
| | | } else { |
| | | //ä¸å失败 æ´æ°ç³»ç»å®æ¶ ä¿çç¡¬ä»¶å®æ¶ ç¡¬ä»¶å®æ¶ |
| | | // commend.setSysScheduled(s); |
| | | oldPlcTaskStatusAndPoles.forEach(task -> { |
| | | if (task.getPlcAddress().equals(commend.getPlcAddress()) && task.getDeviceCode().equals(commend.getDeviceCode())) { |
| | | //åä¸ä¸ªç¯å¤´ |
| | | commend.setDeviceScheduled(task.getDeviceScheduled()); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | } |
| | | ); |
| | | |
| | | /** |
| | | * ä¸åè·¯ç¯ä»»å¡æ¥å¿è®°å½å¼å§ |
| | | */ |
| | | |
| | | String content1 = "{ä»»å¡IDï¼" + newPlcTask.getTaskId() + "ï¼ ä»»å¡åï¼" + newPlcTask.getTaskName() + "}," + " ç¯æIDï¼" + poleIdList.toString() + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(poleCodeList, null, "ä¸åPLCä»»å¡", content1); |
| | | /** |
| | | * ä¸åè·¯ç¯ä»»å¡æ¥å¿è®°å½ç»æ |
| | | */ |
| | | |
| | | |
| | | //å 餿§çå
³ç³» |
| | | plcTaskPoleRelationService.remove(Wrappers.lambdaQuery(PlcTaskPoleRelation.class) |
| | | .in(PlcTaskPoleRelation::getPoleId, poleIdList).eq(PlcTaskPoleRelation::getPlcAddress, newPlcTask.getPlcAdress())); |
| | | |
| | | |
| | | boolean b = true; |
| | | //ä¿åä»»å¡å
³ç³» |
| | | if (!newPoleMap.isEmpty()) { |
| | | b = plcTaskPoleRelationService.saveBatch(newPoleMap); |
| | | } |
| | | |
| | | if (!b) { |
| | | //ææç¯æé½ä¸å失败 æ°å¢çä»»å¡ä¸ä¿ç |
| | | removeById(newPlcTask); |
| | | throw new BusinessException("æä»¤ä¸å失败,è¯·æ£æ¥ç¯æç¶æåéæ°æ°å¢ä»»å¡"); |
| | | } else { |
| | | return "任塿°å¢æå"; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * ç¼è¾è·¯ç¯ä»»å¡ |
| | | * |
| | | * @param taskId |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String newUpdatePlcTask(Long taskId, PlcTaskParam param) { |
| | | if (StrUtil.length(param.getControlOrder()) % PlcTaskParam.REQUEST_ORDER_LENGTH != 0) { |
| | | throw new BusinessException("ç¯æ§å½ä»¤æ ¼å¼ä¸æ£ç¡®"); |
| | | } |
| | | if (!"0001".equals(param.getPlcAddress()) |
| | | && !"0002".equals(param.getPlcAddress()) |
| | | && !"0003".equals(param.getPlcAddress())) { |
| | | throw new BusinessException("ç¯å¤´å°åæ ¼å¼ä¸æ£ç¡®"); |
| | | } |
| | | |
| | | PlcTask newPlcTask = getById(taskId); |
| | | |
| | | if (newPlcTask == null) { |
| | | throw new BusinessException("æ¾ä¸å°PLCä»»å¡"); |
| | | } |
| | | |
| | | |
| | | int week = 0; |
| | | for (Integer w : param.getWeekList()) { |
| | | week |= w; |
| | | } |
| | | |
| | | newPlcTask.setTaskName(param.getTaskName()); |
| | | |
| | | newPlcTask.setClientId(clientService.getClientId(SecurityUtils.getUserId())); |
| | | newPlcTask.setUserId(SecurityUtils.getUserId()); |
| | | |
| | | newPlcTask.setWeek(week); |
| | | newPlcTask.setCreateUser(SecurityUtils.getUsername()); |
| | | newPlcTask.setControlOrder(param.getControlOrder()); |
| | | newPlcTask.setOpenOrder(param.getOpenOrder()); |
| | | newPlcTask.setCloseOrder(param.getCloseOrder()); |
| | | newPlcTask.setPlcAdress(param.getPlcAddress()); |
| | | newPlcTask.setUpdateTime(LocalDateTime.now()); |
| | | newPlcTask.setFramePayload(buildControlFramePayload(param.getOpenOrder(), param.getCloseOrder(), param.getControlOrder(), week)); |
| | | |
| | | updateById(newPlcTask); |
| | | |
| | | //ç¼è¾åç¯æIDéå |
| | | List<Long> poleIdList = new ArrayList<>(); |
| | | //å»é |
| | | for (Long item : param.getPoleIdList()) { |
| | | if (!poleIdList.contains(item)) { |
| | | poleIdList.add(item); |
| | | } |
| | | } |
| | | //è®°å½ä»»å¡ç¼è¾å¨åç¯æIDéå |
| | | // List<PlcTaskStatusAndPole> oldPlcTaskStatusAndPoles = plcTaskPoleRelationService.listPoleAndStatusIdByTaskId(taskId); |
| | | List<PlcTaskPoleRelation> oldPlcTaskStatusAndPoles = plcTaskPoleRelationService. |
| | | list(Wrappers.lambdaQuery(PlcTaskPoleRelation.class).eq(PlcTaskPoleRelation::getTaskId, taskId)); |
| | | List<Long> oldList = oldPlcTaskStatusAndPoles.stream(). |
| | | map(PlcTaskPoleRelation::getPoleId).collect(Collectors.toList()); |
| | | |
| | | //夿poleIdList䏿¯å¦ææ§çç¯æID (ç´æ¥ä¸å) |
| | | List<Long> newPoleIdList = poleIdList.stream().filter(poleId -> !oldList.contains(poleId)).collect(Collectors.toList()); |
| | | //夿poleIdList䏿¯å¦ææ°çç¯æID (è¦çæä½) |
| | | List<Long> oldPoleIdList = poleIdList.stream().filter(poleId -> oldList.contains(poleId)).collect(Collectors.toList()); |
| | | |
| | | |
| | | //oldList䏿çç¯æIDï¼ä½æ¯poleIdList䏿²¡æ (å
³ç¯æä½) |
| | | List<Long> closeLight = oldList.stream().filter(poleId -> !poleIdList.contains(poleId)).collect(Collectors.toList()); |
| | | |
| | | |
| | | //ååºè¦çæä½çå
³ç³»ä¿¡æ¯ |
| | | //è®°å½è¿äºç¯æåå
çä»»å¡ |
| | | List<PlcTaskPoleRelation> oldRelation = new ArrayList<>(); |
| | | |
| | | if (CollectionUtil.isNotEmpty(oldPoleIdList)) { |
| | | List<Long> oldRelationList = new ArrayList<>(); |
| | | oldRelationList.addAll(oldPoleIdList); |
| | | oldRelationList.addAll(closeLight); |
| | | oldRelation = plcTaskPoleRelationService.list(Wrappers.lambdaQuery(PlcTaskPoleRelation.class).in(PlcTaskPoleRelation::getPoleId, oldRelationList) |
| | | .ne(PlcTaskPoleRelation::getTaskId, taskId).eq(PlcTaskPoleRelation::getPlcAddress, param.getPlcAddress())); |
| | | } |
| | | |
| | | //ååºä»»å¡ä¸åæçä»»å¡ä¿¡æ¯ |
| | | List<PlcTaskPoleRelation> relations = plcTaskPoleRelationService.list(Wrappers.lambdaQuery(PlcTaskPoleRelation.class) |
| | | .eq(PlcTaskPoleRelation::getTaskId, taskId).eq(PlcTaskPoleRelation::getPlcAddress, param.getPlcAddress())); |
| | | |
| | | relations.addAll(oldRelation); |
| | | |
| | | List<PlcTaskPoleRelation> newPoleAll = new ArrayList<>(); |
| | | List<PlcTaskPoleRelation> newPoleSuccess = new ArrayList<>(); |
| | | List<PlcTaskPoleRelation> newPoleFail = new ArrayList<>(); |
| | | if (CollectionUtil.isNotEmpty(newPoleIdList)) { |
| | | //æ°ç¯æä¸åæ°ä»»å¡ |
| | | Map<String, List<PlcTaskPoleRelation>> newPoleMap = sendControllerFrame(newPoleIdList, newPlcTask.getFramePayload(), param.getPlcAddress()); |
| | | |
| | | if (newPoleMap != null) { |
| | | //newPoleAlléååé¢ç¨äºåå¨å
³ç³»è¡¨ |
| | | newPoleAll = newPoleMap.getOrDefault("all", new ArrayList<>()); |
| | | newPoleSuccess = newPoleMap.getOrDefault("success", new ArrayList<>()); |
| | | newPoleFail = newPoleMap.getOrDefault("fail", new ArrayList<>()); |
| | | } |
| | | } |
| | | |
| | | List<PlcTaskPoleRelation> oldPoleFail = new ArrayList<>(); |
| | | List<PlcTaskPoleRelation> oldPoleSuccess = new ArrayList<>(); |
| | | if (CollectionUtil.isNotEmpty(oldPoleIdList)) { |
| | | //è¦çæä½ç¯æ |
| | | Map<String, List<PlcTaskPoleRelation>> oldPoleMap = sendControllerFrame(oldPoleIdList, newPlcTask.getFramePayload(), param.getPlcAddress()); |
| | | if (oldPoleMap != null) { |
| | | oldPoleFail = oldPoleMap.getOrDefault("fail", new ArrayList<>()); |
| | | oldPoleSuccess = oldPoleMap.getOrDefault("success", new ArrayList<>()); |
| | | } |
| | | } |
| | | |
| | | |
| | | List<PlcTaskPoleRelation> closePoleFail = new ArrayList<>(); |
| | | List<PlcTaskPoleRelation> closePoleSuccess = new ArrayList<>(); |
| | | System.out.println(closeLight + "closeLight"); |
| | | if (CollectionUtil.isNotEmpty(closeLight) && closeLight != null && closeLight.get(0) != null) { |
| | | //æ¸
é¤å¸§æä»¤ |
| | | String framePayloadClose = ""; |
| | | //å
³ç¯æä½ç¯æ |
| | | Map<String, List<PlcTaskPoleRelation>> closePoleMap = sendControllerFrame(closeLight, framePayloadClose, param.getPlcAddress()); |
| | | if (closePoleMap != null) { |
| | | closePoleFail = closePoleMap.getOrDefault("fail", new ArrayList<>()); |
| | | closePoleSuccess = closePoleMap.getOrDefault("success", new ArrayList<>()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * ç¼è¾è·¯ç¯ä»»å¡æ¥å¿è®°å½å¼å§ |
| | | */ |
| | | List<String> poleCodeList = new ArrayList<>(); |
| | | if (CollectionUtil.isNotEmpty(poleIdList)) { |
| | | List<Pole> poleList = SpringContextHolder.getBean(PoleService.class).listByIds(poleIdList); |
| | | if (CollectionUtil.isNotEmpty(poleList)) { |
| | | poleCodeList = poleList.stream().map(Pole::getDeviceCode).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | String content = "{ä»»å¡IDï¼" + newPlcTask.getTaskId() + "ï¼ ä»»å¡åï¼" + newPlcTask.getTaskName() + "}ï¼{å
帧æä»¤" + newPlcTask.getFramePayload() + "ï¼ ç¯æIDï¼" + poleIdList.toString() + "ï¼ æ§å¶çç¯å¤´å°åï¼" + param.getPlcAddress() + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(poleCodeList, null, "ç¼è¾PLCä»»å¡", content); |
| | | /** |
| | | * ç¼è¾è·¯ç¯ä»»å¡æ¥å¿è®°å½ç»æ |
| | | */ |
| | | |
| | | |
| | | List<PlcTaskPoleRelation> all = new ArrayList<>(); |
| | | all.addAll(newPoleSuccess); |
| | | all.addAll(newPoleFail); |
| | | all.addAll(oldPoleSuccess); |
| | | all.addAll(oldPoleFail); |
| | | |
| | | |
| | | if (closePoleFail.size() != 0) { |
| | | List<PlcTaskPoleRelation> colesFail = new ArrayList<>(); |
| | | //忥任å¡ä¸æ¬èº«å°±ä¸å失败çä»»å¡ å³ç¡¬ä»¶å®æ¶ä¸ºç©º ç¼è¾åè¿è¡å
³ç¯æä½ å¯ç´æ¥åé¤ä»»å¡å
³ç³» |
| | | closePoleFail.forEach( |
| | | close -> { |
| | | relations.forEach( |
| | | task -> { |
| | | System.out.println(task.getPlcAddress().equals(close.getPlcAddress()) + " addressResult"); |
| | | System.out.println(close.getPlcAddress() + " close.getPlcAddress()"); |
| | | if (task.getPlcAddress().equals(close.getPlcAddress()) && task.getDeviceCode().equals(close.getDeviceCode()) |
| | | && task.getDeviceScheduled() != null && !task.getDeviceScheduled().isEmpty()) { |
| | | colesFail.add(close); |
| | | } |
| | | } |
| | | ); |
| | | all.addAll(colesFail); |
| | | } |
| | | ); |
| | | |
| | | } |
| | | |
| | | |
| | | if (!all.isEmpty()) { |
| | | List<PlcTaskPoleRelation> finalOldRelation = relations; |
| | | all.forEach( |
| | | commend -> { |
| | | // æ´æ°ç³»ç»å®æ¶ |
| | | commend.setSysScheduled(JSON.toJSONString(newPlcTask)); |
| | | commend.setTaskId(taskId); |
| | | // å
è®¾ç½®ç¡¬ä»¶å®æ¶ä¸ºä¸æ¬¡çç¡¬ä»¶å®æ¶ ä¸è®ºæå失败 |
| | | finalOldRelation.forEach(task -> { |
| | | if (task.getPlcAddress().equals(commend.getPlcAddress()) && task.getDeviceCode().equals(commend.getDeviceCode())) { |
| | | //åä¸ä¸ªç¯å¤´ |
| | | commend.setDeviceScheduled(task.getDeviceScheduled()); |
| | | if (commend.getIssueStatus() == 0) { |
| | | //ä¸åæå æ´æ°ç³»ç»å®æ¶åç¡¬ä»¶å®æ¶ |
| | | commend.setDeviceScheduled(JSON.toJSONString(newPlcTask)); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | |
| | | } |
| | | ); |
| | | } |
| | | boolean b = true; |
| | | |
| | | //ç¼è¾ååææçç¯æIDéå |
| | | poleIdList.addAll(oldList); |
| | | //å»é |
| | | List<Long> collect = poleIdList.stream().distinct().collect(Collectors.toList()); |
| | | if (!collect.isEmpty()) { |
| | | plcTaskPoleRelationService.remove(Wrappers.lambdaQuery(PlcTaskPoleRelation.class) |
| | | .in(PlcTaskPoleRelation::getPoleId, collect).eq(PlcTaskPoleRelation::getPlcAddress, newPlcTask.getPlcAdress())); |
| | | |
| | | } |
| | | |
| | | |
| | | if (!all.isEmpty()) { |
| | | b = plcTaskPoleRelationService.saveBatch(all); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * ä¸åè·¯ç¯ä»»å¡æ¥å¿è®°å½å¼å§ |
| | | */ |
| | | String content1 = "{ä»»å¡IDï¼" + newPlcTask.getTaskId() + "ï¼ ä»»å¡åï¼" + newPlcTask.getTaskName() + "}," + " ç¯æIDï¼" + poleCodeList.toString() + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(poleCodeList, null, "ä¸åè·¯ç¯ä»»å¡", content1); |
| | | /** |
| | | * ä¸åè·¯ç¯ä»»å¡æ¥å¿è®°å½ç»æ |
| | | */ |
| | | |
| | | if (b) { |
| | | return "ç¼è¾æå"; |
| | | } else { |
| | | return "ç¼è¾å¤±è´¥"; |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String delPlcTask(Long taskId) { |
| | | PlcTask byId = getById(taskId); |
| | | if (byId == null) { |
| | | throw new BusinessException("æ¾ä¸å°ä»»å¡ä¿¡æ¯"); |
| | | } |
| | | |
| | | //ååºä»»å¡å
³ç³» |
| | | List<PlcTaskPoleRelation> relations = plcTaskPoleRelationService.list(Wrappers.lambdaQuery(PlcTaskPoleRelation.class).eq(PlcTaskPoleRelation::getTaskId, taskId)); |
| | | |
| | | //ååºç¯æid |
| | | List<Long> poleIds = relations.stream().map(PlcTaskPoleRelation::getPoleId).distinct().collect(Collectors.toList()); |
| | | |
| | | if (poleIds != null && poleIds.size() > 0) { |
| | | //åå¨ä»»å¡å
³ç³» ä¸åæ¸
é¤ä»»å¡æä»¤ |
| | | Map<String, List<PlcTaskPoleRelation>> ffff = sendControllerFrame(poleIds, "", byId.getPlcAdress()); |
| | | |
| | | if (ffff == null) { |
| | | throw new BusinessException("å é¤å¤±è´¥"); |
| | | } |
| | | |
| | | /** |
| | | * å 餿§ç¯ä»»å¡æ¥å¿è®°å½å¼å§ |
| | | */ |
| | | String content = "{æ§ç¯ä»»å¡idï¼" + taskId + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "å 餿§ç¯ä»»å¡", content); |
| | | /** |
| | | * å 餿§ç¯ä»»å¡æ¥å¿è®°å½ç»æ |
| | | */ |
| | | if (ffff.get("fail").size() == 0) { |
| | | //å
¨é¨æ¸
餿å å é¤å
¨é¨ä»»å¡å
³ç³» |
| | | plcTaskPoleRelationService.remove(Wrappers.lambdaQuery(PlcTaskPoleRelation.class).eq(PlcTaskPoleRelation::getTaskId, taskId)); |
| | | //å é¤ä»»å¡ |
| | | removeById(taskId); |
| | | return "ä»»å¡å 餿å"; |
| | | } else if (ffff.get("success").size() != ffff.get("all").size()) { |
| | | //é¨åæå å 餿åé¨åçå
³ç³» ä¿çä»»å¡ |
| | | List<PlcTaskPoleRelation> relations1 = ffff.get("success"); |
| | | if (relations1 != null && relations1.size() > 0) { |
| | | relations1.forEach(plcTaskPoleRelation -> { |
| | | plcTaskPoleRelationService.remove(Wrappers.lambdaUpdate(PlcTaskPoleRelation.class) |
| | | .eq(PlcTaskPoleRelation::getPoleId, plcTaskPoleRelation.getPoleId()).eq(PlcTaskPoleRelation::getTaskId, taskId)); |
| | | }); |
| | | } |
| | | return "é¨åä»»å¡å 餿å,æ¸
é¤ä»»å¡å¤±è´¥çä»»å¡åæ°æ®ä¿ç!"; |
| | | } else if (ffff.get("fail").size() == ffff.get("all").size()) { |
| | | //å
¨é¨å¤±è´¥ ä¿çä»»å¡ |
| | | return "ä»»å¡å é¤å¤±è´¥ ,è¯·æ£æ¥ç¡¬ä»¶è®¾å¤!"; |
| | | } else { |
| | | return "ä»»å¡å é¤å¤±è´¥,æªç¥é误类å!"; |
| | | } |
| | | } else { |
| | | //ä¸åå¨ä»»å¡å
³ç³» 空任å¡ç´æ¥å é¤ |
| | | removeById(taskId); |
| | | return "ä»»å¡å 餿å"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ä¸ååä¸ªç¯æçä»»å¡ |
| | | */ |
| | | public boolean issuePlcTask(PlcTaskIssueParam param) { |
| | | |
| | | PlcTaskPoleRelation relation = plcTaskPoleRelationService.getOne(Wrappers.lambdaQuery(PlcTaskPoleRelation.class) |
| | | .eq(PlcTaskPoleRelation::getPoleId, param.getPoleId()).eq(PlcTaskPoleRelation::getTaskId, param.getTaskId())); |
| | | |
| | | if (relation == null) { |
| | | throw new BusinessException("æ¾ä¸å°ä»»å¡å
³ç³»,æ æ³è¡¥å"); |
| | | } |
| | | PlcTask plcTask = JSONObject.parseObject(relation.getSysScheduled(), PlcTask.class); |
| | | // PlcTask plcTask = getById(param.getTaskId()); |
| | | if (plcTask == null) { |
| | | throw new BusinessException("æ¾ä¸å°ä»»å¡"); |
| | | } |
| | | //转æ¢å¸§æä»¤ |
| | | String framePayload = buildControlFramePayload(plcTask.getOpenOrder(), plcTask.getCloseOrder(), plcTask.getControlOrder(), plcTask.getWeek()); |
| | | //åérrpc å¾å°åéç»æ |
| | | List<PlcTaskPoleRelation> plcTaskPoleRelationList = sendControllerFrame(plcTask, ListUtil.toList(param.getPoleId()), framePayload, plcTask.getPlcAdress()); |
| | | |
| | | /** |
| | | * ä¸åè·¯ç¯ä»»å¡æ¥å¿è®°å½å¼å§ |
| | | */ |
| | | List<String> poleCodeList = new ArrayList<>(); |
| | | List<Pole> list = SpringContextHolder.getBean(PoleService.class).list(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, param.getPoleId())); |
| | | if (CollectionUtil.isNotEmpty(list)) { |
| | | poleCodeList = list.stream().map(Pole::getDeviceCode).collect(Collectors.toList()); |
| | | } |
| | | String content = "{ä»»å¡IDï¼" + plcTask.getTaskId() + "ï¼ ä»»å¡åï¼" + plcTask.getTaskName() + "}," + " ç¯æIDï¼" + param.getPoleId() + " }"; |
| | | StoreOperationRecordsUtils.storeOperationData(poleCodeList, null, "ä¸åPLCä»»å¡", content); |
| | | /** |
| | | * ä¸åè·¯ç¯ä»»å¡æ¥å¿è®°å½ç»æ |
| | | */ |
| | | |
| | | |
| | | if (CollectionUtil.isNotEmpty(plcTaskPoleRelationList)) { |
| | | PlcTaskPoleRelation plcTaskPoleRelation = plcTaskPoleRelationList.get(0); |
| | | if (plcTaskPoleRelation.getIssueStatus() == 0) { |
| | | //ä¸åæå æ´æ°ç¡¬ä»¶å®æ¶ è¿åæå |
| | | relation.setDeviceScheduled(JSON.toJSONString(plcTaskPoleRelation)); |
| | | plcTaskPoleRelationService.updateById(relation); |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | public Map checkTask(PlcTaskParam param) { |
| | | /** |
| | | * éå¤ä»»å¡çç¯å¤´ |
| | | */ |
| | | String plcAddress = param.getPlcAddress(); |
| | | List<Long> poleIdList = param.getPoleIdList(); |
| | | List<PlcTaskPoleRelation> plcTaskPoleRelations = plcTaskPoleRelationService.list(Wrappers.lambdaQuery(PlcTaskPoleRelation.class) |
| | | .in(PlcTaskPoleRelation::getPoleId, poleIdList).eq(PlcTaskPoleRelation::getPlcAddress, plcAddress)); |
| | | //éå¤çä»»å¡id |
| | | List<Long> taskIds = plcTaskPoleRelations.stream().map(PlcTaskPoleRelation::getTaskId).collect(Collectors.toList()); |
| | | //éå¤çç¯æid |
| | | List<Long> oldPoleIds = plcTaskPoleRelations.stream().map(PlcTaskPoleRelation::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()); |
| | | oldPoleIds = oldPoleIds.stream().distinct().collect(Collectors.toList()); |
| | | newPoleIds = newPoleIds.stream().distinct().collect(Collectors.toList()); |
| | | Map map = new HashMap(); |
| | | if (!plcTaskPoleRelations.isEmpty()) { |
| | | |
| | | map.put("result", "false"); |
| | | map.put("newPoleIds", newPoleIds); |
| | | map.put("oldPoleIds", oldPoleIds); |
| | | map.put("taskIds", taskIds); |
| | | } else { |
| | | map.put("result", "true"); |
| | | map.put("msg", "ä»»å¡ä¸æ éå¤ç¯æå°å"); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | |
| | | public List<PlcTaskDto> listPlcTask(BaseConditionVO conditionVO, String keyword, Integer order, Integer seq) { |
| | | |
| | | //æåºå段 |
| | | String orderByResult = "task_id"; |
| | | //æ£åºãåå |
| | | String orderBySeq = OrderByEnums.ASC.getCode(); |
| | | if (order != null) { |
| | | switch (order) { |
| | | case 1: |
| | | orderByResult = OrderByEnums.LIGHT_TASK_UPDATE_TIME.getCode(); |
| | | break; |
| | | default: |
| | | } |
| | | } |
| | | if (seq != null) { |
| | | switch (seq) { |
| | | case 1: |
| | | orderBySeq = OrderByEnums.ASC.getCode(); |
| | | break; |
| | | case 2: |
| | | orderBySeq = OrderByEnums.DESC.getCode(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | //æåºæ¹å¼ |
| | | String orderBy = orderByResult + " " + orderBySeq; |
| | | |
| | | PageHelper.startPage(conditionVO.getPageNo(), conditionVO.getPageSize(), orderBy); |
| | | List<PlcTask> list = baseMapper.listTask(SecurityUtils.getClientId(), keyword, orderBy); |
| | | |
| | | |
| | | Page<PlcTaskDto> page = new Page<>(); |
| | | BeanUtils.copyProperties(list, page); |
| | | for (PlcTask plcTask : list) { |
| | | PlcTaskDto plcTaskDto = new PlcTaskDto(); |
| | | BeanUtils.copyProperties(plcTask, plcTaskDto); |
| | | plcTaskDto.setWeekList(TaskOrderUtil.parseLightWeek2List(plcTask.getWeek())); |
| | | |
| | | |
| | | //夿ç¯å¤´æ¯å¦åå¨ä»»å¡ |
| | | List<PlcTaskPoleRelation> plcTaskPoleRelationList = plcTaskPoleRelationService.list(Wrappers.<PlcTaskPoleRelation>lambdaQuery().eq(PlcTaskPoleRelation::getTaskId, plcTask.getTaskId())); |
| | | |
| | | //ä¸åæåçç¯ææ°é |
| | | Integer successCount = baseMapper.successCount(plcTaskDto.getTaskId()); |
| | | ///ä»»å¡ä¸æ»çç¯ææ°é |
| | | Integer toTalCount = baseMapper.toTalCount(plcTaskDto.getTaskId()); |
| | | if (successCount == null) { |
| | | successCount = 0; |
| | | } |
| | | if (toTalCount == null) { |
| | | toTalCount = 0; |
| | | } |
| | | if (toTalCount == 0) { |
| | | //ä»»å¡ä¸æ²¡æç¯æ |
| | | plcTaskDto.setSyncStatus("æªåæ¥"); |
| | | } else { |
| | | //ä»»å¡ä¸æç¯æ |
| | | if (successCount == 0) { |
| | | //ä¸åæåæª0 |
| | | plcTaskDto.setSyncStatus("æªåæ¥"); |
| | | } else if (successCount != 0 && successCount < toTalCount) { |
| | | //åå¨ä¸åæå ä½å¹¶æªå
¨é¨æå |
| | | plcTaskDto.setSyncStatus("é¨å忥"); |
| | | } else if (toTalCount.equals(successCount) && toTalCount != 0 && successCount != 0) { |
| | | //å
¨é¨æå |
| | | plcTaskDto.setSyncStatus("已忥"); |
| | | } else { |
| | | //æªç¥ç±»å |
| | | plcTaskDto.setSyncStatus("åæ¥ç¶æåºé"); |
| | | } |
| | | } |
| | | page.add(plcTaskDto); |
| | | } |
| | | return page; |
| | | } |
| | | |
| | | /** |
| | | * æ§è¡ä¸çè·¯ç¯ä»»å¡ |
| | | * |
| | | * @return |
| | | */ |
| | | public List<PlcTaskDto> listTask() { |
| | | Long clientId = SecurityUtils.getClientId(); |
| | | List<PlcTask> plcTasks = plcTaskMapper.listPlcTask(clientId); |
| | | Page<PlcTaskDto> page = new Page<>(); |
| | | BeanUtils.copyProperties(plcTasks, page); |
| | | for (PlcTask plcTask : plcTasks) { |
| | | PlcTaskDto plcTaskDto = new PlcTaskDto(); |
| | | BeanUtils.copyProperties(plcTask, plcTaskDto); |
| | | plcTaskDto.setWeekList(TaskOrderUtil.parseLightWeek2List(plcTask.getWeek())); |
| | | page.add(plcTaskDto); |
| | | } |
| | | return page; |
| | | } |
| | | |
| | | /** |
| | | * ä»»å¡è¯¦æ
|
| | | */ |
| | | public Object detailPlcTask(Long taskId) { |
| | | PlcTask plcTask = getById(taskId); |
| | | if (plcTask == null) { |
| | | throw new BusinessException("æ¾ä¸å°ä»»å¡"); |
| | | } |
| | | PlcTaskInfoVO vo = new PlcTaskInfoVO(); |
| | | |
| | | // LightTaskDto plcTaskDto = new LightTaskDto(); |
| | | // BeanUtils.copyProperties(plcTask, plcTaskDto); |
| | | |
| | | plcTask.setWeekList(TaskOrderUtil.parseLightWeek2List(plcTask.getWeek())); |
| | | |
| | | vo.setPlcTask(plcTask); |
| | | List<PlcTaskRelationVO> relations = new ArrayList<>(); |
| | | List<PlcTaskPoleRelation> taskPoleRelations = plcTaskPoleRelationService.list(Wrappers.lambdaQuery(PlcTaskPoleRelation.class) |
| | | .eq(PlcTaskPoleRelation::getTaskId, taskId)); |
| | | if (taskPoleRelations != null && !taskPoleRelations.isEmpty()) { |
| | | taskPoleRelations.forEach( |
| | | relation -> { |
| | | PlcTaskRelationVO plcTaskRelationVO = new PlcTaskRelationVO(); |
| | | plcTaskRelationVO.setPlcAddress(relation.getPlcAddress()); |
| | | plcTaskRelationVO.setIssueStatus(relation.getIssueStatus()); |
| | | plcTaskRelationVO.setPoleId(relation.getPoleId()); |
| | | Pole byId = poleService.getById(relation.getPoleId()); |
| | | if (byId != null) { |
| | | plcTaskRelationVO.setPoleName(byId.getPoleName()); |
| | | } |
| | | |
| | | PlcTaskVO sys = JSONObject.parseObject(relation.getSysScheduled(), PlcTaskVO.class); |
| | | sys.setWeekList(TaskOrderUtil.parseLightWeek2List(sys.getWeek())); |
| | | plcTaskRelationVO.setSysScheduled(sys); |
| | | |
| | | PlcTaskVO device = JSONObject.parseObject(relation.getDeviceScheduled(), PlcTaskVO.class); |
| | | if (device != null) { |
| | | device.setWeekList(TaskOrderUtil.parseLightWeek2List(device.getWeek())); |
| | | plcTaskRelationVO.setDeviceScheduled(device); |
| | | } |
| | | relations.add(plcTaskRelationVO); |
| | | } |
| | | ); |
| | | |
| | | vo.setRelations(relations); |
| | | } |
| | | |
| | | // List<LightTaskStatusAndPole> plcTaskStatusAndPoles = plcTaskPoleRelationService.listPoleAndStatusIdByTaskId(taskId); |
| | | |
| | | // return MapUtil.builder().put("task", plcTask).put("poles", plcTaskStatusAndPoles).build(); |
| | | return vo; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | case PoleBindingEnums.LIGHT: |
| | | size = SpringContextHolder.getBean(LightService.class).list(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, param.getDeviceCode())).size(); |
| | | break; |
| | | case PoleBindingEnums.PLC: |
| | | size = SpringContextHolder.getBean(PlcService.class).list(Wrappers.lambdaQuery(Plc.class).eq(Plc::getDeviceCode, param.getDeviceCode())).size(); |
| | | break; |
| | | case PoleBindingEnums.VONNOX: |
| | | size = SpringContextHolder.getBean(LedPlayerEntityService.class).list(Wrappers.lambdaQuery(LedPlayerEntity.class).eq(LedPlayerEntity::getSn, param.getDeviceCode())).size(); |
| | | break; |
| | |
| | | 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.A7PlcResetReqInnerFrame; |
| | | 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.dao.domain.*; |
| | | import com.sandu.ximon.dao.enums.OrderByEnums; |
| | | import com.sandu.ximon.dao.mapper.PoleMapper; |
| | | import eu.bitwalker.useragentutils.DeviceType; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.RandomStringUtils; |
| | |
| | | if (deviceName.isEmpty()) { |
| | | throw new BusinessException("è¯¥ç¯æMac为空"); |
| | | } |
| | | IRequestFrame build = FrameBuilder.builderA5().orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode()).innerFrame(new A5LightResetReqInnerFrame()).build(); |
| | | Integer deviceType = byId.getDeviceType(); |
| | | |
| | | IRequestFrame build = null; |
| | | if (deviceType < 2){ |
| | | build = FrameBuilder.builderA5().orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode()).innerFrame(new A5LightResetReqInnerFrame()).build(); |
| | | } |
| | | else if (deviceType == 2){ |
| | | build = FrameBuilder.builderA7().orderType(A7OrderEnum.REQUEST_PLC_DATA.getCode()).innerFrame(new A7PlcResetReqInnerFrame()).build(); |
| | | |
| | | } |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, build); |
| | | |
| | | StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "ç¯ææ¢å¤åºå设置", build, commonFrame); |
| | | |
| | | System.out.println(commonFrame.toString()); |
| | | IRequestFrame iRequestFrame = FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame()).orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build(); |
| | | CommonFrame rebootFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, iRequestFrame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "ç¯æéå¯", iRequestFrame, commonFrame); |
| | |
| | | pole.setDeviceType(0); |
| | | } else if ("01".equals(a1DeviceMacRespInnerFrame.getType())) { |
| | | pole.setDeviceType(1); |
| | | } else if ("02".equals(a1DeviceMacRespInnerFrame.getType())) { |
| | | pole.setDeviceType(2); |
| | | } |
| | | |
| | | pole.setPoleCode(generatePoleCode()); |
| | |
| | | boolean result = saveOrUpdate(pole); |
| | | |
| | | if (result) { |
| | | Light light = SpringContextHolder.getBean(LightService.class).getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, pole.getDeviceCode()).last("limit 1")); |
| | | if (pole.getDeviceType() < 2) { |
| | | Light light = SpringContextHolder.getBean(LightService.class). |
| | | getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, pole.getDeviceCode()).last("limit 1")); |
| | | if (light == null) { |
| | | light = new Light(); |
| | | light.setDeviceCode(uniqueMac); |
| | | light.setLightCount(2); |
| | | SpringContextHolder.getBean(LightService.class).save(light); |
| | | } |
| | | } else if (pole.getDeviceType() == 2) { |
| | | Plc plc = SpringContextHolder.getBean(PlcService.class). |
| | | getOne(Wrappers.lambdaQuery(Plc.class).eq(Plc::getDeviceCode,pole.getDeviceCode()).last("limit 1")); |
| | | if (plc == null){ |
| | | plc = new Plc(); |
| | | plc.setDeviceCode(uniqueMac); |
| | | plc.setPlcCount(3); |
| | | SpringContextHolder.getBean(PlcService.class).save(plc); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.utils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import java.lang.reflect.Field; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | |
| | | /** |
| | | * MybatisPluså·¥å
·ç±» |
| | | * |
| | | * @author van |
| | | * @since 2022-12-16 10:54:58 |
| | | */ |
| | | public class MybatisPlusUtil { |
| | | |
| | | /** |
| | | * å¯¹ä¼ å
¥å®ä½å¨ææ¼æ¥æ¥è¯¢æ¡ä»¶ |
| | | * |
| | | * @param target æ¥è¯¢å®ä½ |
| | | * @param <T> å®ä½ç±»å |
| | | * @return è¿åæ¥è¯¢æ¡ä»¶ |
| | | */ |
| | | public static <T> QueryWrapper<T> queryWrapperBuilder(T target) { |
| | | |
| | | QueryWrapper<T> queryWrapper = new QueryWrapper<>(); |
| | | //è·åå®ä½ææå±æ§éå |
| | | Field[] declaredFields = target.getClass().getDeclaredFields(); |
| | | //éå屿§éåï¼è·åå±åç±»åå屿§å¼ |
| | | for (Field declaredField : declaredFields) { |
| | | declaredField.setAccessible(true); |
| | | //è·å屿§å |
| | | String fieldName = declaredField.getName(); |
| | | |
| | | //屿§å¼ |
| | | Object value = null; |
| | | try { |
| | | //è·å屿§å¼ |
| | | value = declaredField.get(target); |
| | | } catch (IllegalAccessException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //è·å屿§ç±»å |
| | | String simpleName = declaredField.getType().getSimpleName(); |
| | | |
| | | //è·åTableField注解对象ï¼ç¨äºå¤æè¯¥å段æ¯å¦å¨æ°æ®åºä¸ä½¿ç¨ä¸å线 |
| | | TableField tableFieldAnnotation = declaredField.getAnnotation(TableField.class); |
| | | |
| | | //妿æ¯Stringç±»åï¼æ¼æ¥æ¨¡ç³æ¥æ¾æ¡ä»¶ï¼å¦åæ¼æ¥ç弿¥æ¾ï¼å¿½ç¥serialVersionUID屿§ |
| | | if (simpleName.equals("String")) { |
| | | //è¥åå¨tableField注解ï¼åä½¿ç¨æ³¨è§£ä¸çvalueä½ä¸ºæ¥è¯¢ååï¼è¥ä¸åå¨ï¼å使ç¨å±æ§åä½ä¸ºåå |
| | | if(tableFieldAnnotation !=null){ |
| | | String annotationValue = tableFieldAnnotation.value(); |
| | | queryWrapper.like(value != null, annotationValue, value); |
| | | }else { |
| | | queryWrapper.like(value != null, fieldName, value); |
| | | } |
| | | |
| | | } else if (!fieldName.equals("serialVersionUID")) { |
| | | //è¥åå¨tableField注解ï¼åä½¿ç¨æ³¨è§£ä¸çvalueä½ä¸ºæ¥è¯¢ååï¼è¥ä¸åå¨ï¼å使ç¨å±æ§åä½ä¸ºåå |
| | | if(tableFieldAnnotation !=null){ |
| | | String annotationValue = tableFieldAnnotation.value(); |
| | | queryWrapper.eq(value != null, annotationValue, value); |
| | | }else { |
| | | queryWrapper.eq(value != null, fieldName, value); |
| | | } |
| | | } |
| | | } |
| | | return queryWrapper; |
| | | } |
| | | |
| | | /** |
| | | * @param c éè¦è·å¾æ¥è¯¢æ¡ä»¶çå®ä½å¯¹è±¡ |
| | | * @param <E> å®ä½å¯¹è±¡ç±»å |
| | | * @return LambdaQueryWrapper |
| | | */ |
| | | public static <E> LambdaQueryWrapper<E> getLQWrapper(Class<E> c) { |
| | | |
| | | return new LambdaQueryWrapper<>(); |
| | | } |
| | | |
| | | /** |
| | | * @param c éè¦è·å¾æ¥è¯¢æ¡ä»¶çå®ä½å¯¹è±¡ |
| | | * @param <E> å®ä½å¯¹è±¡ç±»å |
| | | * @return QueryWrapper |
| | | */ |
| | | public static <E> QueryWrapper<E> getQWrapper(Class<E> c) { |
| | | |
| | | return new QueryWrapper<>(); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.vo; |
| | | |
| | | import com.sandu.ximon.dao.domain.LightTask; |
| | | import com.sandu.ximon.dao.domain.PlcTask; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author van |
| | | */ |
| | | @Data |
| | | public class PlcTaskInfoVO { |
| | | |
| | | /** |
| | | * ä»»å¡ |
| | | */ |
| | | private PlcTask plcTask; |
| | | |
| | | private List<PlcTaskRelationVO> relations; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author van |
| | | */ |
| | | @Data |
| | | public class PlcTaskRelationVO { |
| | | |
| | | private Long poleId; |
| | | private String poleName; |
| | | |
| | | |
| | | private String plcAddress; |
| | | |
| | | /** |
| | | * ä»»å¡ä¸åç¶æï¼0æåï¼1æ ¡éªç é误ï¼2é¿åº¦é误ï¼3åflashé误ï¼255å
¶ä»é误 |
| | | */ |
| | | private Integer issueStatus; |
| | | |
| | | |
| | | /** |
| | | * ç³»ç»å®æ¶ |
| | | */ |
| | | private PlcTaskVO sysScheduled; |
| | | |
| | | /** |
| | | * ç¡¬ä»¶å®æ¶ |
| | | */ |
| | | private PlcTaskVO deviceScheduled; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author van |
| | | */ |
| | | @Data |
| | | public class PlcTaskVO { |
| | | |
| | | 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 plcAdress; |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | spring: |
| | | # 叿¢¦æ¬å°å¼å |
| | | datasource: |
| | | # æ°æ®åºç¨æ·å |
| | | username: root |
| | | # æ°æ®åºå¯ç |
| | | password: zhxm2512209 |
| | | url: jdbc:mysql://39.103.154.108:2512/xm_dev?useUnicode=true&autoReconnect=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | druid: |
| | | connection-init-sqls: set names utf8mb4 |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | redis: |
| | | host: 39.103.154.108 |
| | | password: zhxm2512209 |
| | | port: 6379 |
| | | database: 0 |
| | | server: |
| | | port: 20017 |
| | | sandu: |
| | | jwt: |
| | | header: Authorization |
| | | # 令çåç¼ |
| | | token-start-with: Bearer |
| | | # å¿
é¡»ä½¿ç¨æå°88ä½çBase64对该令çè¿è¡ç¼ç |
| | | base64-secret: U1GZNSKOH43V19GNIVE8HUYM9H86K657V1D66EAVSL9Q023J4JNWE44BNHCS6V9E66BPKF0KXUI5R1ZOYK2OWZZYALPD07JHOYUROL930UGJQUJDNAEYNTMUS27BHKTJEF9011DGGQ4QT9BN6CM2P9SY2VV2MZKJPCOW9YIGN0VJ |
| | | # 令çè¿ææ¶é´ æ¤å¤åä½/æ¯«ç§ ï¼å¯å¨æ¤ç½ç«çæ https://www.convertworld.com/zh-hans/time/milliseconds.html 1个æ |
| | | token-validity-in-seconds: 2629800000 |
| | | # å¨çº¿ç¨æ·key |
| | | online-key: online-token |
| | | # æ¯å¦å¯å¨redisç¼åç¨æ·ä¿¡æ¯ |
| | | cache-online: false |
| | | #************************æ¬å°ä¸ä¼ æä»¶é
ç½®************************ |
| | | upload: |
| | | #æä»¶æå¡å¨è·¯å¾ |
| | | upload-root-path: D:\file\ |
| | | storage: local |
| | | #æå¡å¨æä»¶åç¼ |
| | | real-url: http://localhost/ |
| | | common: |
| | | urlPrefix: http://localhost/ |
| | | quartz: |
| | | enable: true |
| | | |
| | | # MQTTçå¬ |
| | | listenter: |
| | | isOpen: true |
| | | |
| | | minio: |
| | | endpoint: 47.106.172.9 |
| | | port: 9000 |
| | | accessKey: minioadmin |
| | | secretKey: zhxm2512209 |
| | | secure: false |
| | | |
| | | |
| | | # ledå±å¹æå¡å¨å°åï¼æ´æ¹éè¦åæ¶æ´æ¹ï¼ |
| | | realtime-server: |
| | | # 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/ |
| | | |
| | | |
| | | server-conf: |
| | | ip: 127.0.0.1 # 47.106.172.9/101.132.131.91 |
| | | |
| | | |
| | | |
| | | nova-conf: #诺ç¦åè° |
| | | notify-url: http://39.103.154.108:20018/serv/vnnox/progress |
| | | screen-shot-notify-url: http://39.103.154.108:20018/serv/vnnox/screenshot |
| | | status-notify-url: http://39.103.154.108:20018/serv/vnnox/asyncStatus |
| | | |
| | | #iot产åç§é¥ |
| | | iot: |
| | | access_key: LTAI4G27Af8MZEF55phdMQ4y |
| | | access_secret: KUc2yOtr7TRB4FuF5Wr0dWeTblbEuh |
| | | |
| | | #é¿éäºossé
ç½® |
| | | oss-conf: |
| | | end-point: oss-cn-shanghai.aliyuncs.com |
| | | key-id: LTAI5tPdpt5wvJyLipRijFSP |
| | | key-secret: 1ahYfCKd0yTddsUnuDLQzI23MLh4VQ |
| | | bucket-name: ximonsmart |
| | | |
| | | #æ°è¯ºç¦ |
| | | new-nova: |
| | | #ä¾èµå°å |
| | | string-path: D:\file\novaWin\bin\viplexcore.dll |
| | | #èç®çæè·¯å¾ |
| | | out-put-path: D:\file\temp |
| | | new-nova-file: |
| | | upload: |
| | | #æä»¶æå¡å¨è·¯å¾ |
| | | upload-root-path: D:\file\ |
| | | storage: local |
| | | #æå¡å¨æä»¶åç¼ |
| | | file-url: http://192.168.0.12:20017/file/ |
| | | #è¯ºç¦æªå±åæ¾è·¯å¾ æä»¶å¤¹å¿
é¡»åå¨ ä¸æ¯æå¡å¨æä»¶è·¯å¾(upload-root-path)ä¸çåæä»¶å¤¹ |
| | | screen-shot-path: D:\file\screenShot\ |
| | | |
| | | |
| | | |
| | | customer: |
| | | mqtt: |
| | | broker: tcp://127.0.0.1:1883 |
| | | clientList: |
| | | #客æ·ç«¯ID |
| | | - clientId: java_server_msg |
| | | #çå¬ä¸»é¢ |
| | | subscribeTopic: v1/devices/response/+ |
| | | #ç¨æ·å |
| | | userName: server_admin |
| | | #å¯ç |
| | | password: zhxm2512209 |
| | | #ä¸åä¸»é¢ |
| | | publishTopic: v1/devices/request/ |
| | | #çå¬ä¸ä¸çº¿ |
| | | - clientId: java_server_status |
| | | #çå¬ä¸»é¢ |
| | | subscribeTopic: $SYS/brokers/+/clients/# |
| | | #ç¨æ·å |
| | | userName: server_admin |
| | | #å¯ç |
| | | password: zhxm2512209 |
| | | #ä¸åä¸»é¢ |
| | | publishTopic: v1/devices/request/ |
| | | |
| | |
| | | spring: |
| | | profiles: |
| | | active: prod |
| | | active: xm_local |
| | | jackson: |
| | | date-format: yyyy-MM-dd HH:mm:ss |
| | | time-zone: GMT+8 |