Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
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
haoban3.0
haoban-manage3.0
Commits
57e36b3b
Commit
57e36b3b
authored
Sep 28, 2022
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
8a69d1a2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
19 deletions
+22
-19
QwTimesUtils.java
...java/com/gic/haoban/manage/service/util/QwTimesUtils.java
+16
-19
HmPageServiceTest.java
haoban-manage3-service/src/test/java/HmPageServiceTest.java
+6
-0
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/util/QwTimesUtils.java
View file @
57e36b3b
...
...
@@ -39,29 +39,29 @@ public class QwTimesUtils {
QwTimesUtils
.
enterpriseService
=
enterpriseService
;
}
public
static
boolean
isLimit
(
String
wxEnterpriseId
,
String
enterpriseId
,
QwInterfaceLimitEnum
obj
)
{
QwLimitTimesBO
setTimeBO
=
getSettingTimes
(
wxEnterpriseId
,
obj
);
public
static
boolean
isLimit
(
String
wxEnterpriseId
,
String
enterpriseId
,
QwInterfaceLimitEnum
qwInterface
)
{
QwLimitTimesBO
setTimeBO
=
getSettingTimes
(
wxEnterpriseId
,
qwInterface
);
logger
.
info
(
"获取配置次数={},wxEnterpriseId={}"
,
JSON
.
toJSONString
(
setTimeBO
),
wxEnterpriseId
);
// 先判断月
String
interfaceName
=
obj
.
getName
();
String
interfaceName
=
qwInterface
.
getName
();
Date
now
=
new
Date
();
String
dateStr
=
getDateStr
(
now
);
String
keyMonth
=
getCacheKey
(
wxEnterpriseId
,
interfaceName
,
dateStr
.
substring
(
0
,
6
));
boolean
monthResult
=
timesCheck
(
1
,
keyMonth
,
obj
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
boolean
monthResult
=
timesCheck
(
1
,
keyMonth
,
qwInterface
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
if
(
monthResult
)
{
logger
.
info
(
"月达到限制={}"
,
keyMonth
);
return
true
;
}
// 天
String
keyDay
=
getCacheKey
(
wxEnterpriseId
,
interfaceName
,
dateStr
.
substring
(
0
,
8
));
boolean
dayResult
=
timesCheck
(
2
,
keyDay
,
obj
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
boolean
dayResult
=
timesCheck
(
2
,
keyDay
,
qwInterface
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
if
(
dayResult
)
{
logger
.
info
(
"天达到限制={}"
,
keyDay
);
return
true
;
}
// 小时
String
keyHour
=
getCacheKey
(
wxEnterpriseId
,
interfaceName
,
dateStr
.
substring
(
0
,
10
));
boolean
hourResult
=
timesCheck
(
3
,
keyHour
,
obj
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
boolean
hourResult
=
timesCheck
(
3
,
keyHour
,
qwInterface
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
if
(
hourResult
)
{
logger
.
info
(
"小时达到限制={}"
,
keyHour
);
return
true
;
...
...
@@ -69,8 +69,8 @@ public class QwTimesUtils {
return
false
;
}
private
static
boolean
timesCheck
(
int
type
,
String
cacheKey
,
QwInterfaceLimitEnum
obj
,
String
wxEnterpriseId
,
String
enterpriseId
,
Date
now
,
QwLimitTimesBO
setTimeBO
)
{
private
static
boolean
timesCheck
(
int
type
,
String
cacheKey
,
QwInterfaceLimitEnum
qwInterface
,
String
wxEnterpriseId
,
String
enterpriseId
,
Date
now
,
QwLimitTimesBO
setTimeBO
)
{
Integer
doneTimes
=
RedisUtil
.
getCache
(
cacheKey
,
Integer
.
class
);
logger
.
info
(
"获取已调次数={},cacheKey={}"
,
doneTimes
,
cacheKey
);
if
(
null
==
doneTimes
)
{
...
...
@@ -90,18 +90,18 @@ public class QwTimesUtils {
default
:
break
;
}
sendAlert
(
type
,
doneTimes
,
setTimes
,
obj
,
enterpriseId
,
now
);
sendAlert
(
type
,
doneTimes
,
setTimes
,
qwInterface
,
enterpriseId
,
now
);
if
(
doneTimes
>=
setTimes
)
{
return
true
;
}
return
false
;
}
private
static
QwLimitTimesBO
getSettingTimes
(
String
wxEnterpriseId
,
QwInterfaceLimitEnum
obj
)
{
String
key
=
String
.
format
(
"%s_%s"
,
obj
.
getName
(),
wxEnterpriseId
);
private
static
QwLimitTimesBO
getSettingTimes
(
String
wxEnterpriseId
,
QwInterfaceLimitEnum
qwInterface
)
{
String
key
=
String
.
format
(
"%s_%s"
,
qwInterface
.
getName
(),
wxEnterpriseId
);
QwLimitTimesBO
times
=
getTimes
(
key
);
if
(
null
==
times
)
{
return
getTimes
(
obj
.
getName
());
return
getTimes
(
qwInterface
.
getName
());
}
return
times
;
}
...
...
@@ -112,16 +112,13 @@ public class QwTimesUtils {
ServiceResponse
<
Map
<
String
,
Object
>>
resp
=
customSettingApiService
.
getDetail
(
"tab_gic_map"
,
searchParamMap
.
toJSONString
());
if
(
resp
.
isSuccess
()
&&
null
!=
resp
.
getResult
())
{
QwLimitTimesBO
times
=
new
QwLimitTimesBO
();
times
=
JSON
.
parseObject
(
resp
.
getResult
().
get
(
"value"
).
toString
(),
QwLimitTimesBO
.
class
);
logger
.
info
(
"获取默认配置次数={},{}"
,
times
,
key
);
return
times
;
return
JSON
.
parseObject
(
resp
.
getResult
().
get
(
"value"
).
toString
(),
QwLimitTimesBO
.
class
);
}
return
null
;
}
private
static
void
sendAlert
(
int
type
,
int
doneTimes
,
int
setTimes
,
QwInterfaceLimitEnum
obj
,
String
enterpriseId
,
Date
now
)
{
private
static
void
sendAlert
(
int
type
,
int
doneTimes
,
int
setTimes
,
QwInterfaceLimitEnum
qwInterface
,
String
enterpriseId
,
Date
now
)
{
// 调用次数达上线
String
time
=
null
;
String
title
=
"已达上限"
;
...
...
@@ -163,7 +160,7 @@ public class QwTimesUtils {
EnterpriseDTO
enterpriseDTO
=
enterpriseService
.
getEnterpriseById
(
enterpriseId
);
String
brandName
=
enterpriseDTO
.
getBrandName
();
// 达到上限时文案
String
msg
=
String
.
format
(
"告警【%s】%s调用在【%s】%s"
,
brandName
,
obj
.
getRemark
(),
time
,
title
);
String
msg
=
String
.
format
(
"告警【%s】%s调用在【%s】%s"
,
brandName
,
qwInterface
.
getRemark
(),
time
,
title
);
DingUtils
.
send
(
msg
,
false
);
}
}
...
...
haoban-manage3-service/src/test/java/HmPageServiceTest.java
View file @
57e36b3b
...
...
@@ -19,6 +19,7 @@ import com.gic.haoban.manage.api.dto.hm.HmWelcomeRelationDTO;
import
com.gic.haoban.manage.api.dto.qdto.hm.HmPageRelationQDTO
;
import
com.gic.haoban.manage.api.dto.welcome.qdto.QueryWelcomeRelationQDTO
;
import
com.gic.haoban.manage.api.enums.hm.HmWelcomeReferType
;
import
com.gic.haoban.manage.api.service.QwFriendApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService
;
import
com.gic.haoban.manage.api.service.hm.HmGroupApiService
;
...
...
@@ -48,10 +49,15 @@ public class HmPageServiceTest {
private
WxEnterpriseApiService
wxEnterpriseApiService
;
@Autowired
private
ExternalClerkRelatedService
externalClerkRelatedService
;
@Autowired
private
QwFriendApiService
qwFriendApiService
;
@Test
public
void
test
(){
System
.
out
.
println
(
this
.
qwFriendApiService
.
getPendingIdByUnionid
(
"ff8080815dacd3a2015dacd3ef5c0000"
,
"orXl9t9gIRbvfIoDPfrPf7jHYHmU"
,
"o0Yvd006OXKv71RIu8SbXA5mT7Zk"
));
this
.
externalClerkRelatedService
.
repairExternalUserId
(
"218a8a6c2ca14e28a1053f541be0e49d,ca66a01b79474c40b3e7c7f93daf1a3b"
);
// this.wxEnterpriseApiService.stopHaoban("ff80808182c3a46b0182c3a4ea7d0000");
...
...
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