83 Commits

Author SHA1 Message Date
76e2b9de24 Merge remote-tracking branch 'upstream/dyf-device' into main-dyf 2025-09-02 09:30:38 +08:00
0787e4b205 Merge remote-tracking branch 'origin/dyf-device' into 6170
# Conflicts:
#	fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBizService.java
#	fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/LocationHistoryDetailVo.java
2025-09-02 08:51:41 +08:00
eca113d388 首页数据 2025-09-02 08:49:42 +08:00
127e26e0d4 首页数据 2025-09-01 16:03:46 +08:00
dfb5d8ac65 修改获取实时状态类型 2025-08-30 13:53:41 +08:00
896c501cd6 报警持续时间 2025-08-30 11:07:04 +08:00
d8686e3cbd Merge branch 'dyf-device' into 6170 2025-08-30 09:40:51 +08:00
c2ce9679c4 设备充放电记录 2025-08-30 09:39:41 +08:00
d66fb7d2c2 设备告警 2025-08-29 18:58:16 +08:00
400c53030a Merge remote-tracking branch 'origin/6170' into 6170 2025-08-29 16:49:44 +08:00
b5565da752 web端控制中心4 2025-08-29 16:49:16 +08:00
e17a64ad57 查询设备告警列表 2025-08-29 13:59:23 +08:00
d97ace42d0 Merge remote-tracking branch 'upstream/dyf-device' into main-dyf 2025-08-29 10:31:18 +08:00
3969e50566 查询设备分享列表(web) 2025-08-29 10:29:53 +08:00
760738bcdd 设备告警记录 2025-08-28 13:30:50 +08:00
765e0f8509 设备告警 2025-08-28 11:26:00 +08:00
2c565f5c2d 设备告警 2025-08-28 11:22:04 +08:00
837953bf3d 设备类型ID 2025-08-27 10:20:37 +08:00
8b25fd9ba4 设备操作记录 2025-08-27 09:25:08 +08:00
a8c9c631ad Merge remote-tracking branch 'upstream/dyf-device' into main-dyf 2025-08-27 09:12:05 +08:00
8a7565459b Merge branch '6170' of http://47.107.152.87:3000/dyf/fys-Multi-tenant into 6170 2025-08-27 09:09:20 +08:00
0bbac2b497 设备用户详情 2025-08-27 09:08:27 +08:00
364574eeae web端控制中心3 2025-08-27 08:59:29 +08:00
f9d9dadf08 绑定设备分组 2025-08-26 10:00:35 +08:00
e4df695f5e 绑定设备分组 2025-08-26 09:26:33 +08:00
4663a5560f Merge remote-tracking branch 'upstream/dyf-device' into main-dyf 2025-08-25 14:32:19 +08:00
816b3aa5ee Merge remote-tracking branch 'upstream/dyf-device' 2025-08-22 16:41:23 +08:00
8c883688bd Merge remote-tracking branch 'origin/fys-prod' 2025-08-21 15:12:00 +08:00
c34a39a308 WebApp用户信息 2025-08-21 15:11:22 +08:00
7b842f5cc7 查询APP用户信息列表 2025-08-21 11:48:36 +08:00
b08d23eef4 Merge branch 'main' into fys-prod
# Conflicts:
#	fys-admin/src/main/resources/application-prod.yml
2025-08-21 09:59:23 +08:00
add0738b28 Merge remote-tracking branch 'origin/main' 2025-08-21 09:55:26 +08:00
b61c9c7a06 配置文件提交 2025-08-21 09:54:42 +08:00
8106d09e67 生产配置 2025-08-20 16:53:27 +08:00
425ea306e3 Merge branch 'main' into fys-prod 2025-08-20 16:48:48 +08:00
fd7768acc9 Merge remote-tracking branch 'upstream/6170' 2025-08-20 16:45:49 +08:00
75756eb8ab Merge remote-tracking branch 'upstream/6170'
# Conflicts:
#	fys-common/fys-common-encrypt/src/main/java/com/fuyuanshen/common/encrypt/utils/EncryptUtilsTest.java
2025-08-19 14:11:02 +08:00
285abaedfb Merge branch 'main' into fys-prod 2025-08-15 14:37:23 +08:00
07bc831f1a 登录测试 2025-08-13 19:21:57 +08:00
65caea4a00 解决冲突 2025-08-07 18:17:49 +08:00
83458d0060 Merge remote-tracking branch 'upstream/main'
# Conflicts:
#	fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceBizService.java
#	fys-admin/src/main/java/com/fuyuanshen/app/service/AppLoginService.java
#	fys-admin/src/main/java/com/fuyuanshen/web/handler/mqtt/DeviceReceiverMessageHandler.java
#	fys-admin/src/main/resources/application-prod.yml
#	fys-modules/fys-app/src/main/java/com/fuyuanshen/app/service/impl/AppUserServiceImpl.java
2025-08-07 18:10:47 +08:00
0b0cc84eea Merge branch 'main' into fys-prod 2025-08-04 09:39:08 +08:00
ae393e8155 校验设备类型名称 2025-08-04 09:36:17 +08:00
38caba1fad 修改用户状态-强制下线 2025-08-04 09:35:59 +08:00
6626a1a35e 设备行为 2025-08-04 09:34:16 +08:00
4271085e78 用户注销 2025-08-01 09:58:33 +08:00
2cb4f5b83e 设备绑定优化2 2025-08-01 09:07:27 +08:00
a3a1d43dde Merge remote-tracking branch 'origin/main'
# Conflicts:
#	fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceBizService.java
#	fys-modules/fys-app/src/main/java/com/fuyuanshen/app/domain/AppDeviceBindRecord.java
2025-08-01 09:06:03 +08:00
5f4b12a320 设备绑定优化 2025-08-01 09:00:32 +08:00
f2c7549d6e Merge branch 'main' into fys-prod 2025-07-31 09:24:23 +08:00
7bd652f9b8 Merge remote-tracking branch 'upstream/main' 2025-07-31 09:23:34 +08:00
9ffdcace53 LngLonUtil.java 2025-07-28 10:41:09 +08:00
8cc969bbe6 Merge remote-tracking branch 'upstream/main' 2025-07-28 10:40:31 +08:00
6a900335ef LngLonUtil.java 2025-07-28 10:40:13 +08:00
f1806fa482 app用户登录 2025-07-24 14:49:40 +08:00
17ed75f54a Merge branch 'main' into fys-prod 2025-07-23 19:26:46 +08:00
0abc5d48c0 Merge remote-tracking branch 'upstream/main' 2025-07-23 19:26:12 +08:00
e7c8e245ba Merge remote-tracking branch 'upstream/main' 2025-07-23 11:01:01 +08:00
80b944cbf0 Merge remote-tracking branch 'upstream/main' into fys-prod
# Conflicts:
#	fys-admin/pom.xml
2025-07-23 10:57:03 +08:00
537cc0b2d7 Merge branch 'main' into fys-prod
# Conflicts:
#	pom.xml
2025-07-21 08:45:53 +08:00
8750bc8e10 Merge remote-tracking branch 'upstream/main' 2025-07-21 08:43:34 +08:00
6dde6c3a3b 去掉demo 2025-07-21 08:42:21 +08:00
bb096f53cd 去除demo模块 2025-07-19 16:16:22 +08:00
38724dbfad Merge branch 'main' into fys-prod 2025-07-19 15:58:51 +08:00
e9227dea89 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	fys-admin/src/main/java/com/fuyuanshen/web/controller/CaptchaController.java
2025-07-19 14:24:21 +08:00
b369b28949 新增忘记密码手机短信验证码 2025-07-19 14:23:29 +08:00
f1d1528c40 Merge remote-tracking branch 'upstream/main'
# Conflicts:
#	fys-common/fys-common-core/src/main/java/com/fuyuanshen/common/core/constant/GlobalConstants.java
2025-07-19 10:26:52 +08:00
73e1df4232 Merge branch 'main' into fys-prod 2025-07-18 16:30:02 +08:00
fys
4e608b8f3a merge upstream 2025-07-18 16:24:05 +08:00
e35955f156 prod 2025-07-17 17:27:14 +08:00
3c2d97aaf2 提交 2025-07-17 17:17:30 +08:00
6ed1241a6d Merge remote-tracking branch 'upstream/main'
# Conflicts:
#	fys-modules/fys-app/src/main/resources/mapper/app/AppBusinessFileMapper.xml
2025-07-17 17:03:25 +08:00
1cf7c47ef9 正式环境配置提交 2025-07-14 16:28:54 +08:00
bdee8c8383 Merge remote-tracking branch 'origin/main' 2025-07-12 15:31:42 +08:00
6f4e18fb3f 文件管理代码优化 2025-07-12 15:31:27 +08:00
fys
3ca6b69709 merge upstream 2025-07-12 14:04:03 +08:00
e13e3c57a6 解绑问题修改2 2025-07-12 10:41:35 +08:00
56704f6014 个人中心修改 2025-07-12 10:18:12 +08:00
4f00c69f91 绑定优化2 2025-07-12 09:55:29 +08:00
fcd17634dc 绑定优化 2025-07-12 09:54:08 +08:00
24f0caacd5 绑定蓝牙问题解决 2025-07-12 09:52:14 +08:00
c73a700210 app登录配置修改 2025-07-11 17:39:53 +08:00
3ed2f97752 app接口功能实现 2025-07-11 16:40:20 +08:00
90 changed files with 3448 additions and 242 deletions

View File

@ -94,10 +94,10 @@
</dependency>
<!-- demo模块 -->
<!--<dependency>
<groupId>com.fuyuanshen</groupId>
<artifactId>fys-demo</artifactId>
</dependency>-->
<!-- <dependency> -->
<!-- <groupId>com.fuyuanshen</groupId> -->
<!-- <artifactId>fys-demo</artifactId> -->
<!-- </dependency> -->
<!-- 工作流模块 -->
<dependency>

View File

@ -4,14 +4,13 @@ import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.exception.NotLoginException;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.fuyuanshen.app.model.AppSmsLoginBody;
import com.fuyuanshen.app.service.AppLoginService;
import com.fuyuanshen.common.core.constant.SystemConstants;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.domain.model.RegisterBody;
import com.fuyuanshen.common.core.domain.model.SmsLoginBody;
import com.fuyuanshen.common.core.domain.model.AppLoginBody;
import com.fuyuanshen.common.core.domain.model.AppSmsRegisterBody;
import com.fuyuanshen.common.core.domain.model.PasswordLoginBody;
import com.fuyuanshen.common.core.utils.*;
import com.fuyuanshen.common.encrypt.annotation.ApiEncrypt;
import com.fuyuanshen.common.json.utils.JsonUtils;
import com.fuyuanshen.common.satoken.utils.LoginHelper;
import com.fuyuanshen.common.tenant.helper.TenantHelper;
@ -24,8 +23,8 @@ import com.fuyuanshen.system.service.ISysTenantService;
import com.fuyuanshen.web.domain.vo.LoginTenantVo;
import com.fuyuanshen.web.domain.vo.LoginVo;
import com.fuyuanshen.web.domain.vo.TenantListVo;
import com.fuyuanshen.web.service.AppRegisterService;
import com.fuyuanshen.web.service.IAuthStrategy;
import com.fuyuanshen.web.service.SysRegisterService;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -51,7 +50,7 @@ import java.util.List;
public class AppAuthController {
private final AppLoginService loginService;
private final SysRegisterService registerService;
private final AppRegisterService registerService;
private final ISysConfigService configService;
private final ISysTenantService tenantService;
private final ISysClientService clientService;
@ -64,15 +63,15 @@ public class AppAuthController {
*/
// @ApiEncrypt
@PostMapping("/login")
public R<LoginVo> login(@RequestBody AppSmsLoginBody appSmsLoginBody) {
public R<LoginVo> login(@RequestBody AppLoginBody appLoginBody) {
// SmsLoginBody loginBody = JsonUtils.parseObject(body, SmsLoginBody.class);
ValidatorUtils.validate(appSmsLoginBody);
SmsLoginBody loginBody = new SmsLoginBody();
loginBody.setPhonenumber(appSmsLoginBody.getPhonenumber());
loginBody.setSmsCode(appSmsLoginBody.getSmsCode());
loginBody.setTenantId(appSmsLoginBody.getTenantId());
loginBody.setClientId("ca839698e245d60aa2f0e59bd52b34f8");
loginBody.setGrantType("appSms");
ValidatorUtils.validate(appLoginBody);
PasswordLoginBody loginBody = new PasswordLoginBody();
loginBody.setUsername(appLoginBody.getUserName());
loginBody.setPassword(appLoginBody.getPassword());
loginBody.setTenantId(appLoginBody.getTenantId());
loginBody.setClientId("835b15335d389c9fcfdf99421fa8019b");
loginBody.setGrantType("appPassword");
// 授权类型和客户端id
String clientId = loginBody.getClientId();
String grantType = loginBody.getGrantType();
@ -93,7 +92,14 @@ public class AppAuthController {
}
/**
* 用户注销
*/
@DeleteMapping("/cancelAccount")
public R<Void> cancelAccount() {
loginService.cancelAccount();
return R.ok("用户注销成功");
}
/**
* 退出登录
@ -104,24 +110,11 @@ public class AppAuthController {
return R.ok("退出成功");
}
/**
* 用户注销
*/
@PostMapping("/cancelAccount")
public R<Void> cancelAccount() {
loginService.cancelAccount();
return R.ok("用户注销成功");
}
/**
* 用户注册
*/
@ApiEncrypt
@PostMapping("/register")
public R<Void> register(@Validated @RequestBody RegisterBody user) {
if (!configService.selectRegisterEnabled(user.getTenantId())) {
return R.fail("当前系统没有开启注册功能!");
}
public R<Void> register(@Validated @RequestBody AppSmsRegisterBody user) {
registerService.register(user);
return R.ok();
}

View File

@ -0,0 +1,88 @@
package com.fuyuanshen.app.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.util.RandomUtil;
import com.fuyuanshen.app.domain.dto.APPForgotPasswordDTO;
import com.fuyuanshen.app.domain.dto.APPForgotPasswordSmsDTO;
import com.fuyuanshen.app.domain.dto.APPUpdateUserDTO;
import com.fuyuanshen.app.domain.vo.APPUserInfoVo;
import com.fuyuanshen.app.service.IAppUserService;
import com.fuyuanshen.common.core.constant.Constants;
import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.ratelimiter.annotation.RateLimiter;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.web.core.BaseController;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import org.dromara.sms4j.api.SmsBlend;
import org.dromara.sms4j.api.entity.SmsResponse;
import org.dromara.sms4j.core.factory.SmsFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.time.Duration;
import java.util.LinkedHashMap;
/**
* APP 用户管理
* @date 2025-06-27
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/user")
public class AppUserController extends BaseController {
private final IAppUserService appUserService;
/**
* 个人中心
*/
@GetMapping("/getUserInfo")
public R<APPUserInfoVo> getUserInfo() {
return R.ok(appUserService.getUserInfo());
}
/**
* 修改个人信息
*/
@PostMapping("/updateUser")
public R<Void> updateUser(@Validated @ModelAttribute APPUpdateUserDTO bo) {
return toAjax(appUserService.updateUser(bo));
}
/**
* 忘记密码
*/
@SaIgnore
@PostMapping("/forgotPassword")
public R<Void> forgotPassword(@RequestBody APPForgotPasswordDTO bo) {
return toAjax(appUserService.forgotPassword(bo));
}
/**
* 发送忘记密码短信
*
* @param phonenumber 用户手机号
*/
@SaIgnore
@RateLimiter(key = "#phonenumber", time = 60, count = 1)
@GetMapping("/sendForgotPasswordSms")
public R<Void> smsCode(@NotBlank(message = "{user.phonenumber.not.blank}") String phonenumber) {
String key = GlobalConstants.APP_FORGOT_PASSWORD_SMS_KEY + phonenumber;
String code = RandomUtil.randomNumbers(4);
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
// 验证码模板id 自行处理 (查数据库或写死均可)
String templateId = "";
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
map.put("code", code);
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, map);
if (!smsResponse.isSuccess()) {
return R.fail(smsResponse.getData().toString());
}
return R.ok();
}
}

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

@ -15,8 +15,7 @@ import org.springframework.stereotype.Component;
import java.time.Duration;
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_LIGHT_MODE_KEY_PREFIX;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
/**
* 灯光模式订阅设备回传消息
@ -37,14 +36,10 @@ public class BjqLaserModeSettingsRule implements MqttMessageRule {
try {
Object[] convertArr = context.getConvertArr();
String mainLightMode = convertArr[1].toString();
if(StringUtils.isNotBlank(mainLightMode)){
if("0".equals(mainLightMode)){
String deviceOnlineStatusRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ context.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX ;
RedisUtils.setCacheObject(deviceOnlineStatusRedisKey, "0", Duration.ofSeconds(60*15));
}
String mode = convertArr[1].toString();
if(StringUtils.isNotBlank(mode)){
// 发送设备状态和位置信息到Redis
syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mainLightMode);
syncSendDeviceDataToRedisWithFuture(context.getDeviceImei(),mode);
}
RedisUtils.setCacheObject(functionAccess, FunctionAccessStatus.OK.getCode(), Duration.ofSeconds(30));
@ -65,7 +60,7 @@ public class BjqLaserModeSettingsRule implements MqttMessageRule {
// });
try {
// 将设备状态信息存储到Redis中
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + deviceImei + DEVICE_LIGHT_MODE_KEY_PREFIX;
String deviceRedisKey = GlobalConstants.GLOBAL_REDIS_KEY+DeviceRedisKeyConstants.DEVICE_KEY_PREFIX + deviceImei + DEVICE_LASER_MODE_KEY_PREFIX;
// 存储到Redis
RedisUtils.setCacheObject(deviceRedisKey, convertValue.toString());

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

@ -63,11 +63,10 @@ public class CaptchaController {
String code = RandomUtil.randomNumbers(4);
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
// 验证码模板id 自行处理 (查数据库或写死均可)
String templateId = "SMS_322180518";
String templateId = "";
LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
map.put("code", code);
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
// SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, templateId, map);
SmsResponse smsResponse = smsBlend.sendMessage(phonenumber, map);
if (!smsResponse.isSuccess()) {
log.error("验证码短信发送异常 => {}", smsResponse);

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,23 +4,21 @@ 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.WebDeviceVo;
import com.fuyuanshen.equipment.domain.vo.*;
import com.fuyuanshen.web.service.device.DeviceBizService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -30,10 +28,12 @@ import java.util.Map;
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/device/controlCenter")
@RequestMapping("/api/device")
public class DeviceControlCenterController extends BaseController {
private final DeviceBizService appDeviceService;
/**
* 查询设备列表
*/
@ -95,4 +95,56 @@ public class DeviceControlCenterController extends BaseController {
return R.ok(appDeviceService.getDeviceInfo(deviceMac));
}
/**
* 指令下发记录
*/
@GetMapping("/instructionRecord")
public TableDataInfo<InstructionRecordVo> getInstructionRecord(InstructionRecordDto dto, PageQuery pageQuery) {
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,8 +128,39 @@ 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));
}
/**
* 绑定设备分组
*
* @param groupId 分组id
* @param deviceId 设备id
*/
@Operation(summary = "绑定设备分组")
// @SaCheckPermission("fys-equipment:group:remove")
@Log(title = "绑定设备分组", businessType = BusinessType.DELETE)
@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

@ -1,29 +1,20 @@
package com.fuyuanshen.web.controller.device;
import com.fuyuanshen.app.domain.dto.APPReNameDTO;
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.common.core.domain.R;
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.Device;
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
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 com.fuyuanshen.web.service.device.DeviceBizService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @Description:
@ -62,12 +53,54 @@ 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);
}
/**
* 设备用户详情
*
* @param deviceId
* @return
*/
@Operation(summary = "设备详情")
@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

@ -0,0 +1,131 @@
package com.fuyuanshen.web.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fuyuanshen.app.domain.AppUser;
import com.fuyuanshen.app.domain.vo.AppUserVo;
import com.fuyuanshen.app.mapper.AppUserMapper;
import com.fuyuanshen.common.core.constant.Constants;
import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.domain.model.AppSmsRegisterBody;
import com.fuyuanshen.common.core.enums.UserType;
import com.fuyuanshen.common.core.exception.BadRequestException;
import com.fuyuanshen.common.core.exception.user.CaptchaException;
import com.fuyuanshen.common.core.exception.user.CaptchaExpireException;
import com.fuyuanshen.common.core.exception.user.UserException;
import com.fuyuanshen.common.core.utils.MessageUtils;
import com.fuyuanshen.common.core.utils.ServletUtils;
import com.fuyuanshen.common.core.utils.SpringUtils;
import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.log.event.LogininforEvent;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.tenant.helper.TenantHelper;
import com.fuyuanshen.common.web.config.properties.CaptchaProperties;
import com.fuyuanshen.system.mapper.SysUserMapper;
import com.fuyuanshen.system.service.ISysUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* 注册校验方法
*
* @author Lion Li
*/
@RequiredArgsConstructor
@Service
public class AppRegisterService {
private final ISysUserService userService;
private final SysUserMapper userMapper;
private final CaptchaProperties captchaProperties;
private final AppUserMapper appUserMapper;
/**
* 注册
*/
public void register(AppSmsRegisterBody registerBody) {
String phoneNumber = registerBody.getPhoneNumber();
LambdaQueryWrapper<AppUser> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(AppUser::getPhonenumber, phoneNumber);
wrapper.eq(AppUser::getUserType, UserType.APP_USER.getUserType());
AppUserVo appUserVo = appUserMapper.selectVoOne(wrapper);
if (appUserVo != null) {
throw new BadRequestException("该手机号已被注册");
}
String verificationCode = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + phoneNumber);
if (verificationCode == null) {
throw new BadRequestException("验证码已过期");
}
if(!registerBody.getVerificationCode().equals(verificationCode)){
throw new BadRequestException("验证码错误");
}
String tenantId = registerBody.getTenantId();
String username = registerBody.getPhoneNumber();
String password = registerBody.getPassword();
AppUser appUser = new AppUser();
appUser.setUserName(username);
appUser.setNickName(username);
appUser.setPhonenumber(phoneNumber);
appUser.setPassword(password);
appUser.setUserType(UserType.APP_USER.getUserType());
appUser.setTenantId(tenantId);
appUser.setLoginIp(ServletUtils.getClientIP());
appUser.setStatus("0");
appUser.setDelFlag("0");
appUser.setCreateTime(new Date());
boolean exist = TenantHelper.dynamic(tenantId, () -> {
return appUserMapper.exists(new LambdaQueryWrapper<AppUser>()
.eq(AppUser::getUserName, appUser.getUserName()));
});
if (exist) {
throw new UserException("user.register.save.error", username);
}
appUserMapper.insert(appUser);
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.register.success"));
}
/**
* 校验验证码
*
* @param username 用户名
* @param code 验证码
* @param uuid 唯一标识
*/
public void validateCaptcha(String tenantId, String username, String code, String uuid) {
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.blankToDefault(uuid, "");
String captcha = RedisUtils.getCacheObject(verifyKey);
RedisUtils.deleteObject(verifyKey);
if (captcha == null) {
recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
throw new CaptchaExpireException();
}
if (!code.equalsIgnoreCase(captcha)) {
recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"));
throw new CaptchaException();
}
}
/**
* 记录登录信息
*
* @param tenantId 租户ID
* @param username 用户名
* @param status 状态
* @param message 消息内容
* @return
*/
private void recordLogininfor(String tenantId, String username, String status, String message) {
LogininforEvent logininforEvent = new LogininforEvent();
logininforEvent.setTenantId(tenantId);
logininforEvent.setUsername(username);
logininforEvent.setStatus(status);
logininforEvent.setMessage(message);
logininforEvent.setRequest(ServletUtils.getRequest());
SpringUtils.context().publishEvent(logininforEvent);
}
}

View File

@ -43,7 +43,7 @@ import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*;
public class DeviceShareService {
private final AppDeviceShareMapper appDeviceShareMapper;
private final DeviceMapper deviceMapper;
private final DeviceTypeMapper deviceTypeMapper;
@ -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

@ -2,14 +2,17 @@ package com.fuyuanshen.web.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
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;
@ -38,4 +41,28 @@ public interface WEBDeviceService extends IService<Device> {
*/
WebDeviceVo getDevice(Long id);
/**
* 设备用户详情
*
* @param id
* @return
*/
List<AppPersonnelInfoRecords> getDeviceUser(Long id);
/**
* 设备操作记录
*
* @param deviceId
* @return
*/
List<DeviceLog> getOperationRecord(Long deviceId);
/**
* 设备告警记录
*
* @param deviceId
* @return
*/
List<DeviceAlarmVo> getAlarmRecord(Long deviceId);
}

View File

@ -190,6 +190,22 @@ public class DeviceBJQBizService {
vo.setBatteryPercentage("0");
}
String lightModeStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LIGHT_MODE_KEY_PREFIX);
// 获取电量
if(StringUtils.isNotBlank(deviceStatus)){
vo.setMainLightMode(lightModeStatus);
}
String lightBrightnessStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LIGHT_BRIGHTNESS_KEY_PREFIX);
if(StringUtils.isNotBlank(lightBrightnessStatus)){
vo.setLightBrightness(lightBrightnessStatus);
}
String laserLightMode = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LASER_MODE_KEY_PREFIX);
if(StringUtils.isNotBlank(laserLightMode)){
vo.setLaserLightMode(laserLightMode);
}
// 获取经度纬度
String locationKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_LOCATION_KEY_PREFIX;
String locationInfo = RedisUtils.getCacheObject(locationKey);

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;
@ -14,7 +15,6 @@ import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
import com.fuyuanshen.app.domain.vo.AppUserVo;
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
import com.fuyuanshen.app.mapper.AppDeviceShareMapper;
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
import com.fuyuanshen.app.mapper.AppUserMapper;
import com.fuyuanshen.app.mapper.equipment.APPDeviceMapper;
import com.fuyuanshen.common.core.exception.ServiceException;
@ -26,15 +26,13 @@ import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
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.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;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
import com.fuyuanshen.global.mqtt.config.MqttGateway;
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
import com.fuyuanshen.web.service.device.status.base.DeviceStatusRule;
import com.fuyuanshen.web.service.device.status.base.RealTimeStatusEngine;
@ -42,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.*;
@ -314,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("未匹配到处理命令");
}
@ -332,4 +329,68 @@ public class DeviceBizService {
// List<Device> devices = deviceMapper.selectList(queryWrapper);
return deviceMapper.getDeviceInfo(deviceMac);
}
public TableDataInfo<InstructionRecordVo> getInstructionRecord(InstructionRecordDto bo, PageQuery pageQuery) {
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

@ -0,0 +1,125 @@
package com.fuyuanshen.web.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fuyuanshen.app.domain.AppUser;
import com.fuyuanshen.app.domain.vo.AppUserVo;
import com.fuyuanshen.app.mapper.AppUserMapper;
import com.fuyuanshen.app.service.AppLoginService;
import com.fuyuanshen.common.core.constant.Constants;
import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.constant.SystemConstants;
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
import com.fuyuanshen.common.core.domain.model.PasswordLoginBody;
import com.fuyuanshen.common.core.enums.LoginType;
import com.fuyuanshen.common.core.enums.UserType;
import com.fuyuanshen.common.core.exception.user.CaptchaException;
import com.fuyuanshen.common.core.exception.user.CaptchaExpireException;
import com.fuyuanshen.common.core.exception.user.UserException;
import com.fuyuanshen.common.core.utils.MessageUtils;
import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.core.utils.ValidatorUtils;
import com.fuyuanshen.common.json.utils.JsonUtils;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
import com.fuyuanshen.common.satoken.utils.LoginHelper;
import com.fuyuanshen.common.tenant.helper.TenantHelper;
import com.fuyuanshen.common.web.config.properties.CaptchaProperties;
import com.fuyuanshen.system.domain.vo.SysClientVo;
import com.fuyuanshen.web.domain.vo.LoginVo;
import com.fuyuanshen.web.service.IAuthStrategy;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* 密码认证策略
*
* @author Michelle.Chung
*/
@Slf4j
@Service("appPassword" + IAuthStrategy.BASE_NAME)
@RequiredArgsConstructor
public class AppPasswordAuthStrategy implements IAuthStrategy {
private final CaptchaProperties captchaProperties;
private final AppLoginService loginService;
private final AppUserMapper appUserMapper;
@Override
public LoginVo login(String body, SysClientVo client) {
PasswordLoginBody loginBody = JsonUtils.parseObject(body, PasswordLoginBody.class);
ValidatorUtils.validate(loginBody);
String tenantId = loginBody.getTenantId();
String username = loginBody.getUsername();
String password = loginBody.getPassword();
String code = loginBody.getCode();
String uuid = loginBody.getUuid();
// boolean captchaEnabled = captchaProperties.getEnable();
// // 验证码开关
// if (captchaEnabled) {
// validateCaptcha(tenantId, username, code, uuid);
// }
AppLoginUser loginUser = TenantHelper.dynamic(tenantId, () -> {
AppUserVo user = loadUserByUsername(username);
loginService.checkLogin(LoginType.PASSWORD, tenantId, username, () -> !password.equals(user.getPassword()));
// 此处可根据登录用户的数据不同 自行创建 loginUser
return loginService.buildLoginUser(user);
});
loginUser.setClientKey(client.getClientKey());
loginUser.setDeviceType(client.getDeviceType());
SaLoginParameter model = new SaLoginParameter();
model.setDeviceType(client.getDeviceType());
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
// 例如: 后台用户30分钟过期 app用户1天过期
model.setTimeout(client.getTimeout());
model.setActiveTimeout(client.getActiveTimeout());
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
// 生成token
AppLoginHelper.login(loginUser, model);
LoginVo loginVo = new LoginVo();
loginVo.setAccessToken(StpUtil.getTokenValue());
loginVo.setExpireIn(StpUtil.getTokenTimeout());
loginVo.setClientId(client.getClientId());
return loginVo;
}
/**
* 校验验证码
*
* @param username 用户名
* @param code 验证码
* @param uuid 唯一标识
*/
private void validateCaptcha(String tenantId, String username, String code, String uuid) {
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.blankToDefault(uuid, "");
String captcha = RedisUtils.getCacheObject(verifyKey);
RedisUtils.deleteObject(verifyKey);
if (captcha == null) {
loginService.recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
throw new CaptchaExpireException();
}
if (!code.equalsIgnoreCase(captcha)) {
loginService.recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"));
throw new CaptchaException();
}
}
private AppUserVo loadUserByUsername(String username) {
AppUserVo user = appUserMapper.selectVoOne(new LambdaQueryWrapper<AppUser>()
.eq(AppUser::getUserName, username)
.eq(AppUser::getUserType, UserType.APP_USER.getUserType()));
if (ObjectUtil.isNull(user)) {
log.info("登录用户:{} 不存在.", username);
throw new UserException("user.not.exists", username);
} else if (SystemConstants.DISABLE.equals(user.getStatus())) {
log.info("登录用户:{} 已被停用.", username);
throw new UserException("user.blocked", username);
}
return user;
}
}

View File

@ -6,14 +6,21 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuyuanshen.app.domain.AppDeviceBindRecord;
import com.fuyuanshen.app.domain.AppDeviceShare;
import com.fuyuanshen.app.domain.AppPersonnelInfoRecords;
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
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;
@ -22,6 +29,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @Description:
* @Author: WY
@ -35,6 +44,9 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
private final AppDeviceBindRecordMapper appDeviceBindRecordMapper;
private final AppPersonnelInfoRecordsMapper infoRecordsMapper;
private final DeviceLogMapper deviceLogMapper;
private final DeviceAlarmMapper deviceAlarmMapper;
private final DeviceMapper deviceMapper;
private final AppDeviceShareMapper appDeviceShareMapper;
@ -95,4 +107,50 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
}
/**
* 设备用户详情
*
* @param id
* @return
*/
@Override
public List<AppPersonnelInfoRecords> getDeviceUser(Long id) {
List<AppPersonnelInfoRecords> appPersonnelInfoRecords = infoRecordsMapper.selectList(
new QueryWrapper<AppPersonnelInfoRecords>().eq("device_id", id)
.orderByDesc("create_time"));
return appPersonnelInfoRecords;
}
/**
* 设备操作记录
*
* @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

@ -49,9 +49,9 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://47.120.79.150:3306/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
url: jdbc:mysql://120.79.224.186:3366/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
password: Jq_123456#
password: 1fys@QWER..
# # 从库数据源
# slave:
# lazy: true
@ -98,13 +98,13 @@ spring:
spring.data:
redis:
# 地址
host: 47.120.79.150
host: 120.79.224.186
# 端口默认为6379
port: 6379
port: 26379
# 数据库索引
database: 2
# redis 密码必须配置
password: xhYc_djkl382^#780!
password: 1fys@QWER..
# 连接超时时间
timeout: 10s
# 是否开启ssl
@ -174,14 +174,14 @@ sms:
# 框架定义的厂商名称标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
supplier: alibaba
# 有些称为accessKey有些称之为apiKey也有称为sdkKey或者appId。
access-key-id: LTAI5tJdDNpZootsPQ5hdELx
access-key-id: LTAI5tDGfJd4kMvrGtvyzCHz
# 称为accessSecret有些称之为apiSecret
access-key-secret: mU4WtffcCXpHPz5tLwQpaGtLsJXONt
access-key-secret: a4ZlVHVSYeMQHn0p1R18thA6xCdHQh
#模板ID 非必须配置如果使用sendMessage的快速发送需此配置
template-id: SMS_322180518
template-id: SMS_324526343
#模板变量 上述模板的变量
templateName: code
signature: 湖北星汉研创科技
signature: 深圳市富源晟科技
# sdk-app-id: 您的sdkAppId
config2:
# 厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
@ -300,8 +300,8 @@ file:
# MQTT配置
mqtt:
username: admin
password: #YtvpSfCNG
url: tcp://47.120.79.150:2883
password: fys123456
url: tcp://47.107.152.87:1883
subClientId: fys_subClient
subTopic: worker/location/#
pubTopic: B/#

View File

@ -52,9 +52,9 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://47.120.79.150:3306/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
url: jdbc:mysql://47.107.152.87:3306/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
password: Jq_123456#
password: Jz_5623_cl1
# # 从库数据源
# slave:
# lazy: true
@ -101,13 +101,13 @@ spring:
spring.data:
redis:
# 地址
host: 47.120.79.150
host: 47.107.152.87
# 端口默认为6379
port: 6379
# 数据库索引
database: 1
# redis 密码必须配置
password: xhYc_djkl382^#780!
password: re_fs_11520631
# 连接超时时间
timeout: 10s
# 是否开启ssl
@ -177,14 +177,14 @@ sms:
# 框架定义的厂商名称标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
supplier: alibaba
# 有些称为accessKey有些称之为apiKey也有称为sdkKey或者appId。
access-key-id: LTAI5tJdDNpZootsPQ5hdELx
access-key-id: LTAI5tDGfJd4kMvrGtvyzCHz
# 称为accessSecret有些称之为apiSecret
access-key-secret: mU4WtffcCXpHPz5tLwQpaGtLsJXONt
access-key-secret: a4ZlVHVSYeMQHn0p1R18thA6xCdHQh
#模板ID 非必须配置如果使用sendMessage的快速发送需此配置
template-id: SMS_322180518
template-id: SMS_324526343
#模板变量 上述模板的变量
templateName: code
signature: 湖北星汉研创科技
signature: 深圳市富源晟科技
config2:
# 厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
supplier: tencent
@ -280,12 +280,13 @@ justauth:
# MQTT配置
mqtt:
username: admin
password: #YtvpSfCNG
url: tcp://47.120.79.150:2883
password: fys123456
url: tcp://47.107.152.87:1883
subClientId: fys_subClient
subTopic: A/#,B/#,worker/location/#
subTopic: A/#,worker/location/#
pubTopic: B/#
pubClientId: fys_pubClient
enabled: false
# 文件存储路径

View File

@ -1,7 +1,7 @@
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8000
port: 8001
servlet:
# 应用的访问路径
context-path: /

View File

@ -22,6 +22,11 @@ public interface GlobalConstants {
*/
String DEVICE_SHARE_CODES_KEY = GLOBAL_REDIS_KEY + "device_share_codes:";
/**
* 验证码 redis key
*/
String APP_FORGOT_PASSWORD_SMS_KEY = GLOBAL_REDIS_KEY + "app_sms_forgotPassword:";
/**
* 防重提交 redis key
*/

View File

@ -0,0 +1,22 @@
package com.fuyuanshen.common.core.domain.model;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@Data
public class AppLoginBody {
/**
* 手机号不能为空
*/
@NotBlank(message = "手机号不能为空")
private String userName;
/**
* 密码不能为空
*/
@NotBlank(message = "密码不能为空")
private String password;
private String tenantId;
}

View File

@ -0,0 +1,22 @@
package com.fuyuanshen.common.core.domain.model;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@Data
public class AppSmsRegisterBody {
@NotBlank(message = "手机号不能为空")
private String phoneNumber;
@NotBlank(message = "密码不能为空")
private String password;
@NotBlank(message = "验证码不能为空")
private String verificationCode;
/**
* 租户ID
*/
private String tenantId;
}

View File

@ -18,14 +18,14 @@ public class PasswordLoginBody extends LoginBody {
* 用户名
*/
@NotBlank(message = "{user.username.not.blank}")
@Length(min = 2, max = 30, message = "{user.username.length.valid}")
// @Length(min = 2, max = 30, message = "{user.username.length.valid}")
private String username;
/**
* 用户密码
*/
@NotBlank(message = "{user.password.not.blank}")
@Length(min = 5, max = 30, message = "{user.password.length.valid}")
// @Length(min = 5, max = 30, message = "{user.password.length.valid}")
private String password;
}

View File

@ -24,6 +24,13 @@ public class DecryptRequestBodyWrapper extends HttpServletRequestWrapper {
private final byte[] body;
/**
* @param request
* @param privateKey
* @param headerFlag encrypt-key
* @throws IOException
*/
public DecryptRequestBodyWrapper(HttpServletRequest request, String privateKey, String headerFlag) throws IOException {
super(request);
// 获取 AES 密码 采用 RSA 加密

View File

@ -19,31 +19,36 @@ public class EncryptUtilsTest {
String s = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKNPuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gAkM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWowcSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99EcvDQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthhYhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3UP8iWi1Qw0Y=";
/**
* encrypt-key
*/
String s1 = EncryptUtils.encryptByRsa("MTIzNDU2Nzg5MGFiY2RlZg==", g);
System.out.println(s1);
System.out.println("-------------s1--------------");
String s2 = EncryptUtils.decryptByRsa("jJPaW7hgFXD/gjdkrfBOEUdXpPZnQg/LZUASoOJAOLU/XRVXO/5666CzyALjw7neK1ujvRuys4MdKCvr9cRARw==", s);
System.out.println(s2);
System.out.println("-------------s2--------------");
String s3 = EncryptUtils.decryptByBase64(s2);
System.out.println(s3);
System.out.println("-------------s2--------------");
String s4 = EncryptUtils.encryptByAes("123456", s3);
System.out.println(s4);
System.out.println("-------------s2--------------");
String s5 = EncryptUtils.decryptByAes(s4, s3);
System.out.println(s5);
System.out.println("-------------s2--------------");
// 1. 构造 LoginBody 对象
PasswordLoginBody loginBody = new PasswordLoginBody();
loginBody.setClientId("e5cd7e4891bf95d1d19206ce24a7b32e");
loginBody.setGrantType("password");
loginBody.setTenantId("894078");
loginBody.setCode("9");
loginBody.setUuid("d5be31eac1244cee851a9903f358bc6a");
loginBody.setCode("2");
loginBody.setUuid("d339659cea5245aab7df92642326218e");
// loginBody.setUsername("admin");
// loginBody.setPassword("admin123");
loginBody.setUsername("dyf");
loginBody.setUsername("fel");
loginBody.setPassword("123456");
// 2. 使用更清晰的方式拼接 JSON 字符串
@ -67,9 +72,12 @@ public class EncryptUtilsTest {
);
/**
* body
*/
String S5 = EncryptUtils.encryptByAes(jsonLoginBody, s3);
System.out.println(S5);
System.out.println("-------------s5--------------");
String S6 = EncryptUtils.decryptByAes(S5, s3);
System.out.println(S6);

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

@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestSMSController {
@GetMapping("/test")
public void testSend() {
// 在创建完SmsBlend实例后再未手动调用注销的情况下框架会持有该实例可以直接通过指定configId来获取想要的配置如果你想使用

View File

@ -39,7 +39,7 @@ public class WebAppUserController extends BaseController {
/**
* 查询APP用户信息列表
* 查询APP用户信息列表
*/
// @SaCheckPermission("app:user:list")
@GetMapping("/list")
@ -67,7 +67,7 @@ public class WebAppUserController extends BaseController {
@SaCheckPermission("app:user:query")
@GetMapping("/{userId}")
public R<AppUserVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long userId) {
@PathVariable Long userId) {
return R.ok(appUserService.queryById(userId));
}
@ -105,4 +105,5 @@ public class WebAppUserController extends BaseController {
@PathVariable Long[] userIds) {
return toAjax(appUserService.deleteWithValidByIds(List.of(userIds), true));
}
}

View File

@ -1,14 +1,13 @@
package com.fuyuanshen.app.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fuyuanshen.common.mybatis.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fuyuanshen.common.tenant.core.TenantEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serial;
import java.util.Date;
/**
* 设备绑定关系对象 app_device_bind_record

View File

@ -1,13 +1,14 @@
package com.fuyuanshen.app.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
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;
import java.util.Date;
/**
* APP用户信息对象 app_user
@ -95,5 +96,9 @@ public class AppUser extends TenantEntity {
*/
private String remark;
/**
* 地区
*/
private String region;
}

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

@ -0,0 +1,19 @@
package com.fuyuanshen.app.domain.dto;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@Data
public class APPForgotPasswordDTO {
@NotBlank(message = "手机号不能为空")
private String phoneNumber;
@NotBlank(message = "密码不能为空")
private String password;
@NotBlank(message = "验证码不能为空")
private String verificationCode;
}

View File

@ -0,0 +1,12 @@
package com.fuyuanshen.app.domain.dto;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@Data
public class APPForgotPasswordSmsDTO {
@NotBlank(message = "手机号不能为空")
private String phoneNumber;
}

View File

@ -1,8 +1,6 @@
package com.fuyuanshen.app.domain.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

View File

@ -0,0 +1,33 @@
package com.fuyuanshen.app.domain.dto;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
/**
* @author: 默苍璃
* @date: 2025-06-1818:36
*/
@Data
public class APPUpdateUserDTO {
/**
* 用户昵称
*/
private String nickName;
/**
* 用户地区
*/
private String region;
/**
* 用户性别
*/
private String gender;
/**
* 用户头像
*/
private MultipartFile file;
}

View File

@ -0,0 +1,39 @@
package com.fuyuanshen.app.domain.vo;
import lombok.Data;
@Data
public class APPUserInfoVo {
/**
* 用户ID
*/
private Long id;
/**
* 用户昵称
*/
private String nickName;
/**
* 性别
*/
private String gender;
/**
* 手机号码
*/
private String phone;
/**
* 头像地址
*/
private String avatarPath;
/**
* 地区
*/
private String region;
}

View File

@ -23,4 +23,8 @@ public class AppFileVo {
* 文件url
*/
private String fileUrl;
/**
* 文件类型(1:操作说明2:产品参数)
*/
private Long fileType;
}

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

@ -14,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface AppUserMapper extends BaseMapperPlus<AppUser, AppUserVo> {
AppUser appFindByUsername(String phoneNumber);
}

View File

@ -1,9 +1,13 @@
package com.fuyuanshen.app.service;
import com.fuyuanshen.app.domain.vo.AppUserVo;
import com.fuyuanshen.app.domain.bo.AppUserBo;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.app.domain.dto.APPForgotPasswordDTO;
import com.fuyuanshen.app.domain.dto.APPForgotPasswordSmsDTO;
import com.fuyuanshen.app.domain.dto.APPUpdateUserDTO;
import com.fuyuanshen.app.domain.vo.APPUserInfoVo;
import com.fuyuanshen.app.domain.vo.AppUserVo;
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import java.util.Collection;
import java.util.List;
@ -65,4 +69,12 @@ public interface IAppUserService {
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
APPUserInfoVo getUserInfo();
int updateUser(APPUpdateUserDTO bo);
int forgotPassword(APPForgotPasswordDTO bo);
int sendForgotPasswordSms(APPForgotPasswordSmsDTO dto);
}

View File

@ -7,6 +7,7 @@ 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 com.fuyuanshen.common.satoken.utils.AppLoginHelper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -66,6 +67,8 @@ public class AppOperationVideoServiceImpl implements IAppOperationVideoService {
*/
@Override
public List<AppOperationVideoVo> queryList(AppOperationVideoBo bo) {
Long userId = AppLoginHelper.getUserId();
bo.setCreateBy(userId);
LambdaQueryWrapper<AppOperationVideo> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}

View File

@ -3,8 +3,15 @@ package com.fuyuanshen.app.service.impl;
import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fuyuanshen.app.domain.dto.APPForgotPasswordDTO;
import com.fuyuanshen.app.domain.dto.APPForgotPasswordSmsDTO;
import com.fuyuanshen.app.domain.dto.APPUpdateUserDTO;
import com.fuyuanshen.app.domain.vo.APPUserInfoVo;
import com.fuyuanshen.common.core.constant.Constants;
import com.fuyuanshen.common.core.constant.GlobalConstants;
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
import com.fuyuanshen.common.core.exception.BadRequestException;
import com.fuyuanshen.common.core.utils.MapstructUtils;
import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
@ -12,9 +19,12 @@ 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 com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
import com.fuyuanshen.common.satoken.utils.LoginHelper;
import com.fuyuanshen.common.tenant.helper.TenantHelper;
import com.fuyuanshen.system.domain.vo.SysOssVo;
import com.fuyuanshen.system.service.ISysOssService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -42,6 +52,7 @@ public class AppUserServiceImpl implements IAppUserService {
private final AppUserMapper baseMapper;
private final ISysOssService sysOssService;
/**
* 查询APP用户信息
*
@ -148,4 +159,75 @@ public class AppUserServiceImpl implements IAppUserService {
}
return baseMapper.deleteByIds(ids) > 0;
}
@Override
public APPUserInfoVo getUserInfo() {
String username = AppLoginHelper.getUsername();
QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_name", username);
List<AppUser> appUsers = baseMapper.selectList(queryWrapper);
if(appUsers.isEmpty()){
throw new BadRequestException("用户不存在");
}
AppUser user = appUsers.get(0);
// AppUserVo user = baseMapper.selectVoById(userId);
APPUserInfoVo appUserVo = new APPUserInfoVo();
appUserVo.setId(user.getUserId());
appUserVo.setNickName(user.getNickName());
appUserVo.setGender(user.getSex());
appUserVo.setPhone(user.getPhonenumber());
appUserVo.setRegion(user.getRegion());
if(user.getAvatar() != null){
SysOssVo oss = sysOssService.getById(user.getAvatar());
if(oss != null){
appUserVo.setAvatarPath(oss.getUrl());
}
}
return appUserVo;
}
@Override
public int updateUser(APPUpdateUserDTO bo) {
AppLoginUser appUser = AppLoginHelper.getLoginUser();
AppUserVo appUserVo = baseMapper.selectVoById(appUser.getUserId());
if(appUserVo == null){
throw new BadRequestException("用户不存在");
}
AppUser updUser= new AppUser();
updUser.setUserId(appUser.getUserId());
updUser.setNickName(bo.getNickName());
if(bo.getFile() != null){
SysOssVo oss = sysOssService.upload(bo.getFile());
updUser.setAvatar(oss.getOssId());
}
updUser.setRegion(bo.getRegion());
updUser.setSex(bo.getGender());
return baseMapper.update(updUser, new LambdaQueryWrapper<AppUser>().eq(AppUser::getUserId, appUser.getUserId()));
}
@Override
public int forgotPassword(APPForgotPasswordDTO bo) {
AppUser appUser = baseMapper.appFindByUsername(bo.getPhoneNumber());
if (appUser == null) {
throw new BadRequestException("手机号不存在");
}
String verificationCode = RedisUtils.getCacheObject(GlobalConstants.APP_FORGOT_PASSWORD_SMS_KEY + bo.getPhoneNumber());
if (verificationCode == null) {
throw new BadRequestException("验证码已过期");
}
if(!bo.getVerificationCode().equals(verificationCode)){
throw new BadRequestException("验证码错误");
}
appUser.setPassword(bo.getPassword());
baseMapper.updateById(appUser);
return 1;
}
@Override
public int sendForgotPasswordSms(APPForgotPasswordSmsDTO dto) {
return 1;
}
}

View File

@ -7,6 +7,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="queryAppFileList" resultType="com.fuyuanshen.app.domain.vo.AppFileVo">
select a.id,a.business_id,a.file_id,b.file_name,b.url fileUrl from app_business_file a left join sys_oss b on a.file_id = b.oss_id
where 1=1
<if test="createBy != null">
a.create_by = #{createBy}
</if>
<if test="businessId != null">
and a.business_id = #{businessId}
</if>

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.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">
@ -33,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dt.type_name,
dt.communication_mode,
d.bluetooth_name,
dt.model_dictionary detailPageUrl,
dt.app_model_dictionary detailPageUrl,
c.binding_time,
ad.*,u.user_name otherPhonenumber
from
@ -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

@ -4,4 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuyuanshen.app.mapper.AppUserMapper">
<select id="appFindByUsername" resultType="com.fuyuanshen.app.domain.AppUser">
select * from app_user where user_name = #{phoneNumber}
</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;
@ -154,4 +161,8 @@ public class Device extends TenantEntity {
@Schema(title = "出厂日期")
private Date productionDate;
/**
* 在线状态(0离线1在线)
*/
private Integer onlineStatus;
}

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

@ -0,0 +1,43 @@
package com.fuyuanshen.equipment.domain.dto;
import lombok.Data;
@Data
public class InstructionRecordDto {
/**
* 设备类型
*/
private String deviceType;
/**
* 设备名称
*/
private String deviceName;
/**
* 设备MAC
*/
private String deviceMac;
/**
* 设备IMEI
*/
private String deviceImei;
/**
* content
*/
private String content;
/**
* 操作时间-开始时间
*/
private String startTime;
/**
* 操作时间-结束时间
*/
private String endTime;
/**
* 分组id
*/
private Long groupId;
}

View File

@ -18,22 +18,34 @@ import java.util.Set;
@Data
public class DeviceQueryCriteria extends BaseEntity {
@Schema(name = "设备id")
/**
* 设备id
*/
private Long deviceId;
@Schema(name = "设备名称")
/**
* 设备名称
*/
private String deviceName;
@Schema(name = "设备类型")
/**
* 设备类型
*/
private Long deviceType;
@Schema(name = "设备MAC")
/**
* 设备MAC
*/
private String deviceMac;
@Schema(name = "设备IMEI")
/**
* 设备IMEI
*/
private String deviceImei;
@Schema(name = "设备SN")
/**
* 设备SN
*/
private String deviceSn;
/**
@ -41,26 +53,37 @@ public class DeviceQueryCriteria extends BaseEntity {
* 0 失效
* 1 正常
*/
@Schema(name = "设备状态 0 失效 1 正常 ")
private Integer deviceStatus;
@Schema(name = "页码", example = "1")
/**
* 页码
*/
private Integer pageNum = 1;
@Schema(name = "每页数据量", example = "10")
/**
* 每页数据量
*/
private Integer pageSize = 10;
@Schema(name = "客户id")
/**
* 客户id
*/
private Long customerId;
private Set<Long> customerIds;
@Schema(name = "当前所有者")
/**
* 当前所有者
*/
private Long currentOwnerId;
@Schema(name = "租户ID")
/**
* 租户ID
*/
private String tenantId;
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
/**
* 通讯方式 0:4G;1:蓝牙
*/
private Integer communicationMode;
/* app绑定用户id */
@ -72,22 +95,22 @@ public class DeviceQueryCriteria extends BaseEntity {
*/
private String personnelBy;
/**
* 是否为管理员
*/
@Schema(name = "是否为管理员")
private Boolean isAdmin = false;
/**
* 设备所属分组
*/
@Schema(name = "设备所属分组")
private Long groupId;
/**
* 设备地区
*/
@Schema(name = "设备地区")
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

@ -0,0 +1,39 @@
package com.fuyuanshen.equipment.domain.vo;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class InstructionRecordVo {
private Long id;
/**
* 设备名称
*/
@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

@ -1,8 +1,12 @@
package com.fuyuanshen.equipment.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.equipment.domain.DeviceLog;
import com.fuyuanshen.equipment.domain.dto.InstructionRecordDto;
import com.fuyuanshen.equipment.domain.vo.DeviceLogVo;
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
import com.fuyuanshen.equipment.domain.vo.InstructionRecordVo;
import org.apache.ibatis.annotations.Param;
/**
* 设备日志Mapper接口
@ -12,4 +16,5 @@ import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
*/
public interface DeviceLogMapper extends BaseMapperPlus<DeviceLog, DeviceLogVo> {
Page<InstructionRecordVo> getInstructionRecord(Page<InstructionRecordVo> page,@Param("bo") InstructionRecordDto bo);
}

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;
@ -70,5 +72,7 @@ public interface DeviceMapper extends BaseMapper<Device> {
AppDeviceVo getDeviceInfo(@Param("deviceMac") String deviceMac);
Page<WebDeviceVo> queryWebDeviceList(Page<Object> build, DeviceQueryCriteria bo);
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

@ -3,6 +3,7 @@ package com.fuyuanshen.equipment.service;
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.equipment.domain.vo.DeviceGroupVo;
import com.fuyuanshen.equipment.domain.bo.DeviceGroupBo;
import jakarta.validation.constraints.NotEmpty;
import java.util.Collection;
import java.util.List;
@ -56,4 +57,22 @@ public interface IDeviceGroupService {
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/**
* 绑定设备分组
*
* @param groupId 分组id
* @param deviceId 设备id
* @return 是否绑定成功
*/
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

@ -1,6 +1,7 @@
package com.fuyuanshen.equipment.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuyuanshen.common.core.domain.R;
@ -11,6 +12,8 @@ import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
import com.fuyuanshen.common.satoken.utils.LoginHelper;
import com.fuyuanshen.equipment.domain.Device;
import com.fuyuanshen.equipment.domain.DeviceTypeGrants;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import jakarta.validation.constraints.NotEmpty;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -22,6 +25,7 @@ import com.fuyuanshen.equipment.mapper.DeviceGroupMapper;
import com.fuyuanshen.equipment.service.IDeviceGroupService;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Collection;
@ -39,6 +43,7 @@ import java.util.stream.Collectors;
public class DeviceGroupServiceImpl implements IDeviceGroupService {
private final DeviceGroupMapper baseMapper;
private final DeviceMapper deviceMapper;
/**
@ -63,7 +68,7 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
public List<DeviceGroupVo> queryList(DeviceGroupBo bo) {
Page<Device> page = new Page<>(bo.getPageNum(), bo.getPageSize());
// 1. 查询顶级分组parent_id为null
IPage<DeviceGroup> rootGroups = baseMapper.selectRootGroups(bo, page);
IPage<DeviceGroup> rootGroups = baseMapper.selectRootGroups(bo, page);
List<DeviceGroup> records = rootGroups.getRecords();
// 2. 递归构建树形结构
@ -87,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;
}
@ -119,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);
@ -169,4 +177,52 @@ public class DeviceGroupServiceImpl implements IDeviceGroupService {
}
return baseMapper.deleteByIds(ids) > 0;
}
/**
* 绑定设备分组
*
* @param groupId 分组id
* @param deviceId 设备id
* @return 是否绑定成功
*/
@Override
public Boolean bindingDevice(Long groupId, Long[] deviceId) {
if (deviceId != null && deviceId.length > 0) {
// 创建更新条件
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
updateWrapper.in("id", Arrays.asList(deviceId));
updateWrapper.set("group_id", groupId);
// 执行批量更新
deviceMapper.update(updateWrapper);
}
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

@ -4,4 +4,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuyuanshen.equipment.mapper.DeviceLogMapper">
<select id="getInstructionRecord" resultType="com.fuyuanshen.equipment.domain.vo.InstructionRecordVo">
SELECT
a.id,
a.device_name AS deviceName,
c.type_name deviceType,
a.device_action AS deviceAction,
a.content,
a.create_time AS createTime
FROM
device_log a left join device b on a.device_id = b.id
left join device_type c on b.device_type = c.id
WHERE 1 = 1
<if test="bo.deviceType != null">
AND c.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 b.device_mac = #{bo.deviceMac}
</if>
<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 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 b.group_id = #{bo.groupId}
</if>
ORDER BY
a.create_time DESC
</select>
</mapper>

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>
@ -151,7 +154,7 @@
dt.type_name,
dt.communication_mode,
d.bluetooth_name,
dt.model_dictionary detailPageUrl,
dt.app_model_dictionary detailPageUrl,
c.binding_time
from device d
inner join device_type dt on d.device_type = dt.id
@ -181,7 +184,7 @@
d.device_pic,
dt.type_name,
dt.communication_mode,
dt.model_dictionary detailPageUrl,
dt.app_model_dictionary detailPageUrl,
d.bluetooth_name
from device d
inner join device_type dt on d.device_type = dt.id
@ -227,7 +230,7 @@
dt.type_name,
dt.communication_mode,
d.bluetooth_name,
dt.model_dictionary detailPageUrl
dt.app_model_dictionary detailPageUrl
from device d
inner join device_type dt on d.device_type = dt.id
where d.device_mac = #{deviceMac}
@ -242,7 +245,7 @@
dt.type_name,
dt.communication_mode,
d.bluetooth_name,
dt.model_dictionary detailPageUrl,
dt.pc_model_dictionary detailPageUrl,
ap.name personnelBy,
d.device_status,
c.binding_time
@ -254,14 +257,14 @@
<if test="criteria.deviceType != null">
and d.device_type = #{criteria.deviceType}
</if>
<if test="criteria.deviceName != null">
<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}
@ -270,8 +273,42 @@
and ap.name like concat('%', #{criteria.personnelBy}, '%')
</if>
<if test="criteria.communicationMode != null">
and dt.communication_mode, = #{criteria.communicationMode}
and dt.communication_mode = #{criteria.communicationMode}
</if>
<if test="criteria.groupId != null">
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

16
pom.xml
View File

@ -83,10 +83,10 @@
<monitor.username>fys</monitor.username>
<monitor.password>123456</monitor.password>
</properties>
<activation>
<!-- 默认环境 -->
<activeByDefault>true</activeByDefault>
</activation>
<!-- <activation> -->
<!-- &lt;!&ndash; 默认环境 &ndash;&gt; -->
<!-- <activeByDefault>true</activeByDefault> -->
<!-- </activation> -->
</profile>
<profile>
<id>prod</id>
@ -96,10 +96,10 @@
<monitor.username>fys</monitor.username>
<monitor.password>123456</monitor.password>
</properties>
<!-- <activation> -->
<!-- &lt;!&ndash; 默认环境 &ndash;&gt; -->
<!-- <activeByDefault>true</activeByDefault> -->
<!-- </activation> -->
<activation>
<!-- 默认环境 -->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>jingquan</id>