diff --git a/adc-da-convert/pom.xml b/adc-da-convert/pom.xml
index f11c490a..da2487c4 100644
--- a/adc-da-convert/pom.xml
+++ b/adc-da-convert/pom.xml
@@ -24,19 +24,11 @@
- org.jodconverter
- jodconverter-core
- 4.2.2
-
-
- org.jodconverter
- jodconverter-spring-boot-starter
- 4.2.2
-
-
- org.jodconverter
- jodconverter-local
- 4.2.2
+ com.artofsolving
+ jodconverter
+ system
+ 2.2.2
+ ${basedir}/src/main/lib/jodconverter-2.2.2.jar
diff --git a/adc-da-convert/src/main/java/com/adc/da/convert/common/DocConverterPdf.java b/adc-da-convert/src/main/java/com/adc/da/convert/common/DocConverterPdf.java
index d7840550..27974771 100644
--- a/adc-da-convert/src/main/java/com/adc/da/convert/common/DocConverterPdf.java
+++ b/adc-da-convert/src/main/java/com/adc/da/convert/common/DocConverterPdf.java
@@ -1,24 +1,20 @@
package com.adc.da.convert.common;
+import com.artofsolving.jodconverter.DocumentConverter;
+import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
+import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
+import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
+import com.artofsolving.jodconverter.openoffice.converter.StreamOpenOfficeDocumentConverter;
import org.apache.commons.lang.StringUtils;
-import org.jodconverter.DocumentConverter;
-import org.jodconverter.OfficeDocumentConverter;
-import org.jodconverter.document.DefaultDocumentFormatRegistry;
-import org.jodconverter.office.DefaultOfficeManagerBuilder;
-import org.jodconverter.office.OfficeException;
-import org.jodconverter.office.OfficeManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
import java.io.*;
public class DocConverterPdf {
private static final Logger logger = LoggerFactory.getLogger(DocConverterPdf.class);
- @Autowired
- private DocumentConverter converter;
+ private static String OS_NAME = System.getProperty("os.name").toLowerCase();
private static final int ENVIRONMENT = 1;// 环境 1:windows 2:linux
private String fileString;// (只涉及pdf2swf路径问题)
@@ -28,7 +24,6 @@ public class DocConverterPdf {
private File convertPdfFile;
private File swfFile;
private File docFile;
- private String filesType;
String waterPdfPath;
private String convertHost;
@@ -56,7 +51,6 @@ public class DocConverterPdf {
fileName = fileString.substring(0, fileString.lastIndexOf("."));
if(".doc".equals(fileType.toLowerCase()) || ".docx".equals(fileType.toLowerCase()) || ".xlsx".equals(fileType.toLowerCase()) || ".xls".equals(fileType.toLowerCase()) || ".ppt".equals(fileType.toLowerCase()) || ".pptx".equals(fileType.toLowerCase())){
docFile = new File(fileString);
- filesType = fileType.toLowerCase();
convertPdfFile=new File(fileName+"_C"+ ".pdf");
pdfFile = new File(fileName + ".pdf");
swfFile = new File(fileName + ".swf");
@@ -66,38 +60,6 @@ public class DocConverterPdf {
}
}
- /**
- * openOffice目录,window 可能在C://Program Files (x86)//OpenOffice 4
- */
- private static final String openOfficeHome = "/opt/openoffice4";
-
- /**
- * openOffice端口
- */
- private static final int openOfficePort = 8100;
-
- /**
- * 转化文档
- * @param input
- * @param output
- */
- public static void convertFile(File input , File output) throws OfficeException {
- try {
- DefaultOfficeManagerBuilder defaultOfficeManagerBuilder = new DefaultOfficeManagerBuilder();
- defaultOfficeManagerBuilder.setOfficeHome(openOfficeHome);
- OfficeManager officeManager = defaultOfficeManagerBuilder.build();
- officeManager.start();
-
- //转换,自动识别转化类型
- OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
- converter.convert(input, output);
-
- officeManager.stop();
- } catch (OfficeException e) {
- throw e;
- }
- }
-
/**
* 转为PDF
*
@@ -105,16 +67,22 @@ public class DocConverterPdf {
*/
private void doc2pdf() throws Exception {
if (!pdfFile.exists()) {
+ OpenOfficeConnection connection = null;
logger.info("转换服务地址接口:"+convertHost);
- InputStream in = null;
- OutputStream out = null;
try {
-// in = new FileInputStream(docFile);
-// out = new FileOutputStream(convertPdfFile);
- convertFile(docFile,convertPdfFile);
-// converter.convert(in).as(DefaultDocumentFormatRegistry.getFormatByMediaType(filesType)).
-// to(out).as(DefaultDocumentFormatRegistry.PDF);
+ if(StringUtils.isNotBlank(convertHost)){
+ connection = new SocketOpenOfficeConnection(convertHost,8100);
+ }else{
+ connection = new SocketOpenOfficeConnection(8100);
+ }
+ connection.connect();
+ DocumentConverter converter = new StreamOpenOfficeDocumentConverter(connection);
+ converter.convert(docFile, convertPdfFile);
+
+ //addWaterToPdf(pdfFile,userId);
+
// close the connection
+ connection.disconnect();
// 开始设置PDF文档相关属性保证其安全性
logger.info("开始设置转换后的PDF文件安全性相关设置");
PDFEditUtils.setPDFFileSecurity(pdfFile.getAbsolutePath(),convertPdfFile.getAbsolutePath());
@@ -123,6 +91,10 @@ public class DocConverterPdf {
logger.error(e.getMessage(),e);
logger.info("****pdf转换器异常,openoffice服务未启动!****");
throw e;
+ } catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) {
+ logger.error(e.getMessage(),e);
+ logger.info("****pdf转换器异常,读取转换文件失败****");
+ throw e;
} catch (Exception e) {
logger.error(e.getMessage(),e);
throw e;
@@ -268,6 +240,11 @@ public class DocConverterPdf {
}
public void setConvertHost(String convertHost) {
- this.convertHost = convertHost;
+ OS_NAME = OS_NAME.toLowerCase();
+ if (OS_NAME.contains("win")) {
+ this.convertHost = convertHost;
+ } else {
+ this.convertHost = "62.234.136.153";
+ }
}
}
diff --git a/adc-da-slrs/src/main/java/com/adc/da/scheduled/ScheduledJob.java b/adc-da-slrs/src/main/java/com/adc/da/scheduled/ScheduledJob.java
index cd14b2b6..c9e0cd00 100644
--- a/adc-da-slrs/src/main/java/com/adc/da/scheduled/ScheduledJob.java
+++ b/adc-da-slrs/src/main/java/com/adc/da/scheduled/ScheduledJob.java
@@ -5,8 +5,12 @@ import com.adc.da.scheduled.dao.SarStandardItemDao;
import com.adc.da.scheduled.dao.SarStandardWarningDao;
import com.adc.da.scheduled.entity.DataDTO;
import com.adc.da.scheduled.entity.WarningEO;
-import com.adc.da.slrs.sarStandWarning.entity.EarlyWarningEO;
+import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao;
+import com.adc.da.slrs.sarStandAttrInfo.entity.SarStandAttrInfo;
+import com.adc.da.slrs.sarStandardsInfo.dao.SarStandardsInfoDao;
+import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
import com.adc.da.util.UUIDUtils;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -18,6 +22,7 @@ import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
@EnableScheduling
@Component
@@ -31,35 +36,28 @@ public class ScheduledJob {
@Value("${isNotScheduled}")
private boolean isNotScheduled; //是否开启定时器
-//
-// @Scheduled(cron="*/5 * * * * ?")
-// @Async
-// public void StandScheduledJob(){
-// System.out.println("hello");
-//// if(isNotScheduled){
-//// System.out.println(Thread.currentThread().getName() + " cron=0 0 1 1 * ? --- " + new Date()+"---START-01");
-//// System.out.println(Thread.currentThread().getName() + " cron=0 0 1 1 * ? --- " + new Date()+"---End-01");
-//// try{
-//// Thread.sleep(2000);
-//// }catch(Exception e){
-//// }
-//// }
-// }
-
@Autowired
- private SarStandardWarningDao sarStandardWarningDao;
+ private SarStandardInfoDao sarStandardInfoDao; //标准信息表
@Autowired
- private SarStandardItemDao sarStandardItemDao;
+ private SarStandardsInfoDao sarStandardsInfoDao;//标准信息表
@Autowired
- private SarStandardInfoDao sarStandardInfoDao;
+ private SarStandardWarningDao sarStandardWarningDao;//预警表
+
+ @Autowired
+ private SarStandardItemDao sarStandardItemDao; //分解单表
+
+ @Autowired
+ private SarStandAttrInfoDao sarStandAttrInfoDao; //属性字段表
+
+
@Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行
// @Scheduled(cron="*/5 * * * * ?")
@Async
- public void schedulingTasks() {
+ public void WarningSchedulingTasks() {
/**
@@ -79,12 +77,12 @@ public class ScheduledJob {
2:在产车条款预警
*/
System.out.println("开始执行预警!!!");
- //预警期限
- DataDTO term = new DataDTO();
- LinkedList warningList = new LinkedList<>();
+ DataDTO term = new DataDTO(); //预警期限(当前日期至3个月后)
+
+ LinkedList warningList = new LinkedList<>();//需预警的标准和条款列表集合
//分解单(条款) 新车型 mark=1
- List itemForXCXSSRQ = sarStandardItemDao.select(term, "XCXSSRQ");
+ List itemForXCXSSRQ = sarStandardItemDao.selectWithinTerm(term, "XCXSSRQ");
for (WarningEO warningEO : itemForXCXSSRQ) {
warningEO.setId(UUIDUtils.randomUUID20())
.setPower("1")
@@ -94,7 +92,7 @@ public class ScheduledJob {
warningList.addAll(itemForXCXSSRQ);
//分解单(条款) 在产车型 mark=2
- List itemForZCCSSRQ = sarStandardItemDao.select(term, "ZCCSSRQ");
+ List itemForZCCSSRQ = sarStandardItemDao.selectWithinTerm(term, "ZCCSSRQ");
for (WarningEO warningEO : itemForZCCSSRQ) {
warningEO.setId(UUIDUtils.randomUUID20())
.setPower("1")
@@ -104,33 +102,110 @@ public class ScheduledJob {
warningList.addAll(itemForZCCSSRQ);
//标准 新车型 预警 mark=3
- List standInfoXCXSSRQ = sarStandardInfoDao.select(term, "XCXSSRQ");
+ List standInfoXCXSSRQ = sarStandardInfoDao.selectWithinTerm(term, "XCXSSRQ");
for (WarningEO warningEO : standInfoXCXSSRQ) {
warningEO.setId(UUIDUtils.randomUUID20())
.setPower("1")
.setMark("3")
.setPutTime(warningEO.getXCXSSRQ())
- .setStandCode(warningEO.getStandSort()+" "+warningEO.getStandNum()+"-"+warningEO.getStandYear());
+ .setStandCode(warningEO.getStandSort()+" "+ warningEO.getStandNum()+"-"+ warningEO.getStandYear());
}
warningList.addAll(standInfoXCXSSRQ);
//标准 在产车型 mark=4
- List standInfoZCCSSRQ = sarStandardInfoDao.select(term, "ZCCSSRQ");
+ List standInfoZCCSSRQ = sarStandardInfoDao.selectWithinTerm(term, "ZCCSSRQ");
for (WarningEO warningEO : standInfoZCCSSRQ) {
warningEO.setId(UUIDUtils.randomUUID20())
.setPower("1")
.setMark("4")
.setPutTime(warningEO.getZCCSSRQ())
- .setStandCode(warningEO.getStandSort()+" "+warningEO.getStandNum()+"-"+warningEO.getStandYear());
+ .setStandCode(warningEO.getStandSort()+" "+ warningEO.getStandNum()+"-"+ warningEO.getStandYear());
}
warningList.addAll(standInfoZCCSSRQ);
//持久化至预警表 忽略标准id和标志位都一样的数据
if (warningList.size()!=0){
- //此表的STAND_CODE和MARK字段需建立唯一性约束
+ //此表的STAND_ID和MARK字段以及ITEMS_ID和MARK字段需两个建立唯一性约束
int count = sarStandardWarningDao.ignoreInsert(warningList);
System.out.println("已预警 " + count + " 条标准或条款!!");
}
}
+
+
+
+
+
+
+
+
+
+
+
+
+ @Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行
+// @Scheduled(cron="*/5 * * * * ?")
+ @Async
+ public void TextStatusSchedulingTasks() {
+ QueryWrapper wrapper = new QueryWrapper<>();
+
+ DataDTO data = new DataDTO(LocalDate.now(), LocalDate.now());
+
+ /**
+ *实施日期是当前系统时间的标准文本状态变为'现行有效'
+ */
+ QueryWrapper columnsAndCondition = new QueryWrapper<>();
+ columnsAndCondition.select("STAND_ID").like("SSRQ",LocalDate.now());
+ List