Compare commits
No commits in common. "ec20e746a7b0dae6becae7483af7e52c03b9d907" and "3aa7145e58422c7e5296e1e7750a638f6abf0a38" have entirely different histories.
ec20e746a7
...
3aa7145e58
|
@ -99,16 +99,16 @@ public class AppController extends BaseController
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据定位获取运营区详细信息 device not subscribed
|
* 根据定位获取运营区详细信息
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/area/info")
|
@GetMapping(value = "/area/info")
|
||||||
public AjaxResult areaInfo(String longitude,String latitude, String deptId)
|
public AjaxResult areaInfo(String longitude,String latitude)
|
||||||
{
|
{
|
||||||
if(StrUtil.isBlank(longitude) || StrUtil.isBlank(latitude)){
|
if(StrUtil.isBlank(longitude) || StrUtil.isBlank(latitude)){
|
||||||
logger.info("没有经纬度参数:【longitude={}】,【latitude={}】",longitude,latitude);
|
logger.info("没有经纬度参数:【longitude={}】,【latitude={}】",longitude,latitude);
|
||||||
return error("请传经纬度参数"+"【longitude="+longitude+"】,【latitude="+latitude+"】");
|
return error("请传经纬度参数"+"【longitude="+longitude+"】,【latitude="+latitude+"】");
|
||||||
}
|
}
|
||||||
EtOperatingArea area = etOperatingAreaService.getAreaInfoByLocation(longitude,latitude,deptId);
|
EtOperatingArea area = etOperatingAreaService.getAreaInfoByLocation(longitude,latitude);
|
||||||
return success(area);
|
return success(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONArray;
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.ruoyi.common.constant.IotConstants;
|
import com.ruoyi.common.constant.IotConstants;
|
||||||
import com.ruoyi.common.constant.ServiceConstants;
|
import com.ruoyi.common.constant.ServiceConstants;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
@ -35,6 +37,7 @@ import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -74,8 +77,6 @@ public class ReceiveController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ScheduledExecutorService scheduledExecutorService;
|
private ScheduledExecutorService scheduledExecutorService;
|
||||||
|
|
||||||
private final Object lock = new Object();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 功能描述:第三方平台数据接收。<p>
|
* 功能描述:第三方平台数据接收。<p>
|
||||||
|
@ -96,32 +97,11 @@ public class ReceiveController {
|
||||||
log.info("receive方法接收到参数: body String --- " +body);
|
log.info("receive方法接收到参数: body String --- " +body);
|
||||||
/************************************************
|
/************************************************
|
||||||
* 解析数据推送请求,非加密模式。
|
* 解析数据推送请求,非加密模式。
|
||||||
* 如果是明文模式使用以下代码 hangdleBody(body, false); ChatGPT is under heavy load
|
* 如果是明文模式使用以下代码
|
||||||
**************************************************/
|
**************************************************/
|
||||||
/*************明文模式 start****************/
|
/*************明文模式 start****************/
|
||||||
BodyObj obj = Util.resolveBody(body, false);
|
BodyObj obj = Util.resolveBody(body, false);
|
||||||
log.info("receive方法解析对象: body Object --- " + JSON.toJSONString(obj));
|
log.info("receive方法解析对象: body Object --- " + JSON.toJSONString(obj));
|
||||||
// 起一个异步线程处理数据
|
|
||||||
scheduledExecutorService.schedule(() -> {
|
|
||||||
new Thread(() -> {
|
|
||||||
synchronized (lock) {
|
|
||||||
try {
|
|
||||||
handleBody(obj);
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvalidKeyException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}, 0, TimeUnit.SECONDS);
|
|
||||||
/*************明文模式 end****************/
|
|
||||||
return "ok";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleBody(BodyObj obj) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException {
|
|
||||||
if (obj != null){
|
if (obj != null){
|
||||||
boolean dataRight = Util.checkSignature(obj, token);
|
boolean dataRight = Util.checkSignature(obj, token);
|
||||||
if (dataRight){
|
if (dataRight){
|
||||||
|
@ -181,52 +161,17 @@ public class ReceiveController {
|
||||||
String noRidingOutage = area.getNoRidingOutage();
|
String noRidingOutage = area.getNoRidingOutage();
|
||||||
if (noRidingOutage.equals("1") && value.getStatus() != 3) { // 禁行区内断电
|
if (noRidingOutage.equals("1") && value.getStatus() != 3) { // 禁行区内断电
|
||||||
log.info("禁行区内断电命令--SN:" + device.getSn());
|
log.info("禁行区内断电命令--SN:" + device.getSn());
|
||||||
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "禁行区内断电");
|
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE, "禁行区内断电");
|
||||||
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
|
||||||
int updateAsDevice = asDeviceService.updateAsDevice(device);
|
|
||||||
if (updateAsDevice > 0) {
|
|
||||||
log.info("禁行区内断电--更新设备锁状态成功SN:" + device.getSn());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 3.超出运营区外断电*/
|
/** 3.超出运营区外断电*/
|
||||||
boolean isAreaZone = asDeviceService.isAreaZone(device.getSn(), area);
|
boolean isAreaZone = asDeviceService.isAreaZone(device.getSn(), area);
|
||||||
if(!isAreaZone){
|
if(!isAreaZone){
|
||||||
//是否在30米范围内
|
|
||||||
boolean inPolygon = GeoUtils.isInPolygonWithTolerance(lon.toString(), lat.toString(), GeoUtils.fromWkt(area.getBoundary()), 60);
|
|
||||||
if(inPolygon){
|
|
||||||
//在20米范围内,发报警
|
|
||||||
log.info("超出运营区30米内发送警告命令--SN:" + device.getSn());
|
|
||||||
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY3, "超出运营区30米内");
|
|
||||||
}else{
|
|
||||||
//超出运营区外断电
|
|
||||||
String isAdminUnlocking = device.getIsAdminUnlocking();// 是否管理员开锁
|
String isAdminUnlocking = device.getIsAdminUnlocking();// 是否管理员开锁
|
||||||
String areaOutOutage = area.getAreaOutOutage();
|
String areaOutOutage = area.getAreaOutOutage();
|
||||||
if (areaOutOutage.equals("1") && value.getStatus() != 3 && !isAdminUnlocking.equals("1")) { // 超出营运区断电
|
if (areaOutOutage.equals("1") && value.getStatus() != 3 && !isAdminUnlocking.equals("1")) { // 超出营运区断电
|
||||||
log.info("超出营运区断电命令--SN:" + device.getSn());
|
log.info("超出营运区断电命令--SN:" + device.getSn());
|
||||||
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "超出营运区断电");
|
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE, "超出营运区断电");
|
||||||
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
|
||||||
int updateAsDevice = asDeviceService.updateAsDevice(device);
|
|
||||||
if (updateAsDevice > 0) {
|
|
||||||
log.info("禁行区内断电--更新设备锁状态成功SN:" + device.getSn());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
// 判断该车辆是否在进行中的订单,并且车辆的锁状态是关,状态是骑行中
|
|
||||||
Boolean inOrderBySn = etOrderService.isInOrderBySn(device.getSn());
|
|
||||||
if (inOrderBySn && ServiceConstants.VEHICLE_STATUS_IN_USING.equals(device.getStatus()) && ServiceConstants.LOCK_STATUS_CLOSE.equals(device.getLockStatus())) { // 有正在骑行的订单,给车辆上电
|
|
||||||
log.info("返回营运区上电,有正在骑行的订单,给车辆上电--SN:" + device.getSn());
|
|
||||||
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "返回营运区上电");
|
|
||||||
// 更新车辆状态和锁状态
|
|
||||||
/** 3.更新车辆状态*/
|
|
||||||
device.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
|
||||||
device.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
|
|
||||||
device.setIsAdminUnlocking("0");
|
|
||||||
int i1 = asDeviceService.updateAsDevice(device);
|
|
||||||
if(i1>1){
|
|
||||||
log.info("【返回营运区上电】更新车辆状态成功");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 4.行程线路添加,更新订单中的trip_route字段 */
|
/** 4.行程线路添加,更新订单中的trip_route字段 */
|
||||||
|
@ -309,6 +254,8 @@ public class ReceiveController {
|
||||||
}else {
|
}else {
|
||||||
log.info("receive方法参数为空: body empty error");
|
log.info("receive方法参数为空: body empty error");
|
||||||
}
|
}
|
||||||
|
/*************明文模式 end****************/
|
||||||
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLastPointSame(JSONArray jsonArray, BigDecimal lon, BigDecimal lat) {
|
private boolean isLastPointSame(JSONArray jsonArray, BigDecimal lon, BigDecimal lat) {
|
||||||
|
|
|
@ -138,7 +138,6 @@ public class SysLoginController
|
||||||
log.info("没有传入areaId参数:【areaId={}】",areaId);
|
log.info("没有传入areaId参数:【areaId={}】",areaId);
|
||||||
return AjaxResult.error("请传areaId参数"+"【areaId="+areaId+"】");
|
return AjaxResult.error("请传areaId参数"+"【areaId="+areaId+"】");
|
||||||
}
|
}
|
||||||
log.info("【微信登录/wxlogin】areaId参数:【areaId={}】",areaId);
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
// 生成令牌
|
// 生成令牌
|
||||||
String token = loginService.wxloing(mobileCode,jsCode,areaId);
|
String token = loginService.wxloing(mobileCode,jsCode,areaId);
|
||||||
|
|
|
@ -116,22 +116,6 @@ public class IotConstants {
|
||||||
*/
|
*/
|
||||||
public static final String COMMAND_PLAY8 = "play8@";
|
public static final String COMMAND_PLAY8 = "play8@";
|
||||||
|
|
||||||
/**
|
|
||||||
* 命令 频率:5秒
|
|
||||||
*/
|
|
||||||
public static final String COMMAND_FREQUENCY_5 = "sub5@";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 命令 频率:20秒
|
|
||||||
*/
|
|
||||||
public static final String COMMAND_FREQUENCY_20 = "sub20@";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 命令 频率:一个小时
|
|
||||||
*/
|
|
||||||
public static final String COMMAND_FREQUENCY_3600 = "sub3600@";
|
|
||||||
|
|
||||||
|
|
||||||
/**----------------------------命令end----------------------------*/
|
/**----------------------------命令end----------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,6 @@ public class GeoUtils {
|
||||||
Coordinate[] coordinates = polygon.getCoordinates();
|
Coordinate[] coordinates = polygon.getCoordinates();
|
||||||
for (Coordinate coord : coordinates) {
|
for (Coordinate coord : coordinates) {
|
||||||
double distance = calculateDistance(lat, lon, coord.y, coord.x);
|
double distance = calculateDistance(lat, lon, coord.y, coord.x);
|
||||||
log.info("距离----distance:{}",distance);
|
|
||||||
if (distance <= tolerance) {
|
if (distance <= tolerance) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import javax.annotation.Resource;
|
||||||
|
|
||||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.ruoyi.common.core.domain.entity.AsUser;
|
import com.ruoyi.common.core.domain.entity.AsUser;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
|
@ -14,7 +13,6 @@ import com.ruoyi.common.utils.wx.AccessTokenUtil;
|
||||||
import com.ruoyi.common.utils.wx.vo.WeChatMiniAuthorizeVo;
|
import com.ruoyi.common.utils.wx.vo.WeChatMiniAuthorizeVo;
|
||||||
import com.ruoyi.system.service.IAsUserService;
|
import com.ruoyi.system.service.IAsUserService;
|
||||||
import com.ruoyi.system.service.IWxPayService;
|
import com.ruoyi.system.service.IWxPayService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
|
@ -49,7 +47,6 @@ import com.ruoyi.system.service.ISysUserService;
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
@Component
|
@Component
|
||||||
public class SysLoginService
|
public class SysLoginService
|
||||||
{
|
{
|
||||||
|
@ -209,15 +206,13 @@ public class SysLoginService
|
||||||
*/
|
*/
|
||||||
public String wxloing(String mobileCode,String jsCode,String areaId) {
|
public String wxloing(String mobileCode,String jsCode,String areaId) {
|
||||||
//根据jsCode换取openid
|
//根据jsCode换取openid
|
||||||
SysDept dept = wxPayService.getDeptObjByAreaId(Long.parseLong(areaId));
|
String openId = getOpenId(jsCode);
|
||||||
log.info("【微信登录/wxlogin】获取到运营商对象:【{}】", JSON.toJSON(dept));
|
|
||||||
String openId = getOpenId(jsCode,dept.getAppid(),dept.getAppSecret());
|
|
||||||
String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=";
|
String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=";
|
||||||
String phoneNumber = null;
|
String phoneNumber = null;
|
||||||
AsUser user = null;
|
AsUser user = null;
|
||||||
|
|
||||||
/** 根据手机号获取到用户名*/
|
/** 根据手机号获取到用户名*/
|
||||||
|
SysDept dept = wxPayService.getDeptObjByAreaId(Long.parseLong(areaId));
|
||||||
String token = AccessTokenUtil.getToken(dept.getAppid(), dept.getAppSecret());
|
String token = AccessTokenUtil.getToken(dept.getAppid(), dept.getAppSecret());
|
||||||
url = url+token;
|
url = url+token;
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
@ -291,10 +286,8 @@ public class SysLoginService
|
||||||
*/
|
*/
|
||||||
public String loginByopenid(String jsCode,String areaId) {
|
public String loginByopenid(String jsCode,String areaId) {
|
||||||
//根据jsCode换取openid
|
//根据jsCode换取openid
|
||||||
SysDept dept = wxPayService.getDeptObjByAreaId(Long.parseLong(areaId));
|
String openid = getOpenId(jsCode);
|
||||||
log.info("【微信登录/wxlogin】获取到运营商对象:【{}】", JSON.toJSON(dept));
|
AsUser user = asUserService.selectUserByWxopenid(openid);
|
||||||
String openId = getOpenId(jsCode,dept.getAppid(),dept.getAppSecret());
|
|
||||||
AsUser user = asUserService.selectUserByWxopenid(openId);
|
|
||||||
if(ObjectUtils.isEmpty(user)){
|
if(ObjectUtils.isEmpty(user)){
|
||||||
throw new ServiceException("未查询到用户信息");
|
throw new ServiceException("未查询到用户信息");
|
||||||
}else{
|
}else{
|
||||||
|
@ -325,8 +318,10 @@ public class SysLoginService
|
||||||
return tokenService.createToken(loginUser);
|
return tokenService.createToken(loginUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getOpenId(String jsCode,String appId,String secret) {
|
private String getOpenId(String jsCode) {
|
||||||
//根据jsCode换取openid
|
//根据jsCode换取openid
|
||||||
|
String appId = SpringUtils.getRequiredProperty("wx.appid");
|
||||||
|
String secret = SpringUtils.getRequiredProperty("wx.appSecret");
|
||||||
String url = StrUtil.format("https://api.weixin.qq.com/sns/jscode2session?appid={}&secret={}&js_code={}&grant_type=authorization_code", appId, secret, jsCode);
|
String url = StrUtil.format("https://api.weixin.qq.com/sns/jscode2session?appid={}&secret={}&js_code={}&grant_type=authorization_code", appId, secret, jsCode);
|
||||||
String s = HttpUtils.sendGet(url);
|
String s = HttpUtils.sendGet(url);
|
||||||
WeChatMiniAuthorizeVo authorizeVo = JSONObject.parseObject(s, WeChatMiniAuthorizeVo.class);
|
WeChatMiniAuthorizeVo authorizeVo = JSONObject.parseObject(s, WeChatMiniAuthorizeVo.class);
|
||||||
|
|
|
@ -30,10 +30,6 @@ public class EtOperatingArea extends BaseEntityPlus implements Serializable
|
||||||
@TableId(value = "area_id", type = IdType.AUTO)
|
@TableId(value = "area_id", type = IdType.AUTO)
|
||||||
private Long areaId;
|
private Long areaId;
|
||||||
|
|
||||||
/** 运营商id */
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/** 区域名称 */
|
/** 区域名称 */
|
||||||
@Excel(name = "区域名称")
|
@Excel(name = "区域名称")
|
||||||
private String areaName;
|
private String areaName;
|
||||||
|
|
|
@ -94,14 +94,6 @@ public interface EtOrderMapper
|
||||||
*/
|
*/
|
||||||
public List<EtOrder> isInOrder(@Param("userId") Long userId,@Param("orderNo") String orderNo);
|
public List<EtOrder> isInOrder(@Param("userId") Long userId,@Param("orderNo") String orderNo);
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询当前车辆是否有正在进行中的订单
|
|
||||||
*
|
|
||||||
* @param sn 用户id
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public List<EtOrder> isInOrderBySn(@Param("sn") String sn);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检验预约订单只能有一个
|
* 检验预约订单只能有一个
|
||||||
*
|
*
|
||||||
|
|
|
@ -92,10 +92,9 @@ public interface IEtOperatingAreaService extends IService<EtOperatingArea>
|
||||||
*
|
*
|
||||||
* @param longitude 经度
|
* @param longitude 经度
|
||||||
* @param latitude 纬度
|
* @param latitude 纬度
|
||||||
* @param deptId 运营商id
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
EtOperatingArea getAreaInfoByLocation(String longitude, String latitude,String deptId);
|
EtOperatingArea getAreaInfoByLocation(String longitude, String latitude);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门ID获取运营区选择框列表
|
* 根据部门ID获取运营区选择框列表
|
||||||
|
|
|
@ -110,11 +110,6 @@ public interface IEtOrderService
|
||||||
*/
|
*/
|
||||||
List<EtOrder> isInOrder(Long userId,String orderNo);
|
List<EtOrder> isInOrder(Long userId,String orderNo);
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询当前车辆是否有正在进行中的订单
|
|
||||||
*/
|
|
||||||
Boolean isInOrderBySn(String sn);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建订单
|
* 创建订单
|
||||||
* @param order 订单信息
|
* @param order 订单信息
|
||||||
|
|
|
@ -437,7 +437,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
String token = Token.getToken();
|
String token = Token.getToken();
|
||||||
String finalOrderNo = orderNo;
|
String finalOrderNo = orderNo;
|
||||||
/** 2.发送命令*/
|
/** 2.发送命令*/
|
||||||
ResponseVo responseVo = sendCommandWithResp(asDevice.getMac(), token, IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "编号开锁");
|
ResponseVo responseVo = sendCommandWithResp(asDevice.getMac(), token, IotConstants.COMMAND_OPEN, "编号开锁");
|
||||||
if(responseVo.getCode() != 0){
|
if(responseVo.getCode() != 0){
|
||||||
throw new ServiceException("【扫码/编号开锁骑行】更新车辆状态失败");
|
throw new ServiceException("【扫码/编号开锁骑行】更新车辆状态失败");
|
||||||
}
|
}
|
||||||
|
@ -501,7 +501,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
String token = Token.getToken();
|
String token = Token.getToken();
|
||||||
Boolean execute = transactionTemplate.execute(e -> {
|
Boolean execute = transactionTemplate.execute(e -> {
|
||||||
/** 2.发送命令*/
|
/** 2.发送命令*/
|
||||||
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_20,"管理员开锁");
|
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"管理员开锁");
|
||||||
asDevice.setIsAdminUnlocking("1");
|
asDevice.setIsAdminUnlocking("1");
|
||||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
|
||||||
int i = asDeviceMapper.updateAsDevice(asDevice);
|
int i = asDeviceMapper.updateAsDevice(asDevice);
|
||||||
|
@ -689,7 +689,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
/** 1.获取token*/
|
/** 1.获取token*/
|
||||||
String token = Token.getToken();
|
String token = Token.getToken();
|
||||||
/** 2.发送命令*/
|
/** 2.发送命令*/
|
||||||
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_LLOSE+IotConstants.COMMAND_FREQUENCY_3600,"临时锁车");
|
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_LLOSE,"临时锁车");
|
||||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
||||||
if(StrUtil.isNotBlank(orderNo)){//有订单号,则是用户临时锁车
|
if(StrUtil.isNotBlank(orderNo)){//有订单号,则是用户临时锁车
|
||||||
/** 改变车辆状态:4-临时锁车 */
|
/** 改变车辆状态:4-临时锁车 */
|
||||||
|
@ -721,7 +721,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
if(StrUtil.isBlank(sn))throw new ServiceException("sn不能为空");
|
if(StrUtil.isBlank(sn))throw new ServiceException("sn不能为空");
|
||||||
AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn);
|
AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn);
|
||||||
/** 2.发送命令*/
|
/** 2.发送命令*/
|
||||||
sendCommand(asDevice.getMac(), Token.getToken(),IotConstants.COMMAND_CLOSE+IotConstants.COMMAND_FREQUENCY_3600,"管理员锁车");
|
sendCommand(asDevice.getMac(), Token.getToken(),IotConstants.COMMAND_CLOSE,"管理员锁车");
|
||||||
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
||||||
asDevice.setIsAdminUnlocking("0");
|
asDevice.setIsAdminUnlocking("0");
|
||||||
int device = asDeviceMapper.updateAsDevice(asDevice);
|
int device = asDeviceMapper.updateAsDevice(asDevice);
|
||||||
|
@ -750,7 +750,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
Boolean execute = transactionTemplate.execute(e -> {
|
Boolean execute = transactionTemplate.execute(e -> {
|
||||||
/** TODO 临时解锁*/
|
/** TODO 临时解锁*/
|
||||||
/** 2.发送命令*/
|
/** 2.发送命令*/
|
||||||
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5,"临时解锁");
|
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"临时解锁");
|
||||||
//间隔1秒
|
//间隔1秒
|
||||||
// try {
|
// try {
|
||||||
// Thread.sleep(500);
|
// Thread.sleep(500);
|
||||||
|
@ -960,7 +960,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
String token = Token.getToken();
|
String token = Token.getToken();
|
||||||
AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn());
|
AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn());
|
||||||
/** 2. 车辆远程关锁*/
|
/** 2. 车辆远程关锁*/
|
||||||
sendCommand(device.getMac(), token,IotConstants.COMMAND_CLOSE+IotConstants.COMMAND_FREQUENCY_3600,"还车关锁");
|
sendCommand(device.getMac(), token,IotConstants.COMMAND_CLOSE,"还车关锁");
|
||||||
/** 4. 更新车辆状态*/
|
/** 4. 更新车辆状态*/
|
||||||
device.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
|
device.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
|
||||||
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
||||||
|
@ -1260,8 +1260,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
List<EtParkingArea> parkingAreas = parkingAreaService.selectEtParkingAreaList(parkingArea);
|
List<EtParkingArea> parkingAreas = parkingAreaService.selectEtParkingAreaList(parkingArea);
|
||||||
if(ObjectUtil.isNull(parkingAreas) || parkingAreas.size() == 0){
|
if(ObjectUtil.isNull(parkingAreas) || parkingAreas.size() == 0){
|
||||||
log.info("运营区【{}】没有禁停区,",areaId);
|
log.info("运营区【{}】没有禁停区,",areaId);
|
||||||
return false;
|
throw new ServiceException("运营区【{}】没有禁停区"+areaId.toString());
|
||||||
// throw new ServiceException("运营区【{}】没有禁停区"+areaId.toString());
|
|
||||||
}
|
}
|
||||||
for (EtParkingArea etParkingArea : parkingAreas) {
|
for (EtParkingArea etParkingArea : parkingAreas) {
|
||||||
if(etParkingArea.getType().equals(ServiceConstants.PARKING_AREA_TYPE_NO_PARKFING)){
|
if(etParkingArea.getType().equals(ServiceConstants.PARKING_AREA_TYPE_NO_PARKFING)){
|
||||||
|
|
|
@ -12,7 +12,6 @@ import com.ruoyi.common.annotation.DataScope;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.entity.AsUser;
|
import com.ruoyi.common.core.domain.entity.AsUser;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictType;
|
import com.ruoyi.common.core.domain.entity.SysDictType;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.map.GeoUtils;
|
import com.ruoyi.common.utils.map.GeoUtils;
|
||||||
|
@ -244,16 +243,13 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl<EtOperatingAreaMappe
|
||||||
*
|
*
|
||||||
* @param longitude 经度
|
* @param longitude 经度
|
||||||
* @param latitude 纬度
|
* @param latitude 纬度
|
||||||
* @param deptId 运营商
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public EtOperatingArea getAreaInfoByLocation(String longitude, String latitude,String deptId) {
|
public EtOperatingArea getAreaInfoByLocation(String longitude, String latitude) {
|
||||||
double lon = Double.parseDouble(longitude);
|
double lon = Double.parseDouble(longitude);
|
||||||
double lat = Double.parseDouble(latitude);
|
double lat = Double.parseDouble(latitude);
|
||||||
EtOperatingArea area1 = new EtOperatingArea();
|
List<EtOperatingArea> etOperatingAreas = etOperatingAreaService.selectEtOperatingAreaList(new EtOperatingArea());
|
||||||
area1.setDeptId(Long.parseLong(deptId));
|
|
||||||
List<EtOperatingArea> etOperatingAreas = etOperatingAreaService.selectEtOperatingAreaList(area1);
|
|
||||||
EtOperatingArea area = null;
|
EtOperatingArea area = null;
|
||||||
for(EtOperatingArea etOperatingArea:etOperatingAreas){
|
for(EtOperatingArea etOperatingArea:etOperatingAreas){
|
||||||
String boundary = etOperatingArea.getBoundary();
|
String boundary = etOperatingArea.getBoundary();
|
||||||
|
@ -278,7 +274,6 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl<EtOperatingAreaMappe
|
||||||
GeometryFactory geometryFactory = new GeometryFactory();
|
GeometryFactory geometryFactory = new GeometryFactory();
|
||||||
Coordinate coordinate = new Coordinate(lon, lat);
|
Coordinate coordinate = new Coordinate(lon, lat);
|
||||||
Point point = geometryFactory.createPoint(coordinate);
|
Point point = geometryFactory.createPoint(coordinate);
|
||||||
if(ObjectUtil.isNotNull(etOperatingAreas) && etOperatingAreas.size()>0){
|
|
||||||
for(EtOperatingArea etOperatingArea:etOperatingAreas){
|
for(EtOperatingArea etOperatingArea:etOperatingAreas){
|
||||||
Geometry geometry = GeoUtils.fromWkt(etOperatingArea.getBoundary());
|
Geometry geometry = GeoUtils.fromWkt(etOperatingArea.getBoundary());
|
||||||
if (geometry.contains(point)) {
|
if (geometry.contains(point)) {
|
||||||
|
@ -295,9 +290,6 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl<EtOperatingAreaMappe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
throw new ServiceException("没有找到任何运营区");
|
|
||||||
}
|
|
||||||
return closestArea;
|
return closestArea;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -812,12 +812,4 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
}
|
}
|
||||||
return inOrder;
|
return inOrder;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 查询当前车辆是否有正在进行中的订单
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Boolean isInOrderBySn(String sn) {
|
|
||||||
List<EtOrder> inOrder = etOrderMapper.isInOrderBySn(sn);
|
|
||||||
return inOrder.size() > 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
left join sys_dept d on d.dept_id = ad.dept_id
|
left join sys_dept d on d.dept_id = ad.dept_id
|
||||||
where 1 = 1
|
where 1 = 1
|
||||||
<if test="areaName != null and areaName != ''"> and a.area_name like concat('%', #{areaName}, '%')</if>
|
<if test="areaName != null and areaName != ''"> and a.area_name like concat('%', #{areaName}, '%')</if>
|
||||||
<if test="deptId != null "> and d.dept_id = #{deptId}</if>
|
|
||||||
<!-- 数据范围过滤 -->
|
<!-- 数据范围过滤 -->
|
||||||
${params.dataScope}
|
${params.dataScope}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -146,11 +146,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="isInOrderBySn" resultMap="EtOrderResult" parameterType="String">
|
|
||||||
<include refid="selectEtOrderVo"/>
|
|
||||||
where sn = #{sn} and status =2 and type = 1
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="checkIsUnique" resultType="Integer" parameterType="Long">
|
<select id="checkIsUnique" resultType="Integer" parameterType="Long">
|
||||||
select count(1) from et_order
|
select count(1) from et_order
|
||||||
where user_id = #{userId} and status = 0 and type=1
|
where user_id = #{userId} and status = 0 and type=1
|
||||||
|
|
|
@ -104,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
<select id="selectEtOperatingAreaBySerialNumber" resultMap="SysDeptResult">
|
<select id="selectEtOperatingAreaBySerialNumber" resultMap="SysDeptResult">
|
||||||
<include refid="selectDeptVo"/>
|
<include refid="selectDeptVo"/>
|
||||||
where wechatpay_serial = #{wechatpaySerial}
|
where merchant_serial_number = #{merchantSerialNumber}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertDept" parameterType="SysDept" useGeneratedKeys="true" keyProperty="deptId">
|
<insert id="insertDept" parameterType="SysDept" useGeneratedKeys="true" keyProperty="deptId">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user