1.骑行线路更新

This commit is contained in:
邱贞招 2024-05-29 15:12:52 +08:00
parent daaba224af
commit e95769e375
5 changed files with 94 additions and 8 deletions

View File

@ -1,24 +1,25 @@
package com.ruoyi.web.controller.iot.receive;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.constant.IotConstants;
import com.ruoyi.common.constant.ServiceConstants;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.CommonUtil;
import com.ruoyi.common.utils.map.GeoUtils;
import com.ruoyi.common.utils.onenet.Token;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.domain.AsDevice;
import com.ruoyi.system.domain.EtAdminOrder;
import com.ruoyi.system.domain.EtModel;
import com.ruoyi.system.domain.EtOperatingArea;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.*;
import com.ruoyi.web.controller.iot.domain.BodyObj;
import com.ruoyi.web.controller.iot.domain.LogEntry;
import com.ruoyi.web.controller.iot.util.Util;
import lombok.SneakyThrows;
import org.locationtech.jts.geom.Geometry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -60,6 +61,9 @@ public class ReceiveController {
@Autowired
private ISysUserService sysUserService;
@Autowired
private IEtOrderService etOrderService;
/**
* 功能描述第三方平台数据接收<p>
@ -152,8 +156,36 @@ public class ReceiveController {
log.info("超出营运区发送断电命令:" +logEntry.getDevName());
}
}
/** todo 4.行程线路添加更新订单中的trip_route字段 */
/** TODO 4.行程线路添加更新订单中的trip_route字段 */
Integer status = value.getStatus();
if(status == 1){//上电运行
log.info("上电运行:" +logEntry.getDevName());
//获取当前正在骑行中的订单
EtOrder etOrder = etOrderService.getCurrentOrder(device.getSn());
JSONArray jsonArray;
if(StrUtil.isNotBlank(etOrder.getTripRouteStr())){
jsonArray = JSON.parseArray(etOrder.getTripRouteStr());
}else{
jsonArray = new JSONArray();
}
JSONArray newPoint = new JSONArray();
newPoint.add(value.getLon());
newPoint.add(value.getLat());
jsonArray.add(newPoint);
jsonArray.toJSONString();
log.info("更新行程jsonArray" +jsonArray.toJSONString());
etOrder.setTripRouteStr(jsonArray.toJSONString());
Geometry geometry = GeoUtils.toGeometry(jsonArray.toJSONString());
String wkt = GeoUtils.wkt(geometry);
etOrder.setTripRoute(wkt);
int updateEtOrder = etOrderService.updateEtOrder(etOrder);
if (updateEtOrder > 0) {
log.info("更新行程线路成功==========================>" +logEntry.getDevName());
}else{
log.info("更新行程线路失败==========================>" +logEntry.getDevName());
}
}
/** 5.低于电量(%)不得骑行,声音播报 */
if(electricQuantity <= model.getLowBatteryReminder()){
@ -195,8 +227,12 @@ public class ReceiveController {
throw new ServiceException("车辆状态更新失败");
}
}
/** todo 7.运营边界判断 几米判断? 5 */
// /** TODO 7.运营边界判断 几米判断? 3 播报运营边界 play2@ 是否靠近运营区边界*/
// boolean isCloseToTheBoundary = asDeviceService.isCloseToTheBoundary(device.getSn(), area);
// if(isCloseToTheBoundary){
// //发送超出营运区播报指令
// asDeviceService.sendCommand(device.getMac(), Token.getToken(),IotConstants.COMMAND_PLAY2,"靠近营运边界播报");
// }
}else{
log.info("更新定位失败:" +logEntry.getDevName());

View File

@ -214,4 +214,9 @@ public interface IAsDeviceService extends IService<AsDevice>
* 判断是否在运营时间内
*/
Boolean isOperatingTime(String sn);
// /**
// * 是否靠近运营区边界
// */
// boolean isCloseToTheBoundary(String sn, EtOperatingArea area);
}

View File

@ -160,7 +160,10 @@ public interface IEtOrderService
*/
List<RechargeVo> rechargeList(EtOrder etOrder);
/**
* 获取当前正在骑行中的订单
*/
EtOrder getCurrentOrder(String sn);
// public partnerBill();
}

View File

@ -1271,4 +1271,27 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
}
return Boolean.TRUE;
}
/**
* 判断是否靠近边界
*/
// @Override
// public boolean isCloseToTheBoundary(String sn, EtOperatingArea area) {
// Boolean isClose = false;
// AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn);
// String latitude = device.getLatitude();
// String longitude = device.getLongitude();
// Geometry geometry = GeoUtils.fromWkt(area.getBoundary());
//
// double distanceToBoundary = GeoUtils.distanceToBoundary(longitude, latitude, geometry);
// if(distanceToBoundary <= 3.0) {
// log.info("车辆【{}】靠近【{}】运营边界",sn,area.getAreaName());
// isClose = true;
// }else{
// log.info("车辆【{}】为靠近靠近【{}】运营边界",sn,area.getAreaName());
// }
// return isClose;
// }
}

View File

@ -260,6 +260,25 @@ public class EtOrderServiceImpl implements IEtOrderService
return rechargeVoList;
}
/**
* 获取当前正在骑行中的订单
* @param sn
* @return
*/
@Override
public EtOrder getCurrentOrder(String sn) {
if(ObjectUtil.isNotNull(asDeviceService.selectAsDeviceBySn(sn))){
EtOrder etOrder = new EtOrder();
etOrder.setSn(sn);
etOrder.setStatus(ServiceConstants.ORDER_STATUS_RIDING);
List<EtOrder> etOrders = etOrderMapper.selectEtOrderList(etOrder);
if(ObjectUtil.isNotEmpty(etOrders)){
return etOrders.get(0);
}
}
return null;
}
private boolean toBePaid(String[] statusList) {
boolean hasOne = false;
boolean hasThree = false;