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
18079263
Commit
18079263
authored
Mar 13, 2023
by
shyWang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PDM前端改造
附件 主内容相关
parent
1bb01cf1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1305 additions
and
28 deletions
+1305
-28
ContentHolderController.java
...om/yonde/basedata/controller/ContentHolderController.java
+123
-0
SearchOperatorEnumUtil.java
src/com/yonde/basedata/search/SearchOperatorEnumUtil.java
+12
-7
BaseSearchService.java
src/com/yonde/basedata/service/BaseSearchService.java
+96
-4
ObjFileLinkVO.java
src/com/yonde/basedata/vo/ObjFileLinkVO.java
+72
-0
RepoFileVO.java
src/com/yonde/basedata/vo/RepoFileVO.java
+139
-0
DocUtil.java
src/com/yonde/common/DocUtil.java
+93
-1
DxCommonUtils.java
src/com/yonde/common/DxCommonUtils.java
+248
-2
DxPartUtil.java
src/com/yonde/common/DxPartUtil.java
+8
-2
DxSearchUtil.java
src/com/yonde/common/DxSearchUtil.java
+5
-2
PartUtil.java
src/com/yonde/common/PartUtil.java
+138
-0
DxDocService.java
src/com/yonde/doc/service/DxDocService.java
+1
-1
DxDocServiceImpl.java
src/com/yonde/doc/service/impl/DxDocServiceImpl.java
+1
-1
DxDocUtil.java
src/com/yonde/doc/util/DxDocUtil.java
+5
-4
DxDocumentVO.java
src/com/yonde/doc/vo/DxDocumentVO.java
+18
-2
DxPartController.java
src/com/yonde/part/controller/DxPartController.java
+11
-0
DxPartService.java
src/com/yonde/part/service/DxPartService.java
+72
-0
DxPartDescribeLinkVO.java
src/com/yonde/part/vo/DxPartDescribeLinkVO.java
+1
-1
DxPartReferenceLinkVO.java
src/com/yonde/part/vo/DxPartReferenceLinkVO.java
+1
-1
DxProcessLinkController.java
src/com/yonde/plan/controller/DxProcessLinkController.java
+41
-0
DxProcessLinkService.java
src/com/yonde/plan/service/DxProcessLinkService.java
+75
-0
DxProcessDocDescribeLinkVO.java
src/com/yonde/plan/vo/DxProcessDocDescribeLinkVO.java
+72
-0
DxProcessDocReferenceLinkVO.java
src/com/yonde/plan/vo/DxProcessDocReferenceLinkVO.java
+73
-0
No files found.
src/com/yonde/basedata/controller/ContentHolderController.java
0 → 100644
View file @
18079263
package
com
.
yonde
.
basedata
.
controller
;
import
com.yonde.basedata.service.BaseSearchService
;
import
com.yonde.basedata.vo.ObjFileLinkVO
;
import
com.yonde.common.DxCommonUtils
;
import
com.yonde.common.ObjectsUtil
;
import
com.yonde.doc.vo.DxDocumentVO
;
import
org.apache.commons.io.IOUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.commons.CommonsMultipartFile
;
import
wt.content.ApplicationData
;
import
wt.content.Streamed
;
import
wt.fc.ObjectReference
;
import
wt.util.WTProperties
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
@RestController
@RequestMapping
({
"/DxContentHolder"
})
public
class
ContentHolderController
{
@PostMapping
({
"/uploads"
})
//@ApiOperation("获取工作副本")
public
void
uploadFiles
(
@RequestParam
ObjFileLinkVO
fileForm
,
@RequestParam
(
"files"
)
MultipartFile
[]
files
)
{
//DxDocumentVO dxDocumentVO = null;
try
{
//dxDocumentVO = DxDocService.checkout(id, "Dex检出");
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
;
}
@PostMapping
({
"/uploadFile"
})
public
DxDocumentVO
uploadFile
(
@RequestParam
ObjFileLinkVO
fileForm
,
@RequestParam
(
"file"
)
MultipartFile
file
)
{
DxDocumentVO
dxDocumentVO
=
null
;
try
{
System
.
out
.
println
(
"fileForm===="
+
fileForm
.
getSourceId
());
System
.
out
.
println
(
"file===="
+
file
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
dxDocumentVO
;
}
/* @GetMapping({"/downLoadIO"})
//@ApiOperation("获取文件流")
public byte[] uploadFile(@RequestParam("appId") String appId) {
byte[] bytes = null;
try {
bytes = DxCommonUtils.getInputStreamById(appId);
System.out.println("====bytes===" + bytes);
} catch (Exception e) {
e.printStackTrace();
}
return bytes;
}*/
@GetMapping
({
"/downLoadIO"
})
//@ApiOperation("获取文件流")
public
void
uploadFile
(
@RequestParam
(
"appId"
)
String
appId
,
HttpServletResponse
response
)
{
//InputStream inputStream = null;
String
fileName
=
"fileName"
;
String
filePath
=
null
;
try
{
filePath
=
DxCommonUtils
.
getFileById
(
appId
,
fileName
);
File
file
=
new
File
(
filePath
);
IOUtils
.
copy
(
new
FileInputStream
(
file
),
response
.
getOutputStream
());
/*BufferedOutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
byte[] buff = new byte[1024];
int n;
while ((n=inputStream.read(buff))!=1) {
outputStream.write(buff, 0, n);
}
outputStream.flush();
outputStream.close();
inputStream.close();
System.out.println("====inputStream===" + inputStream);*/
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
;
}
@RequestMapping
(
value
=
"/upload"
,
consumes
=
"multipart/form-data"
,
method
=
RequestMethod
.
POST
)
public
DxDocumentVO
createRelatedInformation
(
@RequestParam
(
"file"
)
CommonsMultipartFile
file
,
@RequestParam
(
"sourceId"
)
String
sourceId
,
@RequestParam
(
"sourceType"
)
String
sourceType
,
@RequestParam
(
"targetId"
)
String
targetId
,
@RequestParam
(
"contentType"
)
String
contentType
,
@RequestParam
(
"operator"
)
String
operator
)
{
System
.
out
.
println
(
"sourceId===="
+
sourceId
);
System
.
out
.
println
(
"contentType===="
+
contentType
);
System
.
out
.
println
(
"operator===="
+
operator
);
System
.
out
.
println
(
"file===="
+
file
.
isEmpty
());
ObjFileLinkVO
fileForm
=
new
ObjFileLinkVO
();
fileForm
.
setSourceId
(
Long
.
valueOf
(
sourceId
));
fileForm
.
setOperator
(
operator
);
fileForm
.
setContentType
(
contentType
);
fileForm
.
setSourceIdType
(
sourceType
);
fileForm
.
setTargetId
(
targetId
);
try
{
String
importFiledirPath
=
WTProperties
.
getLocalProperties
().
getProperty
(
"wt.content.temp"
)
+
File
.
separator
+
System
.
nanoTime
();
File
importFiledir
=
new
File
(
importFiledirPath
);
importFiledir
.
mkdir
();
System
.
out
.
println
(
">>>>importFileDirPath="
+
importFiledirPath
);
File
importFile
=
new
File
(
importFiledirPath
+
File
.
separator
+
file
.
getOriginalFilename
());
file
.
transferTo
(
importFile
);
System
.
out
.
println
(
">>>>importFile="
+
importFile
);
BaseSearchService
.
uploadFile
(
importFile
,
fileForm
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
src/com/yonde/basedata/search/SearchOperatorEnumUtil.java
View file @
18079263
package
com
.
yonde
.
basedata
.
search
;
import
com.yonde.basedata.entity.users.DxUserVO
;
import
com.yonde.basedata.vo.DxMasterVO
;
import
com.yonde.basedata.vo.DxOrganizationVO
;
import
com.yonde.basedata.vo.DxVersionVO
;
import
com.yonde.basedata.vo.*
;
import
com.yonde.context.vo.DxContextVO
;
import
com.yonde.doc.vo.DxDocumentVO
;
import
com.yonde.part.vo.*
;
import
com.yonde.plan.vo.DxProcessDocDescribeLinkVO
;
import
com.yonde.plan.vo.DxProcessDocReferenceLinkVO
;
import
wt.clients.beans.query.WTAttribute
;
import
wt.doc.WTDocument
;
import
wt.fc.ObjectIdentifier
;
...
...
@@ -48,7 +48,7 @@ public class SearchOperatorEnumUtil {
public
static
final
Map
<
Class
<?>,
String
>
typeItemMap
=
new
HashMap
();
// 类型映射
public
static
final
Map
<
Lo
ng
,
String
>
viewMap
=
new
HashMap
();
// 视图映射
public
static
final
Map
<
Stri
ng
,
String
>
viewMap
=
new
HashMap
();
// 视图映射
public
static
final
Map
<
Class
<?>,
String
>
typePrefixMap
=
new
HashMap
();
// 类型映射
...
...
@@ -62,9 +62,9 @@ public class SearchOperatorEnumUtil {
}
public
static
void
initViewMap
()
{
viewMap
.
put
(
1L
,
"Design"
);
viewMap
.
put
(
2L
,
"Planning"
);
viewMap
.
put
(
3L
,
"Manufacture"
);
viewMap
.
put
(
"1"
,
"Design"
);
viewMap
.
put
(
"2"
,
"Planning"
);
viewMap
.
put
(
"3"
,
"Manufacture"
);
}
public
static
void
initTypePrefixMap
()
{
...
...
@@ -93,6 +93,11 @@ public class SearchOperatorEnumUtil {
typeItemMap
.
put
(
DxPartDescribeLinkVO
.
class
,
"com.yonde.dcs.xbom.common.entity.vo.DxPartDescribeLinkVO"
);
typeItemMap
.
put
(
DxPartReferenceLinkVO
.
class
,
"com.yonde.dcs.xbom.common.entity.vo.DxPartReferenceLinkVO"
);
typeItemMap
.
put
(
DxOrganizationVO
.
class
,
"com.yonde.dex.user.common.vo.DxOrganizationVO"
);
typeItemMap
.
put
(
ObjFileLinkVO
.
class
,
"com.yonde.dex.dfs.vo.ObjFileLinkVO"
);
typeItemMap
.
put
(
RepoFileVO
.
class
,
"com.yonde.dex.dfs.vo.RepoFileVO"
);
typeItemMap
.
put
(
DxProcessDocReferenceLinkVO
.
class
,
"com.yonde.dcs.process.common.entity.vo.DxProcessDocReferenceLinkVO"
);
typeItemMap
.
put
(
DxProcessDocDescribeLinkVO
.
class
,
"com.yonde.dcs.process.common.entity.vo.DxProcessDocDescribeLinkVO"
);
//TODO add
}
...
...
src/com/yonde/basedata/service/BaseSearchService.java
View file @
18079263
...
...
@@ -5,22 +5,30 @@ import com.yonde.basedata.entity.api.ApiResult;
import
com.yonde.basedata.search.SearchOperatorEnumUtil
;
import
com.yonde.basedata.search.SearchQueryCondition
;
import
com.yonde.basedata.vo.IdVO
;
import
com.yonde.common.DocUtil
;
import
com.yonde.common.DxCommonUtils
;
import
com.yonde.common.DxSearchUtil
;
import
com.yonde.common.RfUtil
;
import
com.yonde.basedata.vo.ObjFileLinkVO
;
import
com.yonde.common.*
;
import
com.yonde.doc.vo.DxDocumentVO
;
import
com.yonde.part.service.DxPartService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.log4j.Logger
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.commons.CommonsMultipartFile
;
import
wt.content.ApplicationData
;
import
wt.content.ContentHolder
;
import
wt.content.ContentRoleType
;
import
wt.doc.WTDocument
;
import
wt.fc.WTObject
;
import
wt.log4j.LogR
;
import
wt.method.RemoteAccess
;
import
wt.method.RemoteMethodServer
;
import
wt.part.WTPart
;
import
wt.session.SessionContext
;
import
wt.session.SessionHelper
;
import
wt.util.WTProperties
;
import
java.io.File
;
import
java.util.List
;
@Service
...
...
@@ -77,4 +85,88 @@ public class BaseSearchService <V extends IdVO> implements RemoteAccess {
return
false
;
}
public
static
void
uploadFile
(
CommonsMultipartFile
file
,
ObjFileLinkVO
fileForm
)
throws
Exception
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
RemoteMethodServer
.
getDefault
().
invoke
(
"uploadFile"
,
BaseSearchService
.
class
.
getName
(),
null
,
new
Class
[]
{
CommonsMultipartFile
.
class
,
ObjFileLinkVO
.
class
},
new
Object
[]
{
file
,
fileForm
});
return
;
}
SessionContext
previous
=
SessionContext
.
newContext
();
try
{
SessionHelper
.
manager
.
setAdministrator
();
String
importFiledirPath
=
WTProperties
.
getLocalProperties
().
getProperty
(
"wt.content.temp"
)
+
File
.
separator
+
System
.
nanoTime
();
File
importFiledir
=
new
File
(
importFiledirPath
);
importFiledir
.
mkdir
();
logger
.
error
(
">>>>importFiledirPath="
+
importFiledirPath
);
File
importFile
=
new
File
(
importFiledirPath
+
File
.
separator
+
file
.
getOriginalFilename
());
file
.
transferTo
(
importFile
);
logger
.
error
(
"====importFile ====="
+
importFile
);
String
contentType
=
fileForm
.
getContentType
();
Long
sourceId
=
fileForm
.
getSourceId
();
String
targetId
=
fileForm
.
getTargetId
();
String
operator
=
fileForm
.
getOperator
();
String
sourceIdType
=
fileForm
.
getSourceIdType
();
ContentHolder
holder
=
DxDocUtil
.
getDocById
(
sourceId
);
if
(
StringUtils
.
isNotEmpty
(
sourceIdType
)
&&
sourceIdType
.
toLowerCase
().
contains
(
"part"
))
{
holder
=
DxPartUtil
.
getPartById
(
sourceId
);
}
if
(
"ADD"
.
equalsIgnoreCase
(
operator
))
{
ContentRoleType
roleType
=
ContentRoleType
.
PRIMARY
;
if
(
StringUtils
.
isNotEmpty
(
contentType
)
&&
contentType
.
equalsIgnoreCase
(
"ATTACH_FILE"
))
{
roleType
=
ContentRoleType
.
SECONDARY
;
}
DocUtil
.
uploadContentHolder
(
holder
,
file
,
roleType
);
}
else
{
ApplicationData
dataById
=
DxCommonUtils
.
getAppDataById
(
targetId
);
if
(
ObjectsUtil
.
nonNull
(
dataById
))
{
DocUtil
.
delContentItem
(
holder
,
dataById
);
}
}
logger
.
error
(
"===fileForm==="
+
fileForm
);
}
finally
{
SessionContext
.
setContext
(
previous
);
}
}
public
static
void
uploadFile
(
File
file
,
ObjFileLinkVO
fileForm
)
throws
Exception
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
RemoteMethodServer
.
getDefault
().
invoke
(
"uploadFile"
,
BaseSearchService
.
class
.
getName
(),
null
,
new
Class
[]
{
File
.
class
,
ObjFileLinkVO
.
class
},
new
Object
[]
{
file
,
fileForm
});
return
;
}
SessionContext
previous
=
SessionContext
.
newContext
();
try
{
SessionHelper
.
manager
.
setAdministrator
();
logger
.
error
(
"====importFile ====="
+
file
);
String
contentType
=
fileForm
.
getContentType
();
Long
sourceId
=
fileForm
.
getSourceId
();
String
targetId
=
fileForm
.
getTargetId
();
String
operator
=
fileForm
.
getOperator
();
String
sourceIdType
=
fileForm
.
getSourceIdType
();
ContentHolder
holder
=
DxDocUtil
.
getDocById
(
sourceId
);
if
(
StringUtils
.
isNotEmpty
(
sourceIdType
)
&&
sourceIdType
.
toLowerCase
().
contains
(
"part"
))
{
holder
=
DxPartUtil
.
getPartById
(
sourceId
);
}
if
(
"ADD"
.
equalsIgnoreCase
(
operator
))
{
ContentRoleType
roleType
=
ContentRoleType
.
PRIMARY
;
if
(
StringUtils
.
isNotEmpty
(
contentType
)
&&
contentType
.
equalsIgnoreCase
(
"ATTACH_FILE"
))
{
roleType
=
ContentRoleType
.
SECONDARY
;
}
DocUtil
.
uploadContentHolder
(
holder
,
file
,
roleType
);
}
else
{
ApplicationData
dataById
=
DxCommonUtils
.
getAppDataById
(
targetId
);
if
(
ObjectsUtil
.
nonNull
(
dataById
))
{
DocUtil
.
delContentItem
(
holder
,
dataById
);
}
}
logger
.
error
(
"===fileForm==="
+
fileForm
);
}
finally
{
SessionContext
.
setContext
(
previous
);
}
}
}
src/com/yonde/basedata/vo/ObjFileLinkVO.java
0 → 100644
View file @
18079263
package
com
.
yonde
.
basedata
.
vo
;
import
wt.fc.WTObject
;
import
wt.util.WTException
;
public
class
ObjFileLinkVO
extends
IdVO
{
private
RepoFileVO
target
;
private
Long
sourceId
;
//文档id
private
String
sourceIdType
;
//DxDocument
private
String
targetId
;
private
String
targetIdType
;
//RepoFile
private
String
contentType
;
//MASTER_FILE,ATTACH_FILE
public
ObjFileLinkVO
()
{
}
public
ObjFileLinkVO
(
WTObject
object
,
RepoFileVO
target
,
String
contentType
)
throws
WTException
{
super
(
object
);
this
.
target
=
target
;
this
.
sourceId
=
this
.
id
;
this
.
contentType
=
contentType
;
}
public
RepoFileVO
getTarget
()
{
return
target
;
}
public
void
setTarget
(
RepoFileVO
target
)
{
this
.
target
=
target
;
}
public
Long
getSourceId
()
{
return
sourceId
;
}
public
void
setSourceId
(
Long
sourceId
)
{
this
.
sourceId
=
sourceId
;
}
public
String
getSourceIdType
()
{
return
sourceIdType
;
}
public
void
setSourceIdType
(
String
sourceIdType
)
{
this
.
sourceIdType
=
sourceIdType
;
}
public
String
getTargetId
()
{
return
targetId
;
}
public
void
setTargetId
(
String
targetId
)
{
this
.
targetId
=
targetId
;
}
public
String
getTargetIdType
()
{
return
targetIdType
;
}
public
void
setTargetIdType
(
String
targetIdType
)
{
this
.
targetIdType
=
targetIdType
;
}
public
String
getContentType
()
{
return
contentType
;
}
public
void
setContentType
(
String
contentType
)
{
this
.
contentType
=
contentType
;
}
}
src/com/yonde/basedata/vo/RepoFileVO.java
0 → 100644
View file @
18079263
package
com
.
yonde
.
basedata
.
vo
;
import
wt.content.ApplicationData
;
import
wt.fc.PersistenceHelper
;
import
wt.util.WTException
;
public
class
RepoFileVO
extends
IdVO
{
private
Long
bucketId
;
private
String
secretCode
;
private
Long
originalSiteId
;
private
Long
originalBucketId
;
private
Long
originalDirId
;
private
String
repoFileName
;
private
String
fileMd5
;
private
String
originalFileName
;
// fileName
private
String
fileSize
;
// fileSize
private
Boolean
isLink
=
true
;
private
String
fileExtension
;
// 后缀
private
String
fileCode
;
// 下载用
private
String
fileStatus
=
"success"
;
public
RepoFileVO
()
{
}
public
RepoFileVO
(
ApplicationData
applicationData
)
throws
WTException
{
super
(
applicationData
);
this
.
bucketId
=
PersistenceHelper
.
getObjectIdentifier
(
applicationData
).
getId
();
this
.
originalFileName
=
applicationData
.
getFileName
();
this
.
fileSize
=
String
.
valueOf
(
applicationData
.
getFileSize
());
this
.
fileExtension
=
this
.
originalFileName
.
substring
(
this
.
originalFileName
.
lastIndexOf
(
"."
)
+
1
);
this
.
fileCode
=
String
.
valueOf
(
this
.
bucketId
);
}
public
Long
getBucketId
()
{
return
bucketId
;
}
public
void
setBucketId
(
Long
bucketId
)
{
this
.
bucketId
=
bucketId
;
}
public
String
getSecretCode
()
{
return
secretCode
;
}
public
void
setSecretCode
(
String
secretCode
)
{
this
.
secretCode
=
secretCode
;
}
public
Long
getOriginalSiteId
()
{
return
originalSiteId
;
}
public
void
setOriginalSiteId
(
Long
originalSiteId
)
{
this
.
originalSiteId
=
originalSiteId
;
}
public
Long
getOriginalBucketId
()
{
return
originalBucketId
;
}
public
void
setOriginalBucketId
(
Long
originalBucketId
)
{
this
.
originalBucketId
=
originalBucketId
;
}
public
Long
getOriginalDirId
()
{
return
originalDirId
;
}
public
void
setOriginalDirId
(
Long
originalDirId
)
{
this
.
originalDirId
=
originalDirId
;
}
public
String
getRepoFileName
()
{
return
repoFileName
;
}
public
void
setRepoFileName
(
String
repoFileName
)
{
this
.
repoFileName
=
repoFileName
;
}
public
String
getFileMd5
()
{
return
fileMd5
;
}
public
void
setFileMd5
(
String
fileMd5
)
{
this
.
fileMd5
=
fileMd5
;
}
public
String
getOriginalFileName
()
{
return
originalFileName
;
}
public
void
setOriginalFileName
(
String
originalFileName
)
{
this
.
originalFileName
=
originalFileName
;
}
public
String
getFileSize
()
{
return
fileSize
;
}
public
void
setFileSize
(
String
fileSize
)
{
this
.
fileSize
=
fileSize
;
}
public
Boolean
getIsLink
()
{
return
isLink
;
}
public
void
setIsLink
(
Boolean
isLink
)
{
isLink
=
isLink
;
}
public
String
getFileExtension
()
{
return
fileExtension
;
}
public
void
setFileExtension
(
String
fileExtension
)
{
this
.
fileExtension
=
fileExtension
;
}
public
String
getFileCode
()
{
return
fileCode
;
}
public
void
setFileCode
(
String
fileCode
)
{
this
.
fileCode
=
fileCode
;
}
public
String
getFileStatus
()
{
return
fileStatus
;
}
public
void
setFileStatus
(
String
fileStatus
)
{
this
.
fileStatus
=
fileStatus
;
}
}
src/com/yonde/common/DocUtil.java
View file @
18079263
...
...
@@ -5,6 +5,7 @@ import com.ptc.core.meta.type.mgmt.server.impl.WTTypeDefinition;
import
com.ptc.core.meta.type.mgmt.server.impl.WTTypeDefinitionMaster
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.log4j.Logger
;
import
org.springframework.web.multipart.MultipartFile
;
import
wt.access.NotAuthorizedException
;
import
wt.content.*
;
import
wt.doc.*
;
...
...
@@ -23,7 +24,6 @@ import wt.method.RemoteAccess;
import
wt.method.RemoteMethodServer
;
import
wt.org.WTPrincipal
;
import
wt.org.WTPrincipalReference
;
import
wt.part.WTPart
;
import
wt.query.ClassAttribute
;
import
wt.query.QuerySpec
;
import
wt.query.SearchCondition
;
...
...
@@ -43,6 +43,9 @@ import wt.vc.config.LatestConfigSpec;
import
wt.vc.wip.CheckoutLink
;
import
wt.vc.wip.WorkInProgressHelper
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
import
java.io.Serializable
;
import
java.lang.reflect.InvocationTargetException
;
import
java.rmi.RemoteException
;
...
...
@@ -352,6 +355,55 @@ public class DocUtil implements RemoteAccess, Serializable {
return
data
;
}
/**
* 获取文档主内容
*
* @param holder
* 文档
* @param roleType
* 所属类型
* @return 结果
* @throws WTException
* 异常
*/
public
static
List
<
ApplicationData
>
getHolderContents
(
ContentHolder
holder
,
ContentRoleType
roleType
)
throws
WTException
{
List
<
ApplicationData
>
dataList
=
new
ArrayList
<
ApplicationData
>();
QueryResult
qr
=
ContentHelper
.
service
.
getContentsByRole
(
holder
,
roleType
);
while
(
qr
.
hasMoreElements
())
{
ContentItem
item
=
(
ContentItem
)
qr
.
nextElement
();
if
(
item
instanceof
ApplicationData
)
{
dataList
.
add
((
ApplicationData
)
item
);
}
}
return
dataList
;
}
/**
* 获取文档主内容
*
* @param holder
* 文档
* @param roleType
* 所属类型
* @return 结果
* @throws WTException
* 异常
*/
public
static
ApplicationData
getHolderContent
(
ContentHolder
holder
,
ContentRoleType
roleType
)
throws
WTException
{
ApplicationData
data
=
null
;
QueryResult
qr
=
ContentHelper
.
service
.
getContentsByRole
(
holder
,
roleType
);
if
(
qr
.
hasMoreElements
())
{
ContentItem
item
=
(
ContentItem
)
qr
.
nextElement
();
if
(
item
instanceof
ApplicationData
)
{
data
=
(
ApplicationData
)
item
;
}
}
return
data
;
}
/**
* 根据oid获取文档
*
...
...
@@ -1282,4 +1334,44 @@ public class DocUtil implements RemoteAccess, Serializable {
}
return
null
;
}
public
static
void
uploadContentHolder
(
ContentHolder
holder
,
MultipartFile
multipartFile
,
ContentRoleType
roleType
)
throws
Exception
{
if
(
roleType
.
equals
(
ContentRoleType
.
PRIMARY
))
{
QueryResult
qr2
=
ContentHelper
.
service
.
getContentsByRole
(
holder
,
roleType
);
if
(
qr2
.
hasMoreElements
())
{
ApplicationData
appData
=
(
ApplicationData
)
qr2
.
nextElement
();
ContentServerHelper
.
service
.
deleteContent
(
holder
,
appData
);
logger
.
debug
(
"找到已存在的主内容,删除"
);
}
}
ApplicationData
applicationData
=
ApplicationData
.
newApplicationData
(
holder
);
applicationData
.
setRole
(
roleType
);
InputStream
ins
=
multipartFile
.
getInputStream
();
ApplicationData
applicationData1
=
ContentServerHelper
.
service
.
updateContent
(
holder
,
applicationData
,
ins
);
PersistenceHelper
.
manager
.
save
(
applicationData1
);
PersistenceServerHelper
.
manager
.
restore
(
holder
);
ins
.
close
();
}
public
static
void
uploadContentHolder
(
ContentHolder
holder
,
File
file
,
ContentRoleType
roleType
)
throws
Exception
{
if
(
roleType
.
equals
(
ContentRoleType
.
PRIMARY
))
{
QueryResult
qr2
=
ContentHelper
.
service
.
getContentsByRole
(
holder
,
roleType
);
if
(
qr2
.
hasMoreElements
())
{
ApplicationData
appData
=
(
ApplicationData
)
qr2
.
nextElement
();
ContentServerHelper
.
service
.
deleteContent
(
holder
,
appData
);
logger
.
debug
(
"找到已存在的主内容,删除"
);
}
}
ApplicationData
applicationData
=
ApplicationData
.
newApplicationData
(
holder
);
applicationData
.
setRole
(
roleType
);
//InputStream ins = new FileInputStream(file);
ApplicationData
applicationData1
=
ContentServerHelper
.
service
.
updateContent
(
holder
,
applicationData
,
file
.
getPath
());
PersistenceHelper
.
manager
.
save
(
applicationData1
);
PersistenceServerHelper
.
manager
.
restore
(
holder
);
//ins.close();
}
public
static
void
delContentItem
(
ContentHolder
holder
,
ApplicationData
data
)
throws
WTException
,
WTPropertyVetoException
{
ContentServerHelper
.
service
.
deleteContent
(
holder
,
data
);
}
}
src/com/yonde/common/DxCommonUtils.java
View file @
18079263
This diff is collapsed.
Click to expand it.
src/com/yonde/common/DxPartUtil.java
View file @
18079263
...
...
@@ -223,9 +223,14 @@ public class DxPartUtil implements RemoteAccess, Serializable {
}
}
DxViewVO
dxView
=
dxPartVO
.
getDxView
();
logger
.
error
(
"dxView===="
+
dxView
);
if
(
ObjectsUtil
.
nonNull
(
dxView
))
{
logger
.
error
(
"dxView id===="
+
dxView
.
getId
());
if
(
ObjectsUtil
.
isNull
(
dxView
.
getName
()))
{
partView
=
SearchOperatorEnumUtil
.
viewMap
.
get
(
dxView
.
getId
());
partView
=
SearchOperatorEnumUtil
.
viewMap
.
get
(
String
.
valueOf
(
dxView
.
getId
()));
logger
.
error
(
"dxView name===="
+
partView
);
}
else
{
partView
=
dxView
.
getName
();
}
}
String
partType
=
""
;
...
...
@@ -285,11 +290,12 @@ public class DxPartUtil implements RemoteAccess, Serializable {
View
part_view
=
null
;
try
{
if
(
partView
==
null
||
partView
.
trim
().
equals
(
""
))
{
if
(
StringUtils
.
isEmpty
(
partView
))
{
part_view
=
ViewHelper
.
service
.
getView
(
"Design"
);
}
else
{
part_view
=
ViewHelper
.
service
.
getView
(
partView
);
}
logger
.
error
(
"partView Name======"
+
partView
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
src/com/yonde/common/DxSearchUtil.java
View file @
18079263
...
...
@@ -206,12 +206,15 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
//视图
if
(
fieldName
.
equals
(
SearchOperatorEnumUtil
.
DX_VIEWID
))
{
addQuerySpecOp
(
querySpec
,
operator
);
View
view
=
ViewHelper
.
service
.
getView
(
SearchOperatorEnumUtil
.
viewMap
.
get
(
item
.
value
));
String
viewName
=
SearchOperatorEnumUtil
.
viewMap
.
get
(
String
.
valueOf
(
item
.
value
));
logger
.
error
(
"viewName========="
+
viewName
);
View
view
=
ViewHelper
.
service
.
getView
(
viewName
);
logger
.
error
(
"view========="
+
view
);
if
(
view
==
null
)
{
continue
;
}
SearchCondition
sc
=
buildScd
(
clazz
,
typeSearchMap
.
get
(
fieldName
),
item
.
operator
.
name
(),
PersistenceHelper
.
getObjectIdentifier
(
view
));
.
getObjectIdentifier
(
view
)
.
getId
()
);
if
(
ObjectsUtil
.
nonNull
(
sc
))
{
querySpec
.
appendWhere
(
sc
,
new
int
[]{
0
});
}
...
...
src/com/yonde/common/PartUtil.java
View file @
18079263
...
...
@@ -14,17 +14,21 @@ import wt.inf.container.WTContainerRef;
import
wt.log4j.LogR
;
import
wt.method.RemoteAccess
;
import
wt.method.RemoteMethodServer
;
import
wt.org.WTUser
;
import
wt.part.*
;
import
wt.pds.StatementSpec
;
import
wt.query.ArrayExpression
;
import
wt.query.ClassAttribute
;
import
wt.query.QuerySpec
;
import
wt.query.SearchCondition
;
import
wt.session.SessionHelper
;
import
wt.session.SessionServerHelper
;
import
wt.type.TypedUtility
;
import
wt.util.WTException
;
import
wt.vc.VersionControlHelper
;
import
wt.vc.config.ConfigSpec
;
import
wt.vc.config.IteratedOrderByPrimitive
;
import
wt.vc.config.LatestConfigSpec
;
import
wt.vc.config.VersionedOrderByPrimitive
;
import
wt.vc.views.View
;
import
wt.vc.views.ViewHelper
;
...
...
@@ -33,6 +37,7 @@ import wt.vc.views.ViewReference;
import
java.lang.reflect.InvocationTargetException
;
import
java.rmi.RemoteException
;
import
java.text.DecimalFormat
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Hashtable
;
import
java.util.List
;
...
...
@@ -409,4 +414,137 @@ public class PartUtil implements RemoteAccess {
}
return
latestPart
;
}
/**
* @描述 获得所有的子件,不包括根节点
* @作者 Pengfei,Li
* @时间 2015-9-11上午11:13:19
*/
public
static
void
getAllChildByView
(
WTPart
parent
,
ConfigSpec
configSpec
,
List
<
WTPart
>
childSet
)
throws
Exception
{
List
<
WTPart
>
childs
=
getChildByView
(
parent
,
configSpec
);
childSet
.
addAll
(
childs
);
for
(
WTPart
wtPart
:
childs
)
{
getAllChildByView
(
wtPart
,
configSpec
,
childSet
);
}
}
/**
* @描述 获取指定视图的子件,若子件无该视图则返回上游Design视图
* @作者 Pengfei,Li
* @时间 2015-9-11上午10:47:16
*/
@SuppressWarnings
(
"unchecked"
)
public
static
List
<
WTPart
>
getChildByView
(
WTPart
parent
,
String
viewStr
)
throws
WTException
{
List
<
WTPart
>
childs
=
new
ArrayList
<
WTPart
>();
if
(!
RemoteMethodServer
.
ServerFlag
)
{
try
{
childs
=
(
List
<
WTPart
>)
RemoteMethodServer
.
getDefault
().
invoke
(
"getChildByView"
,
PartUtil
.
class
.
getName
(),
null
,
new
Class
[]
{
WTPart
.
class
,
String
.
class
},
new
Object
[]
{
parent
,
viewStr
});
}
catch
(
Exception
e
)
{
throw
new
WTException
(
e
);
}
}
else
{
SessionServerHelper
.
manager
.
setAccessEnforced
(
false
);
try
{
WTPartConfigSpec
partConfigSpec
=
WTPartConfigSpec
.
newWTPartConfigSpec
(
WTPartStandardConfigSpec
.
newWTPartStandardConfigSpec
(
ViewHelper
.
service
.
getView
(
viewStr
),
null
));
for
(
QueryResult
subNodes
=
WTPartHelper
.
service
.
getUsesWTParts
(
parent
,
partConfigSpec
);
subNodes
.
hasMoreElements
();)
{
wt
.
fc
.
Persistable
aSubNodePair
[]
=
(
wt
.
fc
.
Persistable
[])
subNodes
.
nextElement
();
if
(
aSubNodePair
[
1
]
instanceof
WTPart
)
{
WTPart
tempPart
=
(
WTPart
)
aSubNodePair
[
1
];
if
(
tempPart
!=
null
)
{
childs
.
add
(
tempPart
);
}
}
else
if
(
aSubNodePair
[
1
]
instanceof
WTPartMaster
)
{
String
partNo
=
((
WTPartMaster
)
aSubNodePair
[
1
]).
getNumber
();
WTPart
tempPart
=
null
;
try
{
tempPart
=
getLatestViewPart
(
partNo
,
viewStr
);
if
(
tempPart
==
null
)
{
tempPart
=
getLatestViewPart
(
partNo
,
"Design"
);
}
if
(
tempPart
!=
null
)
{
childs
.
add
(
tempPart
);
}
}
catch
(
Exception
e
)
{
throw
new
WTException
(
e
);
}
}
}
}
finally
{
SessionServerHelper
.
manager
.
setAccessEnforced
(
true
);
}
}
return
childs
;
}
/**
* @描述 获取指定视图的最新版
*/
public
static
WTPart
getLatestViewPart
(
String
number
,
String
viewName
)
throws
WTException
{
try
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
return
(
WTPart
)
RemoteMethodServer
.
getDefault
().
invoke
(
"getLatestViewPart"
,
PartUtil
.
class
.
getName
(),
null
,
new
Class
[]
{
String
.
class
,
String
.
class
},
new
Object
[]
{
number
,
viewName
});
}
else
{
WTPart
part
=
null
;
if
(!
StringUtils
.
isEmpty
(
number
)
&&
!
StringUtils
.
isEmpty
(
viewName
))
{
QuerySpec
qs
=
new
QuerySpec
(
WTPart
.
class
);
qs
.
setAdvancedQueryEnabled
(
true
);
qs
.
appendWhere
(
new
SearchCondition
(
WTPart
.
class
,
WTPart
.
LATEST_ITERATION
,
SearchCondition
.
IS_TRUE
),
new
int
[]
{
0
});
number
=
number
==
null
?
null
:
number
.
toUpperCase
();
qs
.
appendAnd
();
qs
.
appendWhere
(
new
SearchCondition
(
WTPart
.
class
,
WTPart
.
NUMBER
,
SearchCondition
.
EQUAL
,
number
),
new
int
[]
{
0
});
View
view
=
ViewHelper
.
service
.
getView
(
viewName
);
qs
.
appendAnd
();
qs
.
appendWhere
(
new
SearchCondition
(
WTPart
.
class
,
WTPart
.
VIEW
+
"."
+
ObjectReference
.
KEY
,
SearchCondition
.
EQUAL
,
PersistenceHelper
.
getObjectIdentifier
(
view
)),
new
int
[]
{
0
});
QueryResult
queryResult
=
PersistenceHelper
.
manager
.
find
((
StatementSpec
)
qs
);
queryResult
=
new
LatestConfigSpec
().
process
(
queryResult
);
if
(
queryResult
.
hasMoreElements
())
{
part
=
(
WTPart
)
queryResult
.
nextElement
();
}
}
return
part
;
}
}
catch
(
RemoteException
e
)
{
e
.
printStackTrace
();
}
catch
(
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* @描述 返回指定配置的子件
*/
@SuppressWarnings
(
"unchecked"
)
public
static
List
<
WTPart
>
getChildByView
(
WTPart
parent
,
ConfigSpec
configSpec
)
throws
Exception
{
List
<
WTPart
>
childs
=
new
ArrayList
<
WTPart
>();
if
(!
RemoteMethodServer
.
ServerFlag
)
{
childs
=
(
List
<
WTPart
>)
RemoteMethodServer
.
getDefault
().
invoke
(
"getChildByView"
,
PartUtil
.
class
.
getName
(),
null
,
new
Class
[]
{
WTPart
.
class
,
WTPartConfigSpec
.
class
},
new
Object
[]
{
parent
,
configSpec
});
}
else
{
WTUser
currentUser
=
(
WTUser
)
SessionHelper
.
manager
.
getPrincipal
();
try
{
SessionHelper
.
manager
.
setAdministrator
();
for
(
QueryResult
subNodes
=
WTPartHelper
.
service
.
getUsesWTParts
(
parent
,
configSpec
);
subNodes
.
hasMoreElements
();)
{
//for (QueryResult subNodes = StructHelper.service.navigateUsesToIteration(parent, false, configSpec); subNodes.hasMoreElements();) {
Object
result
=
subNodes
.
nextElement
();
if
(!(
result
instanceof
Persistable
[]))
continue
;
wt
.
fc
.
Persistable
aSubNodePair
[]
=
(
wt
.
fc
.
Persistable
[])
result
;
if
(
aSubNodePair
[
1
]
instanceof
WTPart
)
{
WTPartUsageLink
link
=
(
WTPartUsageLink
)
aSubNodePair
[
0
];
WTPart
tempPart
=
(
WTPart
)
aSubNodePair
[
1
];
if
(
tempPart
!=
null
)
{
childs
.
add
(
tempPart
);
}
}
}
}
catch
(
Exception
e
)
{
throw
new
WTException
(
e
);
}
finally
{
SessionHelper
.
manager
.
setPrincipal
(
currentUser
.
getName
());
}
}
return
childs
;
}
}
src/com/yonde/doc/service/DxDocService.java
View file @
18079263
...
...
@@ -192,7 +192,7 @@ public class DxDocService implements RemoteAccess {
}
public
DxDocumentVO
findByNumber
(
String
var1
)
throws
WTException
,
RemoteException
,
InvocationTarget
Exception
{
public
DxDocumentVO
findByNumber
(
String
var1
)
throws
Exception
{
return
new
DxDocumentVO
(
DocUtil
.
getDoc
(
var1
));
}
...
...
src/com/yonde/doc/service/impl/DxDocServiceImpl.java
View file @
18079263
...
...
@@ -17,7 +17,7 @@ public class DxDocServiceImpl {
}
public
DxDocumentVO
findByNumber
(
String
var1
)
throws
WTException
,
RemoteException
,
InvocationTarget
Exception
{
public
DxDocumentVO
findByNumber
(
String
var1
)
throws
Exception
{
return
new
DxDocumentVO
(
DocUtil
.
getDoc
(
var1
));
}
...
...
src/com/yonde/doc/util/DxDocUtil.java
View file @
18079263
...
...
@@ -107,15 +107,16 @@ public class DxDocUtil {
if
(
state
!=
null
&&
state
.
length
()
>
0
)
{
doc
=
(
WTDocument
)
LifeCycleServerHelper
.
setState
(
doc
,
State
.
toState
(
state
));
}
doc
=
(
WTDocument
)
PersistenceHelper
.
manager
.
save
(
doc
);
doc
=
(
WTDocument
)
PersistenceHelper
.
manager
.
refresh
(
doc
);
log
.
info
(
">>>>>>>>>refresh.doc="
+
doc
.
getNumber
());
//doc = (WTDocument) PersistenceHelper.manager.refresh(doc);
Object
description
=
ibaMap
.
get
(
"description"
);
if
(
ObjectsUtil
.
nonNull
(
description
))
{
doc
.
setDescription
(
String
.
valueOf
(
description
));
ibaMap
.
remove
(
"description"
);
}
doc
=
(
WTDocument
)
PersistenceHelper
.
manager
.
save
(
doc
);
doc
=
(
WTDocument
)
PersistenceHelper
.
manager
.
refresh
(
doc
);
log
.
info
(
">>>>>>>>>refresh.doc="
+
doc
.
getNumber
());
//doc = (WTDocument) PersistenceHelper.manager.refresh(doc);
int
ibaSize
=
ibaMap
==
null
?
0
:
ibaMap
.
size
();
log
.
debug
(
"开始设置软属性,数:"
+
ibaSize
);
if
(
ibaSize
>
0
)
{
...
...
src/com/yonde/doc/vo/DxDocumentVO.java
View file @
18079263
...
...
@@ -4,8 +4,10 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import
com.fasterxml.jackson.annotation.JsonTypeInfo
;
import
com.yonde.basedata.entity.users.DxUserVO
;
import
com.yonde.basedata.vo.*
;
import
com.yonde.common.DxCommonUtils
;
import
com.yonde.common.IBAHelper
;
import
com.yonde.context.vo.DxContextVO
;
import
org.apache.commons.lang.StringUtils
;
import
wt.doc.WTDocument
;
import
wt.fc.PersistenceHelper
;
import
wt.org.WTOrganization
;
...
...
@@ -18,6 +20,7 @@ import wt.vc.wip.WorkInProgressHelper;
import
java.io.Serializable
;
import
java.lang.reflect.InvocationTargetException
;
import
java.rmi.RemoteException
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
...
...
@@ -57,10 +60,12 @@ public class DxDocumentVO extends RevisionControlledVO implements Serializable {
private
Long
dxDocumentFolderId
;
private
String
dxDocumentFolderIdType
;
private
List
<
ObjFileLinkVO
>
objFileLinks
;
//TODO link
public
DxDocumentVO
(
WTDocument
wtDoc
)
throws
WTException
,
RemoteException
,
InvocationTarget
Exception
{
public
DxDocumentVO
(
WTDocument
wtDoc
)
throws
Exception
{
super
(
wtDoc
);
//TODO
//Team team = TeamHelper.service.getTeam("");
...
...
@@ -91,8 +96,11 @@ public class DxDocumentVO extends RevisionControlledVO implements Serializable {
this
.
latest
=
wtDoc
.
isLatestIteration
();
this
.
checkOuted
=
WorkInProgressHelper
.
isCheckedOut
(
wtDoc
);
//this.setOperator("NO_CHANGE");
if
(
StringUtils
.
isNotEmpty
(
wtDoc
.
getDescription
()))
{
this
.
getDynamicAttrs
().
put
(
"description"
,
wtDoc
.
getDescription
());
}
this
.
lifecycleTemplateId
=
PersistenceHelper
.
getObjectIdentifier
(
wtDoc
.
getLifeCycleTemplate
().
getObject
()).
getId
();
this
.
setObjFileLinks
(
DxCommonUtils
.
buildObjFileLinks
(
wtDoc
));
}
finally
{
SessionContext
.
setContext
(
previous
);
}
...
...
@@ -110,6 +118,14 @@ public class DxDocumentVO extends RevisionControlledVO implements Serializable {
}
}
public
List
<
ObjFileLinkVO
>
getObjFileLinks
()
{
return
objFileLinks
;
}
public
void
setObjFileLinks
(
List
<
ObjFileLinkVO
>
objFileLinks
)
{
this
.
objFileLinks
=
objFileLinks
;
}
public
DxDocumentFolderVO
getDxDocumentFolder
()
{
return
dxDocumentFolder
;
}
...
...
src/com/yonde/part/controller/DxPartController.java
View file @
18079263
...
...
@@ -183,4 +183,15 @@ public class DxPartController extends AbstractBaseController {
return
parentDxPart
;
}
}
@PostMapping
({
"/version/{id}/convertView"
})
//@ApiOperation("转视图")
public
ApiResult
convertView
(
@PathVariable
Long
id
)
{
try
{
DxPartService
.
convertViewAll
(
id
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
ApiResult
.
ok
(
"转视图成功"
);
}
}
src/com/yonde/part/service/DxPartService.java
View file @
18079263
...
...
@@ -515,4 +515,76 @@ public class DxPartService implements RemoteAccess, Serializable {
return
resultList
;
}
/**
* 转视图
* @param id
* @return
* @throws Exception
*/
public
static
DxPartVO
convertView
(
Long
id
)
throws
Exception
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
return
(
DxPartVO
)
RemoteMethodServer
.
getDefault
().
invoke
(
"convertView"
,
DxPartService
.
class
.
getName
(),
null
,
new
Class
[]
{
Long
.
class
},
new
Object
[]
{
id
});
}
WTPart
partById
=
DxPartUtil
.
getPartById
(
id
);
String
viewName
=
partById
.
getViewName
();
if
(!
viewName
.
equalsIgnoreCase
(
"Planning"
)){
WTPart
tmpPart
=
(
WTPart
)
ViewHelper
.
service
.
newBranchForView
(
partById
,
"Planning"
);
tmpPart
.
setContainer
(
partById
.
getContainer
());
CommonUtil
.
setFolder
(
"/Default/PBOM/PBOM零部件"
,
partById
.
getContainerReference
(),
tmpPart
);
tmpPart
=
(
WTPart
)
PersistenceHelper
.
manager
.
save
(
tmpPart
);
return
new
DxPartVO
(
tmpPart
);
}
else
{
return
new
DxPartVO
(
partById
);
}
}
/**
* 批量转视图
* @param id
* @return
* @throws Exception
*/
public
static
void
convertViewAll
(
Long
id
)
throws
Exception
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
RemoteMethodServer
.
getDefault
().
invoke
(
"convertViewAll"
,
DxPartService
.
class
.
getName
(),
null
,
new
Class
[]
{
Long
.
class
},
new
Object
[]
{
id
});
}
/* SessionContext previous = SessionContext.newContext();
try {
SessionHelper.manager.setAdministrator();
} finally {
SessionContext.setContext(previous);
}*/
WTPart
partById
=
DxPartUtil
.
getPartById
(
id
);
String
viewName
=
partById
.
getViewName
();
if
(!
viewName
.
equalsIgnoreCase
(
"Planning"
)){
WTPart
ppart
=
PartUtil
.
getLatestViewPart
(
partById
.
getNumber
(),
"Planning"
);
ArrayList
<
WTPart
>
list
=
new
ArrayList
<
WTPart
>();
if
(
ppart
==
null
){
WTPartConfigSpec
partConfigSpec
=
WTPartConfigSpec
.
newWTPartConfigSpec
(
WTPartStandardConfigSpec
.
newWTPartStandardConfigSpec
(
ViewHelper
.
service
.
getView
(
"Design"
),
null
));
PartUtil
.
getAllChildByView
(
partById
,
partConfigSpec
,
list
);
ppart
=
(
WTPart
)
ViewHelper
.
service
.
newBranchForView
(
partById
,
"Planning"
);
ppart
.
setContainer
(
partById
.
getContainer
());
CommonUtil
.
setFolder
(
"/Default/PBOM/PBOM零部件"
,
partById
.
getContainerReference
(),
ppart
);
PersistenceHelper
.
manager
.
save
(
ppart
);
}
for
(
WTPart
tempPart
:
list
){
tempPart
=
(
WTPart
)
ViewHelper
.
service
.
newBranchForView
(
partById
,
"Planning"
);
tempPart
.
setContainer
(
partById
.
getContainer
());
CommonUtil
.
setFolder
(
"/Default/PBOM/PBOM零部件"
,
partById
.
getContainerReference
(),
tempPart
);
PersistenceHelper
.
manager
.
save
(
tempPart
);
}
}
else
{
throw
new
Exception
(
"无需转视图"
);
}
}
}
src/com/yonde/part/vo/DxPartDescribeLinkVO.java
View file @
18079263
...
...
@@ -37,7 +37,7 @@ public class DxPartDescribeLinkVO extends IdVO implements Serializable{
public
DxPartDescribeLinkVO
()
{
}
public
DxPartDescribeLinkVO
(
WTPartDescribeLink
describeLink
)
throws
WTException
,
RemoteException
,
InvocationTarget
Exception
{
public
DxPartDescribeLinkVO
(
WTPartDescribeLink
describeLink
)
throws
Exception
{
super
(
describeLink
);
SessionContext
previous
=
SessionContext
.
newContext
();
try
{
...
...
src/com/yonde/part/vo/DxPartReferenceLinkVO.java
View file @
18079263
...
...
@@ -39,7 +39,7 @@ public class DxPartReferenceLinkVO extends IdVO implements Serializable{
public
DxPartReferenceLinkVO
()
{
}
public
DxPartReferenceLinkVO
(
WTPartReferenceLink
referenceLink
)
throws
WTException
,
RemoteException
,
InvocationTarget
Exception
{
public
DxPartReferenceLinkVO
(
WTPartReferenceLink
referenceLink
)
throws
Exception
{
super
(
referenceLink
);
SessionContext
previous
=
SessionContext
.
newContext
();
try
{
...
...
src/com/yonde/plan/controller/DxProcessLinkController.java
0 → 100644
View file @
18079263
package
com
.
yonde
.
plan
.
controller
;
import
com.yonde.plan.service.DxProcessLinkService
;
import
com.yonde.plan.vo.DxProcessDocDescribeLinkVO
;
import
com.yonde.plan.vo.DxProcessDocReferenceLinkVO
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
value
=
"/DxProcessLink"
)
public
class
DxProcessLinkController
{
//@ApiOperation("深度保存对象")
@PostMapping
({
"/ref/search"
})
public
List
processRefDocLinks
(
@RequestBody
Map
entity
)
{
try
{
List
<
DxProcessDocReferenceLinkVO
>
linkVOList
=
DxProcessLinkService
.
buildProcessDocRefLink
(
entity
);
return
linkVOList
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
//@ApiOperation("深度保存对象")
@PostMapping
({
"/des/search"
})
public
List
processDesDocLinks
(
@RequestBody
Map
entity
)
{
try
{
List
<
DxProcessDocDescribeLinkVO
>
linkVOList
=
DxProcessLinkService
.
buildProcessDocDesLink
(
entity
);
return
linkVOList
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
}
src/com/yonde/plan/service/DxProcessLinkService.java
0 → 100644
View file @
18079263
package
com
.
yonde
.
plan
.
service
;
import
com.yonde.doc.util.DxDocUtil
;
import
com.yonde.plan.vo.DxProcessDocDescribeLinkVO
;
import
com.yonde.plan.vo.DxProcessDocReferenceLinkVO
;
import
org.apache.log4j.Logger
;
import
org.springframework.stereotype.Service
;
import
wt.doc.WTDocument
;
import
wt.log4j.LogR
;
import
wt.method.RemoteAccess
;
import
wt.method.RemoteMethodServer
;
import
wt.session.SessionContext
;
import
wt.session.SessionHelper
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.StringTokenizer
;
@Service
public
class
DxProcessLinkService
implements
RemoteAccess
{
private
static
Logger
logger
=
LogR
.
getLogger
(
DxProcessLinkService
.
class
.
getName
());
public
static
List
<
DxProcessDocReferenceLinkVO
>
buildProcessDocRefLink
(
Map
entity
)
throws
Exception
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
return
(
List
)
RemoteMethodServer
.
getDefault
().
invoke
(
"buildProcessDocRefLink"
,
DxProcessLinkService
.
class
.
getName
(),
null
,
new
Class
[]
{
Map
.
class
},
new
Object
[]
{
entity
});
}
SessionContext
previous
=
SessionContext
.
newContext
();
List
<
DxProcessDocReferenceLinkVO
>
resultList
=
new
ArrayList
<
DxProcessDocReferenceLinkVO
>();
try
{
SessionHelper
.
manager
.
setAdministrator
();
String
docIds
=
(
String
)
entity
.
get
(
"docIds"
);
//String sourceId = (String) entity.get("sourceId");
logger
.
error
(
"docIds===="
+
docIds
);
StringTokenizer
tokenizer
=
new
StringTokenizer
(
docIds
,
","
);
while
(
tokenizer
.
hasMoreElements
())
{
String
docId
=
tokenizer
.
nextToken
();
WTDocument
wtDocument
=
DxDocUtil
.
getDocById
(
Long
.
valueOf
(
docId
));
DxProcessDocReferenceLinkVO
linkVO
=
new
DxProcessDocReferenceLinkVO
(
wtDocument
);
resultList
.
add
(
linkVO
);
}
}
finally
{
SessionContext
.
setContext
(
previous
);
}
return
resultList
;
}
public
static
List
<
DxProcessDocDescribeLinkVO
>
buildProcessDocDesLink
(
Map
entity
)
throws
Exception
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
return
(
List
)
RemoteMethodServer
.
getDefault
().
invoke
(
"buildProcessDocDesLink"
,
DxProcessLinkService
.
class
.
getName
(),
null
,
new
Class
[]
{
Map
.
class
},
new
Object
[]
{
entity
});
}
List
<
DxProcessDocDescribeLinkVO
>
resultList
=
new
ArrayList
<
DxProcessDocDescribeLinkVO
>();
SessionContext
previous
=
SessionContext
.
newContext
();
try
{
SessionHelper
.
manager
.
setAdministrator
();
String
docIds
=
(
String
)
entity
.
get
(
"docIds"
);
StringTokenizer
tokenizer
=
new
StringTokenizer
(
docIds
,
","
);
while
(
tokenizer
.
hasMoreElements
())
{
String
docId
=
tokenizer
.
nextToken
();
WTDocument
wtDocument
=
DxDocUtil
.
getDocById
(
Long
.
valueOf
(
docId
));
DxProcessDocDescribeLinkVO
linkVO
=
new
DxProcessDocDescribeLinkVO
(
wtDocument
);
resultList
.
add
(
linkVO
);
}
}
finally
{
SessionContext
.
setContext
(
previous
);
}
return
resultList
;
}
}
src/com/yonde/plan/vo/DxProcessDocDescribeLinkVO.java
0 → 100644
View file @
18079263
package
com
.
yonde
.
plan
.
vo
;
import
com.yonde.basedata.vo.IdVO
;
import
com.yonde.doc.vo.DxDocumentVO
;
import
wt.doc.WTDocument
;
public
class
DxProcessDocDescribeLinkVO
extends
IdVO
{
private
Object
source
;
private
Long
sourceId
;
private
String
sourceIdType
;
private
DxDocumentVO
target
;
private
Long
targetId
;
private
String
targetIdType
;
public
DxProcessDocDescribeLinkVO
(
WTDocument
document
)
throws
Exception
{
super
(
document
);
this
.
target
=
new
DxDocumentVO
(
document
);
this
.
targetId
=
target
.
getId
();
this
.
sourceId
=
targetId
;
this
.
sourceIdType
=
"DxProcessPlan"
;
this
.
targetIdType
=
"DxDocument"
;
this
.
setOperator
(
"NO_CHANGE"
);
}
public
Object
getSource
()
{
return
source
;
}
public
void
setSource
(
Object
source
)
{
this
.
source
=
source
;
}
public
Long
getSourceId
()
{
return
sourceId
;
}
public
void
setSourceId
(
Long
sourceId
)
{
this
.
sourceId
=
sourceId
;
}
public
String
getSourceIdType
()
{
return
sourceIdType
;
}
public
void
setSourceIdType
(
String
sourceIdType
)
{
this
.
sourceIdType
=
sourceIdType
;
}
public
DxDocumentVO
getTarget
()
{
return
target
;
}
public
void
setTarget
(
DxDocumentVO
target
)
{
this
.
target
=
target
;
}
public
Long
getTargetId
()
{
return
targetId
;
}
public
void
setTargetId
(
Long
targetId
)
{
this
.
targetId
=
targetId
;
}
public
String
getTargetIdType
()
{
return
targetIdType
;
}
public
void
setTargetIdType
(
String
targetIdType
)
{
this
.
targetIdType
=
targetIdType
;
}
}
src/com/yonde/plan/vo/DxProcessDocReferenceLinkVO.java
0 → 100644
View file @
18079263
package
com
.
yonde
.
plan
.
vo
;
import
com.yonde.basedata.vo.IdVO
;
import
com.yonde.doc.vo.DxDocumentVO
;
import
wt.doc.WTDocument
;
public
class
DxProcessDocReferenceLinkVO
extends
IdVO
{
private
Object
source
;
private
Long
sourceId
;
private
String
sourceIdType
;
private
DxDocumentVO
target
;
private
Long
targetId
;
private
String
targetIdType
;
public
DxProcessDocReferenceLinkVO
(
WTDocument
document
)
throws
Exception
{
super
(
document
);
this
.
target
=
new
DxDocumentVO
(
document
);
this
.
targetId
=
target
.
getId
();
this
.
sourceId
=
targetId
;
this
.
sourceIdType
=
"DxProcessPlan"
;
this
.
targetIdType
=
"DxDocument"
;
this
.
setOperator
(
"NO_CHANGE"
);
}
public
Object
getSource
()
{
return
source
;
}
public
void
setSource
(
Object
source
)
{
this
.
source
=
source
;
}
public
Long
getSourceId
()
{
return
sourceId
;
}
public
void
setSourceId
(
Long
sourceId
)
{
this
.
sourceId
=
sourceId
;
}
public
String
getSourceIdType
()
{
return
sourceIdType
;
}
public
void
setSourceIdType
(
String
sourceIdType
)
{
this
.
sourceIdType
=
sourceIdType
;
}
public
DxDocumentVO
getTarget
()
{
return
target
;
}
public
void
setTarget
(
DxDocumentVO
target
)
{
this
.
target
=
target
;
}
public
Long
getTargetId
()
{
return
targetId
;
}
public
void
setTargetId
(
Long
targetId
)
{
this
.
targetId
=
targetId
;
}
public
String
getTargetIdType
()
{
return
targetIdType
;
}
public
void
setTargetIdType
(
String
targetIdType
)
{
this
.
targetIdType
=
targetIdType
;
}
}
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