From 5e66e66dc2561c86893d483cab57128ebbd9bc5b Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期一, 09 十月 2023 13:34:22 +0800
Subject: [PATCH] 集成mqtt
---
server/services/src/main/java/com/doumee/core/annotation/excel/ExcelDataHandlerAdapter.java | 2
server/services/src/main/java/com/doumee/core/mqtt/service/MqttPushCallback.java | 33 ++
server/services/src/main/java/com/doumee/core/mqtt/service/MqttToolService.java | 55 +++
server/services/src/main/java/com/doumee/service/business/DeviceService.java | 20 +
server/services/src/main/resources/application-dev.yml | 7
server/services/src/main/java/com/doumee/service/business/DeviceSubcribeService.java | 18 +
server/services/src/main/java/com/doumee/core/annotation/excel/ExportExcelUtils.java | 88 +++++
server/platform/src/main/java/com/doumee/api/business/LocksController.java | 15
server/services/src/main/java/com/doumee/service/business/impl/DeviceSubscribeServiceImpl.java | 25 +
server/pom.xml | 5
server/services/src/main/java/com/doumee/core/constants/Constants.java | 8
server/services/src/main/java/com/doumee/core/mqtt/config/MqttClientInit.java | 51 +++
server/services/src/main/java/com/doumee/core/mqtt/config/MqttConfig.java | 34 ++
server/services/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java | 507 +++++++++++++++++++++++++++++++
server/services/src/main/java/com/doumee/core/annotation/excel/ExcelColumn.java | 7
server/services/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java | 35 ++
16 files changed, 895 insertions(+), 15 deletions(-)
diff --git a/server/platform/src/main/java/com/doumee/api/business/LocksController.java b/server/platform/src/main/java/com/doumee/api/business/LocksController.java
index b926095..532d4ee 100644
--- a/server/platform/src/main/java/com/doumee/api/business/LocksController.java
+++ b/server/platform/src/main/java/com/doumee/api/business/LocksController.java
@@ -7,6 +7,7 @@
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.dao.business.model.Locks;
+import com.doumee.service.business.DeviceService;
import com.doumee.service.business.LocksService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -29,6 +30,8 @@
@Autowired
private LocksService locksService;
+ @Autowired
+ private DeviceService deviceService;
@PreventRepeat
@ApiOperation("鏂板缓")
@@ -50,7 +53,7 @@
@GetMapping("/delete/batch")
@RequiresPermissions("business:locks:delete")
public ApiResponse deleteByIdInBatch(@RequestParam String ids) {
- String [] idArray = ids.split(",");
+ String[] idArray = ids.split(",");
List<String> idList = new ArrayList<>();
for (String id : idArray) {
idList.add(id);
@@ -70,14 +73,14 @@
@ApiOperation("鍒嗛〉鏌ヨ")
@PostMapping("/page")
@RequiresPermissions("business:locks:query")
- public ApiResponse<PageData<Locks>> findPage (@RequestBody PageWrap<Locks> pageWrap) {
+ public ApiResponse<PageData<Locks>> findPage(@RequestBody PageWrap<Locks> pageWrap) {
return ApiResponse.success(locksService.findPage(pageWrap));
}
@ApiOperation("瀵煎嚭Excel")
@PostMapping("/exportExcel")
@RequiresPermissions("business:locks:exportExcel")
- public void exportExcel (@RequestBody PageWrap<Locks> pageWrap, HttpServletResponse response) {
+ public void exportExcel(@RequestBody PageWrap<Locks> pageWrap, HttpServletResponse response) {
ExcelExporter.build(Locks.class).export(locksService.findPage(pageWrap).getRecords(), "閿佸ご淇℃伅琛�", response);
}
@@ -87,4 +90,10 @@
public ApiResponse findById(@PathVariable String id) {
return ApiResponse.success(locksService.findById(id));
}
+
+ @ApiOperation("娴嬭瘯mqtt娑堟伅鍙戦��")
+ @PostMapping("/testMqtt")
+ public ApiResponse testMqtt(@RequestBody Locks locks) {
+ return ApiResponse.success(deviceService.openLock(locks));
+ }
}
diff --git a/server/pom.xml b/server/pom.xml
index 64899f2..46d108d 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -285,6 +285,11 @@
<artifactId>wechatpay-java</artifactId>
<version>0.2.11</version>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.paho</groupId>
+ <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
+ <version>1.2.2</version>
+ </dependency>
</dependencies>
diff --git a/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelColumn.java b/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelColumn.java
index b649597..b7c7ef8 100644
--- a/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelColumn.java
+++ b/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelColumn.java
@@ -8,7 +8,7 @@
/**
* 鏍囪涓篍xcel鍒�
* @author Eva.Caesar Liu
- * @date 2022/03/15 09:54
+ * @date 2022/04/18 18:12
*/
@Inherited
@Target(ElementType.FIELD)
@@ -19,6 +19,7 @@
* 鍒楀悕
*/
String name();
+
/**
* 鍒楀锛堝崟浣嶄负瀛楃锛夛紝-1鑷姩璁$畻
@@ -33,7 +34,7 @@
/**
* 瀵归綈鏂瑰紡
*/
- HorizontalAlignment align() default HorizontalAlignment.LEFT;
+ HorizontalAlignment align() default HorizontalAlignment.LEFT;
/**
* 鍒楄儗鏅壊
@@ -83,7 +84,7 @@
/**
* 鏃ユ湡鏍煎紡
*/
- String dateFormat() default "yyyy-MM-dd HH:mm:ss";
+ String dateFormat() default "yyyy-MM-dd";
/**
* 鑷畾涔夋暟鎹鐞嗗櫒
diff --git a/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelDataHandlerAdapter.java b/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelDataHandlerAdapter.java
index 6334b85..a3c721f 100644
--- a/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelDataHandlerAdapter.java
+++ b/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelDataHandlerAdapter.java
@@ -3,7 +3,7 @@
/**
* Excel鏁版嵁鏍煎紡澶勭悊閫傞厤鍣�
* @author Eva.Caesar Liu
- * @date 2022/03/15 09:54
+ * @date 2022/04/18 18:12
*/
public interface ExcelDataHandlerAdapter {
diff --git a/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java b/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
index fc2bad2..cfeb782 100644
--- a/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
+++ b/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
@@ -4,24 +4,40 @@
import com.doumee.core.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Data;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.CharUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.math.NumberUtils;
+import org.apache.poi.hssf.usermodel.HSSFRichTextString;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.AnnotationConfigurationException;
+import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Excel瀵煎嚭瀹炵幇
* @author Eva.Caesar Liu
- * @date 2022/03/15 09:54
+ * @date 2022/04/18 18:12
*/
@Data
public class ExcelExporter<T> {
@@ -31,6 +47,13 @@
private Class<T> modelClass;
private ExcelExporter(){}
+
+
+
+ private final static Logger log = LoggerFactory.getLogger(ExcelExporter.class);
+
+ private final static String EXCEL2003 = "xls";
+ private final static String EXCEL2007 = "xlsx";
/**
* 鏋勯�犲櫒
@@ -52,6 +75,8 @@
SXSSFWorkbook sxssfWorkbook;
try {
sxssfWorkbook = new SXSSFWorkbook();
+
+ CellStyle style = sxssfWorkbook.createCellStyle();
Sheet sheet = sxssfWorkbook.createSheet(sheetName);
// 鍒涘缓鍒楀ご
sheet.createFreezePane(0, 1);
@@ -68,7 +93,7 @@
sheet.setColumnWidth(columnIndex, column.columnConfig.width() * 2 * 256);
}
// 璁剧疆鍒楀ご鍗曞厓鏍�
- configHeaderCell(sxssfWorkbook, cell, column.columnConfig);
+ configHeaderCell(sxssfWorkbook, cell, column.columnConfig,style);
}
// 鍒涘缓鏁版嵁璁板綍
for (int rowIndex = 0; rowIndex < data.size(); rowIndex++) {
@@ -78,7 +103,7 @@
Cell cell = row.createCell(columnIndex);
cell.setCellValue(getCellData(column, data.get(rowIndex)));
// 璁剧疆鏁版嵁鍗曞厓鏍�
- configDataCell(sxssfWorkbook, cell, column.columnConfig);
+ configDataCell(sxssfWorkbook, cell, column.columnConfig,style);
}
}
sxssfWorkbook.write(os);
@@ -125,7 +150,187 @@
public void export (List<T> data, String fileName, HttpServletResponse response) {
this.export(data, fileName, DEFAULT_SHEET_NAME, response);
}
+ /**
+ * 瀵煎嚭鑷冲搷搴旀祦
+ * @param data 鏁版嵁
+ * @param fileName Excel鏂囦欢鍚�
+ * @param response HttpServletResponse瀵硅薄
+ */
+ public void exportWithFirstAndEnd (List<T> data, String fileName,String first,String end, HttpServletResponse response) {
+ this.exportWithFirstAndEnd(data, fileName, DEFAULT_SHEET_NAME, first,end,response);
+ }
+ /**
+ * 瀵煎嚭鑷冲搷搴旀祦
+ * @param data 鏁版嵁
+ * @param fileName Excel鏂囦欢鍚�
+ * @param sheetName Sheet鍚嶇О
+ * @param response HttpServletResponse瀵硅薄
+ */
+ public void exportWithFirstAndEnd (List<T> data, String fileName, String sheetName, String first,String end ,HttpServletResponse response) {
+ try {
+ String encodeFileName = URLEncoder.encode(fileName, Charset.forName("UTF-8").toString()) + ".xlsx";
+ response.setHeader("Content-Disposition","attachment;filename=" + encodeFileName);
+ response.setContentType("application/octet-stream");
+ response.setHeader("eva-opera-type", "download");
+ response.setHeader("eva-download-filename", encodeFileName);
+ this.exportWithFirstAndEnd(data, sheetName,first,end, response.getOutputStream());
+ } catch (IOException e) {
+ throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
+ }
+ }
+ /**
+ * 瀵煎嚭鍒版寚瀹氳緭鍑烘祦
+ * @param data 鏁版嵁
+ * @param sheetName Sheet鍚嶇О
+ */
+ public void exportWithFirstAndEnd (List<T> data, String sheetName,String first,String end, OutputStream os) {
+ SXSSFWorkbook sxssfWorkbook;
+ try {
+ sxssfWorkbook = new SXSSFWorkbook();
+ Sheet sheet = sxssfWorkbook.createSheet(sheetName);
+ // 鍒涘缓鍒楀ご
+ sheet.createFreezePane(0, 2);
+ sheet.addMergedRegion(new CellRangeAddress(0 ,0,0,this.getColumns().size()-1));
+ Row title = sheet.createRow(0);
+ title.setHeight((short) 1000);
+ Cell c = title.createCell(0);
+ c.setCellValue(first);
+ configFirstCell(sxssfWorkbook,c);
+
+ Row header = sheet.createRow(1);
+ header.setHeight((short)600);
+ List<ColumnInfo> columns = this.getColumns();
+ for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) {
+ ColumnInfo column = columns.get(columnIndex);
+ Cell cell = header.createCell(columnIndex);
+ cell.setCellValue(new HSSFRichTextString(column.columnConfig.name()));
+ // 鍒楀璁剧疆
+ if (column.columnConfig.width() == -1) {
+ sheet.setColumnWidth(columnIndex, column.columnConfig.name().length() * 2 * 256);
+ } else {
+ sheet.setColumnWidth(columnIndex, column.columnConfig.width() * 2 * 256);
+ }
+ // 璁剧疆鍒楀ご鍗曞厓鏍�
+ configHeaderCell(sxssfWorkbook, cell, column.columnConfig);
+ }
+ // 鍒涘缓鏁版嵁璁板綍
+ for (int rowIndex = 0; rowIndex < data.size(); rowIndex++) {
+ Row row = sheet.createRow(rowIndex + 2);
+ for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) {
+ ColumnInfo column = columns.get(columnIndex);
+ Cell cell = row.createCell(columnIndex);
+ cell.setCellValue(getCellData(column, data.get(rowIndex)));
+ // 璁剧疆鏁版嵁鍗曞厓鏍�
+ configDataCell(sxssfWorkbook, cell, column.columnConfig);
+ }
+ }
+ if(StringUtils.isNotBlank(end)){
+ sheet.addMergedRegion(new CellRangeAddress(data.size()+2 ,data.size()+2,0,this.getColumns().size()-1));
+ Row endRow = sheet.createRow(data.size()+2);
+// endRow.setHeight((short) 600);
+ Cell c1 = endRow.createCell(0);
+ c1.setCellValue(end);
+ configEndCell(sxssfWorkbook,c1);
+ }
+ sxssfWorkbook.write(os);
+ os.close();
+ } catch (Exception e) {
+ throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
+ } finally {
+ if (os != null) {
+ try {
+ os.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ /**
+ * 閰嶇疆鏁版嵁鍗曞厓鏍�
+ */
+ private void configDataCell (SXSSFWorkbook workbook, Cell cell, ExcelColumn columnConfig) {
+ CellStyle style = workbook.createCellStyle();
+ style.setAlignment(columnConfig.align());
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
+ // 璁剧疆鑳屾櫙
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+ style.setFillForegroundColor(columnConfig.dataBackgroundColor().getIndex());
+ // 瀛椾綋
+ Font font = workbook.createFont();
+ font.setFontHeightInPoints(columnConfig.fontSize());
+ // 瀛椾綋棰滆壊
+ font.setColor(columnConfig.color().getIndex());
+ // 绮椾綋
+ font.setBold(columnConfig.bold());
+ // 鏂滀綋
+ font.setItalic(columnConfig.italic());
+ style.setFont(font);
+ // 杈规
+ configCellBorder(style);
+ style.setWrapText(true);
+ cell.setCellStyle(style);
+ }
+ /**
+ * 閰嶇疆鍒楀ご鍗曞厓鏍�
+ */
+ private void configFirstCell (SXSSFWorkbook workbook, Cell cell ) {
+ CellStyle style = workbook.createCellStyle();
+ style.setAlignment(HorizontalAlignment.CENTER);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
+ // 璁剧疆鑳屾櫙
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+ style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
+ // 瀛椾綋
+ Font font = workbook.createFont();
+ font.setFontHeightInPoints((short)24);
+ font.setBold(true);
+ style.setFont(font);
+ // 璁剧疆杈规
+ configCellBorder(style);
+ cell.setCellStyle(style);
+ }
+ /**
+ * 閰嶇疆鍒楀ご鍗曞厓鏍�
+ */
+ private void configEndCell (SXSSFWorkbook workbook, Cell cell ) {
+ CellStyle style = workbook.createCellStyle();
+ style.setAlignment(HorizontalAlignment.RIGHT);
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
+ // 璁剧疆鑳屾櫙
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+ style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+ // 瀛椾綋
+ Font font = workbook.createFont();
+ font.setFontHeightInPoints((short)14);
+ style.setFont(font);
+ // 璁剧疆杈规
+ configCellBorder(style);
+ cell.setCellStyle(style);
+ }
+ /**
+ * 閰嶇疆鍒楀ご鍗曞厓鏍�
+ */
+ private void configHeaderCell (SXSSFWorkbook workbook, Cell cell, ExcelColumn columnConfig) {
+ CellStyle style = workbook.createCellStyle();
+ style.setAlignment(columnConfig.align());
+ style.setVerticalAlignment(VerticalAlignment.CENTER);
+ // 璁剧疆鑳屾櫙
+ style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+// style.setFillForegroundColor(columnConfig.backgroundColor().getIndex());
+ style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
+ // 瀛椾綋
+ Font font = workbook.createFont();
+ font.setFontHeightInPoints((short)11);
+ font.setColor(columnConfig.color().index);
+ font.setBold(true);
+ style.setFont(font);
+ // 璁剧疆杈规
+ style.setWrapText(true);
+ configCellBorder(style);
+ cell.setCellStyle(style);
+ }
/**
* 鑾峰彇鍒楅泦鍚�
*/
@@ -147,11 +352,15 @@
return new ArrayList<>(sortedFields.values());
}
+ public static void main(String[] args) {
+ ExcelExporter m = new ExcelExporter();
+// ExcelExporter.build(UserSalaryListVO.class).getColumns();
+ }
/**
* 閰嶇疆鏁版嵁鍗曞厓鏍�
*/
- private void configDataCell (SXSSFWorkbook workbook, Cell cell, ExcelColumn columnConfig) {
- CellStyle style = workbook.createCellStyle();
+ private void configDataCell (SXSSFWorkbook workbook, Cell cell, ExcelColumn columnConfig, CellStyle style) {
+ // CellStyle style = workbook.createCellStyle();
style.setAlignment(columnConfig.align());
style.setVerticalAlignment(VerticalAlignment.CENTER);
// 璁剧疆鑳屾櫙
@@ -175,8 +384,8 @@
/**
* 閰嶇疆鍒楀ご鍗曞厓鏍�
*/
- private void configHeaderCell (SXSSFWorkbook workbook, Cell cell, ExcelColumn columnConfig) {
- CellStyle style = workbook.createCellStyle();
+ private void configHeaderCell (SXSSFWorkbook workbook, Cell cell, ExcelColumn columnConfig,CellStyle style) {
+ // CellStyle style = workbook.createCellStyle();
style.setAlignment(columnConfig.align());
style.setVerticalAlignment(VerticalAlignment.CENTER);
// 璁剧疆鑳屾櫙
@@ -263,4 +472,288 @@
private Field field;
}
+
+
+ public static <T> List<T> readExcel(String path, Class<T> cls, MultipartFile file) {
+
+ String fileName = file.getOriginalFilename();
+ if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) {
+ log.error("涓婁紶鏂囦欢鏍煎紡涓嶆纭�");
+ }
+ List<T> dataList = new ArrayList<>();
+ Workbook workbook = null;
+ try {
+ InputStream is = file.getInputStream();
+ if (fileName.endsWith(EXCEL2007)) {
+ workbook = new XSSFWorkbook(is);
+ }
+ if (fileName.endsWith(EXCEL2003)) {
+ workbook = new HSSFWorkbook(is);
+ }
+ if (workbook != null) {
+ //绫绘槧灏� 娉ㄨВ value-->bean columns
+ Map<String, List<Field>> classMap = new HashMap<>();
+ List<Field> fields = Stream.of(cls.getDeclaredFields()).collect(Collectors.toList());
+ fields.forEach(
+ field -> {
+ ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
+ if (annotation != null) {
+ String value = annotation.name();
+ if (StringUtils.isBlank(value)) {
+ return;//return璧峰埌鐨勪綔鐢ㄥ拰continue鏄浉鍚岀殑 璇硶
+ }
+ if (!classMap.containsKey(value)) {
+ classMap.put(value, new ArrayList<>());
+ }
+ field.setAccessible(true);
+ classMap.get(value).add(field);
+ }
+ }
+ );
+ //绱㈠紩-->columns
+ Map<Integer, List<Field>> reflectionMap = new HashMap<>(16);
+ //榛樿璇诲彇绗竴涓猻heet
+ Sheet sheet = workbook.getSheetAt(0);
+
+ boolean firstRow = true;
+ for (int i = sheet.getFirstRowNum(); i <= sheet.getLastRowNum(); i++) {
+ Row row = sheet.getRow(i);
+ //棣栬 鎻愬彇娉ㄨВ
+ if (firstRow) {
+ for (int j = row.getFirstCellNum(); j <= row.getLastCellNum(); j++) {
+ Cell cell = row.getCell(j);
+ String cellValue = getCellValue(cell);
+ if (classMap.containsKey(cellValue)) {
+ reflectionMap.put(j, classMap.get(cellValue));
+ }
+ }
+ firstRow = false;
+ } else {
+ //蹇界暐绌虹櫧琛�
+ if (row == null) {
+ continue;
+ }
+ try {
+ T t = cls.newInstance();
+ //鍒ゆ柇鏄惁涓虹┖鐧借
+ boolean allBlank = true;
+ for (int j = row.getFirstCellNum(); j <= row.getLastCellNum(); j++) {
+ if (reflectionMap.containsKey(j)) {
+ Cell cell = row.getCell(j);
+ String cellValue = getCellValue(cell);
+ if (StringUtils.isNotBlank(cellValue)) {
+ allBlank = false;
+ }
+ List<Field> fieldList = reflectionMap.get(j);
+ fieldList.forEach(
+ x -> {
+ try {
+ handleField(t, cellValue, x);
+ } catch (Exception e) {
+ log.error(String.format("reflect field:%s value:%s exception!", x.getName(), cellValue), e);
+ }
+ }
+ );
+ }
+ }
+ if (!allBlank) {
+ dataList.add(t);
+ } else {
+ log.warn(String.format("row:%s is blank ignore!", i));
+ }
+ } catch (Exception e) {
+ log.error(String.format("parse row:%s exception!", i), e);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.error(String.format("parse excel exception!"), e);
+ } finally {
+ if (workbook != null) {
+ try {
+ workbook.close();
+ } catch (Exception e) {
+ log.error(String.format("parse excel exception!"), e);
+ }
+ }
+ }
+ return dataList;
+ }
+
+ private static <T> void handleField(T t, String value, Field field) throws Exception {
+ Class<?> type = field.getType();
+ if (type == null || type == void.class || StringUtils.isBlank(value)) {
+ return;
+ }
+ if (type == Object.class) {
+ field.set(t, value);
+ //鏁板瓧绫诲瀷
+ } else if (type.getSuperclass() == null || type.getSuperclass() == Number.class) {
+ if (type == int.class || type == Integer.class) {
+ field.set(t, NumberUtils.toInt(value));
+ } else if (type == long.class || type == Long.class) {
+ field.set(t, NumberUtils.toLong(value));
+ } else if (type == byte.class || type == Byte.class) {
+ field.set(t, NumberUtils.toByte(value));
+ } else if (type == short.class || type == Short.class) {
+ field.set(t, NumberUtils.toShort(value));
+ } else if (type == double.class || type == Double.class) {
+ field.set(t, NumberUtils.toDouble(value));
+ } else if (type == float.class || type == Float.class) {
+ field.set(t, NumberUtils.toFloat(value));
+ } else if (type == char.class || type == Character.class) {
+ field.set(t, CharUtils.toChar(value));
+ } else if (type == boolean.class) {
+ field.set(t, BooleanUtils.toBoolean(value));
+ } else if (type == BigDecimal.class) {
+ field.set(t, new BigDecimal(value));
+ }
+ } else if (type == Boolean.class) {
+ field.set(t, BooleanUtils.toBoolean(value));
+ } else if (type == Date.class) {
+ field.set(t, value);
+ } else if (type == String.class) {
+ field.set(t, value);
+ } else {
+ Constructor<?> constructor = type.getConstructor(String.class);
+ field.set(t, constructor.newInstance(value));
+ }
+ }
+
+ private static String getCellValue(Cell cell) {
+ if (cell == null) {
+ return "";
+ }else{
+ return StringUtils.trimToEmpty(cell.getStringCellValue());
+ }
+ /* if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
+ if (HSSFDateUtil.isCellDateFormatted(cell)) {
+ return HSSFDateUtil.getJavaDate(cell.getNumericCellValue()).toString();
+ } else {
+ return new BigDecimal(cell.getNumericCellValue()).toString();
+ }
+ } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
+ return StringUtils.trimToEmpty(cell.getStringCellValue());
+ } else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
+ return StringUtils.trimToEmpty(cell.getCellFormula());
+ } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) {
+ return "";
+ } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
+ return String.valueOf(cell.getBooleanCellValue());
+ } else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) {
+ return "ERROR";
+ } else {
+ return cell.toString().trim();
+ }*/
+ }
+
+ /* public static <T> void writeExcel(HttpServletResponse response, List<T> dataList, Class<T> cls, String fileName) {
+ Field[] fields = cls.getDeclaredFields();
+ List<Field> fieldList = Arrays.stream(fields)
+ .filter(field -> {
+ ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
+ if (annotation != null && annotation.col() > 0) {
+ field.setAccessible(true);
+ return true;
+ }
+ return false;
+ }).sorted(Comparator.comparing(field -> {
+ int col = 0;
+ ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
+ if (annotation != null) {
+ col = annotation.col();
+ }
+ return col;
+ })).collect(Collectors.toList());
+
+ Workbook wb = new XSSFWorkbook();
+ Sheet sheet = wb.createSheet("Sheet1");
+ AtomicInteger ai = new AtomicInteger();
+ {
+ Row row = sheet.createRow(ai.getAndIncrement());
+ AtomicInteger aj = new AtomicInteger();
+ //鍐欏叆澶撮儴
+ fieldList.forEach(field -> {
+ ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
+ String columnName = "";
+ if (annotation != null) {
+ columnName = annotation.value();
+ }
+ Cell cell = row.createCell(aj.getAndIncrement());
+ CellStyle cellStyle = wb.createCellStyle();
+ cellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
+ Font font = wb.createFont();
+ cellStyle.setFont(font);
+ cell.setCellStyle(cellStyle);
+ cell.setCellValue(columnName);
+ });
+ }
+ if (CollectionUtils.isNotEmpty(dataList)) {
+ dataList.forEach(t -> {
+ Row row1 = sheet.createRow(ai.getAndIncrement());
+ AtomicInteger aj = new AtomicInteger();
+ fieldList.forEach(field -> {
+ Class<?> type = field.getType();
+ Object value = "";
+ try {
+ value = field.get(t);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ Cell cell = row1.createCell(aj.getAndIncrement());
+ if (value != null) {
+ if (type == Date.class) {
+ cell.setCellValue(value.toString());
+ } else {
+ cell.setCellValue(value.toString());
+ }
+ cell.setCellValue(value.toString());
+ }
+ });
+ });
+ }
+ //鍐荤粨绐楁牸
+ wb.getSheet("Sheet1").createFreezePane(0, 1, 0, 1);
+ //娴忚鍣ㄤ笅杞絜xcel
+ buildExcelDocument(fileName, wb, response);
+ }*/
+
+ /**
+ * 娴忚鍣ㄤ笅杞絜xcel
+ *
+ * @param fileName
+ * @param wb
+ * @param response
+ */
+/*
+ private static void buildExcelDocument(String fileName, Workbook wb, HttpServletResponse response) {
+ try {
+ response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
+ response.flushBuffer();
+ wb.write(response.getOutputStream());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }*/
+
+ /**
+ * 鐢熸垚excel鏂囦欢
+ *
+ * @param path 鐢熸垚excel璺緞
+ * @param wb
+ */
+ /* private static void buildExcelFile(String path, Workbook wb) {
+ File file = new File(path);
+ if (file.exists()) {
+ file.delete();
+ }
+ try {
+ wb.write(new FileOutputStream(file));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }*/
+
}
diff --git a/server/services/src/main/java/com/doumee/core/annotation/excel/ExportExcelUtils.java b/server/services/src/main/java/com/doumee/core/annotation/excel/ExportExcelUtils.java
new file mode 100644
index 0000000..eeac8bc
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/core/annotation/excel/ExportExcelUtils.java
@@ -0,0 +1,88 @@
+package com.doumee.core.annotation.excel;
+/*
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.ExcelImportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.ImportParams;
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;*/
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * @Author: Melon
+ * @Date: 2018/4/26
+ * @Descrip:
+ */
+@Slf4j
+public class ExportExcelUtils {
+
+ /* public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, boolean isCreateHeader, HttpServletResponse response){
+ ExportParams exportParams = new ExportParams(title, sheetName);
+ exportParams.setCreateHeadRows(isCreateHeader);
+ defaultExport(list, pojoClass, fileName, response, exportParams);
+
+ }
+ public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass,String fileName, HttpServletResponse response){
+ defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName));
+ }
+ public static void exportExcel(List<Map<String, Object>> list, String fileName, HttpServletResponse response){
+ defaultExport(list, fileName, response);
+ }
+
+ private static void defaultExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response, ExportParams exportParams) {
+ Workbook workbook = ExcelExportUtil.exportExcel(exportParams,pojoClass,list);
+ if (workbook != null);
+ downLoadExcel(fileName, response, workbook);
+ }
+
+ private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
+ try {
+ response.setCharacterEncoding("UTF-8");
+ response.setHeader("content-Type", "application/vnd.ms-excel");
+ response.setHeader("Content-Disposition",
+ "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
+ workbook.write(response.getOutputStream());
+ } catch (IOException e) {
+
+ }
+ }
+ private static void defaultExport(List<Map<String, Object>> list, String fileName, HttpServletResponse response) {
+ Workbook workbook = ExcelExportUtil.exportExcel(list, ExcelType.HSSF);
+ if (workbook != null);
+ downLoadExcel(fileName, response, workbook);
+ }
+
+ public static <T> List<T> importExcel(String filePath,Integer titleRows,Integer headerRows, Class<T> pojoClass){
+ if (StringUtils.isBlank(filePath)){
+ return null;
+ }
+ ImportParams params = new ImportParams();
+ params.setTitleRows(titleRows);
+ params.setHeadRows(headerRows);
+ List<T> list = null;
+ try {
+ list = ExcelImportUtil.importExcel(new File(filePath), pojoClass, params);
+ }catch (NoSuchElementException e){
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return list;
+ }
+ public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass){
+ if (file == null){
+ return null;
+ }
+ ImportParams params = new ImportParams();
+ params.setTitleRows(titleRows);
+ params.setHeadRows(headerRows);
+ List<T> list = null;
+ try {
+ list = ExcelImportUtil.importExcel(file.getInputStream(), pojoClass, params);
+ }catch (NoSuchElementException e){
+
+ } catch (Exception e) {
+
+ }
+ return list;
+ }*/
+}
diff --git a/server/services/src/main/java/com/doumee/core/constants/Constants.java b/server/services/src/main/java/com/doumee/core/constants/Constants.java
index 072f1cb..1173448 100644
--- a/server/services/src/main/java/com/doumee/core/constants/Constants.java
+++ b/server/services/src/main/java/com/doumee/core/constants/Constants.java
@@ -28,8 +28,14 @@
public static final String FILE_DIR ="FILE_DIR" ;
public static final String PRIVATE_KEY = "PRIVATE_KEY";
public static String REDIS_DEBUG_STR="test_";
+ public interface MqttTopic{
+ //寮�閿�
+ String openLock = "OPENLOCK";
+ //鍏抽棴閿佸ご
+ String closeLock = "CLOSELOCK";
+ }
- /**
+ /**
* 鏁版嵁鏉冮檺鑼冨洿锛�0鍙湅鑷繁锛�1鍙湅鑷繁鎵�鍦ㄦ牎鍖猴紱2鐪嬪叏閮ㄦ牎鍖猴紱3鐪嬫寚瀹氭牎鍖猴紙澶氶�夛級
*/
public interface PermissionType{
diff --git a/server/services/src/main/java/com/doumee/core/mqtt/config/MqttClientInit.java b/server/services/src/main/java/com/doumee/core/mqtt/config/MqttClientInit.java
new file mode 100644
index 0000000..06cf76f
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/core/mqtt/config/MqttClientInit.java
@@ -0,0 +1,51 @@
+package com.doumee.core.mqtt.config;
+
+import com.doumee.core.mqtt.service.MqttPushCallback;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttTopic;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.stereotype.Component;
+
+public class MqttClientInit {
+ static MqttClient client;
+ private String userName = "doumee";
+ private String passWord = "doumee@168";
+
+ public static synchronized MqttClient getInstance(MqttConfig config,MqttPushCallback callBack){
+ if(client !=null){
+ return client;
+ }
+ try {
+ // host涓轰富鏈哄悕锛宑lientid鍗宠繛鎺QTT鐨勫鎴风ID锛屼竴鑸互鍞竴鏍囪瘑绗﹁〃绀猴紝MemoryPersistence璁剧疆clientid鐨勪繚瀛樺舰寮忥紝榛樿涓轰互鍐呭瓨淇濆瓨
+ client = new org.eclipse.paho.client.mqttv3.MqttClient(config.getHost(), config.getClientid() ,new MemoryPersistence());
+ // MQTT鐨勮繛鎺ヨ缃�
+ MqttConnectOptions options = new MqttConnectOptions();
+ // 璁剧疆鏄惁娓呯┖session,杩欓噷濡傛灉璁剧疆涓篺alse琛ㄧず鏈嶅姟鍣ㄤ細淇濈暀瀹㈡埛绔殑杩炴帴璁板綍锛岃缃负true琛ㄧず姣忔杩炴帴鍒版湇鍔″櫒閮戒互鏂扮殑韬唤杩炴帴
+ options.setCleanSession(false);
+ // 璁剧疆杩炴帴鐨勭敤鎴峰悕
+ options.setUserName(config.getUsername());
+ // 璁剧疆杩炴帴鐨勫瘑鐮�
+ options.setPassword(config.getPassword().toCharArray());
+ // 璁剧疆瓒呮椂鏃堕棿 鍗曚綅涓虹
+ options.setConnectionTimeout(10);
+ // 璁剧疆浼氳瘽蹇冭烦鏃堕棿 鍗曚綅涓虹 鏈嶅姟鍣ㄤ細姣忛殧1.5*20绉掔殑鏃堕棿鍚戝鎴风鍙戦�佷釜娑堟伅鍒ゆ柇瀹㈡埛绔槸鍚﹀湪绾匡紝浣嗚繖涓柟娉曞苟娌℃湁閲嶈繛鐨勬満鍒�
+ options.setKeepAliveInterval(20);
+ // 璁剧疆鍥炶皟
+ client.setCallback(callBack);
+ //璁剧疆鏂紑鍚庨噸鏂拌繛鎺�
+ options.setAutomaticReconnect(true);
+ MqttTopic topic = client.getTopic(config.getClientid()+"_close");
+ //閬楀槺
+ options.setWill(topic, "close".getBytes(), 1, true);
+ client.connect(options);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return client;
+ }
+
+}
diff --git a/server/services/src/main/java/com/doumee/core/mqtt/config/MqttConfig.java b/server/services/src/main/java/com/doumee/core/mqtt/config/MqttConfig.java
new file mode 100644
index 0000000..2188978
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/core/mqtt/config/MqttConfig.java
@@ -0,0 +1,34 @@
+package com.doumee.core.mqtt.config;
+
+import lombok.Data;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.eclipse.paho.client.mqttv3.MqttTopic;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+
+@Component
+@ConfigurationProperties(prefix = "mqtt")
+@Data
+public class MqttConfig {
+ /**
+ *鏈嶅姟鍣ㄥ湴鍧� ip+绔彛锛屽tcp://175.27.187.84:1883
+ */
+ private String host;
+ /**
+ * 瀹㈡埛绔紪鐮�
+ */
+ private String clientid;
+ /**
+ * 鎺堟潈璐﹀彿
+ */
+ private String username ;
+ /**
+ * 鎺堟潈瀵嗙爜
+ */
+ private String password;
+
+}
diff --git a/server/services/src/main/java/com/doumee/core/mqtt/service/MqttPushCallback.java b/server/services/src/main/java/com/doumee/core/mqtt/service/MqttPushCallback.java
new file mode 100644
index 0000000..83eab12
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/core/mqtt/service/MqttPushCallback.java
@@ -0,0 +1,33 @@
+package com.doumee.core.mqtt.service;
+
+import com.doumee.service.business.DeviceService;
+import com.doumee.service.business.DeviceSubcribeService;
+import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
+import org.eclipse.paho.client.mqttv3.MqttCallback;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MqttPushCallback implements MqttCallback {
+ @Autowired
+ private DeviceSubcribeService deviceSubcribeService;
+ //鎺ユ敹娑堟伅鍥炶皟
+ public void connectionLost(Throwable cause) {
+
+ // 杩炴帴涓㈠け鍚庯紝涓�鑸湪杩欓噷闈㈣繘琛岄噸杩�
+ System.out.println("杩炴帴鏂紑锛屽彲浠ュ仛閲嶈繛");
+ }
+
+ public void deliveryComplete(IMqttDeliveryToken token) {
+ System.out.println("deliveryComplete---------" + token.isComplete());
+ }
+
+ public void messageArrived(String topic, MqttMessage message) throws Exception {
+ // subscribe鍚庡緱鍒扮殑娑堟伅浼氭墽琛屽埌杩欓噷闈�
+ System.out.println("鎺ユ敹娑堟伅涓婚 : " + topic);
+ System.out.println("鎺ユ敹娑堟伅Qos : " + message.getQos());
+ System.out.println("鎺ユ敹娑堟伅鍐呭 : " + new String(message.getPayload()));
+ deviceSubcribeService.listener(new String(message.getPayload()),topic);
+ }
+}
diff --git a/server/services/src/main/java/com/doumee/core/mqtt/service/MqttToolService.java b/server/services/src/main/java/com/doumee/core/mqtt/service/MqttToolService.java
new file mode 100644
index 0000000..4dfae17
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/core/mqtt/service/MqttToolService.java
@@ -0,0 +1,55 @@
+package com.doumee.core.mqtt.service;
+
+import com.doumee.core.mqtt.config.MqttClientInit;
+import com.doumee.core.mqtt.config.MqttConfig;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+
+@Service
+public class MqttToolService {
+ @Autowired
+ private MqttConfig config;
+ @Autowired
+ private MqttPushCallback callBack ;
+
+ /**
+ * 璁㈤槄娑堟伅锛屽惎鍔ㄥ姞杞戒竴娆�
+ * @param topics
+ */
+ public void subscribe(String[] topics) {
+ try {
+ //璁㈤槄娑堟伅
+ int[] Qos = new int[topics.length];//0锛氭渶澶氫竴娆� 銆�1锛氭渶灏戜竴娆� 銆�2锛氬彧鏈変竴娆�
+ for (int i = 0; i < Qos.length; i++) {
+ Qos[i] = 1;
+ }
+ MqttClientInit.getInstance(config,callBack).subscribe(topics, Qos);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ /**
+ * 娑堟伅鍙戦��
+ * @param message
+ * @param topic
+ */
+ public void pubMessage(String message,String topic){
+ MqttMessage mess = new MqttMessage();
+ mess.setQos(1);
+ mess.setRetained(true);
+ mess.setPayload(message.getBytes());
+ try {
+ MqttClientInit.getInstance(config,callBack).publish(topic, mess);
+ } catch (Exception e) {
+ //LOGGER.error(e.getLocalizedMessage());
+ }
+ }
+ public static void main(String[] args) {
+ MqttToolService client1 = new MqttToolService();
+ client1.pubMessage("浣犲ソ鍟�","test");
+ }
+
+}
diff --git a/server/services/src/main/java/com/doumee/service/business/DeviceService.java b/server/services/src/main/java/com/doumee/service/business/DeviceService.java
new file mode 100644
index 0000000..8af85d9
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/service/business/DeviceService.java
@@ -0,0 +1,20 @@
+package com.doumee.service.business;
+
+import com.doumee.dao.business.model.Locks;
+
+/**
+ * 涓庣‖浠跺鎺ユ湇鍔�
+ * @author 姹熻箘韫�
+ * @date 2023/10/09 18:06
+ */
+public interface DeviceService {
+
+
+ /**
+ * 涓嬪彂寮�杞﹀紑閿佹寚浠�
+ * @return String
+ */
+ String openLock(Locks locks);
+ void startSubcribe();
+
+}
diff --git a/server/services/src/main/java/com/doumee/service/business/DeviceSubcribeService.java b/server/services/src/main/java/com/doumee/service/business/DeviceSubcribeService.java
new file mode 100644
index 0000000..0c9b079
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/service/business/DeviceSubcribeService.java
@@ -0,0 +1,18 @@
+package com.doumee.service.business;
+
+import com.doumee.dao.business.model.Locks;
+
+/**
+ * 涓庣‖浠跺鎺ユ湇鍔�
+ * @author 姹熻箘韫�
+ * @date 2023/10/09 18:06
+ */
+public interface DeviceSubcribeService {
+
+ /**
+ * 璁惧涓婃姤鏁版嵁锛堜笂鎶ワ級
+ * @param param 涓婃姤鍙傛暟
+ */
+ void listener(String param ,String topic);
+
+}
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
new file mode 100644
index 0000000..64cf5ed
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
@@ -0,0 +1,35 @@
+package com.doumee.service.business.impl;
+
+import com.doumee.core.constants.Constants;
+import com.doumee.core.mqtt.service.MqttPushCallback;
+import com.doumee.core.mqtt.service.MqttToolService;
+import com.doumee.dao.business.model.Locks;
+import com.doumee.service.business.DeviceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * 涓庣‖浠跺鎺ユ湇鍔�
+ * @author 姹熻箘韫�
+ * @date 2023/10/09 18:06
+ */
+@Service
+public class DeviceServiceImpl implements DeviceService {
+
+ @Autowired
+ private MqttToolService mqttToolService;
+
+ @Override
+ @PostConstruct
+ public void startSubcribe() {
+ mqttToolService.subscribe(new String[]{ Constants.MqttTopic.openLock, Constants.MqttTopic.closeLock});
+ }
+ @Override
+ public String openLock(Locks locks) {
+ mqttToolService.pubMessage(locks.getName(), Constants.MqttTopic.openLock);
+ return null;
+ }
+
+}
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/DeviceSubscribeServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/DeviceSubscribeServiceImpl.java
new file mode 100644
index 0000000..6da2187
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/service/business/impl/DeviceSubscribeServiceImpl.java
@@ -0,0 +1,25 @@
+package com.doumee.service.business.impl;
+
+import com.doumee.core.constants.Constants;
+import com.doumee.core.mqtt.service.MqttToolService;
+import com.doumee.dao.business.model.Locks;
+import com.doumee.service.business.DeviceService;
+import com.doumee.service.business.DeviceSubcribeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * 涓庣‖浠跺鎺ユ湇鍔�
+ * @author 姹熻箘韫�
+ * @date 2023/10/09 18:06
+ */
+@Service
+public class DeviceSubscribeServiceImpl implements DeviceSubcribeService {
+
+ @Override
+ public void listener(String param,String topic) {
+ System.out.println("mqtt娑堟伅璁㈤槄==================="+param);
+ }
+}
diff --git a/server/services/src/main/resources/application-dev.yml b/server/services/src/main/resources/application-dev.yml
index 8f6a30b..842d361 100644
--- a/server/services/src/main/resources/application-dev.yml
+++ b/server/services/src/main/resources/application-dev.yml
@@ -51,6 +51,13 @@
notifyUrl: https://dmtest.ahapp.net/martempo_interface/web/api/wxPayNotify
keyPath: D:/work/svn/cert/apiclient_cert.p12
+########################mqtt鐩稿叧閰嶇疆########################
+mqtt:
+ host: tcp://175.27.187.84:1883
+ clientid: doumeetest
+ username: doumee
+ password: doumee@168
+
tencent:
map:
remoteHost: https://apis.map.qq.com
--
Gitblit v1.9.3