Parcourir la source

1.测试-前后端打包到一起

wangt il y a 1 an
Parent
commit
8c080c9d98

+ 3 - 0
.gitignore

@@ -63,3 +63,6 @@ node_modules
 /agcavc-console/src/main/resources/static/
 /agcavc-ui/node/
 /dbh2/
+/neim-biz/src/main/resources/static/
+/neim-biz/src/main/resources/js/
+/neim-biz/src/main/resources/templates/

+ 81 - 26
neim-biz/pom.xml

@@ -78,7 +78,11 @@
             <artifactId>commons-math3</artifactId>
             <version>3.6.1</version>
         </dependency>
-
+        <!-- spring-boot-thymeleaf -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
+        </dependency>
     </dependencies>
 
     <profiles>    <!--考虑到window 和linux环境 npm命令格式的问题,使用maven的profile实现动态指定命令-->
@@ -111,8 +115,7 @@
                     <skipTests>true</skipTests>
                 </configuration>
             </plugin>
-
-            <!--             插件maven-clean-plugin,用于在编译前,清除之前编译的文件、文件夹等,避免残留之前的内容 -->
+            <!-- 插件maven-clean-plugin,用于在编译前,清除之前编译的文件、文件夹等,避免残留之前的内容 -->
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-clean-plugin</artifactId>
@@ -125,11 +128,59 @@
                         </fileset>
                         <fileset>
                             <!-- 最终项目打包自动生成的package目录 -->
-                            <directory>../package/neim/${project.version}</directory>
+                            <directory>src/main/resources/templates</directory>
+                        </fileset>
+                        <fileset>
+                            <!-- 最终项目打包自动生成的package目录 -->
+                            <directory>src/main/resources/static</directory>
+                            <directory>src/main/resources/js</directory>
                         </fileset>
                     </filesets>
                 </configuration>
             </plugin>
+
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>2.7.10</version> <!-- 如果 spring.boot.version 版本修改,则这里也要跟着修改 -->
+                <configuration>
+                    <includeSystemScope>true</includeSystemScope>
+                    <mainClass>com.jiayue.NeimApplication</mainClass>
+                    <layout>ZIP</layout>
+                    <fork>true</fork>
+                    <includes>
+                        <!-- 不包含任何jar包 -->
+                        <include>
+                            <groupId>nothing</groupId>
+                            <artifactId>nothing</artifactId>
+                        </include>
+                    </includes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal> <!-- 将引入的 jar 打入其中 -->
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- third-party jar into lib directory -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-dependencies</id>
+                        <phase>prepare-package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>exec-maven-plugin</artifactId>
@@ -184,52 +235,56 @@
                 </configuration>
                 <executions>
                     <execution>
-                        <id>copy static</id>
+                        <id>copy html</id>
                         <phase>generate-resources</phase>
                         <goals>
                             <goal>copy-resources</goal>
                         </goals>
                         <configuration>
                             <!-- 复制前端打包文件到这里 -->
-                            <outputDirectory>../package/neim/${project.version}/vue</outputDirectory>
+                            <outputDirectory>src/main/resources/templates</outputDirectory>
                             <overwrite>true</overwrite>
                             <resources>
                                 <resource>
                                     <!-- 从前端打包的目录dist进行指定文件、文件夹内容的复制-->
-                                    <directory>../neim-ui</directory>
+                                    <directory>../neim-ui/dist</directory>
+
                                     <includes>
-                                        <!-- 具体根据实际前端代码、及目录结构进行配置-->
-                                        <include>dist/</include>
-                                        <include>nginx.conf</include>
+                                        <include>favicon.ico</include>
                                         <include>index.html</include>
                                         <include>robots.txt</include>
+                                        <include>simhei-normal.js</include>
+                                        <include>html</include>
+                                        <include>img</include>
                                     </includes>
                                 </resource>
                             </resources>
                         </configuration>
                     </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-                <version>2.1.7.RELEASE</version>
-                <configuration>
-                    <outputDirectory>../package/neim/${project.version}/java</outputDirectory>
-                    <!--控制是否启用支持Linux下service方式运行-->
-                    <executable>true</executable>
-                    <includeSystemScope>true</includeSystemScope>
-                </configuration>
-                <executions>
                     <execution>
+                        <id>copy static</id>
+                        <phase>generate-resources</phase>
                         <goals>
-                            <goal>build-info</goal>
-                            <goal>repackage</goal>
+                            <goal>copy-resources</goal>
                         </goals>
+                        <configuration>
+                            <!-- 复制前端打包文件到这里 -->
+                            <outputDirectory>src/main/resources/</outputDirectory>
+                            <overwrite>true</overwrite>
+                            <resources>
+                                <resource>
+                                    <!-- 从前端打包的目录dist进行指定文件、文件夹内容的复制-->
+                                    <directory>../neim-ui/dist</directory>
+                                    <includes>
+                                        <include>static/</include>
+                                        <include>js/</include>
+                                    </includes>
+                                </resource>
+                            </resources>
+                        </configuration>
                     </execution>
                 </executions>
             </plugin>
         </plugins>
     </build>
-
 </project>

+ 0 - 19
neim-biz/src/main/java/com/jiayue/biz/conf/Channel.java

@@ -55,25 +55,6 @@ public class Channel {
 //    @Bean
     public void timingTunnel() {
         List<TunnelInfo> tunnelInfoList = tunnelInfoService.list();
-        tunnelInfoList.clear();
-        TunnelInfo tunnelInfo1 = new TunnelInfo();
-        TunnelInfo tunnelInfo2 = new TunnelInfo();
-        tunnelInfo1.setDataFormat("CDAB");
-//        tunnelInfo1.setIp("192.168.10.75");
-        tunnelInfo1.setIp("192.168.1.206");
-        tunnelInfo1.setPort(502);
-        tunnelInfo1.setStationId("七台河3005");
-        tunnelInfo1.setEquipmentNo("3005");
-//        tunnelInfo1.setStationId("虎林15244");
-//        tunnelInfo1.setEquipmentNo("15244");
-
-        tunnelInfo2.setDataFormat("CDAB");
-        tunnelInfo2.setIp("192.168.10.75");
-        tunnelInfo2.setPort(502);
-        tunnelInfo2.setStationId("虎林15244");
-        tunnelInfo2.setEquipmentNo("15244");
-        tunnelInfoList.add(tunnelInfo1);
-        tunnelInfoList.add(tunnelInfo2);
         for (TunnelInfo tunnelInfo : tunnelInfoList) {
             ModbusTcpMasterBuilder master = start(tunnelInfo);
             masterMap.put(tunnelInfo.getStationId(), master);

+ 8 - 10
neim-biz/src/main/resources/application-dev.yml

@@ -6,19 +6,20 @@ spring:
       max-request-size: 200MB
   data:
     mongodb:
-      host: 168.178.8.2
+      host: 192.168.1.208
       port: 27017
       database: neim
       username: root
       password: '!QAZ2root'
+      authentication-database: admin
   datasource:
     dynamic:
       primary: mysql #设置默认的数据源或者数据源组,默认值即为master
       datasource:
         mysql:
-#          url: jdbc:mysql://192.168.1.205:3306/nerp-test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
+          url: jdbc:mysql://192.168.1.205:3306/nerp-test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
 #          url: jdbc:mysql://49.4.78.194:17136/nerp-test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
-          url: jdbc:mysql://168.178.8.2:3306/nerp-db-v2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
+          #url: jdbc:mysql://168.178.8.2:3306/nerp-db-v2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
           username: root
           password: '!QAZ2root'
           driver-class-name: com.mysql.cj.jdbc.Driver
@@ -65,12 +66,9 @@ spring:
                 config:
                   multi-statement-allow: true
         tdengine:
-#          url: jdbc:TAOS://192.168.1.208:6030/nerp_db
-#          url: jdbc:TAOS://10.124.252.246:6030/nerp_db
-          url: jdbc:TAOS://168.178.8.2:6030/nerp_db
+          url: jdbc:TAOS://192.168.1.208:6030/nerp_db
           username: root
-#          password: 123456
-          password: "!QAZ2root"
+          password: 123456
           driver-class-name: com.taosdata.jdbc.TSDBDriver
           type: com.alibaba.druid.pool.DruidDataSource
           druid:
@@ -80,8 +78,8 @@ spring:
   # redis 配置
   redis:
     # 地址
- #   host: 192.168.1.205
-    host: 168.178.8.2
+    host: 192.168.1.205
+    #host: 168.178.8.2
     # 端口,默认为6379
     port: 6379
 #    port: 17137

+ 3 - 0
neim-system/src/main/java/com/jiayue/framework/config/ResourcesConfig.java

@@ -35,6 +35,9 @@ public class ResourcesConfig implements WebMvcConfigurer {
         /* swagger配置 */
         registry.addResourceHandler("/swagger-ui/**")
                 .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
+        /** 前端静态资源配置 */
+        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
+        registry.addResourceHandler("/js/**").addResourceLocations("classpath:/js/");
     }
 
     /**

+ 5 - 1
neim-system/src/main/java/com/jiayue/framework/config/SecurityConfig.java

@@ -98,7 +98,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
                         "/**/*.html",
                         "/**/*.css",
                         "/**/*.js",
-                        "/profile/**"
+                        "/profile/**",
+                        "/static/**",
+                        "/js/**",
+                        "/",
+                        "/index"
                 ).permitAll()
                 .antMatchers("/swagger-ui.html").anonymous()
                 .antMatchers("/swagger-resources/**").anonymous()

+ 1 - 1
neim-ui/.env.development

@@ -5,7 +5,7 @@ VUE_APP_TITLE = 新能源风光资源监测平台
 ENV = 'development'
 
 # ELF管理系统/开发环境
-VUE_APP_BASE_API = '/dev-api'
+VUE_APP_BASE_API = ''
 
 # 路由懒加载
 VUE_CLI_BABEL_TRANSPILE_MODULES = true

+ 2 - 2
neim-ui/.env.production

@@ -5,6 +5,6 @@ VUE_APP_TITLE = 新能源风光资源监测平台
 ENV = 'production'
 
 # ELF管理系统/生产环境
-VUE_APP_BASE_API = '/prod-api'
+VUE_APP_BASE_API = ''
 
-VUE_APP_GIS_API = '/webgis-api'
+VUE_APP_GIS_API = ''

+ 2 - 2
neim-ui/src/utils/bigemap/3dmap.js

@@ -1,7 +1,7 @@
 //map.js
 // 换成本地的服务器js文件即可
 let script = [
-  'http://10.124.241.21:9000/bigemap-gl.js/v1.1.0/bigemap-gl.js',
+  'http://127.0.0.1:9000/bigemap-gl.js/v1.1.0/bigemap-gl.js',
   // '/js/bigemap-velocity.min.js',
   '/jquery.min.js',
   //如果有更多的JS要引用 ,也一起放到这个数组中
@@ -11,7 +11,7 @@ export default new Promise(resolve => {
   link.rel = "stylesheet";
   link.async = false;
   // 换成本地的服务器css文件即可
-  link.href = "http://10.124.241.21:9000/bigemap-gl.js/v1.1.0/Widgets/widgets.css";
+  link.href = "http://127.0.0.1:9000/bigemap-gl.js/v1.1.0/Widgets/widgets.css";
   document.head.appendChild(link);
   let loads = script.map(v => {
     let script = document.createElement("script");

+ 2 - 2
neim-ui/src/utils/bigemap/map.js

@@ -1,7 +1,7 @@
 //map.js
 // 换成本地的服务器js文件即可
 let script = [
-  'http://10.124.241.21:9000/bigemap.js/v2.1.0/bigemap.js',
+  'http://127.0.0.1:9000/bigemap.js/v2.1.0/bigemap.js',
   // 'http://www.bigemap.com/public/js/tool/BMturf.min.js',
   // '/js/bigemap-velocity.min.js',
   '/js/BMturf.min.js',
@@ -13,7 +13,7 @@ export default new Promise(resolve => {
   link.rel = "stylesheet";
   link.async = false;
   // 换成本地的服务器css文件即可
-  link.href = "http://10.124.241.21:9000/bigemap.js/v2.1.0/bigemap.css";
+  link.href = "http://127.0.0.1:9000/bigemap.js/v2.1.0/bigemap.css";
   document.head.appendChild(link);
   let loads = script.map(v => {
     let script = document.createElement("script");

+ 3 - 1
neim-ui/src/views/largeScreenPage/components/3DbigeMap.vue

@@ -50,7 +50,7 @@ export default {
         // console.log(center, 154);
         // window.bmgl.Config.HTTP_URL ='http://www.bigemap.com:9000';
         //TODO 修改地址和端口的时候要同步修改下面的TODO
-        window.bmgl.Config.HTTP_URL = 'http://10.124.241.21:9000';
+        window.bmgl.Config.HTTP_URL = 'http://127.0.0.1:9000';
         // window.bmgl.Config.HTTP_URL = 'http://localhost:9000';
         let viewer = new bmgl.Viewer('container', {
           // mapId: 'bigemap.zhongkexingtu',
@@ -71,6 +71,8 @@ export default {
         let helper = new bmgl.EventHelper();
         helper.add(viewer.scene.globe.tileLoadProgressEvent, e => {
           var layer=viewer.imageryLayers.get(0);
+          // TODO 改端口了这里需要屏蔽或者跟着调整
+          layer.imageryProvider._imageryProvider._resource._url=layer.imageryProvider._imageryProvider._resource._url.replace('9000','17143');
           console.log(layer.imageryProvider._imageryProvider._resource._url)
           helper.removeAll();
           helper=null;

+ 1 - 4
neim-ui/src/views/largeScreenPage/components/bigeHeatMap.vue

@@ -69,7 +69,7 @@ export default {
 
         window.BM.Config.HTTP_URL = process.env.VUE_APP_GIS_API;
         let ip1 = process.env.VUE_APP_GIS_API;
-        let ip2 = 'http://10.124.241.21:9000';
+        let ip2 = 'http://127.0.0.1:9000';
         // window.BM.Config.HTTP_URL = 'http://localhost:9000';
         // let ip1 = 'http://localhost:9000';
         // let ip2 = 'http://localhost:9000';
@@ -115,10 +115,7 @@ export default {
           }
         )
         window.Bmap = map;
-        // var layer1=window.BM.tileLayer('bigemap.re-huafu')
-        //var layer2=window.BM.tileLayer('bigemap.heatMapWs',{opacity:0.7});
         let heatmapid = 'bigemap.heatMapWs';
-        // let heatmapid = 'bigemap.900gyz4b';
         fetch(`${ip1}/tokens/v1?access_token=none`).then(function (response) {
           return response.json();
         }).then(function (body) {

+ 1 - 1
neim-ui/src/views/largeScreenPage/components/bigeHeatSunMap.vue

@@ -70,7 +70,7 @@ export default {
 
         window.BM.Config.HTTP_URL = process.env.VUE_APP_GIS_API;
         let ip1 = process.env.VUE_APP_GIS_API;
-        let ip2 = 'http://10.124.241.21:9000';
+        let ip2 = 'http://127.0.0.1:9000';
         // window.BM.Config.HTTP_URL = 'http://localhost:9000';
         // let ip1 = 'http://localhost:9000';
         // let ip2 = 'http://localhost:9000';

+ 12 - 21
neim-ui/src/views/largeScreenPage/components/bigeMap.vue

@@ -62,22 +62,10 @@ export default {
     initBigeMap() {
       let _self = this
       bigemap.then(() => {
-        // window.BM.Config.HTTP_URL = 'http://www.bigemap.com:9000';
-        //window.BM.Config.HTTP_URL = 'http://10.124.252.244/webgis-api';
-
         window.BM.Config.HTTP_URL = process.env.VUE_APP_GIS_API;
         let ip1 = process.env.VUE_APP_GIS_API;
-        let ip2 = 'http://10.124.241.21:9000';
-
-        // window.BM.Config.HTTP_URL = 'http://localhost:9000';
-        // let ip1 = 'http://localhost:9000';
-        // let ip2 = 'http://localhost:9000';
+        let ip2 = 'http://127.0.0.1:9000';
         let mapid = 'bigemap.re-huafu'
-        // window.BM.Config.HTTP_URL = 'http://192.168.1.181:9000';
-        // arcgis-satellite
-        // amap-satellite
-        // zhongkexingtu
-        // let map = window.BM.map('map', 'bigemap.arcgis-satellite', {
         let map = window.BM.map('map', null, {
           center: [30, 104],
           // center:[46.69090,128.13354],
@@ -172,17 +160,20 @@ export default {
             fillOpacity: 0.7
           }).addTo(this.bMap);
 
+          //初始化热力图
+          // this.setHeatMap(this.bMap);
           //绑定事件
           this.bindEvents(this.bMap);
-          setTimeout(function (){
-          if (_self.mapData.level !== null) {
-            _self.level = _self.mapData.level
-            _self.center = _self.mapData.center
-            _self.bMap.setView(_self.mapData.center, _self.mapData.level)
+          if (this.mapData.level !== null) {
+            _self.level = this.mapData.level
+            _self.center = this.mapData.center
+            this.bMap.setView(this.mapData.center, this.mapData.level)
+            // this.bMap.setZoom(this.mapData.level)
+            // this.bMap.panTo(this.mapData.center)
           } else {
-            _self.bMap.setView([46.69090, 128.13354], 7)
-          }},500
-        )
+            this.bMap.setView([46.69090, 128.13354], 7)
+          }
+
 
         })
         let sIconurl = 'http://' + _self.href.split("//")[1].split("/")[0] + '/largeScreenImg/station.png'

+ 2 - 2
neim-ui/src/views/largeScreenPage/components/zaiXianBigeMap.vue

@@ -64,8 +64,8 @@ export default {
         // window.BM.Config.HTTP_URL = 'http://www.bigemap.com:9000';
 
         window.BM.Config.HTTP_URL = process.env.VUE_APP_GIS_API;
-        let ip1 = 'http://10.124.241.21:9000';
-        let ip2 = 'http://10.124.241.21:9000';
+        let ip1 = 'http://127.0.0.1:9000';
+        let ip2 = 'http://127.0.0.1:9000';
 
         // window.BM.Config.HTTP_URL = 'http://49.4.78.194:17143';
         // let ip1 = 'http://49.4.78.194:17143';