喷淋自动关闭,超时10分钟扬尘不报警
This commit is contained in:
parent
ddd2d7ce41
commit
9e49309773
@ -1,9 +1,12 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.entity.vo.ConcreteMonitorCurrentDataVo;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Notice;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
|
||||
import com.zhgd.xmgl.modules.concrete.entity.ConcreteMonitorCurrentData;
|
||||
import com.zhgd.xmgl.util.MessageUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@ -32,13 +35,28 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
@Api(tags = "消息通知")
|
||||
public class NoticeController {
|
||||
@Autowired
|
||||
private INoticeService noticeService;
|
||||
@Autowired
|
||||
private INoticeService noticeService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "添加消息通知信息", notes = "添加消息通知信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<Notice> add(@RequestBody Notice notice) {
|
||||
log.info("添加消息通知信息:{}", JSON.toJSONString(notice));
|
||||
noticeService.save(notice);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页列表查询消息通知信息", notes = "分页列表查询消息通知信息", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "title", value = "通知标题", dataType = "String", paramType = "body", required = false),
|
||||
|
||||
@ -7,6 +7,7 @@ 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.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.redis.lock.RedisRepository;
|
||||
import com.zhgd.xmgl.async.AsyncEnvironment;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Notice;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
@ -682,10 +683,9 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
|
||||
}
|
||||
}
|
||||
|
||||
//打开喷淋后,自动10分钟后关闭
|
||||
if (isThreeAlarm) {
|
||||
sprayRtDevService.setSwitchStatusIf(dustNoiseData.getProjectSn(), 2);
|
||||
} else {
|
||||
sprayRtDevService.setSwitchStatusIf(dustNoiseData.getProjectSn(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -25,5 +25,11 @@ public interface ISprayRtDevService extends IService<SprayRtDev> {
|
||||
|
||||
void editByDevSn(SprayRtDev sprayRtDev);
|
||||
|
||||
/**
|
||||
* 开关喷淋
|
||||
*
|
||||
* @param projectSn
|
||||
* @param switchStatus
|
||||
*/
|
||||
void setSwitchStatusIf(String projectSn, Integer switchStatus);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.zhgd.xmgl.modules.sprayrt.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -7,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.redis.lock.RedisRepository;
|
||||
import com.zhgd.xmgl.modules.sprayrt.entity.SprayRtDev;
|
||||
import com.zhgd.xmgl.modules.sprayrt.mapper.SprayRtDevMapper;
|
||||
import com.zhgd.xmgl.modules.sprayrt.service.ISprayRtDevService;
|
||||
@ -31,6 +33,10 @@ import java.util.Objects;
|
||||
public class SprayRtDevServiceImpl extends ServiceImpl<SprayRtDevMapper, SprayRtDev> implements ISprayRtDevService {
|
||||
@Autowired
|
||||
private SprayRtDevMapper sprayRtDevMapper;
|
||||
@Autowired
|
||||
private RedisRepository redisRepository;
|
||||
|
||||
public static String SPRAY_FREFIX_AUTO_CLOSE = "SPRAY:AUTO_CLOSE:";
|
||||
|
||||
@Override
|
||||
public IPage<SprayRtDev> queryPageList(HashMap<String, Object> paramMap) {
|
||||
@ -88,9 +94,15 @@ public class SprayRtDevServiceImpl extends ServiceImpl<SprayRtDevMapper, SprayRt
|
||||
List<SprayRtDev> devs = sprayRtDevMapper.selectList(new LambdaQueryWrapper<SprayRtDev>()
|
||||
.eq(SprayRtDev::getProjectSn, projectSn));
|
||||
for (SprayRtDev dev : devs) {
|
||||
//自动模式
|
||||
if (Objects.equals(dev.getSprayMode(), 2)) {
|
||||
dev.setSwitchStatus(switchStatus);
|
||||
sprayRtDevMapper.updateById(dev);
|
||||
|
||||
if (Objects.equals(switchStatus, 2)) {
|
||||
//自动模式,设置自动关闭时间,定时关闭
|
||||
redisRepository.set(SPRAY_FREFIX_AUTO_CLOSE + dev.getId(), DateUtil.now(), 3600 * 24 * 30L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -326,6 +326,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/xmgl/bridgeErectMachineAlarm/add").permitAll()
|
||||
.antMatchers("/xmgl/workerBlacklist/list").permitAll()
|
||||
.antMatchers("/xmgl/carPassRecord/addCarPassRecord").permitAll()
|
||||
.antMatchers("/xmgl/notice/add").permitAll()
|
||||
.antMatchers(HttpMethod.OPTIONS, "/**").anonymous()
|
||||
.anyRequest().authenticated() // 剩下所有的验证都需要验证.
|
||||
.and()
|
||||
|
||||
@ -2,17 +2,24 @@ package com.zhgd.xmgl.task;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.zhgd.redis.lock.RedisRepository;
|
||||
import com.zhgd.xmgl.modules.environment.entity.DustNoiseData;
|
||||
import com.zhgd.xmgl.modules.environment.entity.EnvironmentDev;
|
||||
import com.zhgd.xmgl.modules.environment.mapper.DustNoiseDataMapper;
|
||||
import com.zhgd.xmgl.modules.environment.mapper.EnvironmentDevMapper;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
import com.zhgd.xmgl.modules.sprayrt.entity.SprayRtDev;
|
||||
import com.zhgd.xmgl.modules.sprayrt.mapper.SprayRtDevMapper;
|
||||
import com.zhgd.xmgl.modules.sprayrt.service.ISprayRtDevService;
|
||||
import com.zhgd.xmgl.modules.sprayrt.service.impl.SprayRtDevServiceImpl;
|
||||
import com.zhgd.xmgl.task.dto.EnvironmentDustDataDto;
|
||||
import com.zhgd.xmgl.util.EnvironmentUtils;
|
||||
import com.zhgd.xmgl.util.WindDirectionUtils;
|
||||
@ -25,7 +32,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -50,8 +56,13 @@ public class EnvironmentDevTask {
|
||||
@Autowired
|
||||
private EnvironmentDevMapper environmentDevMapper;
|
||||
@Autowired
|
||||
private SprayRtDevMapper sprayRtDevMapper;
|
||||
@Autowired
|
||||
private DustNoiseDataMapper dustNoiseDataMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisRepository redisRepository;
|
||||
@Autowired
|
||||
private ISprayRtDevService sprayRtDevService;
|
||||
@Value("${isGetEnvironmentData}")
|
||||
private boolean isGetEnvironmentData;
|
||||
@Autowired
|
||||
@ -213,4 +224,37 @@ public class EnvironmentDevTask {
|
||||
log.error("设备sn:{},请求失败!当前code:{},msg:{}", devSn, code, realTimeData.getString("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 喷淋自动关闭,超时10分钟扬尘不报警
|
||||
*/
|
||||
@SchedulerLock(name = "sprayAutoClose", lockAtMostFor = 1000 * 60 * 5, lockAtLeastFor = 1000 * 60 * 3)
|
||||
@Scheduled(cron = "0 0/1 * * * ?")
|
||||
@GetMapping("sprayAutoClose")
|
||||
public void sprayAutoClose() {
|
||||
List<SprayRtDev> sprayDevList = sprayRtDevMapper.selectList(null);
|
||||
if (CollUtil.isNotEmpty(sprayDevList)) {
|
||||
for (SprayRtDev sprayDev : sprayDevList) {
|
||||
try {
|
||||
//过期时间
|
||||
String key = SprayRtDevServiceImpl.SPRAY_FREFIX_AUTO_CLOSE + sprayDev.getId();
|
||||
String time = (String) redisRepository.get(key);
|
||||
long between = DateUtil.between(DateUtil.parse(time), DateUtil.date(), DateUnit.MINUTE);
|
||||
if (between > 10) {
|
||||
redisRepository.del(key);
|
||||
if (Objects.equals(sprayDev.getSprayMode(), 2)) {
|
||||
sprayDev.setSwitchStatus(1);
|
||||
sprayRtDevMapper.updateById(sprayDev);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("喷淋自动关闭异常:" + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(DateUtil.date());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user