Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rpc-dj-strategy
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 4b1bc8b9
authored
Jul 01, 2026
by
chenxi
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
【展业助手APP】查询客户近7天推送任务记录,查询最近一条任务执行时间逻辑重新,单独使用新SQL查询
1 parent
727f553f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
11 deletions
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/sop/SopTaskCustomerMapper.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/SopTaskCustomerService.java
rpc-dj-strategy/src/main/resources/META-INF/orm/SopTaskCustomerMapper.xml
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/sop/SopTaskCustomerMapper.java
View file @
4b1bc8b
...
@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
...
@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
@Mapper
@Mapper
public
interface
SopTaskCustomerMapper
{
public
interface
SopTaskCustomerMapper
{
...
@@ -29,4 +30,6 @@ public interface SopTaskCustomerMapper {
...
@@ -29,4 +30,6 @@ public interface SopTaskCustomerMapper {
@Param
(
"merchantId"
)
Integer
merchantId
,
@Param
(
"merchantId"
)
Integer
merchantId
,
@Param
(
"weekAgo"
)
Date
weekAgo
,
@Param
(
"weekAgo"
)
Date
weekAgo
,
@Param
(
"tomorrowStart"
)
Date
tomorrowStart
);
@Param
(
"tomorrowStart"
)
Date
tomorrowStart
);
List
<
Map
<
String
,
Object
>>
selectLastExecuteTimeByCustomerIds
(
@Param
(
"customerInstanceIds"
)
List
<
Long
>
customerInstanceIds
);
}
}
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/SopTaskCustomerService.java
View file @
4b1bc8b
...
@@ -17,10 +17,7 @@ import org.springframework.util.CollectionUtils;
...
@@ -17,10 +17,7 @@ import org.springframework.util.CollectionUtils;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.time.ZoneId
;
import
java.util.Collections
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Slf4j
@Slf4j
...
@@ -56,6 +53,7 @@ public class SopTaskCustomerService {
...
@@ -56,6 +53,7 @@ public class SopTaskCustomerService {
Page
<
CustomerSopTaskRespDTO
>
page
=
PageHelper
.
startPage
(
pagination
.
getPageNum
(),
pagination
.
getPageSize
());
Page
<
CustomerSopTaskRespDTO
>
page
=
PageHelper
.
startPage
(
pagination
.
getPageNum
(),
pagination
.
getPageSize
());
List
<
CustomerSopTaskRespDTO
>
list
=
sopTaskCustomerMapper
.
selectLastWeekReachedCustomers
(
List
<
CustomerSopTaskRespDTO
>
list
=
sopTaskCustomerMapper
.
selectLastWeekReachedCustomers
(
weekAgo
,
tomorrowStart
,
todayStart
,
condition
.
getMerchantId
());
weekAgo
,
tomorrowStart
,
todayStart
,
condition
.
getMerchantId
());
fillLastExecuteTime
(
list
);
for
(
CustomerSopTaskRespDTO
dto
:
list
)
{
for
(
CustomerSopTaskRespDTO
dto
:
list
)
{
dto
.
setConfirmBy
(
StringUtils
.
isBlank
(
dto
.
getConfirmBy
())
?
dto
.
getAdvanceUserName
()
:
dto
.
getConfirmBy
());
dto
.
setConfirmBy
(
StringUtils
.
isBlank
(
dto
.
getConfirmBy
())
?
dto
.
getAdvanceUserName
()
:
dto
.
getConfirmBy
());
}
}
...
@@ -145,6 +143,30 @@ public class SopTaskCustomerService {
...
@@ -145,6 +143,30 @@ public class SopTaskCustomerService {
return
1
;
return
1
;
}
}
private
void
fillLastExecuteTime
(
List
<
CustomerSopTaskRespDTO
>
list
)
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
;
}
List
<
Long
>
customerIds
=
list
.
stream
()
.
map
(
CustomerSopTaskRespDTO:
:
getCustomerInstanceId
)
.
filter
(
Objects:
:
nonNull
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
customerIds
))
{
return
;
}
List
<
Map
<
String
,
Object
>>
rows
=
sopTaskCustomerMapper
.
selectLastExecuteTimeByCustomerIds
(
customerIds
);
Map
<
Long
,
Date
>
lastExecuteTimeMap
=
rows
.
stream
()
.
collect
(
Collectors
.
toMap
(
row
->
(
Long
)
row
.
get
(
"customer_instance_id"
),
row
->
(
Date
)
row
.
get
(
"last_execute_time"
),
(
v1
,
v2
)
->
v2
));
for
(
CustomerSopTaskRespDTO
dto
:
list
)
{
dto
.
setLastExecuteTime
(
lastExecuteTimeMap
.
get
(
dto
.
getCustomerInstanceId
()));
}
}
private
Date
getTodayStart
()
{
private
Date
getTodayStart
()
{
return
Date
.
from
(
LocalDate
.
now
().
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
return
Date
.
from
(
LocalDate
.
now
().
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
}
}
...
...
rpc-dj-strategy/src/main/resources/META-INF/orm/SopTaskCustomerMapper.xml
View file @
4b1bc8b
...
@@ -59,7 +59,6 @@
...
@@ -59,7 +59,6 @@
SELECT
SELECT
t1.customer_instance_id,
t1.customer_instance_id,
t1.confirm_by,
t1.confirm_by,
t1.execute_time AS last_execute_time,
ci.customer_phone,
ci.customer_phone,
ci.customer_name,
ci.customer_name,
ci.customer_status,
ci.customer_status,
...
@@ -68,11 +67,6 @@
...
@@ -68,11 +67,6 @@
ci.order_handle_time,
ci.order_handle_time,
ci.advance_user_name
ci.advance_user_name
FROM sop_strategy_task t1
FROM sop_strategy_task t1
LEFT JOIN sop_strategy_task t2
ON t1.customer_instance_id = t2.customer_instance_id
AND t1.execute_time
<
t2.execute_time
AND t2.confirm_status IN (-1, 1, 2)
AND t2.deleted_flag = 'N'
LEFT JOIN sop_strategy_task t3
LEFT JOIN sop_strategy_task t3
ON t1.customer_instance_id = t3.customer_instance_id
ON t1.customer_instance_id = t3.customer_instance_id
AND t3.trigger_time >= #{todayStart}
AND t3.trigger_time >= #{todayStart}
...
@@ -83,7 +77,6 @@
...
@@ -83,7 +77,6 @@
INNER JOIN dj_car_life_customer_info ci ON t1.customer_instance_id = ci.id
INNER JOIN dj_car_life_customer_info ci ON t1.customer_instance_id = ci.id
WHERE t1.confirm_status IN (-1, 1, 2)
WHERE t1.confirm_status IN (-1, 1, 2)
AND t1.deleted_flag = 'N'
AND t1.deleted_flag = 'N'
AND t2.id IS NULL
AND t3.id IS NULL
AND t3.id IS NULL
AND ci.deleted_flag = 'N'
AND ci.deleted_flag = 'N'
AND ci.merchant_id = #{merchantId}
AND ci.merchant_id = #{merchantId}
...
@@ -143,5 +136,16 @@
...
@@ -143,5 +136,16 @@
AND a.deleted_flag = 'N'
AND a.deleted_flag = 'N'
ORDER BY t.execute_time DESC
ORDER BY t.execute_time DESC
</select>
</select>
<!-- 批量查询客户最后一次任务执行时间 -->
<select
id=
"selectLastExecuteTimeByCustomerIds"
resultType=
"java.util.HashMap"
>
SELECT customer_instance_id, MAX(execute_time) AS last_execute_time
FROM sop_strategy_task
WHERE customer_instance_id IN
<foreach
collection=
"customerInstanceIds"
item=
"id"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
AND deleted_flag = 'N'
GROUP BY customer_instance_id
</select>
</mapper>
</mapper>
Write
Preview
Markdown
is supported
Attach a file
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 post a comment