Procházet zdrojové kódy

设备表新增address字段,修改设备名字段错误。

skyline před 1 měsícem
rodič
revize
fd82c181a0

+ 6 - 6
haha-admin-web/src/views/device/utils/hook.tsx

@@ -29,7 +29,7 @@ export function useDevice(tableRef: Ref) {
     deviceId: "",
     shopId: "",
     status: "",
-    storeName: ""
+    name: ""
   });
   const formRef = ref();
   const ruleFormRef = ref();
@@ -66,7 +66,7 @@ export function useDevice(tableRef: Ref) {
     },
     {
       label: "设备名称",
-      prop: "deviceName",
+      prop: "name",
       minWidth: 120
     },
     {
@@ -75,9 +75,9 @@ export function useDevice(tableRef: Ref) {
       minWidth: 120
     },
     {
-      label: "货柜名称",
-      prop: "storeName",
-      minWidth: 100
+      label: "设备地址",
+      prop: "address",
+      minWidth: 150
     },
     {
       label: "温度(℃)",
@@ -137,7 +137,7 @@ export function useDevice(tableRef: Ref) {
       if (form.deviceId) searchParams.deviceId = form.deviceId;
       if (form.shopId) searchParams.shopId = form.shopId;
       if (form.status) searchParams.status = form.status;
-      if (form.storeName) searchParams.storeName = form.storeName;
+      if (form.name) searchParams.name = form.name;
       
       const { data } = await getDeviceList(searchParams);
       dataList.value = data.list;

+ 2 - 1
haha-admin-web/src/views/device/utils/types.ts

@@ -6,6 +6,7 @@ export interface DeviceItem {
   shopId: number;
   shopName: string;
   storeName: string;
+  address: string;
   status: number;
   temperature: number;
   volume: number;
@@ -19,5 +20,5 @@ export interface DeviceSearchForm {
   deviceId: string;
   shopId: number | string;
   status: number | string;
-  storeName: string;
+  name: string;
 }

+ 5 - 2
haha-entity/src/main/java/com/haha/entity/Device.java

@@ -34,6 +34,11 @@ public class Device implements Serializable {
      */
     private String doorStatus;
 
+    /**
+     * 设备地址(同步自哈哈平台)
+     */
+    private String address;
+
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
     private LocalDateTime createTime;
 
@@ -45,8 +50,6 @@ public class Device implements Serializable {
     @TableField(exist = false)
     private String shopName;
 
-    @TableField(exist = false)
-    private String address;
 
     @TableField(exist = false)
     private String deviceTypeLabel;

+ 2 - 2
haha-service/src/main/java/com/haha/service/impl/DataSyncServiceImpl.java

@@ -144,8 +144,8 @@ public class DataSyncServiceImpl extends ServiceImpl<SyncRecordMapper, SyncRecor
         if (existDevice != null) {
             // 更新设备信息
             existDevice.setName(deviceInfo.getName());
+            existDevice.setAddress(deviceInfo.getAddress());
             existDevice.setStatus("1".equals(deviceInfo.getStatus()) ? 1 : 0);
-            // existDevice.setAddress(deviceInfo.getAddress()); // Device实体暂无address字段
             deviceService.updateById(existDevice);
 
             // 记录成功日志
@@ -156,7 +156,7 @@ public class DataSyncServiceImpl extends ServiceImpl<SyncRecordMapper, SyncRecor
             Device newDevice = new Device();
             newDevice.setDeviceId(deviceInfo.getId());
             newDevice.setName(deviceInfo.getName());
-            // newDevice.setAddress(deviceInfo.getAddress()); // Device实体暂无address字段
+            newDevice.setAddress(deviceInfo.getAddress());
             newDevice.setStatus("1".equals(deviceInfo.getStatus()) ? 1 : 0);
             deviceService.save(newDevice);
 

+ 6 - 3
haha-service/src/main/java/com/haha/service/impl/DeviceServiceImpl.java

@@ -363,11 +363,14 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
         }
         
         // 填充门店信息
-        if (device.getShopId() != null && device.getShopName() == null) {
+        if (device.getShopId() != null) {
             Shop shop = shopMapper.selectById(device.getShopId());
             if (shop != null) {
-                device.setShopName(shop.getName());
-                if (device.getAddress() == null) {
+                if (device.getShopName() == null) {
+                    device.setShopName(shop.getName());
+                }
+                // 设备自身没有地址时,回退到关联门店的地址
+                if (device.getAddress() == null && shop.getAddress() != null) {
                     device.setAddress(shop.getAddress());
                 }
             }