设备录入

This commit is contained in:
邱贞招 2024-11-13 11:09:36 +08:00
parent 1210a63f15
commit dc40089668
6 changed files with 82 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import com.ruoyi.common.core.domain.entity.RlUser;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.verify.vo.IDResponse; import com.ruoyi.common.utils.verify.vo.IDResponse;
@ -610,4 +611,39 @@ public class AppVerifyController extends BaseController
return success(order); return success(order);
} }
/**
* sn和mac号绑定
*/
@Log(title = "设备绑定", businessType = BusinessType.BAND)
@PostMapping("/band")
public AjaxResult bandSn(String sn,String mac,Long hardwareVersionId)
{
logger.info("sn和mac号绑定【sn="+sn+"【mac="+mac+"】,【hardwareVersionId="+hardwareVersionId+"");
RlDevice asDevice = new RlDevice();
asDevice.setSn(sn);
asDevice.setMac(mac);
asDevice.setHardwareVersionId(hardwareVersionId);
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NOT_BAND);
asDevice.setCreateTime(DateUtils.getNowDate());
return toAjax(deviceService.bandSn(asDevice));
}
/**
* 根据mac修改sn
*/
@Log(title = "根据mac修改sn", businessType = BusinessType.UPDATESN)
@PostMapping("/updateSn")
public AjaxResult updateSn(String sn,String mac,Long hardwareVersionId)
{
logger.info("根据mac修改sn【sn="+sn+"【mac="+mac+"】,【hardwareVersionId="+hardwareVersionId+"");
RlDevice asDevice = new RlDevice();
asDevice.setSn(sn);
asDevice.setMac(mac);
asDevice.setHardwareVersionId(hardwareVersionId);
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NOT_BAND);
asDevice.setCreateTime(DateUtils.getNowDate());
return toAjax(deviceService.updateSn(asDevice));
}
} }

View File

@ -153,4 +153,12 @@ public enum BusinessType
* 更新设备 * 更新设备
*/ */
REFRESH, REFRESH,
/**
* 绑定
*/
BAND,
/**
* 根据mac修改sn
*/
UPDATESN
} }

View File

@ -89,6 +89,14 @@ public interface RlDeviceMapper extends BaseMapper<RlDevice>
*/ */
public int updateDeviceBySn(RlDevice RlDevice); public int updateDeviceBySn(RlDevice RlDevice);
/**
* 根据MAC修改设备
*
* @param rlDevice 设备
* @return 结果
*/
public int updateAsDeviceByMac(RlDevice rlDevice);
/** /**
* 删除设备 * 删除设备
* *

View File

@ -361,6 +361,11 @@ public interface IRlDeviceService extends IService<RlDevice>
*/ */
int bandSn(RlDevice device); int bandSn(RlDevice device);
/**
* 根据mac修改sn
*/
int updateSn(RlDevice device);
/** /**
* 根据mac号判断是否有绑定过 * 根据mac号判断是否有绑定过
*/ */

View File

@ -2096,6 +2096,23 @@ public class RlDeviceServiceImpl extends ServiceImpl<RlDeviceMapper, RlDevice> i
return 1; return 1;
} }
/**
* 根据mac修改sn
*/
@SneakyThrows
@Override
public int updateSn(RlDevice device) {
RlDevice updateDevice = new RlDevice();
updateDevice.setSn(device.getSn());
updateDevice.setHardwareVersionId(device.getHardwareVersionId());
updateDevice.setMac(device.getMac());
int i = deviceMapper.updateAsDeviceByMac(updateDevice);
if(i>0){
log.info("【sn和mac号绑定】===>mac【{}】已经绑定过:更新sn【{}】成功",device.getMac(),device.getSn());
}
return 1;
}
/** /**
* 判断是否靠近边界 * 判断是否靠近边界

View File

@ -304,9 +304,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
where sn = #{sn} where sn = #{sn}
</update> </update>
<update id="batchDisable">
update
<update id="updateAsDeviceByMac">
update rl_device
<trim prefix="SET" suffixOverrides=",">
<if test="sn != null">sn = #{sn},</if>
<if test="hardwareVersionId != null">hardware_version_id = #{hardwareVersionId},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
</trim>
where mac = #{mac}
</update> </update>
<delete id="deleteDeviceByDeviceId" parameterType="Long"> <delete id="deleteDeviceByDeviceId" parameterType="Long">