merge upstream

This commit is contained in:
2025-09-02 09:06:54 +08:00
55 changed files with 2461 additions and 113 deletions

View File

@ -14,7 +14,7 @@ public class AppRealTimeStatusDto {
private String deviceImei;
/**
* 设备类型
* 获取实时状态类型FunctionAccessBatchStatusRule 批量 FunctionAccessStatusRule 单个
*/
private String typeName;

View File

@ -10,6 +10,7 @@ import com.fuyuanshen.global.mqtt.base.MqttRuleContext;
import com.fuyuanshen.global.mqtt.base.MqttRuleEngine;
import com.fuyuanshen.global.mqtt.base.MqttXinghanCommandType;
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
import com.fuyuanshen.global.queue.MqttMessageQueueConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
@ -51,6 +52,9 @@ public class ReceiverMessageHandler implements MessageHandler {
//在线状态
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "1", Duration.ofSeconds(62));
// String queueKey = MqttMessageQueueConstants.MQTT_MESSAGE_QUEUE_KEY;
// String dedupKey = MqttMessageQueueConstants.MQTT_MESSAGE_DEDUP_KEY;
// RedisUtils.offerDeduplicated(queueKey,dedupKey,deviceImei, Duration.ofHours(24));
}
String state = payloadDict.getStr("state");

View File

@ -0,0 +1,110 @@
package com.fuyuanshen.global.queue;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@Service
@Slf4j
public class MqttMessageConsumer {
@Autowired
private DeviceMapper deviceMapper;
// 创建两个线程池:一个用于消息获取,一个用于业务处理
private ExecutorService messageConsumerPool = Executors.newFixedThreadPool(3);
private ExecutorService messageProcessorPool = Executors.newFixedThreadPool(10);
// 初始化方法,启动消息监听
// @PostConstruct
public void start() {
log.info("启动MQTT消息消费者...");
// 启动消息获取线程
for (int i = 0; i < 3; i++) {
messageConsumerPool.submit(this::consumeMessages);
}
}
// 销毁方法,关闭线程池
@PreDestroy
public void stop() {
log.info("关闭MQTT消息消费者...");
shutdownExecutorService(messageConsumerPool);
shutdownExecutorService(messageProcessorPool);
}
private void shutdownExecutorService(ExecutorService executorService) {
if (executorService != null && !executorService.isShutdown()) {
executorService.shutdown();
try {
if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
executorService.shutdownNow();
}
} catch (InterruptedException e) {
executorService.shutdownNow();
Thread.currentThread().interrupt();
}
}
}
// 消费者方法 - 专门负责从队列获取消息
public void consumeMessages() {
String queueKey = MqttMessageQueueConstants.MQTT_MESSAGE_QUEUE_KEY;
String threadName = Thread.currentThread().getName();
log.info("消息消费者线程 {} 开始监听队列: {}", threadName, queueKey);
try {
while (!Thread.currentThread().isInterrupted() && !messageConsumerPool.isShutdown()) {
// 阻塞式获取队列中的消息
String message = RedisUtils.pollDeduplicated(
queueKey,
MqttMessageQueueConstants.MQTT_MESSAGE_DEDUP_KEY,
1,
TimeUnit.SECONDS
);
if (message != null) {
log.info("线程 {} 从队列中获取到消息,提交到处理线程池: {}", threadName, message);
// 将消息处理任务提交到处理线程池
messageProcessorPool.submit(() -> processMessage(message));
}
}
} catch (Exception e) {
log.error("线程 {} 消费消息时发生错误", threadName, e);
}
log.info("消息消费者线程 {} 停止监听队列", threadName);
}
// 处理具体业务逻辑的方法
private void processMessage(String message) {
String threadName = Thread.currentThread().getName();
try {
log.info("业务处理线程 {} 开始处理消息: {}", threadName, message);
// 实现具体的业务逻辑
// 例如更新数据库、发送通知等
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("device_imei", message)
.set("online_status", 1);
deviceMapper.update(updateWrapper);
// 模拟业务处理耗时
Thread.sleep(200);
log.info("业务处理线程 {} 完成消息处理: {}", threadName, message);
} catch (Exception e) {
log.error("业务处理线程 {} 处理消息时发生错误: {}", threadName, message, e);
}
}
}

View File

@ -0,0 +1,6 @@
package com.fuyuanshen.global.queue;
public class MqttMessageQueueConstants {
public static final String MQTT_MESSAGE_QUEUE_KEY = "mqtt:message:queue";
public static final String MQTT_MESSAGE_DEDUP_KEY = "mqtt:message:dedup";
}

View File

@ -0,0 +1,107 @@
package com.fuyuanshen.web.controller.device;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.common.excel.utils.ExcelUtil;
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
import com.fuyuanshen.common.log.annotation.Log;
import com.fuyuanshen.common.log.enums.BusinessType;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.equipment.service.IDeviceAlarmService;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 设备告警
*
* @author Lion Li
* @date 2025-08-28
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("api/equipment/alarm")
public class DeviceAlarmController extends BaseController {
private final IDeviceAlarmService deviceAlarmService;
/**
* 查询设备告警列表
*/
// @SaCheckPermission("equipment:alarm:list")
@GetMapping("/list")
public TableDataInfo<DeviceAlarmVo> list(DeviceAlarmBo bo, PageQuery pageQuery) {
return deviceAlarmService.queryPageList(bo, pageQuery);
}
/**
* 导出设备告警列表
*/
// @SaCheckPermission("equipment:alarm:export")
@Log(title = "导出设备告警列表", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(DeviceAlarmBo bo, HttpServletResponse response) {
List<DeviceAlarmVo> list = deviceAlarmService.queryList(bo);
ExcelUtil.exportExcel(list, "设备告警", DeviceAlarmVo.class, response);
}
/**
* 获取设备告警详细信息
*
* @param id 主键
*/
// @SaCheckPermission("equipment:alarm:query")
@GetMapping("/{id}")
public R<DeviceAlarmVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(deviceAlarmService.queryById(id));
}
/**
* 新增设备告警
*/
// @SaCheckPermission("equipment:alarm:add")
@Log(title = "设备告警", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody DeviceAlarmBo bo) {
return toAjax(deviceAlarmService.insertByBo(bo));
}
/**
* 修改设备告警
*/
// @SaCheckPermission("equipment:alarm:edit")
@Log(title = "设备告警", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody DeviceAlarmBo bo) {
return toAjax(deviceAlarmService.updateByBo(bo));
}
/**
* 删除设备告警
*
* @param ids 主键串
*/
// @SaCheckPermission("equipment:alarm:remove")
@Log(title = "设备告警", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(deviceAlarmService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@ -0,0 +1,105 @@
package com.fuyuanshen.web.controller.device;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
import com.fuyuanshen.common.log.annotation.Log;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.common.log.enums.BusinessType;
import com.fuyuanshen.common.excel.utils.ExcelUtil;
import com.fuyuanshen.equipment.domain.vo.DeviceChargeDischargeVo;
import com.fuyuanshen.equipment.domain.bo.DeviceChargeDischargeBo;
import com.fuyuanshen.equipment.service.IDeviceChargeDischargeService;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
/**
* 设备充放电记录
*
* @author Lion Li
* @date 2025-08-30
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/equipment/chargeDischarge")
public class DeviceChargeDischargeController extends BaseController {
private final IDeviceChargeDischargeService deviceChargeDischargeService;
/**
* 查询设备充放电记录列表
*/
@SaCheckPermission("equipment:chargeDischarge:list")
@GetMapping("/list")
public TableDataInfo<DeviceChargeDischargeVo> list(DeviceChargeDischargeBo bo, PageQuery pageQuery) {
return deviceChargeDischargeService.queryPageList(bo, pageQuery);
}
/**
* 设备充放电记录列表
*/
@SaCheckPermission("equipment:chargeDischarge:export")
@Log(title = "设备充放电记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(DeviceChargeDischargeBo bo, HttpServletResponse response) {
List<DeviceChargeDischargeVo> list = deviceChargeDischargeService.queryList(bo);
ExcelUtil.exportExcel(list, "设备充放电记录", DeviceChargeDischargeVo.class, response);
}
/**
* 获取设备充放电记录详细信息
*
* @param id 主键
*/
@SaCheckPermission("equipment:chargeDischarge:query")
@GetMapping("/{id}")
public R<DeviceChargeDischargeVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(deviceChargeDischargeService.queryById(id));
}
/**
* 新增设备充放电记录
*/
@SaCheckPermission("equipment:chargeDischarge:add")
@Log(title = "设备充放电记录", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody DeviceChargeDischargeBo bo) {
return toAjax(deviceChargeDischargeService.insertByBo(bo));
}
/**
* 修改设备充放电记录
*/
@SaCheckPermission("equipment:chargeDischarge:edit")
@Log(title = "设备充放电记录", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody DeviceChargeDischargeBo bo) {
return toAjax(deviceChargeDischargeService.updateByBo(bo));
}
/**
* 删除设备充放电记录
*
* @param ids 主键串
*/
@SaCheckPermission("equipment:chargeDischarge:remove")
@Log(title = "设备充放电记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(deviceChargeDischargeService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@ -4,16 +4,16 @@ import com.fuyuanshen.app.domain.dto.APPReNameDTO;
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.excel.utils.ExcelUtil;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.InstructionRecordVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import com.fuyuanshen.equipment.domain.vo.*;
import com.fuyuanshen.web.service.device.DeviceBizService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
@ -32,6 +32,8 @@ import java.util.Map;
public class DeviceControlCenterController extends BaseController {
private final DeviceBizService appDeviceService;
/**
* 查询设备列表
*/
@ -101,4 +103,48 @@ public class DeviceControlCenterController extends BaseController {
return appDeviceService.getInstructionRecord(dto,pageQuery);
}
/**
* 导出
*/
@GetMapping("/export")
public void export(InstructionRecordDto dto, PageQuery pageQuery, HttpServletResponse response) {
pageQuery.setPageNum(1);
pageQuery.setPageSize(2000);
TableDataInfo<InstructionRecordVo> instructionRecord = appDeviceService.getInstructionRecord(dto, pageQuery);
if(instructionRecord.getRows() == null){
return;
}
ExcelUtil.exportExcel(instructionRecord.getRows(), "设备操作日志", InstructionRecordVo.class, response);
}
/**
* 历史轨迹查询
*/
@GetMapping("/locationHistory")
public TableDataInfo<LocationHistoryVo> getLocationHistory(InstructionRecordDto dto, PageQuery pageQuery) {
return appDeviceService.getLocationHistory(dto,pageQuery);
}
/**
* 历史轨迹导出
*/
@GetMapping("/locationHistoryExport")
public void locationHistoryExport(InstructionRecordDto dto, PageQuery pageQuery, HttpServletResponse response) {
pageQuery.setPageNum(1);
pageQuery.setPageSize(2000);
TableDataInfo<LocationHistoryVo> result = appDeviceService.getLocationHistory(dto, pageQuery);
if(result.getRows() == null){
return;
}
ExcelUtil.exportExcel(result.getRows(), "历史轨迹记录", LocationHistoryVo.class, response);
}
/**
* 历史轨迹播放
*/
@GetMapping("/getLocationHistoryDetail")
public R<List<LocationHistoryDetailVo>> getLocationHistoryDetail(Long id) {
return R.ok(appDeviceService.getLocationHistoryDetail(id));
}
}

View File

@ -1,27 +1,27 @@
package com.fuyuanshen.web.controller.device;
import java.util.List;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
import com.fuyuanshen.common.log.annotation.Log;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.common.log.enums.BusinessType;
import com.fuyuanshen.common.excel.utils.ExcelUtil;
import com.fuyuanshen.equipment.domain.vo.DeviceGroupVo;
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
import com.fuyuanshen.common.log.annotation.Log;
import com.fuyuanshen.common.log.enums.BusinessType;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.bo.DeviceGroupBo;
import com.fuyuanshen.equipment.domain.vo.DeviceGroupVo;
import com.fuyuanshen.equipment.service.IDeviceGroupService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 设备分组
@ -51,6 +51,24 @@ public class DeviceGroupController extends BaseController {
}
/**
* 查询设备分组列表(分页)
*/
@Operation(summary = "查询设备分组列表(分页)")
@SaCheckPermission("fys-equipment:group:list")
@GetMapping("/listPage")
public TableDataInfo<DeviceGroupVo> listPage(DeviceGroupBo bo) {
List<DeviceGroupVo> list = deviceGroupService.queryList(bo);
// return R.ok(list);
return null;
}
// @GetMapping("/list")
// public TableDataInfo<DeviceAlarmVo> list(DeviceAlarmBo bo, PageQuery pageQuery) {
// return deviceAlarmService.queryPageList(bo, pageQuery);
// }
/**
* 导出设备分组列表
*/
@ -110,7 +128,7 @@ public class DeviceGroupController extends BaseController {
@SaCheckPermission("fys-equipment:group:remove")
@Log(title = "设备分组", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
public R<Void> remove(@NotNull(message = "主键不能为空") @PathVariable Long[] ids) {
return toAjax(deviceGroupService.deleteWithValidByIds(List.of(ids), true));
}
@ -124,11 +142,25 @@ public class DeviceGroupController extends BaseController {
@Operation(summary = "绑定设备分组")
// @SaCheckPermission("fys-equipment:group:remove")
@Log(title = "绑定设备分组", businessType = BusinessType.DELETE)
@GetMapping("/groupId/{deviceId}")
public R<Void> bindingDevice(@NotEmpty(message = "分组id 不能为空") @PathVariable Long groupId,
@NotEmpty(message = "设备id 不能为空") @PathVariable Long[] deviceId) {
@GetMapping("/groupId/{groupId}/{deviceId}")
public R<Void> bindingDevice(@NotNull(message = "分组id 不能为空") @PathVariable Long groupId,
@NotNull(message = "设备id 不能为空") @PathVariable Long[] deviceId) {
return toAjax(deviceGroupService.bindingDevice(groupId, deviceId));
}
/**
* 解绑设备分组
*
* @param deviceId 设备id
*/
@Operation(summary = "解绑设备分组")
// @SaCheckPermission("fys-equipment:group:remove")
@Log(title = "解绑设备分组", businessType = BusinessType.DELETE)
@GetMapping("/groupUnbind/{deviceId}")
public R<Void> groupUnbind(@NotNull(message = "设备id 不能为空") @PathVariable Long[] deviceId) {
return toAjax(deviceGroupService.groupUnbind(deviceId));
}
}

View File

@ -0,0 +1,43 @@
package com.fuyuanshen.web.controller.device;
import com.fuyuanshen.app.domain.bo.AppDeviceShareBo;
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.web.service.DeviceShareService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 设备分享管理
*
* @author Lion Li
* @date 2025-08-28
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("api/equipment/share")
public class DeviceShareController extends BaseController {
private final DeviceShareService appDeviceShareService;
/**
*查询设备分享列表(web)
*/
// @SaCheckPermission("equipment:alarm:list")
@GetMapping("/list")
public TableDataInfo<AppDeviceShareVo> list(AppDeviceShareBo bo, PageQuery pageQuery) {
return appDeviceShareService.queryWebList(bo, pageQuery);
}
}

View File

@ -0,0 +1,67 @@
package com.fuyuanshen.web.controller.device;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.equipment.domain.vo.DataOverviewVo;
import com.fuyuanshen.equipment.service.DeviceService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 首页数据
*
* @author: 默苍璃
* @date: 2025-09-0113:46
*/
@Tag(name = "首页数据", description = "首页数据")
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/device/homepage")
public class HomePageController {
private final DeviceService deviceService;
/**
* 获取 数据总览
* DataOverview
*/
@GetMapping("/getDataOverview")
public R<DataOverviewVo> getDataOverview() {
return R.ok(deviceService.getDataOverview());
}
// 获取设备使用数据
@GetMapping("/{deviceId}")
public Map<String, Object> getUsageData(
@PathVariable String deviceId,
@RequestParam String range) {
Map<String, Object> response = new HashMap<>();
if ("halfYear".equals(range)) {
response.put("months", Arrays.asList("1月", "2月", "3月", "4月", "5月", "6月"));
response.put("data", Arrays.asList(45, 52, 38, 60, 56, 48));
} else if ("oneYear".equals(range)) {
response.put("months", Arrays.asList("7月", "8月", "9月", "10月", "11月", "12月",
"1月", "2月", "3月", "4月", "5月", "6月"));
response.put("data", Arrays.asList(42, 38, 45, 48, 52, 55, 45, 52, 38, 60, 56, 48));
}
response.put("deviceId", deviceId);
response.put("range", range);
response.put("lastUpdate", new Date());
return response;
}
}

View File

@ -4,6 +4,8 @@ package com.fuyuanshen.web.controller.device;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.DeviceLog;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import com.fuyuanshen.web.service.WEBDeviceService;
import io.swagger.v3.oas.annotations.Operation;
@ -51,7 +53,7 @@ public class WEBDeviceController extends BaseController {
*/
@Operation(summary = "设备详情")
@GetMapping(value = "/pc/detail/{id}")
public R<WebDeviceVo> getDevice(@PathVariable Long id) {
public R<WebDeviceVo> getDeviceDetail(@PathVariable Long id) {
WebDeviceVo device = deviceService.getDevice(id);
return R.ok(device);
}
@ -60,13 +62,41 @@ public class WEBDeviceController extends BaseController {
/**
* 设备用户详情
*
* @param id
* @param deviceId
* @return
*/
@Operation(summary = "设备详情")
@GetMapping(value = "/getDeviceUser/{id}")
public R<List<AppPersonnelInfoRecords>> getDeviceUser(@PathVariable Long id) {
List<AppPersonnelInfoRecords> device = deviceService.getDeviceUser(id);
@GetMapping(value = "/getDeviceUser/{deviceId}")
public R<List<AppPersonnelInfoRecords>> getDeviceUser(@PathVariable Long deviceId) {
List<AppPersonnelInfoRecords> device = deviceService.getDeviceUser(deviceId);
return R.ok(device);
}
/**
* 设备操作记录
*
* @param deviceId
* @return
*/
@Operation(summary = "设备操作记录")
@GetMapping(value = "/getOperationRecord/{deviceId}")
public R<List<DeviceLog>> getOperationRecord(@PathVariable Long deviceId) {
List<DeviceLog> device = deviceService.getOperationRecord(deviceId);
return R.ok(device);
}
/**
* 设备告警记录
*
* @param deviceId
* @return
*/
@Operation(summary = "设备告警记录")
@GetMapping(value = "/getAlarmRecord/{deviceId}")
public R<List<DeviceAlarmVo>> getAlarmRecord(@PathVariable Long deviceId) {
List<DeviceAlarmVo> device = deviceService.getAlarmRecord(deviceId);
return R.ok(device);
}

View File

@ -61,32 +61,32 @@ public class DeviceShareService {
}
private static void buildDeviceStatus(AppDeviceShareVo item) {
//设备在线状态
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ item.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
if(StringUtils.isNotBlank(onlineStatus)){
// 设备在线状态
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
if (StringUtils.isNotBlank(onlineStatus)) {
item.setOnlineStatus(1);
}else{
} else {
item.setOnlineStatus(0);
}
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX+ item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX);
// 获取电量
if(StringUtils.isNotBlank(deviceStatus)){
if (StringUtils.isNotBlank(deviceStatus)) {
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
item.setBattery(jsonObject.getString("batteryPercentage"));
}else{
} else {
item.setBattery("0");
}
String location = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY +DEVICE_KEY_PREFIX+ item.getDeviceImei()+ DEVICE_LOCATION_KEY_PREFIX);
if(StringUtils.isNotBlank(location)){
String location = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_LOCATION_KEY_PREFIX);
if (StringUtils.isNotBlank(location)) {
JSONObject jsonObject = JSONObject.parseObject(location);
item.setLatitude(jsonObject.getString("latitude"));
item.setLongitude(jsonObject.getString("longitude"));
}
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY +DEVICE_KEY_PREFIX+ item.getDeviceImei()+ DEVICE_ALARM_KEY_PREFIX);
if(StringUtils.isNotBlank(alarmStatus)){
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
if (StringUtils.isNotBlank(alarmStatus)) {
item.setAlarmStatus(alarmStatus);
}
}
@ -96,7 +96,7 @@ public class DeviceShareService {
LambdaQueryWrapper<AppDeviceShare> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AppDeviceShare::getId, id);
List<AppDeviceShareVo> appDeviceShareVos = appDeviceShareMapper.selectVoList(queryWrapper);
if(appDeviceShareVos==null || appDeviceShareVos.isEmpty()){
if (appDeviceShareVos == null || appDeviceShareVos.isEmpty()) {
return null;
}
@ -113,7 +113,7 @@ public class DeviceShareService {
shareDetailVo.setDeviceMac(device.getDeviceMac());
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
if(deviceType!=null){
if (deviceType != null) {
shareDetailVo.setCommunicationMode(Integer.valueOf(deviceType.getCommunicationMode()));
}
shareDetailVo.setDevicePic(device.getDevicePic());
@ -125,52 +125,53 @@ public class DeviceShareService {
LambdaQueryWrapper<AppPersonnelInfo> qw = new LambdaQueryWrapper<>();
qw.eq(AppPersonnelInfo::getDeviceId, device.getId());
List<AppPersonnelInfoVo> appPersonnelInfoVos = appPersonnelInfoMapper.selectVoList(qw);
if(appPersonnelInfoVos!=null && !appPersonnelInfoVos.isEmpty()){
if (appPersonnelInfoVos != null && !appPersonnelInfoVos.isEmpty()) {
shareDetailVo.setPersonnelInfo(appPersonnelInfoVos.get(0));
}
//设备在线状态
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei()+ DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
if(StringUtils.isNotBlank(onlineStatus)){
// 设备在线状态
String onlineStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX);
if (StringUtils.isNotBlank(onlineStatus)) {
shareDetailVo.setOnlineStatus(1);
}else{
} else {
shareDetailVo.setOnlineStatus(0);
}
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_STATUS_KEY_PREFIX);
String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_STATUS_KEY_PREFIX);
// 获取电量
if(StringUtils.isNotBlank(deviceStatus)){
if (StringUtils.isNotBlank(deviceStatus)) {
JSONObject jsonObject = JSONObject.parseObject(deviceStatus);
shareDetailVo.setMainLightMode(jsonObject.getString("mainLightMode"));
shareDetailVo.setLaserLightMode(jsonObject.getString("laserLightMode"));
shareDetailVo.setBatteryPercentage(jsonObject.getString("batteryPercentage"));
shareDetailVo.setChargeState(jsonObject.getString("chargeState"));
shareDetailVo.setBatteryRemainingTime(jsonObject.getString("batteryRemainingTime"));
}else{
} else {
shareDetailVo.setBatteryPercentage("0");
}
// 获取经度纬度
String locationKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
String locationKey = GlobalConstants.GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
String locationInfo = RedisUtils.getCacheObject(locationKey);
if(StringUtils.isNotBlank(locationInfo)){
if (StringUtils.isNotBlank(locationInfo)) {
JSONObject jsonObject = JSONObject.parseObject(locationInfo);
shareDetailVo.setLongitude(jsonObject.get("longitude").toString());
shareDetailVo.setLatitude(jsonObject.get("latitude").toString());
shareDetailVo.setAddress((String)jsonObject.get("address"));
shareDetailVo.setAddress((String) jsonObject.get("address"));
}
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY +DEVICE_KEY_PREFIX+ device.getDeviceImei()+ DEVICE_ALARM_KEY_PREFIX);
if(StringUtils.isNotBlank(alarmStatus)){
String alarmStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_ALARM_KEY_PREFIX);
if (StringUtils.isNotBlank(alarmStatus)) {
shareDetailVo.setAlarmStatus(alarmStatus);
}
String lightBrightness = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY +DEVICE_KEY_PREFIX+ device.getDeviceImei()+ DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX);
if(StringUtils.isNotBlank(lightBrightness)){
String lightBrightness = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX);
if (StringUtils.isNotBlank(lightBrightness)) {
shareDetailVo.setLightBrightness(lightBrightness);
}
return shareDetailVo;
}
/**
* 校验短信验证码
*/
@ -181,14 +182,15 @@ public class DeviceShareService {
}
return code.equals(smsCode);
}
public int deviceShare(AppDeviceShareBo bo) {
boolean flag = validateSmsCode(AppLoginHelper.getTenantId(), bo.getPhonenumber(), bo.getSmsCode());
if(!flag){
if (!flag) {
throw new ServiceException("验证码错误");
}
Device device = deviceMapper.selectById(bo.getDeviceId());
if(device==null){
if (device == null) {
throw new ServiceException("设备不存在");
}
Long userId = AppLoginHelper.getUserId();
@ -196,7 +198,7 @@ public class DeviceShareService {
lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId());
lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber());
Long count = appDeviceShareMapper.selectCount(lqw);
if(count>0){
if (count > 0) {
UpdateWrapper<AppDeviceShare> uw = new UpdateWrapper<>();
uw.eq("device_id", bo.getDeviceId());
@ -206,7 +208,7 @@ public class DeviceShareService {
uw.set("update_time", new Date());
return appDeviceShareMapper.update(uw);
}else {
} else {
AppDeviceShare appDeviceShare = new AppDeviceShare();
appDeviceShare.setDeviceId(bo.getDeviceId());
appDeviceShare.setPhonenumber(bo.getPhonenumber());
@ -232,4 +234,19 @@ public class DeviceShareService {
}
/**
* 查询设备分享列表(web)
*
* @param bo
* @param pageQuery
* @return
*/
public TableDataInfo<AppDeviceShareVo> queryWebList(AppDeviceShareBo bo, PageQuery pageQuery) {
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
Page<AppDeviceShareVo> result = appDeviceShareMapper.selectWebDeviceShareList(bo, page);
List<AppDeviceShareVo> records = result.getRecords();
records.forEach(DeviceShareService::buildDeviceStatus);
return TableDataInfo.build(result);
}
}

View File

@ -6,11 +6,13 @@ import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.DeviceLog;
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
import com.fuyuanshen.equipment.domain.form.DeviceForm;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.CustomerVo;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import java.io.IOException;
@ -45,6 +47,22 @@ public interface WEBDeviceService extends IService<Device> {
* @param id
* @return
*/
List<AppPersonnelInfoRecords> getDeviceUser(Long id);
List<AppPersonnelInfoRecords> getDeviceUser(Long id);
/**
* 设备操作记录
*
* @param deviceId
* @return
*/
List<DeviceLog> getOperationRecord(Long deviceId);
/**
* 设备告警记录
*
* @param deviceId
* @return
*/
List<DeviceAlarmVo> getAlarmRecord(Long deviceId);
}

View File

@ -1,6 +1,7 @@
package com.fuyuanshen.web.service.device;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@ -27,9 +28,7 @@ import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.InstructionRecordVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import com.fuyuanshen.equipment.domain.vo.*;
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
@ -41,9 +40,8 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.time.*;
import java.util.*;
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
@ -313,8 +311,8 @@ public class DeviceBizService {
public Map<String, Object> getRealTimeStatus(AppRealTimeStatusDto statusDto) {
try {
String commandType = statusDto.getTypeName()+"_" + statusDto.getFunctionMode();
DeviceStatusRule rule = realTimeStatusEngine.getDeviceStatusRule(commandType);
// String commandType = statusDto.getTypeName()+"_" + statusDto.getFunctionMode();"FunctionAccessBatchStatusRule"
DeviceStatusRule rule = realTimeStatusEngine.getDeviceStatusRule(statusDto.getTypeName());
if(rule == null){
throw new ServiceException("未匹配到处理命令");
}
@ -336,4 +334,63 @@ public class DeviceBizService {
Page<InstructionRecordVo> result = deviceLogMapper.getInstructionRecord(pageQuery.build(), bo);
return TableDataInfo.build(result);
}
public TableDataInfo<LocationHistoryVo> getLocationHistory(InstructionRecordDto bo, PageQuery pageQuery) {
Page<LocationHistoryVo> result = deviceMapper.getLocationHistory(pageQuery.build(), bo);
return TableDataInfo.build(result);
}
public List<LocationHistoryDetailVo> getLocationHistoryDetail(Long id) {
Device device = deviceMapper.selectById(id);
if (device == null) {
throw new ServiceException("设备不存在");
}
// 计算七天前的凌晨时间戳
LocalDateTime sevenDaysAgo = LocalDateTime.of(LocalDate.now().minusDays(7), LocalTime.MIDNIGHT);
long startTime = sevenDaysAgo.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
// 计算今天的凌晨时间戳
LocalDateTime today = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
long endTime = today.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
String deviceImei = device.getDeviceImei();
String a = GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DEVICE_LOCATION_KEY_PREFIX + ":history";
Collection<String> list = RedisUtils.zRangeByScore(a, startTime, endTime);
if (CollectionUtil.isEmpty(list)) {
return null;
}
Map<String, List<JSONObject>> map = new LinkedHashMap<>();
for (String obj : list){
JSONObject jsonObject = JSONObject.parseObject(obj);
Long timestamp = jsonObject.getLong("timestamp");
LocalDate date = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()).toLocalDate();
if (map.containsKey(date.toString())) {
map.get(date.toString()).add(jsonObject);
} else {
ArrayList<JSONObject> jsonList = new ArrayList<>();
jsonList.add(jsonObject);
map.put(date.toString(), jsonList);
}
}
List<LocationHistoryDetailVo> result = new ArrayList<>();
for (Map.Entry<String, List<JSONObject>> entry : map.entrySet()) {
LocationHistoryDetailVo detailVo = new LocationHistoryDetailVo();
detailVo.setDate(entry.getKey());
detailVo.setDeviceName(device.getDeviceName());
detailVo.setStartLocation(entry.getValue().get(0).getString("address"));
detailVo.setEndLocation(entry.getValue().get(entry.getValue().size()-1).getString("address"));
String jsonString = JSONArray.toJSONString(entry.getValue());
List<Object> strings = JSONArray.parseArray(jsonString);
detailVo.setDetailList(strings);
result.add(detailVo);
}
return result;
}
}

View File

@ -22,7 +22,7 @@ import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCES
public class FunctionAccessBatchStatusRule implements DeviceStatusRule {
@Override
public String getCommandType() {
return DeviceTypeConstants.TYPE_BJQ6170+"_2";
return "FunctionAccessBatchStatusRule";
}
@Override

View File

@ -21,7 +21,7 @@ import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCES
public class FunctionAccessStatusRule implements DeviceStatusRule {
@Override
public String getCommandType() {
return DeviceTypeConstants.TYPE_BJQ6170+"_1";
return "FunctionAccessStatusRule";
}
@Override

View File

@ -12,10 +12,15 @@ import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoRecordsMapper;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.DeviceAlarm;
import com.fuyuanshen.equipment.domain.DeviceAssignments;
import com.fuyuanshen.equipment.domain.DeviceLog;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
import com.fuyuanshen.equipment.mapper.DeviceAlarmMapper;
import com.fuyuanshen.equipment.mapper.DeviceAssignmentsMapper;
import com.fuyuanshen.equipment.mapper.DeviceLogMapper;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.web.service.WEBDeviceService;
import com.fuyuanshen.web.service.device.DeviceBizService;
@ -40,6 +45,8 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
private final AppDeviceBindRecordMapper appDeviceBindRecordMapper;
private final AppPersonnelInfoRecordsMapper infoRecordsMapper;
private final DeviceLogMapper deviceLogMapper;
private final DeviceAlarmMapper deviceAlarmMapper;
private final DeviceMapper deviceMapper;
private final AppDeviceShareMapper appDeviceShareMapper;
@ -115,4 +122,35 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
}
/**
* 设备操作记录
*
* @param deviceId
* @return
*/
@Override
public List<DeviceLog> getOperationRecord(Long deviceId) {
List<DeviceLog> logList = deviceLogMapper.selectList(
new QueryWrapper<DeviceLog>().eq("device_id", deviceId)
.orderByDesc("create_time"));
return logList;
}
/**
* 设备告警记录
*
* @param deviceId
* @return
*/
@Override
public List<DeviceAlarmVo> getAlarmRecord(Long deviceId) {
List<DeviceAlarm> alarmList = deviceAlarmMapper.selectList(
new QueryWrapper<DeviceAlarm>().eq("device_id", deviceId)
.orderByDesc("create_time"));
List<DeviceAlarmVo> deviceAlarmVoList = BeanUtil.copyToList(alarmList, DeviceAlarmVo.class);
return deviceAlarmVoList;
}
}

View File

@ -11,6 +11,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -373,6 +374,28 @@ public class RedisUtils {
return 0;
}
}
/**
* 根据时间范围查询Sorted Set中的元素(重载方法,适用于时间戳查询)
*
* @param key 键
* @param startTime 开始时间戳
* @param endTime 结束时间戳
* @return 指定时间范围内的元素集合
*/
public static Collection<String> zRangeByScore(String key, Long startTime, Long endTime) {
try {
RScoredSortedSet<String> sortedSet = CLIENT.getScoredSortedSet(key);
return sortedSet.valueRange(startTime, true, endTime, true);
} catch (Exception e) {
// 记录错误日志(如果项目中有日志工具的话)
// log.error("根据时间范围查询Sorted Set中的元素失败: key={}, startTime={}, endTime={}, error={}",
// key, startTime, endTime, e.getMessage(), e);
return null;
}
}
/**
* 追加缓存Set数据
*
@ -614,4 +637,73 @@ public class RedisUtils {
RKeys rKeys = CLIENT.getKeys();
return rKeys.countExists(key) > 0;
}
/**
* 向去重阻塞队列中添加元素
*
* @param queueKey 队列键
* @param dedupKey 去重集合键
* @param value 消息值
* @param timeout 过期时间
* @return 是否添加成功
*/
public static boolean offerDeduplicated(String queueKey, String dedupKey, String value, Duration timeout) {
// String jsonValue = value instanceof String ? (String) value : JsonUtils.toJsonString(value);
RLock lock = CLIENT.getLock("lock:" + queueKey);
try {
lock.lock();
RSet<String> dedupSet = CLIENT.getSet(dedupKey);
if (dedupSet.contains(value)) {
return false; // 元素已存在,不重复添加
}
// 添加到去重集合
dedupSet.add(value);
// 添加到阻塞队列
RBlockingQueue<String> queue = CLIENT.getBlockingQueue(queueKey);
boolean offered = queue.offer(value);
// 设置过期时间
if (timeout != null) {
queue.expire(timeout);
dedupSet.expire(timeout);
}
return offered;
} finally {
lock.unlock();
}
}
/**
* 从去重阻塞队列中消费元素
*
* @param queueKey 队列键
* @param dedupKey 去重集合键
* @param timeout 超时时间
* @param timeUnit 时间单位
* @return 消息值
*/
public static String pollDeduplicated(String queueKey, String dedupKey, long timeout, TimeUnit timeUnit) {
try {
RBlockingQueue<String> queue = CLIENT.getBlockingQueue(queueKey);
String value = queue.poll(timeout, timeUnit);
// 从去重集合中移除
if (value != null) {
RSet<String> dedupSet = CLIENT.getSet(dedupKey);
dedupSet.remove(value);
}
return value;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return null;
}
}
}

View File

@ -1,5 +1,7 @@
package com.fuyuanshen.app.domain.bo;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fuyuanshen.app.domain.AppDeviceShare;
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
import io.github.linpeilie.annotations.AutoMapper;
@ -7,6 +9,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.util.Date;
/**
* 设备分享业务对象 app_device_share
*
@ -35,10 +39,16 @@ public class AppDeviceShareBo extends BaseEntity {
/**
* 功能权限1灯光模式2激光模式3开机画面4人员信息登记5发送信息6产品信息
以逗号分隔
* 以逗号分隔
*/
private String permission;
/**
* 分享用户
* share_user
*/
private String shareUser;
/**
* 备注
*/
@ -46,4 +56,11 @@ public class AppDeviceShareBo extends BaseEntity {
private String smsCode;
/**
* 分享时间
*/
private Date shareStartTime;
private Date shareEndTime;
}

View File

@ -18,5 +18,13 @@ import org.apache.ibatis.annotations.Param;
public interface AppDeviceShareMapper extends BaseMapperPlus<AppDeviceShare, AppDeviceShareVo> {
IPage<AppDeviceShareVo> otherDeviceShareList(@Param("bo") AppDeviceShareBo bo, Page<AppDeviceShareVo> page);
Page<AppDeviceShareVo> selectAppDeviceShareList(@Param("bo") AppDeviceShareBo bo,Page<AppDeviceShareVo> page);
Page<AppDeviceShareVo> selectAppDeviceShareList(@Param("bo") AppDeviceShareBo bo, Page<AppDeviceShareVo> page);
/**
* 查询设备分享列表(web)
*
* @param bo 设备分享
* @return 设备分享
*/
Page<AppDeviceShareVo> selectWebDeviceShareList(@Param("bo") AppDeviceShareBo bo, Page<AppDeviceShareVo> page);
}

View File

@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuyuanshen.app.mapper.AppDeviceShareMapper">
<select id="otherDeviceShareList" resultType="com.fuyuanshen.app.domain.vo.AppDeviceShareVo">
select d.device_name,
d.device_mac,
d.device_sn,
d.device_imei,
d.device_pic,
dt.type_name,
dt.communication_mode,
dt.app_model_dictionary detailPageUrl,
d.bluetooth_name,
c.binding_time,
ad.*,u.user_name otherPhonenumber
from
app_device_share ad
left join device d on ad.device_id = d.id
left join app_user u on ad.create_by = u.user_id
inner join device_type dt on d.device_type = dt.id
inner join app_device_bind_record c on d.id = c.device_id
d.device_mac,
d.device_sn,
d.device_imei,
d.device_pic,
dt.type_name,
dt.communication_mode,
dt.app_model_dictionary detailPageUrl,
d.bluetooth_name,
c.binding_time,
ad.*,
u.user_name otherPhonenumber
from app_device_share ad
left join device d on ad.device_id = d.id
left join app_user u on ad.create_by = u.user_id
inner join device_type dt on d.device_type = dt.id
inner join app_device_bind_record c on d.id = c.device_id
where ad.phonenumber = #{bo.phonenumber}
</select>
<select id="selectAppDeviceShareList" resultType="com.fuyuanshen.app.domain.vo.AppDeviceShareVo">
@ -47,4 +47,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and ad.device_id = #{bo.deviceId}
</if>
</select>
<!-- 查询设备分享列表(web) -->
<select id="selectWebDeviceShareList" resultType="com.fuyuanshen.app.domain.vo.AppDeviceShareVo">
select *
from
app_device_share ad
<where>
<if test="bo.deviceId != null">
and ad.device_id = #{bo.deviceId}
</if>
<if test="bo.shareUser != null">
and ad.share_user = #{bo.shareUser}
</if>
<if test="criteria.shareStartTime != null and criteria.hareEndTime != null">
and d.create_time between #{bo.shareStartTime} and #{bo.shareEndTime}
</if>
</where>
</select>
</mapper>

View File

@ -25,6 +25,13 @@ public class Device extends TenantEntity {
@Schema(title = "ID")
private Long id;
/**
* 设备ID
*/
@TableField(exist = false)
@Schema(title = "设备ID")
private Long deviceId;
@Schema(title = "设备记录ID")
@TableField(exist = false)
private Long assignId;
@ -153,6 +160,7 @@ public class Device extends TenantEntity {
*/
@Schema(title = "出厂日期")
private Date productionDate;
/**
* 在线状态(0离线1在线)
*/

View File

@ -0,0 +1,99 @@
package com.fuyuanshen.equipment.domain;
import com.fuyuanshen.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serial;
/**
* 设备告警对象 device_alarm
*
* @author Lion Li
* @date 2025-08-28
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("device_alarm")
public class DeviceAlarm extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* ID
*/
@TableId(value = "id")
private Long id;
/**
* 设备ID
*/
private Long deviceId;
/**
* 报警事项
*/
private String deviceAction;
/**
* 设备名称
*/
private String deviceName;
/**
* 数据来源
*/
private String dataSource;
/**
* 内容
*/
private String content;
/**
* 设备类型
*/
private Long deviceType;
/**
* 经度
*/
private Long longitude;
/**
* 纬度
*/
private Long latitude;
/**
* 报警位置
*/
private String location;
/**
* 报警开始时间
*/
private Date startTime;
/**
* 报警结束时间
*/
private Date finishTime;
/**
* 报警持续时间
*/
private Long durationTime;
/**
* 0已处理1未处理
*/
private Long treatmentState;
}

View File

@ -0,0 +1,108 @@
package com.fuyuanshen.equipment.domain;
import com.fuyuanshen.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serial;
/**
* 设备充放电记录对象 device_charge_discharge
*
* @author Lion Li
* @date 2025-08-30
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("device_charge_discharge")
public class DeviceChargeDischarge extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 记录唯一标识
*/
@TableId(value = "id")
private Long id;
/**
* 设备唯一标识
*/
private String deviceId;
/**
* 操作类型: 0 charge-充电, 1 discharge-放电
*/
private Long operationType;
/**
* 开始时间
*/
private Date startTime;
/**
* 结束时间
*/
private Date endTime;
/**
* 起始电量百分比(0-100)
*/
private Long initialSoc;
/**
* 结束电量百分比(0-100)
*/
private Long finalSoc;
/**
* 充放电量(kWh)
*/
private Long energyKwh;
/**
* 设备额定功率(kW)
*/
private Long powerRating;
/**
* 电压(V)
*/
private Long voltage;
/**
* 电流(A)
*/
private Long current;
/**
* 温度(℃)
*/
private Long temperature;
/**
* 当前状态
*/
private Long status;
/**
* 错误代码
*/
private String errorCode;
/**
* 记录创建时间
*/
private Date createdAt;
/**
* 记录更新时间
*/
private Date updatedAt;
}

View File

@ -21,6 +21,12 @@ public class DeviceType extends TenantEntity {
@Schema(title = "ID", hidden = true)
private Long id;
/**
* 设备类型ID
*/
@TableField(exist = false)
private Long deviceTypeId;
@Schema(title = "客户号")
private Long customerId;

View File

@ -0,0 +1,116 @@
package com.fuyuanshen.equipment.domain.bo;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
import com.fuyuanshen.equipment.domain.DeviceAlarm;
import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 设备告警业务对象 device_alarm
*
* @author Lion Li
* @date 2025-08-28
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = DeviceAlarm.class, reverseConvertGenerate = false)
public class DeviceAlarmBo extends BaseEntity {
/**
* ID
*/
@NotNull(message = "ID不能为空", groups = {EditGroup.class})
private Long id;
/**
* 设备ID
*/
private Long deviceId;
/**
* 报警事项
* device_action
*/
private Integer deviceAction;
/**
* 设备名称
*/
private String deviceName;
/**
* 设备MAC
* device_mac
*/
private String deviceMac;
/**
* 设备IMEI
* device_imei
*/
private String deviceImei;
/**
* 数据来源
*/
private String dataSource;
/**
* 内容
*/
private String content;
/**
* 设备类型
* device_type
*/
private Long deviceType;
/**
* 经度
*/
private Long longitude;
/**
* 纬度
*/
private Long latitude;
/**
* 报警位置
*/
private String location;
/**
* 报警开始时间
*/
private Date startTime;
/**
* 报警结束时间
*/
private Date finishTime;
/**
* 报警持续时间
*/
private Long durationTime;
/**
* 报警查询时间
*/
private String queryTime1;
private String queryTime2;
/**
* 0已处理1未处理
*/
private Integer treatmentState;
}

View File

@ -0,0 +1,110 @@
package com.fuyuanshen.equipment.domain.bo;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.core.validate.EditGroup;
import com.fuyuanshen.equipment.domain.DeviceChargeDischarge;
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 设备充放电记录业务对象 device_charge_discharge
*
* @author Lion Li
* @date 2025-08-30
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = DeviceChargeDischarge.class, reverseConvertGenerate = false)
public class DeviceChargeDischargeBo extends BaseEntity {
/**
* 记录唯一标识
*/
@NotNull(message = "记录唯一标识不能为空", groups = { EditGroup.class })
private Long id;
/**
* 设备唯一标识
*/
@NotBlank(message = "设备唯一标识不能为空", groups = { AddGroup.class, EditGroup.class })
private String deviceId;
/**
* 操作类型: 0 charge-充电, 1 discharge-放电
*/
@NotNull(message = "操作类型: 0 charge-充电, 1 discharge-放电不能为空", groups = { AddGroup.class, EditGroup.class })
private Long operationType;
/**
* 开始时间
*/
@NotNull(message = "开始时间不能为空", groups = { AddGroup.class, EditGroup.class })
private Date startTime;
/**
* 结束时间
*/
private Date endTime;
/**
* 起始电量百分比(0-100)
*/
private Long initialSoc;
/**
* 结束电量百分比(0-100)
*/
private Long finalSoc;
/**
* 充放电量(kWh)
*/
private Long energyKwh;
/**
* 设备额定功率(kW)
*/
private Long powerRating;
/**
* 电压(V)
*/
private Long voltage;
/**
* 电流(A)
*/
private Long current;
/**
* 温度(℃)
*/
private Long temperature;
/**
* 当前状态
*/
private Long status;
/**
* 错误代码
*/
private String errorCode;
/**
* 记录创建时间
*/
private Date createdAt;
/**
* 记录更新时间
*/
private Date updatedAt;
}

View File

@ -20,6 +20,12 @@ public class InstructionRecordDto {
* 设备IMEI
*/
private String deviceImei;
/**
* content
*/
private String content;
/**
* 操作时间-开始时间
*/
@ -29,4 +35,9 @@ public class InstructionRecordDto {
* 操作时间-结束时间
*/
private String endTime;
/**
* 分组id
*/
private Long groupId;
}

View File

@ -101,16 +101,16 @@ public class DeviceQueryCriteria extends BaseEntity {
*/
private Boolean isAdmin = false;
/**
* 设备所属分组
*/
private Long groupId;
/**
* 设备地区
*/
private String area;
private String content;
}

View File

@ -0,0 +1,44 @@
package com.fuyuanshen.equipment.domain.vo;
import lombok.Data;
/**
* 报警信息
*
* @author: 默苍璃
* @date: 2025-09-0114:24
*/
@Data
public class AlarmInformationVo {
/**
* 报警总数
*/
private Integer alarmsTotal = 0;
/**
* 总处理报警
*/
private Integer processingAlarm = 0;
/**
* 强制报警
*/
private Integer alarmForced = 0;
/**
* 撞击闯入
*/
private Integer intrusionImpact = 0;
/**
* 手动报警
*/
private Integer alarmManual = 0;
/**
* 电子围栏
*/
private Integer fenceElectronic = 0;
}

View File

@ -0,0 +1,34 @@
package com.fuyuanshen.equipment.domain.vo;
import lombok.Data;
/**
* 数据总览
*
* @author: 默苍璃
* @date: 2025-09-0114:24
*/
@Data
public class DataOverviewVo {
/**
* 设备数据量
*/
private Integer devicesNumber = 0;
/**
* 在线设备
*/
private Integer equipmentOnline = 0;
/**
* 新增绑定设备
*/
private Integer bindingNew = 0;
/**
* 异常设备
*/
private Integer equipmentAbnormal = 0;
}

View File

@ -0,0 +1,137 @@
package com.fuyuanshen.equipment.domain.vo;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fuyuanshen.equipment.domain.DeviceAlarm;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import com.fuyuanshen.common.excel.annotation.ExcelDictFormat;
import com.fuyuanshen.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* 设备告警视图对象 device_alarm
*
* @author Lion Li
* @date 2025-08-28
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = DeviceAlarm.class)
public class DeviceAlarmVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* ID
*/
@ExcelProperty(value = "ID")
private Long id;
/**
* 设备ID
*/
@ExcelProperty(value = "设备ID")
private Long deviceId;
/**
* 报警事项
* 0-强制报警1-撞击闯入2-手动报警3-电子围栏告警4-强制告警
*/
@ExcelProperty(value = "报警事项")
private Integer deviceAction;
/**
* 设备名称
*/
@ExcelProperty(value = "设备名称")
private String deviceName;
/**
* 设备MAC
*/
private String deviceMac;
/**
* 设备IMEI
*/
private String deviceImei;
/**
* 数据来源
*/
@ExcelProperty(value = "数据来源")
private String dataSource;
/**
* 内容
*/
@ExcelProperty(value = "内容")
private String content;
/**
* 设备类型
*/
@ExcelProperty(value = "设备类型")
private Long deviceType;
private String deviceTypeName;
/**
* 经度
*/
@ExcelProperty(value = "经度")
private Long longitude;
/**
* 纬度
*/
@ExcelProperty(value = "纬度")
private Long latitude;
/**
* 报警位置
*/
@ExcelProperty(value = "报警位置")
private String location;
/**
* 报警开始时间
*/
@ExcelProperty(value = "报警开始时间")
private Date startTime;
/**
* 报警结束时间
*/
@ExcelProperty(value = "报警结束时间")
private Date finishTime;
/**
* 报警持续时间
*/
@ExcelProperty(value = "报警持续时间")
private String durationTime;
/**
* 0已处理1未处理
*/
@ExcelProperty(value = "0已处理1未处理")
private Integer treatmentState;
/**
* 设备图片
* device_pic
*/
@Schema(name = "设备图片")
private String devicePic;
}

View File

@ -0,0 +1,130 @@
package com.fuyuanshen.equipment.domain.vo;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fuyuanshen.equipment.domain.DeviceChargeDischarge;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import com.fuyuanshen.common.excel.annotation.ExcelDictFormat;
import com.fuyuanshen.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* 设备充放电记录视图对象 device_charge_discharge
*
* @author Lion Li
* @date 2025-08-30
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = DeviceChargeDischarge.class)
public class DeviceChargeDischargeVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 记录唯一标识
*/
@ExcelProperty(value = "记录唯一标识")
private Long id;
/**
* 设备唯一标识
*/
@ExcelProperty(value = "设备唯一标识")
private String deviceId;
/**
* 操作类型: 0 charge-充电, 1 discharge-放电
*/
@ExcelProperty(value = "操作类型: 0 charge-充电, 1 discharge-放电")
private Long operationType;
/**
* 开始时间
*/
@ExcelProperty(value = "开始时间")
private Date startTime;
/**
* 结束时间
*/
@ExcelProperty(value = "结束时间")
private Date endTime;
/**
* 起始电量百分比(0-100)
*/
@ExcelProperty(value = "起始电量百分比(0-100)")
private Long initialSoc;
/**
* 结束电量百分比(0-100)
*/
@ExcelProperty(value = "结束电量百分比(0-100)")
private Long finalSoc;
/**
* 充放电量(kWh)
*/
@ExcelProperty(value = "充放电量(kWh)")
private Long energyKwh;
/**
* 设备额定功率(kW)
*/
@ExcelProperty(value = "设备额定功率(kW)")
private Long powerRating;
/**
* 电压(V)
*/
@ExcelProperty(value = "电压(V)")
private Long voltage;
/**
* 电流(A)
*/
@ExcelProperty(value = "电流(A)")
private Long current;
/**
* 温度(℃)
*/
@ExcelProperty(value = "温度(℃)")
private Long temperature;
/**
* 当前状态
*/
@ExcelProperty(value = "当前状态")
private Long status;
/**
* 错误代码
*/
@ExcelProperty(value = "错误代码")
private String errorCode;
/**
* 记录创建时间
*/
@ExcelProperty(value = "记录创建时间")
private Date createdAt;
/**
* 记录更新时间
*/
@ExcelProperty(value = "记录更新时间")
private Date updatedAt;
}

View File

@ -0,0 +1,29 @@
package com.fuyuanshen.equipment.domain.vo;
import lombok.Data;
/**
* 设备分类
*
* @author: 默苍璃
* @date: 2025-09-0114:24
*/
@Data
public class EquipmentClassificationVo {
/**
* 4G设备
*/
private Integer equipment4G = 0;
/**
* 蓝牙设备
*/
private Integer deviceBluetooth = 0;
/**
* 4G & 蓝牙 设备
*/
private Integer devices4GAndBluetooth = 0;
}

View File

@ -1,5 +1,6 @@
package com.fuyuanshen.equipment.domain.vo;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
@ -8,25 +9,31 @@ public class InstructionRecordVo {
/**
* 设备名称
*/
@ExcelProperty(value = "设备名称")
private String deviceName;
/**
* 设备类型
*/
@ExcelProperty(value = "设备型号")
private String deviceType;
/**
* 操作模块
*/
@ExcelProperty(value = "操作模块")
private String deviceAction;
/**
* 操作内容
*/
@ExcelProperty(value = "操作内容")
private String content;
/**
* 操作时间
*/
@ExcelProperty(value = "操作时间")
private String createTime;
}

View File

@ -0,0 +1,41 @@
package com.fuyuanshen.equipment.domain.vo;
import cn.idev.excel.annotation.ExcelProperty;
import com.alibaba.fastjson2.JSONObject;
import lombok.Data;
import java.util.List;
@Data
public class LocationHistoryDetailVo {
/**
* 日期
*/
@ExcelProperty(value = "日期")
private String date;
/**
* 设备名称
*/
@ExcelProperty(value = "设备名称")
private String deviceName;
/**
* 初始地点
*/
@ExcelProperty(value = "初始地点")
private String startLocation;
/**
* 结束地点
*/
@ExcelProperty(value = "结束地点")
private String endLocation;
/**
* 轨迹详情
*/
@ExcelProperty(value = "轨迹详情")
private List<Object> detailList;
}

View File

@ -0,0 +1,39 @@
package com.fuyuanshen.equipment.domain.vo;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class LocationHistoryVo {
private Long id;
/**
* 设备名称
*/
@ExcelProperty(value = "设备名称")
private String deviceName;
/**
* 设备类型
*/
private String deviceType;
/**
* 设备类型
*/
@ExcelProperty(value = "设备型号")
private String deviceTypeName;
/**
* 设备IMEI
*/
@ExcelProperty(value = "设备IMEI")
private String deviceImei;
/**
* 设备MAC
*/
@ExcelProperty(value = "设备MAC")
private String deviceMac;
}

View File

@ -1,5 +1,6 @@
package com.fuyuanshen.equipment.domain.vo;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
import java.io.Serializable;

View File

@ -0,0 +1,28 @@
package com.fuyuanshen.equipment.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.equipment.domain.DeviceAlarm;
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;
/**
* 设备告警Mapper接口
*
* @author Lion Li
* @date 2025-08-28
*/
public interface DeviceAlarmMapper extends BaseMapperPlus<DeviceAlarm, DeviceAlarmVo> {
/**
* 查询设备告警列表
*
* @param bo 设备告警
* @return 设备告警
*/
Page<DeviceAlarmVo> selectVoPage( Page pageQuery,@Param("bo") DeviceAlarmBo bo);
}

View File

@ -0,0 +1,15 @@
package com.fuyuanshen.equipment.mapper;
import com.fuyuanshen.equipment.domain.DeviceChargeDischarge;
import com.fuyuanshen.equipment.domain.vo.DeviceChargeDischargeVo;
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
/**
* 设备充放电记录Mapper接口
*
* @author Lion Li
* @date 2025-08-30
*/
public interface DeviceChargeDischargeMapper extends BaseMapperPlus<DeviceChargeDischarge, DeviceChargeDischargeVo> {
}

View File

@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.LocationHistoryVo;
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -71,4 +73,6 @@ public interface DeviceMapper extends BaseMapper<Device> {
AppDeviceVo getDeviceInfo(@Param("deviceMac") String deviceMac);
Page<WebDeviceVo> queryWebDeviceList(Page<Object> build,@Param("criteria") DeviceQueryCriteria criteria);
Page<LocationHistoryVo> getLocationHistory(Page<Object> build, @Param("bo") InstructionRecordDto criteria);
}

View File

@ -11,6 +11,7 @@ import com.fuyuanshen.equipment.domain.form.DeviceForm;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.CustomerVo;
import com.fuyuanshen.equipment.domain.vo.DataOverviewVo;
import java.io.IOException;
import java.util.List;
@ -115,4 +116,10 @@ public interface DeviceService extends IService<Device> {
*/
int webUnBindDevice(Long id);
/**
* 获取数据总览
*
* @return
*/
DataOverviewVo getDataOverview();
}

View File

@ -0,0 +1,68 @@
package com.fuyuanshen.equipment.service;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import java.util.Collection;
import java.util.List;
/**
* 设备告警Service接口
*
* @author Lion Li
* @date 2025-08-28
*/
public interface IDeviceAlarmService {
/**
* 查询设备告警
*
* @param id 主键
* @return 设备告警
*/
DeviceAlarmVo queryById(Long id);
/**
* 分页查询设备告警列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 设备告警分页列表
*/
TableDataInfo<DeviceAlarmVo> queryPageList(DeviceAlarmBo bo, PageQuery pageQuery);
/**
* 查询符合条件的设备告警列表
*
* @param bo 查询条件
* @return 设备告警列表
*/
List<DeviceAlarmVo> queryList(DeviceAlarmBo bo);
/**
* 新增设备告警
*
* @param bo 设备告警
* @return 是否新增成功
*/
Boolean insertByBo(DeviceAlarmBo bo);
/**
* 修改设备告警
*
* @param bo 设备告警
* @return 是否修改成功
*/
Boolean updateByBo(DeviceAlarmBo bo);
/**
* 校验并批量删除设备告警信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@ -0,0 +1,68 @@
package com.fuyuanshen.equipment.service;
import com.fuyuanshen.equipment.domain.vo.DeviceChargeDischargeVo;
import com.fuyuanshen.equipment.domain.bo.DeviceChargeDischargeBo;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import java.util.Collection;
import java.util.List;
/**
* 设备充放电记录Service接口
*
* @author Lion Li
* @date 2025-08-30
*/
public interface IDeviceChargeDischargeService {
/**
* 查询设备充放电记录
*
* @param id 主键
* @return 设备充放电记录
*/
DeviceChargeDischargeVo queryById(Long id);
/**
* 分页查询设备充放电记录列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 设备充放电记录分页列表
*/
TableDataInfo<DeviceChargeDischargeVo> queryPageList(DeviceChargeDischargeBo bo, PageQuery pageQuery);
/**
* 查询符合条件的设备充放电记录列表
*
* @param bo 查询条件
* @return 设备充放电记录列表
*/
List<DeviceChargeDischargeVo> queryList(DeviceChargeDischargeBo bo);
/**
* 新增设备充放电记录
*
* @param bo 设备充放电记录
* @return 是否新增成功
*/
Boolean insertByBo(DeviceChargeDischargeBo bo);
/**
* 修改设备充放电记录
*
* @param bo 设备充放电记录
* @return 是否修改成功
*/
Boolean updateByBo(DeviceChargeDischargeBo bo);
/**
* 校验并批量删除设备充放电记录信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@ -66,5 +66,13 @@ public interface IDeviceGroupService {
* @param deviceId 设备id
* @return 是否绑定成功
*/
Boolean bindingDevice(@NotEmpty(message = "分组id 不能为空") Long groupId, @NotEmpty(message = "设备id 不能为空") Long[] deviceId);
Boolean bindingDevice(Long groupId, Long[] deviceId);
/**
* 解绑设备分组
*
* @param deviceId 设备id
* @return 是否解绑成功
*/
Boolean groupUnbind( Long[] deviceId);
}

View File

@ -0,0 +1,148 @@
package com.fuyuanshen.equipment.service.impl;
import com.fuyuanshen.common.core.utils.MapstructUtils;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.fuyuanshen.equipment.domain.bo.DeviceAlarmBo;
import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo;
import com.fuyuanshen.equipment.domain.DeviceAlarm;
import com.fuyuanshen.equipment.mapper.DeviceAlarmMapper;
import com.fuyuanshen.equipment.service.IDeviceAlarmService;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/**
* 设备告警Service业务层处理
*
* @author Lion Li
* @date 2025-08-28
*/
@Slf4j
@RequiredArgsConstructor
@Service
public class DeviceAlarmServiceImpl implements IDeviceAlarmService {
private final DeviceAlarmMapper baseMapper;
/**
* 查询设备告警
*
* @param id 主键
* @return 设备告警
*/
@Override
public DeviceAlarmVo queryById(Long id) {
return baseMapper.selectVoById(id);
}
/**
* 分页查询设备告警列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 设备告警分页列表
*/
@Override
public TableDataInfo<DeviceAlarmVo> queryPageList(DeviceAlarmBo bo, PageQuery pageQuery) {
// LambdaQueryWrapper<DeviceAlarm> lqw = buildQueryWrapper(bo);
// Page<DeviceAlarmVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
Page<DeviceAlarmVo> result = baseMapper.selectVoPage(pageQuery.build(), bo);
return TableDataInfo.build(result);
}
/**
* 查询符合条件的设备告警列表
*
* @param bo 查询条件
* @return 设备告警列表
*/
@Override
public List<DeviceAlarmVo> queryList(DeviceAlarmBo bo) {
LambdaQueryWrapper<DeviceAlarm> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<DeviceAlarm> buildQueryWrapper(DeviceAlarmBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<DeviceAlarm> lqw = Wrappers.lambdaQuery();
lqw.orderByAsc(DeviceAlarm::getId);
lqw.eq(bo.getDeviceId() != null, DeviceAlarm::getDeviceId, bo.getDeviceId());
// lqw.eq(StringUtils.isNotBlank(bo.getDeviceAction()), DeviceAlarm::getDeviceAction, bo.getDeviceAction());
lqw.like(StringUtils.isNotBlank(bo.getDeviceName()), DeviceAlarm::getDeviceName, bo.getDeviceName());
lqw.eq(StringUtils.isNotBlank(bo.getDataSource()), DeviceAlarm::getDataSource, bo.getDataSource());
lqw.eq(StringUtils.isNotBlank(bo.getContent()), DeviceAlarm::getContent, bo.getContent());
lqw.eq(bo.getDeviceType() != null, DeviceAlarm::getDeviceType, bo.getDeviceType());
lqw.eq(bo.getLongitude() != null, DeviceAlarm::getLongitude, bo.getLongitude());
lqw.eq(bo.getLatitude() != null, DeviceAlarm::getLatitude, bo.getLatitude());
lqw.eq(StringUtils.isNotBlank(bo.getLocation()), DeviceAlarm::getLocation, bo.getLocation());
lqw.eq(bo.getStartTime() != null, DeviceAlarm::getStartTime, bo.getStartTime());
lqw.eq(bo.getFinishTime() != null, DeviceAlarm::getFinishTime, bo.getFinishTime());
lqw.eq(bo.getDurationTime() != null, DeviceAlarm::getDurationTime, bo.getDurationTime());
lqw.eq(bo.getTreatmentState() != null, DeviceAlarm::getTreatmentState, bo.getTreatmentState());
return lqw;
}
/**
* 新增设备告警
*
* @param bo 设备告警
* @return 是否新增成功
*/
@Override
public Boolean insertByBo(DeviceAlarmBo bo) {
DeviceAlarm add = MapstructUtils.convert(bo, DeviceAlarm.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
}
/**
* 修改设备告警
*
* @param bo 设备告警
* @return 是否修改成功
*/
@Override
public Boolean updateByBo(DeviceAlarmBo bo) {
DeviceAlarm update = MapstructUtils.convert(bo, DeviceAlarm.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(DeviceAlarm entity) {
// TODO 做一些数据校验,如唯一约束
}
/**
* 校验并批量删除设备告警信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (isValid) {
// TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}
}

View File

@ -0,0 +1,146 @@
package com.fuyuanshen.equipment.service.impl;
import com.fuyuanshen.common.core.utils.MapstructUtils;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.fuyuanshen.equipment.domain.bo.DeviceChargeDischargeBo;
import com.fuyuanshen.equipment.domain.vo.DeviceChargeDischargeVo;
import com.fuyuanshen.equipment.domain.DeviceChargeDischarge;
import com.fuyuanshen.equipment.mapper.DeviceChargeDischargeMapper;
import com.fuyuanshen.equipment.service.IDeviceChargeDischargeService;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/**
* 设备充放电记录Service业务层处理
*
* @author Lion Li
* @date 2025-08-30
*/
@Slf4j
@RequiredArgsConstructor
@Service
public class DeviceChargeDischargeServiceImpl implements IDeviceChargeDischargeService {
private final DeviceChargeDischargeMapper baseMapper;
/**
* 查询设备充放电记录
*
* @param id 主键
* @return 设备充放电记录
*/
@Override
public DeviceChargeDischargeVo queryById(Long id){
return baseMapper.selectVoById(id);
}
/**
* 分页查询设备充放电记录列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 设备充放电记录分页列表
*/
@Override
public TableDataInfo<DeviceChargeDischargeVo> queryPageList(DeviceChargeDischargeBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<DeviceChargeDischarge> lqw = buildQueryWrapper(bo);
Page<DeviceChargeDischargeVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询符合条件的设备充放电记录列表
*
* @param bo 查询条件
* @return 设备充放电记录列表
*/
@Override
public List<DeviceChargeDischargeVo> queryList(DeviceChargeDischargeBo bo) {
LambdaQueryWrapper<DeviceChargeDischarge> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<DeviceChargeDischarge> buildQueryWrapper(DeviceChargeDischargeBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<DeviceChargeDischarge> lqw = Wrappers.lambdaQuery();
lqw.orderByAsc(DeviceChargeDischarge::getId);
lqw.eq(StringUtils.isNotBlank(bo.getDeviceId()), DeviceChargeDischarge::getDeviceId, bo.getDeviceId());
lqw.eq(bo.getOperationType() != null, DeviceChargeDischarge::getOperationType, bo.getOperationType());
lqw.eq(bo.getStartTime() != null, DeviceChargeDischarge::getStartTime, bo.getStartTime());
lqw.eq(bo.getEndTime() != null, DeviceChargeDischarge::getEndTime, bo.getEndTime());
lqw.eq(bo.getInitialSoc() != null, DeviceChargeDischarge::getInitialSoc, bo.getInitialSoc());
lqw.eq(bo.getFinalSoc() != null, DeviceChargeDischarge::getFinalSoc, bo.getFinalSoc());
lqw.eq(bo.getEnergyKwh() != null, DeviceChargeDischarge::getEnergyKwh, bo.getEnergyKwh());
lqw.eq(bo.getPowerRating() != null, DeviceChargeDischarge::getPowerRating, bo.getPowerRating());
lqw.eq(bo.getVoltage() != null, DeviceChargeDischarge::getVoltage, bo.getVoltage());
lqw.eq(bo.getCurrent() != null, DeviceChargeDischarge::getCurrent, bo.getCurrent());
lqw.eq(bo.getTemperature() != null, DeviceChargeDischarge::getTemperature, bo.getTemperature());
lqw.eq(bo.getStatus() != null, DeviceChargeDischarge::getStatus, bo.getStatus());
lqw.eq(StringUtils.isNotBlank(bo.getErrorCode()), DeviceChargeDischarge::getErrorCode, bo.getErrorCode());
lqw.eq(bo.getCreatedAt() != null, DeviceChargeDischarge::getCreatedAt, bo.getCreatedAt());
lqw.eq(bo.getUpdatedAt() != null, DeviceChargeDischarge::getUpdatedAt, bo.getUpdatedAt());
return lqw;
}
/**
* 新增设备充放电记录
*
* @param bo 设备充放电记录
* @return 是否新增成功
*/
@Override
public Boolean insertByBo(DeviceChargeDischargeBo bo) {
DeviceChargeDischarge add = MapstructUtils.convert(bo, DeviceChargeDischarge.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
}
/**
* 修改设备充放电记录
*
* @param bo 设备充放电记录
* @return 是否修改成功
*/
@Override
public Boolean updateByBo(DeviceChargeDischargeBo bo) {
DeviceChargeDischarge update = MapstructUtils.convert(bo, DeviceChargeDischarge.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(DeviceChargeDischarge entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 校验并批量删除设备充放电记录信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}
}

View File

@ -92,6 +92,7 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
vo.setId(group.getId());
vo.setGroupName(group.getGroupName());
vo.setStatus(group.getStatus() == 1 ? "正常" : "禁用");
vo.setParentId(group.getParentId());
vo.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(group.getCreateTime()));
return vo;
}
@ -124,10 +125,12 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
throw new RuntimeException("分组名称已存在,请勿重复添加!!!");
}
// 验证父分组是否存在如果提供了parentId
DeviceGroup pDeviceGroup = baseMapper.selectById(bo.getParentId());
if (bo.getParentId() != null && pDeviceGroup == null) {
throw new RuntimeException("父分组不存在!!!");
if (bo.getParentId() != null) {
// 验证父分组是否存在如果提供了parentId
DeviceGroup pDeviceGroup = baseMapper.selectById(bo.getParentId());
if (bo.getParentId() != null && pDeviceGroup == null) {
throw new RuntimeException("父分组不存在!!!");
}
}
DeviceGroup add = MapstructUtils.convert(bo, DeviceGroup.class);
@ -199,4 +202,27 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
return true;
}
/**
* 解绑设备分组
*
* @param deviceId 设备id
* @return 是否解绑成功
*/
@Override
public Boolean groupUnbind( Long[] deviceId) {
if (deviceId != null && deviceId.length > 0) {
// 创建更新条件
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
updateWrapper.in("id", Arrays.asList(deviceId));
updateWrapper.set("group_id", null);
// 执行批量更新
deviceMapper.update(updateWrapper);
}
return true;
}
}

View File

@ -30,6 +30,7 @@ import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
import com.fuyuanshen.equipment.domain.vo.CustomerVo;
import com.fuyuanshen.equipment.domain.vo.DataOverviewVo;
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
import com.fuyuanshen.equipment.enums.DeviceActiveStatusEnum;
@ -595,6 +596,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
}
/**
* 查询设备MAC号
*
@ -613,4 +616,14 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
}
/**
* 获取数据总览
*
* @return
*/
@Override
public DataOverviewVo getDataOverview() {
return null;
}
}

View File

@ -157,11 +157,11 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
throw new RuntimeException("设备类型不存在");
}
List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>()
.eq("device_type", deviceTypeGrants.getDeviceTypeId()));
if (CollectionUtil.isNotEmpty(devices)) {
throw new RuntimeException("该设备类型已绑定设备,无法修改!!!");
}
// List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>()
// .eq("device_type", deviceTypeGrants.getDeviceTypeId()));
// if (CollectionUtil.isNotEmpty(devices)) {
// throw new RuntimeException("该设备类型已绑定设备,无法修改!!!");
// }
// 校验设备类型名称
DeviceType dt = deviceTypeMapper.selectOne(new QueryWrapper<DeviceType>().eq("type_name", resources.getTypeName()));

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuyuanshen.equipment.mapper.DeviceAlarmMapper">
<!-- 查询设备告警列表 -->
<select id="selectVoPage" resultType="com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo">
select *, d.device_mac as deviceMac, d.device_imei as deviceImei,
d.type_name as deviceTypeName, d.device_pic as devicePic
from device_alarm da
left join device d on da.device_id = d.id
left join device_type dt on dt.id = da.device_type
<where>
<if test="bo.deviceName != null">
and da.device_name = #{bo.deviceName}
</if>
<if test="bo.deviceType != null">
and da.device_type = #{bo.deviceType}
</if>
<if test="bo.deviceAction != null">
and da.device_action = #{bo.deviceAction}
</if>
<if test="bo.treatmentState != null">
and da.treatment_state = #{bo.treatmentState}
</if>
<if test="bo.queryTime1 != null and bo.queryTime2 != null ">
and da.start_time between #{bo.queryTime1} and #{bo.queryTime2}
</if>
</where>
</select>
</mapper>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuyuanshen.equipment.mapper.DeviceChargeDischargeMapper">
</mapper>

View File

@ -28,11 +28,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="bo.deviceImei != null and bo.deviceImei != ''">
AND b.device_imei = #{bo.deviceImei}
</if>
<if test="bo.content != null and bo.content != ''">
AND b.device_imei = #{bo.content} or b.device_mac = #{bo.content}
</if>
<if test="bo.startTime != null and bo.startTime != ''">
AND create_time <![CDATA[>=]]> #{bo.startTime}
AND a.create_time <![CDATA[>=]]> #{bo.startTime}
</if>
<if test="bo.endTime != null and bo.endTime != ''">
AND create_time <![CDATA[<=]]> #{bo.startTime}
AND a.create_time <![CDATA[<=]]> #{bo.endTime}
</if>
<if test="bo.groupId != null">
and b.group_id = #{bo.groupId}
</if>
ORDER BY
a.create_time DESC

View File

@ -41,7 +41,7 @@
SELECT *
FROM (
SELECT
da.id AS id, d.device_name, d.bluetooth_name,
da.id AS id, d.id AS deviceId, d.device_name, d.bluetooth_name, d.group_id,
d.pub_topic, d.sub_topic, d.device_pic,
d.device_mac, d.device_sn, d.update_by,
d.device_imei, d.update_time, dg.id AS device_type,
@ -71,6 +71,9 @@
<if test="criteria.deviceStatus != null">
and da.active = #{criteria.deviceStatus}
</if>
<if test="criteria.groupId != null">
and d.group_id = #{criteria.groupId}
</if>
<if test="criteria.params.beginTime != null and criteria.params.endTime != null">
and da.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime}
</if>
@ -257,11 +260,11 @@
<if test="criteria.deviceName != null and criteria.deviceName != ''">
and d.device_name like concat('%', #{criteria.deviceName}, '%')
</if>
<if test="criteria.deviceMac != null">
and d.device_mac = #{criteria.deviceMac}
<if test="criteria.deviceImei != null and criteria.deviceImei != ''">
and (d.device_imei = #{criteria.deviceImei}
</if>
<if test="criteria.deviceImei != null">
and d.device_imei = #{criteria.deviceImei}
<if test="criteria.content != null and criteria.content != ''">
AND d.device_imei = #{criteria.content} or d.device_mac = #{criteria.content}
</if>
<if test="criteria.deviceStatus != null">
and d.device_status = #{criteria.deviceStatus}
@ -276,5 +279,36 @@
and d.group_id = #{criteria.groupId}
</if>
</select>
<select id="getLocationHistory" resultType="com.fuyuanshen.equipment.domain.vo.LocationHistoryVo">
select a.id,a.device_name,a.device_type,b.type_name deviceTypeName,a.device_imei,a.device_mac from device a
inner join device_type b on a.device_type = b.id
<if test="bo.deviceType != null">
AND b.id = #{bo.deviceType}
</if>
<if test="bo.deviceName != null and bo.deviceName != ''">
AND a.device_name like concat('%',#{bo.deviceName},'%')
</if>
<if test="bo.deviceMac != null and bo.deviceMac != ''">
AND a.device_mac = #{bo.deviceMac}
</if>
<if test="bo.deviceImei != null and bo.deviceImei != ''">
AND a.device_imei = #{bo.deviceImei}
</if>
<if test="bo.content != null and bo.content != ''">
AND a.device_imei = #{bo.content} or a.device_mac = #{bo.content}
</if>
<if test="bo.startTime != null and bo.startTime != ''">
AND a.create_time <![CDATA[>=]]> #{bo.startTime}
</if>
<if test="bo.endTime != null and bo.endTime != ''">
AND a.create_time <![CDATA[<=]]> #{bo.endTime}
</if>
<if test="bo.groupId != null">
and a.group_id = #{bo.groupId}
</if>
ORDER BY
a.create_time DESC
</select>
</mapper>

View File

@ -4,6 +4,7 @@
<resultMap id="BaseResultMap" type="com.fuyuanshen.equipment.domain.DeviceType">
<id column="grant_id" property="id"/>
<result column="type_name" property="typeName"/>
<result column="device_type_id" property="deviceTypeId"/>
<result column="is_support_ble" property="isSupportBle"/>
<result column="locate_mode" property="locateMode"/>
<result column="network_way" property="networkWay"/>
@ -21,7 +22,7 @@
<!-- 查询所有设备类型 -->
<select id="findAll" resultMap="BaseResultMap">
SELECT DISTINCT dt.* ,dg.id AS grant_id ,dg.create_time AS Dcreate_time
SELECT DISTINCT dt.* ,dg.id AS grant_id ,dg.create_time AS Dcreate_time,dt.id AS device_type_id
FROM device_type dt
JOIN device_type_grants dg ON dt.id = dg.device_type_id
<where>
@ -44,7 +45,7 @@
</select>
<!-- 根据名称查询设备类型 -->
<select id="queryByName" resultMap="BaseResultMap"
<select id="queryByName" resultMap="BaseResultMap"
parameterType="com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria">
SELECT dt.*, dg.id AS grant_id
FROM device_type dt