101captain
2021-09-07 87b163d4034cf6d74cf075391b9fb1183afede5e
物业报警相关提交
18个文件已添加
3个文件已修改
724 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/property/ComPropertyAlarmVO.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/pom.xml 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/ServicePropertyApplication.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/api/ComPropertyAlarmApi.java 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/api/ComPropertyEquipmentApi.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/api/ComPropertyRepairApi.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/dao/ComPropertyAlarmDao.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/dao/ComPropertyEquipmentDao.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/entity/ComPropertyAlarm.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/entity/ComPropertyEquipment.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/MyDecoder.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServer.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServerHandler.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/ServerChannelInitializer.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/ComPropertyAlarmService.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/ComPropertyEquipmentService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/impl/ComPropertyAlarmServiceImpl.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/impl/ComPropertyEquipmentServiceImpl.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/util/MyTools.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/resources/mapper/ComPropertyAlarmMapper.xml 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/resources/mapper/ComPropertyEquipmentMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/property/ComPropertyAlarmVO.java
New file
@@ -0,0 +1,34 @@
package com.panzhihua.common.model.vos.property;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel("")
public class ComPropertyAlarmVO {
    private Integer id;
    /**
     * 设备号
     */
    @ApiModelProperty(value = "设备号")
    private String serialNo;
    /**
     * 报警类型 1一键报警 2长时间无应答报警
     */
    @ApiModelProperty(value = "报警类型 1一键报警 2长时间无应答报警")
    private Integer type;
    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    @ApiModelProperty(value = "位置信息")
    private String position;
}
springcloud_k8s_panzhihuazhihuishequ/service_property/pom.xml
@@ -55,6 +55,21 @@
            <groupId>com.netflix.hystrix</groupId>
            <artifactId>hystrix-javanica</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-integration</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>4.1.36.Final</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/ServicePropertyApplication.java
@@ -1,5 +1,6 @@
package com.panzhihua.service_property;
import com.panzhihua.service_property.netty.NettyServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.SpringCloudApplication;
@@ -7,6 +8,8 @@
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import java.net.InetSocketAddress;
@SpringCloudApplication
@EnableFeignClients(basePackages = {"com.panzhihua.common.service"})
@@ -18,6 +21,8 @@
    public static void main(String[] args) {
        SpringApplication.run(ServicePropertyApplication.class, args);
        NettyServer nettyServer = new NettyServer();
        nettyServer.start(new InetSocketAddress("192.168.5.149", 20012));
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/api/ComPropertyAlarmApi.java
New file
@@ -0,0 +1,85 @@
package com.panzhihua.service_property.api;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.service_property.entity.ComPropertyAlarm;
import com.panzhihua.service_property.service.ComPropertyAlarmService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;
/**
 * (ComPropertyAlarm)表控制层
 *
 * @author makejava
 * @since 2021-09-07 13:29:50
 */
@RestController
@RequestMapping("comPropertyAlarm")
public class ComPropertyAlarmApi {
    /**
     * 服务对象
     */
    @Resource
    private ComPropertyAlarmService comPropertyAlarmService;
    /**
     * 分页查询所有数据
     * @param commonPage 查询实体
     * @return 所有数据
     */
    @GetMapping("queryAll")
    public R selectAll(CommonPage commonPage) {
        return this.comPropertyAlarmService.pageList(commonPage);
    }
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public R selectOne(@PathVariable("id") Integer id) {
        return R.ok(this.comPropertyAlarmService.getById(id));
    }
    /**
     * 新增数据
     *
     * @param comPropertyAlarm 实体对象
     * @return 新增结果
     */
    @PostMapping
    public R insert(@RequestBody ComPropertyAlarm comPropertyAlarm) {
        return R.ok(this.comPropertyAlarmService.save(comPropertyAlarm));
    }
    /**
     * 修改数据
     *
     * @param comPropertyAlarm 实体对象
     * @return 修改结果
     */
    @PostMapping("/update")
    public R update(@RequestBody ComPropertyAlarm comPropertyAlarm) {
        return R.ok(this.comPropertyAlarmService.updateById(comPropertyAlarm));
    }
    /**
     * 删除数据
     *
     * @param id 主键结合
     * @return 删除结果
     */
    @GetMapping("del")
    public R delete(@RequestParam("id") Long id) {
        return R.ok(this.comPropertyAlarmService.removeById(id));
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/api/ComPropertyEquipmentApi.java
New file
@@ -0,0 +1,86 @@
package com.panzhihua.service_property.api;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.panzhihua.common.model.vos.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.service_property.entity.ComPropertyEquipment;
import com.panzhihua.service_property.service.ComPropertyEquipmentService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;
/**
 * (ComPropertyEquipment)表控制层
 *
 * @author makejava
 * @since 2021-09-07 13:29:33
 */
@RestController
@RequestMapping("comPropertyEquipment")
public class ComPropertyEquipmentApi {
    /**
     * 服务对象
     */
    @Resource
    private ComPropertyEquipmentService comPropertyEquipmentService;
    /**
     * 分页查询所有数据
     *
     * @param page                 分页对象
     * @param comPropertyEquipment 查询实体
     * @return 所有数据
     */
    @GetMapping("queryAll")
    public R selectAll(Page<ComPropertyEquipment> page, ComPropertyEquipment comPropertyEquipment) {
        return R.ok(this.comPropertyEquipmentService.page(page, new QueryWrapper<>(comPropertyEquipment)));
    }
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public R selectOne(@PathVariable("id") Integer id) {
        return R.ok(this.comPropertyEquipmentService.getById(id));
    }
    /**
     * 新增数据
     *
     * @param comPropertyEquipment 实体对象
     * @return 新增结果
     */
    @PostMapping
    public R insert(@RequestBody ComPropertyEquipment comPropertyEquipment) {
        return R.ok(this.comPropertyEquipmentService.save(comPropertyEquipment));
    }
    /**
     * 修改数据
     *
     * @param comPropertyEquipment 实体对象
     * @return 修改结果
     */
    @PostMapping("/update")
    public R update(@RequestBody ComPropertyEquipment comPropertyEquipment) {
        return R.ok(this.comPropertyEquipmentService.updateById(comPropertyEquipment));
    }
    /**
     * 删除数据
     *
     * @param id 主键结合
     * @return 删除结果
     */
    @GetMapping("del")
    public R delete(@RequestParam("id") Long id) {
        return R.ok(this.comPropertyEquipmentService.removeById(id));
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/api/ComPropertyRepairApi.java
@@ -1,10 +1,8 @@
package com.panzhihua.service_property.api;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.vos.property.ComPropertyRepairVO;
import com.panzhihua.service_property.entity.ComPropertyRepair;
import com.panzhihua.service_property.service.ComPropertyRepairService;
@@ -12,7 +10,6 @@
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.Serializable;
/**
 * (ComPropertyRepair)表控制层
@@ -89,4 +86,5 @@
    public R delete(@RequestParam("id") Long id) {
        return R.ok(this.comPropertyRepairService.removeById(id));
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/dao/ComPropertyAlarmDao.java
New file
@@ -0,0 +1,21 @@
package com.panzhihua.service_property.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.property.ComPropertyAlarmVO;
import org.apache.ibatis.annotations.Mapper;
import com.panzhihua.service_property.entity.ComPropertyAlarm;
import org.apache.ibatis.annotations.Param;
/**
 * (ComPropertyAlarm)表数据库访问层
 *
 * @author makejava
 * @since 2021-09-07 13:29:49
 */
@Mapper
public interface ComPropertyAlarmDao extends BaseMapper<ComPropertyAlarm> {
    IPage<ComPropertyAlarmVO> selectList(Page page, @Param("commonPage") CommonPage commonPage);
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/dao/ComPropertyEquipmentDao.java
New file
@@ -0,0 +1,16 @@
package com.panzhihua.service_property.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import com.panzhihua.service_property.entity.ComPropertyEquipment;
/**
 * (ComPropertyEquipment)表数据库访问层
 *
 * @author makejava
 * @since 2021-09-07 13:29:32
 */
@Mapper
public interface ComPropertyEquipmentDao extends BaseMapper<ComPropertyEquipment> {
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/entity/ComPropertyAlarm.java
New file
@@ -0,0 +1,59 @@
package com.panzhihua.service_property.entity;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
 * (ComPropertyAlarm)表实体类
 *
 * @author makejava
 * @since 2021-09-07 13:29:49
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("")
public class ComPropertyAlarm implements Serializable {
    private static final long serialVersionUID = -79284364749441136L;
    @TableId(type = IdType.AUTO)
    private Integer id;
    /**
     * 设备号
     */
    @ApiModelProperty(value = "设备号")
    private String serialNo;
    /**
     * 报警类型 1一键报警 2长时间无应答报警
     */
    @ApiModelProperty(value = "报警类型 1一键报警 2长时间无应答报警")
    private Integer type;
    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    public interface  type{
        int one=1;
        int time=2;
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/entity/ComPropertyEquipment.java
New file
@@ -0,0 +1,52 @@
package com.panzhihua.service_property.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
 * (ComPropertyEquipment)表实体类
 *
 * @author makejava
 * @since 2021-09-07 13:29:31
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("")
public class ComPropertyEquipment implements Serializable {
    private static final long serialVersionUID = -71395005704296906L;
    @TableId(type = IdType.AUTO)
    private Integer id;
    /**
     * 设备编号
     */
    @ApiModelProperty(value = "设备编号")
    private String serialNo;
    /**
     * 报警位置
     */
    @ApiModelProperty(value = "报警位置")
    private String position;
    /**
     * 物业id
     */
    @ApiModelProperty(value = "物业id")
    private Integer propertyId;
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/MyDecoder.java
New file
@@ -0,0 +1,25 @@
package com.panzhihua.service_property.netty;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
public class MyDecoder extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
        String HEXES = "0123456789ABCDEF";
        byte[] req = new byte[msg.readableBytes()];
        msg.readBytes(req);
        final StringBuilder hex = new StringBuilder(2 * req.length);
        for (int i = 0; i < req.length; i++) {
            byte b = req[i];
            hex.append(HEXES.charAt((b & 0xF0) >> 4))
                    .append(HEXES.charAt((b & 0x0F)));
        }
        out.add(hex.toString());
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServer.java
New file
@@ -0,0 +1,44 @@
package com.panzhihua.service_property.netty;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import lombok.extern.slf4j.Slf4j;
import java.net.InetSocketAddress;
@Slf4j
public class NettyServer {
    public void start(InetSocketAddress socketAddress) {
        //new 一个主线程组
        EventLoopGroup bossGroup = new NioEventLoopGroup(1);
        //new 一个工作线程组
        EventLoopGroup workGroup = new NioEventLoopGroup(200);
        ServerBootstrap bootstrap = new ServerBootstrap()
                .group(bossGroup, workGroup)
                .channel(NioServerSocketChannel.class)
                .childHandler(new ServerChannelInitializer())
                .localAddress(socketAddress)
                //设置队列大小
                .option(ChannelOption.SO_BACKLOG, 1024)
                // 两小时内没有数据的通信时,TCP会自动发送一个活动探测数据报文
                .childOption(ChannelOption.SO_KEEPALIVE, true);
        //绑定端口,开始接收进来的连接
        try {
            ChannelFuture future = bootstrap.bind(socketAddress).sync();
            log.info("服务器启动开始监听端口: {}", socketAddress.getPort());
            future.channel().closeFuture().sync();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            //关闭主线程组
            bossGroup.shutdownGracefully();
            //关闭工作线程组
            workGroup.shutdownGracefully();
        }
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServerHandler.java
New file
@@ -0,0 +1,62 @@
package com.panzhihua.service_property.netty;
import cn.hutool.core.date.DateUtil;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.service_property.dao.ComPropertyAlarmDao;
import com.panzhihua.service_property.entity.ComPropertyAlarm;
import com.panzhihua.service_property.util.MyTools;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
@Slf4j
@Component
public class NettyServerHandler extends ChannelInboundHandlerAdapter {
    @Resource
    private ComPropertyAlarmDao comPropertyAlarmDao;
    /**
     * 客户端连接会触发
     */
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        log.info("Channel active......");
    }
    /**
     * 客户端发消息会触发
     */
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        MyTools myTools=new MyTools();
        log.info("服务器收到消息: {}", msg.toString());
        if(msg.toString().startsWith("4A1802")){
            myTools.writeToClient("404A021823",ctx,"状态包");
        }
        if(msg.toString().startsWith("4A0C0134")){
            myTools.writeToClient("404A01"+ DateUtils.getDateFormatString(new Date(),"HHmmss")+"23",ctx,"心跳包");
        }
        if(msg.toString().startsWith("4A1803")){
            String serial=msg.toString().substring(12,22);
            myTools.writeToClient("404A03"+msg.toString().substring(msg.toString().length()-2)+"23",ctx,"事件包");
            ComPropertyAlarm comPropertyAlarm=new ComPropertyAlarm();
            comPropertyAlarm.setCreateTime(DateUtil.date());
            comPropertyAlarm.setSerialNo(serial);
            comPropertyAlarm.setType(ComPropertyAlarm.type.one);
            comPropertyAlarmDao.insert(comPropertyAlarm);
        }
        ctx.flush();
    }
    /**
     * 发生异常触发
     */
    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        cause.printStackTrace();
        ctx.close();
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/ServerChannelInitializer.java
New file
@@ -0,0 +1,18 @@
package com.panzhihua.service_property.netty;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.util.CharsetUtil;
public class ServerChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //添加编解码
        //socketChannel.pipeline().addLast("decoder", new StringDecoder(CharsetUtil.UTF_8));
        socketChannel.pipeline().addLast(new MyDecoder());
        socketChannel.pipeline().addLast("encoder", new StringEncoder(CharsetUtil.UTF_8));
        socketChannel.pipeline().addLast(new NettyServerHandler());
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/ComPropertyAlarmService.java
New file
@@ -0,0 +1,21 @@
package com.panzhihua.service_property.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.service_property.entity.ComPropertyAlarm;
/**
 * (ComPropertyAlarm)表服务接口
 *
 * @author makejava
 * @since 2021-09-07 13:29:49
 */
public interface ComPropertyAlarmService extends IService<ComPropertyAlarm> {
    /**
     * 多条件查询报警列表
     * @param commonPage
     * @return
     */
    R pageList(CommonPage commonPage);
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/ComPropertyEquipmentService.java
New file
@@ -0,0 +1,14 @@
package com.panzhihua.service_property.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.panzhihua.service_property.entity.ComPropertyEquipment;
/**
 * (ComPropertyEquipment)表服务接口
 *
 * @author makejava
 * @since 2021-09-07 13:29:32
 */
public interface ComPropertyEquipmentService extends IService<ComPropertyEquipment> {
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/impl/ComPropertyAlarmServiceImpl.java
New file
@@ -0,0 +1,33 @@
package com.panzhihua.service_property.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.property.ComPropertyAlarmVO;
import com.panzhihua.service_property.entity.ComPropertyAlarm;
import com.panzhihua.service_property.dao.ComPropertyAlarmDao;
import com.panzhihua.service_property.service.ComPropertyAlarmService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
 * (ComPropertyAlarm)表服务实现类
 *
 * @author makejava
 * @since 2021-09-07 13:29:50
 */
@Slf4j
@Service
public class ComPropertyAlarmServiceImpl extends ServiceImpl<ComPropertyAlarmDao, ComPropertyAlarm> implements ComPropertyAlarmService {
    @Resource
    private ComPropertyAlarmDao comPropertyAlarmDao;
    @Override
    public R pageList(CommonPage commonPage) {
        IPage<ComPropertyAlarmVO> page=comPropertyAlarmDao.selectList(new Page(commonPage.getPage(), commonPage.getSize()),commonPage);
        return R.ok(page);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/impl/ComPropertyEquipmentServiceImpl.java
New file
@@ -0,0 +1,20 @@
package com.panzhihua.service_property.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.service_property.entity.ComPropertyEquipment;
import com.panzhihua.service_property.dao.ComPropertyEquipmentDao;
import com.panzhihua.service_property.service.ComPropertyEquipmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
 * (ComPropertyEquipment)表服务实现类
 *
 * @author makejava
 * @since 2021-09-07 13:29:32
 */
@Slf4j
@Service
public class ComPropertyEquipmentServiceImpl extends ServiceImpl<ComPropertyEquipmentDao, ComPropertyEquipment> implements ComPropertyEquipmentService {
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/util/MyTools.java
New file
@@ -0,0 +1,72 @@
package com.panzhihua.service_property.util;
import com.panzhihua.common.utlis.StringUtils;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import java.util.HashMap;
import java.util.Map;
public class MyTools {
    //十六进制字符转十进制
    public int covert(String content){
        int number=0;
        String [] HighLetter = {"A","B","C","D","E","F"};
        Map<String,Integer> map = new HashMap<>();
        for(int i = 0;i <= 9;i++){
            map.put(i+"",i);
        }
        for(int j= 10;j<HighLetter.length+10;j++){
            map.put(HighLetter[j-10],j);
        }
        String[]str = new String[content.length()];
        for(int i = 0; i < str.length; i++){
            str[i] = content.substring(i,i+1);
        }
        for(int i = 0; i < str.length; i++){
            number += map.get(str[i])*Math.pow(16,str.length-1-i);
        }
        return number;
    }
    public byte[] hexString2Bytes(String src) {
        int l = src.length() / 2;
        byte[] ret = new byte[l];
        for (int i = 0; i < l; i++) {
            ret[i] = (byte) Integer
                    .valueOf(src.substring(i * 2, i * 2 + 2), 16).byteValue();
        }
        return ret;
    }
    public void writeToClient(final String receiveStr, ChannelHandlerContext channel, final String mark) {
        try {
            ByteBuf bufff = Unpooled.buffer();//netty需要用ByteBuf传输
            bufff.writeBytes(hexString2Bytes(receiveStr));//对接需要16进制
            channel.writeAndFlush(bufff).addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    StringBuilder sb = new StringBuilder();
                    if(!StringUtils.isEmpty(mark)){
                        sb.append("【").append(mark).append("】");
                    }
                    if (future.isSuccess()) {
                        System.out.println(sb+"回写成功"+receiveStr);
                    } else {
                        System.out.println(sb+"回写失败"+receiveStr);
                    }
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("调用通用writeToClient()异常"+e.getMessage());
        }
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/resources/mapper/ComPropertyAlarmMapper.xml
New file
@@ -0,0 +1,26 @@
<?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.panzhihua.service_property.dao.ComPropertyAlarmDao">
    <resultMap type="com.panzhihua.service_property.entity.ComPropertyAlarm" id="ComPropertyAlarmBaseResultMap">
        <result property="id" column="id"/>
        <result property="serialNo" column="serial_no"/>
        <result property="type" column="type"/>
        <result property="createTime" column="create_time"/>
    </resultMap>
    <select id="selectList" resultType="com.panzhihua.common.model.vos.property.ComPropertyAlarmVO">
        select t.*,t1.positon  from com_property_Alarm t left join com_property_equipment t1 on t.serial_no = t1.serial_no
        <where>
            1=1
            <if test="commonPage.paramId !=null">
                and t.property_id =#{commonPage.paramId}
            </if>
            <if test="commonPage.type !=null">
                and t.type =#{commonPage.type}
            </if>
        </where>
        order by create_time desc
    </select>
</mapper>
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/resources/mapper/ComPropertyEquipmentMapper.xml
New file
@@ -0,0 +1,12 @@
<?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.panzhihua.service_property.dao.ComPropertyEquipmentDao">
    <resultMap type="com.panzhihua.service_property.entity.ComPropertyEquipment" id="ComPropertyEquipmentBaseResultMap">
        <result property="id" column="id"/>
        <result property="serialNo" column="serial_no"/>
        <result property="position" column="position"/>
        <result property="propertyId" column="property_id"/>
    </resultMap>
</mapper>