From 80d45d508acfddc39d85819e7fe2f657d1309a81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AE=B5=E9=A3=9E=E5=AE=87?= <2684146481@qq.com>
Date: Fri, 12 May 2023 15:00:49 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpoi=E6=96=87=E6=A1=A3?=
=?UTF-8?q?=E5=AF=BC=E5=87=BA=E7=89=88=E6=9C=AC=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
hzims-biz-common/pom.xml | 6 ++
hzims-service/assets/pom.xml | 8 +--
.../spare/service/impl/WtSpBasicServiceImpl.java | 1 +
.../equipment/src/main/resources/db/1.0.0.sql | 73 ++++++++++++++++++++
hzims-service/operational/pom.xml | 42 ++++++------
hzims-service/ticket/pom.xml | 36 +++++-----
.../service/impl/TicketProcessServiceImpl.java | 78 +++++++---------------
.../java/com/hnac/hzims/ticket/utils/PdfUtils.java | 6 ++
.../ticket/workTicket/dto/WorkTicketInfoDto.java | 4 --
pom.xml | 42 ++++++------
10 files changed, 176 insertions(+), 120 deletions(-)
create mode 100644 hzims-service/equipment/src/main/resources/db/1.0.0.sql
diff --git a/hzims-biz-common/pom.xml b/hzims-biz-common/pom.xml
index 5255f48..be7e8e8 100644
--- a/hzims-biz-common/pom.xml
+++ b/hzims-biz-common/pom.xml
@@ -41,6 +41,12 @@
blade-starter-datascope
+
+
+ cn.afterturn
+ easypoi-spring-boot-starter
+ 4.4.0
+
diff --git a/hzims-service/assets/pom.xml b/hzims-service/assets/pom.xml
index 80a5994..3304ecc 100644
--- a/hzims-service/assets/pom.xml
+++ b/hzims-service/assets/pom.xml
@@ -64,10 +64,10 @@
message-api
compile
-
- cn.afterturn
- easypoi-base
-
+
+
+
+
diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java
index c33c23e..3cd4818 100644
--- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java
+++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java
@@ -1,6 +1,7 @@
package com.hnac.hzims.spare.service.impl;
+import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
diff --git a/hzims-service/equipment/src/main/resources/db/1.0.0.sql b/hzims-service/equipment/src/main/resources/db/1.0.0.sql
new file mode 100644
index 0000000..0725615
--- /dev/null
+++ b/hzims-service/equipment/src/main/resources/db/1.0.0.sql
@@ -0,0 +1,73 @@
+SET FOREIGN_KEY_CHECKS=0;
+
+CREATE TABLE `dev_equipment`.`hzims_em_association` (
+ `ID` bigint(20) NOT NULL COMMENT '主键Id',
+ `EM_ID` bigint(20) NULL DEFAULT NULL COMMENT '设备Id',
+ `FDP_EM_ID` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'FDP设备Id',
+ `FDP_EM_NAME` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'PDF设备名称',
+ `TENANT_ID` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
+ `CREATE_TIME` datetime NULL DEFAULT NULL COMMENT '创建时间',
+ `UPDATE_TIME` datetime NULL DEFAULT NULL COMMENT '更新时间',
+ `CREATE_USER` bigint(64) NULL DEFAULT NULL COMMENT '创建人',
+ `UPDATE_USER` bigint(64) NULL DEFAULT NULL COMMENT '修改人',
+ `CREATE_DEPT` bigint(64) NULL DEFAULT NULL COMMENT '创建部门',
+ `STATUS` int(2) NULL DEFAULT 0 COMMENT '状态',
+ `IS_DELETED` int(2) NULL DEFAULT 0 COMMENT '是否已删除: 0、否; 1、是',
+ PRIMARY KEY (`ID`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备关联表' ROW_FORMAT = Dynamic;
+
+CREATE TABLE `dev_equipment`.`hzims_em_association_detail` (
+ `PID` bigint(20) NOT NULL COMMENT '父id',
+ `ID` bigint(20) NOT NULL COMMENT '主键Id',
+ `EM_POINT_ID` bigint(20) NOT NULL COMMENT '设备点Id',
+ `FDP_EM_POINT_ID` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'FDP点Id',
+ `FDP_EM_POINT_NAME` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'FDP监测点名称',
+ `FDP_EM_POINT_ORD` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'FDP监测点位置',
+ `PRO_TYPE` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '属性类型:yc、yx、soe',
+ `TENANT_ID` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
+ `CREATE_TIME` datetime NULL DEFAULT NULL COMMENT '创建时间',
+ `UPDATE_TIME` datetime NULL DEFAULT NULL COMMENT '更新时间',
+ `CREATE_USER` bigint(64) NULL DEFAULT NULL COMMENT '创建人',
+ `UPDATE_USER` bigint(64) NULL DEFAULT NULL COMMENT '修改人',
+ `CREATE_DEPT` bigint(64) NULL DEFAULT NULL COMMENT '创建部门',
+ `STATUS` int(2) NULL DEFAULT 0 COMMENT '状态',
+ `IS_DELETED` int(2) NULL DEFAULT 0 COMMENT '是否已删除: 0、否; 1、是',
+ PRIMARY KEY (`ID`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备关联明细表' ROW_FORMAT = Dynamic;
+
+ALTER TABLE `dev_equipment`.`hzims_em_info` ADD COLUMN `em_index` tinyint(4) NULL DEFAULT NULL COMMENT '设备序号' AFTER `CREATE_DEPT`;
+
+ALTER TABLE `dev_equipment`.`hzims_em_info` ADD COLUMN `DEVICE_INSTANCE_ID` bigint(20) NULL DEFAULT NULL COMMENT '设备实例化Id' AFTER `em_index`;
+
+ALTER TABLE `dev_equipment`.`hzims_em_info` ADD COLUMN `em_type` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '设备类型' AFTER `DEVICE_INSTANCE_ID`;
+
+ALTER TABLE `dev_equipment`.`hzims_em_info` ADD COLUMN `set_type` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '机组类型' AFTER `em_type`;
+
+ALTER TABLE `dev_equipment`.`hzims_em_info` MODIFY COLUMN `NUMBER` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备编号' AFTER `ID`;
+
+ALTER TABLE `dev_equipment`.`hzims_em_info` MODIFY COLUMN `HOME_PAGE_DISPLAY` char(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0' COMMENT '首页展示' AFTER `LINKER_PHONE`;
+
+ALTER TABLE `dev_equipment`.`hzims_em_info` MODIFY COLUMN `GRADE_CODE` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '设备等级' AFTER `MANAGER`;
+
+ALTER TABLE `dev_equipment`.`hzims_em_info` MODIFY COLUMN `RUN_STATUS` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '2' COMMENT '运行状态' AFTER `INS_LOCATION`;
+
+CREATE TABLE `dev_equipment`.`hzims_workshop_equipment` (
+ `ID` bigint(20) NOT NULL COMMENT '主键ID',
+ `WORKSHOP_ID` bigint(20) NOT NULL COMMENT '厂房ID',
+ `WORKSHOP_NAME` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '厂房名称',
+ `EM_ID` bigint(20) NOT NULL COMMENT '设备ID',
+ `EM_NAME` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '设备名称',
+ `TENANT_ID` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
+ `CREATE_TIME` datetime NOT NULL COMMENT '创建时间',
+ `UPDATE_TIME` datetime NULL DEFAULT NULL COMMENT '更新时间',
+ `CREATE_USER` bigint(20) NOT NULL COMMENT '创建人',
+ `UPDATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
+ `IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除',
+ `STATUS` tinyint(4) NULL DEFAULT NULL COMMENT '状态 0-启用 1-停用',
+ `CREATE_DEPT` bigint(20) NULL DEFAULT NULL COMMENT '创建部门',
+ PRIMARY KEY (`ID`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;
+
+CREATE ALGORITHM = UNDEFINED DEFINER = `root`@`%` SQL SECURITY DEFINER VIEW `dev_equipment`.`v_hzims_fdp_fualt` AS (select `t1`.`ID` AS `ID`,`t1`.`FDP_ID` AS `FDP_ID`,`t1`.`NAME` AS `NAME`,`t1`.`INFO` AS `INFO`,`t1`.`EM_CODE` AS `EM_CODE`,`t1`.`DETECTABILITY` AS `DETECTABILITY`,`t1`.`SEVERITY` AS `SEVERITY`,`t1`.`FDP_DEVICE_ID` AS `FDP_DEVICE_ID`,`t1`.`FDP_DEVICE_NAME` AS `FDP_DEVICE_NAME`,`t1`.`ORD` AS `ORD`,`t1`.`DISPLAY` AS `DISPLAY`,`t1`.`TENANT_ID` AS `TENANT_ID`,`t1`.`CREATE_TIME` AS `CREATE_TIME`,`t1`.`UPDATE_TIME` AS `UPDATE_TIME`,`t1`.`CREATE_USER` AS `CREATE_USER`,`t1`.`UPDATE_USER` AS `UPDATE_USER`,`t1`.`IS_DELETED` AS `IS_DELETED`,`t1`.`STATUS` AS `STATUS`,`t1`.`CREATE_DEPT` AS `CREATE_DEPT`,`t2`.`FAULT_AMOUNT` AS `FAULT_AMOUNT` from (`dev_equipment`.`hzims_fdp_fault` `t1` join (select `t`.`NAME` AS `name`,count(`t`.`NAME`) AS `FAULT_AMOUNT` from `dev_equipment`.`hzims_fdp_fault` `t` group by `t`.`NAME` order by count(`t`.`NAME`) desc) `t2`) where (`t1`.`NAME` = `t2`.`name`) order by `t2`.`FAULT_AMOUNT` desc);
+
+SET FOREIGN_KEY_CHECKS=1;
\ No newline at end of file
diff --git a/hzims-service/operational/pom.xml b/hzims-service/operational/pom.xml
index 8e5a5fd..2eb0339 100644
--- a/hzims-service/operational/pom.xml
+++ b/hzims-service/operational/pom.xml
@@ -18,19 +18,19 @@
-
-
- org.apache.poi
- poi
-
-
- org.apache.poi
- poi-ooxml
-
-
- org.apache.poi
- poi-ooxml-schemas
-
+
+
+
+
+
+
+
+
+
+
+
+
+
org.springblade
@@ -88,10 +88,10 @@
easypoi-web
3.2.0
-->
-
- cn.afterturn
- easypoi-base
-
+
+
+
+
org.apache.poi
@@ -108,10 +108,10 @@
jfreechart
1.5.0
-
- cn.afterturn
- easypoi-annotation
-
+
+
+
+
com.hikvision.ga
artemis-http-client
diff --git a/hzims-service/ticket/pom.xml b/hzims-service/ticket/pom.xml
index 33b15c7..7f5c8c1 100644
--- a/hzims-service/ticket/pom.xml
+++ b/hzims-service/ticket/pom.xml
@@ -66,25 +66,36 @@
org.apache.poi
poi
+ 4.0.0
org.apache.poi
poi-ooxml
+ 4.0.0
-
- org.apache.poi
- poi-ooxml-schemas
-
-
- org.apache.poi
- poi-scratchpad
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
cn.afterturn
- easypoi-web
- ${easypoi.version}
+ easypoi-spring-boot-starter
+ 4.0.0
+
cn.hutool
hutool-core
@@ -285,11 +296,6 @@
swagger-bootstrap-ui
${swagger-bootstrap-ui.version}
-
-
- com.hnac.hzims
- hzims-operational-api
-
diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
index 0770a20..c1f675e 100644
--- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
+++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
@@ -1,5 +1,6 @@
package com.hnac.hzims.ticket.twoTicket.service.impl;
+
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.alibaba.fastjson.JSON;
@@ -612,38 +613,41 @@ public class TicketProcessServiceImpl implements TicketProcessService {
* @param ticketType
* @param ticketId
*/
+ @SneakyThrows
@Override
public void preview(String ticketType, Long ticketId) {
WorkTicketVo workTicketVo = ticketInfoService.selectDetailsById(ticketId);
//将查询的数据转换为map
Map workTicketInfoMap = this.convertMap(workTicketVo);
-
+ workTicketInfoMap.put("name", 22);
String fileName = TicketConstants.WordFileNameEnum.getFileNameByType(ticketType) + PdfUtils.XLSX_SUFFIX;
log.info("工作票模板为:{}", fileName);
TemplateExportParams templateExportParams = new TemplateExportParams("template/新电气第一种工作票模板.xlsx", true);
Workbook workbook = null;
- Map map = new HashMap();
- map.put("name", "你好");
try {
- workbook = ExcelExportUtil.exportExcel(templateExportParams, map);
+ workbook = ExcelExportUtil.exportExcel(templateExportParams, workTicketInfoMap);
} catch (Exception e) {
e.printStackTrace();
}
- //上传xlsx至服务器
- try {
- ExcelUtil.upload(workbook, xlsSavePath, workTicketVo.getWorkTicket().getWorkContent() + PdfUtils.XLSX_SUFFIX);
- } catch (Exception e) {
- e.printStackTrace();
- }
- //将xlsx文件转换为pdf并保存
- String pdfFileName = workTicketVo.getWorkTicket().getWorkContent() + PdfUtils.PDF_SUFFIX;
- String xlsFileName = workTicketVo.getWorkTicket().getWorkContent() + PdfUtils.XLSX_SUFFIX;
- PdfUtils.convertPdf(xlsSavePath, xlsFileName, pdfSavePath, pdfFileName);
- String savePath = pdfSavePath + pdfFileName;
- // 设置response参数,可以打开下载页面
- ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
- HttpServletResponse response = servletRequestAttributes.getResponse();
- PdfUtils.readPdf(response, savePath);
+
+ FileOutputStream fos = new FileOutputStream("F:\\idea项目\\flowable\\demo\\src\\main\\resources\\新电气第一种工作票模板5" +
+ ".xlsx");
+ workbook.write(fos);
+ // //上传xlsx至服务器
+ // try {
+ // ExcelUtil.upload(workbook, xlsSavePath, workTicketVo.getWorkTicket().getWorkContent() + PdfUtils.XLSX_SUFFIX);
+ // } catch (Exception e) {
+ // e.printStackTrace();
+ // }
+ // //将xlsx文件转换为pdf并保存
+ // String pdfFileName = workTicketVo.getWorkTicket().getWorkContent() + PdfUtils.PDF_SUFFIX;
+ // String xlsFileName = workTicketVo.getWorkTicket().getWorkContent() + PdfUtils.XLSX_SUFFIX;
+ // PdfUtils.convertPdf(xlsSavePath, xlsFileName, pdfSavePath, pdfFileName);
+ // String savePath = pdfSavePath + pdfFileName;
+ // // 设置response参数,可以打开下载页面
+ // ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+ // HttpServletResponse response = servletRequestAttributes.getResponse();
+ // PdfUtils.readPdf(response, savePath);
}
@@ -709,42 +713,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
return JSONObject.parseObject(JSONObject.toJSONString(target), Map.class);
}
-
- public static void main(String[] args) throws IOException {
- //System.out.println(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss").format(LocalDateTime.now()));
- TemplateExportParams params = new TemplateExportParams(
- "template/新电气第一种工作票模板.xlsx");
-
- Map map = new HashMap();
- map.put("name", "你好");
- // map.put("money", 2000000.00);
- // map.put("upperMoney", "贰佰万");
- // map.put("company", "执笔潜行科技有限公司");
- // map.put("bureau", "财政局");
- // map.put("person", "JueYue");
- // map.put("phone", "1879740****");
- // List