From 950233b932fac63e1c3f62a8f7fe231f5f6b6260 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Fri, 15 Mar 2024 14:45:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BE=E5=A4=87=E6=8C=89?= =?UTF-8?q?=E7=85=A7=E6=A1=A9=E5=8F=B7=E6=9F=A5=E8=AF=A2=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=BA=8B=E4=BB=B6=E6=A1=A9=E5=8F=B7=E8=8C=83=E5=9B=B4?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20=E6=96=B0=E5=A2=9E=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E8=AE=BE=E5=A4=87=E5=8A=9F=E8=83=BD=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcDeviceController.java | 23 +++++- .../controller/DcEventController.java | 18 +++-- .../java/com/zc/business/domain/DcDevice.java | 2 + .../java/com/zc/business/domain/DcEvent.java | 21 ++++-- .../com/zc/business/mapper/DcEventMapper.java | 5 +- .../zc/business/service/IDcEventService.java | 18 ++--- .../service/impl/DcDeviceServiceImpl.java | 72 ++++++++++--------- .../service/impl/DcEventServiceImpl.java | 65 ++++++++++++++++- .../mapper/business/DcDeviceMapper.xml | 7 +- 9 files changed, 175 insertions(+), 56 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java index c70181c8..e34ac4ca 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java @@ -94,7 +94,7 @@ public class DcDeviceController extends BaseController { @ApiOperation("无分页根据设备桩号查询设备列表") @PreAuthorize("@ss.hasPermi('iot:device:query')") @PostMapping("pileNumberQuery") - public AjaxResult devicePileNumberQueryDevice(@RequestBody Map parameter) { + public AjaxResult devicePileNumberQueryDevice(@RequestBody Map 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 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); + } + /** * 查询物联设备事件数据 * diff --git a/zc-business/src/main/java/com/zc/business/controller/DcEventController.java b/zc-business/src/main/java/com/zc/business/controller/DcEventController.java index 6e8acc50..028532e5 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcEventController.java +++ b/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; @@ -31,7 +26,7 @@ import com.ruoyi.common.core.page.TableDataInfo; /** * 事件信息Controller - * + * * @author ruoyi * @date 2024-01-03 */ @@ -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 parameter) + { + return AjaxResult.success(dcEventService.eventPileNumberQueryEvent(parameter)); + } + /**调度记录-事件列表 按时间展示交通事件。默认当天时间 。可查询条件 交通事件状态 ,时间范围 * */ diff --git a/zc-business/src/main/java/com/zc/business/domain/DcDevice.java b/zc-business/src/main/java/com/zc/business/domain/DcDevice.java index dde7d70a..ee3d8a32 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcDevice.java +++ b/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) diff --git a/zc-business/src/main/java/com/zc/business/domain/DcEvent.java b/zc-business/src/main/java/com/zc/business/domain/DcEvent.java index aa408fac..f3b71177 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcEvent.java +++ b/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; } diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java index 13f71f19..24fc59d0 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcEventMapper.java +++ b/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 { /** * 查询事件信息 diff --git a/zc-business/src/main/java/com/zc/business/service/IDcEventService.java b/zc-business/src/main/java/com/zc/business/service/IDcEventService.java index 2b84d839..7ac8db57 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcEventService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcEventService.java @@ -8,15 +8,15 @@ import java.util.Map; /** * 事件信息Service接口 - * + * * @author ruoyi * @date 2024-01-03 */ -public interface IDcEventService +public interface IDcEventService { /** * 查询事件信息 - * + * * @param id 事件信息主键 * @return 事件信息 */ @@ -24,7 +24,7 @@ public interface IDcEventService /** * 查询事件信息列表 - * + * * @param dcEvent 事件信息 * @return 事件信息集合 */ @@ -32,7 +32,7 @@ public interface IDcEventService /** * 新增事件信息 - * + * * @param dcEvent 事件信息 * @return 结果 */ @@ -40,7 +40,7 @@ public interface IDcEventService public int insertDcEventWarning(DcEvent dcEvent); /** * 修改事件信息 - * + * * @param dcEvent 事件信息 * @return 结果 */ @@ -48,7 +48,7 @@ public interface IDcEventService /** * 批量删除事件信息 - * + * * @param ids 需要删除的事件信息主键集合 * @return 结果 */ @@ -56,7 +56,7 @@ public interface IDcEventService /** * 删除事件信息信息 - * + * * @param id 事件信息主键 * @return 结果 */ @@ -76,4 +76,6 @@ public interface IDcEventService DcEvent selectEventSubclassById(int eventType, String id); Map selectCount(); + + List eventPileNumberQueryEvent(Map parameter); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java index 1f4c0cce..25f04bd7 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java @@ -46,8 +46,7 @@ public class DcDeviceServiceImpl extends ServiceImpl i private RedisCache redisCache; @PostConstruct - public void init() - { + public void init() { /* 添加数据到 redis 缓存 */ @@ -57,12 +56,10 @@ public class DcDeviceServiceImpl extends ServiceImpl i /** * 添加数据到 redis 缓存 */ - public void updateRedisCache() - { + public void updateRedisCache() { // 获取全部设备列表数据 List dcDevices = list(); - if (dcDevices == null || dcDevices.isEmpty()) - { + if (dcDevices == null || dcDevices.isEmpty()) { return; } @@ -396,39 +393,50 @@ public class DcDeviceServiceImpl extends ServiceImpl i List startStakeMarks = castList(parameter.get("startStakeMark"), String.class); List endStakeMarks = castList(parameter.get("endStakeMark"), String.class); String deviceType = String.valueOf(parameter.get("deviceType")); - Integer startStakeMark = Integer.parseInt(startStakeMarks.get(0) + startStakeMarks.get(1)); - Integer endStakeMark = Integer.parseInt(endStakeMarks.get(0) + endStakeMarks.get(1)); - LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - ArrayList integers = new ArrayList<>(); - integers.add(6); - lambdaQueryWrapper.notIn(DcDevice::getDeviceType, integers); - lambdaQueryWrapper.eq(DcDevice::getDeviceType, deviceType); - List list = list(lambdaQueryWrapper); - 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; - } + 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 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)); + 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("-")) { - String[] split = stakeMark.replace("K", "").replace("k", "").split("-"); - for (String s : split) { - String[] ks = s.split("\\+"); + 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) { + 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 { - 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) list; } return dcDevices; diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java index 5fc4be0f..98415896 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java +++ b/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 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 eventPileNumberQueryEvent(Map parameter) { + + ArrayList dcEvents = new ArrayList<>(); + List startStakeMarks = castList(parameter.get("startStakeMark"), String.class); + List endStakeMarks = castList(parameter.get("endStakeMark"), String.class); + String eventType = String.valueOf(parameter.get("eventType")); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(DcEvent::getEventType, eventType); + List 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) list; + } + return dcEvents; + } + + public static List castList(Object obj, Class clazz) { + List result = new ArrayList(); + if (obj instanceof List) { + for (Object o : (List) obj) { + result.add(clazz.cast(o)); + } + return result; + } + return null; + } } diff --git a/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml b/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml index 52c868b6..b9c350de 100644 --- a/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml @@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -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 @@ -70,7 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"