1. 联调
This commit is contained in:
parent
a15c7a369a
commit
34198da5c1
|
@ -1,10 +1,12 @@
|
|||
package com.ruoyi.web.controller.app;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.constant.ServiceConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.CommonUtil;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.system.domain.*;
|
||||
import com.ruoyi.system.service.*;
|
||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.ruoyi.web.controller.system;
|
|||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.system.domain.AsDevice;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -114,4 +115,74 @@ public class AsDeviceController extends BaseController
|
|||
{
|
||||
return toAjax(asDeviceService.deleteAsDeviceByDeviceIds(deviceIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 响铃寻车
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:device:ring')")
|
||||
@PostMapping("/device/ring")
|
||||
public AjaxResult ring(String sn)
|
||||
{
|
||||
if(StrUtil.isBlank(sn)){
|
||||
logger.info("没有sn号参数:【sn={}】",sn);
|
||||
return error("请传sn号参数"+"【sn="+sn+"】");
|
||||
}
|
||||
Boolean i =asDeviceService.ring(sn);
|
||||
return success(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员开锁
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:device:unlocking')")
|
||||
@Log(title = "管理员开锁", businessType = BusinessType.UNLOCKING)
|
||||
@PostMapping("/admin/unlocking")
|
||||
public AjaxResult unlocking(String sn)
|
||||
{
|
||||
logger.info("【管理员开锁请求】:{}",sn);
|
||||
Boolean aBoolean =asDeviceService.unlocking(sn);
|
||||
return success(aBoolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员关锁
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:device:unlocking')")
|
||||
@Log(title = "管理员关锁", businessType = BusinessType.LOCK)
|
||||
@PostMapping("/admin/lock")
|
||||
public AjaxResult lock(String sn)
|
||||
{
|
||||
logger.info("【管理员关锁请求】:{}",sn);
|
||||
Boolean aBoolean =asDeviceService.adminLock(sn);
|
||||
return success(aBoolean);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 车辆上线
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:device:online')")
|
||||
@Log(title = "车辆上线", businessType = BusinessType.ONLINE)
|
||||
@PostMapping("/device/online")
|
||||
public AjaxResult online(String sn)
|
||||
{
|
||||
logger.info("【车辆上线请求】:{}",sn);
|
||||
Boolean aBoolean =asDeviceService.online(sn);
|
||||
return success(aBoolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆下线
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:device:online')")
|
||||
@Log(title = "车辆下线", businessType = BusinessType.OFFLINE)
|
||||
@PostMapping("/device/offline")
|
||||
public AjaxResult offline(String sn)
|
||||
{
|
||||
logger.info("【车辆下线请求】:{}",sn);
|
||||
Boolean aBoolean =asDeviceService.offline(sn);
|
||||
return success(aBoolean);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -223,6 +223,8 @@ iot:
|
|||
daysToExpire: 100
|
||||
# 推送消息token
|
||||
token: JZWgouXXNcgTbxCyRCLKbQkKQMhyUrfL
|
||||
# 创建设备地址
|
||||
deviceUrl: https://iot-api.heclouds.com/device/create
|
||||
geo:
|
||||
# 高德地图key web服务 手续费
|
||||
key: 834f1f029671d84272554528311ff0f1
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.common.utils.onenet;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateDeviceVo {
|
||||
|
||||
private String device_name;
|
||||
|
||||
private String product_id;
|
||||
}
|
|
@ -20,6 +20,7 @@ import com.ruoyi.common.utils.DateUtils;
|
|||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.common.utils.map.GeoUtils;
|
||||
import com.ruoyi.common.utils.onenet.CreateDeviceVo;
|
||||
import com.ruoyi.common.utils.onenet.IotUtil;
|
||||
import com.ruoyi.common.utils.onenet.ResponseVo;
|
||||
import com.ruoyi.common.utils.onenet.Token;
|
||||
|
@ -104,6 +105,9 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
@Value(value = "${iot.timeout}")
|
||||
private String timeout;
|
||||
|
||||
@Value(value = "${iot.deviceUrl}")
|
||||
private String deviceUrl;
|
||||
|
||||
/**
|
||||
* 查询设备
|
||||
*
|
||||
|
@ -659,7 +663,6 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
JSONObject paramsObj = JSON.parseObject(result);
|
||||
String code = paramsObj.getString("code");
|
||||
//记录命令
|
||||
|
||||
if (!HttpStatus.IOT_SUCCESS.equals(code))
|
||||
{
|
||||
throw new ServiceException(code+"-----"+ IotUtil.formatMsg(code));
|
||||
|
@ -1442,9 +1445,32 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
* sn和mac号绑定
|
||||
* 注册onenet设备
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public int bandSn(AsDevice asDevice) {
|
||||
return asDeviceMapper.insert(asDevice);
|
||||
// 调用onenet接口
|
||||
CreateDeviceVo createDeviceVo = new CreateDeviceVo();
|
||||
createDeviceVo.setDevice_name(asDevice.getMac());
|
||||
createDeviceVo.setProduct_id(productId);
|
||||
String result = HttpUtils.sendPostWithToken(deviceUrl,JSON.toJSONString(createDeviceVo), Token.getToken());
|
||||
log.info("【sn和mac号绑定】===>IOT请求调用结果:【{}】",result);
|
||||
JSONObject paramsObj = JSON.parseObject(result);
|
||||
String code = paramsObj.getString("code");
|
||||
//记录命令
|
||||
if (!HttpStatus.IOT_SUCCESS.equals(code))
|
||||
{
|
||||
throw new ServiceException(code+"-----"+ paramsObj.getString("msg"));
|
||||
}
|
||||
try{
|
||||
int insert = asDeviceMapper.insert(asDevice);
|
||||
if(insert==0){
|
||||
throw new ServiceException("该SN已经存在,请勿重复绑定!");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("该SN已经存在",e.getMessage());
|
||||
throw new ServiceException("该SN已经存在,请勿重复绑定!");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="lockStatus != null and lockStatus != ''"> and de.lock_status = #{lockStatus}</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
order by de.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectAsDeviceListWithIsolate" parameterType="AsDevice" resultMap="AsDeviceResult">
|
||||
|
@ -77,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="lockStatus != null and lockStatus != ''"> and de.lock_status = #{lockStatus}</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
order by de.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectAsDeviceByDeviceId" parameterType="Long" resultMap="AsDeviceResult">
|
||||
|
|
Loading…
Reference in New Issue
Block a user