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 2fde22f2
authored
Jan 24, 2026
by
zhouhaibao
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'v5.6.0' of
http://192.168.3.233:8090/dj/rpc-dj-strategy
into v5.6.0
2 parents
d1a823d3
6242eafe
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
499 additions
and
29 deletions
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/dto/StrategyStaffCourseRelDTO.java
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/dto/StrategyStaffRecordingRelDTO.java
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/remote/StrategyInfoRemote.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/config/DataStatsConfig.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/config/DubboConfig.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/StrategyCourseRelMapper.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/StrategyInfoMapper.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/StrategyMerchantTimelineMapper.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/StrategyStaffMessageMapper.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/StrategyStaffRelMapper.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/remote/StrategyInfoRemoteImpl.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/resp/DataResp.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/StrategyCourseRelService.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/StrategyDetailService.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/StrategyInfoService.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/StrategyStaffMessageService.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/util/HttpRequestUtils.java
rpc-dj-strategy/src/main/resources/META-INF/orm/StrategyCourseRelMapper.xml
rpc-dj-strategy/src/main/resources/META-INF/orm/StrategyInfoMapper.xml
rpc-dj-strategy/src/main/resources/META-INF/orm/StrategyMerchantTimelineMapper.xml
rpc-dj-strategy/src/main/resources/META-INF/orm/StrategyStaffMessageMapper.xml
rpc-dj-strategy/src/main/resources/META-INF/orm/StrategyStaffRelMapper.xml
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/dto/StrategyStaffCourseRelDTO.java
0 → 100644
View file @
2fde22f
package
cn
.
com
.
glsx
.
dj
.
strategy
.
dto
;
import
cn.com.glsx.dj.strategy.model.StrategyCourseRel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* 策略-人员-课程 DTO
*/
@Data
public
class
StrategyStaffCourseRelDTO
extends
StrategyCourseRel
{
@ApiModelProperty
(
notes
=
"学习记录"
)
private
Object
learningRecord
;
@ApiModelProperty
(
notes
=
"课程详情"
)
private
Object
courseDetail
;
}
\ No newline at end of file
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/dto/StrategyStaffRecordingRelDTO.java
0 → 100644
View file @
2fde22f
package
cn
.
com
.
glsx
.
dj
.
strategy
.
dto
;
import
cn.com.glsx.dj.strategy.model.LearningRecord
;
import
cn.com.glsx.dj.strategy.model.StrategyRecordingRel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* 策略-人员-录音 DTO
*/
@Data
public
class
StrategyStaffRecordingRelDTO
extends
StrategyRecordingRel
{
@ApiModelProperty
(
notes
=
"学习记录"
)
private
LearningRecord
learningRecord
;
@ApiModelProperty
(
notes
=
"录音详情"
)
private
Object
recordingDetail
;
}
\ No newline at end of file
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/remote/StrategyInfoRemote.java
View file @
2fde22f
...
...
@@ -55,4 +55,9 @@ public interface StrategyInfoRemote {
@ApiParam
(
name
=
"pagination"
,
notes
=
"分页查询条件"
,
dataType
=
ApiParam
.
DataTypeEnum
.
OBJECT
,
required
=
true
)
@ApiResponse
(
"策略分页列表"
)
RpcResponse
<
RpcPagination
<
StrategyInfo
>>
selectStrategyInfoPage
(
RpcPagination
<
StrategyInfo
>
pagination
);
@ApiMethod
(
"策略中心-门店分析-历史人员记录"
)
@ApiParam
(
name
=
"merchantId"
,
notes
=
"查询条件"
,
dataType
=
ApiParam
.
DataTypeEnum
.
OBJECT
,
required
=
true
)
@ApiResponse
(
"策略中心-门店分析-历史人员记录"
)
RpcResponse
<
List
<
StaffHistoryRecordDTO
>>
listMerchantAnalysisEmployeeHistory
(
Integer
merchantId
,
Integer
bizs
);
}
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/config/DataStatsConfig.java
0 → 100644
View file @
2fde22f
package
cn
.
com
.
glsx
.
dj
.
strategy
.
config
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
DataStatsConfig
{
/** 无品牌时的默认传参 */
@Value
(
"${default.brand.id:-1,-2,3454,-4}"
)
public
String
defaultBrandId
;
}
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/config/DubboConfig.java
View file @
2fde22f
...
...
@@ -6,6 +6,7 @@ import cn.com.glsx.dj.peanalysis.remote.BusinessSceneAnalysisRemote;
import
cn.com.glsx.dj.riskmanage.remote.LearningCenterCourseRemote
;
import
cn.com.glsx.dj.smartcarlife.remote.MerchantGoodsInfoRemote
;
import
cn.com.glsx.dj.smartcarlife.remote.PayOrderRemote
;
import
cn.com.glsx.dj.smartcarlife.remote.StaffInfoRemote
;
import
org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -73,5 +74,9 @@ public class DubboConfig {
}
@Bean
public
StaffInfoRemote
staffInfoRemote
()
{
return
factory
.
builder
(
StaffInfoRemote
.
class
).
check
(
check
).
version
(
"1.0.0"
).
timeout
(
timeout
).
build
();
}
}
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/StrategyCourseRelMapper.java
View file @
2fde22f
package
cn
.
com
.
glsx
.
dj
.
strategy
.
mapper
;
import
cn.com.glsx.dj.riskmanage.model.course.BeiSenCourse
;
import
cn.com.glsx.dj.riskmanage.model.course.BeiSenCourseStaff
;
import
cn.com.glsx.dj.strategy.model.StrategyCourseRel
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
java.util.List
;
@Mapper
public
interface
StrategyCourseRelMapper
extends
OreMapper
<
StrategyCourseRel
>
{
List
<
BeiSenCourseStaff
>
queryCourseLearnSituation
(
@Param
(
"beisenUserId"
)
Integer
beisenUserId
,
@Param
(
"courseIdList"
)
List
<
String
>
courseIdList
);
List
<
BeiSenCourse
>
queryCourseDetail
(
@Param
(
"courseIdList"
)
List
<
String
>
courseIdList
);
}
\ No newline at end of file
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/StrategyInfoMapper.java
View file @
2fde22f
...
...
@@ -85,4 +85,14 @@ public interface StrategyInfoMapper extends OreMapper<StrategyInfo> {
* @return 未完成策略任务的策略-人员信息列表
*/
List
<
Integer
>
selectUnfinishedStrategyStaffList
();
/**
* 查询临时支援的员工UUID列表
*
* @param merchantId
* @param yearMonth
* @param userUuidList
* @return
*/
List
<
String
>
selectStaffTempSupport
(
@Param
(
"merchantId"
)
Integer
merchantId
,
@Param
(
"yearMonth"
)
String
yearMonth
,
@Param
(
"userUuidList"
)
List
<
String
>
userUuidList
);
}
\ No newline at end of file
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/StrategyMerchantTimelineMapper.java
View file @
2fde22f
...
...
@@ -2,7 +2,12 @@ package cn.com.glsx.dj.strategy.mapper;
import
cn.com.glsx.dj.strategy.model.StrategyMerchantTimeline
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
java.util.List
;
@Mapper
public
interface
StrategyMerchantTimelineMapper
extends
OreMapper
<
StrategyMerchantTimeline
>
{
List
<
StrategyMerchantTimeline
>
selectMerchantTimeline
(
@Param
(
"merchantId"
)
Integer
merchantId
,
@Param
(
"bizs"
)
Integer
bizs
);
}
\ No newline at end of file
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/StrategyStaffMessageMapper.java
View file @
2fde22f
package
cn
.
com
.
glsx
.
dj
.
strategy
.
mapper
;
import
cn.com.glsx.dj.strategy.dto.TaskStrategyIssueResponse
;
import
cn.com.glsx.dj.strategy.model.StrategyStaffMessage
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
java.util.List
;
@Mapper
public
interface
StrategyStaffMessageMapper
extends
OreMapper
<
StrategyStaffMessage
>
{
...
...
@@ -14,4 +17,13 @@ public interface StrategyStaffMessageMapper extends OreMapper<StrategyStaffMessa
* @return 更新记录数
*/
int
updateReadStatusByMessageId
(
@Param
(
"messageId"
)
Integer
messageId
);
/**
* 根据策略id查询策略推送记录
* @author yangwei
* @since 2026/1/23 15:22
* @param strategyId 策略id
* @return java.util.List<cn.com.glsx.dj.strategy.dto.TaskStrategyIssueResponse>
*/
List
<
TaskStrategyIssueResponse
>
selectStaffMessageByStrategyId
(
@Param
(
"strategyId"
)
Integer
strategyId
);
}
\ No newline at end of file
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/StrategyStaffRelMapper.java
View file @
2fde22f
...
...
@@ -2,7 +2,9 @@ package cn.com.glsx.dj.strategy.mapper;
import
cn.com.glsx.dj.strategy.model.StrategyStaffRel
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
@Mapper
public
interface
StrategyStaffRelMapper
extends
OreMapper
<
StrategyStaffRel
>
{
StrategyStaffRel
selectByStrategyIdAndStaffId
(
@Param
(
"strategyId"
)
Integer
strategyId
,
@Param
(
"userUuid"
)
String
userUuid
);
}
\ No newline at end of file
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/remote/StrategyInfoRemoteImpl.java
View file @
2fde22f
...
...
@@ -149,4 +149,18 @@ public class StrategyInfoRemoteImpl implements StrategyInfoRemote {
return
RpcResponse
.
error
(
DefaultErrorEnum
.
SERVICE_ERROR
,
e
.
getMessage
());
}
}
@Override
public
RpcResponse
<
List
<
StaffHistoryRecordDTO
>>
listMerchantAnalysisEmployeeHistory
(
Integer
merchantId
,
Integer
bizs
)
{
try
{
List
<
StaffHistoryRecordDTO
>
list
=
strategyInfoService
.
listMerchantAnalysisEmployeeHistory
(
merchantId
,
bizs
);
return
RpcResponse
.
success
(
list
);
}
catch
(
RpcServiceException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
RpcResponse
.
error
(
e
.
getError
(),
e
.
getMessage
());
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
RpcResponse
.
error
(
DefaultErrorEnum
.
SERVICE_ERROR
,
e
.
getMessage
());
}
}
}
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/resp/DataResp.java
0 → 100644
View file @
2fde22f
package
cn
.
com
.
glsx
.
dj
.
strategy
.
resp
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.ToString
;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public
class
DataResp
<
T
>
{
private
Integer
code
;
private
String
msg
;
private
T
content
;
}
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/StrategyCourseRelService.java
View file @
2fde22f
package
cn
.
com
.
glsx
.
dj
.
strategy
.
service
;
import
cn.com.glsx.dj.riskmanage.model.course.BeiSenCourse
;
import
cn.com.glsx.dj.riskmanage.model.course.BeiSenCourseStaff
;
import
cn.com.glsx.dj.strategy.mapper.StrategyCourseRelMapper
;
import
cn.com.glsx.dj.strategy.model.StrategyCourseRel
;
import
cn.com.glsx.dj.strategy.model.StrategyInfo
;
...
...
@@ -64,4 +66,12 @@ public class StrategyCourseRelService {
.
andEqualTo
(
"deletedFlag"
,
DeleteFlagEnum
.
N
.
getValue
());
return
strategyCourseRelMapper
.
selectByExample
(
example
);
}
public
List
<
BeiSenCourseStaff
>
queryCourseLearnSituation
(
Integer
beisenUserId
,
List
<
String
>
courseIdList
)
{
return
strategyCourseRelMapper
.
queryCourseLearnSituation
(
beisenUserId
,
courseIdList
);
}
public
List
<
BeiSenCourse
>
queryCourseDetail
(
List
<
String
>
courseIdList
)
{
return
strategyCourseRelMapper
.
queryCourseDetail
(
courseIdList
);
}
}
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/StrategyDetailService.java
View file @
2fde22f
...
...
@@ -13,7 +13,6 @@ import cn.com.glsx.dj.strategy.mapper.StrategyInfoMapper;
import
cn.com.glsx.dj.strategy.mapper.StrategyStaffMessageMapper
;
import
cn.com.glsx.dj.strategy.mapper.StrategyStaffRelMapper
;
import
cn.com.glsx.dj.strategy.model.StrategyInfo
;
import
cn.com.glsx.dj.strategy.model.StrategyStaffMessage
;
import
cn.com.glsx.dj.strategy.model.StrategyStaffRel
;
import
cn.com.glsx.dj.strategy.util.LocalDateUtil
;
import
cn.com.glsx.dj.strategy.util.PercentageCalculator
;
...
...
@@ -38,6 +37,7 @@ import org.springframework.stereotype.Service;
import
tk.mybatis.mapper.entity.Example
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
...
...
@@ -109,34 +109,32 @@ public class StrategyDetailService {
result
.
setExecutePersons
(
BeanUtil
.
copyToList
(
strategyStaffRelList
,
OperatorResponse
.
class
,
CopyOptions
.
create
().
setFieldMapping
(
MapUtil
.<
String
,
String
>
builder
()
.
put
(
"userUuid"
,
"uuid"
)
.
put
(
"userName"
,
"username"
).
build
())));
CopyOptions
.
create
()
.
setFieldMapping
(
MapUtil
.<
String
,
String
>
builder
()
.
put
(
"userUuid"
,
"uuid"
)
.
put
(
"userName"
,
"username"
).
build
())));
break
;
case
FINAL_INVENTORY:
case
POWERFUL_PROMOTION:
RpcResponse
<
StrategyOrderStatisticsRespDTO
>
strategyOrderInfoResponse
=
biAnalyseBackgroundRemote
.
getStrategyOrderInfo
(
strategyOrderStatisticsBuilder
(
strategyInfo
,
strategyByValue
));
// 订单统计
StrategyOrderStatisticsDTO
strategyOrderStatisticsDTO
=
strategyOrderStatisticsBuilder
(
strategyInfo
,
strategyByValue
);
log
.
info
(
"strategyId: {} order statistics rpc strategyOrderStatisticsDTO:{}"
,
strategyInfo
.
getId
(),
strategyOrderStatisticsDTO
);
RpcResponse
<
StrategyOrderStatisticsRespDTO
>
strategyOrderInfoResponse
=
biAnalyseBackgroundRemote
.
getStrategyOrderInfo
(
strategyOrderStatisticsDTO
);
if
(
strategyOrderInfoResponse
.
isFailed
())
{
throw
new
RpcServiceException
(
strategyOrderInfoResponse
.
getError
(),
strategyOrderInfoResponse
.
getMessage
());
}
StrategyOrderStatisticsRespDTO
strategyOrderStatisticsRespDTO
=
Optional
.
ofNullable
(
strategyOrderInfoResponse
.
getResult
()).
orElseGet
(
StrategyOrderStatisticsRespDTO:
:
new
);
result
.
setOrderTotalCount
(
strategyOrderStatisticsRespDTO
.
getOrderCount
());
result
.
setOrderTotalAmount
(
strategyOrderStatisticsRespDTO
.
getTotalPrice
(
));
result
.
setDiscountTotalAmount
(
strategyOrderStatisticsRespDTO
.
getDiscountPrice
(
));
result
.
setOrderTotalAmount
(
Optional
.
ofNullable
(
strategyOrderStatisticsRespDTO
.
getTotalPrice
()).
orElse
(
BigDecimal
.
ZERO
).
setScale
(
2
,
RoundingMode
.
HALF_UP
));
result
.
setDiscountTotalAmount
(
Optional
.
ofNullable
(
strategyOrderStatisticsRespDTO
.
getDiscountPrice
()).
orElse
(
BigDecimal
.
ZERO
).
setScale
(
2
,
RoundingMode
.
HALF_UP
));
break
;
default
:
throw
new
RpcServiceException
(
StrategyErrorEnum
.
STRATEGY_TYPE_NOT_SUPPORTED
);
}
}
else
if
(
StrategyTypeEnum
.
TASK
.
equals
(
strategyByValue
))
{
Example
staffMessageExample
=
new
Example
(
StrategyStaffMessage
.
class
);
staffMessageExample
.
orderBy
(
"id"
).
asc
();
staffMessageExample
.
createCriteria
()
.
andEqualTo
(
"strategyId"
,
request
.
getStrategyId
())
.
andEqualTo
(
"deletedFlag"
,
DeleteFlagEnum
.
N
.
getValue
());
List
<
StrategyStaffMessage
>
strategyStaffMessageList
=
strategyStaffMessageMapper
.
selectByExample
(
staffMessageExample
);
result
.
getTaskStrategyIssueList
().
addAll
(
BeanUtil
.
copyToList
(
strategyStaffMessageList
,
TaskStrategyIssueResponse
.
class
));
List
<
TaskStrategyIssueResponse
>
taskStrategyIssueResponses
=
strategyStaffMessageMapper
.
selectStaffMessageByStrategyId
(
request
.
getStrategyId
());
result
.
getTaskStrategyIssueList
().
addAll
(
taskStrategyIssueResponses
);
}
else
{
throw
new
RpcServiceException
(
StrategyErrorEnum
.
STRATEGY_TYPE_NOT_SUPPORTED
);
}
...
...
@@ -246,9 +244,12 @@ public class StrategyDetailService {
*/
public
List
<
StrategyTypeStatisticsRespDTO
>
findStrategyTypeDistribution
(
StrategyTypeStatisticsDTO
request
)
{
List
<
StrategyTypeStatisticsRespDTO
>
result
=
strategyInfoMapper
.
findStrategyTypeDistribution
(
request
);
Map
<
Integer
,
StrategyTypeStatisticsRespDTO
>
strategyTypeMapStatistics
=
Optional
.
ofNullable
(
result
)
.
orElseGet
(
ArrayList:
:
new
)
.
stream
()
if
(
CollUtil
.
isEmpty
(
result
))
{
log
.
info
(
"策略类型分布结果为空"
);
return
Lists
.
newArrayList
();
}
Map
<
Integer
,
StrategyTypeStatisticsRespDTO
>
strategyTypeMapStatistics
=
result
.
stream
()
.
collect
(
Collectors
.
toMap
(
StrategyTypeStatisticsRespDTO:
:
getStrategyType
,
Function
.
identity
()));
// 计算占比
...
...
@@ -264,6 +265,7 @@ public class StrategyDetailService {
List
<
PercentageResultDTO
<
Integer
>>
percentageResults
=
PercentageCalculator
.
calculateAdjustPercentage
(
statisticItems
,
true
,
0
);
return
percentageResults
.
stream
()
.
sorted
((
o1
,
o2
)
->
Optional
.
ofNullable
(
o2
.
getValue
()).
orElse
(
BigDecimal
.
ZERO
).
compareTo
(
Optional
.
ofNullable
(
o1
.
getValue
()).
orElse
(
BigDecimal
.
ZERO
)))
.
map
(
percentageResultDTO
->
StrategyTypeStatisticsRespDTO
.
builder
()
.
strategyType
(
percentageResultDTO
.
getDimension
())
...
...
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/StrategyInfoService.java
View file @
2fde22f
This diff is collapsed.
Click to expand it.
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/StrategyStaffMessageService.java
View file @
2fde22f
...
...
@@ -3,20 +3,29 @@ package cn.com.glsx.dj.strategy.service;
import
cn.com.glsx.dj.mindworkplate.dto.ConversationBatchDTO
;
import
cn.com.glsx.dj.mindworkplate.model.warning.LearningEffectAnalysisRequest
;
import
cn.com.glsx.dj.mindworkplate.remote.MonitoringRemote
;
import
cn.com.glsx.dj.riskmanage.model.course.BeiSenCourse
;
import
cn.com.glsx.dj.riskmanage.model.course.BeiSenCourseStaff
;
import
cn.com.glsx.dj.strategy.dto.StrategyStaffCourseRelDTO
;
import
cn.com.glsx.dj.strategy.dto.StrategyStaffRecordingRelDTO
;
import
cn.com.glsx.dj.strategy.enums.StrategyTypeEnum
;
import
cn.com.glsx.dj.strategy.mapper.LearningRecordMapper
;
import
cn.com.glsx.dj.strategy.mapper.StrategyInfoMapper
;
import
cn.com.glsx.dj.strategy.mapper.StrategyStaffMessageMapper
;
import
cn.com.glsx.dj.strategy.model.StrategyInfo
;
import
cn.com.glsx.dj.strategy.model.StrategyRecordingRel
;
import
cn.com.glsx.dj.strategy.model.StrategyStaffMessage
;
import
cn.com.glsx.dj.strategy.mapper.StrategyStaffRelMapper
;
import
cn.com.glsx.dj.strategy.model.*
;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.hutool.core.bean.BeanUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -35,6 +44,15 @@ public class StrategyStaffMessageService {
@Autowired
private
StrategyRecordingRelService
strategyRecordingRelService
;
@Autowired
private
LearningRecordMapper
learningRecordMapper
;
@Autowired
private
StrategyCourseRelService
strategyCourseRelService
;
@Autowired
private
StrategyStaffRelMapper
strategyStaffRelMapper
;
/**
* 根据消息盒子ID和手机号更新业务消息记录的已读状态
* @param messageId 消息盒子ID
...
...
@@ -74,10 +92,17 @@ public class StrategyStaffMessageService {
}
else
if
(
StrategyTypeEnum
.
EXCELLENT_RECORDING_SHARE
.
equals
(
strategyInfo
.
getStrategyType
()))
{
// 查询策略关联的全部录音
List
<
StrategyRecordingRel
>
strategyRecordingRels
=
strategyRecordingRelService
.
queryStrategyRecordingRelList
(
strategyId
);
List
<
StrategyStaffRecordingRelDTO
>
strategyStaffRecordingRelDTOS
=
BeanUtil
.
copyToList
(
strategyRecordingRels
,
StrategyStaffRecordingRelDTO
.
class
);
List
<
Integer
>
recordIdList
=
strategyRecordingRels
.
stream
().
map
(
StrategyRecordingRel:
:
getRecordingId
).
collect
(
Collectors
.
toList
());
Map
<
Integer
,
LearningRecord
>
learningRecordMap
=
new
HashMap
<>();
List
<
LearningRecord
>
learningRecords
=
learningRecordMapper
.
queryLearningRecordList
(
recordIdList
,
Collections
.
singletonList
(
staffMessage
.
getUuid
()));
if
(
CollectionUtils
.
isNotEmpty
(
learningRecords
))
{
learningRecords
.
stream
().
map
(
learningRecord
->
learningRecordMap
.
put
(
Integer
.
valueOf
(
learningRecord
.
getRecordingId
()),
learningRecord
));
}
LearningEffectAnalysisRequest
condition
=
new
LearningEffectAnalysisRequest
();
condition
.
setStaffPhone
(
staffMessage
.
getPhone
());
condition
.
setRecordIdList
(
strategyRecordingRels
.
stream
().
map
(
StrategyRecordingRel:
:
getRecordingId
).
collect
(
Collectors
.
toList
()));
condition
.
setRecordIdList
(
recordIdList
);
RpcPagination
<
LearningEffectAnalysisRequest
>
request
=
new
RpcPagination
<>();
request
.
setPageNum
(
1
);
...
...
@@ -85,17 +110,54 @@ public class StrategyStaffMessageService {
request
.
setCondition
(
condition
);
RpcResponse
<
RpcPagination
<
ConversationBatchDTO
>>
recordPageListByCondition
=
monitoringRemote
.
getRecordPageListByCondition
(
request
);
if
(
recordPageListByCondition
.
isSuccess
())
{
return
recordPageListByCondition
.
getResult
().
getList
();
}
else
{
if
(!
recordPageListByCondition
.
isSuccess
())
{
log
.
warn
(
"查询录音详情失败,messageId:{}"
,
messageId
);
return
null
;
}
Map
<
Integer
,
ConversationBatchDTO
>
conversationBatchDTOMap
=
new
HashMap
<>();
List
<
ConversationBatchDTO
>
conversationBatchDTOS
=
recordPageListByCondition
.
getResult
().
getList
();
conversationBatchDTOS
.
forEach
(
conversationBatchDTO
->
conversationBatchDTOMap
.
put
(
conversationBatchDTO
.
getId
(),
conversationBatchDTO
));
for
(
StrategyStaffRecordingRelDTO
dto
:
strategyStaffRecordingRelDTOS
)
{
dto
.
setRecordingDetail
(
conversationBatchDTOMap
.
get
(
dto
.
getRecordingId
()));
dto
.
setLearningRecord
(
learningRecordMap
.
get
(
dto
.
getRecordingId
()));
}
return
strategyStaffRecordingRelDTOS
;
}
else
if
(
StrategyTypeEnum
.
LEARNING
.
equals
(
strategyInfo
.
getStrategyType
()))
{
// 查询策略关联的全部课程
List
<
StrategyCourseRel
>
strategyCourseRels
=
strategyCourseRelService
.
queryStrategyCourseRelList
(
strategyId
);
List
<
StrategyStaffCourseRelDTO
>
strategyStaffCourseRelDTOS
=
BeanUtil
.
copyToList
(
strategyCourseRels
,
StrategyStaffCourseRelDTO
.
class
);
return
null
;
// 查询单个策略-人员关联关系
StrategyStaffRel
strategyStaffRel
=
strategyStaffRelMapper
.
selectByStrategyIdAndStaffId
(
strategyId
,
staffMessage
.
getUuid
());
// 查询课程学习情况
List
<
String
>
courseIdList
=
strategyCourseRels
.
stream
().
map
(
StrategyCourseRel:
:
getCourseId
).
collect
(
Collectors
.
toList
());
Map
<
String
,
BeiSenCourseStaff
>
beisenCourseStaffMap
=
new
HashMap
<>();
List
<
BeiSenCourseStaff
>
beisenCourseStaffs
=
strategyCourseRelService
.
queryCourseLearnSituation
(
strategyStaffRel
.
getBeisenUserId
(),
courseIdList
);
if
(
CollectionUtils
.
isNotEmpty
(
beisenCourseStaffs
))
{
beisenCourseStaffs
.
stream
().
map
(
beisenCourseStaff
->
beisenCourseStaffMap
.
put
(
beisenCourseStaff
.
getCourseId
(),
beisenCourseStaff
));
}
// 查询课程详情
Map
<
String
,
BeiSenCourse
>
courseMap
=
new
HashMap
<>();
List
<
BeiSenCourse
>
courseDetails
=
strategyCourseRelService
.
queryCourseDetail
(
courseIdList
);
if
(
CollectionUtils
.
isNotEmpty
(
courseDetails
))
{
courseDetails
.
stream
().
map
(
courseDetail
->
courseMap
.
put
(
courseDetail
.
getId
(),
courseDetail
));
}
// 封装数据返回
strategyStaffCourseRelDTOS
.
forEach
(
dto
->
{
dto
.
setLearningRecord
(
beisenCourseStaffMap
.
get
(
dto
.
getCourseId
()));
dto
.
setCourseDetail
(
courseMap
.
get
(
dto
.
getCourseId
()));
});
return
strategyStaffCourseRelDTOS
;
}
else
{
// 其他类型,返回null
TODO 待实现 0-学习类,1-优秀录音分享类,剩余类型暂时无推送消息
// 其他类型,返回null
return
null
;
}
}
...
...
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/util/HttpRequestUtils.java
0 → 100644
View file @
2fde22f
package
cn
.
com
.
glsx
.
dj
.
strategy
.
util
;
import
cn.com.glsx.dj.peanalysis.dto.DataBusinessDTO
;
import
cn.com.glsx.dj.strategy.resp.DataResp
;
import
cn.hutool.core.lang.TypeReference
;
import
cn.hutool.json.JSONUtil
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.OutputStream
;
import
java.math.BigDecimal
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.nio.charset.StandardCharsets
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
HttpRequestUtils
{
private
static
final
String
DEFAULT_USER_AGENT
=
"Java-HttpRequestUtils/1.0"
;
private
static
final
int
DEFAULT_CONNECT_TIMEOUT
=
30000
;
// 30秒
private
static
final
int
DEFAULT_READ_TIMEOUT
=
60000
;
// 60秒
/**
* 发送 POST 请求(JSON 数据)
*
* @param urlStr 目标 URL
* @param jsonBody JSON 格式的请求体
* @return 响应内容字符串
* @throws IOException 网络异常
*/
public
static
String
postJson
(
String
urlStr
,
String
jsonBody
)
throws
IOException
{
return
post
(
urlStr
,
jsonBody
,
"application/json; charset=utf-8"
);
}
/**
* 发送 POST 请求(表单数据)
*
* @param urlStr 目标 URL
* @param formData 表单参数(如:key1=value1&key2=value2)
* @return 响应内容字符串
* @throws IOException 网络异常
*/
public
static
String
postForm
(
String
urlStr
,
String
formData
)
throws
IOException
{
return
post
(
urlStr
,
formData
,
"application/x-www-form-urlencoded; charset=utf-8"
);
}
/**
* 通用 POST 方法(支持自定义请求头和超时)
*
* @param urlStr 目标 URL
* @param body 请求体内容
* @param contentType 内容类型
* @param headers 自定义请求头(可选)
* @param connectTimeout 连接超时(毫秒)
* @param readTimeout 读取超时(毫秒)
* @return 响应内容字符串
* @throws IOException 网络异常
*/
public
static
String
post
(
String
urlStr
,
String
body
,
String
contentType
,
Map
<
String
,
String
>
headers
,
int
connectTimeout
,
int
readTimeout
)
throws
IOException
{
URL
url
=
new
URL
(
urlStr
);
HttpURLConnection
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
// 配置请求
connection
.
setRequestMethod
(
"POST"
);
connection
.
setDoOutput
(
true
);
connection
.
setRequestProperty
(
"Content-Type"
,
contentType
);
connection
.
setRequestProperty
(
"User-Agent"
,
DEFAULT_USER_AGENT
);
// 添加自定义请求头
if
(
headers
!=
null
)
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
headers
.
entrySet
())
{
connection
.
setRequestProperty
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
// 设置超时
connection
.
setConnectTimeout
(
connectTimeout
);
connection
.
setReadTimeout
(
readTimeout
);
// 写入请求体
try
(
OutputStream
os
=
connection
.
getOutputStream
())
{
byte
[]
input
=
body
.
getBytes
(
StandardCharsets
.
UTF_8
);
os
.
write
(
input
,
0
,
input
.
length
);
}
// 处理响应
int
responseCode
=
connection
.
getResponseCode
();
if
(
responseCode
==
HttpURLConnection
.
HTTP_OK
)
{
try
(
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
(),
StandardCharsets
.
UTF_8
)))
{
StringBuilder
response
=
new
StringBuilder
();
String
line
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
response
.
append
(
line
);
}
return
response
.
toString
();
}
}
else
{
throw
new
IOException
(
"HTTP error code: "
+
responseCode
+
" - "
+
getErrorResponse
(
connection
));
}
}
// 重载方法(默认值)
public
static
String
post
(
String
urlStr
,
String
body
,
String
contentType
)
throws
IOException
{
return
post
(
urlStr
,
body
,
contentType
,
null
,
DEFAULT_CONNECT_TIMEOUT
,
DEFAULT_READ_TIMEOUT
);
}
// 重载:JSON POST
public
static
String
postJson
(
String
urlStr
,
String
jsonBody
,
Map
<
String
,
String
>
headers
)
throws
IOException
{
return
post
(
urlStr
,
jsonBody
,
"application/json; charset=utf-8"
,
headers
,
DEFAULT_CONNECT_TIMEOUT
,
DEFAULT_READ_TIMEOUT
);
}
// 重载:表单 POST
public
static
String
postForm
(
String
urlStr
,
String
formData
,
Map
<
String
,
String
>
headers
)
throws
IOException
{
return
post
(
urlStr
,
formData
,
"application/x-www-form-urlencoded; charset=utf-8"
,
headers
,
DEFAULT_CONNECT_TIMEOUT
,
DEFAULT_READ_TIMEOUT
);
}
// 获取错误响应体
private
static
String
getErrorResponse
(
HttpURLConnection
connection
)
throws
IOException
{
try
(
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getErrorStream
(),
StandardCharsets
.
UTF_8
)))
{
StringBuilder
errorResponse
=
new
StringBuilder
();
String
line
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
errorResponse
.
append
(
line
);
}
return
errorResponse
.
toString
();
}
catch
(
IOException
e
)
{
return
"Error reading error stream"
;
}
}
// 示例:调用方式
public
static
void
main
(
String
[]
args
)
{
try
{
// 带自定义请求头的 JSON 请求
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
String
jsonResponse
=
postJson
(
"http://192.168.3.211:8021/data"
,
"{\n"
+
" \"bizs\": 1,\n"
+
" \"brandIds\": \"-1,-3\",\n"
+
" \"dateType\": 2,\n"
+
" \"endDate\": \"2025-12-31\",\n"
+
" \"exts\": \"merchantIds\",\n"
+
" \"merchantIds\":\"44218026\",\n"
+
" \"itemCodes\": \"A036\",\n"
+
" \"startDate\": \"2025-01-01\"\n"
+
"}"
,
headers
);
DataResp
<
List
<
DataBusinessDTO
>>
dataResp
=
JSONUtil
.
toBean
(
jsonResponse
,
new
TypeReference
<
DataResp
<
List
<
DataBusinessDTO
>>>()
{
},
true
);
// DataResp<List<DataBusinessDTO>> dataResp = JSON.parseObject(jsonResponse, new TypeReference<DataResp<List<DataBusinessDTO>>>() {});
// System.out.println("JSON Response: " + DateUtil.format(DateUtil.offsetMonth(DateUtil.parse(String.valueOf(2024), "yyyy"), -0), "yyyy-MM"));
// 获取指定年份的12个月
// for (int i = 0; i <= 11; i++) {
// String yyyyMM = DateUtil.format(DateUtil.offsetMonth(DateUtil.parse(String.valueOf(2024), "yyyy"), i), "yyyy-MM");
// System.out.println(yyyyMM);
// }
// for (int i = 10; i >= 1; i--) {
// String yyyyMM = DateUtil.format(DateUtil.offsetMonth(DateUtil.date(), -i + 1), "yyyy-MM");
// System.out.println(yyyyMM);
// }
// 示例数据:已完成量和总量
// BigDecimal completed = new BigDecimal("123.45789");
// BigDecimal total = new BigDecimal("1000");
// 计算完成率(百分比)并保留两位小数
// BigDecimal rate = NumberUtil.div(completed, total, 4, RoundingMode.HALF_UP)
// .multiply(new BigDecimal("100"))
// .setScale(2, RoundingMode.HALF_UP);
//
// System.out.println("完成率: " + rate + "%"); // 输出: 12.35%
int
i
=
new
BigDecimal
(
"30000"
).
compareTo
(
new
BigDecimal
(
"1000"
));
System
.
out
.
println
(
i
);
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Request failed: "
+
e
.
getMessage
());
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
rpc-dj-strategy/src/main/resources/META-INF/orm/StrategyCourseRelMapper.xml
View file @
2fde22f
...
...
@@ -38,4 +38,25 @@
WHERE cr.strategy_id = #{strategyId,jdbcType=INTEGER}
AND cr.deleted_flag = 'N'
</select>
<select
id=
"queryCourseLearnSituation"
resultType=
"cn.com.glsx.dj.riskmanage.model.course.BeiSenCourseStaff"
>
SELECT
*
FROM dj_beisen_course_staff
WHERE deleted_flag = 'N'
and user_id = #{beisenUserId,jdbcType=INTEGER}
and course_id IN
<foreach
collection=
"courseIdList"
item=
"id"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</select>
<select
id=
"queryCourseDetail"
resultType=
"cn.com.glsx.dj.riskmanage.model.course.BeiSenCourse"
>
SELECT
*
FROM dj_beisen_course
WHERE id IN
<foreach
collection=
"courseIdList"
item=
"id"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</select>
</mapper>
\ No newline at end of file
rpc-dj-strategy/src/main/resources/META-INF/orm/StrategyInfoMapper.xml
View file @
2fde22f
...
...
@@ -218,4 +218,22 @@
AND l.id IS NULL
group by ssr.id
</select>
<select
id=
"selectStaffTempSupport"
resultType=
"java.lang.String"
>
SELECT DISTINCT
ssr.user_uuid
FROM dj_car_life_strategy_info si
INNER JOIN dj_car_life_strategy_staff_rel ssr ON si.id = ssr.strategy_id
WHERE si.deleted_flag = 'N'
AND ssr.deleted_flag = 'N'
AND si.strategy_type IN (2, 4)
AND si.end_date IS NOT NULL
AND si.start_date IS NOT NULL
AND si.merchant_id = #{merchantId}
AND DATE_FORMAT(si.start_date, '%Y-%m')
<
= #{yearMonth}
AND DATE_FORMAT(si.end_date, '%Y-%m') >= #{yearMonth}
AND user_uuid in
<foreach
item=
"userUuidList"
index=
"index"
collection=
"uuids"
open=
"("
separator=
","
close=
")"
>
#{uuid}
</foreach>
</select>
</mapper>
\ No newline at end of file
rpc-dj-strategy/src/main/resources/META-INF/orm/StrategyMerchantTimelineMapper.xml
View file @
2fde22f
...
...
@@ -22,4 +22,14 @@
id, merchant_id, node_type, node_date, created_by, created_date, updated_by, updated_date,
deleted_flag
</sql>
<select
id=
"selectMerchantTimeline"
resultMap=
"BaseResultMap"
>
SELECT
<include
refid=
"Base_Column_List"
/>
FROM dj_car_life_strategy_merchant_timeline
WHERE deleted_flag = 'N'
AND merchant_id = #{merchantId}
AND biz = #{bizs}
ORDER BY node_date ASC
</select>
</mapper>
\ No newline at end of file
rpc-dj-strategy/src/main/resources/META-INF/orm/StrategyStaffMessageMapper.xml
View file @
2fde22f
...
...
@@ -41,4 +41,20 @@
WHERE message_id = #{messageId,jdbcType=INTEGER}
AND deleted_flag = 'N'
</update>
<select
id=
"selectStaffMessageByStrategyId"
resultType=
"cn.com.glsx.dj.strategy.dto.TaskStrategyIssueResponse"
>
select
t1.id,
t1.strategy_id as strategyId,
t1.uuid as uuid,
t1.phone as phone,
t1.staff_name as staffName,
t2.user_position as userPosition,
t1.read_status as readStatus,
t1.read_time as readTime
from dj_car_life_strategy_staff_message t1
join dj_car_life_strategy_staff_rel t2 on t1.strategy_id = t2.strategy_id and t1.uuid = t2.user_uuid
where t1.deleted_flag = 'N' and t2.deleted_flag = 'N' and t1.strategy_id = #{strategyId}
</select>
</mapper>
\ No newline at end of file
rpc-dj-strategy/src/main/resources/META-INF/orm/StrategyStaffRelMapper.xml
View file @
2fde22f
...
...
@@ -30,4 +30,12 @@
WHERE strategy_id = #{strategyId,jdbcType=INTEGER}
AND deleted_flag = 'N'
</select>
<select
id=
"selectByStrategyIdAndStaffId"
resultType=
"cn.com.glsx.dj.strategy.model.StrategyStaffRel"
>
SELECT
<include
refid=
"Base_Column_List"
/>
FROM dj_car_life_strategy_staff_rel
WHERE strategy_id = #{strategyId,jdbcType=INTEGER}
AND user_uuid = #{userUuid,jdbcType=VARCHAR}
AND deleted_flag = 'N'
</select>
</mapper>
\ No newline at end of file
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