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
df6107b5
Commit
df6107b5
authored
May 21, 2020
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gic跳转登录
parent
64a8c58b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
170 additions
and
4 deletions
+170
-4
pom.xml
haoban-manage3-service/pom.xml
+11
-0
KafkaMessageServiceImpl.java
...c/haoban/manage/service/task/KafkaMessageServiceImpl.java
+83
-0
kafka-setting.xml
haoban-manage3-service/src/main/resources/kafka-setting.xml
+53
-0
WxEnterpriseRelatedMapper.xml
...e/src/main/resources/mapper/WxEnterpriseRelatedMapper.xml
+3
-1
ServiceTest.java
haoban-manage3-service/src/test/java/ServiceTest.java
+20
-3
No files found.
haoban-manage3-service/pom.xml
View file @
df6107b5
...
@@ -127,6 +127,17 @@
...
@@ -127,6 +127,17 @@
<artifactId>
haoban-app-customer-api
</artifactId>
<artifactId>
haoban-app-customer-api
</artifactId>
<version>
${haoban-app-customer-api}
</version>
<version>
${haoban-app-customer-api}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.kafka
</groupId>
<artifactId>
spring-kafka
</artifactId>
<version>
2.1.4.RELEASE
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-binlog-base
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/task/KafkaMessageServiceImpl.java
0 → 100644
View file @
df6107b5
package
com
.
gic
.
haoban
.
manage
.
service
.
task
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.binlog.base.entity.GicRecord
;
import
com.gic.clerk.api.dto.ClerkListDTO
;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.haoban.common.utils.StringUtil
;
import
com.gic.haoban.communicate.api.dto.SyncJsonColumnDTO
;
import
com.gic.haoban.communicate.api.dto.SyncJsonDTO
;
import
com.gic.haoban.contacts.api.dto.EmployeeClerkAddDTO
;
import
com.gic.haoban.contacts.api.service.EmployeeClerkService
;
import
com.gic.haoban.contacts.manage.api.dto.DepartmentStoreGroupDTO
;
import
com.gic.haoban.contacts.manage.api.service.DepartmentStoreGroupService
;
import
com.gic.haoban.contacts.manage.api.service.StoreService
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.kafka.clients.consumer.ConsumerRecord
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.kafka.listener.MessageListener
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Created 2019/4/10.
*
* @author hua
*/
public
class
KafkaMessageServiceImpl
implements
MessageListener
<
String
,
GicRecord
>
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
KafkaMessageServiceImpl
.
class
);
private
final
String
STORE
=
"tab_gic_store"
;
private
final
String
CLERK
=
"tab_gic_clerk"
;
private
final
String
DEPARTMENT
=
"tab_gic_store_group"
;
private
final
String
STORE_IMAGE
=
"tab_gic_store_photo"
;
@Autowired
private
StoreService
storeService
;
@Autowired
private
ClerkService
clerkService
;
@Autowired
private
StaffApiService
staffApiService
;
@Override
public
void
onMessage
(
ConsumerRecord
<
String
,
GicRecord
>
record
)
{
logger
.
info
(
"message:{}"
,
JSONObject
.
toJSONString
(
record
.
value
()));
String
message
=
JSONObject
.
toJSONString
(
record
.
value
());
if
(
StringUtils
.
isBlank
(
message
)){
return
;
}
// SyncJsonDTO syncJsonDTO = JSON.toJavaObject((JSONObject)JSON.parse(message),SyncJsonDTO.class);
// String fieldListString = syncJsonDTO.getFieldList();
// String tableName = syncJsonDTO.getTableName();
if
(
tableName
.
equals
(
STORE
)){
logger
.
info
(
"【同步门店】"
);
String
haobanClerkListString
=
setClerkList
(
fieldListString
);
logger
.
info
(
"【同步门店】haobanClerkListString={}"
,
haobanClerkListString
);
storeService
.
syncGicStore
(
fieldListString
,
haobanClerkListString
);
}
else
if
(
tableName
.
equals
(
CLERK
)){
logger
.
info
(
"【同步店员】"
);
try
{
employeeClerkService
.
syncGicClerk
(
fieldListString
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"【同步店员】同步失败={}"
,
e
.
toString
());
}
staffApiService
.
syncGicClerk
(
fieldListString
);
}
}
}
haoban-manage3-service/src/main/resources/kafka-setting.xml
0 → 100644
View file @
df6107b5
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:apollo=
"http://www.ctrip.com/schema/apollo"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.ctrip.com/schema/apollo
http://www.ctrip.com/schema/apollo.xsd"
>
<apollo:config/>
<bean
id=
"consumerProperties"
class=
"java.util.HashMap"
>
<constructor-arg>
<map>
<entry
key=
"bootstrap.servers"
value=
"${kafka.service}"
/>
<entry
key=
"group.id"
value=
"haoban-3-sync"
/>
<entry
key=
"key.deserializer"
value=
"org.apache.kafka.common.serialization.StringDeserializer"
/>
<entry
key=
"value.deserializer"
value=
"com.gic.binlog.base.serializer.KafkaGicRecordSerializer"
/>
</map>
</constructor-arg>
</bean>
<!-- 2.创建consumerFactory bean -->
<bean
id=
"consumerFactory"
class=
"org.springframework.kafka.core.DefaultKafkaConsumerFactory"
>
<constructor-arg>
<ref
bean=
"consumerProperties"
/>
</constructor-arg>
</bean>
<!-- 3.定义消费实现类 -->
<bean
id=
"kafkaConsumerService"
class=
"com.gic.haoban.manage.service.task.KafkaMessageServiceImpl"
/>
<!-- 4.消费者容器配置信息 -->
<bean
id=
"containerProperties"
class=
"org.springframework.kafka.listener.config.ContainerProperties"
>
<!-- topic -->
<constructor-arg
name=
"topics"
>
<list>
<value>
haoban_gic_clerk
</value>
<value>
haoban_gic_store
</value>
</list>
</constructor-arg>
<property
name=
"messageListener"
ref=
"kafkaConsumerService"
/>
</bean>
<!-- 5.消费者并发消息监听容器,执行doStart()方法 -->
<bean
id=
"messageListenerContainer"
class=
"org.springframework.kafka.listener.ConcurrentMessageListenerContainer"
init-method=
"doStart"
>
<constructor-arg
ref=
"consumerFactory"
/>
<constructor-arg
ref=
"containerProperties"
/>
<property
name=
"concurrency"
value=
"3"
/>
</bean>
</beans>
\ No newline at end of file
haoban-manage3-service/src/main/resources/mapper/WxEnterpriseRelatedMapper.xml
View file @
df6107b5
...
@@ -154,7 +154,8 @@
...
@@ -154,7 +154,8 @@
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from tab_haoban_wx_enterprise_related
from tab_haoban_wx_enterprise_related
where status_flag = 1
where status_flag = 1
AND update_time > #{time}
AND DATE_FORMAT(update_time,'%Y-%m-%d') = #{time}
</select>
</select>
</mapper>
</mapper>
\ No newline at end of file
haoban-manage3-service/src/test/java/ServiceTest.java
View file @
df6107b5
...
@@ -215,14 +215,31 @@ public void sendMessage() {
...
@@ -215,14 +215,31 @@ public void sendMessage() {
@Test
@Test
public
void
extensionList4
()
{
public
void
extensionList4
()
{
// msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw
// msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw
//
String img="https://pic01-10001430.image.myqcloud.com/53205d69-01f1-4706-a258-014d59d8d106";
String
img
=
"https://pic01-10001430.image.myqcloud.com/53205d69-01f1-4706-a258-014d59d8d106"
;
//
byte[] aByte = getByte(img);
byte
[]
aByte
=
getByte
(
img
);
// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode());
// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode());
// System.out.println(JSONObject.toJSONString(response));
// System.out.println(JSONObject.toJSONString(response));
JSONResponse
response1
=
qywxSuiteApiService
.
resultExternalMessage
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
"msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw"
);
JSONResponse
response1
=
qywxSuiteApiService
.
uploadImage
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
aByte
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
response1
));
System
.
out
.
println
(
JSONObject
.
toJSONString
(
response1
));
}
}
@Test
public
void
redis
()
{
long
key
=
111
;
RedisUtil
.
setCache
(
"test-key-11"
,
key
);
Long
key2
=
111L
;
RedisUtil
.
setCache
(
"test-key-112"
,
key2
);
RedisUtil
.
setCache
(
"test-key-113"
,
1
);
int
ke22y
=
22
;
RedisUtil
.
setCache
(
"test-key-115"
,
ke22y
);
RedisUtil
.
setCache
(
"test-key-114"
,
"1"
);
}
private
byte
[]
getByte
(
String
strUrl
){
private
byte
[]
getByte
(
String
strUrl
){
ByteArrayOutputStream
baos
=
null
;
ByteArrayOutputStream
baos
=
null
;
try
try
...
...
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