瀏覽代碼

【情报二期】数据域服务 - 更新kafka配置文件;数据域测试消费topic数据无问题

peifj 2 月之前
父節點
當前提交
68ee03aeca

二進制
lib/postgresql-42.7.5.jar


+ 81 - 0
pom.xml

@@ -327,6 +327,14 @@
     </dependency>
 
     <!-- excel工具 -->
+    <dependency>
+      <groupId>org.apache.poi</groupId>
+      <artifactId>poi</artifactId>
+      <version>${poi.version}</version>
+      <scope>system</scope>
+      <systemPath>${project.basedir}/lib/poi-4.1.2.jar</systemPath>
+    </dependency>
+
     <dependency>
       <groupId>org.apache.poi</groupId>
       <artifactId>poi-ooxml</artifactId>
@@ -557,6 +565,79 @@
       <systemPath>${project.basedir}/lib/druid-1.2.23.jar</systemPath>
     </dependency>
 
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.2</version>
+      <scope>system</scope>
+      <systemPath>${project.basedir}/lib/commons-logging-1.2.jar</systemPath>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-collections4</artifactId>
+      <version>4.4</version>
+      <scope>system</scope>
+      <systemPath>${project.basedir}/lib/commons-collections4-4.4.jar</systemPath>
+    </dependency>
+
+    <dependency>
+      <groupId>com.alibaba</groupId>
+      <artifactId>easyexcel-core</artifactId>
+      <version>3.3.2</version>
+      <scope>system</scope>
+      <systemPath>${project.basedir}/lib/easyexcel-core-3.3.2.jar</systemPath>
+    </dependency>
+
+    <dependency>
+      <groupId>com.alibaba</groupId>
+      <artifactId>easyexcel-support</artifactId>
+      <version>3.3.2</version>
+      <scope>system</scope>
+      <systemPath>${project.basedir}/lib/easyexcel-support-3.3.2.jar</systemPath>
+    </dependency>
+
+    <dependency>
+      <groupId>org.hibernate.validator</groupId>
+      <artifactId>hibernate-validator</artifactId>
+      <version>6.2.5.Final</version>
+      <scope>system</scope>
+      <systemPath>${project.basedir}/lib/hibernate-validator-6.2.5.Final.jar</systemPath>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging</artifactId>
+      <version>3.4.1.Final</version>
+      <scope>system</scope>
+      <systemPath>${project.basedir}/lib/jboss-logging-3.4.1.Final.jar</systemPath>
+    </dependency>
+
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-classic</artifactId>
+      <version>1.2.12</version>
+      <scope>system</scope>
+      <systemPath>${project.basedir}/lib/logback-classic-1.2.12.jar</systemPath>
+    </dependency>
+
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-core</artifactId>
+      <version>1.2.12</version>
+      <scope>system</scope>
+      <systemPath>${project.basedir}/lib/logback-core-1.2.12.jar</systemPath>
+    </dependency>
+
+    <dependency>
+      <groupId>org.postgresql</groupId>
+      <artifactId>postgresql</artifactId>
+      <version>42.7.5</version>
+      <scope>system</scope>
+      <systemPath>${project.basedir}/lib/postgresql-42.7.5.jar</systemPath>
+    </dependency>
+
+
   </dependencies>
 
 </project>

+ 4 - 3
src/main/java/com/hhwy/qbeqsjy/common/KafkaProperties.java

@@ -22,13 +22,14 @@ public final class KafkaProperties {
     private static KafkaProperties instance = null;
     
     private KafkaProperties() {
-        String filePath = "";
+        String filePath = CommonUtil.getConfValueByKey("kafka.properties.path");
+        /*String filePath = "";
         if(System.getProperty("os.name").contains("Windows")){
 //            filePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "config" + File.separator;
-            filePath = "D:\\idea_projects\\QBEQSJY\\src\\main\\resources\\kafka\\";
+            filePath = "C:\\Users\\Administrator\\Desktop\\pfj\\idea_project\\QBEQSJY\\src\\main\\resources\\kafka\\";
         }else {
             filePath = "/服务器存放路径";
-        }
+        }*/
         try {
             File proFile = new File(filePath + "producer.properties");
             if (proFile.exists()) {

+ 7 - 12
src/main/java/com/hhwy/qbeqsjy/controller/CtrlController.java

@@ -25,6 +25,13 @@ public class CtrlController {
     private CtrlService ctrlService;
 
 
+    @GetMapping("/test")
+    public AjaxResult test(){
+        log.info("测试接口");
+        return AjaxResult.success("test......");
+    }
+
+
     /**
      * 下发布控任务,不支持批量操作,并记录布控任务对应的区域信息
      * @param ctrlDTO
@@ -161,18 +168,6 @@ public class CtrlController {
     }
 
 
-    @GetMapping("/test")
-    public AjaxResult test(){
-        try{
-            log.info("增量查询布控任务预警结果数据...");
-            return AjaxResult.success("6464646464");
-        } catch (Exception e){
-            log.error("增量查询布控任务预警结果数据发生异常", e);
-        }
-        return AjaxResult.error(Constants.SERVER_ERROR_MSG);
-    }
-
-
 
 
 

+ 9 - 7
src/main/java/com/hhwy/qbeqsjy/kafka/service/AuthService.java

@@ -1,5 +1,6 @@
 package com.hhwy.qbeqsjy.kafka.service;
 
+import com.hhwy.qbeqsjy.common.CommonUtil;
 import com.hhwy.qbeqsjy.common.Constants;
 import com.hhwy.qbeqsjy.common.KafkaProperties;
 import com.hhwy.qbeqsjy.common.LoginUtil;
@@ -77,12 +78,12 @@ public class AuthService {
 
     // 集群安全认证准备
     public static void securityPrepare() throws IOException {
-        String filePath = "";
-        if(System.getProperty("os.name").contains("Windows")){
-            filePath = "D:\\idea_projects\\QBEQSJY\\src\\main\\resources\\kafka\\";
+        String filePath = CommonUtil.getConfValueByKey("kafka.properties.path");
+        /*if(System.getProperty("os.name").contains("Windows")){
+            filePath = "C:\\Users\\Administrator\\Desktop\\pfj\\idea_project\\QBEQSJY\\src\\main\\resources\\kafka\\";
         }else {
             filePath = "/服务器存放路径";
-        }
+        }*/
 //        String filePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "config" + File.separator;
         String krbFile = filePath + "krb5.conf";
         String userKeyTableFile = filePath + "user.keytab";
@@ -97,13 +98,14 @@ public class AuthService {
     // 判断 kafka是否开启安全模式
     public static Boolean isSecurityModel() {
         Boolean isSecurity = false;
-        String filePath = "";
+        String filePath = CommonUtil.getConfValueByKey("kafka.properties.path");
+        /*String filePath = "";
         if(System.getProperty("os.name").contains("Windows")){
 //            filePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "config" + File.separator;
-            filePath = "D:\\idea_projects\\QBEQSJY\\src\\main\\resources\\kafka\\";
+            filePath = "C:\\Users\\Administrator\\Desktop\\pfj\\idea_project\\QBEQSJY\\src\\main\\resources\\kafka\\";
         }else {
             filePath = "服务器存放路径";
-        }
+        }*/
 //        String krbFilePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "config" + File.separator + "kafkaSecurityMode";
         String krbFilePath = filePath + "kafkaSecurityMode";
         Properties securityProps = new Properties();

+ 9 - 7
src/main/java/com/hhwy/qbeqsjy/kafka/service/ConsumeService.java

@@ -86,6 +86,7 @@ public class ConsumeService implements ApplicationListener<ContextRefreshedEvent
         consumer.subscribe(Collections.singletonList(topic));
         while (true) {
             // 间隔30秒拉取一次数据
+            log.info("间隔30秒拉取一次数据......");
             ConsumerRecords<Integer, String> records = consumer.poll(Constants.WAIT_TIME);
             if (records != null && records.count() > 0) {
                 List<Object[]> warningInfoList = new ArrayList<>();
@@ -93,15 +94,16 @@ public class ConsumeService implements ApplicationListener<ContextRefreshedEvent
                 for (ConsumerRecord<Integer, String> record : records) {
                     JSONObject message = JSONObject.parseObject(record.value());
                     JSONObject uniCtrl = message.getJSONObject("UNICTRL");
-                    String clueId = uniCtrl.getString("U_CLUEID");
+                    /*String clueId = uniCtrl.getString("U_CLUEID");
                     String[] clueIdStrArr = clueId.split("_");
                     String rwbh = clueIdStrArr[Constants.NUM_1];
                     String clueType = clueIdStrArr[Constants.NUM_2];
                     String clue = clueIdStrArr[Constants.NUM_3];
-                    String resourceId = uniCtrl.getString("U_RESID");
+                    String resourceId = uniCtrl.getString("U_RESID");*/
                     // 每张布控资源表对应的命中数据JSON对象
                     JSONObject oriField = message.getJSONObject("ORIFIELD");
 //                    String yjxxsm = oriField.toJSONString();
+                    log.info(oriField.toJSONString());
                     StringBuilder yjxxsm = new StringBuilder();
                     // 预警时间
                     Date yjsj = new Date();
@@ -110,7 +112,7 @@ public class ConsumeService implements ApplicationListener<ContextRefreshedEvent
                     // 预警状态默认为0(未读)
                     Integer yjzt = 0;
                     // 根据clueId中的任务编号、线索值、线索类型查询对应的布控任务相关信息(包含任务信息、区域信息、线索信息)
-                    List<Map<String, Object>> ctrlTaskInfoList = ctrlDao.queryCtrlTaskInfo(rwbh, clue, clueType);
+                    /*List<Map<String, Object>> ctrlTaskInfoList = ctrlDao.queryCtrlTaskInfo(rwbh, clue, clueType);
                     if(ctrlTaskInfoList.size() > 0){
                         Map<String, Object> ctrlTaskInfo = ctrlTaskInfoList.get(0);
                         String rwmc = String.valueOf(ctrlTaskInfo.get("rwmc"));
@@ -199,13 +201,13 @@ public class ConsumeService implements ApplicationListener<ContextRefreshedEvent
                         } else {   // 如果是其他类布控资源,预警数据直接入库
                             warningInfoList.add(new Object[]{rwbh, rwmc, rwlx, rwlxmc, rwdxlxmc, yjxxbh, yjryXm, yjrySfzh, yjrySjh, yjxxsm.toString(), yjzt, Constants.YJZT_WD, yjsj, zrjz, zrmjid, zrmjxm, zrmjjh, zrmjlxfs, zrdwbm, CommonUtil.getConfValueByKey(zrdwbm), zrbmbm, CommonUtil.getConfValueByKey(zrbmbm), sqrXm, sqrSfzh, sqrJh, sqrDwbm, sqrDwmc, yjryLb, yjryBq, gkjb, gkjbmc, resourceId, yjsj, yjsj});
                         }
-                    }
+                    }*/
                 }
                 // ========================= 批量入库符合条件的预警数据
-                if(warningInfoList.size() > 0){
+                /*if(warningInfoList.size() > 0){
                     batchSaveNum = ctrlDao.batchInsertWarningInfo(warningInfoList);
-                }
-                log.info("【QBEQSJYCTRL - 单人预警消费者服务】 当次消费的数据量:{},符合条件保存入库的数据量:{}", records.count(), batchSaveNum);
+                }*/
+                log.info("【QBEQSJYCTRL - 单人预警消费者服务】 当次消费的数据量:{},符合条件保存入库的数据量:{}", records.count(), batchSaveNum);
             }
         }
     }

+ 10 - 4
src/main/resources/application.properties

@@ -8,11 +8,14 @@ server.tomcat.threads.min-spare=100
 
 
 # \u6570\u636E\u5E93\u914D\u7F6E\uFF08\u540E\u7EED\u66FF\u6362GaussDB\uFF09
-spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
-spring.datasource.url=jdbc:mysql://1.94.209.147:3396/dcuc_zdrgk_ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
-spring.datasource.username=dcuc
-spring.datasource.password=123
+spring.datasource.driver-class-name=org.postgresql.Driver
+spring.datasource.url=jdbc:postgresql://localhost:5432/qbeq?currentSchema=public
+spring.datasource.username=postgres
+spring.datasource.password=123456
 
+#spring.datasource.url=jdbc:postgresql://130.0.46.149:5432/hcacdb_pg?currentSchema=public
+#spring.datasource.username=hcacdb
+#spring.datasource.password=hcacdb
 
 # \u4E1A\u52A1\u914D\u7F6E
 # \u7EBF\u7D22\u7C7B\u578B\u7F16\u7801\u5217\u8868
@@ -59,6 +62,9 @@ fwkfpt.serviceId=673976555399020544
 
 
 # \u534E\u4E3A - kafka\u914D\u7F6E
+# kafka\u96C6\u7FA4\u8BA4\u8BC1\u914D\u7F6E\u6587\u4EF6\u5B58\u653E\u8DEF\u5F84
+#kafka.properties.path=\u670D\u52A1\u5668\u751F\u4EA7\u73AF\u5883\u5B58\u653E\u8DEF\u5F84
+kafka.properties.path=C:\\Users\\Administrator\\Desktop\\pfj\\idea_project\\QBEQSJY\\src\\main\\resources\\kafka\\
 # \u4E1A\u52A1topic
 topic.name=UNICTRL_DATA_QBEQSJYCTRL_V1.0
 # \u662F\u5426\u5F00\u542F\u591A\u7EBF\u7A0B\u6267\u884C\u4EFB\u52A1 - false\uFF1A\u9ED8\u8BA4\u53EA\u5F00\u542F\u4E00\u4E2A\u5B50\u7EBF\u7A0B

+ 0 - 7
src/main/webapp/WEB-INF/web.xml

@@ -1,7 +0,0 @@
-<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd" >
-
-<web-app>
-  <display-name>Archetype Created Web Application</display-name>
-</web-app>

+ 0 - 5
src/main/webapp/index.jsp

@@ -1,5 +0,0 @@
-<html>
-<body>
-<h2>Hello World!</h2>
-</body>
-</html>