4g挂牌对接,可以接收到 心跳日志, 上传的音频文件 ,保存到数据库和本地文件

This commit is contained in:
ZLI263
2025-11-30 21:16:47 +08:00
parent 9344846772
commit 153c8bfaf1
33 changed files with 3418 additions and 36 deletions

View File

@@ -2,14 +2,18 @@ package com.rj.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rj.common.AudioManagementConstants;
import com.rj.common.DataEnrichmentUtil;
import com.rj.entity.AudioManagement;
import com.rj.entity.CustomerManagement;
import com.rj.service.IAudioManagementService;
import com.rj.service.ICustomerManagementService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
@@ -17,6 +21,7 @@ import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* <p>
@@ -34,27 +39,58 @@ public class CustomerManagementController {
@Autowired
private ICustomerManagementService customerManagementService;
@Autowired
private IAudioManagementService audioManagementService;
/**
* 新增客户
*/
@PostMapping("/add")
@Operation(summary = "新增客户", description = "添加新的客户信息")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<Map<String, Object>> addCustomer(
@Parameter(description = "客户信息", required = true)
@RequestBody CustomerManagement customerManagement) {
Map<String, Object> result = new HashMap<>();
try {
customerManagement.setCreateTime(LocalDateTime.now());
customerManagement.setUpdateTime(LocalDateTime.now());
boolean success = customerManagementService.save(customerManagement);
boolean isUpdate = customerManagement.getId() != null && !customerManagement.getId().trim().isEmpty();
LocalDateTime now = LocalDateTime.now();
String operationType = customerManagement.getOperationType();
if (isUpdate) {
CustomerManagement existing = customerManagementService.getById(customerManagement.getId());
if (existing == null) {
result.put("success", false);
result.put("message", "客户不存在,无法更新");
return ResponseEntity.badRequest().body(result);
}
customerManagement.setCreateTime(existing.getCreateTime());
customerManagement.setUpdateTime(now);
} else {
customerManagement.setCreateTime(now);
customerManagement.setUpdateTime(now);
}
boolean success = customerManagementService.saveOrUpdate(customerManagement);
if (success) {
if ("start".equalsIgnoreCase(operationType)) {
if (customerManagement.getId() == null || customerManagement.getId().trim().isEmpty()) {
throw new IllegalStateException("客户ID为空无法同步录音记录");
}
AudioManagement audioRecord = buildAudioRecordFromCustomer(customerManagement, now);
boolean audioSaved = audioManagementService.save(audioRecord);
if (!audioSaved) {
throw new IllegalStateException("录音管理数据保存失败");
}
result.put("audioRecordId", audioRecord.getId());
}
result.put("success", true);
result.put("message", "客户添加成功");
result.put("message", isUpdate ? "客户信息更新成功" : "客户添加成功");
result.put("data", customerManagement);
return ResponseEntity.ok(result);
} else {
result.put("success", false);
result.put("message", "客户添加失败");
result.put("message", isUpdate ? "客户信息更新失败" : "客户添加失败");
return ResponseEntity.badRequest().body(result);
}
} catch (Exception e) {
@@ -103,7 +139,9 @@ public class CustomerManagementController {
Map<String, Object> result = new HashMap<>();
try {
LambdaQueryWrapper<CustomerManagement> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CustomerManagement::getContact, contact);
if (contact != null && !contact.trim().isEmpty()) {
queryWrapper.like(CustomerManagement::getContact, contact.trim());
}
List<CustomerManagement> customers = customerManagementService.list(queryWrapper);
result.put("success", true);
result.put("message", "查询成功");
@@ -363,4 +401,31 @@ public class CustomerManagementController {
return ResponseEntity.internalServerError().body(result);
}
}
private AudioManagement buildAudioRecordFromCustomer(CustomerManagement customer, LocalDateTime now) {
AudioManagement audio = new AudioManagement();
audio.setId(UUID.randomUUID().toString());
String recordingName = customer.getCustomerName() != null && !customer.getCustomerName().trim().isEmpty()
? customer.getCustomerName() + "接待记录"
: "客户接待记录";
audio.setRecordingName(recordingName);
audio.setRecordingTime(now);
audio.setUploadTime(now);
audio.setCreateTime(now);
audio.setUpdateTime(now);
audio.setCustomerId(customer.getId());
audio.setCustomerName(customer.getCustomerName());
audio.setCustomerPhone(customer.getContact());
audio.setSalesId(customer.getSalesId());
audio.setSalesName(customer.getSalesName());
audio.setSalesPhone(customer.getSalesPhone());
audio.setDealershipId(customer.getDealershipId());
audio.setDealershipName(customer.getDealershipName());
audio.setIntentionLevel(customer.getIntendedModel());
audio.setRemarks(customer.getRemark());
audio.setInfoCarddescription(customer.getInfoCard());
audio.setCompanyType(customer.getCustomerSource());
audio.setSyncStatus(AudioManagementConstants.SYNC_STATUS_IN_SERVICE);
return audio;
}
}