Browse Source

设备价格配置

skyline 7 months ago
parent
commit
42f8521174

+ 1 - 1
admin-web/src/views/admin/station/device/index.vue

@@ -141,7 +141,7 @@ const state = reactive({
         )
         )
       }
       }
     },
     },
-    {label: '平台费率', prop: 'feeRateName', width: 120, query: true, type: 'text', resizable: true, fixed: 'left'},
+    {label: '设备配置名', prop: 'deviceConfigName', width: 120, query: true, type: 'text', resizable: true, fixed: 'left'},
     // {label: '设备名称', prop: 'deviceName', width: 180, query: true, type: 'text', resizable: true, fixed: 'left'},
     // {label: '设备名称', prop: 'deviceName', width: 180, query: true, type: 'text', resizable: true, fixed: 'left'},
     // {label: '产品key', prop: 'productKey', width: 180, query: true, type: 'text', resizable: true},
     // {label: '产品key', prop: 'productKey', width: 180, query: true, type: 'text', resizable: true},
     {label: '状态', prop: 'state', width: 90, query: true, type: 'dict', conf: {dict: 'WashDevice.status'}, resizable: true},
     {label: '状态', prop: 'state', width: 90, query: true, type: 'dict', conf: {dict: 'WashDevice.status'}, resizable: true},

+ 0 - 5
car-wash-entity/src/main/java/com/kym/entity/DeviceConfig.java

@@ -20,11 +20,6 @@ public class DeviceConfig extends BaseEntity {
 
 
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 
 
-    /**
-     * 公司(租户)ID
-     */
-    private Long companyId;
-
     /**
     /**
      * 维护模式 0:未设置,1:已设置(屏幕显示设备维护界面)
      * 维护模式 0:未设置,1:已设置(屏幕显示设备维护界面)
      */
      */

+ 1 - 1
car-wash-entity/src/main/java/com/kym/entity/WashDevice.java

@@ -80,5 +80,5 @@ public class WashDevice extends BaseEntity {
     /**
     /**
      * 设备参数配置
      * 设备参数配置
      */
      */
-    private String deviceConfig;
+    private Long deviceConfigId;
 }
 }

+ 4 - 4
car-wash-entity/src/main/java/com/kym/entity/vo/WashDeviceVo.java

@@ -33,14 +33,14 @@ public class WashDeviceVo extends BaseEntity {
     private String stationName;
     private String stationName;
 
 
     /**
     /**
-     * 平台-费率配置id
+     * 设备配置ID
      */
      */
-    private Long feeRateId;
+    private Long deviceConfigId;
 
 
     /**
     /**
-     * 平台-费率配置名称
+     * 设备配置名称
      */
      */
-    private String feeRateName;
+    private String deviceConfigName;
 
 
     /**
     /**
      * 站点编号
      * 站点编号

+ 4 - 4
car-wash-service/src/main/java/com/kym/service/impl/DeviceConfigServiceImpl.java

@@ -3,20 +3,18 @@ package com.kym.service.impl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import com.kym.common.utils.CommUtil;
 import com.kym.common.utils.CommUtil;
 import com.kym.entity.DeviceConfig;
 import com.kym.entity.DeviceConfig;
-import com.kym.entity.PlatformFeeRate;
 import com.kym.entity.WashDevice;
 import com.kym.entity.WashDevice;
 import com.kym.entity.common.PageBean;
 import com.kym.entity.common.PageBean;
 import com.kym.entity.queryParams.DeviceConfigParams;
 import com.kym.entity.queryParams.DeviceConfigParams;
 import com.kym.entity.queryParams.DeviceConfigQueryParams;
 import com.kym.entity.queryParams.DeviceConfigQueryParams;
-import com.kym.entity.queryParams.PlatformFeeRateQueryParam;
 import com.kym.mapper.DeviceConfigMapper;
 import com.kym.mapper.DeviceConfigMapper;
 import com.kym.service.DeviceConfigService;
 import com.kym.service.DeviceConfigService;
 import com.kym.service.WashDeviceService;
 import com.kym.service.WashDeviceService;
 import com.kym.service.awoara.AwoaraService;
 import com.kym.service.awoara.AwoaraService;
 import com.kym.service.cache.KymCache;
 import com.kym.service.cache.KymCache;
 import com.kym.service.mybatisplus.MyBaseServiceImpl;
 import com.kym.service.mybatisplus.MyBaseServiceImpl;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -33,7 +31,7 @@ public class DeviceConfigServiceImpl extends MyBaseServiceImpl<DeviceConfigMappe
 
 
     private final WashDeviceService washDeviceService;
     private final WashDeviceService washDeviceService;
 
 
-    public DeviceConfigServiceImpl(AwoaraService awoaraService, WashDeviceService washDeviceService) {
+    public DeviceConfigServiceImpl(AwoaraService awoaraService, @Lazy WashDeviceService washDeviceService) {
         this.awoaraService = awoaraService;
         this.awoaraService = awoaraService;
         this.washDeviceService = washDeviceService;
         this.washDeviceService = washDeviceService;
     }
     }
@@ -57,6 +55,8 @@ public class DeviceConfigServiceImpl extends MyBaseServiceImpl<DeviceConfigMappe
         var deviceConfig = getById(params.getDeviceConfigId());
         var deviceConfig = getById(params.getDeviceConfigId());
         CommUtil.asserts(CommUtil.isNotEmptyAndNull(deviceConfig), "设备参数不存在");
         CommUtil.asserts(CommUtil.isNotEmptyAndNull(deviceConfig), "设备参数不存在");
         deviceList.forEach(device -> awoaraService.writeConfig(device.getProductKey(), device.getDeviceName(), deviceConfig));
         deviceList.forEach(device -> awoaraService.writeConfig(device.getProductKey(), device.getDeviceName(), deviceConfig));
+        // 更新设备对应的配置ID
+        washDeviceService.lambdaUpdate().set(WashDevice::getDeviceConfigId, params.getDeviceConfigId()).in(WashDevice::getId, params.getDeviceIds()).update();
     }
     }
 
 
     @Override
     @Override

+ 11 - 9
car-wash-service/src/main/java/com/kym/service/impl/WashDeviceServiceImpl.java

@@ -4,14 +4,14 @@ import cn.dev33.satoken.stp.StpUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import com.kym.common.exception.BusinessException;
 import com.kym.common.exception.BusinessException;
 import com.kym.common.utils.CommUtil;
 import com.kym.common.utils.CommUtil;
-import com.kym.entity.StationFeeRate;
+import com.kym.entity.DeviceConfig;
 import com.kym.entity.WashDevice;
 import com.kym.entity.WashDevice;
 import com.kym.entity.WashOrder;
 import com.kym.entity.WashOrder;
 import com.kym.entity.common.PageBean;
 import com.kym.entity.common.PageBean;
 import com.kym.entity.queryParams.DeviceQueryParams;
 import com.kym.entity.queryParams.DeviceQueryParams;
 import com.kym.entity.vo.WashDeviceVo;
 import com.kym.entity.vo.WashDeviceVo;
 import com.kym.mapper.WashDeviceMapper;
 import com.kym.mapper.WashDeviceMapper;
-import com.kym.service.StationFeeRateService;
+import com.kym.service.DeviceConfigService;
 import com.kym.service.WashDeviceService;
 import com.kym.service.WashDeviceService;
 import com.kym.service.WashOrderService;
 import com.kym.service.WashOrderService;
 import com.kym.service.cache.KymCache;
 import com.kym.service.cache.KymCache;
@@ -37,11 +37,12 @@ public class WashDeviceServiceImpl extends MyBaseServiceImpl<WashDeviceMapper, W
 
 
     private WashOrderService washOrderService;
     private WashOrderService washOrderService;
 
 
-    private StationFeeRateService stationFeeRateService;
 
 
-    public WashDeviceServiceImpl(WashOrderService washOrderService,StationFeeRateService stationFeeRateService) {
+    private DeviceConfigService deviceConfigService;
+
+    public WashDeviceServiceImpl(WashOrderService washOrderService, DeviceConfigService deviceConfigService) {
         this.washOrderService = washOrderService;
         this.washOrderService = washOrderService;
-        this.stationFeeRateService = stationFeeRateService;
+        this.deviceConfigService = deviceConfigService;
     }
     }
 
 
 
 
@@ -166,16 +167,17 @@ public class WashDeviceServiceImpl extends MyBaseServiceImpl<WashDeviceMapper, W
         List<WashDevice> list = lambdaQuery()
         List<WashDevice> list = lambdaQuery()
                 .eq(CommUtil.isNotEmptyAndNull(query.getStationId()), WashDevice::getStationId, query.getStationId())
                 .eq(CommUtil.isNotEmptyAndNull(query.getStationId()), WashDevice::getStationId, query.getStationId())
                 .list();
                 .list();
-        // 获取站点-费率配置Map
-        var stationId2FeeRate = stationFeeRateService.lambdaQuery().in(StationFeeRate::getStationId, list.stream().map(WashDevice::getStationId).toList()).list().stream().collect(Collectors.toMap(StationFeeRate::getStationId, Function.identity()));
+
+        // 设备配置ID-设备配置Map
+        var deviceConfigMap = deviceConfigService.lambdaQuery().in(DeviceConfig::getId, list.stream().map(WashDevice::getDeviceConfigId).toList()).list().stream().collect(Collectors.toMap(DeviceConfig::getId, Function.identity()));
+
         var voList = new ArrayList<WashDeviceVo>();
         var voList = new ArrayList<WashDeviceVo>();
         list.forEach(item -> {
         list.forEach(item -> {
             var vo = new WashDeviceVo();
             var vo = new WashDeviceVo();
             BeanUtils.copyProperties(item, vo);
             BeanUtils.copyProperties(item, vo);
             vo.setShortId(KymCache.INSTANCE.getShortIdByProductKeyAndDeviceName(item.getProductKey(), item.getDeviceName()));
             vo.setShortId(KymCache.INSTANCE.getShortIdByProductKeyAndDeviceName(item.getProductKey(), item.getDeviceName()));
             vo.setStationName(KymCache.INSTANCE.getStationNameById(item.getStationId()));
             vo.setStationName(KymCache.INSTANCE.getStationNameById(item.getStationId()));
-            vo.setFeeRateId(stationId2FeeRate.get(item.getStationId()).getId());
-            vo.setFeeRateName(stationId2FeeRate.get(item.getStationId()).getFeeRateName());
+            vo.setDeviceConfigName(deviceConfigMap.get(item.getDeviceConfigId()).getName());
             voList.add(vo);
             voList.add(vo);
         });
         });
         return new PageBean<>(voList);
         return new PageBean<>(voList);