Merge remote-tracking branch 'origin/master' into dev
commit
12c919ee67
@ -0,0 +1,76 @@
|
|||||||
|
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.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.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
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(@RequestBody @Validated OpenTerminalAndTimeVo vo) {
|
||||||
|
ServiceBody<TerminalPhotoListForOpenModel> serviceBody = terminalPhotoService.getPhotoListForOpen(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 = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, 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 +1 @@
|
|||||||
org.springframework.boot.env.EnvironmentPostProcessor=com.shxy.xymanager_framework.config.MyEnvironmentPostProcessor
|
#org.springframework.boot.env.EnvironmentPostProcessor=com.shxy.xymanager_framework.config.MyEnvironmentPostProcessor
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.shxy.xymanager_common.entity;
|
package com.shxy.xymanager_common.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.shxy.xymanager_common.util;
|
||||||
|
|
||||||
|
import com.shxy.xymanager_common.constant.Constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跟Cma通信的工具类
|
||||||
|
*/
|
||||||
|
public class CmaUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手动拍照
|
||||||
|
* @param cmdid
|
||||||
|
* @param channel
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String takePic(String cmdid, Integer channel, Integer type) {
|
||||||
|
String cmd = Constants.CMD + "capture --cmdid=" + cmdid + " --channel=" + channel + " --preset=255 --type=" + type;
|
||||||
|
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.shxy.xymanager_common.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "线路杆塔查询", description = "线路杆塔查询")
|
||||||
|
public class LineAndGtVo {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "查询类型", example = "1--线路 2--杆塔")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "编号", example = "123455")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.shxy.xymanager_common.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "装置编号对象", description = "装置编号对象")
|
||||||
|
public class OpenCmdidVo {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "装置编号", example = "123455")
|
||||||
|
private String deviceID;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "sessionID", example = "123455")
|
||||||
|
private String sessionID;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.shxy.xymanager_common.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "用户登录参数", description = "用户登录参数描述")
|
||||||
|
public class OpenDeviceCaptureVo {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "装置编号", example = "123455")
|
||||||
|
private String deviceID;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "sessionID", example = "123455")
|
||||||
|
private String sessionID;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "操作", example = "1--拍照 2--拍视频")
|
||||||
|
private Integer operateType;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.shxy.xymanager_common.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "用户登录参数", description = "用户登录参数描述")
|
||||||
|
public class UserLoginVo {
|
||||||
|
|
||||||
|
@NotNull(message = "用户名")
|
||||||
|
@ApiModelProperty(value = "用户名", example = "123455")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@NotNull(message = "密码")
|
||||||
|
@ApiModelProperty(value = "密码", example = "123455")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.shxy.xymanager_dao.dao;
|
||||||
|
|
||||||
|
import com.shxy.xymanager_common.entity.SysUser;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
public interface SysUserDao {
|
||||||
|
|
||||||
|
SysUser selectByPrimaryKey(Integer uid);
|
||||||
|
|
||||||
|
SysUser selectByUserName(@Param("username") String username);
|
||||||
|
|
||||||
|
int deleteByPrimaryKey(Integer uid);
|
||||||
|
|
||||||
|
int insert(SysUser record);
|
||||||
|
|
||||||
|
int insertSelective(SysUser record);
|
||||||
|
|
||||||
|
|
||||||
|
int updateByPrimaryKeySelective(SysUser record);
|
||||||
|
|
||||||
|
int updateByPrimaryKey(SysUser record);
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
<?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.SysUserDao">
|
||||||
|
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.SysUser">
|
||||||
|
<id column="uid" jdbcType="INTEGER" property="uid"/>
|
||||||
|
<result column="user_name" jdbcType="VARCHAR" property="userName"/>
|
||||||
|
<result column="status" jdbcType="INTEGER" property="status"/>
|
||||||
|
<result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
|
||||||
|
<result column="password" jdbcType="VARCHAR" property="password"/>
|
||||||
|
<result column="role" jdbcType="INTEGER" property="role"/>
|
||||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
uid, user_name, status, nick_name, password, role, create_time, update_time
|
||||||
|
</sql>
|
||||||
|
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from sys_user
|
||||||
|
where uid = #{uid,jdbcType=INTEGER}
|
||||||
|
</select>
|
||||||
|
<select id="selectByUserName" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from sys_user
|
||||||
|
where user_name = #{username}
|
||||||
|
</select>
|
||||||
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||||
|
delete from sys_user
|
||||||
|
where uid = #{uid,jdbcType=INTEGER}
|
||||||
|
</delete>
|
||||||
|
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.SysUser">
|
||||||
|
insert into sys_user (uid, user_name, status,
|
||||||
|
nick_name, password, role,
|
||||||
|
create_time, update_time)
|
||||||
|
values (#{uid,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
|
||||||
|
#{nickName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{role,jdbcType=INTEGER},
|
||||||
|
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
|
||||||
|
</insert>
|
||||||
|
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.SysUser">
|
||||||
|
insert into sys_user
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="uid != null">
|
||||||
|
uid,
|
||||||
|
</if>
|
||||||
|
<if test="userName != null">
|
||||||
|
user_name,
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
status,
|
||||||
|
</if>
|
||||||
|
<if test="nickName != null">
|
||||||
|
nick_name,
|
||||||
|
</if>
|
||||||
|
<if test="password != null">
|
||||||
|
password,
|
||||||
|
</if>
|
||||||
|
<if test="role != null">
|
||||||
|
role,
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
create_time,
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
update_time,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="uid != null">
|
||||||
|
#{uid,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
|
<if test="userName != null">
|
||||||
|
#{userName,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
#{status,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
|
<if test="nickName != null">
|
||||||
|
#{nickName,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="password != null">
|
||||||
|
#{password,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="role != null">
|
||||||
|
#{role,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
#{createTime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
#{updateTime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<update id="updateByPrimaryKeySelective" parameterType="com.shxy.xymanager_common.entity.SysUser">
|
||||||
|
update sys_user
|
||||||
|
<set>
|
||||||
|
<if test="userName != null">
|
||||||
|
user_name = #{userName,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
status = #{status,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
|
<if test="nickName != null">
|
||||||
|
nick_name = #{nickName,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="password != null">
|
||||||
|
password = #{password,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="role != null">
|
||||||
|
role = #{role,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where uid = #{uid,jdbcType=INTEGER}
|
||||||
|
</update>
|
||||||
|
<update id="updateByPrimaryKey" parameterType="com.shxy.xymanager_common.entity.SysUser">
|
||||||
|
update sys_user
|
||||||
|
set user_name = #{userName,jdbcType=VARCHAR},
|
||||||
|
status = #{status,jdbcType=INTEGER},
|
||||||
|
nick_name = #{nickName,jdbcType=VARCHAR},
|
||||||
|
password = #{password,jdbcType=VARCHAR},
|
||||||
|
role = #{role,jdbcType=INTEGER},
|
||||||
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||||
|
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||||
|
where uid = #{uid,jdbcType=INTEGER}
|
||||||
|
</update>
|
||||||
|
</mapper>
|
@ -0,0 +1,226 @@
|
|||||||
|
package com.shxy.xymanager_service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUnit;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.crypto.SecureUtil;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.shxy.xymanager_common.constant.UuidUtils;
|
||||||
|
import com.shxy.xymanager_common.dto.TerminalsWithHeart;
|
||||||
|
import com.shxy.xymanager_common.entity.SysUser;
|
||||||
|
import com.shxy.xymanager_common.entity.SysUserSession;
|
||||||
|
import com.shxy.xymanager_common.entity.Terminals;
|
||||||
|
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.ProcessExecUtils;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第三方对外接口
|
||||||
|
*/
|
||||||
|
@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 BigInteger time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录鉴权
|
||||||
|
*
|
||||||
|
* @param vo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public JSONObject cmaUserLogin(UserLoginVo vo) {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
String username = vo.getUsername();
|
||||||
|
SysUser sysUser = sysUserDao.selectByUserName(username);
|
||||||
|
// 判断用户是否存在
|
||||||
|
if (BeanUtil.isEmpty(sysUser)) {
|
||||||
|
jsonObject.putOpt("errcode", 1);
|
||||||
|
jsonObject.putOpt("errmsg", "用户不存在");
|
||||||
|
}
|
||||||
|
// 判断密码是否存在
|
||||||
|
String password = vo.getPassword();
|
||||||
|
if (BeanUtil.isEmpty(password)) {
|
||||||
|
jsonObject.putOpt("errcode", 2);
|
||||||
|
jsonObject.putOpt("errmsg", "密码错误");
|
||||||
|
}
|
||||||
|
String userPassword = SecureUtil.md5(password);
|
||||||
|
// 密码对比
|
||||||
|
if (!sysUser.getPassword().equals(userPassword)) {
|
||||||
|
jsonObject.putOpt("errcode", 2);
|
||||||
|
jsonObject.putOpt("errmsg", "密码错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
Date date = new Date();
|
||||||
|
String sessionId = UuidUtils.getUUID();
|
||||||
|
SysUserSession sysUserSession = new SysUserSession();
|
||||||
|
sysUserSession.setUserName(username);
|
||||||
|
sysUserSession.setRole(sysUser.getRole());
|
||||||
|
sysUserSession.setSessionId(sessionId);
|
||||||
|
BigInteger expiretime = MyDateUtils.TimeMillSecond2Second(MyDateUtils.offsetMinute(date, 30));
|
||||||
|
sysUserSession.setExpireTime(expiretime);
|
||||||
|
sysUserMapperDao.insertOrUpdate(sysUserSession, date, date);
|
||||||
|
jsonObject.set("errcode", 0);
|
||||||
|
jsonObject.set("errmsg", "OK");
|
||||||
|
jsonObject.set("sessionid", sessionId);
|
||||||
|
jsonObject.set("keepingtime", 30);
|
||||||
|
|
||||||
|
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();
|
||||||
|
BigInteger currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime());
|
||||||
|
if (currentTime.subtract(expireTime).compareTo(time) > 0) {
|
||||||
|
jsonObject.set("errcode", 1);
|
||||||
|
jsonObject.set("errmsg", "invalid session");
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Terminals terminals = terminalsDao.selectByCmdid(deviceID, CommonStatus.EFFECTIVE.value());
|
||||||
|
if (BeanUtil.isEmpty(terminals)) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
String cmd1 = CmaUtil.takePic(vo.getDeviceID(), 1, operateType);
|
||||||
|
ProcessExecUtils.exec(cmd1);
|
||||||
|
String cmd2 = CmaUtil.takePic(vo.getDeviceID(), 2, operateType);
|
||||||
|
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();
|
||||||
|
BigInteger currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime());
|
||||||
|
if (currentTime.subtract(expireTime).compareTo(time) > 0) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
Long lastheartbeat = terminalsWithHeart.getLastheartbeat();
|
||||||
|
BigInteger time = MyDateUtils.TimeSecond2MillSecond(lastheartbeat);
|
||||||
|
DateTime date = MyDateUtils.date(time.longValue());
|
||||||
|
long between = MyDateUtils.between(MyDateUtils.getNowDate(), date, DateUnit.MINUTE);
|
||||||
|
if (between > 30) {
|
||||||
|
jsonObject.set("isonline", false);
|
||||||
|
jsonObject.set("errcode", 0);
|
||||||
|
jsonObject.set("errmsg", "ok");
|
||||||
|
} else {
|
||||||
|
jsonObject.set("isonline", true);
|
||||||
|
jsonObject.set("errcode", 0);
|
||||||
|
jsonObject.set("errmsg", "ok");
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +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);
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue