修改amb的新增条件;

110的分页条件添加ai字段不为空;
新增110算法接口5分钟一次定时任务
wushunjie
吴顺杰 11 months ago
parent 50ffba72bb
commit 97f5e6faca

@ -2,6 +2,8 @@ package com.yingji.quartz;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.yingji.entity.Alarm;
import com.yingji.entity.dto.request.AlarmRequest;
import com.yingji.service.AlarmService;
@ -16,7 +18,9 @@ import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
@ -46,6 +50,39 @@ public class AlarmQuartz {
String token = alarmService.getToken();
// 查询所有id
List<String> idList = findId(token);
// 根据id查询数据保存
addList(idList, token);
}
/**
* 110
*/
@Async
@Scheduled(cron = "0 */5 * * * ? ")
public void emergencyAlgorithm() {
log.info("============110算法接口开始" + LocalDateTime.now() + "=============");
// 获取当前的时间
LocalDateTime endTime = LocalDateTime.now();
// 获取五分钟前时间
LocalDateTime startTime = endTime.minusMinutes(5);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
String endTimeStr = endTime.format(formatter) + ":00";
String startTimeStr = startTime.format(formatter) + ":00";
Map<String, String> map = new HashMap<>();
map.put("startTime", startTimeStr);
map.put("endTime", endTimeStr);
String body = JSONUtil.toJsonStr(map);
HttpRequest.post("http://localhost:9002/emergency_algorithm").body(body).execute().body();
log.info("============110算法接口结束" + LocalDateTime.now() + "=============");
}
/**
* id
*
* @param idList id
* @param token token
*/
private void addList(List<String> idList, String token) {
// 查询数据条件
AlarmRequest alarmRequest = new AlarmRequest();
alarmRequest.setType("getValue");
@ -59,6 +96,7 @@ public class AlarmQuartz {
try {
for (String x : idList) {
alarmRequest.setValue(x);
// 查询数据
Alarm alarm = alarmService.findDataList(alarmRequest, token);
if (alarm != null) {
alarm.setSourceId(x);

@ -7,41 +7,40 @@
<select id="page" resultType="com.yingji.entity.Alarm">
select * from alarm
<where>
<if test="req.startTime != null ">
emergency_event_time &gt;= #{req.startTime}
</if>
<if test="req.endTime != null ">
and emergency_event_time &lt;= #{req.endTime}
</if>
<if test="req.endTime != null ">
and emergency_event_time &lt;= #{req.endTime}
</if>
<if test="req.emergencyEventDesc != null and req.emergencyEventDesc != ''">
and emergency_event_desc like concat('%', #{req.emergencyEventDesc}, '%')
</if>
<if test="req.emergencyEventAddress != null and req.emergencyEventAddress != ''">
and emergency_event_address like concat('%', #{req.emergencyEventAddress}, '%')
</if>
<if test="req.alarmPhoneNumber != null and req.alarmPhoneNumber != ''">
and alarm_phone_number like concat('%', #{req.alarmPhoneNumber}, '%')
</if>
<if test="req.aiClass != null and req.aiClass != ''">
and ai_class like concat('%', #{req.aiClass}, '%')
</if>
<if test="req.aiClass2 != null and req.aiClass2 != ''">
and ai_class2 like concat('%', #{req.aiClass2}, '%')
</if>
<if test="req.aiLevel != null and req.aiLevel != ''">
and ai_level like concat('%', #{req.aiLevel}, '%')
</if>
<if test="req.aiNumMin != null ">
and ai_num &lt;= #{req.aiNumMin}
</if>
<if test="req.aiNumMax != null ">
and ai_num &lt;= #{req.aiNumMax}
</if>
</where>
where ai_class is not null
<if test="req.startTime != null ">
and emergency_event_time &gt;= #{req.startTime}
</if>
<if test="req.endTime != null ">
and emergency_event_time &lt;= #{req.endTime}
</if>
<if test="req.endTime != null ">
and emergency_event_time &lt;= #{req.endTime}
</if>
<if test="req.emergencyEventDesc != null and req.emergencyEventDesc != ''">
and emergency_event_desc like concat('%', #{req.emergencyEventDesc}, '%')
</if>
<if test="req.emergencyEventAddress != null and req.emergencyEventAddress != ''">
and emergency_event_address like concat('%', #{req.emergencyEventAddress}, '%')
</if>
<if test="req.alarmPhoneNumber != null and req.alarmPhoneNumber != ''">
and alarm_phone_number like concat('%', #{req.alarmPhoneNumber}, '%')
</if>
<if test="req.aiClass != null and req.aiClass != ''">
and ai_class like concat('%', #{req.aiClass}, '%')
</if>
<if test="req.aiClass2 != null and req.aiClass2 != ''">
and ai_class2 like concat('%', #{req.aiClass2}, '%')
</if>
<if test="req.aiLevel != null and req.aiLevel != ''">
and ai_level like concat('%', #{req.aiLevel}, '%')
</if>
<if test="req.aiNumMin != null ">
and ai_num &lt;= #{req.aiNumMin}
</if>
<if test="req.aiNumMax != null ">
and ai_num &lt;= #{req.aiNumMax}
</if>
order by update_time desc
</select>

@ -215,14 +215,14 @@ public class AccidentServiceImpl implements AccidentService {
Task one = taskService.getOne(wrapper);
if (BeanUtil.isEmpty(one)) {
taskService.save(task);
Amb amb = taskInfo.getAmb();
if (BeanUtil.isNotEmpty(amb)) {
amb.setTaskId(task.getTaskId());
ambService.save(amb);
}
} else {
taskService.updateById(task);
}
Amb amb = taskInfo.getAmb();
if (BeanUtil.isNotEmpty(amb)) {
amb.setTaskId(task.getTaskId());
ambService.save(amb);
}
}
}
}

Loading…
Cancel
Save