修改接口逻辑

This commit is contained in:
mi9688
2024-12-17 19:53:20 +08:00
parent 4a38fb84a0
commit fafd3ad8d3
10 changed files with 113 additions and 26 deletions

View File

@ -1,15 +1,17 @@
package com.fastbee.iot.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.fastbee.common.annotation.Excel;
import com.fastbee.common.core.domain.BaseEntity;
import java.util.Date;
/**
* 设备上电审核前上报的基础信息对象 iot_device_report_info
*
@ -136,4 +138,16 @@ public class DeviceReportInfo extends BaseEntity
@Excel(name = "状态:0未审核1已审核2已打印")
@ApiModelProperty("状态:0未审核1已审核2已打印")
private Integer status;
/** 上电时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "上电时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("上电时间")
private Date powersTime;
//----------------------------------------------------------业务字段-----------------------------------------------------------
/** 是否自动审核 */
private Boolean autoReview ;
}

View File

@ -58,4 +58,6 @@ public interface IDeviceReportInfoService
* @return 结果
*/
public int deleteDeviceReportInfoById(Long id);
boolean updateDeviceReportStatus(List<DeviceReportInfo> deviceReportInfo);
}

View File

@ -1,5 +1,6 @@
package com.fastbee.iot.service.impl;
import java.time.LocalDate;
import java.util.List;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
@ -23,9 +24,6 @@ public class DeviceReportInfoServiceImpl implements IDeviceReportInfoService
private DeviceReportInfoMapper deviceReportInfoMapper;
/**
* 查询设备上电审核前上报的基础信息
*
@ -47,7 +45,11 @@ public class DeviceReportInfoServiceImpl implements IDeviceReportInfoService
@Override
public List<DeviceReportInfo> selectDeviceReportInfoList(DeviceReportInfo deviceReportInfo)
{
return deviceReportInfoMapper.selectDeviceReportInfoList(deviceReportInfo);
List<DeviceReportInfo> deviceReportInfos = deviceReportInfoMapper.selectDeviceReportInfoList(deviceReportInfo);
//按照时间由近到远进行排序
deviceReportInfos.sort((o1, o2) -> o2.getPowersTime().compareTo(o1.getPowersTime()));
return deviceReportInfos;
}
/**
@ -62,17 +64,22 @@ public class DeviceReportInfoServiceImpl implements IDeviceReportInfoService
//设备编码查重
List<DeviceReportInfo> list = new LambdaQueryChainWrapper<>(deviceReportInfoMapper)
.select(DeviceReportInfo::getSerialNumber,DeviceReportInfo::getImei)
.eq(DeviceReportInfo::getSerialNumber, deviceReportInfo.getSerialNumber())
.or()
// .eq(DeviceReportInfo::getSerialNumber, deviceReportInfo.getSerialNumber())
// .or()
.eq(DeviceReportInfo::getImei, deviceReportInfo.getImei())
.list();
System.err.println("查重:"+list);
// System.err.println("查重:"+list);
if (!list.isEmpty()) {
if (list.get(0).getImei().equals(deviceReportInfo.getImei())) {
throw new ServiceException("IMEI号重复!");
} else if (list.get(0).getSerialNumber().equals(deviceReportInfo.getSerialNumber())) {
throw new ServiceException("设备编号重复!");
}
// else if (list.get(0).getSerialNumber().equals(deviceReportInfo.getSerialNumber())) {
// throw new ServiceException("设备编号重复!");
// }
}
//处理自动审核
if(deviceReportInfo.getAutoReview()!=null&&deviceReportInfo.getAutoReview()){
deviceReportInfo.setStatus(2);//修改状态为已审核
}
return deviceReportInfoMapper.insertDeviceReportInfo(deviceReportInfo);
}
@ -112,4 +119,11 @@ public class DeviceReportInfoServiceImpl implements IDeviceReportInfoService
{
return deviceReportInfoMapper.deleteDeviceReportInfoById(id);
}
@Override
public boolean updateDeviceReportStatus(List<DeviceReportInfo> deviceReportInfo) {
return false;
}
}