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
b0fc9ed7
Commit
b0fc9ed7
authored
Oct 16, 2024
by
侯彦文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改文档依赖
parent
813cef9f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
27 deletions
+25
-27
ExtPuchasePlanAttributeServiceImpl.java
...core/service/impl/ExtPuchasePlanAttributeServiceImpl.java
+25
-27
No files found.
dcs-plan-core/src/main/java/com/yonde/dcs/plan/core/service/impl/ExtPuchasePlanAttributeServiceImpl.java
View file @
b0fc9ed7
...
@@ -3,15 +3,19 @@ package com.yonde.dcs.plan.core.service.impl;
...
@@ -3,15 +3,19 @@ package com.yonde.dcs.plan.core.service.impl;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.FileUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy
;
import
com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy
;
import
com.inet.dcs.document.feign.expand.ExtDxDocumentServiceFeign
;
import
com.yonde.dcs.document.common.entity.vo.DxDocumentVO
;
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.constants.Constants
;
import
com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO
;
import
com.yonde.dcs.plan.common.vo.ExtPuchasePlanExcelVO
;
import
com.yonde.dcs.plan.common.vo.ExtPuchasePlanExcelVO
;
import
com.yonde.dcs.plan.core.listener.PurchasePlanExcelDataVerifyListenner
;
import
com.yonde.dcs.plan.core.listener.PurchasePlanExcelDataVerifyListenner
;
import
com.yonde.dcs.plan.core.listener.PurchasePlanExcelReadListenner
;
import
com.yonde.dcs.plan.core.listener.PurchasePlanExcelReadListenner
;
import
com.yonde.dcs.plan.core.repository.ExtPuchasePlanAttributeRepository
;
import
com.yonde.dcs.plan.core.service.ExtPuchasePlanAttributeService
;
import
com.yonde.dcs.plan.core.util.CommonUtils
;
import
com.yonde.dcs.plan.core.util.CommonUtils
;
import
com.yonde.dcs.plan.core.util.FileUtils
;
import
com.yonde.dcs.plan.core.util.FileUtils
;
import
com.yonde.dcs.plan.core.util.ResourceHelper
;
import
com.yonde.dcs.plan.core.util.ResourceHelper
;
import
com.yonde.dcs.plan.entity.po.ExtPuchasePlanAttribute
;
import
com.yonde.dex.basedata.data.search.SearchItem
;
import
com.yonde.dex.basedata.data.search.SearchItem
;
import
com.yonde.dex.basedata.data.search.SearchItems
;
import
com.yonde.dex.basedata.data.search.SearchItems
;
import
com.yonde.dex.basedata.data.search.SearchQueryCondition
;
import
com.yonde.dex.basedata.data.search.SearchQueryCondition
;
...
@@ -22,27 +26,20 @@ import com.yonde.dex.basedata.exception.DxBusinessException;
...
@@ -22,27 +26,20 @@ import com.yonde.dex.basedata.exception.DxBusinessException;
import
com.yonde.dex.dfs.feign.FileManagerFeignService
;
import
com.yonde.dex.dfs.feign.FileManagerFeignService
;
import
com.yonde.dex.dfs.feign.RepoFileFeignService
;
import
com.yonde.dex.dfs.feign.RepoFileFeignService
;
import
com.yonde.dex.systemfile.feign.SystemFileFeignService
;
import
com.yonde.dex.systemfile.feign.SystemFileFeignService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.stereotype.Service
;
import
io.swagger.annotations.ApiOperation
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.yonde.dcs.plan.common.vo.ExtPuchasePlanAttributeVO
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
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
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
/**
* @description: ExtPuchasePlanAttribute-ServiceImpl
* @description: ExtPuchasePlanAttribute-ServiceImpl
...
@@ -70,7 +67,7 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
...
@@ -70,7 +67,7 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
@Override
@Override
public
String
importPurchasePlan
(
InputStream
inputStream
,
String
projectId
)
{
public
String
importPurchasePlan
(
InputStream
inputStream
,
String
projectId
)
{
EasyExcel
.
read
(
inputStream
,
ExtPuchasePlanExcelVO
.
class
,
EasyExcel
.
read
(
inputStream
,
ExtPuchasePlanExcelVO
.
class
,
new
PurchasePlanExcelReadListenner
(
projectId
))
new
PurchasePlanExcelReadListenner
(
projectId
))
.
sheet
()
.
sheet
()
...
@@ -110,7 +107,7 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
...
@@ -110,7 +107,7 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
throw
new
DxBusinessException
(
"500"
,
"文件服务下载的文件转换为输入流失败:"
+
fileId
);
throw
new
DxBusinessException
(
"500"
,
"文件服务下载的文件转换为输入流失败:"
+
fileId
);
}
}
String
dir
=
ResourceHelper
.
CreateTemDir
().
getPath
();
String
dir
=
ResourceHelper
.
CreateTemDir
().
getPath
();
String
filePath
=
dir
+
Constants
.
PURCHASE_PLAN_EXCEL_NAME
;
String
filePath
=
dir
+
Constants
.
PURCHASE_PLAN_EXCEL_NAME
;
//创建采购计划列表.xlsx 文件
//创建采购计划列表.xlsx 文件
FileUtils
.
inputToFile
(
inputStream
,
filePath
);
FileUtils
.
inputToFile
(
inputStream
,
filePath
);
//向表格中写入数据
//向表格中写入数据
...
@@ -131,7 +128,8 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
...
@@ -131,7 +128,8 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
/**
/**
* 计划文件签审通过之后,调用该方法,自动导入计划
* 计划文件签审通过之后,调用该方法,自动导入计划
* @param id 文档id
*
* @param id 文档id
* @return
* @return
*/
*/
@Override
@Override
...
@@ -141,7 +139,7 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
...
@@ -141,7 +139,7 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
CustomMultipartFile
multipartFile
=
null
;
CustomMultipartFile
multipartFile
=
null
;
Long
fileId
=
null
;
Long
fileId
=
null
;
DxDocumentVO
dxDocumentVO
=
docCenterFeignService
.
getDocumentWithFiles
(
id
);
DxDocumentVO
dxDocumentVO
=
docCenterFeignService
.
getDocumentWithFiles
(
id
);
if
(!
ObjectUtils
.
isEmpty
(
dxDocumentVO
))
{
if
(!
ObjectUtils
.
isEmpty
(
dxDocumentVO
))
{
try
{
try
{
//todo 取固定类型附件
//todo 取固定类型附件
fileId
=
dxDocumentVO
.
getObjFileLinks
().
get
(
0
).
getTarget
().
getId
();
fileId
=
dxDocumentVO
.
getObjFileLinks
().
get
(
0
).
getTarget
().
getId
();
...
@@ -152,12 +150,12 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
...
@@ -152,12 +150,12 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
}
}
try
{
try
{
inputStream
=
new
ByteArrayInputStream
(
multipartFile
.
getBytes
());
inputStream
=
new
ByteArrayInputStream
(
multipartFile
.
getBytes
());
importPurchasePlan
(
inputStream
,
dxDocumentVO
.
getDxContextId
().
toString
());
importPurchasePlan
(
inputStream
,
dxDocumentVO
.
getDxContextId
().
toString
());
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
log
.
info
(
"[自动导入采购计划] >>> 文件服务下载的文件:{}--转换为输入流失败!"
,
fileId
);
log
.
info
(
"[自动导入采购计划] >>> 文件服务下载的文件:{}--转换为输入流失败!"
,
fileId
);
throw
new
DxBusinessException
(
"500"
,
"文件服务下载的文件转换为输入流失败:"
+
fileId
);
throw
new
DxBusinessException
(
"500"
,
"文件服务下载的文件转换为输入流失败:"
+
fileId
);
}
}
}
else
{
}
else
{
log
.
info
(
"根据计划文档id:"
+
id
+
"未查到相关数据"
);
log
.
info
(
"根据计划文档id:"
+
id
+
"未查到相关数据"
);
}
}
...
@@ -165,10 +163,9 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
...
@@ -165,10 +163,9 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
}
}
/**
/**
* 数据转换,将PO转换成EXCEL-VO;
* 数据转换,将PO转换成EXCEL-VO;
*
* @param content
* @param content
* @return
* @return
*/
*/
...
@@ -194,13 +191,14 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
...
@@ -194,13 +191,14 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
/**
/**
* 在采购计划设计文件走流程之前校验一下主内容的excel表格中的数据是否有效
* 在采购计划设计文件走流程之前校验一下主内容的excel表格中的数据是否有效
*
* @param fileId
* @param fileId
* @param projectId
* @param projectId
* @return
* @return
*/
*/
@Override
@Override
public
String
verifyExcelDataIsValid
(
Long
fileId
,
String
projectId
,
String
projectSecret
)
{
public
String
verifyExcelDataIsValid
(
Long
fileId
,
String
projectId
,
String
projectSecret
)
{
MultipartFile
multipartFile
=
null
;
MultipartFile
multipartFile
=
null
;
InputStream
inputStream
=
null
;
InputStream
inputStream
=
null
;
...
@@ -208,11 +206,11 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
...
@@ -208,11 +206,11 @@ public class ExtPuchasePlanAttributeServiceImpl<V extends ExtPuchasePlanAttribut
multipartFile
=
fileManagerFeignService
.
feignDownloadIO
(
fileId
);
multipartFile
=
fileManagerFeignService
.
feignDownloadIO
(
fileId
);
inputStream
=
new
ByteArrayInputStream
(
multipartFile
.
getBytes
());
inputStream
=
new
ByteArrayInputStream
(
multipartFile
.
getBytes
());
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
new
DxBusinessException
(
"-1"
,
"文件id:"
+
fileId
+
"在系统中未找到!"
);
throw
new
DxBusinessException
(
"-1"
,
"文件id:"
+
fileId
+
"在系统中未找到!"
);
}
}
EasyExcel
.
read
(
inputStream
,
ExtPuchasePlanExcelVO
.
class
,
EasyExcel
.
read
(
inputStream
,
ExtPuchasePlanExcelVO
.
class
,
new
PurchasePlanExcelDataVerifyListenner
(
projectId
,
projectSecret
))
new
PurchasePlanExcelDataVerifyListenner
(
projectId
,
projectSecret
))
.
sheet
()
.
sheet
()
.
doRead
();
.
doRead
();
return
ApiResult
.
SUCCESS
;
return
ApiResult
.
SUCCESS
;
...
...
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