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
Expand all
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
This diff is collapsed.
Click to expand it.
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