|
@@ -25,8 +25,13 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import java.io.OutputStream;
|
|
|
|
+import java.net.URLEncoder;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -399,6 +404,37 @@ public class CwProjectRecordsController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 下载项目导入模板
|
|
|
|
+ *
|
|
|
|
+ * @param response
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/importFinance/template")
|
|
|
|
+ @ApiOperation(value = "下载模板")
|
|
|
|
+ public void importFinanceTemplate(HttpServletResponse response, HttpServletRequest request) {
|
|
|
|
+ try {
|
|
|
|
+ InputStream inputStream = this.getClass().getResourceAsStream("/dot/项目批量导入模板.xlsx");
|
|
|
|
+ //强制下载不打开
|
|
|
|
+ response.setContentType("application/force-download");
|
|
|
|
+ OutputStream out = response.getOutputStream();
|
|
|
|
+ //使用URLEncoder来防止文件名乱码或者读取错误
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("project_records_template.xlsx", "UTF-8"));
|
|
|
|
+ int b = 0;
|
|
|
|
+ byte[] buffer = new byte[1000000];
|
|
|
|
+ while (b != -1) {
|
|
|
|
+ b = inputStream.read(buffer);
|
|
|
|
+ if (b != -1) out.write(buffer, 0, b);
|
|
|
|
+ }
|
|
|
|
+ inputStream.close();
|
|
|
|
+ out.close();
|
|
|
|
+ out.flush();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|