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
89ee59f8
Commit
89ee59f8
authored
Oct 15, 2024
by
wangqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
采购计划导入数据校验
parent
0ca59bd0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
26 deletions
+97
-26
ExtPuchasePlanExcelVO.java
...a/com/yonde/dcs/plan/common/vo/ExtPuchasePlanExcelVO.java
+15
-13
IEDPlanExcelListenner.java
...m/yonde/dcs/plan/core/listener/IEDPlanExcelListenner.java
+1
-1
PurchasePlanExcelReadListenner.java
...cs/plan/core/listener/PurchasePlanExcelReadListenner.java
+80
-12
ExtIEDPlanServiceImpl.java
...nde/dcs/plan/core/service/impl/ExtIEDPlanServiceImpl.java
+1
-0
No files found.
dcs-plan-common/src/main/java/com/yonde/dcs/plan/common/vo/ExtPuchasePlanExcelVO.java
View file @
89ee59f8
...
...
@@ -28,17 +28,25 @@ public class ExtPuchasePlanExcelVO {
@ExcelProperty
(
value
=
{
"采购计划"
,
"操作*"
},
index
=
0
)
@ColumnWidth
(
20
)
private
String
operation
;
/**
* 计划编码
*/
@ExcelProperty
(
value
=
{
"采购计划"
,
"计划编号*"
},
index
=
1
)
@ColumnWidth
(
20
)
private
String
planCode
;
/**
* 外协项目名称
*/
@ExcelProperty
(
value
=
{
"采购计划"
,
"外协(外购)项目名称*"
},
index
=
1
)
@ExcelProperty
(
value
=
{
"采购计划"
,
"外协(外购)项目名称*"
},
index
=
2
)
@ColumnWidth
(
20
)
private
String
outsourceProjectName
;
/**
* 采购技术文件实际提交时间
*/
@ExcelProperty
(
value
=
{
"采购计划"
,
"采购技术文件提交时间*"
},
index
=
2
)
@ExcelProperty
(
value
=
{
"采购计划"
,
"采购技术文件提交时间*"
},
index
=
3
)
@ColumnWidth
(
20
)
private
LocalDateTime
purDesignFileSubmitTime
;
...
...
@@ -46,7 +54,7 @@ public class ExtPuchasePlanExcelVO {
/**
* 合同签订时间*
*/
@ExcelProperty
(
value
=
{
"采购计划"
,
"合同签订时间*"
},
index
=
3
)
@ExcelProperty
(
value
=
{
"采购计划"
,
"合同签订时间*"
},
index
=
4
)
@ColumnWidth
(
20
)
private
LocalDateTime
contractActualSigningTime
;
...
...
@@ -54,14 +62,14 @@ public class ExtPuchasePlanExcelVO {
/**
* 合同交付时间*
*/
@ExcelProperty
(
value
=
{
"采购计划"
,
"合同交付时间*"
},
index
=
4
)
@ExcelProperty
(
value
=
{
"采购计划"
,
"合同交付时间*"
},
index
=
5
)
@ColumnWidth
(
20
)
private
LocalDateTime
contractActualDeliveryTime
;
/**
* 采购技术文件负责人
*/
@ExcelProperty
(
value
=
{
"采购计划"
,
"采购技术文件负责人*"
},
index
=
5
)
@ExcelProperty
(
value
=
{
"采购计划"
,
"采购技术文件负责人*"
},
index
=
6
)
@ColumnWidth
(
20
)
private
String
purDesignFileManager
;
...
...
@@ -69,7 +77,7 @@ public class ExtPuchasePlanExcelVO {
/**
* 采购预算
*/
@ExcelProperty
(
value
=
{
"采购计划"
,
"预算(万元)*"
},
index
=
6
)
@ExcelProperty
(
value
=
{
"采购计划"
,
"预算(万元)*"
},
index
=
7
)
@ColumnWidth
(
20
)
private
String
purchaseBudget
;
...
...
@@ -84,16 +92,10 @@ public class ExtPuchasePlanExcelVO {
/**
* 密级
*/
@ExcelProperty
(
value
=
{
"采购计划"
,
"密级*"
},
index
=
7
)
@ExcelProperty
(
value
=
{
"采购计划"
,
"密级*"
},
index
=
8
)
@ColumnWidth
(
20
)
private
String
secretCode
;
/**
* 计划编码
*/
@ExcelProperty
(
value
=
{
"采购计划"
,
"计划编号*"
},
index
=
8
)
@ColumnWidth
(
20
)
private
String
planCode
;
/**
...
...
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/listener/IEDPlanExcelListenner.java
View file @
89ee59f8
...
...
@@ -290,7 +290,7 @@ public class IEDPlanExcelListenner extends AnalysisEventListener<ExtIEDPlanExcel
}
extIEDPlanVO
.
setEditor
(
extIEDPlanExcelVO
.
getEditor
());
Map
<
String
,
Object
>
dynamicAttrs
=
new
HashMap
<>();
dynamicAttrs
.
put
(
"editorName"
,
userUtils
.
getUserById
(
Long
.
valueOf
(
extIEDPlanExcelVO
.
getEditor
())
));
dynamicAttrs
.
put
(
"editorName"
,
userUtils
.
getUserById
(
Long
.
valueOf
(
extIEDPlanExcelVO
.
getEditor
())).
getName
(
));
extIEDPlanVO
.
setDynamicAttrs
(
dynamicAttrs
);
extIEDPlanVO
.
setChecker
(
extIEDPlanExcelVO
.
getChecker
());
extIEDPlanVO
.
setAuditor
(
extIEDPlanExcelVO
.
getAuditor
());
...
...
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/listener/PurchasePlanExcelReadListenner.java
View file @
89ee59f8
...
...
@@ -10,6 +10,7 @@ import com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO;
import
com.yonde.dcs.plan.common.vo.ExtPuchasePlanExcelVO
;
import
com.yonde.dcs.plan.core.service.ExtPuchasePlanAttributeService
;
import
com.yonde.dcs.plan.core.util.CommonUtils
;
import
com.yonde.dcs.plan.core.util.UserUtils
;
import
com.yonde.dcs.plan.entity.po.ExtPuchasePlanAttribute
;
import
com.yonde.dex.basedata.data.search.SearchItem
;
import
com.yonde.dex.basedata.data.search.SearchItems
;
...
...
@@ -19,6 +20,7 @@ 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.user.common.vo.DxUserInfoVO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -28,6 +30,7 @@ import org.springframework.util.ObjectUtils;
import
javax.servlet.ServletContextListener
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -55,6 +58,14 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
*/
private
Integer
excelDataRow
=
0
;
/**
* 错误信息列表
*/
private
List
<
StringBuffer
>
errorList
=
new
ArrayList
<>();
private
UserUtils
userUtils
;
/**
* 缓存的数据
*/
...
...
@@ -64,13 +75,13 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
public
PurchasePlanExcelReadListenner
(
String
projectId
)
{
this
.
extPuchasePlanAttributeService
=
ApplicationContextUtil
.
getBean
(
ExtPuchasePlanAttributeService
.
class
);
this
.
userUtils
=
ApplicationContextUtil
.
getBean
(
UserUtils
.
class
);
this
.
projectId
=
projectId
;
}
@Override
public
void
invoke
(
ExtPuchasePlanExcelVO
extPuchasePlanExcelVO
,
AnalysisContext
analysisContext
)
{
log
.
info
(
"解析到一条数据:{}"
,
extPuchasePlanExcelVO
);
if
(!
CommonUtils
.
checkAllPropertiesIsEmpty
(
extPuchasePlanExcelVO
)){
cachedDataList
.
add
(
extPuchasePlanExcelVO
);
...
...
@@ -97,12 +108,12 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
extPuchasePlanAttributeVO
.
setOperator
(
OperatorType
.
ADD
);
extPuchasePlanAttributeService
.
saveRecursion
(
extPuchasePlanAttributeVO
);
}
else
if
(
Constants
.
EXCEL_UPDATE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
()))
{
//更新
//根据计划编
码
获取采购计划
//根据计划编
号
获取采购计划
ExtPuchasePlanAttributeVO
purPlanForDB
=
getPurchasePlanByPlanCode
(
extPuchasePlanExcelVO
.
getPlanCode
());
purPlanForDB
.
setOperator
(
OperatorType
.
MODIFY
);
extPuchasePlanAttributeService
.
saveRecursion
(
transformObject
(
purPlanForDB
,
extPuchasePlanExcelVO
));
}
else
if
(
Constants
.
EXCEL_DELETE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
()))
{
//删除;
//根据计划编
码
获取采购计划
//根据计划编
号
获取采购计划
ExtPuchasePlanAttributeVO
purPlanForDB
=
getPurchasePlanByPlanCode
(
extPuchasePlanExcelVO
.
getPlanCode
());
purPlanForDB
.
setOperator
(
OperatorType
.
REMOVE
);
extPuchasePlanAttributeService
.
remove
(
purPlanForDB
.
getId
());
...
...
@@ -112,7 +123,7 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
}
//清理list ,方便内存回收
cachedDataList
.
clear
();
errorList
.
clear
();
}
/**
...
...
@@ -141,6 +152,9 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
extPuchasePlanAttributeVO
.
setPurchaseBudget
(
extPuchasePlanExcelVO
.
getPurchaseBudget
());
//获取密级code
String
secretCode
=
CommonUtils
.
searchDictDataByDictCode
(
Constants
.
SECRET_CODE
,
extPuchasePlanExcelVO
.
getSecretCode
());
Map
<
String
,
Object
>
dynamicAttrs
=
new
HashMap
<>();
dynamicAttrs
.
put
(
"userName"
,
userUtils
.
getUserById
(
Long
.
valueOf
(
extPuchasePlanExcelVO
.
getPurDesignFileManager
())).
getName
());
extPuchasePlanAttributeVO
.
setDynamicAttrs
(
dynamicAttrs
);
extPuchasePlanAttributeVO
.
setSecretCode
(
secretCode
);
extPuchasePlanAttributeVO
.
setPlanCode
(
extPuchasePlanExcelVO
.
getPlanCode
());
extPuchasePlanAttributeVO
.
setNote
(
extPuchasePlanExcelVO
.
getNote
());
...
...
@@ -155,22 +169,24 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
* @return
*/
public
List
<
StringBuffer
>
checkPurchasePlanExcelData
()
{
List
<
StringBuffer
>
errorList
=
new
ArrayList
<>();
if
(
cachedDataList
.
size
()
>
0
)
{
for
(
ExtPuchasePlanExcelVO
extPuchasePlanExcelVO
:
cachedDataList
)
{
StringBuffer
errString
=
new
StringBuffer
();
if
(!
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getOperation
())){
//校验excel必填字段是否有效
verifyExcelRequiredFields
(
extPuchasePlanExcelVO
,
errString
);
if
(!
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getOperation
())
&&
!
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getPlanCode
())){
if
(
Constants
.
EXCEL_ADD
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())
&&
StringUtils
.
isNotEmpty
(
extPuchasePlanExcelVO
.
getPlanCode
())){
ExtPuchasePlanAttributeVO
extPuchasePlanAttributeVO
=
getPurchasePlanByPlanCode
(
extPuchasePlanExcelVO
.
getPlanCode
());
if
(!
ObjectUtils
.
isEmpty
(
extPuchasePlanAttributeVO
)){
errString
.
append
(
"新增计划编
码
:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"已存在,不能重复导入!!"
);
errString
.
append
(
"新增计划编
号
:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"已存在,不能重复导入!!"
);
errorList
.
add
(
errString
);
}
}
else
if
(
Constants
.
EXCEL_UPDATE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())
&&
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getPlanCode
())){
errString
.
append
(
"更新计划编
码:项目代号为"
+
extPuchasePlanExcelVO
.
getProjectCode
()
+
"的计划编码
不能为空"
);
errString
.
append
(
"更新计划编
号:项目代号为"
+
extPuchasePlanExcelVO
.
getProjectCode
()
+
"的计划编号
不能为空"
);
errorList
.
add
(
errString
);
}
else
if
(
Constants
.
EXCEL_DELETE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())
&&
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getPlanCode
())){
errString
.
append
(
"删除计划编
码:项目代号为"
+
extPuchasePlanExcelVO
.
getProjectCode
()
+
"的计划编码
不能为空"
);
errString
.
append
(
"删除计划编
号:项目代号为"
+
extPuchasePlanExcelVO
.
getProjectCode
()
+
"的计划编号
不能为空"
);
errorList
.
add
(
errString
);
}
else
{
log
.
info
(
"无法识别该操作符:"
+
extPuchasePlanExcelVO
.
getOperation
());
...
...
@@ -187,7 +203,59 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
}
/**
* 根据计划编码查询计划
* //校验excel必填字段是否有效
* @param extPuchasePlanExcelVO
* @param errString
*/
private
void
verifyExcelRequiredFields
(
ExtPuchasePlanExcelVO
extPuchasePlanExcelVO
,
StringBuffer
errString
)
{
//外协项目不能为空
if
(
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getOutsourceProjectName
())){
errString
.
append
(
"计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的外协(外购)项目名称不能为空"
);
errorList
.
add
(
errString
);
return
;
}
//采购技术提交时间不能为空
if
(
ObjectUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getPurDesignFileSubmitTime
())){
errString
.
append
(
"计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的采购文件提交时间不能为空"
);
errorList
.
add
(
errString
);
return
;
}
//合同签订时间不能为空
if
(
ObjectUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getContractActualSigningTime
())){
errString
.
append
(
"计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的合同签订时间不能为空"
);
errorList
.
add
(
errString
);
return
;
}
//合同交付时间不能为空
if
(
ObjectUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getContractActualDeliveryTime
())){
errString
.
append
(
"计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的合同交付时间不能为空"
);
errorList
.
add
(
errString
);
return
;
}
//采购技术负责人
if
(
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getPurDesignFileManager
())){
errString
.
append
(
"计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的采购技术文件负责人不能为空"
);
errorList
.
add
(
errString
);
return
;
}
else
{
DxUserInfoVO
dxUserInfoVO
=
userUtils
.
getUserByName
(
extPuchasePlanExcelVO
.
getPurDesignFileManager
());
if
(
ObjectUtils
.
isEmpty
(
dxUserInfoVO
)){
errString
.
append
(
"计划文件编号为:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的采购技术负责人在系统中未查到!!"
);
errorList
.
add
(
errString
);
return
;
}
else
{
extPuchasePlanExcelVO
.
setPurDesignFileManager
(
String
.
valueOf
(
dxUserInfoVO
.
getId
()));
}
}
if
(
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getSecretCode
())){
errString
.
append
(
"计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的密级不能为空"
);
errorList
.
add
(
errString
);
return
;
}
}
/**
* 根据计划编号查询计划
* @param planCode
* @return
*/
...
...
@@ -200,14 +268,14 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
purchasePlanSearch
.
addItem
(
projectIdFilter
);
SearchQueryCondition
searchQuery
=
SearchQueryCondition
.
builder
().
searchItems
(
purchasePlanSearch
).
build
();
//根据计划编
码
获取数据库中采购计划数据
//根据计划编
号
获取数据库中采购计划数据
//DxPageImpl<ExtPuchasePlanAttributeVO> dxPuchasePlanPage = extPuchasePlanAttributeService.findRecursion(SearchUtil.buildQuery("planCode", SearchItem.Operator.EQ, planCode));
DxPageImpl
<
ExtPuchasePlanAttributeVO
>
dxPuchasePlanPage
=
extPuchasePlanAttributeService
.
findRecursion
(
searchQuery
);
if
(!
CollectionUtils
.
isEmpty
(
dxPuchasePlanPage
.
getContent
()))
{
ExtPuchasePlanAttributeVO
extPurPlanForDB
=
DxPageUtils
.
getFirst
(
dxPuchasePlanPage
);
return
extPurPlanForDB
;
}
else
{
log
.
info
(
"根据计划编
码
:{},未查到相关计划"
,
planCode
);
log
.
info
(
"根据计划编
号
:{},未查到相关计划"
,
planCode
);
}
return
null
;
}
...
...
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/impl/ExtIEDPlanServiceImpl.java
View file @
89ee59f8
...
...
@@ -208,6 +208,7 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan
dxDocumentVO
.
setDynamicAttrs
(
dynamicAttrs
);
//创建时间
dxDocumentVO
.
setCreateTime
(
LocalDateTime
.
now
());
//todo wq 设备号和项目代号需要产品解决,暂时注释
//文档扩展类的设备号
dxDocumentExpand
.
setOwnedEquipment
(
extIEDPlanVO
.
getDeviceNumber
());
//文档扩展类的项目代号
...
...
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