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 d32a004..21de10e 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 @@ -458,7 +458,7 @@ public class AppVerifyController extends BaseController public AjaxResult lock(String sn) { logger.info("【管理员关锁请求】:{}",sn); - Boolean aBoolean =asDeviceService.lock(sn,null); + Boolean aBoolean =asDeviceService.adminLock(sn); return success(aBoolean); } @@ -643,16 +643,19 @@ public class AppVerifyController extends BaseController IDResponse.Result result = (IDResponse.Result)authentication; if(result.getIsok()){ //保存身份信息 - AsUser asUser = new AsUser(); + // 更新用户并更新缓存 + LoginUser loginUser = SecurityUtils.getLoginUser(); + AsUser asUser = loginUser.getAsUser(); asUser.setUserId(authenticationVo.getUserId()); asUser.setRealName(authenticationVo.getRealName()); asUser.setIdCard(authenticationVo.getIdCard()); asUser.setIsAuthentication(ServiceConstants.IS_AUTHENTICATION_YES); int updateUser = asUserService.updateUser(asUser); - if(updateUser==0){ - throw new ServiceException("【实名认证】保存身份信息失败"); - }else{ - logger.info("【实名认证】保存身份信息成功"); + if (updateUser>0) + { + logger.info("【提现金额】保存身份信息成功"); + // 更新缓存用户信息 + tokenService.setLoginUser(loginUser); } } return AjaxResult.success(authentication); diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/AsUserController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/AsUserController.java index 802e3c8..ae44cc6 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/AsUserController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/AsUserController.java @@ -139,6 +139,9 @@ public class AsUserController extends BaseController public AjaxResult bandSystemUser(@RequestBody AsUser user) { Long sysUserId = user.getSysUserId(); + if(sysUserId == null || sysUserId == 0){ + user.setRole("1"); + } SysUser sysUser = sysUserService.selectUserById(sysUserId); if(sysUser.getUserName().equals(SpringUtils.getRequiredProperty("et.repairAdmin"))){ user.setRole("2"); diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/EtFault.java b/electripper-system/src/main/java/com/ruoyi/system/domain/EtFault.java index 6955541..114c803 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/EtFault.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/EtFault.java @@ -68,4 +68,7 @@ public class EtFault extends BaseEntity @Excel(name = "设备sn") private String sn; + @Excel(name = "地址") + private String address; + } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java index 9bcb4d4..f55bdb3 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java @@ -137,6 +137,11 @@ public interface IAsDeviceService extends IService */ Boolean lock(String mac,String orderNo); + /** + * 管理员锁车 + */ + Boolean adminLock(String mac); + /** * 临时解锁 */ 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 6f00264..7d77656 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 @@ -500,13 +500,6 @@ public class AsDeviceServiceImpl extends ServiceImpl i Boolean execute = transactionTemplate.execute(e -> { /** 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,"管理员开锁播报"); return Boolean.TRUE; }); if(!execute)throw new ServiceException("管理员开锁失败"); @@ -671,51 +664,52 @@ public class AsDeviceServiceImpl extends ServiceImpl i @Override public Boolean lock(String sn,String orderNo) { EtOrder order = etOrderService.selectEtOrderByOrderNo(orderNo); - if(order==null)throw new ServiceException("订单不存在"); if(StrUtil.isBlank(sn)) { sn = order.getSn(); } AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn); /** 1.获取token*/ String token = Token.getToken(); - String finalSn = sn; - Boolean execute = transactionTemplate.execute(e -> { - /** 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,"临时锁车播报"); - if(StrUtil.isNotBlank(orderNo)){//有订单号,则是用户临时锁车 - /** 改变车辆状态:4-临时锁车 */ - asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_TEMPORARILY_LOCK);//临时锁车 - asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); - int device = asDeviceMapper.updateAsDevice(asDevice); - if(device==0){ - log.info("【临时解锁】改变车辆状态失败"); - throw new ServiceException("【临时锁车】改变车辆状态失败"); - } - /** 5.记录行程*/ - int tripLog = tripLogService.tripLog(orderNo, finalSn,ServiceConstants.TRIP_LOG_TYPE_TEMPORARILY_LOCK); - if(tripLog==0){ - log.info("【临时锁车】记录行程失败"); - throw new ServiceException("【临时锁车】记录行程失败"); - } - }else{ - /** 改变车辆锁状态:1-开 TODO 是否要改变车辆状态?*/ - asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); - int device = asDeviceMapper.updateAsDevice(asDevice); - if(device==0){ - log.info("【临时解锁】改变车辆状态失败"); - throw new ServiceException("【临时解锁】改变车辆状态失败"); - } + /** 2.发送命令*/ + sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_LLOSE,"临时锁车"); + asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); + if(StrUtil.isNotBlank(orderNo)){//有订单号,则是用户临时锁车 + /** 改变车辆状态:4-临时锁车 */ + asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_TEMPORARILY_LOCK);//临时锁车 + /** 5.记录行程*/ + int tripLog = tripLogService.tripLog(orderNo, sn,ServiceConstants.TRIP_LOG_TYPE_TEMPORARILY_LOCK); + if(tripLog==0){ + log.info("【临时锁车】记录行程失败"); + throw new ServiceException("【临时锁车】记录行程失败"); } - return Boolean.TRUE; - }); - if(!execute)throw new ServiceException("临时锁车失败"); + } + int device = asDeviceMapper.updateAsDevice(asDevice); + if(device==0){ + log.info("【临时解锁】改变车辆状态失败"); + throw new ServiceException("【临时锁车】改变车辆状态失败"); + } + return Boolean.TRUE; + } + + /** + * 管理员锁车 + * @param sn + * @return + */ + @Transactional + @SneakyThrows + @Override + public Boolean adminLock(String sn) { + if(StrUtil.isBlank(sn))throw new ServiceException("sn不能为空"); + AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn); + /** 2.发送命令*/ + sendCommand(asDevice.getMac(), Token.getToken(),IotConstants.COMMAND_CLOSE,"管理员锁车"); + asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); + int device = asDeviceMapper.updateAsDevice(asDevice); + if(device==0){ + log.info("【临时解锁】改变车辆状态失败"); + throw new ServiceException("【临时锁车】改变车辆状态失败"); + } return Boolean.TRUE; } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java index e386016..31c196e 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/CallbackServiceImpl.java @@ -166,6 +166,7 @@ public class CallbackServiceImpl implements CallbackService { //创建一个定时器,计算出退还时间后,执行退款操作 // 往后推autoRefundDeposit小时执行 scheduledExecutorService.schedule(() -> { + logger.info("【微信支付回调】退还押金定时任务开始"); // 退款 Long userId = order.getUserId(); EtOrder etOrder = new EtOrder(); diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtFaultServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtFaultServiceImpl.java index 385c12f..4d5fc36 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtFaultServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtFaultServiceImpl.java @@ -7,6 +7,7 @@ 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.exception.ServiceException; +import com.ruoyi.common.utils.CommonUtil; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.system.domain.*; @@ -129,9 +130,9 @@ public class EtFaultServiceImpl implements IEtFaultService if(ObjectUtils.isEmpty(asDevice)){ throw new ServiceException("该设备不存在"); } - //获取车辆定位,并解析地址,将地址保存数据库 - - + //解析地址,将地址保存数据库 + etFault.setAddress(CommonUtil.getAddressByGeo(asDevice.getLongitude() + ","+asDevice.getLatitude())); + etFault.setAreaId(asDevice.getAreaId()); etFault.setCreateTime(DateUtils.getNowDate()); setType(etFault); int i = etFaultMapper.insertEtFault(etFault); diff --git a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java index 2f9525f..0c877e3 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java +++ b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java @@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDate; @@ -48,6 +49,14 @@ public class EtTask { private IEtDividendDetailService dividendDetailService; + /** + * 启动时判断是否有未取消预约的订单、已完成的订单未退还押金的 + */ + @PostConstruct + public void init() { + + log.info("websocket====>init方法被执行"); + } /** * 每天凌晨0点5分执行,计算分账结果 * cron: 0 5 0 * * ? diff --git a/electripper-system/src/main/resources/mapper/system/EtFaultMapper.xml b/electripper-system/src/main/resources/mapper/system/EtFaultMapper.xml index 28eb422..6445ee0 100644 --- a/electripper-system/src/main/resources/mapper/system/EtFaultMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtFaultMapper.xml @@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -15,14 +16,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - select fault_id, area_id, user_id, device_mac, type, create_time, picture, detail, order_id, status from et_fault + select fault_id, area_id, user_id, device_mac, sn, type, create_time, picture, detail, order_id, status, address from et_fault