Commit b0d2725a by zhouhaibao

Merge branch 'v5.6.0' of http://192.168.3.233:8090/dj/rpc-dj-strategy into v5.6.0

2 parents 77f6fa6c 71cddbcc
package cn.com.glsx.dj.strategy.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* 门店策略统计
......@@ -11,6 +13,7 @@ import java.io.Serializable;
* @since 2026/01/22 16:29
*/
@Data
@Accessors(chain = true)
public class MerchantStrategyStatisticsRespDTO implements Serializable {
/**
......@@ -22,4 +25,14 @@ public class MerchantStrategyStatisticsRespDTO implements Serializable {
* 策略数量
*/
private Integer strategyCount;
/**
* 策略类型统计
*/
private Integer strategyType;
/**
* 策略类型统计列表
*/
private List<StrategyTypeStatisticsRespDTO> strategyTypeStatisticsList;
}
......@@ -19,7 +19,7 @@ public class StaffInfoDTO implements Serializable {
private Integer merchantId;
@ApiModelProperty(notes = "是否临时支援")
@ApiModelProperty(notes = "是否临时支援, true:是,false:否")
private Boolean temporarySupport;
}
......@@ -29,20 +29,24 @@ public class UnfinishedStrategyTaskJob implements SimpleJob {
log.info("未完成策略任务定时查询任务开始执行");
try {
// 查询未完成策略任务的策略-人员ID集合
List<Integer> unfinishedTasks = strategyInfoService.queryUnfinishedStrategyStaffList();
List<Integer> strategyStaffRelIdList = strategyInfoService.queryUnfinishedStrategyStaffList();
if (strategyStaffRelIdList == null || strategyStaffRelIdList.size() == 0) {
log.info("未完成策略任务定时查询任务,无未完成策略任务");
return;
}
log.info("查询到未完成策略任务的策略-人员数量: {}", unfinishedTasks.size());
log.info("查询到未完成策略任务的策略-人员数量: {}", strategyStaffRelIdList.size());
// 遍历处理未完成的任务
for (Integer task : unfinishedTasks) {
for (Integer refId : strategyStaffRelIdList) {
try {
strategyInfoService.sendUnfinishedStrategyStaffMessage(task);
strategyInfoService.sendUnfinishedStrategyStaffMessage(refId);
} catch (Exception e) {
// TODO
log.error("未完成策略任务定时查询任务处理异常: {}", e.getMessage(), e);
}
}
log.info("未完成策略任务定时查询任务执行完成,共处理 {} 条记录", unfinishedTasks.size());
log.info("未完成策略任务定时查询任务执行完成,共处理 {} 条记录", strategyStaffRelIdList.size());
} catch (Exception e) {
log.error("未完成策略任务定时查询任务执行异常: {}", e.getMessage(), e);
}
......
......@@ -40,6 +40,10 @@ public class StrategyPushConsumer extends KafkaConsumer {
}
List<StrategyStaffRel> strategyStaffRels = strategyInfoService.queryStrategyStaffRelList(strategyId);
if (strategyStaffRels == null || strategyStaffRels.size() == 0) {
log.info("策略推送无人员,处理结束,msg:{}", message);
return;
}
for (StrategyStaffRel strategyStaffRel : strategyStaffRels) {
try {
......
......@@ -34,8 +34,20 @@ public class UnfinishedStrategyStaffConsumer extends KafkaConsumer {
try {
Integer strategyStaffId = Integer.parseInt(message);
// 查询策略人员关系
StrategyStaffRel strategyStaffRel = strategyStaffRelService.selectByPrimaryKey(strategyStaffId);
if (strategyStaffRel == null) {
log.warn("未找到策略人员关系,strategyStaffId: {}", strategyStaffId);
return; // 如果找不到对应的策略人员关系,则直接返回
}
// 处理策略推送
strategyInfoService.processStrategyPushWithLock(strategyStaffRel, ReminderTypeEnums.PROGRESS_REMINDER.getCode());
log.info("未完成策略任务kafka消息消费,处理成功,msg:{}, strategyStaffId:{}", message, strategyStaffId);
} catch (NumberFormatException e) {
log.error("未完成策略任务消息格式错误,无法解析策略人员ID: {}", message, e);
} catch (Exception e) {
log.error("处理未完成策略任务消息失败: {}", message, e);
}
......
package cn.com.glsx.dj.strategy.service;
import cn.com.glsx.dj.peanalysis.dto.analysis.StrategyOrderStatisticsDTO;
import cn.com.glsx.dj.peanalysis.dto.analysis.StrategyOrderStatisticsRespDTO;
import cn.com.glsx.dj.peanalysis.enums.BusinessTypeEnum;
import cn.com.glsx.dj.peanalysis.remote.BiAnalyseBackgroundRemote;
import cn.com.glsx.dj.smartcarlife.enums.SceneTypeEnum;
......@@ -37,7 +36,6 @@ 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;
......@@ -120,14 +118,17 @@ public class StrategyDetailService {
// 订单统计
StrategyOrderStatisticsDTO strategyOrderStatisticsDTO = strategyOrderStatisticsBuilder(strategyInfo, strategyByValue);
log.info("strategyId: {} order statistics rpc strategyOrderStatisticsDTO:{}", strategyInfo.getId(), strategyOrderStatisticsDTO);
RpcResponse<StrategyOrderStatisticsRespDTO> strategyOrderInfoResponse = biAnalyseBackgroundRemote.getStrategyOrderInfo(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(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));
result.setDiscountTotalAmount(Optional.ofNullable(strategyOrderStatisticsRespDTO.getDiscountPrice()).orElse(BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP));*/
result.setOrderTotalCount(null);
result.setOrderTotalAmount(null);
result.setDiscountTotalAmount(null);
break;
default:
throw new RpcServiceException(StrategyErrorEnum.STRATEGY_TYPE_NOT_SUPPORTED);
......@@ -449,6 +450,32 @@ public class StrategyDetailService {
public List<MerchantStrategyStatisticsRespDTO> findStrategyStatisticsGroupMerchantNo(MerchantStrategyStatisticsReqDTO request) {
BeanValidationUtils.validateAndThrow(request);
return strategyInfoMapper.findStrategyStatisticsGroupMerchantNo(request);
List<MerchantStrategyStatisticsRespDTO> strategyStatisticsGroupMerchantNo = strategyInfoMapper.findStrategyStatisticsGroupMerchantNo(request);
if (CollUtil.isEmpty(strategyStatisticsGroupMerchantNo)) {
log.info("策略分析-门店策略分布结果为空");
return Lists.newArrayList();
}
Map<Integer, String> strategyTypeMap = Arrays.stream(StrategyTypeEnum.values())
.collect(Collectors.toMap(StrategyTypeEnum::getValue, StrategyTypeEnum::getDisplayName, (v1, v2) -> v1));
Map<Integer, List<MerchantStrategyStatisticsRespDTO>> merchantNoMapStrategyStrategyStatistics = strategyStatisticsGroupMerchantNo.stream()
.collect(Collectors.groupingBy(MerchantStrategyStatisticsRespDTO::getMerchantNo));
return merchantNoMapStrategyStrategyStatistics.entrySet()
.stream()
.map(entry -> {
Integer key = entry.getKey();
List<MerchantStrategyStatisticsRespDTO> value = Optional.ofNullable(entry.getValue()).orElseGet(ArrayList::new);
return new MerchantStrategyStatisticsRespDTO()
.setMerchantNo(key)
.setStrategyCount(value.stream().map(MerchantStrategyStatisticsRespDTO::getStrategyCount).reduce(0, Integer::sum))
.setStrategyTypeStatisticsList(
value.stream().map(ele -> StrategyTypeStatisticsRespDTO.builder()
.strategyType(ele.getStrategyType())
.strategyTypeName(strategyTypeMap.get(ele.getStrategyType()))
.strategyCount(ele.getStrategyCount())
.build()
).collect(Collectors.toList())
);
}).collect(Collectors.toList());
}
}
......@@ -6,6 +6,7 @@ import cn.com.glsx.dj.mindworkplate.model.PadMessageBox;
import cn.com.glsx.dj.mindworkplate.remote.PadMessageBoxRemote;
import cn.com.glsx.dj.peanalysis.dto.DataBizQueryParamsDTO;
import cn.com.glsx.dj.peanalysis.dto.DataBusinessDTO;
import cn.com.glsx.dj.smartcarlife.enums.SceneTypeEnum;
import cn.com.glsx.dj.smartcarlife.remote.StaffInfoRemote;
import cn.com.glsx.dj.strategy.config.DataStatsConfig;
import cn.com.glsx.dj.strategy.config.KafkaTopicConfig;
......@@ -35,8 +36,6 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import java.util.ArrayList;
import java.util.Arrays;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.env.OrePropertyConfigurer;
import org.oreframework.distribute.lock.annotation.GlsxDistributeLockable;
......@@ -132,7 +131,7 @@ public class StrategyInfoService {
//批量插入策略基础信息
strategyInfoMapper.insertList(strategyInfoList);
//批量插入策略人员关联信息
strategyStaffRelService.batchInsert(strategyInfoList, batchStrategyInfo.getStaffList());
strategyStaffRelService.batchInsert(strategyInfoList, batchStrategyInfo.getStaffList(), SceneTypeEnum.SCENE1_0.getValue());
//批量插入策略课程关联关系
strategyCourseRelService.batchInsert(strategyInfoList, batchStrategyInfo.getCourseList());
//批量插入策略-录音关联关系
......@@ -302,6 +301,7 @@ public class StrategyInfoService {
/**
* 使用分布式锁处理策略推送
* @param strategyStaffRel 策略人员关联信息
* @param reminderType 提醒类型 ReminderTypeEnums
*/
@GlsxDistributeLockable(name = "'StrategyInfoService_processStrategyPush_' + #strategyStaffRel.id",
time = 5, timeUnit = TimeUnit.MINUTES, timeoutException = RpcServiceException.class
......@@ -318,16 +318,16 @@ public class StrategyInfoService {
// 如果策略类型不是这三种,则不往下执行 0-学习类,1-优秀录音分享类,3-任务型
Integer strategyType = strategyInfo.getStrategyType();
if (strategyType != StrategyTypeEnum.LEARNING.getValue()
&& strategyType != StrategyTypeEnum.EXCELLENT_RECORDING_SHARE.getValue()
&& strategyType != StrategyTypeEnum.TASK.getValue()) {
if (!StrategyTypeEnum.LEARNING.getValue().equals(strategyType)
&& !StrategyTypeEnum.EXCELLENT_RECORDING_SHARE.getValue().equals(strategyType)
&& !StrategyTypeEnum.TASK.getValue().equals(strategyType)) {
log.warn("策略类型不是学习类、优秀录音分享类或任务型,策略ID: {}", strategyStaffRel.getStrategyId());
return;
}
handleTaskStrategyProcessing(strategyInfo, strategyStaffRel, reminderType);
} catch (Exception e) {
// TODO
log.error("处理策略推送时发生异常,策略-人员ID: {}", strategyStaffRel.getId(), e);
}
}
......@@ -490,8 +490,8 @@ public class StrategyInfoService {
return strategyStaffRelService.queryStrategyStaffRelList(strategyId);
}
public void sendUnfinishedStrategyStaffMessage(Integer task) {
String message = String.valueOf(task);
public void sendUnfinishedStrategyStaffMessage(Integer strategyStaffRelId) {
String message = String.valueOf(strategyStaffRelId);
kafkaProducer.send(kafkaTopicConfig.getUnfinishedStrategyStaffTopic(), message.getBytes());
}
......@@ -537,6 +537,8 @@ public class StrategyInfoService {
for (Map.Entry<String, List<DataBusinessDTO>> entry : staffGroupByMonth.entrySet()) {
StaffHistoryRecordDTO dto = new StaffHistoryRecordDTO();
String yearMonth = entry.getKey();
// yearMonth 目前是yyyy-MM-dd格式,需要转换成yyyy-MM格式
yearMonth = yearMonth.substring(0, 7);
dto.setYearMonth(yearMonth);
List<StaffInfoDTO> staffList = new ArrayList<>();
......@@ -561,6 +563,13 @@ public class StrategyInfoService {
// staffHistoryRecordDTOS 按月份倒序展示,最新的在前;
staffHistoryRecordDTOS.sort(Comparator.comparing(StaffHistoryRecordDTO::getYearMonth).reversed());
// yearMonth 目前是yyyy-MM格式,需要转换成 yyyy年MM月 格式
staffHistoryRecordDTOS.forEach(dto -> {
String yearMonth = dto.getYearMonth();
yearMonth = yearMonth.substring(0, 4) + "年" + yearMonth.substring(5, 7) + "月";
dto.setYearMonth(yearMonth);
});
return staffHistoryRecordDTOS;
}
......
......@@ -109,7 +109,7 @@ public class StrategyMerchantTimelineService {
*/
public void handlerAnxiousPackageShelveDate(MerchantBusinessInfo request, Date now, List<StrategyMerchantTimeline> nodes) {
//1.查询业务场景+门店 :安心包产品上架时间
Integer goodsType = environment.getProperty("dj.strategy.merchantTimeline.anxinbao.first", Integer.class, 114);
Integer goodsType = environment.getProperty("dj.strategy.merchantTimeline.yanbao.first", Integer.class, 114);
Integer secondaryGoodsType = environment.getProperty("dj.strategy.merchantTimeline.anxinbao.second", Integer.class, 155);
Date anxiousPackageShelveDate = getFirstShelveDate(request, goodsType, secondaryGoodsType);
if (anxiousPackageShelveDate != null) {
......@@ -123,7 +123,7 @@ public class StrategyMerchantTimelineService {
*/
public void handlerDelayedTireShelveDate(MerchantBusinessInfo request, Date now, List<StrategyMerchantTimeline> nodes) {
//1.查询业务场景+门店 :延保-轮胎上架时间
Integer goodsType = environment.getProperty("dj.strategy.merchantTimeline.delayedTire.first", Integer.class, 0);
Integer goodsType = environment.getProperty("dj.strategy.merchantTimeline.yanbao.first", Integer.class, 0);
Integer secondaryGoodsType = environment.getProperty("dj.strategy.merchantTimeline.delayedTire.second", Integer.class, 0);
Date delayedTireShelveDate = getFirstShelveDate(request, goodsType, secondaryGoodsType);
if (delayedTireShelveDate != null) {
......@@ -137,7 +137,7 @@ public class StrategyMerchantTimelineService {
*/
public void handlerDelayedBatteryShelveDate(MerchantBusinessInfo request, Date now, List<StrategyMerchantTimeline> nodes) {
//1.查询业务场景+门店 :延保-电池上架时间
Integer goodsType = environment.getProperty("dj.strategy.merchantTimeline.delayedBattery.first", Integer.class, 0);
Integer goodsType = environment.getProperty("dj.strategy.merchantTimeline.yanbao.first", Integer.class, 0);
Integer secondaryGoodsType = environment.getProperty("dj.strategy.merchantTimeline.delayedBattery.second", Integer.class, 0);
Date delayedBatteryShelveDate = getFirstShelveDate(request, goodsType, secondaryGoodsType);
if (delayedBatteryShelveDate != null) {
......@@ -162,7 +162,7 @@ public class StrategyMerchantTimelineService {
* @param request
* @return
*/
@GlsxDistributeLockable(name = "'StrategyMerchantTimelineService_node_'+#request.merchantId", timeoutException = RpcServiceException.class)
@GlsxDistributeLockable(name = "'StrategyMerchantTimelineService_node_'+#request.merchantId", timeoutException = Exception.class)
public MerchantBusinessOverview listStrategyMerchantTimeline(MerchantBusinessInfo request) {
//根据门店/场景查询时间线
List<StrategyMerchantTimeline> dbLines = searchMerchantTimeLine(request);
......@@ -197,15 +197,24 @@ public class StrategyMerchantTimelineService {
//5. 查询业务场景+门店 :延保-电池上架时间
handlerDelayedBatteryShelveDate(request, now, nodes);
}
//对dbLines 根据nodeDate 进行降序排序
dbLines.sort(Comparator.comparing(StrategyMerchantTimeline::getNodeDate).reversed());
//对dbLines 根据nodeDate 进行降序排序, 如果nodeDate一致,再根据nodeType 进行降序排序
Collections.sort(dbLines, (o1, o2) -> {
// 第一步:比较日期(降序)
int dateCompare = o2.getNodeDate().compareTo(o1.getNodeDate());
if (dateCompare != 0) {
return dateCompare; // 日期不同,直接返回日期比较结果
}
// 第二步:日期相同,比较节点类型(降序)
return o2.getNodeType().compareTo(o1.getNodeType());
});
//获取当前最后一个正式开单/展业风险/停止展业/恢复展业时间节点
StrategyMerchantTimeline lastLine = dbLines.stream()
.filter(line -> line.getNodeType().equals(MerchantNodeTypeEnum.FORMAL_ORDER.getValue()) ||
line.getNodeType().equals(MerchantNodeTypeEnum.RECOVERY_BUSINESS.getValue()) ||
line.getNodeType().equals(MerchantNodeTypeEnum.STOP_BUSINESS.getValue()) ||
line.getNodeType().equals(MerchantNodeTypeEnum.BUSINESS_RISK.getValue()))
.findFirst().get();
.findFirst().orElse(null);
handlerOrderDay(lastLine, nodes, request, now);
}
//入库保存
......@@ -234,7 +243,7 @@ public class StrategyMerchantTimelineService {
//获取首次开单时间节点
StrategyMerchantTimeline firstNode = newLines.stream()
.filter(line -> line.getNodeType().equals(MerchantNodeTypeEnum.FORMAL_ORDER.getValue()))
.findFirst().get();
.findFirst().orElse(null);
if (firstNode != null) {//存在首次开单时间才计算展业时间
Long developmentDay = null;
if (lastNode.getNodeType().equals(MerchantNodeTypeEnum.STOP_BUSINESS.getValue())) {
......
......@@ -87,9 +87,9 @@ public class StrategyStaffMessageService {
return null;
}
if (StrategyTypeEnum.TASK.equals(strategyInfo.getStrategyType())) {
if (StrategyTypeEnum.TASK.getValue().equals(strategyInfo.getStrategyType())) {
return strategyInfo;
} else if (StrategyTypeEnum.EXCELLENT_RECORDING_SHARE.equals(strategyInfo.getStrategyType())) {
} else if (StrategyTypeEnum.EXCELLENT_RECORDING_SHARE.getValue().equals(strategyInfo.getStrategyType())) {
// 查询策略关联的全部录音
List<StrategyRecordingRel> strategyRecordingRels = strategyRecordingRelService.queryStrategyRecordingRelList(strategyId);
List<StrategyStaffRecordingRelDTO> strategyStaffRecordingRelDTOS = BeanUtil.copyToList(strategyRecordingRels, StrategyStaffRecordingRelDTO.class);
......@@ -98,7 +98,7 @@ public class StrategyStaffMessageService {
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));
learningRecords.forEach(learningRecord -> learningRecordMap.put(Integer.valueOf(learningRecord.getRecordingId()), learningRecord));
}
LearningEffectAnalysisRequest condition = new LearningEffectAnalysisRequest();
......@@ -125,7 +125,7 @@ public class StrategyStaffMessageService {
}
return strategyStaffRecordingRelDTOS;
} else if (StrategyTypeEnum.LEARNING.equals(strategyInfo.getStrategyType())) {
} else if (StrategyTypeEnum.LEARNING.getValue().equals(strategyInfo.getStrategyType())) {
// 查询策略关联的全部课程
List<StrategyCourseRel> strategyCourseRels = strategyCourseRelService.queryStrategyCourseRelList(strategyId);
List<StrategyStaffCourseRelDTO> strategyStaffCourseRelDTOS = BeanUtil.copyToList(strategyCourseRels, StrategyStaffCourseRelDTO.class);
......@@ -139,14 +139,14 @@ public class StrategyStaffMessageService {
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));
beisenCourseStaffs.forEach(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));
courseDetails.forEach(courseDetail -> courseMap.put(courseDetail.getId(), courseDetail));
}
// 封装数据返回
......
package cn.com.glsx.dj.strategy.service;
import cn.com.glsx.dj.smartcarlife.dto.StaffInfoDTO;
import cn.com.glsx.dj.smartcarlife.remote.StaffInfoRemote;
import cn.com.glsx.dj.strategy.mapper.StrategyStaffRelMapper;
import cn.com.glsx.dj.strategy.model.StrategyInfo;
import cn.com.glsx.dj.strategy.model.StrategyStaffRel;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import cn.com.glsx.merchants.dto.beisen.BeiSenEmployeeListRequestDTO;
import cn.com.glsx.merchants.dto.beisen.BeiSenEmployeeListResonseDTO;
......@@ -30,13 +33,16 @@ public class StrategyStaffRelService {
@Autowired
private MerchantStaffRemote merchantStaffRemote;
@Autowired
private StaffInfoRemote staffInfoRemote;
/**
* 批量插入策略人员关联关系
* @param strategyInfoList
* @param staffList
* @return
*/
public int batchInsert(List<StrategyInfo> strategyInfoList, List<StrategyStaffRel> staffList) {
public int batchInsert(List<StrategyInfo> strategyInfoList, List<StrategyStaffRel> staffList, Byte sceneType) {
if (CollectionUtils.isEmpty(staffList)) return 0;
//根据手机号,查询北森人员userId
List<String> phoneList = staffList.stream().map(StrategyStaffRel::getUserPhone).collect(Collectors.toList());
......@@ -46,16 +52,24 @@ public class StrategyStaffRelService {
//构建map
phoneUserIdMap = employeeList.stream().collect(Collectors.toMap(BeiSenEmployeeListResonseDTO::getMobilePhone, BeiSenEmployeeListResonseDTO::getUserID));
}
//根据员工id查询 员工信息
Map<String, StaffInfoDTO> userMap = queryUserMap(strategyInfoList, staffList, sceneType);
//构建对象,遍历2个对象创建新StrategyStaffRel
List<StrategyStaffRel> all = new ArrayList<>();
for (StrategyInfo strategyInfo : strategyInfoList) {
for (StrategyStaffRel staff : staffList) {
StrategyStaffRel rel = new StrategyStaffRel();
rel.setUserUuid(staff.getUserUuid());
rel.setUserName(staff.getUserName());
//rel.setUserName(staff.getUserName());
String key = staff.getUserUuid() + staff.getUserPosition();
if (userMap.containsKey(key)) {
StaffInfoDTO user = userMap.get(key);
rel.setUserName(user.getStaffName());
rel.setUserPhone(user.getPhoneNumber());
}
rel.setStrategyId(strategyInfo.getId());
rel.setUserPosition(staff.getUserPosition());
rel.setUserPhone(staff.getUserPhone());
//rel.setUserPhone(staff.getUserPhone());
rel.setCreatedBy(strategyInfo.getCreatedBy());
rel.setCreatedDate(strategyInfo.getCreatedDate());
rel.setDeletedFlag(DeleteFlagEnum.N.getValue());
......@@ -66,6 +80,33 @@ public class StrategyStaffRelService {
return strategyStaffRelMapper.insertList(all);
}
public Map<String, StaffInfoDTO> queryUserMap(List<StrategyInfo> strategyInfoList, List<StrategyStaffRel> staffList, Byte sceneType) {
//根据员工id查询 员工信息
List<String> userUuidList = staffList.stream().map(x -> x.getUserUuid()).collect(Collectors.toList());
List<Integer> merchantIdList = strategyInfoList.stream().map(x -> x.getMerchantId()).collect(Collectors.toList());
RpcPagination<StaffInfoDTO> pagination = new RpcPagination<>();
pagination.setPageNum(1);
pagination.setPageSize(staffList.size());
StaffInfoDTO staffInfoDTO = new StaffInfoDTO();
staffInfoDTO.setStaffUuidList(userUuidList);
staffInfoDTO.setMerchantIdList(merchantIdList);
staffInfoDTO.setSceneType(sceneType);
List<Integer> postList = staffList.stream().map(StrategyStaffRel::getUserPosition).distinct().collect(Collectors.toList());
staffInfoDTO.setPositionTypeList(postList);
pagination.setCondition(staffInfoDTO);
RpcResponse<RpcPagination<StaffInfoDTO>> response = staffInfoRemote.listMultipleRolesStaffWithPage(pagination);
if (response.hasError()) {
log.error("创建策略,查询人员失败, response: {}", response);
throw new RpcServiceException(DefaultErrorEnum.RPC_ERROR, response.getMessage());
}
Map<String, StaffInfoDTO> userMap = new HashMap<>();
if (response.getResult() != null && CollectionUtils.isNotEmpty(response.getResult().getList())) {
//以 staff_uuid +positionType 为key 构建map
userMap = response.getResult().getList().stream().collect(Collectors.toMap(x -> x.getStaffUuid() + x.getPositionType(), x -> x, (oldVal, newVal) -> newVal));
}
return userMap;
}
/**
* 根据策略id删除关联关系
* @param strategyId
......
......@@ -15,6 +15,67 @@
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap>
<resultMap id="beiSenCourseStaffResultMap" type="cn.com.glsx.dj.riskmanage.model.course.BeiSenCourseStaff" autoMapping="true" >
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="user_id" property="userId" jdbcType="INTEGER"/>
<result column="course_id" property="courseId" jdbcType="VARCHAR"/>
<result column="required_or_optional" property="requiredOrOptional" jdbcType="VARCHAR"/>
<result column="learn_status" property="learnStatus" jdbcType="VARCHAR"/>
<result column="process" property="process" jdbcType="DECIMAL"/>
<result column="learn_duration" property="learnDuration" jdbcType="DECIMAL"/>
<result column="earned_credit" property="earnedCredit" jdbcType="DECIMAL"/>
<result column="is_marked_finish" property="isMarkedFinish" jdbcType="BOOLEAN"/>
<result column="learn_certificate_get_status" property="learnCertificateGetStatus" jdbcType="BOOLEAN"/>
<result column="get_medal" property="getMedal" jdbcType="BOOLEAN"/>
<result column="learn_start_time" property="learnStartTime" jdbcType="TIMESTAMP"/>
<result column="learn_end_time" property="learnEndTime" jdbcType="TIMESTAMP"/>
<result column="total_score" property="totalScore" jdbcType="DECIMAL"/>
<result column="modified_time" property="modifiedTime" jdbcType="TIMESTAMP"/>
<result column="beisen_created_time" property="beisenCreatedTime" jdbcType="TIMESTAMP"/>
<result column="beisen_created_by" property="beisenCreatedBy" jdbcType="INTEGER"/>
<result column="ext_fields" property="extFields" jdbcType="LONGVARCHAR"/>
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR"/>
</resultMap>
<resultMap id="beiSenCourseResultMap" type="cn.com.glsx.dj.riskmanage.model.course.BeiSenCourse" autoMapping="true" >
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="title" property="title" jdbcType="VARCHAR"/>
<result column="catalog" property="catalog" jdbcType="VARCHAR"/>
<result column="organization" property="organization" jdbcType="INTEGER"/>
<result column="course_sources" property="courseSources" jdbcType="VARCHAR"/>
<result column="common_course" property="commonCourse" jdbcType="VARCHAR"/>
<result column="is_enable_hangup" property="isEnableHangup" jdbcType="BOOLEAN"/>
<result column="is_open" property="isOpen" jdbcType="VARCHAR"/>
<result column="share_type" property="shareType" jdbcType="VARCHAR"/>
<result column="total_chapter" property="totalChapter" jdbcType="INTEGER"/>
<result column="total_credit" property="totalCredit" jdbcType="DECIMAL"/>
<result column="total_duration" property="totalDuration" jdbcType="DECIMAL"/>
<result column="total_duration_second" property="totalDurationSecond" jdbcType="DECIMAL"/>
<result column="total_star" property="totalStar" jdbcType="DECIMAL"/>
<result column="learn_total" property="learnTotal" jdbcType="INTEGER"/>
<result column="learn_count" property="learnCount" jdbcType="INTEGER"/>
<result column="page_view" property="pageView" jdbcType="INTEGER"/>
<result column="course_status" property="courseStatus" jdbcType="VARCHAR"/>
<result column="course_file_type" property="courseFileType" jdbcType="VARCHAR"/>
<result column="recommend_status" property="recommendStatus" jdbcType="VARCHAR"/>
<result column="lecturer" property="lecturer" jdbcType="VARCHAR"/>
<result column="recommend_time" property="recommendTime" jdbcType="TIMESTAMP"/>
<result column="modified_time" property="modifiedTime" jdbcType="TIMESTAMP"/>
<result column="publish_time" property="publishTime" jdbcType="TIMESTAMP"/>
<result column="beisen_created_time" property="beisenCreatedTime" jdbcType="TIMESTAMP"/>
<result column="beisen_created_by" property="beisenCreatedBy" jdbcType="INTEGER"/>
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR"/>
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
......@@ -38,7 +99,7 @@
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 id="queryCourseLearnSituation" resultMap="beiSenCourseStaffResultMap">
SELECT
*
FROM dj_beisen_course_staff
......@@ -50,7 +111,7 @@
</foreach>
</select>
<select id="queryCourseDetail" resultType="cn.com.glsx.dj.riskmanage.model.course.BeiSenCourse">
<select id="queryCourseDetail" resultMap="beiSenCourseResultMap">
SELECT
*
FROM dj_beisen_course
......
......@@ -39,7 +39,7 @@
WARNING - @mbg.generated
-->
id, strategy_type, title, sub_title, merchant_id, merchant_name, start_date, end_date, description, handler_type,
push_type, created_by, created_date, updated_by, updated_date, deleted_flag
push_type, created_by, created_date, updated_by, updated_date, deleted_flag, merchant_id, merchant_name, biz, push_flag, created_uuid
</sql>
<sql id="Blob_Column_List" >
<!--
......@@ -137,7 +137,8 @@
resultType="cn.com.glsx.dj.strategy.dto.MerchantStrategyStatisticsRespDTO">
select
merchant_id merchantNo,
count(*) strategyCount
count(*) strategyCount,
strategy_type strategyType
from dj_car_life_strategy_info
where deleted_flag = 'N'
<if test="businessType != null and businessType != ''">
......@@ -152,7 +153,7 @@
<if test="startDate != null and endDate != null">
AND created_date between #{startDate} and #{endDate}
</if>
group by merchant_id order by strategyCount desc
group by merchant_id, strategy_type order by strategyCount desc
</select>
<select id="selectStrategyIdsForPush" resultType="java.lang.Integer">
......@@ -160,7 +161,7 @@
FROM dj_car_life_strategy_info
WHERE deleted_flag = 'N'
AND push_flag = 0
AND DATE_FORMAT(start_date, '%Y-%m-%d %H:%i') = DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i')
AND DATE_FORMAT(start_date, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
AND (
strategy_type IN (0, 1)
OR (
......@@ -183,9 +184,9 @@
and si.end_date is not null
and si.end_date >= now()
and (
TIMESTAMPDIFF(MINUTE, si.end_date, NOW()) = 1440
or TIMESTAMPDIFF(MINUTE, si.end_date, NOW()) = 720
or TIMESTAMPDIFF(MINUTE, si.end_date, NOW()) = 360
TIMESTAMPDIFF(MINUTE, NOW(), si.end_date) = 1440
or TIMESTAMPDIFF(MINUTE, NOW(), si.end_date) = 720
or TIMESTAMPDIFF(MINUTE, NOW(), si.end_date) = 360
)
AND ssr.deleted_flag = 'N'
AND scor.deleted_flag = 'N'
......@@ -209,9 +210,9 @@
and si.end_date is not null
and si.end_date >= now()
and (
TIMESTAMPDIFF(MINUTE, si.end_date, NOW()) = 1440
or TIMESTAMPDIFF(MINUTE, si.end_date, NOW()) = 720
or TIMESTAMPDIFF(MINUTE, si.end_date, NOW()) = 360
TIMESTAMPDIFF(MINUTE, NOW(), si.end_date) = 1440
or TIMESTAMPDIFF(MINUTE, NOW(), si.end_date) = 720
or TIMESTAMPDIFF(MINUTE, NOW(), si.end_date) = 360
)
AND ssr.deleted_flag = 'N'
AND srr.deleted_flag = 'N'
......
......@@ -9,18 +9,21 @@
<result column="strategy_id" property="strategyId" jdbcType="INTEGER" />
<result column="user_uuid" property="userUuid" jdbcType="VARCHAR" />
<result column="user_name" property="userName" jdbcType="VARCHAR" />
<result column="user_phone" property="userPhone" jdbcType="VARCHAR" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
<result column="user_position" property="userPosition" jdbcType="CHAR" />
<result column="beisen_userid" property="beisenUserId" jdbcType="CHAR" />
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
-->
id, strategy_id, user_uuid, user_name, created_by, created_date, updated_by, updated_date,
deleted_flag
id, strategy_id, user_uuid, user_name, user_phone, created_by, created_date, updated_by, updated_date,
deleted_flag, user_position, beisen_userid
</sql>
<select id="selectByStrategyId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
......@@ -30,7 +33,7 @@
WHERE strategy_id = #{strategyId,jdbcType=INTEGER}
AND deleted_flag = 'N'
</select>
<select id="selectByStrategyIdAndStaffId" resultType="cn.com.glsx.dj.strategy.model.StrategyStaffRel">
<select id="selectByStrategyIdAndStaffId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM dj_car_life_strategy_staff_rel
......
package cn.com.glsx.dj.strategy.mqlistener;
import cn.com.glsx.dj.strategy.BaseServiceTest;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2026/1/24
**/
public class StrategyPushConsumerTest extends BaseServiceTest {
@Autowired
private StrategyPushConsumer strategyPushConsumer;
public void testProcessMessage() {
}
}
\ No newline at end of file
package cn.com.glsx.dj.strategy.service;
import cn.com.glsx.dj.mindworkplate.enums.messagebox.ReminderTypeEnums;
import cn.com.glsx.dj.smartcarlife.enums.SceneTypeEnum;
import cn.com.glsx.dj.strategy.BaseServiceTest;
import cn.com.glsx.dj.strategy.dto.BatchInsertStrategyInfo;
import cn.com.glsx.dj.strategy.dto.MerchantBusinessInfo;
import cn.com.glsx.dj.strategy.dto.MerchantBusinessOverview;
import cn.com.glsx.dj.strategy.dto.MerchantInfo;
import cn.com.glsx.dj.strategy.dto.*;
import cn.com.glsx.dj.strategy.enums.StrategyPushType;
import cn.com.glsx.dj.strategy.enums.StrategyTypeEnum;
import cn.com.glsx.dj.strategy.mapper.StrategyStaffRelMapper;
import cn.com.glsx.dj.strategy.model.*;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
......@@ -26,6 +26,9 @@ public class StrategyInfoServiceTest extends BaseServiceTest {
private StrategyInfoService strategyInfoService;
@Autowired
private StrategyStaffRelMapper strategyStaffRelMapper;
@Autowired
private StrategyMerchantTimelineService strategyMerchantTimelineService;
......@@ -96,7 +99,7 @@ public class StrategyInfoServiceTest extends BaseServiceTest {
@Test
public void testQueryStrategyMerchantTimelineList() {
MerchantBusinessInfo request = new MerchantBusinessInfo();
request.setMerchantId(44211227);
request.setMerchantId(44211640);
request.setSceneType(SceneTypeEnum.SCENE1_0.getValue());
request.setBizs(1);
MerchantBusinessOverview overview = strategyMerchantTimelineService.listStrategyMerchantTimeline(request);
......@@ -121,6 +124,24 @@ public class StrategyInfoServiceTest extends BaseServiceTest {
}
@Test
public void testProcessStrategyPushWithLock() {
strategyInfoService.processStrategyPushWithLock(strategyStaffRelMapper.selectByPrimaryKey(76), ReminderTypeEnums.FIRST_REMINDER.getCode());
}
@Test
public void testSendStrategyPushMessage() {
strategyInfoService.sendStrategyPushMessage(12);
}
@Test
public void testQueryUnfinishedStrategyStaffList() {
List<Integer> refIdList = strategyInfoService.queryUnfinishedStrategyStaffList();
}
@Test
public void testListMerchantAnalysisEmployeeHistory() {
List<StaffHistoryRecordDTO> staffHistoryRecordDTOS = strategyInfoService.listMerchantAnalysisEmployeeHistory(44211227, 1);
System.out.println(JSON.toJSONString(staffHistoryRecordDTOS));
}
}
package cn.com.glsx.dj.strategy.service;
import cn.com.glsx.dj.strategy.BaseServiceTest;
import com.alibaba.fastjson.JSON;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2026/1/24
**/
public class StrategyStaffMessageServiceTest extends BaseServiceTest {
@Autowired
private StrategyStaffMessageService strategyStaffMessageService;
@Test
public void testGetBusinessMessageDetailByMessageId() {
Object detail = strategyStaffMessageService.getBusinessMessageDetailByMessageId(10451);
System.out.println(JSON.toJSONString(detail));
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!