调整BUG
This commit is contained in:
parent
2aca665c5d
commit
53b9d01399
@ -73,7 +73,7 @@ public class DeviceController {
|
||||
}
|
||||
@GetMapping("/getDeviceId")
|
||||
@Operation(summary = "根据设备编号获得设备详情")
|
||||
public CommonResult<DeviceRespVO> getDeviceId(@RequestParam("devicecode") Integer devicecode) {
|
||||
public CommonResult<DeviceRespVO> getDeviceId(@RequestParam("devicecode") String devicecode) {
|
||||
DeviceDO device = deviceService.getDeviceId(devicecode);
|
||||
return success(BeanUtils.toBean(device, DeviceRespVO.class));
|
||||
}
|
||||
@ -130,7 +130,7 @@ public class DeviceController {
|
||||
@Operation(summary = "锁定/解锁设备")
|
||||
@Parameter(name = "devicecode", description = "设备编号", required = true)
|
||||
@Parameter(name = "devicestatus", description = "设备状态", required = true)
|
||||
public CommonResult<Boolean> lockDevice(@RequestParam("devicecode") Integer devicecode,
|
||||
public CommonResult<Boolean> lockDevice(@RequestParam("devicecode") String devicecode,
|
||||
@RequestParam("devicestatus") Integer devicestatus) {
|
||||
deviceService.lockDevice(devicecode, devicestatus);
|
||||
return success(true);
|
||||
@ -139,7 +139,7 @@ public class DeviceController {
|
||||
@PutMapping("/restartDevice")
|
||||
@Operation(summary = "重启设备")
|
||||
@Parameter(name = "devicecode", description = "设备编号", required = true)
|
||||
public CommonResult<Boolean> restartDevice(@RequestParam("devicecode") Integer devicecode) {
|
||||
public CommonResult<Boolean> restartDevice(@RequestParam("devicecode") String devicecode) {
|
||||
deviceService.restartDevice(devicecode);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ public class DevicePageReqVO extends PageParam {
|
||||
private String devicename;
|
||||
|
||||
@Schema(description = "设备ID/编号")
|
||||
private Integer devicecode;
|
||||
private String devicecode;
|
||||
|
||||
@Schema(description = "设备类型", example = "1")
|
||||
private String devicetype;
|
||||
|
||||
@ -22,7 +22,7 @@ public class DeviceRespVO {
|
||||
|
||||
@Schema(description = "设备ID/编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("设备ID/编号")
|
||||
private Integer devicecode;
|
||||
private String devicecode;
|
||||
|
||||
@Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("设备类型")
|
||||
|
||||
@ -19,7 +19,7 @@ public class DeviceSaveReqVO {
|
||||
private String devicename;
|
||||
|
||||
@Schema(description = "设备ID/编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer devicecode;
|
||||
private String devicecode;
|
||||
|
||||
@Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotEmpty(message = "设备类型不能为空")
|
||||
|
||||
@ -60,7 +60,7 @@ public class DeviceuserController {
|
||||
}
|
||||
@GetMapping("/getDevCount")
|
||||
@Operation(summary = "获得关联设备人员数量")
|
||||
public CommonResult<Integer> getDeviceusercount(@RequestParam("devicecode") Integer devicecode) {
|
||||
public CommonResult<Integer> getDeviceusercount(@RequestParam("devicecode") String devicecode) {
|
||||
return success(deviceuserService.getDeviceusercount(devicecode));
|
||||
}
|
||||
@GetMapping("/get")
|
||||
@ -93,7 +93,7 @@ public class DeviceuserController {
|
||||
@GetMapping("/getDeviceuserByDeviceId")
|
||||
@Operation(summary = "根据设备ID获得设备人员关联")
|
||||
@Parameter(name = "deviceid", description = "设备编号", required = true)
|
||||
public CommonResult<List<DeviceuserRespVO>> getDeviceuserByDeviceId(@RequestParam("deviceid") Integer deviceid) {
|
||||
public CommonResult<List<DeviceuserRespVO>> getDeviceuserByDeviceId(@RequestParam("deviceid") String deviceid) {
|
||||
List<DeviceuserDO> deviceusers = deviceuserService.getDeviceuserByDeviceId(deviceid);
|
||||
return success(BeanUtils.toBean(deviceusers, DeviceuserRespVO.class));
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
public class DeviceuserPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "设备ID", example = "16280")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
|
||||
@Schema(description = "设备类型", example = "ECU")
|
||||
private String devicetype;
|
||||
|
||||
@ -18,7 +18,7 @@ public class DeviceuserRespVO {
|
||||
|
||||
@Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16280")
|
||||
@ExcelProperty("设备ID")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
|
||||
@Schema(description = "设备类型",requiredMode = Schema.RequiredMode.REQUIRED,example = "ECU")
|
||||
@ExcelProperty("设备类型")
|
||||
|
||||
@ -16,7 +16,7 @@ public class DeviceuserSaveReqVO {
|
||||
|
||||
@Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16280")
|
||||
@NotNull(message = "设备ID不能为空")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
|
||||
@Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "ECU")
|
||||
@NotNull(message = "设备类型不能为空")
|
||||
|
||||
@ -16,7 +16,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
public class DoctornoticePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "设备ID", example = "29419")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
|
||||
@Schema(description = "接收通知的用户ID", example = "2690")
|
||||
private Integer userid;
|
||||
|
||||
@ -18,7 +18,7 @@ public class DoctornoticeRespVO {
|
||||
|
||||
@Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29419")
|
||||
@ExcelProperty("设备ID")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
|
||||
@Schema(description = "接收通知的用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2690")
|
||||
@ExcelProperty("接收通知的用户ID")
|
||||
|
||||
@ -16,7 +16,7 @@ public class DoctornoticeSaveReqVO {
|
||||
|
||||
@Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29419")
|
||||
@NotNull(message = "设备ID不能为空")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
|
||||
@Schema(description = "接收通知的用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2690")
|
||||
@NotNull(message = "接收通知的用户ID不能为空")
|
||||
|
||||
@ -12,6 +12,8 @@ import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
@ -90,18 +92,47 @@ public class EcgdataController {
|
||||
@Operation(summary = "根据用户ID获得心电采集时间列表")
|
||||
@Parameter(name = "userId", description = "用户编号", required = true, example = "1024")
|
||||
public CommonResult<List<EcgdataTimeRespVO>> getEcgdataByUserId(@RequestParam("userId") Integer userId) {
|
||||
List<EcgdataDO> ecgdataList = ecgdataService.getEcgdataByUserId(userId);
|
||||
return success(BeanUtils.toBean(ecgdataList, EcgdataTimeRespVO.class));
|
||||
// 使用优化后的Service方法,直接在数据库层面去重
|
||||
List<LocalDateTime> distinctTimeList = ecgdataService.getDistinctCollectTimeByUserId(userId);
|
||||
|
||||
// 转换为响应对象
|
||||
List<EcgdataTimeRespVO> result = distinctTimeList.stream()
|
||||
.map(time -> {
|
||||
EcgdataTimeRespVO vo = new EcgdataTimeRespVO();
|
||||
vo.setCollecttime(time);
|
||||
return vo;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return success(result);
|
||||
}
|
||||
|
||||
@GetMapping("/getByTime")
|
||||
@Operation(summary = "根据时间戳和用户ID获得心电数据")
|
||||
@Operation(summary = "根据时间戳和用户ID获得心电数据(聚合图片URL)")
|
||||
@Parameter(name = "collecttime", description = "采集时间戳", required = true)
|
||||
@Parameter(name = "userId", description = "用户编号", required = true)
|
||||
public CommonResult<EcgdataRespVO> getEcgdataByTime(@RequestParam("collecttime") Long collecttime,
|
||||
@RequestParam("userId") Integer userId) {
|
||||
EcgdataDO ecgdata = ecgdataService.getEcgdataByTime(collecttime, userId);
|
||||
return success(BeanUtils.toBean(ecgdata, EcgdataRespVO.class));
|
||||
public CommonResult<EcgdataTimeImageRespVO> getEcgdataByTime(@RequestParam("collecttime") Long collecttime,
|
||||
@RequestParam("userId") Integer userId) {
|
||||
List<EcgdataDO> ecgdataList = ecgdataService.getEcgdataListByTime(collecttime, userId);
|
||||
|
||||
if (ecgdataList == null || ecgdataList.isEmpty()) {
|
||||
return success(null);
|
||||
}
|
||||
|
||||
// 取第一条记录作为基础数据
|
||||
EcgdataDO firstEcgdata = ecgdataList.get(0);
|
||||
EcgdataTimeImageRespVO result = BeanUtils.toBean(firstEcgdata, EcgdataTimeImageRespVO.class);
|
||||
|
||||
// 聚合所有的图片URL
|
||||
List<String> imageUrls = new ArrayList<>();
|
||||
for (EcgdataDO ecgdata : ecgdataList) {
|
||||
if (ecgdata.getEcgimageurl() != null && !ecgdata.getEcgimageurl().trim().isEmpty()) {
|
||||
imageUrls.add(ecgdata.getEcgimageurl());
|
||||
}
|
||||
}
|
||||
result.setEcgimageurls(imageUrls);
|
||||
|
||||
return success(result);
|
||||
}
|
||||
|
||||
}
|
||||
@ -17,7 +17,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
public class EcgdataPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "设备ID", example = "2207")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
|
||||
@Schema(description = "设备名称", example = "芋艿")
|
||||
private String devicename;
|
||||
|
||||
@ -19,7 +19,7 @@ public class EcgdataRespVO {
|
||||
|
||||
@Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2207")
|
||||
@ExcelProperty("设备ID")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
|
||||
@Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@ExcelProperty("设备名称")
|
||||
|
||||
@ -17,7 +17,7 @@ public class EcgdataSaveReqVO {
|
||||
|
||||
@Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2207")
|
||||
@NotNull(message = "设备ID不能为空")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
|
||||
@Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotEmpty(message = "设备名称不能为空")
|
||||
|
||||
@ -18,7 +18,7 @@ public class EcgdataTimeImageRespVO {
|
||||
|
||||
@Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2207")
|
||||
@ExcelProperty("设备ID")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
|
||||
@Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@ExcelProperty("设备名称")
|
||||
|
||||
@ -35,7 +35,7 @@ public class DeviceDO {
|
||||
* 设备ID/编号
|
||||
*/
|
||||
@TableField("devicecode")
|
||||
private Integer devicecode;
|
||||
private String devicecode;
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
|
||||
@ -30,7 +30,7 @@ public class DeviceuserDO {
|
||||
* 设备ID
|
||||
*/
|
||||
@TableField("deviceid")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
|
||||
@ -32,7 +32,7 @@ public class DoctornoticeDO {
|
||||
* 设备ID
|
||||
*/
|
||||
@TableField("deviceid")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
/**
|
||||
* 接收通知的用户ID
|
||||
*/
|
||||
|
||||
@ -32,7 +32,7 @@ public class EcgdataDO {
|
||||
* 设备ID
|
||||
*/
|
||||
@TableField("deviceid")
|
||||
private Integer deviceid;
|
||||
private String deviceid;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.ecgdata;
|
||||
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.ecgdata.EcgdataDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.ecgdata.vo.*;
|
||||
|
||||
/**
|
||||
@ -48,4 +50,13 @@ public interface EcgdataMapper extends BaseMapperX<EcgdataDO> {
|
||||
.orderByDesc(EcgdataDO::getId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID获取去重的采集时间列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 去重的采集时间列表,按时间倒序排列
|
||||
*/
|
||||
@Select("SELECT DISTINCT collecttime FROM tb_ecgdata WHERE userid = #{userId} ORDER BY collecttime DESC")
|
||||
List<LocalDateTime> selectDistinctCollectTimeByUserId(Integer userId);
|
||||
|
||||
}
|
||||
@ -50,7 +50,7 @@ public interface DeviceService {
|
||||
/*
|
||||
* 根据设备编号查询设备
|
||||
* */
|
||||
DeviceDO getDeviceId(Integer devicecode);
|
||||
DeviceDO getDeviceId(String devicecode);
|
||||
|
||||
/**
|
||||
* 获得设备分页
|
||||
@ -92,12 +92,12 @@ public interface DeviceService {
|
||||
* @param devicecode 设备编号
|
||||
* @param devicestatus 设备状态
|
||||
*/
|
||||
void lockDevice(Integer devicecode, Integer devicestatus);
|
||||
void lockDevice(String devicecode, Integer devicestatus);
|
||||
|
||||
/**
|
||||
* 重启设备
|
||||
*
|
||||
* @param devicecode 设备编号
|
||||
*/
|
||||
void restartDevice(Integer devicecode);
|
||||
void restartDevice(String devicecode);
|
||||
}
|
||||
@ -75,7 +75,7 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
return deviceMapper.selectById(id);
|
||||
}
|
||||
@Override
|
||||
public DeviceDO getDeviceId(Integer devicecode) {
|
||||
public DeviceDO getDeviceId(String devicecode) {
|
||||
return deviceMapper.selectOne(DeviceDO::getDevicecode, devicecode);
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lockDevice(Integer devicecode, Integer devicestatus) {
|
||||
public void lockDevice(String devicecode, Integer devicestatus) {
|
||||
// 校验设备是否存在
|
||||
DeviceDO device = deviceMapper.selectOne(DeviceDO::getDevicecode, devicecode);
|
||||
if (device == null) {
|
||||
@ -165,7 +165,7 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restartDevice(Integer devicecode) {
|
||||
public void restartDevice(String devicecode) {
|
||||
// 校验设备是否存在
|
||||
DeviceDO device = deviceMapper.selectOne(DeviceDO::getDevicecode, devicecode);
|
||||
if (device == null) {
|
||||
|
||||
@ -46,7 +46,7 @@ public interface DeviceuserService {
|
||||
/*
|
||||
* 设备ID 查询设备人员数量
|
||||
* */
|
||||
Integer getDeviceusercount(Integer devicecode);
|
||||
Integer getDeviceusercount(String devicecode);
|
||||
|
||||
/**
|
||||
* 获得设备人员关联分页
|
||||
@ -62,7 +62,7 @@ public interface DeviceuserService {
|
||||
* @param deviceid 设备编号
|
||||
* @return 设备人员关联列表
|
||||
*/
|
||||
List<DeviceuserDO> getDeviceuserByDeviceId(Integer deviceid);
|
||||
List<DeviceuserDO> getDeviceuserByDeviceId(String deviceid);
|
||||
|
||||
/**
|
||||
* 根据用户ID获得设备人员关联列表
|
||||
|
||||
@ -66,7 +66,7 @@ public class DeviceuserServiceImpl implements DeviceuserService {
|
||||
return deviceuserMapper.selectById(id);
|
||||
}
|
||||
@Override
|
||||
public Integer getDeviceusercount(Integer devicecode) {
|
||||
public Integer getDeviceusercount(String devicecode) {
|
||||
return deviceuserMapper.selectCount(DeviceuserDO::getDeviceid, devicecode).intValue();
|
||||
}
|
||||
@Override
|
||||
@ -75,7 +75,7 @@ public class DeviceuserServiceImpl implements DeviceuserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceuserDO> getDeviceuserByDeviceId(Integer deviceid) {
|
||||
public List<DeviceuserDO> getDeviceuserByDeviceId(String deviceid) {
|
||||
return deviceuserMapper.selectList(new LambdaQueryWrapper<DeviceuserDO>()
|
||||
.eq(DeviceuserDO::getDeviceid, deviceid));
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.service.ecgdata;
|
||||
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.ecgdata.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.ecgdata.EcgdataDO;
|
||||
@ -69,4 +70,21 @@ public interface EcgdataService {
|
||||
*/
|
||||
EcgdataDO getEcgdataByTime(Long collecttime, Integer userId);
|
||||
|
||||
/**
|
||||
* 根据时间戳和用户ID获得心电数据采集列表(聚合图片URL)
|
||||
*
|
||||
* @param collecttime 采集时间戳
|
||||
* @param userId 用户编号
|
||||
* @return 聚合后的心电数据采集
|
||||
*/
|
||||
List<EcgdataDO> getEcgdataListByTime(Long collecttime, Integer userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID获得去重的心电采集时间列表
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @return 去重的采集时间列表
|
||||
*/
|
||||
List<LocalDateTime> getDistinctCollectTimeByUserId(Integer userId);
|
||||
|
||||
}
|
||||
@ -7,6 +7,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.ecgdata.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.ecgdata.EcgdataDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -87,4 +88,17 @@ public class EcgdataServiceImpl implements EcgdataService {
|
||||
.orderByDesc(EcgdataDO::getId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EcgdataDO> getEcgdataListByTime(Long collecttime, Integer userId) {
|
||||
return ecgdataMapper.selectList(new LambdaQueryWrapperX<EcgdataDO>()
|
||||
.eq(EcgdataDO::getUserid, userId)
|
||||
.eq(EcgdataDO::getCollecttime, new Date(collecttime))
|
||||
.orderByDesc(EcgdataDO::getId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalDateTime> getDistinctCollectTimeByUserId(Integer userId) {
|
||||
return ecgdataMapper.selectDistinctCollectTimeByUserId(userId);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user