1. 调整
This commit is contained in:
parent
00c5f92445
commit
87af5ba59f
|
@ -26,7 +26,7 @@ watering:
|
|||
# iot秘钥
|
||||
accessKey: dJqF0qYhUbK/o1Pr9I5qxNoP14FlJLC+BFK2ZTjUX+lnKwoNYvBYsM/7Xu1ERIzSkUoxVkP/N1RMvGlBKMoBtA==
|
||||
# 超时响应时间(秒)
|
||||
timeout: 10
|
||||
timeout: 5
|
||||
# token过期时间
|
||||
daysToExpire: 100
|
||||
# 推送消息token
|
||||
|
|
|
@ -213,7 +213,7 @@
|
|||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="设备Mac" prop="mac">
|
||||
<el-input v-model="form.mac" placeholder="请输入设备Mac号" />
|
||||
<el-input v-model="form.mac" placeholder="请输入设备Mac号" :disabled="title=='修改设备'"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
|
@ -350,7 +350,7 @@ import {listDevice, getDevice, delDevice, addDevice, updateDevice, watering} fro
|
|||
import {listClassify} from "@/api/device/classify";
|
||||
import {listVersion} from "@/api/device/version";
|
||||
import {listModel} from "@/api/device/model";
|
||||
import {listUser} from "@/api/system/user";
|
||||
import {listUser} from "@/api/user/user";
|
||||
|
||||
export default {
|
||||
name: "Device",
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|||
|
||||
/**
|
||||
* 型号列表Controller
|
||||
*
|
||||
*
|
||||
* @author qiuzhenzhao
|
||||
* @date 2023-11-11
|
||||
*/
|
||||
|
@ -77,6 +77,10 @@ public class AsModelController extends BaseController
|
|||
@PostMapping
|
||||
public AjaxResult add(@RequestBody AsModel asModel)
|
||||
{
|
||||
if (!asModelService.checkModelUnique(asModel))
|
||||
{
|
||||
return error("新增型号'" + asModel.getModel() + "'失败,该型号已存在");
|
||||
}
|
||||
asModel.setCreateBy(getUsername());
|
||||
return toAjax(asModelService.insertAsModel(asModel));
|
||||
}
|
||||
|
@ -89,6 +93,10 @@ public class AsModelController extends BaseController
|
|||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody AsModel asModel)
|
||||
{
|
||||
if (!asModelService.checkModelUnique(asModel))
|
||||
{
|
||||
return error("修改型号'" + asModel.getModel() + "'失败,该型号已存在");
|
||||
}
|
||||
return toAjax(asModelService.updateAsModel(asModel));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.ruoyi.device.domain.AsModel;
|
|||
|
||||
/**
|
||||
* 型号列表Mapper接口
|
||||
*
|
||||
*
|
||||
* @author qiuzhenzhao
|
||||
* @date 2023-11-11
|
||||
*/
|
||||
|
@ -16,7 +16,7 @@ public interface AsModelMapper extends BaseMapper<AsModel>
|
|||
{
|
||||
/**
|
||||
* 查询型号列表
|
||||
*
|
||||
*
|
||||
* @param modelId 型号列表主键
|
||||
* @return 型号列表
|
||||
*/
|
||||
|
@ -24,7 +24,7 @@ public interface AsModelMapper extends BaseMapper<AsModel>
|
|||
|
||||
/**
|
||||
* 查询型号列表列表
|
||||
*
|
||||
*
|
||||
* @param asModel 型号列表
|
||||
* @return 型号列表集合
|
||||
*/
|
||||
|
@ -32,7 +32,7 @@ public interface AsModelMapper extends BaseMapper<AsModel>
|
|||
|
||||
/**
|
||||
* 新增型号列表
|
||||
*
|
||||
*
|
||||
* @param asModel 型号列表
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -40,7 +40,7 @@ public interface AsModelMapper extends BaseMapper<AsModel>
|
|||
|
||||
/**
|
||||
* 修改型号列表
|
||||
*
|
||||
*
|
||||
* @param asModel 型号列表
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -48,7 +48,7 @@ public interface AsModelMapper extends BaseMapper<AsModel>
|
|||
|
||||
/**
|
||||
* 删除型号列表
|
||||
*
|
||||
*
|
||||
* @param modelId 型号列表主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -56,9 +56,17 @@ public interface AsModelMapper extends BaseMapper<AsModel>
|
|||
|
||||
/**
|
||||
* 批量删除型号列表
|
||||
*
|
||||
*
|
||||
* @param modelIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAsModelByModelIds(Long[] modelIds);
|
||||
|
||||
/**
|
||||
* 根据型号名称查询
|
||||
*
|
||||
* @param model 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public AsModel checkModelUnique(String model);
|
||||
}
|
||||
|
|
|
@ -5,15 +5,15 @@ import com.ruoyi.device.domain.AsModel;
|
|||
|
||||
/**
|
||||
* 型号列表Service接口
|
||||
*
|
||||
*
|
||||
* @author qiuzhenzhao
|
||||
* @date 2023-11-11
|
||||
*/
|
||||
public interface IAsModelService
|
||||
public interface IAsModelService
|
||||
{
|
||||
/**
|
||||
* 查询型号列表
|
||||
*
|
||||
*
|
||||
* @param modelId 型号列表主键
|
||||
* @return 型号列表
|
||||
*/
|
||||
|
@ -21,7 +21,7 @@ public interface IAsModelService
|
|||
|
||||
/**
|
||||
* 查询型号列表列表
|
||||
*
|
||||
*
|
||||
* @param asModel 型号列表
|
||||
* @return 型号列表集合
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@ public interface IAsModelService
|
|||
|
||||
/**
|
||||
* 新增型号列表
|
||||
*
|
||||
*
|
||||
* @param asModel 型号列表
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -37,7 +37,7 @@ public interface IAsModelService
|
|||
|
||||
/**
|
||||
* 修改型号列表
|
||||
*
|
||||
*
|
||||
* @param asModel 型号列表
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -45,7 +45,7 @@ public interface IAsModelService
|
|||
|
||||
/**
|
||||
* 批量删除型号列表
|
||||
*
|
||||
*
|
||||
* @param modelIds 需要删除的型号列表主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -53,9 +53,18 @@ public interface IAsModelService
|
|||
|
||||
/**
|
||||
* 删除型号列表信息
|
||||
*
|
||||
*
|
||||
* @param modelId 型号列表主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAsModelByModelId(Long modelId);
|
||||
|
||||
|
||||
/**
|
||||
* 校验型号是否唯一
|
||||
*
|
||||
* @param asModel 型号信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean checkModelUnique(AsModel asModel);
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
package com.ruoyi.device.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.AsUser;
|
||||
import com.ruoyi.common.core.domain.onenet.DatapointValue;
|
||||
import com.ruoyi.device.domain.AsDevice;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户 业务层
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface IAsUserService
|
||||
{
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
|
@ -22,7 +23,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 根据条件分页查询已分配用户角色列表
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
|
@ -30,7 +31,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 根据条件分页查询未分配用户角色列表
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
|
@ -38,7 +39,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
|
@ -46,7 +47,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
|
@ -56,7 +57,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -80,7 +81,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 新增用户信息
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -88,7 +89,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -96,7 +97,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -104,7 +105,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 修改用户状态
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -112,7 +113,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 修改用户基本信息
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -120,7 +121,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 修改用户头像
|
||||
*
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param avatar 头像地址
|
||||
* @return 结果
|
||||
|
@ -129,7 +130,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -137,7 +138,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
|
@ -146,7 +147,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 通过用户ID删除用户
|
||||
*
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -154,7 +155,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 批量删除用户信息
|
||||
*
|
||||
*
|
||||
* @param userIds 需要删除的用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
|
@ -162,7 +163,7 @@ public interface IAsUserService
|
|||
|
||||
/**
|
||||
* 导入用户数据
|
||||
*
|
||||
*
|
||||
* @param userList 用户数据列表
|
||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
||||
* @param operName 操作用户
|
||||
|
@ -182,4 +183,9 @@ public interface IAsUserService
|
|||
* 根据登录用户获取是否有绑定设备
|
||||
*/
|
||||
List<AsDevice> selectDeviceInfoByUser(Long userId,Long deviceId);
|
||||
|
||||
/**
|
||||
* 计算下次定时时间
|
||||
*/
|
||||
public void setNextDs(AsDevice asDevice1, DatapointValue.nextDs next_ds);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.ruoyi.common.constant.HttpStatus;
|
|||
import com.ruoyi.common.constant.IotConstants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.onenet.*;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
|
@ -15,6 +16,9 @@ import com.ruoyi.common.utils.onenet.Token;
|
|||
import com.ruoyi.device.domain.*;
|
||||
import com.ruoyi.device.mapper.*;
|
||||
import com.ruoyi.device.service.IAsDeviceService;
|
||||
import com.ruoyi.device.service.IAsTimerService;
|
||||
import com.ruoyi.device.service.IAsUserService;
|
||||
import com.ruoyi.device.service.IAsWateringRecordService;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
@ -24,12 +28,14 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
|
||||
|
||||
/**
|
||||
* 设备列表Service业务层处理
|
||||
*
|
||||
|
@ -60,6 +66,14 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
@Resource
|
||||
private AsWateringRecordMapper wateringRecordMapper;
|
||||
|
||||
@Resource
|
||||
private IAsUserService asUserService;
|
||||
|
||||
@Resource
|
||||
private IAsTimerService asTimerService;
|
||||
|
||||
@Resource
|
||||
private IAsWateringRecordService asWateringRecordService;
|
||||
|
||||
@Value(value = "${watering.iotUrl}")
|
||||
private String iotUrl;
|
||||
|
@ -84,11 +98,12 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
|
||||
|
||||
/**
|
||||
* 查询设备列表
|
||||
* 查询设备详情
|
||||
*
|
||||
* @param deviceId 设备列表主键
|
||||
* @return 设备列表
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public AsDevice selectAsDeviceByDeviceId(Long deviceId)
|
||||
{
|
||||
|
@ -96,10 +111,86 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
if(ObjectUtils.isEmpty(device)){
|
||||
throw new ServiceException("没有找到该设备");
|
||||
}
|
||||
/** 请求onenet更新设备参数*/
|
||||
updateDeviceParam(device);
|
||||
device.setPicture(modelMapper.selectAsModelByModelId(device.getModelId()).getPicture());
|
||||
return device;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从onenet更新设备参数
|
||||
*
|
||||
* @param asDevice1 设备对象
|
||||
* @return 设备列表
|
||||
*/
|
||||
private void updateDeviceParam(AsDevice asDevice1) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException {
|
||||
String sendUrl = iotUrl+ IotConstants.ADDS_COMMAND;
|
||||
String token = Token.getToken();
|
||||
String deviceName = asDevice1.getMac();//mac地址就是产品名称
|
||||
String param = "device_name=" + deviceName + "&product_id=" + productId +"&timeout=" + timeout;
|
||||
sendUrl = sendUrl + "?"+param;
|
||||
String result = HttpUtils.sendPostWithToken(sendUrl, "111", token);
|
||||
JSONObject paramsObj = JSON.parseObject(result);
|
||||
String code = paramsObj.getString("code");
|
||||
if (!HttpStatus.IOT_SUCCESS.equals(code)) {
|
||||
asDevice1.setOnlineStatus("0");//在线状态:0-不在线;1-在线
|
||||
if(ObjectUtils.isEmpty(asDevice1)){
|
||||
throw new ServiceException("设备不在线");
|
||||
}
|
||||
}else{
|
||||
asDevice1.setOnlineStatus("1");
|
||||
// 查询onenet设备参数
|
||||
String datapointsUrl = iotUrl+ IotConstants.ADDS_HISTORY_DATAPOINTS + "?"+param;
|
||||
logger.info("IOT获取到Authorization:【{}】", token);
|
||||
String result2 = HttpUtils.sendGetWithToken(datapointsUrl, null, token);
|
||||
DataPointRes dataPointRes = JSONObject.parseObject(result2, DataPointRes.class);
|
||||
Data data = dataPointRes.getData();
|
||||
List<Datastream> datastreams = data.getDatastreams();
|
||||
for (Datastream datastream: datastreams) {
|
||||
if(datastream.getId().equals("jj")){
|
||||
List<Datapoint> datapoints = datastream.getDatapoints();
|
||||
Datapoint datapoint = datapoints.get(0);
|
||||
DatapointValue value = JSONObject.parseObject(datapoint.getValue().toString(), DatapointValue.class);
|
||||
asDevice1.setWaterIntensity(value.getJiaoshui_qiangdu());
|
||||
DatapointValue.Tr tr = value.getTr();
|
||||
asDevice1.setSoilMoistureClose(tr.getEnd_sd());
|
||||
asDevice1.setSoilMoistureOpen(tr.getStart_sd());
|
||||
asDevice1.setSoilMoisture(tr.getKaiguan().toString());
|
||||
asDevice1.setPulseModeParam(JSON.toJSONString(value.getMc()));
|
||||
DatapointValue.nextDs next_ds = value.getNext_ds();
|
||||
/**设置下次浇水时间日期*/
|
||||
asUserService.setNextDs(asDevice1, next_ds);
|
||||
/**设置浇水模式*/
|
||||
List<String> modeList = new ArrayList<>();
|
||||
Boolean sw = next_ds.getSw();
|
||||
List<DatapointValue.Ds> dsArray = value.getDsArray();
|
||||
//清除无效定时器
|
||||
List<DatapointValue.Ds> ds = asTimerService.cleanInvalidDs(dsArray);
|
||||
if(sw && ds.size()>0){//如果定时器开启且定时器列表不为空
|
||||
modeList.add("1");
|
||||
}
|
||||
Boolean kaiguan = tr.getKaiguan();
|
||||
if(kaiguan){//土壤模式开关
|
||||
modeList.add("2");
|
||||
}
|
||||
asDevice1.setMode(modeList);
|
||||
asDevice1.setModeStr(JSON.toJSONString(modeList));
|
||||
asDevice1.setCurrentSoilMoisture(value.getTuran_show());
|
||||
List<AsWateringRecord> asWateringRecords = asWateringRecordService.selectAsWateringRecordList(AsWateringRecord.builder().deviceId(asDevice1.getDeviceId()).build());
|
||||
// 根据asWateringRecords查询最后一次浇水时间
|
||||
if(asWateringRecords.size()>0){
|
||||
asDevice1.setLastWatering(asWateringRecords.get(0).getWaterTime());
|
||||
}
|
||||
/**将value转成device对象并保存到数据库*/
|
||||
int i = asDeviceMapper.updateAsDevice(asDevice1);
|
||||
if(i>0){
|
||||
logger.info("保存设备参数成功:【{}】", JSON.toJSONString(asDevice1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备列表列表
|
||||
*
|
||||
|
|
|
@ -8,7 +8,9 @@ import java.util.List;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.device.domain.AsDevice;
|
||||
import com.ruoyi.device.domain.AsDeviceClassify;
|
||||
import com.ruoyi.device.domain.AsDeviceVersion;
|
||||
|
@ -69,12 +71,14 @@ public class AsModelServiceImpl extends ServiceImpl<AsModelMapper, AsModel> impl
|
|||
QueryWrapper<AsDevice> queryWrapper = Wrappers.query();
|
||||
for (AsModel model: models) {
|
||||
//累计激活 device表--activation_time激活时间不为null
|
||||
queryWrapper.eq("model_id",model.getModelId());
|
||||
queryWrapper.isNotNull("activation_time").ne("activation_time","");
|
||||
Integer activationNum = deviceMapper.selectCount(queryWrapper);
|
||||
model.setActivationNum(activationNum);
|
||||
|
||||
//在线率 device表--online_status为1 在线数/总数
|
||||
QueryWrapper<AsDevice> queryWrapper2 = Wrappers.query();
|
||||
queryWrapper2.eq("model_id",model.getModelId());
|
||||
queryWrapper2.eq("online_status","1");
|
||||
Double onlineNum = deviceMapper.selectCount(queryWrapper2).doubleValue();
|
||||
|
||||
|
@ -145,4 +149,22 @@ public class AsModelServiceImpl extends ServiceImpl<AsModelMapper, AsModel> impl
|
|||
{
|
||||
return asModelMapper.deleteAsModelByModelId(modelId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验型号是否唯一
|
||||
*
|
||||
* @param asModel 型号信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkModelUnique(AsModel asModel)
|
||||
{
|
||||
Long modelId = StringUtils.isNull(asModel.getModelId()) ? -1L : asModel.getModelId();
|
||||
AsModel info = asModelMapper.checkModelUnique(asModel.getModel());
|
||||
if (StringUtils.isNotNull(info) && info.getModelId().longValue() != modelId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -499,7 +499,7 @@ public class AsUserServiceImpl implements IAsUserService
|
|||
return asDevices;
|
||||
}
|
||||
|
||||
private void setNextDs(AsDevice asDevice1, DatapointValue.nextDs next_ds) {
|
||||
public void setNextDs(AsDevice asDevice1, DatapointValue.nextDs next_ds) {
|
||||
//将week将10进制转成2进制
|
||||
String week = Integer.toBinaryString(next_ds.getWeek());
|
||||
if(StringUtils.isNotEmpty(week)){
|
||||
|
@ -530,6 +530,7 @@ public class AsUserServiceImpl implements IAsUserService
|
|||
System.out.println("浇水时间大于当前时间,浇水时间未过");
|
||||
next_ds.setDate(date);
|
||||
asDevice1.setNextDs(JSON.toJSONString(next_ds));
|
||||
break;
|
||||
}else{
|
||||
System.out.println("浇水时间小于当前时间,浇水时间已过");
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.ruoyi.device.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.utils.DictUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.device.domain.AsWateringRecord;
|
||||
import com.ruoyi.device.mapper.AsWateringRecordMapper;
|
||||
import com.ruoyi.device.service.IAsWateringRecordService;
|
||||
|
@ -61,6 +62,9 @@ public class AsWateringRecordServiceImpl extends ServiceImpl<AsWateringRecordMap
|
|||
sprayingTime = record.getSprayingTime() / 60;
|
||||
stringBuilder.append(sprayingTime+"分钟");
|
||||
}
|
||||
if(StringUtils.isNotEmpty(record.getPulseMode())){
|
||||
record.setPulseMode(record.getPulseMode().equals("true")?"开":"关");
|
||||
}
|
||||
record.setWateringDesc(stringBuilder.toString());
|
||||
// record.setWaterTimeStr(DateUtils.getYYYY_MM_DD(record.getWaterTime()));//时间格式化
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.device.mapper.AsModelMapper">
|
||||
|
||||
|
||||
<resultMap type="AsModel" id="AsModelResult">
|
||||
<result property="modelId" column="model_id" />
|
||||
<result property="classifyId" column="classify_id" />
|
||||
|
@ -27,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectAsModelList" parameterType="AsModel" resultMap="AsModelResult">
|
||||
<include refid="selectAsModelVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="modelName != null and modelName != ''"> and model_name like concat('%', #{modelName}, '%')</if>
|
||||
<if test="model != null and model != ''"> and model = #{model}</if>
|
||||
<if test="picture != null and picture != ''"> and picture = #{picture}</if>
|
||||
|
@ -37,12 +37,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="introduce != null and introduce != ''"> and introduce = #{introduce}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectAsModelByModelId" parameterType="Long" resultMap="AsModelResult">
|
||||
<include refid="selectAsModelVo"/>
|
||||
where model_id = #{modelId}
|
||||
</select>
|
||||
|
||||
<select id="checkModelUnique" parameterType="String" resultMap="AsModelResult">
|
||||
select model_id, model from as_model where model = #{model} limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertAsModel" parameterType="AsModel" useGeneratedKeys="true" keyProperty="modelId">
|
||||
insert into as_model
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
@ -102,9 +105,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</delete>
|
||||
|
||||
<delete id="deleteAsModelByModelIds" parameterType="String">
|
||||
delete from as_model where model_id in
|
||||
delete from as_model where model_id in
|
||||
<foreach item="modelId" collection="array" open="(" separator="," close=")">
|
||||
#{modelId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue
Block a user