Commit 57e63f92 by 杨林龙

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/cn/com/glsx/app/modules/controller/DashboardController.java
#	src/main/java/cn/com/glsx/app/modules/model/param/BasicSearch.java
#	src/main/java/cn/com/glsx/app/modules/service/DashboardService.java
2 parents a34385fe 8802adf2
Showing 48 changed files with 726 additions and 231 deletions
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<dependency> <dependency>
<groupId>com.github.binarywang</groupId> <groupId>com.github.binarywang</groupId>
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId> <artifactId>wx-java-miniapp-spring-boot-starter</artifactId>
<version>4.2.7.B</version> <version>4.3.5.B</version>
</dependency> </dependency>
<dependency> <dependency>
......
package cn.com.glsx.app.modules; package cn.com.glsx.app.modules;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.com.glsx.app.modules.model.AppUser; import cn.com.glsx.app.modules.model.AppUser;
import cn.com.glsx.app.modules.model.LoginByAccountBO; import cn.com.glsx.app.modules.model.param.LoginByAccountBO;
import cn.com.glsx.app.modules.service.LoginService; import cn.com.glsx.app.modules.service.LoginService;
import cn.com.glsx.app.modules.service.UserService; import cn.com.glsx.app.modules.service.UserService;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -34,6 +36,9 @@ public class LocalLoginController { ...@@ -34,6 +36,9 @@ public class LocalLoginController {
@Autowired @Autowired
private LoginService loginService; private LoginService loginService;
@Autowired
private WxMaService wxMaService;
@GetMapping(value = "/") @GetMapping(value = "/")
public String index() { public String index() {
return "success"; return "success";
...@@ -44,10 +49,12 @@ public class LocalLoginController { ...@@ -44,10 +49,12 @@ public class LocalLoginController {
*/ */
@ApiOperation(value = "登录系统") @ApiOperation(value = "登录系统")
@PostMapping(value = "/login") @PostMapping(value = "/login")
public R login(@RequestBody @Validated LoginByAccountBO loginBO) { public R login(@RequestBody @Validated LoginByAccountBO loginBO) throws WxErrorException {
//本地登录授权
AppUser user = loginService.localAuth(loginBO); AppUser user = loginService.localAuth(loginBO);
//关联微信账号
loginService.linkWxAuth(loginBO.getCodeForWx(), user);
//创建授权令牌
String token = userService.createToken(user); String token = userService.createToken(user);
Map<String, Object> rtnMap = new HashMap<>(); Map<String, Object> rtnMap = new HashMap<>();
......
...@@ -4,9 +4,9 @@ import cn.binarywang.wx.miniapp.api.WxMaService; ...@@ -4,9 +4,9 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.com.glsx.app.common.enums.LoginType; import cn.com.glsx.app.common.enums.LoginType;
import cn.com.glsx.app.common.enums.MiniUserType; import cn.com.glsx.app.common.enums.MiniUserType;
import cn.com.glsx.app.common.exception.AppServerException;
import cn.com.glsx.app.modules.entity.UserAuthRel; import cn.com.glsx.app.modules.entity.UserAuthRel;
import cn.com.glsx.app.modules.model.AppUser; import cn.com.glsx.app.modules.model.AppUser;
import cn.com.glsx.app.modules.model.QQOAuth2AccessToken;
import cn.com.glsx.app.modules.service.LoginService; import cn.com.glsx.app.modules.service.LoginService;
import cn.com.glsx.app.modules.service.UserService; import cn.com.glsx.app.modules.service.UserService;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
...@@ -46,29 +46,11 @@ public class ThirdLoginController { ...@@ -46,29 +46,11 @@ public class ThirdLoginController {
private WxMaService wxMaService; private WxMaService wxMaService;
@NoLogin @NoLogin
@ApiOperation(value = "QQ授权登录")
@GetMapping(value = "/qqAuth")
public R qqAuth(@RequestParam String code) {
//获取openId、unionId等
QQOAuth2AccessToken accessToken = new QQOAuth2AccessToken();
log.info("QQ code[{}]获取的Session信息为{}", code, JSONUtil.toJsonStr(accessToken));
UserAuthRel authRel = loginService.qqAuth(accessToken);
Map<String, Object> rtnMap = thirdLogin(LoginType.QQ, 0, authRel);
return R.ok().data(rtnMap);
}
@NoLogin
@ApiOperation(value = "微信授权登录") @ApiOperation(value = "微信授权登录")
@GetMapping(value = "/wechatAuth") @GetMapping(value = "/wechatAuth")
public R wechatAuth(@RequestParam String code, @RequestParam Integer accessMode) throws WxErrorException { public R wechatAuth(@RequestParam String code, @RequestParam Integer accessMode) throws WxErrorException {
//获取openId、unionid、session_key //获取openId、unionid、session_key
WxMaJscode2SessionResult sessionInfo = null;//wxMaService.getUserService().getSessionInfo(code); WxMaJscode2SessionResult sessionInfo = wxMaService.getUserService().getSessionInfo(code);
sessionInfo = new WxMaJscode2SessionResult();
sessionInfo.setOpenid("ocDtn5a60SvMC33CbObTUUMVGOwE");
log.info("微信code[{}]获取的Session信息为{}", code, JSONUtil.toJsonStr(sessionInfo)); log.info("微信code[{}]获取的Session信息为{}", code, JSONUtil.toJsonStr(sessionInfo));
UserAuthRel authRel = loginService.wechatAuth(sessionInfo, accessMode); UserAuthRel authRel = loginService.wechatAuth(sessionInfo, accessMode);
...@@ -89,32 +71,31 @@ public class ThirdLoginController { ...@@ -89,32 +71,31 @@ public class ThirdLoginController {
private Map<String, Object> thirdLogin(LoginType loginType, Integer accessMode, UserAuthRel authRel) { private Map<String, Object> thirdLogin(LoginType loginType, Integer accessMode, UserAuthRel authRel) {
Map<String, Object> rtnMap = new HashMap<>(); Map<String, Object> rtnMap = new HashMap<>();
Optional<Long> optUserId = Optional.ofNullable(authRel.getUserId());
if (!optUserId.isPresent() || optUserId.get() == 0L) {
throw new AppServerException("登录失败,请联系管理员");
}
//分两种情况: //分两种情况:
if (MiniUserType.NORMAL.getFlag().equals(accessMode)) { if (MiniUserType.NORMAL.getFlag().equals(accessMode)) {
//1、常规免登录(通过小程序正常入口) //1、常规免登录(通过小程序正常入口)
Optional<Long> optUserId = Optional.ofNullable(authRel.getUserId()); //已绑定本地账号返回引用账号
if (optUserId.isPresent()) { AppUser user = userService.getRelUserByUserId(authRel.getUserId());
//已绑定本地账号 String token = userService.createToken(user);
AppUser user = userService.getAppUserByUserId(authRel.getUserId()); rtnMap.put("user", user);
String token = userService.createToken(user); rtnMap.put("token", token);
rtnMap.put("user", user);
rtnMap.put("token", token);
} else {
//未绑定本地账号,跳转登录界面登录,回传此id
rtnMap.put("authRelId", authRel.getId());
}
} else if (MiniUserType.SHARED.getFlag().equals(accessMode)) { } else if (MiniUserType.SHARED.getFlag().equals(accessMode)) {
//2、通过分享车辆地址登录,也分两种情况 //2、通过分享车辆地址登录,也分两种情况
//a、存在账号的openid发起免登录 //a、存在账号的openid发起免登录
//b、不存在账号的openid发起免登录 //b、不存在账号的openid发起免登录
AppUser user = userService.getAppUserByAuthId(loginType, authRel.getAuthId()); AppUser user = userService.getLocalUserByUserId(authRel.getUserId());
user.setUserType(MiniUserType.SHARED.getType()); user.setUserType(MiniUserType.SHARED.getType());
String token = userService.createToken(user); String token = userService.createToken(user);
rtnMap.put("user", user); rtnMap.put("user", user);
rtnMap.put("token", token); rtnMap.put("token", token);
} else { } else {
// TODO: 2022/6/29 抛出异常 throw new AppServerException("登录方式参数有误");
} }
return rtnMap; return rtnMap;
} }
......
...@@ -5,6 +5,9 @@ import cn.com.glsx.app.modules.model.vo.DeviceActiveVO; ...@@ -5,6 +5,9 @@ import cn.com.glsx.app.modules.model.vo.DeviceActiveVO;
import cn.com.glsx.app.modules.model.vo.FenceAlarmVO; import cn.com.glsx.app.modules.model.vo.FenceAlarmVO;
import cn.com.glsx.app.modules.model.vo.OfflineAlarmVO; import cn.com.glsx.app.modules.model.vo.OfflineAlarmVO;
import cn.com.glsx.app.modules.model.vo.TrackAlarmVO; import cn.com.glsx.app.modules.model.vo.TrackAlarmVO;
import cn.com.glsx.app.modules.model.param.BasicSearch;
import cn.com.glsx.app.modules.model.view.LowPowerVO;
import cn.com.glsx.app.modules.model.view.StatisticalInfoVO;
import cn.com.glsx.app.modules.service.DashboardService; import cn.com.glsx.app.modules.service.DashboardService;
import cn.hutool.db.Page; import cn.hutool.db.Page;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
...@@ -26,16 +29,36 @@ import java.util.List; ...@@ -26,16 +29,36 @@ import java.util.List;
* *
* @author yangll * @author yangll
*/ */
@Api(value = "看板", tags = {"看板"})
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping(value = "/dashboard") @RequestMapping(value = "/dashboard")
@Api(value = "看板", tags = {"看板"})
public class DashboardController { public class DashboardController {
@Autowired @Autowired
private DashboardService dashboardService; private DashboardService dashboardService;
//todo Basic information
//todo 低电量 /**
* 看板统计信息
*/
@ApiOperation(value = "看板统计信息", notes = "看板统计信息", httpMethod = "GET")
@GetMapping("statisticalInfo")
public R<StatisticalInfoVO> getStatisticalInfo() {
StatisticalInfoVO data = dashboardService.getStatisticalInfo();
return R.ok().data(data);
}
/**
* 低电量统计
*/
@ApiOperation(value = "低电量统计", notes = "低电量统计", httpMethod = "GET")
@GetMapping("pageLowPower")
public R<List<LowPowerVO>> pageTodayLowPower(BasicSearch search) {
List<LowPowerVO> list = dashboardService.listTodayLowPower(search);
return R.ok().putPageData(list, list.size());
}
@GetMapping("/getActiveDeviceInfo") @GetMapping("/getActiveDeviceInfo")
......
package cn.com.glsx.app.modules.controller;
import cn.com.glsx.app.modules.model.param.VehicleSharedBO;
import cn.com.glsx.app.modules.service.DataShareService;
import com.glsx.plat.common.annotation.SysLog;
import com.glsx.plat.common.enums.OperateType;
import com.glsx.plat.core.web.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@Slf4j
@RestController
@RequestMapping(value = "/share")
@Api(value = "数据分享", tags = {"数据分享"})
public class DataShareController {
@Autowired
private DataShareService dataShareService;
@ApiOperation(value = "分享车辆")
@SysLog(module = "分享车辆", value = "分享车辆", action = OperateType.ADD)
@PostMapping(value = "/vehicle")
public R shareVehicle(@RequestBody @Validated VehicleSharedBO sharedBO) {
Long sharedId = dataShareService.shareVehicle(sharedBO);
return R.ok().data(sharedId);
}
@ApiOperation(value = "点击分享")
@SysLog(module = "点击分享", value = "点击分享", action = OperateType.ADD)
@GetMapping(value = "/click")
public R click(@RequestParam("sharedId") Long sharedId) {
dataShareService.clickShared(sharedId);
return R.ok();
}
}
package cn.com.glsx.app.modules.controller; package cn.com.glsx.app.modules.controller;
import cn.com.glsx.app.modules.model.VehicleDeviceDTO; import cn.com.glsx.app.modules.model.view.VehicleDeviceDTO;
import cn.com.glsx.app.modules.model.VehicleLocationDTO; import cn.com.glsx.app.modules.model.view.VehicleLocationDTO;
import cn.com.glsx.app.modules.model.param.ResidentSearch; import cn.com.glsx.app.modules.model.param.ResidentSearch;
import cn.com.glsx.app.modules.model.param.TrackPointSearch; import cn.com.glsx.app.modules.model.param.TrackPointSearch;
import cn.com.glsx.app.modules.model.vo.ResidentListVO; import cn.com.glsx.app.modules.model.view.ResidentListVO;
import cn.com.glsx.app.modules.model.vo.TrackPointVO; import cn.com.glsx.app.modules.model.view.TrackPointVO;
import cn.com.glsx.app.modules.service.VehicleMonitorService; import cn.com.glsx.app.modules.service.VehicleMonitorService;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -14,7 +14,6 @@ import io.swagger.annotations.ApiResponse; ...@@ -14,7 +14,6 @@ import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -54,7 +53,7 @@ public class VehicleMonitorController { ...@@ -54,7 +53,7 @@ public class VehicleMonitorController {
*/ */
@ApiOperation(value = "轨迹回放") @ApiOperation(value = "轨迹回放")
@GetMapping(value = "/location/trackPointList") @GetMapping(value = "/location/trackPointList")
public R<List<TrackPointVO>> getTrackPointList(@SpringQueryMap TrackPointSearch search) { public R<List<TrackPointVO>> getTrackPointList(TrackPointSearch search) {
List<TrackPointVO> list = vehicleMonitorService.getTrackPointList(search); List<TrackPointVO> list = vehicleMonitorService.getTrackPointList(search);
return R.ok().data(list); return R.ok().data(list);
} }
......
package cn.com.glsx.app.modules.converter; package cn.com.glsx.app.modules.converter;
import cn.com.glsx.app.modules.entity.VehicleDeviceWorkOrder; import cn.com.glsx.app.modules.entity.VehicleDeviceWorkOrder;
import cn.com.glsx.app.modules.model.VehicleLocationDTO; import cn.com.glsx.app.modules.model.view.VehicleLocationDTO;
import cn.com.glsx.devicemonitor.api.dto.response.DeviceLocationDTO; import cn.com.glsx.devicemonitor.api.dto.response.DeviceLocationDTO;
import java.util.Objects; import java.util.Objects;
......
...@@ -3,7 +3,7 @@ package cn.com.glsx.app.modules.converter; ...@@ -3,7 +3,7 @@ package cn.com.glsx.app.modules.converter;
import cn.com.glsx.admin.common.util.DateUtil; import cn.com.glsx.admin.common.util.DateUtil;
import cn.com.glsx.app.modules.entity.VehicleDeviceWorkOrder; import cn.com.glsx.app.modules.entity.VehicleDeviceWorkOrder;
import cn.com.glsx.app.modules.model.param.ResidentSearch; import cn.com.glsx.app.modules.model.param.ResidentSearch;
import cn.com.glsx.app.modules.model.vo.ResidentListVO; import cn.com.glsx.app.modules.model.view.ResidentListVO;
import cn.com.glsx.devicemonitor.api.dto.request.ResidentRequest; import cn.com.glsx.devicemonitor.api.dto.request.ResidentRequest;
import cn.com.glsx.devicemonitor.api.dto.response.ResidentDTO; import cn.com.glsx.devicemonitor.api.dto.response.ResidentDTO;
......
package cn.com.glsx.app.modules.entity;
import com.glsx.plat.mybatis.base.BaseEntity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
@Data
@Table(name = "t_cust_user_qq_account")
public class UserQQAccount extends BaseEntity {
/**
* 认证id
*/
@Column(name = "auth_id")
private Long authId;
/**
* 平台id
*/
@Column(name = "union_id")
private String unionId;
/**
* QQ头像
*/
@Column(name = "qq_avatar")
private String avatar;
/**
* QQ名
*/
@Column(name = "qq_name")
private String qqName;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.app.modules.entity;
import com.glsx.plat.mybatis.base.BaseEntity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
import java.util.Date;
@Data
@Table(name = "t_cust_user_shared_data")
public class UserSharedData extends BaseEntity {
/**
* 授权数据id
*/
@Column(name = "content_id")
private Long contentId;
/**
* 内容类型:0车辆
*/
@Column(name = "content_type")
private Integer contentType;
/**
* 权限类型 r=只读 wr=读写
*/
@Column(name = "permit_type")
private String permitType;
/**
* 生效时间
*/
@Column(name = "effective_date")
private Date effectiveDate;
/**
* 失效时间
*/
@Column(name = "expiration_date")
private Date expirationDate;
/**
* 状态:0默认,1有效,2失效
*/
private Integer status;
}
\ No newline at end of file \ No newline at end of file
...@@ -12,6 +12,12 @@ import java.util.Date; ...@@ -12,6 +12,12 @@ import java.util.Date;
public class VehicleShared extends BaseEntity { public class VehicleShared extends BaseEntity {
/** /**
* 分享id,对应t_cust_user_shared_data表id
*/
@Column(name = "shared_id")
private Long sharedId;
/**
* 授权人id,对应t_cust_user表id * 授权人id,对应t_cust_user表id
*/ */
@Column(name = "accorder_id") @Column(name = "accorder_id")
...@@ -29,33 +35,33 @@ public class VehicleShared extends BaseEntity { ...@@ -29,33 +35,33 @@ public class VehicleShared extends BaseEntity {
@Column(name = "content_id") @Column(name = "content_id")
private Long contentId; private Long contentId;
/** // /**
* 内容类型:0车辆 // * 内容类型:0车辆
*/ // */
@Column(name = "content_type") // @Column(name = "content_type")
private Integer contentType; // private Integer contentType;
//
/** // /**
* 权限类型 r=只读 wr=读写 // * 权限类型 r=只读 wr=读写
*/ // */
@Column(name = "permit_type") // @Column(name = "permit_type")
private String permitType; // private String permitType;
//
/** // /**
* 生效时间 // * 生效时间
*/ // */
@Column(name = "effective_date") // @Column(name = "effective_date")
private Date effectiveDate; // private Date effectiveDate;
//
/** // /**
* 失效时间 // * 失效时间
*/ // */
@Column(name = "expiration_date") // @Column(name = "expiration_date")
private Date expirationDate; // private Date expirationDate;
//
/** // /**
* 状态:0默认,1有效,2失效 // * 状态:0默认,1有效,2失效
*/ // */
private Integer status; // private Integer status;
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.app.modules.mapper; package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.UserAuthRel; import cn.com.glsx.app.modules.entity.UserAuthRel;
import cn.com.glsx.app.modules.entity.UserThirdAuth;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -12,6 +13,8 @@ public interface UserAuthRelMapper extends CommonBaseMapper<UserAuthRel> { ...@@ -12,6 +13,8 @@ public interface UserAuthRelMapper extends CommonBaseMapper<UserAuthRel> {
UserAuthRel selectByAuthTypeAndAuthId(@Param("authType") String authType, @Param("authId") Long authId); UserAuthRel selectByAuthTypeAndAuthId(@Param("authType") String authType, @Param("authId") Long authId);
List<UserAuthRel> selectByAuthTypeAndUserId(@Param("authType") String authType, @Param("userId") Long userId); List<UserAuthRel> selectByAuthTypeAndUserId(@Param("authType") String authType, @Param("userId") Long userId);
} }
\ No newline at end of file \ No newline at end of file
...@@ -12,6 +12,8 @@ public interface UserLocalAccountMapper extends CommonBaseMapper<UserLocalAccoun ...@@ -12,6 +12,8 @@ public interface UserLocalAccountMapper extends CommonBaseMapper<UserLocalAccoun
UserLocalAccount selectByAuthId(@Param("authId") Long authId); UserLocalAccount selectByAuthId(@Param("authId") Long authId);
AppUser selectAppUserByUserId(@Param("userId") Long userId); AppUser selectLocalUserByUserId(@Param("userId") Long userId);
AppUser selectRelUserByUserId(@Param("userId") Long userId);
} }
\ No newline at end of file \ No newline at end of file
...@@ -10,6 +10,8 @@ public interface UserMapper extends CommonBaseMapper<User> { ...@@ -10,6 +10,8 @@ public interface UserMapper extends CommonBaseMapper<User> {
User selectById(@Param("id") Long id); User selectById(@Param("id") Long id);
User selectByRelUserId(@Param("relUserId") Long relUserId);
int saveOrUpdate(User user); int saveOrUpdate(User user);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.app.modules.mapper; package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.UserQQAccount; import cn.com.glsx.app.modules.entity.UserSharedData;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper @Mapper
public interface UserQQAccountMapper extends CommonBaseMapper<UserQQAccount> { public interface UserSharedDataMapper extends CommonBaseMapper<UserSharedData> {
UserQQAccount selectByAuthId(Long authId); UserSharedData selectById(@Param("id") Long id);
} }
\ No newline at end of file \ No newline at end of file
...@@ -12,4 +12,6 @@ public interface UserThirdAuthMapper extends CommonBaseMapper<UserThirdAuth> { ...@@ -12,4 +12,6 @@ public interface UserThirdAuthMapper extends CommonBaseMapper<UserThirdAuth> {
UserThirdAuth selectByLoginTypeAndAuthId(@Param("loginType") String loginType, @Param("authId") Long authId); UserThirdAuth selectByLoginTypeAndAuthId(@Param("loginType") String loginType, @Param("authId") Long authId);
UserThirdAuth selectByLoginTypeAndUserId(@Param("loginType") String loginType, @Param("userId") Long userId);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.app.modules.mapper; package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.Vehicle; import cn.com.glsx.app.modules.entity.Vehicle;
import cn.com.glsx.app.modules.model.VehicleDeviceDTO; import cn.com.glsx.app.modules.model.view.VehicleDeviceDTO;
import com.glsx.plat.common.annotation.DataPerm; import com.glsx.plat.common.annotation.DataPerm;
import com.glsx.plat.common.annotation.DataPermShare; import com.glsx.plat.common.annotation.DataPermShare;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
......
...@@ -3,7 +3,11 @@ package cn.com.glsx.app.modules.mapper; ...@@ -3,7 +3,11 @@ package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.VehicleShared; import cn.com.glsx.app.modules.entity.VehicleShared;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper @Mapper
public interface VehicleSharedMapper extends CommonBaseMapper<VehicleShared> { public interface VehicleSharedMapper extends CommonBaseMapper<VehicleShared> {
VehicleShared selectBySharedIdAndReceiverId(@Param("shareId") Long shareId, @Param("receiverId") Long receiverId);
} }
\ No newline at end of file \ No newline at end of file
...@@ -10,9 +10,11 @@ public class AppUser { ...@@ -10,9 +10,11 @@ public class AppUser {
* 看具体用户类型(userType):normal用户id(对应后台t_user表id),C端被分享用户用户id(对应后台t_cust_user表id) * 看具体用户类型(userType):normal用户id(对应后台t_user表id),C端被分享用户用户id(对应后台t_cust_user表id)
*/ */
private Long userId; private Long userId;
private Long cuserId;
private String account; private String account;
private String username; private String username;
private String avatar; private String avatar;
/** /**
* 用户类型:normal常规用户,shared被分享用户,见枚举MiniUserType * 用户类型:normal常规用户,shared被分享用户,见枚举MiniUserType
*/ */
......
package cn.com.glsx.app.modules.model.param; package cn.com.glsx.app.modules.model.param;
import cn.hutool.db.Page; import cn.hutool.db.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.List; import java.util.List;
@ApiModel
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class BasicSearch extends Page { public class BasicSearch extends Page {
...@@ -14,18 +16,19 @@ public class BasicSearch extends Page { ...@@ -14,18 +16,19 @@ public class BasicSearch extends Page {
/** /**
* 组织Id * 组织Id
*/ */
@ApiModelProperty(value = "组织Id") @ApiModelProperty("组织Id")
private Long orgId; private Long orgId;
/**
* 组织类型
*/
@ApiModelProperty("组织类型")
private String orgType; private String orgType;
@ApiModelProperty("")
private List<Long> checkedOrgIds; private List<Long> checkedOrgIds;
@ApiModelProperty("")
private String checkedUserIdsStr; private String checkedUserIdsStr;
/**
* 结清条件
*/
private String settleCondition;
} }
package cn.com.glsx.app.modules.model; package cn.com.glsx.app.modules.model.param;
import lombok.Data; import lombok.Data;
......
package cn.com.glsx.app.modules.model.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Data
public class VehicleSharedBO {
/**
* 分享数据id
*/
@NotNull
private Long vehicleId;
/**
* 生效时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date effectiveDate;
/**
* 失效时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date expirationDate;
/**
* 状态:1有效,2失效
*/
private Integer enableStatus;
}
package cn.com.glsx.app.modules.model.view;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 看板低电量统计返回
*
* @author xiangyanlin
* @date 2022/7/4
*/
@ApiModel(description = "看板低电量统计返回")
@Data
public class LowPowerVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 姓名
*/
@ApiModelProperty("姓名")
private String ownerName;
/**
* 车架号
**/
@ApiModelProperty("车架号")
private String vin;
/**
* 设备号
**/
@ApiModelProperty("设备号")
private String sn;
/**
* 时间
**/
@ApiModelProperty("报警时间")
private String alarmTime;
/**
* 激活时间
**/
@ApiModelProperty("激活时间")
private String activeDate;
/**
* 车辆ID
*/
@ApiModelProperty("车辆ID")
private Long vehicleId;
}
package cn.com.glsx.app.modules.model.vo; package cn.com.glsx.app.modules.model.view;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
......
package cn.com.glsx.app.modules.model.view;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 看板统计信息返回
*
* @author xiangyanlin
* @date 2022/7/4
*/
@ApiModel(description = "看板统计信息返回")
@Data
public class StatisticalInfoVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 设备总数
*/
@ApiModelProperty("设备总数")
private Integer totalDevice;
/**
* 车辆总数
*/
@ApiModelProperty("车辆总数")
private Integer totalVehicle;
/**
* 今日激活
*/
@ApiModelProperty("今日激活")
private Integer activeNumToday;
/**
* 断电报警
*/
@ApiModelProperty("断电报警")
private Integer powerOffAlarmNum;
/**
* 围栏报警
*/
@ApiModelProperty("围栏报警")
private Integer fenceAlarmNum;
/**
* 光感报警
*/
@ApiModelProperty("光感报警")
private Integer lightAlarmNum;
/**
* 在线率
*/
@ApiModelProperty("在线率")
private String onlineRate;
}
package cn.com.glsx.app.modules.model.vo; package cn.com.glsx.app.modules.model.view;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -16,7 +16,6 @@ import java.io.Serializable; ...@@ -16,7 +16,6 @@ import java.io.Serializable;
@Data @Data
public class TrackPointVO implements Serializable { public class TrackPointVO implements Serializable {
@ApiModelProperty("")
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
......
package cn.com.glsx.app.modules.model; package cn.com.glsx.app.modules.model.view;
import lombok.Data; import lombok.Data;
......
package cn.com.glsx.app.modules.model; package cn.com.glsx.app.modules.model.view;
import cn.com.glsx.devicemonitor.api.dto.response.GpsLocation; import cn.com.glsx.devicemonitor.api.dto.response.GpsLocation;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
...@@ -96,5 +96,5 @@ public class VehicleLocationDTO implements Serializable { ...@@ -96,5 +96,5 @@ public class VehicleLocationDTO implements Serializable {
* 设备型号是否有wifi * 设备型号是否有wifi
*/ */
@ApiModelProperty("设备型号是否有wifi") @ApiModelProperty("设备型号是否有wifi")
private Boolean hasWifi = false; private Boolean hasWifi;
} }
...@@ -16,6 +16,9 @@ import cn.hutool.db.Page; ...@@ -16,6 +16,9 @@ import cn.hutool.db.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import cn.com.glsx.app.modules.model.param.BasicSearch;
import cn.com.glsx.app.modules.model.view.LowPowerVO;
import cn.com.glsx.app.modules.model.view.StatisticalInfoVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -27,6 +30,8 @@ import java.util.List; ...@@ -27,6 +30,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.List;
/** /**
* 看板展示 service * 看板展示 service
* *
...@@ -129,4 +134,14 @@ public class DashboardService { ...@@ -129,4 +134,14 @@ public class DashboardService {
public PageInfo<OfflineAlarmVO> getOfflineAlarmInfo(Page page) { public PageInfo<OfflineAlarmVO> getOfflineAlarmInfo(Page page) {
return null; return null;
} }
public StatisticalInfoVO getStatisticalInfo() {
return null;
}
public List<LowPowerVO> listTodayLowPower(BasicSearch search) {
return null;
}
} }
package cn.com.glsx.app.modules.service;
import cn.com.glsx.app.common.exception.AppServerException;
import cn.com.glsx.app.modules.entity.UserSharedData;
import cn.com.glsx.app.modules.entity.VehicleShared;
import cn.com.glsx.app.modules.mapper.UserSharedDataMapper;
import cn.com.glsx.app.modules.mapper.VehicleSharedMapper;
import cn.com.glsx.app.modules.model.param.VehicleSharedBO;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import com.glsx.plat.core.enums.SysConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.Objects;
@Service
public class DataShareService {
@Resource
private UserSharedDataMapper userSharedDataMapper;
@Resource
private VehicleSharedMapper vehicleSharedMapper;
@Autowired
private UserService userService;
public Long shareVehicle(VehicleSharedBO sharedBO) {
UserSharedData sharedData = new UserSharedData();
sharedData.setContentId(sharedBO.getVehicleId());
sharedData.setContentType(0);
sharedData.setPermitType("wr");
sharedData.setEffectiveDate(sharedBO.getEffectiveDate());
sharedData.setExpirationDate(sharedBO.getExpirationDate());
sharedData.setStatus(sharedBO.getEnableStatus());
sharedData.setCreatedBy(userService.getCTerminalUserId());
sharedData.setCreatedDate(new Date());
userSharedDataMapper.insert(sharedData);
return sharedData.getId();
}
public void clickShared(Long sharedId) {
UserSharedData sharedData = userSharedDataMapper.selectById(sharedId);
if (sharedData == null) {
throw new AppServerException("分享不存在");
}
long difference = System.currentTimeMillis() - sharedData.getExpirationDate().getTime();
//禁用或者失效状态返回失败
if (!Objects.equals(SysConstants.EnableStatus.enable.getCode(), sharedData.getStatus()) || difference >= 0) {
throw new AppServerException("分享失效");
}
Long cTerminalUserId = userService.getCTerminalUserId();
VehicleShared vehicleShared = vehicleSharedMapper.selectBySharedIdAndReceiverId(sharedId, cTerminalUserId);
if (vehicleShared == null) {
vehicleShared = new VehicleShared();
}
vehicleShared.setSharedId(sharedId);
vehicleShared.setAccorderId(sharedData.getCreatedBy());
vehicleShared.setReceiverId(ShieldContextHolder.getUserId());
vehicleShared.setContentId(sharedData.getContentId());
// vehicleShared.setContentType(sharedData.getContentType());
// vehicleShared.setPermitType(sharedData.getPermitType());
// vehicleShared.setEffectiveDate(sharedData.getEffectiveDate());
// vehicleShared.setExpirationDate(sharedData.getExpirationDate());
// vehicleShared.setStatus(sharedData.getStatus());
vehicleShared.setCreatedDate(new Date());
vehicleShared.setCreatedBy(cTerminalUserId);
vehicleSharedMapper.insert(vehicleShared);
}
}
package cn.com.glsx.app.modules.service; package cn.com.glsx.app.modules.service;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.com.glsx.app.common.enums.AuthType; import cn.com.glsx.app.common.enums.AuthType;
import cn.com.glsx.app.common.enums.LoginType; import cn.com.glsx.app.common.enums.LoginType;
...@@ -9,14 +10,14 @@ import cn.com.glsx.app.modules.converter.UserConverter; ...@@ -9,14 +10,14 @@ import cn.com.glsx.app.modules.converter.UserConverter;
import cn.com.glsx.app.modules.entity.*; import cn.com.glsx.app.modules.entity.*;
import cn.com.glsx.app.modules.mapper.*; import cn.com.glsx.app.modules.mapper.*;
import cn.com.glsx.app.modules.model.AppUser; import cn.com.glsx.app.modules.model.AppUser;
import cn.com.glsx.app.modules.model.LoginByAccountBO; import cn.com.glsx.app.modules.model.param.LoginByAccountBO;
import cn.com.glsx.app.modules.model.QQOAuth2AccessToken;
import cn.com.glsx.auth.api.AuthFeignClient; import cn.com.glsx.auth.api.AuthFeignClient;
import cn.com.glsx.auth.model.SimpleUser; import cn.com.glsx.auth.model.SimpleUser;
import com.glsx.plat.common.utils.StringUtils; import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.enums.SysConstants; import com.glsx.plat.core.enums.SysConstants;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -48,7 +49,7 @@ public class LoginService { ...@@ -48,7 +49,7 @@ public class LoginService {
private UserWechatAccountMapper wechatAccountMapper; private UserWechatAccountMapper wechatAccountMapper;
@Resource @Resource
private UserQQAccountMapper qqAccountMapper; private WxMaService wxMaService;
@Autowired @Autowired
private AuthFeignClient authFeignClient; private AuthFeignClient authFeignClient;
...@@ -69,12 +70,16 @@ public class LoginService { ...@@ -69,12 +70,16 @@ public class LoginService {
User user = register(simpleUser); User user = register(simpleUser);
//返给前端的用户信息 //返给前端的用户信息
return UserConverter.INSTANCE.su2au(simpleUser); AppUser appUser = UserConverter.INSTANCE.su2au(simpleUser);
} else if (loginBO.getLoginType() == 2) { appUser.setCuserId(user.getId());
//验证码校验 appUser.setUserType(MiniUserType.NORMAL.getType());
//smsService.verifyCode(loginBO.getAccount(), loginBO.getCode()); return appUser;
} }
return null; // else if (loginBO.getLoginType() == 2) {
// //验证码校验
// smsService.verifyCode(loginBO.getAccount(), loginBO.getCode());
// }
throw new AppServerException("登录失败");
} }
/** /**
...@@ -126,42 +131,70 @@ public class LoginService { ...@@ -126,42 +131,70 @@ public class LoginService {
userAuthRel.setUserId(user.getId()); userAuthRel.setUserId(user.getId());
userAuthRel.setAuthId(localAuth.getId()); userAuthRel.setAuthId(localAuth.getId());
userAuthRel.setAuthType(AuthType.LOCAL.getType()); userAuthRel.setAuthType(AuthType.LOCAL.getType());
userAuthRel.setCreatedDate(new Date());
userAuthRelMapper.insertUseGeneratedKeys(userAuthRel); userAuthRelMapper.insertUseGeneratedKeys(userAuthRel);
return user; return user;
} else { } else {
user = userMapper.selectById(userAuthRel.getUserId()); user = userMapper.selectById(userAuthRel.getUserId());
if (user == null) { if (user == null) {
// TODO: 2022/6/30 抛出异常 throw new AppServerException("登录失败,请联系管理员");
} }
} }
return user; return user;
} }
public void linkWxAuth(String code, AppUser user) throws WxErrorException {
UserThirdAuth userThirdAuth = userThirdAuthMapper.selectByLoginTypeAndUserId(LoginType.WECHAT.getType(), user.getCuserId());
WxMaJscode2SessionResult sessionResult = wxMaService.getUserService().getSessionInfo(code);
if (sessionResult != null) {
if (userThirdAuth == null) {
//关联c端用户openid
wechatAuth(sessionResult, user.getCuserId());
} else {
log.info("用户{}已关联微信,Openid为{},新Openid为{}", user.getAccount(), userThirdAuth.getOpenid(), sessionResult.getOpenid());
//更新用户openid
if (!sessionResult.getOpenid().equals(userThirdAuth.getOpenid())) {
userThirdAuth.setOpenid(sessionResult.getOpenid());
userThirdAuth.setUpdatedDate(new Date());
userThirdAuthMapper.updateByPrimaryKeySelective(userThirdAuth);
}
//todo 当c端账号先存在,常规账号后存在时,需要更新账号信息(比如:当某个用户通过被分享车辆链接登录产生了c端账号(账号信息是随机的),后来平台给开了常规账号,这种情况两种账号可以通过openid联系起来)
UserLocalAuth userLocalAuth = userLocalAuthMapper.selectByUserId(user.getUserId());
UserLocalAccount userLocalAccount = userLocalAccountMapper.selectByAuthId(userLocalAuth.getId());
}
}
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public UserAuthRel qqAuth(QQOAuth2AccessToken accessToken) { public UserAuthRel wechatAuth(WxMaJscode2SessionResult sessionInfo, Long userId) {
UserThirdAuth thirdAuth = userThirdAuthMapper.selectByOpenid(accessToken.getOpenId()); UserThirdAuth thirdAuth = userThirdAuthMapper.selectByOpenid(sessionInfo.getOpenid());
if (thirdAuth == null) { if (thirdAuth == null) {
thirdAuth = new UserThirdAuth(); thirdAuth = new UserThirdAuth();
thirdAuth.setOpenid(accessToken.getOpenId()); thirdAuth.setOpenid(sessionInfo.getOpenid());
thirdAuth.setAccessToken(accessToken.getAccessToken()); thirdAuth.setAccessToken(sessionInfo.getSessionKey());
thirdAuth.setLoginType(LoginType.QQ.getType()); thirdAuth.setLoginType(LoginType.WECHAT.getType());
userThirdAuthMapper.insertUseGeneratedKeys(thirdAuth); userThirdAuthMapper.insertUseGeneratedKeys(thirdAuth);
} }
UserAuthRel authRel = userAuthRelMapper.selectByAuthTypeAndAuthId(AuthType.THIRD.getType(), thirdAuth.getId()); UserAuthRel authRel = userAuthRelMapper.selectByAuthTypeAndAuthId(AuthType.THIRD.getType(), thirdAuth.getId());
if (authRel == null) { if (authRel == null) {
authRel = new UserAuthRel(); authRel = new UserAuthRel();
authRel.setUserId(userId);
authRel.setAuthId(thirdAuth.getId()); authRel.setAuthId(thirdAuth.getId());
authRel.setAuthType(AuthType.THIRD.getType()); authRel.setAuthType(AuthType.THIRD.getType());
userAuthRelMapper.insertUseGeneratedKeys(authRel); userAuthRelMapper.insertUseGeneratedKeys(authRel);
} }
UserQQAccount qqAccount = qqAccountMapper.selectByAuthId(thirdAuth.getId()); UserWechatAccount wechatAccount = wechatAccountMapper.selectByAuthId(thirdAuth.getId());
if (qqAccount == null) { if (wechatAccount == null) {
qqAccount = new UserQQAccount(); wechatAccount = new UserWechatAccount();
qqAccount.setAuthId(thirdAuth.getId()); wechatAccount.setAuthId(thirdAuth.getId());
qqAccount.setUnionId(accessToken.getUnionId()); wechatAccount.setUnionId(sessionInfo.getUnionid());
qqAccountMapper.insertUseGeneratedKeys(qqAccount); wechatAccountMapper.insertUseGeneratedKeys(wechatAccount);
} }
return authRel; return authRel;
} }
...@@ -177,21 +210,20 @@ public class LoginService { ...@@ -177,21 +210,20 @@ public class LoginService {
userThirdAuthMapper.insertUseGeneratedKeys(thirdAuth); userThirdAuthMapper.insertUseGeneratedKeys(thirdAuth);
} }
User user = null;
if (MiniUserType.SHARED.getFlag().equals(accessMode)) {
SimpleUser simpleUser = new SimpleUser();
// simpleUser.setId();
// simpleUser.setAccount();
// simpleUser.setUsername();
simpleUser.setBlacklist(SysConstants.EnableStatus.enable.getCode());
user = register(simpleUser);
}
UserAuthRel authRel = userAuthRelMapper.selectByAuthTypeAndAuthId(AuthType.THIRD.getType(), thirdAuth.getId()); UserAuthRel authRel = userAuthRelMapper.selectByAuthTypeAndAuthId(AuthType.THIRD.getType(), thirdAuth.getId());
if (authRel == null) { if (authRel == null) {
User user = null;
//如果是分享链接登录,没有存在C端账号,则新建C端账号
if (MiniUserType.SHARED.getFlag().equals(accessMode)) {
SimpleUser simpleUser = new SimpleUser();
simpleUser.setAccount(thirdAuth.getLoginType() + "_user" + thirdAuth.getId());
simpleUser.setUsername(thirdAuth.getLoginType() + "_user");
simpleUser.setBlacklist(SysConstants.EnableStatus.enable.getCode());
user = register(simpleUser);
}
authRel = new UserAuthRel(); authRel = new UserAuthRel();
authRel.setUserId(user != null ? user.getId() : null); authRel.setUserId(user != null ? user.getId() : 0L);
authRel.setAuthId(thirdAuth.getId()); authRel.setAuthId(thirdAuth.getId());
authRel.setAuthType(AuthType.THIRD.getType()); authRel.setAuthType(AuthType.THIRD.getType());
userAuthRelMapper.insertUseGeneratedKeys(authRel); userAuthRelMapper.insertUseGeneratedKeys(authRel);
......
package cn.com.glsx.app.modules.service; package cn.com.glsx.app.modules.service;
import cn.com.glsx.app.common.enums.AuthType; import cn.com.glsx.admin.common.constant.UserConstants;
import cn.com.glsx.app.common.enums.LoginType; import cn.com.glsx.app.common.exception.AppServerException;
import cn.com.glsx.app.modules.entity.UserAuthRel; import cn.com.glsx.app.modules.entity.User;
import cn.com.glsx.app.modules.entity.UserThirdAuth;
import cn.com.glsx.app.modules.mapper.UserAuthRelMapper;
import cn.com.glsx.app.modules.mapper.UserLocalAccountMapper; import cn.com.glsx.app.modules.mapper.UserLocalAccountMapper;
import cn.com.glsx.app.modules.mapper.UserThirdAuthMapper; import cn.com.glsx.app.modules.mapper.UserMapper;
import cn.com.glsx.app.modules.model.AppUser; import cn.com.glsx.app.modules.model.AppUser;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.hutool.core.lang.UUID; import cn.hutool.core.lang.UUID;
import com.glsx.plat.common.utils.ObjectUtils; import com.glsx.plat.common.utils.ObjectUtils;
import com.glsx.plat.jwt.base.ComJwtUser; import com.glsx.plat.jwt.base.ComJwtUser;
...@@ -26,10 +25,7 @@ public class UserService { ...@@ -26,10 +25,7 @@ public class UserService {
private JwtUtils<ComJwtUser> jwtUtils; private JwtUtils<ComJwtUser> jwtUtils;
@Resource @Resource
private UserAuthRelMapper userAuthRelMapper; private UserMapper userMapper;
@Resource
private UserThirdAuthMapper userThirdAuthMapper;
@Resource @Resource
private UserLocalAccountMapper userLocalAccountMapper; private UserLocalAccountMapper userLocalAccountMapper;
...@@ -54,18 +50,33 @@ public class UserService { ...@@ -54,18 +50,33 @@ public class UserService {
return jwtUtils.createToken(userMap); return jwtUtils.createToken(userMap);
} }
public AppUser getAppUserByUserId(Long userId) { public AppUser getLocalUserByUserId(Long userId) {
//获取用户本地信息 //获取C端用户信息
return userLocalAccountMapper.selectAppUserByUserId(userId); return userLocalAccountMapper.selectLocalUserByUserId(userId);
}
public AppUser getRelUserByUserId(Long userId) {
//获取后台用户信息
return userLocalAccountMapper.selectRelUserByUserId(userId);
} }
public AppUser getAppUserByAuthId(LoginType loginType, Long authId) { /**
//获取具体第三方授权 * 获取c端用户id
UserThirdAuth thirdAuth = userThirdAuthMapper.selectByLoginTypeAndAuthId(loginType.getType(), authId); *
//获取第三方授权关联 * @return
UserAuthRel userAuthRel = userAuthRelMapper.selectByAuthTypeAndAuthId(AuthType.THIRD.getType(), thirdAuth.getId()); */
//获取用户本地信息 public Long getCTerminalUserId() {
return this.getAppUserByUserId(userAuthRel.getUserId()); if (UserConstants.RolePermitCastType.wxShared.getCode().equals(ShieldContextHolder.getRolePermissionType())) {
//如果是被分享的账号,直接返回当前用户id
return ShieldContextHolder.getUserId();
} else {
//如果是非被分享的账号,需要转换成c端用户id
User user = userMapper.selectByRelUserId(ShieldContextHolder.getUserId());
if (user == null) {
throw new AppServerException("数据权限错误");
}
return user.getId();
}
} }
} }
...@@ -8,12 +8,12 @@ import cn.com.glsx.app.modules.entity.Device; ...@@ -8,12 +8,12 @@ import cn.com.glsx.app.modules.entity.Device;
import cn.com.glsx.app.modules.entity.VehicleDevice; import cn.com.glsx.app.modules.entity.VehicleDevice;
import cn.com.glsx.app.modules.entity.VehicleDeviceWorkOrder; import cn.com.glsx.app.modules.entity.VehicleDeviceWorkOrder;
import cn.com.glsx.app.modules.mapper.VehicleMapper; import cn.com.glsx.app.modules.mapper.VehicleMapper;
import cn.com.glsx.app.modules.model.VehicleDeviceDTO; import cn.com.glsx.app.modules.model.view.VehicleDeviceDTO;
import cn.com.glsx.app.modules.model.VehicleLocationDTO; import cn.com.glsx.app.modules.model.view.VehicleLocationDTO;
import cn.com.glsx.app.modules.model.param.ResidentSearch; import cn.com.glsx.app.modules.model.param.ResidentSearch;
import cn.com.glsx.app.modules.model.param.TrackPointSearch; import cn.com.glsx.app.modules.model.param.TrackPointSearch;
import cn.com.glsx.app.modules.model.vo.ResidentListVO; import cn.com.glsx.app.modules.model.view.ResidentListVO;
import cn.com.glsx.app.modules.model.vo.TrackPointVO; import cn.com.glsx.app.modules.model.view.TrackPointVO;
import cn.com.glsx.app.modules.remote.RemoteFeignResidentService; import cn.com.glsx.app.modules.remote.RemoteFeignResidentService;
import cn.com.glsx.app.modules.remote.RemoteGpsBsService; import cn.com.glsx.app.modules.remote.RemoteGpsBsService;
import cn.com.glsx.devicemonitor.api.dto.LngLatDTO; import cn.com.glsx.devicemonitor.api.dto.LngLatDTO;
...@@ -81,7 +81,7 @@ public class VehicleMonitorService { ...@@ -81,7 +81,7 @@ public class VehicleMonitorService {
public List<TrackPointVO> getTrackPointList( TrackPointSearch search) { public List<TrackPointVO> getTrackPointList( TrackPointSearch search) {
return null; return Lists.newArrayList(new TrackPointVO());
} }
/**TrackPointRequestDTO /**TrackPointRequestDTO
......
...@@ -32,7 +32,22 @@ ...@@ -32,7 +32,22 @@
and del_flag = 0 and del_flag = 0
</select> </select>
<select id="selectAppUserByUserId" resultType="cn.com.glsx.app.modules.model.AppUser"> <select id="selectLocalUserByUserId" resultType="cn.com.glsx.app.modules.model.AppUser">
select tcu.id as userId,
tcu.id as cuserId,
tcula.account,
tcula2.username,
tcu.blacklist
from t_cust_user_local_auth tcula
inner join t_cust_user_auth_rel tcuar on tcula.id = tcuar.auth_id
left join t_cust_user_local_account tcula2 on tcuar.auth_id = tcula2.auth_id
left join t_cust_user tcu on tcuar.user_id = tcu.id
where tcula.del_flag = 0
and tcuar.auth_type = 'local'
and tcuar.user_id = #{userId} limit 1
</select>
<select id="selectRelUserByUserId" resultType="cn.com.glsx.app.modules.model.AppUser">
select tcu.rel_user_id as userId, select tcu.rel_user_id as userId,
tcu.id as cuserId, tcu.id as cuserId,
tcula.account, tcula.account,
......
...@@ -33,9 +33,18 @@ ...@@ -33,9 +33,18 @@
and del_flag = 0 and del_flag = 0
</select> </select>
<select id="selectByRelUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_cust_user
where rel_user_id = #{relUserId}
and del_flag = 0
limit 1
</select>
<insert id="saveOrUpdate" useGeneratedKeys="true" keyProperty="id" parameterType="cn.com.glsx.app.modules.entity.User"> <insert id="saveOrUpdate" useGeneratedKeys="true" keyProperty="id" parameterType="cn.com.glsx.app.modules.entity.User">
INSERT INTO t_cust_user (id, rel_user_id, blacklist, del_flag, created_date) INSERT INTO t_cust_user (id, rel_user_id, blacklist, del_flag, created_date)
VALUES (#{id}, #{linkerId}, #{blacklist}, 0, sysdate()) ON DUPLICATE KEY VALUES (#{id}, #{relUserId}, #{blacklist}, 0, sysdate()) ON DUPLICATE KEY
UPDATE updated_date = sysdate() UPDATE updated_date = sysdate()
</insert> </insert>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.app.modules.mapper.UserQQAccountMapper"> <mapper namespace="cn.com.glsx.app.modules.mapper.UserSharedDataMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.app.modules.entity.UserQQAccount"> <resultMap id="BaseResultMap" type="cn.com.glsx.app.modules.entity.UserSharedData">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
<id column="id" jdbcType="INTEGER" property="id"/> <id column="id" jdbcType="INTEGER" property="id"/>
<result column="auth_id" jdbcType="INTEGER" property="authId"/> <result column="content_id" jdbcType="INTEGER" property="contentId"/>
<result column="union_id" jdbcType="VARCHAR" property="unionId"/> <result column="content_type" jdbcType="TINYINT" property="contentType"/>
<result column="qq_avatar" jdbcType="VARCHAR" property="avatar"/> <result column="permit_type" jdbcType="VARCHAR" property="permitType"/>
<result column="qq_name" jdbcType="VARCHAR" property="qqName"/> <result column="effective_date" jdbcType="TIMESTAMP" property="effectiveDate"/>
<result column="expiration_date" jdbcType="TIMESTAMP" property="expirationDate"/>
<result column="status" jdbcType="TINYINT" property="status"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/> <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/> <result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/> <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
...@@ -20,15 +22,15 @@ ...@@ -20,15 +22,15 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
id, auth_id, union_id, qq_avatar, qq_name, del_flag, created_date, created_by, updated_date, id, content_id, content_type, permit_type, effective_date, expiration_date, `status`,
updated_by del_flag, created_date, created_by, updated_date, updated_by
</sql> </sql>
<select id="selectByAuthId" resultMap="BaseResultMap"> <select id="selectById" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from t_cust_user_qq_account from t_cust_user_shared_data
where auth_id = #{authId} where del_flag = 0
and del_flag = 0 and id = #{id}
</select> </select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -38,6 +38,18 @@ ...@@ -38,6 +38,18 @@
where tcuta.del_flag = 0 where tcuta.del_flag = 0
and tcuar.auth_type = 'third' and tcuar.auth_type = 'third'
and tcuta.login_type = #{loginType} and tcuta.login_type = #{loginType}
and tcuar.auth_id = #{userId}; and tcuar.auth_id = #{authId}
</select>
<select id="selectByLoginTypeAndUserId" resultMap="BaseResultMap">
select tcuta.*
from t_cust_user_third_auth tcuta,
t_cust_user_auth_rel tcuar
where tcuta.del_flag = 0
and tcuta.id = tcuar.auth_id
and tcuar.auth_type = 'third'
and tcuta.login_type = #{loginType}
and tcuar.user_id = #{userId}
order by tcuta.id desc limit 1
</select> </select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
del_flag, created_date, created_by, updated_date, updated_by del_flag, created_date, created_by, updated_date, updated_by
</sql> </sql>
<select id="search" resultType="cn.com.glsx.app.modules.model.VehicleDeviceDTO"> <select id="search" resultType="cn.com.glsx.app.modules.model.view.VehicleDeviceDTO">
select tvd.id, select tvd.id,
tv.id vid, tv.id vid,
tv.vin, tv.vin,
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.app.modules.mapper.VehicleSharedMapper"> <mapper namespace="cn.com.glsx.app.modules.mapper.VehicleSharedMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.app.modules.entity.VehicleShared"> <resultMap id="BaseResultMap" type="cn.com.glsx.app.modules.entity.VehicleShared">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
<id column="id" jdbcType="INTEGER" property="id" /> <id column="id" jdbcType="INTEGER" property="id"/>
<result column="accorder_id" jdbcType="INTEGER" property="accorderId" /> <result column="shared_id" jdbcType="INTEGER" property="sharedId"/>
<result column="receiver_id" jdbcType="INTEGER" property="receiverId" /> <result column="accorder_id" jdbcType="INTEGER" property="accorderId"/>
<result column="content_id" jdbcType="INTEGER" property="contentId" /> <result column="receiver_id" jdbcType="INTEGER" property="receiverId"/>
<result column="content_type" jdbcType="TINYINT" property="contentType" /> <result column="content_id" jdbcType="INTEGER" property="contentId"/>
<result column="permit_type" jdbcType="VARCHAR" property="permitType" /> <!-- <result column="content_type" jdbcType="TINYINT" property="contentType"/>-->
<result column="effective_date" jdbcType="TIMESTAMP" property="effectiveDate" /> <!-- <result column="permit_type" jdbcType="VARCHAR" property="permitType"/>-->
<result column="expiration_date" jdbcType="TIMESTAMP" property="expirationDate" /> <!-- <result column="effective_date" jdbcType="TIMESTAMP" property="effectiveDate"/>-->
<result column="status" jdbcType="TINYINT" property="status" /> <!-- <result column="expiration_date" jdbcType="TIMESTAMP" property="expirationDate"/>-->
<result column="del_flag" jdbcType="TINYINT" property="delFlag" /> <!-- <result column="status" jdbcType="TINYINT" property="status"/>-->
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate" /> <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy" /> <result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate" /> <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy" /> <result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
</resultMap> <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
<sql id="Base_Column_List"> </resultMap>
<!-- <sql id="Base_Column_List">
WARNING - @mbg.generated <!--
--> WARNING - @mbg.generated
id, accorder_id, receiver_id, content_id, content_type, permit_type, effective_date, -->
expiration_date, `status`, del_flag, created_date, created_by, updated_date, updated_by id, shared_id, accorder_id, receiver_id, content_id, content_type, permit_type, effective_date,
</sql> expiration_date, `status`, del_flag, created_date, created_by, updated_date, updated_by
</sql>
<select id="selectBySharedIdAndReceiverId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_vehicle_shared tvs
where tvs.del_flag = 0
and tvs.shared_id = #{shareId}
and tvs.receiver_id = #{receiverId}
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.app.modules.service;
import cn.com.glsx.app.modules.converter.VehicleMonitorConvert;
import cn.com.glsx.app.modules.model.view.LowPowerVO;
import cn.com.glsx.app.modules.model.view.StatisticalInfoVO;
import cn.com.glsx.app.modules.model.view.VehicleLocationDTO;
import cn.com.glsx.app.modules.model.view.TrackPointVO;
import cn.com.glsx.devicemonitor.api.dto.response.DeviceLocationDTO;
import cn.com.glsx.devicemonitor.api.dto.response.GpsLocation;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists;
import java.util.List;
/**
* @author xiangyanlin
* @date 2022/7/4
*/
class VehicleMonitorServiceTest {
public static void main(String[] args) {
// generateDeviceLocationDTOJSON();
// generateTrackPointVOJSON();
// generateStatisticalInfoVOJSON();
generateLowPowerVOJSON();
}
private static void generateDeviceLocationDTOJSON() {
DeviceLocationDTO deviceLocationDTO = new DeviceLocationDTO();
deviceLocationDTO.setBsLocation(new GpsLocation());
deviceLocationDTO.setGpsLocation(new GpsLocation());
deviceLocationDTO.setWifiLocation(new GpsLocation());
VehicleLocationDTO vehicleLocationDTO = VehicleMonitorConvert.buildVehicleLocationDTO(deviceLocationDTO, null);
List<VehicleLocationDTO> vehicleLocations = Lists.newArrayList(vehicleLocationDTO);
System.out.println(JSON.toJSONString(
R.ok().data(vehicleLocations)
, SerializerFeature.PrettyFormat,
SerializerFeature.WriteMapNullValue));
}
private static void generateTrackPointVOJSON() {
TrackPointVO element = new TrackPointVO();
List<TrackPointVO> list = Lists.newArrayList(element);
System.out.println(JSON.toJSONString(
R.ok().data(list)
, SerializerFeature.PrettyFormat,
SerializerFeature.WriteMapNullValue));
}
private static void generateStatisticalInfoVOJSON() {
StatisticalInfoVO element = new StatisticalInfoVO();
System.out.println(JSON.toJSONString(
R.ok().data(element)
, SerializerFeature.PrettyFormat,
SerializerFeature.WriteMapNullValue));
}
private static void generateLowPowerVOJSON() {
LowPowerVO element = new LowPowerVO();
List<LowPowerVO> list = Lists.newArrayList(element);
System.out.println(JSON.toJSONString(
R.ok().putPageData(element, 1)
, SerializerFeature.PrettyFormat,
SerializerFeature.WriteMapNullValue));
}
}
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!