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
a1c0d4f4
Commit
a1c0d4f4
authored
Sep 14, 2021
by
xugaojun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
9月迭代:1、任务视图支持删除所有任务;2、企业微信标签同步功能实现
parent
b10e40b2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
30 deletions
+96
-30
YwWxEnterpriseDTO.java
...java/com/gic/haoban/manage/api/dto/YwWxEnterpriseDTO.java
+11
-0
EnterpriseController.java
...ic/haoban/manage/web/controller/EnterpriseController.java
+85
-30
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/dto/YwWxEnterpriseDTO.java
View file @
a1c0d4f4
...
...
@@ -28,6 +28,10 @@ public class YwWxEnterpriseDTO implements Serializable {
private
String
corpSquareLogoUrl
;
//关联商户数量
private
Integer
relationCount
=
0
;
/**
* 是否开启标签同步标记 1 是 0 否
*/
private
Integer
tagOpenFlag
;
public
static
long
getSerialversionuid
()
{
...
...
@@ -133,4 +137,11 @@ public class YwWxEnterpriseDTO implements Serializable {
this
.
version
=
version
;
}
public
Integer
getTagOpenFlag
()
{
return
tagOpenFlag
;
}
public
void
setTagOpenFlag
(
Integer
tagOpenFlag
)
{
this
.
tagOpenFlag
=
tagOpenFlag
;
}
}
haoban-manage3-operation-web/src/main/java/com/gic/haoban/manage/web/controller/EnterpriseController.java
View file @
a1c0d4f4
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletResponse
;
import
com.google.common.collect.Sets
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -20,8 +18,6 @@ import cn.hutool.core.collection.CollectionUtil;
import
com.gic.api.base.commons.Page
;
import
com.gic.commons.util.GlobalVar
;
import
com.gic.commons.util.Md5Util
;
import
com.gic.commons.util.RandomUtil
;
import
com.gic.enterprise.api.dto.EnterpriseDTO
;
import
com.gic.enterprise.api.dto.StoreDTO
;
import
com.gic.enterprise.api.service.EnterpriseService
;
...
...
@@ -39,11 +35,10 @@ import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import
com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.vo.EnterpriseDetailVo
;
import
com.gic.haoban.operation.api.service.EnterpriseRelationService
;
import
com.gic.redis.data.util.RedisUtil
;
@RestController
public
class
EnterpriseController
extends
WebBaseController
{
public
class
EnterpriseController
extends
WebBaseController
{
private
static
final
String
LOGIN_URL
=
"/haoban-manage3-web/yw-login"
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
EnterpriseController
.
class
);
...
...
@@ -57,54 +52,114 @@ public class EnterpriseController extends WebBaseController{
private
StoreService
storeService
;
@Autowired
private
EnterpriseService
enterpriseService
;
// @Autowired
// @Autowired
// private WxEnterpriseRelatedApiService wxEnterpriseRelllatedApiService;
//企业列表
@RequestMapping
(
"wx-enterprise-list"
)
public
HaobanResponse
wxEnterpriseList
(
BasePageInfo
pageInfo
,
String
keyword
,
String
gicEnterpriseName
,
Integer
gicContactHelper
,
String
version
)
{
public
HaobanResponse
wxEnterpriseList
(
BasePageInfo
pageInfo
,
String
keyword
,
String
gicEnterpriseName
,
Integer
gicContactHelper
,
String
version
)
{
List
<
String
>
wxEnterpriseIds
=
new
ArrayList
<
String
>();
if
(!
StringUtils
.
isEmpty
(
gicEnterpriseName
))
{
if
(!
StringUtils
.
isEmpty
(
gicEnterpriseName
))
{
List
<
EnterpriseDTO
>
enterpriseNames
=
enterpriseService
.
getEnterpriseByName
(
gicEnterpriseName
);
if
(
CollectionUtil
.
isNotEmpty
(
enterpriseNames
))
{
List
<
String
>
enterpriseIds
=
enterpriseNames
.
stream
().
map
(
s
->
s
.
getEnterpriseId
()).
collect
(
Collectors
.
toList
());
if
(
CollectionUtil
.
isNotEmpty
(
enterpriseNames
))
{
List
<
String
>
enterpriseIds
=
enterpriseNames
.
stream
().
map
(
s
->
s
.
getEnterpriseId
()).
collect
(
Collectors
.
toList
());
List
<
EnterpriseDetailDTO
>
wxEnterpriseIdDTOs
=
wxEnterpriseRelatedApiService
.
listEnterpriseByEnterpriseIds
(
enterpriseIds
);
if
(
CollectionUtil
.
isNotEmpty
(
wxEnterpriseIdDTOs
))
{
wxEnterpriseIds
=
wxEnterpriseIdDTOs
.
stream
().
map
(
s
->
s
.
getWxEnterpriseId
()).
collect
(
Collectors
.
toList
());
if
(
CollectionUtil
.
isNotEmpty
(
wxEnterpriseIdDTOs
))
{
wxEnterpriseIds
=
wxEnterpriseIdDTOs
.
stream
().
map
(
s
->
s
.
getWxEnterpriseId
()).
collect
(
Collectors
.
toList
());
}
}
if
(
CollectionUtil
.
isEmpty
(
wxEnterpriseIds
))
{
if
(
CollectionUtil
.
isEmpty
(
wxEnterpriseIds
))
{
wxEnterpriseIds
=
Arrays
.
asList
(
"-9999"
);
}
}
Page
<
YwWxEnterpriseDTO
>
page
=
wxEnterpriseApiService
.
list
(
pageInfo
,
keyword
,
wxEnterpriseIds
,
gicContactHelper
,
version
);
// 查询开启标签同步缓存-详情在 /tag/open-tag 接口
String
wxEntIdStr
=
(
String
)
RedisUtil
.
getCache
(
"qywx-tag-open"
);
Set
<
String
>
wxEntIdSet
=
Sets
.
newHashSet
();
if
(
StringUtils
.
isNotEmpty
(
wxEntIdStr
))
{
wxEntIdSet
=
Arrays
.
stream
(
wxEntIdStr
.
split
(
","
)).
collect
(
Collectors
.
toSet
());
}
Page
<
YwWxEnterpriseDTO
>
page
=
wxEnterpriseApiService
.
list
(
pageInfo
,
keyword
,
wxEnterpriseIds
,
gicContactHelper
,
version
);
PageResult
<
YwWxEnterpriseDTO
>
pageVo
=
new
PageResult
<>();
List
<
YwWxEnterpriseDTO
>
list
=
EntityUtil
.
changeEntityListByJSON
(
YwWxEnterpriseDTO
.
class
,
page
.
getResult
());
for
(
YwWxEnterpriseDTO
dto
:
list
)
{
for
(
YwWxEnterpriseDTO
dto
:
list
)
{
dto
.
setVersion
(
"3.0"
);
dto
.
setBuyDate
(
new
Date
());
dto
.
setBuyStatus
(
"1"
);
List
<
EnterpriseDetailDTO
>
counts
=
wxEnterpriseRelatedApiService
.
listEnterpriseByWxEnterpriseId
(
dto
.
getWxEnterpriseId
());
dto
.
setRelationCount
(
counts
.
size
());
dto
.
setTagOpenFlag
(
wxEntIdSet
.
contains
(
dto
.
getWxEnterpriseId
())
?
1
:
0
);
}
pageVo
.
setList
(
list
);
pageVo
.
setPageNum
(
page
.
getCurrentPage
());
pageVo
.
setPages
(
page
.
getPages
());
pageVo
.
setPageSize
(
page
.
getPageSize
());
pageVo
.
setTotal
(
page
.
getTotalCount
());
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
pageVo
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
pageVo
);
}
/**
* 开启关闭标签同步
*
* @param wxEnterpriseId 微信企业id
* @param flag 操作标记 1 开启 0 关闭
* @return HaobanResponse
*/
@RequestMapping
(
"operate-tag-sync"
)
public
HaobanResponse
operateTagSync
(
String
wxEnterpriseId
,
Integer
flag
)
{
if
(
StringUtils
.
isEmpty
(
wxEnterpriseId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_2
);
}
// 操作缓存
String
key
=
"qywx-tag-open"
;
String
lockKey
=
"qywx-tag-open-lock"
;
try
{
RedisUtil
.
lock
(
lockKey
,
5L
);
String
wxEntIdStr
=
(
String
)
RedisUtil
.
getCache
(
key
);
if
(
flag
==
1
)
{
// 开启
if
(
StringUtils
.
isEmpty
(
wxEntIdStr
))
{
wxEntIdStr
=
wxEnterpriseId
;
}
else
{
wxEntIdStr
=
wxEntIdStr
+
","
+
wxEnterpriseId
;
}
logger
.
info
(
"开启企业标签同步, wxEntIdStr:{}"
,
wxEntIdStr
);
RedisUtil
.
setCache
(
key
,
wxEntIdStr
);
}
if
(
flag
==
0
&&
StringUtils
.
isNotEmpty
(
wxEntIdStr
))
{
// 关闭标签同步,只有在字符串不为空时才能关
List
<
String
>
filterList
=
Arrays
.
stream
(
wxEntIdStr
.
split
(
","
))
.
filter
(
one
->
!
one
.
equals
(
wxEnterpriseId
))
.
collect
(
Collectors
.
toList
());
String
closeStr
=
StringUtils
.
join
(
filterList
,
","
);
logger
.
info
(
"关闭企业标签同步, closeStr:{}"
,
closeStr
);
RedisUtil
.
setCache
(
key
,
closeStr
);
}
}
finally
{
RedisUtil
.
unlock
(
lockKey
);
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
//授权详情列表
@RequestMapping
(
"authorize-detail"
)
public
HaobanResponse
authorizeDetail
(
String
wxEnterpriseId
)
{
List
<
EnterpriseDetailDTO
>
list
=
wxEnterpriseRelatedApiService
.
listEnterpriseByWxEnterpriseId
(
wxEnterpriseId
);
List
<
EnterpriseDetailVo
>
result
=
EntityUtil
.
changeEntityListByJSON
(
EnterpriseDetailVo
.
class
,
list
);
for
(
EnterpriseDetailVo
vo:
result
)
{
for
(
EnterpriseDetailVo
vo
:
result
)
{
List
<
StoreDTO
>
stores
=
storeService
.
getStoreByEnterId
(
vo
.
getEnterpriseId
(),
null
,
null
);
if
(
CollectionUtil
.
isEmpty
(
stores
))
{
if
(
CollectionUtil
.
isEmpty
(
stores
))
{
continue
;
}
else
{
List
<
String
>
storeIds
=
stores
.
stream
().
map
(
s
->
s
.
getStoreId
()).
collect
(
Collectors
.
toList
());
}
else
{
List
<
String
>
storeIds
=
stores
.
stream
().
map
(
s
->
s
.
getStoreId
()).
collect
(
Collectors
.
toList
());
List
<
DepartmentDTO
>
countList
=
departmentApiService
.
listByRelatedIds
(
storeIds
);
vo
.
setStoreCount
(
countList
.
size
());
}
...
...
@@ -112,17 +167,17 @@ public class EnterpriseController extends WebBaseController{
vo
.
setEnterpriseName
(
enterpriseDTO
.
getEnterpriseName
());
vo
.
setEnterpriseLogo
(
enterpriseDTO
.
getQcloudImageUrl
());
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
result
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
result
);
}
//登录
@RequestMapping
(
"yw-login"
)
public
void
ywLogin
(
String
wxEnterpriseId
,
HttpServletResponse
httpServletResponse
)
throws
IOException
{
public
void
ywLogin
(
String
wxEnterpriseId
,
HttpServletResponse
httpServletResponse
)
throws
IOException
{
String
host
=
GlobalVar
.
ctxPropertiesMap
.
get
(
"haoban_service_host"
);
logger
.
info
(
"host============================>{}"
,
host
);
String
random
=
"ywLogin:"
+
UuidUtil
.
randomUUID
();
RedisUtil
.
setCache
(
random
,
1
,
1000L
);
String
url
=
host
+
LOGIN_URL
+
"?wxEnterpriseId="
+
wxEnterpriseId
+
"&random="
+
random
;
logger
.
info
(
"host============================>{}"
,
host
);
String
random
=
"ywLogin:"
+
UuidUtil
.
randomUUID
();
RedisUtil
.
setCache
(
random
,
1
,
1000L
);
String
url
=
host
+
LOGIN_URL
+
"?wxEnterpriseId="
+
wxEnterpriseId
+
"&random="
+
random
;
httpServletResponse
.
sendRedirect
(
url
);
}
}
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