1.联调
This commit is contained in:
		
							parent
							
								
									8149a84581
								
							
						
					
					
						commit
						daaba224af
					
				| 
						 | 
				
			
			@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
 | 
			
		|||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.io.UnsupportedEncodingException;
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 接收硬件参数
 | 
			
		||||
| 
						 | 
				
			
			@ -105,13 +106,17 @@ public class ReceiveController {
 | 
			
		|||
                     * */
 | 
			
		||||
                    /** 1.更新车辆定位、电压;计算续航里程 */
 | 
			
		||||
                    AsDevice device = asDeviceService.selectAsDeviceByMac(logEntry.getDevName());
 | 
			
		||||
                    if(ObjectUtil.isNull(device)){
 | 
			
		||||
                        throw new ServiceException("未找到车辆信息");
 | 
			
		||||
                    }
 | 
			
		||||
                    EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(device.getAreaId());
 | 
			
		||||
                    if(ObjectUtil.isNotNull(device)){
 | 
			
		||||
                        device.setLatitude(value.getLon());
 | 
			
		||||
                        device.setLongitude(value.getLat());
 | 
			
		||||
                        Integer bat = value.getBat();
 | 
			
		||||
                        double voltage = (double) bat / 10;//电压
 | 
			
		||||
                        device.setVoltage(String.valueOf(voltage));//电压
 | 
			
		||||
                        BigDecimal divide = new BigDecimal(bat).divide(new BigDecimal(10));
 | 
			
		||||
                        log.info("保存电压:" + divide);
 | 
			
		||||
                        device.setVoltage(divide.toString());//电压
 | 
			
		||||
                        // 根据电压计算续航里程
 | 
			
		||||
                        EtModel model = etModelService.selectEtModelByModelId(device.getModelId());
 | 
			
		||||
                        Integer remainingMileage = CommonUtil.getRemainingMileage(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance());
 | 
			
		||||
| 
						 | 
				
			
			@ -120,7 +125,7 @@ public class ReceiveController {
 | 
			
		|||
                        device.setRemainingPower(electricQuantity.toString());
 | 
			
		||||
                        int i = asDeviceService.updateAsDeviceBySn(device);
 | 
			
		||||
                        if(i>0){
 | 
			
		||||
                            log.info("更新定位成功:" +logEntry.getDevName());
 | 
			
		||||
                            log.info("更新定位成功==========================>" +logEntry.getDevName());
 | 
			
		||||
                            /** 2. 判断是否在禁行区内
 | 
			
		||||
                             *      如果在, 根据配置‘禁行区内断电配置’进行断电
 | 
			
		||||
                             **/
 | 
			
		||||
| 
						 | 
				
			
			@ -153,7 +158,7 @@ public class ReceiveController {
 | 
			
		|||
                            /** 5.低于电量(%)不得骑行,声音播报 */
 | 
			
		||||
                            if(electricQuantity <= model.getLowBatteryReminder()){
 | 
			
		||||
                                //发送低电量播报指令
 | 
			
		||||
                                asDeviceService.sendCommand(device.getMac(), Token.getToken(),IotConstants.COMMAND_PLAY6,"低电量播报");
 | 
			
		||||
//                                asDeviceService.sendCommand(device.getMac(), Token.getToken(),IotConstants.COMMAND_PLAY6,"低电量播报");
 | 
			
		||||
                                log.info("低电量播报:" +logEntry.getDevName());
 | 
			
		||||
                            }
 | 
			
		||||
                            /** 6.低电量 生成换电工单*/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,6 +9,7 @@ import com.ruoyi.common.utils.spring.SpringUtils;
 | 
			
		|||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.math.RoundingMode;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 业务工具类
 | 
			
		||||
| 
						 | 
				
			
			@ -110,11 +111,13 @@ public class CommonUtil {
 | 
			
		|||
     * @param fullEndurance 满电续航里程
 | 
			
		||||
     * @author qzz
 | 
			
		||||
     */
 | 
			
		||||
    public static Integer getRemainingMileage(String voltage,Integer fullVoltage,Integer lowVoltage,Integer fullEndurance) {
 | 
			
		||||
    public static Integer getRemainingMileage(String voltage,Double fullVoltage,Double lowVoltage,Integer fullEndurance) {
 | 
			
		||||
        // 满电电压减去亏电电压 乘以 满电续航里程 除以 满电电压
 | 
			
		||||
        int current = (fullVoltage - Integer.parseInt(voltage)) ;
 | 
			
		||||
        int full = (fullVoltage - lowVoltage) ;
 | 
			
		||||
        BigDecimal divide = new BigDecimal(current).divide(new BigDecimal(full));//当前电量百分百
 | 
			
		||||
        log.info(" 电压--voltage:{},满电电压--fullVoltage:{},亏电电压--lowVoltage:{},满电续航--fullEndurance:{}",voltage,fullVoltage,lowVoltage,fullEndurance);
 | 
			
		||||
        BigDecimal vol = new BigDecimal(voltage);
 | 
			
		||||
        BigDecimal current = new BigDecimal(fullVoltage).subtract(vol);
 | 
			
		||||
        BigDecimal full = new BigDecimal(fullVoltage).subtract(new BigDecimal(lowVoltage));
 | 
			
		||||
        BigDecimal divide = full.subtract(current).divide(full,2, RoundingMode.HALF_UP);//当前电量百分百
 | 
			
		||||
        log.info("当前电量百分百:{}%",divide.multiply(new BigDecimal(100)));
 | 
			
		||||
        BigDecimal multiply = divide.multiply(new BigDecimal(fullEndurance));
 | 
			
		||||
        log.info("当前剩余续航里程:{}km",multiply);
 | 
			
		||||
| 
						 | 
				
			
			@ -129,13 +132,14 @@ public class CommonUtil {
 | 
			
		|||
     * @param lowVoltage 亏电电压
 | 
			
		||||
     * @author qzz
 | 
			
		||||
     */
 | 
			
		||||
    public static Integer getElectricQuantity(String voltage,Integer fullVoltage,Integer lowVoltage) {
 | 
			
		||||
    public static Integer getElectricQuantity(String voltage,Double fullVoltage,Double lowVoltage) {
 | 
			
		||||
        // 满电电压减去亏电电压 乘以 满电续航里程 除以 满电电压
 | 
			
		||||
        int current = (fullVoltage - Integer.parseInt(voltage)) ;
 | 
			
		||||
        int full = (fullVoltage - lowVoltage) ;
 | 
			
		||||
        BigDecimal divide = new BigDecimal(current).divide(new BigDecimal(full));//当前电量百分百
 | 
			
		||||
        BigDecimal vol = new BigDecimal(voltage);
 | 
			
		||||
        BigDecimal current = new BigDecimal(fullVoltage).subtract(vol);
 | 
			
		||||
        BigDecimal full = new BigDecimal(fullVoltage).subtract(new BigDecimal(lowVoltage));
 | 
			
		||||
        BigDecimal divide = full.subtract(current).divide(full,2, RoundingMode.HALF_UP);//当前电量百分百
 | 
			
		||||
        BigDecimal multiply = divide.multiply(new BigDecimal(100));
 | 
			
		||||
        log.info("当前电量百分百:{}%",multiply);
 | 
			
		||||
//        log.info("当前电量百分百:{}%",multiply);
 | 
			
		||||
        return multiply.intValue();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,11 +34,11 @@ public class EtModel extends BaseEntity
 | 
			
		|||
 | 
			
		||||
    /** 满电电压 */
 | 
			
		||||
    @Excel(name = "满电电压")
 | 
			
		||||
    private Integer fullVoltage;
 | 
			
		||||
    private Double fullVoltage;
 | 
			
		||||
 | 
			
		||||
    /** 亏电电压 */
 | 
			
		||||
    @Excel(name = "亏电电压")
 | 
			
		||||
    private Integer lowVoltage;
 | 
			
		||||
    private Double lowVoltage;
 | 
			
		||||
 | 
			
		||||
    /** 满电续航 */
 | 
			
		||||
    @Excel(name = "满电续航")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -406,12 +406,12 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
			
		|||
            /** 2.发送命令*/
 | 
			
		||||
            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"编号开锁");
 | 
			
		||||
            //间隔1秒
 | 
			
		||||
            try {
 | 
			
		||||
                Thread.sleep(500);
 | 
			
		||||
            } catch (InterruptedException ex) {
 | 
			
		||||
                ex.printStackTrace();
 | 
			
		||||
            }
 | 
			
		||||
            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY0,"编号开锁播报");
 | 
			
		||||
//            try {
 | 
			
		||||
//                Thread.sleep(1000);
 | 
			
		||||
//            } catch (InterruptedException ex) {
 | 
			
		||||
//                ex.printStackTrace();
 | 
			
		||||
//            }
 | 
			
		||||
//            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY0,"编号开锁播报");
 | 
			
		||||
            /** 3.更新车辆状态*/
 | 
			
		||||
            asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
 | 
			
		||||
            asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);
 | 
			
		||||
| 
						 | 
				
			
			@ -475,12 +475,12 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
			
		|||
            /** 2.发送命令*/
 | 
			
		||||
            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"管理员开锁");
 | 
			
		||||
            //间隔1秒
 | 
			
		||||
            try {
 | 
			
		||||
                Thread.sleep(500);
 | 
			
		||||
            } catch (InterruptedException ex) {
 | 
			
		||||
                ex.printStackTrace();
 | 
			
		||||
            }
 | 
			
		||||
            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY0,"管理员开锁播报");
 | 
			
		||||
//            try {
 | 
			
		||||
//                Thread.sleep(500);
 | 
			
		||||
//            } catch (InterruptedException ex) {
 | 
			
		||||
//                ex.printStackTrace();
 | 
			
		||||
//            }
 | 
			
		||||
//            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY0,"管理员开锁播报");
 | 
			
		||||
            return Boolean.TRUE;
 | 
			
		||||
        });
 | 
			
		||||
        if(!execute)throw new ServiceException("管理员开锁失败");
 | 
			
		||||
| 
						 | 
				
			
			@ -657,12 +657,12 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
			
		|||
            /** 2.发送命令*/
 | 
			
		||||
            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_LLOSE,"临时锁车");
 | 
			
		||||
            //间隔1秒
 | 
			
		||||
            try {
 | 
			
		||||
                Thread.sleep(500);
 | 
			
		||||
            } catch (InterruptedException ex) {
 | 
			
		||||
                ex.printStackTrace();
 | 
			
		||||
            }
 | 
			
		||||
            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY7,"临时锁车播报");
 | 
			
		||||
//            try {
 | 
			
		||||
//                Thread.sleep(500);
 | 
			
		||||
//            } catch (InterruptedException ex) {
 | 
			
		||||
//                ex.printStackTrace();
 | 
			
		||||
//            }
 | 
			
		||||
//            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY7,"临时锁车播报");
 | 
			
		||||
            if(StrUtil.isNotBlank(orderNo)){//有订单号,则是用户临时锁车
 | 
			
		||||
                /**  改变车辆状态:4-临时锁车 */
 | 
			
		||||
                asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_TEMPORARILY_LOCK);//临时锁车
 | 
			
		||||
| 
						 | 
				
			
			@ -713,12 +713,12 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
			
		|||
            /** 2.发送命令*/
 | 
			
		||||
            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN,"临时解锁");
 | 
			
		||||
            //间隔1秒
 | 
			
		||||
            try {
 | 
			
		||||
                Thread.sleep(500);
 | 
			
		||||
            } catch (InterruptedException ex) {
 | 
			
		||||
                ex.printStackTrace();
 | 
			
		||||
            }
 | 
			
		||||
            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY0,"临时解锁播报");
 | 
			
		||||
//            try {
 | 
			
		||||
//                Thread.sleep(500);
 | 
			
		||||
//            } catch (InterruptedException ex) {
 | 
			
		||||
//                ex.printStackTrace();
 | 
			
		||||
//            }
 | 
			
		||||
//            sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY0,"临时解锁播报");
 | 
			
		||||
            if(StrUtil.isNotBlank(orderNo)){//有订单号,则是用户骑行中解锁
 | 
			
		||||
                /**  改变车辆状态:3-骑行中 */
 | 
			
		||||
                asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_IN_USING);//骑行中
 | 
			
		||||
| 
						 | 
				
			
			@ -789,13 +789,13 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
			
		|||
        //1.发送开锁命令并更新车辆状态
 | 
			
		||||
        String token = Token.getToken();
 | 
			
		||||
        sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_CLOSE,"取消预约关锁");
 | 
			
		||||
        //间隔1秒
 | 
			
		||||
        try {
 | 
			
		||||
            Thread.sleep(500);
 | 
			
		||||
        } catch (InterruptedException ex) {
 | 
			
		||||
            ex.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
        sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY8,"取消预约关锁播报");
 | 
			
		||||
//        //间隔1秒
 | 
			
		||||
//        try {
 | 
			
		||||
//            Thread.sleep(500);
 | 
			
		||||
//        } catch (InterruptedException ex) {
 | 
			
		||||
//            ex.printStackTrace();
 | 
			
		||||
//        }
 | 
			
		||||
//        sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY8,"取消预约关锁播报");
 | 
			
		||||
        /** 5.记录行程*/
 | 
			
		||||
        int tripLog = tripLogService.tripLog(order.getOrderNo(),order.getSn(),ServiceConstants.TRIP_LOG_TYPE_UNLOCK_RIDE);
 | 
			
		||||
        if(tripLog==0){
 | 
			
		||||
| 
						 | 
				
			
			@ -883,12 +883,12 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
 | 
			
		|||
            /** 2. 车辆远程关锁*/
 | 
			
		||||
            sendCommand(device.getMac(), token,IotConstants.COMMAND_CLOSE,"还车关锁");
 | 
			
		||||
            //间隔1秒
 | 
			
		||||
            try {
 | 
			
		||||
                Thread.sleep(500);
 | 
			
		||||
            } catch (InterruptedException ex) {
 | 
			
		||||
                ex.printStackTrace();
 | 
			
		||||
            }
 | 
			
		||||
            sendCommand(device.getMac(), token,IotConstants.COMMAND_PLAY8,"还车关锁播报");
 | 
			
		||||
//            try {
 | 
			
		||||
//                Thread.sleep(500);
 | 
			
		||||
//            } catch (InterruptedException ex) {
 | 
			
		||||
//                ex.printStackTrace();
 | 
			
		||||
//            }
 | 
			
		||||
//            sendCommand(device.getMac(), token,IotConstants.COMMAND_PLAY8,"还车关锁播报");
 | 
			
		||||
            /** 4. 更新车辆状态*/
 | 
			
		||||
            device.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
 | 
			
		||||
            device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -112,6 +112,9 @@ public class WxPayService implements IWxPayService {
 | 
			
		|||
            request.setDescription(description);
 | 
			
		||||
            request.setNotifyUrl(wxPayConfig.getNotifyUrl());
 | 
			
		||||
            request.setPayer(getPayer(user.getWxopenid()));
 | 
			
		||||
            SettleInfo settleInfo = new SettleInfo();
 | 
			
		||||
            settleInfo.setProfitSharing(Boolean.TRUE);
 | 
			
		||||
            request.setSettleInfo(settleInfo);
 | 
			
		||||
            PrepayWithRequestPaymentResponse res = jsapiServiceExtension.prepayWithRequestPayment(request);
 | 
			
		||||
            return res;
 | 
			
		||||
        } finally {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -120,6 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="lockStatus != null">lock_status,</if>
 | 
			
		||||
            <if test="location != null">location,</if>
 | 
			
		||||
            <if test="remainingPower != null">remaining_power,</if>
 | 
			
		||||
            <if test="voltage != null">voltage,</if>
 | 
			
		||||
            <if test="qrcode != null">qrcode,</if>
 | 
			
		||||
            <if test="longitude != null">longitude,</if>
 | 
			
		||||
            <if test="latitude != null">latitude,</if>
 | 
			
		||||
| 
						 | 
				
			
			@ -144,6 +145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="lockStatus != null">#{lockStatus},</if>
 | 
			
		||||
            <if test="location != null">#{location},</if>
 | 
			
		||||
            <if test="remainingPower != null">#{remainingPower},</if>
 | 
			
		||||
            <if test="voltage != null">#{voltage},</if>
 | 
			
		||||
            <if test="qrcode != null">#{qrcode},</if>
 | 
			
		||||
            <if test="longitude != null">#{longitude},</if>
 | 
			
		||||
            <if test="latitude != null">#{latitude},</if>
 | 
			
		||||
| 
						 | 
				
			
			@ -172,6 +174,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="lockStatus != null">lock_status = #{lockStatus},</if>
 | 
			
		||||
            <if test="location != null">location = #{location},</if>
 | 
			
		||||
            <if test="remainingPower != null">remaining_power = #{remainingPower},</if>
 | 
			
		||||
            <if test="voltage != null">voltage = #{voltage},</if>
 | 
			
		||||
            <if test="qrcode != null">qrcode = #{qrcode},</if>
 | 
			
		||||
            <if test="longitude != null">longitude = #{longitude},</if>
 | 
			
		||||
            <if test="latitude != null">latitude = #{latitude},</if>
 | 
			
		||||
| 
						 | 
				
			
			@ -201,6 +204,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
			
		|||
            <if test="lockStatus != null">lock_status = #{lockStatus},</if>
 | 
			
		||||
            <if test="location != null">location = #{location},</if>
 | 
			
		||||
            <if test="remainingPower != null">remaining_power = #{remainingPower},</if>
 | 
			
		||||
            <if test="voltage != null">voltage = #{voltage},</if>
 | 
			
		||||
            <if test="qrcode != null">qrcode = #{qrcode},</if>
 | 
			
		||||
            <if test="longitude != null">longitude = #{longitude},</if>
 | 
			
		||||
            <if test="latitude != null">latitude = #{latitude},</if>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user