Commit 15e5e3d1 authored by duanruiming's avatar duanruiming

[add] 添加海信模块

parent 2153be0a
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.wanji</groupId>
<artifactId>traffic-signal-platform</artifactId>
<version>0.2.1</version>
</parent>
<artifactId>signal-utc-hisense-service</artifactId>
<name>signal-utc-dt-service</name>
<properties>
<java.version>1.8</java.version>
<mybatis.generator.version>1.3.2</mybatis.generator.version>
<mysql.connector.version>5.1.41</mysql.connector.version>
</properties>
<dependencies>
<dependency>
<groupId>net.wanji</groupId>
<artifactId>signal-feign-service</artifactId>
<version>0.0.2</version>
</dependency>
<dependency>
<groupId>net.wanji</groupId>
<artifactId>wj-common</artifactId>
<version>0.0.2</version>
<exclusions>
<exclusion>
<artifactId>mybatis</artifactId>
<groupId>org.mybatis</groupId>
</exclusion>
<exclusion>
<artifactId>jsqlparser</artifactId>
<groupId>com.github.jsqlparser</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.wanji</groupId>
<artifactId>wj-databus</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
</dependency>
<!-- apache commons-->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- redis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- ws rs -->
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</dependency>
<!-- pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
</dependency>
<!-- Hutool -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<!-- Gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<compilerArguments>
<encoding>${project.build.sourceEncoding}</encoding>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>${mybatis.generator.version}</version>
<configuration>
<configurationFile>${basedir}/src/main/resources/mybatis-generator/generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
<dependencies>
<!-- 数据库驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- swagger 导出配置 -->
<plugin>
<groupId>io.github.swagger2markup</groupId>
<artifactId>swagger2markup-maven-plugin</artifactId>
<version>1.3.3</version>
<configuration>
<swaggerInput>http://10.102.1.182:30003/utcsystem/v2/api-docs</swaggerInput>
<outputDir>src/docs/asciidoc/generated</outputDir>
<config>
<swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>
</config>
</configuration>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.6</version>
<configuration>
<sourceDirectory>src/docs/asciidoc/generated</sourceDirectory>
<outputDirectory>src/docs/asciidoc/html</outputDirectory>
<backend>html</backend>
<sourceHighlighter>coderay</sourceHighlighter>
<attributes>
<toc>left</toc>
</attributes>
</configuration>
</plugin>
<!-- mvn clean package -Dmaven.test.skip=true jib:build -DsendCredentialsOverHttp=true -->
<!-- 使用jib 无需深入学习docker, 无需编写Dockerfile -->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.5.2</version>
<!-- 将jib与mvn构建的生命周期绑定 -->
<executions>
<execution>
<id>build-image</id>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<!--from节点用来设置镜像的基础镜像,相当于Docerkfile中的FROM关键字-->
<from>
<!--使用harbor上的openjdk镜像-->
<image>${harbor.ip.port}/xinkong/openjdk:8-alpine3.9</image>
<!--harbor服务器的登录信息-->
<auth>
<username>admin</username>
<password>Wanji300552</password>
</auth>
</from>
<to>
<image>${harbor.ip.port}/xinkong/${artifactId}:${version}</image>
<auth>
<username>admin</username>
<password>Wanji300552</password>
</auth>
</to>
<container>
<!--配置jvm虚拟机参数-->
<jvmFlags>
<jvmFlag>-Xms512m</jvmFlag>
<jvmFlag>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=15118</jvmFlag>
</jvmFlags>
<!--配置使用的时区-->
<environment>
<TZ>Asia/Shanghai</TZ>
<spring.profiles.active>dev</spring.profiles.active>
</environment>
<!--要暴露的端口-->
<ports>
<port>39002</port>
<port>15118</port>
<port>5050</port>
</ports>
<!-- <creationTime>2022-10-14T10:08:59.304+08:00</creationTime>-->
<creationTime>${maven.build.timestamp}</creationTime>
<mainClass>net.wanji.utc.hisense.HisenseApplication</mainClass>
</container>
<!--可以进行HTTP-->
<allowInsecureRegistries>true</allowInsecureRegistries>
</configuration>
</plugin>
</plugins>
</build>
</project>
<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.utc.hisense;
import net.wanji.utc.hisense.netty.NettyClient;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
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.utc.hisense", "net.wanji.databus", "net.wanji.common"})
@MapperScan(basePackages = {"net.wanji.databus.dao.mapper"})
@EnableTransactionManagement
@EnableScheduling
@SuppressWarnings("all")
public class HisenseApplication implements CommandLineRunner {
@Value("${portParam.localPort}")
int localPort;
@Value("${portParam.remotePort}")
int remoteProt;
public static void main(String[] args) {
SpringApplication.run(HisenseApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
NettyClient.connection(localPort, remoteProt);
}
}
package net.wanji.utc.hisense.cache;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.enums.BaseEnum;
import net.wanji.common.utils.tool.StringUtils;
import net.wanji.databus.dao.mapper.CrossInfoMapper;
import net.wanji.databus.dao.mapper.ManufacturerInfoMapper;
import net.wanji.databus.po.CrossInfoPO;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.*;
/**
* @author duanruiming
* @date 2023/05/09 14:30
*/
@Slf4j
@Component
@SuppressWarnings("unchecked")
public class CrossInfoCache implements ApplicationRunner {
@Resource
private CrossInfoMapper crossInfoMapper;
@Resource
private ManufacturerInfoMapper manufacturerInfoMapper;
private static final Map<String, CrossInfoPO> crossInfoMap = new HashMap<>();
public Map<String, CrossInfoPO> getCrossInfoCache() {
if (!crossInfoMap.isEmpty()) {
return crossInfoMap;
}
return Collections.EMPTY_MAP;
}
public static CrossInfoPO getCrossInfoByIp(String ip) {
if (!crossInfoMap.isEmpty()) {
for (Map.Entry<String, CrossInfoPO> entry : crossInfoMap.entrySet()) {
CrossInfoPO crossInfoPO = entry.getValue();
if (StringUtils.equalsIgnoreCase(crossInfoPO.getIp(), ip)) {
return crossInfoPO;
}
}
}
return null;
}
@Override
public void run(ApplicationArguments args) throws Exception {
init();
}
private void init() {
Integer manufacturerId = manufacturerInfoMapper.selectIdByCode(BaseEnum.VendorTypeEnum.DT.getNick());
List<CrossInfoPO> CrossInfoPOS = crossInfoMapper.selectAll();
for (CrossInfoPO crossInfoPO : CrossInfoPOS) {
if (Objects.nonNull(manufacturerId) && Objects.equals(manufacturerId, crossInfoPO.getManufacturerId())) {
crossInfoMap.put(crossInfoPO.getId(), crossInfoPO);
}
}
}
}
package net.wanji.utc.hisense.cache;
import net.wanji.utc.hisense.pojo.convert.PhaseInfoPojo;
import net.wanji.utc.hisense.pojo.convert.PhaseStageInfoPojo;
import net.wanji.utc.hisense.pojo.convert.RunningLightsStatusPojo;
import net.wanji.utc.hisense.pojo.convert.SchemeInfoPojo;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author duanruiming
* @date 2023/06/19 15:28
*/
@Component
public class SignalDataCache {
public static final Map<String, List<SchemeInfoPojo>> schemeInfoCache = new HashMap<>();
public static final Map<String, List<PhaseStageInfoPojo>> phaseStageInfoCache = new HashMap<>();
public static final Map<String, List<PhaseInfoPojo>> phaseInfoCache = new HashMap<>();
// 海信推送灯态数据
public static final Map<String, RunningLightsStatusPojo> runningStateInfoCache = new HashMap<>();
}
package net.wanji.utc.hisense.cache.netty;
import net.wanji.utc.hisense.pojo.netty.MessageResultPojo;
import net.wanji.databus.po.CrossInfoPO;
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_RESULT_TIMEOUT_MAP = new HashMap<>();
/**
* key: ip/port:command
*/
public static final Map<String, CrossInfoPO> COMMAND_RESULT_SIGN_MAP = new HashMap<>();
}
package net.wanji.utc.hisense.common.constants;
import net.wanji.utc.hisense.util.CRC16Utils;
import org.springframework.stereotype.Component;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
@Component
@SuppressWarnings("all")
public class Constants {
public static final String COMMAND_HEAD = "7e";
public static final String COMMAND_TAIL = "7d";
// 操作类型, 数据对象id替换
public static final String COMMAND_COMMON = "010001000000010001%s010105%s000000";
public static final String COMMAND_SET_COMMON = "010001000000010001%s%s0105%s";
public static final String COMMAND_CENTER_COMMON = "010001000000010001%s010105%s%s";
public static final String COMMAND_HEART_BEAT_QUERY = "01000100000001000170";
public static final String COMMAND_HEART_BEAT_REPLY = "80";
public static final String COMMAND_QUERY = "10";
public static final String COMMAND_QUERY_REPLY = "20";
public static final String COMMAND_PHASE_CONFIG = "0402";
public static final String COMMAND_LIGHT_CONFIG = "0302";
public static final String COMMAND_LIGHT_STATUS = "0303";
public static final String COMMAND_PHASE_STAGE_CONFIG = "0602";
public static final String COMMAND_PHASE_STAGE_STATUS= "0603";
public static final String COMMAND_SCHME_CONFIG = "0902";
public static final String COMMAND_DAILYPLAN_CONFIG = "0b02";
public static final String COMMAND_SCHEDULE_CONFIG = "0c02";
public static final String COMMAND_DEVICE_STATUS = "0d01";
public static final String COMMAND_RUNNING_STATUS = "0d02";
public static final String COMMAND_FAULT_LIST = "1001";
public static final String COMMAND_SET = "30";
public static final String COMMAND_SET_REPLY = "40";
public static final String COMMAND_CENTER_COMMON_SIGN = "1101";
public static final String COMMAND_CENTER_CONTROL_STAGE = "11010201";
public static final String COMMAND_CENTER_CONTROL_SCHEME = "11010301";
public static final String COMMAND_CENTER_CONTROL_MODEL = "11010401";
public static final String COMMAND_CENTER_CHANNEL_MODEL = "1201";
/**
* 通过发送报文内容,添加报文长度,crc校验,报文头尾
* @param message
* @return
*/
public static String buildMessage(String message) {
String body = String.format("%04x", message.length() / 2 + 2).concat(message);
String crc16HexStr = CRC16Utils.getCRC16HexStr(body);
return Constants.buildMessageBody(body, crc16HexStr);
}
/**
* 消息体添加头、尾
*
* @param body
* @return
*/
public static String buildMessageBody(String body, String crc16) {
StringBuffer sb = new StringBuffer();
sb.append(Constants.COMMAND_HEAD).append(body).append(crc16).append(Constants.COMMAND_TAIL);
return sb.toString();
}
/**
* 系统缩写
*/
public static final String SYSTEM_ABBR = "UTC";
/**
* 分隔符:下划线
**/
public static final String SEPARATOR_UNDER_LINE = "_";
/**
* 分隔符:逗号
**/
public static final String SEPARATOR_COMMA = ",";
/**
* 分隔符:减号
**/
public static final String SEPARATOR_MINUS = "-";
/**
* 分隔符:冒号
**/
public static final String SEPARATOR_COLON = ":";
/**
* 海康返回成功码
*/
public static final Integer HK_SUCCESS_CODE = 0;
/**
* 海康返回码的 key
*/
public static final String HK_CODE_KEY = "code";
/**
* 海康返回成功码
*/
public static final String HK_SUCCESS_STRING_CODE = "0";
/**
* 失败-false
*/
public static final int FALSE = 0;
/**
* 成功-true
*/
public static final int TRUE = 1;
/**
* 相位(灯态)锁定
*/
public static final Integer LOCK_RUNNING_CONTROL = 12;
/**
* 相位(灯态)解锁: 0-多时段控制模式
*/
public static final Integer UNLOCK_RUNNING_CONTROL = 13;
/**
* 恢复正常方案: 0-多时段控制模式
*/
public static final Integer NORMAL_RUNNING_CONTROL = 0;
/**
* 关灯
*/
public static final Integer CLOSE_LIGHT_CONTROL = 1;
/**
* 黄闪
*/
public static final Integer YELLOW_LIGHT_CONTROL = 2;
/**
* 手动全红
*/
public static final Integer ALL_RED_CONTROL = 3;
/**
* 定周期控制
*/
public static final Integer FIXED_CYCLE_MODE = 4;
/**
* 步进控制
*/
public static final Integer STEP_CONTROL = 10;
/**
* 取消步进
*/
public static final Integer CANCEL_STEP_CONTROL = 11;
/*记录当前用户*/
public static ThreadLocal<String> current_user_id = ThreadLocal.withInitial(() -> "");
//gisc-develop 工作流事务全局标识,默认不开启
public static ThreadLocal<Boolean> OPEN_GLOBAL_TRANSACTION = ThreadLocal.withInitial(() -> Boolean.FALSE);
//gisc-develop D2A事务实现,db操作临时conn存放
public static ThreadLocal<List<Connection>> DB_CONNS = ThreadLocal.withInitial(ArrayList::new);
//日志消息名称关键字
public static final String BP_LOG = "log";
//数据扩展表关键字
public static final String TABLE_RELATION = "_relation";
public final class MessageES {
public static final String MESSAGE_HISTORY = "message_history";
public static final String MESSAGE_CONSUME_HISTORY = "message_consume_history";
public static final String MESSAGE_FILTER_HISTORY = "message_filter_history";
}
public final class WebsocketMessage {
public static final String NEW_UNREAD_MESSAGE = "";
public static final String GET_UNREAD_COUNT = "";
public static final String GET_READ_MESSAGE = "";
public static final String GET_UNREAD_MESSAGE = "";
}
public final class igniteCacheName {
//bp design 模块缓存名称
public static final String BP_DESIGN_CACHE = "gisc-portal-cache-name";
public static final String BP_GATEWAY_CACHE = "gisc-gateway-cache-name";
public static final String GATEWAY_CACHE = "gatewayCache";
public static final String API_RESTFUL_CACHE = "apiRestfulCache";
public static final String A2A_RESTFUL_CACHE = "a2aRestfulCache";
public static final String D2A_TABLE_RESTFUL_CACHE = "d2aTableRestfulCache";
public static final String BP_ROADNET_CACHE = "gisc-roadnet-cache-name";
}
public final class Env {
public static final String BASE_HOME = "";
public static final String WORKFLOW_HOME = "configs/workflow/";
}
// RepoModuleType 分类
public final class RepoModuleTypeType {
public static final String RULE = "rule";
public static final String COMMON = "common";
public static final String APPLICATION = "application";
}
public final class MqTopic {
public static final String JAVA_MODULE_OFFLINE_TOPIC = "javaModuleOffline";
public static final String JAVA_MODULE_ONLINE_TOPIC = "javaModuleOnline";
}
public final class MqKey {
}
public final class ImportExport {
public static final String IMPORT = "import";
public static final String EXPORT = "export";
}
public final class DevExport {
public static final String MAN_DEV_APP = "MAN_DEV_APP.csv";
public static final String MAN_DEV_APPTHEME = "MAN_DEV_APPTHEME.csv";
public static final String MAN_APP_TYPE = "MAN_APP_TYPE.csv";
public static final String MAN_GW_D2A_DATABASE = "MAN_GW_D2A_DATABASE.csv";
public static final String MAN_DEV_API_RESTFUL = "MAN_DEV_API_RESTFUL.csv";
public static final String MAN_GW_D2A_TABLE_RESTFUL = "MAN_GW_D2A_TABLE_RESTFUL.csv";
public static final String MAN_DEV_RESTFUL = "MAN_DEV_RESTFUL.csv";
public static final String MAN_GW_D2A_TABLE = "MAN_GW_D2A_TABLE.csv";
public static final String MAN_GW_D2A_TABLE_FIELDS = "MAN_GW_D2A_TABLE_FIELDS.csv";
public static final String MAN_DEV_DATA_DICT_CONTENT = "MAN_DEV_DATA_DICT_CONTENT.csv";
public static final String MAN_DEV_DATA_DICT_TYPE = "MAN_DEV_DATA_DICT_TYPE.csv";
public static final String MAN_GW_M2A_MAIL = "MAN_GW_M2A_MAIL.csv";
public static final String MAN_REPO_MODULE_TYPE = "MAN_REPO_MODULE_TYPE.csv";
public static final String MAN_REPO_MODULE = "MAN_REPO_MODULE.csv";
public static final String MAN_DEV_MODULE = "MAN_DEV_MODULE.csv";
public static final String MAN_MSG_TOPIC = "MAN_MSG_TOPIC.csv";
public static final String MAN_MSG_ROUTE = "MAN_MSG_ROUTE.csv";
public static final String MAN_MSG_SUBSCRIBE = "MAN_MSG_SUBSCRIBE.csv";
public static final String MAN_MSG_FILTER_ITEM = "MAN_MSG_FILTER_ITEM.csv";
public static final String CLI_IC_APP_BUSINESS_ACCOUNT = "CLI_IC_APP_BUSINESS_ACCOUNT.csv";
public static final String CLI_IC_ORGANIZATION = "CLI_IC_ORGANIZATION.csv";
public static final String CLI_IC_ROLE = "CLI_IC_ROLE.csv";
public static final String CLI_IC_ROLE_BUSINESSACCOUNT_RLAT = "CLI_IC_ROLE_BUSINESSACCOUNT_RLAT.csv";
public static final String CLI_DEV_MENU = "CLI_DEV_MENU.csv";
public static final String MAN_MSG_TOPIC_FILTER_ITEM_RLAT = "MAN_MSG_TOPIC_FILTER_ITEM_RLAT.csv";
public static final String MAN_DEV_PLUGIN_PARAM = "MAN_DEV_PLUGIN_PARAM.csv";
}
public final class BpmExport {
//导出流程定义表
public static final String WORKFLOW = "MAN_BPM_WORKFLOW.csv";
//导出流程实例表
public static final String WORKFLOW_INST = "MAN_BPM_WORKFLOW_INST.csv";
//导出流程任务表
public static final String WORKFLOW_INST_TASK = "MAN_BPM_WORKFLOW_TASK.csv";
//导出流程任务处理人表
public static final String WORKFLOW_INST_TASK_PERSON = "MAN_BPM_WORKFLOW_TASK_PERSON.csv";
//导出流程任务会签表
public static final String WORKFLOW_INST_TASK_SIGN = "MAN_BPM_WORKFLOW_TASK_COUNTERSIGN.csv";
//导出流程通知表
public static final String WORKFLOW_NOTICE = "MAN_BPM_WORKFLOW_NOTICE.csv";
//导出流程分类表
public static final String WORKFLOW_TYPE = "MAN_BPM_WORKFLOW_TYPE.csv";
//导出流程参数表
public static final String WORKFLOW_BPM_VAR = "MAN_BPM_VAR.csv";
//导出流程规则表
public static final String WORKFLOW_BPM_RULE = "MAN_BPM_RULE.csv";
//导出流程节点表
public static final String WORKFLOW_BPM_PLUGIN_PARAM = "MAN_BPM_PLUGIN_PARAM.csv";
//导出流程邮件日志表
public static final String WORKFLOW_MAIL_LOG = "MAN_BPM_MAIL_LOG.csv";
//导出流程原因表
public static final String WORKFLOW_LEAVE_INFO = "MAN_BPM_LEAVE_INFO.csv";
//导出流程form表单表
public static final String WORKFLOW_BPM_FORM = "MAN_BPM_FORM.csv";
//导出页面表
public static final String PAGE_WEB = "CLI_DEV_WEB_PAGE.csv";
//导出组件表
public static final String COMPONENT = "CLI_DEV_COMPONENT.csv";
//导出组件组表
public static final String COMPONENT_GROUP = "CLI_DEV_COMPONENT_GROUP.csv";
//导出组件版本表
public static final String COMPONENT_VERSION = "CLI_DEV_COMPONENT_VERSION.csv";
}
/**
* 系统基础服务路径
*/
public final class RestPathPrefix {
public static final String PREFIX = "bp/";
public static final String DEVELOP_PREFIX = "develop/";
public static final String LOG_PREFIX = "log/";
public static final String DESIGN_PREFIX = "design/";
public static final String MODEL_CONSOLE = "design/console/";
public static final String MODEL_IDENTITYAUTH = "bp/auth/";
public static final String MODEL_RESTFUL = "develop/restful/";
public static final String MODEL_IDENTITY = "bp/identity/";
public static final String MODEL_MSP = "bp/msp/";
public static final String MODEL_DATAMANAGE = "design/datamanage/";
public static final String MODEL_SGW = "design/sgw/";
public static final String MODEL_DISPLAYCENTER = "design/displaycenter/";
public static final String MODEL_TASKSCHEDULE = "design/taskschedule/";
public static final String MODEL_WEB = "design/web/";
public static final String FRONT_DEVELOP = "design/frontdevelop/";
public static final String MODEL_BPM_MANAGER = "design/bpm/";
public static final String MODEL_COMMON = "design/common/";
public static final String MODEL_PROCESS_QUERY = "develop/processquery/";
public static final String MODEL_MESSAGECENTER = "design/messagecenter/";
public static final String MODEL_DEV = "design/develop/";
public static final String MODEL_RULE = "design/rule/";
public static final String MODEL_DATA_CHECK = "design/datacheck/";
public static final String MODEL_TOOLS = "design/tools/";
public static final String MODEL_CONFIG_CENTER = "design/configcenter/";
public static final String MODEL_APPMANAGE = "design/appmanage/";
public static final String MODEL_COMPONENT = "design/component/";
public static final String MODEL_PORTAL = "design/portal/";
public static final String MODEL_LOG = "log/logcenter/";
public static final String MODEL_OPERATION_MONITOR = "design/operationmonitor/";
public static final String MODEL_SYSTEM_SETTING = "design/systemsetting/";
public static final String MODEL_STATISTICS = "bp/statistics/";
public static final String MODEL_IM = "bp/im/";
public static final String MODEL_DEVICE = "bp/things/";
public static final String MODEL_IM_USER = "bp/user/";
public static final String MODEL_IM_MESSAGE = "bp/message/";
public static final String MODEL_IM_GROUP = "bp/group/";
public static final String MODEL_IM_CHANNEL = "bp/channel/";
public static final String MODEL_IM_ORGANIZATION = "bp/organization/";
public static final String MODEL_IM_ORGAN_USER = "bp/organuser/";
public static final String MODEL_IM_STATISTICS = "bp/statistics";
public static final String MODEL_IM_TASK = "bp/task/";
//数据源
public static final String MODEL_DATASOURCE = "develop/datasource/";
//数据资源
public static final String MODEL_RESOURCE = "develop/resource/";
//数据资源管理
public static final String MODEL_RESOURCE_DATA = "develop/resourcedata/";
//基础数据
public static final String MODEL_BASE_DATA = "design/basedata/";
//服务接口
public static final String MODEL_DEV_SERVICE = "develop/service/";
//基础设置
public static final String MODEL_CONFIG_DATA = "design/config/";
//MSP
public static final String MODEL_MSP_STYLECONFIG = "bp/msp/config/";
//geoServer
public static final String GEOSERVER = "geoserver/";
/**
* msp相关path定义
*/
public static final String MODEL_MSP_SERVICE = "bp/msp/service/";
public static final String MODEL_MSP_RESOURCE = "bp/msp/resource/";
public static final String MODEL_MSP_CONFIG = "bp/msp/config/";
public static final String MODEL_MSP_TOOL = "bp/msp/tool/";
public static final String MODEL_MSP_SCENSE = "bp/msp/sense/";
/***
* 路网api定义
*/
public static final String ROADNET_API = "api/roadnet/";
/**
* 设备信息
*/
public static final String DEVICE_API = "api/device/";
}
public final class ServiceDevPathPrefix {
/**
* 数据库接口
*/
public static final String DEV_DB_INTERFACE = "sgw/dbInterface";
/**
* 服务接口接口
*/
public static final String DEV_API_INTERFACE = "sgw/apiInterface";
/**
* dev 注册服务
*/
public static final String DEV_SGW_SERVICE = "develop/sgw/serviceInterface/";
/**
* vt 矢量栅格服务
*/
public static final String DEV_VT_SERVICE = "develop/vt/";
}
/**
* 数据能力标签,元数据驱动的核心代码
*/
public final class DataTag {
/**
* geometry
* 空间表
* --
* export
* 导出
* --
* nest
* 套和
* --
* hook
* 挂接
* --
* cache
* 缓存
* --
* publish
* 发布
* --
* edit
*/
public static final String DATA_TAG_EXPORT = "export";
public static final String DATA_TAG_GEOMETRY = "geometry";
public static final String DATA_TAG_NEST = "nest";
public static final String DATA_TAG_HOOK = "hook";
public static final String DATA_TAG_CACHE = "cache";
public static final String DATA_TAG_PUBLISH = "publish";
public static final String DATA_TAG_EDIT = "edit";
}
/**
* Restful 对外的静态变量
*/
public final class JsonView {
public static final String STATUS_SUCCESS = "success";
public static final String STATUS_FAIL = "fail";
public static final String MESSAGE_FAIL = "操作失败";
public static final String MESSAGE_SUCCESS = "操作成功";
public static final String MESSAGE_PARAM_ERROR = "参数错误";
public static final String MESSAGE_FROMAT_ERROR = "请求格式错误";
public static final String MESSAGE_GET_PARAM_ERROR = "GET请求参数错误,注:暂不支持对象嵌套及数组";
public static final String MESSAGE_LOGIN_SUCCESS = "登录成功";
public static final String DELETE_ERROR_MSG = "表单【%s】已被流程【%s】使用";
}
/**
* 接口服务参数
*/
public static class ServiceConstants {
public static final String API_URL = "url";
public static final String API_ACCESS_METHOD = "method";
public static final String API_ACCESS_GET = "get";
public static final String API_ACCESS_POST = "post";
public static final String API_ACCESS_PUT = "put";
public static final String API_ACCESS_DELETE = "delete";
public static final String API_BODY = "body";
public static final String API_HEADER = "header";
public static final String API_QUERY = "query";
public static final String API_PATH = "pathParam";
}
/**
* @Description: 网关表,类型相关参数
* @return
* @Author mapabc8
* @Date 2020/2/14 10:10
**/
public static class ServiceType {
public static final String SERVICE_D2A = "d2a";
public static final String SERVICE_A2A = "a2a";
public static final String SERVICE_WEB_SERVICE = "webservice";
public static final String SERVICE_M2A = "m2a";
public static final String SERVICE_ORCHESTRATION = "orchestration";
public static final String SERVICE_DEVELOP = "develop";
public static final String SERVICE_BASIC = "basic";
public static final String SERVICE_BUSINESS = "business";
}
public static class AppType {
public static final String APP_REPOSITORY = "repository";
public static final String APP_EXTERNAL = "external";
public static final String APP_ORCHESTRATION = "orchestration";
public static final String APP_DEVELOP = "develop";
public static final String APP_INTERNAL = "internal";
}
/*
* apiType
* api 类型
*/
public static class RestfulApiType {
//内部系统
public static final String SERVICE_INSIDE = "inside";
//外部系统
public static final String SERVICE_OUTSIDE = "outside";
}
/*
* apiParam
* api 参数
*/
public static class ApiParam {
// mock
public static final String MOCK = "mock";
public static final String UNMOCK = "unmock";
}
/*
* spring application name
*/
public static class applicationName {
public static final String BP_RESTFUL = "gisc-restful";
public static final String BP_GATEWAY = "gisc-gateway";
public static final String BP_DESIGN = "gisc-portal";
public static final String BP_DEVELOP = "gisc-develop";
public static final String BP_IDENTITY = "gisc-identity";
public static final String BP_MSP = "gisc-msp";
}
/**
* 缓存名称
*/
public final class Cache {
public static final String USER = "user";
public static final String ONLINE_USER = "online_user";
public static final String ONLINE_MOBILE_USER = "online_mobile_user";
public static final String SYSTEM_SESSION = "system_session";
public static final String LOGIN_CACHE = "login_cache";
public static final String ETL_CACHE = "etl_workflow_cache";
public static final String RE_CACHE = "re_workflow_cache";
public static final String RE_CACHE_TOPIC = "re_workflow_cache_topic";
}
public final static class SystemParam {
/**
* 逗号分隔符
*/
public static String COMMA_SPLIT = ",";
/**
* 冒号分隔符
*/
public static String COLON_SPLIT = ":";
/**
* 空Json串
*/
public static String BLANK_JSON_STRING = "{}";
}
/**
* mysql 的字段类型
*/
public final static class MysqlColumn {
public final static String YEAR = "YEAR";
public final static String DATE = "DATE";
public final static String DATETIME = "DATETIME";
public final static String TIMESTAMP = "TIMESTAMP";
public final static String BINARY = "BINARY";
public final static String VARBINARY = "VARBINARY";
public final static String TINYINT = "TINYINT";
public final static String SMALLINT = "SMALLINT";
public final static String MEDIUMINT = "MEDIUMINT";
public final static String INT = "INT";
public final static String BIGINT = "BIGINT";
public final static String BIT = "BIT";
public final static String CHAR = "CHAR";
public final static String VARCHAR = "VARCHAR";
public final static String TEXT = "TEXT";
public final static String LONGTEXT = "LONGTEXT";
public final static String DECIMAL = "DECIMAL";
public final static String DOUBLE = "DOUBLE";
public final static String FLOAT = "FLOAT";
}
/**
* postgresql 的字段类型
*/
public final static class PostGreSqlColumn {
public final static String TEXT = "text"; // string
public final static String BPCHAR = "char"; // string
public final static String VARCHAR = "varchar"; // string
public final static String INT4 = "int4"; // integer
public final static String INT2 = "int2"; // integer
public final static String FLOAT4 = "float4"; // float
public final static String FLOAT8 = "float8"; // double
public final static String MONEY = "money"; // double
public final static String BIT = "bit"; // boolean
public final static String NUMERIC = "numeric"; // BigDecimal
public final static String BOOL = "bool"; // boolean
public final static String INT8 = "int8"; // long
public final static String TIMESTAMP = "timestamp"; // timestamp
public final static String TIME = "time"; // time
public final static String DATE = "date"; // time
public final static String BYTEA = "bytea"; // ?
public final static String BOX = "box"; // object
public final static String CIDR = "cidr"; // object
public final static String INET = "inet"; // object
public final static String MACADDR = "macaddr"; // object
public final static String VARBIT = "varbit"; // object
public final static String CIRCLE = "circle"; // object
public final static String INTERVAL = "interval"; // object
public final static String LINE = "line"; // object
public final static String LSEG = "lseg"; // object
public final static String POLYGON = "polygon"; // object
public final static String POINT = "point"; // object
public final static String PATH = "path"; // object
}
/**
* oracle 的字段类型
*/
public final static class OracleColumn {
public final static String VARCHAR2 = "VARCHAR2";
public final static String VARCHAR = "VARCHAR";
public final static String ORACLE_CHAR = "CHAR";
public final static String TIMESTAMP = "TIMESTAMP";
public final static String DATE = "DATE";
public final static String RAW = "RAW";
public final static String NVARCHAR2 = "NVARCHAR2";
public final static String TIMESTAMP_WITH_LOCAL_TIME_ZONE = "TIMESTAMP_WITH_LOCAL_TIME_ZONE";
public final static String TIMESTAMP_WITH_TIME_ZONE = "TIMESTAMP_WITH_TIME_ZONE";
public final static String INTERVAL_DAY_TO_SECOND = "INTERVAL_DAY_TO_SECOND";
public final static String INTERVAL_YEAR_TO_MONTH = "INTERVAL_YEAR_TO_MONTH";
public final static String NUMBER = "NUMBER";
public final static String FLOAT = "FLOAT";
}
/**
* @Description: sqlserver 的字段类型
* @return
* @Author mapabc8
* @Date 2020/3/12 17:47
**/
public final static class SqlServerColumn {
// Character 字符串
public final static String CHAR = "char";
public final static String VARCHAR = "varchar";
public final static String TEXT = "text";
// Number 类型
public final static String TINYINT = "tinyint";
public final static String SMALLINT = "smallint";
public final static String INT = "int";
public final static String BIGINT = "bigint";
public final static String FLOAT = "float";
// Binary类型
public final static String BIT = "bit";
public final static String BINARY = "binary";
public final static String VARBINARY = "varbinary";
// Date 类型
public final static String DATETIME = "datetime";
public final static String DATETIME2 = "datetime2";
public final static String TIMESTAMP = "timestamp";
}
/**
* 数据表相关
*/
public final static class TableInfo {
public static final String COLUMN_NAME = "COLUMN_NAME";
public static final String TYPE_NAME = "TYPE_NAME";
public static final String COLUMN_SIZE = "COLUMN_SIZE";
public static final String IS_PK = "IS_PK";
public static final String ISNULL = "ISNULL";
public static final String IS_BUSINESS_PK = "IS_BUSINESS_PK";
public static final String NULLABLE = "NULLABLE";
public static final String COLUMN_DEF = "COLUMN_DEF";
public static final String DECIMAL_DIGITS = "DECIMAL_DIGITS";
}
/**
* 数据库
*/
public final static class DataBase {
public static final String MYSQL = "mysql";
public static final String ORACLE = "oracle";
public static final String BEYONDB = "beyondb";
public static final String POSTGRESQL = "postgresql";
public static final String SQLSERVER = "sqlserver";
}
/**
* 数据源的驱动
*/
public static final class DbDriver {
public static final String MYSQL = "com.mysql.jdbc.Driver";
public static final String ORACLE = "oracle.jdbc.driver.OracleDriver";
public static final String BEYONDB = "org.postgresql.Driver";
public static final String IMPALA = "com.cloudera.impala.jdbc41.Driver";
public static final String SQLSERVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
public static final String POSTGRESQL = "org.postgresql.Driver";
}
private static final String DATE_FORMAT_DAY = "yyyy-MM-dd";
private static final String DATE_FORMAT_HOUR = "yyyy-MM-dd HH";
private static final String DATE_FORMAT_MINUTE = "yyyy-MM-dd HH:mm";
private static final String DATE_FORMAT_SECOND = "yyyy-MM-dd HH:mm:ss";
private static final String DATE_FORMAT_MILLIS = "yyyy-MM-dd HH:mm:ss.SSS";
private static final String DATE_FORMAT_TIME = "HH:mm:ss";
private static final String DATE_FORMAT_WEEKDAY = "EEEE";
public enum DATE_FORMAT {
// 平台指定的时间格式字符串
E_DATE_FORMAT_DAY(DATE_FORMAT_DAY),
E_DATE_FORMAT_HOUR(DATE_FORMAT_HOUR),
E_DATE_FORMAT_MINUTE(DATE_FORMAT_MINUTE),
E_DATE_FORMAT_SECOND(DATE_FORMAT_SECOND),
E_DATE_FORMAT_MILLIS(DATE_FORMAT_MILLIS),
E_DATE_FORMAT_TIME(DATE_FORMAT_TIME),
E_DATE_FORMAT_WEEKDAY(DATE_FORMAT_WEEKDAY);
private final String strFormat;
DATE_FORMAT(String strFormat) {
this.strFormat = strFormat;
}
public String getStrFormat() {
return strFormat;
}
}
public static final class ServicePluginParamArea {
public static final String GLOBAL = "global";
public static final String PARAM = "param";
public static final String OUTPUT = "output";
}
/*流程服务封装公用变量定义*/
public final class ProcessService {
public static final String ERROR_PARAM = "参数错误";
public static final String NO_PROCESS_OPERATE = "参数错误,无对应流程操作";
public static final String OPERATE_FAILD = "操作失败";
public static final String DEPLOY_SUCCESS = "部署成功";
public static final String DEPLOY_FAILD = "部署失败";
public static final String UNDEPLOY_SUCCESS = "取消部署成功";
public static final String UNDEPLOY_FAILD = "取消部署失败";
public static final String SUCCEED_COUNT = "成功条数";
public static final String FAILED_COUNT = "失败条数";
public static final String FAILED_USER_ID = "失败用户id";
public static final String START_ROWNUM = "startRowNum";
public static final String PAGE_SIZE = "pageSize";
public static final String PARAM_ERROR = "参数错误: processId=%s, userId=%s";
public static final String NODE_CONFIG_ERROR = "节点配置错误";
public static final String CANNOT_DEAL = "无法处理此任务,用户无对应操作权限或流程被暂停";
public static final String COMMENT_TYPE_PASS = "PASS";
public static final String COMMENT_TYPE_NO_PASS = "NO_PASS";
public static final String NR_OF_INSTANCES_VAR_NAME = "nrOfInstances";
public static final String NR_OF_ACTIVE_INSTANCES_VAR_NAME = "nrOfActiveInstances";
public static final String APPROVED_COUNTER_VAR_NAME = "approvedCounter";
public static final String COMMENT_BACK = "驳回";
public static final String COMMENT_TYPE_BACK = "BACK";
public static final String PAUSE_PROCESS = "流程已暂停,无法操作";
public static final String ADMIN_ID = "admin";
public static final String ALREADY_ACTIVE = "流程已激活,请勿重复操作";
public static final String ALREADY_ASSIGNED = "任务已分配到指定用户,无需重复操作";
public static final String COMMENT_ASSIGNE = "委派处理";
public static final String REJECT_ASSIGNE = "驳回处理";
public static final String COMMENT_TYPE_DEFAULT = "comment";
public static final String PROCESS_START_EVENT = "start";
public static final String PROCESS_END_EVENT = "end";
public static final String START_USER_ID = "startUserId";
public static final String PROCESS_INSTANCE_NAME = "processInstanceName";
public static final String NEED_EMAIL_VAR_NAME = "needEmail";
public static final String EMAIL_SERVICE_BEAN_NAME = "emailService";
public static final String CANDIDATE_USERS_VAR_NAME = "candidateUsers";
public static final String NOTICE_TYPE_START = "start";
public static final String NOTICE_TYPE_NEXT = "next";
/*流程表单保存在流程变量中的名称*/
public static final String FORM_DATA_USER_DEFINED_VAR_NAME = "formDataUserDefined";
public static final String START_FORM_DATA_USER_DEFINED_VAR_NAME = "startFormDataUserDefined";
/*流程是否通过流程变量*/
public static final String IS_APPROVED_VAR_NAME = "isApproved";
}
/*流程操作,枚举常量*/
public enum ProcessOperateType {
/*启动流程*/
start,
//审批,通过-不通过,通过变量控制
approve,
//驳回,到指定节点
back,
//委派
transfer,
//暂停
suspend,
//激活
active,
//作废
delete,
//抄送标记为已读
readCopyTo,
//抄送标记为未读
unReadCopyTo;
}
/*流程节点权限计算,枚举常量*/
public enum AUTH_CALCULATE_TYPE {
//根据指定企业
withCompany,
//根据指定部门
withDepartment,
//根据岗位
withStation,
//根据角色
withRole,
//根据企业用户
withCompanyUser,
//求并集
withUnion,
//求交集
withIntersection;
}
/**
* 流程定义bpmn20.xml生成字符属性
*/
public final static class Process {
public static final String DEFAULT_CHARSET = "UTF-8"; //编码格式utf-8定义
public static final String BPMN_XML_SUFFIX = ".bpmn20.xml"; //编码格式utf-8定义
/*bpmn20.xml节点定义 start*/
public static final String BPMN_DEFINITIONS = "definitions";
public static final String BPMN_XMLNS = "xmlns";
public static final String BPMN_XMLNS_CONTENT = "http://www.omg.org/spec/BPMN/20100524/MODEL";
public static final String BPMN_XMLNS_ACTIVITI = "xmlns:activiti";
public static final String BPMN_XMLNS_ACTIVITI_CONTENT = "http://activiti.org/bpmn";
public static final String BPMN_TARGET_NAMESPACE = "targetNamespace";
public static final String BPMN_TARGET_NAMESPACE_CONTENT = "http://activiti.org/bpmn20";
public static final String BPMN_XMLNS_XSI = "xmlns:xsi";
public static final String BPMN_XMLNS_XSI_CONTENT = "http://www.w3.org/2001/XMLSchema-instance";
public static final String BPMN_PROCESS = "process";
public static final String BPMN_ID = "id";
public static final String BPMN_PROCESS_ID = "processId";
public static final String BPMN_NAME = "name";
public static final String BPMN_SOURCE_REF = "sourceRef";
public static final String BPMN_TARGET_REF = "targetRef";
public static final String BPMN_CALLED_ELEMENT = "calledElement";
public static final String BPMN_EXTENSION_ELEMENTS = "extensionElements";
public static final String BPMN_SOURCE = "source";
public static final String BPMN_TARGET = "target";
public static final String BPMN_ACTIVITI_IN = "activiti:in";
public static final String BPMN_ACTIVITI_OUT = "activiti:out";
public static final String BPMN_CONDITION_EXPRESSION = "conditionExpression";
public static final String BPMN_XSI_TYPE = "xsi:type";
public static final String BPMN_FORMAL_EXPRESSION = "tFormalExpression";
public static final String BPMN_ACTIVITI_TASKLISTENER = "activiti:taskListener";
public static final String BPMN_EVENT = "event";
public static final String BPMN_CREATE = "create";
public static final String BPMN_CLASS = "class";
public static final String BPMN_ACTIVITI_CLASS = "activiti:class";
public static final String BPMN_ACTIVITI_EXECUTION_LISTENER = "activiti:executionListener";
public static final String BPMN_START = "start";
public static final String BPMN_END = "end";
public static final String BPMN_COMPLETE = "complete";
public static final String BPMN_EXPRESSION = "expression";
public static final String BPMN_COMPLETE_EXPRESSION_METHOD = "${userTaskHandler.postComplete(execution)}";
public static final String BPMN_START_EXPRESSION_METHOD = "${userTaskHandler.preStart(execution)}";
public static final String BPMN_ACTIVITI_CANDIDATE_USERS = "activiti:candidateUsers";
public static final String BPMN_ACTIVITI_CANDIDATE_USERS_VALUE = "${candidates}";
public static final String BPMN_MULTI_INSTANCE_LOOP_CHARACTERISTICS = "multiInstanceLoopCharacteristics";
public static final String BPMN_IS_SEQUENTIAL = "isSequential";
public static final String BPMN_IS_SEQUENTIAL_VALUE = "false";
public static final String BPMN_ACTIVITI_COLLECTION = "activiti:collection";
public static final String BPMN_ACTIVITI_COLLECTION_METHOD_NAME = "${userTaskHandler.getActorUser(execution)}";
public static final String BPMN_ACTIVITI_ELEMENT_VARIABLE = "activiti:elementVariable";
public static final String BPMN_CANDIDATES = "candidates";
public static final String BPMN_COMPLETION_CONDITION = "completionCondition";
public static final String BPMN_COMPLETION_CONDITION_CONTENT = "${userTaskHandler.dealComplete(execution)}";
public static final String BPMN_PROCESS_EXECUTION_LISTENER_NAME = "net.wanji.design.engine.operate.impl.ProcessExecutionListener";
public static final String BPMN_ACTIVITI_CLASS_NAME = "net.wanji.design.engine.operate.impl.AutoNodeServiceTask";
/*bpmn20.xml节点定义 end*/
/*流程设计器元素类型常量定义 start*/
public static final String START_NODE = "startNode";
public static final String END_NODE = "endNode";
public static final String APPROVAL_NODE = "approvalNode";
public static final String CONDITION_LINE = "conditionLine";
public static final String FORK_NODE = "forkNode";
public static final String CALL_ACTIVITY_NODE = "callActivityNode";
public static final String AUTO_NODE = "autoNode";
/*流程设计器元素类型常量定义 end*/
/*xml创建节点类型,枚举常量*/
public enum NodeType {
START("startEvent"),
END("endEvent"),
USERTASK("userTask"),
CONDITION("inclusiveGateway"),
FLOW("sequenceFlow"),
AUTO_NODE("serviceTask"),
CALL_ACTIVITY("callActivity");
private String value;
NodeType(String value) {
this.value = value;
}
@Override
public String toString() {
return this.value;
}
}
/*审批节点类型*/
public enum ApprovalNodeType {
SINGLE_INSTANCE, //非会签节点
MULTI_INSTANCE, //会签节点
COPY_TO; //抄送节点, 通过任务接收人实现, 用权限控制
}
}
/* 消息类型 */
public enum MessageType {
// 工作流消息
BPM_MESSAGE_LOG("bpm_log");
private String value;
MessageType(String value) {
this.value = value;
}
public static MessageType getEnumByValue(String value) {
for (MessageType msgType : MessageType.values()) {
if (msgType.toString().equals(value)) {
return msgType;
}
}
return null;
}
@Override
public String toString() {
return this.value;
}
}
/*日志保存操作类型*/
public enum LogType {
//接口日志 D2A
D2A_INTERFACE_API_LOG("d2a_interface_api_log"),
//接口日志 A2A
A2A_INTERFACE_API_LOG("a2a_interface_api_log"),
//接口日志 webservice
WEBSERVICE_INTERFACE_API_LOG("webservice_interface_api_log"),
//接口日志 基础接口
BASE_INTERFACE_API_LOG("base_interface_api_log"),
//接口日志 业务接口
BUSINESS_INTERFACE_API_LOG("business_interface_api_log"),
//接口日志 集成接口
INTEGRATION_INTERFACE_API_LOG("integration_interface_api_log"),
//接口日志 服务编排接口
SGW_INTERFACE_API_LOG("sgw_interface_api_log"),
//接口日志 邮件接口
MAIL_INTERFACE_API_LOG("mail_interface_api_log"),
//调度日志 d2a接口
SCHEDULE_D2A_INTERFACE_API_LOG("schedule_d2a_interface_api_log"),
//调度日志 A2A接口
SCHEDULE_A2A_INTERFACE_API_LOG("schedule_a2a_interface_api_log"),
//调度日志 基础接口
MICROSERVICE_BASE_INTERFACE_API_LOG("microservice_base_interface_api_log"),
//调度日志 业务接口
MICROSERVICE_BUSINESS_INTERFACE_API_LOG("microservice_business_interface_api_log"),
//调度日志 集成接口
MICROSERVICE_INTEGRATION_INTERFACE_API_LOG("microservice_integration_interface_api_log"),
//调度日志 服务编排
MICROSERVICE_ORCHESTRATION_INTERFACE_API_LOG("microservice_orchestration_interface_api_log"),
//调度日志 系统日志
SYSTEM_TASK_LOG("system_task_log"),
// 授权日志
AUTH_LOG("auth_log"),
//网关日志 基础接口日志
GATEWAY_BASE_INTERFACE_API_LOG("gateway_base_interface_api_log"),
//网关日志 业务接口日志
GATEWAY_BUSINESS_INTERFACE_API_LOG("gateway_business_interface_api_log"),
//网关日志 集成接口日志
GATEWAY_INTEGRATION_INTERFACE_API_LOG("gateway_integration_interface_api_log"),
//网关日志 a2a
GATEWAY_A2A_INTERFACE_API_LOG("gateway_a2a_interface_api_log"),
//网关日志 d2a
GATEWAY_D2A_INTERFACE_API_LOG("gateway_d2a_interface_api_log"),
//网关日志 服务编排
GATEWAY_ORCHESTRATION_INTERFACE_API_LOG("gateway_orchestration_interface_api_log"),
//服务开发插件日志
DEV_SERVICE_PLUGIN_LOG("dev_service_plugin_log"),
//服务开发流程日志
DEV_SERVICE_FLOW_LOG("dev_service_flow_log"),
//服务编排任务调度日志
DEV_SCHEDULE_LOG("dev_schedule_log"),
//服务编排发布日志
SGW_SERVICE_PUBLISH_LOG("sgw_service_publish_log"),
//服务编排插件日志
SGW_SERVICE_PLUGIN_LOG("sgw_service_plugin_log"),
//服务编排流程日志
SGW_SERVICE_FLOW_LOG("sgw_service_flow_log"),
//服务网关D2A日志
SGW_D2A_SERVICE_LOG("sgw_d2a_service_log"),
// 操作日志
OPERATION_LOG("operation_log"),
// 登录日志
LOGIN_LOG("login_log");
private String value;
LogType(String value) {
this.value = value;
}
public static LogType getEnumByValue(String value) {
for (LogType logType : LogType.values()) {
if (logType.toString().equals(value)) {
return logType;
}
}
return null;
}
@Override
public String toString() {
return this.value;
}
}
/**
* 重构移植 重新划分模块后,把之前bp-domain下的constants移植过来 start 20200514
*/
public static class ConsoleConstants {
public static final class User {
public static final String USER = "user";
public static final String SYS_USER = "sysUser";
public static final String TOKEN = "token";
}
}
public static class FunctionManageConstants {
public static final class FunctionJar {
public static final String DOWNLOAD_PATH_KEY = "folder";
}
}
public static class ServiceDevelopConstants {
public static final class TableOperationLogConst {
public static final String RES_TYPE = "table";
// 业务表的操作类型。
public static final String CREATE_TABLE_OPERATION = "new";
public static final String DELETE_TABLE_OPERATION = "delete";
public static final String UPDATE_TABLE_OPERATION = "update";
public static final String IMPORT_TABLE_OPERATION = "import";
}
}
public static class ServiceGateWayConstants {
public static final class D2ADataBase {
public static final String DB_MYSQL = "mysql";
public static final String DB_ORACLE = "oracle";
public static final String DB_SQLSERVER = "sqlserver";
public static final String DB_BEYONDB = "beyondb";
public static final String DB_POSTGRESQL = "postgresql";
}
public static final class DataSource {
public static final String DB_ELASTICSEARCH = "elasticsearch";
public static final String DB_KAFKA = "kafka";
public static final String DB_RABBITMQ = "rabbitmq";
public static final String DB_REDIS = "redis";
public static final String DB_WEBSOCKET = "websocket";
public static final String DB_WEBSERVICE = "webservice";
public static final String DB_MONGODB = "mongo";
}
public static final class TableRestfulConstants {
public final static String INTERFACE_CODE_BY_PAGE = "findByPage";
public final static String INTERFACE_CODE_BY_CONDITION = "findByWhere";
public final static String INTERFACE_CODE_BY_ID = "findById";
public final static String INTERFACE_CODE_INSERT = "insert";
public final static String INTERFACE_CODE_UPDATE = "update";
public final static String INTERFACE_CODE_DELETE = "delete";
public final static String INTERFACE_CODE_BY_SQL = "multiTable";//bySql
}
}
public static class ServicePublishConstants {
public final class SqlConstants {
public static final String BLANK = " ";
public static final String FIELD_NAME_EN = "fieldNameEn";
public static final String FIELD_TYPE = "type";
public static final String FIELD_VALUE = "value";
public static final String FIELD_FLAG = "flag";
public static final String OPERATIONS = "operations";
public static final String CONDITION_COLUMNS = "condition_columns";
public static final String TYPES_AND_VALUES = "typesAndValues";
public static final String CONDITION = "condition";
public static final String SET = "set";
public static final String OPERATION = "operation";
public static final String BETWEEN_OPERATION = "between";
public static final String PAGE_SIZE = "pageSize";
public static final String PAGE_NUM = "pageNum";
public static final String ORDER = "order";
public static final String IN_OPERATION = "in";
public static final String DESC_OPERATION = "DESC";
public static final String ASC_OPERATION = "ASC";
public static final String LIKE_OPERATION = "like";
}
/**
* 数据库类型常量定义
*/
public final class DBType {
public final static String MYSQL = "mysql";
public final static String ORACLE = "oracle";
public final static String SQLSERVER = "sqlserver";
public final static String BEYONDB = "beyondb";
}
}
public static class TaskScheduleConstants {
public static class ScheduleStatus {
public static final String STOP = "0";
public static final String START = "1";
}
}
public static class StatisticalConstants {
public static class UserTrends {
public static final String LOGIN_TIME = "loginTime";
public static final String START_DATE = "startDate";
public static final String END_DATE = "endDate";
public static final String CHART_DATA = "chartData";
public static final String DAILY_ACTIVE_USER = "dailyActiveUser";
public static final String DAILY_NEW_USER = "dailyNewUser";
public static final String DAILY_OLD_USER = "dailyOldUser";
public static final String DAILY_USER_VISITS = "dailyUserVisits";
public static final String DEDICATED_HOSTING_IP = "dedicatedHostingIp";
public static final String DAILY_UPDATE_USER = "dailyUpdateUser";
public static final String DAILY_NEWANDUPDATE_USER = "dailyNewAndUpdateUser";
public static final String DAILY_STARTUP = "dailyStartup";
}
}
/**
* IM类型
*/
public final class IM {
public static final String IM_CLIENT_ID = "IMClientId";
public static final String IM_PLATFORM = "IMPlatform";
public static final String IM_USER = "IMUser";
public static final String IM_TOKEN = "IMToken";
}
public final class Idnetity {
public static final String UNI_USER_AGENT = "X-Uni-User-Agent";
}
/**重构移植 end 20200514*/
/**
* 空间数据表
*/
public final class tableNameConstants {
public static final String RID_RID = "rid_rid";
public static final String RID_CROSS = "rid_cross";
public static final String RID_LANE_OBJ = "rid_lane_obj";
public static final String RID_AXF_THREE = "rid_axf_three";
public static final String ROAD_SEGMENT = "data_roadsegment";
}
/**
* 路网数据更新状态
*/
public final class DataConstants {
// 数据状态 0继承,1删除,2增加,3修改
public final static String DATA_MODE_EXTENTD = "0";
public final static String DATA_MODE_DELETE = "1";
public final static String DATA_MODE_ADD = "2";
public final static String DATA_MODE_EDIT = "3";
}
}
\ No newline at end of file
package net.wanji.utc.hisense.common.enums;
import lombok.Getter;
import net.wanji.utc.hisense.pojo.convert.RunningLightsStatusPojo;
import java.util.Objects;
/**
* @author duanruiming
* @date 2023/05/08 10:17
*/
@Getter
public enum CommandResultSignEnum {
GET_RUNNING_STATE_INFO(RunningLightsStatusPojo.class, "getRunningStateInfoService");
private final Object resultPojo;
private final String className;
CommandResultSignEnum(Class<?> resultPojo, String className) {
this.className = className;
this.resultPojo = resultPojo;
}
public static String getResultPojo(Object pojo) {
for (CommandResultSignEnum value : CommandResultSignEnum.values()) {
if (Objects.equals(value.getResultPojo(), RunningLightsStatusPojo.class)) {
return value.getClassName();
}
}
return null;
}
}
package net.wanji.utc.hisense.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.Objects;
/**
* @author duanruiming
* @date 2023/06/19 10:07
*/
@Getter
@AllArgsConstructor
@RequiredArgsConstructor
public enum ControlModelEnum {
FIXED_CYCLE(1, 2, "定周期"),
GREEN_WAVE(2, 0, "绿波协调"),
YELLOW_CONTROL(3, 1, "黄闪"),
RED_CONTROL(4, 7, "全红"),
CLOSED_CONTROL(5, 6, "关灯"),
SELF_CONTROL(6, 13, "单点自适应 -> 协调优化"),
FULL_INDUCTION(7, 3, "全感应 -> 本地感应"),
HALF_INDUCTION(8, 3, "半感应");
private Integer wjControl;
private Integer hisenseControlHex;
private String message;
public static Integer getWjControlMode(Integer hisenseControlHex) {
for (ControlModelEnum value : ControlModelEnum.values()) {
if (Objects.equals(hisenseControlHex, value.getHisenseControlHex())) {
return value.getWjControl();
}
}
return null;
}
}
package net.wanji.utc.hisense.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.Objects;
/**
* @author duanruiming
* @date 2023/06/19 10:07
*/
@Getter
@AllArgsConstructor
@RequiredArgsConstructor
public enum ControlTypeEnum {
FIXED_CYCLE(1, 6, "定周期-->时段表控制"),
ALL_RED(2, 3, "全红"),
YELLOW_CONTROL(3, 3, "黄闪"),
LOCK_CONTROL(4, 3, "锁定 --> 中心手动控制"),
CLOSED_CONTROL(5, 2, "中心优化"),
SELF_CONTROL(6, 0, "MEC优化"),
FULL_INDUCTION(7, 5, "现场手动-->面板手动"),
LOWER_LEVEL(8, 4, "降级");
private Integer wjControl;
private Integer hisenseControlHex;
private String message;
public static Integer getWjControlType(Integer hisenseControlHex) {
for (ControlTypeEnum value : ControlTypeEnum.values()) {
if (Objects.equals(hisenseControlHex, value.getHisenseControlHex())) {
return value.getWjControl();
}
}
return null;
}
}
package net.wanji.utc.hisense.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
/**
* @author duanruiming
* @date 2023/06/19 16:27
*/
@Getter
@AllArgsConstructor
@RequiredArgsConstructor
public enum PhaseLightColorEnum {
LIGHT_OFF("0", "off", "关灯"),
LIGHT_RED("2", "red", "红灯"),
LIGHT_GREEN("1", "green", "绿灯"),
LIGHT_GREEN_FLASH("21", "green", "绿闪"),
LIGHT_YELLOW("4", "yellow", "黄灯"),
LIGHT_YELLOW_FLASH("31", "yellow", "黄闪"),
LIGHT_RED_YELLOW("6", "redYellow", "红黄灯");
private String dtLightColor;
private String wjLightColor;
private String message;
public static String getWjLightColor(String dtLightColor) {
for (PhaseLightColorEnum value : PhaseLightColorEnum.values()) {
if (StringUtils.equals(dtLightColor, value.getDtLightColor())) {
return value.getWjLightColor();
}
}
return null;
}
}
package net.wanji.utc.hisense.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.Objects;
/**
* @author duanruiming
* @date 2023/06/21 9:31
*/
@Getter
@AllArgsConstructor
@RequiredArgsConstructor
public enum SectionControlModeEnum {
FIXED_CYCLE(1, "21", "定周期"),
GREEN_WAVE(2, "13", "绿灯"),
YELLOW_CONTROL(3, "31", "黄灯"),
RED_CONTROL(4, "32", "红灯"),
CLOSED_CONTROL(5, "33", "关灯"),
SELF_CONTROL(6, "14", "绿闪"),
FULL_INDUCTION(7, "31", "黄闪"),
HALF_INDUCTION(8, "32", "红闪");
private Integer wjControl;
private String dtControlHex;
private String message;
public static Integer getDtControlMode(Integer wjControlHex) {
for (ControlModelEnum value : ControlModelEnum.values()) {
if (Objects.equals(wjControlHex, value.getWjControl())) {
return value.getHisenseControlHex();
}
}
return null;
}
}
package net.wanji.utc.hisense.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.wanji.utc.hisense.service.controller.ControlCommandService;
import net.wanji.utc.hisense.service.controller.SignalStatusService;
import net.wanji.utc.hisense.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.utc.hisense.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.hisense.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.utc.hisense.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import net.wanji.utc.hisense.service.controller.ControlCommandService;
import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.vo.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author duanruiming
* @date 2023/05/08 10:45
*/
@Api(value = "信号指令服务", tags = "信号指令服务")
@RequestMapping("/controlCommand")
@RestController
@RequiredArgsConstructor
public class ControlCommandController {
private final ControlCommandService controlCommandService;
/**
* 信号机方案下发
*
* @param schemeSendVO 方案下发VO
* @return
*/
@AspectLog(description = "信号机方案下发-基础方案下发", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "信号机方案下发-基础方案下发", notes = "信号机方案下发-基础方案下发")
@PostMapping("/schemeSend")
public JsonViewObject schemeSend(@RequestBody @Validated SchemeSendVO schemeSendVO) throws Exception {
return controlCommandService.schemeSend(schemeSendVO);
}
/**
* 下发信号机计划
*
* @param planSendVO 计划下发VO
* @return
*/
@AspectLog(description = "计划下发-计划信息、时段信息", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "计划下发-计划信息、时段信息", notes = "计划下发-计划信息、时段信息")
@PostMapping("/planSend")
public JsonViewObject planSend(@RequestBody @Validated PlanSendVO planSendVO) throws Exception {
return controlCommandService.planSend(planSendVO);
}
/**
* 时间表下发
*
* @param scheduleSendVO 时间表下发VO
* @return
* @throws Exception 异常
*/
@AspectLog(description = "时间表下发-时间表信息", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "时间表下发-时间表信息", notes = "时间表下发-时间表信息")
@PostMapping("/scheduleSend")
public JsonViewObject scheduleSend(@RequestBody @Validated ScheduleSendVO scheduleSendVO) throws Exception {
return controlCommandService.scheduleSend(scheduleSendVO);
}
/**
* 相位配时下发-(下发相位参数)
*
* @return
* @throws InterruptedException 中断异常
*/
@AspectLog(description = "相位配时下发-(下发相位参数)", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "相位配时下发-(下发相位参数)", notes = "相位配时下发-(下发相位参数)")
@PostMapping("/phaseTimingSend")
public JsonViewObject phaseTimingSend(@RequestBody @Validated PhaseTimingSendVO phaseTimingSendVO) throws Exception {
return controlCommandService.phaseTimingSend(phaseTimingSendVO);
}
/**
* 全红控制
*
* @param commandVO 控制指令VO
* @return
* @throws Exception 异常
*/
@AspectLog(description = "全红控制-路口全红控制/恢复", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "全红控制-路口全红控制/恢复", notes = "全红控制-路口全红控制/恢复")
@PostMapping("/allRedControl")
public JsonViewObject allRedControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception {
return controlCommandService.setSignalControl(commandVO);
}
/**
* 黄闪控制
*
* @param commandVO 控制指令VO
* @return
* @throws Exception 异常
*/
@AspectLog(description = "黄闪控制-路口黄闪控制/恢复", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "黄闪控制-路口黄闪控制/恢复", notes = "黄闪控制-路口黄闪控制/恢复")
@PostMapping("/yellowLightControl")
public JsonViewObject yellowLightControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception {
return controlCommandService.setSignalControl(commandVO);
}
/**
* 关灯控制
*
* @param commandVO 控制指令VO
* @return
* @throws Exception 异常
*/
@AspectLog(description = "关灯控制-路口关灯控制/开灯", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "关灯控制-路口关灯控制/开灯", notes = "关灯控制-路口关灯控制/开灯")
@PostMapping("/closeLightControl")
public JsonViewObject closeLightControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception {
return controlCommandService.setSignalControl(commandVO);
}
/**
* 步进控制
*
* @param crossCode 信号id
* @param command 命令
* @param stepNum 一步num
* @return
*/
@AspectLog(description = "步进控制-步进控制/恢复", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "步进控制-步进控制/恢复", notes = "步进控制-步进控制/恢复")
@ApiImplicitParams({
@ApiImplicitParam(name = "crossCode", value = "13位路口编号", paramType = "query", required = true, dataType = "String"),
@ApiImplicitParam(name = "command", value = "1 开始步进 0 取消步进", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "stepNum", value = "0 顺序步进 n 跳过n个相位", paramType = "query", required = true, dataType = "int"),
})
@PostMapping("/stepControl")
public JsonViewObject stepControl(@RequestParam String crossCode,
@RequestParam Integer command,
@RequestParam int stepNum) throws Exception {
return controlCommandService.stepControl(crossCode, command, stepNum);
}
/**
* 恢复时间表
*
* @param crossCode
* @return
*/
@AspectLog(description = "恢复时间表-恢复路口时间表执行", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "恢复时间表-恢复路口时间表执行", notes = "恢复时间表-恢复路口时间表执行")
@PostMapping("/recoverSchedule")
public JsonViewObject recoverSchedule(@RequestParam String crossCode) throws Exception {
return controlCommandService.recoverSchedule(crossCode);
}
/**
* 锁定控制
*
* @param commandVO 控制指令VO
* @return
* @throws Exception 异常
*/
@AspectLog(description = "锁定控制-相位锁定/解锁", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "锁定控制-相位锁定/解锁", notes = "锁定控制-相位锁定/解锁")
@PostMapping("/lockControl")
public JsonViewObject lockControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception {
return controlCommandService.lockControl(commandVO);
}
/**
* 相位差下发
*/
@AspectLog(description = "相位差下发", operationType = BaseEnum.OperationTypeEnum.UPDATE)
@ApiOperation(value = "相位差下发", notes = "相位差下发")
@PostMapping("/phaseDiffSend")
public JsonViewObject phaseDiffSend(String crossCode) {
return controlCommandService.phaseDiffSend();
}
}
package net.wanji.utc.hisense.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.utc.hisense.service.controller.SignalStatusService;
import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.po.SignalStatusLogPO;
import net.wanji.databus.vo.LightsStatusVO;
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 = "运行状态、告警、灯态信息接口", tags = "运行状态、告警、灯态信息接口")
@RequestMapping("/signalStatus")
@RestController
@RequiredArgsConstructor
public class SignalStatusController {
private final SignalStatusService signalStatusService;
@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(String crossId) {
List<SignalStatusLogPO> signalStatusLogPOList = signalStatusService.runningStatusAlarm(crossId);
return JsonViewObject.newInstance().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(String crossId) {
List<LightsStatusVO> lightsStatusVOList = signalStatusService.lightStatus(crossId);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(lightsStatusVOList);
}
}
package net.wanji.utc.hisense.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.utc.hisense.service.controller.StaticInfoService;
import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.dao.entity.CrossSchedulesPO;
import net.wanji.databus.dto.CrossSchedulesDTO;
import net.wanji.databus.dto.PlanSectionDTO;
import net.wanji.databus.dto.SchemePhaseLightsDTO;
import net.wanji.databus.vo.PlanSectionVO;
import net.wanji.databus.vo.SchemePhaseLightsVO;
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;
/**
* 静态信息接口
*
* @date 2022/11/15 9:38
*/
@Api(value = "静态信息接口", tags = "静态信息接口")
@RequestMapping("/staticInfo")
@RestController
@RequiredArgsConstructor
public class StaticInfoController {
private final StaticInfoService staticInfoService;
@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 {
SchemePhaseLightsVO schemePhaseLightsVO = staticInfoService.schemePhaseLights(schemePhaseLightsDTO);
return JsonViewObject.newInstance().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 {
List<PlanSectionVO> planSectionVOS = staticInfoService.planSection(planSectionDTO);
return JsonViewObject.newInstance().success(planSectionVOS);
}
@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 {
List<CrossSchedulesPO> crossSchedulesPOS = staticInfoService.crossSchedules(crossSchedulesDTO);
return JsonViewObject.newInstance().success(crossSchedulesPOS);
}
}
package net.wanji.utc.hisense.netty;
import cn.hutool.core.util.HexUtil;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.DatagramPacket;
import io.netty.channel.socket.nio.NioDatagramChannel;
import lombok.extern.slf4j.Slf4j;
import net.wanji.utc.hisense.cache.CrossInfoCache;
import net.wanji.utc.hisense.cache.netty.NettyMessageCache;
import net.wanji.utc.hisense.netty.codec.MessageDecoder;
import net.wanji.utc.hisense.netty.codec.MessageEnCoder;
import net.wanji.utc.hisense.netty.handler.NettyServerHandler;
import net.wanji.utc.hisense.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.net.InetSocketAddress;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
public class NettyClient {
private static ChannelFuture udpChannelFuture = null;
@Resource(name = "commonThreadPoolExecutor")
private ThreadPoolTaskExecutor commonThreadPoolExecutor;
/**
* 建立连接
*/
public static void connection(int localPort, int remotePort) throws InterruptedException {
EventLoopGroup group = new NioEventLoopGroup();
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(group)
.channel(NioDatagramChannel.class)
.option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(65535))
.localAddress(new InetSocketAddress(localPort))
.remoteAddress(new InetSocketAddress(remotePort))
.handler(new ChannelInitializer<NioDatagramChannel>() {
@Override
protected void initChannel(NioDatagramChannel datagramChannel) {
datagramChannel.pipeline()
.addLast("decoder", new MessageDecoder())
.addLast("encoder", new MessageEnCoder())
.addLast(new NettyServerHandler());
}
});
ChannelFuture channelFuture = bootstrap.bind().sync();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
group.shutdownGracefully();
channelFuture.channel().closeFuture().syncUninterruptibly();
log.warn("udp服务关闭!");
}));
log.info("udp服务正在运行,端口:{}", localPort);
NettyClient.udpChannelFuture = channelFuture;
}
public static void sendMessage(String ip, Integer port, String msg) {
byte[] bytes = HexUtil.decodeHex(msg);
try {
if (udpChannelFuture == null) {
return;
}
udpChannelFuture.channel()
.writeAndFlush(new DatagramPacket(Unpooled.copiedBuffer(bytes), new InetSocketAddress(ip, port))).sync();
log.debug("发送信号机:{}/{}命令消息:{}", ip, port, msg);
} catch (InterruptedException e) {
log.error("sendMsg is error", e);
}
}
public static MessageResultPojo sendMessage(String ip, Integer port, String msg, String command, int timeout) {
try {
if (timeout > 0) {
CountDownLatch countDownLatch = new CountDownLatch(1);
String key = StringUtils.join("/", ip, ":", port, "/", command);
long now = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
MessageResultPojo messageResultPojo = new MessageResultPojo(command, countDownLatch, now, timeout, null);
NettyMessageCache.NETTY_RESULT_TIMEOUT_MAP.put(key, messageResultPojo);
NettyMessageCache.COMMAND_RESULT_SIGN_MAP.put(key, CrossInfoCache.getCrossInfoByIp(ip));
sendMessage(ip, port, msg);
countDownLatch.await(timeout, TimeUnit.MILLISECONDS);
return NettyMessageCache.NETTY_RESULT_TIMEOUT_MAP.remove(key);
}
} catch (InterruptedException e) {
log.error("sendMsg is error", e);
}
return null;
}
@Scheduled(fixedRate = 300)
public void checkWaitTimeout() {
long now = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
NettyMessageCache.NETTY_RESULT_TIMEOUT_MAP.forEach((k, v) -> {
commonThreadPoolExecutor.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.utc.hisense.netty.codec;
import cn.hutool.core.util.HexUtil;
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 {
byte[] bytes = new byte[in.readableBytes()];
in.readBytes(bytes);
out.add(HexUtil.encodeHexStr(bytes));
}
}
package net.wanji.utc.hisense.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.utc.hisense.netty.commandsign;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.wanji.utc.hisense.pojo.convert.RunningLightsStatusPojo;
/**
* @author duanruiming
* @date 2023/05/08 10:14
*/
public class CommandResultSign {
public static Object getHexSign(String data) {
ObjectMapper mapper = new ObjectMapper();
return mapper.convertValue(data, RunningLightsStatusPojo.class);
}
}
package net.wanji.utc.hisense.netty.handler;
import cn.hutool.core.util.HexUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.DatagramPacket;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.spring.ServiceBeanContext;
import net.wanji.databus.po.CrossInfoPO;
import net.wanji.utc.hisense.cache.CrossInfoCache;
import net.wanji.utc.hisense.cache.netty.NettyMessageCache;
import net.wanji.utc.hisense.common.enums.CommandResultSignEnum;
import net.wanji.utc.hisense.netty.commandsign.CommandResultSign;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import net.wanji.utc.hisense.pojo.netty.MessageResultPojo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.net.InetSocketAddress;
import java.util.Objects;
@Slf4j
@Component
public class NettyServerHandler extends SimpleChannelInboundHandler<DatagramPacket> {
@Resource
private CrossInfoCache crossInfoCache;
/**
* 读取消息
*
* @param ctx
* @param packet
* @throws Exception
*/
@Override
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket packet) throws Exception {
ByteBuf content = packet.content();
InetSocketAddress remote = packet.sender();
int i = content.readableBytes();
byte[] b = new byte[i];
content.readBytes(b);
String data = HexUtil.encodeHexStr(b);
Object resultPojo = CommandResultSign.getHexSign(data);
String className = CommandResultSignEnum.getResultPojo(resultPojo);
CommandResponseFactory commandResponseFactory = (CommandResponseFactory) ServiceBeanContext.getBean(className);
String key = StringUtils.join("/", remote.getHostString(), ":", remote.getPort(), "/", resultPojo.getClass().getSimpleName());
CommandPojo commandPojo = getCommandPojo(key, resultPojo);
Object hexResult = commandResponseFactory.getCommandResponse(commandPojo);
if (Objects.nonNull(hexResult)) {
setResultData(key, hexResult);
}
}
private void setResultData(String key, Object hexResult) {
MessageResultPojo resultPojo = NettyMessageCache.NETTY_RESULT_TIMEOUT_MAP.get(key);
if (resultPojo != null) {
resultPojo.setHexMessageResult(hexResult);
resultPojo.getCountDownLatch().countDown();
}
}
private CommandPojo getCommandPojo(String key, Object data) {
CrossInfoPO crossInfo = NettyMessageCache.COMMAND_RESULT_SIGN_MAP.get(key);
CommandPojo commandPojo = new CommandPojo();
commandPojo.setCrossId(crossInfo.getId());
commandPojo.setSignalId(crossInfo.getCode());
commandPojo.setSignalIp(crossInfo.getIp());
commandPojo.setPort(crossInfo.getPort());
commandPojo.setResponseMsg(data);
return commandPojo;
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
}
}
package net.wanji.utc.hisense.netty.pojo;
import lombok.Data;
/**
* @author duanruiming
* @date 2023/05/12 13:41
*/
@Data
public class CommandPojo {
private String crossId;
private String signalId;
private String signalIp;
private Integer port;
private Object responseMsg;
}
package net.wanji.utc.hisense.netty.response;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
/**
* @author duanruiming
* @date 2023/05/10 10:07
*/
public interface CommandResponseFactory {
Object getCommandResponse(CommandPojo commandPojo);
}
package net.wanji.utc.hisense.netty.response.impl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.utc.hisense.cache.CrossInfoCache;
import net.wanji.utc.hisense.common.constants.Constants;
import net.wanji.utc.hisense.netty.NettyClient;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import net.wanji.utc.hisense.pojo.netty.MessageResultPojo;
import net.wanji.databus.po.CrossInfoPO;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* @author duanruiming
* @date 2023/05/12 11:00
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class HeartBeatService implements CommandResponseFactory {
private final CrossInfoCache crossInfoCache;
private final ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
@Scheduled(fixedRate = 30 * 1000, initialDelay = 10 * 1000)
public void heartbeat() {
Map<String, CrossInfoPO> crossInfoMap = crossInfoCache.getCrossInfoCache();
for (Map.Entry<String, CrossInfoPO> entry : crossInfoMap.entrySet()) {
CrossInfoPO crossInfoPO = entry.getValue();
String ip = crossInfoPO.getIp();
Integer port = crossInfoPO.getPort();
threadPoolTaskExecutor.execute(() -> {
String heartBeatRequest = Constants.buildMessage(Constants.COMMAND_HEART_BEAT_QUERY);
MessageResultPojo resultPojo = NettyClient.sendMessage(ip, port, heartBeatRequest, Constants.COMMAND_HEART_BEAT_REPLY, 300);
});
}
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:08
*/
@Service
public class GetAlarmInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:05
*/
@Service
public class GetBaseInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:07
*/
@Service
public class GetDailyPlanInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:06
*/
@Service
public class GetDetectorInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:05
* @description 上载设备信息
*/
@Service
public class GetDeviceInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:08
*/
@Service
public class GetFaultInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:06
*/
@Service
public class GetLightsGroupInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/06/16 9:45
*/
@Service
public class GetLightsStatusInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:06
*/
@Service
public class GetPhaseInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:07
*/
@Service
public class GetPhaseSecurityInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.cache.SignalDataCache;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import net.wanji.utc.hisense.pojo.convert.RunningLightsStatusPojo;
import org.springframework.stereotype.Service;
/**
* 海信平台每隔5s推送灯态
*
* @author duanruiming
* @date 2023/05/12 16:07
*/
@Service
public class GetRunningStateInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
SignalDataCache.runningStateInfoCache.put(commandPojo.getCrossId(), (RunningLightsStatusPojo) commandPojo.getResponseMsg());
return commandPojo;
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:07
*/
@Service
public class GetSchedulesInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:07
*/
@Service
public class GetSchemeInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:06
*/
@Service
public class GetStageInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/06/19 14:27
*/
@Service
public class GetStageStatusService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:08
*/
@Service
public class GetTrafficDataInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:13
*/
@Service
public class SetAlarmInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:10
*/
@Service
public class SetBaseInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:13
*/
@Service
public class SetControlInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:11
*/
@Service
public class SetDailyPlanInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:10
*/
@Service
public class SetDetectorInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:09
*/
@Service
public class SetDeviceInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:13
*/
@Service
public class SetFaultInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:10
*/
@Service
public class SetLightsGroupInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:10
*/
@Service
public class SetPhaseInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:11
*/
@Service
public class SetPhaseSecurityInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:11
*/
@Service
public class SetSchedulesInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:11
*/
@Service
public class SetSchemeInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:10
*/
@Service
public class SetStageInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.set;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/12 16:12
*/
@Service
public class SetTrafficDataInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
package net.wanji.utc.hisense.pojo.convert;
import lombok.Data;
import java.util.List;
/**
* @author duanruiming
* @date 2023/06/14 17:31
*/
@Data
public class DailyPlanInfoPojo {
private Integer dailyPlanId;
private Integer controlCrossId;
private List<String> startTimeChain;
private List<Integer> schemeIdChain;
private List<Integer> controlModelChain;
}
package net.wanji.utc.hisense.pojo.convert;
import lombok.Data;
/**
* @author duanruiming
* @date 2023/06/16 8:43
*/
@Data
public class FaultInfoPojo {
}
package net.wanji.utc.hisense.pojo.convert;
import lombok.Data;
/**
* @author duanruiming
* @date 2023/06/14 10:35
*/
@Data
public class LightsInfoPojo {
private Integer lightId;
// 1-机动车 2-非机动车 3-行人 4-车道 5-可变交通标志 6-公交车灯具 7-有轨电车专用灯 8-特殊灯
private Integer type;
public static Integer getLightsDir(Integer lightId) {
// 万集 灯组放行方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北
Integer dir = null;
if (lightId <= 4) {
dir = 1;
} else if (lightId <= 8) {
dir = 3;
} else if (lightId <= 12) {
dir = 5;
} else if (lightId <= 16) {
dir = 7;
}
return dir;
}
// 万集 灯组转向:1左转;2右转;3直行;4左掉头;5直左;6直右;7右掉头;8向左合流;9向右合流;10左转加掉头;11右转加掉头;
// 12直行加左掉头;13直行加右掉头;14左转右转;15左直右;16左转右转加掉头;17左直掉头;18左直右掉头;20行人
public static Integer getTurnDir(Integer lightId, Integer type) {
Integer turnDir = null;
if (type == 3) {
turnDir = 20;
return turnDir;
}
if (lightId % 4 == 1 && type ==1) {
turnDir = 1;
} else {
turnDir = 6;
}
return turnDir;
}
public static void main(String[] args) {
System.err.println(1 % 4 == 1);
}
}
package net.wanji.utc.hisense.pojo.convert;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Objects;
/**
* @author duanruiming
* @date 2023/06/13 14:21
* @description 相位信息转换实体
*/
@Data
@NoArgsConstructor
public class PhaseInfoPojo {
private Integer phaseId;
private Integer lightsId;
private Integer greenTime;
private Integer greenFlashTime;
private Integer yellowTime;
private Integer yellowFlashTime;
private Integer redTime;
private Integer minGreenTime;
private Integer maxGreenTime;
private Integer maxGreenTime2;
private Integer extendGreenTime;
public static PhaseInfoPojo getPhaseInfoPojoByPhaseId(Integer phaseId, List<PhaseInfoPojo> phaseInfoPojos) {
for (PhaseInfoPojo phaseInfoPojo : phaseInfoPojos) {
if (Objects.equals(phaseInfoPojo.getPhaseId(), phaseId)) {
return phaseInfoPojo;
}
}
return null;
}
}
package net.wanji.utc.hisense.pojo.convert;
import lombok.Data;
import java.util.List;
/**
* @author duanruiming
* @date 2023/06/14 11:25
*/
@Data
public class PhaseStageInfoPojo {
private Integer phaseStageId;
private List<Integer> phaseList;
}
package net.wanji.utc.hisense.pojo.convert;
import lombok.Data;
/**
* @author duanruiming
* @date 2023/06/19 14:29
*/
@Data
public class PhaseStageStatusPojo {
private Integer phaseStageId;
// 10 未放行 20 正在放行 30 过渡
private String phaseStageStatus;
private Integer runningTime;
private Integer remainTime;
}
package net.wanji.utc.hisense.pojo.convert;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* 海信运行状态实体
* @author duanruiming
* @date 2023/06/29 9:08
*/
@Data
public class RunningLightsStatusPojo {
// 路口编号
private String CID;
// 周期长
private Integer CC;
// 周期倒计时
private Integer CCCD;
// 当前控制模式
private Integer CCM;
// 当前控制方式
private Integer CCT;
private List<Channel> CHANNEL;
// 当前运行方案号
private Integer PLN;
// 信号机参数版本
private Integer PV;
// 系统时间戳,毫秒级
private Date TS;
private List<Phase> PHASE;
@Data
public static class Phase {
// 相位灯态 1-绿灯 2-红灯 4-黄灯
private Integer LS;
// 相位倒计时
private Integer PCD;
// 相位号
private Integer PHN;
// 相位绿信比
private Integer PS;
}
@Data
public static class Channel {
// 32个通道信息 1-绿灯 2-红灯 4-黄灯
private List<Integer> SCS;
}
}
package net.wanji.utc.hisense.pojo.convert;
import lombok.Data;
/**
* @author duanruiming
* @date 2023/06/16 10:00
*/
@Data
public class RunningStatusPojo {
private Integer controlCrossId;
private String controlMode;
private Integer schemeId;
private Integer phaseStageId;
}
package net.wanji.utc.hisense.pojo.convert;
import lombok.Data;
import java.util.List;
/**
* @author duanruiming
* @date 2023/06/15 15:07
*/
@Data
public class ScheduleInfoPojo {
private Integer scheduleId;
private Integer controlCrossId;
private Integer priority;
private List<Integer> week;
private List<Integer> month;
private List<Integer> day;
private Integer dailyPlanId;
}
package net.wanji.utc.hisense.pojo.convert;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @author duanruiming
* @date 2023/06/14 15:39
*/
@Data
public class SchemeInfoPojo {
private Integer schemeId;
// 所属方案序号 一台信号机控制多路口时使用
private Integer controlCrossId;
// 单位s
private Integer cycle;
// 方案协调序号 需要协调的相位序号
private Integer harmonizeId;
private Integer offset;
private List<Integer> phaseStageChain;
private List<Integer> phaseStageTimeChain;
// 10 固定出现 20 检测器按需出现
private List<Integer> phaseStageTypeChain;
@Data
public static class SchemeStagePojo {
private Integer schemeId;
private Integer phaseStageId;
private Integer phaseStageTime;
private Integer phaseStageType;
}
public static List<SchemeStagePojo> getStageInfoList(SchemeInfoPojo schemeInfoPojo) {
if (Objects.nonNull(schemeInfoPojo)) {
List<SchemeStagePojo> schemeStagePojos = new ArrayList<>();
for (int i = 0; i < schemeInfoPojo.getPhaseStageChain().size(); i++) {
SchemeStagePojo schemeStagePojo = new SchemeStagePojo();
schemeStagePojo.setSchemeId(schemeInfoPojo.getSchemeId());
schemeStagePojo.setPhaseStageId(schemeInfoPojo.getPhaseStageChain().get(i));
schemeStagePojo.setPhaseStageTime(schemeInfoPojo.getPhaseStageTimeChain().get(i));
schemeStagePojo.setPhaseStageType(schemeInfoPojo.getPhaseStageTypeChain().get(i));
schemeStagePojos.add(schemeStagePojo);
}
return schemeStagePojos;
}
return null;
}
}
package net.wanji.utc.hisense.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 Object hexMessageResult;
}
package net.wanji.utc.hisense.service;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.databus.dao.mapper.CrossInfoMapper;
import net.wanji.databus.dao.mapper.ManufacturerInfoMapper;
import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.po.ManufacturerInfoPO;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/08 16:12
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class CommonService {
private final CrossInfoMapper crossInfoMapper;
private final ManufacturerInfoMapper manufacturerInfoMapper;
/**
* 通过路口编号获取厂商编码
*
* @param crossId
* @return
*/
@NonNull
public String getManufacturerCodeByCrossId(String crossId) {
CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(crossId);
Integer manufacturerId = crossInfoPO.getManufacturerId();
ManufacturerInfoPO manufacturerInfoPO = manufacturerInfoMapper.selectById(manufacturerId);
return manufacturerInfoPO.getCode();
}
}
package net.wanji.utc.hisense.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 {
/**
* 方案下发
*/
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 commandVO 信号机编号
* @return
* @throws Exception 异常
*/
JsonViewObject setSignalControl(ControlCommandVO commandVO) 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.utc.hisense.service.controller;
import net.wanji.databus.po.SignalStatusLogPO;
import net.wanji.databus.vo.LightsStatusVO;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/11/21 9:09
*/
public interface SignalStatusService {
/**
* todo 提供给其他平台,需要确认以厂商还是以路口形式推送数据
*
* @param crossId
* @return
*/
List<SignalStatusLogPO> runningStatusAlarm(String crossId);
List<LightsStatusVO> lightStatus(String crossId);
}
package net.wanji.utc.hisense.service.controller;
import net.wanji.databus.dao.entity.CrossSchedulesPO;
import net.wanji.databus.dto.CrossInfoDTO;
import net.wanji.databus.dto.CrossSchedulesDTO;
import net.wanji.databus.dto.PlanSectionDTO;
import net.wanji.databus.dto.SchemePhaseLightsDTO;
import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.vo.PlanSectionVO;
import net.wanji.databus.vo.SchemePhaseLightsVO;
import java.util.List;
public interface StaticInfoService {
List<CrossInfoPO> crossBasicInfo(CrossInfoDTO crossInfoDTO) throws Exception;
SchemePhaseLightsVO schemePhaseLights(SchemePhaseLightsDTO schemePhaseLightsDTO) throws Exception;
List<PlanSectionVO> planSection(PlanSectionDTO planSectionDTO) throws Exception;
List<CrossSchedulesPO> crossSchedules(CrossSchedulesDTO crossSchedulesDTO) throws Exception;
}
package net.wanji.utc.hisense.service.controller.impl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.vo.*;
import net.wanji.utc.hisense.service.controller.ControlCommandService;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/08 10:43
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class ControlCommandServiceImpl implements ControlCommandService {
@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(ControlCommandVO commandVO) 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.utc.hisense.service.controller.impl;
import net.wanji.databus.po.SignalStatusLogPO;
import net.wanji.databus.vo.LightsStatusVO;
import net.wanji.utc.hisense.cache.SignalDataCache;
import net.wanji.utc.hisense.common.enums.ControlModelEnum;
import net.wanji.utc.hisense.common.enums.PhaseLightColorEnum;
import net.wanji.utc.hisense.pojo.convert.RunningLightsStatusPojo;
import net.wanji.utc.hisense.service.controller.SignalStatusService;
import net.wanji.utc.hisense.util.CommonUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
/**
* @author duanruiming
* @date 2023/05/08 17:28
*/
@Service
public class SignalStatusServiceImpl implements SignalStatusService {
@Override
public List<SignalStatusLogPO> runningStatusAlarm(String crossId) {
return null;
}
@Override
public List<LightsStatusVO> lightStatus(String crossId) {
List<LightsStatusVO> lightsStatusVOS = new ArrayList<>();
Map<String, RunningLightsStatusPojo> runningStateInfoCache = SignalDataCache.runningStateInfoCache;
if (!runningStateInfoCache.isEmpty()) {
RunningLightsStatusPojo runningLightsStatusPojo = runningStateInfoCache.get(crossId);
LightsStatusVO lightsStatusVO = new LightsStatusVO();
lightsStatusVO.setCrossId(crossId);
String runMode = String.valueOf(ControlModelEnum.getWjControlMode(runningLightsStatusPojo.getCCT()));
lightsStatusVO.setRunMode(runMode);
lightsStatusVO.setCycleLen(runningLightsStatusPojo.getCC());
// 相位剩余时长
List<RunningLightsStatusPojo.Phase> phaseList = runningLightsStatusPojo.getPHASE();
Integer phaseId = 0;
Integer phaseCountDown = 0;
for (RunningLightsStatusPojo.Phase phase : phaseList) {
Integer ls = phase.getLS();
if (Objects.equals(ls, 1)) { // 当前相位绿灯
phaseId = phase.getPHN();
phaseCountDown = phase.getPCD();
}
}
lightsStatusVO.setCycleCountDown(phaseCountDown);
lightsStatusVO.setPhaseId(String.valueOf(phaseId));
lightsStatusVO.setSchemeId(String.valueOf(runningLightsStatusPojo.getPLN()));
List<RunningLightsStatusPojo.Channel> channelList = runningLightsStatusPojo.getCHANNEL();
Map<String, Object> dirLampGroupMap = new HashMap<>();
if (!CollectionUtils.isEmpty(channelList)) {
for (RunningLightsStatusPojo.Channel channel : channelList) {
List<Integer> scs = channel.getSCS();
if (!CollectionUtils.isEmpty(scs)) {
for (int i = 0; i < scs.size(); i++) {
Map<Integer, String> turnColorMap = new HashMap<>();
String lightsColor = String.valueOf(scs.get(i));
String wjLightColor = PhaseLightColorEnum.getWjLightColor(lightsColor);
Integer turn = CommonUtils.getTurnByLightsId(i);
turnColorMap.put(turn, wjLightColor);
String dir = String.valueOf(CommonUtils.getDirByLightsId(i));
if (dirLampGroupMap.isEmpty() || Objects.isNull(dirLampGroupMap.get(dir))) {
dirLampGroupMap.put(dir, turnColorMap);
} else {
Map<Integer, String> currentTurnColorMap = (Map<Integer, String>) dirLampGroupMap.get(dir);
currentTurnColorMap.put(turn, wjLightColor);
dirLampGroupMap.put(dir, currentTurnColorMap);
}
}
}
}
}
lightsStatusVO.setDirLampGroupMap(dirLampGroupMap);
lightsStatusVOS.add(lightsStatusVO);
}
return lightsStatusVOS;
}
}
package net.wanji.utc.hisense.service.controller.impl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.databus.dao.entity.CrossSchedulesPO;
import net.wanji.databus.dto.CrossInfoDTO;
import net.wanji.databus.dto.CrossSchedulesDTO;
import net.wanji.databus.dto.PlanSectionDTO;
import net.wanji.databus.dto.SchemePhaseLightsDTO;
import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.vo.PlanSectionVO;
import net.wanji.databus.vo.SchemePhaseLightsVO;
import net.wanji.utc.hisense.service.controller.StaticInfoService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author duanruiming
* @date 2023/05/08 17:29
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class StaticInfoServiceImpl implements StaticInfoService {
@Override
public List<CrossInfoPO> crossBasicInfo(CrossInfoDTO crossInfoDTO) throws Exception {
return null;
}
@Override
public SchemePhaseLightsVO schemePhaseLights(SchemePhaseLightsDTO schemePhaseLightsDTO) throws Exception {
return null;
}
@Override
public List<PlanSectionVO> planSection(PlanSectionDTO planSectionDTO) throws Exception {
return null;
}
@Override
public List<CrossSchedulesPO> crossSchedules(CrossSchedulesDTO crossSchedulesDTO) throws Exception {
return null;
}
}
package net.wanji.utc.hisense.service.protocol;
import net.wanji.databus.po.CrossInfoPO;
/**
* @author duanruiming
* @date 2023/05/08 10:25
*/
public interface ProtocolConversion<R, T> {
/**
* 协议解析为实体类
*
* @param crossInfo
* @return
*/
R protocolConvertEntity(CrossInfoPO crossInfo);
String entityConvertProtocol(T t);
}
package net.wanji.utc.hisense.service.protocol.impl.base;
import net.wanji.utc.hisense.service.protocol.ProtocolConversion;
import net.wanji.databus.po.CrossInfoPO;
/**
* @author duanruiming
* @date 2023/05/11 18:29
*/
public class DailyPlanProtocolConversionService implements ProtocolConversion {
@Override
public Object protocolConvertEntity(CrossInfoPO crossInfo) {
return null;
}
@Override
public String entityConvertProtocol(Object o) {
return null;
}
}
package net.wanji.utc.hisense.service.protocol.impl.base;
import net.wanji.utc.hisense.service.protocol.ProtocolConversion;
import net.wanji.databus.po.CrossInfoPO;
/**
* @author duanruiming
* @date 2023/05/11 18:24
*/
public class DetectorProtocolConversionService implements ProtocolConversion {
@Override
public Object protocolConvertEntity(CrossInfoPO crossInfo) {
return null;
}
@Override
public String entityConvertProtocol(Object o) {
return null;
}
}
package net.wanji.utc.hisense.service.protocol.impl.base;
import net.wanji.utc.hisense.service.protocol.ProtocolConversion;
import net.wanji.databus.po.CrossInfoPO;
/**
* @author duanruiming
* @date 2023/05/11 18:20
*/
public class LightsGroupProtocolConvertionService implements ProtocolConversion {
@Override
public Object protocolConvertEntity(CrossInfoPO crossInfo) {
return null;
}
@Override
public String entityConvertProtocol(Object o) {
return null;
}
}
package net.wanji.utc.hisense.service.protocol.impl.base;
import net.wanji.utc.hisense.netty.NettyClient;
import net.wanji.utc.hisense.pojo.netty.MessageResultPojo;
import net.wanji.utc.hisense.service.protocol.ProtocolConversion;
import net.wanji.databus.po.CrossInfoPO;
/**
* @author duanruiming
* @date 2023/05/09 17:35
*/
public class PhaseProtocolConversionService implements ProtocolConversion<Object, Object> {
@Override
public Object protocolConvertEntity(CrossInfoPO crossInfo) {
MessageResultPojo resultPojo = NettyClient.sendMessage("ip", 80, "aadd", "1122", 300);
return null;
}
@Override
public String entityConvertProtocol(Object o) {
return null;
}
}
package net.wanji.utc.hisense.service.protocol.impl.base;
import net.wanji.utc.hisense.service.protocol.ProtocolConversion;
import net.wanji.databus.po.CrossInfoPO;
/**
* @author duanruiming
* @date 2023/05/11 18:27
*/
public class PhaseSecurityProtocolConversionService implements ProtocolConversion {
@Override
public Object protocolConvertEntity(CrossInfoPO crossInfo) {
return null;
}
@Override
public String entityConvertProtocol(Object o) {
return null;
}
}
package net.wanji.utc.hisense.service.protocol.impl.base;
import net.wanji.utc.hisense.service.protocol.ProtocolConversion;
import net.wanji.databus.po.CrossInfoPO;
/**
* @author duanruiming
* @date 2023/05/11 18:30
*/
public class ScheduleProtocolConversionService implements ProtocolConversion {
@Override
public Object protocolConvertEntity(CrossInfoPO crossInfo) {
return null;
}
@Override
public String entityConvertProtocol(Object o) {
return null;
}
}
package net.wanji.utc.hisense.service.protocol.impl.base;
import net.wanji.utc.hisense.service.protocol.ProtocolConversion;
import net.wanji.databus.po.CrossInfoPO;
/**
* @author duanruiming
* @date 2023/05/11 18:29
*/
public class SchemeProtocolConversionService implements ProtocolConversion {
@Override
public Object protocolConvertEntity(CrossInfoPO crossInfo) {
return null;
}
@Override
public String entityConvertProtocol(Object o) {
return null;
}
}
package net.wanji.utc.hisense.service.protocol.impl.base;
import lombok.extern.slf4j.Slf4j;
import net.wanji.utc.hisense.netty.NettyClient;
import net.wanji.utc.hisense.pojo.netty.MessageResultPojo;
import net.wanji.utc.hisense.service.protocol.ProtocolConversion;
import net.wanji.databus.po.CrossInfoPO;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/16 17:16
*/
@Service
@Slf4j
public class SignalDeviceProtocolConversionService implements ProtocolConversion {
@Override
public Object protocolConvertEntity(CrossInfoPO crossInfo) {
MessageResultPojo resultPojo = NettyClient.sendMessage("10.102.1.204", 5050, "0x7e00120001010000000101011001000501030000005CB40x7d", "20", 300);
log.info("设备基本信息: {}", resultPojo);
return null;
}
@Override
public String entityConvertProtocol(Object o) {
return null;
}
}
package net.wanji.utc.hisense.service.protocol.impl.base;
import net.wanji.utc.hisense.service.protocol.ProtocolConversion;
import net.wanji.databus.po.CrossInfoPO;
/**
* @author duanruiming
* @date 2023/05/11 18:25
*/
public class StageProtocolConversionService implements ProtocolConversion {
@Override
public Object protocolConvertEntity(CrossInfoPO crossInfo) {
return null;
}
@Override
public String entityConvertProtocol(Object o) {
return null;
}
}
package net.wanji.utc.hisense.service.protocol.impl.control;
import net.wanji.utc.hisense.service.protocol.ProtocolConversion;
import net.wanji.databus.po.CrossInfoPO;
/**
* @author duanruiming
* @date 2023/05/12 10:14
*/
public class ControlProtocolConversionService implements ProtocolConversion {
@Override
public Object protocolConvertEntity(CrossInfoPO crossInfo) {
return null;
}
@Override
public String entityConvertProtocol(Object o) {
return null;
}
}
package net.wanji.utc.hisense.service.protocol.impl.status;
import net.wanji.utc.hisense.service.protocol.ProtocolConversion;
import net.wanji.databus.po.CrossInfoPO;
/**
* @author duanruiming
* @date 2023/05/12 10:16
*/
public class RunningStateProtocolConversionService implements ProtocolConversion {
@Override
public Object protocolConvertEntity(CrossInfoPO crossInfo) {
return null;
}
@Override
public String entityConvertProtocol(Object o) {
return null;
}
}
package net.wanji.utc.hisense.util;
import cn.hutool.core.util.HexUtil;
/**
* @author duanruiming
* @date 2023/05/12 15:26
*/
public class CRC16Utils {
/**
* 获取CRC16校验结果 【报文长度+报文体】
*
* @param body
* @return
*/
public static String getCRC16HexStr(String body) {
byte[] bytes = HexUtil.decodeHex(body);
int result = crc16(bytes);
return HexUtil.toHex(result);
}
/**
* 多项式1005 初始值0000 异或值0000 不反转
*
* @param bytes
* @return
*/
public static int crc16(byte[] bytes) {
int crc = 0x0000;
for (byte b : bytes) {
crc ^= (b << 8);
for (int i = 0; i < 8; i++) {
if ((crc & 0x8000) != 0) {
crc = (crc << 1) ^ 0x1005;
} else {
crc = (crc << 1);
}
}
}
return crc & 0xFFFF;
}
}
package net.wanji.utc.hisense.util;
import cn.hutool.core.util.HexUtil;
import freemarker.template.utility.StringUtil;
/**
* @author duanruiming
* @date 2023/06/20 15:07
*/
public class CommonUtils {
/**
* 将数组转化为16进制字符串
*
* @param array
* @return
*/
public static String getHex4Array(int[] array) {
StringBuilder sb = new StringBuilder();
for (int i : array) {
sb.append(i);
}
Integer binary = Integer.valueOf(sb.reverse().toString(), 2);
return HexUtil.toHex(binary);
}
/**
* 将时间转化为16进制 00:00 --> 061E0
*
* @param time
* @return
*/
public static String getHourMinuteHex(String time) {
StringBuffer sb = new StringBuffer();
String[] split = time.split(":");
String hour = String.format("%02x", Integer.valueOf(split[0]));
String minute = String.format("%02x", Integer.valueOf(split[1]));
return sb.append(hour).append(minute).toString();
}
/**
* 将相位转化为64位数组,在转化为16位的16进制
*
* @param param
* @return
*/
public static String getBinary(Integer param) {
int[] array = new int[64];
array[param - 1] = 1;
StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < array.length / 8; i++) {
StringBuffer sb = new StringBuffer();
for (int j = 0; j < 8; j++) {
sb.append(array[i * 8 + j]);
}
String hex = String.format("%02x", Integer.parseInt(sb.reverse().toString(), 2));
resultSb.insert(0, hex);
}
return StringUtil.leftPad(resultSb.toString(), 16, "0");
}
/**
* 将单个参数转化为4位二进制
*
* @param param
* @return
*/
public static Integer get4BinaryInteger(Integer param) {
int[] array = new int[4];
int index = param % 4;
if (param % 4 != 0) {
array[4 - index] = 1;
} else {
array[0] = 1;
}
StringBuffer sb = new StringBuffer();
for (int j = 0; j < 4; j++) {
sb.append(array[j]);
}
return Integer.parseInt(sb.toString(), 2);
}
/**
* 通过灯组编号获取灯组转向, 1 左转 2 直右 3 右 4 行人
*
* @param lightId
* @return
*/
public static Integer getTurnByLightsId(Integer lightId) {
Integer turn = null;
if (lightId % 4 == 0) {
turn = 1;
}
if (lightId % 4 == 1) {
turn = 2;
}
if (lightId % 4 == 2) {
turn = 3;
}
if (lightId % 4 == 3) {
turn = 20;
}
return turn;
}
public static Integer getDirByLightsId(Integer lightsId) {
Integer dir = null;
if (lightsId < 4) {
dir = 1;
}
if (lightsId >= 4 && lightsId < 8) {
dir = 3;
}
if (lightsId >= 8 && lightsId < 12) {
dir = 5;
}
if (lightsId >= 12 && lightsId < 16) {
dir = 7;
}
return dir;
}
public static void main(String[] args) {
System.err.println(get4BinaryInteger(4));
}
}
spring:
cloud:
nacos:
config:
server-addr: 10.102.1.182:8848
file-extension: yaml
group: signal
namespace: signal
username: nacos
password: nacos
application:
# dubbo启动需要程序名称
name: utc-dt
main:
allow-circular-references: true
spring:
profiles:
active: dev
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<property name="encoding" value="UTF-8"/>
<property name="normal-pattern"
value="%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level[%thread]%logger{56}.%method:%L -%msg%n"/>
<property name="LOG_PATH" value="./logs"/>
<!-- 配置打印DEBUG级别日志的环境. 多个使用逗号隔开. -->
<springProfile name="dev,test">
<!-- 如果需要,请自行开启spring或其他组件的debug级别 -->
<logger name="net.wanji.com" level="info"/>
</springProfile>
<!-- 配置打印INFO级别日志的环境 -->
<springProfile name="prod">
<logger name="net.wanji.utc.hisense" level="info" />
</springProfile>
<appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>
${normal-pattern}
</pattern>
</layout>
</appender>
<appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/dt/info.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>DENY</onMatch>
<onMismatch>ACCEPT</onMismatch>
</filter>
<encoder>
<pattern>${normal-pattern}</pattern>
<charset>${encoding}</charset>
</encoder>
<!--滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--路径-->
<fileNamePattern>${LOG_PATH}/dt/%d{yyyy-MM-dd}/info.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<MaxHistory>30</MaxHistory>
<totalSizeCap >10GB</totalSizeCap >
<maxFileSize>200MB</maxFileSize>
</rollingPolicy>
</appender>
<appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/dt/error.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>>
<encoder>
<pattern>${normal-pattern}</pattern>
<charset>${encoding}</charset>
</encoder>
<!--滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--路径-->
<fileNamePattern>${LOG_PATH}/dt/%d{yyyy-MM-dd}/error.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<MaxHistory>30</MaxHistory>
<totalSizeCap >10GB</totalSizeCap >
<maxFileSize>200MB</maxFileSize>
</rollingPolicy>
</appender>
<root level="INFO">
<appender-ref ref="consoleLog"/>
<appender-ref ref="fileInfoLog"/>
<appender-ref ref="fileErrorLog"/>
</root>
</configuration>
\ No newline at end of file
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