Explorar el Código

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	boman-auth/src/main/java/com/boman/auth/controller/TokenController.java
#	boman-common/boman-common-security/src/main/java/com/boman/common/security/service/TokenService.java
Administrator hace 3 años
padre
commit
a4c66b0e46
Se han modificado 20 ficheros con 785 adiciones y 92 borrados
  1. 7 3
      boman-api/boman-api-system/src/main/java/com/boman/system/api/RemoteFileService.java
  2. 20 19
      boman-api/boman-api-system/src/main/java/com/boman/system/api/factory/RemoteFileFallbackFactory.java
  3. 7 0
      boman-api/boman-domain/pom.xml
  4. 4 0
      boman-api/boman-domain/src/main/java/com.boman.domain/dto/AjaxResult.java
  5. 16 9
      boman-api/boman-domain/src/main/java/com.boman.domain/dto/Base64Dto.java
  6. 360 2
      boman-api/boman-domain/src/main/java/com.boman.domain/dto/TaskDto.java
  7. 25 1
      boman-api/boman-domain/src/main/java/com.boman.domain/dto/UpdateDto.java
  8. 62 0
      boman-api/boman-domain/src/main/java/com/boman/domain/utils/ThreadPoolService.java
  9. 12 7
      boman-auth/src/main/java/com/boman/auth/controller/TokenController.java
  10. 73 5
      boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/poi/ExcelUtil.java
  11. 5 0
      boman-common/boman-common-redis/src/main/java/com/boman/common/redis/RedisKey.java
  12. 9 0
      boman-common/boman-common-redis/src/main/java/com/boman/common/redis/service/RedisService.java
  13. 0 0
      boman-common/boman-common-security/src/main/java/com/boman/common/security/service/TokenService.java
  14. 42 0
      boman-modules/boman-file/src/main/java/com/boman/file/controller/ExcelController.java
  15. 5 0
      boman-modules/boman-file/src/main/java/com/boman/file/controller/SysFileController.java
  16. 18 0
      boman-modules/boman-file/src/main/java/com/boman/file/service/ISysFileService.java
  17. 97 12
      boman-modules/boman-file/src/main/java/com/boman/file/service/LocalSysFileServiceImpl.java
  18. 2 2
      boman-modules/boman-system/src/main/java/com/boman/system/controller/SysUserController.java
  19. 18 2
      boman-modules/boman-system/src/main/resources/mapper/system/SysUserMapper.xml
  20. 3 30
      boman-wechat/src/main/java/com/boman/wechat/controller/AppletLoginController.java

+ 7 - 3
boman-api/boman-api-system/src/main/java/com/boman/system/api/RemoteFileService.java

@@ -3,6 +3,7 @@ package com.boman.system.api;
 import com.boman.domain.dto.AjaxResult;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestPart;
@@ -18,8 +19,8 @@ import com.boman.system.api.factory.RemoteFileFallbackFactory;
  * @author ruoyi
  */
 @FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)
-public interface RemoteFileService
-{
+public interface RemoteFileService {
+
     /**
      * 上传文件
      *
@@ -27,11 +28,14 @@ public interface RemoteFileService
      * @return 结果
      */
     @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
-    public R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
+    R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
 
     /**
      * 通用上传请求
      */
     @PostMapping("/upload/base64")
     AjaxResult uploadFileBase64(@RequestBody String base64);
+
+    @GetMapping("/getConfigPath")
+    String getConfigPath();
 }

+ 20 - 19
boman-api/boman-api-system/src/main/java/com/boman/system/api/factory/RemoteFileFallbackFactory.java

@@ -23,24 +23,25 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
     @Override
     public RemoteFileService create(Throwable throwable)
     {
-        log.error("文件服务调用失败:{}", throwable.getMessage());
-        return new RemoteFileService()
-        {
-            @Override
-            public R<SysFile> upload(MultipartFile file)
-            {
-                return R.fail("上传文件失败:" + throwable.getMessage());
-            }
-
-            /**
-             * 通用上传请求
-             *
-             * @param base64
-             */
-            @Override
-            public AjaxResult uploadFileBase64(String base64) {
-                return AjaxResult.error("上传文件失败:" + throwable.getMessage());
-            }
-        };
+//        log.error("文件服务调用失败:{}", throwable.getMessage());
+//        return new RemoteFileService()
+//        {
+//            @Override
+//            public R<SysFile> upload(MultipartFile file)
+//            {
+//                return R.fail("上传文件失败:" + throwable.getMessage());
+//            }
+//
+//            /**
+//             * 通用上传请求
+//             *
+//             * @param base64
+//             */
+//            @Override
+//            public AjaxResult uploadFileBase64(String base64) {
+//                return AjaxResult.error("上传文件失败:" + throwable.getMessage());
+//            }
+//        };
+        return null;
     }
 }

+ 7 - 0
boman-api/boman-domain/pom.xml

@@ -56,6 +56,13 @@
             <artifactId>lombok</artifactId>
             <version>1.18.4</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>20.0</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 4 - 0
boman-api/boman-domain/src/main/java/com.boman.domain/dto/AjaxResult.java

@@ -157,6 +157,10 @@ public class AjaxResult extends HashMap<String, Object>
         return AjaxResult.error(msg, null);
     }
 
+    public static AjaxResult error(Object data) {
+        return new AjaxResult(HttpStatus.ERROR, "失败", data);
+    }
+
     /**
      * 返回错误消息
      * 

+ 16 - 9
boman-api/boman-domain/src/main/java/com.boman.domain/dto/Base64Dto.java

@@ -1,20 +1,27 @@
 package com.boman.domain.dto;
 
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
 /**
  * @author shiqian
  * @date 2021年08月03日 11:24
  **/
-@Data
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
 public class Base64Dto {
 
     private String file;
     private String base64;
+
+    public String getFile() {
+        return file;
+    }
+
+    public void setFile(String file) {
+        this.file = file;
+    }
+
+    public String getBase64() {
+        return base64;
+    }
+
+    public void setBase64(String base64) {
+        this.base64 = base64;
+    }
 }

+ 360 - 2
boman-api/boman-domain/src/main/java/com.boman.domain/dto/TaskDto.java

@@ -14,8 +14,6 @@ import java.util.Map;
  * description:任务中心的DTO
  */
 
-@Data
-@Accessors(chain = true)
 public class TaskDto extends BaseDto {
     private static final long serialVersionUID = -1L;
 
@@ -236,4 +234,364 @@ public class TaskDto extends BaseDto {
     private String candidatorId;
 
     private String candidatorTableName;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getLastTaskId() {
+        return lastTaskId;
+    }
+
+    public void setLastTaskId(Long lastTaskId) {
+        this.lastTaskId = lastTaskId;
+    }
+
+    public String getIds() {
+        return ids;
+    }
+
+    public void setIds(String ids) {
+        this.ids = ids;
+    }
+
+    public Long getNodeId() {
+        return nodeId;
+    }
+
+    public void setNodeId(Long nodeId) {
+        this.nodeId = nodeId;
+    }
+
+    public Long getInstanceId() {
+        return instanceId;
+    }
+
+    public void setInstanceId(Long instanceId) {
+        this.instanceId = instanceId;
+    }
+
+    public Long getActId() {
+        return actId;
+    }
+
+    public void setActId(Long actId) {
+        this.actId = actId;
+    }
+
+    public Short getActType() {
+        return actType;
+    }
+
+    public void setActType(Short actType) {
+        this.actType = actType;
+    }
+
+    public Integer getRev() {
+        return rev;
+    }
+
+    public void setRev(Integer rev) {
+        this.rev = rev;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getApprovedTime() {
+        return approvedTime;
+    }
+
+    public void setApprovedTime(String approvedTime) {
+        this.approvedTime = approvedTime;
+    }
+
+    public Long getLastTask() {
+        return lastTask;
+    }
+
+    public void setLastTask(Long lastTask) {
+        this.lastTask = lastTask;
+    }
+
+    public Short getExcuStatus() {
+        return excuStatus;
+    }
+
+    public void setExcuStatus(Short excuStatus) {
+        this.excuStatus = excuStatus;
+    }
+
+    public Long getApprover() {
+        return approver;
+    }
+
+    public void setApprover(Long approver) {
+        this.approver = approver;
+    }
+
+    public Long getDelegateId() {
+        return delegateId;
+    }
+
+    public void setDelegateId(Long delegateId) {
+        this.delegateId = delegateId;
+    }
+
+    public Integer getLoadType() {
+        return loadType;
+    }
+
+    public void setLoadType(Integer loadType) {
+        this.loadType = loadType;
+    }
+
+    public Short getType() {
+        return type;
+    }
+
+    public void setType(Short type) {
+        this.type = type;
+    }
+
+    public Long getBusinessCode() {
+        return businessCode;
+    }
+
+    public void setBusinessCode(Long businessCode) {
+        this.businessCode = businessCode;
+    }
+
+    public Long getBusinessType() {
+        return businessType;
+    }
+
+    public void setBusinessType(Long businessType) {
+        this.businessType = businessType;
+    }
+
+    public String getBusinessBody() {
+        return businessBody;
+    }
+
+    public void setBusinessBody(String businessBody) {
+        this.businessBody = businessBody;
+    }
+
+    public Long getInitiator() {
+        return initiator;
+    }
+
+    public void setInitiator(Long initiator) {
+        this.initiator = initiator;
+    }
+
+    public String getInitiatorName() {
+        return initiatorName;
+    }
+
+    public void setInitiatorName(String initiatorName) {
+        this.initiatorName = initiatorName;
+    }
+
+    public Boolean getIsinitiator() {
+        return isinitiator;
+    }
+
+    public void setIsinitiator(Boolean isinitiator) {
+        this.isinitiator = isinitiator;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public String getSearchType() {
+        return searchType;
+    }
+
+    public void setSearchType(String searchType) {
+        this.searchType = searchType;
+    }
+
+    public Short getApproverType() {
+        return approverType;
+    }
+
+    public void setApproverType(Short approverType) {
+        this.approverType = approverType;
+    }
+
+    public String getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
+
+    public Long getBackId() {
+        return backId;
+    }
+
+    public void setBackId(Long backId) {
+        this.backId = backId;
+    }
+
+    public Long getModuleId() {
+        return moduleId;
+    }
+
+    public void setModuleId(Long moduleId) {
+        this.moduleId = moduleId;
+    }
+
+    public Short getProcessStatus() {
+        return processStatus;
+    }
+
+    public void setProcessStatus(Short processStatus) {
+        this.processStatus = processStatus;
+    }
+
+    public String getBusinessNumber() {
+        return businessNumber;
+    }
+
+    public void setBusinessNumber(String businessNumber) {
+        this.businessNumber = businessNumber;
+    }
+
+    public String getApproverName() {
+        return approverName;
+    }
+
+    public void setApproverName(String approverName) {
+        this.approverName = approverName;
+    }
+
+    public String getBusinessTypeName() {
+        return businessTypeName;
+    }
+
+    public void setBusinessTypeName(String businessTypeName) {
+        this.businessTypeName = businessTypeName;
+    }
+
+    public String getSearchField() {
+        return searchField;
+    }
+
+    public void setSearchField(String searchField) {
+        this.searchField = searchField;
+    }
+
+    public List<Map<String, String>> getApproverInfo() {
+        return approverInfo;
+    }
+
+    public void setApproverInfo(List<Map<String, String>> approverInfo) {
+        this.approverInfo = approverInfo;
+    }
+
+    public Integer getBatch() {
+        return batch;
+    }
+
+    public void setBatch(Integer batch) {
+        this.batch = batch;
+    }
+
+    public Long getBackNodeId() {
+        return backNodeId;
+    }
+
+    public void setBackNodeId(Long backNodeId) {
+        this.backNodeId = backNodeId;
+    }
+
+    public Long getPassNodeId() {
+        return passNodeId;
+    }
+
+    public void setPassNodeId(Long passNodeId) {
+        this.passNodeId = passNodeId;
+    }
+
+    public Boolean getPoll() {
+        return isPoll;
+    }
+
+    public void setPoll(Boolean poll) {
+        isPoll = poll;
+    }
+
+    public String getNodeName() {
+        return nodeName;
+    }
+
+    public void setNodeName(String nodeName) {
+        this.nodeName = nodeName;
+    }
+
+    public String getTableName() {
+        return tableName;
+    }
+
+    public void setTableName(String tableName) {
+        this.tableName = tableName;
+    }
+
+    public String getOther() {
+        return other;
+    }
+
+    public void setOther(String other) {
+        this.other = other;
+    }
+
+    public String getCandidatorId() {
+        return candidatorId;
+    }
+
+    public void setCandidatorId(String candidatorId) {
+        this.candidatorId = candidatorId;
+    }
+
+    public String getCandidatorTableName() {
+        return candidatorTableName;
+    }
+
+    public void setCandidatorTableName(String candidatorTableName) {
+        this.candidatorTableName = candidatorTableName;
+    }
 }

+ 25 - 1
boman-api/boman-domain/src/main/java/com.boman.domain/dto/UpdateDto.java

@@ -9,7 +9,7 @@ import org.slf4j.LoggerFactory;
  * @author shiqian
  * @date 2021年06月30日 16:42
  **/
-@Data
+
 public class UpdateDto {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(UpdateDto.class);
@@ -18,4 +18,28 @@ public class UpdateDto {
 
     private JSONObject condition;
     private JSONObject commitData;
+
+    public String getTableName() {
+        return tableName;
+    }
+
+    public void setTableName(String tableName) {
+        this.tableName = tableName;
+    }
+
+    public JSONObject getCondition() {
+        return condition;
+    }
+
+    public void setCondition(JSONObject condition) {
+        this.condition = condition;
+    }
+
+    public JSONObject getCommitData() {
+        return commitData;
+    }
+
+    public void setCommitData(JSONObject commitData) {
+        this.commitData = commitData;
+    }
 }

+ 62 - 0
boman-api/boman-domain/src/main/java/com/boman/domain/utils/ThreadPoolService.java

@@ -0,0 +1,62 @@
+package com.boman.domain.utils;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.*;
+
+/**
+ * @author shiqian
+ * @desc 线程池
+ * @date 2021年09月09日 14:56
+ **/
+@Service
+public class ThreadPoolService {
+
+    /**
+     * 自定义线程名称,方便的出错的时候溯源
+     */
+    private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder().setNameFormat("myself-pool-%d").build();
+
+
+    /**
+     * 功能描述:
+     *
+     * @param corePoolSize    线程池核心池的大小
+     * @param maximumPoolSize 线程池中允许的最大线程数量
+     * @param keepAliveTime   当线程数大于核心时,此为终止前多余的空闲线程等待新任务的最长时间
+     * @param unit            keepAliveTime 的时间单位
+     * @param workQueue       用来储存等待执行任务的队列
+     * @param threadFactory   创建线程的工厂类
+     * @param handler         拒绝策略类,当线程池数量达到上线并且workQueue队列长度达到上限时就需要对到来的任务做拒绝处理
+     * @return ExecutorService
+     */
+    private static final ExecutorService EXECUTOR_SERVICE = new ThreadPoolExecutor(
+            4,
+            40,
+            0L,
+            TimeUnit.MILLISECONDS,
+            new LinkedBlockingQueue<>(1024),
+            THREAD_FACTORY,
+            new ThreadPoolExecutor.AbortPolicy()
+    );
+
+    /**
+     * 获取线程池
+     *
+     * @return 线程池
+     */
+    private static ExecutorService getEs() {
+        return EXECUTOR_SERVICE;
+    }
+
+    /**
+     * 使用线程池创建线程并异步执行任务 ps:无返回值
+     *
+     * @param runnable 任务
+     */
+    public static void execute(Runnable runnable) {
+        getEs().execute(runnable);
+    }
+}
+

+ 12 - 7
boman-auth/src/main/java/com/boman/auth/controller/TokenController.java

@@ -1,5 +1,6 @@
 package com.boman.auth.controller;
 
+import com.boman.auth.service.SysLoginService;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 
@@ -7,20 +8,25 @@ import com.alibaba.fastjson.JSONObject;
 import com.boman.auth.form.PoolCache;
 import com.boman.auth.form.ScanPool;
 import com.boman.common.core.exception.BaseException;
+import com.boman.common.core.utils.StringUtils;
+import com.boman.common.security.service.TokenService;
 import com.boman.common.core.utils.SecurityUtils;
 import com.boman.domain.SysUser;
 import com.boman.domain.WechatEnum;
 import com.boman.domain.dto.AjaxResult;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-import com.boman.domain.form.LoginBody;
-import com.boman.auth.service.SysLoginService;
 import com.boman.domain.dto.R;
-import com.boman.common.core.utils.StringUtils;
-import com.boman.common.security.service.TokenService;
+import com.boman.domain.form.LoginBody;
 import com.boman.system.api.model.LoginUser;
 import com.boman.wechat.api.RemoteWechatService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+import com.boman.wechat.api.RemoteWechatService;
 
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import java.util.Map;
 import java.util.UUID;
 
@@ -34,7 +40,6 @@ import java.util.UUID;
 public class TokenController {
     @Autowired
     private TokenService tokenService;
-
     @Autowired
     private SysLoginService sysLoginService;
     @Resource

+ 73 - 5
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/poi/ExcelUtil.java

@@ -2,10 +2,6 @@ package com.boman.common.core.utils.poi;
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.util.TypeUtils;
-import com.boman.domain.annotation.Excel;
-import com.boman.domain.annotation.Excel.ColumnType;
-import com.boman.domain.annotation.Excel.Type;
-import com.boman.domain.annotation.Excels;
 import com.boman.common.core.text.Convert;
 import com.boman.common.core.utils.DateUtils;
 import com.boman.common.core.utils.StringUtils;
@@ -16,6 +12,10 @@ import com.boman.common.core.utils.obj.ObjectUtils;
 import com.boman.common.core.utils.reflect.ReflectUtils;
 import com.boman.domain.GenTableColumn;
 import com.boman.domain.SysDictData;
+import com.boman.domain.annotation.Excel;
+import com.boman.domain.annotation.Excel.ColumnType;
+import com.boman.domain.annotation.Excel.Type;
+import com.boman.domain.annotation.Excels;
 import com.boman.domain.constant.FormDataConstant;
 import org.apache.commons.lang3.BooleanUtils;
 import org.apache.poi.ss.usermodel.*;
@@ -27,6 +27,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.servlet.http.HttpServletResponse;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -39,7 +40,8 @@ import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
 import static com.boman.common.core.utils.obj.ObjectUtils.*;
-import static com.boman.domain.constant.FormDataConstant.*;
+import static com.boman.domain.constant.FormDataConstant.HR;
+import static com.boman.domain.constant.FormDataConstant.NEED_CONVERT_DATE_LIST;
 
 /**
  * Excel相关处理
@@ -482,6 +484,72 @@ public class ExcelUtil<T>
         }
     }
 
+    /**
+     * 功能描述: 通用的导出 异步
+     *
+     * @param outputStream       outputStream
+     * @param list               导出数据集合
+     * @param sheetName          工作表的名称
+     * @param listVisibleColumns 列表可见
+     * @param empty              所有的列
+     * @param result             true直接导出结果 false需要检查列...
+     */
+    public void asyncExportExcelCommon(FileOutputStream outputStream, List<Map<String, Object>> list
+            , String sheetName, List<GenTableColumn> listVisibleColumns, Boolean empty, Boolean result) throws IOException {
+        initJSONObject(list, sheetName, Type.EXPORT);
+        asyncExportExcelCommon(outputStream, list, listVisibleColumns, empty, result);
+    }
+
+    /**
+     * 功能描述: 通用导出
+     *
+     * @param outputStream       outputStream
+     * @param listVisibleColumns listVisibleColumns
+     * @param empty              true=>只带表头的excel,不含数据, false=>带数据的excel
+     * @param result             true直接导出结果, false需要检查列...
+     */
+    public void asyncExportExcelCommon(FileOutputStream outputStream, List<Map<String, Object>> list, List<GenTableColumn> listVisibleColumns
+            , Boolean empty, Boolean result) throws IOException {
+        try {
+            double sheetNo = Math.ceil(list.size() / sheetSize);
+            for (int index = 0; index <= sheetNo; index++) {
+                createSheet(sheetNo, index);
+
+                // 产生一行
+                Row row = sheet.createRow(0);
+                int columnIndex = 0;
+
+                // 直接导出结果,无需检查列
+                if (BooleanUtils.isTrue(result)) {
+                    Map<String, Object> map = list.get(0);
+                    for (Map.Entry<String, Object> entry : map.entrySet()) {
+                        String columnName = entry.getKey();
+                        columnName = covertHead(columnName);
+                        createCellByMap(columnName, row, columnIndex++);
+                    }
+
+                    if (BooleanUtils.isFalse(empty) && Type.EXPORT.equals(type)) {
+                        fillDataByListMap(index);
+                    }
+                } else {
+                    for (GenTableColumn column : listVisibleColumns) {
+                        createCellByColumn(column, row, columnIndex++);
+                    }
+
+                    if (BooleanUtils.isFalse(empty) && Type.EXPORT.equals(type)) {
+                        fillDataByColumns(index, row, listVisibleColumns);
+                    }
+                }
+            }
+
+            wb.write(outputStream);
+        } catch (Exception e) {
+            log.error("导出Excel异常{}", e.getMessage());
+        } finally {
+            close(outputStream);
+        }
+    }
+
     private String covertHead(String columnName) {
         switch (columnName){
             case "userName":

+ 5 - 0
boman-common/boman-common-redis/src/main/java/com/boman/common/redis/RedisKey.java

@@ -32,4 +32,9 @@ public class RedisKey {
      * 单据的seq
      */
     public static final String BILL_SQE = "BILL:SEQ:";
+
+    /**
+     * 异步下载时,判断是否下载完成,download:tableName:username
+     */
+    public static final String ASYNC_DOWNLOAD_SIGN = "download:";
 }

+ 9 - 0
boman-common/boman-common-redis/src/main/java/com/boman/common/redis/service/RedisService.java

@@ -34,6 +34,15 @@ public class RedisService
         redisTemplate.opsForValue().set(key, value);
     }
 
+    /**
+     * 功能描述: ttl
+     *
+     * @param key key
+     */
+    public <T> Long ttl(final String key) {
+        return redisTemplate.opsForValue().getOperations().getExpire(key);
+    }
+
     /**
      * 缓存基本的对象,Integer、String、实体类等
      *

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
boman-common/boman-common-security/src/main/java/com/boman/common/security/service/TokenService.java


+ 42 - 0
boman-modules/boman-file/src/main/java/com/boman/file/controller/ExcelController.java

@@ -1,8 +1,13 @@
 package com.boman.file.controller;
 
+import com.boman.common.core.utils.SecurityUtils;
+import com.boman.common.core.utils.obj.ObjectUtils;
+import com.boman.common.redis.RedisKey;
+import com.boman.common.redis.service.RedisService;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.domain.dto.ExportExcelDto;
 import com.boman.file.service.ISysFileService;
+import com.boman.file.service.LocalSysFileServiceImpl;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -19,6 +24,8 @@ public class ExcelController {
 
     @Resource
     private ISysFileService fileService;
+    @Resource
+    private RedisService redisService;
 
     /**
      * 功能描述: 通用的导入接口
@@ -59,6 +66,41 @@ public class ExcelController {
         return AjaxResult.error("失败");
     }
 
+    /**
+     * 功能描述: 通用的导出接口   异步
+     *
+     * @param response response
+     * @param dto      tableName
+     *                 empty(true=>只带表头的excel,不含数据, false=>带数据的excel)
+     *                 condition 查询条件
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @PostMapping("async/export")
+    public AjaxResult asyncExportExcelCommon(HttpServletResponse response, @RequestBody ExportExcelDto dto) {
+        try {
+            return fileService.asyncExportExcelCommon(response, dto);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return AjaxResult.error("失败");
+    }
+
+    /**
+     * 功能描述: 是否可以下载
+     *
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @GetMapping("/before/download")
+    public AjaxResult canDownloadIfOrNot() {
+        String redisKey = RedisKey.ASYNC_DOWNLOAD_SIGN + SecurityUtils.getUsername();
+        String sign = redisService.getCacheObject(redisKey);
+        if (LocalSysFileServiceImpl.DOWNLOADING.equals(sign)) {
+            return AjaxResult.success(false);
+        }
+
+        return AjaxResult.error(true);
+    }
 
     /**
      * 功能描述: 导出数据,只是sql不一样,其余的都是通用接口的内容

+ 5 - 0
boman-modules/boman-file/src/main/java/com/boman/file/controller/SysFileController.java

@@ -5,6 +5,7 @@ import com.boman.domain.dto.Base64Dto;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
@@ -66,5 +67,9 @@ public class SysFileController
         }
     }
 
+    @GetMapping("/getConfigPath")
+    public String getConfigPath(){
+        return sysFileService.getConfigPath();
+    }
 
 }

+ 18 - 0
boman-modules/boman-file/src/main/java/com/boman/file/service/ISysFileService.java

@@ -62,6 +62,17 @@ public interface ISysFileService
      */
     AjaxResult exportExcelCommon(HttpServletResponse response, ExportExcelDto dto);
 
+    /**
+     * 功能描述: 通用的导出接口
+     *
+     * @param response response
+     * @param dto      tableName
+     *                 empty(true=>只带表头的excel,不含数据, false=>带数据的excel)
+     *                 condition 查询条件
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    AjaxResult asyncExportExcelCommon(HttpServletResponse response, ExportExcelDto dto) throws IOException;
+
     /**
      * 功能描述: 导出数据,只是sql不一样,其余的都是通用接口的内容
      *
@@ -72,4 +83,11 @@ public interface ISysFileService
      * @return com.boman.domain.dto.AjaxResult
      */
     AjaxResult statisticsByMonth(HttpServletResponse response, ExportExcelDto dto);
+
+    /**
+     * 功能描述: 获取系统配置
+     *
+     * @return java.lang.String
+     */
+    String getConfigPath();
 }

+ 97 - 12
boman-modules/boman-file/src/main/java/com/boman/file/service/LocalSysFileServiceImpl.java

@@ -1,17 +1,19 @@
 package com.boman.file.service;
 
 import com.alibaba.fastjson.JSONObject;
+import com.boman.common.core.utils.SecurityUtils;
 import com.boman.common.core.utils.obj.ObjectUtils;
 import com.boman.common.core.utils.poi.ExcelUtil;
-import com.boman.domain.dto.AjaxResult;
 import com.boman.common.redis.RedisKey;
 import com.boman.common.redis.service.RedisService;
 import com.boman.domain.GenTable;
 import com.boman.domain.GenTableColumn;
 import com.boman.domain.constant.MaskConstant;
+import com.boman.domain.dto.AjaxResult;
 import com.boman.domain.dto.ExportExcelDto;
 import com.boman.domain.dto.FormDataDto;
 import com.boman.domain.dto.ImportExcelDto;
+import com.boman.domain.utils.ThreadPoolService;
 import com.boman.file.utils.FileUploadUtils;
 import com.boman.web.core.api.RemoteAttendanceService;
 import com.boman.web.core.api.RemoteObjService;
@@ -26,8 +28,11 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 
 import static com.boman.common.core.utils.obj.ObjectUtils.map;
 
@@ -43,6 +48,7 @@ public class LocalSysFileServiceImpl implements ISysFileService
 {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(LocalSysFileServiceImpl.class);
+    public static final String DOWNLOADING = "downloading";
 
     @Resource
     private RemoteObjService remoteObjService;
@@ -152,21 +158,13 @@ public class LocalSysFileServiceImpl implements ISysFileService
 
         GenTable genTable = redisService.getCacheObject(RedisKey.TABLE_INFO + tableName);
         List<GenTableColumn> columns = genTable.getColumns();
-
+        columns = ExcelUtil.filterData(columns, 4, MaskConstant.LIST_VISIBLE::equals);
         ExcelUtil<JSONObject> util = new ExcelUtil<>(JSONObject.class);
-        List<Map<String, Object>> list = null;
+        List<Map<String, Object>> list;
         if (BooleanUtils.isTrue(empty)) {
             list = new ArrayList<>(0);
         } else {
-            FormDataDto condition = new FormDataDto();
-            condition.setTable(tableName);
-            condition.setFixedData(new JSONObject(dto.getCondition()));
-            AjaxResult ajaxResult = remoteObjService.getByMap(condition);
-            if (AjaxResult.checkSuccess(ajaxResult)) {
-                list = ((List<Map<String, Object>>) ajaxResult.get(AjaxResult.DATA_TAG));
-                columns = ExcelUtil.filterData(columns, 4, MaskConstant.LIST_VISIBLE::equals);
-                handleNullColumnValue(list, map(columns, GenTableColumn::getColumnName));
-            }
+            list = getData(dto, tableName, columns);
         }
 
         try {
@@ -177,6 +175,83 @@ public class LocalSysFileServiceImpl implements ISysFileService
         return null;
     }
 
+
+    /**
+     * 功能描述: 通用的导出接口
+     *
+     * @param response response
+     * @param dto      tableName
+     *                 empty(true=>只带表头的excel,不含数据, false=>带数据的excel)
+     *                 condition 查询条件
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @Override
+    public AjaxResult asyncExportExcelCommon(HttpServletResponse response, ExportExcelDto dto) throws IOException {
+        String tableName = dto.getTableName();
+        Boolean empty = dto.getEmpty();
+        ObjectUtils.requireNonNull(tableName, "exportExcelCommon tableName is empty");
+        ObjectUtils.requireNonNull(empty, "exportExcelCommon empty is empty");
+
+        GenTable genTable = redisService.getCacheObject(RedisKey.TABLE_INFO + tableName);
+        List<GenTableColumn> allColumn = genTable.getColumns();
+        List<GenTableColumn> columns = ExcelUtil.filterData(allColumn, 4, MaskConstant.LIST_VISIBLE::equals);
+
+        String filename = UUID.randomUUID().toString() + ".xlsx";
+        String fileAbsPath = localFilePath + "/" + filename;
+        String fileStaticPath = domain + localFilePrefix + "/" + filename;
+        File file = new File(fileAbsPath);
+
+        ExcelUtil<JSONObject> util = new ExcelUtil<>(JSONObject.class);
+
+        ThreadPoolService.execute(() -> {
+            List<Map<String, Object>> list;
+            int size = 0;
+            if (BooleanUtils.isTrue(empty)) {
+                list = new ArrayList<>(0);
+            } else {
+                LOGGER.info("开始查询, 线程名称: {}", Thread.currentThread().getName());
+                long currentTimeMillis = System.currentTimeMillis();
+                list = getData(dto, tableName, columns);
+                size = list.size();
+                LOGGER.info("查询到的数据长度为: {}, 查询耗时:{}秒", size, (System.currentTimeMillis() - currentTimeMillis) / 1000);
+            }
+
+            try {
+                util.asyncExportExcelCommon(new FileOutputStream(file), list, "sheet1", columns, empty, false);
+                long timeout = 1L;
+                if (size > 100000 && size < 500000) {
+                    timeout = 2L;
+                } else if(size > 500000){
+                    timeout = 4L;
+                }
+
+                redisService.setCacheObject(RedisKey.ASYNC_DOWNLOAD_SIGN + SecurityUtils.getUsername(), DOWNLOADING, timeout, TimeUnit.MINUTES);
+            } catch (IOException e) {
+                LOGGER.error("导出失败", e);
+                e.printStackTrace();
+            }
+        });
+
+
+        return AjaxResult.success("成功", fileStaticPath);
+    }
+
+    private List<Map<String, Object>> getData(ExportExcelDto dto, String tableName, List<GenTableColumn> columns) {
+        List<Map<String, Object>> list = null;
+        FormDataDto condition = new FormDataDto();
+        condition.setTable(tableName);
+        condition.setFixedData(new JSONObject(dto.getCondition()));
+        condition.setPageSize(Integer.MAX_VALUE);
+        condition.setPageNo(1);
+        AjaxResult ajaxResult = remoteObjService.getByMap(condition);
+        if (AjaxResult.checkSuccess(ajaxResult)) {
+            list = ((List<Map<String, Object>>) ajaxResult.get(AjaxResult.DATA_TAG));
+            handleNullColumnValue(list, map(columns, GenTableColumn::getColumnName));
+        }
+
+        return list;
+    }
+
     /**
      * 功能描述: 导出数据,只是sql不一样,其余的都是通用接口的内容
      *
@@ -257,4 +332,14 @@ public class LocalSysFileServiceImpl implements ISysFileService
             }
         }
     }
+
+    /**
+     * 功能描述: 获取系统配置
+     *
+     * @return java.lang.String
+     */
+    @Override
+    public String getConfigPath() {
+        return localFilePrefix + "_._" + domain + "_._" + localFilePath;
+    }
 }

+ 2 - 2
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysUserController.java

@@ -125,7 +125,7 @@ public class SysUserController extends BaseController
     /**
      * 获取当前用户信息
      */
-    @GetMapping("/packInfo")
+    @PostMapping("/packInfo")
     public LoginUser packInfo(@RequestBody SysUser sysUser) {
         return packPermDeptRoles(sysUser);
     }
@@ -343,7 +343,7 @@ public class SysUserController extends BaseController
     @GetMapping("/getByPhone/{phone}")
     public SysUser getByPhone(@PathVariable("phone") String phone) {
         SysUser sysUser = userService.getByPhone(phone);
-        return ObjectUtils.requireNonNull(sysUser, String.format("手机号 [%s] 对应的用户不存在", sysUser.getPhonenumber()));
+        return ObjectUtils.requireNonNull(sysUser, String.format("手机号 [%s] 对应的用户不存在", phone));
     }
 
 

+ 18 - 2
boman-modules/boman-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -195,12 +195,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		update sys_user set open_id = #{openId} where id = #{id}
 	</update>
 
-	<select id="queryByOpenId" resultType="com.boman.domain.SysUser">
+	<select id="queryByOpenId" resultMap="SysUserResult">
 		select * from sys_user where open_id = #{openId} limit 1;
 	</select>
 
 	<select id="getByPhone" resultType="com.boman.domain.SysUser">
-		select * from sys_user where phonenumber = #{phone} limit 1;
+		select id,
+			   dept_id deptId,
+			   user_name userName,
+			   nick_name nickName,
+			   user_type userType,
+			   email,
+			   phonenumber,
+			   sex,
+			   avatar,
+			   password,
+			   status,
+			   del_flag delFlag,
+			   login_ip loginIp,
+			   login_date loginDate,
+			   union_id unionId,
+			   open_id openId
+		from sys_user where phonenumber = #{phone} limit 1;
 	</select>
 	
 </mapper> 

+ 3 - 30
boman-wechat/src/main/java/com/boman/wechat/controller/AppletLoginController.java

@@ -1,16 +1,9 @@
 package com.boman.wechat.controller;
 
-import com.boman.common.core.enums.UserStatus;
-import com.boman.common.core.exception.BaseException;
 import com.boman.common.security.service.TokenService;
 import com.boman.domain.AppletLoginForm;
-import com.boman.domain.SysUser;
-import com.boman.domain.constant.Constants;
-import com.boman.domain.dto.AjaxResult;
 import com.boman.domain.dto.AppletSessionDTO;
-import com.boman.system.api.RemoteLogService;
-import com.boman.system.api.RemoteUserService;
-import com.boman.system.api.model.LoginUser;
+import com.boman.domain.dto.R;
 import com.boman.wechat.utils.WxCodeSessionUtil;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -31,32 +24,12 @@ public class AppletLoginController {
     @Resource
     private WxCodeSessionUtil codeUtil;
     @Resource
-    private RemoteUserService remoteUserService;
-    @Resource
-    private RemoteLogService remoteLogService;
-    @Resource
     private TokenService tokenService;
 
     @PostMapping("/login")
-    public AjaxResult getPhone(@RequestBody AppletLoginForm form) {
+    public R<Map<String, Object>> getPhone(@RequestBody AppletLoginForm form) {
         AppletSessionDTO dto = codeUtil.jscode2Session(form);
-        String phoneNumber = dto.getPhoneNumber();
-        SysUser user = remoteUserService.getByPhone(phoneNumber);
-        String userName = user.getUserName();
-        if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
-            remoteLogService.saveLogininfor(userName, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
-            throw new BaseException("对不起,您的账号:" + userName + " 已被删除");
-        }
-
-        if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
-            remoteLogService.saveLogininfor(userName, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
-            throw new BaseException("对不起,您的账号:" + userName + " 已停用");
-        }
-
-        remoteLogService.saveLogininfor(userName, Constants.LOGIN_SUCCESS, "登录成功");
-        LoginUser loginUser = remoteUserService.packInfo(user);
-        Map<String, Object> map = tokenService.createToken(loginUser);
-        return AjaxResult.success(map);
+        return tokenService.appletLogin(dto.getPhoneNumber());
     }
 
 }

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio