diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/config/config.xlsx b/config/config.xlsx
new file mode 100644
index 0000000..99ab82e
--- /dev/null
+++ b/config/config.xlsx
@@ -0,0 +1,2 @@
+编号 门磁设备IMEI 对应摄像头IP
+1 866674056947364 192.168.0.68
diff --git a/doc/AEP骞冲彴缁戝畾璁惧.doc b/doc/AEP骞冲彴缁戝畾璁惧.doc
new file mode 100644
index 0000000..69bacc2
Binary files /dev/null and b/doc/AEP骞冲彴缁戝畾璁惧.doc differ
diff --git a/doc/AEP璁㈤槄鎺ㄩ佹秷鎭牸寮(1).docx b/doc/AEP璁㈤槄鎺ㄩ佹秷鎭牸寮(1).docx
new file mode 100644
index 0000000..ccb343e
Binary files /dev/null and b/doc/AEP璁㈤槄鎺ㄩ佹秷鎭牸寮(1).docx differ
diff --git a/doc/璁㈤槄浜嬩欢.doc b/doc/璁㈤槄浜嬩欢.doc
new file mode 100644
index 0000000..12f7274
Binary files /dev/null and b/doc/璁㈤槄浜嬩欢.doc differ
diff --git a/doc/闂ㄧBCP鏍煎紡瀹氫箟.doc b/doc/闂ㄧBCP鏍煎紡瀹氫箟.doc
new file mode 100644
index 0000000..afe4d6f
Binary files /dev/null and b/doc/闂ㄧBCP鏍煎紡瀹氫箟.doc differ
diff --git a/doc/闂ㄧ涓ц鏄庝功.pdf b/doc/闂ㄧ涓ц鏄庝功.pdf
new file mode 100644
index 0000000..ddd2607
Binary files /dev/null and b/doc/闂ㄧ涓ц鏄庝功.pdf differ
diff --git a/doc/闂ㄧ鐗╂ā鍨(鏅烘収绀惧尯)鍗忚鏂囨。(3).pdf b/doc/闂ㄧ鐗╂ā鍨(鏅烘収绀惧尯)鍗忚鏂囨。(3).pdf
new file mode 100644
index 0000000..0648dce
Binary files /dev/null and b/doc/闂ㄧ鐗╂ā鍨(鏅烘収绀惧尯)鍗忚鏂囨。(3).pdf differ
diff --git a/doc/闂ㄧ鐗╂ā鍨(鏅烘収绀惧尯)鍗忚鏂囨。.pdf b/doc/闂ㄧ鐗╂ā鍨(鏅烘収绀惧尯)鍗忚鏂囨。.pdf
new file mode 100644
index 0000000..0648dce
Binary files /dev/null and b/doc/闂ㄧ鐗╂ā鍨(鏅烘収绀惧尯)鍗忚鏂囨。.pdf differ
diff --git a/pom.xml b/pom.xml
index beb6396..f8b723f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,19 +21,105 @@
UTF-8
+
+ org.springframework.boot
+ spring-boot-starter-web
+
org.springframework.boot
spring-boot-starter
+ 2.0.5.RELEASE
org.springframework.boot
spring-boot-starter-test
+ 2.0.5.RELEASE
cn.hutool
hutool-all
- 5.8.18
+ 5.8.15
+
+
+ com.alibaba
+ fastjson
+ 1.2.80
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+
+ com.alibaba
+ easyexcel
+ 3.3.3
+
+
+
+
+ com.github.ben-manes.caffeine
+ caffeine
+ 2.9.0
+
+
+ cglib
+ cglib
+ 3.2.7
+
+
+ commons-net
+ commons-net
+ 3.8.0
+
+
+ commons-io
+ commons-io
+ 2.11.0
+
+
+
+ org.apache.commons
+ commons-pool2
+ 2.11.1
+
+
+ com.jcraft
+ jsch
+ 0.1.49
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+ fileHandle
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/doormagnet/AsyncConfiguration.java b/src/main/java/com/doormagnet/AsyncConfiguration.java
new file mode 100644
index 0000000..5f68ba9
--- /dev/null
+++ b/src/main/java/com/doormagnet/AsyncConfiguration.java
@@ -0,0 +1,33 @@
+package com.doormagnet;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadPoolExecutor;
+
+@Configuration
+@EnableAsync
+public class AsyncConfiguration {
+ @Bean("doorMagnetExecutor")
+ public Executor doSomethingExecutor() {
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ // 鏍稿績绾跨▼鏁帮細绾跨▼姹犲垱寤烘椂鍊欏垵濮嬪寲鐨勭嚎绋嬫暟
+ executor.setCorePoolSize(4);
+ // 鏈澶х嚎绋嬫暟锛氱嚎绋嬫睜鏈澶х殑绾跨▼鏁帮紝鍙湁鍦ㄧ紦鍐查槦鍒楁弧浜嗕箣鍚庢墠浼氱敵璇疯秴杩囨牳蹇冪嚎绋嬫暟鐨勭嚎绋
+ executor.setMaxPoolSize(8);
+ // 缂撳啿闃熷垪锛氱敤鏉ョ紦鍐叉墽琛屼换鍔$殑闃熷垪
+ executor.setQueueCapacity(16);
+ // 鍏佽绾跨▼鐨勭┖闂叉椂闂60绉掞細褰撹秴杩囦簡鏍稿績绾跨▼涔嬪鐨勭嚎绋嬪湪绌洪棽鏃堕棿鍒拌揪涔嬪悗浼氳閿姣
+ executor.setKeepAliveSeconds(30);
+ // 绾跨▼姹犲悕鐨勫墠缂锛氳缃ソ浜嗕箣鍚庡彲浠ユ柟渚挎垜浠畾浣嶅鐞嗕换鍔℃墍鍦ㄧ殑绾跨▼姹
+ executor.setThreadNamePrefix("file-handle-");
+ // 缂撳啿闃熷垪婊′簡涔嬪悗鐨勬嫆缁濈瓥鐣ワ細鐢辫皟鐢ㄧ嚎绋嬪鐞嗭紙涓鑸槸涓荤嚎绋嬶級
+ executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
+ executor.initialize();
+ return executor;
+ }
+
+}
diff --git a/src/main/java/com/doormagnet/DoorMagnet.java b/src/main/java/com/doormagnet/DoorMagnetApplication.java
similarity index 51%
rename from src/main/java/com/doormagnet/DoorMagnet.java
rename to src/main/java/com/doormagnet/DoorMagnetApplication.java
index 9d8c7b6..64f06df 100644
--- a/src/main/java/com/doormagnet/DoorMagnet.java
+++ b/src/main/java/com/doormagnet/DoorMagnetApplication.java
@@ -1,17 +1,23 @@
package com.doormagnet;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
/*
* @User $USER
* @Time $DATE $TIME
*
*/
+@Slf4j
+@EnableAsync
+@EnableScheduling
@SpringBootApplication
-public class DoorMagnet {
+public class DoorMagnetApplication {
public static void main(String[] args) {
- SpringApplication.run(DoorMagnet.class);
+ SpringApplication.run(DoorMagnetApplication.class);
System.out.println("闂ㄧ瀵规帴绋嬪簭");
}
}
\ No newline at end of file
diff --git a/src/main/java/com/doormagnet/config/SchuedingConfig.java b/src/main/java/com/doormagnet/config/SchuedingConfig.java
new file mode 100644
index 0000000..1f30dac
--- /dev/null
+++ b/src/main/java/com/doormagnet/config/SchuedingConfig.java
@@ -0,0 +1,23 @@
+package com.doormagnet.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.SchedulingConfigurer;
+import org.springframework.scheduling.config.ScheduledTaskRegistrar;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.Executors;
+
+/**
+ * @Author 鏉滀繆宀
+ * @Date 2023/12/22 17:46
+ * @Version 1.0
+ */
+@Configuration
+@EnableScheduling
+public class SchuedingConfig implements SchedulingConfigurer {
+ @Override
+ public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
+ taskRegistrar.setScheduler(Executors.newScheduledThreadPool(30));
+ }
+}
diff --git a/src/main/java/com/doormagnet/controller/DoorMagnetController.java b/src/main/java/com/doormagnet/controller/DoorMagnetController.java
new file mode 100644
index 0000000..2c06955
--- /dev/null
+++ b/src/main/java/com/doormagnet/controller/DoorMagnetController.java
@@ -0,0 +1,37 @@
+package com.doormagnet.controller;
+
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.ObjectMapper;
+import com.alibaba.fastjson.JSON;
+import com.doormagnet.pojo.EventReport;
+import com.doormagnet.service.DoorMagnetService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.support.BindingAwareModelMap;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.File;
+
+/**
+ * @Author 鏉滀繆宀
+ * @Date 2024/4/24 11:36
+ * @Version 1.0
+ */
+@RestController
+@RequestMapping("/doormagnet")
+public class DoorMagnetController {
+ @Autowired
+ private DoorMagnetService doorMagnetService;
+
+ @PostMapping("/test")
+ public void test(@RequestBody JSONObject jsonObject){
+ EventReport eventReport = JSON.parseObject(String.valueOf(jsonObject), EventReport.class);
+ if (eventReport.getEventContent().getOpenState()== 1 || eventReport.getEventContent().getOpenState()== 0){
+ Boolean flag = doorMagnetService.creatfile(eventReport);
+ System.out.println("eventReport = " + flag);
+ }
+ }
+
+
+
+
+}
diff --git a/src/main/java/com/doormagnet/ftp/config/FtpConfig.java b/src/main/java/com/doormagnet/ftp/config/FtpConfig.java
new file mode 100644
index 0000000..99d4a3c
--- /dev/null
+++ b/src/main/java/com/doormagnet/ftp/config/FtpConfig.java
@@ -0,0 +1,42 @@
+package com.doormagnet.ftp.config;
+
+import cn.hutool.core.util.CharsetUtil;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * ftp閰嶇疆
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "ftp.client")
+public class FtpConfig {
+ //杩炴帴鍦板潃
+ private String ip;
+ //绔彛
+ private Integer port;
+ //鐢ㄦ埛鍚
+ private String username;
+ //瀵嗙爜
+ private String password;
+ //ftp杩炴帴妯″紡锛屼富鍔ㄦā寮忓拰琚姩妯″紡, 0涓诲姩锛1琚姩
+ private Integer model = 1;
+ //缂栫爜鏍煎紡
+ private String charset = CharsetUtil.UTF_8;
+ //杩炴帴瓒呮椂鏃堕暱锛屽崟浣嶆绉
+ private Integer connectionTimeout = 3000;
+ //Socket杩炴帴瓒呮椂鏃堕暱锛屽崟浣嶆绉
+ private long soTimeout = 3000;
+ private String srcPath;
+ private String destPath;
+ private boolean dirFilter;
+ private boolean enableTLS;
+ private List typeList;
+}
+
+
diff --git a/src/main/java/com/doormagnet/ftp/service/FtpService.java b/src/main/java/com/doormagnet/ftp/service/FtpService.java
new file mode 100644
index 0000000..339e487
--- /dev/null
+++ b/src/main/java/com/doormagnet/ftp/service/FtpService.java
@@ -0,0 +1,78 @@
+package com.doormagnet.ftp.service;
+
+import com.doormagnet.ftp.config.FtpConfig;
+import org.apache.commons.net.ftp.FTP;
+import org.apache.commons.net.ftp.FTPClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * @Author 鏉滀繆宀
+ * @Date 2024/4/30 17:48
+ * @Version 1.0
+ */
+@Service
+public class FtpService {
+
+ @Autowired
+ private FtpConfig ftpProperties;
+//
+// public void uploadFile(String localFilePath, String remoteDirectory) throws IOException {
+// FTPClient ftpClient = new FTPClient();
+// try {
+// ftpClient.connect(ftpProperties.getIp(), ftpProperties.getPort());
+// ftpClient.login(ftpProperties.getUsername(), ftpProperties.getPassword());
+// ftpClient.enterLocalPassiveMode();
+// ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+//
+// FileInputStream inputStream = new FileInputStream(localFilePath);
+// boolean uploaded = ftpClient.storeFile(remoteDirectory, inputStream);
+// inputStream.close();
+//
+// if (uploaded) {
+// System.out.println("File uploaded successfully");
+// } else {
+// System.out.println("File upload failed");
+// }
+// } finally {
+// if (ftpClient.isConnected()) {
+// ftpClient.logout();
+// ftpClient.disconnect();
+// }
+// }
+// }
+
+
+ /**
+ * @description
+ * @author 鏉滀繆宀
+ * @param[1] null
+ * @throws
+ * @time 2024/4/30 18:00
+ * 浣跨敤ftp鏍规嵁鐩爣鏂囦欢璺緞锛屾枃浠跺悕锛屾枃浠朵紶杈撳埌ftp鎵鍦ㄦ湇鍔″櫒
+ */
+ public void downloadFile(String srcpath, String filename, File file) throws IOException {
+ FTPClient ftpClient = new FTPClient();
+ try {
+ ftpClient.connect(ftpProperties.getIp(), ftpProperties.getPort());
+ ftpClient.login(ftpProperties.getUsername(), ftpProperties.getPassword());
+ ftpClient.enterLocalPassiveMode();
+ ftpClient.setControlEncoding("UTF-8");
+ ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
+ ftpClient.enterLocalPassiveMode();
+ ftpClient.changeWorkingDirectory(srcpath);
+ ftpClient.storeFile(filename, new FileInputStream(file));
+ } finally {
+ if (ftpClient.isConnected()) {
+ ftpClient.logout();
+ ftpClient.disconnect();
+ }
+ }
+
+ }
+}
diff --git a/src/main/java/com/doormagnet/pojo/EventContent.java b/src/main/java/com/doormagnet/pojo/EventContent.java
new file mode 100644
index 0000000..8f812a9
--- /dev/null
+++ b/src/main/java/com/doormagnet/pojo/EventContent.java
@@ -0,0 +1,29 @@
+package com.doormagnet.pojo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @Author 鏉滀繆宀
+ * @Date 2024/4/24 11:33
+ * @Version 1.0
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class EventContent {
+ @JsonProperty("open_state")
+ private Integer openState = 3;
+ @JsonProperty("battery_voltage")
+ private Double batteryVoltage;
+ @JsonProperty("battery_value")
+ private Integer batteryValue;
+ @JsonProperty("arming_state")
+ private Integer armingState;
+ @JsonProperty("alarm_type")
+ private Integer alarmType;
+}
diff --git a/src/main/java/com/doormagnet/pojo/EventReport.java b/src/main/java/com/doormagnet/pojo/EventReport.java
new file mode 100644
index 0000000..ad6c991
--- /dev/null
+++ b/src/main/java/com/doormagnet/pojo/EventReport.java
@@ -0,0 +1,56 @@
+package com.doormagnet.pojo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @Author 鏉滀繆宀
+ * @Date 2024/4/28 11:24
+ * @Version 1.0
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class EventReport {
+ @JsonProperty("timestamp")
+ private long timestamp;
+
+ @JsonProperty("tenantId")
+ private String tenantId;
+
+ @JsonProperty("serviceId")
+ private Integer serviceId;
+
+ @JsonProperty("protocol")
+ private String protocol;
+
+ @JsonProperty("productId")
+ private String productId;
+
+ @JsonProperty("messageType")
+ private String messageType;
+
+ @JsonProperty("eventType")
+ private Integer eventType;
+
+ @JsonProperty("eventContent")
+ private EventContent eventContent;
+
+ @JsonProperty("deviceSn")
+ private String deviceSn;
+
+ @JsonProperty("deviceId")
+ private String deviceId;
+
+ @JsonProperty("IMSI")
+ private String IMSI;
+
+ @JsonProperty("IMEI")
+ private String IMEI;
+
+
+}
diff --git a/src/main/java/com/doormagnet/service/DoorMagnetService.java b/src/main/java/com/doormagnet/service/DoorMagnetService.java
new file mode 100644
index 0000000..6953f17
--- /dev/null
+++ b/src/main/java/com/doormagnet/service/DoorMagnetService.java
@@ -0,0 +1,82 @@
+package com.doormagnet.service;
+
+import cn.hutool.core.util.RandomUtil;
+import com.doormagnet.ftp.config.FtpConfig;
+import com.doormagnet.ftp.service.FtpService;
+import com.doormagnet.pojo.EventReport;
+import com.doormagnet.task.ExcelReader;
+import com.doormagnet.until.StringKit;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @Author 鏉滀繆宀
+ * @Date 2024/4/24 11:35
+ * @Version 1.0
+ */
+@Slf4j
+@Service
+public class DoorMagnetService {
+
+ @Autowired
+ private FtpConfig properties;
+ @Autowired
+ private FtpService ftpService;
+ private static final SimpleDateFormat hmsSdf = new SimpleDateFormat("HHmmss");
+
+ /**
+ * @description
+ * @author 鏉滀繆宀
+ * @param[1] null
+ * @throws
+ * @time 2024/4/28 14:14
+ * 灏佽bcp + ftp杞彂
+ * bcp鍚嶇О瀹氫箟锛欴oorMagnet_姣鍊糭HHmmss_鍥涗綅闅忔満鏁.bcp
+ * bcp鏍煎紡锛氭椂闂存埑锛屼簨浠剁被鍨嬶紝璁惧鏍囪瘑鍞竴鐮侊紝瀵瑰簲鎽勫儚澶磇p
+ */
+ public Boolean creatfile(EventReport eventReport) {
+ log.info("=============bcp寮濮嬪垱寤================");
+ String path = properties.getSrcPath();
+ String destPath = properties.getDestPath();
+ String fileName = "";
+ String ip = ExcelReader.get(eventReport.getIMEI());
+ String hhmmss = hmsSdf.format(new Date());
+ if (StringKit.isEmpty(ip)) {
+ log.info("=============璁惧ip涓虹┖=");
+ return null;
+ }
+ fileName = "DoorMagnet_" + eventReport.getTimestamp() + "_" + eventReport.getIMEI()+"_" + hhmmss + "_" + RandomUtil.randomNumbers(4) + ".bcp";
+ //鏍规嵁鎿嶄綔绯荤粺鑷姩鍒ゆ柇璺緞鍒嗛殧绗
+ path = path + File.separator + fileName;
+ PrintWriter writer = null;
+ try {
+ log.info("=============bcp鏂囦欢璺緞锛" + path);
+ writer = new PrintWriter(path, "UTF-8");
+ StringBuffer sb = new StringBuffer();
+ sb.append(eventReport.getTimestamp()).append(",").append(eventReport.getEventContent().getOpenState()).append(",");
+ sb.append(eventReport.getIMEI()).append(",").append(ip);
+ writer.print(sb.toString());
+ writer.flush();
+ writer.close();
+ //灏嗙敓鎴愮殑bcp鏂囦欢涓婁紶鍒癴tp
+ File file = new File(path);
+ //ftp杞彂
+ ftpService.downloadFile(destPath,fileName, file);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.error("=============bcp鍒涘缓澶辫触================");
+ return false;
+ }
+ log.info("=============bcp鍒涘缓鎴愬姛================");
+ return true;
+ }
+
+
+}
diff --git a/src/main/java/com/doormagnet/task/ConfigData.java b/src/main/java/com/doormagnet/task/ConfigData.java
new file mode 100644
index 0000000..ac11533
--- /dev/null
+++ b/src/main/java/com/doormagnet/task/ConfigData.java
@@ -0,0 +1,17 @@
+package com.doormagnet.task;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+@Data
+public class ConfigData {
+
+ @ExcelProperty("缂栧彿")
+ private String id;
+ @ExcelProperty("闂ㄧ璁惧IMEI")
+ private String doorwayIMEI;
+ @ExcelProperty("瀵瑰簲鎽勫儚澶碔P")
+ private String cameraIP;
+
+
+}
diff --git a/src/main/java/com/doormagnet/task/ExcelReader.java b/src/main/java/com/doormagnet/task/ExcelReader.java
new file mode 100644
index 0000000..e8e13a0
--- /dev/null
+++ b/src/main/java/com/doormagnet/task/ExcelReader.java
@@ -0,0 +1,68 @@
+package com.doormagnet.task;
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Component
+public class ExcelReader {
+
+ private static final Cache cache = Caffeine.newBuilder().build();
+
+ @PostConstruct
+ public static void readExcel() {
+ String filePath = "F:\\WT\\config.xlsx";
+
+ // 璇诲彇 Excel 鏂囦欢骞舵槧灏勫埌瀵硅薄
+ List dataList = EasyExcel.read(filePath, ConfigData.class, new ExcelListener()).sheet().doReadSync();
+ Map map = new HashMap();
+
+ cache.putAll(map);
+ Map dictMapCode = dataList.stream().collect(Collectors.toMap(
+ e -> e.getDoorwayIMEI(),
+ e -> e.getCameraIP(), (v1, v2) -> v2));
+ cache.putAll(dictMapCode);
+
+ }
+
+ public static class ExcelListener extends AnalysisEventListener {
+
+ private final List dataList = new ArrayList<>();
+
+ @Override
+ public void invoke(ConfigData data, AnalysisContext context) {
+ // 澶勭悊姣忎竴琛岀殑鏁版嵁
+ dataList.add(data);
+ }
+
+ @Override
+ public void doAfterAllAnalysed(AnalysisContext context) {
+ // 鏁版嵁璇诲彇瀹屾垚鍚庣殑澶勭悊
+// System.out.println("鎵鏈夋暟鎹鐞嗗畬姣");
+ }
+
+ public List getDataList() {
+ return dataList;
+ }
+ }
+
+ public static String get(String key) {
+ return cache.get(key, s -> null);
+ }
+
+
+ public static void main(String[] args) {
+ readExcel();
+ }
+}
diff --git a/src/main/java/com/doormagnet/until/StringKit.java b/src/main/java/com/doormagnet/until/StringKit.java
new file mode 100644
index 0000000..ecfa4a6
--- /dev/null
+++ b/src/main/java/com/doormagnet/until/StringKit.java
@@ -0,0 +1,106 @@
+package com.doormagnet.until;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.regex.Pattern;
+
+public class StringKit {
+
+ public StringKit() {
+ }
+
+ public static Boolean isEmpty(Object argObject) {
+ Boolean tbool = false;
+ String tString = toString(argObject);
+ if (tString.equals("")) {
+ tbool = true;
+ }
+
+ return tbool;
+ }
+
+ public static String toString(Object argObject) {
+ String tmpstr = "";
+ try {
+ if (argObject != null) {
+ tmpstr = argObject.toString();
+ tmpstr = tmpstr.replaceAll("\0", "");
+ if( "null".equals(tmpstr) || "underfind".equals(tmpstr) || "undefined".equals(tmpstr) ){
+ tmpstr="";
+ }
+ }
+ } catch (Exception var3) {
+ }
+
+ return tmpstr;
+ }
+
+ public static String toStringNull(Object argObject) {
+ String tmpstr = "";
+ try {
+ if (argObject != null) {
+ tmpstr = argObject.toString();
+ if( "null".equals(tmpstr) || "underfind".equals(tmpstr) || "undefined".equals(tmpstr) ){
+ tmpstr="null";
+ }
+ }
+ } catch (Exception var3) {
+ }
+
+ return tmpstr;
+ }
+
+ @Deprecated
+ public static String toDefaultString(Object argObject) {
+ String tmpstr = "鏃";
+ try {
+ if (argObject != null) {
+ tmpstr = argObject.toString();
+ if( "null".equals(tmpstr) || "underfind".equals(tmpstr) || "undefined".equals(tmpstr) ){
+ tmpstr="鏃";
+ }
+ }
+ } catch (Exception var3) {
+ }
+
+ return tmpstr;
+ }
+
+ @Deprecated
+ public static String toDefaultInt(Object argObject) {
+ String tmpstr = "0";
+ try {
+ if (argObject != null) {
+ tmpstr = argObject.toString();
+ if( "null".equals(tmpstr) || "underfind".equals(tmpstr) || "undefined".equals(tmpstr) ){
+ tmpstr="0";
+ }
+ }
+ } catch (Exception var3) {
+ }
+
+ return tmpstr;
+ }
+
+
+ public static boolean isNumeric(String str){
+ Pattern pattern = Pattern.compile("[0-9]*");
+ return pattern.matcher(str).matches();
+ }
+
+ public static boolean isEng(String str){
+ Pattern pattern = Pattern.compile("[a-zA-Z]");
+ return pattern.matcher(str).matches();
+ }
+
+
+ public static String getTrace(Throwable t){
+
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter writer = new PrintWriter(stringWriter);
+ t.printStackTrace(writer);
+ StringBuffer buffer = stringWriter.getBuffer();
+ return buffer.toString();
+ }
+
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
new file mode 100644
index 0000000..7f7c925
--- /dev/null
+++ b/src/main/resources/application.yml
@@ -0,0 +1,31 @@
+spring:
+ application:
+ name: doormagnetservice
+ profiles:
+ active: dev
+server:
+ port: 9477
+ftp:
+ client:
+ # 杩炴帴鍦板潃
+ ip: 192.168.0.38
+ # 绔彛
+ port: 21
+ # 鐢ㄦ埛鍚
+ username: watu2
+ # 瀵嗙爜
+ password: watu123
+ # ftp杩炴帴妯″紡:涓诲姩妯″紡鍜岃鍔ㄦā寮忥紱 0涓诲姩锛1琚姩锛岄粯璁よ鍔
+ model: 1
+ # Socket杩炴帴瓒呮椂鏃堕暱
+ soTimeout: 30000
+ # 婧愯矾寰勶細閰嶇疆闇瑕佹惉杩愮殑鐩綍
+ srcPath: D:\home
+ # 鐩爣璺緞锛氶厤缃洰鐨勫湴鐩稿璺緞锛岄渶瑕佹敞鎰忓疄闄呯洰鐨勫湴璺緞 = ftp鏈嶅姟鍣ㄩ厤缃殑鐢ㄦ埛鏍硅矾寰 + destPath
+ destPath: /home/doorbcp
+ # 鏂囦欢杩囨护寮鍏筹細榛樿鍏抽棴
+ dirFilter: false
+ # 鏄惁鍚敤FTPS鍔犲瘑浼犺緭锛氶粯璁ゅ叧闂
+ enableTLS: false
+ typeList: bcp
+
diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..572e20f
--- /dev/null
+++ b/src/main/resources/logback-spring.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+ ${CONSOLE_LOG_PATTERN}
+
+ UTF-8
+
+
+
+
+
+ ${LOG_PATH}/info/info.%d{yyyy-MM-dd}.log
+ ${MAX_HISTORY}
+
+
+ ${FILE_LOG_PATTERN}
+ UTF-8
+
+
+ INFO
+ ACCEPT
+ DENY
+
+
+
+
+ ${LOG_PATH}/error/error.%d{yyyy-MM-dd}.log
+ ${MAX_HISTORY}
+
+
+ ${FILE_LOG_PATTERN}
+ UTF-8
+
+
+ ERROR
+ ACCEPT
+ DENY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+