1. 调整

This commit is contained in:
邱贞招 2024-04-24 15:53:18 +08:00
parent e9544c8518
commit 28d17976a3
9 changed files with 69 additions and 5 deletions

View File

@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
/**
@ -65,6 +66,9 @@ public class AppController extends BaseController
@Autowired
private IAsUserCollectionService asUserCollectionService;
@Autowired
private IAsModelService asModelService;
@Value(value = "${baidu.identifyUrl}")
private String identifyUrl;
@ -393,4 +397,18 @@ public class AppController extends BaseController
return AjaxResult.success(asDeviceService.getWeather(ipAddr));
}
/**
* 根据型号返回型号名称
*/
@GetMapping("/getModelName")
public AjaxResult getModelName(String[] asModels)
{
List<AsModel> asModelList = new ArrayList<>();
for (String model:asModels) {
AsModel asModel = asModelService.selectAsModelByModel(model);
asModelList.add(asModel);
}
return AjaxResult.success(asModelList);
}
}

View File

@ -156,4 +156,12 @@ public class AsDevice extends BaseEntity
/** 是否默认展示0-否1-是 */
@Excel(name = "是否默认展示")
private String isDefault;
/** 蓝牙id用于前端链接蓝牙 */
@Excel(name = "蓝牙id")
private String bluetoothId;
/** 蓝牙名称 */
@Excel(name = "蓝牙名称")
private String bluetoothName;
}

View File

@ -1,6 +1,5 @@
package com.ruoyi.device.domain.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@ -22,6 +22,14 @@ public interface AsModelMapper extends BaseMapper<AsModel>
*/
public AsModel selectAsModelByModelId(Long modelId);
/**
* 根据型号查询型号对象
*
* @param model 型号列表主键
* @return 型号列表
*/
public AsModel selectAsModelByModel(String model);
/**
* 查询型号列表列表
*

View File

@ -19,6 +19,14 @@ public interface IAsModelService
*/
public AsModel selectAsModelByModelId(Long modelId);
/**
* 根据型号查询型号对象
*
* @param model 型号列表主键
* @return 型号列表
*/
public AsModel selectAsModelByModel(String model);
/**
* 查询型号列表列表
*

View File

@ -441,10 +441,12 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
if(ObjectUtils.isEmpty(device)){
throw new ServiceException("该设备已经被删除");
}
if(ObjectUtils.isNotEmpty(device.getUserId()) && "1".equals(device.getIsNetwork())){
throw new ServiceException("该设备已经绑定用户,请先");
if(ObjectUtils.isNotEmpty(device.getUserId()) && device.getUserId()>0){
throw new ServiceException("该设备已经绑定用户,请先解绑");
}
device.setUserId(asDevice.getUserId());
device.setBluetoothId(asDevice.getBluetoothId());
device.setBluetoothName(asDevice.getBluetoothName());
int i = asDeviceMapper.updateAsDevice(device);
if(i>0){
toggleDevice(asDevice.getUserId(), device.getDeviceId());

View File

@ -58,6 +58,18 @@ public class AsModelServiceImpl extends ServiceImpl<AsModelMapper, AsModel> impl
return asModelMapper.selectAsModelByModelId(modelId);
}
/**
* 根据型号查询型号对象
*
* @param model 型号列表主键
* @return 型号列表
*/
@Override
public AsModel selectAsModelByModel(String model)
{
return asModelMapper.selectAsModelByModel(model);
}
/**
* 查询型号列表列表
*

View File

@ -38,10 +38,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="isNetwork" column="is_network" />
<result property="isDefault" column="is_default" />
<result property="modeStr" column="mode_str" />
<result property="bluetoothId" column="bluetooth_id" />
<result property="bluetoothName" column="bluetooth_name" />
</resultMap>
<sql id="selectAsDeviceVo">
select device_id, picture, device_name, classify_id, classify_name, model_id, model, mac, activation_time, online_status, user_id, user_name, nick_name, regular_watering, soil_moisture_open, soil_moisture_close, water_intensity, pulse_mode, pulse_mode_param, screen_rest_time, version, version_id, create_by, create_time, update_by, update_time, remark, regular_watering_json, soil_moisture, water_intensity_switch,is_network,is_default,mode_str from as_device
select device_id, picture, device_name, classify_id, classify_name, model_id, model, mac, activation_time, online_status, user_id, user_name, nick_name, regular_watering, soil_moisture_open, soil_moisture_close, water_intensity, pulse_mode, pulse_mode_param, screen_rest_time, version, version_id, create_by, create_time, update_by, update_time, remark, regular_watering_json, soil_moisture, water_intensity_switch,is_network,is_default,mode_str,bluetooth_id,bluetooth_name from as_device
</sql>
<select id="selectAsDeviceList" parameterType="AsDevice" resultMap="AsDeviceResult">
@ -177,7 +179,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status = #{status},</if>
<if test="isNetwork != null">is_network = #{isNetwork},</if>
<if test="isDefault != null">is_default = #{isDefault},</if>
<if test="modeStr != null">mode_str = #{modeStr}</if>
<if test="modeStr != null">mode_str = #{modeStr},</if>
<if test="bluetoothId != null">bluetooth_id = #{bluetoothId},</if>
<if test="bluetoothName != null">bluetooth_name = #{bluetoothName}</if>
</trim>
where device_id = #{deviceId}
</update>

View File

@ -46,6 +46,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select model_id, model from as_model where model = #{model} limit 1
</select>
<select id="selectAsModelByModel" parameterType="string" resultMap="AsModelResult">
<include refid="selectAsModelVo"/>
where model = #{model}
</select>
<insert id="insertAsModel" parameterType="AsModel" useGeneratedKeys="true" keyProperty="modelId">
insert into as_model
<trim prefix="(" suffix=")" suffixOverrides=",">