增加箱门告警手动生成功能
This commit is contained in:
parent
61f1d12550
commit
6b995a83a2
@ -0,0 +1,15 @@
|
||||
package com.fastbee.common.model.bto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 箱门告警参数上传
|
||||
*/
|
||||
@Data
|
||||
public class DoorAlertBto {
|
||||
|
||||
private Long deviceId;
|
||||
//箱门状态:2=箱门打开,1=箱门振动
|
||||
private Integer doorState;
|
||||
|
||||
}
|
@ -7,10 +7,12 @@ import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.core.page.TableDataInfo;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.model.bto.DoorAlertBto;
|
||||
import com.fastbee.common.utils.file.FileUploadUtils;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
||||
import com.fastbee.data.controller.anfang.service.IUploadedPhotosService;
|
||||
import com.fastbee.iot.model.anfang.UploadedPhotos;
|
||||
import com.fastbee.iot.service.impl.DeviceServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@ -123,6 +125,16 @@ public class UploadedPhotosController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 箱门告警
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("doorAlert")
|
||||
public AjaxResult doorAlert(DoorAlertBto doorAlertBto) throws Exception {
|
||||
return toAjax(uploadedPhotosService.doorAlert(doorAlertBto));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改设备告警上传
|
||||
*/
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fastbee.data.controller.anfang.service;
|
||||
|
||||
import com.fastbee.common.model.bto.DoorAlertBto;
|
||||
import com.fastbee.iot.model.anfang.UploadedPhotos;
|
||||
|
||||
import java.util.List;
|
||||
@ -74,4 +75,6 @@ public interface IUploadedPhotosService
|
||||
* @param shakeState
|
||||
*/
|
||||
void sendAlarmMessage(String sn, String doorState, String shakeState);
|
||||
|
||||
String doorAlert(DoorAlertBto doorAlertBto) throws Exception;
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package com.fastbee.data.controller.anfang.service.impl;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.fastbee.common.config.RuoYiConfig;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.model.bto.DoorAlertBto;
|
||||
import com.fastbee.common.utils.DevParamsUtils;
|
||||
import com.fastbee.common.utils.StringUtils;
|
||||
import com.fastbee.common.utils.file.FileUploadUtils;
|
||||
@ -23,19 +25,19 @@ import javax.annotation.Resource;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 存储上传的照片信息Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Service
|
||||
public class UploadedPhotosServiceImpl implements IUploadedPhotosService
|
||||
{
|
||||
public class UploadedPhotosServiceImpl implements IUploadedPhotosService {
|
||||
@Resource
|
||||
private UploadedPhotosMapper uploadedPhotosMapper;
|
||||
@Autowired
|
||||
@ -53,73 +55,67 @@ public class UploadedPhotosServiceImpl implements IUploadedPhotosService
|
||||
|
||||
/**
|
||||
* 查询存储上传的照片信息
|
||||
*
|
||||
*
|
||||
* @param id 存储上传的照片信息主键
|
||||
* @return 存储上传的照片信息
|
||||
*/
|
||||
@Override
|
||||
public UploadedPhotos selectUploadedPhotosById(Long id)
|
||||
{
|
||||
public UploadedPhotos selectUploadedPhotosById(Long id) {
|
||||
return uploadedPhotosMapper.selectUploadedPhotosById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询存储上传的照片信息列表
|
||||
*
|
||||
*
|
||||
* @param uploadedPhotos 存储上传的照片信息
|
||||
* @return 存储上传的照片信息
|
||||
*/
|
||||
@Override
|
||||
public List<UploadedPhotos> selectUploadedPhotosList(UploadedPhotos uploadedPhotos)
|
||||
{
|
||||
public List<UploadedPhotos> selectUploadedPhotosList(UploadedPhotos uploadedPhotos) {
|
||||
return uploadedPhotosMapper.selectUploadedPhotosList(uploadedPhotos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增存储上传的照片信息
|
||||
*
|
||||
*
|
||||
* @param uploadedPhotos 存储上传的照片信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertUploadedPhotos(UploadedPhotos uploadedPhotos)
|
||||
{
|
||||
public int insertUploadedPhotos(UploadedPhotos uploadedPhotos) {
|
||||
return uploadedPhotosMapper.insertUploadedPhotos(uploadedPhotos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改存储上传的照片信息
|
||||
*
|
||||
*
|
||||
* @param uploadedPhotos 存储上传的照片信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUploadedPhotos(UploadedPhotos uploadedPhotos)
|
||||
{
|
||||
public int updateUploadedPhotos(UploadedPhotos uploadedPhotos) {
|
||||
return uploadedPhotosMapper.updateUploadedPhotos(uploadedPhotos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除存储上传的照片信息
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的存储上传的照片信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteUploadedPhotosByIds(Long[] ids)
|
||||
{
|
||||
public int deleteUploadedPhotosByIds(Long[] ids) {
|
||||
return uploadedPhotosMapper.deleteUploadedPhotosByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除存储上传的照片信息信息
|
||||
*
|
||||
*
|
||||
* @param id 存储上传的照片信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteUploadedPhotosById(Long id)
|
||||
{
|
||||
public int deleteUploadedPhotosById(Long id) {
|
||||
return uploadedPhotosMapper.deleteUploadedPhotosById(id);
|
||||
}
|
||||
|
||||
@ -130,12 +126,12 @@ public class UploadedPhotosServiceImpl implements IUploadedPhotosService
|
||||
return "";
|
||||
}
|
||||
Map<String, Object> devParams = DevParamsUtils.getDevParams(device.getDevParams());
|
||||
if(!devParams.containsKey("jiankongIds")){
|
||||
if (!devParams.containsKey("jiankongIds")) {
|
||||
return "";
|
||||
}
|
||||
String jiankongIds = devParams.get("jiankongIds").toString();
|
||||
Device jiankongDevice = deviceService.selectDeviceByDeviceId(Long.parseLong(jiankongIds));
|
||||
if(jiankongDevice == null){
|
||||
if (jiankongDevice == null) {
|
||||
return "";
|
||||
}
|
||||
Map devData = DevParamsUtils.getDevParams(jiankongDevice.getDevParams());
|
||||
@ -222,46 +218,46 @@ public class UploadedPhotosServiceImpl implements IUploadedPhotosService
|
||||
boolean notify = false;
|
||||
SendParams sendParams = new SendParams();
|
||||
sendParams.setId(14L);
|
||||
Map<String,String> temp = new HashMap<>();
|
||||
Map<String, String> temp = new HashMap<>();
|
||||
Device device = deviceService.selectDeviceBySerialNumber(sn);
|
||||
if (device == null) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> devParams = DevParamsUtils.getDevParams(device.getDevParams());
|
||||
Device jijingDevice = null;
|
||||
if(devParams.containsKey("jijingIds")){
|
||||
if (devParams.containsKey("jijingIds")) {
|
||||
String jijingIds = devParams.get("jijingIds").toString();
|
||||
jijingDevice = deviceService.selectDeviceByDeviceId(Long.parseLong(jijingIds));
|
||||
if (jijingDevice == null){
|
||||
if (jijingDevice == null) {
|
||||
return;
|
||||
}
|
||||
temp.put("stationName",jijingDevice.getDeviceName());
|
||||
}else{
|
||||
temp.put("stationName", jijingDevice.getDeviceName());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if(Integer.parseInt(doorState) == 1){
|
||||
temp.put("warnInfo","箱门打开");
|
||||
if (Integer.parseInt(doorState) == 1) {
|
||||
temp.put("warnInfo", "箱门打开");
|
||||
notify = true;
|
||||
}else {
|
||||
if(Integer.parseInt(shakeState) == 1){
|
||||
temp.put("warnInfo","箱门振动");
|
||||
} else {
|
||||
if (Integer.parseInt(shakeState) == 1) {
|
||||
temp.put("warnInfo", "箱门振动");
|
||||
notify = true;
|
||||
}
|
||||
}
|
||||
if(notify){
|
||||
if (notify) {
|
||||
DeviceAlertUser deviceAlertUser = new DeviceAlertUser();
|
||||
deviceAlertUser.setDeviceId(jijingDevice.getDeviceId());
|
||||
List<DeviceAlertUser> deviceAlertUsers = deviceAlertUserMapper.selectDeviceAlertUserList(deviceAlertUser);
|
||||
if(deviceAlertUsers.size() > 0){
|
||||
if (deviceAlertUsers.size() > 0) {
|
||||
String phone = "";
|
||||
for (int i = 0; i < deviceAlertUsers.size(); i++) {
|
||||
if(i == 0){
|
||||
if (i == 0) {
|
||||
phone = deviceAlertUsers.get(i).getPhoneNumber();
|
||||
}else {
|
||||
} else {
|
||||
phone += "," + deviceAlertUsers.get(i).getPhoneNumber();
|
||||
}
|
||||
}
|
||||
if(StringUtils.isEmpty(phone)){
|
||||
if (StringUtils.isEmpty(phone)) {
|
||||
return;
|
||||
}
|
||||
sendParams.setSendAccount(phone);
|
||||
@ -272,4 +268,38 @@ public class UploadedPhotosServiceImpl implements IUploadedPhotosService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doorAlert(DoorAlertBto doorAlertBto) throws Exception {
|
||||
Device device = deviceService.selectDeviceByDeviceId(doorAlertBto.getDeviceId());
|
||||
if (device == null) {
|
||||
throw new Exception("未找到设备");
|
||||
}
|
||||
int doorState = 0;
|
||||
int shakeState = 0;
|
||||
if (doorAlertBto.getDoorState() > 0) {
|
||||
if (doorAlertBto.getDoorState() == 1) {
|
||||
shakeState = doorAlertBto.getDoorState();
|
||||
doorState = 0;
|
||||
} else if (doorAlertBto.getDoorState() == 2) {
|
||||
doorState = doorAlertBto.getDoorState();
|
||||
shakeState = 0;
|
||||
}
|
||||
sendAlarmMessage(device.getSerialNumber(), doorState + "", shakeState + "");
|
||||
}
|
||||
//抓拍监控,并返回路径
|
||||
String monitorPath = captureMonitorPhoto(device.getSerialNumber());
|
||||
UploadedPhotos uploadedPhotos = new UploadedPhotos(
|
||||
null, "", monitorPath, "", device.getSerialNumber(),
|
||||
device.getLatitude()!= null ? device.getLatitude().doubleValue():0d,
|
||||
device.getLongitude()!= null ? device.getLatitude().doubleValue():0d,
|
||||
18.23d, doorState + "", shakeState + "", new Date()
|
||||
);
|
||||
int count = insertUploadedPhotos(uploadedPhotos);
|
||||
if (count > 0) {
|
||||
return "生成成功";
|
||||
} else {
|
||||
return "生成失败";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,20 +180,17 @@ public class DeviceDetailServiceImpl implements IDeviceDetailService {
|
||||
if (StringUtils.isNotEmpty(anfangIds)) {
|
||||
Device anfangDevice = iDeviceService.selectDeviceByDeviceId(Long.parseLong(anfangIds));
|
||||
//获取当前安防告警状态
|
||||
|
||||
anfangInfoVo.setDoorStatus(0);
|
||||
CommonResult<HaiWeiDeviceInfoVo> cache = haiWeiService.getCache(anfangDevice.getDeviceId());
|
||||
HaiWeiDeviceInfoVo checkedData = cache.getCheckedData();
|
||||
List<HaiWeiPropertyVo> propertyList = checkedData.getPropertyList();
|
||||
for (HaiWeiPropertyVo haiWeiPropertyVo : propertyList) {
|
||||
if (haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_open")) {
|
||||
// HashMap<Object, Object> hashMap1 = new HashMap<Object, Object>() {{
|
||||
// put("upType", 0);
|
||||
// put("identifier", "xiangmen");
|
||||
// put("unit", "");
|
||||
// put("value", haiWeiPropertyVo.getValue());
|
||||
// put("name", haiWeiPropertyVo.getNameCn());
|
||||
// }};
|
||||
anfangInfoVo.setDoorStatus(Integer.parseInt(haiWeiPropertyVo.getValue().toString()));
|
||||
if(cache != null){
|
||||
HaiWeiDeviceInfoVo checkedData = cache.getCheckedData();
|
||||
if(checkedData != null){
|
||||
List<HaiWeiPropertyVo> propertyList = checkedData.getPropertyList();
|
||||
for (HaiWeiPropertyVo haiWeiPropertyVo : propertyList) {
|
||||
if (haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_open")) {
|
||||
anfangInfoVo.setDoorStatus(Integer.parseInt(haiWeiPropertyVo.getValue().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
UploadedPhotos uploadedPhotos = new UploadedPhotos();
|
||||
@ -214,7 +211,7 @@ public class DeviceDetailServiceImpl implements IDeviceDetailService {
|
||||
if (uploadedPhotos1.size() > 5) {
|
||||
uploadedPhotos1 = uploadedPhotos1.subList(0, 5);
|
||||
}
|
||||
anfangInfoVo.setDoorStatus(doorStatus);
|
||||
// anfangInfoVo.setDoorStatus(doorStatus);
|
||||
anfangInfoVo.setAnfangList(uploadedPhotos1);
|
||||
}
|
||||
//安防设备
|
||||
|
@ -114,21 +114,21 @@ public class MaWatereleRecordServiceImpl implements IMaWatereleRecordService
|
||||
MaWatereleRecord record = new MaWatereleRecord();
|
||||
record.setDevSn(item.get("dev_sn").toString());
|
||||
record.setWorkstate(Integer.parseInt(item.get("workState").toString()));
|
||||
record.setUsersumflow(item.get("userSumFlow").toString());
|
||||
record.setUsersumele(item.get("userSumEle").toString());
|
||||
record.setUserbalance(item.get("userBalance").toString());
|
||||
record.setSumflow(item.get("sumFlow").toString());
|
||||
record.setSumele(item.get("sumEle").toString());
|
||||
record.setMcusn(item.get("mcuSn").toString());
|
||||
record.setInspower(item.get("insPower").toString());
|
||||
record.setInsflow(item.get("insFlow").toString());
|
||||
record.setCurflow(item.get("curFlow").toString());
|
||||
record.setCurele(item.get("curEle").toString());
|
||||
record.setMetersum(item.get("meterSum").toString());
|
||||
record.setMeterins(item.get("meterIns").toString());
|
||||
record.setCardid(item.get("cardId").toString());
|
||||
record.setAreacode(item.get("areaCode").toString());
|
||||
record.setAction(item.get("action").toString());
|
||||
record.setUsersumflow(item.get("userSumFlow").toString().equals("null")?"--":item.get("userSumFlow").toString());
|
||||
record.setUsersumele(item.get("userSumEle").toString().equals("null")?"--":item.get("userSumEle").toString());
|
||||
record.setUserbalance(item.get("userBalance").toString().equals("null")?"--":(com.fastbee.common.utils.NumberUtils.formatFloat(Float.parseFloat(item.get("user_balance").toString())/100)+""));
|
||||
record.setSumflow(item.get("sumFlow").toString().equals("null")?"--":item.get("sumFlow").toString());
|
||||
record.setSumele(item.get("sumEle").toString().equals("null")?"--":item.get("sumEle").toString());
|
||||
record.setMcusn(item.get("mcuSn").toString().equals("null")?"--":item.get("mcuSn").toString());
|
||||
record.setInspower(item.get("insPower").toString().equals("null")?"--":item.get("insPower").toString());
|
||||
record.setInsflow(item.get("insFlow").toString().equals("null")?"--":item.get("insFlow").toString());
|
||||
record.setCurflow(item.get("curFlow").toString().equals("null")?"--":item.get("curFlow").toString());
|
||||
record.setCurele(item.get("curEle").toString().equals("null")?"--":item.get("curEle").toString());
|
||||
record.setMetersum(item.get("meterSum").toString().equals("null")?"--":item.get("meterSum").toString());
|
||||
record.setMeterins(item.get("meterIns").toString().equals("null")?"--":item.get("meterIns").toString());
|
||||
record.setCardid(item.get("cardId").toString().equals("null")?"--":item.get("cardId").toString());
|
||||
record.setAreacode(item.get("areaCode").toString().equals("null")?"--":item.get("areaCode").toString());
|
||||
record.setAction(item.get("action").toString().equals("null")?"--":item.get("action").toString());
|
||||
if(StringUtils.isNotEmpty(item.get("create_time").toString())){
|
||||
if(NumberUtil.isNumber(item.get("create_time").toString())) {
|
||||
Date date = new Date(Long.parseLong(item.get("create_time").toString()) * 1000);
|
||||
|
Loading…
x
Reference in New Issue
Block a user