whyclxw
2024-08-29 d2edc7e2d7f220148b69d7b5e64e46ea02351241
设备信息实时推送
7个文件已修改
86 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/DevInfController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/DevInfDto.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/DevInfMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/db_lithium_ram_db/DevInf.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/DevInfService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/webSocket/DevInfSocket.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/DevInfMapper.xml 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/DevInfController.java
@@ -39,4 +39,11 @@
    public Response getLine(){
        return service.getLine(101);
    }
    @ApiOperation(value = "编辑设备信息")
    @PostMapping("uodateInf")
    public Response uodateInf(@RequestBody DevInf dinf){
        return service.uodateInf(dinf);
    }
}
src/main/java/com/whyc/dto/DevInfDto.java
@@ -1,9 +1,19 @@
package com.whyc.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
public class DevInfDto {
    private int pageNum;
    private int pageSize;
    private int devType;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date startTime;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date endTime;
    private int devOnline;
    private int uid;
    public int getPageNum() {
@@ -29,4 +39,36 @@
    public void setDevType(int devType) {
        this.devType = devType;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public int getDevOnline() {
        return devOnline;
    }
    public void setDevOnline(int devOnline) {
        this.devOnline = devOnline;
    }
    public int getUid() {
        return uid;
    }
    public void setUid(int uid) {
        this.uid = uid;
    }
}
src/main/java/com/whyc/mapper/DevInfMapper.java
@@ -1,5 +1,6 @@
package com.whyc.mapper;
import com.whyc.dto.DevInfDto;
import com.whyc.pojo.db_lithium_ram_db.DevInf;
import lombok.Value;
import org.apache.ibatis.annotations.Param;
@@ -9,7 +10,7 @@
public interface DevInfMapper extends CustomMapper<DevInf>{
    //查询包机人管理的设备id
    List<DevInf> getAllInf(@Param("uid") Integer uid,@Param("devType") Integer devType);
    List<DevInf> getAllInf(@Param("dto") DevInfDto dto);
    //查询该类型最大设备编号
    Integer getMaxDevId(Integer devType);
    //获取左侧泪飙
src/main/java/com/whyc/pojo/db_lithium_ram_db/DevInf.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -11,6 +12,7 @@
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
 * <p>
@@ -47,6 +49,10 @@
    @ApiModelProperty(value = "设备状态;0:断开,1在线")
    private int devOnline;
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date createTime;
    @TableField(exist = false)
    private A200Realstate a200sTate;
src/main/java/com/whyc/service/DevInfService.java
@@ -1,6 +1,7 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -15,6 +16,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -37,6 +39,7 @@
        //判断设备类型生成devId
        int devId=getDevId(devInf.getDevType());
        devInf.setDevId(devId);
        devInf.setCreateTime(new Date());
        int bl=mapper.insert(devInf);
        return new Response().set(1,bl>0);
    }
@@ -57,7 +60,8 @@
    public Response getAllInf(Integer uid, DevInfDto devInfDto) {
        Map<String, Object> allMap = new HashMap<>();
        PageHelper.startPage(devInfDto.getPageNum(), devInfDto.getPageSize());
        List<DevInf> listype=mapper.getAllInf(uid,devInfDto.getDevType());
        devInfDto.setUid(uid);
        List<DevInf> listype=mapper.getAllInf(devInfDto);
        PageInfo pageInfo=new PageInfo(listype);
        List<DevInf> list=mapper.getLine(uid);
@@ -117,4 +121,11 @@
        allMap.put("actmList",actmList);
        return new Response().setII(1,allMap.size()>0,allMap,"获取左侧列表");
    }
    //编辑设备信息
    public Response uodateInf(DevInf dinf) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("dev_id",dinf.getDevId());
        int flag=mapper.update(dinf,wrapper);
        return new Response().set(1,flag>0,"编辑设备信息");
    }
}
src/main/java/com/whyc/webSocket/DevInfSocket.java
@@ -47,7 +47,7 @@
    }
    @OnMessage
    public void onMessage(Session session, String message) {
        DevInfDto devInfDto = ActionUtil.getGson().fromJson(message, DevInfDto.class);
        DevInfDto devInfDto = ActionUtil.getGson("yyyy-MM-dd").fromJson(message, DevInfDto.class);
        //UserInf user = (UserInf) this.httpSession.getAttribute("user");
        //final int userId = user.getUid();
        final int userId = 101;
src/main/resources/mapper/DevInfMapper.xml
@@ -5,13 +5,20 @@
    <select id="getAllInf" resultType="com.whyc.pojo.db_lithium_ram_db.DevInf">
        select * from db_lithium_ram_db.tb_dev_inf
        <where>
            dev_type=#{devType}
            dev_type=#{dto.devType}
            and dev_online=#{dto.devOnline}
            <if test="dto.startTime!=null">
                and create_time>=#{dto.startTime}
            </if>
            <if test="dto.endTime!=null">
                and create_time&lt;=#{dto.endTime}
            </if>
            and dev_id in (
            SELECT distinct dev_id from db_user.tb_battgroup_baojigroup,db_user.tb_battgroup_usr
            <where>
                tb_battgroup_baojigroup.baoji_group_id=tb_battgroup_usr.baoji_group_id
                <if test="uid!=null">
                    and uid=#{uid}
                <if test="dto.uid!=null">
                    and uid=#{dto.uid}
                </if>
            </where>
            )