Browse Source

优化设备按照桩号查询

新增事件桩号范围查询
新增批量调用设备功能接口
develop
zhaoxianglong 1 year ago
parent
commit
950233b932
  1. 21
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  2. 16
      zc-business/src/main/java/com/zc/business/controller/DcEventController.java
  3. 2
      zc-business/src/main/java/com/zc/business/domain/DcDevice.java
  4. 21
      zc-business/src/main/java/com/zc/business/domain/DcEvent.java
  5. 5
      zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java
  6. 2
      zc-business/src/main/java/com/zc/business/service/IDcEventService.java
  7. 32
      zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java
  8. 65
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  9. 7
      zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

21
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -359,6 +359,27 @@ public class DcDeviceController extends BaseController {
}
/**
* 批量设备功能调用
*
* @param props 调用参数列表
* @return 调用结果
*/
@ApiOperation("批量设备功能调用")
@PostMapping("/batchFunctions")
public AjaxResult batchInvokedFunction(@RequestBody Map<String, Object> props) throws HttpException, IOException, InterruptedException {
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams(props);
Response response // 请求响应
= okHttp
.url(iotAddress + "/api/iot/device/batchFunctions") // 请求地址
.data(requestParams)
.post(); // 请求方法
return JSON.parseObject(response.body().string(), AjaxResult.class);
}
/**
* 查询物联设备事件数据
*

16
zc-business/src/main/java/com/zc/business/controller/DcEventController.java

@ -1,18 +1,13 @@
package com.zc.business.controller;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.zc.business.domain.DcEvent;
import com.zc.business.service.IDcEventService;
import io.swagger.annotations.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
@ -58,6 +53,17 @@ public class DcEventController extends BaseController
return getDataTable(list);
}
/**
* 无分页根据桩号查询事件信息列表
*/
@ApiOperation("无分页根据桩号查询事件信息列表")
// @PreAuthorize("@ss.hasPermi('system:event:query')")
@PostMapping("/query")
public AjaxResult query(@RequestBody Map<String, Object> parameter)
{
return AjaxResult.success(dcEventService.eventPileNumberQueryEvent(parameter));
}
/**调度记录-事件列表 按时间展示交通事件默认当天时间 可查询条件 交通事件状态 时间范围
*
*/

2
zc-business/src/main/java/com/zc/business/domain/DcDevice.java

@ -68,6 +68,8 @@ public class DcDevice {
private Date createTime;
@ApiModelProperty("修改时间")
private Date updateTime;
@ApiModelProperty("子类型")
private String childType;
@TableField(exist = false)
private String longitude;
@TableField(exist = false)

21
zc-business/src/main/java/com/zc/business/domain/DcEvent.java

@ -2,7 +2,6 @@ package com.zc.business.domain;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
@ -11,10 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 事件信息对象 dc_event
@ -27,7 +23,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DcEvent extends BaseEntity {
public class DcEvent {
private static final long serialVersionUID = 1L;
private static final long event_state = 0L;
/**
@ -42,6 +38,7 @@ public class DcEvent extends BaseEntity {
@ApiModelProperty("所属部门")
private Long deptId;
@Excel(name = "所属部门")
@TableField(exist = false)
private String deptName;
/**
@ -282,4 +279,18 @@ public class DcEvent extends BaseEntity {
@ApiModelProperty("事件类型名称")
@TableField(exist = false)
private String eventName;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date updateTime;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date createTime;
/** 备注 */
private String remark;
}

5
zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java

@ -1,7 +1,9 @@
package com.zc.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.DcEvent;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
@ -13,7 +15,8 @@ import java.util.Map;
* @author ruoyi
* @date 2024-01-12
*/
public interface DcEventMapper
@Mapper
public interface DcEventMapper extends BaseMapper<DcEvent>
{
/**
* 查询事件信息

2
zc-business/src/main/java/com/zc/business/service/IDcEventService.java

@ -76,4 +76,6 @@ public interface IDcEventService
DcEvent selectEventSubclassById(int eventType, String id);
Map<String,Object> selectCount();
List<DcEvent> eventPileNumberQueryEvent(Map<String, Object> parameter);
}

32
zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java

@ -46,8 +46,7 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
private RedisCache redisCache;
@PostConstruct
public void init()
{
public void init() {
/*
添加数据到 redis 缓存
*/
@ -57,12 +56,10 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
/**
* 添加数据到 redis 缓存
*/
public void updateRedisCache()
{
public void updateRedisCache() {
// 获取全部设备列表数据
List<DcDevice> dcDevices = list();
if (dcDevices == null || dcDevices.isEmpty())
{
if (dcDevices == null || dcDevices.isEmpty()) {
return;
}
@ -396,14 +393,22 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
List<String> startStakeMarks = castList(parameter.get("startStakeMark"), String.class);
List<String> endStakeMarks = castList(parameter.get("endStakeMark"), String.class);
String deviceType = String.valueOf(parameter.get("deviceType"));
String childType = String.valueOf(parameter.get("childType"));
String deviceState = String.valueOf(parameter.get("deviceState"));
DcDevice device = new DcDevice();
if (!Objects.equals(childType, "null")) {
device.setChildType(childType);
}
if (!Objects.equals(deviceType, "null")) {
device.setDeviceType(Integer.valueOf(deviceType));
}
if (!Objects.equals(deviceState, "null")) {
device.setDeviceState(deviceState);
}
List<DcDevice> list = listDevice(device);
if (startStakeMarks != null && endStakeMarks != null) {
Integer startStakeMark = Integer.parseInt(startStakeMarks.get(0) + startStakeMarks.get(1));
Integer endStakeMark = Integer.parseInt(endStakeMarks.get(0) + endStakeMarks.get(1));
LambdaQueryWrapper<DcDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>();
ArrayList<Integer> integers = new ArrayList<>();
integers.add(6);
lambdaQueryWrapper.notIn(DcDevice::getDeviceType, integers);
lambdaQueryWrapper.eq(DcDevice::getDeviceType, deviceType);
List<DcDevice> list = list(lambdaQueryWrapper);
for (DcDevice dcDevice : list) {
String stakeMark = dcDevice.getStakeMark();
Pattern pat = Pattern.compile(REGEX_CHINESE);
@ -430,6 +435,9 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
}
}
}
} else {
dcDevices = (ArrayList<DcDevice>) list;
}
return dcDevices;
}

65
zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java

@ -1,5 +1,7 @@
package com.zc.business.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
@ -12,9 +14,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
@ -25,7 +30,7 @@ import java.util.Map;
*/
@Service
@Transactional
public class DcEventServiceImpl implements IDcEventService {
public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> implements IDcEventService {
@Autowired
private DcEventMapper dcEventMapper;
//异常天气
@ -576,4 +581,62 @@ public class DcEventServiceImpl implements IDcEventService {
map.put("warningCount", i);
return map;
}
private static String REGEX_CHINESE = "[\u4e00-\u9fa5]";// 中文正则
@Override
public List<DcEvent> eventPileNumberQueryEvent(Map<String, Object> parameter) {
ArrayList<DcEvent> dcEvents = new ArrayList<>();
List<String> startStakeMarks = castList(parameter.get("startStakeMark"), String.class);
List<String> endStakeMarks = castList(parameter.get("endStakeMark"), String.class);
String eventType = String.valueOf(parameter.get("eventType"));
LambdaQueryWrapper<DcEvent> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DcEvent::getEventType, eventType);
List<DcEvent> list = list(lambdaQueryWrapper);
if (startStakeMarks != null && endStakeMarks != null) {
Integer startStakeMark = Integer.parseInt(startStakeMarks.get(0) + startStakeMarks.get(1));
Integer endStakeMark = Integer.parseInt(endStakeMarks.get(0) + endStakeMarks.get(1));
for (DcEvent dcEvent : list) {
String stakeMark = dcEvent.getStakeMark();
Pattern pat = Pattern.compile(REGEX_CHINESE);
Matcher mat = pat.matcher(stakeMark);
stakeMark = mat.replaceAll("");
if (stakeMark == null || stakeMark.equals("")) {
continue;
}
if (stakeMark.startsWith("-")) {
String[] split = stakeMark.replace("K", "").replace("k", "").split("-");
for (String s : split) {
String[] ks = s.split("\\+");
double integer = Double.parseDouble(ks[0] + ks[1]);
if (startStakeMark <= integer && endStakeMark >= integer) {
dcEvents.add(dcEvent);
}
}
} else {
String[] ks = stakeMark.replace("K", "").replace("k", "").split("\\+");
double integer = Double.parseDouble(ks[0] + ks[1]);
if (startStakeMark <= integer && endStakeMark >= integer) {
dcEvents.add(dcEvent);
}
}
}
} else {
dcEvents = (ArrayList<DcEvent>) list;
}
return dcEvents;
}
public static <T> List<T> castList(Object obj, Class<T> clazz) {
List<T> result = new ArrayList<T>();
if (obj instanceof List<?>) {
for (Object o : (List<?>) obj) {
result.add(clazz.cast(o));
}
return result;
}
return null;
}
}

7
zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml

@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="deviceImg" column="device_img"/>
<result property="longitude" column="longitude"/>
<result property="latitude" column="latitude"/>
<result property="childType" column="child_type"/>
</resultMap>
<resultMap id="dcStakeMarkResult" type="dcStakeMark">
@ -62,7 +63,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
facilities_type,
device_ip,
stake_mark_range,
device_img
device_img,
child_type
from dc_device
</sql>
@ -70,7 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDcDeviceList" parameterType="dcDevice" resultMap="DcDevice">
select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark, t1.direction, t1.device_name, t1.device_code, t1.device_type,
t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site,t1.use_state,t1.device_state,t1.other_config,t1.remark,
t1.create_time,t1.update_time,t1.facilities_type,t1.device_ip,t1.stake_mark_range,t1.device_img,
t1.create_time,t1.update_time,t1.facilities_type,t1.device_ip,t1.stake_mark_range,t1.device_img,t1.child_type,
t1.facilities_type,t2.longitude,t2.latitude
from dc_device t1
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction
@ -98,6 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deviceIp != null and deviceIp != ''">and t1.device_ip = #{deviceIp}</if>
<if test="stakeMarkRange != null and stakeMarkRange != ''">and t1.stake_mark_range = #{stakeMarkRange}</if>
<if test="deviceImg != null and deviceImg != ''">and t1.device_img = #{deviceImg}</if>
<if test="childType != null and childType != ''">and t1.child_type = #{childType}</if>
</where>
</select>

Loading…
Cancel
Save