Browse Source

批量下载重出吃力

anderx 2 years ago
parent
commit
3dfc4654cf

+ 4 - 1
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -190,8 +190,10 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         ZipOutputStream zip = new ZipOutputStream(outputStream);
         downloadFileName="项目打卡数据_"+DateUtils.dateTimeNow()+".zip";
         String[] idList = ids.split(",");
+        Integer logx=0;
         for (String id : idList) {
             ProjectStaffRecord psr = projectStaffRecordMapper.selectByPrimaryKey(Long.valueOf(id));
+            //防止重名码
             if (psr != null) {
                 ProjectTask projectTask = projectTaskMapper.selectByPrimaryKey(psr.getPid());
                 String annexUrl = psr.getAnnexUrl();
@@ -202,6 +204,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
                     for (String s : split) {
                         if (StringUtils.isNotEmpty(s)){
                             index++;
+                            logx++;
                             String url=s.replace("/profile/upload","");
                             url=RuoYiConfig.getUploadPath()+url;
                             System.out.println(url);
@@ -209,7 +212,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
                             if (file.exists()){
                                 try {
                                     String suffix = s.substring(s.indexOf("."), s.length());
-                                    String fileName=projectTask.getName()+"_"+psr.getName()+"_"+recordTimes+"_"+index+suffix;
+                                    String fileName=projectTask.getName()+"_"+psr.getName()+"_"+recordTimes+logx+"_"+index+suffix;
                                     ZipEntry e = new ZipEntry(fileName);
                                     zip.putNextEntry(e);
                                     IOUtils.write(FileUtils.getBytes(file),zip);

+ 1 - 0
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectTaskServiceImpl.java

@@ -155,6 +155,7 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
                     if(StringUtils.isNotBlank(p.getStaffName())) {
                         String[] split = p.getStaffName().split(",");
                         for (String s : split) {
+                            System.out.println(s);
                             ProjectStaff newPs = new ProjectStaff();
                             SysUser sysUser = userMapper.selectByNikeName(s,company);
                             if (sysUser == null) {