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

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.tika.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@@ -301,24 +302,16 @@ public class AudioManagementController {
@GetMapping("/list")
@Operation(summary = "分页查询录音列表", description = "分页查询录音信息列表")
public ResponseEntity<Map<String, Object>> getAudioList(
@Parameter(description = "页码", example = "1")
@RequestParam(defaultValue = "1") Integer current,
@Parameter(description = "每页大小", example = "10")
@RequestParam(defaultValue = "10") Integer size,
@Parameter(description = "录音名称(模糊查询)")
@RequestParam(required = false) String recordingName,
@Parameter(description = "客户手机号(模糊查询)")
@RequestParam(required = false) String customerPhone,
@Parameter(description = "客户姓名(模糊查询)")
@RequestParam(required = false) String customerName,
@Parameter(description = "所属销售姓名(模糊查询)")
@RequestParam(required = false) String salesName,
@Parameter(description = "所属门店ID")
@RequestParam(required = false) String dealershipId,
@Parameter(description = "意向级别")
@RequestParam(required = false) String intentionLevel,
@Parameter(description = "销售人员电话(模糊查询)")
@RequestParam(required = false) String salesPhone) {
@Parameter(description = "页码", example = "1") @RequestParam(defaultValue = "1") Integer current,
@Parameter(description = "每页大小", example = "10") @RequestParam(defaultValue = "10") Integer size,
@Parameter(description = "录音名称(模糊查询)") @RequestParam(required = false) String recordingName,
@Parameter(description = "客户手机号(模糊查询)") @RequestParam(required = false) String customerPhone,
@Parameter(description = "客户姓名(模糊查询)") @RequestParam(required = false) String customerName,
@Parameter(description = "所属销售姓名(模糊查询)") @RequestParam(required = false) String salesName,
@Parameter(description = "所属门店ID") @RequestParam(required = false) String dealershipId,
@Parameter(description = "意向级别") @RequestParam(required = false) String intentionLevel,
@Parameter(description = "同步状态") @RequestParam(required = false) String syncStatus,
@Parameter(description = "销售人员电话(模糊查询)") @RequestParam(required = false) String salesPhone) {
Map<String, Object> result = new HashMap<>();
try {
Page<AudioManagement> page = new Page<>(current, size);
@@ -346,6 +339,9 @@ public class AudioManagementController {
if (salesPhone != null && !salesPhone.trim().isEmpty()) {
queryWrapper.like(AudioManagement::getSalesPhone, salesPhone);
}
if (syncStatus != null && !syncStatus.trim().isEmpty()) {
queryWrapper.eq(AudioManagement::getSyncStatus, syncStatus);
}
// 按创建时间倒序排列
queryWrapper.orderByDesc(AudioManagement::getUpdateTime);
@@ -367,7 +363,9 @@ public class AudioManagementController {
audioPage.getRecords().forEach(audio -> {
audio.setDealershipName(dealershipNameMap.getOrDefault(audio.getDealershipId(), ""));
audio.setSalesName(saleNameMap.getOrDefault(audio.getSalesId(), ""));
if (StringUtils.isEmpty( audio.getSalesName())) {
audio.setSalesName(saleNameMap.getOrDefault(audio.getSalesId(), ""));
}
audio.setSalesPhone(salePhoneMap.getOrDefault(audio.getSalesId(), ""));
audio.setProjectName(projectNameMap.getOrDefault(audio.getProjectId(), ""));
// audio.setCustomerName(customerNameMap.getOrDefault(audio.getCustomerId(), ""));

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;
}
}

View File

@@ -0,0 +1,161 @@
package com.rj.controller;
import com.rj.entity.YhyAudioUploadLog;
import com.rj.service.IYhyAudioUploadLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* <p>
* 音频上传日志表 前端控制器
* </p>
*
* @author Auto Generated
* @since 2025-01-29
*/
@RestController
@RequestMapping("/api/yhyAudioUploadLog")
@Tag(name = "音频上传日志", description = "音频上传日志相关接口")
@Slf4j
public class YhyAudioUploadLogController {
@Autowired
private IYhyAudioUploadLogService yhyAudioUploadLogService;
/**
* 分页查询音频上传日志列表
*/
@GetMapping("/list")
@Operation(summary = "分页查询音频上传日志列表", description = "分页查询音频上传日志信息列表,支持按设备号和开始时间、结束时间查询")
public ResponseEntity<Map<String, Object>> getYhyAudioUploadLogList(
@Parameter(description = "页码", example = "1")
@RequestParam(defaultValue = "1") Integer current,
@Parameter(description = "每页大小", example = "10")
@RequestParam(defaultValue = "10") Integer size,
@Parameter(description = "设备号(精确查询)")
@RequestParam(required = false) String deviceNo,
@Parameter(description = "开始时间格式251129185131")
@RequestParam(required = false) String startTime,
@Parameter(description = "结束时间格式251129190131")
@RequestParam(required = false) String endTime,
@Parameter(description = "创建开始时间", example = "2025-01-01 00:00:00")
@RequestParam(required = false) String createStartTime,
@Parameter(description = "创建结束时间", example = "2025-12-31 23:59:59")
@RequestParam(required = false) String createEndTime) {
Map<String, Object> result = yhyAudioUploadLogService.getYhyAudioUploadLogList(
current, size, deviceNo, startTime, endTime, createStartTime, createEndTime);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
} else {
String message = (String) result.get("message");
if (message != null && message.contains("格式错误")) {
return ResponseEntity.badRequest().body(result);
}
return ResponseEntity.internalServerError().body(result);
}
}
/**
* 根据ID查询音频上传日志
*/
@GetMapping("/get/{id}")
@Operation(summary = "根据ID查询音频上传日志", description = "根据音频上传日志ID获取详细信息")
public ResponseEntity<Map<String, Object>> getYhyAudioUploadLogById(
@Parameter(description = "音频上传日志ID", required = true)
@PathVariable String id) {
Map<String, Object> result = yhyAudioUploadLogService.getYhyAudioUploadLogById(id);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
} else {
return ResponseEntity.notFound().build();
}
}
/**
* 根据设备号查询音频上传日志列表
*/
@GetMapping("/getByDeviceNo")
@Operation(summary = "根据设备号查询音频上传日志", description = "根据设备号查询音频上传日志列表")
public ResponseEntity<Map<String, Object>> getYhyAudioUploadLogByDeviceNo(
@Parameter(description = "设备号", required = true)
@RequestParam String deviceNo) {
Map<String, Object> result = yhyAudioUploadLogService.getYhyAudioUploadLogByDeviceNo(deviceNo);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
} else {
return ResponseEntity.internalServerError().body(result);
}
}
/**
* 新增音频上传日志
*/
@PostMapping("/add")
@Operation(summary = "新增音频上传日志", description = "添加新的音频上传日志信息")
public ResponseEntity<Map<String, Object>> addYhyAudioUploadLog(
@Parameter(description = "音频上传日志信息", required = true)
@RequestBody YhyAudioUploadLog yhyAudioUploadLog) {
Map<String, Object> result = yhyAudioUploadLogService.addYhyAudioUploadLog(yhyAudioUploadLog);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
} else {
return ResponseEntity.badRequest().body(result);
}
}
/**
* 更新音频上传日志信息
*/
@PutMapping("/update")
@Operation(summary = "更新音频上传日志信息", description = "更新音频上传日志详细信息")
public ResponseEntity<Map<String, Object>> updateYhyAudioUploadLog(
@Parameter(description = "音频上传日志信息", required = true)
@RequestBody YhyAudioUploadLog yhyAudioUploadLog) {
Map<String, Object> result = yhyAudioUploadLogService.updateYhyAudioUploadLog(yhyAudioUploadLog);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
} else {
String message = (String) result.get("message");
if (message != null && message.contains("不能为空")) {
return ResponseEntity.badRequest().body(result);
}
return ResponseEntity.badRequest().body(result);
}
}
/**
* 根据ID删除音频上传日志
*/
@DeleteMapping("/delete/{id}")
@Operation(summary = "删除音频上传日志", description = "根据音频上传日志ID删除信息")
public ResponseEntity<Map<String, Object>> deleteYhyAudioUploadLog(
@Parameter(description = "音频上传日志ID", required = true)
@PathVariable String id) {
Map<String, Object> result = yhyAudioUploadLogService.deleteYhyAudioUploadLog(id);
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
} else {
return ResponseEntity.badRequest().body(result);
}
}
}

View File

@@ -0,0 +1,13 @@
package com.rj.controller.yhy.readme;
/**
* Author: 李中华 wx: spllzh email(qq): 28668817@qq.com
* Date: 2025/11/29 15:28
* 深圳悦航益科技有限公司
* 地址https://iot.yuehangyi.com/
* 账户BJYDW
* 密码aBDd]@Gvy!
**/
public class log {
}