Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kwell-mes
Project
Project
Details
Activity
Releases
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
gavelinfo
kwell-mes
Commits
74c3ce96
Commit
74c3ce96
authored
Apr 06, 2022
by
zhoumaotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oa接口调用最终版
parent
d3d7558f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
60 deletions
+67
-60
RestTemplateConfig.java
.../main/java/com/gavel/kwell/config/RestTemplateConfig.java
+0
-39
KmesBoardServiceImpl.java
...va/com/gavel/kwell/service/impl/KmesBoardServiceImpl.java
+6
-18
KemsHttpUtil.java
gavel/src/main/java/com/gavel/kwell/utils/KemsHttpUtil.java
+38
-0
KqtjVO.java
gavel/src/main/java/com/gavel/kwell/vo/KqtjVO.java
+20
-0
api.js
gavel/src/main/resources/static/js/dashboard/api.js
+3
-3
No files found.
gavel/src/main/java/com/gavel/kwell/config/RestTemplateConfig.java
deleted
100644 → 0
View file @
d3d7558f
package
com
.
gavel
.
kwell
.
config
;
import
org.apache.http.conn.HttpClientConnectionManager
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.web.client.RestTemplate
;
@Configuration
public
class
RestTemplateConfig
{
@Bean
public
HttpClientConnectionManager
poolingConnectionManager
()
{
PoolingHttpClientConnectionManager
poolingConnectionManager
=
new
PoolingHttpClientConnectionManager
();
poolingConnectionManager
.
setMaxTotal
(
1000
);
// 连接池最大连接数
poolingConnectionManager
.
setDefaultMaxPerRoute
(
500
);
// 每个主机的并发
return
poolingConnectionManager
;
}
@Bean
public
HttpClientBuilder
httpClientBuilder
()
{
HttpClientBuilder
httpClientBuilder
=
HttpClientBuilder
.
create
();
//设置HTTP连接管理器
httpClientBuilder
.
setConnectionManager
(
poolingConnectionManager
());
return
httpClientBuilder
;
}
@Bean
(
"restTemplate"
)
public
RestTemplate
restTemplate
(){
HttpComponentsClientHttpRequestFactory
httpRequestFactory
=
new
HttpComponentsClientHttpRequestFactory
();
httpRequestFactory
.
setHttpClient
(
httpClientBuilder
().
build
());
httpRequestFactory
.
setConnectionRequestTimeout
(
3000
);
//获取链接超时时间
httpRequestFactory
.
setConnectTimeout
(
3000
);
//指客户端和服务器建立连接的timeout
httpRequestFactory
.
setReadTimeout
(
120000
);
//读取数据的超时时间
RestTemplate
restTemplate
=
new
RestTemplate
(
httpRequestFactory
);
return
restTemplate
;
}
}
gavel/src/main/java/com/gavel/kwell/service/impl/KmesBoardServiceImpl.java
View file @
74c3ce96
...
...
@@ -4,25 +4,26 @@ import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
import
com.gavel.common.base.service.impl.BaseEditServiceImpl
;
import
com.gavel.common.business.service.CommonService
;
import
com.gavel.common.utils.*
;
import
com.gavel.common.utils.CollectionUtils
;
import
com.gavel.common.utils.DateUtils
;
import
com.gavel.common.utils.NumberUtils
;
import
com.gavel.common.utils.StringUtils
;
import
com.gavel.kwell.dao.GpfkcxDao
;
import
com.gavel.kwell.dao.KmesBoardDao
;
import
com.gavel.kwell.persistent.Gpfkjg
;
import
com.gavel.kwell.service.KmesBoardService
;
import
com.gavel.kwell.utils.DateCalculateUtil
;
import
com.gavel.kwell.utils.KemsHttpUtil
;
import
com.gavel.kwell.utils.KwellParamEnum
;
import
com.gavel.kwell.vo.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.client.RestTemplate
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.nio.charset.StandardCharsets
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
...
...
@@ -43,8 +44,6 @@ public class KmesBoardServiceImpl extends BaseEditServiceImpl implements KmesBoa
@Autowired
private
CommonService
commonService
;
@Autowired
private
RestTemplate
restTemplate
;
@Override
public
void
initService
(){
...
...
@@ -315,20 +314,9 @@ public class KmesBoardServiceImpl extends BaseEditServiceImpl implements KmesBoa
@Override
public
KqtjVO
queryOA
()
{
KqtjVO
kqtjVO
=
new
KqtjVO
();
String
time
=
DateUtils
.
formatDate
(
DateUtils
.
getDateTime
(),
"yyyyMMddHHmmss"
);
String
url
=
"http://oa.kewell.com.cn/api/cube/restful/interface/getModeDataPageList/mes_kqtj"
;
StringBuilder
param
=
new
StringBuilder
();
param
.
append
(
"{\"datajson\":{\"operationinfo\":{\"operator\":\"1\"},\"mainTable\":{},\"pageInfo\":{\"pageNo\":\"1\",\"pageSize\":\"10\"},"
);
param
.
append
(
"\"header\":{\"systemid\":\"oa\","
);
param
.
append
(
"\"currentDateTime\":"
).
append
(
"\""
+
time
+
"\""
).
append
(
",\"Md5\":"
).
append
(
"\""
+
MD5Utils
.
md5Hex
(
"oa"
+
"123456"
+
time
)+
"\""
).
append
(
"}}}"
);
try
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
headers
.
set
(
HttpHeaders
.
ACCEPT_CHARSET
,
StandardCharsets
.
UTF_8
.
toString
());
HttpEntity
httpEntity
=
new
HttpEntity
<>(
param
,
headers
);
ResponseEntity
<
String
>
exchange
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
httpEntity
,
String
.
class
);
String
body
=
exchange
.
getBody
();
String
body
=
KemsHttpUtil
.
postWithParamsForString
(
url
);
logger
.
info
(
"返回信息:"
+
body
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
body
);
int
ydrs
=
0
;
...
...
gavel/src/main/java/com/gavel/kwell/utils/KemsHttpUtil.java
0 → 100644
View file @
74c3ce96
package
com
.
gavel
.
kwell
.
utils
;
import
com.gavel.common.utils.DateUtils
;
import
com.gavel.common.utils.MD5Utils
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
java.io.IOException
;
public
class
KemsHttpUtil
{
public
static
String
postWithParamsForString
(
String
url
)
throws
IOException
{
String
jsonStr
=
""
;
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
String
requestBody
=
createRequestBody
();
HttpPost
httpPost
=
new
HttpPost
(
url
);
httpPost
.
setHeader
(
"Content-Type"
,
"application/x-www-form-urlencoded;charset=utf-8"
);
StringEntity
entity
=
new
StringEntity
(
requestBody
);
httpPost
.
setEntity
(
entity
);
CloseableHttpResponse
response
=
httpClient
.
execute
(
httpPost
);
jsonStr
=
EntityUtils
.
toString
(
response
.
getEntity
());
return
jsonStr
;
}
private
static
String
createRequestBody
()
{
String
time
=
DateUtils
.
formatDate
(
DateUtils
.
getDateTime
(),
"yyyyMMddHHmmss"
);
StringBuilder
param
=
new
StringBuilder
();
param
.
append
(
"datajson={\"operationinfo\":{\"operator\":\"1\"},\"mainTable\":{},\"pageInfo\":{\"pageNo\":\"1\",\"pageSize\":\"10\"},"
);
param
.
append
(
"\"header\":{\"systemid\":\"oa\","
);
param
.
append
(
"\"currentDateTime\":"
).
append
(
"\""
+
time
+
"\""
).
append
(
",\"Md5\":"
).
append
(
"\""
+
MD5Utils
.
md5Hex
(
"oa"
+
"123456"
+
time
)+
"\""
).
append
(
"}}"
);
return
param
.
toString
();
}
}
gavel/src/main/java/com/gavel/kwell/vo/KqtjVO.java
View file @
74c3ce96
...
...
@@ -9,6 +9,10 @@ public class KqtjVO extends BaseEntity {
private
Integer
sdrs
;
//实到人数
private
Integer
xjrs
;
//休假人数
private
Double
zscl
;
public
Integer
getYdrs
()
{
return
ydrs
;
}
...
...
@@ -24,4 +28,20 @@ public class KqtjVO extends BaseEntity {
public
void
setSdrs
(
Integer
sdrs
)
{
this
.
sdrs
=
sdrs
;
}
public
Integer
getXjrs
()
{
return
xjrs
;
}
public
void
setXjrs
(
Integer
xjrs
)
{
this
.
xjrs
=
xjrs
;
}
public
Double
getZscl
()
{
return
zscl
;
}
public
void
setZscl
(
Double
zscl
)
{
this
.
zscl
=
zscl
;
}
}
gavel/src/main/resources/static/js/dashboard/api.js
View file @
74c3ce96
...
...
@@ -259,9 +259,9 @@
function
apiqueryOA
(){
HTTP
.
post
(
"queryOA"
,
{},
function
(
result
)
{
if
(
result
[
'success'
])
{
let
data
=
result
.
data
.
records
||
{}
$
(
"#ydrs"
).
text
(
data
.
ydrs
||
0
)
$
(
"#sdrs"
).
text
(
data
.
y
drs
||
0
)
let
data
=
result
.
data
.
records
||
{}
;
$
(
"#ydrs"
).
text
(
data
.
ydrs
||
0
)
;
$
(
"#sdrs"
).
text
(
data
.
s
drs
||
0
)
}
else
{
console
.
log
(
"请求失败"
)
}
...
...
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