shiqian il y a 3 ans
Parent
commit
cc4f31df43

+ 10 - 3
boman-modules/boman-file/src/main/java/com/boman/file/controller/ExcelController.java

@@ -2,15 +2,12 @@ package com.boman.file.controller;
 
 import com.alibaba.fastjson.JSONObject;
 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.VaccineInfoOperation;
 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.apache.commons.lang3.BooleanUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -19,6 +16,8 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 
+import static com.boman.common.core.utils.obj.ObjectUtils.isEmpty;
+
 /**
  * @author shiqian
  * @date 2021年06月07日 16:24
@@ -113,7 +112,15 @@ public class ExcelController {
         JSONObject jsonObject = redisService.getCacheObject(redisKey);
         String fileAbsPath = jsonObject.getString("fileAbsPath");
         String fileStaticPath = jsonObject.getString("fileStaticPath");
+        if (isEmpty(fileAbsPath)) {
+            return AjaxResult.success(false);
+        }
+
         File file = new File(fileAbsPath);
+        if (!file.exists()) {
+            return AjaxResult.success(false);
+        }
+
         long length = file.length();
         return length == 0 ? AjaxResult.success(false) : AjaxResult.success(fileStaticPath, true);
 

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

@@ -46,8 +46,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 
-import static com.boman.common.core.utils.obj.ObjectUtils.isEmpty;
-import static com.boman.common.core.utils.obj.ObjectUtils.map;
+import static com.boman.common.core.utils.obj.ObjectUtils.*;
 
 /**
  * 本地文件存储
@@ -242,9 +241,9 @@ public class LocalSysFileServiceImpl implements ISysFileService
             } else {
                 LOGGER.info("开始查询, 线程名称: {}", Thread.currentThread().getName());
                 long currentTimeMillis = System.currentTimeMillis();
-                list = getData1(dto, tableName, columns, deptIdList);
+                list = getData1(dto, tableName, columns, token);
                 if (isEmpty(list)) {
-                    size =0;
+                    size = 0;
                     emptyIn = true;
                 } else {
                     size = list.size();
@@ -255,18 +254,18 @@ public class LocalSysFileServiceImpl implements ISysFileService
 
             try {
                 util.asyncExportExcelCommon(new FileOutputStream(file), list, "sheet1", columns, emptyIn, false);
-                long timeout = 2L;
-                if (size > 100000 && size < 500000) {
-                    timeout = 5L;
-                } else if(size > 500000){
-                    timeout = 10L;
-                }
+//                long timeout = 2L;
+//                if (size > 100000 && size < 500000) {
+//                    timeout = 5L;
+//                } else if(size > 500000){
+//                    timeout = 10L;
+//                }
 
                 String key = RedisKey.ASYNC_DOWNLOAD_YMJZ + username;
                 JSONObject jsonObject = new JSONObject();
                 jsonObject.put("fileStaticPath", fileStaticPath);
                 jsonObject.put("fileAbsPath", fileAbsPath);
-                redisService.setCacheObject(key, jsonObject, timeout, TimeUnit.MINUTES);
+                redisService.setCacheObject(key, jsonObject);
             } catch (IOException e) {
                 LOGGER.error("导出失败", e);
                 e.printStackTrace();
@@ -348,12 +347,71 @@ public class LocalSysFileServiceImpl implements ISysFileService
         return list;
     }
 
-    private List<Map<String, Object>> getData1(ExportExcelDto dto, String tableName, List<GenTableColumn> columns, List<Long> deptIdList) {
+    private List<Map<String, Object>> getData1(ExportExcelDto dto, String tableName, List<GenTableColumn> columns, String token) {
         List<Map<String, Object>> list = null;
+        Map<String, Object> formData = dto.getCondition();
+        String idCard = (String) formData.get("idCard");
+        String phoneNum = (String) formData.get("phoneNum");
+        String jici = (String) formData.get("jici");
+        String keyIndustries = (String) formData.get("keyIndustries");
+        String vaccineName = (String) formData.get("vaccineName");
+        String vaccinationPlace = (String) formData.get("vaccinationPlace");
+        String isVaccination = (String) formData.get("isVaccination");
+        String shouldBe = (String) formData.get("shouldBe");
+        String shouldSlow = (String) formData.get("shouldslow");
+        long deptId = ((Number) formData.get("deptId")).longValue();
+        if (deptId == 0) {
+            LoginUser loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token);
+            deptId = loginUser.getSysUser().getDeptId();
+        }
+
+        List<SysDept> sysDepts = remoteDeptService.listChildrenDepts(deptId);
+        List<Long> deptIdList = new ArrayList<>();
+        if (sysDepts != null && sysDepts.size() > 0) {
+            for (SysDept sysDept : sysDepts) {
+                Long id = sysDept.getId();
+                deptIdList.add(id);
+            }
+        }
+
         FormDataDto condition = new FormDataDto();
         condition.setTable(tableName);
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("dept_id", deptIdList);
+        if (isNotEmpty(idCard)) {
+            jsonObject.put("id_card", idCard);
+        }
+
+        if (isNotEmpty(phoneNum)) {
+            jsonObject.put("phone_num", phoneNum);
+        }
+
+        if (isNotEmpty(jici)) {
+            jsonObject.put("jici", jici);
+        }
+
+        if (isNotEmpty(keyIndustries)) {
+            jsonObject.put("key_industries", keyIndustries);
+        }
+
+        if (isNotEmpty(vaccineName)) {
+            jsonObject.put("vaccine_name", vaccineName);
+        }
+
+        if (isNotEmpty(vaccinationPlace)) {
+            jsonObject.put("vaccination_place", vaccinationPlace);
+        }
+        if (isNotEmpty(isVaccination)) {
+            jsonObject.put("is_vaccination", isVaccination);
+        }
+        if (isNotEmpty(shouldBe)) {
+            jsonObject.put("should_be", shouldBe);
+        }
+
+        if (isNotEmpty(shouldSlow)) {
+            jsonObject.put("should_slow", shouldSlow);
+        }
+
         condition.setFixedData(jsonObject);
         condition.setPageSize(Integer.MAX_VALUE);
         condition.setPageNo(1);