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
113def65
Commit
113def65
authored
Oct 11, 2024
by
wangqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IED计划删除时,删除技术文件和流程任务的功能开发
parent
81604937
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
13 deletions
+94
-13
IEDPlanExcelListenner.java
...m/yonde/dcs/plan/core/listener/IEDPlanExcelListenner.java
+80
-12
ExtIEDPlanServiceImpl.java
...nde/dcs/plan/core/service/impl/ExtIEDPlanServiceImpl.java
+2
-1
WorkFlowUtil.java
.../main/java/com/yonde/dcs/plan/core/util/WorkFlowUtil.java
+12
-0
No files found.
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/listener/IEDPlanExcelListenner.java
View file @
113def65
...
...
@@ -4,13 +4,19 @@ import com.alibaba.excel.context.AnalysisContext;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.excel.util.ListUtils
;
import
com.alibaba.excel.util.StringUtils
;
import
com.yonde.dcs.document.common.entity.vo.DxDocumentVO
;
import
com.yonde.dcs.document.feign.expand.ExtDxDocumentServiceFeign
;
import
com.yonde.dcs.plan.common.constants.Constants
;
import
com.yonde.dcs.plan.common.utils.SearchUtil
;
import
com.yonde.dcs.plan.common.vo.ExtIEDPlanDocLinkVO
;
import
com.yonde.dcs.plan.common.vo.ExtIEDPlanExcelVO
;
import
com.yonde.dcs.plan.common.vo.ExtIEDPlanVO
;
import
com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO
;
import
com.yonde.dcs.plan.core.service.ExtIEDPlanDocLinkService
;
import
com.yonde.dcs.plan.core.service.ExtIEDPlanService
;
import
com.yonde.dcs.plan.core.util.CommonUtils
;
import
com.yonde.dcs.plan.core.util.WorkFlowUtil
;
import
com.yonde.dcs.plan.entity.po.ExtIEDPlanDocLink
;
import
com.yonde.dex.basedata.data.search.SearchItem
;
import
com.yonde.dex.basedata.data.search.SearchItems
;
import
com.yonde.dex.basedata.data.search.SearchQueryCondition
;
...
...
@@ -19,13 +25,18 @@ import com.yonde.dex.basedata.entity.data.OperatorType;
import
com.yonde.dex.basedata.exception.DxBusinessException
;
import
com.yonde.dex.dao.service.util.ApplicationContextUtil
;
import
com.yonde.dex.dao.service.util.DxPageUtils
;
import
com.yonde.dex.wfc.common.vo.DxWfProcessVO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
...
...
@@ -35,7 +46,9 @@ import java.util.List;
public
class
IEDPlanExcelListenner
extends
AnalysisEventListener
<
ExtIEDPlanExcelVO
>
{
private
ExtIEDPlanService
extIEDPlanService
;
private
ExtIEDPlanDocLinkService
extIEDPlanDocLinkService
;
private
ExtDxDocumentServiceFeign
extDxDocumentServiceFeign
;
private
WorkFlowUtil
workFlowUtil
;
/**
* 每隔100条处理下,然后清理list ,方便内存回收
*/
...
...
@@ -71,6 +84,9 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
public
IEDPlanExcelListenner
(
String
projectId
)
{
this
.
extIEDPlanService
=
ApplicationContextUtil
.
getBean
(
ExtIEDPlanService
.
class
);
this
.
extIEDPlanDocLinkService
=
ApplicationContextUtil
.
getBean
(
ExtIEDPlanDocLinkService
.
class
);
this
.
workFlowUtil
=
ApplicationContextUtil
.
getBean
(
WorkFlowUtil
.
class
);
this
.
extDxDocumentServiceFeign
=
ApplicationContextUtil
.
getBean
(
ExtDxDocumentServiceFeign
.
class
);
this
.
projectId
=
projectId
;
}
...
...
@@ -88,6 +104,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
analysisContext
)
{
// 收尾工作,处理剩下的缓存数据。。。
...
...
@@ -110,7 +127,21 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
extIEDPlanService
.
saveRecursion
(
extIEDPlanVOForDB
);
}
else
{
//删除
ExtIEDPlanVO
extIEDPlanVOForDB
=
getIEDPlanByFileNumber
(
extIEDPlanExcelVO
.
getFileNumber
());
extIEDPlanService
.
remove
(
extIEDPlanVOForDB
.
getId
());
if
(
extIEDPlanVOForDB
.
getState
().
equals
(
Constants
.
PLAN_STATE_UNOPENED
)){
//删除计划 --如果是未开启状态,表示还未启动计划;所以没有技术文件及流程,所以不用删除技术文件及流程,只删除计划。
extIEDPlanService
.
remove
(
extIEDPlanVOForDB
.
getId
());
}
else
{
//删除计划
extIEDPlanService
.
remove
(
extIEDPlanVOForDB
.
getId
());
//删除技术文件
DxDocumentVO
dxDocumentVO
=
getDocmentVoByPlanId
(
extIEDPlanVOForDB
.
getId
());
extDxDocumentServiceFeign
.
delete
(
dxDocumentVO
.
getId
());
//删除流程
workFlowUtil
.
stopWf
(
dxDocumentVO
);
}
}
}
...
...
@@ -162,20 +193,34 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
}
//如果是新增,查看一下数据库中是不是已经存在
if
(
Constants
.
EXCEL_ADD
.
equals
(
extIEDPlanExcelVO
.
getOperation
()))
{
//文件编码、文件代号、管理系统编码只要有一个存在就不能新增。
//文件编码、文件代号、管理系统编码只要有一个
为删除
存在就不能新增。
ExtIEDPlanVO
extIEDPlanVO
=
getIEDPlanByFileNumberAndFileCodeAndSystemNumber
(
extIEDPlanExcelVO
.
getFileNumber
(),
extIEDPlanExcelVO
.
getFileCode
(),
extIEDPlanExcelVO
.
getSystemNumber
());
if
(!
ObjectUtils
.
isEmpty
(
extIEDPlanVO
))
{
errorString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,新增IED计划的文件编号、文件代号或者管理信息系统编码已存在,不能重复添加!"
);
errorList
.
add
(
errorString
);
}
}
else
if
(
Constants
.
EXCEL_DELETE
.
equals
(
extIEDPlanExcelVO
.
getOperation
())){
ExtIEDPlanVO
extIEDPlanVO
=
getIEDPlanByFileNumberAndDeleted
(
extIEDPlanExcelVO
.
getFileNumber
());
if
(!
ObjectUtils
.
isEmpty
(
extIEDPlanVO
)
&&
Constants
.
COMPLETE
.
equals
(
extIEDPlanVO
.
getState
())){
// ExtIEDPlanVO extIEDPlanVO = getIEDPlanByFileNumberAndDeleted(extIEDPlanExcelVO.getFileNumber(),true);
// if(!ObjectUtils.isEmpty(extIEDPlanVO)){
// errorString.append("解析到数据第"+excelDataRow+"行,删除IED计划的文件编号:" + extIEDPlanExcelVO.getFileNumber() + "未查到相关数据,删除失败!");
// errorList.add(errorString);
// }
ExtIEDPlanVO
iedPlan
=
getIEDPlanByFileNumberAndDeleted
(
extIEDPlanExcelVO
.
getFileNumber
(),
false
);
//已完成的计划不允许删除
if
(!
ObjectUtils
.
isEmpty
(
iedPlan
)
&&
Constants
.
COMPLETE
.
equals
(
iedPlan
.
getState
())){
errorString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,删除IED计划的文件编号:"
+
extIEDPlanExcelVO
.
getFileNumber
()
+
"已完成的计划不能删除!"
);
errorList
.
add
(
errorString
);
}
//未完成的计划且技术文件不是待审阅状态不允许删除
if
(
Constants
.
UNFINISHED
.
equals
(
iedPlan
.
getState
())
){
DxDocumentVO
dxDocumentVO
=
getDocmentVoByPlanId
(
iedPlan
.
getId
());
if
(!
Constants
.
PENDING_REVIEW
.
equals
(
dxDocumentVO
.
getState
())){
errorString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,删除IED计划的文件编号:"
+
extIEDPlanExcelVO
.
getFileNumber
()
+
"的状态是未完成且审阅状态是"
+
getStateValue
(
dxDocumentVO
.
getState
())+
"不能删除!"
);
errorList
.
add
(
errorString
);
}
}
}
else
{
ExtIEDPlanVO
extIEDPlanVO
=
getIEDPlanByFileNumberAndDeleted
(
extIEDPlanExcelVO
.
getFileNumber
());
ExtIEDPlanVO
extIEDPlanVO
=
getIEDPlanByFileNumberAndDeleted
(
extIEDPlanExcelVO
.
getFileNumber
()
,
true
);
if
(!
ObjectUtils
.
isEmpty
(
extIEDPlanVO
)
&&
1
==
extIEDPlanVO
.
getDeleted
())
{
errorString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,更新IED计划的文件编号:"
+
extIEDPlanExcelVO
.
getFileNumber
()
+
"已被删除,更新或删除失败!"
);
errorList
.
add
(
errorString
);
...
...
@@ -206,7 +251,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
extIEDPlanVO
.
setPhase
(
extIEDPlanExcelVO
.
getPhase
());
if
(!
ObjectUtils
.
isEmpty
(
extIEDPlanExcelVO
.
getAuditTime
())){
try
{
LocalDateTime
auditTime
=
LocalDateTime
.
parse
(
extIEDPlanExcelVO
.
getAuditTime
()
);
LocalDateTime
auditTime
=
LocalDateTime
.
of
(
LocalDate
.
parse
(
extIEDPlanExcelVO
.
getAuditTime
(),
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
)),
LocalTime
.
MIDNIGHT
);
extIEDPlanVO
.
setAuditTime
(
auditTime
);
}
catch
(
Exception
e
){
throw
new
DxBusinessException
(
"-1"
,
"审核时间格式不正确!"
);
...
...
@@ -215,7 +260,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
}
if
(!
ObjectUtils
.
isEmpty
(
extIEDPlanExcelVO
.
getFileSubmitTime
())){
try
{
LocalDateTime
submitTime
=
LocalDateTime
.
parse
(
extIEDPlanExcelVO
.
getFileSubmitTime
()
);
LocalDateTime
submitTime
=
LocalDateTime
.
of
(
LocalDate
.
parse
(
extIEDPlanExcelVO
.
getFileSubmitTime
(),
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
)),
LocalTime
.
MIDNIGHT
);
extIEDPlanVO
.
setFileSubmitTime
(
submitTime
);
}
catch
(
Exception
e
){
throw
new
DxBusinessException
(
"-1"
,
"文件提交时间格式不正确!"
);
...
...
@@ -273,8 +318,12 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
.
item
(
new
SearchItem
(
"fileCode"
,
SearchItem
.
Operator
.
EQ
,
fileCode
,
(
Object
)
null
))
.
item
(
new
SearchItem
(
"systemNumber"
,
SearchItem
.
Operator
.
EQ
,
systemNumber
,
(
Object
)
null
))
.
operator
(
SearchItems
.
BooleanOperator
.
OR
).
build
())
.
item
(
new
SearchItem
(
"dxContextId"
,
SearchItem
.
Operator
.
EQ
,
projectId
,
(
Object
)
null
)).
operator
(
SearchItems
.
BooleanOperator
.
AND
).
build
()
).
build
();
.
item
(
new
SearchItem
(
"dxContextId"
,
SearchItem
.
Operator
.
EQ
,
projectId
,
(
Object
)
null
))
.
item
(
new
SearchItem
(
"deleted"
,
SearchItem
.
Operator
.
EQ
,
false
,
(
Object
)
null
))
.
operator
(
SearchItems
.
BooleanOperator
.
AND
)
.
build
()
).
build
();
//根据文件编号查询IED计划
// DxPageImpl<ExtIEDPlanVO> IEDPlanPage = extIEDPlanService.findRecursion(SearchUtil.buildQuery("fileNumber", SearchItem.Operator.EQ, fileNumber));
...
...
@@ -293,12 +342,12 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
* @param fileNumber
* @return
*/
private
ExtIEDPlanVO
getIEDPlanByFileNumberAndDeleted
(
String
fileNumber
)
{
private
ExtIEDPlanVO
getIEDPlanByFileNumberAndDeleted
(
String
fileNumber
,
Boolean
deleted
)
{
SearchQueryCondition
condition
=
SearchQueryCondition
.
builder
()
.
searchItems
(
SearchItems
.
builder
()
.
item
(
new
SearchItem
(
"fileNumber"
,
SearchItem
.
Operator
.
EQ
,
fileNumber
,
null
))
.
item
(
new
SearchItem
(
"deleted"
,
SearchItem
.
Operator
.
EQ
,
1
,
null
))
.
item
(
new
SearchItem
(
"deleted"
,
SearchItem
.
Operator
.
EQ
,
deleted
,
null
))
.
build
())
.
build
();
...
...
@@ -312,5 +361,24 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
}
return
null
;
}
public
DxDocumentVO
getDocmentVoByPlanId
(
Long
planId
){
DxPageImpl
iedDocLinkPage
=
extIEDPlanDocLinkService
.
findRecursion
(
SearchUtil
.
buildQuery
(
"sourceId"
,
SearchItem
.
Operator
.
EQ
,
planId
));
if
(!
ObjectUtils
.
isEmpty
(
iedDocLinkPage
.
getContent
())){
ExtIEDPlanDocLinkVO
extIEDPlanDocLink
=
(
ExtIEDPlanDocLinkVO
)
iedDocLinkPage
.
getContent
().
get
(
0
);
DxPageImpl
docPage
=
extDxDocumentServiceFeign
.
findRecursion
(
SearchUtil
.
buildQuery
(
"id"
,
SearchItem
.
Operator
.
EQ
,
extIEDPlanDocLink
.
getTargetId
()));
return
(
DxDocumentVO
)
docPage
.
getContent
().
get
(
0
);
}
return
null
;
}
/**
* 状态英文转中文
* @param state
* @return
*/
public
String
getStateValue
(
String
state
){
return
CommonUtils
.
searchDictDataValueByDictCode
(
Constants
.
OBJ_STATUS
,
state
);
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/impl/ExtIEDPlanServiceImpl.java
View file @
113def65
...
...
@@ -192,7 +192,8 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan
//文件编号
dxDocumentVO
.
setNumber
(
extIEDPlanVO
.
getFileNumber
());
//文件名称
dxDocumentVO
.
setName
(
extIEDPlanVO
.
getFileName
());
Map
<
String
,
Object
>
dynamicAttrs
=
new
HashMap
<>();
//文件代号
dynamicAttrs
.
put
(
"fileNumber"
,
extIEDPlanVO
.
getFileCode
());
...
...
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/util/WorkFlowUtil.java
View file @
113def65
...
...
@@ -271,5 +271,17 @@ public class WorkFlowUtil {
return
processInfoVO
;
}
public
boolean
stopWf
(
DxDocumentVO
doc
){
DxWfProcessSearchVO
dxWfProcessSearchVO
=
new
DxWfProcessSearchVO
();
dxWfProcessSearchVO
.
setPboClass
(
DxDocumentVO
.
class
.
getName
());
dxWfProcessSearchVO
.
setPboId
(
doc
.
getVersionId
());
Page
<
DxWfProcessVO
>
processList
=
wfcProcessFeign
.
getProcessList
(
dxWfProcessSearchVO
,
1
,
10
);
if
(!
CollectionUtils
.
isEmpty
(
processList
.
getContent
()))
{
wfcProcessFeign
.
stopProcess
(
processList
.
getContent
().
get
(
0
).
getId
());
return
true
;
}
return
false
;
}
}
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