From 98ef841f184e927910bb0aa8059ec92130f7303d Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Tue, 2 Sep 2025 10:32:17 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E9=80=9A=E8=AE=AF=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../equipment/domain/query/DeviceQueryCriteria.java | 1 + .../src/main/resources/mapper/equipment/DeviceMapper.xml | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java index 233230ee..d4cb7766 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java @@ -83,6 +83,7 @@ public class DeviceQueryCriteria extends BaseEntity { /** * 通讯方式 0:4G;1:蓝牙 + * communication_mode */ private Integer communicationMode; diff --git a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml index 20b385cc..45bca794 100644 --- a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml +++ b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml @@ -74,6 +74,9 @@ and d.group_id = #{criteria.groupId} + + and t.communication_mode = #{criteria.communicationMode} + and da.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime} @@ -280,7 +283,7 @@ + + + + + + + + + + + + + + \ No newline at end of file From d97928b38abdbf837a0ecbf2663e82217af6240d Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Wed, 3 Sep 2025 09:45:17 +0800 Subject: [PATCH 03/18] =?UTF-8?q?=E5=88=86=E9=85=8D=E5=AE=A2=E6=88=B7=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DeviceController.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceController.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceController.java index 229c2da3..030452a1 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceController.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/controller/DeviceController.java @@ -126,26 +126,26 @@ public class DeviceController extends BaseController { // @Log("分配客户") - @Operation(summary = "分配客户") - @PutMapping(value = "/assignCustomer") - public R assignCustomer(@Validated @RequestBody CustomerVo customerVo) { - deviceService.assignCustomer(customerVo); - return R.ok(); - } + // @Operation(summary = "分配客户") + // @PutMapping(value = "/assignCustomer") + // public R assignCustomer(@Validated @RequestBody CustomerVo customerVo) { + // deviceService.assignCustomer(customerVo); + // return R.ok(); + // } // @Log("撤回设备") - @Operation(summary = "撤回分配设备") - @PostMapping(value = "/withdraw") - public R withdrawDevice(@RequestBody List ids) { - try { - deviceService.withdrawDevice(ids); - } catch (Exception e) { - log.error("updateDevice error: " + e.getMessage()); - return R.fail(e.getMessage()); - } - return R.ok(); - } + // @Operation(summary = "撤回分配设备") + // @PostMapping(value = "/withdraw") + // public R withdrawDevice(@RequestBody List ids) { + // try { + // deviceService.withdrawDevice(ids); + // } catch (Exception e) { + // log.error("updateDevice error: " + e.getMessage()); + // return R.fail(e.getMessage()); + // } + // return R.ok(); + // } // // /** From 98cb67b1365a0538c18609fec92ea89606211888 Mon Sep 17 00:00:00 2001 From: chenyouting <514333061@qq.com> Date: Wed, 3 Sep 2025 15:11:24 +0800 Subject: [PATCH 04/18] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=BB=8F=E7=BA=AC=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mqtt/rule/bjq/BjqLocationDataRule.java | 42 +++++++++---------- .../device/DeviceShareController.java | 16 +++++-- .../service/impl/DeviceLogServiceImpl.java | 1 + 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/rule/bjq/BjqLocationDataRule.java b/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/rule/bjq/BjqLocationDataRule.java index 0c3bda1f..69637bfd 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/rule/bjq/BjqLocationDataRule.java +++ b/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/rule/bjq/BjqLocationDataRule.java @@ -117,28 +117,28 @@ public class BjqLocationDataRule implements MqttMessageRule { if(StringUtils.isBlank(latitude) || StringUtils.isBlank(longitude)){ return; } - String[] latArr = latitude.split("\\."); - String[] lonArr = longitude.split("\\."); - // 将位置信息存储到Redis中 +// String[] latArr = latitude.split("\\."); +// String[] lonArr = longitude.split("\\."); +// // 将位置信息存储到Redis中 String redisKey = GlobalConstants.GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DEVICE_LOCATION_KEY_PREFIX; - String redisObj = RedisUtils.getCacheObject(redisKey); - JSONObject jsonOBj = JSONObject.parseObject(redisObj); - if(jsonOBj != null){ - String str1 = latArr[0] +"."+ latArr[1].substring(0,4); - String str2 = lonArr[0] +"."+ lonArr[1].substring(0,4); - - String cacheLatitude = jsonOBj.getString("wgs84_latitude"); - String cacheLongitude = jsonOBj.getString("wgs84_longitude"); - String[] latArr1 = cacheLatitude.split("\\."); - String[] lonArr1 = cacheLongitude.split("\\."); - - String cacheStr1 = latArr1[0] +"."+ latArr1[1].substring(0,4); - String cacheStr2 = lonArr1[0] +"."+ lonArr1[1].substring(0,4); - if(str1.equals(cacheStr1) && str2.equals(cacheStr2)){ - log.info("位置信息未发生变化: device={}, lat={}, lon={}", deviceImei, latitude, longitude); - return; - } - } +// String redisObj = RedisUtils.getCacheObject(redisKey); +// JSONObject jsonOBj = JSONObject.parseObject(redisObj); +// if(jsonOBj != null){ +// String str1 = latArr[0] +"."+ latArr[1].substring(0,4); +// String str2 = lonArr[0] +"."+ lonArr[1].substring(0,4); +// +// String cacheLatitude = jsonOBj.getString("wgs84_latitude"); +// String cacheLongitude = jsonOBj.getString("wgs84_longitude"); +// String[] latArr1 = cacheLatitude.split("\\."); +// String[] lonArr1 = cacheLongitude.split("\\."); +// +// String cacheStr1 = latArr1[0] +"."+ latArr1[1].substring(0,4); +// String cacheStr2 = lonArr1[0] +"."+ lonArr1[1].substring(0,4); +// if(str1.equals(cacheStr1) && str2.equals(cacheStr2)){ +// log.info("位置信息未发生变化: device={}, lat={}, lon={}", deviceImei, latitude, longitude); +// return; +// } +// } // 构造位置信息对象 Map locationInfo = new LinkedHashMap<>(); diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java index e623e9d6..e271fc64 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java @@ -2,6 +2,9 @@ package com.fuyuanshen.web.controller.device; import com.fuyuanshen.app.domain.bo.AppDeviceShareBo; import com.fuyuanshen.app.domain.vo.AppDeviceShareVo; +import com.fuyuanshen.common.core.domain.R; +import com.fuyuanshen.common.core.validate.AddGroup; +import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit; import com.fuyuanshen.common.mybatis.core.page.PageQuery; import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; import com.fuyuanshen.common.web.core.BaseController; @@ -10,9 +13,7 @@ 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; +import org.springframework.web.bind.annotation.*; /** * 设备分享管理 @@ -39,5 +40,12 @@ public class DeviceShareController extends BaseController { } - + /** + * 新增设备分享 + */ + @RepeatSubmit() + @PostMapping("/deviceShare") + public R deviceShare(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) { + return toAjax(appDeviceShareService.deviceShare(bo)); + } } diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceLogServiceImpl.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceLogServiceImpl.java index 16ca6d3d..9ded85ab 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceLogServiceImpl.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceLogServiceImpl.java @@ -99,6 +99,7 @@ public class DeviceLogServiceImpl implements IDeviceLogService { lqw.eq(StringUtils.isNotBlank(bo.getDataSource()), DeviceLog::getDataSource, bo.getDataSource()); lqw.like(StringUtils.isNotBlank(bo.getContent()), DeviceLog::getContent, bo.getContent()); lqw.in(CollectionUtil.isNotEmpty(bo.getDeviceIds()), DeviceLog::getDeviceId, bo.getDeviceIds()); + lqw.orderByDesc(DeviceLog::getCreateTime); return lqw; } From ff4db34e2adfec2af15f67487fc7447604f6cf06 Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Thu, 4 Sep 2025 11:29:07 +0800 Subject: [PATCH 05/18] =?UTF-8?q?=E5=9E=8B=E5=8F=B7=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E7=94=A8=E4=BA=8EAPP=E9=A1=B5=E9=9D=A2=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../equipment/domain/form/DeviceTypeForm.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/form/DeviceTypeForm.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/form/DeviceTypeForm.java index d5e1df70..93197f47 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/form/DeviceTypeForm.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/form/DeviceTypeForm.java @@ -35,4 +35,18 @@ public class DeviceTypeForm { @Schema(title = "型号字典用于APP页面跳转") private String modelDictionary; + /** + * 型号字典用于APP页面跳转 + * app_model_dictionary + */ + @Schema(title = "型号字典用于APP页面跳转") + private String appModelDictionary; + + /** + * 型号字典用于PC页面跳转 + * pc_model_dictionary + */ + @Schema(title = "型号字典用于PC页面跳转") + private String pcModelDictionary; + } From 452c37c4caf2da52151d93607aee6fc460a12531 Mon Sep 17 00:00:00 2001 From: chenyouting <514333061@qq.com> Date: Thu, 4 Sep 2025 18:40:08 +0800 Subject: [PATCH 06/18] =?UTF-8?q?=E7=A6=BB=E7=BA=BF=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/RedisKeyExpirationListener.java | 29 +++++++++++++++++-- .../service/device/DeviceBJQBizService.java | 1 - .../domain/query/DeviceQueryCriteria.java | 6 ++++ .../mapper/equipment/DeviceMapper.xml | 4 +++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/listener/RedisKeyExpirationListener.java b/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/listener/RedisKeyExpirationListener.java index 86e669a0..11305d19 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/listener/RedisKeyExpirationListener.java +++ b/fys-admin/src/main/java/com/fuyuanshen/global/mqtt/listener/RedisKeyExpirationListener.java @@ -1,23 +1,37 @@ package com.fuyuanshen.global.mqtt.listener; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.fuyuanshen.common.core.constant.GlobalConstants; import com.fuyuanshen.common.redis.utils.RedisUtils; +import com.fuyuanshen.equipment.domain.Device; +import com.fuyuanshen.equipment.mapper.DeviceMapper; import com.fuyuanshen.global.mqtt.listener.domain.FunctionAccessStatus; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.connection.Message; import org.springframework.data.redis.connection.MessageListener; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; import java.time.Duration; -import java.util.HashMap; -import java.util.Map; import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY; import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_TIMEOUT_KEY; +import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX; +import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_ONLINE_STATUS_KEY_PREFIX; @Component @Slf4j public class RedisKeyExpirationListener implements MessageListener { + @Autowired + @Qualifier("threadPoolTaskExecutor") + private ThreadPoolTaskExecutor threadPoolTaskExecutor; + + @Autowired + private DeviceMapper deviceMapper; + @Override public void onMessage(Message message, byte[] pattern) { String expiredKey = new String(message.getBody()); @@ -26,8 +40,17 @@ public class RedisKeyExpirationListener implements MessageListener { String element = expiredKey.substring(FUNCTION_ACCESS_KEY.length()); handleFunctionAccessExpired(element); } + if(expiredKey.endsWith(DEVICE_ONLINE_STATUS_KEY_PREFIX)){ + threadPoolTaskExecutor.execute(() -> { + log.info("设备离线:{}", expiredKey); + String element = expiredKey.substring(GlobalConstants.GLOBAL_REDIS_KEY.length() + DEVICE_KEY_PREFIX.length(), expiredKey.length() - DEVICE_ONLINE_STATUS_KEY_PREFIX.length()); + UpdateWrapper deviceUpdateWrapper = new UpdateWrapper<>(); + deviceUpdateWrapper.eq("device_imei", element); + deviceUpdateWrapper.set("online_status", 0); + deviceMapper.update(deviceUpdateWrapper); + }); + } } - /** * 访问key过期事件 * @param element 批次ID diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBJQBizService.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBJQBizService.java index 17c8d8ae..591ed6ef 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBJQBizService.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/device/DeviceBJQBizService.java @@ -100,7 +100,6 @@ public class DeviceBJQBizService { UpdateWrapper updateWrapper = new UpdateWrapper<>(); updateWrapper.eq("id", deviceId) - .eq("binding_user_id", AppLoginHelper.getUserId()) .set("send_msg", bo.getSendMsg()); deviceMapper.update(updateWrapper); diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java index d4cb7766..1ec9137f 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/query/DeviceQueryCriteria.java @@ -114,4 +114,10 @@ public class DeviceQueryCriteria extends BaseEntity { private String content; + /** + * 设备在线状态 + * 0:离线;1:在线 + */ + private Integer onlineStatus; + } diff --git a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml index 88b17759..81c66744 100644 --- a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml +++ b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml @@ -281,6 +281,10 @@ and d.group_id = #{criteria.groupId} + + and d.online_status = #{criteria.onlineStatus} + + ORDER BY d.create_time DESC - select * + select d.device_name, + d.device_mac, + d.device_sn, + d.device_imei, + d.device_pic, + dt.type_name, + dt.communication_mode, + d.bluetooth_name, + dt.app_model_dictionary detailPageUrl, + 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 and ad.device_id = #{bo.deviceId} - and ad.share_user = #{bo.shareUser} + and u.user_name = #{bo.shareUser} - and d.create_time between #{bo.shareStartTime} and #{bo.shareEndTime} + and ad.create_time between #{bo.shareStartTime} and #{bo.shareEndTime} diff --git a/fys-modules/fys-generator/src/main/resources/vm/java/controller.java.vm b/fys-modules/fys-generator/src/main/resources/vm/java/controller.java.vm index 9f9c8185..6b836491 100644 --- a/fys-modules/fys-generator/src/main/resources/vm/java/controller.java.vm +++ b/fys-modules/fys-generator/src/main/resources/vm/java/controller.java.vm @@ -56,7 +56,7 @@ public class ${ClassName}Controller extends BaseController { #end /** - * 导出${functionName}列表 + * ${functionName}列表 */ @SaCheckPermission("${permissionPrefix}:export") @Log(title = "${functionName}", businessType = BusinessType.EXPORT) From 870f94b2d4cb8dc4f7ad7a5f3dcfde70511602d3 Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Mon, 8 Sep 2025 16:12:02 +0800 Subject: [PATCH 11/18] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/DeviceShareController.java | 1 + .../device/WEBDeviceController.java | 19 +++++++++--- .../web/service/WEBDeviceService.java | 9 ++++-- .../service/impl/WEBDeviceServiceImpl.java | 31 +++++++++++++++---- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java index 9b448047..26c0fc02 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java @@ -46,4 +46,5 @@ public class DeviceShareController extends BaseController { public R deviceShare(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) { return toAjax(appDeviceShareService.deviceShare(bo)); } + } diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java index c9580591..7f61a218 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java @@ -65,7 +65,7 @@ public class WEBDeviceController extends BaseController { * @param deviceId * @return */ - @Operation(summary = "设备详情") + @Operation(summary = "设备用户详情") @GetMapping(value = "/getDeviceUser/{deviceId}") public R> getDeviceUser(@PathVariable Long deviceId) { List device = deviceService.getDeviceUser(deviceId); @@ -77,12 +77,16 @@ public class WEBDeviceController extends BaseController { * 设备操作记录 * * @param deviceId + * @param startTime 开始时间 + * @param endTime 结束时间 * @return */ @Operation(summary = "设备操作记录") @GetMapping(value = "/getOperationRecord/{deviceId}") - public R> getOperationRecord(@PathVariable Long deviceId) { - List device = deviceService.getOperationRecord(deviceId); + public R> getOperationRecord(@PathVariable Long deviceId, + @RequestParam(required = false) String startTime, + @RequestParam(required = false) String endTime) { + List device = deviceService.getOperationRecord(deviceId, startTime, endTime); return R.ok(device); } @@ -91,16 +95,21 @@ public class WEBDeviceController extends BaseController { * 设备告警记录 * * @param deviceId + * @param startTime 开始时间 + * @param endTime 结束时间 * @return */ @Operation(summary = "设备告警记录") @GetMapping(value = "/getAlarmRecord/{deviceId}") - public R> getAlarmRecord(@PathVariable Long deviceId) { - List device = deviceService.getAlarmRecord(deviceId); + public R> getAlarmRecord(@PathVariable Long deviceId, + @RequestParam(required = false) String startTime, + @RequestParam(required = false) String endTime) { + List device = deviceService.getAlarmRecord(deviceId, startTime, endTime); return R.ok(device); } + } diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/WEBDeviceService.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/WEBDeviceService.java index 7066a519..f83658c6 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/WEBDeviceService.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/WEBDeviceService.java @@ -53,16 +53,21 @@ public interface WEBDeviceService extends IService { * 设备操作记录 * * @param deviceId + * @param startTime 开始时间 + * @param endTime 结束时间 * @return */ - List getOperationRecord(Long deviceId); + List getOperationRecord(Long deviceId, String startTime, String endTime); /** * 设备告警记录 * * @param deviceId + * @param startTime 开始时间 + * @param endTime 结束时间 * @return */ - List getAlarmRecord(Long deviceId); + List getAlarmRecord(Long deviceId, String startTime, String endTime); + } diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java index cc927804..b6ec1f15 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java @@ -1,6 +1,7 @@ package com.fuyuanshen.web.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -129,10 +130,19 @@ public class WEBDeviceServiceImpl extends ServiceImpl impl * @return */ @Override - public List getOperationRecord(Long deviceId) { + public List getOperationRecord(Long deviceId, String startTime, String endTime) { + QueryWrapper queryWrapper = new QueryWrapper().eq("device_id", deviceId); + + if (StrUtil.isNotEmpty(startTime)) { + queryWrapper.ge("create_time", startTime); + } + + if (StrUtil.isNotEmpty(endTime)) { + queryWrapper.le("create_time", endTime); + } + List logList = deviceLogMapper.selectList( - new QueryWrapper().eq("device_id", deviceId) - .orderByDesc("create_time")); + queryWrapper.orderByDesc("create_time")); return logList; } @@ -144,10 +154,19 @@ public class WEBDeviceServiceImpl extends ServiceImpl impl * @return */ @Override - public List getAlarmRecord(Long deviceId) { + public List getAlarmRecord(Long deviceId, String startTime, String endTime) { + QueryWrapper queryWrapper = new QueryWrapper().eq("device_id", deviceId); + + if (StrUtil.isNotEmpty(startTime)) { + queryWrapper.ge("create_time", startTime); + } + + if (StrUtil.isNotEmpty(endTime)) { + queryWrapper.le("create_time", endTime); + } + List alarmList = deviceAlarmMapper.selectList( - new QueryWrapper().eq("device_id", deviceId) - .orderByDesc("create_time")); + queryWrapper.orderByDesc("create_time")); List deviceAlarmVoList = BeanUtil.copyToList(alarmList, DeviceAlarmVo.class); return deviceAlarmVoList; } From 91f787eec7493ff8ade1df888f13b87518ef54dd Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Mon, 8 Sep 2025 17:37:01 +0800 Subject: [PATCH 12/18] pageQuery --- .../device/WEBDeviceController.java | 13 ++++++---- .../web/service/WEBDeviceService.java | 2 +- .../service/impl/WEBDeviceServiceImpl.java | 25 +++++++++++-------- .../equipment/domain/DeviceAlarm.java | 5 ++-- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java index 7f61a218..e05e6b74 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java @@ -3,6 +3,8 @@ package com.fuyuanshen.web.controller.device; 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.DeviceLog; import com.fuyuanshen.equipment.domain.vo.DeviceAlarmVo; @@ -101,15 +103,16 @@ public class WEBDeviceController extends BaseController { */ @Operation(summary = "设备告警记录") @GetMapping(value = "/getAlarmRecord/{deviceId}") - public R> getAlarmRecord(@PathVariable Long deviceId, - @RequestParam(required = false) String startTime, - @RequestParam(required = false) String endTime) { - List device = deviceService.getAlarmRecord(deviceId, startTime, endTime); - return R.ok(device); + public TableDataInfo getAlarmRecord(@PathVariable Long deviceId, + @RequestParam(required = false) String startTime, + @RequestParam(required = false) String endTime, + PageQuery pageQuery) { + return deviceService.getAlarmRecord(deviceId, startTime, endTime, pageQuery); } + } diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/WEBDeviceService.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/WEBDeviceService.java index f83658c6..e891de0f 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/WEBDeviceService.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/WEBDeviceService.java @@ -68,6 +68,6 @@ public interface WEBDeviceService extends IService { * @param endTime 结束时间 * @return */ - List getAlarmRecord(Long deviceId, String startTime, String endTime); + TableDataInfo getAlarmRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery); } diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java index b6ec1f15..ea7199a1 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java @@ -4,14 +4,17 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; 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.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.common.mybatis.core.page.PageQuery; +import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; import com.fuyuanshen.equipment.domain.Device; import com.fuyuanshen.equipment.domain.DeviceAlarm; import com.fuyuanshen.equipment.domain.DeviceAssignments; @@ -24,7 +27,6 @@ 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; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -154,22 +156,23 @@ public class WEBDeviceServiceImpl extends ServiceImpl impl * @return */ @Override - public List getAlarmRecord(Long deviceId, String startTime, String endTime) { + public TableDataInfo getAlarmRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery) { + Page page = pageQuery.build(); QueryWrapper queryWrapper = new QueryWrapper().eq("device_id", deviceId); if (StrUtil.isNotEmpty(startTime)) { - queryWrapper.ge("create_time", startTime); + queryWrapper.ge("start_time", startTime); } - if (StrUtil.isNotEmpty(endTime)) { - queryWrapper.le("create_time", endTime); + queryWrapper.le("start_time", endTime); } + queryWrapper.orderByDesc("start_time"); + IPage alarmPage = deviceAlarmMapper.selectPage(page, queryWrapper); - List alarmList = deviceAlarmMapper.selectList( - queryWrapper.orderByDesc("create_time")); - List deviceAlarmVoList = BeanUtil.copyToList(alarmList, DeviceAlarmVo.class); - return deviceAlarmVoList; + // List deviceAlarmVoList = BeanUtil.copyToList(alarmPage.getRecords(), DeviceAlarmVo.class); + return TableDataInfo.build(alarmPage); } - } + + diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/DeviceAlarm.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/DeviceAlarm.java index 65b4e88c..720ee9bc 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/DeviceAlarm.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/DeviceAlarm.java @@ -4,7 +4,9 @@ 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; @@ -63,7 +65,6 @@ public class DeviceAlarm extends TenantEntity { /** * 经度 - */ private Long longitude; @@ -90,7 +91,7 @@ public class DeviceAlarm extends TenantEntity { /** * 报警持续时间 */ - private Long durationTime; + private String durationTime; /** * 0已处理,1未处理 From f7a82ef13800c3d9ca6a511fdf78a88dc2907d45 Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Tue, 9 Sep 2025 09:55:58 +0800 Subject: [PATCH 13/18] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=20=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/DeviceChargeDischargeController.java | 14 ++++++++------ .../web/controller/device/WEBDeviceController.java | 11 +++++------ .../fuyuanshen/web/service/WEBDeviceService.java | 2 +- .../web/service/impl/WEBDeviceServiceImpl.java | 11 +++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceChargeDischargeController.java b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceChargeDischargeController.java index c8cc77c4..c43890fd 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceChargeDischargeController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceChargeDischargeController.java @@ -39,7 +39,7 @@ public class DeviceChargeDischargeController extends BaseController { /** * 查询设备充放电记录列表 */ - @SaCheckPermission("equipment:chargeDischarge:list") + // @SaCheckPermission("equipment:chargeDischarge:list") @GetMapping("/list") public TableDataInfo list(DeviceChargeDischargeBo bo, PageQuery pageQuery) { return deviceChargeDischargeService.queryPageList(bo, pageQuery); @@ -48,7 +48,7 @@ public class DeviceChargeDischargeController extends BaseController { /** * 设备充放电记录列表 */ - @SaCheckPermission("equipment:chargeDischarge:export") + // @SaCheckPermission("equipment:chargeDischarge:export") @Log(title = "设备充放电记录", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(DeviceChargeDischargeBo bo, HttpServletResponse response) { @@ -61,7 +61,7 @@ public class DeviceChargeDischargeController extends BaseController { * * @param id 主键 */ - @SaCheckPermission("equipment:chargeDischarge:query") + // @SaCheckPermission("equipment:chargeDischarge:query") @GetMapping("/{id}") public R getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) { @@ -71,7 +71,7 @@ public class DeviceChargeDischargeController extends BaseController { /** * 新增设备充放电记录 */ - @SaCheckPermission("equipment:chargeDischarge:add") + // @SaCheckPermission("equipment:chargeDischarge:add") @Log(title = "设备充放电记录", businessType = BusinessType.INSERT) @RepeatSubmit() @PostMapping() @@ -82,7 +82,7 @@ public class DeviceChargeDischargeController extends BaseController { /** * 修改设备充放电记录 */ - @SaCheckPermission("equipment:chargeDischarge:edit") + // @SaCheckPermission("equipment:chargeDischarge:edit") @Log(title = "设备充放电记录", businessType = BusinessType.UPDATE) @RepeatSubmit() @PutMapping() @@ -95,11 +95,13 @@ public class DeviceChargeDischargeController extends BaseController { * * @param ids 主键串 */ - @SaCheckPermission("equipment:chargeDischarge:remove") + // @SaCheckPermission("equipment:chargeDischarge:remove") @Log(title = "设备充放电记录", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public R remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) { return toAjax(deviceChargeDischargeService.deleteWithValidByIds(List.of(ids), true)); } + + } diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java index e05e6b74..aa1fc9f4 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java @@ -85,11 +85,12 @@ public class WEBDeviceController extends BaseController { */ @Operation(summary = "设备操作记录") @GetMapping(value = "/getOperationRecord/{deviceId}") - public R> getOperationRecord(@PathVariable Long deviceId, + public TableDataInfo getOperationRecord(@PathVariable Long deviceId, @RequestParam(required = false) String startTime, - @RequestParam(required = false) String endTime) { - List device = deviceService.getOperationRecord(deviceId, startTime, endTime); - return R.ok(device); + @RequestParam(required = false) String endTime, + PageQuery pageQuery) { + TableDataInfo device = deviceService.getOperationRecord(deviceId, startTime, endTime,pageQuery); + return device; } @@ -111,8 +112,6 @@ public class WEBDeviceController extends BaseController { } - - } diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/WEBDeviceService.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/WEBDeviceService.java index e891de0f..121982ff 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/WEBDeviceService.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/WEBDeviceService.java @@ -57,7 +57,7 @@ public interface WEBDeviceService extends IService { * @param endTime 结束时间 * @return */ - List getOperationRecord(Long deviceId, String startTime, String endTime); + TableDataInfo getOperationRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery); /** diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java index ea7199a1..6e7d5a16 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java @@ -132,20 +132,19 @@ public class WEBDeviceServiceImpl extends ServiceImpl impl * @return */ @Override - public List getOperationRecord(Long deviceId, String startTime, String endTime) { + public TableDataInfo getOperationRecord(Long deviceId, String startTime, String endTime, PageQuery pageQuery) { + Page page = pageQuery.build(); QueryWrapper queryWrapper = new QueryWrapper().eq("device_id", deviceId); if (StrUtil.isNotEmpty(startTime)) { queryWrapper.ge("create_time", startTime); } - if (StrUtil.isNotEmpty(endTime)) { queryWrapper.le("create_time", endTime); } - - List logList = deviceLogMapper.selectList( - queryWrapper.orderByDesc("create_time")); - return logList; + queryWrapper.orderByDesc("create_time"); + IPage logList = deviceLogMapper.selectPage(page, queryWrapper); + return TableDataInfo.build(logList); } From 5e3307d2b04f0a5ee9ff7cec9678a49e6fd0589e Mon Sep 17 00:00:00 2001 From: chenyouting <514333061@qq.com> Date: Tue, 9 Sep 2025 10:29:51 +0800 Subject: [PATCH 14/18] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=88=86=E4=BA=AB2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AppDeviceShareController.java | 3 +- .../device/AppDeviceHBYController.java | 119 ++++++++ .../app/service/AppDeviceShareService.java | 262 ++++++++++++++++++ .../queue/MqttMessageQueueConstants.java | 6 +- .../device/DeviceShareController.java | 17 +- .../web/service/DeviceShareService.java | 24 +- .../mapper/app/AppDeviceShareMapper.xml | 2 +- 7 files changed, 418 insertions(+), 15 deletions(-) create mode 100644 fys-admin/src/main/java/com/fuyuanshen/app/controller/device/AppDeviceHBYController.java create mode 100644 fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceShareService.java diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppDeviceShareController.java b/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppDeviceShareController.java index 613bb7ea..388c84f7 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppDeviceShareController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/app/controller/AppDeviceShareController.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.RandomUtil; import com.fuyuanshen.app.domain.bo.AppDeviceShareBo; import com.fuyuanshen.app.domain.vo.AppDeviceShareDetailVo; import com.fuyuanshen.app.domain.vo.AppDeviceShareVo; +import com.fuyuanshen.app.service.AppDeviceShareService; import com.fuyuanshen.app.service.IAppDeviceShareService; import com.fuyuanshen.common.core.constant.Constants; import com.fuyuanshen.common.core.domain.R; @@ -45,7 +46,7 @@ public class AppDeviceShareController extends BaseController { private final IAppDeviceShareService deviceShareService; - private final DeviceShareService appDeviceShareService; + private final AppDeviceShareService appDeviceShareService; /** * 分享管理列表 diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/controller/device/AppDeviceHBYController.java b/fys-admin/src/main/java/com/fuyuanshen/app/controller/device/AppDeviceHBYController.java new file mode 100644 index 00000000..01883072 --- /dev/null +++ b/fys-admin/src/main/java/com/fuyuanshen/app/controller/device/AppDeviceHBYController.java @@ -0,0 +1,119 @@ +package com.fuyuanshen.app.controller.device; + +import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo; +import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto; +import com.fuyuanshen.app.domain.dto.DeviceInstructDto; +import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo; +import com.fuyuanshen.common.core.domain.R; +import com.fuyuanshen.common.core.validate.AddGroup; +import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation; +import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation; +import com.fuyuanshen.common.web.core.BaseController; +import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo; +import com.fuyuanshen.web.service.device.DeviceBJQBizService; +import jakarta.validation.constraints.NotNull; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +/** + * HBY210设备控制类 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/app/hby/device") +public class AppDeviceHBYController extends BaseController { + + private final DeviceBJQBizService appDeviceService; + + /** + * 获取设备详细信息 + * + * @param id 主键 + */ + @GetMapping("/{id}") + public R getInfo(@NotNull(message = "主键不能为空") + @PathVariable Long id) { + return R.ok(appDeviceService.getInfo(id)); + } + + /** + * 人员信息登记 + */ + @PostMapping(value = "/registerPersonInfo") +// @FunctionAccessAnnotation("registerPersonInfo") + public R registerPersonInfo(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoBo bo) { + return toAjax(appDeviceService.registerPersonInfo(bo)); + } + + /** + * 发送信息 + */ + @PostMapping(value = "/sendMessage") + @FunctionAccessBatcAnnotation(value = "sendMessage", timeOut = 30, batchMaxTimeOut = 40) + public R sendMessage(@RequestBody AppDeviceSendMsgBo bo) { + return toAjax(appDeviceService.sendMessage(bo)); + } + + /** + * 发送报警信息 + */ + @PostMapping(value = "/sendAlarmMessage") + @FunctionAccessBatcAnnotation(value = "sendAlarmMessage", timeOut = 5, batchMaxTimeOut = 10) + public R sendAlarmMessage(@RequestBody AppDeviceSendMsgBo bo) { + return toAjax(appDeviceService.sendAlarmMessage(bo)); + } + + /** + * 上传设备logo图片 + */ + @PostMapping("/uploadLogo") + @FunctionAccessAnnotation("uploadLogo") + public R upload(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) { + + MultipartFile file = bo.getFile(); + if(file.getSize()>1024*1024*2){ + return R.warn("图片不能大于2M"); + } + appDeviceService.uploadDeviceLogo(bo); + + return R.ok(); + } + + /** + * 灯光模式 + * 0(关灯),1(强光模式),2(弱光模式), 3(爆闪模式), 4(泛光模式) + */ +// @FunctionAccessAnnotation("lightModeSettings") + @PostMapping("/lightModeSettings") + public R lightModeSettings(@RequestBody DeviceInstructDto params) { + // params 转 JSONObject + appDeviceService.lightModeSettings(params); + return R.ok(); + } + + /** + * 灯光亮度设置 + * + */ +// @FunctionAccessAnnotation("lightBrightnessSettings") + @PostMapping("/lightBrightnessSettings") + public R lightBrightnessSettings(@RequestBody DeviceInstructDto params) { + appDeviceService.lightBrightnessSettings(params); + return R.ok(); + } + + /** + * 激光模式设置 + * + */ + @PostMapping("/laserModeSettings") +// @FunctionAccessAnnotation("laserModeSettings") + public R laserModeSettings(@RequestBody DeviceInstructDto params) { + appDeviceService.laserModeSettings(params); + return R.ok(); + } + +} diff --git a/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceShareService.java b/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceShareService.java new file mode 100644 index 00000000..44d1ba42 --- /dev/null +++ b/fys-admin/src/main/java/com/fuyuanshen/app/service/AppDeviceShareService.java @@ -0,0 +1,262 @@ +package com.fuyuanshen.app.service; + +import com.alibaba.fastjson2.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +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.app.domain.AppDeviceShare; +import com.fuyuanshen.app.domain.AppPersonnelInfo; +import com.fuyuanshen.app.domain.bo.AppDeviceShareBo; +import com.fuyuanshen.app.domain.vo.AppDeviceShareDetailVo; +import com.fuyuanshen.app.domain.vo.AppDeviceShareVo; +import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo; +import com.fuyuanshen.app.mapper.AppDeviceShareMapper; +import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper; +import com.fuyuanshen.common.core.constant.GlobalConstants; +import com.fuyuanshen.common.core.exception.ServiceException; +import com.fuyuanshen.common.core.utils.StringUtils; +import com.fuyuanshen.common.mybatis.core.page.PageQuery; +import com.fuyuanshen.common.mybatis.core.page.TableDataInfo; +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.DeviceType; +import com.fuyuanshen.equipment.mapper.DeviceMapper; +import com.fuyuanshen.equipment.mapper.DeviceTypeMapper; +import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY; +import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.*; + + +@RequiredArgsConstructor +@Slf4j +@Service +public class AppDeviceShareService { + + private final AppDeviceShareMapper appDeviceShareMapper; + + private final DeviceMapper deviceMapper; + + private final DeviceTypeMapper deviceTypeMapper; + + private final AppPersonnelInfoMapper appPersonnelInfoMapper; + + public TableDataInfo queryPageList(AppDeviceShareBo bo, PageQuery pageQuery) { + Long userId = AppLoginHelper.getUserId(); + bo.setCreateBy(userId); + Page page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize()); + Page result = appDeviceShareMapper.selectAppDeviceShareList(bo, page); + List records = result.getRecords(); + records.forEach(AppDeviceShareService::buildDeviceStatus); + return TableDataInfo.build(result); + } + + public TableDataInfo queryWebPageList(AppDeviceShareBo bo, PageQuery pageQuery) { +// Long userId = AppLoginHelper.getUserId(); +// bo.setCreateBy(userId); + Page page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize()); + Page result = appDeviceShareMapper.selectWebDeviceShareList(bo, page); + List records = result.getRecords(); + records.forEach(AppDeviceShareService::buildDeviceStatus); + return TableDataInfo.build(result); + } + + 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)) { + + item.setOnlineStatus(1); + } else { + item.setOnlineStatus(0); + } + String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + item.getDeviceImei() + DEVICE_STATUS_KEY_PREFIX); + // 获取电量 + if (StringUtils.isNotBlank(deviceStatus)) { + JSONObject jsonObject = JSONObject.parseObject(deviceStatus); + item.setBattery(jsonObject.getString("batteryPercentage")); + } else { + item.setBattery("0"); + } + + 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)) { + item.setAlarmStatus(alarmStatus); + } + } + + public AppDeviceShareDetailVo getInfo(Long id) { + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(AppDeviceShare::getId, id); + List appDeviceShareVos = appDeviceShareMapper.selectVoList(queryWrapper); + if (appDeviceShareVos == null || appDeviceShareVos.isEmpty()) { + return null; + } + + AppDeviceShareVo shareVo = appDeviceShareVos.get(0); + AppDeviceShareDetailVo shareDetailVo = new AppDeviceShareDetailVo(); + shareDetailVo.setId(shareVo.getId()); + shareDetailVo.setDeviceId(shareVo.getDeviceId()); + shareDetailVo.setPhonenumber(shareVo.getPhonenumber()); + shareDetailVo.setPermission(shareVo.getPermission()); + + Device device = deviceMapper.selectById(shareVo.getDeviceId()); + shareDetailVo.setDeviceName(device.getDeviceName()); + shareDetailVo.setDeviceImei(device.getDeviceImei()); + shareDetailVo.setDeviceMac(device.getDeviceMac()); + + DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType()); + if (deviceType != null) { + shareDetailVo.setCommunicationMode(Integer.valueOf(deviceType.getCommunicationMode())); + } + shareDetailVo.setDevicePic(device.getDevicePic()); + shareDetailVo.setTypeName(deviceType.getTypeName()); + shareDetailVo.setBluetoothName(device.getBluetoothName()); + shareDetailVo.setDeviceStatus(device.getDeviceStatus()); + shareDetailVo.setSendMsg(device.getSendMsg()); + + LambdaQueryWrapper qw = new LambdaQueryWrapper<>(); + qw.eq(AppPersonnelInfo::getDeviceId, device.getId()); + List appPersonnelInfoVos = appPersonnelInfoMapper.selectVoList(qw); + 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)) { + shareDetailVo.setOnlineStatus(1); + } else { + shareDetailVo.setOnlineStatus(0); + } + String deviceStatus = RedisUtils.getCacheObject(GLOBAL_REDIS_KEY + DEVICE_KEY_PREFIX + device.getDeviceImei() + DeviceRedisKeyConstants.DEVICE_STATUS_KEY_PREFIX); + // 获取电量 + 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 { + shareDetailVo.setBatteryPercentage("0"); + } + + // 获取经度纬度 + 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)) { + JSONObject jsonObject = JSONObject.parseObject(locationInfo); + shareDetailVo.setLongitude(jsonObject.get("longitude").toString()); + shareDetailVo.setLatitude(jsonObject.get("latitude").toString()); + 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)) { + shareDetailVo.setAlarmStatus(alarmStatus); + } + + 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; + } + + /** + * 校验短信验证码 + */ + private boolean validateSmsCode(String tenantId, String phonenumber, String smsCode) { + String code = RedisUtils.getCacheObject(GlobalConstants.DEVICE_SHARE_CODES_KEY + phonenumber); + if (StringUtils.isBlank(code)) { + throw new ServiceException("验证码失效"); + } + return code.equals(smsCode); + } + + public int deviceShare(AppDeviceShareBo bo) { + boolean flag = validateSmsCode(AppLoginHelper.getTenantId(), bo.getPhonenumber(), bo.getSmsCode()); + if (!flag) { + throw new ServiceException("验证码错误"); + } + + Device device = deviceMapper.selectById(bo.getDeviceId()); + if (device == null) { + throw new ServiceException("设备不存在"); + } + Long userId = AppLoginHelper.getUserId(); + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId()); + lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber()); + Long count = appDeviceShareMapper.selectCount(lqw); + if (count > 0) { + + UpdateWrapper uw = new UpdateWrapper<>(); + uw.eq("device_id", bo.getDeviceId()); + uw.eq("phonenumber", bo.getPhonenumber()); + uw.set("permission", bo.getPermission()); + uw.set("update_by", userId); + uw.set("update_time", new Date()); + + return appDeviceShareMapper.update(uw); + } else { + AppDeviceShare appDeviceShare = new AppDeviceShare(); + appDeviceShare.setDeviceId(bo.getDeviceId()); + appDeviceShare.setPhonenumber(bo.getPhonenumber()); + appDeviceShare.setPermission(bo.getPermission()); + appDeviceShare.setCreateBy(userId); + return appDeviceShareMapper.insert(appDeviceShare); + } + } + + public int remove(Long[] ids) { + return appDeviceShareMapper.deleteByIds(Arrays.asList(ids)); + } + + public TableDataInfo otherDeviceShareList(AppDeviceShareBo bo, PageQuery pageQuery) { + String username = AppLoginHelper.getUsername(); + bo.setPhonenumber(username); + Page page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize()); + IPage result = appDeviceShareMapper.otherDeviceShareList(bo, page); + List records = result.getRecords(); + + records.forEach(AppDeviceShareService::buildDeviceStatus); + return TableDataInfo.build(result); + } + + + /** + * 查询设备分享列表(web) + * + * @param bo + * @param pageQuery + * @return + */ + public TableDataInfo queryWebList(AppDeviceShareBo bo, PageQuery pageQuery) { + Page page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize()); + Page result = appDeviceShareMapper.selectWebDeviceShareList(bo, page); + List records = result.getRecords(); + records.forEach(AppDeviceShareService::buildDeviceStatus); + return TableDataInfo.build(result); + } + +} diff --git a/fys-admin/src/main/java/com/fuyuanshen/global/queue/MqttMessageQueueConstants.java b/fys-admin/src/main/java/com/fuyuanshen/global/queue/MqttMessageQueueConstants.java index b4eb34d2..392e06bc 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/global/queue/MqttMessageQueueConstants.java +++ b/fys-admin/src/main/java/com/fuyuanshen/global/queue/MqttMessageQueueConstants.java @@ -1,6 +1,8 @@ package com.fuyuanshen.global.queue; +import com.fuyuanshen.common.core.constant.GlobalConstants; + 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"; + public static final String MQTT_MESSAGE_QUEUE_KEY = GlobalConstants.GLOBAL_REDIS_KEY + "mqtt:message:queue"; + public static final String MQTT_MESSAGE_DEDUP_KEY = GlobalConstants.GLOBAL_REDIS_KEY + "mqtt:message:dedup"; } diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java index 5f214e60..ce2cc2be 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceShareController.java @@ -40,7 +40,7 @@ import static com.fuyuanshen.common.core.constant.GlobalConstants.DEVICE_SHARE_C @RequestMapping("api/equipment/share") public class DeviceShareController extends BaseController { - private final DeviceShareService appDeviceShareService; + private final DeviceShareService deviceShareService; /** @@ -48,7 +48,7 @@ public class DeviceShareController extends BaseController { */ @GetMapping("/deviceShareList") public TableDataInfo list(AppDeviceShareBo bo, PageQuery pageQuery) { - return appDeviceShareService.queryWebPageList(bo, pageQuery); + return deviceShareService.queryWebPageList(bo, pageQuery); } @@ -58,7 +58,16 @@ public class DeviceShareController extends BaseController { @RepeatSubmit() @PostMapping("/deviceShare") public R deviceShare(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) { - return toAjax(appDeviceShareService.deviceShare(bo)); + return toAjax(deviceShareService.deviceShare(bo)); + } + + /** + * 权限管理 + */ + @RepeatSubmit() + @PostMapping("/permission") + public R permission(@Validated(AddGroup.class) @RequestBody AppDeviceShareBo bo) { + return toAjax(deviceShareService.deviceShare(bo)); } /** @@ -69,7 +78,7 @@ public class DeviceShareController extends BaseController { @DeleteMapping("/{ids}") public R remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) { - return toAjax(appDeviceShareService.remove(ids)); + return toAjax(deviceShareService.remove(ids)); } /** diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/DeviceShareService.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/DeviceShareService.java index 9983fc8f..42204bb7 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/DeviceShareService.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/DeviceShareService.java @@ -2,15 +2,18 @@ package com.fuyuanshen.web.service; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +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.app.domain.AppDeviceBindRecord; import com.fuyuanshen.app.domain.AppDeviceShare; import com.fuyuanshen.app.domain.AppPersonnelInfo; import com.fuyuanshen.app.domain.bo.AppDeviceShareBo; import com.fuyuanshen.app.domain.vo.AppDeviceShareDetailVo; import com.fuyuanshen.app.domain.vo.AppDeviceShareVo; import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo; +import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper; import com.fuyuanshen.app.mapper.AppDeviceShareMapper; import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper; import com.fuyuanshen.common.core.constant.GlobalConstants; @@ -50,6 +53,8 @@ public class DeviceShareService { private final AppPersonnelInfoMapper appPersonnelInfoMapper; + private final AppDeviceBindRecordMapper appDeviceBindRecordMapper; + public TableDataInfo queryPageList(AppDeviceShareBo bo, PageQuery pageQuery) { Long userId = AppLoginHelper.getUserId(); bo.setCreateBy(userId); @@ -185,7 +190,7 @@ public class DeviceShareService { /** * 校验短信验证码 */ - private boolean validateSmsCode(String tenantId, String phonenumber, String smsCode) { + private boolean validateSmsCode(String phonenumber, String smsCode) { String code = RedisUtils.getCacheObject(GlobalConstants.DEVICE_SHARE_CODES_KEY + phonenumber); if (StringUtils.isBlank(code)) { throw new ServiceException("验证码失效"); @@ -194,16 +199,21 @@ public class DeviceShareService { } public int deviceShare(AppDeviceShareBo bo) { - boolean flag = validateSmsCode(AppLoginHelper.getTenantId(), bo.getPhonenumber(), bo.getSmsCode()); - if (!flag) { - throw new ServiceException("验证码错误"); - } - Device device = deviceMapper.selectById(bo.getDeviceId()); if (device == null) { throw new ServiceException("设备不存在"); } - Long userId = AppLoginHelper.getUserId(); + + boolean flag = validateSmsCode( bo.getPhonenumber(), bo.getSmsCode()); + if (!flag) { + throw new ServiceException("验证码错误"); + } + + LambdaQueryWrapper qw = new LambdaQueryWrapper<>(); + qw.eq(AppDeviceBindRecord::getDeviceId, bo.getDeviceId()); + AppDeviceBindRecord bindRecord = appDeviceBindRecordMapper.selectOne(qw); + Long userId = bindRecord.getBindingUserId(); + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); lqw.eq(AppDeviceShare::getDeviceId, bo.getDeviceId()); lqw.eq(AppDeviceShare::getPhonenumber, bo.getPhonenumber()); diff --git a/fys-modules/fys-app/src/main/resources/mapper/app/AppDeviceShareMapper.xml b/fys-modules/fys-app/src/main/resources/mapper/app/AppDeviceShareMapper.xml index 9208f90a..8b77aecb 100644 --- a/fys-modules/fys-app/src/main/resources/mapper/app/AppDeviceShareMapper.xml +++ b/fys-modules/fys-app/src/main/resources/mapper/app/AppDeviceShareMapper.xml @@ -74,7 +74,7 @@ and u.user_name = #{bo.shareUser} - + and ad.create_time between #{bo.shareStartTime} and #{bo.shareEndTime} From ebd86681781345b83d3c74f3daebc0c47a83080f Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Tue, 9 Sep 2025 11:03:38 +0800 Subject: [PATCH 15/18] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/vo/EquipmentClassificationVo.java | 20 +++++++++++++++++++ .../service/impl/DeviceServiceImpl.java | 1 + .../mapper/equipment/DeviceMapper.xml | 4 ++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/EquipmentClassificationVo.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/EquipmentClassificationVo.java index d84f59ad..2ebecdc1 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/EquipmentClassificationVo.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/domain/vo/EquipmentClassificationVo.java @@ -26,4 +26,24 @@ public class EquipmentClassificationVo { */ private Integer devices4GAndBluetooth = 0; + /** + * 设备总数 + */ + private Integer total; + + + /** + * 计算设备总数 + * + * @return 设备总数 + */ + public Integer getTotal() { + if (total == null) { + total = (equipment4G == null ? 0 : equipment4G) + + (deviceBluetooth == null ? 0 : deviceBluetooth) + + (devices4GAndBluetooth == null ? 0 : devices4GAndBluetooth); + } + return total; + } + } diff --git a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java index 967bc391..f356e414 100644 --- a/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java +++ b/fys-modules/fys-equipment/src/main/java/com/fuyuanshen/equipment/service/impl/DeviceServiceImpl.java @@ -630,6 +630,7 @@ public class DeviceServiceImpl extends ServiceImpl impleme @Override public EquipmentClassificationVo getEquipmentClassification() { EquipmentClassificationVo equipmentClassification = deviceMapper.getEquipmentClassification(); + equipmentClassification.getTotal(); return equipmentClassification; } diff --git a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml index 81c66744..0ce9fc67 100644 --- a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml +++ b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml @@ -321,11 +321,11 @@ From 7e87971c0b5ed51a76ce47a4df06b4945e7f3702 Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Tue, 9 Sep 2025 15:02:46 +0800 Subject: [PATCH 16/18] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/equipment/DeviceMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml index 0ce9fc67..d1ebc0ea 100644 --- a/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml +++ b/fys-modules/fys-equipment/src/main/resources/mapper/equipment/DeviceMapper.xml @@ -322,7 +322,7 @@ - SELECT COUNT(CASE WHEN MONTH (dl.create_time) = 1 THEN 1 END) AS m1, - COUNT(CASE WHEN MONTH (dl.create_time) = 2 THEN 1 END) AS m2, - COUNT(CASE WHEN MONTH (dl.create_time) = 3 THEN 1 END) AS m3, - COUNT(CASE WHEN MONTH (dl.create_time) = 4 THEN 1 END) AS m4, - COUNT(CASE WHEN MONTH (dl.create_time) = 5 THEN 1 END) AS m5, - COUNT(CASE WHEN MONTH (dl.create_time) = 6 THEN 1 END) AS m6, - COUNT(CASE WHEN MONTH (dl.create_time) = 7 THEN 1 END) AS m7, - COUNT(CASE WHEN MONTH (dl.create_time) = 8 THEN 1 END) AS m8, - COUNT(CASE WHEN MONTH (dl.create_time) = 9 THEN 1 END) AS m9, - COUNT(CASE WHEN MONTH (dl.create_time) = 10 THEN 1 END) AS m10, - COUNT(CASE WHEN MONTH (dl.create_time) = 11 THEN 1 END) AS m11, - COUNT(CASE WHEN MONTH (dl.create_time) = 12 THEN 1 END) AS m12 + SELECT COUNT(CASE WHEN MONTH (dl.create_time) = 1 THEN 1 END) AS m1, + COUNT(CASE WHEN MONTH (dl.create_time) = 2 THEN 1 END) AS m2, + COUNT(CASE WHEN MONTH (dl.create_time) = 3 THEN 1 END) AS m3, + COUNT(CASE WHEN MONTH (dl.create_time) = 4 THEN 1 END) AS m4, + COUNT(CASE WHEN MONTH (dl.create_time) = 5 THEN 1 END) AS m5, + COUNT(CASE WHEN MONTH (dl.create_time) = 6 THEN 1 END) AS m6, + COUNT(CASE WHEN MONTH (dl.create_time) = 7 THEN 1 END) AS m7, + COUNT(CASE WHEN MONTH (dl.create_time) = 8 THEN 1 END) AS m8, + COUNT(CASE WHEN MONTH (dl.create_time) = 9 THEN 1 END) AS m9, + COUNT(CASE WHEN MONTH (dl.create_time) = 10 THEN 1 END) AS m10, + COUNT(CASE WHEN MONTH (dl.create_time) = 11 THEN 1 END) AS m11, + COUNT(CASE WHEN MONTH (dl.create_time) = 12 THEN 1 END) AS m12 FROM device_log dl - LEFT JOIN device d ON dl.device_id = d.id - LEFT JOIN device_type dt ON d.device_type = dt.id - WHERE dt.id = #{deviceId} - AND ( + LEFT JOIN device d ON dl.device_id = d.id + LEFT JOIN device_type dt ON d.device_type = dt.id + + + dt.id = #{deviceTypeId} + + AND ( (#{range} = 1 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH)) OR (#{range} = 2 AND dl.create_time >= DATE_SUB(NOW(), INTERVAL 12 MONTH)) ) + - SELECT (SELECT COUNT(1) FROM device_alarm WHERE treatment_state = 0 AND DATE (create_time) = CURDATE()) AS alarmsTotal, ( + SELECT (SELECT COUNT(1) FROM device_alarm WHERE treatment_state = 0) AS alarmsTotal + , (SELECT COUNT(1) + FROM device_alarm + WHERE treatment_state = 0) AS processingAlarm + , (SELECT COUNT(1) + FROM device_alarm + WHERE treatment_state = 0 AND + DATE (create_time) = CURDATE()) AS alarmsTotalToday + , ( SELECT COUNT (1) FROM device_alarm WHERE treatment_state = 0 - AND DATE (create_time) = CURDATE()) AS processingAlarm + AND DATE (create_time) = CURDATE()) AS processingAlarmToday , ( SELECT COUNT (1) FROM device_alarm WHERE device_action = 0 - AND DATE (create_time) = CURDATE()) AS alarmForced + ) AS alarmForced , ( SELECT COUNT (1) FROM device_alarm WHERE device_action = 1 - AND DATE (create_time) = CURDATE()) AS intrusionImpact + ) AS intrusionImpact , ( SELECT COUNT (1) FROM device_alarm WHERE device_action = 2 - AND DATE (create_time) = CURDATE()) AS alarmManual + ) AS alarmManual , ( SELECT COUNT (1) FROM device_alarm - WHERE device_action = 3 AND DATE (create_time) = CURDATE()) AS fenceElectronic + WHERE device_action = 3) AS fenceElectronic