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
b025054e
Commit
b025054e
authored
Aug 11, 2021
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
会员标签同步-校验定时器
parent
99293ffb
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
189 additions
and
1 deletions
+189
-1
QuartzEnum.java
...main/java/com/gic/haoban/manage/api/enums/QuartzEnum.java
+2
-1
QywxTagApiService.java
.../com/gic/haoban/manage/api/service/QywxTagApiService.java
+5
-0
QywxTagItemMapper.java
...c/haoban/manage/service/dao/mapper/QywxTagItemMapper.java
+10
-0
QywxTagService.java
...com/gic/haoban/manage/service/service/QywxTagService.java
+9
-0
WxEnterpriseService.java
...ic/haoban/manage/service/service/WxEnterpriseService.java
+9
-0
QywxTagServiceImpl.java
...aoban/manage/service/service/impl/QywxTagServiceImpl.java
+5
-0
WxEnterpriseServiceImpl.java
.../manage/service/service/impl/WxEnterpriseServiceImpl.java
+5
-0
QywxTagApiServiceImpl.java
...anage/service/service/out/impl/QywxTagApiServiceImpl.java
+126
-0
QywxTagItemMapper.xml
...3-service/src/main/resources/mapper/QywxTagItemMapper.xml
+13
-0
QywxTagTest.java
haoban-manage3-service/src/test/java/QywxTagTest.java
+5
-0
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/enums/QuartzEnum.java
View file @
b025054e
...
@@ -9,7 +9,8 @@ public enum QuartzEnum {
...
@@ -9,7 +9,8 @@ public enum QuartzEnum {
/**
/**
* 企业微信
* 企业微信
*/
*/
HANDOVER_QYWX
(
"handover"
,
"com.gic.haoban.manage.api.service.HandoverOperationApiService"
,
"batchQywxHandoverTimeTask"
,
"0 0 0 * * *"
,
"-1"
);
HANDOVER_QYWX
(
"handover"
,
"com.gic.haoban.manage.api.service.HandoverOperationApiService"
,
"batchQywxHandoverTimeTask"
,
"0 0 0 * * *"
,
"-1"
),
TAG_QYWX
(
"qywxTagCheck"
,
"com.gic.haoban.manage.api.service.QywxTagApiService"
,
"checkQywxSync"
,
"0 5 17 * * *"
,
"-1"
);
private
String
key
;
private
String
key
;
private
String
serviceName
;
private
String
serviceName
;
private
String
method
;
private
String
method
;
...
...
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/QywxTagApiService.java
View file @
b025054e
...
@@ -149,4 +149,9 @@ public interface QywxTagApiService {
...
@@ -149,4 +149,9 @@ public interface QywxTagApiService {
*/
*/
public
QywxTagInfoDTO
getQywxTagByQywxTagId
(
String
qywxTagId
);
public
QywxTagInfoDTO
getQywxTagByQywxTagId
(
String
qywxTagId
);
/**
* 校验企业微信标签同步
*/
public
void
checkQywxSync
();
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/QywxTagItemMapper.java
View file @
b025054e
...
@@ -76,4 +76,13 @@ public interface QywxTagItemMapper {
...
@@ -76,4 +76,13 @@ public interface QywxTagItemMapper {
* @return
* @return
*/
*/
List
<
TabQywxTagItem
>
listByQywxTagItemsIds
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"ids"
)
List
<
String
>
ids
);
List
<
TabQywxTagItem
>
listByQywxTagItemsIds
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"ids"
)
List
<
String
>
ids
);
/**
* 根据id 获取标签项信息
*
* @param wxEnterpriseId
* @param qywxTagKeys
* @return
*/
List
<
TabQywxTagItem
>
listByQywxTagItemsKeys
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"qywxTagKeys"
)
List
<
String
>
qywxTagKeys
);
}
}
\ No newline at end of file
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/QywxTagService.java
View file @
b025054e
...
@@ -174,6 +174,15 @@ public interface QywxTagService {
...
@@ -174,6 +174,15 @@ public interface QywxTagService {
public
List
<
TabQywxTagItem
>
listQywxTagItemByIds
(
String
wxEnterpriseId
,
List
<
String
>
ids
);
public
List
<
TabQywxTagItem
>
listQywxTagItemByIds
(
String
wxEnterpriseId
,
List
<
String
>
ids
);
/**
/**
* 根据企业微信的标签项获取 标签项列表
*
* @param wxEnterpriseId
* @param keys
* @return
*/
public
List
<
TabQywxTagItem
>
listQywxTagItemByKeys
(
String
wxEnterpriseId
,
List
<
String
>
keys
);
/**
* 变更状态
* 变更状态
*
*
* @param id
* @param id
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/WxEnterpriseService.java
View file @
b025054e
...
@@ -3,6 +3,8 @@ package com.gic.haoban.manage.service.service;
...
@@ -3,6 +3,8 @@ package com.gic.haoban.manage.service.service;
import
com.gic.haoban.manage.api.dto.WxEnterpriseDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseDTO
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise
;
import
java.util.List
;
public
interface
WxEnterpriseService
{
public
interface
WxEnterpriseService
{
String
add
(
WxEnterpriseDTO
wxDTO
);
String
add
(
WxEnterpriseDTO
wxDTO
);
...
@@ -30,4 +32,11 @@ public interface WxEnterpriseService {
...
@@ -30,4 +32,11 @@ public interface WxEnterpriseService {
int
unbind
(
String
wxEnterpriseId
);
int
unbind
(
String
wxEnterpriseId
);
TabHaobanWxEnterprise
getEnterpriseBycorpIdNoStatus
(
String
corpid
);
TabHaobanWxEnterprise
getEnterpriseBycorpIdNoStatus
(
String
corpid
);
/**
* 所有企业微信
*
* @return
*/
List
<
TabHaobanWxEnterprise
>
listAll
();
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/QywxTagServiceImpl.java
View file @
b025054e
...
@@ -222,6 +222,11 @@ public class QywxTagServiceImpl implements QywxTagService {
...
@@ -222,6 +222,11 @@ public class QywxTagServiceImpl implements QywxTagService {
}
}
@Override
@Override
public
List
<
TabQywxTagItem
>
listQywxTagItemByKeys
(
String
wxEnterpriseId
,
List
<
String
>
keys
)
{
return
qywxTagItemMapper
.
listByQywxTagItemsKeys
(
wxEnterpriseId
,
keys
);
}
@Override
public
void
changeTagRelationStatus
(
String
id
,
int
status
)
{
public
void
changeTagRelationStatus
(
String
id
,
int
status
)
{
TabQywxTagRelation
tabQywxTagRelation
=
new
TabQywxTagRelation
();
TabQywxTagRelation
tabQywxTagRelation
=
new
TabQywxTagRelation
();
tabQywxTagRelation
.
setQywxTagRelationId
(
id
);
tabQywxTagRelation
.
setQywxTagRelationId
(
id
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/WxEnterpriseServiceImpl.java
View file @
b025054e
...
@@ -89,4 +89,9 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
...
@@ -89,4 +89,9 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
return
null
;
return
null
;
}
}
@Override
public
List
<
TabHaobanWxEnterprise
>
listAll
()
{
List
<
TabHaobanWxEnterprise
>
ret
=
mapper
.
listAll
();
return
ret
;
}
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/QywxTagApiServiceImpl.java
View file @
b025054e
...
@@ -2,12 +2,15 @@ package com.gic.haoban.manage.service.service.out.impl;
...
@@ -2,12 +2,15 @@ package com.gic.haoban.manage.service.service.out.impl;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.commons.util.GICMQClientUtil
;
import
com.gic.commons.util.ToolUtil
;
import
com.gic.commons.util.ToolUtil
;
import
com.gic.dubbo.entity.ProviderLocalTag
;
import
com.gic.haoban.app.customer.enums.QywxTaskStatusEnum
;
import
com.gic.haoban.app.customer.enums.QywxTaskStatusEnum
;
import
com.gic.haoban.app.customer.service.api.service.QywxTagSyncApiService
;
import
com.gic.haoban.app.customer.service.api.service.QywxTagSyncApiService
;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.common.utils.EntityUtil
;
import
com.gic.haoban.common.utils.EntityUtil
;
import
com.gic.haoban.manage.api.dto.*
;
import
com.gic.haoban.manage.api.dto.*
;
import
com.gic.haoban.manage.api.enums.AlertTypeEnum
;
import
com.gic.haoban.manage.api.enums.QywxTagRelationSyncFlagEnum
;
import
com.gic.haoban.manage.api.enums.QywxTagRelationSyncFlagEnum
;
import
com.gic.haoban.manage.api.enums.QywxTagRelationTypeEnum
;
import
com.gic.haoban.manage.api.enums.QywxTagRelationTypeEnum
;
import
com.gic.haoban.manage.api.service.DealSyncOperationApiService
;
import
com.gic.haoban.manage.api.service.DealSyncOperationApiService
;
...
@@ -20,6 +23,7 @@ import com.gic.haoban.manage.service.service.QywxTagService;
...
@@ -20,6 +23,7 @@ import com.gic.haoban.manage.service.service.QywxTagService;
import
com.gic.haoban.manage.service.service.WxEnterpriseService
;
import
com.gic.haoban.manage.service.service.WxEnterpriseService
;
import
com.gic.member.api.dto.MemberTagDTO
;
import
com.gic.member.api.dto.MemberTagDTO
;
import
com.gic.member.api.service.MemberTagService
;
import
com.gic.member.api.service.MemberTagService
;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.search.engine.api.service.dynamic.ESDataDynamicOperationApiService
;
import
com.gic.search.engine.api.service.dynamic.ESDataDynamicOperationApiService
;
import
com.gic.wechat.api.dto.qywx.QywxTagDTO
;
import
com.gic.wechat.api.dto.qywx.QywxTagDTO
;
import
com.gic.wechat.api.dto.qywx.QywxTagGroupDTO
;
import
com.gic.wechat.api.dto.qywx.QywxTagGroupDTO
;
...
@@ -816,4 +820,126 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
...
@@ -816,4 +820,126 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
TabQywxTag
tabQywxTag
=
qywxTagService
.
getQywxTagByQywxTagId
(
null
,
qywxTagId
);
TabQywxTag
tabQywxTag
=
qywxTagService
.
getQywxTagByQywxTagId
(
null
,
qywxTagId
);
return
EntityUtil
.
changeEntityByJSON
(
QywxTagInfoDTO
.
class
,
tabQywxTag
);
return
EntityUtil
.
changeEntityByJSON
(
QywxTagInfoDTO
.
class
,
tabQywxTag
);
}
}
@Override
public
void
checkQywxSync
()
{
List
<
TabHaobanWxEnterprise
>
wxEnterprises
=
wxEnterpriseService
.
listAll
();
wxEnterprises
.
forEach
(
wxEnterprise
->
{
logger
.
info
(
"企业:{}"
,
wxEnterprise
.
getWxEnterpriseId
());
try
{
List
<
TabQywxTagRelation
>
tagRelations
=
qywxTagService
.
listAllQywxRelation
(
wxEnterprise
.
getWxEnterpriseId
());
if
(
CollectionUtils
.
isEmpty
(
tagRelations
))
{
logger
.
info
(
"无需校验: 没有要同步的企业"
);
return
;
}
QywxSyncTagFormatPojo
pojo
=
this
.
listSyncTagItems
(
wxEnterprise
.
getWxEnterpriseId
());
List
<
TabQywxTagRelation
>
qywxTagRelations
=
tagRelations
.
stream
().
filter
(
dto
->
dto
.
getRelationType
()
==
QywxTagRelationTypeEnum
.
TAG_GROUP
.
getType
()).
collect
(
Collectors
.
toList
());
for
(
TabQywxTagRelation
qywxTagRelation
:
qywxTagRelations
)
{
Map
<
String
,
Object
>
map
=
checkQywxSyncByQywxTag
(
qywxTagRelation
,
wxEnterprise
,
pojo
);
if
(
MapUtils
.
isNotEmpty
(
map
))
{
AlertMessageDTO
messageDTO
=
new
AlertMessageDTO
();
messageDTO
.
setAlertTitle
(
"标签同步异常"
);
messageDTO
.
setEnterpriseId
(
qywxTagRelation
.
getEnterpriseId
());
messageDTO
.
setAlertType
(
AlertTypeEnum
.
QYWX_TAG_SYNC
.
getType
());
messageDTO
.
setWxEnterpriseId
(
wxEnterprise
.
getWxEnterpriseId
());
messageDTO
.
setContentMap
(
map
);
ProviderLocalTag
providerLocalTag
=
ProviderLocalTag
.
tag
.
get
();
String
traceId
=
providerLocalTag
.
traceId
;
messageDTO
.
setTraceId
(
traceId
);
GicMQClient
clientInstance
=
GICMQClientUtil
.
getClientInstance
();
try
{
clientInstance
.
sendMessage
(
"haobanAlertMq"
,
JSONObject
.
toJSONString
(
messageDTO
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
info
(
"异常:{}"
,
e
);
}
}
}
}
catch
(
Exception
e
)
{
logger
.
info
(
"校验异常:{}"
,
e
);
}
});
}
/**
* 校验
*
* @param relation
* @param wxEnterprise
*/
private
Map
<
String
,
Object
>
checkQywxSyncByQywxTag
(
TabQywxTagRelation
relation
,
TabHaobanWxEnterprise
wxEnterprise
,
QywxSyncTagFormatPojo
pojo
)
{
Map
<
String
,
Object
>
ret
=
new
HashMap
<>();
boolean
flag
=
false
;
ret
.
put
(
"hb标签id"
,
relation
.
getQywxTagId
());
TabQywxTag
tabQywxTag
=
qywxTagService
.
getQywxTagByQywxTagId
(
relation
.
getWxEnterpriseId
(),
relation
.
getQywxTagId
());
if
(
null
==
tabQywxTag
)
{
logger
.
info
(
"数据库不存在该企业微信标签:{}"
,
relation
.
getQywxTagId
());
ret
.
put
(
"描述"
,
"标签数据库不存在:"
+
relation
.
getTagItemId
());
return
ret
;
}
ret
.
put
(
"标签名称"
,
tabQywxTag
.
getQywxGroupName
());
List
<
String
>
ids
=
new
ArrayList
<>();
ids
.
add
(
tabQywxTag
.
getQywxGroupKey
());
QywxGetCorpTagListDTO
tagDetail
=
qywxSuiteApiService
.
getCorpTagList
(
wxEnterprise
.
getCorpid
(),
config
.
getWxSuiteid
(),
ids
,
QywxTagRelationTypeEnum
.
TAG_GROUP
.
getType
());
if
(
tagDetail
.
getErrcode
()
!=
0
)
{
logger
.
info
(
"查询失败,无需操作:{}"
,
JSONObject
.
toJSONString
(
tagDetail
));
ret
.
put
(
"描述"
,
"查询失败:"
+
tagDetail
.
getErrmsg
());
return
ret
;
}
if
(
CollectionUtils
.
isEmpty
(
tagDetail
.
getTagGroup
()))
{
logger
.
info
(
"标签组不存在:{}"
,
JSONObject
.
toJSONString
(
tagDetail
));
ret
.
put
(
"描述"
,
"标签组不存在:"
+
tabQywxTag
.
getQywxGroupName
());
return
ret
;
}
//获取该标签已经绑定的标签项key
Map
<
String
,
String
>
qywxToGicTagItemIdMap
=
pojo
.
getQywxToGicTagItemIdMap
();
List
<
TabQywxTagItem
>
gicQywxTagItems
=
qywxTagService
.
listByQywxTagId
(
wxEnterprise
.
getWxEnterpriseId
(),
relation
.
getQywxTagId
());
Map
<
String
,
String
>
gicQywxTagNameMap
=
gicQywxTagItems
.
stream
().
filter
(
tab
->
qywxToGicTagItemIdMap
.
containsKey
(
tab
.
getQywxTagKey
())).
collect
(
Collectors
.
toMap
(
mid
->
mid
.
getQywxTagKey
(),
mid
->
mid
.
getQywxTagName
()));
if
(
CollectionUtils
.
isEmpty
(
gicQywxTagItems
))
{
logger
.
info
(
"gic同步企业微信标签异常"
);
ret
.
put
(
"描述"
,
"gic同步企业微信标签异常:"
+
tabQywxTag
.
getQywxGroupName
());
return
ret
;
}
Set
<
String
>
gicQywxKeysSet
=
gicQywxTagNameMap
.
keySet
();
//获取企业微信的标签项key
QywxTagGroupDTO
qywxTagGroupDTO
=
tagDetail
.
getTagGroup
().
get
(
0
);
List
<
QywxTagDTO
>
tagItems
=
qywxTagGroupDTO
.
getTag
();
if
(
CollectionUtils
.
isEmpty
(
tagItems
))
{
ret
.
put
(
"描述"
,
"企业微信标签项空:"
+
tabQywxTag
.
getQywxGroupName
());
return
ret
;
}
Map
<
String
,
QywxTagDTO
>
qywxTagDTOMap
=
tagItems
.
stream
().
collect
(
Collectors
.
toMap
(
dto
->
dto
.
getId
(),
dto
->
dto
));
Set
<
String
>
qywxKeysSet
=
qywxTagDTOMap
.
keySet
();
//在gic存在 企业微信不存在
Sets
.
SetView
<
String
>
qywxUnHaves
=
Sets
.
difference
(
gicQywxKeysSet
,
qywxKeysSet
);
//企业微信存在 gic不存在
Sets
.
SetView
<
String
>
gicUnHaves
=
Sets
.
difference
(
qywxKeysSet
,
gicQywxKeysSet
);
//企业微信缺少
if
(!
CollectionUtils
.
isEmpty
(
qywxUnHaves
))
{
flag
=
true
;
ret
.
put
(
"企微缺少标签项"
,
qywxUnHaves
.
stream
().
map
(
mid
->
gicQywxTagNameMap
.
get
(
mid
)).
collect
(
Collectors
.
joining
(
", "
,
""
,
""
)));
}
//gic缺少
if
(!
CollectionUtils
.
isEmpty
(
gicUnHaves
))
{
flag
=
true
;
ret
.
put
(
"gic缺少标签项"
,
gicUnHaves
.
stream
().
map
(
id
->
qywxTagDTOMap
.
get
(
id
).
getName
()).
collect
(
Collectors
.
joining
(
","
,
""
,
""
)));
}
if
(
flag
)
{
return
ret
;
}
return
null
;
}
}
}
haoban-manage3-service/src/main/resources/mapper/QywxTagItemMapper.xml
View file @
b025054e
...
@@ -199,4 +199,16 @@
...
@@ -199,4 +199,16 @@
and status_flag=1
and status_flag=1
and wx_enterprise_id=#{wxEnterpriseId}
and wx_enterprise_id=#{wxEnterpriseId}
</select>
</select>
<select
id=
"listByQywxTagItemsKeys"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_haoban_qywx_tag_item
where qywx_tag_key in
<foreach
collection=
"qywxTagKeys"
open=
"("
close=
")"
separator=
","
item=
"item"
>
#{item}
</foreach>
and status_flag=1
and wx_enterprise_id=#{wxEnterpriseId}
</select>
</mapper>
</mapper>
\ No newline at end of file
haoban-manage3-service/src/test/java/QywxTagTest.java
View file @
b025054e
...
@@ -56,4 +56,9 @@ public class QywxTagTest {
...
@@ -56,4 +56,9 @@ public class QywxTagTest {
}
}
@Test
public
void
test3
()
{
qywxTagApiService
.
checkQywxSync
();
}
}
}
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