diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java index 072132b..2e0926b 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java @@ -9,6 +9,7 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.AsUser; import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; @@ -79,6 +80,9 @@ public class AppVerifyController extends BaseController @Resource private AsDeviceMapper asDeviceMapper; + @Resource + private ISysUserService sysUserService; + /** * 故障上报 @@ -242,6 +246,21 @@ public class AppVerifyController extends BaseController if(!ServiceConstants.ORDER_PAY_STATUS_NON_PAYMENT.equals(etOrder1.getPaid())){ throw new ServiceException("订单已支付,不能改价"); } + BigDecimal payFee = BigDecimal.ZERO; + if(ObjectUtil.isNotNull(etOrder.getDispatchFee())){ + payFee = payFee.add(etOrder.getDispatchFee()); + } + if(ObjectUtil.isNotNull(etOrder.getRidingFee())){ + payFee = payFee.add(etOrder.getRidingFee()); + } + if(ObjectUtil.isNotNull(etOrder.getManageFee())){ + payFee = payFee.add(etOrder.getManageFee()); + } + if(ObjectUtil.isNotNull(etOrder.getAppointmentFee())){ + payFee = payFee.add(etOrder.getAppointmentFee()); + } + etOrder.setPayFee(payFee); + etOrder.setTotalFee(payFee); return toAjax(etOrderService.updateEtOrderByOrderNo(etOrder)); } @@ -741,4 +760,25 @@ public class AppVerifyController extends BaseController return toAjax(asDeviceService.bandSn(asDevice)); } + /** + * 根据userId获取areaId(管理员属于哪个运营区) + */ + @PostMapping("/getAreaId") + public AjaxResult getAreaId(String userId) + { + logger.info("根据userId获取areaId:【userId="+userId+"】"); + if(StrUtil.isBlank(userId)){ + throw new ServiceException("userId不能为空"); + } + AsUser asUser = asUserService.selectUserById(Long.valueOf(userId)); + if(ObjectUtil.isNull(asUser)){ + throw new ServiceException("用户【"+userId+"】不存在"); + } + SysUser sysUser = sysUserService.selectUserById(asUser.getSysUserId()); + if(ObjectUtil.isNull(sysUser)){ + throw new ServiceException("用户【"+userId+"】未绑定系统用户"); + } + return success(sysUser.getAreaId()); + } + } diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java index 3d0d7f4..6d6ce93 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java @@ -154,10 +154,29 @@ public class ReceiveController { if(ObjectUtil.isNotNull(device)){ BigDecimal lon = new BigDecimal(value.getLon()); BigDecimal lat = new BigDecimal(value.getLat()); - log.info("WGS84经纬度:" + lon + "---" + lat); - double[] doubles = GpsCoordinateUtils.calWGS84toGCJ02(lat.doubleValue(), lon.doubleValue()); - lat = new BigDecimal(doubles[0]).setScale(4, RoundingMode.HALF_UP); - lon = new BigDecimal(doubles[1]).setScale(4, RoundingMode.HALF_UP); + log.info("WGS84经纬度(未计算):" + lon + "---" + lat); + // 除以100 + lon = lon.divide(new BigDecimal(100), 10, RoundingMode.HALF_UP); + lat = lat.divide(new BigDecimal(100), 10, RoundingMode.HALF_UP); + log.info("WGS84经纬度(除以100后):" + lon + "---" + lat); + // 取出lon中后面的小数点 + String[] lonStr = getDecimalPart(lon); + String[] latStr = getDecimalPart(lat); + log.info("WGS84经纬度(截取小数点):" + lonStr[0] + "---" + lonStr[1] + "---"+ latStr[0]+"---"+ latStr[1]); + // 再将结果乘以5/3 + String lon2 = "0."+ lonStr[1]; + String lat2 = "0."+ latStr[1]; + BigDecimal lons = new BigDecimal(lon2).multiply(new BigDecimal(5).divide(new BigDecimal(3), 8, RoundingMode.HALF_UP)); + BigDecimal lats = new BigDecimal(lat2).multiply(new BigDecimal(5).divide(new BigDecimal(3), 8, RoundingMode.HALF_UP)); + BigDecimal lo = new BigDecimal(lonStr[0]).add(lons); + BigDecimal la = new BigDecimal(latStr[0]).add(lats); + log.info("WGS84经纬度(计算后):" + lo + "---" + la); + lo = lo.setScale(8, RoundingMode.HALF_UP); + la = la.setScale(8, RoundingMode.HALF_UP); + log.info("WGS84经纬度(保留8为小数):" + lo + "---" + la); + double[] doubles = GpsCoordinateUtils.calWGS84toGCJ02(la.doubleValue(), lo.doubleValue()); + lat = new BigDecimal(doubles[0]).setScale(8, RoundingMode.HALF_UP); + lon = new BigDecimal(doubles[1]).setScale(8, RoundingMode.HALF_UP); log.info("转换后的GCJ02经纬度:" + lon + "---" + lat); if(BigDecimal.ZERO.compareTo(lon) != 0 && BigDecimal.ZERO.compareTo(lat) != 0){ device.setLatitude(lat.toString()); @@ -390,4 +409,27 @@ public class ReceiveController { } } + + private static String[] getDecimalPart(BigDecimal number) { + // 将BigDecimal转换为字符串 + String numberStr = number.toPlainString(); + + // 找到小数点的位置 + int indexOfDecimal = numberStr.indexOf("."); + + // 初始化结果数组 + String[] parts = new String[2]; + + // 如果有小数点 + if (indexOfDecimal >= 0) { + parts[0] = numberStr.substring(0, indexOfDecimal); // 整数部分 + parts[1] = numberStr.substring(indexOfDecimal + 1); // 小数部分 + } else { + // 如果没有小数点,整数部分为整个字符串,小数部分为空 + parts[0] = numberStr; + parts[1] = ""; + } + + return parts; + } } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java index d8317a8..7aef1ca 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java @@ -1079,7 +1079,11 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i String token = Token.getToken(); AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn()); /** 2. 车辆远程关锁*/ - sendCommand(device.getMac(), token,IotConstants.COMMAND_CLOSE+IotConstants.COMMAND_FREQUENCY_3600,"还车关锁"); + ResponseVo responseVo = sendCommandWithResp(device.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "还车关锁"); + if(responseVo.getCode()!=0){ + log.info("【还车关锁】远程关锁失败"); + throw new ServiceException("远程关锁失败"); + } /** 4. 更新车辆状态*/ device.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL); device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); @@ -1242,7 +1246,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i //minutes除以startingMinutes得到的结构四舍五入 minutes = minutes - timeoutTime;//扣掉起步分钟数后 double ceil = Math.ceil(minutes / timeoutTime) +1 ; - ridingFee = new BigDecimal(ceil * Integer.parseInt(timeoutPrice)); + ridingFee = new BigDecimal(ceil * Double.parseDouble(timeoutPrice)); BigDecimal startingPriceB = new BigDecimal(startingPrice); ridingFee = ridingFee.add(startingPriceB); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java index 3fd2b23..28f4d22 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java @@ -6,8 +6,6 @@ import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.ServiceConstants; import com.ruoyi.common.core.domain.entity.AsUser; -import com.ruoyi.common.core.domain.entity.SysUser; -import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.CommonUtil; import com.ruoyi.common.utils.DateUtils; @@ -903,7 +901,7 @@ public class EtOrderServiceImpl implements IEtOrderService //todo 更新订单的payFee = totalFee - refundAmount /** 2.记录退款表 创建退款对象*/ - EtRefund refund1= createRefund(etOrder, refundAmount, appointmentFee, dispatchFee, manageFee, ridingFee, refund,ServiceConstants.REFUND_TYPE_SYSTEM); + EtRefund refund1= createRefund(etOrder1, refundAmount, appointmentFee, dispatchFee, manageFee, ridingFee, refund,ServiceConstants.REFUND_TYPE_SYSTEM); int i = etRefundService.insertEtRefund(refund1); if(i>0){ log.info("保存退款对象成功"); diff --git a/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml b/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml index 072a0a9..5acce2e 100644 --- a/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml @@ -45,6 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="payType != null and payType != ''"> and cf.pay_type = #{payType}</if> <!-- 数据范围过滤 --> ${params.dataScope} + order by cf.create_time desc </select> <select id="selectEtCapitalFlowByFlowId" parameterType="Long" resultMap="EtCapitalFlowResult"> diff --git a/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml b/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml index 45a0834..f384566 100644 --- a/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml @@ -536,7 +536,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <if test="createTime != null">create_time = #{createTime},</if> <if test="appointmentStartTime != null">appointment_start_time = #{appointmentStartTime},</if> <if test="appointmentEndTime != null">appointment_end_time = #{appointmentEndTime},</if> - <if test="appointment_timeout != null">appointment_timeout = #{appointment_timeout},</if> + <if test="appointmentTimeout != null">appointment_timeout = #{appointmentTimeout},</if> <if test="unlockTime != null">unlock_time = #{unlockTime},</if> <if test="returnTime != null">return_time = #{returnTime},</if> <if test="returnType != null">return_type = #{returnType},</if>