Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gf_back
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tianchao
gf_back
Commits
9cae20b3
Commit
9cae20b3
authored
Mar 18, 2024
by
ZWT
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nocommit
parent
a525e8f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
19 deletions
+45
-19
C12-prediction/pps-core-prediction/src/main/java/pps/core/prediction/service/WellheadDailyProductionSituationService.java
...tion/service/WellheadDailyProductionSituationService.java
+45
-19
No files found.
C12-prediction/pps-core-prediction/src/main/java/pps/core/prediction/service/WellheadDailyProductionSituationService.java
View file @
9cae20b3
package
pps.core.prediction.service
;
package
pps.core.prediction.service
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
...
@@ -28,7 +29,6 @@ import xstartup.feature.api.annotation.XApiAnonymous;
...
@@ -28,7 +29,6 @@ import xstartup.feature.api.annotation.XApiAnonymous;
import
xstartup.feature.api.annotation.XApiGet
;
import
xstartup.feature.api.annotation.XApiGet
;
import
xstartup.feature.api.annotation.XApiPost
;
import
xstartup.feature.api.annotation.XApiPost
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -78,7 +78,7 @@ public class WellheadDailyProductionSituationService {
...
@@ -78,7 +78,7 @@ public class WellheadDailyProductionSituationService {
@XApiAnonymous
@XApiAnonymous
@XApiPost
@XApiPost
public
XListResult
<
QueryWellheadDailyProductionSituationOutput
>
t
(
XContext
context
,
QueryWellheadDailyProductionSituationInput
input
)
{
public
XListResult
<
QueryWellheadDailyProductionSituationOutput
>
t
(
XContext
context
,
QueryWellheadDailyProductionSituationInput
input
)
{
String
cqToken
=
this
.
get
Cq
Token
(
context
);
String
cqToken
=
this
.
getToken
(
context
);
return
XListResult
.
success
();
return
XListResult
.
success
();
}
}
...
@@ -90,7 +90,7 @@ public class WellheadDailyProductionSituationService {
...
@@ -90,7 +90,7 @@ public class WellheadDailyProductionSituationService {
String
cqToken
=
""
;
String
cqToken
=
""
;
String
api
=
""
;
String
api
=
""
;
try
{
try
{
cqToken
=
this
.
get
Cq
Token
(
context
);
cqToken
=
this
.
getToken
(
context
);
context
.
getLogger
().
info
(
"cqToken: "
+
cqToken
);
context
.
getLogger
().
info
(
"cqToken: "
+
cqToken
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -139,34 +139,60 @@ public class WellheadDailyProductionSituationService {
...
@@ -139,34 +139,60 @@ public class WellheadDailyProductionSituationService {
return
XServiceResult
.
OK
;
return
XServiceResult
.
OK
;
}
}
/*----------------------------------- 私有方法 -----------------------------------*/
/**
/**
* 获取长庆TOKEN
* 获取长庆TOKEN
*
*
* @param context 上下文
* @param context 上下文
* @return {@link String}
* @return {@link String}
*/
*/
private
String
get
Cq
Token
(
XContext
context
)
{
private
String
getToken
(
XContext
context
)
{
String
token
;
String
token
;
ThirdPartyConfigCache
exist
=
ThirdPartyConfigCache
.
exist
(
context
,
ThirdPartyApiConstant
.
CQ_TOKEN_CACHE_KEY
);
ThirdPartyConfigCache
exist
=
ThirdPartyConfigCache
.
exist
(
context
,
ThirdPartyApiConstant
.
CQ_TOKEN_CACHE_KEY
);
if
(
ObjectUtil
.
isNull
(
exist
))
{
if
(
ObjectUtil
.
isNull
(
exist
))
{
String
url
=
XStartup
.
getCurrent
().
getProperty
(
"third-party.chang-qing.url"
);
token
=
this
.
getCqToken
();
url
+=
ThirdPartyApiConstant
.
CQ_TOKEN
;
this
.
setThirdPartyConfigCache
(
context
,
token
);
Map
<
String
,
String
>
param
=
new
HashMap
<>(
4
);
param
.
put
(
"UserAccount"
,
"PvGroup"
);
param
.
put
(
"UserPassWord"
,
"PvGroup@147369"
);
String
result
=
XHttpUtils
.
postAsForm
(
url
,
param
);
context
.
getLogger
().
info
(
"CQ_TOKEN: "
+
result
);
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
result
);
token
=
jsonObject
.
getStr
(
"token"
);
ThirdPartyConfigCache
cache
=
new
ThirdPartyConfigCache
();
cache
.
setCodeKey
(
ThirdPartyApiConstant
.
CQ_TOKEN_CACHE_KEY
);
cache
.
setCode
(
token
);
cache
.
setValidity
(
90
);
cache
.
setCurrentDate
(
new
Date
());
ThirdPartyConfigCache
.
set
(
context
,
cache
);
}
else
{
}
else
{
long
between
=
DateUtil
.
between
(
exist
.
getCurrentDate
(),
DateUtil
.
date
(),
DateUnit
.
SECOND
);
long
duration
=
(
long
)
exist
.
getDuration
();
if
(
between
-
duration
<
300
)
{
token
=
this
.
getCqToken
();
this
.
setThirdPartyConfigCache
(
context
,
token
);
}
token
=
exist
.
getCode
();
token
=
exist
.
getCode
();
}
}
return
token
;
return
token
;
}
}
/**
* 获取长庆Token
*
* @return {@link String}
*/
private
String
getCqToken
()
{
String
url
=
XStartup
.
getCurrent
().
getProperty
(
"third-party.chang-qing.url"
);
url
+=
ThirdPartyApiConstant
.
CQ_TOKEN
;
Map
<
String
,
String
>
param
=
new
HashMap
<>(
4
);
param
.
put
(
"UserAccount"
,
"PvGroup"
);
param
.
put
(
"UserPassWord"
,
"PvGroup@147369"
);
String
result
=
XHttpUtils
.
postAsForm
(
url
,
param
);
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
result
);
return
jsonObject
.
getStr
(
"token"
);
}
/**
* 设置缓存
*
* @param context 上下文
* @param token 代币
*/
private
void
setThirdPartyConfigCache
(
XContext
context
,
String
token
)
{
ThirdPartyConfigCache
cache
=
new
ThirdPartyConfigCache
();
cache
.
setCodeKey
(
ThirdPartyApiConstant
.
CQ_TOKEN_CACHE_KEY
);
cache
.
setCode
(
token
);
cache
.
setValidity
(
90
);
cache
.
setCurrentDate
(
DateUtil
.
date
());
ThirdPartyConfigCache
.
set
(
context
,
cache
);
}
}
}
\ No newline at end of file
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