Browse Source

优化设备按照桩号查询

新增事件桩号范围查询
新增批量调用设备功能接口
develop
zhaoxianglong 1 year ago
parent
commit
950233b932
  1. 23
      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. 72
      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

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

@ -94,7 +94,7 @@ public class DcDeviceController extends BaseController {
@ApiOperation("无分页根据设备桩号查询设备列表") @ApiOperation("无分页根据设备桩号查询设备列表")
@PreAuthorize("@ss.hasPermi('iot:device:query')") @PreAuthorize("@ss.hasPermi('iot:device:query')")
@PostMapping("pileNumberQuery") @PostMapping("pileNumberQuery")
public AjaxResult devicePileNumberQueryDevice(@RequestBody Map<String,Object> parameter) { public AjaxResult devicePileNumberQueryDevice(@RequestBody Map<String, Object> parameter) {
return AjaxResult.success(dcDeviceService.devicePileNumberQueryDevice(parameter)); return AjaxResult.success(dcDeviceService.devicePileNumberQueryDevice(parameter));
} }
@ -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; package com.zc.business.controller;
import java.io.InputStream;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletResponse; 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.domain.DcEvent;
import com.zc.business.service.IDcEventService; import com.zc.business.service.IDcEventService;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired; 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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
@ -58,6 +53,17 @@ public class DcEventController extends BaseController
return getDataTable(list); 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; private Date createTime;
@ApiModelProperty("修改时间") @ApiModelProperty("修改时间")
private Date updateTime; private Date updateTime;
@ApiModelProperty("子类型")
private String childType;
@TableField(exist = false) @TableField(exist = false)
private String longitude; private String longitude;
@TableField(exist = false) @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.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
@ -11,10 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; 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.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/** /**
* 事件信息对象 dc_event * 事件信息对象 dc_event
@ -27,7 +23,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class DcEvent extends BaseEntity { public class DcEvent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final long event_state = 0L; private static final long event_state = 0L;
/** /**
@ -42,6 +38,7 @@ public class DcEvent extends BaseEntity {
@ApiModelProperty("所属部门") @ApiModelProperty("所属部门")
private Long deptId; private Long deptId;
@Excel(name = "所属部门") @Excel(name = "所属部门")
@TableField(exist = false)
private String deptName; private String deptName;
/** /**
@ -282,4 +279,18 @@ public class DcEvent extends BaseEntity {
@ApiModelProperty("事件类型名称") @ApiModelProperty("事件类型名称")
@TableField(exist = false) @TableField(exist = false)
private String eventName; 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; package com.zc.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.DcEvent; import com.zc.business.domain.DcEvent;
import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -13,7 +15,8 @@ import java.util.Map;
* @author ruoyi * @author ruoyi
* @date 2024-01-12 * @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); DcEvent selectEventSubclassById(int eventType, String id);
Map<String,Object> selectCount(); Map<String,Object> selectCount();
List<DcEvent> eventPileNumberQueryEvent(Map<String, Object> parameter);
} }

72
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; private RedisCache redisCache;
@PostConstruct @PostConstruct
public void init() public void init() {
{
/* /*
添加数据到 redis 缓存 添加数据到 redis 缓存
*/ */
@ -57,12 +56,10 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
/** /**
* 添加数据到 redis 缓存 * 添加数据到 redis 缓存
*/ */
public void updateRedisCache() public void updateRedisCache() {
{
// 获取全部设备列表数据 // 获取全部设备列表数据
List<DcDevice> dcDevices = list(); List<DcDevice> dcDevices = list();
if (dcDevices == null || dcDevices.isEmpty()) if (dcDevices == null || dcDevices.isEmpty()) {
{
return; return;
} }
@ -396,39 +393,50 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
List<String> startStakeMarks = castList(parameter.get("startStakeMark"), String.class); List<String> startStakeMarks = castList(parameter.get("startStakeMark"), String.class);
List<String> endStakeMarks = castList(parameter.get("endStakeMark"), String.class); List<String> endStakeMarks = castList(parameter.get("endStakeMark"), String.class);
String deviceType = String.valueOf(parameter.get("deviceType")); String deviceType = String.valueOf(parameter.get("deviceType"));
Integer startStakeMark = Integer.parseInt(startStakeMarks.get(0) + startStakeMarks.get(1)); String childType = String.valueOf(parameter.get("childType"));
Integer endStakeMark = Integer.parseInt(endStakeMarks.get(0) + endStakeMarks.get(1)); String deviceState = String.valueOf(parameter.get("deviceState"));
LambdaQueryWrapper<DcDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>(); DcDevice device = new DcDevice();
ArrayList<Integer> integers = new ArrayList<>(); if (!Objects.equals(childType, "null")) {
integers.add(6); device.setChildType(childType);
lambdaQueryWrapper.notIn(DcDevice::getDeviceType, integers); }
lambdaQueryWrapper.eq(DcDevice::getDeviceType, deviceType); if (!Objects.equals(deviceType, "null")) {
List<DcDevice> list = list(lambdaQueryWrapper); device.setDeviceType(Integer.valueOf(deviceType));
for (DcDevice dcDevice : list) { }
String stakeMark = dcDevice.getStakeMark(); if (!Objects.equals(deviceState, "null")) {
Pattern pat = Pattern.compile(REGEX_CHINESE); device.setDeviceState(deviceState);
Matcher mat = pat.matcher(stakeMark); }
stakeMark = mat.replaceAll(""); List<DcDevice> list = listDevice(device);
if (stakeMark == null || stakeMark.equals("")) { if (startStakeMarks != null && endStakeMarks != null) {
continue; Integer startStakeMark = Integer.parseInt(startStakeMarks.get(0) + startStakeMarks.get(1));
} Integer endStakeMark = Integer.parseInt(endStakeMarks.get(0) + endStakeMarks.get(1));
for (DcDevice dcDevice : list) {
String stakeMark = dcDevice.getStakeMark();
Pattern pat = Pattern.compile(REGEX_CHINESE);
Matcher mat = pat.matcher(stakeMark);
stakeMark = mat.replaceAll("");
if (stakeMark == null || stakeMark.equals("")) {
continue;
}
if (stakeMark.startsWith("-")) { if (stakeMark.startsWith("-")) {
String[] split = stakeMark.replace("K", "").replace("k", "").split("-"); String[] split = stakeMark.replace("K", "").replace("k", "").split("-");
for (String s : split) { for (String s : split) {
String[] ks = s.split("\\+"); String[] ks = s.split("\\+");
double integer = Double.parseDouble(ks[0] + ks[1]);
if (startStakeMark <= integer && endStakeMark >= integer) {
dcDevices.add(dcDevice);
}
}
} else {
String[] ks = stakeMark.replace("K", "").replace("k", "").split("\\+");
double integer = Double.parseDouble(ks[0] + ks[1]); double integer = Double.parseDouble(ks[0] + ks[1]);
if (startStakeMark <= integer && endStakeMark >= integer) { if (startStakeMark <= integer && endStakeMark >= integer) {
dcDevices.add(dcDevice); dcDevices.add(dcDevice);
} }
} }
} else {
String[] ks = stakeMark.replace("K", "").replace("k", "").split("\\+");
double integer = Double.parseDouble(ks[0] + ks[1]);
if (startStakeMark <= integer && endStakeMark >= integer) {
dcDevices.add(dcDevice);
}
} }
} else {
dcDevices = (ArrayList<DcDevice>) list;
} }
return dcDevices; 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; 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.DateUtils;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
@ -25,7 +30,7 @@ import java.util.Map;
*/ */
@Service @Service
@Transactional @Transactional
public class DcEventServiceImpl implements IDcEventService { public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> implements IDcEventService {
@Autowired @Autowired
private DcEventMapper dcEventMapper; private DcEventMapper dcEventMapper;
//异常天气 //异常天气
@ -576,4 +581,62 @@ public class DcEventServiceImpl implements IDcEventService {
map.put("warningCount", i); map.put("warningCount", i);
return map; 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="deviceImg" column="device_img"/>
<result property="longitude" column="longitude"/> <result property="longitude" column="longitude"/>
<result property="latitude" column="latitude"/> <result property="latitude" column="latitude"/>
<result property="childType" column="child_type"/>
</resultMap> </resultMap>
<resultMap id="dcStakeMarkResult" type="dcStakeMark"> <resultMap id="dcStakeMarkResult" type="dcStakeMark">
@ -62,7 +63,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
facilities_type, facilities_type,
device_ip, device_ip,
stake_mark_range, stake_mark_range,
device_img device_img,
child_type
from dc_device from dc_device
</sql> </sql>
@ -70,7 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDcDeviceList" parameterType="dcDevice" resultMap="DcDevice"> <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, 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.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 t1.facilities_type,t2.longitude,t2.latitude
from dc_device t1 from dc_device t1
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction 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="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="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="deviceImg != null and deviceImg != ''">and t1.device_img = #{deviceImg}</if>
<if test="childType != null and childType != ''">and t1.child_type = #{childType}</if>
</where> </where>
</select> </select>

Loading…
Cancel
Save