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
b88b3393
Commit
b88b3393
authored
Feb 24, 2023
by
shyWang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PDM前端改造
产品中心改造测试bug修复
parent
ee457e27
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
296 additions
and
103 deletions
+296
-103
AbstractBaseController.java
...com/yonde/basedata/controller/AbstractBaseController.java
+23
-4
SearchOperatorEnumUtil.java
src/com/yonde/basedata/search/SearchOperatorEnumUtil.java
+30
-4
BaseSearchService.java
src/com/yonde/basedata/service/BaseSearchService.java
+21
-0
DxCommonUtils.java
src/com/yonde/common/DxCommonUtils.java
+10
-0
DxPartUtil.java
src/com/yonde/common/DxPartUtil.java
+50
-20
DxSearchUtil.java
src/com/yonde/common/DxSearchUtil.java
+45
-39
DxPartController.java
src/com/yonde/part/controller/DxPartController.java
+20
-0
DxUsageLinkController.java
src/com/yonde/part/controller/DxUsageLinkController.java
+6
-12
DxPartService.java
src/com/yonde/part/service/DxPartService.java
+56
-8
DxUsageLinkVO.java
src/com/yonde/part/vo/DxUsageLinkVO.java
+35
-16
No files found.
src/com/yonde/basedata/controller/AbstractBaseController.java
View file @
b88b3393
...
...
@@ -8,11 +8,11 @@ import com.yonde.basedata.service.BaseSearchService;
import
com.yonde.basedata.vo.IdVO
;
import
com.yonde.basedata.vo.lc.LifecycleTemplateVO
;
import
com.yonde.common.ObjectsUtil
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
com.yonde.part.vo.DxUsageLinkVO
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
AbstractBaseController
{
...
...
@@ -48,6 +48,25 @@ public class AbstractBaseController {
return
null
;
}
}
@DeleteMapping
({
"/batch/{ids}"
})
// id,id2,id3 linkId
//@SubPermission({"remove"})
public
ApiResult
deleteDxPartUsageLink
(
@PathVariable
(
"ids"
)
String
ids
)
{
//this.getService().deleteAllIterationFromSameVersion(id);
try
{
List
<
String
>
idList
=
new
ArrayList
<
String
>();
if
(
ObjectsUtil
.
nonNull
(
ids
))
{
String
[]
split
=
ids
.
split
(
","
);
idList
=
Arrays
.
asList
(
split
);
}
BaseSearchService
.
delObjByIds
(
idList
,
DxUsageLinkVO
.
class
);
return
ApiResult
.
ok
((
Object
)
null
,
"删除成功"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ApiResult
.
error
(
"501"
,
"删除失败"
,
e
);
}
}
/* //@ApiOperation("配置规范查询")
@PostMapping({"findBySpec"})
List<DxPartVO> findByConfigSpec(@RequestBody SearchQueryCondition specSearch) {
...
...
src/com/yonde/basedata/search/SearchOperatorEnumUtil.java
View file @
b88b3393
...
...
@@ -6,12 +6,17 @@ import com.yonde.basedata.vo.DxVersionVO;
import
com.yonde.context.vo.DxContextVO
;
import
com.yonde.doc.vo.DxDocumentVO
;
import
com.yonde.part.vo.DxPartVO
;
import
com.yonde.part.vo.DxUsageLinkVO
;
import
com.yonde.part.vo.DxViewVO
;
import
wt.clients.beans.query.WTAttribute
;
import
wt.doc.WTDocument
;
import
wt.fc.ObjectIdentifier
;
import
wt.fc.ObjectReference
;
import
wt.part.WTPart
;
import
wt.part.WTPartMaster
;
import
wt.query.SearchCondition
;
import
wt.util.WTAttributeNameIfc
;
import
wt.vc.Iterated
;
import
wt.vc.views.ViewReference
;
import
java.util.HashMap
;
...
...
@@ -31,6 +36,8 @@ public class SearchOperatorEnumUtil {
public
static
final
String
DX_TYPE
=
"type"
;
public
static
final
String
DX_MASTER_ID
=
"masterId"
;
public
static
final
Map
<
String
,
String
>
commonSearchItemMap
=
new
HashMap
();
// 通用搜索条件
public
static
final
Map
<
String
,
String
>
partSearchItemMap
=
new
HashMap
();
// 部件搜索条件
...
...
@@ -43,12 +50,15 @@ public class SearchOperatorEnumUtil {
public
static
final
Map
<
Long
,
String
>
viewMap
=
new
HashMap
();
// 视图映射
public
static
final
Map
<
Class
<?>,
String
>
typePrefixMap
=
new
HashMap
();
// 类型映射
static
{
initSearchItemMap
();
initPartItemMap
();
initDocItemMap
();
initTypeItemMap
();
initViewMap
();
initTypePrefixMap
();
}
public
static
void
initViewMap
()
{
...
...
@@ -57,6 +67,18 @@ public class SearchOperatorEnumUtil {
viewMap
.
put
(
3L
,
"Manufacture"
);
}
public
static
void
initTypePrefixMap
()
{
typePrefixMap
.
put
(
DxPartVO
.
class
,
"wt.part.WTPart:"
);
typePrefixMap
.
put
(
DxDocumentVO
.
class
,
"wt.doc.WTDocument:"
);
typePrefixMap
.
put
(
DxUserVO
.
class
,
"wt.user.WTUser:"
);
typePrefixMap
.
put
(
DxViewVO
.
class
,
"wt.view.View:"
);
/* typePrefixMap.put(DxVersionVO.class, "com.yonde.dex.version.plugin.common.entity.DxVersionVO");
typePrefixMap.put(DxMasterVO.class, "com.yonde.dex.version.plugin.common.entity.DxMasterVO");
typePrefixMap.put(DxContextVO.class, "com.yonde.dex.context.common.vo.DxContextProjectVO");*/
typePrefixMap
.
put
(
DxUsageLinkVO
.
class
,
"wt.part.WTPartUsageLink:"
);
//TODO add
}
public
static
void
initTypeItemMap
()
{
typeItemMap
.
put
(
DxPartVO
.
class
,
"com.yonde.dcs.xbom.common.entity.vo.DxPartVO"
);
typeItemMap
.
put
(
DxDocumentVO
.
class
,
"com.yonde.dcs.document.common.entity.vo.DxDocumentVO"
);
...
...
@@ -65,7 +87,7 @@ public class SearchOperatorEnumUtil {
typeItemMap
.
put
(
DxVersionVO
.
class
,
"com.yonde.dex.version.plugin.common.entity.DxVersionVO"
);
typeItemMap
.
put
(
DxMasterVO
.
class
,
"com.yonde.dex.version.plugin.common.entity.DxMasterVO"
);
typeItemMap
.
put
(
DxContextVO
.
class
,
"com.yonde.dex.context.common.vo.DxContextProjectVO"
);
typeItemMap
.
put
(
DxUsageLinkVO
.
class
,
"com.yonde.dcs.xbom.common.entity.vo.DxUsageLinkVO"
);
//TODO add
}
...
...
@@ -76,23 +98,27 @@ public class SearchOperatorEnumUtil {
}
public
static
void
initPartItemMap
()
{
partSearchItemMap
.
put
(
DX_ID
,
WTAttributeNameIfc
.
ID_NAME
);
partSearchItemMap
.
put
(
DX_ID
,
"thePersistInfo.theObjectIdentifier.id\""
);
partSearchItemMap
.
put
(
DX_NUMBER
,
WTPart
.
NUMBER
);
partSearchItemMap
.
put
(
DX_NAME
,
WTPart
.
NAME
);
partSearchItemMap
.
put
(
DX_VIEWID
,
WTPart
.
VIEW
+
"."
+
ViewReference
.
KEY
);
+
ViewReference
.
KEY
+
"."
+
ObjectIdentifier
.
ID
);
partSearchItemMap
.
put
(
DX_STATE
,
WTPart
.
LIFE_CYCLE_STATE
);
partSearchItemMap
.
put
(
DX_MASTER_ID
,
Iterated
.
MASTER_REFERENCE
+
"."
+
ObjectReference
.
KEY
+
"."
+
ObjectIdentifier
.
ID
);
//部件类型映射
typeSearchItemMap
.
put
(
WTPart
.
class
,
partSearchItemMap
);
}
public
static
void
initDocItemMap
()
{
docSearchItemMap
.
put
(
DX_ID
,
WTAttributeNameIfc
.
ID_NAME
);
docSearchItemMap
.
put
(
DX_ID
,
"thePersistInfo.theObjectIdentifier.id"
);
docSearchItemMap
.
put
(
DX_NUMBER
,
WTDocument
.
NUMBER
);
docSearchItemMap
.
put
(
DX_NAME
,
WTDocument
.
NAME
);
docSearchItemMap
.
put
(
DX_STATE
,
WTDocument
.
LIFE_CYCLE_STATE
);
partSearchItemMap
.
put
(
DX_MASTER_ID
,
Iterated
.
MASTER_REFERENCE
+
"."
+
ObjectReference
.
KEY
+
"."
+
ObjectIdentifier
.
ID
);
//文档类型映射
typeSearchItemMap
.
put
(
WTDocument
.
class
,
docSearchItemMap
);
...
...
src/com/yonde/basedata/service/BaseSearchService.java
View file @
b88b3393
...
...
@@ -2,13 +2,16 @@ package com.yonde.basedata.service;
import
com.yonde.basedata.data.DxPageImpl
;
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.doc.vo.DxDocumentVO
;
import
com.yonde.part.service.DxPartService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.log4j.Logger
;
import
org.springframework.stereotype.Service
;
import
wt.doc.WTDocument
;
...
...
@@ -53,7 +56,25 @@ public class BaseSearchService <V extends IdVO> implements RemoteAccess {
}
logger
.
error
(
"findByConfigSpecSelect===111"
+
searchQueryCondition
.
toString
());
/*boolean enforce = SessionServerHelper.manager.setAccessEnforced(false);*/
List
<
IdVO
>
partList
=
DxSearchUtil
.
findByConfigSpecSelect
(
searchQueryCondition
);;
return
partList
;
}
public
static
boolean
delObjByIds
(
List
<
String
>
ids
,
Class
<?>
cls
)
throws
Exception
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
return
(
Boolean
)
RemoteMethodServer
.
getDefault
().
invoke
(
"delObjByIds"
,
BaseSearchService
.
class
.
getName
(),
null
,
new
Class
[]
{
List
.
class
,
Class
.
class
},
new
Object
[]
{
ids
,
cls
});
}
if
(
ids
!=
null
)
{
for
(
String
id
:
ids
)
{
String
oid
=
"OR:"
+
SearchOperatorEnumUtil
.
typePrefixMap
.
get
(
cls
)
+
id
;
WTObject
wtObjectByOid
=
RfUtil
.
getWTObjectByOid
(
oid
);
DxCommonUtils
.
delWTObj
(
wtObjectByOid
);
}
}
return
false
;
}
}
src/com/yonde/common/DxCommonUtils.java
View file @
b88b3393
...
...
@@ -4,6 +4,8 @@ import com.ptc.windchill.enterprise.templateutil.ActionValidator;
import
wt.access.AccessControlHelper
;
import
wt.access.AccessPermission
;
import
wt.doc.WTDocument
;
import
wt.fc.PersistenceServerHelper
;
import
wt.fc.WTObject
;
import
wt.lifecycle.LifeCycleHelper
;
import
wt.lifecycle.LifeCycleManaged
;
import
wt.lifecycle.State
;
...
...
@@ -125,4 +127,12 @@ public class DxCommonUtils implements RemoteAccess, Serializable {
}
return
lcm
;
}
public
static
boolean
delWTObj
(
WTObject
object
)
throws
WTException
{
if
(
ObjectsUtil
.
nonNull
(
object
))
{
PersistenceServerHelper
.
manager
.
remove
(
object
);
return
true
;
}
return
false
;
}
}
src/com/yonde/common/DxPartUtil.java
View file @
b88b3393
...
...
@@ -200,10 +200,23 @@ public class DxPartUtil implements RemoteAccess, Serializable {
WTPart
part
=
null
;
try
{
String
partSource
=
""
;
String
partAssembly
=
""
;
String
partView
=
""
;
String
number
=
dxPartVO
.
getNumber
();
String
name
=
dxPartVO
.
getName
();
if
(
number
==
null
||
number
.
equalsIgnoreCase
(
""
))
{
number
=
PartUtil
.
getDefaultPartSeqNumber
();
}
else
{
WTPart
existPart
=
PartUtil
.
getPart
(
number
,
false
);
if
(
existPart
!=
null
)
{
existPart
=
(
WTPart
)
IBAUtil
.
forceSetIBAValues
(
existPart
,
dxPartVO
.
getDynamicAttrs
());
return
existPart
;
}
}
DxViewVO
dxView
=
dxPartVO
.
getDxView
();
if
(
ObjectsUtil
.
nonNull
(
dxView
))
{
if
(
ObjectsUtil
.
isNull
(
dxView
.
getName
()))
{
...
...
@@ -212,8 +225,7 @@ public class DxPartUtil implements RemoteAccess, Serializable {
}
String
partType
=
""
;
String
partFolder
=
""
;
String
number
=
dxPartVO
.
getNumber
();
String
name
=
dxPartVO
.
getName
();
DxContextVO
dxContext
=
dxPartVO
.
getDxContext
();
WTContainer
container
=
null
;
if
(
ObjectsUtil
.
nonNull
(
dxContext
))
{
...
...
@@ -233,17 +245,6 @@ public class DxPartUtil implements RemoteAccess, Serializable {
return
null
;
}
if
(
number
==
null
||
number
.
equalsIgnoreCase
(
""
))
{
number
=
PartUtil
.
getDefaultPartSeqNumber
();
}
else
{
WTPart
existPart
=
PartUtil
.
getPart
(
number
,
false
);
if
(
existPart
!=
null
)
{
existPart
=
(
WTPart
)
IBAUtil
.
forceSetIBAValues
(
existPart
,
dxPartVO
.
getDynamicAttrs
());
return
existPart
;
}
}
if
(
name
==
null
||
name
.
equalsIgnoreCase
(
""
))
{
return
null
;
}
...
...
@@ -333,7 +334,7 @@ public class DxPartUtil implements RemoteAccess, Serializable {
part
=
(
WTPart
)
PersistenceHelper
.
manager
.
save
(
part
);
part
=
(
WTPart
)
PersistenceHelper
.
manager
.
refresh
(
part
);
part
=
(
WTPart
)
IBAUtil
.
forceSetIBAValues
(
part
,
dxPartVO
.
getDynamicAttrs
());
//
part = (WTPart) IBAUtil.forceSetIBAValues(part, dxPartVO.getDynamicAttrs());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -349,6 +350,7 @@ public class DxPartUtil implements RemoteAccess, Serializable {
public
static
WTPartUsageLink
saveWTPartUsageLink
(
DxUsageLinkVO
usageLinkVO
)
throws
Exception
{
Transaction
ts
=
null
;
WTPartUsageLink
wtPartUsageLink
=
null
;
try
{
ts
=
new
Transaction
();
ts
.
start
();
...
...
@@ -366,19 +368,16 @@ public class DxPartUtil implements RemoteAccess, Serializable {
}
else
{
child
=
getPartById
(
target
.
getId
());
}
saveWTPartUsageLink
(
parent
,
child
,
usageLinkVO
.
getAmount
(),
usageLinkVO
.
getUnit
());
wtPartUsageLink
=
saveWTPartUsageLink
(
parent
,
child
,
usageLinkVO
.
getAmount
(),
usageLinkVO
.
getUnit
());
ts
.
commit
();
ts
=
null
;
}
catch
(
Exception
e
)
{
ts
.
rollback
();
throw
new
WTException
(
"create link fail"
+
e
.
getLocalizedMessage
());
}
finally
{
if
(
ts
!=
null
)
{
ts
.
rollback
();
}
}
return
null
;
return
wtPartUsageLink
;
}
public
static
DxPartVO
updateDxUsageLink
(
DxPartVO
dxPartVO
)
throws
Exception
{
...
...
@@ -428,6 +427,9 @@ public class DxPartUtil implements RemoteAccess, Serializable {
if
(
ObjectsUtil
.
isNull
(
unit
))
{
unit
=
"ea"
;
}
if
(
ObjectsUtil
.
isNull
(
quantity
))
{
quantity
=
1
D
;
}
WTPartUsageLink
usage
=
WTPartUsageLink
.
newWTPartUsageLink
(
parent
,
(
WTPartMaster
)
part
.
getMaster
());
Quantity
quan
=
Quantity
.
newQuantity
(
quantity
,
...
...
@@ -439,4 +441,32 @@ public class DxPartUtil implements RemoteAccess, Serializable {
return
null
;
}
/**
* 根据物料和视图得到相同视图的父阶
*
* @version: 2018年8月27日
* @author Dirck
*/
public
static
ArrayList
<
WTPart
>
getParentPart
(
WTPart
part
,
String
viewN
)
{
if
(
ObjectsUtil
.
isNull
(
viewN
))
{
viewN
=
part
.
getViewName
();
}
ArrayList
<
WTPart
>
partList
=
new
ArrayList
<
WTPart
>();
WTPartMaster
master
=
(
WTPartMaster
)
part
.
getMaster
();
try
{
QueryResult
qs
=
WTPartHelper
.
service
.
getUsedByWTParts
(
master
);
while
(
qs
.
hasMoreElements
())
{
WTPart
parentPart
=
(
WTPart
)
qs
.
nextElement
();
String
viewName
=
parentPart
.
getViewName
();
if
(
viewN
.
equals
(
viewName
))
{
partList
.
add
(
parentPart
);
}
}
}
catch
(
WTException
e
)
{
e
.
printStackTrace
();
}
return
partList
;
}
}
src/com/yonde/common/DxSearchUtil.java
View file @
b88b3393
...
...
@@ -23,6 +23,7 @@ import wt.query.*;
import
wt.session.SessionServerHelper
;
import
wt.util.WTException
;
import
wt.util.WTPropertyVetoException
;
import
wt.vc.Iterated
;
import
wt.vc.views.View
;
import
wt.vc.views.ViewHelper
;
import
wt.vc.wip.WorkInProgressHelper
;
...
...
@@ -48,6 +49,7 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
logger
.
error
(
"searchCondition===111"
+
searchQueryCondition
.
toString
());
boolean
enforce
=
SessionServerHelper
.
manager
.
setAccessEnforced
(
false
);
List
partList
;
List
<
String
>
indices
=
searchQueryCondition
.
getIndices
();
try
{
SearchItems
searchItems
=
searchQueryCondition
.
getSearchItems
();
if
(
ObjectsUtil
.
isNull
(
searchItems
))
{
...
...
@@ -63,17 +65,7 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
while
(
qr
.
hasMoreElements
())
{
WTObject
o
=
(
WTObject
)
qr
.
nextElement
();
if
(
o
instanceof
WTPart
)
{
WTPart
wtPart
=
(
WTPart
)
o
;
buildQueryResult
(
o
,
partList
);
/* logger.error("WTPart===111" + wtPart.getNumber() + ":" +wtPart.isLatestIteration());
if (WorkInProgressHelper.isWorkingCopy(wtPart) || !wtPart.isLatestIteration()) {
continue;
}
System.out.println("DxPartVO===user" + wtPart.getCreator().getObject());
System.out.println("DxPartVO===user" + wtPart.getCreator().getPrincipal());
DxPartVO dxPartVO = new DxPartVO(wtPart);
logger.error("DxPartVO===111" + dxPartVO.getName());
partList.add(dxPartVO);*/
buildQueryResult
(
o
,
partList
,
indices
);
}
}
}
finally
{
...
...
@@ -93,11 +85,17 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
logger
.
error
(
"searchCondition===111"
+
searchQueryCondition
.
toString
());
boolean
enforce
=
SessionServerHelper
.
manager
.
setAccessEnforced
(
false
);
List
partList
;
List
<
String
>
indices
=
searchQueryCondition
.
getIndices
();
try
{
SearchItems
searchItems
=
searchQueryCondition
.
getSearchItems
();
if
(
ObjectsUtil
.
isNull
(
searchItems
))
{
searchItems
=
searchQueryCondition
.
getSearchVersion
().
getSearchItems
();
}
/* List<SearchItems> children = searchItems.getChildren();
for (SearchItems child : children) {
List<SearchItem> items = child.getItems();
}*/
QuerySpec
querySpec
=
DxSearchUtil
.
buildQuerySpec
(
searchItems
,
WTPart
.
class
);
/* LatestConfigSpec ls = new LatestConfigSpec();
querySpec = ls.appendSearchCriteria(querySpec);*/
...
...
@@ -107,26 +105,7 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
partList
=
new
ArrayList
<
DxPartVO
>();
while
(
qr
.
hasMoreElements
())
{
WTObject
o
=
(
WTObject
)
qr
.
nextElement
();
buildQueryResult
(
o
,
partList
);
/*if (o instanceof WTPart) {
WTPart wtPart = (WTPart) o;
logger.error("WTPart===111" + wtPart.getNumber() + ":" +wtPart.isLatestIteration());
if (WorkInProgressHelper.isWorkingCopy(wtPart) || !wtPart.isLatestIteration()) {
continue;
}
DxPartVO dxPartVO = new DxPartVO(wtPart);
logger.error("DxPartVO===111" + dxPartVO.getName());
partList.add(dxPartVO);
continue;
}
if (o instanceof WTDocument) {
WTDocument document = (WTDocument) o;
if (WorkInProgressHelper.isWorkingCopy(document) || !document.isLatestIteration()) {
continue;
}
DxDocumentVO dxPartVO = new DxDocumentVO(document);
partList.add(dxPartVO);
}*/
buildQueryResult
(
o
,
partList
,
indices
);
}
}
finally
{
SessionServerHelper
.
manager
.
setAccessEnforced
(
enforce
);
...
...
@@ -134,13 +113,20 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
return
partList
;
}
public
static
void
buildQueryResult
(
WTObject
o
,
List
partList
)
throws
Exception
{
public
static
void
buildQueryResult
(
WTObject
o
,
List
partList
,
List
<
String
>
indices
)
throws
Exception
{
if
(
o
instanceof
WTPart
)
{
WTPart
wtPart
=
(
WTPart
)
o
;
logger
.
error
(
"WTPart===111"
+
wtPart
.
getNumber
()
+
":"
+
wtPart
.
isLatestIteration
());
if
(
CollectionUtils
.
isNotEmpty
(
indices
))
{
if
(
WorkInProgressHelper
.
isWorkingCopy
(
wtPart
)
||
!
wtPart
.
isLatestIteration
())
{
return
;
}
}
else
{
if
(
WorkInProgressHelper
.
isWorkingCopy
(
wtPart
))
{
return
;
}
}
DxPartVO
dxPartVO
=
new
DxPartVO
(
wtPart
);
logger
.
error
(
"DxPartVO===111"
+
dxPartVO
.
getName
());
partList
.
add
(
dxPartVO
);
...
...
@@ -148,11 +134,19 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
}
if
(
o
instanceof
WTDocument
)
{
WTDocument
document
=
(
WTDocument
)
o
;
if
(
CollectionUtils
.
isNotEmpty
(
indices
))
{
if
(
WorkInProgressHelper
.
isWorkingCopy
(
document
)
||
!
document
.
isLatestIteration
())
{
return
;
}
}
else
{
if
(
WorkInProgressHelper
.
isWorkingCopy
(
document
))
{
return
;
}
}
DxDocumentVO
dxPartVO
=
new
DxDocumentVO
(
document
);
partList
.
add
(
dxPartVO
);
}
else
{
//TODO ...other type
}
}
...
...
@@ -180,6 +174,9 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
for
(
SearchItem
item
:
items
)
{
logger
.
error
(
"item===111"
+
item
.
toString
());
String
fieldName
=
item
.
fieldName
;
/* if (fieldName.equals("masterId")) {
return null;
}*/
if
(
fieldName
.
equals
(
"checkOuted"
)
||
fieldName
.
equals
(
SearchOperatorEnumUtil
.
DX_ID
))
{
continue
;
}
...
...
@@ -230,7 +227,7 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
* @return
*/
public
static
SearchCondition
buildScd
(
Class
<?
extends
WTObject
>
clazz
,
String
fieldName
,
String
operator
,
Object
value
)
throws
QueryException
{
SearchCondition
sc
=
null
;
SearchCondition
sc
;
if
(
ObjectsUtil
.
isNull
(
value
))
{
return
null
;
}
...
...
@@ -243,20 +240,29 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
}
sc
=
new
SearchCondition
(
clazz
,
fieldName
,
op
,
scVal
);
return
sc
;
}
if
(
value
instanceof
Long
||
fieldName
.
contains
(
Iterated
.
MASTER_REFERENCE
))
{
sc
=
new
SearchCondition
(
clazz
,
fieldName
,
op
,
Long
.
valueOf
(
String
.
valueOf
(
value
)));
return
sc
;
}
if
(
value
instanceof
Integer
)
{
sc
=
new
SearchCondition
(
clazz
,
fieldName
,
op
,
((
Integer
)
value
).
intValue
());
op
,
Integer
.
valueOf
(
String
.
valueOf
(
value
)));
return
sc
;
}
if
(
value
instanceof
Boolean
)
{
sc
=
new
SearchCondition
(
clazz
,
fieldName
,
(
Boolean
)
value
);
return
sc
;
}
if
(
value
instanceof
Timestamp
)
{
sc
=
new
SearchCondition
(
clazz
,
fieldName
,
op
,
(
Timestamp
)
value
);
return
sc
;
}
return
sc
;
return
null
;
}
public
static
void
addQuerySpecOp
(
QuerySpec
querySpec
,
SearchItems
.
BooleanOperator
operator
)
{
...
...
src/com/yonde/part/controller/DxPartController.java
View file @
b88b3393
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import
com.yonde.basedata.controller.AbstractBaseController
;
import
com.yonde.basedata.entity.api.ApiResult
;
import
com.yonde.basedata.search.BaseSearchCondition
;
import
com.yonde.common.DxPartUtil
;
import
com.yonde.common.ObjectsUtil
;
import
com.yonde.part.service.DxPartService
;
import
com.yonde.part.service.PartService
;
...
...
@@ -11,6 +12,8 @@ import com.yonde.part.vo.BOMQueryVO;
import
com.yonde.part.vo.DxPartVO
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
@RestController
...
...
@@ -163,4 +166,21 @@ public class DxPartController extends AbstractBaseController {
return
ApiResult
.
error
(
"501"
,
e
.
getLocalizedMessage
(),
e
);
}
}
//@ApiOperation("深度保存对象")
@PostMapping
({
"collectRefPart"
})
public
List
<
DxPartVO
>
collectRefPart
(
@RequestBody
Map
entity
)
{
List
<
DxPartVO
>
parentDxPart
=
new
ArrayList
<
DxPartVO
>();
try
{
Object
id
=
entity
.
get
(
"id"
);
Object
type
=
entity
.
get
(
"type"
);
if
(
"UPPER"
.
equals
(
type
))
{
parentDxPart
=
DxPartService
.
getParentDxPart
(
Long
.
valueOf
(
String
.
valueOf
(
id
)));
}
return
parentDxPart
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
parentDxPart
;
}
}
}
src/com/yonde/part/controller/DxUsageLinkController.java
View file @
b88b3393
package
com
.
yonde
.
part
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.yonde.basedata.controller.AbstractBaseController
;
import
com.yonde.basedata.entity.api.ApiResult
;
import
com.yonde.part.service.DxPartService
;
import
com.yonde.part.vo.DxPartVO
;
...
...
@@ -13,7 +14,7 @@ import java.util.Map;
@RestController
@RequestMapping
(
value
=
"/DxUsageLink"
)
public
class
DxUsageLinkController
{
public
class
DxUsageLinkController
extends
AbstractBaseController
{
//@ApiOperation("深度保存对象")
...
...
@@ -33,14 +34,14 @@ public class DxUsageLinkController {
//@ApiOperation("深度保存对象")
@PostMapping
({
"recursions"
})
public
ApiResult
recursionObj
(
@RequestBody
List
entity
)
{
public
ApiResult
recursionObj
(
@RequestBody
List
<
Object
>
entity
)
{
//return ApiResult.ok(this.getService().saveRecursion(entity));
try
{
String
jsonString
=
JSON
.
toJSONString
(
entity
);
List
entityVOList
=
JSON
.
parseObject
(
jsonString
,
List
.
class
);
List
<
DxUsageLinkVO
>
entityVOList
=
JSON
.
parseArray
(
jsonString
,
DxUsageLinkVO
.
class
);
List
<
DxUsageLinkVO
>
resultList
=
new
ArrayList
<
DxUsageLinkVO
>();
for
(
Object
o
:
entityVOList
)
{
DxUsageLinkVO
entityVO
=
DxPartService
.
createDxPartUsageLink
(
(
DxUsageLinkVO
)
o
);
for
(
DxUsageLinkVO
o
:
entityVOList
)
{
DxUsageLinkVO
entityVO
=
DxPartService
.
createDxPartUsageLink
(
o
);
resultList
.
add
(
entityVO
);
}
return
ApiResult
.
ok
(
resultList
);
...
...
@@ -50,11 +51,4 @@ public class DxUsageLinkController {
}
}
@DeleteMapping
({
"/batch/{id}"
})
// id,id2,id3 linkId
//@SubPermission({"remove"})
public
ApiResult
deleteDxPartUsageLink
(
@PathVariable
(
"id"
)
Long
id
)
{
//this.getService().deleteAllIterationFromSameVersion(id);
return
ApiResult
.
ok
((
Object
)
null
,
"删除成功"
);
}
}
src/com/yonde/part/service/DxPartService.java
View file @
b88b3393
...
...
@@ -8,6 +8,7 @@ import com.yonde.common.*;
import
com.yonde.part.vo.BOMQueryVO
;
import
com.yonde.part.vo.DxPartVO
;
import
com.yonde.part.vo.DxUsageLinkVO
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.log4j.Logger
;
import
org.springframework.stereotype.Service
;
import
wt.fc.QueryResult
;
...
...
@@ -19,9 +20,12 @@ import wt.part.WTPartHelper;
import
wt.part.WTPartUsageLink
;
import
wt.session.SessionContext
;
import
wt.session.SessionHelper
;
import
wt.util.WTException
;
import
wt.vc.VersionControlHelper
;
import
java.io.Serializable
;
import
java.lang.reflect.InvocationTargetException
;
import
java.rmi.RemoteException
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -72,6 +76,16 @@ public class DxPartService implements RemoteAccess, Serializable {
SessionHelper
.
manager
.
setAdministrator
();
dxPartVO
=
DxPartUtil
.
getDxPartVO
(
partId
);
if
(
2
==
level
)
{
List
<
DxUsageLinkVO
>
childList
=
getChildList
(
dxPartVO
,
level
);
dxPartVO
.
setSourceUsageLinks
(
childList
);
}
}
finally
{
SessionContext
.
setContext
(
previous
);
}
return
dxPartVO
;
}
public
static
List
<
DxUsageLinkVO
>
getChildList
(
DxPartVO
dxPartVO
,
int
level
)
throws
WTException
,
RemoteException
,
InvocationTargetException
{
List
<
DxUsageLinkVO
>
childList
=
new
ArrayList
<
DxUsageLinkVO
>();
WTPart
wtPart
=
dxPartVO
.
getWtPart
();
QueryResult
partMasters
=
WTPartHelper
.
service
.
getUsesWTPartMasters
(
wtPart
);
...
...
@@ -80,12 +94,7 @@ public class DxPartService implements RemoteAccess, Serializable {
DxUsageLinkVO
dxUsageLinkVO
=
new
DxUsageLinkVO
(
link
,
level
);
childList
.
add
(
dxUsageLinkVO
);
}
dxPartVO
.
setSourceUsageLinks
(
childList
);
}
}
finally
{
SessionContext
.
setContext
(
previous
);
}
return
dxPartVO
;
return
childList
;
}
/**
...
...
@@ -285,6 +294,12 @@ public class DxPartService implements RemoteAccess, Serializable {
return
dxPartVO
;
}
/**
* 创建部件link
* @param dxPartVO
* @return
* @throws Exception
*/
public
static
DxUsageLinkVO
createDxPartUsageLink
(
DxUsageLinkVO
dxPartVO
)
throws
Exception
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
return
(
DxUsageLinkVO
)
RemoteMethodServer
.
getDefault
().
invoke
(
"createDxPartUsageLink"
,
DxPartService
.
class
.
getName
(),
null
,
...
...
@@ -295,6 +310,7 @@ public class DxPartService implements RemoteAccess, Serializable {
try
{
SessionHelper
.
manager
.
setAdministrator
();
WTPartUsageLink
partLink
=
DxPartUtil
.
saveWTPartUsageLink
(
dxPartVO
);
System
.
out
.
println
(
"partLink===="
+
partLink
);
dxPartVO
=
new
DxUsageLinkVO
(
partLink
,
-
1
);
// 父-子
}
finally
{
SessionContext
.
setContext
(
previous
);
...
...
@@ -317,4 +333,36 @@ public class DxPartService implements RemoteAccess, Serializable {
}
return
dxPartVO
;
}
/**
* 获取对象
* @param id
* @return
* @throws Exception
*/
public
static
List
<
DxPartVO
>
getParentDxPart
(
Long
id
)
throws
Exception
{
if
(!
RemoteMethodServer
.
ServerFlag
)
{
return
(
List
)
RemoteMethodServer
.
getDefault
().
invoke
(
"getParentDxPart"
,
DxPartService
.
class
.
getName
(),
null
,
new
Class
[]
{
Long
.
class
},
new
Object
[]
{
id
});
}
List
<
DxPartVO
>
partVOList
=
new
ArrayList
<
DxPartVO
>();
SessionContext
previous
=
SessionContext
.
newContext
();
try
{
SessionHelper
.
manager
.
setAdministrator
();
WTPart
partById
=
DxPartUtil
.
getPartById
(
id
);
ArrayList
<
WTPart
>
parentPart
=
DxPartUtil
.
getParentPart
(
partById
,
null
);
if
(
CollectionUtils
.
isNotEmpty
(
parentPart
))
{
for
(
WTPart
wtPart
:
parentPart
)
{
DxPartVO
dxPartVO
=
new
DxPartVO
(
wtPart
);
List
<
DxUsageLinkVO
>
childList
=
getChildList
(
dxPartVO
,
2
);
dxPartVO
.
setSourceUsageLinks
(
childList
);
partVOList
.
add
(
dxPartVO
);
}
}
}
finally
{
SessionContext
.
setContext
(
previous
);
}
return
partVOList
;
}
}
src/com/yonde/part/vo/DxUsageLinkVO.java
View file @
b88b3393
package
com
.
yonde
.
part
.
vo
;
import
com.fasterxml.jackson.annotation.JsonTypeInfo
;
import
com.yonde.basedata.vo.IdVO
;
import
com.yonde.common.IBAHelper
;
import
com.yonde.common.PartUtil
;
...
...
@@ -8,12 +9,21 @@ import wt.part.Quantity;
import
wt.part.WTPart
;
import
wt.part.WTPartMaster
;
import
wt.part.WTPartUsageLink
;
import
wt.session.SessionContext
;
import
wt.session.SessionHelper
;
import
wt.util.WTException
;
import
java.io.Serializable
;
import
java.lang.reflect.InvocationTargetException
;
import
java.rmi.RemoteException
;
public
class
DxUsageLinkVO
extends
IdVO
{
@JsonTypeInfo
(
use
=
JsonTypeInfo
.
Id
.
CLASS
,
property
=
"classname"
,
visible
=
true
,
defaultImpl
=
DxUsageLinkVO
.
class
)
public
class
DxUsageLinkVO
extends
IdVO
implements
Serializable
{
//private List<DxPartSubstituteLinkVO> partSubstituteLinks;
private
DxPartVO
target
;
...
...
@@ -27,16 +37,21 @@ public class DxUsageLinkVO extends IdVO {
private
String
sourceIdType
;
//TODO
//private String dxClassname = "com.yonde.dcs.xbom.common.entity.vo.DxUsageLinkVO";
public
DxUsageLinkVO
(){
}
public
DxUsageLinkVO
(
WTPartUsageLink
usageLink
,
int
level
)
throws
WTException
,
RemoteException
,
InvocationTargetException
{
super
(
usageLink
);
SessionContext
previous
=
SessionContext
.
newContext
();
try
{
// To set the user of the session to be the administrator
SessionHelper
.
manager
.
setAdministrator
();
WTPart
parent
=
(
WTPart
)
usageLink
.
getUsedBy
();
Quantity
qt
=
usageLink
.
getQuantity
();
this
.
setAmount
(
qt
.
getAmount
());
this
.
setUnit
(
qt
.
getUnit
().
toString
());
WTPartMaster
uses
=
(
WTPartMaster
)
usageLink
.
getUses
();
WTPart
child
=
PartUtil
.
getLatestPartByNoViewWithState
(
uses
.
getNumber
(),
parent
.
getViewName
(),
null
,
false
);
this
.
setTargetId
(
PersistenceHelper
.
getObjectIdentifier
(
child
).
getId
());
this
.
setTargetId
(
PersistenceHelper
.
getObjectIdentifier
(
child
.
getMaster
()
).
getId
());
this
.
setSourceId
(
PersistenceHelper
.
getObjectIdentifier
(
parent
).
getId
());
if
(
level
>
0
)
{
this
.
setTarget
(
new
DxPartVO
(
child
));
...
...
@@ -45,6 +60,10 @@ public class DxUsageLinkVO extends IdVO {
this
.
setSource
(
new
DxPartVO
(
parent
));
}
this
.
dynamicAttrs
=
IBAHelper
.
getAllIBAValues
(
usageLink
);
}
finally
{
SessionContext
.
setContext
(
previous
);
}
}
public
DxPartVO
getTarget
()
{
...
...
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