home 2 лет назад
Родитель
Сommit
19b55c1312
14 измененных файлов с 247 добавлено и 26 удалено
  1. 1 1
      hx-common/code-generator/src/main/java/com/fjhx/modular/Victoriatourist.java
  2. 10 0
      hx-service-api/victoriatourist-api/src/main/java/com/fjhx/constants/VRedisKeyConstant.java
  3. 0 5
      hx-service-api/victoriatourist-api/src/main/java/com/fjhx/entity/excel/ExcelImportLog.java
  4. 44 0
      hx-service-api/victoriatourist-api/src/main/java/com/fjhx/entity/system/SystemConfig.java
  5. 22 0
      hx-service-api/victoriatourist-api/src/main/java/com/fjhx/params/excel/BaseExcelVo.java
  6. 17 0
      hx-service-api/victoriatourist-api/src/main/java/com/fjhx/params/system/SystemConfigEx.java
  7. 17 0
      hx-service-api/victoriatourist-api/src/main/java/com/fjhx/params/system/SystemConfigVo.java
  8. 4 1
      hx-service/victoriatourist/src/main/java/com/fjhx/listener/EasyExcelListener.java
  9. 16 0
      hx-service/victoriatourist/src/main/java/com/fjhx/mapper/system/SystemConfigMapper.java
  10. 5 0
      hx-service/victoriatourist/src/main/java/com/fjhx/mapper/system/SystemConfigMapper.xml
  11. 13 4
      hx-service/victoriatourist/src/main/java/com/fjhx/service/excel/ExcelImportLogService.java
  12. 22 15
      hx-service/victoriatourist/src/main/java/com/fjhx/service/excel/impl/ExcelImportLogServiceImpl.java
  13. 28 0
      hx-service/victoriatourist/src/main/java/com/fjhx/service/system/SystemConfigService.java
  14. 48 0
      hx-service/victoriatourist/src/main/java/com/fjhx/service/system/impl/SystemConfigServiceImpl.java

+ 1 - 1
hx-common/code-generator/src/main/java/com/fjhx/modular/Victoriatourist.java

@@ -12,7 +12,7 @@ public class Victoriatourist {
         CodeGenerator.MODULAR_NAME = "victoriatourist";
 
         // 需要生成的表名称,多表用,隔开
-        CodeGenerator.INCLUDE = "logistics_company";
+        CodeGenerator.INCLUDE = "system_config";
 
         // mysql连接
         CodeGenerator.MYSQL_URL = "36.134.91.96:17330";

+ 10 - 0
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/constants/VRedisKeyConstant.java

@@ -0,0 +1,10 @@
+package com.fjhx.constants;
+
+public interface VRedisKeyConstant {
+
+    /**
+     * 文件导入状态标记key
+     */
+    String EXCEL_FLAG_KEY = "excelFlagKey:";
+
+}

+ 0 - 5
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/entity/excel/ExcelImportLog.java

@@ -20,11 +20,6 @@ import lombok.EqualsAndHashCode;
 public class ExcelImportLog extends BaseEntity {
 
     /**
-     * 标记
-     */
-    private String flag;
-
-    /**
      * 业务类型
      */
     private Integer businessType;

+ 44 - 0
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/entity/system/SystemConfig.java

@@ -0,0 +1,44 @@
+package com.fjhx.entity.system;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.Version;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fjhx.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 参数配置表
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-08
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class SystemConfig extends BaseEntity {
+
+
+    /**
+     * 参数说明
+     */
+    private String configName;
+
+    /**
+     * 参数键名
+     */
+    private String configKey;
+
+    /**
+     * 参数键值
+     */
+    private String configValue;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+
+}

+ 22 - 0
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/params/excel/BaseExcelVo.java

@@ -0,0 +1,22 @@
+package com.fjhx.params.excel;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class BaseExcelVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 行好
+     */
+    Integer lineNumber;
+
+    /**
+     * 异常原因
+     */
+    String failReason;
+
+}

+ 17 - 0
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/params/system/SystemConfigEx.java

@@ -0,0 +1,17 @@
+package com.fjhx.params.system;
+
+import com.fjhx.entity.system.SystemConfig;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 参数配置表
+ *
+ * @author ${author}
+ * @since 2022-12-08
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class SystemConfigEx extends SystemConfig {
+
+}

+ 17 - 0
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/params/system/SystemConfigVo.java

@@ -0,0 +1,17 @@
+package com.fjhx.params.system;
+
+import com.fjhx.entity.system.SystemConfig;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 参数配置表
+ *
+ * @author ${author}
+ * @since 2022-12-08
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class SystemConfigVo extends SystemConfig {
+
+}

+ 4 - 1
hx-service/victoriatourist/src/main/java/com/fjhx/listener/EasyExcelListener.java

@@ -2,18 +2,20 @@ package com.fjhx.listener;
 
 import com.alibaba.excel.context.AnalysisContext;
 import com.alibaba.excel.event.AnalysisEventListener;
+import com.fjhx.params.excel.BaseExcelVo;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.function.Consumer;
 
-public class EasyExcelListener<T> extends AnalysisEventListener<T> {
+public class EasyExcelListener<T extends BaseExcelVo> extends AnalysisEventListener<T> {
     private final int pageSize;
     private final List<T> list;
     private final IHandleData<T> handleDataFun;
     private final Consumer<Exception> handleException;
     private int radeLine = 0;
     private Integer totalLine;
+    private int lineNumber = 2;
 
     public EasyExcelListener(int pageSize, IHandleData<T> handleDataFun, Consumer<Exception> handleExceptionFun) {
         this.pageSize = pageSize;
@@ -24,6 +26,7 @@ public class EasyExcelListener<T> extends AnalysisEventListener<T> {
 
     @Override
     public void invoke(T data, AnalysisContext context) {
+        data.setLineNumber(lineNumber++);
         list.add(data);
         if (list.size() >= pageSize) {
             if (totalLine == null) {

+ 16 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/mapper/system/SystemConfigMapper.java

@@ -0,0 +1,16 @@
+package com.fjhx.mapper.system;
+
+import com.fjhx.entity.system.SystemConfig;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 参数配置表 Mapper 接口
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-08
+ */
+public interface SystemConfigMapper extends BaseMapper<SystemConfig> {
+
+}

+ 5 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/mapper/system/SystemConfigMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.mapper.system.SystemConfigMapper">
+
+</mapper>

+ 13 - 4
hx-service/victoriatourist/src/main/java/com/fjhx/service/excel/ExcelImportLogService.java

@@ -2,6 +2,7 @@ package com.fjhx.service.excel;
 
 import com.fjhx.base.BaseService;
 import com.fjhx.entity.excel.ExcelImportLog;
+import com.fjhx.params.excel.BaseExcelVo;
 import com.fjhx.params.excel.ExcelProcessingProgress;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -29,21 +30,29 @@ public interface ExcelImportLogService extends BaseService<ExcelImportLog> {
      * @param errorFun     发生异常处理方法
      * @param <T>          对象类型
      */
-    <T> void asyncRead(String flag, MultipartFile file, Class<T> cls, Integer businessType,
-                       Consumer<List<T>> handleFun, Runnable errorFun);
+    <T extends BaseExcelVo> void asyncRead(Long flag, MultipartFile file, Class<T> cls, Integer businessType,
+                                           Consumer<List<T>> handleFun, Runnable errorFun);
 
     /**
      * 查看处理进度
      *
      * @param flag 缓存标记
      */
-    ExcelProcessingProgress getReadRate(String flag);
+    ExcelProcessingProgress getReadRate(Long flag);
 
     /**
      * 停止处理
      *
      * @param flag 缓存标记
      */
-    void stopRead(String flag);
+    void stopRead(Long flag);
+
+    /**
+     * 记录异常行数据
+     *
+     * @param flag 缓存标记
+     * @param list 异常数据
+     */
+    void readErrorData(Long flag, List<? extends BaseExcelVo> list);
 
 }

+ 22 - 15
hx-service/victoriatourist/src/main/java/com/fjhx/service/excel/impl/ExcelImportLogServiceImpl.java

@@ -6,9 +6,11 @@ import com.alibaba.excel.EasyExcel;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.base.BaseEntity;
 import com.fjhx.config.TaskPoolConfig;
+import com.fjhx.constants.VRedisKeyConstant;
 import com.fjhx.entity.excel.ExcelImportLog;
 import com.fjhx.listener.EasyExcelListener;
 import com.fjhx.mapper.excel.ExcelImportLogMapper;
+import com.fjhx.params.excel.BaseExcelVo;
 import com.fjhx.params.excel.ExcelProcessingProgress;
 import com.fjhx.service.excel.ExcelImportLogService;
 import org.springblade.core.excel.support.ExcelException;
@@ -48,8 +50,8 @@ public class ExcelImportLogServiceImpl extends ServiceImpl<ExcelImportLogMapper,
     private BladeRedis bladeRedis;
 
     @Override
-    public <T> void asyncRead(String flag, MultipartFile file, Class<T> cls, Integer businessType,
-                              Consumer<List<T>> handleFun, Runnable errorFun) {
+    public <T extends BaseExcelVo> void asyncRead(Long flag, MultipartFile file, Class<T> cls, Integer businessType,
+                                                  Consumer<List<T>> handleFun, Runnable errorFun) {
 
         String filename = file.getOriginalFilename();
         if (ObjectUtils.isEmpty(filename)) {
@@ -119,19 +121,19 @@ public class ExcelImportLogServiceImpl extends ServiceImpl<ExcelImportLogMapper,
     }
 
     @Override
-    public ExcelProcessingProgress getReadRate(String flag) {
-        ExcelProcessingProgress excelProcessingProgress = bladeRedis.get(flag);
+    public ExcelProcessingProgress getReadRate(Long flag) {
+        ExcelProcessingProgress excelProcessingProgress = bladeRedis.get(VRedisKeyConstant.EXCEL_FLAG_KEY + flag);
 
         // 如果处理完成、用户取消、发生异常,删除缓存
         if (excelProcessingProgress != null && excelProcessingProgress.getStatus() > 3) {
-            bladeRedis.del(flag);
+            bladeRedis.del(VRedisKeyConstant.EXCEL_FLAG_KEY + flag);
         }
 
         return excelProcessingProgress;
     }
 
     @Override
-    public void stopRead(String flag) {
+    public void stopRead(Long flag) {
         // 导入信息放入redis缓存
         ExcelProcessingProgress excelProcessingProgress = new ExcelProcessingProgress();
         excelProcessingProgress.setStatus(6); // 预处理阶段
@@ -139,14 +141,19 @@ public class ExcelImportLogServiceImpl extends ServiceImpl<ExcelImportLogMapper,
         setProgress(flag, excelProcessingProgress);
     }
 
+    @Override
+    public void readErrorData(Long flag, List<? extends BaseExcelVo> list) {
+
+    }
+
     /**
      * 插入缓存信息
      *
      * @param flag                    缓存标记
      * @param excelProcessingProgress 缓存对象
      */
-    private synchronized void setProgress(String flag, ExcelProcessingProgress excelProcessingProgress) {
-        bladeRedis.setEx(flag, excelProcessingProgress, 60L * 60 * 12);
+    private synchronized void setProgress(Long flag, ExcelProcessingProgress excelProcessingProgress) {
+        bladeRedis.setEx(VRedisKeyConstant.EXCEL_FLAG_KEY + flag, excelProcessingProgress, 60L * 60 * 12);
     }
 
     /**
@@ -156,15 +163,15 @@ public class ExcelImportLogServiceImpl extends ServiceImpl<ExcelImportLogMapper,
      * @param status     状态
      * @param percentage 进度
      */
-    private synchronized void verificationAndUpdateProgress(String flag, Integer status, Integer percentage) {
-        ExcelProcessingProgress excelProcessingProgress = bladeRedis.get(flag);
+    private synchronized void verificationAndUpdateProgress(Long flag, Integer status, Integer percentage) {
+        ExcelProcessingProgress excelProcessingProgress = bladeRedis.get(VRedisKeyConstant.EXCEL_FLAG_KEY + flag);
         if (ObjectUtil.isNull(excelProcessingProgress) || excelProcessingProgress.getStatus().equals(6)) {
             throw new ExcelException("取消导入");
         }
 
         excelProcessingProgress.setStatus(status);
         excelProcessingProgress.setPercentage(percentage);
-        bladeRedis.setEx(flag, excelProcessingProgress, 60L * 60 * 12);
+        bladeRedis.setEx(VRedisKeyConstant.EXCEL_FLAG_KEY + flag, excelProcessingProgress, 60L * 60 * 12);
     }
 
     /**
@@ -174,10 +181,10 @@ public class ExcelImportLogServiceImpl extends ServiceImpl<ExcelImportLogMapper,
      * @param businessType 业务类型
      * @param file         文件
      */
-    private void saveLog(String flag, Integer businessType, MultipartFile file) {
+    private void saveLog(Long flag, Integer businessType, MultipartFile file) {
         // 上传记录记录数据库
         ExcelImportLog excelImportLog = new ExcelImportLog();
-        excelImportLog.setFlag(flag);
+        excelImportLog.setId(flag);
         excelImportLog.setBusinessType(businessType);
         excelImportLog.setStatus(0);
         excelImportLog.setFileName(file.getOriginalFilename());
@@ -191,11 +198,11 @@ public class ExcelImportLogServiceImpl extends ServiceImpl<ExcelImportLogMapper,
      * @param flag   标记
      * @param status 状态
      */
-    private void editLog(Long start, String flag, Integer status) {
+    private void editLog(Long start, Long flag, Integer status) {
         long end = System.currentTimeMillis();
 
         update(q -> q
-                .eq(ExcelImportLog::getFlag, flag)
+                .eq(ExcelImportLog::getId, flag)
                 .set(ExcelImportLog::getStatus, status)
                 .set(ExcelImportLog::getExecuteTime, (end - start) / 1000)
                 .set(BaseEntity::getUpdateTime, new Date())

+ 28 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/system/SystemConfigService.java

@@ -0,0 +1,28 @@
+package com.fjhx.service.system;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.entity.system.SystemConfig;
+import com.fjhx.params.system.SystemConfigVo;
+import com.fjhx.base.BaseService;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * 参数配置表 服务类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-08
+ */
+public interface SystemConfigService extends BaseService<SystemConfig> {
+
+    Page<SystemConfig> getPage(Map<String, Object> condition);
+
+    void add(SystemConfigVo systemConfigVo);
+
+    void edit(SystemConfigVo systemConfigVo);
+
+    void delete(SystemConfigVo systemConfigVo);
+
+}

+ 48 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/system/impl/SystemConfigServiceImpl.java

@@ -0,0 +1,48 @@
+package com.fjhx.service.system.impl;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.entity.system.SystemConfig;
+import com.fjhx.params.system.SystemConfigVo;
+import com.fjhx.mapper.system.SystemConfigMapper;
+import com.fjhx.service.system.SystemConfigService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.utils.wrapperUtil.IWrapper;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * 参数配置表 服务实现类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-08
+ */
+@Service
+public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigMapper, SystemConfig> implements SystemConfigService {
+
+    @Override
+    public Page<SystemConfig> getPage(Map<String, Object> condition) {
+
+        IWrapper<SystemConfig> wrapper = IWrapper.getWrapper(condition);
+
+        return page(condition, wrapper);
+    }
+
+    @Override
+    public void add(SystemConfigVo systemConfigVo) {
+        save(systemConfigVo);
+    }
+
+    @Override
+    public void edit(SystemConfigVo systemConfigVo) {
+        updateById(systemConfigVo);
+    }
+
+    @Override
+    public void delete(SystemConfigVo systemConfigVo) {
+        removeById(systemConfigVo.getId());
+    }
+
+}