|
|
|
@ -1,7 +1,10 @@
|
|
|
|
|
package com.dsideal.QingLong.Zbdc.Controller;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.compress.ZipWriter;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.dsideal.QingLong.Base.Model.BaseModel;
|
|
|
|
|
import com.dsideal.QingLong.Bean.TZbdcTree;
|
|
|
|
|
import com.dsideal.QingLong.Interceptor.EmptyInterface;
|
|
|
|
|
import com.dsideal.QingLong.Interceptor.IsLoginInterface;
|
|
|
|
@ -22,8 +25,11 @@ import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
public class ZbdcController extends Controller {
|
|
|
|
@ -1054,12 +1060,68 @@ public class ZbdcController extends Controller {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:一键导出
|
|
|
|
|
* 功能:一键导出(学校使用)
|
|
|
|
|
*
|
|
|
|
|
* @param year
|
|
|
|
|
*/
|
|
|
|
|
@IsLoginInterface({})
|
|
|
|
|
public void CheckOneKeyExportExcel(int year) {
|
|
|
|
|
public void CheckOneKeyExportExcel(int year) throws URISyntaxException, IOException {
|
|
|
|
|
if (year == 0) year = DateTime.now().year();//如果没有传入获取的年份,那么就是系统的默认当前年份
|
|
|
|
|
//当前登录人员的单位ID
|
|
|
|
|
String bureau_id = SessionKit.get(getRequest(), getResponse(), "bureau_id");
|
|
|
|
|
String excelPath = CommonUtil.getClassPath() + PropKit.get("excelExportTemplatePathSuffix").replace("\\", "/");
|
|
|
|
|
// 定义压缩包的输出路径
|
|
|
|
|
File zipFile = new File(excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".zip");
|
|
|
|
|
Map<String, String> _map = new HashMap<>();
|
|
|
|
|
//1、基础信息
|
|
|
|
|
Page<Record> p1 = zm.getQueryBaseInfo(null, 0, year, null, 1, 99999, bureau_id);
|
|
|
|
|
String template = excelPath + "Query_BaseInfo.xlsx";
|
|
|
|
|
//导出
|
|
|
|
|
String excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xlsx";
|
|
|
|
|
ExcelExportUtil.exportByTemplate(p1.getList(), template, excelFile);
|
|
|
|
|
_map.put(excelFile, "基础信息.xlsx");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//2、常规装备
|
|
|
|
|
Page<Record> p2 = zm.getQueryCgzb(null, 0, year, null, 1, 99999, bureau_id);
|
|
|
|
|
template = excelPath + "Query_Cgzb.xlsx";
|
|
|
|
|
//导出
|
|
|
|
|
excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xlsx";
|
|
|
|
|
ExcelExportUtil.exportByTemplate(p2.getList(), template, excelFile);
|
|
|
|
|
_map.put(excelFile, "常规装备.xlsx");
|
|
|
|
|
|
|
|
|
|
//3、仪器设备
|
|
|
|
|
Page<Record> p3 = zm.getQueryYqsb("'" + bureau_id + "'", year, "", "", 0, 0, 1, 99999);
|
|
|
|
|
template = excelPath + "Query_Yqsb.xlsx";
|
|
|
|
|
//导出
|
|
|
|
|
excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xlsx";
|
|
|
|
|
ExcelExportUtil.exportByTemplate(p3.getList(), template, excelFile);
|
|
|
|
|
_map.put(excelFile, "仪器装备.xlsx");
|
|
|
|
|
|
|
|
|
|
//4、信息化设备
|
|
|
|
|
List<Record> list = zm.getXxzbdcTable();
|
|
|
|
|
for (Record record : list) {
|
|
|
|
|
int dcb_id = record.getInt("dcb_id");
|
|
|
|
|
String dcb_name = record.getStr("dcb_name");
|
|
|
|
|
Page<Record> p4 = zm.getQueryXxhsb(bureau_id, null, 0, year, null, dcb_id, 1, 99999);
|
|
|
|
|
template = excelPath + "Query_Xxhsb.xlsx";
|
|
|
|
|
//导出
|
|
|
|
|
excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xlsx";
|
|
|
|
|
ExcelExportUtil.exportByTemplate(p4.getList(), template, excelFile);
|
|
|
|
|
_map.put(excelFile, "信息化设备/"+dcb_name + ".xlsx");
|
|
|
|
|
}
|
|
|
|
|
// 使用 ZipWriter 创建 ZIP 包并添加文件,同时更改文件名称
|
|
|
|
|
ZipWriter zipWriter = new ZipWriter(zipFile, StandardCharsets.UTF_8);
|
|
|
|
|
|
|
|
|
|
// 使用 keySet() 遍历
|
|
|
|
|
for (String key : _map.keySet()) {
|
|
|
|
|
zipWriter.add(_map.get(key), new FileInputStream(key));
|
|
|
|
|
}
|
|
|
|
|
zipWriter.close();
|
|
|
|
|
//学校名称
|
|
|
|
|
BaseModel bm = new BaseModel();
|
|
|
|
|
String school_name = bm.getOrgInfoById(bureau_id).getStr("org_name");
|
|
|
|
|
//导出
|
|
|
|
|
renderFile(zipFile, "【" + school_name + "】" + year + "年装备信息.zip");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|