Selaa lähdekoodia

Merge branch 'master' of http://git.xt.wenhq.top:8083/hs/prod_group_bg

learshaw 4 kuukautta sitten
vanhempi
commit
8d3b0da465

+ 2 - 2
bd-park/park-backend/park-application/build.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project name="bd-location" basedir=".">
+<project name="park-app" basedir=".">
     <property environment="SystemVariable"/>
-    <property name="buildName" value="bd-location"/>
+    <property name="buildName" value="park-application"/>
     <!--默认目标-->
     <target name="Build" depends="copy-out"/>
     <!--所有的打包最终需要文件copy到特定目录,方便jenkins上取包-->

+ 2 - 2
bd-park/park-backend/park-application/pom.xml

@@ -9,11 +9,11 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>park-appliication</artifactId>
+    <artifactId>park-application</artifactId>
     <version>${park.version}</version>
 
     <description>
-        park-appliication核心模块
+        park-application核心模块
     </description>
 
     <properties>

+ 6 - 0
bd-park/park-backend/park-application/src/main/java/com/huashe/park/application/web/controller/cons/ConsUnitInfoController.java

@@ -85,6 +85,12 @@ public class ConsUnitInfoController extends BaseController {
         consUnitInfoService.exportConsUnitHole(consUnitInfo, response);
     }
 
+    @Log(title = "施工单元", businessType = BusinessType.EXPORT)
+    @PostMapping("/export/csv")
+    public void exportCsv(HttpServletResponse response, ConsUnitInfo consUnitInfo) {
+        consUnitInfoService.exportConsUnitRes(consUnitInfo, response);
+    }
+
     /**
      * 获取施工单元详细信息
      */

+ 106 - 0
bd-park/park-backend/park-application/src/main/resources/application-test.yml

@@ -0,0 +1,106 @@
+# 数据源配置
+spring:
+  # redis 配置
+  redis:
+    # 地址
+    host: 127.0.0.1
+    # 端口,默认为6379
+    port: 16379
+    # 数据库索引
+    database: 1
+    # 密码
+    password:
+    # 连接超时时间
+    timeout: 10s
+    lettuce:
+      pool:
+        # 连接池中的最小空闲连接
+        min-idle: 0
+        # 连接池中的最大空闲连接
+        max-idle: 8
+        # 连接池的最大数据库连接数
+        max-active: 8
+        # #连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: 3s
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    driverClassName: com.mysql.cj.jdbc.Driver
+    druid:
+      # 主库数据源
+      master:
+        url: jdbc:mysql://127.0.0.1:3306/hs_bds?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        username: root
+        password: Hs@123456
+      # 从库数据源
+      slave:
+        # 从数据源开关/默认关闭
+        enabled: false
+        url:
+        username:
+        password:
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+      # 配置连接超时时间
+      connectTimeout: 30000
+      # 配置网络超时时间
+      socketTimeout: 60000
+      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+      timeBetweenEvictionRunsMillis: 60000
+      # 配置一个连接在池中最小生存的时间,单位是毫秒
+      minEvictableIdleTimeMillis: 300000
+      # 配置一个连接在池中最大生存的时间,单位是毫秒
+      maxEvictableIdleTimeMillis: 900000
+      # 配置检测连接是否有效
+      validationQuery: SELECT 1 FROM DUAL
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      webStatFilter:
+        enabled: true
+      statViewServlet:
+        enabled: true
+        # 设置白名单,不填则允许所有访问
+        allow:
+        url-pattern: /druid/*
+        # 控制台管理用户名和密码
+        login-username: ruoyi
+        login-password: 123456
+      filter:
+        stat:
+          enabled: true
+          # 慢SQL记录
+          log-slow-sql: true
+          slow-sql-millis: 1000
+          merge-sql: true
+        wall:
+          config:
+            multi-statement-allow: true
+mqtt:
+  client:
+    enabled: false
+    ip: xt.wenhq.top
+    port: 8581
+    name: uwb-location-client
+    client-id: uwb-000001
+    global-subscribe:
+    timeout: 5
+    reconnect: true
+    re-interval: 5000
+    version: mqtt_3_1_1
+    read-buffer-size: 8KB
+    max-bytes-in-message: 10MB
+    keep-alive-secs: 60
+    clean-session: true
+    ssl:
+      enabled: false
+bd:
+  mqtt:
+    enabled: false
+server:
+  port: 28181

+ 13 - 0
bd-park/park-backend/park-collect/build.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="park-collection" basedir=".">
+    <property environment="SystemVariable"/>
+    <property name="buildName" value="park-collect"/>
+    <!--默认目标-->
+    <target name="Build" depends="copy-out"/>
+    <!--所有的打包最终需要文件copy到特定目录,方便jenkins上取包-->
+    <target name="copy-out">
+        <copy todir="${basedir}/../out" overwrite="true" failonerror="no">
+            <fileset file="${basedir}/target/${buildName}.jar"/>
+        </copy>
+    </target>
+</project>

+ 22 - 1
bd-park/park-backend/park-collect/pom.xml

@@ -96,7 +96,7 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
-                <version>2.5.15</version>
+                <version>${spring-boot.version}</version>
                 <configuration>
                     <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
                 </configuration>
@@ -117,6 +117,27 @@
                     <warName>${project.artifactId}</warName>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <version>1.8</version>
+                <executions>
+                    <execution>
+                        <id>package</id>
+                        <phase>package</phase>
+                        <configuration>
+                            <target>
+                                <ant antfile="build.xml">
+                                    <target name="Build"/>
+                                </ant>
+                            </target>
+                        </configuration>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
         <finalName>${project.artifactId}</finalName>
     </build>

+ 93 - 0
bd-park/park-backend/park-collect/src/main/resources/application-test.yml

@@ -0,0 +1,93 @@
+## MQTT##
+aliyun:
+  mqtt:
+    uri: tcp://127.0.0.1:1883
+
+
+# 数据源配置
+spring:
+  # redis 配置
+  redis:
+    # 地址
+    host: 127.0.0.1
+    # 端口,默认为6379
+    port: 16379
+    # 数据库索引
+    database: 1
+    # 密码
+    password:
+    # 连接超时时间
+    timeout: 10s
+    lettuce:
+      pool:
+        # 连接池中的最小空闲连接
+        min-idle: 0
+        # 连接池中的最大空闲连接
+        max-idle: 8
+        # 连接池的最大数据库连接数
+        max-active: 8
+        # #连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: 3s
+  cache:
+    cache-names:
+      - pileHoleList
+      - pileMachineList
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    driverClassName: com.mysql.cj.jdbc.Driver
+    druid:
+      # 主库数据源
+      master:
+        url: jdbc:mysql://127.0.0.1:3306/hs_bds?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        username: root
+        password: Hs@123456
+      # 从库数据源
+      pkb:
+        # 从数据源开关/默认关闭
+        enabled: true
+        url: jdbc:mysql://127.0.0.1:3306/hs_bds?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        username: root
+        password: Hs@123456
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+      # 配置连接超时时间
+      connectTimeout: 30000
+      # 配置网络超时时间
+      socketTimeout: 60000
+      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+      timeBetweenEvictionRunsMillis: 60000
+      # 配置一个连接在池中最小生存的时间,单位是毫秒
+      minEvictableIdleTimeMillis: 300000
+      # 配置一个连接在池中最大生存的时间,单位是毫秒
+      maxEvictableIdleTimeMillis: 900000
+      # 配置检测连接是否有效
+      validationQuery: SELECT 1 FROM DUAL
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      webStatFilter:
+        enabled: true
+      statViewServlet:
+        enabled: true
+        # 设置白名单,不填则允许所有访问
+        allow:
+        url-pattern: /druid/*
+        # 控制台管理用户名和密码
+        login-username: ruoyi
+        login-password: 123456
+      filter:
+        stat:
+          enabled: true
+          # 慢SQL记录
+          log-slow-sql: true
+          slow-sql-millis: 1000
+          merge-sql: true
+        wall:
+          config:
+            multi-statement-allow: true

+ 1 - 1
bd-park/park-backend/park-collect/src/main/resources/logback.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
     <!-- 日志存放路径 -->
-	<property name="log.path" value="/opt/project/ruoyi/ruoyi-backend/logs" />
+	<property name="log.path" value="/opt/project/ruoyi/ruoyi-backend/collect-logs" />
     <!-- 日志输出格式 -->
 	<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
 

+ 4 - 2
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/IConsUnitInfoService.java

@@ -2,11 +2,11 @@ package com.huashe.park.core.service;
 
 import java.util.List;
 
+import javax.servlet.http.HttpServletResponse;
+
 import com.huashe.park.domain.dto.cons.ConsUnitMachine;
 import com.huashe.park.domain.entity.ConsUnitInfo;
 
-import javax.servlet.http.HttpServletResponse;
-
 /**
  * 施工单元Service接口
  * 
@@ -72,6 +72,8 @@ public interface IConsUnitInfoService {
 
     void exportConsUnitHole(ConsUnitInfo consUnitHole, HttpServletResponse response);
 
+    void exportConsUnitRes(ConsUnitInfo consUnitHole, HttpServletResponse response);
+
     List<ConsUnitInfo> machineAssignedUnit(Long machineId);
 
 }

+ 29 - 13
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/impl/ConsUnitInfoServiceImpl.java

@@ -2,8 +2,10 @@ package com.huashe.park.core.service.impl;
 
 import java.io.BufferedInputStream;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -268,11 +270,9 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
         InputStream dwgFile = HttpRequest.post(cadForestCfg.getCadServer() + "/download").form("dwg_file", file)
             .form("csv_file", csvFile).execute().bodyStream();
         // 创建一个BufferedInputStream来缓冲输入流,提高读取效率
-        BufferedInputStream bis = new BufferedInputStream(dwgFile);
-        try {
-
+        try (BufferedInputStream bis = new BufferedInputStream(dwgFile);
+            ServletOutputStream outputStream = response.getOutputStream();) {
             FileUtils.setAttachmentResponseHeader(response, file.getName());
-            ServletOutputStream outputStream = response.getOutputStream();
             byte[] buffer = new byte[1024]; // 定义一个缓冲区
             int bytesRead;
 
@@ -286,14 +286,29 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
         catch (IOException e) {
             log.error("download input stream: {}", e.getMessage());
         }
-        finally {
-            try {
-                // 确保关闭输入流
-                bis.close();
-            }
-            catch (IOException e) {
-                log.error("Error closing input stream: {}", e.getMessage());
+    }
+
+    @Override
+    public void exportConsUnitRes(ConsUnitInfo consUnitHole, HttpServletResponse response) {
+        ConsUnitInfo consUnitInfo = consUnitInfoMapper.selectConsUnitInfoById(consUnitHole.getId());
+        File csvFile = generatePileHoleFile(consUnitInfo);
+        writeFileToResponse(csvFile, response);
+    }
+
+    private void writeFileToResponse(File file, HttpServletResponse response) {
+        // 读取文件内容并写入响应输出流
+        try (FileInputStream fis = new FileInputStream(file); OutputStream os = response.getOutputStream()) {
+            FileUtils.setAttachmentResponseHeader(response, file.getName());
+            byte[] buffer = new byte[4096];
+            int bytesRead;
+            while ((bytesRead = fis.read(buffer)) != -1) {
+                os.write(buffer, 0, bytesRead);
             }
+            // 刷新并关闭流
+            os.flush();
+        }
+        catch (IOException e) {
+            log.error("Error during file download: {}", e.getMessage());
         }
     }
 
@@ -340,7 +355,7 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
 
         ProjectInfo projectInfo = projectInfos.get(0);
         CsvWriteConfig csvWriteConfig = new CsvWriteConfig();
-        Field[] fields = ReflectUtil.getFields(ConsUnitInfo.class);
+        Field[] fields = ReflectUtil.getFields(ResultCADCsv.class);
         for (Field field : fields) {
             CsvAlias annotation = field.getAnnotation(CsvAlias.class);
             if (annotation != null) {
@@ -359,6 +374,7 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
         });
 
         List<PileMachineInfo> pileMachineInfos = pileMachineInfoService.qryUnitMachine(consUnitInfo.getId());
+        ConsUnitInfo consUnitInfo1 = consUnitInfoMapper.selectConsUnitInfoById(consUnitInfo.getId());
         if (!CollectionUtils.isEmpty(pileMachineInfos)) {
             List<String> machineNum = pileMachineInfos.stream().map(PileMachineInfo::getMachineNum)
                 .collect(Collectors.toList());
@@ -380,7 +396,7 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
             });
         }
         header.add(new String[] {
-            "Cluster Number :", ""
+            "Cluster Number :", consUnitInfo1.getName()
         });
         header.add(new String[] {
             "Operator Name :", ""

+ 83 - 0
bd-park/park-backend/start.bat

@@ -0,0 +1,83 @@
+@echo off
+
+rem jar平级目录
+set AppName=park-application.jar
+set appPort=28080
+
+set JarPath=./out/park-application.jar
+
+set Env=test
+
+rem JVM参数
+set JVM_OPTS="-Dapp.name=%AppName% -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps  -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC"
+
+
+ECHO.
+	ECHO.  [1] 启动%AppName%
+	ECHO.  [2] 关闭%AppName%
+	ECHO.  [3] 重启%AppName%
+	ECHO.  [4] 启动状态 %AppName%
+	ECHO.  [6] 关闭Nginx
+	ECHO.  [5] 退 出
+ECHO.
+
+ECHO.请输入选择项目的序号:
+set /p ID=
+	IF "%id%"=="1" GOTO start
+	IF "%id%"=="2" GOTO stop
+	IF "%id%"=="3" GOTO restart
+	IF "%id%"=="4" GOTO status
+	IF "%id%"=="6" GOTO stopNginx
+	IF "%id%"=="7" GOTO startNginx
+	IF "%id%"=="5" EXIT
+PAUSE
+
+:stopNginx
+   taskkill /f /fi "imagename eq nginx.exe"
+goto:eof
+
+:start
+    set pid=
+    for /f "usebackq tokens=2,5" %%a in (`netstat -ano ^| findstr  %appPort%`) do (
+		set pid=%%b
+		set image_name=%%a
+	)
+   if  defined pid (
+        echo %%pid is running
+        exit /b
+   )
+
+echo javaw %JVM_OPTS% -jar %JarPath% --spring.profiles.active=%Env%
+start javaw %JVM_OPTS% -jar %JarPath% --spring.profiles.active=%Env%
+
+echo  starting……
+echo  Start %AppName% success...
+goto:eof
+
+rem 函数stop通过jps命令查找pid并结束进程
+:stop
+    set pid=
+	for /f "usebackq tokens=2,5" %%a in (`netstat -ano ^| findstr  %appPort%`) do (
+		set pid=%%b
+		set image_name=%%a
+	)
+	if not defined pid (echo process %AppName% does not exists) else (
+		echo prepare to kill %image_name%
+		echo start kill %pid% ...
+		rem 根据进程ID,kill进程
+		taskkill /f /t /pid %pid%
+	)
+goto:eof
+:restart
+    call :stop
+    call :start
+goto:eof
+:status
+	for /f "usebackq tokens=2,5" %%a in (`netstat -ano ^| findstr  %appPort%`) do (
+		set pid=%%b
+		set image_name=%%a
+	)
+	if not defined pid (echo process %AppName% is dead ) else (
+		echo %image_name% is running
+	)
+goto:eof