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
4237444c
Commit
4237444c
authored
Jun 10, 2020
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步绑定流程
parent
a1f74bc7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
24 deletions
+62
-24
ClerkSyncPojo.java
...ava/com/gic/haoban/manage/service/pojo/ClerkSyncPojo.java
+10
-0
KafkaMessageServiceImpl.java
...c/haoban/manage/service/task/KafkaMessageServiceImpl.java
+52
-24
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/pojo/ClerkSyncPojo.java
View file @
4237444c
...
@@ -24,6 +24,16 @@ public class ClerkSyncPojo extends BinlogBasePojo {
...
@@ -24,6 +24,16 @@ public class ClerkSyncPojo extends BinlogBasePojo {
private
Integer
status
;
private
Integer
status
;
private
Integer
oldStatus
;
public
Integer
getOldStatus
()
{
return
oldStatus
;
}
public
void
setOldStatus
(
Integer
oldStatus
)
{
this
.
oldStatus
=
oldStatus
;
}
public
ClerkSyncPojo
()
{
public
ClerkSyncPojo
()
{
prefix
=
"clerk"
;
prefix
=
"clerk"
;
}
}
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/task/KafkaMessageServiceImpl.java
View file @
4237444c
...
@@ -10,6 +10,7 @@ import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
...
@@ -10,6 +10,7 @@ import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import
com.gic.haoban.manage.service.pojo.BinlogBasePojo
;
import
com.gic.haoban.manage.service.pojo.BinlogBasePojo
;
import
com.gic.haoban.manage.service.pojo.ClerkSyncPojo
;
import
com.gic.haoban.manage.service.pojo.ClerkSyncPojo
;
import
com.gic.haoban.manage.service.service.StaffClerkRelationService
;
import
com.gic.haoban.manage.service.service.StaffClerkRelationService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.apache.kafka.clients.consumer.ConsumerRecord
;
import
org.apache.kafka.clients.consumer.ConsumerRecord
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -17,10 +18,7 @@ import org.slf4j.LoggerFactory;
...
@@ -17,10 +18,7 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.kafka.listener.MessageListener
;
import
org.springframework.kafka.listener.MessageListener
;
import
java.util.Date
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* Created 2019/4/10.
* Created 2019/4/10.
...
@@ -60,31 +58,55 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
...
@@ -60,31 +58,55 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
staffClerkRelationService
.
delBind
(
syncPojo
.
getClerkId
());
staffClerkRelationService
.
delBind
(
syncPojo
.
getClerkId
());
}
else
if
(
gicRecordType
.
equals
(
GicRecordType
.
INSERT
))
{
}
else
if
(
gicRecordType
.
equals
(
GicRecordType
.
INSERT
))
{
StaffClerkRelationDTO
relationDTO
=
staffClerkRelationService
.
getOneBindCodeNoStatus
(
syncPojo
.
getEnterpriseId
(),
syncPojo
.
getClerkCode
());
StaffClerkRelationDTO
relationDTO
=
staffClerkRelationService
.
getOneBindCodeNoStatus
(
syncPojo
.
getEnterpriseId
(),
syncPojo
.
getClerkCode
());
if
(
null
==
relationDTO
)
{
moveOrAddClerk
(
syncPojo
,
relationDTO
);
logger
.
info
(
"没有关联导购,不需要新增"
);
}
else
if
(
gicRecordType
.
equals
(
GicRecordType
.
UPDATE
))
{
return
;
StaffClerkRelationDTO
relationDTO
=
new
StaffClerkRelationDTO
();
relationDTO
.
setClerkId
(
syncPojo
.
getClerkId
());
relationDTO
.
setStoreId
(
syncPojo
.
getStoreId
());
relationDTO
.
setClerkCode
(
syncPojo
.
getClerkCode
());
//非正常状态 删除
if
(!
syncPojo
.
getStatus
().
equals
(
1
))
{
staffClerkRelationService
.
delBind
(
syncPojo
.
getClerkId
());
}
else
{
List
<
String
>
clerkIds
=
new
ArrayList
<>();
clerkIds
.
add
(
syncPojo
.
getClerkId
());
StaffClerkRelationDTO
bindRelationDTO
=
staffClerkRelationService
.
getOneBindCodeNoStatus
(
syncPojo
.
getEnterpriseId
(),
syncPojo
.
getClerkCode
());
if
(
bindRelationDTO
==
null
)
{
logger
.
info
(
"没有关联导购,不需要操作"
);
return
;
}
if
(
bindRelationDTO
.
getStatusFlag
().
equals
(
StatusEnum
.
NORMAL
.
getValue
())
&&
syncPojo
.
getOldStatus
().
equals
(
1
))
{
logger
.
info
(
"更新关联信息"
);
staffClerkRelationService
.
updateByClerkId
(
relationDTO
);
}
else
{
logger
.
info
(
"走新增逻辑"
);
//走新增逻辑
moveOrAddClerk
(
syncPojo
,
bindRelationDTO
);
}
}
}
//正常的时候
}
if
(
relationDTO
.
getStatusFlag
()
!=
StatusEnum
.
DEL
.
getValue
())
{
}
private
void
moveOrAddClerk
(
ClerkSyncPojo
syncPojo
,
StaffClerkRelationDTO
relationDTO
)
{
if
(
null
==
relationDTO
)
{
logger
.
info
(
"没有关联导购,不需要新增"
);
return
;
}
//正常的时候
if
(
relationDTO
.
getStatusFlag
()
!=
StatusEnum
.
DEL
.
getValue
())
{
staffClerkRelationService
.
delBind
(
relationDTO
.
getClerkId
());
relationDTO
.
setClerkId
(
syncPojo
.
getClerkId
());
relationDTO
.
setStoreId
(
syncPojo
.
getStoreId
());
staffClerkRelationService
.
bind
(
relationDTO
);
}
else
{
//删除状态 需要判断是否近段时间有操作删除 2分组内有更新 判断是转移操作
Date
timeDiff
=
DateUtils
.
addMinutes
(
new
Date
(),
-
2
);
if
(
relationDTO
.
getUpdateTime
().
after
(
timeDiff
)){
staffClerkRelationService
.
delBind
(
relationDTO
.
getClerkId
());
staffClerkRelationService
.
delBind
(
relationDTO
.
getClerkId
());
relationDTO
.
setClerkId
(
syncPojo
.
getClerkId
());
relationDTO
.
setClerkId
(
syncPojo
.
getClerkId
());
relationDTO
.
setStoreId
(
syncPojo
.
getStoreId
());
relationDTO
.
setStoreId
(
syncPojo
.
getStoreId
());
staffClerkRelationService
.
bind
(
relationDTO
);
staffClerkRelationService
.
bind
(
relationDTO
);
}
else
{
//删除状态 需要判断是否近段时间有操作删除 2分组内有更新 判断是转移操作
Date
timeDiff
=
DateUtils
.
addMinutes
(
new
Date
(),
-
2
);
if
(
relationDTO
.
getUpdateTime
().
after
(
timeDiff
)){
staffClerkRelationService
.
delBind
(
relationDTO
.
getClerkId
());
relationDTO
.
setClerkId
(
syncPojo
.
getClerkId
());
relationDTO
.
setStoreId
(
syncPojo
.
getStoreId
());
staffClerkRelationService
.
bind
(
relationDTO
);
}
}
}
}
else
if
(
gicRecordType
.
equals
(
GicRecordType
.
UPDATE
))
{
StaffClerkRelationDTO
relationDTO
=
new
StaffClerkRelationDTO
();
relationDTO
.
setClerkId
(
syncPojo
.
getClerkId
());
relationDTO
.
setStoreId
(
syncPojo
.
getStoreId
());
relationDTO
.
setClerkCode
(
syncPojo
.
getClerkCode
());
staffClerkRelationService
.
updateByClerkId
(
relationDTO
);
}
}
}
}
...
@@ -103,7 +125,13 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
...
@@ -103,7 +125,13 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
private
BinlogBasePojo
binlogMap
(
List
<
GicField
>
list
,
GicRecordType
recordType
,
Class
<?
extends
BinlogBasePojo
>
aclass
)
{
private
BinlogBasePojo
binlogMap
(
List
<
GicField
>
list
,
GicRecordType
recordType
,
Class
<?
extends
BinlogBasePojo
>
aclass
)
{
Map
<
String
,
String
>
mid
=
new
HashMap
<>();
Map
<
String
,
String
>
mid
=
new
HashMap
<>();
for
(
GicField
gicField
:
list
)
{
for
(
GicField
gicField
:
list
)
{
mid
.
put
(
gicField
.
getName
(),
gicField
.
getValue
());
if
(
gicField
.
getName
().
equals
(
"status"
)
&&
recordType
.
equals
(
GicRecordType
.
UPDATE
)
&&!
mid
.
containsKey
(
"oldStatus"
))
{
mid
.
put
(
"oldStatus"
,
gicField
.
getValue
());
}
else
{
mid
.
put
(
gicField
.
getName
(),
gicField
.
getValue
());
}
}
}
BinlogBasePojo
pojo
=
EntityUtil
.
changeEntityByJSON
(
aclass
,
mid
);
BinlogBasePojo
pojo
=
EntityUtil
.
changeEntityByJSON
(
aclass
,
mid
);
pojo
.
setRecordType
(
recordType
.
value
());
pojo
.
setRecordType
(
recordType
.
value
());
...
...
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