From b3245b2608e7f4dadc24e26ecf43107dae1c33ee Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: Sat, 22 Mar 2025 11:44:00 +0800
Subject: [PATCH] 优化

---
 ard-work/src/main/java/com/ard/tianyu/service/impl/UavBoxServiceImpl.java |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/ard-work/src/main/java/com/ard/tianyu/service/impl/UavBoxServiceImpl.java b/ard-work/src/main/java/com/ard/tianyu/service/impl/UavBoxServiceImpl.java
index 5f36607..bc73c5a 100644
--- a/ard-work/src/main/java/com/ard/tianyu/service/impl/UavBoxServiceImpl.java
+++ b/ard-work/src/main/java/com/ard/tianyu/service/impl/UavBoxServiceImpl.java
@@ -1,7 +1,7 @@
 package com.ard.tianyu.service.impl;
 
 import com.ard.common.utils.DateUtils;
-import com.ard.tianyu.domain.UavBox;
+import com.ard.tianyu.domain.entity.UavBoxEntity;
 import com.ard.tianyu.domain.receiver.BoxInfoReceiver;
 import com.ard.tianyu.mapper.UavBoxMapper;
 import com.ard.tianyu.service.ITyService;
@@ -36,43 +36,43 @@
      * @return 无人机盒子
      */
     @Override
-    public UavBox selectUavBoxById(Long id) {
+    public UavBoxEntity selectUavBoxById(Long id) {
         return uavBoxMapper.selectUavBoxById(id);
     }
 
     /**
      * 查询无人机盒子列表
      *
-     * @param uavBox 无人机盒子
+     * @param uavBoxEntity 无人机盒子
      * @return 无人机盒子
      */
     @Override
-    public List<UavBox> selectUavBoxList(UavBox uavBox) {
-        return uavBoxMapper.selectUavBoxList(uavBox);
+    public List<UavBoxEntity> selectUavBoxList(UavBoxEntity uavBoxEntity) {
+        return uavBoxMapper.selectUavBoxList(uavBoxEntity);
     }
 
     /**
      * 新增无人机盒子
      *
-     * @param uavBox 无人机盒子
+     * @param uavBoxEntity 无人机盒子
      * @return 结果
      */
     @Override
-    public int insertUavBox(UavBox uavBox) {
-        uavBox.setCreateTime(DateUtils.getNowDate());
-        return uavBoxMapper.insertUavBox(uavBox);
+    public int insertUavBox(UavBoxEntity uavBoxEntity) {
+        uavBoxEntity.setCreateTime(DateUtils.getNowDate());
+        return uavBoxMapper.insertUavBox(uavBoxEntity);
     }
 
     /**
      * 修改无人机盒子
      *
-     * @param uavBox 无人机盒子
+     * @param uavBoxEntity 无人机盒子
      * @return 结果
      */
     @Override
-    public int updateUavBox(UavBox uavBox) {
-        uavBox.setUpdateTime(DateUtils.getNowDate());
-        return uavBoxMapper.updateUavBox(uavBox);
+    public int updateUavBox(UavBoxEntity uavBoxEntity) {
+        uavBoxEntity.setUpdateTime(DateUtils.getNowDate());
+        return uavBoxMapper.updateUavBox(uavBoxEntity);
     }
 
     /**
@@ -104,25 +104,25 @@
      */
     @Scheduled(fixedRate = 1000 * 60)
     public void syncBoxInfo() {
-        List<UavBox> uavBoxeList = selectUavBoxList(new UavBox());
+        List<UavBoxEntity> uavBoxeListEntity = selectUavBoxList(new UavBoxEntity());
         // 将本地列表转换为Map,方便快速查找
-        Map<String, UavBox> localUavBoxMap = uavBoxeList.stream()
-                .collect(Collectors.toMap(UavBox::getBoxSn, drone -> drone));
+        Map<String, UavBoxEntity> localUavBoxMap = uavBoxeListEntity.stream()
+                .collect(Collectors.toMap(UavBoxEntity::getBoxSn, drone -> drone));
         //遍历接口最新获取的无人机盒子信息
         tyService.getBoxList().forEach(remoteUavBox -> {
-            UavBox localUavBox = localUavBoxMap.get(remoteUavBox.getBoxSn());
-            if (localUavBox != null) {
-                if (!localUavBox.isSameAs(remoteUavBox)) {
+            UavBoxEntity localUavBoxEntity = localUavBoxMap.get(remoteUavBox.getBoxSn());
+            if (localUavBoxEntity != null) {
+                if (!localUavBoxEntity.isSameAs(remoteUavBox)) {
                     // 修改无人机(只更新变化的属性)
-                    updateChangedAttributes(localUavBox, remoteUavBox);
-                    updateUavBox(localUavBox);
+                    updateChangedAttributes(localUavBoxEntity, remoteUavBox);
+                    updateUavBox(localUavBoxEntity);
                 }
             }
         });
     }
 
     // 更新变化的属性
-    private void updateChangedAttributes(UavBox localBoxInfo, BoxInfoReceiver remoteUavBox) {
+    private void updateChangedAttributes(UavBoxEntity localBoxInfo, BoxInfoReceiver remoteUavBox) {
         if (!Objects.equals(localBoxInfo.getBoxName(), remoteUavBox.getBoxName())) {
             localBoxInfo.setBoxName(remoteUavBox.getBoxName());
         }

--
Gitblit v1.9.3