nahida 1 jaar geleden
bovenliggende
commit
d9b7ff2dc6
19 gewijzigde bestanden met toevoegingen van 154 en 41 verwijderingen
  1. 2 2
      environment-data-service/src/main/java/com/zksy/environment/service/impl/PictureMessageServiceImpl.java
  2. 1 1
      environment-data-service/src/main/java/com/zksy/environment/service/impl/StationHourServiceImpl.java
  3. 5 5
      environment-data-service/src/main/java/com/zksy/environment/utils/MonitorDatasynch.java
  4. 1 1
      environment-data-service/src/main/java/com/zksy/environment/utils/ServerHandler.java
  5. 3 2
      environment-data-service/src/main/resources/application-dev.yaml
  6. 9 6
      environment-data-service/src/main/resources/application-prod.yaml
  7. 9 0
      park-overview-service/Dockerfile
  8. 16 1
      park-overview-service/pom.xml
  9. 7 1
      park-overview-service/src/main/java/com/zksy/park/controller/ParkStemScreenController.java
  10. 3 0
      park-overview-service/src/main/java/com/zksy/park/domain/ParkVisualVideo.java
  11. 5 0
      park-overview-service/src/main/java/com/zksy/park/service/ParkStemScreenService.java
  12. 38 6
      park-overview-service/src/main/java/com/zksy/park/service/imp/ParkStemScreenServiceImpl.java
  13. 3 3
      pole-service/src/main/java/com/zksy/pole/MQTTServer/callBack/BootNettyMqttMsgBack.java
  14. 1 1
      pole-service/src/main/java/com/zksy/pole/service/impl/InstructionIssuanceServerImpl.java
  15. 5 5
      visualization-service/src/main/resources/application-prod.yaml
  16. 7 0
      zksy-gateway/pom.xml
  17. 24 0
      zksy-gateway/src/main/java/com/zksy/gateway/config/CorsGlobalConfiguration.java
  18. 7 7
      zksy-gateway/src/main/resources/application-dev.yaml
  19. 8 0
      zksy-gateway/src/main/resources/application-prod.yaml

+ 2 - 2
environment-data-service/src/main/java/com/zksy/environment/service/impl/PictureMessageServiceImpl.java

@@ -131,7 +131,7 @@ public class PictureMessageServiceImpl extends ServiceImpl<PictureMessageMapper,
                     return false;
                 }
 
-                System.out.println("packageNumber====="+packageNumber+"total====="+totalPackets);
+//                System.out.println("packageNumber====="+packageNumber+"total====="+totalPackets);
                 // 检查是否所有数据包都已经收到
                 if (packageNumber == totalPackets) {
                     // 重新组合所有的数据包
@@ -166,7 +166,7 @@ public class PictureMessageServiceImpl extends ServiceImpl<PictureMessageMapper,
             }
             return flag;
         } catch (Exception e) {
-            log.info("==========数据解析错误==========", oldDataStr);
+//            log.info("==========数据解析错误==========", oldDataStr);
             e.printStackTrace();
             allDataSegments.clear(); // 清空列表以便下次使用
         }

+ 1 - 1
environment-data-service/src/main/java/com/zksy/environment/service/impl/StationHourServiceImpl.java

@@ -120,7 +120,7 @@ public class StationHourServiceImpl extends ServiceImpl<StationHourMapper, Stati
             System.out.println("stationHour====="+stationHour);
              flag = super.save(stationHour);
         } catch (Exception e) {
-            log.info("==========数据解析错误==========", dataStr);
+//            log.info("==========数据解析错误==========", dataStr);
             e.printStackTrace();
         }
         return flag;

+ 5 - 5
environment-data-service/src/main/java/com/zksy/environment/utils/MonitorDatasynch.java

@@ -44,7 +44,7 @@ public class MonitorDatasynch {
             // 读取并转换 ByteBuf 中的数据为16进制字符串
             String oldDataStr = HexToImageConverter.bytesToHex(dataByte);
 
-            log.info("==========接收到数据:" + oldDataStr + "==========");
+//            log.info("==========接收到数据:" + oldDataStr + "==========");
 
             // 获取检验码数据
             String codeStr = oldDataStr.substring(0, oldDataStr.length() - 4);
@@ -67,21 +67,21 @@ public class MonitorDatasynch {
                     if ("36".equals(dataType)) {
                         // 获取数据正文
                         String dataStr = oldDataStr.substring(26, oldDataStr.length() - 6);
-                        log.info("数据主体正文:" + dataStr);
+//                        log.info("数据主体正文:" + dataStr);
                         flag = pictureMessageService.savePictureMessage(oldDataStr, dataStr);
                         //清除data1List
                         data1List.clear();
                     } else {
                         // 获取数据正文
                         String dataStr = oldDataStr.substring(32, oldDataStr.length() - 6);
-                        log.info("数据主体正文:" + dataStr);
+//                        log.info("数据主体正文:" + dataStr);
                         flag = stationHourService.saveStationHour(oldDataStr, dataStr);
                     }
 
                     if (flag) {
                         log.info("新增成功", oldDataStr);
                     } else {
-                        log.info("新增失败", oldDataStr);
+//                        log.info("新增失败", oldDataStr);
                     }
                 } else {
                     log.info("收到2f数据========", oldDataStr);
@@ -145,7 +145,7 @@ public class MonitorDatasynch {
                     if ("36".equals(dataType)) {
                         // 获取数据正文
                         String dataStr = oldDataStr.substring(26, oldDataStr.length() - 6);
-                        log.info("数据主体正文:" + dataStr);
+//                        log.info("数据主体正文:" + dataStr);
                         pictureMessageService.savePictureMessage(oldDataStr, dataStr);
                         data1List.clear();
                     }

+ 1 - 1
environment-data-service/src/main/java/com/zksy/environment/utils/ServerHandler.java

@@ -60,7 +60,7 @@ public class ServerHandler extends SimpleChannelInboundHandler<ByteBuf> {
     @Override
     public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
         ctx.flush();
-        log.info("信息接收完毕...");
+//        log.info("信息接收完毕...");
     }
 
     /**

+ 3 - 2
environment-data-service/src/main/resources/application-dev.yaml

@@ -15,5 +15,6 @@ minio:
   secretKey: minio123
   bucket: zksy-file
   readPath: http://192.168.110.30:9000
-
-
+netty:
+  # 端口号
+  port: 8085

+ 9 - 6
environment-data-service/src/main/resources/application-prod.yaml

@@ -1,17 +1,20 @@
 zksy:
   db:
-    host: 192.168.110.30
+    host: 172.16.102.51
     un: root
-    pw: 123
-    port: 3307
+    pw: d$3%#*(jnhUDGHB]z0x876c~
+    port: 3306
     database: environment_data
 spring:
   redis:
-    host: 192.168.110.30
+    host: 172.16.102.52
     port: 6379
 minio:
-  endpoint: http://192.168.110.30:9000
+  endpoint: http://172.16.102.52:9000
   accessKey: minio
   secretKey: minio123
   bucket: test
-  readPath: http://192.168.110.30:9000
+  readPath: http://172.16.102.52:9000
+netty:
+  # 端口号
+  port: 8085

+ 9 - 0
park-overview-service/Dockerfile

@@ -0,0 +1,9 @@
+# 基础镜像
+FROM openjdk:11.0-jre-buster
+# 设定时区
+ENV TZ=Asia/Shanghai
+RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
+# 拷贝jar包
+COPY park-service.jar /app.jar
+# 入口
+ENTRYPOINT ["java", "-Xms256m", "-Xmx512m", "-jar", "/app.jar"]

+ 16 - 1
park-overview-service/pom.xml

@@ -7,7 +7,7 @@
         <artifactId>dh-server-micro</artifactId>
         <version>1.0.0</version>
     </parent>
-    <artifactId>park-overview-service</artifactId>
+    <artifactId>park-service</artifactId>
 
     <groupId>com.zksy.park</groupId>
     <properties>
@@ -62,10 +62,25 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-redis</artifactId>
         </dependency>
+        <!--sentinel-->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.zksy</groupId>
             <artifactId>minioutil</artifactId>
             <version>1.0.0</version>
         </dependency>
     </dependencies>
+
+    <build>
+        <finalName>${project.artifactId}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
 </project>

+ 7 - 1
park-overview-service/src/main/java/com/zksy/park/controller/ParkStemScreenController.java

@@ -31,7 +31,7 @@ public class ParkStemScreenController {
 
     @GetMapping("/getById")
     @ApiOperation(value = "园区灯杆大屏搜索getById")
-    public Result getById(@PathVariable String id) {
+    public Result getById(String id) {
         return service.getByIdWithFile(id);
     }
 
@@ -47,6 +47,12 @@ public class ParkStemScreenController {
         return Result.ok(service.list(SearchUtil.parseWhereSql(conditionJson)));
     }
 
+    @GetMapping("/getListWithImg")
+    @ApiOperation(value = "园区灯杆大屏查询所有以及图片")
+    public Result getListWithImg(String conditionJson) throws Exception {
+        return Result.ok(service.listWithImg(SearchUtil.parseWhereSql(conditionJson)));
+    }
+
     @PostMapping("/save")
     @ApiOperation(value = "园区灯杆大屏新增")
     @Log(title = "新增园区灯杆大屏", businessType = BusinessType.INSERT)

+ 3 - 0
park-overview-service/src/main/java/com/zksy/park/domain/ParkVisualVideo.java

@@ -43,6 +43,9 @@ public class ParkVisualVideo {
     @ApiModelProperty(value = "通道编码")
     private String channelId;
 
+    @ApiModelProperty(value = "通道名称")
+    private String channelName;
+
     @ApiModelProperty(value = "属于的tab栏")
     private Integer belong;
 

+ 5 - 0
park-overview-service/src/main/java/com/zksy/park/service/ParkStemScreenService.java

@@ -1,5 +1,6 @@
 package com.zksy.park.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zksy.common.core.domain.Result;
 import com.zksy.park.domain.ParkInfo;
@@ -7,6 +8,8 @@ import com.zksy.park.domain.ParkStemScreen;
 import com.zksy.park.domain.dto.PackInfoDto;
 import com.zksy.park.domain.dto.ParkStemScreenDto;
 
+import java.util.List;
+
 /**
  * @author nahida
  * @version 1.0
@@ -22,4 +25,6 @@ public interface ParkStemScreenService extends IService<ParkStemScreen> {
     Result<String> deleteById(String id);
 
     Result<ParkStemScreen> getByIdWithFile(String id);
+
+    List<ParkStemScreen> listWithImg(QueryWrapper<ParkStemScreen> queryWrapper);
 }

+ 38 - 6
park-overview-service/src/main/java/com/zksy/park/service/imp/ParkStemScreenServiceImpl.java

@@ -3,6 +3,7 @@ package com.zksy.park.service.imp;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zksy.common.core.domain.Result;
 import com.zksy.park.domain.FileGeneral;
@@ -17,6 +18,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -63,6 +65,18 @@ public class ParkStemScreenServiceImpl extends ServiceImpl<ParkStemScreenMapper,
     public Result<String> updateByParkStemScreenId(ParkStemScreenDto dto) {
         try {
             if (dto.getFiles() != null) {
+                if(dto.getFilePath() != null){
+                    dto.getFilePath().forEach(q->{
+                        minioFileStorageService.deleteFile(q);
+                    });
+                }else {
+                    LambdaQueryWrapper<FileGeneral> wrapper = new LambdaQueryWrapper<>();
+                    wrapper.eq(FileGeneral::getFormId, dto.getId());
+                    List<FileGeneral> list = fileGeneralService.list(wrapper);
+                    list.forEach(w->{
+                        minioFileStorageService.deleteFile(w.getFilePath());
+                    });
+                }
                 LambdaQueryWrapper<FileGeneral> wrapper = new LambdaQueryWrapper<>();
                 wrapper.eq(FileGeneral::getFormId, dto.getId());
                 fileGeneralService.remove(wrapper);
@@ -92,11 +106,13 @@ public class ParkStemScreenServiceImpl extends ServiceImpl<ParkStemScreenMapper,
         if (StrUtil.isNotBlank(id)) {
             LambdaQueryWrapper<FileGeneral> wrapper = new LambdaQueryWrapper<>();
             wrapper.eq(FileGeneral::getFormId, id);
-            FileGeneral one = fileGeneralService.getOne(wrapper);
-            if(one!=null){
-                minioFileStorageService.deleteFile(one.getFilePath());
-                fileGeneralService.remove(wrapper);
-            }
+            List<FileGeneral> list = fileGeneralService.list(wrapper);
+            list.forEach(q->{
+                if(q!=null){
+                    minioFileStorageService.deleteFile(q.getFilePath());
+                    fileGeneralService.remove(wrapper);
+                }
+            });
             this.removeById(id);
             return Result.ok("删除成功");
         }
@@ -111,7 +127,7 @@ public class ParkStemScreenServiceImpl extends ServiceImpl<ParkStemScreenMapper,
             wrapper.eq(FileGeneral::getFormId, id);
             List<FileGeneral> fileGeneralList = fileGeneralService.list(wrapper);
             if(fileGeneralList != null){
-                List<String> stringList = null;
+                List<String> stringList = new ArrayList<>();
                 fileGeneralList.forEach(q ->{
                     stringList.add(q.getFilePath());
                 });
@@ -121,4 +137,20 @@ public class ParkStemScreenServiceImpl extends ServiceImpl<ParkStemScreenMapper,
         }
         return Result.error("获取失败");
     }
+
+    @Override
+    public List<ParkStemScreen> listWithImg(QueryWrapper<ParkStemScreen> queryWrapper) {
+        List<ParkStemScreen> list = this.list(queryWrapper);
+        list.forEach(q->{
+            LambdaQueryWrapper<FileGeneral> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(FileGeneral::getFormId, q.getId());
+            List<FileGeneral> fileGeneralList = fileGeneralService.list(wrapper);
+            ArrayList<String> fileList = new ArrayList<>();
+            fileGeneralList.forEach(w->{
+                fileList.add(w.getFilePath());
+            });
+            q.setFilePath(fileList);
+        });
+        return list;
+    }
 }

+ 3 - 3
pole-service/src/main/java/com/zksy/pole/MQTTServer/callBack/BootNettyMqttMsgBack.java

@@ -95,7 +95,7 @@ public class BootNettyMqttMsgBack {
 		String lightNums = topicName.substring(lastIndex + 1);
 		System.err.println("topicName========"+topicName);
         String data = new String(headBytes);
-        log.info("收到数据-->"+data);
+//        log.info("收到数据-->"+data);
 		String jsonRes = handleCmdFactory.HandleCmd(data);
 		//重置读取的指针
 		mqttPublishMessage.payload().resetReaderIndex();
@@ -182,7 +182,7 @@ public class BootNettyMqttMsgBack {
 	 * @param mqttMessage
 	 */
 	public  void suback(Channel channel, MqttMessage mqttMessage) {
-		System.out.println("=============客户端订阅主题===================");
+//		System.out.println("=============客户端订阅主题===================");
 		MqttSubscribeMessage mqttSubscribeMessage = (MqttSubscribeMessage) mqttMessage;
 		MqttMessageIdVariableHeader messageIdVariableHeader = mqttSubscribeMessage.variableHeader();
 		//	构建返回报文, 可变报头
@@ -192,7 +192,7 @@ public class BootNettyMqttMsgBack {
 		List<Integer> grantedQoSLevels = new ArrayList<>(topics.size());
 		for (int i = 0; i < topics.size(); i++) {
 			grantedQoSLevels.add(mqttSubscribeMessage.payload().topicSubscriptions().get(i).qualityOfService().value());
-			System.out.println("topics=========================="+topics);
+//			System.out.println("topics=========================="+topics);
 		}
 		//	构建返回报文	有效负载
 		MqttSubAckPayload payloadBack = new MqttSubAckPayload(grantedQoSLevels);

+ 1 - 1
pole-service/src/main/java/com/zksy/pole/service/impl/InstructionIssuanceServerImpl.java

@@ -174,7 +174,7 @@ public class InstructionIssuanceServerImpl implements InstructionIssuanceServer
         long timeoutMillis = 20000;
         while (lockUtils.isLocked("lock:cmd:" + dto.getCmd())){
             try {
-                System.out.println("当前锁住了");
+//                System.out.println("当前锁住了");
                 Thread.sleep(100);
             } catch (InterruptedException e) {
                 Thread.currentThread().interrupt();

+ 5 - 5
visualization-service/src/main/resources/application-prod.yaml

@@ -1,11 +1,11 @@
 zksy:
   db:
-    host: 192.168.110.30
+    host: 172.16.102.51
     un: root
-    pw: 123
-    port: 3307
-    database: zksy-visualization
+    pw: d$3%#*(jnhUDGHB]z0x876c~
+    port: 3306
+    database: zhongkeshengyang
 spring:
   redis:
-    host: 192.168.110.30
+    host: 172.16.102.52
     port: 6379

+ 7 - 0
zksy-gateway/pom.xml

@@ -52,6 +52,13 @@
             <version>1.0.0</version>
             <scope>compile</scope>
         </dependency>
+        <!-- 添加 javax.servlet-api 依赖 -->
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>4.0.1</version>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
     <build>
         <finalName>${project.artifactId}</finalName>

+ 24 - 0
zksy-gateway/src/main/java/com/zksy/gateway/config/CorsGlobalConfiguration.java

@@ -0,0 +1,24 @@
+package com.zksy.gateway.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.reactive.CorsWebFilter;
+import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
+import org.springframework.web.cors.CorsConfiguration;
+
+@Configuration
+public class CorsGlobalConfiguration {
+
+    @Bean
+    public CorsWebFilter corsFilter() {
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+        CorsConfiguration config = new CorsConfiguration();
+        config.setAllowCredentials(true);
+//        config.addAllowedOrigin("*"); // 允许任何源
+        config.addAllowedOriginPattern("*"); // 使用模式匹配
+        config.addAllowedHeader("*"); // 允许任何头
+        config.addAllowedMethod("*"); // 允许任何方法
+        source.registerCorsConfiguration("/**", config);
+        return new CorsWebFilter(source);
+    }
+}

+ 7 - 7
zksy-gateway/src/main/resources/application-dev.yaml

@@ -12,10 +12,10 @@ hm:
       - /users/login
       - /items/**
 spring:
-  cloud:
-    nacos:
-      server-addr: 192.168.110.30:8848
-      discovery:
-        server-addr: 192.168.110.30:8848
-      config:
-        server-addr: 192.168.110.30:8848
+  graphql:
+    cors:
+      allowed-origins: "*"
+      allowed-methods: "GET,POST,PUT,DELETE,OPTIONS"
+      allowed-headers: "*"
+      allow-credentials: true
+      max-age: 3600

+ 8 - 0
zksy-gateway/src/main/resources/application-prod.yaml

@@ -11,3 +11,11 @@ hm:
       - /search/**
       - /users/login
       - /items/**
+spring:
+  graphql:
+    cors:
+      allowed-origins: "*"
+      allowed-methods: "GET,POST,PUT,DELETE,OPTIONS"
+      allowed-headers: "*"
+      allow-credentials: true
+      max-age: 3600