Browse Source

youhua

master
4670101279 11 months ago
parent
commit
ab1b01ea45
  1. 41
      ruoyi-api/src/main/java/com/ruoyi/api/app/AlarmJobController.java
  2. 40
      ruoyi-api/src/main/java/com/ruoyi/api/domain/XsAlarmEntity.java
  3. 36
      ruoyi-api/src/main/java/com/ruoyi/api/domain/XsAlarmListEntity.java
  4. 34
      ruoyi-api/src/main/java/com/ruoyi/api/domain/XsAlarmUserEntity.java
  5. 13
      ruoyi-api/src/main/java/com/ruoyi/api/mapper/XsAlarmListMapper.java
  6. 13
      ruoyi-api/src/main/java/com/ruoyi/api/mapper/XsAlarmMapper.java
  7. 13
      ruoyi-api/src/main/java/com/ruoyi/api/mapper/XsAlarmUserMapper.java
  8. 17
      ruoyi-api/src/main/java/com/ruoyi/api/params/AlarmJobDataParams.java
  9. 21
      ruoyi-api/src/main/java/com/ruoyi/api/params/AlarmJobParams.java
  10. 13
      ruoyi-api/src/main/java/com/ruoyi/api/params/AlarmJobSendUserParams.java
  11. 65
      ruoyi-api/src/main/java/com/ruoyi/api/service/AlarmJobService.java
  12. 12
      ruoyi-api/src/main/java/com/ruoyi/api/service/XsAlarmListService.java
  13. 12
      ruoyi-api/src/main/java/com/ruoyi/api/service/XsAlarmService.java
  14. 12
      ruoyi-api/src/main/java/com/ruoyi/api/service/XsAlarmUserService.java
  15. 13
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/XsAlarmListServiceImpl.java
  16. 13
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/XsAlarmServiceImpl.java
  17. 13
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/XsAlarmUserServiceImpl.java
  18. 4
      ruoyi-api/src/main/java/com/ruoyi/api/util/HttpRequestUtils.java
  19. 8
      ruoyi-common/src/main/java/com/ruoyi/common/utils/sm3/SM3Utils.java
  20. 8
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

41
ruoyi-api/src/main/java/com/ruoyi/api/app/AlarmJobController.java

@ -0,0 +1,41 @@
package com.ruoyi.api.app;
import com.ruoyi.api.controller.AbstractApiController;
import com.ruoyi.api.params.AlarmJobParams;
import com.ruoyi.api.service.AlarmJobService;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.validator.ValidatorUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* 系统对外接口-检测信息
*/
@RestController
@RequestMapping("/job")
@Slf4j
public class AlarmJobController extends AbstractApiController {
@Resource
private AlarmJobService alarmJobService;
/**
* 报警数据接收
*
* @param params
* @return
*/
@PostMapping("v1/alarm/add")
public R query(@RequestBody AlarmJobParams params) {
log.info("[报警数据接收接口数据为:{}]", params);
ValidatorUtils.validateV2(params);
return alarmJobService.add(params);
}
}

40
ruoyi-api/src/main/java/com/ruoyi/api/domain/XsAlarmEntity.java

@ -0,0 +1,40 @@
package com.ruoyi.api.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 对外接口表
*
*/
@Data
@TableName("xs_alarm")
public class XsAlarmEntity implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
private Long id;
private String name;
private String level;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date alarmTime;
private String longitudeAndLatitude;
private String description;
private Long mainId;
}

36
ruoyi-api/src/main/java/com/ruoyi/api/domain/XsAlarmListEntity.java

@ -0,0 +1,36 @@
package com.ruoyi.api.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 对外接口表
*
*/
@Data
@TableName("xs_alarm_list")
public class XsAlarmListEntity implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
private Long id;
private String sendTitle;
private String sendPhone;
private String sendContent;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date sendEffectiveTime;
}

34
ruoyi-api/src/main/java/com/ruoyi/api/domain/XsAlarmUserEntity.java

@ -0,0 +1,34 @@
package com.ruoyi.api.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 对外接口表
*
*/
@Data
@TableName("xs_alarm_user")
public class XsAlarmUserEntity implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
private Long id;
private String name;
private String sex;
private String phone;
private Long mainId;
}

13
ruoyi-api/src/main/java/com/ruoyi/api/mapper/XsAlarmListMapper.java

@ -0,0 +1,13 @@
package com.ruoyi.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.api.domain.XsAlarmListEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 对外接口表
*
*/
@Mapper
public interface XsAlarmListMapper extends BaseMapper<XsAlarmListEntity> {
}

13
ruoyi-api/src/main/java/com/ruoyi/api/mapper/XsAlarmMapper.java

@ -0,0 +1,13 @@
package com.ruoyi.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.api.domain.XsAlarmEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 对外接口表
*
*/
@Mapper
public interface XsAlarmMapper extends BaseMapper<XsAlarmEntity> {
}

13
ruoyi-api/src/main/java/com/ruoyi/api/mapper/XsAlarmUserMapper.java

@ -0,0 +1,13 @@
package com.ruoyi.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.api.domain.XsAlarmUserEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 对外接口表
*
*/
@Mapper
public interface XsAlarmUserMapper extends BaseMapper<XsAlarmUserEntity> {
}

17
ruoyi-api/src/main/java/com/ruoyi/api/params/AlarmJobDataParams.java

@ -0,0 +1,17 @@
package com.ruoyi.api.params;
import lombok.Data;
@Data
public class AlarmJobDataParams {
private String name;
private String level;
private String alarmTime;
private String longitudeAndLatitude;
private String description;
}

21
ruoyi-api/src/main/java/com/ruoyi/api/params/AlarmJobParams.java

@ -0,0 +1,21 @@
package com.ruoyi.api.params;
import lombok.Data;
import java.util.List;
@Data
public class AlarmJobParams {
private String sendTitle;
private String sendPhone;
private String sendContent;
private String sendEffectiveTime;
private AlarmJobDataParams data;
private List<AlarmJobSendUserParams> sendUser;
}

13
ruoyi-api/src/main/java/com/ruoyi/api/params/AlarmJobSendUserParams.java

@ -0,0 +1,13 @@
package com.ruoyi.api.params;
import lombok.Data;
@Data
public class AlarmJobSendUserParams {
private String name;
private String sex;
private String phone;
}

65
ruoyi-api/src/main/java/com/ruoyi/api/service/AlarmJobService.java

@ -0,0 +1,65 @@
package com.ruoyi.api.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.api.domain.XsAlarmEntity;
import com.ruoyi.api.domain.XsAlarmListEntity;
import com.ruoyi.api.domain.XsAlarmUserEntity;
import com.ruoyi.api.params.AlarmJobDataParams;
import com.ruoyi.api.params.AlarmJobParams;
import com.ruoyi.api.params.AlarmJobSendUserParams;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service
public class AlarmJobService {
@Resource
private XsAlarmListService xsAlarmListService;
@Resource
private XsAlarmUserService xsAlarmUserService;
@Resource
private XsAlarmService xsAlarmService;
public R add(AlarmJobParams params) {
XsAlarmListEntity list = new XsAlarmListEntity();
list.setSendTitle(params.getSendTitle());
list.setSendContent(params.getSendContent());
list.setSendEffectiveTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, params.getSendEffectiveTime()));
xsAlarmListService.save(list);
List<AlarmJobSendUserParams> sendUser = params.getSendUser();
if(!sendUser.isEmpty()){
XsAlarmUserEntity user;
List<XsAlarmUserEntity> userList = new ArrayList<>();
for (AlarmJobSendUserParams u : sendUser) {
user = new XsAlarmUserEntity();
user.setMainId(list.getId());
user.setName(u.getName());
user.setPhone(u.getPhone());
user.setSex(u.getSex());
userList.add(user);
}
xsAlarmUserService.saveBatch(userList);
}
AlarmJobDataParams data = params.getData();
XsAlarmEntity alarm = new XsAlarmEntity();
if(data != null){
alarm.setMainId(list.getId());
alarm.setName(data.getName());
alarm.setAlarmTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, data.getAlarmTime()));
alarm.setDescription(data.getDescription());
alarm.setLongitudeAndLatitude(data.getLongitudeAndLatitude());
alarm.setLevel(data.getLevel());
xsAlarmService.save(alarm);
}
return R.ok();
}
}

12
ruoyi-api/src/main/java/com/ruoyi/api/service/XsAlarmListService.java

@ -0,0 +1,12 @@
package com.ruoyi.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.api.domain.XsAlarmListEntity;
/**
* 对外接口表
*
*/
public interface XsAlarmListService extends IService<XsAlarmListEntity> {
}

12
ruoyi-api/src/main/java/com/ruoyi/api/service/XsAlarmService.java

@ -0,0 +1,12 @@
package com.ruoyi.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.api.domain.XsAlarmEntity;
/**
* 对外接口表
*
*/
public interface XsAlarmService extends IService<XsAlarmEntity> {
}

12
ruoyi-api/src/main/java/com/ruoyi/api/service/XsAlarmUserService.java

@ -0,0 +1,12 @@
package com.ruoyi.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.api.domain.XsAlarmUserEntity;
/**
* 对外接口表
*
*/
public interface XsAlarmUserService extends IService<XsAlarmUserEntity> {
}

13
ruoyi-api/src/main/java/com/ruoyi/api/service/impl/XsAlarmListServiceImpl.java

@ -0,0 +1,13 @@
package com.ruoyi.api.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.api.domain.XsAlarmListEntity;
import com.ruoyi.api.mapper.XsAlarmListMapper;
import com.ruoyi.api.service.XsAlarmListService;
import org.springframework.stereotype.Service;
@Service("xsAlarmListService")
public class XsAlarmListServiceImpl extends ServiceImpl<XsAlarmListMapper, XsAlarmListEntity> implements XsAlarmListService {
}

13
ruoyi-api/src/main/java/com/ruoyi/api/service/impl/XsAlarmServiceImpl.java

@ -0,0 +1,13 @@
package com.ruoyi.api.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.api.domain.XsAlarmEntity;
import com.ruoyi.api.mapper.XsAlarmMapper;
import com.ruoyi.api.service.XsAlarmService;
import org.springframework.stereotype.Service;
@Service("xsAlarmService")
public class XsAlarmServiceImpl extends ServiceImpl<XsAlarmMapper, XsAlarmEntity> implements XsAlarmService {
}

13
ruoyi-api/src/main/java/com/ruoyi/api/service/impl/XsAlarmUserServiceImpl.java

@ -0,0 +1,13 @@
package com.ruoyi.api.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.api.domain.XsAlarmUserEntity;
import com.ruoyi.api.mapper.XsAlarmUserMapper;
import com.ruoyi.api.service.XsAlarmUserService;
import org.springframework.stereotype.Service;
@Service("xsAlarmUserService")
public class XsAlarmUserServiceImpl extends ServiceImpl<XsAlarmUserMapper, XsAlarmUserEntity> implements XsAlarmUserService {
}

4
ruoyi-api/src/main/java/com/ruoyi/api/util/HttpRequestUtils.java

@ -34,7 +34,7 @@ public class HttpRequestUtils {
String jsonRtsp = HttpRequestUtils.sendPost(mediaLiveUrl, String jsonRtsp = HttpRequestUtils.sendPost(mediaLiveUrl,
"", "nb012105", "Fhsw123456", "{\n" + "", "nb012105", "Fhsw123456", "{\n" +
" \"cameraId\": \"33021322031505040301000000581506\",\n" + " \"cameraId\": \"33021322031505040301000000581502\",\n" +
" \"streamType\": 1,\n" + " \"streamType\": 1,\n" +
" \"urlType\": 1,\n" + " \"urlType\": 1,\n" +
" \"agentType\": 1\n" + " \"agentType\": 1\n" +
@ -52,6 +52,8 @@ public class HttpRequestUtils {
System.out.println(jsonRtsp); System.out.println(jsonRtsp);
JSONObject object = JSON.parseObject(jsonRtsp); JSONObject object = JSON.parseObject(jsonRtsp);
System.out.println(object.getString("url")); System.out.println(object.getString("url"));
System.out.println("ws://localhost:8866/live?url="+object.getString("url"));
System.out.println("let rtspUrl =\""+object.getString("url")+"\";");
} }

8
ruoyi-common/src/main/java/com/ruoyi/common/utils/sm3/SM3Utils.java

@ -7,13 +7,15 @@ import java.io.IOException;
public class SM3Utils { public class SM3Utils {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
String plainText = "test" + "qawsedrftg" + "1656492199425"; Long time = System.currentTimeMillis();
System.out.println(time);
String plainText = "xsdxyj" + "qsfe2efavweh" + time;
System.out.println(encode(plainText)); System.out.println(encode(plainText));
} }
public static String encode(String plainText) { public static String encode(String str) {
byte[] md = new byte[32]; byte[] md = new byte[32];
byte[] msg1 = plainText.getBytes(); byte[] msg1 = str.getBytes();
SM3Digest sm3 = new SM3Digest(); SM3Digest sm3 = new SM3Digest();
sm3.update(msg1, 0, msg1.length); sm3.update(msg1, 0, msg1.length);
sm3.doFinal(md, 0); sm3.doFinal(md, 0);

8
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@ -97,7 +97,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求 // 过滤请求
.authorizeRequests() .authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage").anonymous() .antMatchers("/login", "/register", "/captchaImage", "/api").anonymous()
.antMatchers( .antMatchers(
HttpMethod.GET, HttpMethod.GET,
"/", "/",
@ -111,8 +111,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/swagger-resources/**").anonymous() .antMatchers("/swagger-resources/**").anonymous()
.antMatchers("/webjars/**").anonymous() .antMatchers("/webjars/**").anonymous()
.antMatchers("/*/api-docs").anonymous() .antMatchers("/*/api-docs").anonymous()
.antMatchers("/druid/**").anonymous() .antMatchers("/job/**").anonymous()
// .antMatchers("/api/**").anonymous() // .antMatchers("/druid/**").anonymous()
.antMatchers("/api/camera/heart").anonymous()
.antMatchers("/api/getPicJson").anonymous()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()

Loading…
Cancel
Save