Browse Source

Merge remote-tracking branch 'origin/master'

jzh 1 year ago
parent
commit
fae08b9046

+ 2 - 15
zjugis-framework/zjugis-spring-boot-starter-file/src/main/java/com/zjugis/framework/file/core/client/s3/S3FileClient.java

@@ -92,31 +92,18 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
 
     @Override
     public String upload(byte[] content, String path, String type) throws Exception {
-        String objectName = generateUniqueFileName(path);
         // 执行上传
         client.putObject(PutObjectArgs.builder()
                 .bucket(config.getBucket()) // bucket 必须传递
                 .contentType(type)
-                .object(objectName) // 相对路径作为 key
+                .object(path) // 相对路径作为 key
                 .stream(new ByteArrayInputStream(content), content.length, -1) // 文件内容
                 .build());
         // 拼接返回路径
-        return config.getDomain() + "/" + objectName;
+        return config.getDomain() + "/" + path;
     }
 
 
-    private static String generateUniqueFileName(String path) {
-        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date());
-        int dotIndex = path.lastIndexOf('.');
-        if (dotIndex != -1) {
-            String name = path.substring(0, dotIndex);
-            String extension = path.substring(dotIndex);
-            return name + "_" + timeStamp + extension;
-        } else {
-            return path + "_" + timeStamp;
-        }
-    }
-
 
     @Override
     public void delete(String path) throws Exception {

+ 11 - 0
zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/dal/mysql/report/ReportMapper.java

@@ -2,6 +2,9 @@ package com.zjugis.module.adm.dal.mysql.report;
 
 import java.util.*;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zjugis.framework.common.pojo.PageResult;
 import com.zjugis.framework.mybatis.core.query.LambdaQueryWrapperX;
 import com.zjugis.framework.mybatis.core.mapper.BaseMapperX;
@@ -10,6 +13,8 @@ import com.zjugis.module.adm.controller.admin.report.dto.report.ReportReqDTO;
 import com.zjugis.module.adm.controller.admin.report.dto.report.ReportPageReqDTO;
 import com.zjugis.module.adm.dal.dataobject.report.ReportDO;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 import static com.zjugis.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 
@@ -79,4 +84,10 @@ public interface ReportMapper extends BaseMapperX<ReportDO> {
                 .eqIfPresent(ReportDO::getReportMonth, reqVO.getReportMonth()));
     }
 
+
+    @Select("SELECT REPORT.* FROM ADM_REPORT_RECEIVE RECEIVE LEFT JOIN  ADM_REPORT REPORT " +
+            "ON RECEIVE.REPORT_ID = REPORT.ID " +
+            "${ew.customSqlSegment}")
+    Page<ReportDO> getReportList(Page<ReportDO> page, @Param(Constants.WRAPPER) Wrapper wrapper);
+
 }

+ 13 - 32
zjugis-module-adm/zjugis-module-adm-biz/src/main/java/com/zjugis/module/adm/service/report/ReportServiceImpl.java

@@ -199,51 +199,32 @@ public class ReportServiceImpl implements ReportService {
 
     @Override
     public PageResult<ReportRespVO> getReportMePage(ReportPageQueryDTO reqVO) {
-        //获取当前用户接收的报告Id
-        List<ReportReceiveRespVO> userReportReceiveList = reportReceiveService.getUserReportReceiveList(SecurityFrameworkUtils.getLoginUserId());
-        if (CollectionUtil.isEmpty(userReportReceiveList)) {
-            return new PageResult<>();
-        }
-        List<Long> reportIdList = userReportReceiveList.stream().filter(c -> c.getReportId() != null).limit(2000).map(ReportReceiveRespVO::getReportId).distinct().collect(Collectors.toList());
-
         //获取报告分页列表
-        LambdaQueryWrapper<ReportDO> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(ReportDO::getDeleted, 0);
-        queryWrapper.eq(ReportDO::getIsTemp, 0);
-//        queryWrapper.in(ReportDO::getId, reportIdList);
-        // 每1000个元素分一个List (oracle的in最多接收1000)
-        int chunkSize = 1000;
-        List<List<Long>> reportIdGroupList = IntStream.range(0, (reportIdList.size() + chunkSize - 1) / chunkSize).mapToObj(i -> reportIdList.subList(i * chunkSize, Math.min((i + 1) * chunkSize, reportIdList.size()))).collect(Collectors.toList());
-        int lastIndex = reportIdGroupList.size() - 1;
-        queryWrapper.and(qw -> {
-            for (int i = 0; i <= lastIndex; i++) {
-                List<Long> idList = reportIdGroupList.get(i);
-                qw.in(ReportDO::getId, idList);
-                // 判断是否是最后一个元素
-                if (i != lastIndex) {
-                    qw.or();
-                }
-            }
-        });
-        queryWrapper.eq(StrUtil.isNotBlank(reqVO.getReportType()), ReportDO::getReportType, reqVO.getReportType());
-        queryWrapper.orderByDesc(ReportDO::getUpdateTime);
+        QueryWrapper<ReportDO> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("REPORT.DELETED", 0);
+        queryWrapper.eq("REPORT.IS_TEMP", 0);
+        queryWrapper.eq("RECEIVE.DELETED", 0);
+        queryWrapper.eq("RECEIVE.RECEIVE_USER_ID", SecurityFrameworkUtils.getLoginUserId());
+        queryWrapper.eq(StrUtil.isNotBlank(reqVO.getReportType()),"REPORT.REPORT_TYPE", reqVO.getReportType());
+        queryWrapper.orderByDesc("REPORT.UPDATE_TIME");
         if (reqVO.getReportYear() != null) {
             if (StrUtil.isNotBlank(reqVO.getReportType())) {
                 if ("daily".equals(reqVO.getReportType())) {
-                    queryWrapper.between(ReportDO::getReportStartDate, DateUtils.getStartDateTime(reqVO.getReportYear(), reqVO.getReportMonth()), DateUtils.getEndDateTime(reqVO.getReportYear(), reqVO.getReportMonth()));
+                    queryWrapper.between("REPORT.REPORT_START_DATE", DateUtils.getStartDateTime(reqVO.getReportYear(), reqVO.getReportMonth()), DateUtils.getEndDateTime(reqVO.getReportYear(), reqVO.getReportMonth()));
                 } else {
-                    queryWrapper.eq(ReportDO::getReportYear, reqVO.getReportYear()).eq(ReportDO::getReportMonth, reqVO.getReportMonth()).eq(ReportDO::getReportWeek, reqVO.getReportWeek());
+                    queryWrapper.eq("REPORT.REPORT_YEAR", reqVO.getReportYear()).eq("REPORT.REPORT_MONTH", reqVO.getReportMonth());
                 }
             } else {
                 queryWrapper.and(qw -> {
-                    qw.eq(ReportDO::getReportType, "daily").between(ReportDO::getReportStartDate, DateUtils.getStartDateTime(reqVO.getReportYear(), reqVO.getReportMonth()), DateUtils.getEndDateTime(reqVO.getReportYear(), reqVO.getReportMonth()));
+                    qw.eq("REPORT.REPORT_TYPE", "daily").between("REPORT.REPORT_START_DATE", DateUtils.getStartDateTime(reqVO.getReportYear(), reqVO.getReportMonth()), DateUtils.getEndDateTime(reqVO.getReportYear(), reqVO.getReportMonth()));
                     qw.or();
-                    qw.eq(ReportDO::getReportType, "weekly").eq(ReportDO::getReportYear, reqVO.getReportYear()).eq(ReportDO::getReportMonth, reqVO.getReportMonth());
+                    qw.eq("REPORT.REPORT_TYPE", "weekly").eq("REPORT.REPORT_YEAR", reqVO.getReportYear()).eq("REPORT.REPORT_MONTH", reqVO.getReportMonth());
                 });
             }
         }
 
-        PageResult<ReportRespVO> reportPageResult = ReportConvert.INSTANCE.convertPage(reportMapper.selectPage(reqVO, queryWrapper));
+        Page<ReportDO> reportDOPage = reportMapper.getReportList(new Page<>(reqVO.getPageNo(), reqVO.getPageSize()), queryWrapper);
+        PageResult<ReportRespVO> reportPageResult = ReportConvert.INSTANCE.convertPage(new PageResult<>(reportDOPage.getRecords(), reportDOPage.getTotal()));
         if (reportPageResult.getTotal() == 0L) {
             return reportPageResult;
         }

+ 16 - 0
zjugis-module-infra/zjugis-module-infra-biz/src/main/java/com/zjugis/module/infra/service/file/FileServiceImpl.java

@@ -17,7 +17,10 @@ import org.jetbrains.annotations.NotNull;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
+import java.util.Locale;
 import java.util.Set;
 
 import static com.zjugis.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -76,6 +79,7 @@ public class FileServiceImpl implements FileService {
         if (StrUtil.isEmpty(name)) {
             name = path;
         }
+        path = generateUniqueFileName(path);
 
         // 上传到文件存储器
         FileClient client = clientId == null? fileConfigService.getMasterFileClient():fileConfigService.getFileClient(clientId);
@@ -94,6 +98,18 @@ public class FileServiceImpl implements FileService {
         return file;
     }
 
+    private static String generateUniqueFileName(String path) {
+        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date());
+        int dotIndex = path.lastIndexOf('.');
+        if (dotIndex != -1) {
+            String name = path.substring(0, dotIndex);
+            String extension = path.substring(dotIndex);
+            return name + "_" + timeStamp + extension;
+        } else {
+            return path + "_" + timeStamp;
+        }
+    }
+
     @Override
     public void deleteFile(Long id) throws Exception {
         // 校验存在

+ 1 - 1
zjugis-module-infra/zjugis-module-infra-biz/src/main/resources/bootstrap-local.yaml

@@ -5,7 +5,7 @@ server:
 spring:
   cloud:
     inetutils:
-      preferred-networks: 10.10
+      preferred-networks: 10.10cre
     nacos:
       server-addr: 10.10.10.7:8848
       discovery: