Commit 6fbcfbe4 authored by KeYong's avatar KeYong

更新

parent 51f29838
......@@ -33,5 +33,5 @@ public interface IJgChangeRegistrationTransferService extends IService<JgChangeR
void revocation(String instanceId);
File exportUseRegistrationCertificate(String sequenceNbr);
void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response);
}
......@@ -156,24 +156,24 @@ public class JgChangeRegistrationTransferController extends BaseController {
@GetMapping(value = "/export")
@ApiOperation(httpMethod = "GET", value = "导出使用登记证", notes = "导出使用登记证")
public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr) throws IOException {
File file = jgChangeRegistrationTransferService.exportUseRegistrationCertificate(sequenceNbr);
if(ValidationUtil.isEmpty(file)){
throw new BadRequest("使用登记证导出失败,请稍后重试!");
}
FileInputStream in = new FileInputStream(file);
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("使用登记证", "UTF-8") + ".pdf");
response.setHeader("content-Type", "application/msword");
response.setCharacterEncoding("utf-8");
OutputStream out = new BufferedOutputStream(response.getOutputStream());
int b = 0;
byte[] buffer = new byte[2048];
while ((b = in.read(buffer)) != -1) {
out.write(buffer, 0, b);
}
in.close();
out.flush();
out.close();
jgChangeRegistrationTransferService.exportUseRegistrationCertificate(sequenceNbr, response);
// if(ValidationUtil.isEmpty(file)){
// throw new BadRequest("使用登记证导出失败,请稍后重试!");
// }
// FileInputStream in = new FileInputStream(file);
// response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("使用登记证", "UTF-8") + ".pdf");
// response.setHeader("content-Type", "application/msword");
// response.setCharacterEncoding("utf-8");
//
// OutputStream out = new BufferedOutputStream(response.getOutputStream());
// int b = 0;
// byte[] buffer = new byte[2048];
// while ((b = in.read(buffer)) != -1) {
// out.write(buffer, 0, b);
// }
// in.close();
// out.flush();
// out.close();
}
}
......@@ -162,10 +162,10 @@ public class JgTransferNoticeController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "特种设备登记证导出", notes = "特种设备登记证导出")
@GetMapping(value = "/certificate/report")
public void generateCertificateReport() {
public void generateCertificateReport(HttpServletResponse response) {
Map<String, Object> map = new HashMap<>();
// 组装模板变量
map.put("useRegistrationCode", "20231225123"); // 编号
map.put("useRegistrationCode", "202311056"); // 编号
map.put("useUnitName", "西安市高科物业服务有限公司"); // 使用单位名称
map.put("fullAddress", "西安市曲江新区春临东街南湖意境1单元2号楼"); // 设备使用地点
map.put("equList", "电梯"); // 设备种类
......@@ -181,6 +181,6 @@ public class JgTransferNoticeController extends BaseController {
// 生成二维码
String qrCode = ImageUtils.generateQRCode("YZGZ20231225001", 70, 65);
map.put("supervisoryCode", qrCode); // 监管二维码
commonService.generateCertificateReport(map);
commonService.generateCertificateReport(map, response);
}
}
......@@ -36,5 +36,5 @@ public interface ICommonService {
List<Map<String,Object>> getEnterpriseEmployee(String unitCode);
File generateCertificateReport(Map<String, Object> map);
void generateCertificateReport(Map<String, Object> map, HttpServletResponse response);
}
......@@ -284,7 +284,7 @@ public class CommonServiceImpl implements ICommonService {
}
@Override
public File generateCertificateReport(Map<String, Object> map) {
public void generateCertificateReport(Map<String, Object> map, HttpServletResponse response) {
if (CollectionUtils.isEmpty(map)) {
throw new IllegalArgumentException("参数不能为空");
}
......@@ -324,21 +324,13 @@ public class CommonServiceImpl implements ICommonService {
// log.error("删除临时文件失败:{}", e);
// }
return pdfFile;
// try {
// byte[] bytes = file2byte(pdfFile);
// String docTitle = pdfFile.getName();
// FileExporter.exportFile(FileExporter.FileType.valueOf("pdf"), docTitle, bytes, response);
// } catch (Exception e) {
// log.error("pdf文件转换失败:{}", e);
// } finally {
// try {
// Files.deleteIfExists(pdfFile.toPath());
// } catch (Exception e) {
// log.error("文件找不到,删除失败:{}", e);
// }
// }
try {
byte[] bytes = file2byte(pdfFile);
String docTitle = pdfFile.getName();
FileExporter.exportFile(FileExporter.FileType.valueOf("pdf"), docTitle, bytes, response);
} catch (Exception e) {
log.error("pdf文件转换失败:{}", e);
}
}
/**
......
......@@ -830,7 +830,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
*
* @param sequenceNbr
*/
public File exportUseRegistrationCertificate(String sequenceNbr) {
public void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response) {
Map<String, Object> exportParamsMap = new HashMap<>();
//查询移装变更详情
JgChangeRegistrationTransfer transfer = this.getById(sequenceNbr);
......@@ -929,6 +929,6 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
exportParamsMap.put("factoryNum", factoryInfo.getFactoryNum());
}
//调用生成使用登记证
return commonService.generateCertificateReport(exportParamsMap);
commonService.generateCertificateReport(exportParamsMap, response);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment