From bed5cd20e7564733a554f3f62cf1ec404374f70a Mon Sep 17 00:00:00 2001 From: 101captain <237651143@qq.com> Date: 星期四, 16 九月 2021 16:18:56 +0800 Subject: [PATCH] 一键报警相关功能修改 --- springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/impl/ComPropertyAlarmServiceImpl.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/impl/ComPropertyAlarmServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/impl/ComPropertyAlarmServiceImpl.java index 7281042..ddcb000 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/impl/ComPropertyAlarmServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/service/impl/ComPropertyAlarmServiceImpl.java @@ -1,18 +1,26 @@ package com.panzhihua.service_property.service.impl; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.panzhihua.common.model.dtos.property.CommonPage; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.property.ComPropertyAlarmVO; +import com.panzhihua.service_property.dao.ComPropertyEquipmentDao; import com.panzhihua.service_property.entity.ComPropertyAlarm; import com.panzhihua.service_property.dao.ComPropertyAlarmDao; +import com.panzhihua.service_property.entity.ComPropertyEquipment; import com.panzhihua.service_property.service.ComPropertyAlarmService; +import com.panzhihua.service_property.util.JPushUtil; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; /** * (ComPropertyAlarm)表服务实现类 @@ -25,6 +33,8 @@ public class ComPropertyAlarmServiceImpl extends ServiceImpl<ComPropertyAlarmDao, ComPropertyAlarm> implements ComPropertyAlarmService { @Resource private ComPropertyAlarmDao comPropertyAlarmDao; + @Resource + private ComPropertyEquipmentDao comPropertyEquipmentDao; @Override public R pageList(CommonPage commonPage) { IPage<ComPropertyAlarmVO> page=comPropertyAlarmDao.selectList(new Page(commonPage.getPage(), commonPage.getSize()),commonPage); @@ -35,4 +45,47 @@ public R selectDetail(Integer id) { return R.ok(comPropertyAlarmDao.selectById(id)); } + + @Override + public R insert(ComPropertyAlarm comPropertyAlarm) { + if(comPropertyAlarm!=null){ + ComPropertyEquipment comPropertyEquipment=comPropertyEquipmentDao.selectOne(new QueryWrapper<ComPropertyEquipment>().lambda().eq(ComPropertyEquipment::getSerialNo,comPropertyAlarm.getSerialNo())); + ComPropertyAlarmVO propertyAlarmVO=new ComPropertyAlarmVO(); + if(comPropertyEquipment!=null) { + if (comPropertyAlarm.getType().equals(ComPropertyAlarm.type.one)) { + comPropertyAlarm.setStatus(ComPropertyAlarm.status.dcl); + comPropertyAlarm.setCommunityId(comPropertyEquipment.getCommunityId()); + comPropertyAlarm.setPhone(comPropertyEquipment.getPhone()); + comPropertyAlarm.setName(comPropertyEquipment.getUsername()); + if (comPropertyAlarmDao.insert(comPropertyAlarm) > 0) { + BeanUtils.copyProperties(comPropertyAlarm,propertyAlarmVO); + propertyAlarmVO.setLatitude(comPropertyEquipment.getLatitude()); + propertyAlarmVO.setLongitude(comPropertyEquipment.getLongitude()); + Map<String, String> map = new HashMap<>(); + map.put("title", "一键报警通知"); + map.put("msg", comPropertyEquipment.getPosition() + "," + comPropertyEquipment.getUsername() + "发起报警"); + map.put("communityId", comPropertyEquipment.getCommunityId().toString()); + map.put("alarm",JSONObject.toJSONString(propertyAlarmVO)); + JPushUtil.jpushAndroid(map); + return R.ok(); + } + + } else { + if (comPropertyAlarmDao.insert(comPropertyAlarm) > 0) { + BeanUtils.copyProperties(comPropertyAlarm,propertyAlarmVO); + propertyAlarmVO.setLatitude(comPropertyEquipment.getLatitude()); + propertyAlarmVO.setLongitude(comPropertyEquipment.getLongitude()); + Map<String, String> map = new HashMap<>(); + map.put("title", "长时间未移动报警通知"); + map.put("msg", comPropertyEquipment.getPosition() + "," + comPropertyEquipment.getUsername() + "长时间未移动报警"); + map.put("communityId", comPropertyEquipment.getCommunityId().toString()); + map.put("alarm",JSONObject.toJSONString(propertyAlarmVO)); + JPushUtil.jpushAndroid(map); + return R.ok(); + } + } + } + } + return R.fail(); + } } -- Gitblit v1.7.1