ito测试问题修复,app预警内容推送
This commit is contained in:
parent
4efbea7893
commit
e95b3d35ff
|
|
@ -0,0 +1,46 @@
|
|||
package com.bonus.sgzb.common.core.constant;
|
||||
|
||||
public class RoleConstans {
|
||||
|
||||
private RoleConstans() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员
|
||||
*/
|
||||
public static final String STRING_ADMIN = "admin";
|
||||
/**
|
||||
* 机具设备分公司--机具库管员
|
||||
*/
|
||||
public static final String STRING_JJFGS = "jjfgs";
|
||||
/**
|
||||
* 机具设备分公司--班长
|
||||
*/
|
||||
public static final String STRING_JJBZ = "jjbz";
|
||||
/**
|
||||
* 副班长
|
||||
*/
|
||||
public static final String STRING_FBZ = "fbz";
|
||||
/**
|
||||
*机具设备分公司--机具经理/书记
|
||||
*/
|
||||
public static final String STRING_EM01 = "em01";
|
||||
/**
|
||||
* 机具设备分公司--机具副经理
|
||||
*/
|
||||
public static final String STRING_EM02 = "em02";
|
||||
/**
|
||||
* 机具设备分公司--安全员
|
||||
*/
|
||||
public static final String STRING_EM03 = "em03";
|
||||
/**
|
||||
* 调试分公司--调试经理
|
||||
*/
|
||||
public static final String STRING_DM01 = "dm01";
|
||||
|
||||
/**
|
||||
* 调试分公司--调试库管员
|
||||
*/
|
||||
public static final String STRING_DM05 = "dm05";
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 工机具类型管理 数据层
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Mapper
|
||||
|
|
@ -84,4 +84,6 @@ public interface MaTypeMapper {
|
|||
int deletePropSetByTypeId(Long typeId);
|
||||
|
||||
int updateTypeNum(MaMachine maMachine);
|
||||
|
||||
List<MaTypeKeeper> selectMaTypeByUserId(Long userId);
|
||||
}
|
||||
|
|
@ -3,10 +3,7 @@ package com.bonus.sgzb.material.controller;
|
|||
import com.bonus.sgzb.common.core.web.controller.BaseController;
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.sgzb.material.domain.IotDto;
|
||||
import com.bonus.sgzb.material.domain.IotLocationVo;
|
||||
import com.bonus.sgzb.material.domain.IotRecordVo;
|
||||
import com.bonus.sgzb.material.domain.IotVo;
|
||||
import com.bonus.sgzb.material.domain.*;
|
||||
import com.bonus.sgzb.material.service.IotMachineService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -162,29 +159,50 @@ public class IotMachineController extends BaseController {
|
|||
|
||||
@ApiOperation("获取定位")
|
||||
@PostMapping("/getLocation")
|
||||
public AjaxResult getLocation(@Validated @RequestBody IotDto iotDto) {
|
||||
log.info("获取定位接口:{}", iotDto);
|
||||
return iotMachineService.getLocation(iotDto);
|
||||
public AjaxResult getLocation(@Validated @RequestBody IotLocationVo iotLocationVo) {
|
||||
log.info("获取定位接口:{}", iotLocationVo);
|
||||
return AjaxResult.success(iotMachineService.getLocation(iotLocationVo));
|
||||
}
|
||||
|
||||
@ApiOperation("查询行程")
|
||||
@PostMapping("/searchItinerary")
|
||||
public AjaxResult searchItinerary(@Validated @RequestBody IotLocationVo iotLocationVo) {
|
||||
log.info("查询行程接口:{}", iotLocationVo);
|
||||
return iotMachineService.searchItinerary(iotLocationVo);
|
||||
return AjaxResult.success(iotMachineService.searchItinerary(iotLocationVo));
|
||||
}
|
||||
|
||||
@ApiOperation("查询停留点")
|
||||
@PostMapping("/reportParkDetailByTime")
|
||||
public AjaxResult reportParkDetailByTime(@Validated @RequestBody IotLocationVo iotLocationVo) {
|
||||
log.info("查询停留点接口:{}", iotLocationVo);
|
||||
return iotMachineService.reportParkDetailByTime(iotLocationVo);
|
||||
return AjaxResult.success(iotMachineService.reportParkDetailByTime(iotLocationVo));
|
||||
}
|
||||
|
||||
@ApiOperation("报警记录")
|
||||
@PostMapping("/reportAlarm")
|
||||
public AjaxResult reportAlarm(@Validated @RequestBody IotLocationVo iotLocationVo) {
|
||||
log.info("报警记录接口:{}", iotLocationVo);
|
||||
return iotMachineService.reportAlarm(iotLocationVo);
|
||||
return AjaxResult.success(iotMachineService.reportAlarm(iotLocationVo));
|
||||
}
|
||||
|
||||
@ApiOperation("报警推送")
|
||||
@GetMapping("/alarmPush")
|
||||
public AjaxResult alarmPush() {
|
||||
log.info("报警推送:=======");
|
||||
return AjaxResult.success(iotMachineService.alarmPush());
|
||||
}
|
||||
|
||||
@ApiOperation("报警列表")
|
||||
@PostMapping("/alarmList")
|
||||
public AjaxResult alarmList(@Validated @RequestBody IotLocationVo iotLocationVo) {
|
||||
log.info("报警列表:=======");
|
||||
return AjaxResult.success(iotMachineService.alarmList(iotLocationVo));
|
||||
}
|
||||
|
||||
@ApiOperation("报警处置")
|
||||
@PostMapping("/alarmManagement")
|
||||
public AjaxResult alarmManagement(@Validated @RequestBody ReportAlarm reportAlarm) {
|
||||
log.info("报警处置:=======");
|
||||
return AjaxResult.success(iotMachineService.alarmManagement(reportAlarm));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ public class IotLocationVo {
|
|||
|
||||
/** iot设备ID */
|
||||
@ApiModelProperty(value = "iot设备ID")
|
||||
private Long iotId;
|
||||
private String iotId;
|
||||
|
||||
/** 经度 */
|
||||
@ApiModelProperty(value = "经度")
|
||||
|
|
@ -40,4 +40,10 @@ public class IotLocationVo {
|
|||
/** 报警内容 */
|
||||
@ApiModelProperty(value = "报警内容")
|
||||
private String startAlarm;
|
||||
|
||||
/**
|
||||
* 记录的uuid 唯一确定这一条记录
|
||||
*/
|
||||
@ApiModelProperty(value = "记录的uuid 唯一确定这一条记录")
|
||||
private String deviceAlarmId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
package com.bonus.sgzb.material.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class ReportAlarm {
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/** iot设备编码 */
|
||||
@ApiModelProperty(value = "iot设备编码")
|
||||
private String iotCode;
|
||||
|
||||
/**
|
||||
* 记录的uuid 唯一确定这一条记录
|
||||
*/
|
||||
private String deviceAlarmId;
|
||||
|
||||
/** 报警时间 */
|
||||
@ApiModelProperty(value = "报警时间")
|
||||
private Date startAlarmTime;
|
||||
|
||||
/** 报警内容 */
|
||||
@ApiModelProperty(value = "报警内容")
|
||||
private String startAlarm;
|
||||
|
||||
/** 是否推送 0:否,1:是 */
|
||||
@ApiModelProperty(value = "是否推送 0:否,1:是")
|
||||
private Integer whetherPush;
|
||||
|
||||
/** 是否核实 0:否,1:是 */
|
||||
@ApiModelProperty(value = "是否核实 0:否,1:是")
|
||||
private String whetherVerify;
|
||||
|
||||
/** 核实人 */
|
||||
@ApiModelProperty(value = "核实人")
|
||||
private Long StringBy;
|
||||
|
||||
/** 核实时间 */
|
||||
@ApiModelProperty(value = "核实时间")
|
||||
private Date verifyTime;
|
||||
}
|
||||
|
|
@ -117,4 +117,6 @@ public interface IotMachineMapper {
|
|||
* @return
|
||||
*/
|
||||
List<IotRecordVo> getRecordList(IotDto iotDto);
|
||||
|
||||
List<IotVo> selectListByTypeId(Long typeId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.bonus.sgzb.material.mapper;
|
||||
|
||||
import com.bonus.sgzb.material.domain.IotLocationVo;
|
||||
import com.bonus.sgzb.material.domain.ReportAlarm;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ReportAlarmMapper {
|
||||
|
||||
int add(ReportAlarm reportAlarm);
|
||||
|
||||
|
||||
int deleteById(Long id);
|
||||
|
||||
|
||||
int update(ReportAlarm reportAlarm);
|
||||
|
||||
|
||||
ReportAlarm selectByDeviceAlarmId(@Param("DeviceAlarmId") String DeviceAlarmId);
|
||||
|
||||
List<ReportAlarm> selectByIotCode(IotLocationVo iotLocationVo);
|
||||
}
|
||||
|
|
@ -1,10 +1,7 @@
|
|||
package com.bonus.sgzb.material.service;
|
||||
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.sgzb.material.domain.IotDto;
|
||||
import com.bonus.sgzb.material.domain.IotLocationVo;
|
||||
import com.bonus.sgzb.material.domain.IotRecordVo;
|
||||
import com.bonus.sgzb.material.domain.IotVo;
|
||||
import com.bonus.sgzb.material.domain.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -83,21 +80,21 @@ public interface IotMachineService {
|
|||
* @param iotDto
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getLocation(IotDto iotDto);
|
||||
IotLocationVo getLocation(IotLocationVo iotLocationVo);
|
||||
|
||||
/**
|
||||
* 查询行程
|
||||
* @param iotLocationVo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult searchItinerary(IotLocationVo iotLocationVo);
|
||||
String searchItinerary(IotLocationVo iotLocationVo);
|
||||
|
||||
/**
|
||||
* 查询停留点
|
||||
* @param iotLocationVo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult reportParkDetailByTime(IotLocationVo iotLocationVo);
|
||||
List<IotLocationVo> reportParkDetailByTime(IotLocationVo iotLocationVo);
|
||||
|
||||
/**
|
||||
* App绑定设备
|
||||
|
|
@ -111,5 +108,16 @@ public interface IotMachineService {
|
|||
* @param iotLocationVo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult reportAlarm(IotLocationVo iotLocationVo);
|
||||
List<IotLocationVo> reportAlarm(IotLocationVo iotLocationVo);
|
||||
|
||||
/**
|
||||
* 报警推送
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
int alarmPush();
|
||||
|
||||
List<ReportAlarm> alarmList(IotLocationVo iotLocationVo);
|
||||
|
||||
int alarmManagement(ReportAlarm reportAlarm);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,13 @@ package com.bonus.sgzb.material.service.impl;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.bonus.sgzb.base.domain.MaTypeKeeper;
|
||||
import com.bonus.sgzb.base.mapper.MaTypeMapper;
|
||||
import com.bonus.sgzb.common.core.constant.HttpStatus;
|
||||
import com.bonus.sgzb.common.core.constant.RoleConstans;
|
||||
import com.bonus.sgzb.common.core.constant.TokenConstants;
|
||||
import com.bonus.sgzb.common.core.exception.ServiceException;
|
||||
import com.bonus.sgzb.common.core.utils.DateUtils;
|
||||
import com.bonus.sgzb.common.core.utils.HttpHelper;
|
||||
import com.bonus.sgzb.common.core.utils.StringHelper;
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -15,17 +19,20 @@ import com.bonus.sgzb.material.config.ExceptionEnum;
|
|||
import com.bonus.sgzb.material.config.FieldGenerator;
|
||||
import com.bonus.sgzb.material.domain.*;
|
||||
import com.bonus.sgzb.material.mapper.IotMachineMapper;
|
||||
import com.bonus.sgzb.material.mapper.ReportAlarmMapper;
|
||||
import com.bonus.sgzb.material.service.IotMachineService;
|
||||
import com.bonus.sgzb.system.api.domain.SysUser;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
|
|
@ -42,6 +49,12 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@Resource
|
||||
private MaTypeMapper maTypeMapper;
|
||||
|
||||
@Resource
|
||||
private ReportAlarmMapper reportAlarmMapper;
|
||||
|
||||
/**
|
||||
* 添加设备-保存
|
||||
*
|
||||
|
|
@ -108,14 +121,14 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
iotDto.setUpdateBy(SecurityUtils.getLoginUser().getUserid().toString());
|
||||
try {
|
||||
//设备修改
|
||||
int res = iotMachineMapper.update(iotDto);
|
||||
if (res == 0) {
|
||||
// 如果修改失败,返回修改到数据库异常的错误信息
|
||||
throw new ServiceException(ExceptionEnum.UPDATE_TO_DATABASE.getMsg());
|
||||
} else {
|
||||
// 修改成功,返回成功的消息和修改的记录数
|
||||
return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), res);
|
||||
}
|
||||
int res = iotMachineMapper.update(iotDto);
|
||||
if (res == 0) {
|
||||
// 如果修改失败,返回修改到数据库异常的错误信息
|
||||
throw new ServiceException(ExceptionEnum.UPDATE_TO_DATABASE.getMsg());
|
||||
} else {
|
||||
// 修改成功,返回成功的消息和修改的记录数
|
||||
return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error updating to database: " + e.getMessage());
|
||||
//捕获异常
|
||||
|
|
@ -281,13 +294,13 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
|
||||
/**
|
||||
* 获取定位
|
||||
* @param iotDto
|
||||
* @param iotLocationVo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getLocation(IotDto iotDto) {
|
||||
log.info("getLocation:{}", iotDto);
|
||||
if (iotDto == null || iotDto.getIotId() == null) {
|
||||
public IotLocationVo getLocation(IotLocationVo iotLocationVo) {
|
||||
log.info("getLocation:{}", iotLocationVo);
|
||||
if (iotLocationVo == null || iotLocationVo.getIotId() == null) {
|
||||
throw new ServiceException(ExceptionEnum.PARAM_NULL.getMsg());
|
||||
}
|
||||
List<String> list=new ArrayList<>();
|
||||
|
|
@ -300,14 +313,14 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
redisService.setCacheObject(TokenConstants.TOKEN_LOCATION,redisCode,23L, TimeUnit.HOURS);
|
||||
}
|
||||
map.clear();
|
||||
list.add(iotDto.getIotId().toString());
|
||||
list.add(iotLocationVo.getIotId());
|
||||
map.put("deviceids",list);
|
||||
String param = JSON.toJSONString(map);
|
||||
String res = HttpHelper.doPost(HttpStatus.LAST_POSITION_URL+redisCode,param);
|
||||
//对返回的结果进行解析
|
||||
IotLocationVo iotLocationVo = resultDataHandler(res);
|
||||
log.info("返回结果resultDataHandler:{}", iotLocationVo);
|
||||
return AjaxResult.success(iotLocationVo);
|
||||
IotLocationVo iotLocationVoRes = resultDataHandler(res);
|
||||
log.info("返回结果resultDataHandler:{}", iotLocationVoRes);
|
||||
return iotLocationVoRes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -316,7 +329,7 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult searchItinerary(IotLocationVo iotLocationVo) {
|
||||
public String searchItinerary(IotLocationVo iotLocationVo) {
|
||||
log.info("searchItinerary:{}", iotLocationVo);
|
||||
if (iotLocationVo == null || iotLocationVo.getBeginTime() == null || iotLocationVo.getEndTime() == null) {
|
||||
throw new ServiceException(ExceptionEnum.PARAM_NULL.getMsg());
|
||||
|
|
@ -335,7 +348,7 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
map.put("endtime",iotLocationVo.getEndTime());
|
||||
String param = JSON.toJSONString(map);
|
||||
String res = HttpHelper.doPost(HttpStatus.QUERY_TRIPS_URL+redisCode,param);
|
||||
return AjaxResult.success(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -344,7 +357,7 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult reportParkDetailByTime(IotLocationVo iotLocationVo) {
|
||||
public List<IotLocationVo> reportParkDetailByTime(IotLocationVo iotLocationVo) {
|
||||
|
||||
log.info("reportParkDetailByTime:{}", iotLocationVo);
|
||||
if (iotLocationVo == null || iotLocationVo.getBeginTime() == null || iotLocationVo.getEndTime() == null) {
|
||||
|
|
@ -366,8 +379,8 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
String res = HttpHelper.doPost(HttpStatus.REPORT_PARK_DETAIL_BY_TIME_URL+redisCode,param);
|
||||
//对返回的结果进行解析
|
||||
List<IotLocationVo> iotLocationVoList = resultReportParkDetailByTime(res);
|
||||
log.info("resultDataHandler:{}", iotLocationVo);
|
||||
return AjaxResult.success(iotLocationVoList);
|
||||
log.info("resultReportParkDetailByTime:{}", iotLocationVoList);
|
||||
return iotLocationVoList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -447,7 +460,7 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult reportAlarm(IotLocationVo iotLocationVo) {
|
||||
public List<IotLocationVo> reportAlarm(IotLocationVo iotLocationVo) {
|
||||
log.info("reportAlarm:{}", iotLocationVo);
|
||||
if (iotLocationVo == null || iotLocationVo.getIotId() == null || iotLocationVo.getBeginTime() == null || iotLocationVo.getEndTime() == null) {
|
||||
throw new ServiceException(ExceptionEnum.PARAM_NULL.getMsg());
|
||||
|
|
@ -463,7 +476,7 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
redisService.setCacheObject(TokenConstants.TOKEN_LOCATION,redisCode,23L, TimeUnit.HOURS);
|
||||
}
|
||||
map.clear();
|
||||
list.add(iotLocationVo.getIotId().toString());
|
||||
list.add(iotLocationVo.getIotId());
|
||||
map.put("devices",list);
|
||||
map.put("startday",iotLocationVo.getBeginTime());
|
||||
map.put("endday",iotLocationVo.getEndTime());
|
||||
|
|
@ -474,9 +487,87 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
//对返回的结果进行解析
|
||||
List<IotLocationVo> iotLocationVoList = resultReportAlarm(res);
|
||||
log.info("resultDataHandler:{}", iotLocationVo);
|
||||
return AjaxResult.success(iotLocationVoList);
|
||||
return iotLocationVoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 报警推送
|
||||
* @param
|
||||
* @return
|
||||
* 每三个小时执行一次(3 * 60 * 60 * 1000 毫秒 = 10800000 毫秒)
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Scheduled(fixedRate = 10800000)
|
||||
public int alarmPush() {
|
||||
log.info("开始获取报警信息====");
|
||||
//获取当前登录用户的所有信息
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
//查看当前用户名下有哪些类型的设备
|
||||
List<MaTypeKeeper> maTypeKeeperList = maTypeMapper.selectMaTypeByUserId(userId);
|
||||
List<IotLocationVo> iotLocationVoAll = new ArrayList<>();
|
||||
for (int i = 0; i < maTypeKeeperList.size(); i++) {
|
||||
//查询该类机具有哪些设备绑定的iot设备
|
||||
List<IotVo> iotVoList = iotMachineMapper.selectListByTypeId(maTypeKeeperList.get(i).getTypeId());
|
||||
for (IotVo iotVo:iotVoList) {
|
||||
IotLocationVo iotLocationVo = new IotLocationVo();
|
||||
iotLocationVo.setIotId(iotVo.getIotCode());
|
||||
iotLocationVo.setBeginTime(DateUtils.getDate());
|
||||
iotLocationVo.setEndTime(DateUtils.getDate());
|
||||
//获取当前设备的报警信息
|
||||
List<IotLocationVo> iotLocationVoList = reportAlarm(iotLocationVo);
|
||||
//保存所有的报警信息
|
||||
iotLocationVoAll.addAll(iotLocationVoList);
|
||||
}
|
||||
}
|
||||
int count = handlingAlarmInformation(iotLocationVoAll);
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReportAlarm> alarmList(IotLocationVo iotLocationVo) {
|
||||
log.info("alarmList:{}", iotLocationVo);
|
||||
return reportAlarmMapper.selectByIotCode(iotLocationVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int alarmManagement(ReportAlarm reportAlarm) {
|
||||
log.info("alarmManagement:{}", reportAlarm);
|
||||
return reportAlarmMapper.update(reportAlarm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理报警信息
|
||||
* @param iotLocationVoAll
|
||||
* @return
|
||||
*/
|
||||
private int handlingAlarmInformation(List<IotLocationVo> iotLocationVoAll) {
|
||||
log.info("处理报警信息====");
|
||||
int fly = 0;
|
||||
if (iotLocationVoAll != null && iotLocationVoAll.size() > 0) {
|
||||
for (IotLocationVo iotLocationVo : iotLocationVoAll) {
|
||||
//根据当前的报警uuid查看是否有这条记录
|
||||
ReportAlarm reportAlarm = reportAlarmMapper.selectByDeviceAlarmId(iotLocationVo.getDeviceAlarmId());
|
||||
if (reportAlarm == null) {
|
||||
reportAlarm.setIotCode(iotLocationVo.getIotId());
|
||||
reportAlarm.setDeviceAlarmId(iotLocationVo.getDeviceAlarmId());
|
||||
reportAlarm.setStartAlarm(iotLocationVo.getStartAlarm());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(DateUtils.YYYY_MM_DD_HH_MM_SS);
|
||||
try {
|
||||
reportAlarm.setStartAlarmTime(sdf.parse(iotLocationVo.getStartAlarmTime()));
|
||||
} catch (ParseException e) {
|
||||
log.error("日期转换异常!!!");
|
||||
}
|
||||
//异常信息保存到数据库
|
||||
reportAlarmMapper.add(reportAlarm);
|
||||
fly=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fly;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解析报警返回报文
|
||||
* @param res
|
||||
|
|
@ -500,6 +591,8 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
IotLocationVo iotLocationVo = new IotLocationVo();
|
||||
iotLocationVo.setStartAlarmTime(jsonObject.getString("startalarmtime"));
|
||||
iotLocationVo.setStartAlarm(jsonObject.getString("stralarm"));
|
||||
iotLocationVo.setDeviceAlarmId(jsonObject.getString("devicealarmid"));
|
||||
iotLocationVo.setIotId(jsonObject.getString("deviceid"));
|
||||
iotLocationVoList.add(iotLocationVo);
|
||||
}
|
||||
}
|
||||
|
|
@ -528,7 +621,7 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
JSONArray jsonArray = JSON.parseArray(records);
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject jsonObject = JSONObject.from(jsonArray.getJSONObject(i));
|
||||
iotLocationVo.setIotId(StringHelper.conversionLong(jsonObject.getString("deviceid")));
|
||||
iotLocationVo.setIotId(jsonObject.getString("deviceid"));
|
||||
iotLocationVo.setCallat(StringHelper.conversionBigDecimal(jsonObject.getString("callat")));
|
||||
iotLocationVo.setCallon(StringHelper.conversionBigDecimal(jsonObject.getString("callon")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.sgzb.base.mapper.MaTypeMapper">
|
||||
<resultMap type="com.bonus.sgzb.base.api.domain.MaType" id="MaTypeResult">
|
||||
<result property="typeId" column="type_id" />
|
||||
|
|
@ -176,11 +176,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectMaTypeList" parameterType="String" resultMap="MaTypeResult">
|
||||
select DISTINCT m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.unit_name, m.manage_type,
|
||||
m.lease_price,m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
|
||||
m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl,
|
||||
mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId,
|
||||
su.nick_name keeperUserName, mpi.prop_name, m.del_flag, m.create_by, m.create_time,
|
||||
m.remark, m.company_id ,m.type_id id , m.type_name label
|
||||
m.lease_price,m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
|
||||
m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl,
|
||||
mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId,
|
||||
su.nick_name keeperUserName, mpi.prop_name, m.del_flag, m.create_by, m.create_time,
|
||||
m.remark, m.company_id ,m.type_id id , m.type_name label
|
||||
from ma_type m
|
||||
left join ma_prop_set mps on m.type_id = mps.type_id and mps.`status`='0' and mps.del_flag='0'
|
||||
left join ma_prop_info mpi on mps.prop_id = mpi.prop_id and mpi.`status`='0' and mpi.del_flag='0'
|
||||
|
|
@ -217,19 +217,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<insert id="insertKeeper">
|
||||
insert into ma_type_keeper
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="typeId != null">type_id,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="time != null">time,</if>
|
||||
<if test="companyId != null">company_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="typeId != null">#{typeId},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="time != null">#{time},</if>
|
||||
<if test="companyId != null">#{companyId},</if>
|
||||
</trim>
|
||||
insert into ma_type_keeper
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="typeId != null">type_id,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="time != null">time,</if>
|
||||
<if test="companyId != null">company_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="typeId != null">#{typeId},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="time != null">#{time},</if>
|
||||
<if test="companyId != null">#{companyId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insertRepair">
|
||||
|
|
@ -285,14 +285,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
m.del_flag, m.create_by, m.create_time,
|
||||
m.remark, m.company_id,m.fac_model as facModel
|
||||
from ma_type m
|
||||
left join ma_prop_set mps on m.type_id = mps.type_id
|
||||
left join ma_prop_info mpi on mps.prop_id = mpi.prop_id
|
||||
left join (select * from ma_type_file where file_type = '1') mtf on m.type_id = mtf.type_id
|
||||
left join (select * from ma_type_file where file_type = '2') mtf2 on m.type_id = mtf2.type_id
|
||||
left join ma_type_keeper mtk on m.type_id = mtk.type_id
|
||||
left join sys_user su on mtk.user_id = su.user_id
|
||||
left join ma_type_repair mtr on m.type_id = mtr.type_id
|
||||
left join sys_user su1 on mtr.user_id = su1.user_id
|
||||
left join ma_prop_set mps on m.type_id = mps.type_id
|
||||
left join ma_prop_info mpi on mps.prop_id = mpi.prop_id
|
||||
left join (select * from ma_type_file where file_type = '1') mtf on m.type_id = mtf.type_id
|
||||
left join (select * from ma_type_file where file_type = '2') mtf2 on m.type_id = mtf2.type_id
|
||||
left join ma_type_keeper mtk on m.type_id = mtk.type_id
|
||||
left join sys_user su on mtk.user_id = su.user_id
|
||||
left join ma_type_repair mtr on m.type_id = mtr.type_id
|
||||
left join sys_user su1 on mtr.user_id = su1.user_id
|
||||
where m.type_id = #{typeId} and m.status = '0'
|
||||
</select>
|
||||
|
||||
|
|
@ -414,6 +414,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectMaTypeByUserId" resultType="com.bonus.sgzb.base.domain.MaTypeKeeper">
|
||||
select * from ma_type_keeper where user_id = #{userId}
|
||||
|
||||
</select>
|
||||
|
||||
<update id="updateTypeNum">
|
||||
update ma_type set num = IFNULL( num, 0 ) + 1 where type_id = #{typeId}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.sgzb.material.mapper.IotMachineMapper">
|
||||
|
||||
<insert id="add">
|
||||
|
|
@ -78,37 +78,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
iot_machine
|
||||
WHERE
|
||||
del_flag = '0'
|
||||
AND qr_code = #{qrCode}
|
||||
AND qr_code = #{qrCode}
|
||||
</select>
|
||||
<select id="selectIotCode" resultType="com.bonus.sgzb.material.domain.IotVo">
|
||||
<select id="selectIotCode" resultType="com.bonus.sgzb.material.domain.IotVo">
|
||||
SELECT
|
||||
id AS iotId,
|
||||
iot_code AS iotCode,
|
||||
iot_type AS iotType,
|
||||
iot_status AS iotStatus,
|
||||
qr_code AS qrCode
|
||||
id AS iotId,
|
||||
iot_code AS iotCode,
|
||||
iot_type AS iotType,
|
||||
iot_status AS iotStatus,
|
||||
qr_code AS qrCode
|
||||
FROM
|
||||
iot_machine
|
||||
iot_machine
|
||||
WHERE
|
||||
del_flag = '0'
|
||||
<if test="iotType != null and iotType != ''" >
|
||||
AND iot_type = #{iotType}
|
||||
</if>
|
||||
<if test="iotCode != null and iotCode != ''" >
|
||||
AND iot_code = #{iotCode}
|
||||
</if>
|
||||
del_flag = '0'
|
||||
<if test="iotType != null and iotType != ''" >
|
||||
AND iot_type = #{iotType}
|
||||
</if>
|
||||
<if test="iotCode != null and iotCode != ''" >
|
||||
AND iot_code = #{iotCode}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getIotList" resultType="com.bonus.sgzb.material.domain.IotVo">
|
||||
SELECT
|
||||
im.id AS iotId,
|
||||
im.iot_code AS iotCode,
|
||||
im.iot_type AS iotType,
|
||||
im.iot_status AS iotStatus,
|
||||
sd.name AS iotTypeName,
|
||||
im.qr_code AS qrCode,
|
||||
im.bind_status AS bindStatus
|
||||
im.id AS iotId,
|
||||
im.iot_code AS iotCode,
|
||||
im.iot_type AS iotType,
|
||||
im.iot_status AS iotStatus,
|
||||
sd.name AS iotTypeName,
|
||||
im.qr_code AS qrCode,
|
||||
im.bind_status AS bindStatus
|
||||
FROM
|
||||
iot_machine im
|
||||
iot_machine im
|
||||
LEFT JOIN sys_dic sd on im.iot_type = sd.id
|
||||
WHERE
|
||||
del_flag = '0'
|
||||
|
|
@ -130,31 +130,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
iot_machine
|
||||
WHERE
|
||||
del_flag = '0'
|
||||
AND id = #{iotId}
|
||||
AND id = #{iotId}
|
||||
</select>
|
||||
<select id="getTypeList" resultType="com.bonus.sgzb.material.domain.IotVo">
|
||||
SELECT
|
||||
imb.id AS id,
|
||||
im.iot_type AS iotType,
|
||||
sd.name AS iotTypeName,
|
||||
im.iot_code AS iotCode,
|
||||
im.iot_status AS iotStatus,
|
||||
imb.iot_id AS iotId,
|
||||
imb.bind_time AS bindTime,
|
||||
im.bind_status AS bindStatus
|
||||
imb.id AS id,
|
||||
im.iot_type AS iotType,
|
||||
sd.name AS iotTypeName,
|
||||
im.iot_code AS iotCode,
|
||||
im.iot_status AS iotStatus,
|
||||
imb.iot_id AS iotId,
|
||||
imb.bind_time AS bindTime,
|
||||
im.bind_status AS bindStatus
|
||||
FROM
|
||||
iot_machine im
|
||||
LEFT JOIN sys_dic sd on im.iot_type = sd.id
|
||||
LEFT JOIN iot_machine_bind imb ON im.id = imb.iot_id
|
||||
iot_machine im
|
||||
LEFT JOIN sys_dic sd on im.iot_type = sd.id
|
||||
LEFT JOIN iot_machine_bind imb ON im.id = imb.iot_id
|
||||
WHERE
|
||||
im.del_flag = '0'
|
||||
im.del_flag = '0'
|
||||
AND im.bind_status = '0'
|
||||
AND imb.unbind_time IS NULL
|
||||
AND imb.ma_code = #{maCode}
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
AND (
|
||||
im.iot_type like concat('%', #{keyWord}, '%') or
|
||||
im.iot_code like concat('%', #{keyWord}, '%')
|
||||
im.iot_type like concat('%', #{keyWord}, '%') or
|
||||
im.iot_code like concat('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
|
@ -168,7 +168,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sys_dic
|
||||
WHERE
|
||||
status = '0'
|
||||
AND p_id = '124'
|
||||
AND p_id = '124'
|
||||
</select>
|
||||
<select id="selectCodeList" resultType="com.bonus.sgzb.material.domain.IotCodeVo">
|
||||
SELECT
|
||||
|
|
@ -184,28 +184,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
<select id="getRecordList" resultType="com.bonus.sgzb.material.domain.IotRecordVo">
|
||||
SELECT
|
||||
imb.id AS id,
|
||||
mt1.type_name AS typeName,
|
||||
imb.ma_code AS maCode,
|
||||
imb.type_id AS typeId,
|
||||
imb.bind_time AS bindTime,
|
||||
imb.unbind_time AS unBindTime
|
||||
imb.id AS id,
|
||||
mt1.type_name AS typeName,
|
||||
imb.ma_code AS maCode,
|
||||
imb.type_id AS typeId,
|
||||
imb.bind_time AS bindTime,
|
||||
imb.unbind_time AS unBindTime
|
||||
FROM
|
||||
iot_machine_bind imb
|
||||
LEFT JOIN ma_type mt ON imb.type_id = mt.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
||||
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
|
||||
LEFT JOIN iot_machine im ON imb.iot_id = im.id
|
||||
iot_machine_bind imb
|
||||
LEFT JOIN ma_type mt ON imb.type_id = mt.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
||||
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
|
||||
LEFT JOIN iot_machine im ON imb.iot_id = im.id
|
||||
WHERE
|
||||
im.del_flag = '0'
|
||||
AND im.id = #{iotId}
|
||||
im.del_flag = '0'
|
||||
AND im.id = #{iotId}
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
AND (
|
||||
mt1.type_name like concat('%', #{keyWord}, '%') or
|
||||
imb.ma_code like concat('%', #{keyWord}, '%')
|
||||
mt1.type_name like concat('%', #{keyWord}, '%') or
|
||||
imb.ma_code like concat('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectListByTypeId" resultType="com.bonus.sgzb.material.domain.IotVo">
|
||||
SELECT imb.id AS id,
|
||||
imb.ma_code AS maCode,
|
||||
imb.type_id AS typeId,
|
||||
imb.bind_time AS bindTime,
|
||||
imb.unbind_time AS unBindTime,
|
||||
im.iot_code AS iotCode,
|
||||
im.iot_type AS iotType,
|
||||
im.iot_status AS iotStatus,
|
||||
im.qr_code AS qrCode,
|
||||
im.bind_status AS bindStatus
|
||||
FROM
|
||||
iot_machine_bind imb
|
||||
LEFT JOIN iot_machine im ON imb.iot_id = im.id
|
||||
WHERE
|
||||
imb.type_id = #{typeId}
|
||||
AND imb.unbind_time IS NULL
|
||||
AND im.iot_status ='0'
|
||||
AND im.del_flag ='0'
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?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.bonus.sgzb.material.mapper.ReportAlarmMapper">
|
||||
|
||||
|
||||
<insert id="add">
|
||||
insert into report_alarm(iot_code,device_alarm_id,start_alarm,start_alarm_time,whether_push)
|
||||
values(#{iotCode},#{deviceAlarmId},#{startAlarm},#{startAlarmTime},1)
|
||||
</insert>
|
||||
<update id="update">
|
||||
update report_alarm
|
||||
<set>
|
||||
<if test="whetherVerify != null">whether_verify = #{whetherVerify},</if>
|
||||
<if test="verifySituation != null">verify_situation = #{verifySituation},</if>
|
||||
</set>
|
||||
where device_alarm_id = #{deviceAlarmId}
|
||||
|
||||
</update>
|
||||
<delete id="deleteById"></delete>
|
||||
<select id="selectByDeviceAlarmId" resultType="com.bonus.sgzb.material.domain.ReportAlarm">
|
||||
select * from report_alarm where device_alarm_id = #{DeviceAlarmId}
|
||||
</select>
|
||||
<select id="selectByIotCode" resultType="com.bonus.sgzb.material.domain.ReportAlarm">
|
||||
select * from report_alarm where iot_code = #{iotCode}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue