Commit 1ded3369 authored by duanruiming's avatar duanruiming

[add] 信号机通讯模块

parent dbfb73db
......@@ -34,6 +34,7 @@
<module>wj-databus</module>
<module>wj-identity</module>
<module>wj-portal</module>
<module>signal-communication-service</module>
</modules>
<!-- 依赖版本 -->
......
This diff is collapsed.
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>1.0</id>
<formats>
<format>tar.gz</format>
<format>dir</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<!-- for bin -->
<fileSet>
<directory>src/main/bin</directory>
<includes>
<include>*.*</include>
</includes>
<directoryMode>775</directoryMode>
<outputDirectory>bin/</outputDirectory>
</fileSet>
<!-- for configs -->
<fileSet>
<directory>src/main/resources</directory>
<includes>
<include>*.yml</include>
<include>*.xml</include>
</includes>
<outputDirectory>/</outputDirectory>
</fileSet>
<!-- for jar -->
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
<!-- for lib -->
<dependencySets>
<dependencySet>
<outputDirectory>lib/</outputDirectory>
<scope>runtime</scope>
<excludes>
<exclude>${groupId}:${artifactId}</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
package net.wanji.com;
import net.wanji.com.netty.NettyServer;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @author duanruiming
* @date 2023/05/08 13:37
*/
@SpringBootApplication(scanBasePackages = {"net.wanji.com", "net.wanji.databus", "net.wanji.common"})
@MapperScan(basePackages = {"net.wanji.com.mapper", "net.wanji.databus.dao.mapper"})
@EnableTransactionManagement
@EnableScheduling
@SuppressWarnings("all")
public class CommunicationApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(CommunicationApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
NettyServer.start(3000);
}
}
package net.wanji.com.cache;
import lombok.extern.slf4j.Slf4j;
import net.wanji.com.mapper.TCrossInfoMapper;
import net.wanji.com.pojo.po.CrossInfoPO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author duanruiming
* @date 2023/05/09 14:30
*/
@Slf4j
@Component
public class CrossInfoCache implements CommandLineRunner {
@Autowired
private TCrossInfoMapper crossInfoMapper;
private static final Map<String, CrossInfoPO> crossInfoMap = new HashMap<>();
public Map<String, CrossInfoPO> getCrossInfoCache() {
if (!crossInfoMap.isEmpty()) {
return crossInfoMap;
}
return Collections.EMPTY_MAP;
}
public CrossInfoPO getCrossInfo(String key) {
if (!crossInfoMap.isEmpty()) {
return crossInfoMap.get(key);
}
return null;
}
@Override
public void run(String... args) throws Exception {
init();
}
private void init() {
List<CrossInfoPO> crossInfoPOS = crossInfoMapper.selectAll();
for (CrossInfoPO crossInfoPO : crossInfoPOS) {
String key = StringUtils.join("/", crossInfoPO.getIp(), ":", crossInfoPO.getPort());
crossInfoMap.put(key, crossInfoPO);
}
}
}
package net.wanji.com.cache;
import lombok.extern.slf4j.Slf4j;
import net.wanji.com.service.controller.BeanMarkService;
import net.wanji.com.service.controller.ControlCommandService;
import net.wanji.com.service.controller.SignalStatusService;
import net.wanji.com.service.controller.StaticInfoService;
import net.wanji.com.common.enums.SignalInterfaceTypeEnum;
import net.wanji.common.framework.spring.ServiceBeanContext;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @author duanruiming
* @date 2023/05/08 11:05
*/
@Slf4j
@Component
public class SignalCommandInterfaceCache implements CommandLineRunner {
private final Map<String, BeanMarkService> controlCommandInterfaceMap = new HashMap<>();
/**
* 获取缓存
* key:主题名/类名,value: bean
*
* @return
*/
public Map<String, BeanMarkService> getCache() throws Exception{
if (controlCommandInterfaceMap.isEmpty()) {
throw new Exception("SignalCommandInterfaceCache");
}
return controlCommandInterfaceMap;
}
@Override
public void run(String... args) throws Exception {
Map<String, BeanMarkService> map = ServiceBeanContext.getInterfaceBeanMap(BeanMarkService.class);
for (Map.Entry<String, BeanMarkService> item : map.entrySet()) {
BeanMarkService bean = item.getValue();
String beanMark = bean.getBeanMark();
String type = "";
if (bean instanceof ControlCommandService) {
type = SignalInterfaceTypeEnum.CONTROL.getCode();
}
if (bean instanceof SignalStatusService) {
type = SignalInterfaceTypeEnum.STATUS.getCode();
}
if (bean instanceof StaticInfoService) {
type = SignalInterfaceTypeEnum.STATIC.getCode();
}
controlCommandInterfaceMap.put(beanMark.concat(type), bean);
}
}
/**
* 通过beanMark获取接口实现类
*
* @param beanMark
* @return
*/
public BeanMarkService getService(String beanMark) {
if (!controlCommandInterfaceMap.isEmpty()) {
return controlCommandInterfaceMap.get(beanMark);
}
return null;
}
}
package net.wanji.com.cache.netty;
import net.wanji.com.pojo.netty.MessageResultPojo;
import java.util.HashMap;
import java.util.Map;
/**
* @author duanruiming
* @date 2023/05/08 14:07
*/
public class NettyMessageCache {
public static final Map<String, MessageResultPojo> NETTY_MESSAGE_RESULT_MAP = new HashMap<>();
}
package net.wanji.com.common.enums;
import org.apache.commons.lang3.StringUtils;
/**
* @author duanruiming
* @date 2023/05/08 10:17
*/
public enum HexSign {
HEARTBEAT("1631", "heartbeatService"),
GET_SCHEDULE_PARAM("2393", "getScheduleService"),
GET_DAY_SCHEDULE_PARAM("2394", "getDayScheduleService"),
GET_DAILY_PLAN_PRAM("2392", "getDailyPlanService"),
GET_PLAN_PARAM("2353", "getPlanService"),
SET_SCHEDULE_PARAM("1293", "setScheduleService"),
SET_DAILY_PLAN_PARAM("1292", "setDailyPlanService"),
SET_PLAN_PARAM("1253", "setPlanService"),
CTL_CROSS_CONTROL("11", "ctlControlService"),
SIGNAL_REAL_DATA("1549", "signalRealDataService"),
SIGNAL_NET_CONFIG("3300", "signalNetConfig");
private String hexSign;
private String className;
HexSign(String hexSign, String className) {
this.hexSign = hexSign;
this.className = className;
}
public static String getClassNameByHexSign(String hexSign) {
if (StringUtils.isEmpty(hexSign)) {
return null;
}
for (HexSign uniqueHexSign : values()) {
if (uniqueHexSign.hexSign.equals(hexSign)) {
return uniqueHexSign.className;
}
}
return null;
}
}
package net.wanji.com.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.wanji.com.service.controller.ControlCommandService;
import net.wanji.com.service.controller.SignalStatusService;
import net.wanji.com.service.controller.StaticInfoService;
import java.util.Objects;
/**
* @author duanruiming
* @date 2023/05/09 10:35
*/
@Getter
@AllArgsConstructor
@RequiredArgsConstructor
public enum SignalInterfaceTypeEnum {
CONTROL("control", ControlCommandService.class, "控制类型接口"),
STATUS("status",SignalStatusService.class, "状态类型接口"),
STATIC("static",StaticInfoService.class, "静态类型接口");
private String code;
private Object type;
private String desc;
/**
* 通过编号获取接口类型
*
* @param code
* @return
*/
public Object getInterfaceType(String code) {
for (SignalInterfaceTypeEnum value : SignalInterfaceTypeEnum.values()) {
if (Objects.equals(code, value.getCode())) {
return value.getType();
}
}
return null;
}
}
package net.wanji.com.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class Swagger2 {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//为当前包路径
.apis(RequestHandlerSelectors.basePackage("net.wanji.utc.controller"))
.paths(PathSelectors.any())
.build();
}
//构建 api文档的详细信息函数,注意这里的注解引用的是哪个
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
//页面标题
.title("万集科技-城市交通信号OpenAPI")
//创建人
.contact(new Contact("test", "#", "test@wanji.net.cn"))
//版本号
.version("0.2.1")
//描述
.description("城市交通信号厂商调用服务API")
.build();
}
}
\ No newline at end of file
package net.wanji.com.config;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author duanruiming
* @date 2023/02/14 10:17
*/
@Configuration
public class ThreadPoolConfig {
@Value("${threadPoolConfig.threadPoolName}")
private String threadPoolName;
@Value("${threadPoolConfig.coreSize}")
private int coreSize;
@Value("${threadPoolConfig.maxSize}")
private int maxSize;
@Value("${threadPoolConfig.queueCapacity}")
private int queueCapacity;
@Value("${threadPoolConfig.keepAliveTime}")
private int keepAliveTime;
@Value("${threadPoolConfig.allowCoreTimeOut}")
private boolean allowCoreTimeOut;
@Bean
public ThreadPoolTaskExecutor threadPoolExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
ThreadFactory build = new ThreadFactoryBuilder().setNameFormat(threadPoolName).build();
executor.setThreadFactory(build);
executor.setCorePoolSize(coreSize);
executor.setMaxPoolSize(maxSize);
executor.setQueueCapacity(queueCapacity);
executor.setKeepAliveSeconds(keepAliveTime);
executor.setAllowCoreThreadTimeOut(allowCoreTimeOut);
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
executor.initialize();
return executor;
}
}
package net.wanji.com.controller;
/**
* @author Kent HAN
* @date 2022/12/1 15:07
*/
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import net.wanji.com.cache.SignalCommandInterfaceCache;
import net.wanji.com.common.enums.SignalInterfaceTypeEnum;
import net.wanji.com.pojo.po.SignalStatusLogPO;
import net.wanji.com.pojo.vo.LightsStatusVO;
import net.wanji.com.service.controller.SignalStatusService;
import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.ws.rs.core.MediaType;
import java.util.List;
/**
* 运行状态、告警、灯态信息接口
*
* @date 2022/11/15 9:38
*/
@Api(value = "运行状态、告警、灯态信息接口", description = "运行状态、告警、灯态信息接口")
@RequestMapping("/signalStatus")
@RestController
@RequiredArgsConstructor
public class SignalStatusController {
private final SignalStatusService signalStatusService;
private final SignalCommandInterfaceCache signalCommandInterfaceCache;
private SignalStatusService getService(String manufacturerId) {
return (SignalStatusService) (signalCommandInterfaceCache.getService(manufacturerId.concat(SignalInterfaceTypeEnum.STATUS.getCode())));
}
@AspectLog(description = "运行状态、告警数据", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/runningStatusAlarm", produces = MediaType.APPLICATION_JSON)
@ApiOperation(value = "运行状态、告警数据", notes = "运行状态、告警数据", response = SignalStatusLogPO.class,
produces = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = SignalStatusLogPO.class)
})
public JsonViewObject runningStatusAlarm() {
List<SignalStatusLogPO> signalStatusLogPOList = signalStatusService.runningStatusAlarm();
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(signalStatusLogPOList);
}
@AspectLog(description = "灯态数据", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/lightStatus", produces = MediaType.APPLICATION_JSON)
@ApiOperation(value = "灯态数据", notes = "灯态数据", response = LightsStatusVO.class,
produces = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = LightsStatusVO.class)
})
public JsonViewObject lightStatus() {
List<LightsStatusVO> lightsStatusVOList = signalStatusService.lightStatus();
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(lightsStatusVOList);
}
}
package net.wanji.com.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import net.wanji.com.cache.SignalCommandInterfaceCache;
import net.wanji.com.common.enums.SignalInterfaceTypeEnum;
import net.wanji.com.pojo.dto.CrossInfoDTO;
import net.wanji.com.pojo.dto.CrossSchedulesDTO;
import net.wanji.com.pojo.dto.PlanSectionDTO;
import net.wanji.com.pojo.dto.SchemePhaseLightsDTO;
import net.wanji.com.pojo.po.CrossInfoPO;
import net.wanji.com.pojo.po.CrossSchedulesPO;
import net.wanji.com.pojo.vo.PlanSectionVO;
import net.wanji.com.pojo.vo.SchemePhaseLightsVO;
import net.wanji.com.service.controller.StaticInfoService;
import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Objects;
/**
* 静态信息接口
*
* @date 2022/11/15 9:38
*/
@Api(value = "静态信息接口", description = "静态信息接口")
@RequestMapping("/staticInfo")
@RestController
@RequiredArgsConstructor
public class StaticInfoController {
private final StaticInfoService staticInfoService;
private final SignalCommandInterfaceCache signalCommandInterfaceCache;
private StaticInfoService getService(String manufacturerId) {
return (StaticInfoService) (signalCommandInterfaceCache.getService(manufacturerId.concat(SignalInterfaceTypeEnum.STATIC.getCode())));
}
@AspectLog(description = "信号路口基础信息", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/crossInfo",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiOperation(value = "信号路口基础信息", notes = "信号路口基础信息", response = CrossInfoPO.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CrossInfoPO.class)
})
public JsonViewObject crossInfo(@RequestBody @Validated CrossInfoDTO crossInfoDTO) throws Exception {
List<CrossInfoPO> crossInfoPOList = staticInfoService.crossBasicInfo(crossInfoDTO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(crossInfoPOList);
}
@AspectLog(description = "方案数据-方案信息、相位信息、灯组信息", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/schemePhaseLights",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiOperation(value = "方案数据-方案信息、相位信息、灯组信息", notes = "方案数据-方案信息、相位信息、灯组信息",
response = SchemePhaseLightsVO.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = SchemePhaseLightsVO.class)
})
public JsonViewObject schemePhaseLights(@RequestBody @Validated SchemePhaseLightsDTO schemePhaseLightsDTO) throws Exception {
// 更新数据库
staticInfoService.schemePhaseLights(schemePhaseLightsDTO);
// 构造返回值
SchemePhaseLightsVO schemePhaseLightsVO = staticInfoService.buildSchemePhaseLightsResponse(schemePhaseLightsDTO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(schemePhaseLightsVO);
}
@AspectLog(description = "计划数据-计划信息、时段信息", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/planSection",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiOperation(value = "计划数据-计划信息、时段信息", notes = "计划数据-计划信息、时段信息", response = PlanSectionVO.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = PlanSectionVO.class)
})
public JsonViewObject planSection(@RequestBody @Validated PlanSectionDTO planSectionDTO) throws Exception {
// 更新数据库
staticInfoService.planSection(planSectionDTO);
// 构造返回值
String crossId = planSectionDTO.getCrossId();
Integer planNo = planSectionDTO.getPlanNo();
PlanSectionVO planSectionVO = new PlanSectionVO();
if (Objects.isNull(planNo) || planNo == -1) {
// 返回所有
planSectionVO = staticInfoService.buildPlanSectionResponse(crossId);
} else {
// 按计划号返回
planSectionVO = staticInfoService.buildPlanSectionResponse(crossId, planNo);
}
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(planSectionVO);
}
@AspectLog(description = "时间表数据", operationType = BaseEnum.OperationTypeEnum.QUERY)
@PostMapping(value = "/crossSchedules",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiOperation(value = "时间表数据", notes = "时间表数据", response = CrossSchedulesPO.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CrossSchedulesPO.class)
})
public JsonViewObject crossSchedules(@RequestBody @Validated CrossSchedulesDTO crossSchedulesDTO) throws Exception {
// 更新数据库
staticInfoService.crossSchedules(crossSchedulesDTO);
// 构造返回值
List<String> crossIdList = crossSchedulesDTO.getCrossIdList();
List<CrossSchedulesPO> crossSchedulesPOList = staticInfoService.buildCrossSchedulesResponse(crossIdList);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(crossSchedulesPOList);
}
}
package net.wanji.com.mapper;
import net.wanji.com.pojo.po.ManufacturerInfoPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/11/15 16:48
*/
@Mapper
public interface ManufacturerInfoMapper {
ManufacturerInfoPO selectByCode(@Param("code") String code);
ManufacturerInfoPO selectById(@Param("manufacturerId") Integer manufacturerId);
List<ManufacturerInfoPO> selectAll();
List<ManufacturerInfoPO> selectByOptionalPartialName(@Param("name") String name);
void insertOne(ManufacturerInfoPO manufacturerInfoPO);
void updateOne(ManufacturerInfoPO manufacturerInfoPO);
void deleteBatch(@Param("ids") List<Integer> ids);
Integer selectIdByNick(@Param("manufacturerNick") String manufacturerNick);
String selectNickById(@Param("manufacturerId") Integer manufacturerId);
}
package net.wanji.com.mapper;
import net.wanji.com.pojo.po.CrossInfoPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author duanruiming
* @date 2023/05/09 9:10
*/
@Mapper
public interface TCrossInfoMapper {
CrossInfoPO selectByPrimaryKey(@Param("key") String key);
void insertBatch(@Param("entities") List<CrossInfoPO> crossInfoPOList);
List<String> selectCrossCodesByIds(@Param("entities") List<String> crossIdList);
String selectIdByCodeAndManufacturerId(@Param("crossCode") String crossCode,
@Param("manufacturerId")Integer manufacturerId);
List<CrossInfoPO> selectByManufacturerId(@Param("manufacturerId") Integer manufacturerId);
List<CrossInfoPO> selectByOptionals(@Param("crossName") String crossName,
@Param("manufacturerId") Integer manufacturerId);
void insertOne(CrossInfoPO crossInfoPO);
void updateOne(CrossInfoPO crossInfoPO);
void deleteBatch(@Param("ids") List<String> ids);
void updateOneByCodeAndManufacturerId(CrossInfoPO crossInfoPO);
void deleteById(String id);
List<CrossInfoPO> selectAll();
}
package net.wanji.com.netty;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.channel.group.ChannelGroup;
import io.netty.channel.group.DefaultChannelGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.util.concurrent.GlobalEventExecutor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.com.cache.netty.NettyMessageCache;
import net.wanji.com.netty.handler.NettyServerHandler;
import net.wanji.com.pojo.netty.MessageResultPojo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.nio.ByteOrder;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;
@Slf4j
@Component
public class NettyServer {
private static final Map<String, ChannelId> IP_PORT_CHANNEL_ID_MAP = new HashMap<>();
private static ChannelGroup channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
@Resource(name = "threadPoolExecutor")
ThreadPoolTaskExecutor threadPoolExecutor;
/**
* 建立连接
*/
public static void start(int port) throws InterruptedException {
final EventLoopGroup parent = new NioEventLoopGroup();
final EventLoopGroup child = new NioEventLoopGroup();
ServerBootstrap serverBootstrap = new ServerBootstrap();
serverBootstrap.group(parent, child)
.channel(NioServerSocketChannel.class)
.childOption(ChannelOption.TCP_NODELAY, true)
.childOption(ChannelOption.SO_KEEPALIVE, true)
.childHandler(new ChannelInitializer<NioSocketChannel>() {
@Override
protected void initChannel(NioSocketChannel socketChannel) {
socketChannel.pipeline()
.addFirst()
// .addLast(new MessageDecoder())
// .addLast(new MessageEnCoder())
// 格林威解码器
.addLast(new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, Integer.MAX_VALUE, 4, 2, 0, 0, true))
.addLast(new NettyServerHandler());
channelGroup.add(socketChannel);
String key = StringUtils.join(socketChannel.remoteAddress().getHostString(), ":".intern(), socketChannel.remoteAddress().getPort());
log.info("client {} is connect success", key);
IP_PORT_CHANNEL_ID_MAP.put(key, socketChannel.id());
}
});
ChannelFuture channelFuture = serverBootstrap.bind(port).sync();
log.info("server is started in {}", channelFuture.channel().localAddress());
//收到停止信号
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
//停掉所有的线程
channelGroup.close().syncUninterruptibly();
parent.shutdownGracefully();
child.shutdownGracefully();
channelFuture.channel().closeFuture().syncUninterruptibly();
log.warn("server is closed");
}));
}
public static void sendMessage(String ip, int port, String message) {
Channel channel = channelGroup.find(IP_PORT_CHANNEL_ID_MAP.get(StringUtils.join(ip, ":", port)));
channel.writeAndFlush(message);
}
public static Object sendMessage(String ip, int port, String message, String command) {
sendMessage(ip, port, message, command, 500);
return null;
}
public static String sendMessage(String ip, int port, String message, String command, int waitMillisecond) {
CountDownLatch countDownLatch = new CountDownLatch(1);
String key = StringUtils.joinWith("#", ip, port, command);
long now = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
MessageResultPojo messageResultPojo = new MessageResultPojo(command, countDownLatch, now, waitMillisecond, null);
NettyMessageCache.NETTY_MESSAGE_RESULT_MAP.put(key, messageResultPojo);
try {
sendMessage(ip, port, message);
countDownLatch.await();
} catch (InterruptedException e) {
log.error("error", e);
}
MessageResultPojo resultPojo = NettyMessageCache.NETTY_MESSAGE_RESULT_MAP.remove(key);
if (Objects.nonNull(resultPojo)) {
return resultPojo.getMessageHexStr();
}
return null;
}
@Scheduled(fixedRate = 300)
public void checkWaitTimeout() {
long now = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
NettyMessageCache.NETTY_MESSAGE_RESULT_MAP.forEach((k, v) -> {
threadPoolExecutor.execute(() -> {
if (now - v.getStartTime() > v.getWaitMillisecond()) {
log.warn("wait {}ms {} timeout", v.getWaitMillisecond(), k);
v.getCountDownLatch().countDown();
}
});
});
}
}
\ No newline at end of file
package net.wanji.com.netty.agreementcommon;
import java.util.Objects;
/**
* @author duanruiming
* @date 2023/05/08 10:14
*/
public class AgreementCommon {
public static String getHexSign(String data) {
//根据不同需求获取消息唯一标识
String controlHex = data.substring(28, 30);
// 控制类型
if (Objects.equals("11", controlHex)) {
return "11";
} else {
String hex = data.substring(28, 32);
return hex;
}
}
}
package net.wanji.com.netty.codec;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
/**
* @author duanruiming
* @date 2023/05/08 10:07
*/
public class MessageDecoder extends ByteToMessageDecoder {
/*
*自定义解码器
*/
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
}
}
package net.wanji.com.netty.codec;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import net.wanji.common.utils.licenseUtils.AESUtils;
/**
* @author duanruiming
* @date 2023/05/08 10:08
*/
public class MessageEnCoder extends MessageToByteEncoder<String> {
/**
* 自定义编码器
*
* @param ctx
* @param msg
* @param out
* @throws Exception
*/
@Override
protected void encode(ChannelHandlerContext ctx, String msg, ByteBuf out) throws Exception {
out.writeBytes(AESUtils.parseHexStr2Byte(msg));
}
}
package net.wanji.com.netty.handler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.com.cache.CrossInfoCache;
import net.wanji.com.cache.netty.NettyMessageCache;
import net.wanji.com.common.enums.HexSign;
import net.wanji.com.netty.agreementcommon.AgreementCommon;
import net.wanji.com.pojo.netty.MessageResultPojo;
import net.wanji.com.pojo.po.CrossInfoPO;
import net.wanji.com.service.protocol.ProtocolConversionService;
import net.wanji.common.framework.spring.ServiceBeanContext;
import org.apache.commons.lang3.StringUtils;
import javax.annotation.Resource;
@Slf4j
@NoArgsConstructor
public class NettyServerHandler extends ChannelInboundHandlerAdapter {
@Resource
private CrossInfoCache crossInfoCache;
/**
* 建立连接后
*
* @param ctx
* @throws Exception
*/
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
log.info("{} connection is active....", ctx.channel().remoteAddress());
ctx.fireChannelActive();
}
/**
* 读
*
* @param ctx
* @param msg
* @throws Exception
*/
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
String key = ctx.channel().remoteAddress().toString();
String data = msg.toString();
log.debug("receive server data :{}", data);
String hexSign = AgreementCommon.getHexSign(data);
if (StringUtils.isEmpty(hexSign)) {
log.error("data unique hex sign error");
return;
}
String className = HexSign.getClassNameByHexSign(hexSign);
ProtocolConversionService bean = (ProtocolConversionService) ServiceBeanContext.getBean(className);
CrossInfoPO crossInfo = crossInfoCache.getCrossInfo(key);
String result = bean.protocolConvert(crossInfo);
if (StringUtils.isNotEmpty(result)) {
setResultData(key, result);
}
}
private void setResultData(String key, String data) {
MessageResultPojo resultPojo = NettyMessageCache.NETTY_MESSAGE_RESULT_MAP.get(key);
if (resultPojo != null) {
resultPojo.setMessageHexStr(data);
resultPojo.getCountDownLatch().countDown();
}
}
/**
* 关闭
*
* @param ctx
* @throws Exception
*/
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
String s = ctx.channel().remoteAddress().toString();
log.error("{} connection break", s);
ctx.fireChannelInactive();
}
}
package net.wanji.com.pojo.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* @author Kent HAN
* @date 2022/11/15 9:57
*/
@Data
@ApiModel(value = "CrossInfoDTO", description = "查询信号路口基础信息输入参数")
public class CrossInfoDTO {
@ApiModelProperty(value = "厂商代码 HK")
@NotBlank
@Pattern(regexp = "^[A-Z]*$", message = "厂商代码只能包含大写英文字母")
String manufacturerCode;
}
package net.wanji.com.pojo.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/11/18 17:15
*/
@Data
@ApiModel(value = "CrossSchedulesDTO", description = "查询时间表数据输入参数")
public class CrossSchedulesDTO {
@ApiModelProperty(value = "厂商代码 HK")
@NotBlank
@Pattern(regexp = "^[A-Z]*$", message = "厂商代码只能包含大写英文字母")
String manufacturerCode;
@ApiModelProperty(value = "路口列表")
@NotEmpty
List<String> crossIdList;
}
package net.wanji.com.pojo.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
* @author Kent HAN
* @date 2022/11/15 9:57
*/
@Data
@ApiModel(value = "PlanSectionDTO", description = "查询计划数据-计划信息、时段信息输入参数")
public class PlanSectionDTO {
@ApiModelProperty(value = "路口ID")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossId;
@ApiModelProperty(value = "计划号,-1代表所有")
@NotNull(message = "最小为-1,查所有")
@Min(value = -1, message = "最小为-1,查所有")
private Integer planNo;
}
package net.wanji.com.pojo.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Pattern;
/**
* @author Kent HAN
* @date 2022/11/16 13:23
*/
@Data
@ApiModel(value = "SchemePhaseLightsDTO", description = "查询方案数据-方案信息、相位信息、灯组信息输入参数")
public class SchemePhaseLightsDTO {
@ApiModelProperty(value = "路口ID")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossId;
}
package net.wanji.com.pojo.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author Kent HAN
* @date 2022/11/15 9:57
*/
@Data
@ApiModel(value = "TelesemeCodeDTO", description = "信号机编号")
public class TelesemeCodeDTO {
@ApiModelProperty(value = "信号机编号")
String telesemeCode;
}
package net.wanji.com.pojo.netty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.concurrent.CountDownLatch;
/**
* @author duanruiming
* @date 2023/05/08 14:14
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MessageResultPojo {
/**
* 命令标识
*/
private String sign;
/**
* 计数对象
*/
private CountDownLatch countDownLatch;
/**
* 消息请求时间
*/
private long startTime;
/**
* 灯态毫秒时长
*/
private int waitMillisecond;
/**
* netty响应消息16进制字符串
*/
private String messageHexStr;
}
package net.wanji.com.pojo.po;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author Kent HAN
* @date 2022/11/15 10:14
*/
@Data
@ApiModel(value = "BaseCrossInfo", description = "查询信号路口基础信息输出参数")
public class BaseCrossInfo {
@ApiModelProperty(value = "信号机ID")
private String code;
@ApiModelProperty(value = "路口ID")
private String crossId;
@ApiModelProperty(value = "厂商代码")
private String manufacturerCode;
}
package net.wanji.com.pojo.po;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/15 10:48
*/
@Data
@JsonIgnoreProperties(value = {"gmtCreate", "gmtModified"})
public class CrossInfoPO {
@ApiModelProperty(value = "路口ID",notes = "")
private String id ;
/** 路口名称 */
@ApiModelProperty(value = "路口名称",notes = "")
private String name ;
/** 信号机编号 */
@ApiModelProperty(value = "信号机编号",notes = "")
private String code ;
/** 厂商ID */
@ApiModelProperty(value = "厂商ID",notes = "")
private Integer manufacturerId ;
/** 信号机IP */
@ApiModelProperty(value = "信号机IP",notes = "")
private String ip ;
/** 信号机端口 */
@ApiModelProperty(value = "信号机端口",notes = "")
private Integer port ;
/** 经纬度 */
@ApiModelProperty(value = "经纬度",notes = "")
private String location ;
/** 版本号 */
@ApiModelProperty(value = "版本号",notes = "")
private String version ;
/** 型号 */
@ApiModelProperty(value = "型号",notes = "")
private String model ;
/** 安装时间 */
@ApiModelProperty(value = "安装时间",notes = "")
private Date installTime ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(value = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.com.pojo.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/18 13:20
*/
@Data
public class CrossLightsPO {
/** 灯组ID */
@ApiModelProperty(value = "灯组ID",notes = "")
private Integer id ;
/** 灯组号 */
@ApiModelProperty(value = "灯组号",notes = "")
private String lightsNo ;
/** 灯组名称 */
@ApiModelProperty(value = "灯组名称",notes = "")
private String name ;
/** 灯组类型:1箭头;2圆饼,3行人 */
@ApiModelProperty(value = "灯组类型:1箭头2圆饼3行人",notes = "")
private Integer type ;
/** 灯组方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北 */
@ApiModelProperty(value = "灯组方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北",notes = "")
private Integer dir ;
/** 灯组转向:1左转;2右转;3直行;4左掉头;5直左;6直右;7右掉头;8向左合流;9向右合流;10左转加掉头;11右转加掉头;12直行加左掉头;13直行加右掉头;14左转右转;15左直右;16左转右转加掉头;17左直掉头;18左直右掉头;20行人 */
@ApiModelProperty(value = "灯组转向:1左转;2右转;3直行;4左掉头;5直左;6直右;7右掉头;8向左合流;9向右合流;10左转加掉头;11右转加掉头;12直行加左掉头;13直行加右掉头;14左转右转;15左直右;16左转右转加掉头;17左直掉头;18左直右掉头;20行人",notes = "")
private Integer turn ;
/** 路口ID */
@ApiModelProperty(value = "路口ID",notes = "")
private String crossId ;
/** 行人进出口:1进口;2出口,3进出口 */
@ApiModelProperty(value = "行人进出口:1进口2出口3进出口",notes = "")
private Integer inOutType ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(value = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.com.pojo.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/18 14:32
*/
@Data
public class CrossPhaseLightsPO {
/** 主键 */
@ApiModelProperty(name = "主键",notes = "")
private Integer id ;
/** 灯组ID */
@ApiModelProperty(name = "灯组ID",notes = "")
private Integer lightsId ;
/** 相位ID */
@ApiModelProperty(name = "相位ID",notes = "")
private Integer phaseId ;
/** 路口ID */
@ApiModelProperty(name = "路口ID",notes = "")
private String crossId ;
/** 创建时间 */
@ApiModelProperty(name = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(name = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.com.pojo.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/18 8:49
*/
@Data
public class CrossPhasePO {
/** 相位ID */
@ApiModelProperty(value = "相位ID",notes = "")
private Integer id ;
/** 相位号 */
@ApiModelProperty(value = "相位号",notes = "")
private String phaseNo;
/** 相位名称 */
@ApiModelProperty(value = "相位名称",notes = "")
private String name ;
/** 相位序号 */
@ApiModelProperty(value = "相位序号",notes = "")
private Integer sort ;
/** 路口ID */
@ApiModelProperty(value = "路口ID",notes = "")
private String crossId ;
/** 方案ID */
@ApiModelProperty(value = "方案ID",notes = "")
private Integer planId ;
/** 环号 */
@ApiModelProperty(value = "环号",notes = "")
private Integer ringNo ;
/** 控制模式:1定周期;2绿灯;3黄灯;4红灯;5关灯;6绿闪;7黄闪;8红闪 */
@ApiModelProperty(value = "控制模式:1定周期;2绿灯;3黄灯;4红灯;5关灯;6绿闪;7黄闪;8红闪",notes = "")
private Integer controlMode ;
/** 相位时间 */
@ApiModelProperty(value = "相位时间",notes = "")
private Integer phaseTime ;
/** 绿灯时间 */
@ApiModelProperty(value = "绿灯时间",notes = "")
private Integer greenTime ;
/** 绿闪时间 */
@ApiModelProperty(value = "绿闪时间",notes = "")
private Integer greenFlashTime ;
/** 行闪时间 */
@ApiModelProperty(value = "行闪时间",notes = "")
private Integer pedFlashTime ;
/** 黄灯时间 */
@ApiModelProperty(value = "黄灯时间",notes = "")
private Integer yellowTime ;
/** 红灯时间 */
@ApiModelProperty(value = "红灯时间",notes = "")
private Integer redTime ;
/** 最小绿灯时间 */
@ApiModelProperty(value = "最小绿灯时间",notes = "")
private Integer minGreenTime ;
/** 最大绿灯时间 */
@ApiModelProperty(value = "最大绿灯时间",notes = "")
private Integer maxGreenTime ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(value = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.com.pojo.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/18 15:52
*/
@Data
public class CrossPlanPO {
/** 计划ID */
@ApiModelProperty(value = "计划ID",notes = "")
private Integer id ;
/** 计划号 */
@ApiModelProperty(value = "计划号",notes = "")
private String planNo ;
/** 计划名称 */
@ApiModelProperty(value = "计划名称",notes = "")
private String name ;
/** 路口ID */
@ApiModelProperty(value = "路口ID",notes = "")
private String crossId ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(value = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.com.pojo.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/18 18:37
*/
@Data
public class CrossSchedulesPO {
/** 日期ID */
@ApiModelProperty(value = "日期ID",notes = "")
private Integer id ;
/** 日期编号 */
@ApiModelProperty(value = "日期编号",notes = "")
private Integer scheduleNo ;
/** 日期名称 */
@ApiModelProperty(value = "日期名称",notes = "")
private String name ;
/** 路口ID */
@ApiModelProperty(value = "路口ID",notes = "")
private String crossId ;
/** 计划ID */
@ApiModelProperty(value = "计划ID",notes = "")
private Integer planId ;
/** 星期:1周一;2周二,3周三,4周四,5周五,6周六,7周日,0特殊日期 */
@ApiModelProperty(value = "星期:1周一",notes = "2周二,3周三,4周四,5周五,6周六,7周日,0特殊日期")
private Integer week ;
/** 特殊日期 */
@ApiModelProperty(value = "特殊日期",notes = "")
private Date specialDate ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(value = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.com.pojo.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/16 16:09
*/
@Data
public class CrossSchemePO {
/** 方案ID */
@ApiModelProperty(value = "方案ID",notes = "")
private Integer id ;
/** 方案号 */
@ApiModelProperty(value = "方案号",notes = "")
private String schemeNo;
/** 方案名称 */
@ApiModelProperty(value = "方案名称",notes = "")
private String name ;
/** 路口ID */
@ApiModelProperty(value = "路口ID",notes = "")
private String crossId ;
/** 周期 */
@ApiModelProperty(value = "周期",notes = "")
private Integer cycle ;
/** 协调相位ID */
@ApiModelProperty(value = "协调相位ID",notes = "")
private Integer coordPhase ;
/** 相位差 */
@ApiModelProperty(value = "相位差",notes = "")
private Integer offset ;
/** 数据来源:1信号机;2平台 */
@ApiModelProperty(value = "数据来源:1信号机;2平台",notes = "")
private Integer source ;
/** 删除标识:1删除;0未删除 */
@ApiModelProperty(value = "删除标识:1删除;0未删除",notes = "")
private Integer isDeleted ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(value = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.com.pojo.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/18 16:14
*/
@Data
public class CrossSectionPO {
/** 时段ID */
@ApiModelProperty(value = "时段ID",notes = "")
private Integer id ;
/** 时段号 */
@ApiModelProperty(value = "时段号",notes = "")
private String sectionNo ;
/** 开始时间 */
@ApiModelProperty(value = "开始时间",notes = "")
private String startTime ;
/** 结束时间 */
@ApiModelProperty(value = "结束时间",notes = "")
private String endTime ;
/** 路口ID */
@ApiModelProperty(value = "路口ID",notes = "")
private String crossId ;
/** 计划ID */
@ApiModelProperty(value = "计划ID",notes = "")
private Integer planId ;
/** 控制模式:1定周期;2绿波协调;3黄闪;4全红;5关灯;6单点自适应;7全感应;8半感应;9 */
@ApiModelProperty(value = "控制模式:1定周期;2绿波协调;3黄闪;4全红;5关灯;6单点自适应;7全感应;8半感应;9",notes = "")
private Integer controlMode ;
/** 方案ID */
@ApiModelProperty(value = "方案ID",notes = "")
private Integer scemeId ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(value = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.com.pojo.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/15 13:41
*/
@Data
public class ManufacturerApiInfoPO {
/** 接口ID */
@ApiModelProperty(value = "接口ID",notes = "")
private Integer id ;
/** 接口代码 */
@ApiModelProperty(value = "接口代码",notes = "")
private String code ;
/** 接口名称 */
@ApiModelProperty(value = "接口名称",notes = "")
private String name ;
/** 接口类型:1、静态;2、动态;3、控制 */
@ApiModelProperty(value = "接口类型:1、静态;2、动态;3、控制",notes = "")
private Integer type ;
/** 请求方式:GET、POST */
@ApiModelProperty(value = "请求方式:GET、POST",notes = "")
private String method ;
/** 接口地址 */
@ApiModelProperty(value = "接口地址",notes = "")
private String address ;
/** 厂商ID */
@ApiModelProperty(value = "厂商ID",notes = "")
private Integer manufacturerId ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(value = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.com.pojo.po;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/15 16:47
*/
@Data
@ApiModel(value = "ManufacturerInfoPO", description = "查询厂商列表返回值")
public class ManufacturerInfoPO {
/** 厂商ID */
@ApiModelProperty(value = "厂商ID",notes = "")
private Integer id ;
/** 厂商代码 */
@ApiModelProperty(value = "厂商代码",notes = "")
private String code ;
/** 厂商名称 */
@ApiModelProperty(value = "厂商名称",notes = "")
private String name ;
/** 厂商简称 */
@ApiModelProperty(value = "厂商简称",notes = "")
private String nickName ;
/** 平台地址 */
@ApiModelProperty(value = "平台地址",notes = "")
private String address ;
/** 维护单位 */
@ApiModelProperty(value = "维护单位",notes = "")
private String maintenanceUnit ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(value = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.com.pojo.po;
import lombok.Data;
import java.util.HashMap;
@Data
public class SignalLampStatus {
//信号机编号
private String signalId;
//运行模式
private Integer runmodel;
//方案号
private String planId;
//周期
private Integer cycleLen;
//当前步
private Integer stepNo;
//周期剩余时长
private Integer cycleCountDown;
//相位号
private String phaseId;
//当前步已走时间
private Integer stepGoneTime;
//方向灯组状态
private HashMap<String, HashMap<String, String>> dirLampGroupMap;
//存放当前方案每个相位的时长
HashMap<String, Integer> phaseMap;
//记录灯态变更时间
Long updateTime = Long.valueOf(0);
/**
* 信号机厂商编号
*/
private String signalType;
/**
* 当前步长
*/
private Integer stepLen;
/**
* 当前步剩余时长
*/
private Integer stepSurplusTime;
/**
* 相位内步号
*/
private Integer stepNum;
}
\ No newline at end of file
package net.wanji.com.pojo.po;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "SignalRunring", description = "信号机运行环数实体")
public class SignalRunring {
//绿灯1
@ApiModelProperty(value = "绿灯1时长")
private Integer oneTime;
//绿灯2
@ApiModelProperty(value = "绿灯2时长")
private Integer twoTime;
//绿灯3
@ApiModelProperty(value = "绿灯3时长")
private Integer threeTime;
//黄灯4
@ApiModelProperty(value = "黄灯4时长")
private Integer fourTime;
//红灯5
@ApiModelProperty(value = "红灯5时长")
private Integer fiveTime;
//环号
@ApiModelProperty(value = "环号")
private String runringNo;
//当前相位编号
@ApiModelProperty(value = "当前相位编号")
private String phaseId;
//相位时长
@ApiModelProperty(value = "相位时长")
private Integer phaseLen;
//相位剩余时长
@ApiModelProperty(value = "相位剩余时长")
private Integer phaseLeft;
//当前步号
@ApiModelProperty(value = "当前步号")
private Integer stepNo;
//当前步类型
@ApiModelProperty(value = "当前步类型")
private Integer stepType;
//当前步长
@ApiModelProperty(value = "当前步长")
private Integer stepLen;
//当前步剩余时间
@ApiModelProperty(value = "当前步剩余时间")
private Integer stepLeft;
//下一相位id
@ApiModelProperty(value = "下一相位id")
private String nextPhaseId;
//相位顺序号
@ApiModelProperty(value = "相位顺序号")
private Integer phaseOrderId;
//当前灯色
@ApiModelProperty(value = "当前灯色")
private Integer lampStatus;
//当前说明
// 11 灭灯
// 21 红灯
// 22 黄灯
// 23 绿灯
// 31 红黄
@ApiModelProperty(value = "当前灯色")
private String lampStatusName;
}
\ No newline at end of file
package net.wanji.com.pojo.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/21 11:18
*/
@Data
public class SignalStatusLogPO {
/** 日志ID */
@ApiModelProperty(value = "日志ID",notes = "")
private Integer id ;
/** 路口ID */
@ApiModelProperty(value = "路口ID",notes = "")
private String crossId ;
/** 信号机ID */
@ApiModelProperty(value = "信号机ID",notes = "")
@NotBlank(message = "信号机ID不能为空")
@Pattern(regexp = "^[\\w\\-]{1,50}$", message = "信号机ID只能包含英文、数字、下划线和中横线,1~50个字符")
private String signalId ;
// @Pattern(regexp = "^[\\u4E00-\\u9FA5\\w\\-]{0,20}$", messsage="信号机名称只能包含中文、英文、数字、下划线和中横线,0~20个字符")
/** 信号状态:0离线;1在线 */
@ApiModelProperty(value = "信号状态:0离线;1在线",notes = "")
private Integer status ;
/** 故障类型:0正常;1检测器故障;2时钟故障;3电源故障;4驱动模块故障;5信号灯故障;6箱门开启;7方案错误;8绿冲突;9红全熄;10行人红熄; */
@ApiModelProperty(value = "故障类型:0正常;1检测器故障;2时钟故障;3电源故障;4驱动模块故障;5信号灯故障;6箱门开启;7方案错误;8绿冲突;9红全熄;10行人红熄;",notes = "")
private Integer faultType ;
/** 控制类型:1时间表;2全红;3黄闪;4锁定;5中心优化;6MEC优化;7现场手动 */
@ApiModelProperty(value = "控制类型:1时间表;2全红;3黄闪;4锁定;5中心优化;6MEC优化;7现场手动",notes = "")
private Integer controlType ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
private Date gmtCreate ;
}
package net.wanji.com.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
import java.util.List;
/**
* 控制指令VO
*
* @author wuxiaokai
* @date 2022/11/15 15:05:57
*/
@Data
@ApiModel(value = "ControlCommandVO", description = "相位锁定实体类")
public class ControlCommandVO {
@ApiModelProperty(value = "路口编号", notes = "路口编号")
@NotBlank(message = "路口编号不可为空")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossCode;
@ApiModelProperty(value = "1是;0否")
@NotNull(message = "控制类型不可为空,1是;0否")
@Max(value = 1, message = "控制类型:1是;0否")
@Min(value = 0, message = "控制类型:1是;0否")
private Integer command;
@ApiModelProperty(value = "持续时间", notes = "持续时间, 可为空,默认999")
private Integer duration;
@ApiModelProperty(value = "锁定相位列表", notes = "锁定相位列表, 可为空")
private List<Integer> phaseList;
}
package net.wanji.com.pojo.vo;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class CrossLanesVo {
/** 通道号 */
private Integer channelNo;
/** 车道号 */
private Integer laneNo;
/** 方向 */
private Integer direction;
/** 转向 */
private Integer turn;
/** 灯组类型 */
private Integer lampGroupType;
}
\ No newline at end of file
package net.wanji.com.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author duanruiming
* @date 2023/04/11 9:26
*/
@Data
@ApiModel(value = "delBaseConfigVO", description = "信号机删除命令实体")
public class DelBaseConfigVO {
@ApiModelProperty(value = "路口编号")
@NotBlank
private String crossId;
@ApiModelProperty(value = "参数类型:4-相位、5-方案、6-计划、7-日期")
@NotNull
private Integer type;
@ApiModelProperty(value = "需要删除对应配置的id列表")
@NotEmpty
private List<Integer> ids;
}
package net.wanji.com.pojo.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.wanji.com.pojo.po.BaseCrossInfo;
import java.util.Date;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Data
public class DetailCrossInfoVO extends BaseCrossInfo {
//路口名称
private String crossName;
//路口类型,2行人过街 3 丁字口 4 十字口 5 五岔口 6 六岔口
private String crossType;
private String ip;
private Integer port;
// 版本号
private String version;
// 型号
private String model ;
// 安装时间
private Date installTime;
//经度
private Double lon;
//纬度
private Double lat;
//路口进口方向对象列表
private List<Direction> directions;
}
\ No newline at end of file
package net.wanji.com.pojo.vo;
import lombok.Data;
import java.util.List;
@Data
public class Direction {
//方向:0 北 1 东北 2 东 3 东南 4 南 5 西南 6 西 7 西北
private Integer direction;
//道路信息列表
private List<Road> roads;
}
\ No newline at end of file
package net.wanji.com.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.wanji.com.pojo.po.BaseCrossInfo;
import net.wanji.com.pojo.po.SignalRunring;
import java.util.List;
import java.util.Map;
/**
* @author Kent HAN
* @date 2022/11/21 14:04
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class LightsStatusVO extends BaseCrossInfo {
//运行模式
@ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`," +
"`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`,`255=临时控制方案`")
private String runMode;
//控制模式
@ApiModelProperty(value = "控制模式")
private String controlMode;
//相位方案号
@ApiModelProperty(value = "相位方案号")
private String phasePlanId;
//相位配时方案
@ApiModelProperty(value = "相位配时方案")
private String timePlanId;
//方案开始时间
@ApiModelProperty(value = "方案开始时间")
private String planStartTime;
//方案运行时间
@ApiModelProperty(value = "方案运行时间")
private Integer runTime;
//相位周期剩余时长
@ApiModelProperty(value = "相位周期剩余时长")
private Integer cycleCountDown;
@ApiModelProperty(value = "相位周期剩余时长")
private Integer cyclePhaseCountDown;
//相位周期时长
@ApiModelProperty(value = "相位周期时长")
private Integer cycleLen;
//运行环数组
private List<SignalRunring> runrings;
//相位编号
@ApiModelProperty(value = "当前相位号")
private String phaseId;
//方案编号
@ApiModelProperty(value = "当前方案号")
private String planId;
//灯组状态
@ApiModelProperty(value = "灯组状态")
private Map<String,Object> dirLampGroupMap;
//相位对象:key:相位编号,value:绿灯时长
@ApiModelProperty(value = "相位对象:key相位编号,value绿灯时长")
private Map<String,Object> phaseMap;
public void setCycleCountDown(Integer cycleCountDown) {
if (null == cycleCountDown) {
this.cycleCountDown = -1;
} else {
this.cycleCountDown = cycleCountDown;
}
}
public Integer getCycleCountDown() {
if (null == cycleCountDown) {
return -1;
}
return cycleCountDown;
}
}
package net.wanji.com.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
* 下发相位参数VO
*
* @author wuxiaokai
* @date 2022/12/9 11:08:51
*/
@Setter
@Getter
@ApiModel(value = "下发相位参数输入参数", description = "下发相位参数输入参数")
public class PhaseTimingSendVO {
@ApiModelProperty(value = "路口编号", notes = "路口编号")
@NotBlank(message = "路口编号不可为空")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossCode;
@ApiModelProperty(value = "需要下发的相位列表", notes = "需要下发的相位列表")
@NotEmpty(message = "相位列表不可为空")
private List<Phase> phaseList;
/**
* 相位
*/
@Setter
@Getter
public static class Phase {
/**
* 相位号
*/
@ApiModelProperty(value = "相位号", notes = "相位号")
private Integer phaseNo;
/**
* 相位描述
*/
@ApiModelProperty(value = "相位描述", notes = "相位描述")
private String desc;
/**
* 黄灯
*/
@ApiModelProperty(value = "黄灯", notes = "黄灯")
private Integer yellow;
/**
* 全红
*/
@ApiModelProperty(value = "全红", notes = "全红")
private Integer allred;
/**
* 绿闪
*/
@ApiModelProperty(value = "绿闪", notes = "绿闪")
private String greenFlash;
/**
* 红闪
*/
@ApiModelProperty(value = "红闪", notes = "红闪")
private String redFlash;
/**
* 最小绿
*/
@ApiModelProperty(value = "最小绿", notes = "最小绿")
private String minGreen;
/**
* 最大绿
*/
@ApiModelProperty(value = "最大绿", notes = "最大绿")
private String maxGreen;
/**
* 相位关联的车道列表
*/
@ApiModelProperty(value = "相位关联的车道列表", notes = "相位关联的车道列表")
private List<Lane> lanes;
@Setter
@Getter
public static class Lane {
/**
* 车道号
*/
@ApiModelProperty(value = "车道号", notes = "车道号")
private Integer laneNo;
/**
* 方向
*/
@ApiModelProperty(value = "方向", notes = "方向")
private Integer direction;
/**
* 转向
*/
@ApiModelProperty(value = "转向", notes = "转向")
private Integer turn;
}
}
}
package net.wanji.com.pojo.vo;
import lombok.Data;
import net.wanji.com.pojo.po.CrossPlanPO;
import net.wanji.com.pojo.po.CrossSectionPO;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/12/1 14:07
*/
@Data
public class PlanSectionVO {
private List<CrossPlanPO> crossPlanPOList;
private List<CrossSectionPO> crossSectionPOList;
}
package net.wanji.com.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
* 信号机计划下发VO
*
* @author wuxiaokai
* @date 2022/11/24 15:55:08
*/
@Setter
@Getter
@ApiModel(value = "信号机计划下发输入参数", description = "信号机计划下发输入参数")
public class PlanSendVO {
@ApiModelProperty(value = "路口编号", notes = "路口编号")
@NotBlank(message = "路口编号不可为空")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossCode;
@ApiModelProperty(value = "计划列表", notes = "计划列表")
@NotEmpty(message = "计划列表不可为空")
private List<Plan> planList;
@Setter
@Getter
public static class Plan {
/**
* 计划号
*/
@ApiModelProperty(value = "计划号", notes = "计划号")
private String planNo;
/**
* 计划描述
*/
@ApiModelProperty(value = "计划描述", notes = "计划描述")
private String planDescribe;
/**
* 时段列表
*/
@ApiModelProperty(value = "时段列表", notes = "时段列表")
private List<Section> sectionList;
@Setter
@Getter
public static class Section {
/**
* 时段号
*/
@ApiModelProperty(value = "时段号", notes = "时段号")
private String sectionNo;
/**
* 开始时间
*/
@ApiModelProperty(value = "开始时间", notes = "开始时间")
private String beginTime;
/**
* 结束时间
*/
@ApiModelProperty(value = "结束时间", notes = "结束时间")
private String endTime;
/**
* 控制模式:1定周期;2绿灯;3黄灯;4红灯;5关灯;6绿闪;7黄闪;8红闪
*/
@ApiModelProperty(value = "控制模式:1定周期;2绿灯;3黄灯;4红灯;5关灯;6绿闪;7黄闪;8红闪", notes = "")
private String controlMode;
/**
* 方案号
*/
@ApiModelProperty(value = "方案号", notes = "")
private String patternNo;
}
}
}
package net.wanji.com.pojo.vo;
import lombok.Data;
@Data
public class Road {
//道路编号
private String roadId;
//道路名称
private String roadName;
}
\ No newline at end of file
package net.wanji.com.pojo.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.wanji.com.pojo.po.BaseCrossInfo;
/**
* @author Kent HAN
* @date 2022/11/21 9:44
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class RunningStatusVO extends BaseCrossInfo {
// 信号状态:0离线;1在线
private Integer status;
// 故障类型:0正常;1检测器故障;2时钟故障;3电源故障;4驱动模块故障;5信号灯故障;6箱门开启;7方案错误;8绿冲突;9红全熄;10行人红熄
private Integer faultType;
// 控制模式:1时间表;2全红;3黄闪;4锁定;5中心优化;6MEC优化;7现场手动
private Integer controlType;
}
package net.wanji.com.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
* 时间表下发VO
*
* @author wuxiaokai
* @date 2022/11/23 14:11:09
*/
@Setter
@Getter
@ApiModel(value = "信号机时间表下发输入参数", description = "信号机时间表下发输入参数")
public class ScheduleSendVO {
@ApiModelProperty(value = "路口编号", notes = "路口编号")
@NotBlank(message = "路口编号不可为空")
@Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossCode;
@ApiModelProperty(value = "时间表", notes = "时间表")
@NotEmpty(message = "时间表不可为空")
private List<Schedule> schedules;
@Setter
@Getter
public static class Schedule {
/**
* 调度号
*/
private String scheduleNo;
/**
* 星期列表
*/
@ApiModelProperty(value = "星期列表", notes = "星期列表")
private List<Week> weeks;
/**
* 特殊日期列表
*/
@ApiModelProperty(value = "特殊日期列表", notes = "特殊日期列表")
private List<SpecialDay> specialDays;
@Setter
@Getter
public static class Week {
@ApiModelProperty(value = "星期", notes = "星期")
private Integer weekNum;
@ApiModelProperty(value = "计划号", notes = "计划号")
private Integer planNo;
}
@Setter
@Getter
public static class SpecialDay {
/**
* 日期 2019-05-01
*/
@ApiModelProperty(value = "日期", notes = "日期")
private String dateStr;
/**
* 计划号
*/
@ApiModelProperty(value = "计划号", notes = "计划号")
private Integer planNo;
}
}
}
package net.wanji.com.pojo.vo;
import lombok.Data;
import net.wanji.com.pojo.po.CrossLightsPO;
import net.wanji.com.pojo.po.CrossPhaseLightsPO;
import net.wanji.com.pojo.po.CrossPhasePO;
import net.wanji.com.pojo.po.CrossSchemePO;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/12/1 11:23
*/
@Data
public class SchemePhaseLightsVO {
private List<CrossSchemePO> crossSchemeList;
private List<CrossPhasePO> crossPhaseList;
private List<CrossLightsPO> crossLightsList;
private List<CrossPhaseLightsPO> crossPhaseLightsPOList;
}
package net.wanji.com.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
* 信号机方案下发VO
*
* @author wuxiaokai
* @date 2022/12/6 16:14:27
*/
@Setter
@Getter
@ApiModel(value = "信号机方案下发输入参数", description = "信号机方案下发输入参数")
public class SchemeSendVO {
@ApiModelProperty(value = "路口编号", notes = "路口编号")
@NotBlank(message = "路口编号不可为空")
@javax.validation.constraints.Pattern(regexp = "^[A-Za-z0-9]{11}$", message = "路口编号只能包含英文、数字,必须11个字符")
private String crossCode;
@ApiModelProperty(value = "方案列表", notes = "方案列表")
@NotEmpty(message = "方案列表不可为空")
private List<Pattern> patternList;
/**
* 方案
*/
@Setter
@Getter
public static class Pattern {
/**
* 方案号
*/
@ApiModelProperty(value = "方案号", notes = "")
private String patternNo;
/**
* 方案名称
*/
@ApiModelProperty(value = "方案名称", notes = "")
private String patternName;
/**
* 方案周期
*/
@ApiModelProperty(value = "方案周期", notes = "")
private String cycle;
/**
* 协调相位号
*/
@ApiModelProperty(value = "协调相位号", notes = "")
private String coordPhase;
/**
* 协调相位差
*/
@ApiModelProperty(value = "协调相位差", notes = "协调相位差")
private String offset;
@ApiModelProperty(value = "环列表", notes = "环列表")
private List<Ring> rings;
@Setter
@Getter
public static class Ring {
@ApiModelProperty(value = "环号", notes = "环号")
private String ringNo;
@ApiModelProperty(value = "相位列表", notes = "相位列表")
private List<Phase> phaseList;
/**
* 相位
*/
@Setter
@Getter
public static class Phase {
/**
* 相位号
*/
@ApiModelProperty(value = "相位号", notes = "")
private String phaseNo;
/**
* 相位名称
*/
@ApiModelProperty(value = "相位名称", notes = "")
private String phaseName;
/**
* 相位序号
*/
@ApiModelProperty(value = "相位序号", notes = "")
private String sort;
/**
* 控制模式:1定周期;2绿灯;3黄灯;4红灯;5关灯;6绿闪;7黄闪;8红闪
*/
@ApiModelProperty(value = "控制模式:1定周期;2绿灯;3黄灯;4红灯;5关灯;6绿闪;7黄闪;8红闪", notes = "")
private String controlMode;
/**
* 最小绿灯时间
*/
@ApiModelProperty(value = "最小绿灯时间", notes = "")
private String minGreenTime;
/**
* 最大绿灯时间
*/
@ApiModelProperty(value = "最大绿灯时间", notes = "")
private String maxGreenTime;
/**
* 相位时间
*/
@ApiModelProperty(value = "相位时间", notes = "")
private String phaseTime;
/**
* 绿灯时间
*/
@ApiModelProperty(value = "绿灯时间", notes = "")
private String greenTime;
/**
* 绿闪时间
*/
@ApiModelProperty(value = "绿闪时间", notes = "")
private String greenFlashTime;
/**
* 行闪时间
*/
@ApiModelProperty(value = "行闪时间", notes = "")
private String pedFlashTime;
/**
* 黄灯时间
*/
@ApiModelProperty(value = "黄灯时间", notes = "")
private String yellowTime;
/**
* 红灯时间
*/
@ApiModelProperty(value = "红灯时间", notes = "")
private String redTime;
}
//@Setter
//@Getter
//public static class Lights {
//
// /**
// * 灯组号
// */
// @ApiModelProperty(value = "灯组号", notes = "")
// private String lightsNo;
// /**
// * 灯组名称
// */
// @ApiModelProperty(value = "灯组名称", notes = "")
// private String name;
// /**
// * 灯组类型:1箭头;2圆饼,3行人
// */
// @ApiModelProperty(value = "灯组类型:1箭头2圆饼3行人", notes = "")
// private String type;
// /**
// * 灯组方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北
// */
// @ApiModelProperty(value = "灯组方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北", notes = "")
// private String dir;
// /**
// * 灯组转向:1左转;2右转;3直行;4左掉头;5直左;6直右;7右掉头;8向左合流;9向右合流;10左转加掉头;11右转加掉头;12直行加左掉头;13直行加右掉头;14左转右转;15左直右;16左转右转加掉头;17左直掉头;18左直右掉头;20行人
// */
// @ApiModelProperty(value = "灯组转向:1左转;2右转;3直行;4左掉头;5直左;6直右;7右掉头;8向左合流;9向右合流;10左转加掉头;11右转加掉头;12直行加左掉头;13直行加右掉头;14左转右转;15左直右;16左转右转加掉头;17左直掉头;18左直右掉头;20行人", notes = "")
// private String turn;
// /**
// * 行人进出口:1进口;2出口,3进出口
// */
// @ApiModelProperty(value = "行人进出口:1进口2出口,3进出口", notes = "")
// private String inOutType;
//}
}
}
}
package net.wanji.com.service;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.com.mapper.TCrossInfoMapper;
import net.wanji.com.mapper.ManufacturerInfoMapper;
import net.wanji.com.pojo.po.CrossInfoPO;
import net.wanji.com.pojo.po.ManufacturerInfoPO;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/08 16:12
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class CommonService {
private final TCrossInfoMapper TCrossInfoMapper;
private final ManufacturerInfoMapper manufacturerInfoMapper;
/**
* 通过路口编号获取厂商编码
*
* @param crossId
* @return
*/
@NonNull
public String getManufacturerCodeByCrossId(String crossId) {
CrossInfoPO crossInfoPO = TCrossInfoMapper.selectByPrimaryKey(crossId);
Integer manufacturerId = crossInfoPO.getManufacturerId();
ManufacturerInfoPO manufacturerInfoPO = manufacturerInfoMapper.selectById(manufacturerId);
return manufacturerInfoPO.getCode();
}
}
package net.wanji.com.service.controller;
/**
* @author duanruiming
* @date 2023/05/09 9:24
*/
public interface BeanMarkService {
String getBeanMark();
}
package net.wanji.com.service.controller;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.vo.*;
/**
* @author duanruiming
* @date 2023/05/08 10:42
*/
public interface ControlCommandService extends BeanMarkService{
/**
* 方案下发
*/
JsonViewObject schemeSend(SchemeSendVO schemeSendVO) throws Exception;
/**
* 计划下发
*
* @param planSendVO 计划下发VO
* @return
*/
JsonViewObject planSend(PlanSendVO planSendVO) throws Exception;
/**
* 时间表下发
*
* @param scheduleSendVO 时间表下发VO
* @return
*/
JsonViewObject scheduleSend(ScheduleSendVO scheduleSendVO) throws Exception;
/**
* 锁定控制
*
* @param commandVO 控制指令VO
* @return
* @throws Exception 异常
*/
JsonViewObject lockControl(ControlCommandVO commandVO) throws Exception;
/**
* 步进控制
*
* @param code 信号机编号
* @param command 1 开始步进 0 取消步进
* @param stepNum 0 顺序步进 n 跳过n个相位
* @return
* @throws Exception 异常
*/
JsonViewObject stepControl(String code, Integer command, Integer stepNum) throws Exception;
/**
* 设置信号机控制模式
*
* @param code 信号机编号
* @param command 指令 1 开 0 关
* @param commandType 命令类型
* @return
* @throws Exception 异常
*/
JsonViewObject setSignalControl(String code, Integer command, Integer commandType) throws Exception;
/**
* 恢复时间表
*
* @param code 信号机编号
* @return
*/
JsonViewObject recoverSchedule(String code) throws Exception;
/**
* 相位配时下发
*
* @return
* @throws InterruptedException 中断异常
*/
JsonViewObject phaseTimingSend(PhaseTimingSendVO phaseTimingSendVO) throws Exception;
/**
* 相位差下发
*/
JsonViewObject phaseDiffSend();
/**
* 删除信号机配置参数
* 删除信号机配置参数-目前支持相位、方案、计划、日期
*
* @param delBaseConfigPO
* @return
*/
// JsonViewObject delBaseConfig(DelBaseConfigPOfigPO delBaseConfigPO) throws Exception;
}
package net.wanji.com.service.controller;
import net.wanji.com.pojo.po.SignalStatusLogPO;
import net.wanji.com.pojo.vo.LightsStatusVO;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/11/21 9:09
*/
public interface SignalStatusService extends BeanMarkService {
List<SignalStatusLogPO> runningStatusAlarm();
/**
* todo 提供给其他平台,需要确认以厂商还是以路口形式推送数据
*
* @param crossId
* @return
*/
List<SignalStatusLogPO> runningStatusAlarm(String crossId);
List<LightsStatusVO> lightStatus();
List<LightsStatusVO> lightStatus(String crossId);
}
package net.wanji.com.service.controller;
import net.wanji.com.pojo.dto.CrossInfoDTO;
import net.wanji.com.pojo.dto.CrossSchedulesDTO;
import net.wanji.com.pojo.dto.PlanSectionDTO;
import net.wanji.com.pojo.dto.SchemePhaseLightsDTO;
import net.wanji.com.pojo.po.CrossInfoPO;
import net.wanji.com.pojo.po.CrossSchedulesPO;
import net.wanji.com.pojo.vo.PlanSectionVO;
import net.wanji.com.pojo.vo.SchemePhaseLightsVO;
import java.util.List;
public interface StaticInfoService extends BeanMarkService {
List<CrossInfoPO> crossBasicInfo(CrossInfoDTO crossInfoDTO) throws Exception;
void schemePhaseLights(SchemePhaseLightsDTO schemePhaseLightsDTO) throws Exception;
void planSection(PlanSectionDTO planSectionDTO) throws Exception;
void crossSchedules(CrossSchedulesDTO crossSchedulesDTO) throws Exception;
SchemePhaseLightsVO buildSchemePhaseLightsResponse(SchemePhaseLightsDTO schemePhaseLightsDTO);
PlanSectionVO buildPlanSectionResponse(String crossId);
PlanSectionVO buildPlanSectionResponse(String crossId, Integer planNo);
List<CrossSchedulesPO> buildCrossSchedulesResponse(List<String> crossIdList);
}
package net.wanji.com.service.controller.dt.impl;
import net.wanji.com.service.controller.ControlCommandService;
import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.vo.*;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/08 10:43
*/
@Service
public class DTControlCommandServiceImpl implements ControlCommandService {
@Override
public String getBeanMark() {
return BaseEnum.VendorTypeEnum.DT.getNick();
}
@Override
public JsonViewObject schemeSend(SchemeSendVO schemeSendVO) throws Exception {
return null;
}
@Override
public JsonViewObject planSend(PlanSendVO planSendVO) throws Exception {
return null;
}
@Override
public JsonViewObject scheduleSend(ScheduleSendVO scheduleSendVO) throws Exception {
return null;
}
@Override
public JsonViewObject lockControl(ControlCommandVO commandVO) throws Exception {
return null;
}
@Override
public JsonViewObject stepControl(String code, Integer command, Integer stepNum) throws Exception {
return null;
}
@Override
public JsonViewObject setSignalControl(String code, Integer command, Integer commandType) throws Exception {
return null;
}
@Override
public JsonViewObject recoverSchedule(String code) throws Exception {
return null;
}
@Override
public JsonViewObject phaseTimingSend(PhaseTimingSendVO phaseTimingSendVO) throws Exception {
return null;
}
@Override
public JsonViewObject phaseDiffSend() {
return null;
}
}
package net.wanji.com.service.controller.dt.impl;
import net.wanji.com.pojo.po.SignalStatusLogPO;
import net.wanji.com.pojo.vo.LightsStatusVO;
import net.wanji.com.service.controller.SignalStatusService;
import net.wanji.common.enums.BaseEnum;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author duanruiming
* @date 2023/05/08 17:28
*/
@Service
public class DTSignalStatusServiceImpl implements SignalStatusService {
@Override
public String getBeanMark() {
return BaseEnum.VendorTypeEnum.DT.getNick();
}
@Override
public List<SignalStatusLogPO> runningStatusAlarm() {
return null;
}
@Override
public List<SignalStatusLogPO> runningStatusAlarm(String crossId) {
return null;
}
@Override
public List<LightsStatusVO> lightStatus() {
return null;
}
@Override
public List<LightsStatusVO> lightStatus(String crossId) {
return null;
}
}
package net.wanji.com.service.controller.dt.impl;
import net.wanji.com.pojo.dto.CrossInfoDTO;
import net.wanji.com.pojo.dto.CrossSchedulesDTO;
import net.wanji.com.pojo.dto.PlanSectionDTO;
import net.wanji.com.pojo.dto.SchemePhaseLightsDTO;
import net.wanji.com.pojo.po.CrossInfoPO;
import net.wanji.com.pojo.po.CrossSchedulesPO;
import net.wanji.com.pojo.vo.PlanSectionVO;
import net.wanji.com.pojo.vo.SchemePhaseLightsVO;
import net.wanji.com.service.controller.StaticInfoService;
import net.wanji.common.enums.BaseEnum;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author duanruiming
* @date 2023/05/08 17:29
*/
@Service
public class DTStaticInfoServiceImpl implements StaticInfoService {
@Override
public String getBeanMark() {
return BaseEnum.VendorTypeEnum.DT.getNick();
}
@Override
public List<CrossInfoPO> crossBasicInfo(CrossInfoDTO crossInfoDTO) throws Exception {
return null;
}
@Override
public void schemePhaseLights(SchemePhaseLightsDTO schemePhaseLightsDTO) throws Exception {
}
@Override
public void planSection(PlanSectionDTO planSectionDTO) throws Exception {
}
@Override
public void crossSchedules(CrossSchedulesDTO crossSchedulesDTO) throws Exception {
}
@Override
public SchemePhaseLightsVO buildSchemePhaseLightsResponse(SchemePhaseLightsDTO schemePhaseLightsDTO) {
return null;
}
@Override
public PlanSectionVO buildPlanSectionResponse(String crossId) {
return null;
}
@Override
public PlanSectionVO buildPlanSectionResponse(String crossId, Integer planNo) {
return null;
}
@Override
public List<CrossSchedulesPO> buildCrossSchedulesResponse(List<String> crossIdList) {
return null;
}
}
package net.wanji.com.service.protocol;
import net.wanji.com.pojo.po.CrossInfoPO;
/**
* @author duanruiming
* @date 2023/05/08 10:25
*/
public interface ProtocolConversionService {
/**
* 协议解析接口
*
* @param crossInfo
* @return
*/
String protocolConvert(CrossInfoPO crossInfo);
}
package net.wanji.com.service.protocol.dt.impl;
import net.wanji.com.pojo.po.CrossInfoPO;
import net.wanji.com.service.protocol.ProtocolConversionService;
/**
* @author duanruiming
* @date 2023/05/08 15:38
*/
public class DTProtocolConversionServiceImpl implements ProtocolConversionService {
@Override
public String protocolConvert(CrossInfoPO crossInfo) {
return null;
}
}
server:
port: 32002
servlet:
display-name: Wanji
context-path: /com
multipart:
max-file-size: 50MB
max-request-size: 50MB
tomcat:
threads:
max: 10000
#线程池配置
threadPool:
corePoolSize: 5
maxPoolSize: 200
queueCapacity: 5
keepAliveTime: 60000
spring:
datasource:
dynamic:
primary: master
datasource:
master:
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://106.120.201.126:14726/t_signal_utc_changsha?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'&useSSL=false&useCursorFetch=true
username: root
password: Wanji300552
driverClassName: com.mysql.cj.jdbc.Driver
slave:
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://106.120.201.126:14726/t_signal_utc_changsha?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'&useSSL=false&useCursorFetch=true
username: root
password: Wanji300552
driverClassName: com.mysql.cj.jdbc.Driver
webService:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://106.120.201.126:14726/t_signal?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'&useSSL=false&useCursorFetch=true
username: root
password: Wanji300552
type: com.alibaba.druid.pool.DruidDataSource
redis:
host: 106.120.201.126
port: 14728
password: Wanji300552
jedis:
pool:
max-active: 200
max-wait: 5000
max-idle: 20
min-idle: 10
timeout: 5000
database: 3
# 信号平台
signal:
\ No newline at end of file
spring:
# dubbo启动需要程序名称
application:
name: com
profiles:
active: dev
jackson:
mapper:
accept_case_insensitive_properties: true
main:
allow-circular-references: true
# allow-bean-definition-overriding: true
mvc:
pathmatch:
matching-strategy: ant_path_matcher
service:
name: signal-communication-service
mybatis:
type-aliases-package: net.wanji.*.model
mapper-locations: classpath*:mapper/*.xml,classpath:mapper/*/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper:
mappers:
- net.wanji.web.mapper.MyBaseMapper
not-empty: false
identity: MYSQL
pagehelper:
helper-dialect: mysql
reasonable: false
# pagehelper分页 配置参数 supportMethodsArguments 建议不要全局设置
# https://www.cnblogs.com/liran123/p/12889093.html
support-methods-arguments: false
params: count=countSql
jasypt:
encryptor:
algorithm: PBEWithMD5AndDES
password: 7F84150B6A114C48F0EA1158484BF63C
iv-generator-classname: org.jasypt.iv.NoIvGenerator
mybatis-plus:
mapper-locations: classpath*:mapper/*.xml,classpath:mapper/*/*.xml
typeAliasesPackage: net.wanji.web.entity
check-config-location: true
configuration:
#是否开启自动驼峰命名规则(camel case)映射
map-underscore-to-camel-case: true
#全局地开启或关闭配置文件中的所有映射器已经配置的任何缓存
cache-enabled: false
call-setters-on-nulls: true
#配置JdbcTypeForNull, oracle数据库必须配置
jdbc-type-for-null: 'null'
#MyBatis 自动映射时未知列或未知属性处理策略 NONE:不做任何处理 (默认值), WARNING:以日志的形式打印相关警告信息, FAILING:当作映射失败处理,并抛出异常和详细信息
auto-mapping-unknown-column-behavior: warning
#开启SQL打印
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#线程池配置
threadPoolConfig:
threadPoolName: threadPoolExecutor
coreSize: 8
maxSize: 16
queueCapacity: 200
keepAliveTime: 6000
allowCoreTimeOut: false
<?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="net.wanji.com.mapper.ManufacturerInfoMapper">
<resultMap type="net.wanji.com.pojo.po.ManufacturerInfoPO" id="BaseResultMap">
<result property="id" column="id"/>
<result property="code" column="code"/>
<result property="name" column="name"/>
<result property="nickName" column="nick_name"/>
<result property="address" column="address"/>
<result property="maintenanceUnit" column="maintenance_unit"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<insert id="insertOne">
insert into t_manufacturer_info(code,name,nick_name,address,maintenance_unit)
values (#{code},#{name},#{nickName},#{address},#{maintenanceUnit})
</insert>
<update id="updateOne">
update t_manufacturer_info
<set>
<if test="code != null and code != ''">
code = #{code},
</if>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="nickName != null and nickName != ''">
nick_name = #{nickName},
</if>
<if test="address != null and address != ''">
address = #{address},
</if>
<if test="maintenanceUnit != null and maintenanceUnit != ''">
maintenance_unit = #{maintenanceUnit},
</if>
</set>
where id = #{id}
</update>
<delete id="deleteBatch">
delete from t_manufacturer_info
where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
<select id="selectByCode" resultMap="BaseResultMap">
select
id,code,name,nick_name,address,maintenance_unit,gmt_create,gmt_modified
from t_manufacturer_info
where code = #{code}
</select>
<select id="selectById" resultMap="BaseResultMap">
select
id,code,name,nick_name,address,maintenance_unit,gmt_create,gmt_modified
from t_manufacturer_info
where id = #{manufacturerId}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select
id,code,name,nick_name,address,maintenance_unit,gmt_create,gmt_modified
from t_manufacturer_info
</select>
<select id="selectByOptionalPartialName" resultMap="BaseResultMap">
select id,code,name,nick_name,address,maintenance_unit,gmt_create,gmt_modified
from t_manufacturer_info
<where>
<if test="name != null and name != ''">
AND name LIKE CONCAT('%',#{name},'%')
</if>
</where>
order by id
</select>
<select id="selectIdByNick" resultType="java.lang.Integer">
select id from t_manufacturer_info
where nick_name = #{manufacturerNick}
</select>
<select id="selectNickById" resultType="java.lang.String">
select nick_name from t_manufacturer_info
where id = #{manufacturerId}
</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="net.wanji.com.mapper.TCrossInfoMapper">
<resultMap type="net.wanji.com.pojo.po.CrossInfoPO" id="BaseResultMap">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="code" column="code"/>
<result property="manufacturerId" column="manufacturer_id"/>
<result property="ip" column="ip"/>
<result property="port" column="port"/>
<result property="location" column="location"/>
<result property="version" column="version"/>
<result property="model" column="model"/>
<result property="installTime" column="install_time"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<!-- 批量新增数据 -->
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into t_cross_info(id,name,code,manufacturer_id,ip,port,location,version,model,install_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.id},#{entity.name},#{entity.code},#{entity.manufacturerId},#{entity.ip},#{entity.port},#{entity.location},#{entity.version},#{entity.model},#{entity.installTime})
</foreach>
</insert>
<insert id="insertOne">
insert into t_cross_info(id, name, code, manufacturer_id, ip, port, location, version, model, install_time)
values (#{id}, #{name}, #{code}, #{manufacturerId}, #{ip}, #{port}, #{location}, #{version}, #{model},
#{installTime})
</insert>
<update id="updateOne">
update t_cross_info
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="code != null and code != ''">
code = #{code},
</if>
<if test="manufacturerId != null and manufacturerId != ''">
manufacturer_id = #{manufacturerId},
</if>
<if test="ip != null and ip != ''">
ip = #{ip},
</if>
<if test="port != null and port != ''">
port = #{port},
</if>
<if test="location != null and location != ''">
location = #{location},
</if>
<if test="version != null and version != ''">
version = #{version},
</if>
<if test="model != null and model != ''">
model = #{model},
</if>
<if test="installTime != null">
install_time = #{installTime},
</if>
</set>
where id = #{id}
</update>
<update id="updateOneByCodeAndManufacturerId">
update t_cross_info
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="code != null and code != ''">
code = #{code},
</if>
<if test="manufacturerId != null and manufacturerId != ''">
manufacturer_id = #{manufacturerId},
</if>
<if test="ip != null and ip != ''">
ip = #{ip},
</if>
<if test="port != null and port != ''">
port = #{port},
</if>
<if test="location != null and location != ''">
location = #{location},
</if>
<if test="version != null and version != ''">
version = #{version},
</if>
<if test="model != null and model != ''">
model = #{model},
</if>
<if test="installTime != null">
install_time = #{installTime},
</if>
</set>
where code = #{code} and manufacturer_id = #{manufacturerId}
</update>
<delete id="deleteBatch">
delete from t_cross_info
where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
<delete id="deleteById">
delete
from t_cross_info
where id = #{id}
</delete>
<select id="selectByPrimaryKey" resultMap="BaseResultMap">
select id,
name,
code,
manufacturer_id,
ip,
port,
location,
version,
model,
install_time,
gmt_create,
gmt_modified
from t_cross_info
where id = #{key}
</select>
<select id="selectCrossCodesByIds" resultType="java.lang.String">
select code
from t_cross_info
where id in
<foreach collection="entities" item="entity" separator="," open="(" close=")">
#{entity}
</foreach>
</select>
<select id="selectIdByCodeAndManufacturerId" resultType="java.lang.String">
select id
from t_cross_info
where code = #{crossCode}
and manufacturer_id = #{manufacturerId}
</select>
<select id="selectByCode" resultMap="BaseResultMap">
select id,
name,
code,
manufacturer_id,
ip,
port,
location,
version,
model,
install_time,
gmt_create,
gmt_modified
from t_cross_info
where code = #{code}
</select>
<select id="selectByManufacturerId" resultMap="BaseResultMap">
select id,
name,
code,
manufacturer_id,
ip,
port,
location,
version,
model,
install_time,
gmt_create,
gmt_modified
from t_cross_info
where manufacturer_id = #{manufacturerId}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select id,
name,
code,
manufacturer_id,
ip,
port,
location,
version,
model,
install_time,
gmt_create,
gmt_modified
from t_cross_info
</select>
<select id="selectByOptionals" resultMap="BaseResultMap">
select id,name,code,manufacturer_id,ip,port,location,version,model,install_time,gmt_create,gmt_modified
from t_cross_info
<where>
<if test="crossName != null and crossName != ''">
AND name LIKE CONCAT('%',#{crossName},'%')
</if>
<if test="manufacturerId != null and manufacturerId != 0">
AND manufacturer_id = #{manufacturerId}
</if>
</where>
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment