From 3637f31f3fbb563a4b61f114151d0b57ce372178 Mon Sep 17 00:00:00 2001 From: SjS Date: Wed, 16 Apr 2025 18:10:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=9E=8B=E5=8F=B7=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AsDeviceServiceImpl.java | 23 ++++++++++--------- .../mapper/device/AsDeviceMapper.xml | 4 ++++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/AutoSprout-watering/src/main/java/com/ruoyi/device/service/impl/AsDeviceServiceImpl.java b/AutoSprout-watering/src/main/java/com/ruoyi/device/service/impl/AsDeviceServiceImpl.java index 719af22..187376a 100644 --- a/AutoSprout-watering/src/main/java/com/ruoyi/device/service/impl/AsDeviceServiceImpl.java +++ b/AutoSprout-watering/src/main/java/com/ruoyi/device/service/impl/AsDeviceServiceImpl.java @@ -507,18 +507,19 @@ public class AsDeviceServiceImpl extends ServiceImpl i */ @Override public Boolean bandDevice(AsDevice asDevice) { - int i = asDeviceMapper.insertAsDevice(asDevice); - ServiceUtil.assertion(i == 0, "绑定失败!"); -// Boolean execute = transactionTemplate.execute(e -> { -// asDevice.setDeviceName(defaultName); -// int i = bandSn(asDevice); -// ServiceUtil.assertion(i == 0, "录入失败!"); -// setDeviceValue(asDevice); + Boolean execute = transactionTemplate.execute(e -> { + asDevice.setDeviceName(defaultName); + int i = bandSn(asDevice); + ServiceUtil.assertion(i == 0, "录入失败!"); + AsDevice device = setDeviceValue(asDevice); + i = asDeviceMapper.insertAsDevice(device); + ServiceUtil.assertion(i == 0, "绑定失败!"); // 切换默认设备 - // toggleDevice(asDevice.getUserId(), asDevice.getDeviceId()); -// return Boolean.TRUE; -// }); -// if(Boolean.FALSE.equals(execute))throw new ServiceException("绑定失败"); + // toggleDevice(asDevice.getUserId(), asDevice.getDeviceId()); + logger.info("=================【绑定设备】成功=================="); + return Boolean.TRUE; + }); + if(Boolean.FALSE.equals(execute))throw new ServiceException("绑定失败"); return true; } diff --git a/AutoSprout-watering/src/main/resources/mapper/device/AsDeviceMapper.xml b/AutoSprout-watering/src/main/resources/mapper/device/AsDeviceMapper.xml index d893bce..03629d7 100644 --- a/AutoSprout-watering/src/main/resources/mapper/device/AsDeviceMapper.xml +++ b/AutoSprout-watering/src/main/resources/mapper/device/AsDeviceMapper.xml @@ -161,6 +161,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" regular_watering_json, soil_moisture, water_intensity_switch, + bluetooth_id, + bluetooth_name, pre @@ -194,6 +196,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{regularWateringJson}, #{soilMoisture}, #{waterIntensitySwitch}, + #{bluetoothId}, + #{bluetoothName}, #{pre}