| | |
| | | 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; |
| | | |
| | |
| | | */ |
| | | @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); |
| | | } |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | | |
| | |
| | | private Integer id; |
| | | @TableField("name") |
| | | private String name; |
| | | @TableField("pid") |
| | | private Integer pid; |
| | | @TableField("pId") |
| | | private Integer pId; |
| | | @TableField("eqid") |
| | | private String eqid; |
| | | |
| | |
| | | * @since 2020-07-06 |
| | | */ |
| | | public interface catalogMapper extends BaseMapper<catalog> { |
| | | List<catalogVO> selectCatalogList(); |
| | | List<Map<String, Object>> selectCatalogList(); |
| | | |
| | | String selectCatalogEqNUmber(String pid); |
| | | } |
| | |
| | | <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> |
| | | |
| | | |
| | |
| | | * @since 2020-07-06 |
| | | */ |
| | | public interface catalogService extends IService<catalog> { |
| | | List<catalogVO> selectCatalogList(); |
| | | |
| | | List<Map<String, Object>> selectCatalogList(); |
| | | String selectCatalogEqNUmber(String pid); |
| | | } |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | |
| | | private final IEquipmentService equipmentService; |
| | | private final IDeployService iDeployService; |
| | | private final catalogService catalogService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | @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); |
| | | } |
| | | |
| | |
| | | private String addvcd; |
| | | private String street; |
| | | private String dtype; |
| | | private String serialNumber; |
| | | private String stype; |
| | | private String channelNumber; |
| | | |
| | | |
| | | |
| | |
| | | <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"> |
| | |
| | | |
| | | |
| | | <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> |
| | | |
| | | <!--新增--> |
| | |
| | | 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"> |
| | |
| | | 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; |
| | |
| | | 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); |
| | | //// } |
| | | } |
| | |
| | | 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; |
| | | } |
| | | /** |
| | | * 客户端与服务端创建连接的时候调用 |
| | | */ |
| | |
| | | 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); |
| | |
| | | # mybatis |
| | | mybatis-plus: |
| | | mapper-locations: classpath:org/springblade/**/mapper/*Mapper.xml |
| | | |
| | | #实体扫描,多个package用逗号或者分号分隔 |
| | | typeAliasesPackage: org.springblade.**.entity |
| | | #typeEnumsPackage: org.springblade.dashboard.entity.enums |
| | |
| | | # 逻辑未删除全局值(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公共信息 |