haungxing
2 years ago
54 changed files with 1258 additions and 343 deletions
@ -1,59 +1,59 @@
|
||||
package com.hnac.hzims.scheduled.config; |
||||
|
||||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.ComponentScan; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
/** |
||||
* @Author WL |
||||
* @Version v1.0 |
||||
* @Serial 1.0 |
||||
* @Date 2022/1/8 10:23 |
||||
*/ |
||||
@Slf4j |
||||
@Configuration |
||||
//指定任务Handler所在包路径
|
||||
public class XxlJobConfig { |
||||
|
||||
|
||||
@Value("${xxl.job.admin.addresses}") |
||||
private String adminAddresses; |
||||
|
||||
@Value("${xxl.job.executor.appname}") |
||||
private String appName; |
||||
|
||||
@Value("${xxl.job.executor.ip}") |
||||
private String ip; |
||||
|
||||
@Value("${xxl.job.executor.port}") |
||||
private int port; |
||||
|
||||
@Value("${xxl.job.accessToken}") |
||||
private String accessToken; |
||||
|
||||
@Value("${xxl.job.executor.logpath}") |
||||
private String logPath; |
||||
|
||||
@Value("${xxl.job.executor.logretentiondays}") |
||||
private int logRetentionDays; |
||||
|
||||
|
||||
@Bean(initMethod = "start", destroyMethod = "destroy") |
||||
public XxlJobSpringExecutor xxlJobExecutor() { |
||||
log.info("====xxl-job config init===="); |
||||
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); |
||||
xxlJobSpringExecutor.setAdminAddresses(adminAddresses); |
||||
xxlJobSpringExecutor.setAppName(appName); |
||||
xxlJobSpringExecutor.setIp(ip); |
||||
xxlJobSpringExecutor.setPort(port); |
||||
xxlJobSpringExecutor.setAccessToken(accessToken); |
||||
xxlJobSpringExecutor.setLogPath(logPath); |
||||
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); |
||||
return xxlJobSpringExecutor; |
||||
} |
||||
|
||||
} |
||||
|
||||
// package com.hnac.hzims.scheduled.config;
|
||||
//
|
||||
// import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
||||
// import lombok.extern.slf4j.Slf4j;
|
||||
// import org.springframework.beans.factory.annotation.Value;
|
||||
// import org.springframework.context.annotation.Bean;
|
||||
// import org.springframework.context.annotation.ComponentScan;
|
||||
// import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
// /**
|
||||
// * @Author WL
|
||||
// * @Version v1.0
|
||||
// * @Serial 1.0
|
||||
// * @Date 2022/1/8 10:23
|
||||
// */
|
||||
// @Slf4j
|
||||
// @Configuration
|
||||
// //指定任务Handler所在包路径
|
||||
// public class XxlJobConfig {
|
||||
//
|
||||
//
|
||||
// @Value("${xxl.job.admin.addresses}")
|
||||
// private String adminAddresses;
|
||||
//
|
||||
// @Value("${xxl.job.executor.appname}")
|
||||
// private String appName;
|
||||
//
|
||||
// @Value("${xxl.job.executor.ip}")
|
||||
// private String ip;
|
||||
//
|
||||
// @Value("${xxl.job.executor.port}")
|
||||
// private int port;
|
||||
//
|
||||
// @Value("${xxl.job.accessToken}")
|
||||
// private String accessToken;
|
||||
//
|
||||
// @Value("${xxl.job.executor.logpath}")
|
||||
// private String logPath;
|
||||
//
|
||||
// @Value("${xxl.job.executor.logretentiondays}")
|
||||
// private int logRetentionDays;
|
||||
//
|
||||
//
|
||||
// @Bean(initMethod = "start", destroyMethod = "destroy")
|
||||
// public XxlJobSpringExecutor xxlJobExecutor() {
|
||||
// log.info("====xxl-job config init====");
|
||||
// XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
||||
// xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
|
||||
// xxlJobSpringExecutor.setAppName(appName);
|
||||
// xxlJobSpringExecutor.setIp(ip);
|
||||
// xxlJobSpringExecutor.setPort(port);
|
||||
// xxlJobSpringExecutor.setAccessToken(accessToken);
|
||||
// xxlJobSpringExecutor.setLogPath(logPath);
|
||||
// xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
|
||||
// return xxlJobSpringExecutor;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
|
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.scheduled.mapper.operation.HistoryAbnormalAlarmMapper"> |
||||
<select id="getHistoryAbnormalAlarm" resultType="com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity"> |
||||
select * from hzims_history_abnormal_alarm |
||||
where station_id = #{stationId} |
||||
and type = #{type} |
||||
and status = 0 |
||||
</select> |
||||
</mapper> |
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.scheduled.mapper.operation.StationMapper"> |
||||
<select id="selectStationByType" resultType="com.hnac.hzims.operational.station.entity.StationEntity"> |
||||
select * from hzims_station where IS_DELETED = 0 and REF_DEPT IS NOT NULL and `TYPE` IS NOT NULL |
||||
<if test="serveType != null"> |
||||
AND SERVE_TYPE = #{serveType} |
||||
</if> |
||||
<if test="stationType != null"> |
||||
AND `TYPE` = #{stationType} |
||||
</if> |
||||
</select> |
||||
|
||||
|
||||
<select id="selectAll" resultType="com.hnac.hzims.operational.station.entity.StationEntity"> |
||||
select * from hzims_station where IS_DELETED = 0 and REF_DEPT IS NOT NULL AND REF_DOMAIN IS NOT NULL AND `TYPE` IS NOT NULL |
||||
</select> |
||||
|
||||
|
||||
<select id="selectStationByInCode" resultType="com.hnac.hzims.operational.station.entity.StationEntity"> |
||||
SELECT * FROM hzims_station WHERE IS_DELETED = 0 and `CODE` IN |
||||
<foreach collection="list" item="item" index="index" open="(" close=")" separator=","> |
||||
#{item} |
||||
</foreach> |
||||
</select> |
||||
</mapper> |
@ -0,0 +1,67 @@
|
||||
package com.hnac.hzims.ticket.twoTicket.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableLogic; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import lombok.Data; |
||||
|
||||
import java.time.LocalDateTime; |
||||
|
||||
/** |
||||
* |
||||
* 工作票危险点分析及控制措施票 |
||||
* @Author WL |
||||
* @Version v1.0 |
||||
* @Serial 1.0 |
||||
* @Date 2023/5/25 17:03 |
||||
*/ |
||||
@Data |
||||
@TableName("hzims_ticket_info_danger") |
||||
public class TicketInfoDanger { |
||||
|
||||
|
||||
/** |
||||
* 编号 |
||||
*/ |
||||
private Long id; |
||||
|
||||
|
||||
/** |
||||
* 工作票编号 |
||||
*/ |
||||
private Long ticketId; |
||||
|
||||
/** |
||||
* 安全措施 |
||||
*/ |
||||
private String maintenance; |
||||
|
||||
|
||||
/** |
||||
* 危险点 |
||||
*/ |
||||
private String dangerousPoint; |
||||
|
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
@TableField(value = "update_time", fill = FieldFill.INSERT) |
||||
private LocalDateTime createTime; |
||||
|
||||
|
||||
/** |
||||
* 更新时间 |
||||
*/ |
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) |
||||
private LocalDateTime updateTime; |
||||
|
||||
|
||||
/** |
||||
* 逻辑删除 |
||||
*/ |
||||
@TableLogic |
||||
@TableField("is_deleted") |
||||
private Boolean deleted; |
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.hnac.hzims.ticket.twoTicket.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger; |
||||
|
||||
/** |
||||
* @Author WL |
||||
* @Version v1.0 |
||||
* @Serial 1.0 |
||||
* @Date 2023/5/25 17:13 |
||||
*/ |
||||
public interface TicketInfoDangerMapper extends BaseMapper<TicketInfoDanger> { |
||||
} |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.ticket.twoTicket.mapper.TicketInfoDangerMapper"> |
||||
|
||||
</mapper> |
@ -0,0 +1,24 @@
|
||||
package com.hnac.hzims.ticket.twoTicket.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author WL |
||||
* @Version v1.0 |
||||
* @Serial 1.0 |
||||
* @Date 2023/5/25 17:15 |
||||
*/ |
||||
public interface TicketInfoDangerService extends IService<TicketInfoDanger> { |
||||
|
||||
|
||||
/** |
||||
* 根据工作票Id查询工作票危险点分析及控制措施票 |
||||
* @param ticketId |
||||
* @return |
||||
*/ |
||||
|
||||
List<TicketInfoDanger> selectAllByTicket(Long ticketId); |
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.hnac.hzims.ticket.twoTicket.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger; |
||||
import com.hnac.hzims.ticket.twoTicket.mapper.TicketInfoDangerMapper; |
||||
import com.hnac.hzims.ticket.twoTicket.service.TicketInfoDangerService; |
||||
import lombok.RequiredArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author WL |
||||
* @Version v1.0 |
||||
* @Serial 1.0 |
||||
* @Date 2023/5/25 17:15 |
||||
*/ |
||||
@Slf4j |
||||
@RequiredArgsConstructor |
||||
@Service |
||||
public class TicketInfoDangerServiceImpl extends ServiceImpl<TicketInfoDangerMapper, TicketInfoDanger> implements TicketInfoDangerService { |
||||
/** |
||||
* 根据工作票Id查询工作票危险点分析及控制措施票 |
||||
* |
||||
* @param ticketId |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<TicketInfoDanger> selectAllByTicket(Long ticketId) { |
||||
LambdaQueryWrapper<TicketInfoDanger> queryWrapper = new LambdaQueryWrapper<>(); |
||||
queryWrapper.eq(TicketInfoDanger::getTicketId,ticketId); |
||||
return baseMapper.selectList(queryWrapper); |
||||
} |
||||
} |
@ -0,0 +1,178 @@
|
||||
package com.hnac.hzims.ticket.utils; |
||||
|
||||
/** |
||||
* @Author WL |
||||
* @Version v1.0 |
||||
* @Serial 1.0 |
||||
* @Date 2023/5/23 16:42 |
||||
*/ |
||||
import org.apache.poi.openxml4j.opc.OPCPackage; |
||||
import org.apache.poi.xwpf.usermodel.BreakType; |
||||
import org.apache.poi.xwpf.usermodel.Document; |
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument; |
||||
import org.apache.poi.xwpf.usermodel.XWPFPictureData; |
||||
import org.apache.xmlbeans.XmlOptions; |
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBody; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.FileOutputStream; |
||||
import java.io.OutputStream; |
||||
import java.time.LocalDate; |
||||
import java.util.*; |
||||
import java.util.regex.Matcher; |
||||
import java.util.regex.Pattern; |
||||
|
||||
|
||||
/** |
||||
* 参数1:需要合并的word的文件对象list |
||||
* 参数2:合并之后word存储的全路径file对象 |
||||
*/ |
||||
public class MergeDocUtils { |
||||
|
||||
|
||||
/** |
||||
* word文档合并 |
||||
* @param fileList 合并文档的路径 |
||||
* @param response 新的word |
||||
* @throws Exception |
||||
*/ |
||||
public static void mergeDoc(List<File> fileList, HttpServletResponse response)throws Exception { |
||||
|
||||
OutputStream dest = response.getOutputStream(); |
||||
ArrayList<XWPFDocument> documentList = new ArrayList<XWPFDocument>(); |
||||
XWPFDocument doc = null; |
||||
for (int i = 0; i < fileList.size(); i++) { |
||||
FileInputStream in = new FileInputStream(fileList.get(i).getPath()); |
||||
OPCPackage open = OPCPackage.open(in); |
||||
XWPFDocument document = new XWPFDocument(open); |
||||
documentList.add(document); |
||||
} |
||||
|
||||
|
||||
|
||||
for (int i = 0; i < documentList.size(); i++) { |
||||
doc = documentList.get(0); |
||||
if (i == 0) { |
||||
//首页直接分页,不再插入首页文档内容
|
||||
documentList.get(i).createParagraph().createRun().addBreak(BreakType.PAGE); |
||||
} else if (i == documentList.size() - 1) { |
||||
//尾页不再分页,直接插入最后文档内容
|
||||
appendBody(doc, documentList.get(i)); |
||||
} else { |
||||
documentList.get(i).createParagraph().createRun().addBreak(BreakType.PAGE); |
||||
appendBody(doc, documentList.get(i)); |
||||
} |
||||
} |
||||
//输出合并之后的文件
|
||||
doc.write(dest); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 图片文件追加 |
||||
* @param src |
||||
* @param append |
||||
* @throws Exception |
||||
*/ |
||||
public static void appendBody(XWPFDocument src, XWPFDocument append) throws Exception { |
||||
CTBody src1Body = src.getDocument().getBody(); |
||||
CTBody src2Body = append.getDocument().getBody(); |
||||
|
||||
List<XWPFPictureData> allPictures = append.getAllPictures(); |
||||
// 记录图片合并前及合并后的ID
|
||||
Map<String, String> map = new HashMap(); |
||||
for (XWPFPictureData picture : allPictures) { |
||||
String before = append.getRelationId(picture); |
||||
//将原文档中的图片加入到目标文档中
|
||||
String after = src.addPictureData(picture.getData(), Document.PICTURE_TYPE_PNG); |
||||
map.put(before, after); |
||||
} |
||||
|
||||
appendBody(src1Body, src2Body, map); |
||||
|
||||
} |
||||
|
||||
private static void appendBody(CTBody src, CTBody append, Map<String, String> map) throws Exception { |
||||
XmlOptions optionsOuter = new XmlOptions(); |
||||
optionsOuter.setSaveOuter(); |
||||
String appendString = append.xmlText(optionsOuter); |
||||
|
||||
//去掉追加word内容中的 w:sectPr 标签,确保合成的word中只有一个 w:sectPr 标签对
|
||||
//避免合成的word文档打开之后会提示有些内容读不出来,导致文件损坏
|
||||
String rgex = "<[\\s]*?w:sectPr[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?w:sectPr[\\s]*?>"; |
||||
appendString = appendString.replaceAll(rgex, ""); |
||||
|
||||
String srcString = src.xmlText(); |
||||
String regex = regex(srcString, "w:sectPr"); |
||||
// System.out.println(regex);
|
||||
|
||||
String prefix = srcString.substring(0, srcString.indexOf(">") + 1); |
||||
String mainPart = srcString.substring(srcString.indexOf(">") + 1, srcString.lastIndexOf("<")); |
||||
String sufix = srcString.substring(srcString.lastIndexOf("<")); |
||||
String addPart = appendString.substring(appendString.indexOf(">") + 1, appendString.lastIndexOf("<")); |
||||
|
||||
if (map != null && !map.isEmpty()) { |
||||
//对xml字符串中图片ID进行替换
|
||||
for (Map.Entry<String, String> set : map.entrySet()) { |
||||
addPart = addPart.replace(set.getKey(), set.getValue()); |
||||
} |
||||
} |
||||
//将两个文档的xml内容进行拼接
|
||||
CTBody makeBody = CTBody.Factory.parse(prefix + mainPart + addPart + sufix); |
||||
|
||||
src.set(makeBody); |
||||
} |
||||
|
||||
/** |
||||
* 获取指定标签中的内容 |
||||
* |
||||
* @param xml |
||||
* @param label |
||||
* @return |
||||
*/ |
||||
public static String regex(String xml, String label) { |
||||
String context = ""; |
||||
// 正则表达式
|
||||
String rgex = "<" + label + "[^>]*>((?:(?!<\\/" + label + ">)[\\s\\S])*)<\\/" + label + ">"; |
||||
Pattern pattern = Pattern.compile(rgex);// 匹配的模式
|
||||
Matcher m = pattern.matcher(xml); |
||||
// 匹配的有多个
|
||||
List<String> list = new ArrayList<String>(); |
||||
while (m.find()) { |
||||
int i = 1; |
||||
list.add(m.group(i)); |
||||
i++; |
||||
} |
||||
if (list.size() > 0) { |
||||
// 输出内容自己定义
|
||||
context = String.valueOf(list.size()); |
||||
} |
||||
return context; |
||||
} |
||||
|
||||
|
||||
// public static void main(String[] args) throws Exception {
|
||||
// //new一个list 模拟要合并的word对象集合
|
||||
// List<File>docFileList = new ArrayList<>();
|
||||
// docFileList.add(new File("F:\\idea项目\\flowable\\demo\\src\\main\\resources\\电气第一种工作票模版.docx"));
|
||||
// docFileList.add(new File("F:\\idea项目\\flowable\\demo\\src\\main\\resources\\动火工作票.docx"));
|
||||
//
|
||||
// //合并之后doc存储路径 此处读的配置文件的存储路径 D:/pdfData/
|
||||
// String docPath = "D:\\导出excel\\";
|
||||
// //当前日期+UUID作为文件名防止重复
|
||||
// String fileName = LocalDate.now() + "-" + UUID.randomUUID().toString().replaceAll("-", "");
|
||||
// //合并之后doc存储路径
|
||||
// String mergeDocUrl = docPath+fileName+".docx";
|
||||
// //转成file对象
|
||||
// File mergeDocFile = new File(mergeDocUrl);
|
||||
//
|
||||
// //合并doc
|
||||
// MergeDocUtils.mergeDoc(docFileList,mergeDocFile);
|
||||
//
|
||||
// System.out.println("合并word成功");
|
||||
//
|
||||
// }
|
||||
} |
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue