|
|
@@ -17,8 +17,7 @@ import org.sky.scientific.pojo.entity.YfzdEntity;
|
|
|
import org.sky.scientific.service.IYfzdService;
|
|
|
import org.sky.scientific.utils.ZipDownloadUtils;
|
|
|
import org.sky.scientific.utils.ZipFileRef;
|
|
|
-import org.sky.scientific.utils.ZipGroup;
|
|
|
-import org.sky.scientific.utils.ZipSubDir;
|
|
|
+import org.sky.scientific.utils.ZipDir;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.BufferedOutputStream;
|
|
|
@@ -69,23 +68,23 @@ public class YfzdServiceImpl extends BaseServiceImpl<YfzdMapper, YfzdEntity> imp
|
|
|
@Override
|
|
|
public void downloadZipFiles(HttpServletRequest request, HttpServletResponse response, String year) {
|
|
|
// ==== 示例数据 ====
|
|
|
- List<ZipGroup> data = new ArrayList<>();
|
|
|
+ List<ZipDir> data = new ArrayList<>();
|
|
|
|
|
|
YfzdEntity yfzd = new YfzdEntity();
|
|
|
yfzd.setYearAndMonth(year);
|
|
|
Map<String, List<YfzdEntity>> map = selectYfzd(yfzd);
|
|
|
for (String type : map.keySet()) {
|
|
|
- ZipGroup group = new ZipGroup();
|
|
|
+ ZipDir group = new ZipDir();
|
|
|
group.setDirName(type);
|
|
|
|
|
|
List<YfzdEntity> list = map.get(type);
|
|
|
//企业制度
|
|
|
- ZipSubDir qiyezhiduDir = new ZipSubDir();
|
|
|
- qiyezhiduDir.setSubDirName("企业制度");
|
|
|
+ ZipDir qiyezhiduDir = new ZipDir();
|
|
|
+ qiyezhiduDir.setDirName("企业制度");
|
|
|
qiyezhiduDir.setFileRefs(new ArrayList<>());
|
|
|
//实施证明
|
|
|
- ZipSubDir shishizhengmDir = new ZipSubDir();
|
|
|
- shishizhengmDir.setSubDirName("企业制度实施证明");
|
|
|
+ ZipDir shishizhengmDir = new ZipDir();
|
|
|
+ shishizhengmDir.setDirName("企业制度实施证明");
|
|
|
shishizhengmDir.setFileRefs(new ArrayList<>());
|
|
|
|
|
|
for (YfzdEntity entity : list) {
|
|
|
@@ -104,12 +103,9 @@ public class YfzdServiceImpl extends BaseServiceImpl<YfzdMapper, YfzdEntity> imp
|
|
|
ref.setHttpUrl(obj.getString("value"));
|
|
|
shishizhengmDir.getFileRefs().add(ref);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
group.setSubDirs(Arrays.asList(qiyezhiduDir, shishizhengmDir));
|
|
|
data.add(group);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
try (BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream());
|
|
|
@@ -118,15 +114,15 @@ public class YfzdServiceImpl extends BaseServiceImpl<YfzdMapper, YfzdEntity> imp
|
|
|
ZipDownloadUtils.setResponse(request, response, fileName);
|
|
|
// 快速压缩
|
|
|
zipOut.setLevel(Deflater.BEST_SPEED);
|
|
|
- for (ZipGroup group : data) {
|
|
|
+ for (ZipDir group : data) {
|
|
|
String groupDir = ZipDownloadUtils.safeName(group.getDirName()) + "/";
|
|
|
- List<ZipSubDir> subDirs = group.getSubDirs();
|
|
|
+ List<ZipDir> subDirs = group.getSubDirs();
|
|
|
if (subDirs == null || subDirs.isEmpty()) {
|
|
|
ZipDownloadUtils.writeEmptyDirToZip(zipOut, groupDir);
|
|
|
continue;
|
|
|
}
|
|
|
- for (ZipSubDir subDir : subDirs) {
|
|
|
- String subDirPath = groupDir + ZipDownloadUtils.safeName(subDir.getSubDirName()) + "/";
|
|
|
+ for (ZipDir subDir : subDirs) {
|
|
|
+ String subDirPath = groupDir + ZipDownloadUtils.safeName(subDir.getDirName()) + "/";
|
|
|
List<ZipFileRef> fileRefs = subDir.getFileRefs();
|
|
|
if (fileRefs == null || fileRefs.isEmpty()) {
|
|
|
ZipDownloadUtils.writeEmptyDirToZip(zipOut, subDirPath);
|