登录接口修改
parent
033b316c69
commit
8e373ae329
@ -1,80 +1,80 @@
|
||||
package com.shxy.xymanager_admin.controller;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.shxy.xymanager_common.annotation.Log;
|
||||
import com.shxy.xymanager_common.base.BaseController;
|
||||
import com.shxy.xymanager_common.base.ResponseReult;
|
||||
import com.shxy.xymanager_common.bean.ServiceBody;
|
||||
import com.shxy.xymanager_common.bean.ServiceStatus;
|
||||
import com.shxy.xymanager_common.model.*;
|
||||
import com.shxy.xymanager_common.util.xinyin.HeaderUtil;
|
||||
import com.shxy.xymanager_common.vo.*;
|
||||
import com.shxy.xymanager_service.service.OpenService;
|
||||
import com.shxy.xymanager_service.service.TerminalPhotoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@Api(value = "精益化平台接口", tags = "精益化平台相关")
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class OpenController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
TerminalPhotoService terminalPhotoService;
|
||||
|
||||
@Autowired
|
||||
OpenService openService;
|
||||
|
||||
|
||||
@ApiOperation(value = "对外图片查询", notes = "对外图片查询", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
||||
@RequestMapping("/getPhotoListForOpen")
|
||||
@Log(title = "对外图片查询", type = "查询")
|
||||
public ResponseReult<TerminalPhotoListForOpenModel> getPhotoListForOpen(@RequestHeader HttpHeaders headers, @RequestBody @Validated OpenTerminalAndTimeVo vo) {
|
||||
String requestIp = HeaderUtil.getRequestIp(headers);
|
||||
ServiceBody<TerminalPhotoListForOpenModel> serviceBody = terminalPhotoService.getPhotoListForOpen(requestIp,vo);
|
||||
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
|
||||
return ResponseReult.success(serviceBody.getData());
|
||||
} else {
|
||||
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "第三方登录认证接口", notes = "第三方登录认证接口", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 0, message = "请求成功"), @ApiResponse(code = 1, message = "用户名错误"), @ApiResponse(code = 2, message = "密码错误")})
|
||||
@RequestMapping("/cmaUserLogin")
|
||||
@Log(title = "第三方登录认证接口", type = "查询")
|
||||
public JSONObject cmaUserLogin(@RequestBody @Validated UserLoginVo vo) {
|
||||
JSONObject serviceBody = openService.cmaUserLogin(vo);
|
||||
return serviceBody;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "远程拍照(短视频)控制", notes = "远程拍照(短视频)控制接口", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 0, message = "请求成功"), @ApiResponse(code = 1, message = "用户名错误"), @ApiResponse(code = 2, message = "密码错误")})
|
||||
@RequestMapping("/ctrlCmaDeviceCapture")
|
||||
@Log(title = "远程拍照(短视频)控制", type = "查询")
|
||||
public JSONObject ctrlCmaDeviceCapture(@RequestBody @Validated OpenDeviceCaptureVo vo) {
|
||||
JSONObject serviceBody = openService.ctrlCmaDeviceCapture(vo);
|
||||
return serviceBody;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询装置状态", notes = "查询装置状态接口", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 0, message = "请求成功"), @ApiResponse(code = 1, message = "用户名错误"), @ApiResponse(code = 2, message = "密码错误")})
|
||||
@RequestMapping("/cmaDeviceStatus")
|
||||
@Log(title = "查询装置状态接口", type = "查询")
|
||||
public JSONObject cmaDeviceStatus(@RequestBody @Validated OpenCmdidVo vo) {
|
||||
JSONObject serviceBody = openService.cmaDeviceStatus(vo);
|
||||
return serviceBody;
|
||||
}
|
||||
}
|
||||
//package com.shxy.xymanager_admin.controller;
|
||||
//
|
||||
//import cn.hutool.json.JSONObject;
|
||||
//import com.shxy.xymanager_common.annotation.Log;
|
||||
//import com.shxy.xymanager_common.base.BaseController;
|
||||
//import com.shxy.xymanager_common.base.ResponseReult;
|
||||
//import com.shxy.xymanager_common.bean.ServiceBody;
|
||||
//import com.shxy.xymanager_common.bean.ServiceStatus;
|
||||
//import com.shxy.xymanager_common.model.*;
|
||||
//import com.shxy.xymanager_common.util.xinyin.HeaderUtil;
|
||||
//import com.shxy.xymanager_common.vo.*;
|
||||
//import com.shxy.xymanager_service.service.OpenService;
|
||||
//import com.shxy.xymanager_service.service.TerminalPhotoService;
|
||||
//import io.swagger.annotations.Api;
|
||||
//import io.swagger.annotations.ApiOperation;
|
||||
//import io.swagger.annotations.ApiResponse;
|
||||
//import io.swagger.annotations.ApiResponses;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.http.HttpHeaders;
|
||||
//import org.springframework.validation.annotation.Validated;
|
||||
//import org.springframework.web.bind.annotation.RequestBody;
|
||||
//import org.springframework.web.bind.annotation.RequestHeader;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//
|
||||
//@Api(value = "精益化平台接口", tags = "精益化平台相关")
|
||||
//@RestController
|
||||
//@Slf4j
|
||||
//public class OpenController extends BaseController {
|
||||
//
|
||||
// @Autowired
|
||||
// TerminalPhotoService terminalPhotoService;
|
||||
//
|
||||
// @Autowired
|
||||
// OpenService openService;
|
||||
//
|
||||
//
|
||||
// @ApiOperation(value = "对外图片查询", notes = "对外图片查询", httpMethod = "POST")
|
||||
// @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
||||
// @RequestMapping("/getPhotoListForOpen")
|
||||
// @Log(title = "对外图片查询", type = "查询")
|
||||
// public ResponseReult<TerminalPhotoListForOpenModel> getPhotoListForOpen(@RequestHeader HttpHeaders headers, @RequestBody @Validated OpenTerminalAndTimeVo vo) {
|
||||
// String requestIp = HeaderUtil.getRequestIp(headers);
|
||||
// ServiceBody<TerminalPhotoListForOpenModel> serviceBody = terminalPhotoService.getPhotoListForOpen(requestIp,vo);
|
||||
// if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
|
||||
// return ResponseReult.success(serviceBody.getData());
|
||||
// } else {
|
||||
// return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @ApiOperation(value = "第三方登录认证接口", notes = "第三方登录认证接口", httpMethod = "POST")
|
||||
// @ApiResponses({@ApiResponse(code = 0, message = "请求成功"), @ApiResponse(code = 1, message = "用户名错误"), @ApiResponse(code = 2, message = "密码错误")})
|
||||
// @RequestMapping("/cmaUserLogin")
|
||||
// @Log(title = "第三方登录认证接口", type = "查询")
|
||||
// public JSONObject cmaUserLogin(@RequestBody @Validated UserLoginVo vo) {
|
||||
// JSONObject serviceBody = openService.cmaUserLogin(vo);
|
||||
// return serviceBody;
|
||||
// }
|
||||
//
|
||||
// @ApiOperation(value = "远程拍照(短视频)控制", notes = "远程拍照(短视频)控制接口", httpMethod = "POST")
|
||||
// @ApiResponses({@ApiResponse(code = 0, message = "请求成功"), @ApiResponse(code = 1, message = "用户名错误"), @ApiResponse(code = 2, message = "密码错误")})
|
||||
// @RequestMapping("/ctrlCmaDeviceCapture")
|
||||
// @Log(title = "远程拍照(短视频)控制", type = "查询")
|
||||
// public JSONObject ctrlCmaDeviceCapture(@RequestBody @Validated OpenDeviceCaptureVo vo) {
|
||||
// JSONObject serviceBody = openService.ctrlCmaDeviceCapture(vo);
|
||||
// return serviceBody;
|
||||
// }
|
||||
//
|
||||
// @ApiOperation(value = "查询装置状态", notes = "查询装置状态接口", httpMethod = "POST")
|
||||
// @ApiResponses({@ApiResponse(code = 0, message = "请求成功"), @ApiResponse(code = 1, message = "用户名错误"), @ApiResponse(code = 2, message = "密码错误")})
|
||||
// @RequestMapping("/cmaDeviceStatus")
|
||||
// @Log(title = "查询装置状态接口", type = "查询")
|
||||
// public JSONObject cmaDeviceStatus(@RequestBody @Validated OpenCmdidVo vo) {
|
||||
// JSONObject serviceBody = openService.cmaDeviceStatus(vo);
|
||||
// return serviceBody;
|
||||
// }
|
||||
//}
|
||||
|
@ -1,29 +0,0 @@
|
||||
package com.shxy.xymanager_common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class SysUserSession implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
private String sessionId;
|
||||
|
||||
private String token;
|
||||
|
||||
private String userName;
|
||||
|
||||
private Integer role;
|
||||
|
||||
private BigInteger expireTime;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
<?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">
|
||||
<mapper namespace="com.shxy.xymanager_dao.dao.SysUserMapperDao">
|
||||
<resultMap id="SysUserResult" type="com.shxy.xymanager_common.bean.SysUser">
|
||||
<id column="uid" property="userId"/>
|
||||
<result column="name" property="userName"/>
|
||||
<result column="password" property="password"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="role" property="role"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.SysUserSession">
|
||||
<id column="id" jdbcType="INTEGER" property="id"/>
|
||||
<result column="session_id" jdbcType="VARCHAR" property="sessionId"/>
|
||||
<result column="user_name" jdbcType="INTEGER" property="userName"/>
|
||||
<result column="role" jdbcType="INTEGER" property="role"/>
|
||||
<result column="expire_time" jdbcType="VARCHAR" property="expireTime"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectUserVo">
|
||||
SELECT
|
||||
uid,
|
||||
user_name,
|
||||
`status`
|
||||
FROM
|
||||
sys_users u
|
||||
</sql>
|
||||
|
||||
<select id="selectByPrimaryKey" resultMap="SysUserResult">
|
||||
select
|
||||
*
|
||||
from sys_users
|
||||
where uid = #{uid}
|
||||
</select>
|
||||
|
||||
<select id="selectByUserAccount" resultMap="SysUserResult">
|
||||
SELECT * FROM sys_users WHERE user_name = #{userName} and status = 1
|
||||
</select>
|
||||
|
||||
<select id="selectPages" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
WHERE status = '0'
|
||||
<if test="params.userName != null and params.userName != ''">
|
||||
AND user_name like concat('%', #{params.userName}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_name = #{userName}
|
||||
</select>
|
||||
|
||||
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectBySessionId" resultMap="BaseResultMap">
|
||||
select
|
||||
id ,
|
||||
session_id,
|
||||
user_name,
|
||||
role,
|
||||
expire_time
|
||||
FROM
|
||||
sys_user_session u
|
||||
where session_id = #{sessionid}
|
||||
</select>
|
||||
|
||||
<insert id="addUser" parameterType="com.shxy.xymanager_common.bean.SysUser">
|
||||
insert into sys_users(user_name,nick_name,password,role,create_time)
|
||||
values(#{userName},#{userName},#{password},#{role},#{createTime})
|
||||
</insert>
|
||||
|
||||
<select id="selectUserBySessionId" resultType="com.shxy.xymanager_common.entity.SysUserSession">
|
||||
select
|
||||
session_id as sessionId,
|
||||
user_name as userName,
|
||||
role,
|
||||
expire_time as expireTime
|
||||
from sys_user_session
|
||||
where session_id = #{sessionId}
|
||||
</select>
|
||||
|
||||
<update id="updateUserSession" parameterType="com.shxy.xymanager_common.entity.SysUserSession">
|
||||
update `sys_user_session`
|
||||
<set>
|
||||
<if test="expireTime!= null">
|
||||
expire_time = #{expireTime},
|
||||
</if>
|
||||
</set>
|
||||
where session_id = #{sessionId}
|
||||
</update>
|
||||
|
||||
<update id="updateById" parameterType="com.shxy.xymanager_common.bean.SysUser">
|
||||
update `sys_users`
|
||||
<set>
|
||||
<if test="userName!= null">
|
||||
user_name = #{userName},
|
||||
</if>
|
||||
<if test="nickName!= null">
|
||||
nick_name = #{nickName},
|
||||
</if>
|
||||
<if test="password!= null">
|
||||
password = #{password},
|
||||
</if>
|
||||
<if test="role!= null">
|
||||
role = #{role},
|
||||
</if>
|
||||
<if test="status!= null">
|
||||
status = #{status},
|
||||
</if>
|
||||
</set>
|
||||
where uid = #{userId}
|
||||
</update>
|
||||
|
||||
<update id="deleteUserById" parameterType="java.lang.String">
|
||||
update `sys_users`
|
||||
set status = 0
|
||||
where uid = #{userId}
|
||||
</update>
|
||||
|
||||
<insert id="insertUserSession" parameterType="com.shxy.xymanager_common.entity.SysUserSession">
|
||||
insert into sys_user_session (session_id, user_name,role,expire_time)
|
||||
values (#{sessionId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, #{role,jdbcType=VARCHAR}, #{expireTime,jdbcType=INTEGER})
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="selectUserInfoList" resultType="com.shxy.xymanager_common.bean.SysUser">
|
||||
select
|
||||
uid as userId,
|
||||
user_name as userName,
|
||||
nick_name as nickName,
|
||||
create_time as createTime,
|
||||
role
|
||||
from sys_users
|
||||
WHERE status = #{status} and role != 0 and role != 3
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<insert id="insertOrUpdate">
|
||||
insert into sys_user_session (session_id,user_name,role,expire_time,create_time,update_time)
|
||||
values (#{item.sessionId} ,#{item.userName}, #{item.role},#{item.expireTime},#{createat},#{updateat})
|
||||
ON DUPLICATE KEY UPDATE
|
||||
user_name = values(user_name),
|
||||
role = values(role),
|
||||
session_id = values (session_id),
|
||||
expire_time = values (expire_time)
|
||||
</insert>
|
||||
|
||||
|
||||
</mapper>
|
@ -1,240 +1,231 @@
|
||||
package com.shxy.xymanager_service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.shxy.xymanager_common.constant.Constants;
|
||||
import com.shxy.xymanager_common.constant.UuidUtils;
|
||||
import com.shxy.xymanager_common.dto.TerminalsWithHeart;
|
||||
import com.shxy.xymanager_common.entity.*;
|
||||
import com.shxy.xymanager_common.enums.CommonStatus;
|
||||
import com.shxy.xymanager_common.util.CmaUtil;
|
||||
import com.shxy.xymanager_common.util.MyDateUtils;
|
||||
import com.shxy.xymanager_common.util.xinyin.ProcessExecUtils;
|
||||
import com.shxy.xymanager_common.util.xinyin.TerminalUtils;
|
||||
import com.shxy.xymanager_common.vo.OpenCmdidVo;
|
||||
import com.shxy.xymanager_common.vo.OpenDeviceCaptureVo;
|
||||
import com.shxy.xymanager_common.vo.UserLoginVo;
|
||||
import com.shxy.xymanager_dao.dao.SysUserDao;
|
||||
import com.shxy.xymanager_dao.dao.SysUserMapperDao;
|
||||
import com.shxy.xymanager_dao.dao.TerminalStatusDao;
|
||||
import com.shxy.xymanager_dao.dao.TerminalsDao;
|
||||
import com.shxy.xymanager_service.service.OpenService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 第三方对外接口
|
||||
*/
|
||||
@Service
|
||||
@Component
|
||||
@Slf4j
|
||||
public class OpenServiceImpl implements OpenService {
|
||||
@Autowired
|
||||
private SysUserMapperDao sysUserMapperDao;
|
||||
|
||||
@Autowired
|
||||
private SysUserDao sysUserDao;
|
||||
|
||||
@Autowired
|
||||
private TerminalsDao terminalsDao;
|
||||
|
||||
@Autowired
|
||||
private TerminalStatusDao terminalStatusDao;
|
||||
|
||||
|
||||
@Value("${session.open_expire_time}")
|
||||
public Integer time;
|
||||
|
||||
/**
|
||||
* 登录鉴权
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JSONObject cmaUserLogin(UserLoginVo vo) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String username = vo.getUserName();
|
||||
String userPassword = vo.getPassWord();
|
||||
|
||||
SysUserExample example = new SysUserExample();
|
||||
example.createCriteria().andUserNameEqualTo(username);
|
||||
List<SysUser> sysUsers = sysUserDao.selectByExample(example);
|
||||
// 判断用户是否存在
|
||||
if (CollectionUtil.isEmpty(sysUsers)) {
|
||||
jsonObject.putOpt("errcode", 1);
|
||||
jsonObject.putOpt("errmsg", "用户不存在");
|
||||
return jsonObject;
|
||||
}
|
||||
// 判断密码是否存在
|
||||
String password = vo.getPassWord();
|
||||
if (BeanUtil.isEmpty(password)) {
|
||||
jsonObject.putOpt("errcode", 2);
|
||||
jsonObject.putOpt("errmsg", "密码错误");
|
||||
return jsonObject;
|
||||
}
|
||||
SysUser sysUser = sysUsers.get(0);
|
||||
// 密码对比
|
||||
if (!sysUser.getPassword().equals(userPassword)) {
|
||||
jsonObject.putOpt("errcode", 2);
|
||||
jsonObject.putOpt("errmsg", "密码错误");
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
Date date = new Date();
|
||||
String sessionId = UuidUtils.getUUID();
|
||||
SysUserSession sysUserSession = new SysUserSession();
|
||||
sysUserSession.setUserName(username);
|
||||
sysUserSession.setRole(sysUser.getRole());
|
||||
sysUserSession.setSessionId(sessionId);
|
||||
long expiretime = MyDateUtils.TimeMillSecond2Second(MyDateUtils.offsetMinute(date, time));
|
||||
sysUserSession.setExpireTime(BigInteger.valueOf(expiretime));
|
||||
sysUserMapperDao.insertOrUpdate(sysUserSession, date, date);
|
||||
jsonObject.set("errcode", 0);
|
||||
jsonObject.set("errmsg", "OK");
|
||||
jsonObject.set("sessionid", sessionId);
|
||||
jsonObject.set("keepingtime", time);
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制拍照视频
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JSONObject ctrlCmaDeviceCapture(OpenDeviceCaptureVo vo) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String sessionID = vo.getSessionID();
|
||||
String deviceID = vo.getDeviceID();
|
||||
Integer operateType = vo.getOperateType();
|
||||
if (StrUtil.isEmpty(sessionID)) {
|
||||
jsonObject.set("errcode", 1);
|
||||
jsonObject.set("errmsg", "invalid session");
|
||||
return jsonObject;
|
||||
}
|
||||
if (StrUtil.isEmpty(deviceID)) {
|
||||
jsonObject.set("errcode", 2);
|
||||
jsonObject.set("errmsg", "device not register");
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
SysUserSession sysUserSession = sysUserMapperDao.selectBySessionId(sessionID);
|
||||
if (BeanUtil.isEmpty(sysUserSession)) {
|
||||
jsonObject.set("errcode", 1);
|
||||
jsonObject.set("errmsg", "invalid session");
|
||||
return jsonObject;
|
||||
} else {
|
||||
BigInteger expireTime = sysUserSession.getExpireTime();
|
||||
long currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime());
|
||||
if ((currentTime - expireTime.longValue()) > time.longValue()) {
|
||||
jsonObject.set("errcode", 1);
|
||||
jsonObject.set("errmsg", "invalid session");
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
||||
TerminalsExample example = new TerminalsExample();
|
||||
example.createCriteria().andCmdidEqualTo(deviceID);
|
||||
List<Terminals> list = terminalsDao.selectByExample(example);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
jsonObject.set("errcode", 2);
|
||||
jsonObject.set("errmsg", "device not register");
|
||||
return jsonObject;
|
||||
}
|
||||
// Terminals terminals = terminalsDao.selectByCmdid(deviceID, CommonStatus.EFFECTIVE.value());
|
||||
// if (BeanUtil.isEmpty(terminals)) {
|
||||
//package com.shxy.xymanager_service.impl;
|
||||
//
|
||||
//import cn.hutool.core.bean.BeanUtil;
|
||||
//import cn.hutool.core.collection.CollectionUtil;
|
||||
//import cn.hutool.core.date.DateTime;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import cn.hutool.json.JSONObject;
|
||||
//import com.shxy.xymanager_common.constant.Constants;
|
||||
//import com.shxy.xymanager_common.constant.UuidUtils;
|
||||
//import com.shxy.xymanager_common.dto.TerminalsWithHeart;
|
||||
//import com.shxy.xymanager_common.entity.*;
|
||||
//import com.shxy.xymanager_common.util.CmaUtil;
|
||||
//import com.shxy.xymanager_common.util.MyDateUtils;
|
||||
//import com.shxy.xymanager_common.util.xinyin.ProcessExecUtils;
|
||||
//import com.shxy.xymanager_common.util.xinyin.TerminalUtils;
|
||||
//import com.shxy.xymanager_common.vo.OpenCmdidVo;
|
||||
//import com.shxy.xymanager_common.vo.OpenDeviceCaptureVo;
|
||||
//import com.shxy.xymanager_common.vo.UserLoginVo;
|
||||
//import com.shxy.xymanager_dao.dao.SysUserDao;
|
||||
//import com.shxy.xymanager_dao.dao.TerminalStatusDao;
|
||||
//import com.shxy.xymanager_dao.dao.TerminalsDao;
|
||||
//import com.shxy.xymanager_service.service.OpenService;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import java.math.BigInteger;
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * 第三方对外接口
|
||||
// */
|
||||
//@Service
|
||||
//@Component
|
||||
//@Slf4j
|
||||
//public class OpenServiceImpl implements OpenService {
|
||||
// @Autowired
|
||||
// private SysUserMapperDao sysUserMapperDao;
|
||||
//
|
||||
// @Autowired
|
||||
// private SysUserDao sysUserDao;
|
||||
//
|
||||
// @Autowired
|
||||
// private TerminalsDao terminalsDao;
|
||||
//
|
||||
// @Autowired
|
||||
// private TerminalStatusDao terminalStatusDao;
|
||||
//
|
||||
//
|
||||
// @Value("${session.open_expire_time}")
|
||||
// public Integer time;
|
||||
//
|
||||
// /**
|
||||
// * 登录鉴权
|
||||
// *
|
||||
// * @param vo
|
||||
// * @return
|
||||
// */
|
||||
// @Override
|
||||
// public JSONObject cmaUserLogin(UserLoginVo vo) {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// String username = vo.getUserName();
|
||||
// String userPassword = vo.getPassWord();
|
||||
//
|
||||
// SysUserExample example = new SysUserExample();
|
||||
// example.createCriteria().andUserNameEqualTo(username);
|
||||
// List<SysUser> sysUsers = sysUserDao.selectByExample(example);
|
||||
// // 判断用户是否存在
|
||||
// if (CollectionUtil.isEmpty(sysUsers)) {
|
||||
// jsonObject.putOpt("errcode", 1);
|
||||
// jsonObject.putOpt("errmsg", "用户不存在");
|
||||
// return jsonObject;
|
||||
// }
|
||||
// // 判断密码是否存在
|
||||
// String password = vo.getPassWord();
|
||||
// if (BeanUtil.isEmpty(password)) {
|
||||
// jsonObject.putOpt("errcode", 2);
|
||||
// jsonObject.putOpt("errmsg", "密码错误");
|
||||
// return jsonObject;
|
||||
// }
|
||||
// SysUser sysUser = sysUsers.get(0);
|
||||
// // 密码对比
|
||||
// if (!sysUser.getPassword().equals(userPassword)) {
|
||||
// jsonObject.putOpt("errcode", 2);
|
||||
// jsonObject.putOpt("errmsg", "密码错误");
|
||||
// return jsonObject;
|
||||
// }
|
||||
//
|
||||
// Date date = new Date();
|
||||
// String sessionId = UuidUtils.getUUID();
|
||||
// SysUserSession sysUserSession = new SysUserSession();
|
||||
// sysUserSession.setUserName(username);
|
||||
// sysUserSession.setRole(sysUser.getRole());
|
||||
// sysUserSession.setSessionId(sessionId);
|
||||
// long expiretime = MyDateUtils.TimeMillSecond2Second(MyDateUtils.offsetMinute(date, time));
|
||||
// sysUserSession.setExpireTime(BigInteger.valueOf(expiretime));
|
||||
// sysUserDao.insertOrUpdate(sysUserSession, date, date);
|
||||
// jsonObject.set("errcode", 0);
|
||||
// jsonObject.set("errmsg", "OK");
|
||||
// jsonObject.set("sessionid", sessionId);
|
||||
// jsonObject.set("keepingtime", time);
|
||||
//
|
||||
// return jsonObject;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 控制拍照视频
|
||||
// *
|
||||
// * @param vo
|
||||
// * @return
|
||||
// */
|
||||
// @Override
|
||||
// public JSONObject ctrlCmaDeviceCapture(OpenDeviceCaptureVo vo) {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// String sessionID = vo.getSessionID();
|
||||
// String deviceID = vo.getDeviceID();
|
||||
// Integer operateType = vo.getOperateType();
|
||||
// if (StrUtil.isEmpty(sessionID)) {
|
||||
// jsonObject.set("errcode", 1);
|
||||
// jsonObject.set("errmsg", "invalid session");
|
||||
// return jsonObject;
|
||||
// }
|
||||
// if (StrUtil.isEmpty(deviceID)) {
|
||||
// jsonObject.set("errcode", 2);
|
||||
// jsonObject.set("errmsg", "device not register");
|
||||
// return jsonObject;
|
||||
// }
|
||||
|
||||
if (operateType == 1) {
|
||||
operateType = 0;
|
||||
} else if (operateType == 2) {
|
||||
operateType = 1;
|
||||
} else {
|
||||
jsonObject.set("errcode", 3);
|
||||
jsonObject.set("errmsg", "invalid protocol");
|
||||
return jsonObject;
|
||||
}
|
||||
int requestId = Constants.REQUEST_ID.addAndGet(1);
|
||||
String cmd1 = CmaUtil.takePic(vo.getDeviceID(), 1,255, operateType, requestId);
|
||||
ProcessExecUtils.exec(cmd1);
|
||||
int requestId2 = Constants.REQUEST_ID.addAndGet(1);
|
||||
String cmd2 = CmaUtil.takePic(vo.getDeviceID(), 2,255, operateType,requestId2);
|
||||
ProcessExecUtils.exec(cmd2);
|
||||
jsonObject.set("errcode", 0);
|
||||
jsonObject.set("errmsg", "OK");
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备在线状态
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JSONObject cmaDeviceStatus(OpenCmdidVo vo) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String sessionID = vo.getSessionID();
|
||||
String deviceID = vo.getDeviceID();
|
||||
if (StrUtil.isEmpty(sessionID)) {
|
||||
jsonObject.set("errcode", 1);
|
||||
jsonObject.set("errmsg", "invalid session");
|
||||
return jsonObject;
|
||||
}
|
||||
SysUserSession sysUserSession = sysUserMapperDao.selectBySessionId(sessionID);
|
||||
if (BeanUtil.isEmpty(sysUserSession)) {
|
||||
jsonObject.set("errcode", 1);
|
||||
jsonObject.set("errmsg", "invalid session");
|
||||
return jsonObject;
|
||||
} else {
|
||||
BigInteger expireTime = sysUserSession.getExpireTime();
|
||||
long currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime());
|
||||
if ((currentTime - expireTime.longValue()) > time.longValue()) {
|
||||
jsonObject.set("errcode", 1);
|
||||
jsonObject.set("errmsg", "invalid session");
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
if (StrUtil.isEmpty(deviceID)) {
|
||||
jsonObject.set("errcode", 2);
|
||||
jsonObject.set("errmsg", "device not register");
|
||||
return jsonObject;
|
||||
}
|
||||
TerminalsWithHeart terminalsWithHeart = terminalStatusDao.selectByCmdId(deviceID);
|
||||
if (BeanUtil.isEmpty(terminalsWithHeart)) {
|
||||
jsonObject.set("errcode", 2);
|
||||
jsonObject.set("errmsg", "device not register");
|
||||
return jsonObject;
|
||||
}
|
||||
BigInteger lastheartbeat = terminalsWithHeart.getLastheartbeat();
|
||||
boolean b = TerminalUtils.judgeTerminalStatus(lastheartbeat);
|
||||
if (b) {
|
||||
jsonObject.set("isonline", true);
|
||||
jsonObject.set("errcode", 0);
|
||||
jsonObject.set("errmsg", "ok");
|
||||
} else {
|
||||
jsonObject.set("isonline", false);
|
||||
jsonObject.set("errcode", 0);
|
||||
jsonObject.set("errmsg", "ok");
|
||||
}
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
//
|
||||
// SysUserSession sysUserSession = sysUserMapperDao.selectBySessionId(sessionID);
|
||||
// if (BeanUtil.isEmpty(sysUserSession)) {
|
||||
// jsonObject.set("errcode", 1);
|
||||
// jsonObject.set("errmsg", "invalid session");
|
||||
// return jsonObject;
|
||||
// } else {
|
||||
// BigInteger expireTime = sysUserSession.getExpireTime();
|
||||
// long currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime());
|
||||
// if ((currentTime - expireTime.longValue()) > time.longValue()) {
|
||||
// jsonObject.set("errcode", 1);
|
||||
// jsonObject.set("errmsg", "invalid session");
|
||||
// return jsonObject;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// TerminalsExample example = new TerminalsExample();
|
||||
// example.createCriteria().andCmdidEqualTo(deviceID);
|
||||
// List<Terminals> list = terminalsDao.selectByExample(example);
|
||||
// if (CollectionUtil.isEmpty(list)) {
|
||||
// jsonObject.set("errcode", 2);
|
||||
// jsonObject.set("errmsg", "device not register");
|
||||
// return jsonObject;
|
||||
// }
|
||||
// if (operateType == 1) {
|
||||
// operateType = 0;
|
||||
// } else if (operateType == 2) {
|
||||
// operateType = 1;
|
||||
// } else {
|
||||
// jsonObject.set("errcode", 3);
|
||||
// jsonObject.set("errmsg", "invalid protocol");
|
||||
// return jsonObject;
|
||||
// }
|
||||
// int requestId = Constants.REQUEST_ID.addAndGet(1);
|
||||
// String cmd1 = CmaUtil.takePic(vo.getDeviceID(), 1,255, operateType, requestId);
|
||||
// ProcessExecUtils.exec(cmd1);
|
||||
// int requestId2 = Constants.REQUEST_ID.addAndGet(1);
|
||||
// String cmd2 = CmaUtil.takePic(vo.getDeviceID(), 2,255, operateType,requestId2);
|
||||
// ProcessExecUtils.exec(cmd2);
|
||||
// jsonObject.set("errcode", 0);
|
||||
// jsonObject.set("errmsg", "OK");
|
||||
//
|
||||
// return jsonObject;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询设备在线状态
|
||||
// *
|
||||
// * @param vo
|
||||
// * @return
|
||||
// */
|
||||
// @Override
|
||||
// public JSONObject cmaDeviceStatus(OpenCmdidVo vo) {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// String sessionID = vo.getSessionID();
|
||||
// String deviceID = vo.getDeviceID();
|
||||
// if (StrUtil.isEmpty(sessionID)) {
|
||||
// jsonObject.set("errcode", 1);
|
||||
// jsonObject.set("errmsg", "invalid session");
|
||||
// return jsonObject;
|
||||
// }
|
||||
// SysUserSession sysUserSession = sysUserMapperDao.selectBySessionId(sessionID);
|
||||
// if (BeanUtil.isEmpty(sysUserSession)) {
|
||||
// jsonObject.set("errcode", 1);
|
||||
// jsonObject.set("errmsg", "invalid session");
|
||||
// return jsonObject;
|
||||
// } else {
|
||||
// BigInteger expireTime = sysUserSession.getExpireTime();
|
||||
// long currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime());
|
||||
// if ((currentTime - expireTime.longValue()) > time.longValue()) {
|
||||
// jsonObject.set("errcode", 1);
|
||||
// jsonObject.set("errmsg", "invalid session");
|
||||
// return jsonObject;
|
||||
// }
|
||||
// }
|
||||
// if (StrUtil.isEmpty(deviceID)) {
|
||||
// jsonObject.set("errcode", 2);
|
||||
// jsonObject.set("errmsg", "device not register");
|
||||
// return jsonObject;
|
||||
// }
|
||||
// TerminalsWithHeart terminalsWithHeart = terminalStatusDao.selectByCmdId(deviceID);
|
||||
// if (BeanUtil.isEmpty(terminalsWithHeart)) {
|
||||
// jsonObject.set("errcode", 2);
|
||||
// jsonObject.set("errmsg", "device not register");
|
||||
// return jsonObject;
|
||||
// }
|
||||
// BigInteger lastheartbeat = terminalsWithHeart.getLastheartbeat();
|
||||
// boolean b = TerminalUtils.judgeTerminalStatus(lastheartbeat);
|
||||
// if (b) {
|
||||
// jsonObject.set("isonline", true);
|
||||
// jsonObject.set("errcode", 0);
|
||||
// jsonObject.set("errmsg", "ok");
|
||||
// } else {
|
||||
// jsonObject.set("isonline", false);
|
||||
// jsonObject.set("errcode", 0);
|
||||
// jsonObject.set("errmsg", "ok");
|
||||
// }
|
||||
//
|
||||
// return jsonObject;
|
||||
// }
|
||||
//}
|
||||
|
@ -1,22 +1,22 @@
|
||||
package com.shxy.xymanager_service.service;
|
||||
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.shxy.xymanager_common.vo.OpenCmdidVo;
|
||||
import com.shxy.xymanager_common.vo.OpenDeviceCaptureVo;
|
||||
import com.shxy.xymanager_common.vo.UserLoginVo;
|
||||
|
||||
/**
|
||||
* 第三方接口
|
||||
*
|
||||
* @author 晶晶
|
||||
*/
|
||||
public interface OpenService {
|
||||
|
||||
JSONObject cmaUserLogin(UserLoginVo vo);
|
||||
|
||||
JSONObject ctrlCmaDeviceCapture(OpenDeviceCaptureVo vo);
|
||||
|
||||
JSONObject cmaDeviceStatus(OpenCmdidVo vo);
|
||||
|
||||
}
|
||||
//package com.shxy.xymanager_service.service;
|
||||
//
|
||||
//
|
||||
//import cn.hutool.json.JSONObject;
|
||||
//import com.shxy.xymanager_common.vo.OpenCmdidVo;
|
||||
//import com.shxy.xymanager_common.vo.OpenDeviceCaptureVo;
|
||||
//import com.shxy.xymanager_common.vo.UserLoginVo;
|
||||
//
|
||||
///**
|
||||
// * 第三方接口
|
||||
// *
|
||||
// * @author 晶晶
|
||||
// */
|
||||
//public interface OpenService {
|
||||
//
|
||||
// JSONObject cmaUserLogin(UserLoginVo vo);
|
||||
//
|
||||
// JSONObject ctrlCmaDeviceCapture(OpenDeviceCaptureVo vo);
|
||||
//
|
||||
// JSONObject cmaDeviceStatus(OpenCmdidVo vo);
|
||||
//
|
||||
//}
|
||||
|
Loading…
Reference in New Issue