Explorar o código

项目初始化

unknown %!s(int64=3) %!d(string=hai) anos
achega
19c0c21791

+ 355 - 0
pom.xml

@@ -0,0 +1,355 @@
+<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>com.persagy</groupId>
+	<artifactId>ibms-switch</artifactId>
+	<version>1.0.0</version>
+
+	<properties>
+		<!-- java版本 -->
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<java.encoding>UTF-8</java.encoding>
+		<java.version>8</java.version>
+		<java.source.version>1.8</java.source.version>
+		<java.target.version>1.8</java.target.version>
+
+		<!-- spring版本依赖 -->
+		<integrated-platform.version>2.0.0</integrated-platform.version>
+		<spring-boot-dependencies.version>2.1.14.RELEASE</spring-boot-dependencies.version>
+		<spring-cloud-dependencies.version>Greenwich.SR6</spring-cloud-dependencies.version>
+		<mybatis-spring-boot-starter.version>1.3.2</mybatis-spring-boot-starter.version>
+		<dynamic-datasource-spring-boot-starter.version>3.4.1</dynamic-datasource-spring-boot-starter.version>
+		
+		<!-- 三方jar依赖 -->
+		<dmp-mybatis.version>1.0.0</dmp-mybatis.version>
+		<mybatis-plus.version>3.3.1</mybatis-plus.version>
+		<guava.version>20.0</guava.version>
+
+		<!-- maven依赖 -->
+		<maven.compiler.version>3.8.0</maven.compiler.version>
+		<maven.surefire.version>2.22.1</maven.surefire.version>
+		<maven.source.version>3.0.1</maven.source.version>
+		<maven.javadoc.version>3.0.1</maven.javadoc.version>
+		<maven.gpg.version>1.6</maven.gpg.version>
+		<maven.jacoco.version>0.8.3</maven.jacoco.version>
+		<maven.jar.version>3.1.0</maven.jar.version>
+		<maven.pmd.version>3.8</maven.pmd.version>
+	</properties>
+
+	<dependencyManagement>
+		<dependencies>
+			<dependency>
+				<groupId>com.persagy</groupId>
+				<artifactId>integrated-platform</artifactId>
+				<version>${integrated-platform.version}</version>
+				<type>pom</type>
+				<scope>import</scope>
+			</dependency>
+		</dependencies>
+	</dependencyManagement>
+
+	<!-- 服务依赖 -->
+	<dependencies>
+		<!-- 依赖集成自定义jar -->
+		<dependency>
+			<groupId>com.persagy</groupId>
+			<artifactId>integrated-config-client</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.persagy</groupId>
+			<artifactId>integrated-db-spring-boot-starter</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.persagy</groupId>
+			<artifactId>integrated-ribbon-spring-boot-starter</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.persagy</groupId>
+			<artifactId>integrated-swagger-spring-boot-starter</artifactId>
+		</dependency>
+
+		
+		<!-- 多数据源 -->
+		<dependency>
+			<groupId>com.baomidou</groupId>
+			<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
+			<version>${dynamic-datasource-spring-boot-starter.version}</version>
+		</dependency>
+		<!-- <dependency>
+            <groupId>com.persagy</groupId>
+            <artifactId>dmp-mybatis</artifactId>
+            <version>${dmp-mybatis.version}</version>
+        </dependency> -->
+
+		<!-- web -->
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+
+		<!-- 服务注册 -->
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+		</dependency>
+
+		<!-- mysql -->
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-context-support</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-actuator</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.social</groupId>
+			<artifactId>spring-social-security</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-context</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>cn.hutool</groupId>
+			<artifactId>hutool-all</artifactId>
+		</dependency>
+
+		<!-- fastjson -->
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>fastjson</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.projectlombok</groupId>
+			<artifactId>lombok</artifactId>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<finalName>${project.artifactId}</finalName>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+				<executions>
+					<execution>
+						<goals>
+							<goal>repackage</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-pmd-plugin</artifactId>
+				<version>${maven.pmd.version}</version>
+				<configuration>
+					<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
+					<minimumPriority>1</minimumPriority>
+					<excludeRoots>
+						<excludeRoot>com/alibaba/csp/sentinel/benchmark</excludeRoot>
+					</excludeRoots>
+					<excludes>
+						<exclude>**/*_jmhTest.java</exclude>
+					</excludes>
+					<printFailingErrors>true</printFailingErrors>
+					<rulesets>
+						<ruleset>rulesets/java/ali-comment.xml</ruleset>
+						<ruleset>rulesets/java/ali-concurrent.xml</ruleset>
+						<ruleset>rulesets/java/ali-constant.xml</ruleset>
+						<ruleset>rulesets/java/ali-exception.xml</ruleset>
+						<ruleset>rulesets/java/ali-flowcontrol.xml</ruleset>
+						<ruleset>rulesets/java/ali-naming.xml</ruleset>
+						<ruleset>rulesets/java/ali-oop.xml</ruleset>
+						<ruleset>rulesets/java/ali-orm.xml</ruleset>
+						<ruleset>rulesets/java/ali-other.xml</ruleset>
+						<ruleset>rulesets/java/ali-set.xml</ruleset>
+					</rulesets>
+				</configuration>
+				<executions>
+					<execution>
+						<phase>verify</phase>
+						<goals>
+							<goal>check</goal>
+						</goals>
+					</execution>
+				</executions>
+				<dependencies>
+					<dependency>
+						<groupId>com.alibaba.p3c</groupId>
+						<artifactId>p3c-pmd</artifactId>
+						<version>1.3.6</version>
+					</dependency>
+				</dependencies>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>${maven.compiler.version}</version>
+				<configuration>
+					<source>${java.source.version}</source>
+					<target>${java.target.version}</target>
+					<encoding>${java.encoding}</encoding>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<configuration>
+					<!-- CircleCI build workaround -->
+					<argLine>@{argLine} -Xms1024m -Xmx2048m</argLine>
+					<argLine>-Dfile.encoding=UTF-8</argLine>
+					<useSystemClassLoader>false</useSystemClassLoader>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.jacoco</groupId>
+				<artifactId>jacoco-maven-plugin</artifactId>
+				<version>${maven.jacoco.version}</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>prepare-agent</goal>
+						</goals>
+					</execution>
+					<execution>
+						<id>report</id>
+						<phase>test</phase>
+						<goals>
+							<goal>report</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<plugin>
+					<groupId>org.apache.maven.plugins</groupId>
+					<artifactId>maven-surefire-plugin</artifactId>
+					<version>${maven.surefire.version}</version>
+				</plugin>
+				<plugin>
+					<groupId>org.apache.maven.plugins</groupId>
+					<artifactId>maven-jar-plugin</artifactId>
+					<version>${maven.jar.version}</version>
+				</plugin>
+				<plugin>
+					<groupId>org.apache.maven.plugins</groupId>
+					<artifactId>maven-gpg-plugin</artifactId>
+					<version>${maven.gpg.version}</version>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+
+	<profiles>
+		<profile>
+			<build>
+				<plugins>
+					<!-- Source -->
+					<plugin>
+						<groupId>org.apache.maven.plugins</groupId>
+						<artifactId>maven-source-plugin</artifactId>
+						<version>${maven.source.version}</version>
+						<executions>
+							<execution>
+								<phase>package</phase>
+								<goals>
+									<goal>jar-no-fork</goal>
+								</goals>
+							</execution>
+						</executions>
+					</plugin>
+					<!-- Javadoc -->
+					<plugin>
+						<groupId>org.apache.maven.plugins</groupId>
+						<artifactId>maven-javadoc-plugin</artifactId>
+						<version>${maven.javadoc.version}</version>
+						<executions>
+							<execution>
+								<phase>package</phase>
+								<goals>
+									<goal>jar</goal>
+								</goals>
+								<configuration>
+									<locale>en_US</locale>
+									<encoding>UTF-8</encoding>
+									<charset>UTF-8</charset>
+									<doclint>none</doclint>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+					<!-- GPG -->
+					<plugin>
+						<groupId>org.apache.maven.plugins</groupId>
+						<artifactId>maven-gpg-plugin</artifactId>
+						<version>${maven.gpg.version}</version>
+						<executions>
+							<execution>
+								<phase>verify</phase>
+								<goals>
+									<goal>sign</goal>
+								</goals>
+							</execution>
+						</executions>
+					</plugin>
+				</plugins>
+			</build>
+
+		</profile>
+	</profiles>
+
+	<repositories>
+		<repository>
+			<id>persagy</id>
+			<name>releases Repository</name>
+			<url>http://47.93.132.139:8081/nexus/content/repositories/persagy/</url>
+		</repository>
+
+		<repository>
+			<id>integrated</id>
+			<name>releases Repository</name>
+			<url>http://47.93.132.139:8081/nexus/content/repositories/integrated/</url>
+			<snapshots>
+				<enabled>false</enabled>
+			</snapshots>
+		</repository>
+		<repository>
+			<id>aliyun</id>
+			<name>releases Repository</name>
+			<url>http://maven.aliyun.com/nexus/content/groups/public</url>
+		</repository>
+	</repositories>
+
+	<pluginRepositories>
+		<pluginRepository>
+			<id>central</id>
+			<url>http://maven.aliyun.com/nexus/content/groups/public</url>
+		</pluginRepository>
+	</pluginRepositories>
+
+</project>

+ 29 - 0
src/main/java/com/persagy/IbmsSwitchApplication.java

@@ -0,0 +1,29 @@
+package com.persagy;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
+import com.persagy.common.annotation.EnableControllerLog;
+import com.persagy.common.annotation.EnableIdGenerator;
+
+/**
+ * 启动类
+ * 
+ * @version 1.0.0
+ * @company persagy
+ * @author zhangqiankun
+ * @date 2021年9月15日 下午2:30:39
+ */
+@EnableIdGenerator
+@EnableControllerLog
+@EnableTransactionManagement
+@SpringBootApplication(exclude = {DruidDataSourceAutoConfigure.class})
+public class IbmsSwitchApplication {
+	
+	public static void main(String[] args) {
+		SpringApplication.run(IbmsSwitchApplication.class, args);
+	}
+	
+}

+ 32 - 0
src/main/java/com/persagy/transfer/aop/GlobalExceptionHandler.java

@@ -0,0 +1,32 @@
+package com.persagy.transfer.aop;
+
+import org.springframework.dao.DuplicateKeyException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+import com.persagy.common.aop.CommonExceptionHandler;
+import com.persagy.common.enums.ResponseCode;
+import com.persagy.common.utils.ResponseResult;
+import com.persagy.common.utils.ResponseUtil;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 异常全局处理类
+ * 
+ * @version 1.0.0
+ * @company persagy 
+ * @author zhangqiankun
+ * @date 2021年9月15日 下午2:32:28
+ */
+@Slf4j
+@RestControllerAdvice
+public class GlobalExceptionHandler extends CommonExceptionHandler {
+
+	@ExceptionHandler(DuplicateKeyException.class)
+	public ResponseResult handleDuplicateKeyException(Exception e) {
+		log.error(e.getMessage(), e);
+		return ResponseUtil.errorResult(ResponseCode.C0341.getCode(), ResponseCode.C0341.getDesc());
+	}
+	
+}

+ 22 - 0
src/main/java/com/persagy/transfer/config/ApplicationProperties.java

@@ -0,0 +1,22 @@
+package com.persagy.transfer.config;
+
+import org.springframework.stereotype.Component;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 获取配置中心的属性
+ * 
+ * @version 
+ * @description
+ * @company persagy
+ * @author zhangqiankun
+ * @since 2020年11月25日:	下午4:17:36
+ */
+@Getter
+@Setter
+@Component
+public class ApplicationProperties {
+
+}

+ 83 - 0
src/main/java/com/persagy/transfer/config/SpringMVCConfig.java

@@ -0,0 +1,83 @@
+package com.persagy.transfer.config;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpOutputMessage;
+import org.springframework.http.MediaType;
+import org.springframework.http.converter.HttpMessageNotWritableException;
+import org.springframework.util.StreamUtils;
+
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.alibaba.fastjson.support.config.FastJsonConfig;
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
+
+/**
+ * @description 
+ * @author zhangqiankun
+ * @since 2020年8月26日:	下午5:17:08
+ */
+@Configuration
+public class SpringMVCConfig {
+	private static final String ENCODE_UTF_8 = "UTF-8";
+	
+	/**
+	 * HttpMessageConverters - FastJson
+	 * 首字母会改为小写,如有必要,手动在实体类上加上@JSONField 注解
+	 */
+	@Bean
+	public HttpMessageConverters fastJsonHttpMessageConverters() {
+		// 1、定义一个convert转换消息的对象
+		FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverterConfig();
+
+		// 2、添加fastjson的配置信息
+		FastJsonConfig fastJsonConfig = new FastJsonConfig();
+
+		SerializerFeature[] serializerFeatures = new SerializerFeature[] {
+				// 循环引用
+				SerializerFeature.DisableCircularReferenceDetect
+			};
+
+		fastJsonConfig.setSerializerFeatures(serializerFeatures);
+		fastJsonConfig.setCharset(Charset.forName(ENCODE_UTF_8));
+		
+		//3、设置类型
+		List<MediaType> mediaTypes = new ArrayList<MediaType>();
+		mediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
+		mediaTypes.add(MediaType.TEXT_PLAIN);
+		mediaTypes.add(MediaType.ALL);
+		fastConverter.setSupportedMediaTypes(mediaTypes);
+        
+        //4、将转换规则应用于转换对象 
+        fastConverter.setFastJsonConfig(fastJsonConfig);
+        fastConverter.setDefaultCharset(Charset.forName(ENCODE_UTF_8));
+        
+        return new HttpMessageConverters(fastConverter);
+	}
+
+}
+
+class FastJsonHttpMessageConverterConfig extends FastJsonHttpMessageConverter{
+	
+	@Override
+	protected void writeInternal(Object obj, HttpOutputMessage outputMessage)
+			throws IOException, HttpMessageNotWritableException {
+		if (obj instanceof String) {
+			//设置 字符串返回的 ContentType 类型
+			HttpHeaders headers = outputMessage.getHeaders();
+			//headers.setContentType(MediaType.TEXT_PLAIN);
+			headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
+			Charset charset = this.getDefaultCharset();
+	        StreamUtils.copy((String) obj, charset, outputMessage.getBody());
+		} else {
+			super.writeInternal(obj, outputMessage);
+		}
+	}
+
+}

+ 22 - 0
src/main/java/com/persagy/transfer/constant/GraphCodeEnum.java

@@ -0,0 +1,22 @@
+package com.persagy.transfer.constant;
+
+/**
+ * 图类型编码
+ * 
+ * @version 1.0.0
+ * @company persagy
+ * @author zhangqiankun
+ * @date 2021年9月2日 下午4:31:27
+ */
+
+public enum GraphCodeEnum {
+
+	ArchSubset, SpaceNeighborhood, ThroughRelationship, TrafficNetwork, ConvectionNetwork, RadiationNetwork,
+	SpaceCorrespond, ArchForArch, MechInArch, MechForArch, MechSubset, LUDistribution, HUDistribution, ChillWaterLoop,
+	CoolingWaterLoop, HeatWaterLoop, CondWaterNetwork, ACAirNetwork, FreshAirNetwork, VentNetwork, VRFNetwork,
+	DomesticWaterNetwork, DrainingWaterNetwork, RecycleWaterNetwork, DrinkingWaterNetwork, DHWNetwork, GasNetwork,
+	FireWaterNetwork, FireVentNetwork, WENetwork, MechCtrl, MechPower, SensorRelationship, ValveRelationship,
+	EnergySubMeter, ScheduleRelationship, MeteorologyRelationship, TenentInArch, BlocRelationship, Property2Mech,
+	PropertyInArch,
+
+}

+ 113 - 0
src/main/java/com/persagy/transfer/constant/ObjectTypeMapping.java

@@ -0,0 +1,113 @@
+package com.persagy.transfer.constant;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import cn.hutool.core.util.StrUtil;
+
+/**
+ * 对象类型的前缀与全名的来回映射,以及根据边类型获取对应的对象类型前缀
+ * 
+ * @version 1.0.0
+ * @company persagy 
+ * @author zhangqiankun
+ * @date 2021年9月3日 下午9:16:10
+ */
+public class ObjectTypeMapping {
+	
+	/** 对象类型 项目 */
+	public static final String PROJECT = "project";
+	/** 对象类型 建筑 */
+	public static final String BUILDING = "building";
+	/** 对象类型 楼层 */
+	public static final String FLOOR = "floor";
+	/** 对象类型 空间 */
+	public static final String SPACE = "space";
+	/** 对象类型 系统 */
+	public static final String SYSTEM = "system";
+	/** 对象类型 设备 */
+	public static final String EQUIPMENT = "equipment";
+	/** 对象类型 竖井 */
+	public static final String SHAFT = "shaft";
+	/** 对象类型 部件 */
+	public static final String COMPONENT = "component";
+	/** 对象类型 资产 */
+	public static final String PROPERTY = "property";
+	
+	/** example: Sp -> space */
+	public static final Map<String, String> PREFIX_FULLNAME = new HashMap<String, String>();
+	
+	/** example: space -> Sp */
+	public static final Map<String, String> FULLNAME_PREFIX = new HashMap<String, String>();
+	
+	/** example: space -> 空间 */
+	public static final Map<String, String> FULLNAME_NAME = new HashMap<String, String>();
+	
+	/** example: Sp -> 空间 */
+	public static final Map<String, String> PREFIX_NAME = new HashMap<String, String>();
+	
+	static {
+	    
+		PREFIX_FULLNAME.put("Pj", "project");
+		PREFIX_FULLNAME.put("Bd", "building");
+		PREFIX_FULLNAME.put("Fl", "floor");
+		PREFIX_FULLNAME.put("Sp", "space");
+		PREFIX_FULLNAME.put("Sy", "system");
+		PREFIX_FULLNAME.put("Eq", "equipment");
+		PREFIX_FULLNAME.put("Sh", "shaft");
+		PREFIX_FULLNAME.put("Ec", "component");
+		PREFIX_FULLNAME.put("Pe", "property");
+		
+		FULLNAME_PREFIX.put("project", "Pj");
+		FULLNAME_PREFIX.put("building", "Bd");
+		FULLNAME_PREFIX.put("floor", "Fl");
+		FULLNAME_PREFIX.put("space", "Sp");
+		FULLNAME_PREFIX.put("system", "Sy");
+		FULLNAME_PREFIX.put("equipment", "Eq");
+		FULLNAME_PREFIX.put("shaft", "Sh");
+		FULLNAME_PREFIX.put("component", "Ec");
+		FULLNAME_PREFIX.put("property", "Pe");
+		
+		PREFIX_NAME.put("Pj", "项目");
+		PREFIX_NAME.put("Bd", "建筑");
+		PREFIX_NAME.put("Fl", "楼层");
+		PREFIX_NAME.put("Sp", "空间");
+		PREFIX_NAME.put("Sy", "系统");
+		PREFIX_NAME.put("Eq", "设备");
+		PREFIX_NAME.put("Sh", "竖井");
+		PREFIX_NAME.put("Ec", "部件");
+		PREFIX_NAME.put("Pe", "资产");
+		
+		FULLNAME_NAME.put("project", "项目");
+		FULLNAME_NAME.put("building", "建筑");
+		FULLNAME_NAME.put("floor", "楼层");
+		FULLNAME_NAME.put("space", "空间");
+		FULLNAME_NAME.put("system", "系统");
+		FULLNAME_NAME.put("equipment", "设备");
+		FULLNAME_NAME.put("shaft", "竖井");
+		FULLNAME_NAME.put("component", "部件");
+		FULLNAME_NAME.put("property", "资产");
+		
+	}
+	
+	/**
+	 * 获取中台中边类型编码的前两位
+	 * 
+	 * @param relCode 最低2位,不然抛异常
+	 * @return 空字符串或者对应前缀
+	 */
+	public static String getRelCodePrefix(String relCode) {
+		return StrUtil.isBlank(relCode) ? SwitchConstant.EMPTY : relCode.substring(0, 2);
+	}
+	
+	/**
+	 * 获取中台中边类型编码的最后两位
+	 * 
+	 * @param objType 最低5位,不然抛异常
+	 * @return 空字符串或者对应后缀
+	 */
+	public static String getRelCodeSuffix(String relCode) {
+		return StrUtil.isBlank(relCode) ? SwitchConstant.EMPTY : relCode.substring(3, 5);
+	}
+	
+}

+ 18 - 0
src/main/java/com/persagy/transfer/constant/RelCodeEnum.java

@@ -0,0 +1,18 @@
+package com.persagy.transfer.constant;
+
+/**
+ * 边类型编码
+ * 
+ * @version 1.0.0
+ * @company persagy
+ * @author zhangqiankun
+ * @date 2021年9月2日 下午4:32:28
+ */
+public enum RelCodeEnum {
+	Pj2Bd, Bd2Fl, None, Door, Window, DoorWindow, FFOpen, FFClose, Natural, OnewayMech, MixMech, Connect, Transparent,
+	Fl2Bd, Fl2Fl, Fl2Sh, Fl2Sp, Sh2Bd, Sh2Fl, Sh2Sh, Sh2Sp, Sp2Bd, ExactCorrespond, InexactCorrespond, Bd2Bd, Bd2Sh,
+	Bd2Sp, Sp2Fl, Sp2Sh, Sp2Sp, Sy2Bd, Sy2Fl, Sy2Sh, Sy2Sp, Eq2Bd, Eq2Fl, Eq2Sh, Eq2Sp, Pj2Sy, Pj2Eq, Sy2Eq, Eq2Ec,
+	Backup, Fill, Return, Fresh, Uncertain, SupplyReturn, Supply, Bypass, Discharge, Normal, SyCtrl, EqCtrl, SyNormal,
+	SyBackup, EqNormal, EqBackup, Ss2Eq, Ss2Sy, Ss2Sp, Vv2Eq, Vv2Sy, Vv2Vv, Em2Bd, Sub2Em, SubTree, Br2Sub, Br2Eq,
+	Sch2Pj, Sch2Bd, Sch2Fl, Sch2Sp, Sch2Tn, Ms2Pj, Tn2Sp, Bl2Pj, Pe2Eq, Pe2Ec, Pe2Pj, Pe2Bd, Pe2Fl, Pe2Sh, Pe2Sp;
+}

+ 41 - 0
src/main/java/com/persagy/transfer/constant/SpaceTypeEnum.java

@@ -0,0 +1,41 @@
+package com.persagy.transfer.constant;
+
+import lombok.Getter;
+
+/**
+ * 业务空间类型
+ * 
+ * @version 1.0.0
+ * @company persagy 
+ * @author zhangqiankun
+ * @date 2021年9月6日 下午3:43:35
+ */
+@Getter
+public enum SpaceTypeEnum {
+
+	GeneralZone("GeneralZone", "物业分区"),
+	PowerSupplyZone("PowerSupplyZone", "供电分区"),
+	LightingZone("LightingZone", "照明分区"),
+	NetworkZone("NetworkZone", "网络分区"),
+	AirConditioningZone("AirConditioningZone", "空调分区"),
+	HeatingZone("HeatingZone", "采暖分区"),
+	CleanZone("CleanZone", "洁净分区"),
+	DomesticWaterSupplyZone("DomesticWaterSupplyZone", "生活给水分区"),
+	FireZone("FireZone", "防火分区"),
+	SecurityZone("SecurityZone", "安防分区"),
+	TenantZone("TenantZone", "租户分区"),
+	FunctionZone("FunctionZone", "功能分区"),
+	PassengerFlowZone("PassengerFlowZone", "客流分区"),
+	EvacuateZone("EvacuateZone", "疏散分区"),
+	EnvironmentZone("EnvironmentZone", "环境分区"),
+	OtherZone("OtherZone", "其他分区");
+
+	private String code;
+    private String desc;
+
+    SpaceTypeEnum(String code, String desc) {
+        this.code = code;
+        this.desc = desc;
+    }
+    
+}

+ 57 - 0
src/main/java/com/persagy/transfer/constant/SwitchConstant.java

@@ -0,0 +1,57 @@
+package com.persagy.transfer.constant;
+
+/**
+ * ADM 通用常量
+ * @author Charlie Yu
+ * @date 2021-08-16
+ */
+public interface SwitchConstant {
+	
+	/** 数据源 1 */
+	String DS_MASTER_1 = "master_1";
+	
+	/** 数据源 2 */
+	String DS_MASTER_2 = "master_2";
+	
+	/** 项目根路径*/
+	String SERVER_ROOT_PATH = System.getProperty("user.dir");
+	
+	String EMPTY = "";
+	
+    /** appId */
+    String APP_ID = "DMZ";
+    
+    /** 默认的userId */
+    String USER_ID = "systemId";
+    
+    /** 集团编码 header key*/
+    String GROUP_CODE_HEADER = "groupCode";
+
+    /** 项目ID header key*/
+    String PROJECT_ID_HEADER = "projectId";
+    
+    /** appID header key*/
+    String APP_ID_HEADER = "appId";
+    
+    /** userID header key*/
+    String USER_ID_HEADER = "userId";
+    
+    /** 连接符 ? */
+    String WHERE = "?";
+
+    /** 连接符 & */
+    String AND = "&";
+    
+    /** 连接符 _ */
+    String UNDERLINE = "_";
+    
+    /** 连接符 - */
+    String LINE_THROUGH = "-";
+    
+    /** 连接符 → */
+    String RIGHT_ARROW = "→";
+    
+    /** 有效标示*/
+    String VALID = "valid";
+
+}

+ 31 - 0
src/main/java/com/persagy/transfer/controller/DemoController.java

@@ -0,0 +1,31 @@
+package com.persagy.transfer.controller;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.persagy.transfer.service.impl.DemoService;
+
+/**
+ * 多数据源测试
+ * 
+ * @version 1.0.0
+ * @company persagy 
+ * @author zhangqiankun
+ * @date 2021年9月15日 下午4:12:18
+ */
+@RestController
+public class DemoController {
+
+	@Autowired
+	private DemoService demoService;
+	
+	@RequestMapping("/test")
+	public Object queryCount(HttpServletRequest request) {
+		String datasource = request.getHeader("datasource");
+		return "1".equals(datasource) ? this.demoService.getDataByMasterOne() : this.demoService.getDataByMasterTwo();
+	}
+	
+}

+ 17 - 0
src/main/java/com/persagy/transfer/mapper/MasterOneMapper.java

@@ -0,0 +1,17 @@
+package com.persagy.transfer.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 
+ * @version 1.0.0
+ * @company persagy 
+ * @author zhangqiankun
+ * @date 2021年9月15日 下午4:27:51
+ */
+@Mapper
+public interface MasterOneMapper {
+
+	String queryOne();
+	
+}

+ 17 - 0
src/main/java/com/persagy/transfer/mapper/MasterTwoMapper.java

@@ -0,0 +1,17 @@
+package com.persagy.transfer.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 
+ * @version 1.0.0
+ * @company persagy 
+ * @author zhangqiankun
+ * @date 2021年9月15日 下午4:27:51
+ */
+@Mapper
+public interface MasterTwoMapper {
+
+	String queryTwo();
+	
+}

+ 17 - 0
src/main/java/com/persagy/transfer/service/IDemoService.java

@@ -0,0 +1,17 @@
+package com.persagy.transfer.service;
+
+/**
+ * 多数据源测试
+ * 
+ * @version 1.0.0
+ * @company persagy 
+ * @author zhangqiankun
+ * @date 2021年9月15日 下午4:12:35
+ */
+public interface IDemoService {
+
+	Object getDataByMasterOne();
+	
+	Object getDataByMasterTwo();
+	
+}

+ 41 - 0
src/main/java/com/persagy/transfer/service/impl/DemoService.java

@@ -0,0 +1,41 @@
+package com.persagy.transfer.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.persagy.transfer.constant.SwitchConstant;
+import com.persagy.transfer.mapper.MasterOneMapper;
+import com.persagy.transfer.mapper.MasterTwoMapper;
+import com.persagy.transfer.service.IDemoService;
+
+/**
+ * 多数据源测试
+ * 
+ * @version 1.0.0
+ * @company persagy 
+ * @author zhangqiankun
+ * @date 2021年9月15日 下午4:13:29
+ */
+@Service
+@DS(value = SwitchConstant.DS_MASTER_1)
+public class DemoService implements IDemoService {
+
+	@Autowired
+	private MasterOneMapper masterOneMapper;
+	
+	@Autowired
+	private MasterTwoMapper masterTwoMapper;
+	
+	@Override
+	public Object getDataByMasterOne() {
+		return this.masterOneMapper.queryOne();
+	}
+
+	@Override
+	@DS(value = SwitchConstant.DS_MASTER_2)
+	public Object getDataByMasterTwo() {
+		return this.masterTwoMapper.queryTwo();
+	}
+	
+}

+ 0 - 0
src/main/resources/application.yml


+ 68 - 0
src/main/resources/bootstrap.yml

@@ -0,0 +1,68 @@
+server:
+  port: ${SERVER_PORT:8864}
+
+spring: 
+  application:
+    name: ibms-switch
+
+  datasource:
+    dynamic:
+      primary: master_1 #设置默认的数据源或者数据源组,默认值即为master
+      strict: true   #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源
+      datasource:
+        master_1:
+          url: jdbc:mysql://192.168.100.94:9934/saas_ems?serverTimezone=GMT&useUnicode=true&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true
+          username: root
+          password: persagy@2020
+          driver-class-name: com.mysql.cj.jdbc.Driver
+          type: com.alibaba.druid.pool.DruidDataSource
+          druid: 
+            initial-size: 10
+            max-active: 20
+            min-idle: 10
+            max-wait: 60000
+            validation-query: select 1
+            test-on-borrow: false
+            test-on-return: false
+            test-while-idle: true
+            filters: stat,slf4j
+            keep-alive: true
+            pool-prepared-statements: true
+            min-evictable-idle-time-millis: 100000
+            max-evictable-idle-time-millis: 200000
+            time-between-eviction-runs-millis: 50000
+            max-pool-prepared-statement-per-connection-size: 20  
+        master_2:
+          url: jdbc:mysql://192.168.64.15:9934/calendar-center?serverTimezone=GMT&useUnicode=true&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true
+          username: root
+          password: D56dLvRbSy5bMn
+          driver-class-name: com.mysql.cj.jdbc.Driver
+          type: com.alibaba.druid.pool.DruidDataSource
+          druid: 
+            initial-size: 10
+            max-active: 20
+            min-idle: 10
+            max-wait: 60000
+            validation-query: select 1
+            test-on-borrow: false
+            test-on-return: false
+            test-while-idle: true
+            filters: stat,slf4j
+            keep-alive: true
+            pool-prepared-statements: true
+            min-evictable-idle-time-millis: 100000
+            max-evictable-idle-time-millis: 200000
+            time-between-eviction-runs-millis: 50000
+            max-pool-prepared-statement-per-connection-size: 20          
+          
+mybatis-plus: 
+  mapper-locations: classpath:/*mapper/*.xml
+#  typeAliasesPackage: com.persagy.transfer.pojo.bdtp, com.persagy.transfer.pojo.wd
+      
+integrated: 
+  swagger: 
+    enabled: true
+    title: 数据转换中心
+    description: 数据转换中心接口文档
+    version: 1.0.0
+    base-package: com.persagy.transfer.controller

+ 9 - 0
src/main/resources/mapper/MasterOneMapper.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.persagy.transfer.mapper.MasterOneMapper">
+
+    <select id="queryOne" resultType="java.lang.String">
+        select 'one' from dual
+    </select>
+    
+</mapper>

+ 9 - 0
src/main/resources/mapper/MasterTwoMapper.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.persagy.transfer.mapper.MasterTwoMapper">
+
+    <select id="queryTwo" resultType="java.lang.String">
+        select 'two' from dual
+    </select>
+    
+</mapper>