客户信息补录

This commit is contained in:
zhonghua1
2026-01-09 22:10:31 +08:00
parent 34e352fbb6
commit 3c97a21baa
4 changed files with 107 additions and 4 deletions

View File

@@ -132,3 +132,7 @@ hikari:

View File

@@ -7,6 +7,7 @@ import com.rj.common.AudioManagementConstants;
import com.rj.common.DataEnrichmentUtil; import com.rj.common.DataEnrichmentUtil;
import com.rj.entity.AudioManagement; import com.rj.entity.AudioManagement;
import com.rj.entity.AudioManagementSegments; import com.rj.entity.AudioManagementSegments;
import com.rj.entity.CustomerManagement;
import com.rj.service.*; import com.rj.service.*;
import com.rj.dto.AsrRequest; import com.rj.dto.AsrRequest;
import com.rj.dto.AsrResponse; import com.rj.dto.AsrResponse;
@@ -46,10 +47,17 @@ public class AudioManagementController {
private static final String SCENARIO_FURNITURE_SALE = "FURNITURE_SALE"; private static final String SCENARIO_FURNITURE_SALE = "FURNITURE_SALE";
private static final String SCENARIO_MEETING_SUMMARY = "MEETING_SUMMARY"; private static final String SCENARIO_MEETING_SUMMARY = "MEETING_SUMMARY";
private static final String SCENARIO_CAR_SALE = "CAR_SALE"; private static final String SCENARIO_CAR_SALE = "CAR_SALE";
private static final String SCENARIO_SPEAKING_TRAINING= "SPEAKING_TRAINING"; //租赁模式
@Autowired @Autowired
private IAudioManagementService audioManagementService; private IAudioManagementService audioManagementService;
@Autowired
private ICustomerManagementService customerManagementService;
@Autowired @Autowired
private IFileUploadService fileUploadService; private IFileUploadService fileUploadService;
@@ -440,6 +448,83 @@ public class AudioManagementController {
return ResponseEntity.internalServerError().body(result); return ResponseEntity.internalServerError().body(result);
} }
} }
@PutMapping("/updateForCustomerInfo")
@Operation(summary = "更新录音信息", description = "更新录音详细信息")
public ResponseEntity<Map<String, Object>> updateAudioForCustomer(
@Parameter(description = "录音信息", required = true)
@RequestBody AudioManagement audioManagement) {
Map<String, Object> result = new HashMap<>();
try {
if (audioManagement.getId() == null || audioManagement.getId().trim().isEmpty()) {
result.put("success", false);
result.put("message", "录音ID不能为空");
return ResponseEntity.badRequest().body(result);
}
AudioManagement audioManagementDB = new AudioManagement();
audioManagementDB.setUpdateTime(LocalDateTime.now());
audioManagementDB.setCustomerName(audioManagement.getCustomerName());
audioManagementDB.setCustomerPhone(audioManagement.getCustomerPhone());
audioManagementDB.setId(audioManagement.getId());
boolean success = audioManagementService.updateById(audioManagementDB);
if (success) {
// 同步更新客户信息
try {
CustomerManagement customerToUpdate = null;
// 优先通过 customerId 查找客户
if (audioManagement.getCustomerId() != null && !audioManagement.getCustomerId().trim().isEmpty()) {
customerToUpdate = customerManagementService.getById(audioManagement.getCustomerId());
}
// 如果通过 customerId 没找到,且提供了 customerPhone则通过联系方式查找
if (customerToUpdate == null && audioManagement.getCustomerPhone() != null && !audioManagement.getCustomerPhone().trim().isEmpty()) {
LambdaQueryWrapper<CustomerManagement> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CustomerManagement::getContact, audioManagement.getCustomerPhone().trim());
List<CustomerManagement> customers = customerManagementService.list(queryWrapper);
if (customers != null && !customers.isEmpty()) {
customerToUpdate = customers.get(0);
}
}
// 如果找到了客户,更新客户信息
if (customerToUpdate != null) {
customerToUpdate.setCustomerName(audioManagement.getCustomerName());
customerToUpdate.setContact(audioManagement.getCustomerPhone());
customerToUpdate.setRemark(audioManagement.getRemarks());
customerToUpdate.setUpdateTime(LocalDateTime.now());
customerManagementService.updateById(customerToUpdate);
log.info("同步更新客户信息成功客户ID: {}", customerToUpdate.getId());
} else {
log.warn("未找到对应的客户信息无法同步更新。customerId: {}, customerPhone: {}",
audioManagement.getCustomerId(), audioManagement.getCustomerPhone());
}
} catch (Exception e) {
// 客户信息更新失败不影响音频信息更新的结果,只记录日志
log.error("同步更新客户信息时发生异常: {}", e.getMessage(), e);
}
result.put("success", true);
result.put("message", "录音信息更新成功");
result.put("data", audioManagement);
return ResponseEntity.ok(result);
} else {
result.put("success", false);
result.put("message", "录音信息更新失败");
return ResponseEntity.badRequest().body(result);
}
} catch (Exception e) {
result.put("success", false);
result.put("message", "更新异常:" + e.getMessage());
return ResponseEntity.internalServerError().body(result);
}
}
@Autowired @Autowired
private com.rj.service.IAudioManagementSegmentsService audioManagementSegmentsService; private com.rj.service.IAudioManagementSegmentsService audioManagementSegmentsService;

View File

@@ -77,6 +77,20 @@ public class CustomerManagementController {
if (customerManagement.getId() == null || customerManagement.getId().trim().isEmpty()) { if (customerManagement.getId() == null || customerManagement.getId().trim().isEmpty()) {
throw new IllegalStateException("客户ID为空无法同步录音记录"); throw new IllegalStateException("客户ID为空无法同步录音记录");
} }
// 检查销售人员是否正在服务其他客户
String salesPhone = customerManagement.getSalesPhone();
if (salesPhone != null && !salesPhone.trim().isEmpty()) {
LambdaQueryWrapper<AudioManagement> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AudioManagement::getSalesPhone, salesPhone.trim())
.eq(AudioManagement::getServiceStatus, AudioManagementConstants.SERVICE_STATUS_IN_SERVICE);
long count = audioManagementService.count(queryWrapper);
if (count > 0) {
result.put("success", true);
result.put("message", isUpdate ? "客户信息更新成功" : "客户添加成功");
result.put("message", "该销售人员正在服务其他客户,无法创建新的服务记录");
return ResponseEntity.badRequest().body(result);
}
}
AudioManagement audioRecord = buildAudioRecordFromCustomer(customerManagement, now); AudioManagement audioRecord = buildAudioRecordFromCustomer(customerManagement, now);
boolean audioSaved = audioManagementService.save(audioRecord); boolean audioSaved = audioManagementService.save(audioRecord);
if (!audioSaved) { if (!audioSaved) {

View File

@@ -136,8 +136,8 @@ public class DeviceManagementController {
@RequestParam(required = false) String dealershipId, @RequestParam(required = false) String dealershipId,
@Parameter(description = "绑定状态") @Parameter(description = "绑定状态")
@RequestParam(required = false) Boolean bindStatus, @RequestParam(required = false) Boolean bindStatus,
@Parameter(description = "充电状态") @Parameter(description = "电话")
@RequestParam(required = false) String chargingStatus) { @RequestParam(required = false) String salesPhone) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
try { try {
Page<DeviceManagement> page = new Page<>(current, size); Page<DeviceManagement> page = new Page<>(current, size);
@@ -153,8 +153,8 @@ public class DeviceManagementController {
if (bindStatus != null) { if (bindStatus != null) {
queryWrapper.eq(DeviceManagement::getBindStatus, bindStatus); queryWrapper.eq(DeviceManagement::getBindStatus, bindStatus);
} }
if (chargingStatus != null && !chargingStatus.trim().isEmpty()) { if (salesPhone != null && !salesPhone.trim().isEmpty()) {
queryWrapper.eq(DeviceManagement::getChargingStatus, chargingStatus); queryWrapper.eq(DeviceManagement::getSalesPhone, salesPhone);
} }
// 按getUpdateTime 时间倒序排列 // 按getUpdateTime 时间倒序排列