|
|
@@ -2244,18 +2244,25 @@ public class Task {
|
|
|
public void cleanupWatchLog(){
|
|
|
logger.info("开始执行数据清理任务...");
|
|
|
try {
|
|
|
- long oldDataCount = fsCourseWatchLogService.getOldDataCount();
|
|
|
- logger.info("一个月前的数据量: {} 条", oldDataCount);
|
|
|
-
|
|
|
- if (oldDataCount > 0) {
|
|
|
- int deletedCount = fsCourseWatchLogService.deleteOldDataBatch();
|
|
|
- logger.info("数据清理完成,共删除 {} 条数据", deletedCount);
|
|
|
- } else {
|
|
|
- logger.info("没有需要清理的数据");
|
|
|
- }
|
|
|
+ int deletedCount = fsCourseWatchLogService.deleteOldDataBatch();
|
|
|
+ logger.info("数据清理完成,共删除 {} 条数据", deletedCount);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("数据清理任务执行失败", e);
|
|
|
+ //throw new RuntimeException(e);
|
|
|
}
|
|
|
+// try {
|
|
|
+// long oldDataCount = fsCourseWatchLogService.getOldDataCount();
|
|
|
+// logger.info("一个月前的数据量: {} 条", oldDataCount);
|
|
|
+//
|
|
|
+// if (oldDataCount > 0) {
|
|
|
+// int deletedCount = fsCourseWatchLogService.deleteOldDataBatch();
|
|
|
+// logger.info("数据清理完成,共删除 {} 条数据", deletedCount);
|
|
|
+// } else {
|
|
|
+// logger.info("没有需要清理的数据");
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// logger.error("数据清理任务执行失败", e);
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
public void obtainSopInfoData() {
|
|
|
@@ -2355,13 +2362,13 @@ public class Task {
|
|
|
|
|
|
switch (isBuy) {
|
|
|
case 1:
|
|
|
- return 1; // 小品未购
|
|
|
+ return 1; // 未升单未购
|
|
|
case 2:
|
|
|
- return 2; // 小品已购
|
|
|
+ return 2; // 未升单已购
|
|
|
case 3:
|
|
|
- return 3; // 主品未购
|
|
|
+ return 3; // 升单未购
|
|
|
case 4:
|
|
|
- return 4; // 主品已购
|
|
|
+ return 4; // 升单已购
|
|
|
default:
|
|
|
logger.warn("未知 isBuy 值: {}, 跳过 exId: {}", isBuy, exId);
|
|
|
return null;
|
|
|
@@ -2390,13 +2397,120 @@ public class Task {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 定时向销售和医生分发SOP任务。
|
|
|
+ * */
|
|
|
+// public void obtainSopInfoData2() {
|
|
|
+// List<SopOrderLog> sopOrderLogs = sopOrderLogMapper.queryUnsentSOPData();
|
|
|
+// if (CollectionUtils.isEmpty(sopOrderLogs)) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// for (SopOrderLog log : sopOrderLogs) {
|
|
|
+// List<SopUserLogsInfo> logsInfo = sopUserLogsInfoMapper.querySopUserLogsRecord(log.getSopId(),log.getIsBuy());
|
|
|
+// if (CollectionUtils.isEmpty(logsInfo)){
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 过滤 externalId 非空
|
|
|
+// List<Long> externalIds = logsInfo.stream()
|
|
|
+// .filter(info -> info.getExternalId() != null)
|
|
|
+// .map(SopUserLogsInfo::getExternalId)
|
|
|
+// .collect(Collectors.toList());
|
|
|
+//
|
|
|
+// if (CollectionUtils.isEmpty(externalIds)) {
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 构建 productBuyMap:根据 isBuy 类型选择字段
|
|
|
+// Map<Long, Integer> productBuyMap;
|
|
|
+// boolean isUpsell = (log.getIsBuy() == 3 || log.getIsBuy() == 4); // 是否升单
|
|
|
+//
|
|
|
+// if (isUpsell) {//升单就取IsUpsellProductBuy属性值
|
|
|
+// productBuyMap = logsInfo.stream()
|
|
|
+// .filter(info -> info.getExternalId() != null)
|
|
|
+// .collect(Collectors.toMap(
|
|
|
+// SopUserLogsInfo::getExternalId,
|
|
|
+// SopUserLogsInfo::getIsUpsellProductBuy,
|
|
|
+// (v1, v2) -> v1//防止重复key,一般同一个营期内不会有重复的
|
|
|
+// ));
|
|
|
+// } else {//未升单就取IsProductBuy属性值
|
|
|
+// productBuyMap = logsInfo.stream()
|
|
|
+// .filter(info -> info.getExternalId() != null)
|
|
|
+// .collect(Collectors.toMap(
|
|
|
+// SopUserLogsInfo::getExternalId,
|
|
|
+// SopUserLogsInfo::getIsProductBuy,
|
|
|
+// (v1, v2) -> v1//防止重复key
|
|
|
+// ));
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 查询qw_external_contact 表获取客户id,销售id
|
|
|
+// List<QwExternalContact> contacts = qwExternalContactMapper.selectQwExternalContactByIds(externalIds);
|
|
|
+// if (CollectionUtils.isEmpty(contacts)) {
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// for (QwExternalContact contact : contacts) {
|
|
|
+// Long fsUserId = contact.getFsUserId(); // 客户ID
|
|
|
+// Long companyUserId = contact.getCompanyUserId();//销售ID
|
|
|
+//
|
|
|
+// CompanyUser companyUser = companyUserMapper.selectCompanyUserByCompanyUserId(companyUserId);
|
|
|
+// if (companyUser == null) continue; // 防空指针
|
|
|
+//
|
|
|
+// Long doctorId = companyUser.getDoctorId();//医生ID
|
|
|
+// // - 根据当前外部联系人 ID(contact.getId()),从购买sop_user_logs_info表中获取其购买状态
|
|
|
+// // - 如果是“未升单”场景,buyStatus 来自字段 isProductBuy(1=未购,2=已购)
|
|
|
+// // - 如果是“升单”场景,buyStatus 来自字段 isUpsellProductBuy(1=未购,2=已购)
|
|
|
+// Integer buyStatus = productBuyMap.get(contact.getId());
|
|
|
+//
|
|
|
+//
|
|
|
+// // 安全校验:确保 buyStatus 为 1(未购)或 2(已购)
|
|
|
+// if (buyStatus == null || (buyStatus != 1 && buyStatus != 2)) {
|
|
|
+// logger.error("方法obtainSopInfoData():buyStatus 异常,externalId: {}, 值: {}", contact.getId(), buyStatus);
|
|
|
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+// throw new CustomException("分发医生和销售sop任务失败");
|
|
|
+// }
|
|
|
+//
|
|
|
+// //核心映射:1/2 → 1/2(未升单),1/2 → 3/4(升单)
|
|
|
+// int type = isUpsell ? (buyStatus + 2) : buyStatus;
|
|
|
+//
|
|
|
+// // 分发任务
|
|
|
+// switch (log.getOrderSendType()) {
|
|
|
+// case 1:
|
|
|
+// //分发给销售sop数据
|
|
|
+// obtainSopCompanyUserTaskData(fsUserId, companyUserId, doctorId, type,contact.getId());
|
|
|
+// break;
|
|
|
+// case 2:
|
|
|
+// //分发给医生sop数据
|
|
|
+// obtainSopDoctorTaskData(fsUserId, companyUserId, doctorId, type,contact.getId());
|
|
|
+// break;
|
|
|
+// case 3:
|
|
|
+// //分发给销售和医生sop数据
|
|
|
+// obtainSopCompanyUserTaskData(fsUserId, companyUserId, doctorId, type,contact.getId());
|
|
|
+// obtainSopDoctorTaskData(fsUserId, companyUserId, doctorId, type,contact.getId());
|
|
|
+// break;
|
|
|
+// default:
|
|
|
+// logger.error("未知的type: {}", type);
|
|
|
+// break;
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //对于已经推送的数据需要修改sop库的sop_order_log表的status状态为1:已推送
|
|
|
+// List<Long> ids = sopOrderLogs.stream().map(SopOrderLog::getId).collect(Collectors.toList());
|
|
|
+// int i = sopOrderLogMapper.updateIsSentSOPDataByIds(ids);
|
|
|
+// if (i > 0){
|
|
|
+// logger.info("修改了{}条sop_order_log表的status状态为1:已推送", i);
|
|
|
+// }
|
|
|
+// }
|
|
|
//辅助方法 增加医生和销售的sop推送数据
|
|
|
/**
|
|
|
* 增加sop医生推送数据
|
|
|
* @param fsUserId 用户id
|
|
|
* @param companyUserId 销售人员id
|
|
|
* @param doctorId 医生id
|
|
|
- * @param type 1:小品未购 2:小品已购 3:主品未购 4:主品已购
|
|
|
+ * @param type 1:未升单未购 2:未升单已购 3:升单未购 4:升单已购
|
|
|
* */
|
|
|
public int obtainSopDoctorTaskData(Long fsUserId, Long companyUserId,Long doctorId, Integer type,Long qwExternalContactId) {
|
|
|
if (doctorId==null){
|
|
|
@@ -2418,7 +2532,7 @@ public class Task {
|
|
|
* @param fsUserId 用户id
|
|
|
* @param companyUserId 销售人员id
|
|
|
* @param doctorId 医生id
|
|
|
- * @param type 1:小品未购 2:小品已购 3:主品未购 4:主品已购
|
|
|
+ * @param type 1:未升单未购 2:未升单已购 3:升单未购 4:升单已购
|
|
|
* */
|
|
|
public int obtainSopCompanyUserTaskData(Long fsUserId, Long companyUserId,Long doctorId, Integer type,Long qwExternalContactId) {
|
|
|
FsSopCompanyUserTask fsSopCompanyUserTask = new FsSopCompanyUserTask();
|