Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BasicAPI
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
杜科
BasicAPI
Commits
86f0cded
Commit
86f0cded
authored
Jul 11, 2023
by
hanson.yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
可视化逻辑修改
parent
e1ad43e1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
58 deletions
+70
-58
CADController.java
src/com/yonde/cadpro/controller/CADController.java
+20
-9
FtpUtil.java
src/com/yonde/cadpro/util/FtpUtil.java
+6
-5
AssembleTransformUtil.java
...com/yonde/cadpro/visualization/AssembleTransformUtil.java
+3
-2
VisualizationService.java
...nde/cadpro/visualization/facade/VisualizationService.java
+41
-42
No files found.
src/com/yonde/cadpro/controller/CADController.java
View file @
86f0cded
package
com
.
yonde
.
cadpro
.
controller
;
import
com.yonde.cadpro.CADProConstants
;
import
com.yonde.cadpro.bean.DxCADBomVo
;
import
com.yonde.cadpro.service.PartVisService
;
import
com.yonde.cadpro.util.Base64Util
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.yonde.basedata.entity.api.ApiResult
;
import
com.yonde.cadpro.service.PartVisService
;
import
com.yonde.cadpro.util.Base64Util
;
import
javax.servlet.http.HttpServletRequest
;
/**
...
...
@@ -17,13 +18,23 @@ import javax.servlet.http.HttpServletRequest;
* @author
*/
@RestController
@RequestMapping
(
value
=
"/
cad
"
)
@RequestMapping
(
value
=
"/
DxEPMDocument
"
)
public
class
CADController
{
private
static
String
PORT_USER
=
"portUserName"
;
@SuppressWarnings
(
"rawtypes"
)
@RequestMapping
(
value
=
"/expandCADBom"
,
method
=
RequestMethod
.
GET
)
public
ApiResult
expandCADBom
(
@RequestParam
String
oid
,
HttpServletRequest
request
)
throws
Exception
{
String
userName
=
Base64Util
.
decodeForUserName
(
request
);
return
ApiResult
.
ok
(
PartVisService
.
expandCADBom
(
oid
,
userName
));
@RequestMapping
(
value
=
"/expandBOM"
,
method
=
RequestMethod
.
GET
)
public
DxCADBomVo
expandCADBom
(
@RequestParam
String
oid
,
HttpServletRequest
request
)
throws
Exception
{
String
authorization
=
request
.
getHeader
(
CADProConstants
.
AUTHORIZATION
);
String
userName
=
""
;
if
(
StringUtils
.
isNotBlank
(
authorization
))
{
userName
=
Base64Util
.
decodeForUserName
(
request
);
}
String
portUserName
=
request
.
getHeader
(
PORT_USER
);
if
(
StringUtils
.
isNotBlank
(
portUserName
))
{
userName
=
portUserName
;
}
return
PartVisService
.
expandCADBom
(
oid
,
userName
);
}
}
src/com/yonde/cadpro/util/FtpUtil.java
View file @
86f0cded
...
...
@@ -275,18 +275,18 @@ public class FtpUtil {
/**
* 从ftp下载文件到本地
*
* @param file
name 服务器上的文件名
* @param new
filename 本地生成的文件名
* @param file
Name 服务器上的文件名
* @param new
FileName 本地生成的文件名
* @return
* @throws Exception
*/
public
long
downloadFile
(
String
file
name
,
String
newfilename
)
{
public
long
downloadFile
(
String
file
Name
,
String
newFileName
)
throws
IOException
{
long
result
=
0
;
TelnetInputStream
is
=
null
;
FileOutputStream
os
=
null
;
try
{
is
=
ftpClient
.
get
(
file
n
ame
);
File
outfile
=
new
File
(
new
filen
ame
);
is
=
ftpClient
.
get
(
file
N
ame
);
File
outfile
=
new
File
(
new
FileN
ame
);
os
=
new
FileOutputStream
(
outfile
);
byte
[]
bytes
=
new
byte
[
1024
];
int
c
;
...
...
@@ -296,6 +296,7 @@ public class FtpUtil {
}
}
catch
(
IOException
e
){
e
.
printStackTrace
();
throw
new
IOException
(
"ftp download file failed... "
,
e
);
}
finally
{
try
{
if
(
is
!=
null
){
...
...
src/com/yonde/cadpro/visualization/AssembleTransformUtil.java
View file @
86f0cded
...
...
@@ -11,6 +11,7 @@ import wt.util.WTException;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.UUID
;
/**
...
...
@@ -120,7 +121,7 @@ public class AssembleTransformUtil {
StringBuffer
insert
=
new
StringBuffer
(
" insert into AssembleTransformInfo(SNAPSHOTID,ID,PARENTMODEL,CHILDMODEL,TRANSFORM,IDENTIFY) VALUES ("
);
insert
.
append
(
"'"
+
snapshot
.
getId
()
+
"',"
);
insert
.
append
(
"'"
+
System
.
currentTimeMillis
()
+
"',"
);
insert
.
append
(
"'"
+
UUID
.
randomUUID
().
toString
()
+
"',"
);
insert
.
append
(
"'"
+
EPMUtil
.
getOROid
(
rootCAD
)
+
"',"
);
insert
.
append
(
"'"
+
EPMUtil
.
getOROid
(
linkedChildEPM
)
+
"',"
);
insert
.
append
(
"'"
+
EPMUtil
.
getOROid
(
epmMemberLink
)
+
"',"
);
...
...
@@ -138,7 +139,7 @@ public class AssembleTransformUtil {
*/
public
static
AssembleTransformSnapshot
newAssembleTransformSnapshot
(
String
parentId
,
String
snapshotHash
)
throws
WTException
{
System
.
out
.
println
(
">>>newAssembleTransformSnapshot start......"
);
String
id
=
String
.
valueOf
(
System
.
currentTimeMillis
()
);
String
id
=
UUID
.
randomUUID
().
toString
(
);
StringBuffer
insert
=
new
StringBuffer
(
" insert into ASSEMBLETRANSFORMSNAPSHOT(ID,PARENTID,SNAPSHOTHASH) VALUES ("
);
insert
.
append
(
"'"
+
id
+
"',"
);
insert
.
append
(
"'"
+
parentId
+
"',"
);
...
...
src/com/yonde/cadpro/visualization/facade/VisualizationService.java
View file @
86f0cded
package
com
.
yonde
.
cadpro
.
visualization
.
facade
;
import
com.yonde.cadpro.CADProConstants
;
import
com.yonde.cadpro.config.CatiaInteConfigPropertiesUtil
;
import
com.yonde.cadpro.util.*
;
import
com.yonde.cadpro.visualization.AssembleTransformUtil
;
import
com.yonde.cadpro.visualization.catia.ConvertCatia2B3dUtil
;
...
...
@@ -121,31 +122,17 @@ public class VisualizationService {
System
.
out
.
println
(
"uploadFiles : "
+
uploadFiles
);
//2. 上传至FTP目录
FtpUtil
ftpUtil
=
null
;
if
(!
transferModel
)
{
ftpUtil
=
new
FtpUtil
(
officeTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_OFFICE_FTP_HOST
),
Integer
.
valueOf
(
officeTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_OFFICE_FTP_PORT
)),
officeTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_OFFICE_FTP_USERNAME
),
officeTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_OFFICE_FTP_PASSWORD
));
}
else
{
ftpUtil
=
new
FtpUtil
(
catiaTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_CATIA_FTP_HOST
),
FtpUtil
ftpUtil
=
new
FtpUtil
(
catiaTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_CATIA_FTP_HOST
),
Integer
.
valueOf
(
catiaTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_CATIA_FTP_PORT
)),
catiaTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_CATIA_FTP_USERNAME
),
catiaTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_CATIA_FTP_PASSWORD
));
}
if
(!
ftpUtil
.
connectServer
())
{
throw
new
WTException
(
"FTP连接失败,请重试或联系系统管理员。"
);
}
String
ftpRemoteFolder
=
""
;
if
(!
transferModel
)
{
ftpRemoteFolder
=
officeTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_OFFICE_TEMPFOLDERPATH
)
+
uuidStr
+
"/"
;
}
else
{
if
(
transferModel
)
{
ftpRemoteFolder
=
catiaTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_CATIA_TEMPFOLDERPATH
)
+
uuidStr
+
"/"
;
}
...
...
@@ -203,11 +190,24 @@ public class VisualizationService {
}
System
.
out
.
println
(
"transformedFtpPath :"
+
transformedFtpPath
);
System
.
out
.
println
(
"transformedFileName :"
+
transformedFileName
);
//woker机b3d转换完成后将文件通过ftp下载到pdm codebase/tempDownload/时间戳/ 文件夹下
ftpUtil
=
new
FtpUtil
(
VisualizationFacade
.
catiaTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_CATIA_FTP_HOST
),
Integer
.
valueOf
(
VisualizationFacade
.
catiaTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_CATIA_FTP_PORT
)),
VisualizationFacade
.
catiaTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_CATIA_FTP_USERNAME
),
VisualizationFacade
.
catiaTransferConfig
.
getValueByKey
(
CADProConstants
.
CONFIG_KEY_CATIA_FTP_PASSWORD
));
if
(!
ftpUtil
.
connectServer
())
{
throw
new
WTException
(
"FTP连接失败,请重试或联系系统管理员。"
);
}
String
downloadFile
=
ContentUtil
.
getTempPath
()
+
transformedFileName
;
ftpUtil
.
downloadFile
(
transformedFtpPath
+
transformedFileName
,
downloadFile
);
ftpUtil
.
closeServer
();
//4. 上传转可视化之后文件至contentHolder
if
(
StringUtils
.
isNotBlank
(
transformedFtpPath
)
&&
StringUtils
.
isNotBlank
(
transformedFileName
))
{
if
(
transferModel
)
{
String
xmlFile
=
transformedFileRemotePath
;
String
xmlFile
=
downloadFile
;
System
.
out
.
println
(
"xmlFile : "
+
xmlFile
);
//处理下载文件
Map
<
String
,
Set
<
String
>>
numberVisMap
=
new
HashMap
<
String
,
Set
<
String
>>();
...
...
@@ -413,18 +413,13 @@ public class VisualizationService {
Set
<
EPMMemberLink
>
allMembership
=
memberLinkWithTrasform
.
keySet
();
for
(
EPMMemberLink
epmMemberLink
:
allMembership
)
{
Map
<
EPMDocument
,
String
>
epmTrans
=
memberLinkWithTrasform
.
get
(
epmMemberLink
);
Map
<
EPMDocument
,
String
>
epmTrans
=
memberLinkWithTrasform
.
get
(
epmMemberLink
);
if
(
epmTrans
!=
null
)
{
Set
<
Entry
<
EPMDocument
,
String
>>
epmKeyEnters
=
epmTrans
.
entrySet
();
Iterator
<
Entry
<
EPMDocument
,
String
>>
itEntry
=
epmKeyEnters
.
iterator
();
Set
<
Entry
<
EPMDocument
,
String
>>
epmKeyEnters
=
epmTrans
.
entrySet
();
Iterator
<
Entry
<
EPMDocument
,
String
>>
itEntry
=
epmKeyEnters
.
iterator
();
if
(
itEntry
.
hasNext
())
{
Entry
<
EPMDocument
,
String
>
epmKeyEntry
=
itEntry
.
next
();
EPMDocument
linkedChildEPM
=
epmKeyEntry
.
getKey
();
Entry
<
EPMDocument
,
String
>
epmKeyEntry
=
itEntry
.
next
();
EPMDocument
linkedChildEPM
=
epmKeyEntry
.
getKey
();
String
formatTransform
=
epmKeyEntry
.
getValue
();
System
.
out
.
println
(
"process snapshot :"
+
snapshot
+
", epm:"
+
rootCAD
...
...
@@ -495,13 +490,24 @@ public class VisualizationService {
Set
<
String
>
b3dPaths
=
numberVisMap
.
get
(
cadNumber
);
if
(
b3dPaths
!=
null
)
{
for
(
String
b3dPath
:
b3dPaths
)
{
System
.
out
.
println
(
"b3dPath : "
+
b3dPath
);
File
file
=
new
File
(
transformedFileRemotePath
);
String
parent
=
file
.
getParent
()
+
File
.
separator
;
String
parent
=
file
.
getParent
()
+
File
.
separator
;
b3dPath
=
b3dPath
.
replace
(
tempFolderPath
,
parent
);
if
(!
ftpUtil
.
connectServer
())
{
throw
new
WTException
(
"FTP连接失败,请重试或联系系统管理员。"
);
}
System
.
out
.
println
(
"b3dPath2 : "
+
b3dPath
);
File
b3dFile
=
new
File
(
b3dPath
);
if
(!
b3dFile
.
exists
()
||
b3dFile
.
isDirectory
())
{
if
(!
b3dFile
.
getParentFile
().
exists
()){
b3dFile
.
getParentFile
().
mkdirs
();
b3dFile
.
createNewFile
();
}
//将worker机的b3d文件存储到pdm服务器临时目录中
String
replace
=
b3dPath
.
replace
(
new
File
(
CatiaInteConfigPropertiesUtil
.
getFtpRootPath
()).
getPath
(),
""
);
ftpUtil
.
downloadFile
(
replace
,
b3dPath
);
ftpUtil
.
closeServer
();
if
(!
b3dFile
.
exists
()
||
b3dFile
.
isDirectory
()
||
b3dFile
.
length
()<
1
)
{
logger
.
error
(
"b3dPath File ["
+
b3dPath
+
"] is not exist,continue..."
);
continue
;
}
...
...
@@ -512,7 +518,7 @@ public class VisualizationService {
ContentRoleType
.
toContentRoleType
(
"ADDITIONAL_FILES"
));
epm
=
(
EPMDocument
)
PersistenceHelper
.
manager
.
refresh
(
epm
);
b3dFile
.
deleteOnExit
();
//处理PMI 轻量化文件
//String fileName = FilenameUtils.getBaseName(b3dPath);
...
...
@@ -616,13 +622,6 @@ public class VisualizationService {
if
(
element
instanceof
EPMDocument
)
{
child
=
(
EPMDocument
)
element
;
}
else
if
(
element
instanceof
EPMDocumentMaster
)
{
/*
QueryResult versionQr = VersionControlHelper.service
.allVersionsOf((EPMDocumentMaster) element);
if (versionQr != null && versionQr.hasMoreElements()) {
child = (EPMDocument) versionQr.nextElement();
}
*/
child
=
EPMUtil
.
getEPM
(((
EPMDocumentMaster
)
element
).
getNumber
(),
""
,
""
);
}
if
(
child
!=
null
)
{
...
...
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