From 07ca844b3441a2774a1ca02a952e27e3fe986819 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期三, 19 二月 2025 17:50:44 +0800
Subject: [PATCH] jtt808初始化
---
server/services/src/main/java/com/doumee/core/wx/WxMiniUtilService.java | 6
server/services/src/main/java/com/doumee/service/business/impl/SitesServiceImpl.java | 5
server/services/src/main/java/com/doumee/core/annotation/excel/ExcelDataHandlerAdapter.java | 2
server/services/src/main/java/com/doumee/service/business/impl/BaseParamServiceImpl.java | 2
server/web/src/main/java/com/doumee/api/web/AccountApi.java | 6
server/services/src/main/java/com/doumee/service/business/BikesService.java | 4
server/services/src/main/java/com/doumee/core/annotation/excel/Reflections.java | 294 ++++++++++
server/services/src/main/java/com/doumee/service/business/impl/BikesServiceImpl.java | 138 ++++
server/services/src/main/java/com/doumee/core/annotation/excel/ExcelImporter.java | 394 ++++++++++++++
/dev/null | 88 ---
server/services/src/main/java/com/doumee/service/business/impl/DeviceSubscribeServiceImpl.java | 2
server/platform/src/main/java/com/doumee/task/ScheduleTool.java | 4
server/pom.xml | 5
server/services/src/main/java/com/doumee/dao/business/model/Bikes.java | 3
server/services/src/main/java/com/doumee/core/constants/Constants.java | 2
server/services/src/main/java/com/doumee/dao/business/vo/BikesImportVO.java | 29 +
server/services/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java | 625 ++++-----------------
server/services/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java | 2
server/services/src/main/java/com/doumee/core/annotation/excel/ExcelColumn.java | 26
server/platform/src/main/java/com/doumee/api/business/BikesController.java | 15
server/services/src/main/java/com/doumee/service/business/impl/PricingParamServiceImpl.java | 2
server/services/src/main/java/com/doumee/service/business/impl/LocksServiceImpl.java | 6
22 files changed, 1,054 insertions(+), 606 deletions(-)
diff --git a/server/platform/src/main/java/com/doumee/api/business/BikesController.java b/server/platform/src/main/java/com/doumee/api/business/BikesController.java
index 7e07ac9..bcb848f 100644
--- a/server/platform/src/main/java/com/doumee/api/business/BikesController.java
+++ b/server/platform/src/main/java/com/doumee/api/business/BikesController.java
@@ -8,13 +8,14 @@
import com.doumee.core.model.PageWrap;
import com.doumee.dao.business.model.Bikes;
import com.doumee.service.business.BikesService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -86,7 +87,15 @@
public void exportExcel (@RequestBody PageWrap<Bikes> pageWrap, HttpServletResponse response) {
ExcelExporter.build(Bikes.class).export(bikesService.findPage(pageWrap).getRecords(), "鑷杞︿俊鎭〃", response);
}
-
+ @ApiOperation(value = "鐢佃溅鎵归噺瀵煎叆" ,notes = "淇濆崟鐢宠")
+ @PostMapping("/importExcel")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "file", value = "file", required = true, paramType = "query", dataType = "file", dataTypeClass = File.class),
+ })
+ @RequiresPermissions("business:member:create")
+ public ApiResponse<String> importExcel (@ApiParam(value = "file") MultipartFile file) {
+ return ApiResponse.success(bikesService.importBatch(file));
+ }
@ApiOperation("鏍规嵁ID鏌ヨ")
@GetMapping("/{id}")
@RequiresPermissions("business:bikes:query")
diff --git a/server/platform/src/main/java/com/doumee/task/ScheduleTool.java b/server/platform/src/main/java/com/doumee/task/ScheduleTool.java
index a7e0340..b6b5774 100644
--- a/server/platform/src/main/java/com/doumee/task/ScheduleTool.java
+++ b/server/platform/src/main/java/com/doumee/task/ScheduleTool.java
@@ -121,7 +121,7 @@
/**
* 鏇存柊寰俊 ACCESS_TOKEN
*/
- @Scheduled(fixedDelay = 1000L * 60L * 90L)
+// @Scheduled(fixedDelay = 1000L * 60L * 90L)
public void updAccessToken(){
DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
ThreadContext.bind(manager);
@@ -134,7 +134,7 @@
}
//鐢熸垚寰俊token
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appId+"&secret="+appSecret;
- String response = HttpsUtil.doGet(url,null);
+ String response = HttpsUtil.get(url,false);
JSONObject json = JSONObject.parseObject(response);
SystemDictData systemDictData = systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.ACCESS_TOKEN);
if(!Objects.isNull(systemDictData)){
diff --git a/server/pom.xml b/server/pom.xml
index a733ab1..ead7f56 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -30,7 +30,7 @@
<swagger.bootstrap-ui.version>1.9.6</swagger.bootstrap-ui.version>
<fastjson.version>1.2.70</fastjson.version>
<druid.version>1.2.0</druid.version>
- <mybatis.plus.version>3.4.2</mybatis.plus.version>
+ <mybatis.plus.version>3.5.7</mybatis.plus.version>
<apache.shiro.version>1.9.1</apache.shiro.version>
<oshi.version>5.7.0</oshi.version>
<jna.version>5.7.0</jna.version>
@@ -90,11 +90,12 @@
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
- <version>1.3.0</version>
+ <!-- <version>1.3.0</version>-->
<!--浣跨敤spring boot2鏁村悎 pagehelper-spring-boot-starter蹇呴』鎺掗櫎涓�涓嬩緷璧�
鍥犱负pagehelper-spring-boot-starter涔熷凡缁忓湪pom渚濊禆浜唌ybatis涓巑ybatis-spring
鎵�浠ヤ細涓巑ybatis-plus-boot-starter涓殑mybatis涓巑ybatis-spring鍙戠敓鍐茬獊
-->
+ <version>2.1.0</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
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 b7c7ef8..c0de11a 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,18 +8,25 @@
/**
* 鏍囪涓篍xcel鍒�
* @author Eva.Caesar Liu
- * @date 2022/04/18 18:12
+ * @date 2023/02/14 11:14
*/
@Inherited
-@Target(ElementType.FIELD)
+//@Target(ElementType.FIELD)
+@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface ExcelColumn {
-
+ /**
+ * 瀵煎嚭瀛楁鍚嶏紙榛樿璋冪敤褰撳墠瀛楁鐨勨�済et鈥濇柟娉曪紝濡傛寚瀹氬鍑哄瓧娈典负瀵硅薄锛岃濉啓鈥滃璞″悕.瀵硅薄灞炴�р�濓紝渚嬶細鈥渁rea.name鈥濄�佲�渙ffice.name鈥濓級
+ */
+ String value() default "";
+ /**
+ * 瀛楁绫诲瀷锛�0锛氬鍑哄鍏ワ紱1锛氫粎瀵煎嚭锛�2锛氫粎瀵煎叆锛�
+ */
+ int type() default 0;
/**
* 鍒楀悕
*/
String name();
-
/**
* 鍒楀锛堝崟浣嶄负瀛楃锛夛紝-1鑷姩璁$畻
@@ -34,7 +41,7 @@
/**
* 瀵归綈鏂瑰紡
*/
- HorizontalAlignment align() default HorizontalAlignment.LEFT;
+ HorizontalAlignment align() default HorizontalAlignment.LEFT;
/**
* 鍒楄儗鏅壊
@@ -96,4 +103,13 @@
*/
String[] args() default {};
+ /**
+ * 鍙嶅皠绫诲瀷
+ */
+ Class<?> fieldType() default Class.class;
+
+ /**
+ * 瀛楁褰掑睘缁勶紙鏍规嵁鍒嗙粍瀵煎嚭瀵煎叆锛�
+ */
+ int[] groups() default {};
}
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 a3c721f..33a153b 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/04/18 18:12
+ * @date 2023/02/14 11:14
*/
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 cfeb782..d2fac34 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,40 +4,25 @@
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/04/18 18:12
+ * @date 2023/02/14 11:14
*/
@Data
public class ExcelExporter<T> {
@@ -48,13 +33,6 @@
private ExcelExporter(){}
-
-
- private final static Logger log = LoggerFactory.getLogger(ExcelExporter.class);
-
- private final static String EXCEL2003 = "xls";
- private final static String EXCEL2007 = "xlsx";
-
/**
* 鏋勯�犲櫒
* @param modelClass 瀹炰綋Class瀵硅薄
@@ -63,6 +41,75 @@
ExcelExporter<T> excelExporter = new ExcelExporter<>();
excelExporter.setModelClass(modelClass);
return excelExporter;
+ }
+ /**
+ * 瀵煎嚭鍒版寚瀹氳緭鍑烘祦
+ * @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);
+ 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(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);
+
+ }
+ }
+
+
+ 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();
+ }
+ }
+ }
}
/**
@@ -75,8 +122,6 @@
SXSSFWorkbook sxssfWorkbook;
try {
sxssfWorkbook = new SXSSFWorkbook();
-
- CellStyle style = sxssfWorkbook.createCellStyle();
Sheet sheet = sxssfWorkbook.createSheet(sheetName);
// 鍒涘缓鍒楀ご
sheet.createFreezePane(0, 1);
@@ -93,7 +138,7 @@
sheet.setColumnWidth(columnIndex, column.columnConfig.width() * 2 * 256);
}
// 璁剧疆鍒楀ご鍗曞厓鏍�
- configHeaderCell(sxssfWorkbook, cell, column.columnConfig,style);
+ configHeaderCell(sxssfWorkbook, cell, column.columnConfig);
}
// 鍒涘缓鏁版嵁璁板綍
for (int rowIndex = 0; rowIndex < data.size(); rowIndex++) {
@@ -102,8 +147,10 @@
ColumnInfo column = columns.get(columnIndex);
Cell cell = row.createCell(columnIndex);
cell.setCellValue(getCellData(column, data.get(rowIndex)));
+
// 璁剧疆鏁版嵁鍗曞厓鏍�
- configDataCell(sxssfWorkbook, cell, column.columnConfig,style);
+ configDataCell(sxssfWorkbook, cell, column.columnConfig);
+
}
}
sxssfWorkbook.write(os);
@@ -140,26 +187,6 @@
throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
}
}
-
- /**
- * 瀵煎嚭鑷冲搷搴旀祦
- * @param data 鏁版嵁
- * @param fileName Excel鏂囦欢鍚�
- * @param response HttpServletResponse瀵硅薄
- */
- 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 鏁版嵁
@@ -179,74 +206,48 @@
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();
- }
- }
- }
+ /**
+ * 瀵煎嚭鑷冲搷搴旀祦
+ * @param data 鏁版嵁
+ * @param fileName Excel鏂囦欢鍚�
+ * @param response HttpServletResponse瀵硅薄
+ */
+ 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);
+ }
+
+ /**O
+ * 鑾峰彇鍒楅泦鍚�
+ */
+ private List<ColumnInfo> getColumns () {
+ Map<Integer, ColumnInfo> sortedFields = new TreeMap<>();
+ Field[] fields = modelClass.getDeclaredFields();
+ int index = 0;
+ for (Field field : fields) {
+ ExcelColumn excelColumn = field.getAnnotation(ExcelColumn.class);
+ if (excelColumn == null) {
+ continue;
+ }
+ if (sortedFields.get(excelColumn.index()) != null) {
+ throw new AnnotationConfigurationException("Excel column contains the same index.");
+ }
+ sortedFields.put(excelColumn.index() == -1 ? index : excelColumn.index(), new ColumnInfo(excelColumn, field));
+ index++;
+ }
+ return new ArrayList<>(sortedFields.values());
+ }
+
/**
* 閰嶇疆鏁版嵁鍗曞厓鏍�
*/
@@ -272,6 +273,25 @@
style.setWrapText(true);
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());
+ // 瀛椾綋
+ Font font = workbook.createFont();
+ font.setFontHeightInPoints(columnConfig.fontSize());
+ style.setFont(font);
+ // 璁剧疆杈规
+ configCellBorder(style);
+ cell.setCellStyle(style);
+ }
/**
* 閰嶇疆鍒楀ご鍗曞厓鏍�
*/
@@ -281,11 +301,10 @@
style.setVerticalAlignment(VerticalAlignment.CENTER);
// 璁剧疆鑳屾櫙
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
- style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
+ style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
// 瀛椾綋
Font font = workbook.createFont();
- font.setFontHeightInPoints((short)24);
- font.setBold(true);
+ font.setFontHeightInPoints((short)18);
style.setFont(font);
// 璁剧疆杈规
configCellBorder(style);
@@ -304,96 +323,6 @@
// 瀛椾綋
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);
- }
- /**
- * 鑾峰彇鍒楅泦鍚�
- */
- private List<ColumnInfo> getColumns () {
- Map<Integer, ColumnInfo> sortedFields = new TreeMap<>();
- Field[] fields = modelClass.getDeclaredFields();
- int index = 0;
- for (Field field : fields) {
- ExcelColumn excelColumn = field.getAnnotation(ExcelColumn.class);
- if (excelColumn == null) {
- continue;
- }
- if (sortedFields.get(excelColumn.index()) != null) {
- throw new AnnotationConfigurationException("Excel column contains the same index.");
- }
- sortedFields.put(excelColumn.index() == -1 ? index : excelColumn.index(), new ColumnInfo(excelColumn, field));
- index++;
- }
- 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) {
- // 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);
- cell.setCellStyle(style);
- }
-
- /**
- * 閰嶇疆鍒楀ご鍗曞厓鏍�
- */
- private void configHeaderCell (SXSSFWorkbook workbook, Cell cell, ExcelColumn columnConfig,CellStyle style) {
- // CellStyle style = workbook.createCellStyle();
- style.setAlignment(columnConfig.align());
- style.setVerticalAlignment(VerticalAlignment.CENTER);
- // 璁剧疆鑳屾櫙
- style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
- style.setFillForegroundColor(columnConfig.backgroundColor().getIndex());
- // 瀛椾綋
- Font font = workbook.createFont();
- font.setFontHeightInPoints(columnConfig.fontSize());
style.setFont(font);
// 璁剧疆杈规
configCellBorder(style);
@@ -471,289 +400,5 @@
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/ExcelImporter.java b/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelImporter.java
new file mode 100644
index 0000000..f8f067c
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/core/annotation/excel/ExcelImporter.java
@@ -0,0 +1,394 @@
+package com.doumee.core.annotation.excel;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.*;
+
+/**
+ * 瀵煎叆Excel鏂囦欢锛堟敮鎸佲�淴LS鈥濆拰鈥淴LSX鈥濇牸寮忥級
+ */
+public class ExcelImporter {
+
+ private static Logger log = LoggerFactory.getLogger(ExcelImporter.class);
+
+ /**
+ * 宸ヤ綔钖勫璞�
+ */
+ private Workbook wb;
+
+ /**
+ * 宸ヤ綔琛ㄥ璞�
+ */
+ private Sheet sheet;
+
+ /**
+ * 鏍囬琛屽彿
+ */
+ private int headerNum;
+ /**
+ * 鏍囬琛屽彿
+ */
+ private CellType changeType;
+
+ /**
+ * 鏋勯�犲嚱鏁�
+ * @param--path 瀵煎叆鏂囦欢锛岃鍙栫涓�涓伐浣滆〃
+ * @param headerNum 鏍囬琛屽彿锛屾暟鎹鍙�=鏍囬琛屽彿+1
+ * @throws InvalidFormatException
+ * @throws IOException
+ */
+ public ExcelImporter(String fileName, int headerNum)
+ throws InvalidFormatException, IOException {
+ this(new File(fileName), headerNum);
+ }
+
+ /**
+ * 鏋勯�犲嚱鏁�
+ * @param--path 瀵煎叆鏂囦欢瀵硅薄锛岃鍙栫涓�涓伐浣滆〃
+ * @param headerNum 鏍囬琛屽彿锛屾暟鎹鍙�=鏍囬琛屽彿+1 (eg: 1)
+ * @throws InvalidFormatException
+ * @throws IOException
+ */
+ public ExcelImporter(File file, int headerNum)
+ throws InvalidFormatException, IOException {
+ this(file, headerNum, 0);
+ }
+
+ /**
+ * 鏋勯�犲嚱鏁�
+ * @param--path 瀵煎叆鏂囦欢
+ * @param headerNum 鏍囬琛屽彿锛屾暟鎹鍙�=鏍囬琛屽彿+1
+ * @param sheetIndex 宸ヤ綔琛ㄧ紪鍙�
+ * @throws InvalidFormatException
+ * @throws IOException
+ */
+ public ExcelImporter(String fileName, int headerNum, int sheetIndex)
+ throws InvalidFormatException, IOException {
+ this(new File(fileName), headerNum, sheetIndex);
+ }
+
+ /**
+ * 鏋勯�犲嚱鏁�
+ * @param--path 瀵煎叆鏂囦欢瀵硅薄
+ * @param headerNum 鏍囬琛屽彿锛屾暟鎹鍙�=鏍囬琛屽彿+1
+ * @param sheetIndex 宸ヤ綔琛ㄧ紪鍙�
+ * @throws InvalidFormatException
+ * @throws IOException
+ */
+ public ExcelImporter(File file, int headerNum, int sheetIndex)
+ throws InvalidFormatException, IOException {
+ this(file.getName(), new FileInputStream(file), headerNum, sheetIndex);
+ }
+
+ /**
+ * 鏋勯�犲嚱鏁� (閲嶈)
+ * @param--file 瀵煎叆鏂囦欢瀵硅薄
+ * @param headerNum 鏍囬琛屽彿锛屾暟鎹鍙�=鏍囬琛屽彿+1
+ * @param sheetIndex 宸ヤ綔琛ㄧ紪鍙�
+ * @throws InvalidFormatException
+ * @throws IOException
+ */
+ public ExcelImporter(MultipartFile multipartFile, int headerNum, int sheetIndex)
+ throws InvalidFormatException, IOException {
+ this(multipartFile.getOriginalFilename(), multipartFile.getInputStream(), headerNum, sheetIndex);
+ }
+ /**
+ * 鏋勯�犲嚱鏁� (閲嶈)
+ * @param--file 瀵煎叆鏂囦欢瀵硅薄
+ * @param headerNum 鏍囬琛屽彿锛屾暟鎹鍙�=鏍囬琛屽彿+1
+ * @param sheetIndex 宸ヤ綔琛ㄧ紪鍙�
+ * @throws InvalidFormatException
+ * @throws IOException
+ */
+ public ExcelImporter(MultipartFile multipartFile, int headerNum, int sheetIndex, CellType cellType)
+ throws InvalidFormatException, IOException {
+ this(multipartFile.getOriginalFilename(), multipartFile.getInputStream(), headerNum, sheetIndex,cellType);
+ }
+
+ /**
+ * 鏋勯�犲嚱鏁� 锛堬級
+ * @param--path 瀵煎叆鏂囦欢瀵硅薄
+ * @param headerNum 鏍囬琛屽彿锛屾暟鎹鍙�=鏍囬琛屽彿+1
+ * @param sheetIndex 宸ヤ綔琛ㄧ紪鍙� (eg: 0)
+ * @throws InvalidFormatException
+ * @throws IOException
+ */
+ public ExcelImporter(String fileName, InputStream in, int headerNum, int sheetIndex)
+ throws InvalidFormatException, IOException {
+ if (StringUtils.isBlank(fileName)){
+ throw new RuntimeException("瀵煎叆鏂囨。涓虹┖!");
+ }else if(fileName.toLowerCase().endsWith("xls")){
+ this.wb = new HSSFWorkbook(in);
+ }else if(fileName.toLowerCase().endsWith("xlsx")){
+ this.wb = new XSSFWorkbook(in);
+ }else{
+ throw new RuntimeException("鏂囨。鏍煎紡涓嶆纭�!");
+ }
+ if (this.wb.getNumberOfSheets()<sheetIndex){
+ throw new RuntimeException("鏂囨。涓病鏈夊伐浣滆〃!");
+ }
+ this.sheet = this.wb.getSheetAt(sheetIndex);
+ this.headerNum = headerNum;
+ log.debug("Initialize success.");
+ }
+ public ExcelImporter(String fileName, InputStream in, int headerNum, int sheetIndex,CellType cellType)
+ throws InvalidFormatException, IOException {
+ if (StringUtils.isBlank(fileName)){
+ throw new RuntimeException("瀵煎叆鏂囨。涓虹┖!");
+ }else if(fileName.toLowerCase().endsWith("xls")){
+ this.wb = new HSSFWorkbook(in);
+ }else if(fileName.toLowerCase().endsWith("xlsx")){
+ this.wb = new XSSFWorkbook(in);
+ }else{
+ throw new RuntimeException("鏂囨。鏍煎紡涓嶆纭�!");
+ }
+ if (this.wb.getNumberOfSheets()<sheetIndex){
+ throw new RuntimeException("鏂囨。涓病鏈夊伐浣滆〃!");
+ }
+ this.sheet = this.wb.getSheetAt(sheetIndex);
+ this.headerNum = headerNum;
+ this.changeType = cellType;
+ log.debug("Initialize success.");
+ }
+
+
+
+ /**
+ * 鑾峰彇琛屽璞�
+ * @param rownum
+ * @return
+ */
+ public Row getRow(int rownum){
+ return this.sheet.getRow(rownum);
+ }
+
+ /**
+ * 鑾峰彇鏁版嵁琛屽彿
+ * @return
+ */
+ public int getDataRowNum(){
+ return headerNum+1;
+ }
+
+ /**
+ * 鑾峰彇鏈�鍚庝竴涓暟鎹鍙�
+ * @return
+ */
+ public int getLastDataRowNum(){
+ return this.sheet.getLastRowNum()+headerNum;
+ }
+
+ /**
+ * 鑾峰彇鏈�鍚庝竴涓垪鍙�
+ * @return
+ */
+ public int getLastCellNum(){
+ return this.getRow(headerNum).getLastCellNum();
+ }
+
+ /**
+ * 鑾峰彇鍗曞厓鏍煎��
+ * @param row 鑾峰彇鐨勮
+ * @param column 鑾峰彇鍗曞厓鏍煎垪鍙�
+ * @return 鍗曞厓鏍煎��
+ */
+ public Object getCellValue(Row row, int column){
+ Object val = "";
+ try{
+ Cell cell = row.getCell(column);
+ if (cell != null){
+ if (cell.getCellType() == CellType.NUMERIC){
+ cell.setCellType(CellType.STRING); // 纭繚鍗曞厓鏍肩被鍨嬩负瀛楃涓�
+ val = cell.getStringCellValue();
+ }else if (cell.getCellType() == CellType.STRING){
+ val = cell.getStringCellValue();
+ }else if (cell.getCellType() == CellType.FORMULA){
+ val = cell.getCellFormula();
+ }else if (cell.getCellType() == CellType.BOOLEAN){
+ val = cell.getBooleanCellValue();
+ }else if (cell.getCellType() == CellType.ERROR){
+ val = cell.getErrorCellValue();
+ }
+ }
+ }catch (Exception e) {
+ return val;
+ }
+ return val;
+ }
+
+ /**
+ * 鑾峰彇瀵煎叆鏁版嵁鍒楄〃
+ * @param cls 瀵煎叆瀵硅薄绫诲瀷
+ * @param groups 瀵煎叆鍒嗙粍 鍙负绌�
+ */
+ public <E> List<E> getDataList(Class<E> cls, int... groups) throws InstantiationException, IllegalAccessException{
+ List<Object[]> annotationList = new ArrayList<>();
+ // Get annotation field
+ Field[] fs = cls.getDeclaredFields();
+ for (Field f : fs){
+ ExcelColumn ef = f.getAnnotation(ExcelColumn.class);
+ if (ef != null && (ef.type()==0 || ef.type()==2)){
+ if (groups!=null && groups.length>0){
+ boolean inGroup = false;
+ for (int g : groups){
+ if (inGroup){
+ break;
+ }
+ for (int efg : ef.groups()){
+ if (g == efg){
+ inGroup = true;
+ annotationList.add(new Object[]{ef, f});
+ break;
+ }
+ }
+ }
+ }else{
+ annotationList.add(new Object[]{ef, f});
+ }
+ }
+ }
+ // Get annotation method
+ Method[] ms = cls.getDeclaredMethods();
+ for (Method m : ms){
+ ExcelColumn ef = m.getAnnotation(ExcelColumn.class);
+ if (ef != null && (ef.type()==0 || ef.type()==2)){
+ if (groups!=null && groups.length>0){
+ boolean inGroup = false;
+ for (int g : groups){
+ if (inGroup){
+ break;
+ }
+ for (int efg : ef.groups()){
+ if (g == efg){
+ inGroup = true;
+ annotationList.add(new Object[]{ef, m});
+ break;
+ }
+ }
+ }
+ }else{
+ annotationList.add(new Object[]{ef, m});
+ }
+ }
+ }
+ // Field sorting
+ Collections.sort(annotationList, (o1, o2) -> {
+ int index1 =((ExcelColumn)o1[0]).index(), index2=((ExcelColumn)o2[0]).index();
+ if(index1 == -1){
+ index1 = annotationList.size()+99999;
+ }
+ if(index2 == -1){
+ index2 = annotationList.size()+99999;
+ }
+ return new Integer(index1).compareTo(new Integer(index2));
+ });
+ //log.debug("Import column count:"+annotationList.size());
+ // Get excel data
+ List<E> dataList = new ArrayList<>();
+ System.out.println("璧峰鏁版嵁琛�:"+getDataRowNum());
+ System.out.println("缁撴潫鏁版嵁琛�:"+getLastDataRowNum());
+ for (int i = this.getDataRowNum(); i <= this.getLastDataRowNum(); i++) {
+ E e = (E)cls.newInstance();
+ int column = 0;
+ Row row = this.getRow(i);
+ if (Objects.isNull(row)){
+ continue;
+ }
+ StringBuilder sb = new StringBuilder();
+ for (Object[] os : annotationList){
+ Object val = this.getCellValue(row, column++);
+ if (val != null){
+ ExcelColumn ef = (ExcelColumn)os[0];
+ // Get param type and type cast
+ Class<?> valType = Class.class;
+ if (os[1] instanceof Field){
+ valType = ((Field)os[1]).getType();
+ }else if(os[1] instanceof Method){
+ Method method = ((Method)os[1]);
+ if ("get".equals(method.getName().substring(0, 3))){
+ valType = method.getReturnType();
+ }else if("set".equals(method.getName().substring(0, 3))){
+ valType = ((Method)os[1]).getParameterTypes()[0];
+ }
+ }
+ //log.debug("Import value type: ["+i+","+column+"] " + valType);
+ try {
+ if (valType == String.class){
+ String s = String.valueOf(val.toString());
+ if(StringUtils.endsWith(s, ".0")){
+ val = StringUtils.substringBefore(s, ".0");
+ }else{
+ val = String.valueOf(val.toString()).trim();
+ }
+ }
+ else if (valType == Integer.class){
+ val = Double.valueOf(val.toString()).intValue();
+ }else if (valType == Long.class){
+ val = Double.valueOf(val.toString()).longValue();
+ }else if (valType == Double.class){
+ val = Double.valueOf(val.toString());
+ }else if (valType == Float.class){
+ val = Float.valueOf(val.toString());
+ }else if (valType == Date.class){
+ val = DateUtil.getJavaDate((Double)val);
+ }else{
+ if (ef.fieldType() != Class.class){
+ val = ef.fieldType().getMethod("getValue", String.class).invoke(null, val.toString());
+ }else{
+ val = Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(),
+ "fieldtype."+valType.getSimpleName()+"Type")).getMethod("getValue", String.class).invoke(null, val.toString());
+ }
+ }
+ } catch (Exception ex) {
+ log.info("Get cell value ["+i+","+column+"] error: " + ex.toString());
+ val = null;
+ }
+ // set entity value
+ if (os[1] instanceof Field){
+ Reflections.invokeSetter(e, ((Field)os[1]).getName(), val);
+ }else if (os[1] instanceof Method){
+ String mthodName = ((Method)os[1]).getName();
+ if ("get".equals(mthodName.substring(0, 3))){
+ mthodName = "set"+StringUtils.substringAfter(mthodName, "get");
+ }
+ Reflections.invokeMethod(e, mthodName, new Class[] {valType}, new Object[] {val});
+ }
+ }
+ sb.append(val+", ");
+ }
+ dataList.add(e);
+ log.debug("Read success: ["+i+"] "+sb.toString());
+ }
+ return dataList;
+ }
+
+ /**
+ * 鍏抽棴娴� 娓呯悊涓存椂鏂囦欢
+ */
+ public void dispose(){
+ try {
+ if(wb!=null){
+ wb.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+
+ }
+
+
+}
\ No newline at end of file
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
deleted file mode 100644
index eeac8bc..0000000
--- a/server/services/src/main/java/com/doumee/core/annotation/excel/ExportExcelUtils.java
+++ /dev/null
@@ -1,88 +0,0 @@
-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/annotation/excel/Reflections.java b/server/services/src/main/java/com/doumee/core/annotation/excel/Reflections.java
new file mode 100644
index 0000000..044dc97
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/core/annotation/excel/Reflections.java
@@ -0,0 +1,294 @@
+package com.doumee.core.annotation.excel;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.Validate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.Assert;
+
+import java.lang.reflect.*;
+
+/**
+ * 鍙嶅皠宸ュ叿绫�.
+ * 鎻愪緵璋冪敤getter/setter鏂规硶, 璁块棶绉佹湁鍙橀噺, 璋冪敤绉佹湁鏂规硶, 鑾峰彇娉涘瀷绫诲瀷Class, 琚獳OP杩囩殑鐪熷疄绫荤瓑宸ュ叿鍑芥暟.
+ */
+@SuppressWarnings("rawtypes")
+public class Reflections {
+
+ private static final String SETTER_PREFIX = "set";
+
+ private static final String GETTER_PREFIX = "get";
+
+ private static final String CGLIB_CLASS_SEPARATOR = "$$";
+
+ private static Logger logger = LoggerFactory.getLogger(Reflections.class);
+
+ /**
+ * 璋冪敤Getter鏂规硶.
+ * 鏀寔澶氱骇锛屽锛氬璞″悕.瀵硅薄鍚�.鏂规硶
+ */
+ public static Object invokeGetter(Object obj, String propertyName) {
+ Object object = obj;
+ for (String name : StringUtils.split(propertyName, ".")){
+ String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
+ object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
+ }
+ return object;
+ }
+
+ /**
+ * 璋冪敤Setter鏂规硶, 浠呭尮閰嶆柟娉曞悕銆�
+ * 鏀寔澶氱骇锛屽锛氬璞″悕.瀵硅薄鍚�.鏂规硶
+ */
+ public static void invokeSetter(Object obj, String propertyName, Object value) {
+ Object object = obj;
+ String[] names = StringUtils.split(propertyName, ".");
+ for (int i=0; i<names.length; i++){
+ if(i<names.length-1){
+ String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
+ object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
+ }else{
+ String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
+ invokeMethodByName(object, setterMethodName, new Object[] { value });
+ }
+ }
+ }
+
+ /**
+ * 鐩存帴璇诲彇瀵硅薄灞炴�у��, 鏃犺private/protected淇グ绗�, 涓嶇粡杩噂etter鍑芥暟.
+ */
+ public static Object getFieldValue(final Object obj, final String fieldName) {
+ Field field = getAccessibleField(obj, fieldName);
+
+ if (field == null) {
+ throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
+ }
+
+ Object result = null;
+ try {
+ result = field.get(obj);
+ } catch (IllegalAccessException e) {
+ logger.error("闈炴硶璁块棶鐨勫紓甯竰}", e.getMessage());
+ }
+ return result;
+ }
+
+ /**
+ * 鐩存帴璁剧疆瀵硅薄灞炴�у��, 鏃犺private/protected淇グ绗�, 涓嶇粡杩噑etter鍑芥暟.
+ */
+ public static void setFieldValue(final Object obj, final String fieldName, final Object value) {
+ Field field = getAccessibleField(obj, fieldName);
+
+ if (field == null) {
+ throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
+ }
+
+ try {
+ field.set(obj, value);
+ } catch (IllegalAccessException e) {
+ logger.error("闈炴硶璁块棶鐨勫紓甯�:{}", e.getMessage());
+ }
+ }
+
+ /**
+ * 鐩存帴璋冪敤瀵硅薄鏂规硶, 鏃犺private/protected淇グ绗�.
+ * 鐢ㄤ簬涓�娆℃�ц皟鐢ㄧ殑鎯呭喌锛屽惁鍒欏簲浣跨敤getAccessibleMethod()鍑芥暟鑾峰緱Method鍚庡弽澶嶈皟鐢�.
+ * 鍚屾椂鍖归厤鏂规硶鍚�+鍙傛暟绫诲瀷锛�
+ */
+ public static Object invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes,
+ final Object[] args) {
+ Method method = getAccessibleMethod(obj, methodName, parameterTypes);
+ if (method == null) {
+ throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]");
+ }
+
+ try {
+ return method.invoke(obj, args);
+ } catch (Exception e) {
+ throw convertReflectionExceptionToUnchecked(e);
+ }
+ }
+
+ /**
+ * 鐩存帴璋冪敤瀵硅薄鏂规硶, 鏃犺private/protected淇グ绗︼紝
+ * 鐢ㄤ簬涓�娆℃�ц皟鐢ㄧ殑鎯呭喌锛屽惁鍒欏簲浣跨敤getAccessibleMethodByName()鍑芥暟鑾峰緱Method鍚庡弽澶嶈皟鐢�.
+ * 鍙尮閰嶅嚱鏁板悕锛屽鏋滄湁澶氫釜鍚屽悕鍑芥暟璋冪敤绗竴涓��
+ */
+ public static Object invokeMethodByName(final Object obj, final String methodName, final Object[] args) {
+ Method method = getAccessibleMethodByName(obj, methodName);
+ if (method == null) {
+ throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]");
+ }
+
+ try {
+ return method.invoke(obj, args);
+ } catch (Exception e) {
+ throw convertReflectionExceptionToUnchecked(e);
+ }
+ }
+
+ /**
+ * 寰幆鍚戜笂杞瀷, 鑾峰彇瀵硅薄鐨凞eclaredField, 骞跺己鍒惰缃负鍙闂�.
+ *
+ * 濡傚悜涓婅浆鍨嬪埌Object浠嶆棤娉曟壘鍒�, 杩斿洖null.
+ */
+ public static Field getAccessibleField(final Object obj, final String fieldName) {
+ Validate.notNull(obj, "object can't be null");
+ Validate.notBlank(fieldName, "fieldName can't be blank");
+ for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
+ try {
+ Field field = superClass.getDeclaredField(fieldName);
+ makeAccessible(field);
+ return field;
+ } catch (NoSuchFieldException e) {//NOSONAR
+ // Field涓嶅湪褰撳墠绫诲畾涔�,缁х画鍚戜笂杞瀷
+ continue;// new add
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 寰幆鍚戜笂杞瀷, 鑾峰彇瀵硅薄鐨凞eclaredMethod,骞跺己鍒惰缃负鍙闂�.
+ * 濡傚悜涓婅浆鍨嬪埌Object浠嶆棤娉曟壘鍒�, 杩斿洖null.
+ * 鍖归厤鍑芥暟鍚�+鍙傛暟绫诲瀷銆�
+ *
+ * 鐢ㄤ簬鏂规硶闇�瑕佽澶氭璋冪敤鐨勬儏鍐�. 鍏堜娇鐢ㄦ湰鍑芥暟鍏堝彇寰桵ethod,鐒跺悗璋冪敤Method.invoke(Object obj, Object... args)
+ */
+ public static Method getAccessibleMethod(final Object obj, final String methodName,
+ final Class<?>... parameterTypes) {
+ Validate.notNull(obj, "object can't be null");
+ Validate.notBlank(methodName, "methodName can't be blank");
+
+ for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
+ try {
+ Method method = searchType.getDeclaredMethod(methodName, parameterTypes);
+ makeAccessible(method);
+ return method;
+ } catch (NoSuchMethodException e) {
+ // Method涓嶅湪褰撳墠绫诲畾涔�,缁х画鍚戜笂杞瀷
+ continue;// new add
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 寰幆鍚戜笂杞瀷, 鑾峰彇瀵硅薄鐨凞eclaredMethod,骞跺己鍒惰缃负鍙闂�.
+ * 濡傚悜涓婅浆鍨嬪埌Object浠嶆棤娉曟壘鍒�, 杩斿洖null.
+ * 鍙尮閰嶅嚱鏁板悕銆�
+ *
+ * 鐢ㄤ簬鏂规硶闇�瑕佽澶氭璋冪敤鐨勬儏鍐�. 鍏堜娇鐢ㄦ湰鍑芥暟鍏堝彇寰桵ethod,鐒跺悗璋冪敤Method.invoke(Object obj, Object... args)
+ */
+ public static Method getAccessibleMethodByName(final Object obj, final String methodName) {
+ Validate.notNull(obj, "object can't be null");
+ Validate.notBlank(methodName, "methodName can't be blank");
+
+ for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
+ Method[] methods = searchType.getDeclaredMethods();
+ for (Method method : methods) {
+ if (method.getName().equals(methodName)) {
+ makeAccessible(method);
+ return method;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 鏀瑰彉private/protected鐨勬柟娉曚负public锛屽敖閲忎笉璋冪敤瀹為檯鏀瑰姩鐨勮鍙ワ紝閬垮厤JDK鐨凷ecurityManager鎶辨�ㄣ��
+ */
+ public static void makeAccessible(Method method) {
+ if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers()))
+ && !method.isAccessible()) {
+ method.setAccessible(true);
+ }
+ }
+
+ /**
+ * 鏀瑰彉private/protected鐨勬垚鍛樺彉閲忎负public锛屽敖閲忎笉璋冪敤瀹為檯鏀瑰姩鐨勮鍙ワ紝閬垮厤JDK鐨凷ecurityManager鎶辨�ㄣ��
+ */
+ public static void makeAccessible(Field field) {
+ if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) || Modifier
+ .isFinal(field.getModifiers())) && !field.isAccessible()) {
+ field.setAccessible(true);
+ }
+ }
+
+ /**
+ * 閫氳繃鍙嶅皠, 鑾峰緱Class瀹氫箟涓0鏄庣殑娉涘瀷鍙傛暟鐨勭被鍨�, 娉ㄦ剰娉涘瀷蹇呴』瀹氫箟鍦ㄧ埗绫诲
+ * 濡傛棤娉曟壘鍒�, 杩斿洖Object.class.
+ * eg.
+ * public UserDao extends HibernateDao<User>
+ *
+ * @param clazz The class to introspect
+ * @return the first generic declaration, or Object.class if cannot be determined
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> Class<T> getClassGenricType(final Class clazz) {
+ return getClassGenricType(clazz, 0);
+ }
+
+ /**
+ * 閫氳繃鍙嶅皠, 鑾峰緱Class瀹氫箟涓0鏄庣殑鐖剁被鐨勬硾鍨嬪弬鏁扮殑绫诲瀷.
+ * 濡傛棤娉曟壘鍒�, 杩斿洖Object.class.
+ *
+ * 濡俻ublic UserDao extends HibernateDao<User,Long>
+ *
+ * @param clazz clazz The class to introspect
+ * @param index the Index of the generic ddeclaration,start from 0.
+ * @return the index generic declaration, or Object.class if cannot be determined
+ */
+ public static Class getClassGenricType(final Class clazz, final int index) {
+
+ Type genType = clazz.getGenericSuperclass();
+
+ if (!(genType instanceof ParameterizedType)) {
+ logger.warn(clazz.getSimpleName() + "'s superclass not ParameterizedType");
+ return Object.class;
+ }
+
+ Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
+
+ if (index >= params.length || index < 0) {
+ logger.warn("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: "
+ + params.length);
+ return Object.class;
+ }
+ if (!(params[index] instanceof Class)) {
+ logger.warn(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
+ return Object.class;
+ }
+
+ return (Class) params[index];
+ }
+
+ public static Class<?> getUserClass(Object instance) {
+ Assert.notNull(instance, "Instance must not be null");
+ Class clazz = instance.getClass();
+ if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
+ Class<?> superClass = clazz.getSuperclass();
+ if (superClass != null && !Object.class.equals(superClass)) {
+ return superClass;
+ }
+ }
+ return clazz;
+
+ }
+
+ /**
+ * 灏嗗弽灏勬椂鐨刢hecked exception杞崲涓簎nchecked exception.
+ */
+ public static RuntimeException convertReflectionExceptionToUnchecked(Exception e) {
+ if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException
+ || e instanceof NoSuchMethodException) {
+ return new IllegalArgumentException(e);
+ } else if (e instanceof InvocationTargetException) {
+ return new RuntimeException(((InvocationTargetException) e).getTargetException());
+ } else if (e instanceof RuntimeException) {
+ return (RuntimeException) e;
+ }
+ return new RuntimeException("Unexpected Checked Exception.", e);
+ }
+}
\ No newline at end of file
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 a732f80..9ca52dd 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
@@ -51,6 +51,7 @@
public static final String PAUSE_BIKE_TYPE ="PAUSE_BIKE_TYPE" ;
public static final String HEART_TIME_EXPIRE_TIME ="HEART_TIME_EXPIRE_TIME" ;
public static final String PARK_LAT_LNG_LIST = "PARK_LAT_LNG_LIST";
+ public static final String LOW_BIKE_VOLTAGE ="LOW_BIKE_VOLTAGE" ;
public static String REDIS_DEBUG_STR="test_";
public static final String AD = "AD";
public static String REPAIR = "REPAIR";
@@ -176,6 +177,7 @@
}
public interface RedisKeys {
public static final String submission_period_key = "sp_";
+ public static final String import_bikes = "import_bikes";
}
public static final String ACCESS_ID = "ACCESS_ID";
diff --git a/server/services/src/main/java/com/doumee/core/wx/WxMiniUtilService.java b/server/services/src/main/java/com/doumee/core/wx/WxMiniUtilService.java
index 68b4972..68410dc 100644
--- a/server/services/src/main/java/com/doumee/core/wx/WxMiniUtilService.java
+++ b/server/services/src/main/java/com/doumee/core/wx/WxMiniUtilService.java
@@ -254,12 +254,12 @@
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/qr-code/getUnlimitedQRCode.html
* @return
*/
- public void generateWXMiniCode(Locks locks,SystemDictData systemDictData,String prePath,String path){
+ public void generateWXMiniCode(Locks locks,String token,String prePath,String path){
- if(Objects.isNull(systemDictData)){
+ if(Objects.isNull(token)){
return;
}
- String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+ systemDictData.getCode();
+ String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+ token;
String release = systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.MINI_PROGRAMME_REALEASE).getCode();
//鐢熸垚鍥剧墖涓婁紶OSS
Map<String,Object> body = new HashMap<>();
diff --git a/server/services/src/main/java/com/doumee/dao/business/model/Bikes.java b/server/services/src/main/java/com/doumee/dao/business/model/Bikes.java
index 30c1208..c9417fc 100644
--- a/server/services/src/main/java/com/doumee/dao/business/model/Bikes.java
+++ b/server/services/src/main/java/com/doumee/dao/business/model/Bikes.java
@@ -126,6 +126,9 @@
@ApiModelProperty(value = "鏈�杩戝畾浣嶅湴鍧�")
@ExcelColumn(name="鏈�杩戝畾浣嶅湴鍧�")
private String location;
+ @ApiModelProperty(value = "鏄惁浣庣數閲� 0鍚� 1鏄�")
+ @TableField(exist = false )
+ private Integer lowVoltage;
}
diff --git a/server/services/src/main/java/com/doumee/dao/business/vo/BikesImportVO.java b/server/services/src/main/java/com/doumee/dao/business/vo/BikesImportVO.java
new file mode 100644
index 0000000..f000fc1
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/dao/business/vo/BikesImportVO.java
@@ -0,0 +1,29 @@
+package com.doumee.dao.business.vo;
+
+import com.doumee.core.annotation.excel.ExcelColumn;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 璁㈠崟淇℃伅琛�
+ * @author 姹熻箘韫�
+ * @date 2023/09/27 18:06
+ */
+@Data
+@ApiModel("鐢佃溅瀵煎叆妯$増")
+public class BikesImportVO {
+
+ @ExcelColumn(name="杞﹁締绫诲瀷",value = "paramName",index = 1)
+ private String paramName;
+ @ExcelColumn(name="杞︾墝鍙�",value = "code",index = 2)
+ private String code;
+
+ @ExcelColumn(name="鎺у埗鍣ㄧ紪鐮�",value = "sn",index = 3)
+ private String sn;
+
+}
diff --git a/server/services/src/main/java/com/doumee/service/business/BikesService.java b/server/services/src/main/java/com/doumee/service/business/BikesService.java
index 785ac4e..9aaf144 100644
--- a/server/services/src/main/java/com/doumee/service/business/BikesService.java
+++ b/server/services/src/main/java/com/doumee/service/business/BikesService.java
@@ -3,6 +3,8 @@
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.dao.business.model.Bikes;
+import org.springframework.web.multipart.MultipartFile;
+
import java.util.List;
/**
@@ -86,7 +88,7 @@
* @return PageData<Bikes>
*/
PageData<Bikes> findPage(PageWrap<Bikes> pageWrap);
-
+ String importBatch(MultipartFile file);
/**
* 鏉′欢缁熻
*
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/BaseParamServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/BaseParamServiceImpl.java
index 53081d9..cde6826 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/BaseParamServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/BaseParamServiceImpl.java
@@ -51,7 +51,7 @@
.eq(BaseParam::getIsdeleted,Constants.ZERO)
.eq(BaseParam::getName,baseParam.getName());
- Integer count = baseParamMapper.selectCount(wrapper);
+ long count = baseParamMapper.selectCount(wrapper);
if (count > 0){
throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"杞﹁締闂宸插瓨鍦�");
}
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/BikesServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/BikesServiceImpl.java
index 8cc0ddf..e441663 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/BikesServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/BikesServiceImpl.java
@@ -1,6 +1,7 @@
package com.doumee.service.business.impl;
import com.doumee.biz.system.SystemDictDataBiz;
+import com.doumee.core.annotation.excel.ExcelImporter;
import com.doumee.core.constants.Constants;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
@@ -13,6 +14,7 @@
import com.doumee.dao.business.BikesMapper;
import com.doumee.dao.business.join.BikesJoinMapper;
import com.doumee.dao.business.model.*;
+import com.doumee.dao.business.vo.BikesImportVO;
import com.doumee.dao.business.web.response.BikeLogDTO;
import com.doumee.dao.business.web.response.MemberRidesDTO;
import com.doumee.dao.business.web.response.MiniProgrammeDTO;
@@ -27,10 +29,14 @@
import com.github.xiaoymin.knife4j.core.util.StrUtil;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
import java.util.*;
import java.util.stream.Collectors;
@@ -43,6 +49,9 @@
@Service
public class BikesServiceImpl implements BikesService {
+
+ @Autowired
+ private RedisTemplate<String, Object> redisTemplate;
@Autowired
private BikesMapper bikesMapper;
@Autowired
@@ -70,7 +79,7 @@
.eq(Bikes::getCode,bikes.getCode())
.eq(Bikes::getIsdeleted,Constants.ZERO)
.eq(Bikes::getType,Constants.ONE);
- Integer count = bikesMapper.selectCount(wrapper);
+ Long count = bikesMapper.selectCount(wrapper);
if (count > 0){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"杞︾墝鍙峰彿宸插瓨鍦�");
}
@@ -114,7 +123,7 @@
.eq(Bikes::getIsdeleted,Constants.ZERO)
.ne(Bikes::getId,bikes.getId())
.eq(Bikes::getType,Constants.ONE);
- Integer count = bikesMapper.selectCount(wrapper);
+ long count = bikesMapper.selectCount(wrapper);
if (count > 0){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"杞︾墝鍙峰彿宸插瓨鍦�");
}
@@ -185,7 +194,7 @@
QueryWrapper<SystemDictData> wrapper = new QueryWrapper<>();
wrapper.lambda()
- .in(SystemDictData::getLabel, Arrays.asList(Constants.FORCE_BACK_SITE,Constants.FORCE_BACK_LOCK));
+ .in(SystemDictData::getLabel, Arrays.asList(Constants.FORCE_BACK_SITE,Constants.FORCE_BACK_LOCK,Constants.LOW_BIKE_VOLTAGE));
List<SystemDictData> systemDictData = systemDictDataMapper.selectList(wrapper);
Map<String, SystemDictData> collect = systemDictData.stream().collect(Collectors.toMap(s -> s.getLabel(), s -> s));
@@ -197,7 +206,10 @@
.leftJoin(Sites.class,Sites::getId,Bikes::getSiteId)
.like(StringUtils.isNotBlank(pageWrap.getModel().getSiteId()),Bikes::getSiteId,pageWrap.getModel().getSiteId())
.like(StringUtils.isNotBlank(pageWrap.getModel().getSiteName()), Sites::getName,pageWrap.getModel().getSiteName())
+ .like(StringUtils.isNotBlank(pageWrap.getModel().getCode()), Bikes::getCode,pageWrap.getModel().getCode())
+ .like(StringUtils.isNotBlank(pageWrap.getModel().getDeviceSn()), Bikes::getDeviceSn,pageWrap.getModel().getDeviceSn())
.eq( pageWrap.getModel().getLockId() !=null,Bikes::getLockId,pageWrap.getModel().getLockId())
+ .eq( Bikes::getType,Constants.formatIntegerNum(pageWrap.getModel().getType()))//榛樿鏌ヨ鑷杞�
.ne(Bikes::getLockId,Constants.formatIntegerFromStr(collect.get(Constants.FORCE_BACK_LOCK).getCode()))
.ne(Bikes::getSiteId,collect.get(Constants.FORCE_BACK_SITE).getCode())
.and(Constants.formatIntegerNum(pageWrap.getModel().getHasBike()) == Constants.ONE,
@@ -206,6 +218,20 @@
.and(Constants.formatIntegerNum(pageWrap.getModel().getHasBike()) == Constants.TWO,s->s
.isNotNull(Bikes::getCode)
.and(b->b.ne(Bikes::getCode,"")));
+ if(pageWrap.getModel().getLowVoltage()!=null){
+ double low = 0;
+ try {
+ low = Double.parseDouble(collect.get(Constants.LOW_BIKE_VOLTAGE).getCode());
+ }catch (Exception e){
+ }
+ if(pageWrap.getModel().getType() == Constants.ONE){
+ //浣庣數閲�
+ queryWrapper.lt(Bikes::getVoltage,low);
+ }else{
+ //姝e父鐢甸噺
+ queryWrapper.ge(Bikes::getVoltage,low);
+ }
+ }
queryWrapper.selectAll(Bikes.class)
.selectAs(BaseParam::getName,Bikes::getParamName)
.selectAs(Sites::getName,Bikes::getSiteName) ;
@@ -280,4 +306,110 @@
QueryWrapper<Bikes> wrapper = new QueryWrapper<>(bikes);
return bikesMapper.selectCount(wrapper);
}
+
+
+ @Override
+ @Transactional(rollbackFor = {BusinessException.class,Exception.class})
+ public String importBatch(MultipartFile file){
+ Boolean importing = (Boolean) redisTemplate.opsForValue().get(Constants.RedisKeys.import_bikes);
+ if(importing!=null && importing){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝宸插瓨鍦ㄥ鍏ヤ换鍔℃鍦ㄦ墽琛屼腑锛岃绋嶅悗鍐嶈瘯锛�");
+ }
+ LoginUserInfo user =(LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+
+ redisTemplate.opsForValue().set(Constants.RedisKeys.import_bikes,true);
+ try {
+ ExcelImporter ie = null;
+ List<BikesImportVO> dataList =null;
+ try {
+ ie = new ExcelImporter(file,1,0, CellType.STRING); // 纭繚鍗曞厓鏍肩被鍨嬩负瀛楃涓�
+ dataList = ie.getDataList(BikesImportVO.class,null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if(dataList == null || dataList.size() ==0){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝褰曞叆鏁版嵁涓虹┖锛�");
+ }
+ List<Bikes> list = bikesJoinMapper.selectJoinList(Bikes.class,new MPJLambdaWrapper<Bikes>()
+ .selectAll(Bikes.class)
+ .eq(Member::getIsdeleted,Constants.ZERO)
+ );
+ List<BaseParam> params = baseParamMapper.selectList(new QueryWrapper<BaseParam>().lambda()
+ .eq(BaseParam::getIsdeleted,Constants.ZERO)
+ .eq(BaseParam::getType,Constants.FOUR)
+ );
+ List<Bikes> newList = new ArrayList<>();
+ Date date = new Date();
+ for(int i=0;i<dataList.size();i++){
+ BikesImportVO model = dataList.get(i);
+ if(StringUtils.isBlank(model.getSn())
+ &&StringUtils.isBlank(model.getCode())
+ &&StringUtils.isBlank(model.getParamName())){
+ continue;
+ }
+ Bikes bike = checkModelParam(model,newList,i,list,params,user.getId(),date);
+ newList.add(bike);
+ }
+ if(newList == null || newList.size() ==0){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝褰曞叆鏈夋晥鏁版嵁涓虹┖锛�");
+ }
+ bikesMapper.insert(newList);
+ return "瀵煎叆鎴愬姛";
+ }catch (BusinessException e){
+ throw e;
+ }catch (Exception e){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"鍛樺伐淇℃伅瀵煎叆澶辫触锛岃绋嶅悗閲嶈瘯");
+ }finally {
+ redisTemplate.delete(Constants.RedisKeys.import_bikes);
+ }
+ }
+
+ private Bikes checkModelParam(BikesImportVO model, List<Bikes> newList, int index, List<Bikes> list, List<BaseParam> params,String userId,Date date) {
+ Bikes bike = new Bikes();
+ if(StringUtils.isBlank(model.getParamName())
+ ||StringUtils.isBlank(model.getCode())
+ ||StringUtils.isBlank(model.getSn())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+(index+3)+"琛屼汉鍛樹俊鎭笉瀹屾暣锛岃妫�鏌ヨ〃鏍煎唴瀹癸紒");
+ }
+ if(params ==null){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝鐢佃溅绫诲瀷鏈厤缃紝璇疯仈绯荤郴缁熸妧鏈汉鍛樺鐞嗭紒");
+ }
+ for(BaseParam p: params){
+ if(StringUtils.equals(model.getParamName(),p.getName())){
+ bike.setParamId(p.getId());
+ }
+ }
+ if(bike.getParamId() ==null){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+(index+3)+"琛岃溅杈嗙被鍨嬨��"+model.getParamName()+"銆戜笉瀛樺湪锛岃妫�鏌ヨ〃鏍煎唴瀹癸紒");
+ }
+ if(list!=null){
+ for(Bikes bikes: list){
+ if(StringUtils.equals(model.getCode(),bikes.getCode())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+(index+3)+"琛岃溅鐗屽彿銆�"+model.getCode()+"銆戝凡瀛樺湪锛岃妫�鏌ヨ〃鏍煎唴瀹癸紒");
+ }
+ if(StringUtils.equals(model.getSn(),bikes.getDeviceSn())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+(index+3)+"琛屾帶鍒跺櫒sn銆�"+model.getSn()+"銆戝凡瀛樺湪锛岃妫�鏌ヨ〃鏍煎唴瀹癸紒");
+ }
+ }
+ }
+ for(Bikes bikes: newList){
+ if(StringUtils.equals(model.getCode(),bikes.getCode())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+(index+3)+"琛岃溅鐗屽彿銆�"+model.getCode()+"銆戦噸澶嶅嚭鐜帮紝璇锋鏌ヨ〃鏍煎唴瀹癸紒");
+ }
+ if(StringUtils.equals(model.getSn(),bikes.getDeviceSn())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+(index+3)+"琛屾帶鍒跺櫒sn銆�"+model.getSn()+"銆戦噸澶嶅嚭鐜帮紝璇锋鏌ヨ〃鏍煎唴瀹癸紒");
+ }
+ }
+ bike.setCode(model.getCode());
+ bike.setDeviceSn(model.getSn());
+ bike.setId(UUID.randomUUID().toString());
+ bike.setCreateDate(new Date());
+ bike.setCreator(userId);
+ bike.setEditDate(date);
+ bike.setEditor(userId);
+ bike.setStatus(Constants.ZERO);
+ bike.setIsdeleted(Constants.ZERO);
+ bike.setType(Constants.ONE);//鍙兘鏂板鐢佃溅鏁版嵁
+ return bike;
+ }
}
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
index fd27fdd..6314d3a 100644
--- 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
@@ -64,7 +64,7 @@
MqttLog mqttLog = new MqttLog();
mqttLog.setMsgId(msgId);
mqttLog.setTopic(topic);
- int msgCount =mqttLogMapper.selectCount(new QueryWrapper<MqttLog>().lambda().eq(MqttLog::getMsg, param).eq(MqttLog::getType, Constants.ZERO));
+ long msgCount =mqttLogMapper.selectCount(new QueryWrapper<MqttLog>().lambda().eq(MqttLog::getMsg, param).eq(MqttLog::getType, Constants.ZERO));
if(msgCount>0){
log.error("mqtt娑堟伅璁㈤槄==============宸叉秷璐规暟鎹�====="+param);
return;
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/LocksServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/LocksServiceImpl.java
index 7dc07a0..63c8345 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/LocksServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/LocksServiceImpl.java
@@ -2,6 +2,7 @@
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
+import com.doumee.core.wx.WxMiniConfig;
import com.google.common.collect.Lists;
import com.doumee.biz.system.SystemDictDataBiz;
@@ -140,7 +141,10 @@
// 妫�鏌ユ槸鍚︽湁鍥剧墖淇℃伅娌℃湁鏇存柊淇濆瓨鍥剧墖
locksList.forEach(s-> {
if (StringUtils.isBlank(s.getInfo())){
- wxMiniUtilService.generateWXMiniCode(s,systemDictData,prePath,code);
+ try {
+ wxMiniUtilService.generateWXMiniCode(s, WxMiniConfig.wxMaService.getAccessToken(),prePath,code);
+ }catch (Exception e){
+ }
s.setEditor(loginUserInfo.getId());
s.setEditDate(new Date());
updateById(s);
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
index e6471a7..2286c40 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
@@ -71,7 +71,7 @@
.eq(Member::getIsdeleted,Constants.ZERO)
.eq(Member::getType,Constants.ONE)
.eq(Member::getCardNo,member.getCardNo());
- Integer integer = memberMapper.selectCount(wrapper);
+ long integer = memberMapper.selectCount(wrapper);
if (integer > 0){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鍗″彿瀛樺湪閲嶅");
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/PricingParamServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/PricingParamServiceImpl.java
index 48b43bd..8653305 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/PricingParamServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/PricingParamServiceImpl.java
@@ -133,7 +133,7 @@
wrapper.lambda()
.eq(PricingParam::getIsdeleted,Constants.ZERO)
.eq(PricingParam::getStatus,Constants.ZERO);
- Integer integer = pricingParamMapper.selectCount(wrapper);
+ long integer = pricingParamMapper.selectCount(wrapper);
if (integer <= 1 ){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"璇ュ畾浠锋柟妗堝繀椤婚厤缃�");
}
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/SitesServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/SitesServiceImpl.java
index b3343fe..30b29df 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/SitesServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/SitesServiceImpl.java
@@ -68,7 +68,7 @@
wrapper.lambda()
.eq(Sites::getCode,sites.getCode())
.eq(Sites::getIsdeleted,Constants.ZERO);
- Integer count = sitesMapper.selectCount(wrapper);
+ Long count = sitesMapper.selectCount(wrapper);
if (count > 0){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"绔欑偣缂栧彿宸插瓨鍦�");
}
@@ -244,6 +244,9 @@
if (pageWrap.getModel().getClientVersion() != null) {
queryWrapper.lambda().eq(Sites::getClientVersion, pageWrap.getModel().getClientVersion());
}
+ if (pageWrap.getModel().getType() != null) {
+ queryWrapper.lambda().eq(Sites::getType, pageWrap.getModel().getType());
+ }
/*for(PageWrap.SortData sortData: pageWrap.getSorts()) {
if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
queryWrapper.orderByDesc(sortData.getProperty());
diff --git a/server/web/src/main/java/com/doumee/api/web/AccountApi.java b/server/web/src/main/java/com/doumee/api/web/AccountApi.java
index 1ae42d1..6a884f9 100644
--- a/server/web/src/main/java/com/doumee/api/web/AccountApi.java
+++ b/server/web/src/main/java/com/doumee/api/web/AccountApi.java
@@ -7,6 +7,7 @@
import com.doumee.core.annotation.trace.Trace;
import com.doumee.core.constants.Constants;
import com.doumee.core.model.ApiResponse;
+import com.doumee.core.wx.WxMiniConfig;
import com.doumee.core.wx.WxMiniUtilService;
import com.doumee.dao.business.model.Locks;
import com.doumee.dao.business.web.request.RegisterRequest;
@@ -20,6 +21,7 @@
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -109,12 +111,12 @@
@ApiOperation(value = "娴嬭瘯鐢熸垚浜岀淮鐮�", notes = "灏忕▼搴忕")
@GetMapping("/generateWXMiniCode")
- public ApiResponse<Locks> generateWXMiniCode() {
+ public ApiResponse<Locks> generateWXMiniCode() throws WxErrorException {
Locks locks = new Locks();
locks.setCode(12);
locks.setSiteId("1005");
SystemDictData systemDictData = systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.ACCESS_TOKEN);
- wxMiniUtilService.generateWXMiniCode(locks,systemDictData,"/usr/local/static_resources/bike/bike_file/","");
+ wxMiniUtilService.generateWXMiniCode(locks, WxMiniConfig.wxMaService.getAccessToken(),"/usr/local/static_resources/bike/bike_file/","");
return ApiResponse.success("鎿嶄綔鎴愬姛",locks);
}
--
Gitblit v1.9.3