Merge remote-tracking branch 'origin/develop_master' into develop_master

This commit is contained in:
yuezhihang
2021-08-30 17:50:50 +08:00
15 changed files with 217 additions and 115 deletions
+5 -13
View File
@@ -24,19 +24,11 @@
</dependency>
<!-- openOffice 和 jobconverter-->
<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-core</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-spring-boot-starter</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-local</artifactId>
<version>4.2.2</version>
<groupId>com.artofsolving</groupId>
<artifactId>jodconverter</artifactId>
<scope>system</scope>
<version>2.2.2</version>
<systemPath>${basedir}/src/main/lib/jodconverter-2.2.2.jar</systemPath>
</dependency>
<!-- openOffice end-->
<dependency>
@@ -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;// 环境 1windows 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";
}
}
}
@@ -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<WarningEO> warningList = new LinkedList<>();
DataDTO term = new DataDTO(); //预警期限(当前日期至3个月后)
LinkedList<WarningEO> warningList = new LinkedList<>();//需预警的标准和条款列表集合
//分解单(条款) 新车型 mark=1
List<WarningEO> itemForXCXSSRQ = sarStandardItemDao.select(term, "XCXSSRQ");
List<WarningEO> 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<WarningEO> itemForZCCSSRQ = sarStandardItemDao.select(term, "ZCCSSRQ");
List<WarningEO> 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<WarningEO> standInfoXCXSSRQ = sarStandardInfoDao.select(term, "XCXSSRQ");
List<WarningEO> 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<WarningEO> standInfoZCCSSRQ = sarStandardInfoDao.select(term, "ZCCSSRQ");
List<WarningEO> 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<SarStandardsInfo> wrapper = new QueryWrapper<>();
DataDTO data = new DataDTO(LocalDate.now(), LocalDate.now());
/**
*实施日期是当前系统时间的标准文本状态变为'现行有效'
*/
QueryWrapper<SarStandAttrInfo> columnsAndCondition = new QueryWrapper<>();
columnsAndCondition.select("STAND_ID").like("SSRQ",LocalDate.now());
List<Map<String, Object>> effectiveList=sarStandAttrInfoDao.selectMaps(columnsAndCondition);
// List<ScheduledDTO> effectiveList = sarStandardInfoDao.selectWithinTerm(data, "SSRQ");
effectiveList.forEach(item->{
try {
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
sarStandardsInfo.setId(item.get("STAND_ID").toString());
sarStandardsInfo.setTextStatus("vsaga7nwub");
sarStandardsInfoDao.updateById(sarStandardsInfo);
// sarStandardInfoDao.updateStandardInfo(item.getStandId(),"vsaga7nwub");
}catch (Exception e){
System.out.println("标准id为=="+item.get("STAND_ID").toString()+"==文本状态更新失败");
}
});
/**
* 被多个标准代替的标准变为“被代替”,只有一个被代替的自动变为“废止”
*/
QueryWrapper<SarStandAttrInfo> columns = new QueryWrapper<>();
columns.select("DTBJH","STAND_ID");
List<Map<String, Object>> mapsDTBZH = sarStandAttrInfoDao.selectMaps(columns);
mapsDTBZH.forEach(item->{
if (item.get("DTBJH")!=null && !item.get("DTBJH").toString().equals("")){
String dtbzh = item.get("DTBJH").toString();
String[] split = dtbzh.split(",");
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
sarStandardsInfo.setId(item.get("STAND_ID").toString());
//一个被代替标准号时,文本状态更新为废止状态,两个及以上时更新为被代替状态
switch (split.length){
case 0 :
break;
case 1 :
sarStandardsInfo.setTextStatus("chblaarg77");//废止状态
break;
default:
sarStandardsInfo.setTextStatus("qke0ckro2p");//被代替状态
}
try {
sarStandardsInfoDao.updateById(sarStandardsInfo);
}catch (Exception e){
System.out.println("代替标准状态更新:id为"+item.get("STAND_ID").toString()+"文本状态更新失败");
}
}
});
}
}
@@ -3,8 +3,8 @@ package com.adc.da.scheduled.dao;
import com.adc.da.scheduled.entity.DataDTO;
import com.adc.da.scheduled.entity.WarningEO;
import com.adc.da.slrs.sarStandWarning.entity.EarlyWarningEO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@@ -12,6 +12,8 @@ import java.util.List;
@Repository
public interface SarStandardInfoDao{
public List<WarningEO> select(DataDTO date, String str);
public List<WarningEO> selectWithinTerm(DataDTO date, String str);
public int updateStandardInfo(@Param("id")String id, @Param("textStatus") String textStatus);
}
@@ -2,7 +2,6 @@ package com.adc.da.scheduled.dao;
import com.adc.da.scheduled.entity.DataDTO;
import com.adc.da.scheduled.entity.WarningEO;
import com.adc.da.slrs.sarStandWarning.entity.EarlyWarningEO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
@@ -12,6 +11,6 @@ import java.util.List;
@Repository
public interface SarStandardItemDao extends BaseMapper{
public List<WarningEO> select(DataDTO date, String str);
public List<WarningEO> selectWithinTerm(DataDTO date, String str);
}
@@ -1,8 +1,8 @@
package com.adc.da.scheduled.entity;
import com.adc.da.base.entity.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
@@ -13,15 +13,21 @@ public class DataDTO {
* 预警的期限为系统日期的次日至3个月后
*/
@DateTimeFormat(pattern="yyyy-MM-dd")
private LocalDate startDate;
@DateTimeFormat(pattern="yyyy-MM-dd")
private LocalDate endDate;
// private String str;
public DataDTO() {
this.startDate =LocalDate.now().plusDays(1); //系统日期的下一天
this.endDate = LocalDate.now().plusMonths(3).plusDays(1);//系统日期3个月后
this.startDate =LocalDate.now().plusDays(1); //系统当前日期
this.endDate = LocalDate.now().plusMonths(3);//系统当前日期3个月后
}
public DataDTO(LocalDate startDate,LocalDate endDate){
this.startDate=startDate;
this.endDate=endDate;
}
}
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@@ -15,8 +16,10 @@ import java.util.Date;
public class WarningEO extends EarlyWarningEO {
private static final long serialVersionUID = 1L;
@DateTimeFormat(pattern = "YYYY-MM-dd")
private Date XCXSSRQ;
@DateTimeFormat(pattern = "YYYY-MM-dd")
private Date ZCCSSRQ;
private String standNum;
@@ -24,4 +27,6 @@ public class WarningEO extends EarlyWarningEO {
private String standSort;
private String standYear;
}
@@ -24,11 +24,11 @@ public class FindSarItemsPageReqDTO extends BasePage {
private String itemsName;
@ApiModelProperty(value = "新车型实施日期")
@DateTimeFormat(pattern = "yyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date XCXSSRQ;
@ApiModelProperty(value = "在产车实施日期")
@DateTimeFormat(pattern = "yyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date ZCCSSRQ;
@ApiModelProperty(value = "文件类型")
@@ -5,6 +5,7 @@ import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
@@ -63,5 +64,6 @@ public class UtArea extends BaseEntity {
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date modifyTime;
@TableField(exist = false)
private List<String> sarTypeList;
}
@@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -37,6 +38,18 @@ public class UtAreaServiceImpl extends ServiceImpl<UtAreaDao, UtArea> implements
}
public List<SelectionResult> getAreaSelList(UtArea utAreaEO){
List<String> list = new ArrayList<>();
if(utAreaEO.getSarType().equals("INLAND_STAND")){
utAreaEO.setSarType(null);
list.add("INLAND_STAND");
list.add("STAND");
utAreaEO.setSarTypeList(list);
}else if(utAreaEO.getSarType().equals("FOREIGN_STAND")){
utAreaEO.setSarType(null);
list.add("FOREIGN_STAND");
list.add("STAND");
utAreaEO.setSarTypeList(list);
}
return dao.getAreaSelList(utAreaEO);
}
@@ -387,12 +387,12 @@
</if>
<if test="itemsName != null and itemsName!=''">
and ITEMS_NAME=#{itemsName}
and ITEMS_NAME like CONCAT('%', #{itemsName},'%')
</if>
<if test="XCXSSRQ !=null and XCXSSRQ!=''">
<if test="XCXSSRQ !=null">
and XCXSSRQ=#{XCXSSRQ}
</if>
<if test="ZCCSSRQ !=null and ZCCSSRQ != ''">
<if test="ZCCSSRQ !=null">
and ZCCSSRQ=#{ZCCSSRQ}
</if>
</where>
@@ -17,7 +17,7 @@
</resultMap>
<!-- 查询条件 -->
<select id="select" resultMap="resultMap" parameterType="com.adc.da.scheduled.entity.DataDTO">
<select id="selectWithinTerm" resultMap="resultMap" parameterType="com.adc.da.scheduled.entity.DataDTO">
SELECT
info.ID,
info.STAND_SORT,
@@ -31,12 +31,27 @@
FROM
sar_standards_info AS info
JOIN sar_stand_attr_info AS attrInfo ON info.id = attrinfo.stand_id
WHERE
attrInfo.${str} BETWEEN #{date.startDate} and #{date.endDate}
<where>
1=1
<if test="date!=null">
and
attrInfo.${str}
BETWEEN DATE_FORMAT( #{date.startDate},'%Y-%m-%d %H:%i:%s')
and DATE_FORMAT( #{date.endDate},'%Y-%m-%d %H:%i:%s')
</if>
</where>
</select>
<update id="updateStandardInfo">
update sar_standards_info
set TEXT_STATUS=#{textStatus}
where ID=#{id}
</update>
</mapper>
@@ -17,7 +17,7 @@
<result column="ZRGCS" property="dutyEngineer"/>
</resultMap>
<!-- 查询条件 -->
<select id="select" resultMap="resultMap" parameterType="com.adc.da.scheduled.entity.DataDTO">
<select id="selectWithinTerm" resultMap="resultMap" parameterType="com.adc.da.scheduled.entity.DataDTO">
SELECT
items.ID,
STAND_ID,
@@ -182,7 +182,7 @@
</select>
<select id="getAreaSelList" parameterType="com.adc.da.slrs.utArea.entity.UtArea" resultType="com.adc.da.sys.common.SelectionResult">
select id as value,area_name as label
select id as value,area_name as label,sar_type AS sarType
from UT_AREA
where 1=1
<if test="id != null" >
@@ -191,6 +191,12 @@
<if test="sarType != null" >
and sar_type like concat(concat('%',#{sarType}),'%')
</if>
<if test="sarTypeList != null" >
and sar_type in
<foreach collection="sarTypeList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
order by show_index,id
</select>
</mapper>
@@ -11,6 +11,8 @@ public class SelectionResult {
private String value;
private String sarType;
public String getLabel() {
return label;
}
@@ -26,4 +28,12 @@ public class SelectionResult {
public void setValue(String value) {
this.value = value;
}
public String getSarType() {
return sarType;
}
public void setSarType(String sarType) {
this.sarType = sarType;
}
}