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
0d23dee0
Commit
0d23dee0
authored
Oct 16, 2024
by
wangqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
采购计划导入数据校验功能开发;导入计划数据的密级不能大于项目密级bug修复
parent
ea954424
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
369 additions
and
14 deletions
+369
-14
ExtPuchasePlanAttributeController.java
...an/core/controller/ExtPuchasePlanAttributeController.java
+18
-0
PurchasePlanExcelDataVerifyListenner.java
...n/core/listener/PurchasePlanExcelDataVerifyListenner.java
+258
-0
PurchasePlanExcelReadListenner.java
...cs/plan/core/listener/PurchasePlanExcelReadListenner.java
+24
-14
ExtPuchasePlanAttributeService.java
...dcs/plan/core/service/ExtPuchasePlanAttributeService.java
+2
-0
ExtPuchasePlanAttributeServiceImpl.java
...core/service/impl/ExtPuchasePlanAttributeServiceImpl.java
+31
-0
CommonUtils.java
...c/main/java/com/yonde/dcs/plan/core/util/CommonUtils.java
+31
-0
pom.xml
dcs-plan-feign/pom.xml
+5
-0
No files found.
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/controller/ExtPuchasePlanAttributeController.java
View file @
0d23dee0
...
...
@@ -68,6 +68,24 @@ public class ExtPuchasePlanAttributeController<V extends ExtPuchasePlanAttribute
public
ApiResult
autoImportPurchasePlan
(
@RequestParam
(
"id"
)
long
id
){
return
ApiResult
.
ok
(
extPuchasePlanAttributeService
.
autoImportPurchasePlan
(
id
),
"采购计划自动导入成功"
);
}
/**
* 导入采购计划
*
* @param fileId
* @param projectId
* @param projectSecret
* @return
* @throws IOException
*/
@ApiOperation
(
"校验上传的excel中的采购计划列表是否合法"
)
@PostMapping
(
value
=
"/verifyExcelDataIsValid"
)
public
ApiResult
verifyExcelDataIsValid
(
@RequestParam
(
value
=
"fileId"
,
required
=
true
)
Long
fileId
,
@RequestParam
(
value
=
"projectId"
,
required
=
true
)
String
projectId
,
@RequestParam
(
value
=
"projectSecret"
,
required
=
true
)
String
projectSecret
)
throws
IOException
{
return
ApiResult
.
ok
(
extPuchasePlanAttributeService
.
verifyExcelDataIsValid
(
fileId
,
projectId
,
projectSecret
),
"校验成功!"
);
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/listener/PurchasePlanExcelDataVerifyListenner.java
0 → 100644
View file @
0d23dee0
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.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.dex.basedata.data.search.SearchItem
;
import
com.yonde.dex.basedata.data.search.SearchItems
;
import
com.yonde.dex.basedata.data.search.SearchQueryCondition
;
import
com.yonde.dex.basedata.entity.data.DxPageImpl
;
import
com.yonde.dex.basedata.entity.data.OperatorType
;
import
com.yonde.dex.basedata.exception.DxBusinessException
;
import
com.yonde.dex.basic.feign.expand.ExtDxContextProjectServiceFeign
;
import
com.yonde.dex.context.common.vo.DxContextProjectVO
;
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.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
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
;
@Component
@Slf4j
public
class
PurchasePlanExcelDataVerifyListenner
extends
AnalysisEventListener
<
ExtPuchasePlanExcelVO
>
implements
ServletContextListener
{
private
ExtPuchasePlanAttributeService
extPuchasePlanAttributeService
;
/**
* 每隔100条处理下,然后清理list ,方便内存回收
*/
private
static
final
int
BATCH_COUNT
=
100
;
private
String
projectId
;
private
String
projectSecret
;
/**
* 密级列别
*/
private
Map
<
Integer
,
String
>
securityList
=
new
ConcurrentHashMap
();
/**
* excel数据行数
*/
private
Integer
excelDataRow
=
0
;
/**
* 错误信息列表
*/
private
List
<
StringBuffer
>
errorList
=
new
ArrayList
<>();
private
UserUtils
userUtils
;
/**
* 缓存的数据
*/
private
List
<
ExtPuchasePlanExcelVO
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
public
PurchasePlanExcelDataVerifyListenner
()
{}
public
PurchasePlanExcelDataVerifyListenner
(
String
projectId
,
String
projectSecret
)
{
this
.
extPuchasePlanAttributeService
=
ApplicationContextUtil
.
getBean
(
ExtPuchasePlanAttributeService
.
class
);
this
.
userUtils
=
ApplicationContextUtil
.
getBean
(
UserUtils
.
class
);
this
.
projectId
=
projectId
;
this
.
projectSecret
=
projectSecret
;
}
@Override
public
void
invoke
(
ExtPuchasePlanExcelVO
extPuchasePlanExcelVO
,
AnalysisContext
analysisContext
)
{
log
.
info
(
"解析到一条数据:{}"
,
extPuchasePlanExcelVO
);
if
(!
CommonUtils
.
checkAllPropertiesIsEmpty
(
extPuchasePlanExcelVO
)){
excelDataRow
++;
cachedDataList
.
add
(
extPuchasePlanExcelVO
);
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
analysisContext
)
{
// 收尾工作,处理剩下的缓存数据。。。
log
.
info
(
"sheet={} 所有数据解析完成!"
,
analysisContext
.
readSheetHolder
().
getSheetName
());
//校验表格中的数据是否合法
List
<
StringBuffer
>
errList
=
checkPurchasePlanExcelData
();
if
(
errList
.
size
()
>
0
)
{
throw
new
DxBusinessException
(
"-1"
,
"导入采购计划数据有误!!"
+
errList
.
toString
());
}
//清理list ,方便内存回收
cachedDataList
.
clear
();
errorList
.
clear
();
excelDataRow
=
0
;
}
/**
* @param exception
* @param context
* @throws Exception
*/
@Override
public
void
onException
(
Exception
exception
,
AnalysisContext
context
)
throws
Exception
{
log
.
error
(
"======>>>解析异常:"
,
exception
);
throw
exception
;
}
/**
* 检查采购计划数据的合法性
*
* @return
*/
public
List
<
StringBuffer
>
checkPurchasePlanExcelData
()
{
if
(
cachedDataList
.
size
()
>
0
)
{
for
(
ExtPuchasePlanExcelVO
extPuchasePlanExcelVO
:
cachedDataList
)
{
StringBuffer
errString
=
new
StringBuffer
();
//校验excel必填字段是否有效
verifyExcelRequiredFields
(
extPuchasePlanExcelVO
,
errString
);
//校验新增,更新,删除的逻辑
if
(!
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getOperation
())
&&
!
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getPlanCode
())){
ExtPuchasePlanAttributeVO
extPuchasePlanAttributeVO
=
getPurchasePlanByPlanCode
(
extPuchasePlanExcelVO
.
getPlanCode
(),
false
);
if
(
Constants
.
EXCEL_ADD
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())){
if
(!
ObjectUtils
.
isEmpty
(
extPuchasePlanAttributeVO
)){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,新增计划编号:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"已存在,不能重复导入,新增失败!!"
);
errorList
.
add
(
errString
);
}
}
else
if
(
Constants
.
EXCEL_UPDATE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())){
if
(
ObjectUtils
.
isEmpty
(
extPuchasePlanAttributeVO
)){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()+
"在数据库不存在,更新失败!!"
);
errorList
.
add
(
errString
);
}
}
else
if
(
Constants
.
EXCEL_DELETE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())){
if
(
ObjectUtils
.
isEmpty
(
extPuchasePlanAttributeVO
)){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()+
"在数据库不存在,删除失败!!"
);
errorList
.
add
(
errString
);
}
}
else
{
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
",行无法识别该操作符:"
+
extPuchasePlanExcelVO
.
getOperation
());
errorList
.
add
(
errString
);
}
}
else
{
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,的操作符或计划编码不能为空!"
);
errorList
.
add
(
errString
);
}
}
}
return
errorList
;
}
/**
* //校验excel必填字段是否有效
* @param extPuchasePlanExcelVO
* @param errString
*/
private
void
verifyExcelRequiredFields
(
ExtPuchasePlanExcelVO
extPuchasePlanExcelVO
,
StringBuffer
errString
)
{
//外协项目不能为空
if
(
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getOutsourceProjectName
())){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的外协(外购)项目名称不能为空"
);
errorList
.
add
(
errString
);
return
;
}
//采购技术提交时间不能为空
if
(
ObjectUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getPurDesignFileSubmitTime
())){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的采购文件提交时间不能为空"
);
errorList
.
add
(
errString
);
return
;
}
//合同签订时间不能为空
if
(
ObjectUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getContractActualSigningTime
())){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的合同签订时间不能为空"
);
errorList
.
add
(
errString
);
return
;
}
//合同交付时间不能为空
if
(
ObjectUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getContractActualDeliveryTime
())){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的合同交付时间不能为空"
);
errorList
.
add
(
errString
);
return
;
}
//采购技术负责人
if
(
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getPurDesignFileManager
())){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的采购技术文件负责人不能为空"
);
errorList
.
add
(
errString
);
return
;
}
else
{
DxUserInfoVO
dxUserInfoVO
=
userUtils
.
getUserByName
(
extPuchasePlanExcelVO
.
getPurDesignFileManager
());
if
(
ObjectUtils
.
isEmpty
(
dxUserInfoVO
)){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,计划文件编号为:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的采购技术负责人在系统中未查到!!"
);
errorList
.
add
(
errString
);
return
;
}
else
{
extPuchasePlanExcelVO
.
setPurDesignFileManager
(
String
.
valueOf
(
dxUserInfoVO
.
getId
()));
}
}
if
(
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getSecretCode
())){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的密级不能为空"
);
errorList
.
add
(
errString
);
return
;
}
else
{
//校验密级,计划密级不能大于项目密级
if
(!
CommonUtils
.
verifySecretLevel
(
projectSecret
,
extPuchasePlanExcelVO
.
getSecretCode
())){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"的密级不能大于项目密级"
);
errorList
.
add
(
errString
);
return
;
}
}
}
/**
* 根据计划编号查询计划
* @param planCode
* @param delete true已删除 false 未删除
* @return
*/
public
ExtPuchasePlanAttributeVO
getPurchasePlanByPlanCode
(
String
planCode
,
Boolean
delete
){
SearchItems
purchasePlanSearch
=
new
SearchItems
();
SearchItem
planCodeFilter
=
new
SearchItem
(
"planCode"
,
SearchItem
.
Operator
.
EQ
,
planCode
,
(
Object
)
null
);
SearchItem
projectIdFilter
=
new
SearchItem
(
"dxContextId"
,
SearchItem
.
Operator
.
EQ
,
projectId
,
(
Object
)
null
);
SearchItem
deleteFilter
=
new
SearchItem
(
"deleted"
,
SearchItem
.
Operator
.
EQ
,
delete
,
(
Object
)
null
);
purchasePlanSearch
.
addItem
(
planCodeFilter
);
purchasePlanSearch
.
addItem
(
projectIdFilter
);
purchasePlanSearch
.
addItem
(
deleteFilter
);
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
);
}
return
null
;
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/listener/PurchasePlanExcelReadListenner.java
View file @
0d23dee0
...
...
@@ -109,12 +109,12 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
extPuchasePlanAttributeService
.
saveRecursion
(
extPuchasePlanAttributeVO
);
}
else
if
(
Constants
.
EXCEL_UPDATE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
()))
{
//更新
//根据计划编号获取采购计划
ExtPuchasePlanAttributeVO
purPlanForDB
=
getPurchasePlanByPlanCode
(
extPuchasePlanExcelVO
.
getPlanCode
());
ExtPuchasePlanAttributeVO
purPlanForDB
=
getPurchasePlanByPlanCode
(
extPuchasePlanExcelVO
.
getPlanCode
()
,
false
);
purPlanForDB
.
setOperator
(
OperatorType
.
MODIFY
);
extPuchasePlanAttributeService
.
saveRecursion
(
transformObject
(
purPlanForDB
,
extPuchasePlanExcelVO
));
}
else
if
(
Constants
.
EXCEL_DELETE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
()))
{
//删除;
//根据计划编号获取采购计划
ExtPuchasePlanAttributeVO
purPlanForDB
=
getPurchasePlanByPlanCode
(
extPuchasePlanExcelVO
.
getPlanCode
());
ExtPuchasePlanAttributeVO
purPlanForDB
=
getPurchasePlanByPlanCode
(
extPuchasePlanExcelVO
.
getPlanCode
()
,
false
);
purPlanForDB
.
setOperator
(
OperatorType
.
REMOVE
);
extPuchasePlanAttributeService
.
remove
(
purPlanForDB
.
getId
());
}
else
{
...
...
@@ -175,24 +175,31 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
StringBuffer
errString
=
new
StringBuffer
();
//校验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
());
ExtPuchasePlanAttributeVO
extPuchasePlanAttributeVO
=
getPurchasePlanByPlanCode
(
extPuchasePlanExcelVO
.
getPlanCode
(),
false
);
if
(
Constants
.
EXCEL_ADD
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())){
if
(!
ObjectUtils
.
isEmpty
(
extPuchasePlanAttributeVO
)){
errString
.
append
(
"
新增计划编号:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"已存在,不能重复导入
!!"
);
errString
.
append
(
"
解析到数据第"
+
excelDataRow
+
"行,新增计划编号:"
+
extPuchasePlanExcelVO
.
getPlanCode
()
+
"已存在,不能重复导入,新增失败
!!"
);
errorList
.
add
(
errString
);
}
}
else
if
(
Constants
.
EXCEL_UPDATE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())
&&
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getPlanCode
())){
errString
.
append
(
"更新计划编号:项目代号为"
+
extPuchasePlanExcelVO
.
getProjectCode
()
+
"的计划编号不能为空"
);
}
else
if
(
Constants
.
EXCEL_UPDATE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())){
if
(
ObjectUtils
.
isEmpty
(
extPuchasePlanAttributeVO
)){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()+
"在数据库不存在,更新失败!!"
);
errorList
.
add
(
errString
);
}
else
if
(
Constants
.
EXCEL_DELETE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())
&&
StringUtils
.
isEmpty
(
extPuchasePlanExcelVO
.
getPlanCode
())){
errString
.
append
(
"删除计划编号:项目代号为"
+
extPuchasePlanExcelVO
.
getProjectCode
()
+
"的计划编号不能为空"
);
}
}
else
if
(
Constants
.
EXCEL_DELETE
.
equals
(
extPuchasePlanExcelVO
.
getOperation
())){
if
(
ObjectUtils
.
isEmpty
(
extPuchasePlanAttributeVO
)){
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
"行,计划编号是:"
+
extPuchasePlanExcelVO
.
getPlanCode
()+
"在数据库不存在,删除失败!!"
);
errorList
.
add
(
errString
);
}
}
else
{
log
.
info
(
"无法识别该操作符:"
+
extPuchasePlanExcelVO
.
getOperation
());
errString
.
append
(
"解析到数据第"
+
excelDataRow
+
",行无法识别该操作符:"
+
extPuchasePlanExcelVO
.
getOperation
());
errorList
.
add
(
errString
);
}
}
else
{
errString
.
append
(
"
项目代号为"
+
extPuchasePlanExcelVO
.
getProjectCode
()
+
"的操作符
不能为空"
);
errString
.
append
(
"
解析到数据第"
+
excelDataRow
+
"行,的操作符或计划编码
不能为空"
);
errorList
.
add
(
errString
);
}
...
...
@@ -257,15 +264,18 @@ public class PurchasePlanExcelReadListenner extends AnalysisEventListener<ExtPuc
/**
* 根据计划编号查询计划
* @param planCode
* @param deleteFlag true已删除 false未删除
* @return
*/
public
ExtPuchasePlanAttributeVO
getPurchasePlanByPlanCode
(
String
planCode
){
public
ExtPuchasePlanAttributeVO
getPurchasePlanByPlanCode
(
String
planCode
,
boolean
deleteFlag
){
SearchItems
purchasePlanSearch
=
new
SearchItems
();
SearchItem
planCodeFilter
=
new
SearchItem
(
"planCode"
,
SearchItem
.
Operator
.
EQ
,
planCode
,
(
Object
)
null
);
SearchItem
projectIdFilter
=
new
SearchItem
(
"dxContextId"
,
SearchItem
.
Operator
.
EQ
,
projectId
,
(
Object
)
null
);
SearchItem
deleteFilter
=
new
SearchItem
(
"deleted"
,
SearchItem
.
Operator
.
EQ
,
deleteFlag
,
(
Object
)
null
);
purchasePlanSearch
.
addItem
(
planCodeFilter
);
purchasePlanSearch
.
addItem
(
projectIdFilter
);
purchasePlanSearch
.
addItem
(
deleteFilter
);
SearchQueryCondition
searchQuery
=
SearchQueryCondition
.
builder
().
searchItems
(
purchasePlanSearch
).
build
();
//根据计划编号获取数据库中采购计划数据
...
...
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/ExtPuchasePlanAttributeService.java
View file @
0d23dee0
...
...
@@ -24,4 +24,6 @@ public interface ExtPuchasePlanAttributeService<V extends ExtPuchasePlanAttribut
public
String
exportPurchasePlanFile
(
HttpServletResponse
response
,
List
<
String
>
ids
)
throws
IOException
;
public
String
autoImportPurchasePlan
(
long
id
);
public
String
verifyExcelDataIsValid
(
Long
fileId
,
String
projectId
,
String
projectSecret
);
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/impl/ExtPuchasePlanAttributeServiceImpl.java
View file @
0d23dee0
...
...
@@ -7,6 +7,7 @@ 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.vo.ExtPuchasePlanExcelVO
;
import
com.yonde.dcs.plan.core.listener.PurchasePlanExcelDataVerifyListenner
;
import
com.yonde.dcs.plan.core.listener.PurchasePlanExcelReadListenner
;
import
com.yonde.dcs.plan.core.util.CommonUtils
;
import
com.yonde.dcs.plan.core.util.FileUtils
;
...
...
@@ -38,6 +39,7 @@ import org.springframework.web.bind.annotation.*;
import
com.yonde.dcs.plan.core.service.ExtPuchasePlanAttributeService
;
import
com.yonde.dcs.plan.core.repository.ExtPuchasePlanAttributeRepository
;
import
com.yonde.dcs.plan.entity.po.ExtPuchasePlanAttribute
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -162,6 +164,9 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
return
ApiResult
.
SUCCESS
;
}
/**
* 数据转换,将PO转换成EXCEL-VO;
* @param content
...
...
@@ -186,6 +191,32 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
}
return
extPuchasePlanExcelVOList
;
}
/**
* 在采购计划设计文件走流程之前校验一下主内容的excel表格中的数据是否有效
* @param fileId
* @param projectId
* @return
*/
@Override
public
String
verifyExcelDataIsValid
(
Long
fileId
,
String
projectId
,
String
projectSecret
)
{
MultipartFile
multipartFile
=
null
;
InputStream
inputStream
=
null
;
try
{
multipartFile
=
fileManagerFeignService
.
feignDownloadIO
(
fileId
);
inputStream
=
new
ByteArrayInputStream
(
multipartFile
.
getBytes
());
}
catch
(
IOException
e
)
{
throw
new
DxBusinessException
(
"-1"
,
"文件id:"
+
fileId
+
"在系统中未找到!"
);
}
EasyExcel
.
read
(
inputStream
,
ExtPuchasePlanExcelVO
.
class
,
new
PurchasePlanExcelDataVerifyListenner
(
projectId
,
projectSecret
))
.
sheet
()
.
doRead
();
return
ApiResult
.
SUCCESS
;
}
}
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/util/CommonUtils.java
View file @
0d23dee0
package
com
.
yonde
.
dcs
.
plan
.
core
.
util
;
import
com.yonde.dex.basedata.exception.DxBusinessException
;
import
com.yonde.dex.dao.service.util.ApplicationContextUtil
;
import
com.yonde.dex.dict.feign.DictDataFeignService
;
import
com.yonde.dex.dict.service.vo.DictDataVO
;
import
lombok.extern.slf4j.Slf4j
;
import
mssql.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.logging.log4j.util.Strings
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -11,6 +14,7 @@ import org.springframework.util.StringUtils;
import
java.lang.reflect.Field
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -120,4 +124,31 @@ public class CommonUtils {
}
return
dictMap
.
get
(
key
);
}
/**
* 校验密级等级
* @return
*/
public
static
Boolean
verifySecretLevel
(
String
sourceSecret
,
String
targetSecret
){
Map
<
Object
,
Object
>
secretMap
=
new
LinkedHashMap
<>();
secretMap
.
put
(
"公开"
,
1
);
secretMap
.
put
(
"非密"
,
2
);
secretMap
.
put
(
"内部"
,
3
);
secretMap
.
put
(
"秘密"
,
4
);
secretMap
.
put
(
"机密"
,
5
);
Integer
sourceLevel
=
(
Integer
)
secretMap
.
get
(
sourceSecret
);
Integer
targetLevel
=
(
Integer
)
secretMap
.
get
(
targetSecret
);
if
(
ObjectUtils
.
isEmpty
(
sourceLevel
)){
throw
new
DxBusinessException
(
"-1"
,
"原密级不存在,请检查数据!"
);
}
else
if
(
ObjectUtils
.
isEmpty
(
targetLevel
)){
throw
new
DxBusinessException
(
"-1"
,
"目标密级不存在,请检查数据!"
);
}
else
{
if
(
targetLevel
>
sourceLevel
){
return
false
;
}
return
true
;
}
}
}
\ No newline at end of file
dcs-plan-feign/pom.xml
View file @
0d23dee0
...
...
@@ -53,6 +53,11 @@
<artifactId>
inet-doc-expand-feign
</artifactId>
<version>
4.1-20240919-RELEASE
</version>
</dependency>
<dependency>
<groupId>
com.yonde.dex
</groupId>
<artifactId>
dex-basic-service-expand-feign
</artifactId>
<version>
4.1-20240919-RELEASE
</version>
</dependency>
<dependency>
<groupId>
com.yonde.dex
</groupId>
<artifactId>
dex-basic-service-feign
</artifactId>
...
...
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