nnnjjj123
2021-01-07 c50e7293cb05a212d9c67828e42cbc82f28d087d
1.netty调整
2.客户列表
13 files modified
148 ■■■■ changed files
src/main/java/org/springblade/Application.java 9 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/catalog/controller/catalogController.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/catalog/entitly/catalog.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/catalog/mapper/catalogMapper.java 4 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/catalog/mapper/catalogMapper.xml 10 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/catalog/service/catalogService.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/catalog/service/impl/CatalogServiceImpl.java 7 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/equipment/controller/EquipmentController.java 29 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/equipment/entity/Equipment.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/equipment/mapper/EquipmentMapper.xml 32 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/nettyServer/Server.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/nettyServer/ServerHandler.java 20 ●●●●● patch | view | raw | blame | history
src/main/resources/application.yml 3 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/Application.java
@@ -19,6 +19,9 @@
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import org.springblade.common.constant.CommonConstant;
import org.springblade.core.launch.BladeApplication;
import org.springblade.modules.nettyServer.Server;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@@ -29,11 +32,15 @@
 */
@EnableScheduling
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
public class Application {
public class Application implements CommandLineRunner {
    public static void main(String[] args) {
        BladeApplication.run(CommonConstant.APPLICATION_NAME, Application.class, args);
    }
    @Override
    public void run(String... args) throws Exception {
        Server server=new Server(8088);
    }
}
src/main/java/org/springblade/modules/catalog/controller/catalogController.java
@@ -135,7 +135,17 @@
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
        response.setHeader("Access-Control-Allow-Credentials","true");
        return R.data(catalogService.selectCatalogList());
        List<Map<String, Object>> list = catalogService.selectCatalogList();
        for (int i=0;i<list.size();i++){
            Object pId = list.get(i).get("pId");
            String s = pId.toString();
            int i1 = Integer.parseInt(s);
            if (i1==0){
                list.get(i).put("isParent","true");
            }
        }
        return R.data(list);
    }
src/main/java/org/springblade/modules/catalog/entitly/catalog.java
@@ -39,8 +39,8 @@
    private Integer id;
    @TableField("name")
    private String name;
    @TableField("pid")
    private Integer pid;
    @TableField("pId")
    private Integer pId;
    @TableField("eqid")
    private String eqid;
src/main/java/org/springblade/modules/catalog/mapper/catalogMapper.java
@@ -33,5 +33,7 @@
 * @since 2020-07-06
 */
public interface catalogMapper extends BaseMapper<catalog> {
    List<catalogVO> selectCatalogList();
    List<Map<String, Object>> selectCatalogList();
    String selectCatalogEqNUmber(String pid);
}
src/main/java/org/springblade/modules/catalog/mapper/catalogMapper.xml
@@ -6,13 +6,17 @@
    <resultMap id="catalogResultMap" type="org.springblade.modules.catalog.entitly.catalog">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="pid" property="pid"/>
        <result column="pId" property="pId"/>
        <result column="eqid" property="eqid"/>
    </resultMap>
    <select id="selectCatalogList" resultMap="catalogResultMap">
        SELECT id,name,pid FROM `sys_catalog`
    <select id="selectCatalogList" resultType="java.util.HashMap">
        SELECT id,name,pId FROM `sys_catalog`
    </select>
    <select id="selectCatalogEqNUmber" resultType="java.lang.String">
        SELECT GROUP_CONCAT(eqid) FROM sys_catalog WHERE pId=#{pid} and eqid is NOT NULL;
    </select>
src/main/java/org/springblade/modules/catalog/service/catalogService.java
@@ -33,6 +33,6 @@
 * @since 2020-07-06
 */
public interface catalogService extends IService<catalog> {
    List<catalogVO> selectCatalogList();
    List<Map<String, Object>> selectCatalogList();
    String selectCatalogEqNUmber(String pid);
}
src/main/java/org/springblade/modules/catalog/service/impl/CatalogServiceImpl.java
@@ -42,7 +42,12 @@
public class CatalogServiceImpl extends ServiceImpl<catalogMapper, catalog> implements catalogService {
    @Override
    public List<catalogVO> selectCatalogList() {
    public List<Map<String, Object>> selectCatalogList() {
        return baseMapper.selectCatalogList();
    }
    @Override
    public String selectCatalogEqNUmber(String pid) {
        return baseMapper.selectCatalogEqNUmber(pid);
    }
}
src/main/java/org/springblade/modules/equipment/controller/EquipmentController.java
@@ -26,6 +26,7 @@
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.catalog.service.catalogService;
import org.springblade.modules.deploy.service.IDeployService;
import org.springblade.modules.equipment.vo.EquipmentVOS;
import org.springblade.modules.equipment.wrapper.EqWrapper;
@@ -56,6 +57,7 @@
    private final IEquipmentService equipmentService;
    private final IDeployService iDeployService;
    private final catalogService catalogService;
    /**
     * 详情
@@ -89,8 +91,31 @@
    @GetMapping("/page")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入equipment")
    public R<IPage<EquipmentVO>> page(EquipmentVO equipment, Query query) {
        IPage<EquipmentVO> pages = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment);
    public R<IPage<EquipmentVO>> page(EquipmentVO equipment, Query query,String pid, HttpServletResponse response) {
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
        response.setHeader("Access-Control-Allow-Credentials","true");
        IPage<EquipmentVO> pages;
        if (pid==null){
             pages = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment);
        }
        else {
            String s = catalogService.selectCatalogEqNUmber(pid);
            if(s==null){
                pages = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment);
            }else{
                String[] split = s.split(",");
                String strArrays="";
                for(int i=0;i<split.length;i++){
                    strArrays+="'"+split[i]+"',";
                }
                String substring = strArrays.substring(0,strArrays.length()-1);
                equipment.setDeviceNumber(substring);
                pages = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment);
            }
        }
        return R.data(pages);
    }
src/main/java/org/springblade/modules/equipment/entity/Equipment.java
@@ -102,6 +102,9 @@
    private String addvcd;
    private String street;
    private String dtype;
    private String serialNumber;
    private String stype;
    private String channelNumber;
src/main/java/org/springblade/modules/equipment/mapper/EquipmentMapper.xml
@@ -18,6 +18,9 @@
        <result column="wd" property="wd"/>
        <result column="addvcd" property="addvcd"/>
        <result column="street" property="street"/>
        <result column="serialNumber" property="serialNumber"/>
        <result column="stype" property="stype"/>
        <result column="channelNumber" property="channelNumber"/>
    </resultMap>
    <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
@@ -52,7 +55,28 @@
    <select id="selectEquipmentPage" resultMap="equipmentResultMap">
        select * from sys_equipment where is_deleted = 0
        select id,deviceName,deviceNumber,deviceType,ownership,ownerId,devicestate,stime,ST_ASTEXT (coordinate ) AS coordinate,dtype,
        parent_id,
        FORMAT( jd, 6 ) AS jd,
        FORMAT( wd, 6 ) AS wd,
        street,
        addvcd  from sys_equipment where 1=1
        <if test="equipment.deviceName!=null">
            and deviceName like concat('%',#{equipment.deviceName},'%')
        </if>
        <if test="equipment.addvcd!=null">
            and addvcd=#{equipment.addvcd}
        </if>
        <if test="equipment.deviceType!=null">
            and deviceType like concat('%',#{equipment.deviceType},'%')
        </if>
        <if test="equipment.deviceNumber!=null">
            and deviceNumber IN (${equipment.deviceNumber})
        </if>
        <if test="equipment.dtype!=null">
            and dtype=#{equipment.dtype}
        </if>
        and parent_id!=0
    </select>
    <!--新增-->
@@ -108,6 +132,12 @@
    coordinate=POINT(#{jd},#{wd}),parent_id=#{parentId},jd=#{jd},wd=#{wd},addvcd=#{addvnm},street=#{streeName},dtype=#{dtype} where id=#{id}
</update>
    <update id="updateOnes" parameterType="org.springblade.modules.equipment.entity.Equipment">
    update sys_equipment SET deviceName=#{deviceName},deviceNumber=#{deviceNumber},deviceType=#{deviceType},
    ownership=#{ownership},ownerId=#{yname},devicestate=#{devicestate},stime=#{stime},
    coordinate=POINT(#{jd},#{wd}),parent_id=#{parentId},jd=#{jd},wd=#{wd},addvcd=#{addvnm},street=#{streeName},dtype=#{dtype} where id=#{id}
</update>
    <select id="selectInfo" resultMap="deptVOResultMap"
            parameterType="org.springblade.modules.equipment.entity.Equipment">
src/main/java/org/springblade/modules/nettyServer/Server.java
@@ -9,6 +9,9 @@
import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
public class Server {
    private int port;
@@ -85,8 +88,8 @@
            serverSocketChannel.writeAndFlush(msg);
        }
    }
/*
    public static void main(String[] args) {
        Server server = new Server(8088);
    }*/
//    public static void main(String[] args) {
////        Server server = new Server(8088);
////    }
}
src/main/java/org/springblade/modules/nettyServer/ServerHandler.java
@@ -10,11 +10,29 @@
import io.netty.channel.group.DefaultChannelGroup;
import io.netty.util.CharsetUtil;
import io.netty.util.concurrent.GlobalEventExecutor;
import org.springblade.modules.alarm.service.IAlarmService;
import org.springblade.modules.alarm.vo.AlarmVO;
import org.springblade.modules.catalog.service.catalogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@Component
public class ServerHandler extends ChannelInboundHandlerAdapter {
    @Autowired
    private catalogService catalogService;
    private static ServerHandler serverHandler;
    @PostConstruct
    public void init() {
        serverHandler = this;
    }
    /**
     * 客户端与服务端创建连接的时候调用
     */
@@ -64,6 +82,8 @@
        String body = new String(req, "UTF-8");
        System.out.println("接收客户端数据:" + body);
        channelHandlerContext.writeAndFlush(Unpooled.copiedBuffer("LEOK#@!", CharsetUtil.UTF_8));
        List<Map<String, Object>> list = serverHandler.catalogService.selectCatalogList();
        System.out.println(list);
//        ByteBuf pingMessage = Unpooled.buffer();
//        pingMessage.writeBytes(req);
//        channelHandlerContext.writeAndFlush(pingMessage);
src/main/resources/application.yml
@@ -45,6 +45,7 @@
# mybatis
mybatis-plus:
  mapper-locations: classpath:org/springblade/**/mapper/*Mapper.xml
  #实体扫描,多个package用逗号或者分号分隔
  typeAliasesPackage: org.springblade.**.entity
  #typeEnumsPackage: org.springblade.dashboard.entity.enums
@@ -66,7 +67,7 @@
      # 逻辑未删除全局值(0表示未删除,这也是Mybatis Plus的默认配置)
      logic-not-delete-value: 0
  configuration:
    map-underscore-to-camel-case: true
    map-underscore-to-camel-case: false
    cache-enabled: false
#swagger公共信息