修改接口逻辑

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

View File

@ -28,10 +28,11 @@
<result property="replaceManufacturerName" column="replace_manufacturer_name" />
<result property="deviceId" column="device_id" />
<result property="status" column="status" />
<result property="powersTime" column="powers_time" />
</resultMap>
<sql id="selectDeviceReportInfoVo">
select id, imei, iccid, mcu_id, bsp_type, lte_type, mcu_type, mcu_fw, lte_fw, lcd_manufacturer, voice_manufacturer, fram_model, replace_manufacturer, test_record, batch_number, serial_number, qr_code, name, lcd_manufacturer_name, voice_manufacturer_name, replace_manufacturer_name, device_id, status from iot_device_report_info
select id, imei, iccid, mcu_id, bsp_type, lte_type, mcu_type, mcu_fw, lte_fw, lcd_manufacturer, voice_manufacturer, fram_model, replace_manufacturer, test_record, batch_number, serial_number, qr_code, name, lcd_manufacturer_name, voice_manufacturer_name, replace_manufacturer_name, device_id, status, powers_time from iot_device_report_info
</sql>
<select id="selectDeviceReportInfoList" parameterType="DeviceReportInfo" resultMap="DeviceReportInfoResult">
@ -59,6 +60,7 @@
<if test="replaceManufacturerName != null and replaceManufacturerName != ''"> and replace_manufacturer_name like concat('%', #{replaceManufacturerName}, '%')</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="status != null "> and status = #{status}</if>
<if test="powersTime != null "> and powers_time = #{powersTime}</if>
</where>
</select>
@ -92,6 +94,7 @@
<if test="replaceManufacturerName != null">replace_manufacturer_name,</if>
<if test="deviceId != null">device_id,</if>
<if test="status != null">status,</if>
<if test="powersTime != null">powers_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="imei != null and imei != ''">#{imei},</if>
@ -116,6 +119,7 @@
<if test="replaceManufacturerName != null">#{replaceManufacturerName},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="status != null">#{status},</if>
<if test="powersTime != null">#{powersTime},</if>
</trim>
</insert>
@ -144,6 +148,7 @@
<if test="replaceManufacturerName != null">replace_manufacturer_name = #{replaceManufacturerName},</if>
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="status != null">status = #{status},</if>
<if test="powersTime != null">powers_time = #{powersTime},</if>
</trim>
where id = #{id}
</update>