Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dcs-plan
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
INET-TWO
server
dcs-plan
Commits
de1267a6
Commit
de1267a6
authored
Sep 03, 2024
by
wangqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加:使用EasyExcel插件创建IED excelvo
parent
dc093fad
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
240 additions
and
2 deletions
+240
-2
ExtIEDPlanExcelVO.java
.../java/com/yonde/dcs/plan/common/vo/ExtIEDPlanExcelVO.java
+159
-0
IEDPlanExcelListenner.java
...m/yonde/dcs/plan/core/listener/IEDPlanExcelListenner.java
+67
-0
PurchasePlanExcelListenner.java
...de/dcs/plan/core/listener/PurchasePlanExcelListenner.java
+14
-2
No files found.
dcs-plan-common/src/main/java/com/yonde/dcs/plan/common/vo/ExtIEDPlanExcelVO.java
0 → 100644
View file @
de1267a6
package
com
.
yonde
.
dcs
.
plan
.
common
.
vo
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.write.style.ColumnWidth
;
import
lombok.*
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
@EqualsAndHashCode
(
callSuper
=
false
)
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ExtIEDPlanExcelVO
{
@ExcelProperty
(
value
=
{
"IED计划"
,
"操作*"
},
index
=
0
)
@ColumnWidth
(
15
)
private
String
operation
;
/**
* 文件类型
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"文件类型*"
},
index
=
1
)
@ColumnWidth
(
15
)
private
Integer
fileType
;
/**
* 文件分类
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"文件分类*"
},
index
=
2
)
@ColumnWidth
(
15
)
private
Integer
fileClassify
;
/**
* 文件编号
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"文件编号*"
},
index
=
3
)
@ColumnWidth
(
15
)
private
String
fileNumber
;
/**
* 文件代号
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"文件代号*"
},
index
=
4
)
@ColumnWidth
(
15
)
private
String
fileCode
;
/**
* 管理员系统编码
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"管理员系统编码*"
},
index
=
5
)
@ColumnWidth
(
15
)
private
String
systemNumber
;
/**
* 设备编号
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"设备编号*"
},
index
=
6
)
@ColumnWidth
(
15
)
private
String
deviceNumber
;
/**
* 阶段
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"阶段*"
},
index
=
7
)
@ColumnWidth
(
15
)
private
String
phase
;
/**
* 节点审核时间
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"节点审核时间*"
},
index
=
8
)
@ColumnWidth
(
15
)
private
LocalDateTime
auditTime
;
/**
* 文件提交时间
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"文件提交时间*"
},
index
=
9
)
@ColumnWidth
(
15
)
private
LocalDateTime
fileSubmitTimee
;
/**
* 编写者
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"编写*"
},
index
=
10
)
@ColumnWidth
(
15
)
private
String
editor
;
/**
* 校核者
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"校核*"
},
index
=
11
)
@ColumnWidth
(
15
)
private
String
checker
;
/**
* 审核者
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"审核*"
},
index
=
12
)
@ColumnWidth
(
15
)
private
String
auditor
;
/**
* 审定者
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"审定*"
},
index
=
13
)
@ColumnWidth
(
15
)
private
String
investigator
;
/**
* 批准者
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"批准*"
},
index
=
14
)
@ColumnWidth
(
15
)
private
String
ratifier
;
/**
* 备注
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"备注*"
},
index
=
15
)
@ColumnWidth
(
15
)
private
String
note
;
/**
* 密级
*/
@ExcelProperty
(
value
=
{
"IED计划"
,
"密级*"
},
index
=
16
)
@ColumnWidth
(
15
)
private
String
secretCode
;
public
static
void
main
(
String
[]
args
)
{
List
<
ExtIEDPlanExcelVO
>
list
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<=
1
;
i
++){
ExtIEDPlanExcelVO
extIEDPlanExcelVO
=
new
ExtIEDPlanExcelVO
();
extIEDPlanExcelVO
.
setNote
(
"测试"
+
i
);
list
.
add
(
extIEDPlanExcelVO
);
}
EasyExcel
.
write
(
"F:\\yangyi\\项目\\清华核研院\\核研院设计文档及原型\\IED计划导入模板22.xlsx"
,
ExtIEDPlanExcelVO
.
class
)
.
sheet
(
"采购计划"
).
doWrite
(
list
);
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/listener/IEDPlanExcelListenner.java
0 → 100644
View file @
de1267a6
package
com
.
yonde
.
dcs
.
plan
.
core
.
listener
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.excel.util.ListUtils
;
import
com.yonde.dcs.plan.common.constants.Constants
;
import
com.yonde.dcs.plan.common.vo.ExtIDEPlanVO
;
import
com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO
;
import
com.yonde.dcs.plan.common.vo.ExtPuchasePlanExcelVO
;
import
com.yonde.dcs.plan.core.service.ExtDistributeRecordService
;
import
com.yonde.dcs.plan.core.service.ExtIDEPlanService
;
import
com.yonde.dex.basedata.entity.data.OperatorType
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Component
@Slf4j
public
class
IEDPlanExcelListenner
extends
AnalysisEventListener
<
ExtIDEPlanVO
>
{
@Autowired
private
ExtIDEPlanService
extIDEPlanService
;
/**
* 每隔100条处理下,然后清理list ,方便内存回收
*/
private
static
final
int
BATCH_COUNT
=
100
;
/**
* 缓存的数据
*/
private
List
<
ExtPuchasePlanExcelVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
ExtIDEPlanVO
extIDEPlanVO
,
AnalysisContext
analysisContext
)
{
log
.
info
(
"解析到一条数据:{}"
,
extIDEPlanVO
);
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
analysisContext
)
{
// 收尾工作,处理剩下的缓存数据。。。
log
.
info
(
"sheet={} 所有数据解析完成!"
,
analysisContext
.
readSheetHolder
().
getSheetName
());
}
/**
*
* @param exception
* @param context
* @throws Exception
*/
@Override
public
void
onException
(
Exception
exception
,
AnalysisContext
context
)
throws
Exception
{
log
.
error
(
"======>>>解析异常:"
,
exception
);
throw
exception
;
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/listener/PurchasePlanExcelListenner.java
View file @
de1267a6
...
...
@@ -7,8 +7,10 @@ import com.yonde.dcs.plan.common.constants.Constants;
import
com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO
;
import
com.yonde.dcs.plan.common.vo.ExtPuchasePlanExcelVO
;
import
com.yonde.dcs.plan.core.service.ExtDistributeRecordService
;
import
com.yonde.dcs.plan.core.service.ExtPuchasePlanAttributeService
;
import
com.yonde.dex.basedata.entity.data.OperatorType
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -19,7 +21,7 @@ import java.util.List;
public
class
PurchasePlanExcelListenner
extends
AnalysisEventListener
<
ExtPuchasePlanExcelVO
>
{
@Autowired
private
Ext
DistributeRecordService
extDistributeRecord
Service
;
private
Ext
PuchasePlanAttributeService
extPuchasePlanAttribute
Service
;
/**
* 每隔100条处理下,然后清理list ,方便内存回收
...
...
@@ -40,7 +42,7 @@ public class PurchasePlanExcelListenner extends AnalysisEventListener<ExtPuchase
//根据excle中操作符执行 新增、更新、删除
if
(
Constants
.
EXCEL_ADD
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())){
extPuchasePlanAttributeVO
.
setOperator
(
OperatorType
.
ADD
);
ext
DistributeRecord
Service
.
saveRecursion
(
transformObject
(
extPuchasePlanAttributeVO
,
extPuchasePlanExcelVO
));
ext
PuchasePlanAttribute
Service
.
saveRecursion
(
transformObject
(
extPuchasePlanAttributeVO
,
extPuchasePlanExcelVO
));
}
else
if
(
Constants
.
EXCEL_UPDATE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())){
extPuchasePlanAttributeVO
.
setOperator
(
OperatorType
.
MODIFY
);
...
...
@@ -89,4 +91,14 @@ public class PurchasePlanExcelListenner extends AnalysisEventListener<ExtPuchase
return
extPuchasePlanAttributeVO
;
}
/**
* 检查采购计划数据的合法性
* @param extPuchasePlanExcelVO
* @return
*/
public
StringBuffer
checkPurchasePlanExcelData
(
ExtPuchasePlanExcelVO
extPuchasePlanExcelVO
){
return
null
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment