OfdConvertRest.java
2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.thinkgem.jeesite.modules.eci.method;
import com.suwell.ofd.custom.agent.ConvertException;
import com.suwell.ofd.custom.agent.HTTPAgent;
import com.suwell.ofd.custom.wrapper.PackException;
import com.thinkgem.jeesite.modules.eci.dao.ElecLicenseInfoDao;
import com.thinkgem.jeesite.modules.eci.entity.ElecLicenseInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* ofd文件转换
*/
@Component
public class OfdConvertRest {
private Logger logger = LoggerFactory.getLogger(OfdConvertRest.class);
HTTPAgent ha = new HTTPAgent("http://172.16.56.42:8090");
@Autowired
ElecLicenseInfoDao licenseInfoDao;
public void convert() {
List<ElecLicenseInfo> waitForConverts = licenseInfoDao.getWaitForConvert();
for (ElecLicenseInfo waitForConvert : waitForConverts) {
OutputStream out = null;
//转换后文件输出路径
try {
String bizId = waitForConvert.getBizId();
String ofdPath = waitForConvert.getOfdWjdz();
// TODO: 2022/2/16/0016 ofd文件转换
File ofdFile = new File(ofdPath);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dddd");
String dateDir = simpleDateFormat.format(new Date());
String documentId = waitForConvert.getDocumentId();
File tiffDir = new File("E:\\ECI\\TIFF" + dateDir + "\\");
if (!tiffDir.exists()) {
tiffDir.mkdirs();
}
File tiffFile = new File(tiffDir + documentId + ".tiff");
if (!tiffFile.exists()) {
tiffFile.createNewFile();
}
out = new FileOutputStream(tiffFile);
//输出格式。true输出格式为zip ;false输出格式为tiff
ha.OFDToImge(ofdFile, out, -1, false);
licenseInfoDao.updateJpgWjdzAndStatus(tiffFile.getAbsolutePath(), bizId);
} catch (PackException | ConvertException | IOException e) {
e.printStackTrace();
} finally {
try {
ha.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}