1.绑定APP用户,解绑

2.停车区数量
This commit is contained in:
邱贞招 2024-08-02 11:12:53 +08:00
parent 6906314224
commit 69e1aade39
20 changed files with 190 additions and 49 deletions

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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));
}
/**
* 删除用户
*/

View File

@ -16,7 +16,7 @@ ruoyi:
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8080
port: 8088
servlet:
# 应用的访问路径
context-path: /

View File

@ -88,6 +88,7 @@ public class IotConstants {
/**
* 命令 2营运边界
* 接近运营边界请规划好路线
*/
public static final String COMMAND_PLAY2 = "play2@";

View File

@ -135,6 +135,17 @@ public class SysUser extends BaseEntity
/** app用户名 */
private String appUserName;
/** 角色对象 */
private List<AsUser> users;
public List<AsUser> getUsers() {
return users;
}
public void setUsers(List<AsUser> users) {
this.users = users;
}
public String getRoleNames() {
return roleNames;
}

View File

@ -182,4 +182,14 @@ public enum BusinessType
* 换车开锁
*/
CHANGEUNLOCK,
/**
* 绑定系统用户
*/
BANDSYSUSER,
/**
* 解绑系统用户
*/
UNBANDSYSUSER,
}

View File

@ -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;
}

View File

@ -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;

View File

@ -175,4 +175,9 @@ public interface AsUserMapper
* 更新用户密码
*/
int updateUserPwd(@Param("userId") Long userId, @Param("password") String password);
/**
* 解绑系统用户
*/
int unbindSystemUser(AsUser user);
}

View File

@ -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<EtParkingArea>
* @return 结果
*/
public EtParkingArea checkParkingNameUnique(String parkingName);
/**
* 根据运营区id查询运营区信息
*
* @param areaId 运营区id
* @return 结果
*/
int selectParkingAreaNumByAreaId(@Param("areaId") Long areaId,@Param("type") String type);
}

View File

@ -221,6 +221,11 @@ public interface IAsUserService
*/
int bandSystemUser(AsUser user);
/**
* 解绑系统用户
*/
int unbindSystemUser(AsUser user);
/**
* 实名认证
*

View File

@ -91,4 +91,11 @@ public interface IEtParkingAreaService extends IService<EtParkingArea>
* @return 结果
*/
public int updateParkingStatus(EtParkingArea area);
/**
* 根据区域id查询该区域下所有停车点数
* @param areaId
* @return
*/
public int selectParkingAreaNumByAreaId(Long areaId,String type);
}

View File

@ -1935,42 +1935,42 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> 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<EtParkingArea> 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<EtParkingArea> 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<AsDeviceMapper, AsDevice> 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) {

View File

@ -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<String> keys = SpringUtils.getBean(RedisCache.class).keys(CacheConstants.APP_LOGIN_TOKEN_KEY + "*");
redisCache.deleteObject(keys);
return asUserMapper.unbindSystemUser(user);
}
/**
* 实名认证
*/

View File

@ -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<EtOperatingAreaMappe
@Resource
private EtAreaDeptMapper etAreaDeptMapper;
@Resource
private IEtParkingAreaService etParkingAreaService;
/**
* 查询运营区
@ -128,6 +133,9 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl<EtOperatingAreaMappe
ruleStr.append(rule);
}
area.setRuleStr(ruleStr.toString().trim());
area.setParkingAreaNum(etParkingAreaService.selectParkingAreaNumByAreaId(area.getAreaId(),ServiceConstants.PARKING_AREA_TYPE_PARKFING));
area.setNoParkingAreaNum(etParkingAreaService.selectParkingAreaNumByAreaId(area.getAreaId(),ServiceConstants.PARKING_AREA_TYPE_NO_PARKFING));
area.setBannedRidingAreaNum(etParkingAreaService.selectParkingAreaNumByAreaId(area.getAreaId(),ServiceConstants.PARKING_AREA_TYPE_BANNED_RIDING));
}
return etOperatingAreas;
}

View File

@ -168,5 +168,15 @@ public class EtParkingAreaServiceImpl extends ServiceImpl<EtParkingAreaMapper, E
return etParkingAreaMapper.updateEtParkingArea(area);
}
/**
* 根据运营区域id查询运营区域下的停车点数量
* @param areaId
* @return
*/
@Override
public int selectParkingAreaNumByAreaId(Long areaId,String type){
return etParkingAreaMapper.selectParkingAreaNumByAreaId(areaId,type);
}
}

View File

@ -114,9 +114,9 @@ public class SysUserServiceImpl implements ISysUserService
AsUser asUser1 = new AsUser();
asUser1.setSysUserId(sysUser.getUserId());
List<AsUser> 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<AsUser> asUsers = asUserMapper.selectUserList(asUser1);
sysUser.setUsers(asUsers);
return sysUser;
}

View File

@ -275,6 +275,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update et_user set password = #{password} where user_id = #{userId}
</update>
<update id="unbindSystemUser">
update et_user set sys_user_id = null,role = null where user_id = #{userId}
</update>
<delete id="deleteUserById" parameterType="Long">
update et_user set del_flag = '2' where user_id = #{userId}
</delete>

View File

@ -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
</select>
<select id="selectParkingAreaNumByAreaId" resultType="java.lang.Integer">
select count(1) from et_parking_area where area_id = #{areaId} and type = #{type}
</select>
<insert id="insertEtParkingArea" parameterType="EtParkingArea">
insert into et_parking_area
<trim prefix="(" suffix=")" suffixOverrides=",">