Selaa lähdekoodia

下载并合并文件

licailing 5 vuotta sitten
vanhempi
commit
bd2a1d8f33

+ 2 - 0
src/main/java/com/izouma/wenlvju/repo/RateRepo.java

@@ -18,4 +18,6 @@ public interface RateRepo extends JpaRepository<Rate, Long>, JpaSpecificationExe
     void softDelete(Long id);
     void softDelete(Long id);
 
 
     List<Rate> findAllByOrganizationIdAndYearAndStatusNot(@NonNull Long organizationId, String year, RateStatus status);
     List<Rate> findAllByOrganizationIdAndYearAndStatusNot(@NonNull Long organizationId, String year, RateStatus status);
+
+    Long countAllByOrganizationIdAndYear(@NonNull Long organizationId, String year);
 }
 }

+ 2 - 0
src/main/java/com/izouma/wenlvju/security/WebSecurityConfig.java

@@ -65,6 +65,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/user/regOrganization").permitAll()
                 .antMatchers("/user/regOrganization").permitAll()
                 .antMatchers("/gradingOrganization/all").permitAll()
                 .antMatchers("/gradingOrganization/all").permitAll()
                 .antMatchers("/district").permitAll()
                 .antMatchers("/district").permitAll()
+                .antMatchers("/rate/export/**").permitAll()
+                .antMatchers("/rate/test").permitAll()
                 .antMatchers("/district/NJ").permitAll()
                 .antMatchers("/district/NJ").permitAll()
                 .antMatchers("/upload/**").permitAll()
                 .antMatchers("/upload/**").permitAll()
                 .antMatchers("/files/**").permitAll()
                 .antMatchers("/files/**").permitAll()

+ 51 - 12
src/main/java/com/izouma/wenlvju/service/RateService.java

@@ -19,6 +19,8 @@ import freemarker.template.Template;
 import freemarker.template.Version;
 import freemarker.template.Version;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.pdfbox.io.MemoryUsageSetting;
+import org.apache.pdfbox.multipdf.PDFMergerUtility;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -29,6 +31,13 @@ import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+
 @Service
 @Service
 @Slf4j
 @Slf4j
 @AllArgsConstructor
 @AllArgsConstructor
@@ -150,12 +159,12 @@ public class RateService {
                 .stream();
                 .stream();
         files.add(stream);
         files.add(stream);
         this.downloadFile1(files, rate.getPrivacyPolicy());
         this.downloadFile1(files, rate.getPrivacyPolicy());
-//        this.downloadFile(files, rate.getBusiness(), "业务内容");
-//        this.downloadFile(files, rate.getCredits(), "社会信誉");
-//        this.downloadFile(files, rate.getFire(), "消防安全");
-//        this.downloadFile(files, rate.getHygiene(), "卫生防疫");
-//        this.downloadFile(files, rate.getFinance(), "财务报表");
-//        this.downloadFile(files, rate.getProperty(), "房产证明");
+        this.downloadFile1(files, rate.getBusiness());
+        this.downloadFile1(files, rate.getCredits());
+        this.downloadFile1(files, rate.getFire());
+        this.downloadFile1(files, rate.getHygiene());
+        this.downloadFile1(files, rate.getFinance());
+        this.downloadFile1(files, rate.getProperty());
         return files;
         return files;
     }
     }
 
 
@@ -172,8 +181,7 @@ public class RateService {
                         .stream();
                         .stream();
                 files.add(stream);
                 files.add(stream);
             } else if (getSuffix(privacy).equals("pdf")) {
             } else if (getSuffix(privacy).equals("pdf")) {
-                InputStream stream = HttpRequest.get(privacy)
-                        .stream();
+                InputStream stream = HttpRequest.get(privacy).stream();
                 files.add(stream);
                 files.add(stream);
             }
             }
         });
         });
@@ -185,16 +193,14 @@ public class RateService {
             num.getAndIncrement();
             num.getAndIncrement();
             File file1 = new File("/Users/qiufangchao/Desktop/" + filename + num + ".pdf");
             File file1 = new File("/Users/qiufangchao/Desktop/" + filename + num + ".pdf");
             if (getSuffix(privacy).equals("doc") || getSuffix(privacy).equals("docx")) {
             if (getSuffix(privacy).equals("doc") || getSuffix(privacy).equals("docx")) {
-                InputStream is1 = HttpRequest.get(privacy)
-                        .stream();
+                InputStream is1 = HttpRequest.get(privacy).stream();
                 HttpRequest.post("http://192.168.50.238:8080/word2pdf")
                 HttpRequest.post("http://192.168.50.238:8080/word2pdf")
                         .accept("*/*")
                         .accept("*/*")
                         .part("file", "审核材料.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", is1)
                         .part("file", "审核材料.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", is1)
                         .receive(file1);
                         .receive(file1);
                 files.add(file1);
                 files.add(file1);
             } else if (getSuffix(privacy).equals("pdf")) {
             } else if (getSuffix(privacy).equals("pdf")) {
-                HttpRequest.get(privacy)
-                        .receive(file1);
+                HttpRequest.get(privacy).receive(file1);
                 files.add(file1);
                 files.add(file1);
             }
             }
         });
         });
@@ -207,4 +213,37 @@ public class RateService {
         }
         }
         return url.substring(index + 1);
         return url.substring(index + 1);
     }
     }
+
+    public void exportPdf(Long id, HttpServletResponse response) throws IOException {
+        Rate rate = rateRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+        List<InputStream> files = this.upLoad1(rate);
+
+        // pdf合并工具类
+        PDFMergerUtility mergePdf = new PDFMergerUtility();
+        mergePdf.addSources(files);
+
+        // 指定目标文件输出流
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        mergePdf.setDestinationStream(outputStream);
+
+        mergePdf.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
+
+        // 设置合并生成pdf文件名称
+//        String targetPath = "/Users/qiufangchao/Desktop/result.pdf";
+//        mergePdf.setDestinationFileName(targetPath);
+
+        for (InputStream is : files) {
+            is.close();
+        }
+//        return outputStream.toString();
+
+        response.setContentType("application/pdf");
+        response.setHeader("Content-Disposition", "attachment; filename=" + "result.pdf");
+
+        ServletOutputStream sos = response.getOutputStream();
+        sos.write(outputStream.toByteArray());
+
+        sos.flush();
+        outputStream.close();
+    }
 }
 }

+ 36 - 8
src/main/java/com/izouma/wenlvju/web/RateController.java

@@ -1,8 +1,7 @@
 package com.izouma.wenlvju.web;
 package com.izouma.wenlvju.web;
 
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
+import com.github.kevinsawicki.http.HttpRequest;
 import com.izouma.wenlvju.domain.GradingOrganization;
 import com.izouma.wenlvju.domain.GradingOrganization;
 import com.izouma.wenlvju.domain.Organization;
 import com.izouma.wenlvju.domain.Organization;
 import com.izouma.wenlvju.domain.Rate;
 import com.izouma.wenlvju.domain.Rate;
@@ -26,7 +25,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
+import java.io.*;
 import java.time.LocalDate;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.util.List;
 import java.util.List;
@@ -132,11 +131,13 @@ public class RateController extends BaseController {
         rateService.addExpert(id, userId);
         rateService.addExpert(id, userId);
     }
     }
 
 
-    @GetMapping(value = "/export/{id}", produces = "application/msword;charset=utf-8")
-    public String export(@PathVariable Long id) {
-        Rate rate = rateRepo.findById(id).orElseThrow(new BusinessException("无申请"));
-        return rateService.export(rate);
-//        return "ok";
+    @GetMapping(value = "/export/{id}", produces = "application/pdf;charset=utf-8")
+    public void export(@PathVariable Long id, HttpServletResponse response) {
+        try {
+            rateService.exportPdf(id, response);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
     }
     }
 
 
     @GetMapping("/saveReviewTime")
     @GetMapping("/saveReviewTime")
@@ -149,5 +150,32 @@ public class RateController extends BaseController {
                 .build());
                 .build());
         return rateRepo.save(rate);
         return rateRepo.save(rate);
     }
     }
+
+    @GetMapping(value = "/test", produces = "application/pdf;charset=utf-8")
+    @ResponseBody
+    public void test(HttpServletResponse response) throws IOException {
+        InputStream in = HttpRequest.get("https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/application/2021-04-09-10-29-31sAAmcakx.pdf")
+                .stream();
+        response.setContentType("application/pdf");
+        response.setHeader("Content-Disposition", "attachment; filename=" + "result.pdf");
+
+        OutputStream sos = response.getOutputStream();
+
+        int readBytes;
+        while ((readBytes = in.read()) != -1) {
+            sos.write(readBytes);
+        }
+
+        sos.flush();
+        sos.close();
+        in.close();
+    }
+
+    @GetMapping("/canApply")
+    public boolean canApply(@RequestParam Long id) {
+        String year = String.valueOf(LocalDate.now().getYear());
+        return rateRepo.countAllByOrganizationIdAndYear(id, year) == 0;
+    }
+
 }
 }
 
 

+ 1 - 1
src/main/vue/src/mixins/rateStatus.js

@@ -5,7 +5,7 @@ export default {
                 { label: '草稿', value: 'DRAFT' },
                 { label: '草稿', value: 'DRAFT' },
                 { label: '等待初审', value: 'FIRST_REVIEW_PENDING' },
                 { label: '等待初审', value: 'FIRST_REVIEW_PENDING' },
                 { label: '初审驳回', value: 'FIRST_REVIEW_DENY' },
                 { label: '初审驳回', value: 'FIRST_REVIEW_DENY' },
-                { label: '已上报', value: 'ASSIGN_EXPERT' },
+                { label: '已审核上报', value: 'ASSIGN_EXPERT' },
                 { label: '待专家组考察', value: 'REVIEW_PENDING' },
                 { label: '待专家组考察', value: 'REVIEW_PENDING' },
                 { label: '待最终评审', value: 'SUBMIT_GRADE' },
                 { label: '待最终评审', value: 'SUBMIT_GRADE' },
                 { label: '待提交纸质材料', value: 'SUBMIT_PAPER_MATERIALS' },
                 { label: '待提交纸质材料', value: 'SUBMIT_PAPER_MATERIALS' },

+ 1 - 1
src/main/vue/src/router.js

@@ -448,7 +448,7 @@ router.beforeEach((to, from, next) => {
         window.open(url);
         window.open(url);
         return;
         return;
     }
     }
-    console.log(store.state.isORGANIZER);
+    // console.log(store.state.isORGANIZER);
     if (!store.state.userInfo && to.path !== '/login') {
     if (!store.state.userInfo && to.path !== '/login') {
         store
         store
             .dispatch('getUserInfo')
             .dispatch('getUserInfo')

+ 1 - 1
src/main/vue/src/store.js

@@ -58,7 +58,7 @@ export default new Vuex.Store({
                 });
                 });
         },
         },
         checkOrganization(context) {
         checkOrganization(context) {
-            console.log(context.state.organization);
+            // console.log(context.state.organization);
             if (context.state.organization) {
             if (context.state.organization) {
                 if (
                 if (
                     context.state.organization.owner &&
                     context.state.organization.owner &&

+ 1 - 5
src/main/vue/src/views/Login.vue

@@ -72,11 +72,7 @@
                     >
                     >
                         <el-input class="input-width" v-model="registerInfo.email" placeholder="电子邮箱"> </el-input>
                         <el-input class="input-width" v-model="registerInfo.email" placeholder="电子邮箱"> </el-input>
                     </el-form-item>
                     </el-form-item>
-                    <el-form-item
-                        prop="gradingOrganizationId"
-                        label="所属考级机构"
-                        :rules="{ required: true, message: '请选择所属考级机构', trigger: 'blur' }"
-                    >
+                    <el-form-item prop="gradingOrganizationId" label="所属考级机构">
                         <el-select
                         <el-select
                             v-model="registerInfo.gradingOrganizationId"
                             v-model="registerInfo.gradingOrganizationId"
                             placeholder="请选择所属考级机构"
                             placeholder="请选择所属考级机构"

+ 43 - 20
src/main/vue/src/views/RateList.vue

@@ -123,7 +123,7 @@
                         plain
                         plain
                         size="mini"
                         size="mini"
                         @click="saveComplete(row)"
                         @click="saveComplete(row)"
-                        >完成</el-button
+                        >收取纸质材料</el-button
                     >
                     >
                     <el-button @click="editRow(row)" type="primary" size="mini" plain>审核材料</el-button>
                     <el-button @click="editRow(row)" type="primary" size="mini" plain>审核材料</el-button>
                     <!-- <el-button @click="deleteRow(row)" type="danger" size="mini" plain>删除</el-button> -->
                     <!-- <el-button @click="deleteRow(row)" type="danger" size="mini" plain>删除</el-button> -->
@@ -249,9 +249,6 @@ export default {
             status: ''
             status: ''
         };
         };
     },
     },
-    created() {
-        this.getAdmin();
-    },
     computed: {
     computed: {
         selection() {
         selection() {
             return this.$refs.table.selection.map(i => i.id);
             return this.$refs.table.selection.map(i => i.id);
@@ -289,8 +286,16 @@ export default {
             if (this.search) {
             if (this.search) {
                 data.search = this.search;
                 data.search = this.search;
             }
             }
-            if (!this.display) {
+            if (!this.getAdmin()) {
                 data.query.district = this.userInfo.district;
                 data.query.district = this.userInfo.district;
+            } else {
+                data.query.status = [
+                    'ASSIGN_EXPERT',
+                    'REVIEW_PENDING',
+                    'SUBMIT_GRADE',
+                    'SUBMIT_PAPER_MATERIALS',
+                    'COMPLETE'
+                ];
             }
             }
             if (this.status) {
             if (this.status) {
                 data.query.status = this.status;
                 data.query.status = this.status;
@@ -376,22 +381,37 @@ export default {
         },
         },
         audit(row, status, remark) {
         audit(row, status, remark) {
             this.$set(row, 'loading', true);
             this.$set(row, 'loading', true);
-            this.$http
-                .post('/rate/audit', {
-                    id: row.id,
-                    status: status,
-                    score: 0,
-                    remark: remark
-                })
-                .then(res => {
-                    this.$set(row, 'loading', false);
-                    this.$message.success('OK');
-                    this.getData();
+
+            this.$confirm('确认此承办单位同意上报?', '提示', {
+                confirmButtonText: '同意上报',
+                cancelButtonText: '取消',
+                type: 'warning'
+            })
+                .then(() => {
+                    this.$http
+                        .post('/rate/audit', {
+                            id: row.id,
+                            status: status,
+                            score: 0,
+                            remark: remark
+                        })
+                        .then(res => {
+                            this.$set(row, 'loading', false);
+                            this.$message.success('上报成功');
+                            this.getData();
+                        })
+                        .catch(e => {
+                            console.log(e);
+                            this.$set(row, 'loading', false);
+                            this.$message.error(e.error);
+                        });
                 })
                 })
-                .catch(e => {
-                    console.log(e);
+                .catch(() => {
+                    this.$message({
+                        type: 'info',
+                        message: '已取消'
+                    });
                     this.$set(row, 'loading', false);
                     this.$set(row, 'loading', false);
-                    this.$message.error(e.error);
                 });
                 });
         },
         },
         dismiss(row) {
         dismiss(row) {
@@ -448,11 +468,14 @@ export default {
         },
         },
         getAdmin() {
         getAdmin() {
             let data = this.userInfo.authorities;
             let data = this.userInfo.authorities;
+            let display = false;
             data.forEach(element => {
             data.forEach(element => {
                 if (element.name === 'ROLE_ADMIN') {
                 if (element.name === 'ROLE_ADMIN') {
-                    this.display = true;
+                    display = true;
                 }
                 }
             });
             });
+            this.display = display;
+            return display;
         },
         },
         openScore(row) {
         openScore(row) {
             this.dialogScore = true;
             this.dialogScore = true;

+ 3 - 1
src/main/vue/src/views/organization/GradeList.vue

@@ -277,6 +277,7 @@ export default {
                 return item.type === key;
                 return item.type === key;
             });
             });
 
 
+            // console.log(info);
             return info ? info.expertScore || 0 : 0;
             return info ? info.expertScore || 0 : 0;
         },
         },
         getInfo(key) {
         getInfo(key) {
@@ -304,7 +305,8 @@ export default {
                     return;
                     return;
                 } else if (index === 6) {
                 } else if (index === 6) {
                     sums[index] = data.reduce((total, currentValue) => {
                     sums[index] = data.reduce((total, currentValue) => {
-                        return total + this.form[currentValue.value];
+                        // return total + this.form[currentValue.value];
+                        return total + this.getExpertScore(currentValue.value);
                     }, 0);
                     }, 0);
                     return;
                     return;
                 } else {
                 } else {

+ 9 - 5
src/main/vue/src/views/organization/OrganizationInfo.vue

@@ -4,12 +4,11 @@
             :model="formData"
             :model="formData"
             :rules="rules"
             :rules="rules"
             ref="form"
             ref="form"
-            label-width="100px"
+            label-width="108px"
             label-position="right"
             label-position="right"
             size="small"
             size="small"
-            style="max-width: 640px;"
+            style="max-width: 660px;"
             inline
             inline
-            hide-required-asterisk
         >
         >
             <div class="info-content">
             <div class="info-content">
                 <el-form-item label="登陆账号" prop="username">
                 <el-form-item label="登陆账号" prop="username">
@@ -56,7 +55,7 @@
                     <el-input
                     <el-input
                         v-model="formData.uscc"
                         v-model="formData.uscc"
                         placeholder="请输入统一社会信用代码"
                         placeholder="请输入统一社会信用代码"
-                        style="width:480px"
+                        style="width:488px"
                     ></el-input>
                     ></el-input>
                 </el-form-item>
                 </el-form-item>
                 <el-form-item label="地址" prop="district" class="address">
                 <el-form-item label="地址" prop="district" class="address">
@@ -164,7 +163,12 @@ export default {
                     trigger: 'blur'
                     trigger: 'blur'
                 },
                 },
                 privacyPolicy: { required: true, message: '请输入法人姓名', trigger: 'blur' },
                 privacyPolicy: { required: true, message: '请输入法人姓名', trigger: 'blur' },
-                idNo: { required: true, message: '请输入证件号码', trigger: 'blur' },
+                idNo: {
+                    required: true,
+                    message: '请输入证件号码',
+                    trigger: 'blur',
+                    pattern: /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|[xX])$/
+                },
                 uscc: { required: true, message: '请输入信用代码', trigger: 'blur' },
                 uscc: { required: true, message: '请输入信用代码', trigger: 'blur' },
                 district: { required: true, message: '请选择地址', trigger: 'change' },
                 district: { required: true, message: '请选择地址', trigger: 'change' },
                 address: { required: true, message: '请输入详细地址', trigger: 'blur' },
                 address: { required: true, message: '请输入详细地址', trigger: 'blur' },

+ 6 - 3
src/main/vue/src/views/organization/RateEdit.vue

@@ -48,11 +48,14 @@
                 <div class="info-item address">
                 <div class="info-item address">
                     <div class="val">
                     <div class="val">
                         <el-form-item prop="introduction" label="单位概况">
                         <el-form-item prop="introduction" label="单位概况">
+                            <div class="name" style="margin-top: 5px">
+                                (从事与艺术考级开考专业相关的业务情况和成绩,可附支撑材料)
+                            </div>
                             <el-input
                             <el-input
                                 :readonly="readonly"
                                 :readonly="readonly"
                                 type="textarea"
                                 type="textarea"
                                 :autosize="{ minRows: 4, maxRows: 6 }"
                                 :autosize="{ minRows: 4, maxRows: 6 }"
-                                placeholder="请输入单位概况"
+                                placeholder="从事与艺术考级开考专业相关的业务情况和成绩,可附支撑材料"
                                 v-model="formData.introduction"
                                 v-model="formData.introduction"
                             ></el-input>
                             ></el-input>
                         </el-form-item>
                         </el-form-item>
@@ -670,14 +673,14 @@ export default {
         top: 12px;
         top: 12px;
     }
     }
     .name {
     .name {
-        font-size: 14px;
+        font-size: 13px;
         font-family: PingFangSC-Regular, PingFang SC;
         font-family: PingFangSC-Regular, PingFang SC;
         font-weight: 400;
         font-weight: 400;
         color: #565b66;
         color: #565b66;
         line-height: 22px;
         line-height: 22px;
         min-width: 75px;
         min-width: 75px;
         margin-right: 10px;
         margin-right: 10px;
-        text-align: right;
+        text-align: left;
     }
     }
 
 
     .val {
     .val {

+ 36 - 4
src/main/vue/src/views/organization/RateOrganizerList.vue

@@ -3,7 +3,9 @@
         <div class="filters-container">
         <div class="filters-container">
             <!-- <el-input placeholder="输入关键字" v-model="search" clearable class="filter-item"></el-input>
             <!-- <el-input placeholder="输入关键字" v-model="search" clearable class="filter-item"></el-input>
             <el-button @click="getData" type="primary" icon="el-icon-search" class="filter-item">搜索 </el-button> -->
             <el-button @click="getData" type="primary" icon="el-icon-search" class="filter-item">搜索 </el-button> -->
-            <el-button @click="addRow" type="primary" icon="el-icon-plus" class="filter-item">创建申请 </el-button>
+            <el-button @click="addRow" type="primary" icon="el-icon-plus" class="filter-item" v-if="canApply"
+                >创建申请
+            </el-button>
             <!-- <el-button
             <!-- <el-button
                 @click="download"
                 @click="download"
                 type="primary"
                 type="primary"
@@ -99,9 +101,21 @@ export default {
             multipleMode: false,
             multipleMode: false,
             search: '',
             search: '',
             url: '/rate/all',
             url: '/rate/all',
-            downloading: false
+            downloading: false,
+            canApply: false
         };
         };
     },
     },
+    created() {
+        this.$http
+            .get('/rate/canApply', { id: this.organization.id })
+            .then(res => {
+                this.canApply = res;
+            })
+            .catch(e => {
+                console.log(e);
+                this.$message.error(e.error);
+            });
+    },
     computed: {
     computed: {
         selection() {
         selection() {
             return this.$refs.table.selection.map(i => i.id);
             return this.$refs.table.selection.map(i => i.id);
@@ -191,14 +205,14 @@ export default {
         word(row) {
         word(row) {
             this.downloading = true;
             this.downloading = true;
             this.$axios
             this.$axios
-                .get('/rate/export/' + row.id)
+                .get('/rate/export/' + row.id, { responseType: 'blob' })
                 .then(res => {
                 .then(res => {
                     console.log(res);
                     console.log(res);
                     this.downloading = false;
                     this.downloading = false;
                     const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
                     const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
                     const link = document.createElement('a');
                     const link = document.createElement('a');
                     link.href = downloadUrl;
                     link.href = downloadUrl;
-                    link.setAttribute('download', '申请材料.doc');
+                    link.setAttribute('download', '申请材料.pdf');
                     document.body.appendChild(link);
                     document.body.appendChild(link);
                     link.click();
                     link.click();
                     link.remove();
                     link.remove();
@@ -208,6 +222,24 @@ export default {
                     this.downloading = false;
                     this.downloading = false;
                     this.$message.error(e.error);
                     this.$message.error(e.error);
                 });
                 });
+            // this.$axios
+            //     .get('/rate/test', { responseType: 'blob' })
+            //     .then(res => {
+            //         console.log(res);
+            //         this.downloading = false;
+            //         const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+            //         const link = document.createElement('a');
+            //         link.href = downloadUrl;
+            //         link.setAttribute('download', '申请材料.pdf');
+            //         document.body.appendChild(link);
+            //         link.click();
+            //         link.remove();
+            //     })
+            //     .catch(e => {
+            //         console.log(e);
+            //         this.downloading = false;
+            //         this.$message.error(e.error);
+            //     });
         }
         }
     }
     }
 };
 };

+ 45 - 7
src/test/java/com/izouma/wenlvju/service/RateServiceTest.java

@@ -1,6 +1,7 @@
 package com.izouma.wenlvju.service;
 package com.izouma.wenlvju.service;
 
 
 
 
+import com.github.kevinsawicki.http.HttpRequest;
 import com.izouma.wenlvju.ApplicationTests;
 import com.izouma.wenlvju.ApplicationTests;
 import com.izouma.wenlvju.domain.Rate;
 import com.izouma.wenlvju.domain.Rate;
 import com.izouma.wenlvju.exception.BusinessException;
 import com.izouma.wenlvju.exception.BusinessException;
@@ -10,10 +11,7 @@ import org.apache.pdfbox.multipdf.PDFMergerUtility;
 import org.junit.Test;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 import java.util.List;
 import java.util.List;
 
 
 
 
@@ -30,7 +28,8 @@ public class RateServiceTest extends ApplicationTests {
     }
     }
 
 
     @Test
     @Test
-    public void test2() throws IOException {
+    public void test2() {
+
         Rate rate = rateRepo.findById(467L).orElseThrow(new BusinessException("无记录"));
         Rate rate = rateRepo.findById(467L).orElseThrow(new BusinessException("无记录"));
         List<InputStream> files = rateService.upLoad1(rate);
         List<InputStream> files = rateService.upLoad1(rate);
 
 
@@ -47,8 +46,47 @@ public class RateServiceTest extends ApplicationTests {
         // 设置合并生成pdf文件名称
         // 设置合并生成pdf文件名称
         mergePdf.setDestinationFileName(targetPath);
         mergePdf.setDestinationFileName(targetPath);
         // 合并pdf
         // 合并pdf
-        mergePdf.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
-        new File(targetPath);
+        try {
+            mergePdf.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
+            for (InputStream is : files) {
+                is.close();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+//        System.out.println(writer.toString());
+//        new File(targetPath);
+
+    }
+
+    @Test
+    public void test3() throws IOException {
+        String targetPath = "/Users/qiufangchao/Desktop/result.pdf";
+
+        String uri = "http://192.168.50.238:8080/word2pdf";
+        // 表格
+        Rate rate = rateRepo.findById(467L).orElseThrow(new BusinessException("无申请"));
+        String export = rateService.export(rate);
+        InputStream is = new ByteArrayInputStream(export.getBytes());
+        InputStream stream = HttpRequest.post(uri)
+                .accept("*/*")
+                .part("file", "审核材料.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", is)
+                .stream();
+
+//        StringWriter writer = new StringWriter();
+//        IOUtils.copy(stream, writer, StandardCharsets.UTF_8.name());
+//        String str = writer.toString();
+//        stream.close();
+
+        int index;
+        byte[] bytes = new byte[1024];
+        FileOutputStream downloadFile = new FileOutputStream(targetPath);
+        while ((index = stream.read(bytes)) != -1) {
+            downloadFile.write(bytes, 0, index);
+            downloadFile.flush();
+        }
+        downloadFile.close();
+        stream.close();
 
 
     }
     }