Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
topsun-bpm
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
鲁鑫
topsun-bpm
Commits
d48aa997
Commit
d48aa997
authored
Dec 27, 2023
by
wanghang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
手动请求sap
parent
c556c675
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
305 additions
and
50 deletions
+305
-50
templates.xml
.idea/mybatisx/templates.xml
+2
-2
technologyAndBom.js
.../biz/topsun/proofing/technologyAndBom/technologyAndBom.js
+39
-2
statsIndicators.js
.../webapp/biz/topsun/sap/statsIndicators/statsIndicators.js
+1
-1
statsIndicatorsList.js
...app/biz/topsun/sap/statsIndicators/statsIndicatorsList.js
+25
-3
SapStatsIndicatorsApplication.java
...Indicators/application/SapStatsIndicatorsApplication.java
+2
-0
SapStatsIndicatorsApplicationImpl.java
...s/application/impl/SapStatsIndicatorsApplicationImpl.java
+64
-41
SapStatsIndicatorsController.java
...tsIndicators/controller/SapStatsIndicatorsController.java
+11
-0
SapStatsIndicatorsResult.java
.../sap/statsIndicators/domain/SapStatsIndicatorsResult.java
+130
-0
SapStatsIndicatorsResultRepository.java
...cators/repository/SapStatsIndicatorsResultRepository.java
+13
-0
MyBaseUtil.java
topsun/src/main/java/com/huigou/topsun/util/MyBaseUtil.java
+15
-0
statsIndicators.xml
...ces/config/topsun/sap/statsIndicators/statsIndicators.xml
+3
-1
No files found.
.idea/mybatisx/templates.xml
View file @
d48aa997
...
@@ -48,8 +48,8 @@
...
@@ -48,8 +48,8 @@
<option
name=
"tableUIInfoList"
>
<option
name=
"tableUIInfoList"
>
<list>
<list>
<TableUIInfo>
<TableUIInfo>
<option
name=
"className"
value=
"SapStatsIndicators"
/>
<option
name=
"className"
value=
"SapStatsIndicators
Result
"
/>
<option
name=
"tableName"
value=
"sap_stats_indicators"
/>
<option
name=
"tableName"
value=
"sap_stats_indicators
_result
"
/>
</TableUIInfo>
</TableUIInfo>
</list>
</list>
</option>
</option>
...
...
topsun-xt/src/main/webapp/biz/topsun/proofing/technologyAndBom/technologyAndBom.js
View file @
d48aa997
//是否开启联动事件
//是否开启联动事件
var
isDetail
=
false
;
var
isDetail
=
false
,
isComplete
=
null
;
//定义生成表格的参数对象
//定义生成表格的参数对象
var
bomObj
=
{
var
bomObj
=
{
parms
:{},
parms
:{},
...
@@ -123,6 +123,7 @@ var processBomObj={
...
@@ -123,6 +123,7 @@ var processBomObj={
//创建表格(参数、列、插入的节点、请求地址)
//创建表格(参数、列、插入的节点、请求地址)
function
loadProofingApplyGrid
(
obj
)
{
function
loadProofingApplyGrid
(
obj
)
{
isComplete
=
false
;
var
toolbarOptions
=
UICtrl
.
getDefaultToolbarOptions
({
var
toolbarOptions
=
UICtrl
.
getDefaultToolbarOptions
({
addHandler
:
function
()
{
addHandler
:
function
()
{
UICtrl
.
addGridRow
(
obj
.
gridManager
);
UICtrl
.
addGridRow
(
obj
.
gridManager
);
...
@@ -147,6 +148,13 @@ function loadProofingApplyGrid(obj) {
...
@@ -147,6 +148,13 @@ function loadProofingApplyGrid(obj) {
checkbox
:
true
,
checkbox
:
true
,
fixedCellHeight
:
true
,
fixedCellHeight
:
true
,
selectRowButtonOnly
:
true
,
selectRowButtonOnly
:
true
,
onAfterShowData
:
function
(
data
)
{
debugger
console
.
log
(
obj
.
gridManager
)
console
.
log
(
data
)
console
.
log
(
"1执行了"
)
// 确保 onAfterShowData 执行完成后才执行的代码
}
});
});
UICtrl
.
setSearchAreaToggle
(
obj
.
gridManager
);
UICtrl
.
setSearchAreaToggle
(
obj
.
gridManager
);
return
obj
;
return
obj
;
...
@@ -154,6 +162,15 @@ function loadProofingApplyGrid(obj) {
...
@@ -154,6 +162,15 @@ function loadProofingApplyGrid(obj) {
}
}
function
a
(){
b
()
//必须这个函数执行完,才可以执行下方的函数
c
()
}
function
b
(){
//这个函数是异步的
}
function
c
(){
}
/**
/**
* 详情页初始化调用
* 详情页初始化调用
* 获取申请或制造单的工艺工序等数据生成表格
* 获取申请或制造单的工艺工序等数据生成表格
...
@@ -204,25 +221,42 @@ function showTechnologyTable(productId){
...
@@ -204,25 +221,42 @@ function showTechnologyTable(productId){
if
(
technologyObj
.
gridManager
!=
null
){
if
(
technologyObj
.
gridManager
!=
null
){
technologyObj
.
parms
=
{
productId
:
productId
}
technologyObj
.
parms
=
{
productId
:
productId
}
reloadGrid
(
technologyObj
);
reloadGrid
(
technologyObj
);
let
result
=
DataUtil
.
getUpdateRow
(
technologyObj
.
gridManager
);
// 获取选中行
processObj
.
parms
=
{
technologyId
:
result
.
technologyId
};
processBomObj
.
parms
=
{
technologyId
:
result
.
technologyId
};
reloadGrid
(
processObj
);
reloadGrid
(
processObj
);
//产品编号每次发生变动后删除残留的工序数据
//产品编号每次发生变动后删除残留的工序数据
if
(
processObj
.
gridManager
!=
null
){
if
(
processObj
.
gridManager
!=
null
){
processObj
.
parms
=
{
technologyId
:
-
1
};
//手动切换gridManager
processObj
.
parms
=
{
technologyId
:
-
1
};
//手动切换gridManager
reloadGrid
(
processObj
);
reloadGrid
(
processObj
);
}
}
if
(
processBomObj
.
gridManager
!=
null
){
if
(
processBomObj
.
gridManager
!=
null
){
processBomObj
.
parms
=
{
a
:
-
1
};
//手动切换gridManager
processBomObj
.
parms
=
{
a
:
-
1
};
//手动切换gridManager
reloadGrid
(
processBomObj
);
reloadGrid
(
processBomObj
);
}
}
}
else
{
}
else
{
technologyObj
.
parms
=
{
productId
:
productId
};
technologyObj
.
parms
=
{
productId
:
productId
};
loadProofingApplyGrid
(
technologyObj
);
loadProofingApplyGrid
(
technologyObj
);
debugger
let
result
=
DataUtil
.
getUpdateRow
(
technologyObj
.
gridManager
);
// 获取选中行
processObj
.
parms
=
{
technologyId
:
result
.
technologyId
};
processBomObj
.
parms
=
{
technologyId
:
result
.
technologyId
};
loadProofingApplyGrid
(
processObj
);
loadProofingApplyGrid
(
processBomObj
);
}
}
}
}
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
// switchGridManager();
// switchGridManager();
technologyClickRequestProcess
();
//
technologyClickRequestProcess();
UICtrl
.
layout
(
"#layout"
,{
UICtrl
.
layout
(
"#layout"
,{
leftWidth
:
2
,
leftWidth
:
2
,
rightWidth
:
4
,
rightWidth
:
4
,
...
@@ -242,6 +276,8 @@ function reloadGrid(obj) {
...
@@ -242,6 +276,8 @@ function reloadGrid(obj) {
}
}
/**
/**
* 根据选定的technology列获取对应的process
* 根据选定的technology列获取对应的process
* 冒泡机制永远都会先执行此点击事件,需要让平台内置事件先执行来获取行id
* 冒泡机制永远都会先执行此点击事件,需要让平台内置事件先执行来获取行id
...
@@ -250,6 +286,7 @@ function technologyClickRequestProcess(){
...
@@ -250,6 +286,7 @@ function technologyClickRequestProcess(){
$
(
document
).
on
(
'click'
,
'#technology .l-grid-row'
,
function
(
event
)
{
$
(
document
).
on
(
'click'
,
'#technology .l-grid-row'
,
function
(
event
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
if
(
isDetail
)
return
;
if
(
isDetail
)
return
;
debugger
let
result
=
DataUtil
.
getUpdateRow
(
technologyObj
.
gridManager
);
// 获取选中行
let
result
=
DataUtil
.
getUpdateRow
(
technologyObj
.
gridManager
);
// 获取选中行
processObj
.
parms
=
{
technologyId
:
result
.
technologyId
};
processObj
.
parms
=
{
technologyId
:
result
.
technologyId
};
processBomObj
.
parms
=
{
technologyId
:
result
.
technologyId
};
processBomObj
.
parms
=
{
technologyId
:
result
.
technologyId
};
...
...
topsun-xt/src/main/webapp/biz/topsun/sap/statsIndicators/statsIndicators.js
View file @
d48aa997
...
@@ -18,7 +18,7 @@ function loadStatsIndicatorsDetailListGrid() {
...
@@ -18,7 +18,7 @@ function loadStatsIndicatorsDetailListGrid() {
},
},
deleteHandler
:
function
()
{
deleteHandler
:
function
()
{
var
_grid
=
UICtrl
.
getGridManager
(
'#statsIndicatorsDetailGrid'
);
var
_grid
=
UICtrl
.
getGridManager
(
'#statsIndicatorsDetailGrid'
);
_grid
.
deleteSelectedRow
();
//删除
选定
节点
_grid
.
deleteSelectedRow
();
//删除
fieldCol="2"
节点
}
}
});
});
gridManager
=
UICtrl
.
grid
(
"#statsIndicatorsDetailGrid"
,
{
gridManager
=
UICtrl
.
grid
(
"#statsIndicatorsDetailGrid"
,
{
...
...
topsun-xt/src/main/webapp/biz/topsun/sap/statsIndicators/statsIndicatorsList.js
View file @
d48aa997
var
gridManager
=
null
;
var
gridManager
=
null
;
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
initializateUI
();
initializateUI
();
loadStatsIndicatorsListGridGrid
();
loadStatsIndicatorsListGridGrid
();
});
})
function
initializateUI
()
{
function
initializateUI
()
{
UICtrl
.
layout
(
"#layout"
,
{
leftWidth
:
3
});
UICtrl
.
layout
(
"#layout"
,
{
leftWidth
:
3
});
}
}
...
@@ -20,11 +19,13 @@ function loadStatsIndicatorsListGridGrid() {
...
@@ -20,11 +19,13 @@ function loadStatsIndicatorsListGridGrid() {
});
});
gridManager
=
UICtrl
.
grid
(
"#statsIndicatorsListGrid"
,
{
gridManager
=
UICtrl
.
grid
(
"#statsIndicatorsListGrid"
,
{
columns
:
[
columns
:
[
{
display
:
"导入sap"
,
name
:
"btns"
,
width
:
60
,
minWidth
:
60
,
type
:
"string"
,
align
:
"left"
},
{
display
:
"成本控制范围"
,
name
:
"kokrs"
,
width
:
120
,
minWidth
:
60
,
type
:
"string"
,
align
:
"left"
},
{
display
:
"成本控制范围"
,
name
:
"kokrs"
,
width
:
120
,
minWidth
:
60
,
type
:
"string"
,
align
:
"left"
},
{
display
:
"凭证日期"
,
name
:
"bldat"
,
width
:
120
,
minWidth
:
60
,
type
:
"string"
,
align
:
"left"
},
{
display
:
"凭证日期"
,
name
:
"bldat"
,
width
:
120
,
minWidth
:
60
,
type
:
"string"
,
align
:
"left"
},
{
display
:
"过账日期"
,
name
:
"budat"
,
width
:
120
,
minWidth
:
60
,
type
:
"string"
,
align
:
"left"
},
{
display
:
"过账日期"
,
name
:
"budat"
,
width
:
120
,
minWidth
:
60
,
type
:
"string"
,
align
:
"left"
},
{
display
:
"凭证文本"
,
name
:
"bltxt"
,
width
:
140
,
minWidth
:
60
,
type
:
"string"
,
align
:
"left"
},
{
display
:
"凭证文本"
,
name
:
"bltxt"
,
width
:
140
,
minWidth
:
60
,
type
:
"string"
,
align
:
"left"
},
{
display
:
"SAP用户名"
,
name
:
"usnam"
,
width
:
140
,
minWidth
:
60
,
type
:
"string"
,
align
:
"left"
},
{
display
:
"SAP用户名"
,
name
:
"usnam"
,
width
:
140
,
minWidth
:
60
,
type
:
"string"
,
align
:
"left"
},
],
],
dataAction
:
"server"
,
dataAction
:
"server"
,
url
:
web_app
.
name
+
'/sapStatsIndicators/slicedStatsIndicatorsList.ajax'
,
url
:
web_app
.
name
+
'/sapStatsIndicators/slicedStatsIndicatorsList.ajax'
,
...
@@ -39,6 +40,21 @@ function loadStatsIndicatorsListGridGrid() {
...
@@ -39,6 +40,21 @@ function loadStatsIndicatorsListGridGrid() {
selectRowButtonOnly
:
true
,
selectRowButtonOnly
:
true
,
onDblClickRow
:
function
(
data
,
rowindex
,
rowobj
)
{
onDblClickRow
:
function
(
data
,
rowindex
,
rowobj
)
{
doView
(
data
.
id
);
doView
(
data
.
id
);
},
onAfterShowData
:
function
(){
let
obj
=
gridManager
.
records
;
Object
.
keys
(
obj
).
forEach
(
function
(
key
)
{
let
node
=
null
;
console
.
log
(
obj
[
key
]);
if
(
obj
[
key
].
status
!==
3
){
node
=
"<div>待审批</div>"
;
}
else
if
(
obj
[
key
].
type
!==
"S"
){
node
=
`<button onclick="sendSapData('
${
obj
[
key
].
id
}
')" class="btn btn-success" type="button">send</button>`
;
}
else
{
node
=
"<div>成功</div>"
;
}
$
(
"tr[id*='"
+
key
+
"'] .btns"
).
replaceWith
(
node
);
});
}
}
});
});
UICtrl
.
setSearchAreaToggle
(
gridManager
);
UICtrl
.
setSearchAreaToggle
(
gridManager
);
...
@@ -91,4 +107,10 @@ function doView(id) {
...
@@ -91,4 +107,10 @@ function doView(id) {
text
:
"统计指标详情"
,
text
:
"统计指标详情"
,
url
:
web_app
.
name
+
'/sapStatsIndicators/showStatsIndicators.job?bizId='
+
id
+
"&isDetailPage=true"
url
:
web_app
.
name
+
'/sapStatsIndicators/showStatsIndicators.job?bizId='
+
id
+
"&isDetailPage=true"
});
});
}
function
sendSapData
(
bizId
){
Public
.
ajax
(
web_app
.
name
+
'/sapStatsIndicators/againSendSapDate.ajax'
,{
bizId
:
bizId
},
function
(
data
){
reloadGrid
();
})
}
}
\ No newline at end of file
topsun/src/main/java/com/huigou/topsun/sap/statsIndicators/application/SapStatsIndicatorsApplication.java
View file @
d48aa997
...
@@ -22,4 +22,6 @@ public interface SapStatsIndicatorsApplication {
...
@@ -22,4 +22,6 @@ public interface SapStatsIndicatorsApplication {
void
deleteStatsIndicatorsById
(
String
id
);
void
deleteStatsIndicatorsById
(
String
id
);
void
deleteStatsIndicatorsByIds
(
List
<
String
>
ids
);
void
deleteStatsIndicatorsByIds
(
List
<
String
>
ids
);
void
sendSapDate
(
String
bizId
);
}
}
\ No newline at end of file
topsun/src/main/java/com/huigou/topsun/sap/statsIndicators/application/impl/SapStatsIndicatorsApplicationImpl.java
View file @
d48aa997
...
@@ -11,16 +11,19 @@ import com.huigou.topsun.sap.common.serializer.MessageCodec;
...
@@ -11,16 +11,19 @@ import com.huigou.topsun.sap.common.serializer.MessageCodec;
import
com.huigou.topsun.sap.statsIndicators.application.SapStatsIndicatorsApplication
;
import
com.huigou.topsun.sap.statsIndicators.application.SapStatsIndicatorsApplication
;
import
com.huigou.topsun.sap.statsIndicators.domain.SapStatsIndicators
;
import
com.huigou.topsun.sap.statsIndicators.domain.SapStatsIndicators
;
import
com.huigou.topsun.sap.statsIndicators.domain.SapStatsIndicatorsDetail
;
import
com.huigou.topsun.sap.statsIndicators.domain.SapStatsIndicatorsDetail
;
import
com.huigou.topsun.sap.statsIndicators.domain.SapStatsIndicatorsResult
;
import
com.huigou.topsun.sap.statsIndicators.domain.query.SapStatsIndicatorsDetailQueryRequest
;
import
com.huigou.topsun.sap.statsIndicators.domain.query.SapStatsIndicatorsDetailQueryRequest
;
import
com.huigou.topsun.sap.statsIndicators.domain.query.SapStatsIndicatorsQueryRequest
;
import
com.huigou.topsun.sap.statsIndicators.domain.query.SapStatsIndicatorsQueryRequest
;
import
com.huigou.topsun.sap.statsIndicators.repository.SapStatsIndicatorsDetailRepository
;
import
com.huigou.topsun.sap.statsIndicators.repository.SapStatsIndicatorsDetailRepository
;
import
com.huigou.topsun.sap.statsIndicators.repository.SapStatsIndicatorsRepository
;
import
com.huigou.topsun.sap.statsIndicators.repository.SapStatsIndicatorsRepository
;
import
com.huigou.topsun.sap.statsIndicators.repository.SapStatsIndicatorsResultRepository
;
import
com.huigou.topsun.util.MyBaseUtil
;
import
com.huigou.topsun.util.MyBaseUtil
;
import
com.huigou.uasp.bmp.common.BizBillStatus
;
import
com.huigou.uasp.bmp.common.BizBillStatus
;
import
com.huigou.uasp.bpm.FlowBroker
;
import
com.huigou.uasp.bpm.FlowBroker
;
import
com.huigou.util.ClassHelper
;
import
com.huigou.util.ClassHelper
;
import
com.huigou.util.SDO
;
import
com.huigou.util.SDO
;
import
com.mchange.v1.util.MapUtils
;
import
lombok.SneakyThrows
;
import
lombok.SneakyThrows
;
import
org.activiti.engine.delegate.DelegateExecution
;
import
org.activiti.engine.delegate.DelegateExecution
;
import
org.activiti.engine.delegate.DelegateTask
;
import
org.activiti.engine.delegate.DelegateTask
;
...
@@ -40,20 +43,26 @@ import java.util.ArrayList;
...
@@ -40,20 +43,26 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
@Service
(
"sapStatsIndicatorsApplication"
)
@Service
(
"sapStatsIndicatorsApplication"
)
public
class
SapStatsIndicatorsApplicationImpl
extends
FlowBroker
implements
SapStatsIndicatorsApplication
{
public
class
SapStatsIndicatorsApplicationImpl
extends
FlowBroker
implements
SapStatsIndicatorsApplication
{
@Autowired
@Autowired
private
SapStatsIndicatorsRepository
sapStatsIndicatorsRepository
;
private
SapStatsIndicatorsRepository
sapStatsIndicatorsRepository
;
@Autowired
@Autowired
private
SapStatsIndicatorsDetailRepository
sapStatsIndicatorsDetailRepository
;
private
SapStatsIndicatorsDetailRepository
sapStatsIndicatorsDetailRepository
;
@Autowired
private
SapStatsIndicatorsResultRepository
sapStatsIndicatorsResultRepository
;
@Autowired
@Autowired
DefaultHttpClient
defaultHttpClient
;
DefaultHttpClient
defaultHttpClient
;
@Autowired
@Autowired
MessageCodec
messageCodec
;
MessageCodec
messageCodec
;
@SneakyThrows
@SneakyThrows
@Transactional
(
propagation
=
Propagation
.
REQUIRES_NEW
)
@Transactional
(
propagation
=
Propagation
.
REQUIRES_NEW
)
@Override
@Override
...
@@ -71,7 +80,8 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
...
@@ -71,7 +80,8 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
SDO
sdo
=
this
.
getBizAndApprovalData
();
SDO
sdo
=
this
.
getBizAndApprovalData
();
String
statsIndicatorsDetailJSON
=
sdo
.
getString
(
"statsIndicatorsDetail"
);
String
statsIndicatorsDetailJSON
=
sdo
.
getString
(
"statsIndicatorsDetail"
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
List
<
SapStatsIndicatorsDetail
>
statsIndicatorsDetailList
=
objectMapper
.
readValue
(
statsIndicatorsDetailJSON
,
new
TypeReference
<
List
<
SapStatsIndicatorsDetail
>>()
{});
List
<
SapStatsIndicatorsDetail
>
statsIndicatorsDetailList
=
objectMapper
.
readValue
(
statsIndicatorsDetailJSON
,
new
TypeReference
<
List
<
SapStatsIndicatorsDetail
>>()
{
});
List
<
SapStatsIndicatorsDetail
>
allStatsIndicatorsDetail
=
sapStatsIndicatorsDetailRepository
.
findAllByStatsIndicatorsId
(
sapStatsIndicators
.
getId
());
List
<
SapStatsIndicatorsDetail
>
allStatsIndicatorsDetail
=
sapStatsIndicatorsDetailRepository
.
findAllByStatsIndicatorsId
(
sapStatsIndicators
.
getId
());
if
(!
allStatsIndicatorsDetail
.
isEmpty
())
{
if
(!
allStatsIndicatorsDetail
.
isEmpty
())
{
...
@@ -95,6 +105,7 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
...
@@ -95,6 +105,7 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
/**
/**
* 流程实例结束
* 流程实例结束
*
* @param delegateExecution
* @param delegateExecution
*/
*/
@Override
@Override
...
@@ -105,45 +116,11 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
...
@@ -105,45 +116,11 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
SapStatsIndicators
sapStatsIndicators
=
sapStatsIndicatorsRepository
.
findOne
(
bizId
);
SapStatsIndicators
sapStatsIndicators
=
sapStatsIndicatorsRepository
.
findOne
(
bizId
);
sapStatsIndicators
.
setStatusId
(
status
.
getId
());
sapStatsIndicators
.
setStatusId
(
status
.
getId
());
sapStatsIndicatorsRepository
.
save
(
sapStatsIndicators
);
sapStatsIndicatorsRepository
.
save
(
sapStatsIndicators
);
//审核完成、远程调用sap接口
//审核完成、远程调用sap接口
// 延迟3秒后异步执行sendSapDate方法
List
<
SapStatsIndicatorsDetail
>
all
=
sapStatsIndicatorsDetailRepository
.
findAllByStatsIndicatorsId
(
bizId
);
ScheduledExecutorService
executor
=
Executors
.
newSingleThreadScheduledExecutor
();
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
executor
.
schedule
(()
->
sendSapDate
(
bizId
),
3
,
TimeUnit
.
SECONDS
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
executor
.
shutdown
();
// 任务执行完毕后关闭executor
Map
<
String
,
Object
>
map
=
MyBaseUtil
.
convertToMap
(
sapStatsIndicators
);
//封装参数
for
(
SapStatsIndicatorsDetail
sapStatsIndicatorsDetail
:
all
)
{
Map
<
String
,
Object
>
detailMap
=
objectMapper
.
convertValue
(
sapStatsIndicatorsDetail
,
Map
.
class
);
map
.
put
(
"item"
,
detailMap
);
list
.
add
(
map
);
}
//三次失败抛出异常
int
retries
=
0
;
boolean
success
=
false
;
String
url
=
"http://192.168.3.109:8000/sap/bc/erp_ep/cud_kb31n/kb31n?sap-client=200"
;
while
(!
success
&&
retries
<
3
)
{
try
{
String
execute
=
defaultHttpClient
.
execute
(
list
,
url
);
TypeReference
<
List
<
Map
<
String
,
Object
>>>
typeRef
=
new
TypeReference
<
List
<
Map
<
String
,
Object
>>>()
{};
List
<
Map
<
String
,
Object
>>
mapList
=
objectMapper
.
readValue
(
execute
,
typeRef
);
Map
<
String
,
Object
>
resMap
=
mapList
.
get
(
0
);
//Message message = messageCodec.deserialze(execute);
//Map<String, Object> body = message.getBody();
if
(
"s"
.
equals
(
resMap
.
get
(
"TYPE"
)))
{
success
=
true
;
}
else
{
retries
++;
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"sap服务器无响应请稍后再试!"
);
}
}
if
(!
success
)
{
throw
new
RuntimeException
(
"远程调用SAP接口失败"
);
}
}
}
@Override
@Override
...
@@ -178,7 +155,7 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
...
@@ -178,7 +155,7 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
@Override
@Override
public
Map
<
String
,
Object
>
slicedStatsIndicatorsQuery
(
SapStatsIndicatorsQueryRequest
query
)
{
public
Map
<
String
,
Object
>
slicedStatsIndicatorsQuery
(
SapStatsIndicatorsQueryRequest
query
)
{
QueryDescriptor
queryDescriptor
=
this
.
sqlExecutorDao
.
getQuery
(
QUERY_XML_FILE_PATH
,
"slicedStatsIndicatorsQuery"
);
QueryDescriptor
queryDescriptor
=
this
.
sqlExecutorDao
.
getQuery
(
QUERY_XML_FILE_PATH
,
"slicedStatsIndicatorsQuery"
);
return
this
.
sqlExecutorDao
.
executeSlicedQuery
(
queryDescriptor
,
query
);
return
this
.
sqlExecutorDao
.
executeSlicedQuery
(
queryDescriptor
,
query
);
}
}
...
@@ -198,4 +175,50 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
...
@@ -198,4 +175,50 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
}
}
/**
* 远程调用sap接口,传递数据
*
* @param bizId
*/
public
void
sendSapDate
(
String
bizId
)
{
SapStatsIndicators
sapStatsIndicators
=
sapStatsIndicatorsRepository
.
findOne
(
bizId
);
if
(
sapStatsIndicators
.
getStatusId
()
==
BizBillStatus
.
APPLYING
.
getId
())
{
throw
new
RuntimeException
(
"本数据未经审批完成!"
);
}
List
<
SapStatsIndicatorsDetail
>
all
=
sapStatsIndicatorsDetailRepository
.
findAllByStatsIndicatorsId
(
bizId
);
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
Map
<
String
,
Object
>
map
=
MyBaseUtil
.
convertToMap
(
sapStatsIndicators
);
//封装参数
for
(
SapStatsIndicatorsDetail
sapStatsIndicatorsDetail
:
all
)
{
Map
<
String
,
Object
>
detailMap
=
objectMapper
.
convertValue
(
sapStatsIndicatorsDetail
,
Map
.
class
);
map
.
put
(
"ITEM"
,
detailMap
);
list
.
add
(
map
);
}
String
url
=
"cud_kb31n/kb31n"
;
SapStatsIndicatorsResult
sapStatsIndicatorsResult
=
null
;
try
{
String
result
=
defaultHttpClient
.
execute
(
list
,
url
);
List
<
SapStatsIndicatorsResult
>
resultList
=
objectMapper
.
readValue
(
result
,
new
TypeReference
<
List
<
SapStatsIndicatorsResult
>>()
{
});
sapStatsIndicatorsResult
=
resultList
.
get
(
0
);
if
(!
"s"
.
equals
(
sapStatsIndicatorsResult
.
getType
()))
{
throw
new
RuntimeException
(
"数据传输失败,请稍后手动重试!"
);
}
}
catch
(
IOException
e
)
{
if
(
sapStatsIndicatorsResult
==
null
)
{
sapStatsIndicatorsResult
=
new
SapStatsIndicatorsResult
();
}
sapStatsIndicatorsResult
.
setType
(
"A"
);
throw
new
RuntimeException
(
"sap服务器无响应请稍后手动重试!"
);
}
finally
{
SapStatsIndicatorsResult
statsIndicatorsId
=
sapStatsIndicatorsResultRepository
.
findByStatsIndicatorsId
(
bizId
);
if
(
statsIndicatorsId
!=
null
)
sapStatsIndicatorsResultRepository
.
delete
(
statsIndicatorsId
);
sapStatsIndicatorsResult
.
setStatsIndicatorsId
(
bizId
);
sapStatsIndicatorsResultRepository
.
save
(
sapStatsIndicatorsResult
);
}
}
}
}
\ No newline at end of file
topsun/src/main/java/com/huigou/topsun/sap/statsIndicators/controller/SapStatsIndicatorsController.java
View file @
d48aa997
...
@@ -88,4 +88,15 @@ public class SapStatsIndicatorsController extends CommonController {
...
@@ -88,4 +88,15 @@ public class SapStatsIndicatorsController extends CommonController {
sapStatsIndicatorsApplication
.
deleteStatsIndicatorsByIds
(
ids
);
sapStatsIndicatorsApplication
.
deleteStatsIndicatorsByIds
(
ids
);
return
success
();
return
success
();
}
}
/**
* 手动发送数据到sap
* @return
*/
public
String
againSendSapDate
(){
SDO
sdo
=
this
.
getSDO
();
String
id
=
sdo
.
getBizId
();
sapStatsIndicatorsApplication
.
sendSapDate
(
id
);
return
success
();
}
}
}
\ No newline at end of file
topsun/src/main/java/com/huigou/topsun/sap/statsIndicators/domain/SapStatsIndicatorsResult.java
0 → 100644
View file @
d48aa997
package
com
.
huigou
.
topsun
.
sap
.
statsIndicators
.
domain
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Data
;
import
org.hibernate.annotations.GenericGenerator
;
import
javax.persistence.*
;
import
java.io.Serializable
;
/**
*
* @TableName sap_stats_indicators_result
*/
@Table
(
name
=
"sap_stats_indicators_result"
)
@Entity
@Data
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
SapStatsIndicatorsResult
implements
Serializable
{
/**
* 回执信息id
*/
@Id
@GeneratedValue
(
generator
=
"system-uuid"
)
@GenericGenerator
(
name
=
"system-uuid"
,
strategy
=
"guid"
)
@Column
(
name
=
"stats_indicators_result_id"
)
private
String
statsIndicatorsResultId
;
/**
* 主表id
*/
@Column
(
name
=
"stats_indicators_id"
)
private
String
statsIndicatorsId
;
/**
* 消息类型
*/
@Column
(
name
=
"TYPE"
)
private
String
type
;
/**
* 消息类
*/
@Column
(
name
=
"ID"
)
private
String
id
;
/**
* 消息编号
*/
@Column
(
name
=
"NUMBER"
)
private
Integer
number
;
/**
* 消息文本
*/
@Column
(
name
=
"MESSAGE"
)
private
String
message
;
/**
* 应用程序日志:日志编号
*/
@Column
(
name
=
"LOG_NO"
)
private
String
logNo
;
/**
* 应用程序日志:内部消息序列号
*/
@Column
(
name
=
"LOG_MSG_NO"
)
private
Integer
logMsgNo
;
/**
* 消息变量
*/
@Column
(
name
=
"MESSAGE_V1"
)
private
String
messageV1
;
/**
* 消息变量
*/
@Column
(
name
=
"MESSAGE_V2"
)
private
String
messageV2
;
/**
* 消息变量
*/
@Column
(
name
=
"MESSAGE_V3"
)
private
String
messageV3
;
/**
* 消息变量
*/
@Column
(
name
=
"MESSAGE_V4"
)
private
String
messageV4
;
/**
* 参数名称
*/
@Column
(
name
=
"PARAMETER"
)
private
String
parameter
;
/**
* 参数中的行
*/
@Column
(
name
=
"`ROW`"
)
private
Integer
row
;
/**
* 参数中的字段
*/
@Column
(
name
=
"FIELD"
)
private
String
field
;
/**
* 引发消息的逻辑系统
*/
@Column
(
name
=
"`SYSTEM`"
)
private
String
system
;
/**
* 凭证编号
*/
@Column
(
name
=
"BELNR"
)
private
String
belnr
;
private
static
final
long
serialVersionUID
=
1L
;
}
\ No newline at end of file
topsun/src/main/java/com/huigou/topsun/sap/statsIndicators/repository/SapStatsIndicatorsResultRepository.java
0 → 100644
View file @
d48aa997
package
com
.
huigou
.
topsun
.
sap
.
statsIndicators
.
repository
;
import
com.huigou.topsun.sap.statsIndicators.domain.SapStatsIndicatorsDetail
;
import
com.huigou.topsun.sap.statsIndicators.domain.SapStatsIndicatorsResult
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
SapStatsIndicatorsResultRepository
extends
JpaRepository
<
SapStatsIndicatorsResult
,
String
>
{
SapStatsIndicatorsResult
findByStatsIndicatorsId
(
String
statsIndicatorsId
);
}
topsun/src/main/java/com/huigou/topsun/util/MyBaseUtil.java
View file @
d48aa997
...
@@ -147,6 +147,21 @@ public class MyBaseUtil {
...
@@ -147,6 +147,21 @@ public class MyBaseUtil {
return
map
;
return
map
;
}
}
/**
* 将输入Map中的所有key转换为大写
*
* @param inputMap 输入的Map,包含要转换的key和对应的值
* @return 转换后的Map,其中所有的key都被转换为大写
*/
public
Map
<
String
,
Object
>
convertMapKeysToUpperCase
(
Map
<
String
,
Object
>
inputMap
)
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
inputMap
.
entrySet
())
{
String
key
=
entry
.
getKey
().
toUpperCase
();
resultMap
.
put
(
key
,
entry
.
getValue
());
}
return
resultMap
;
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
topsun/src/main/resources/config/topsun/sap/statsIndicators/statsIndicators.xml
View file @
d48aa997
...
@@ -10,7 +10,9 @@
...
@@ -10,7 +10,9 @@
<query
name=
"slicedStatsIndicatorsQuery"
table=
"sap_stats_indicators"
>
<query
name=
"slicedStatsIndicatorsQuery"
table=
"sap_stats_indicators"
>
<sql-query>
<sql-query>
select t.* from sap_stats_indicators t
select t.*,sr.TYPE,sr.ID as srId,sr.NUMBER,sr.MESSAGE,sr.LOG_NO,sr.LOG_MSG_NO,sr.MESSAGE_V1,sr.MESSAGE_V2,
sr.MESSAGE_V3,sr.MESSAGE_V4,sr.`ROW`,sr.FIELD,sr.`SYSTEM`,sr.BELNR
from sap_stats_indicators t left join sap_stats_indicators_result sr on(t.id=sr.stats_indicators_id)
where 1=1
where 1=1
</sql-query>
</sql-query>
<condition
column=
"id"
name=
"id"
type=
"java.lang.String"
symbol=
"="
alias=
"t"
/>
<condition
column=
"id"
name=
"id"
type=
"java.lang.String"
symbol=
"="
alias=
"t"
/>
...
...
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