浏览代码

查询条件 2

shiqian 3 年之前
父节点
当前提交
0f85f9a659

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

@@ -110,6 +110,10 @@ public class ExcelController {
     public AjaxResult canDownloadIfOrNot() {
         String redisKey = RedisKey.ASYNC_DOWNLOAD_YMJZ + SecurityUtils.getUsername();
         JSONObject jsonObject = redisService.getCacheObject(redisKey);
+        if (isEmpty(jsonObject)) {
+            return AjaxResult.success(false);
+        }
+
         String fileAbsPath = jsonObject.getString("fileAbsPath");
         String fileStaticPath = jsonObject.getString("fileStaticPath");
         if (isEmpty(fileAbsPath)) {
@@ -122,23 +126,12 @@ public class ExcelController {
         }
 
         long length = file.length();
-        return length == 0 ? AjaxResult.success(false) : AjaxResult.success(fileStaticPath, true);
-
-//        if (length == 0) {
-//            return AjaxResult.success(false);
-//        } else {
-//            return AjaxResult.success(true);
-//        }
-//        // 可以下载
-//        if (BooleanUtils.isFalse(download)) {
-//            jsonObject.put("download", true);
-//            redisService.deleteObject(redisKey);
-//            return AjaxResult.success(jsonObject);
-//        }
-//
-//        jsonObject.clear();
-//        jsonObject.put("download", false);
-//        return AjaxResult.success(false);
+        if (length == 0) {
+            return AjaxResult.success(false);
+        } else {
+            redisService.deleteObject(redisKey);
+            return AjaxResult.success(fileStaticPath, true);
+        }
     }
 
     /**

+ 18 - 10
boman-modules/boman-file/src/main/java/com/boman/file/service/LocalSysFileServiceImpl.java

@@ -249,7 +249,7 @@ public class LocalSysFileServiceImpl implements ISysFileService
                     size = list.size();
                 }
 
-                LOGGER.info("查询到的数据长度为: {}, 查询耗时:{}秒", size, (System.currentTimeMillis() - currentTimeMillis) / 1000);
+                LOGGER.info("查询到的数据长度为: {}, 查询耗时:{}秒, 文件:{}", size, (System.currentTimeMillis() - currentTimeMillis) / 1000, filename);
             }
 
             try {
@@ -302,13 +302,17 @@ public class LocalSysFileServiceImpl implements ISysFileService
             List<Map<String, Object>> list;
             LOGGER.info("开始查询, 线程名称: {}", Thread.currentThread().getName());
             long currentTimeMillis = System.currentTimeMillis();
+            String key = RedisKey.ASYNC_DOWNLOAD_YMJZ + username;
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("fileStaticPath", fileStaticPath);
+            jsonObject.put("fileAbsPath", fileAbsPath);
+            redisService.setCacheObject(key, jsonObject);
             list = listYmjz(info, columns);
             boolean empty = isEmpty(list);
             int size = BooleanUtils.isFalse(empty) ? 0 : list.size();
             LOGGER.info("查询到的数据长度为: {}, 查询耗时:{}秒", size, (System.currentTimeMillis() - currentTimeMillis) / 1000);
 
             try {
-                String key = RedisKey.ASYNC_DOWNLOAD_YMJZ + username;
                 util.asyncExportExcelCommon(new FileOutputStream(file), list, "sheet1", columns, empty, false);
                 long timeout = 2L;
                 if (size > 100000 && size < 500000) {
@@ -316,11 +320,6 @@ public class LocalSysFileServiceImpl implements ISysFileService
                 } else if (size > 500000) {
                     timeout = 10L;
                 }
-
-                JSONObject jsonObject = new JSONObject();
-                jsonObject.put("fileStaticPath", fileStaticPath);
-                jsonObject.put("fileAbsPath", fileAbsPath);
-                redisService.setCacheObject(key, jsonObject, timeout, TimeUnit.MINUTES);
             } catch (IOException e) {
                 LOGGER.error("导出失败", e);
                 e.printStackTrace();
@@ -351,6 +350,7 @@ public class LocalSysFileServiceImpl implements ISysFileService
         List<Map<String, Object>> list = null;
         Map<String, Object> formData = dto.getCondition();
         String idCard = (String) formData.get("idCard");
+        String userName = (String) formData.get("userName");
         String phoneNum = (String) formData.get("phoneNum");
         String jici = (String) formData.get("jici");
         String keyIndustries = (String) formData.get("keyIndustries");
@@ -358,11 +358,14 @@ public class LocalSysFileServiceImpl implements ISysFileService
         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) {
+        String shouldSlow = (String) formData.get("shouldSlow");
+        Integer deptIdTemp = (Integer) formData.get("deptId");
+        Long deptId;
+        if (deptIdTemp == null) {
             LoginUser loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token);
             deptId = loginUser.getSysUser().getDeptId();
+        } else {
+            deptId = deptIdTemp.longValue();
         }
 
         List<SysDept> sysDepts = remoteDeptService.listChildrenDepts(deptId);
@@ -378,6 +381,7 @@ public class LocalSysFileServiceImpl implements ISysFileService
         condition.setTable(tableName);
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("dept_id", deptIdList);
+        jsonObject.put("is_del", 'N');
         if (isNotEmpty(idCard)) {
             jsonObject.put("id_card", idCard);
         }
@@ -386,6 +390,10 @@ public class LocalSysFileServiceImpl implements ISysFileService
             jsonObject.put("phone_num", phoneNum);
         }
 
+        if (isNotEmpty(userName)) {
+            jsonObject.put("user_name", userName);
+        }
+
         if (isNotEmpty(jici)) {
             jsonObject.put("jici", jici);
         }