4670101279
11 months ago
20 changed files with 394 additions and 7 deletions
@ -0,0 +1,41 @@
@@ -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); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,40 @@
@@ -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; |
||||
|
||||
} |
@ -0,0 +1,36 @@
@@ -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; |
||||
|
||||
} |
@ -0,0 +1,34 @@
@@ -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; |
||||
|
||||
} |
@ -0,0 +1,13 @@
@@ -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> { |
||||
} |
@ -0,0 +1,13 @@
@@ -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> { |
||||
} |
@ -0,0 +1,13 @@
@@ -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> { |
||||
} |
@ -0,0 +1,17 @@
@@ -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; |
||||
} |
@ -0,0 +1,21 @@
@@ -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; |
||||
} |
@ -0,0 +1,13 @@
@@ -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; |
||||
} |
@ -0,0 +1,65 @@
@@ -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(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,12 @@
@@ -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> { |
||||
} |
||||
|
@ -0,0 +1,12 @@
@@ -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> { |
||||
} |
||||
|
@ -0,0 +1,12 @@
@@ -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> { |
||||
} |
||||
|
@ -0,0 +1,13 @@
@@ -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 { |
||||
|
||||
} |
@ -0,0 +1,13 @@
@@ -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 { |
||||
|
||||
} |
@ -0,0 +1,13 @@
@@ -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 { |
||||
|
||||
} |
Loading…
Reference in new issue