|
|
@@ -30,6 +30,8 @@ import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.pdfbox.io.MemoryUsageSetting;
|
|
|
import org.apache.pdfbox.multipdf.PDFMergerUtility;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -46,16 +48,25 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
-@AllArgsConstructor
|
|
|
+//@AllArgsConstructor
|
|
|
public class RateService {
|
|
|
|
|
|
- private final RateRepo rateRepo;
|
|
|
- private final CollaborateRepo collaborateRepo;
|
|
|
- private final GradingOrganizationRepo gradingOrganizationRepo;
|
|
|
- private final RateAuditRepo rateAuditRepo;
|
|
|
- private final UserRepo userRepo;
|
|
|
- private final NjwlSmsService njwlSmsService;
|
|
|
- private final OrganizationRepo organizationRepo;
|
|
|
+ @Autowired
|
|
|
+ private RateRepo rateRepo;
|
|
|
+ @Autowired
|
|
|
+ private CollaborateRepo collaborateRepo;
|
|
|
+ @Autowired
|
|
|
+ private GradingOrganizationRepo gradingOrganizationRepo;
|
|
|
+ @Autowired
|
|
|
+ private RateAuditRepo rateAuditRepo;
|
|
|
+ @Autowired
|
|
|
+ private UserRepo userRepo;
|
|
|
+ @Autowired
|
|
|
+ private NjwlSmsService njwlSmsService;
|
|
|
+ @Autowired
|
|
|
+ private OrganizationRepo organizationRepo;
|
|
|
+ @Value("${storage.local_path}")
|
|
|
+ private String localPath;
|
|
|
|
|
|
public Page<Rate> all(PageQuery pageQuery) {
|
|
|
return rateRepo.findAll(JpaUtils.toSpecification(pageQuery, Rate.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
@@ -524,7 +535,10 @@ public class RateService {
|
|
|
response.addHeader("Content-Disposition", "attachment;filename=" + "result.pdf");
|
|
|
|
|
|
String pdfUrl = rate.getPdfUrl();
|
|
|
- File file = new File(pdfUrl);
|
|
|
+
|
|
|
+ int start = pdfUrl.indexOf("/pdf");
|
|
|
+ String end = pdfUrl.substring(start + 1);
|
|
|
+ File file = new File(localPath + end);
|
|
|
|
|
|
// 以流的形式下载文件。
|
|
|
InputStream fis = new BufferedInputStream(new FileInputStream(file));
|
|
|
@@ -532,6 +546,9 @@ public class RateService {
|
|
|
|
|
|
fis.read(buffer);
|
|
|
fis.close();
|
|
|
+
|
|
|
+ //删除文件
|
|
|
+ FileUtils.delFiles(file);
|
|
|
return buffer;
|
|
|
|
|
|
// OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
|