From 69e1aade3922d4bca8c2f022ffddd7a552c8d0de Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Fri, 2 Aug 2024 11:12:53 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=BB=91=E5=AE=9AAPP=E7=94=A8=E6=88=B7?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E7=BB=91=202.=E5=81=9C=E8=BD=A6=E5=8C=BA?= =?UTF-8?q?=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/app/AppController.java | 23 ++++++ .../controller/app/AppVerifyController.java | 7 +- .../controller/system/AsUserController.java | 12 ++- .../src/main/resources/application.yml | 2 +- .../ruoyi/common/constant/IotConstants.java | 1 + .../common/core/domain/entity/SysUser.java | 11 +++ .../com/ruoyi/common/enums/BusinessType.java | 10 +++ .../ruoyi/system/domain/EtOperatingArea.java | 12 +++ .../com/ruoyi/system/domain/EtWithdraw.java | 4 + .../com/ruoyi/system/mapper/AsUserMapper.java | 5 ++ .../system/mapper/EtParkingAreaMapper.java | 9 +++ .../ruoyi/system/service/IAsUserService.java | 5 ++ .../system/service/IEtParkingAreaService.java | 7 ++ .../service/impl/AsDeviceServiceImpl.java | 75 ++++++++++--------- .../service/impl/AsUserServiceImpl.java | 22 +++++- .../impl/EtOperatingAreaServiceImpl.java | 8 ++ .../impl/EtParkingAreaServiceImpl.java | 10 +++ .../service/impl/SysUserServiceImpl.java | 8 +- .../resources/mapper/system/AsUserMapper.xml | 4 + .../mapper/system/EtParkingAreaMapper.xml | 4 + 20 files changed, 190 insertions(+), 49 deletions(-) diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java index 883a76a..76cf831 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java @@ -19,6 +19,7 @@ import com.ruoyi.common.utils.CommonUtil; import com.ruoyi.common.utils.SendAliSmsUtil; import com.ruoyi.common.utils.SendSmsVo; import com.ruoyi.common.utils.map.GeoUtils; +import com.ruoyi.common.utils.onenet.Token; import com.ruoyi.framework.web.service.SysLoginService; import com.ruoyi.system.domain.*; import com.ruoyi.system.mapper.AsDeviceMapper; @@ -31,6 +32,9 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.io.UnsupportedEncodingException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; import java.util.List; /** @@ -564,4 +568,23 @@ public class AppController extends BaseController return success(list); } + /** + * 获取token + */ + @GetMapping("/getToken") + public AjaxResult getToken() + { + String token = null; + try { + token = Token.getToken(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (InvalidKeyException e) { + e.printStackTrace(); + } + return success(token); + } + } 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 5d4f1c1..65eb1fc 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 @@ -1023,12 +1023,7 @@ public class AppVerifyController extends BaseController public AjaxResult add(@RequestBody EtWithdraw etWithdraw) { logger.info("管理员提现请求:【{}】", JSON.toJSON(etWithdraw)); - AsUser asUser = getLoginUser().getAsUser(); - logger.info("【管理员提现】获取当前用户:【{}】", JSON.toJSON(asUser)); - SysUser sysUser = sysUserService.selectUserById(asUserMapper.selectUserById(asUser.getUserId()).getSysUserId()); - logger.info("【管理员提现】获取当前系统用户:【{}】", JSON.toJSON(sysUser)); - Long deptId = sysUser.getDeptId(); - SysDept sysDept = deptService.selectDeptById(deptId); + SysDept sysDept = wxPayService.getDeptObjByAreaId(etWithdraw.getAreaId()); int i = deptService.adminWithdraw(etWithdraw.getAmount(),sysDept,"1"); return toAjax(i); } 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 a6ff445..69d8d70 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 @@ -145,13 +145,23 @@ public class AsUserController extends BaseController /** * 绑定系统用户 */ - @Log(title = "绑定系统用户", businessType = BusinessType.UPDATE) + @Log(title = "绑定系统用户", businessType = BusinessType.BANDSYSUSER) @PutMapping("/bandSystemUser") public AjaxResult bandSystemUser(@RequestBody AsUser user) { return toAjax(asUserService.bandSystemUser(user)); } + /** + * 解绑系统用户 + */ + @Log(title = "解绑系统用户", businessType = BusinessType.UNBANDSYSUSER) + @PutMapping("/unbindSystemUser") + public AjaxResult unbindSystemUser(@RequestBody AsUser user) + { + return toAjax(asUserService.unbindSystemUser(user)); + } + /** * 删除用户 */ diff --git a/electripper-admin/src/main/resources/application.yml b/electripper-admin/src/main/resources/application.yml index 103c4ab..c5287d3 100644 --- a/electripper-admin/src/main/resources/application.yml +++ b/electripper-admin/src/main/resources/application.yml @@ -16,7 +16,7 @@ ruoyi: # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 - port: 8080 + port: 8088 servlet: # 应用的访问路径 context-path: / diff --git a/electripper-common/src/main/java/com/ruoyi/common/constant/IotConstants.java b/electripper-common/src/main/java/com/ruoyi/common/constant/IotConstants.java index ab41731..8ae3a0e 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/constant/IotConstants.java +++ b/electripper-common/src/main/java/com/ruoyi/common/constant/IotConstants.java @@ -88,6 +88,7 @@ public class IotConstants { /** * 命令 2营运边界 + * 接近运营边界请规划好路线 */ public static final String COMMAND_PLAY2 = "play2@"; diff --git a/electripper-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java b/electripper-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java index 27979fd..1ca3357 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java +++ b/electripper-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java @@ -135,6 +135,17 @@ public class SysUser extends BaseEntity /** app用户名 */ private String appUserName; + /** 角色对象 */ + private List users; + + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users; + } + public String getRoleNames() { return roleNames; } diff --git a/electripper-common/src/main/java/com/ruoyi/common/enums/BusinessType.java b/electripper-common/src/main/java/com/ruoyi/common/enums/BusinessType.java index 0a893c1..755bbc1 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/enums/BusinessType.java +++ b/electripper-common/src/main/java/com/ruoyi/common/enums/BusinessType.java @@ -182,4 +182,14 @@ public enum BusinessType * 换车开锁 */ CHANGEUNLOCK, + + /** + * 绑定系统用户 + */ + BANDSYSUSER, + + /** + * 解绑系统用户 + */ + UNBANDSYSUSER, } diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/EtOperatingArea.java b/electripper-system/src/main/java/com/ruoyi/system/domain/EtOperatingArea.java index 3932bcd..66c5ac0 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/EtOperatingArea.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/EtOperatingArea.java @@ -226,4 +226,16 @@ public class EtOperatingArea extends BaseEntityPlus implements Serializable /** 导览开关*/ private String guideSwitch; + + /** 停车区数*/ + @TableField(exist = false) + private Integer parkingAreaNum; + + /** 禁停区数*/ + @TableField(exist = false) + private Integer noParkingAreaNum; + + /** 禁停区数*/ + @TableField(exist = false) + private Integer bannedRidingAreaNum; } diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/EtWithdraw.java b/electripper-system/src/main/java/com/ruoyi/system/domain/EtWithdraw.java index 9656e9e..2fb7cd7 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/EtWithdraw.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/EtWithdraw.java @@ -32,6 +32,10 @@ public class EtWithdraw extends BaseEntity @Excel(name = "运营商id") private Long deptId; + /** 运营区id */ + @Excel(name = "运营区id") + private Long areaId; + /** 运营商 */ @Excel(name = "运营商") private String deptName; diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/AsUserMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/AsUserMapper.java index 468b7b5..2f665cb 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/AsUserMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/AsUserMapper.java @@ -175,4 +175,9 @@ public interface AsUserMapper * 更新用户密码 */ int updateUserPwd(@Param("userId") Long userId, @Param("password") String password); + + /** + * 解绑系统用户 + */ + int unbindSystemUser(AsUser user); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtParkingAreaMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtParkingAreaMapper.java index 024208c..f02b793 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtParkingAreaMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtParkingAreaMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.system.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.system.domain.EtParkingArea; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -76,4 +77,12 @@ public interface EtParkingAreaMapper extends BaseMapper * @return 结果 */ public EtParkingArea checkParkingNameUnique(String parkingName); + + /** + * 根据运营区id查询运营区信息 + * + * @param areaId 运营区id + * @return 结果 + */ + int selectParkingAreaNumByAreaId(@Param("areaId") Long areaId,@Param("type") String type); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IAsUserService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IAsUserService.java index 8889328..dc5bf40 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IAsUserService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IAsUserService.java @@ -221,6 +221,11 @@ public interface IAsUserService */ int bandSystemUser(AsUser user); + /** + * 解绑系统用户 + */ + int unbindSystemUser(AsUser user); + /** * 实名认证 * diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IEtParkingAreaService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IEtParkingAreaService.java index 201a348..9239d37 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IEtParkingAreaService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IEtParkingAreaService.java @@ -91,4 +91,11 @@ public interface IEtParkingAreaService extends IService * @return 结果 */ public int updateParkingStatus(EtParkingArea area); + + /** + * 根据区域id查询该区域下所有停车点数 + * @param areaId + * @return + */ + public int selectParkingAreaNumByAreaId(Long areaId,String type); } 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 0670a97..20882d7 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 @@ -1935,42 +1935,42 @@ public class AsDeviceServiceImpl extends ServiceImpl i return cycle.intValue(); } - /** - * 是否在停车区内 - */ - private Boolean isParkingZone(String sn,Long areaId) { - Boolean inCircle = false; - EtParkingArea parkingArea = new EtParkingArea(); - parkingArea.setAreaId(areaId); - parkingArea.setStatus("0"); - List parkingAreas = parkingAreaService.selectEtParkingAreaList(parkingArea); - EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId); - if(ObjectUtil.isNull(parkingAreas) || parkingAreas.size() == 0){ - log.info("运营区【{}】没有停车区,",areaId); - throw new ServiceException("运营区【{"+area.getAreaName()+"}】没有停车区"); - } - double tolerance = area.getError(); // 误差距离 - for (EtParkingArea etParkingArea : parkingAreas) { - if(etParkingArea.getType().equals(ServiceConstants.PARKING_AREA_TYPE_PARKFING)){ - AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn); - String latitude = device.getLatitude(); - String longitude = device.getLongitude(); - Geometry geometry = GeoUtils.fromWkt(etParkingArea.getBoundary()); - if(ObjectUtil.isNotNull(etParkingArea.getError())){ - tolerance = etParkingArea.getError(); - } - inCircle = GeoUtils.isInPolygonWithTolerance(longitude, latitude, geometry, tolerance); - if(inCircle){ - log.info("车辆【{}】在停车区【{}】内",sn,etParkingArea.getParkingName()); - inCircle = true; - break; - }else{ - log.info("车辆【{}】不在停车区【{}】内",sn,etParkingArea.getParkingName()); - } - } - } - return inCircle; - } +// /** +// * 是否在停车区内 +// */ +// private Boolean isParkingZone(String sn,Long areaId) { +// Boolean inCircle = false; +// EtParkingArea parkingArea = new EtParkingArea(); +// parkingArea.setAreaId(areaId); +// parkingArea.setStatus("0"); +// List parkingAreas = parkingAreaService.selectEtParkingAreaList(parkingArea); +// EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId); +// if(ObjectUtil.isNull(parkingAreas) || parkingAreas.size() == 0){ +// log.info("运营区【{}】没有停车区,",areaId); +// throw new ServiceException("运营区【{"+area.getAreaName()+"}】没有停车区"); +// } +// double tolerance = area.getError(); // 误差距离 +// for (EtParkingArea etParkingArea : parkingAreas) { +// if(etParkingArea.getType().equals(ServiceConstants.PARKING_AREA_TYPE_PARKFING)){ +// AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn); +// String latitude = device.getLatitude(); +// String longitude = device.getLongitude(); +// Geometry geometry = GeoUtils.fromWkt(etParkingArea.getBoundary()); +// if(ObjectUtil.isNotNull(etParkingArea.getError())){ +// tolerance = etParkingArea.getError(); +// } +// inCircle = GeoUtils.isInPolygonWithTolerance(longitude, latitude, geometry, tolerance); +// if(inCircle){ +// log.info("车辆【{}】在停车区【{}】内",sn,etParkingArea.getParkingName()); +// inCircle = true; +// break; +// }else{ +// log.info("车辆【{}】不在停车区【{}】内",sn,etParkingArea.getParkingName()); +// } +// } +// } +// return inCircle; +// } private Boolean isParkingZoneByLocation(String longitude, String latitude,Long areaId) { Boolean inCircle = false; @@ -1982,7 +1982,8 @@ public class AsDeviceServiceImpl extends ServiceImpl i EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId); if(ObjectUtil.isNull(parkingAreas) || parkingAreas.size() == 0){ log.info("运营区【{}】没有停车区,",areaId); - throw new ServiceException("运营区【{}】没有停车区"+areaId.toString()); + return true; +// throw new ServiceException("运营区【{}】没有停车区"+areaId.toString()); } double tolerance = area.getError(); // 误差距离 for (EtParkingArea etParkingArea : parkingAreas) { diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java index 80fd45a..d77e3bb 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsUserServiceImpl.java @@ -17,6 +17,7 @@ import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.common.utils.bean.BeanValidators; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.common.utils.verify.VerifyIdentityUtil; +import com.ruoyi.system.domain.EtOperatingArea; import com.ruoyi.system.domain.EtOrder; import com.ruoyi.system.domain.vo.AuthenticationVo; import com.ruoyi.system.mapper.AsUserMapper; @@ -466,8 +467,12 @@ public class AsUserServiceImpl implements IAsUserService public Boolean checkIsDeposit(Long userId) { AsUser asUser = asUserMapper.selectUserById(userId); BigDecimal balance = asUser.getBalance(); -// EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asUser.getAreaId()); -// BigDecimal deposit = new BigDecimal(area.getDeposit()); + EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(Long.parseLong(asUser.getAreaId())); + BigDecimal deposit = new BigDecimal(area.getDeposit()); + if(deposit.compareTo(BigDecimal.ZERO)==0){//押金为0直接返回true + log.info("运营区【{}】押金为0",area.getAreaName()); + return true; + } if(ObjectUtil.isNull(balance)){ log.info("用户【{}】余额为空",userId); return false; @@ -530,6 +535,19 @@ public class AsUserServiceImpl implements IAsUserService return asUserMapper.updateUser(user); } + + /** + * 解绑系统用户 + */ + @Transactional + @Override + public int unbindSystemUser(AsUser user) { + // 删除用户缓存 + Collection keys = SpringUtils.getBean(RedisCache.class).keys(CacheConstants.APP_LOGIN_TOKEN_KEY + "*"); + redisCache.deleteObject(keys); + return asUserMapper.unbindSystemUser(user); + } + /** * 实名认证 */ diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOperatingAreaServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOperatingAreaServiceImpl.java index 96afb6f..2411960 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOperatingAreaServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOperatingAreaServiceImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.ServiceConstants; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.DateUtils; @@ -23,6 +24,7 @@ import com.ruoyi.system.mapper.EtOperatingAreaMapper; import com.ruoyi.system.service.IAsDeviceService; import com.ruoyi.system.service.IEtFeeRuleService; import com.ruoyi.system.service.IEtOperatingAreaService; +import com.ruoyi.system.service.IEtParkingAreaService; import lombok.extern.slf4j.Slf4j; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; @@ -66,6 +68,9 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl asUsers = asUserMapper.selectUserList(asUser1); - if(ObjectUtil.isNotNull(asUsers) && asUsers.size()>0){ + if (ObjectUtil.isNotNull(asUsers) && !asUsers.isEmpty()) { String appUserName = asUsers.stream() - .map(AsUser::getRealName) + .map(user1 -> user1.getRealName() != null ? user1.getRealName() : user1.getUserName()) .collect(Collectors.joining(",")); sysUser.setAppUserName(appUserName); } @@ -182,6 +182,10 @@ public class SysUserServiceImpl implements ISysUserService // 显示分润项目 showDividendItem(sysUser); } + AsUser asUser1 = new AsUser(); + asUser1.setSysUserId(sysUser.getUserId()); + List asUsers = asUserMapper.selectUserList(asUser1); + sysUser.setUsers(asUsers); return sysUser; } diff --git a/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml b/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml index c9512e5..793aeb7 100644 --- a/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml @@ -275,6 +275,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update et_user set password = #{password} where user_id = #{userId} + + update et_user set sys_user_id = null,role = null where user_id = #{userId} + + update et_user set del_flag = '2' where user_id = #{userId} diff --git a/electripper-system/src/main/resources/mapper/system/EtParkingAreaMapper.xml b/electripper-system/src/main/resources/mapper/system/EtParkingAreaMapper.xml index 457130a..8ac2ee3 100644 --- a/electripper-system/src/main/resources/mapper/system/EtParkingAreaMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtParkingAreaMapper.xml @@ -49,6 +49,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select parking_id, parking_name from et_parking_area where parking_name = #{parkingName} limit 1 + + insert into et_parking_area