Browse Source

Merge remote-tracking branch 'origin/master-碰一下' into test

tanbin 9 months ago
parent
commit
67404a3596

+ 26 - 1
device-api-service-merc-mini/src/main/java/com/xy/controller/MercMiniDeviceController.java

@@ -365,7 +365,12 @@ public class MercMiniDeviceController {
     @PostMapping("restActive")
     @ApiOperation("重置设备激活")
     public R restActive(@RequestBody @Validated MercMiniDeviceDto.RestActive restActive) {
-        DeviceInfo deviceInfo = deviceInfoService.getById(restActive.getDeviceId());
+        DeviceInfoDto.Vo deviceInfo = deviceInfoService.obj(new DeviceInfoDto.Obj().setDeviceId(restActive.getDeviceId()).setIsSysinfo(true)).getData();
+        DeviceSysinfoDto.Vo deviceSysinfo = deviceInfo.getDeviceSysinfo();
+        if (deviceSysinfo != null) {
+            restActive.setNfcSn(deviceSysinfo.getNfcSn());
+        }
+
         return FactoryUtils.getServiceRoute(DeviceFactory.class, deviceInfo.getDeviceType()).restActive(restActive);
     }
 
@@ -495,4 +500,24 @@ public class MercMiniDeviceController {
         return R.ok(deviceBluetoothAuthService.saveOrUpdate(deviceBluetoothAuth));
     }
 
+
+    @ApiOperation("支付宝Npad音量设置")
+    @PostMapping("setAliNpadVol")
+    public R<Boolean> setAliNpadVol(@RequestBody @Validated DeviceInfoDto.NfcVol nfcVol) {
+        String deviceId = nfcVol.getDeviceId();
+        DeviceSetAttr dto = new DeviceSetAttr();
+        dto.setType("VOL").setTerminalId(deviceId).setValue(nfcVol.getValue());
+        return R.ok(R.feignCheckData(alipayDeviceService.setAttributes(dto)));
+    }
+
+
+    @ApiOperation("音量、温度查询")
+    @PostMapping("queryAliNpadVol")
+    public R<Boolean> queryAliNpadVol(@RequestBody DeviceInfoDto.NfcVolQuery dto) {
+        DeviceQueryAttr deviceQueryAttr = new DeviceQueryAttr();
+        deviceQueryAttr.setTerminalId(dto.getDeviceId());
+        deviceQueryAttr.setType("VOL");
+        return R.ok(R.feignCheckData(alipayDeviceService.queryAttributes(deviceQueryAttr)));
+    }
+
 }

+ 5 - 2
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -1346,6 +1346,8 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
                 if (CollUtil.isNotEmpty(deviceIdGoodsMap)) {
                     List<GoodsDeviceDto.Vo> goodsDevice = deviceIdGoodsMap.get(dId);
                     if (CollUtil.isNotEmpty(goodsDevice)) {
+                        //过滤商品id为1 和 2的商品
+                        goodsDevice = goodsDevice.stream().filter(g -> g.getGoodsId() != 1 && g.getGoodsId() != 2).collect(Collectors.toList());
                         device.setOnSaleNum(goodsDevice.stream().mapToInt(GoodsDeviceDto.Vo::getStock).sum());
                         device.setFillNum(goodsDevice.stream().mapToInt(GoodsDeviceDto.Vo::getFillCount).sum());
                     }
@@ -1830,6 +1832,8 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         Integer stock = 0;
         Integer afterFillStock = 0;
         if (CollUtil.isNotEmpty(goodsDeviceList)) {
+            //goodsDeviceList 过滤商品id=1和商品id=2的商品
+            goodsDeviceList = goodsDeviceList.stream().filter(g -> g.getGoodsId() != 1 && g.getGoodsId() != 2).collect(Collectors.toList());
             stock = goodsDeviceList.stream().mapToInt(GoodsDeviceDto.Vo::getStock).sum();
             afterFillStock = goodsDeviceList.stream().mapToInt(GoodsDeviceDto.Vo::getFillCount).sum();
         }
@@ -1879,8 +1883,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
                 .eq(DeviceInfo::getActiveState, DeviceActiveStateEnum.TRUE.getCode())
                 .eq(DeviceInfo::getBusyState, EnumDeviceBusyStatus.N_1.getCode())
                 .eq(DeviceInfo::getShowStatus, true)
-                .eq(DeviceInfo::getFreezeStatus, EnumDeviceFreezeStatus.N_1.getCode())
-                ;
+                .eq(DeviceInfo::getFreezeStatus, EnumDeviceFreezeStatus.N_1.getCode());
         List<DeviceInfo> list = list(lqw);
         if (!Emptys.check(list)) {
             return R.ok(new ArrayList<>());

+ 18 - 14
device-api-service/src/main/java/com/xy/service/factory/device/impl/alipay/AliPayOpenDeviceFatoryImpl.java

@@ -340,18 +340,18 @@ public class AliPayOpenDeviceFatoryImpl implements DeviceFactory, SpiDeviceServi
         String value = dto.getValue();
 
         //查询设备信息
-        DeviceInfo deviceInfo = deviceInfoService.getById(Long.valueOf(terminalId));
+        DeviceInfoDto.Vo deviceInfo = R.feignCheckData(deviceInfoService.obj(new DeviceInfoDto.Obj().setIsSysinfo(true).setDeviceId(Long.valueOf(terminalId))));
         if (deviceInfo == null) {
             log.warn("温度、音量查询SPI通知,无设备信息");
             return SpiResponseConst.SUCCESS;
         }
+        DeviceSysinfoDto.Vo deviceSysinfo = deviceInfo.getDeviceSysinfo();
+        boolean isHaveNfc = false;
+        if (deviceSysinfo != null && StrUtil.isNotEmpty(deviceSysinfo.getNfcSn())) {
+            isHaveNfc = true;
+        }
         //温度更新
         FunctionUtils.NoParamsNoResult updateTmp = () -> {
-//            deviceStatus.setTempValue(Integer.valueOf(value));
-//            deviceStatusService.updateById(deviceStatus);
-//            DeviceSysinfoDto.Up sysUp = new DeviceSysinfoDto.Up();
-//            sysUp.setDeviceId(deviceInfo.getDeviceId()).setIsHaveTemp(true);
-//            deviceSysinfoService.up(sysUp);
             DeviceStatusDto.Up up = new DeviceStatusDto.Up();
             up.setDeviceId(deviceInfo.getDeviceId())
                     .setTempState(0)
@@ -360,21 +360,19 @@ public class AliPayOpenDeviceFatoryImpl implements DeviceFactory, SpiDeviceServi
         };
 
         DeviceStatus deviceStatus = deviceStatusService.getById(deviceInfo.getDeviceId());
-        if (deviceStatus == null) {
+        if (deviceStatus == null && !isHaveNfc) {
             log.warn("温度、音量查询SPI通知,无设备状态记录");
             return SpiResponseConst.SUCCESS;
         }
         //音量更新
         FunctionUtils.NoParamsNoResult updateVoice = () -> {
-//            deviceStatus.setVoiceVolume(Integer.valueOf(value));
-//            deviceStatusService.updateById(deviceStatus);
             DeviceStatusDto.Up up = new DeviceStatusDto.Up();
             up.setDeviceId(deviceInfo.getDeviceId())
                     .setVoiceVolume(Integer.valueOf(value));
             deviceStatusService.up(up);
         };
 
-        if (BooleanUtil.isTrue(success)) {
+        if (BooleanUtil.isTrue(success) && !isHaveNfc) {
             //温度:TEMP 音量:VOL
             if ("VOL".equals(type)) {
                 updateVoice.run();
@@ -394,13 +392,19 @@ public class AliPayOpenDeviceFatoryImpl implements DeviceFactory, SpiDeviceServi
         String value = dto.getValue();
 
         //查询设备信息
-        DeviceInfo deviceInfo = deviceInfoService.getById(Long.valueOf(terminalId));
+        DeviceInfoDto.Vo deviceInfo = R.feignCheckData(deviceInfoService.obj(new DeviceInfoDto.Obj().setIsSysinfo(true).setDeviceId(Long.valueOf(terminalId))));
         if (deviceInfo == null) {
-            log.warn("温度、音量设置SPI通知,无设备信息");
+            log.warn("温度、音量查询SPI通知,无设备信息");
             return SpiResponseConst.SUCCESS;
         }
+        DeviceSysinfoDto.Vo deviceSysinfo = deviceInfo.getDeviceSysinfo();
+        boolean isHaveNfc = false;
+        if (deviceSysinfo != null && StrUtil.isNotEmpty(deviceSysinfo.getNfcSn())) {
+            isHaveNfc = true;
+        }
+
         DeviceStatus deviceStatus = deviceStatusService.getById(deviceInfo.getDeviceId());
-        if (deviceStatus == null) {
+        if (deviceStatus == null && !isHaveNfc) {
             log.warn("温度、音量设置SPI通知,无设备状态记录");
             return SpiResponseConst.SUCCESS;
         }
@@ -415,7 +419,7 @@ public class AliPayOpenDeviceFatoryImpl implements DeviceFactory, SpiDeviceServi
             deviceStatusService.updateById(deviceStatus);
         };
 
-        if (BooleanUtil.isTrue(success)) {
+        if (BooleanUtil.isTrue(success) && !isHaveNfc) {
             //温度:TEMP 音量:VOL
             if ("VOL".equals(type)) {
                 updateVoice.run();

+ 19 - 3
device-api-service/src/main/java/com/xy/service/factory/device/impl/open/OpenDeviceFactoryImpl.java

@@ -16,6 +16,7 @@ import com.xy.device.EnumDeviceBusyStatus;
 import com.xy.dto.*;
 import com.xy.dto.be.MercDto;
 import com.xy.dto.nfc.ActiveDeviceDTO;
+import com.xy.dto.nfc.ResetDeviceDTO;
 import com.xy.entity.*;
 import com.xy.enums.SysCodeConfigureEnum;
 import com.xy.mapper.DeviceCreateIdsMapper;
@@ -197,7 +198,11 @@ public class OpenDeviceFactoryImpl implements DeviceFactory {
         deviceIds.forEach(deviceId -> {
             DeviceInfoDto.Vo dv = R.feignCheckData(deviceInfoService.obj(new DeviceInfoDto.Obj().setDeviceId(deviceId).setIsSysinfo(Boolean.TRUE)));
             DeviceSysinfoDto.Vo deviceSysinfo = dv.getDeviceSysinfo();
-            if (deviceSysinfo != null && StrUtil.isNotEmpty(deviceSysinfo.getNfcSn())) {
+            if (deviceSysinfo != null && deviceSysinfo.getIsHaveAlipayNpad()) {
+                String nfcSn = deviceSysinfo.getNfcSn();
+                if (StrUtil.isEmpty(nfcSn)) {
+                    throw new RuntimeException("nfc sn 不存在!");
+                }
                 String deviceName = dv.getDeviceName();
                 if (StrUtil.isEmpty(deviceName)) {
                     deviceName = "" + deviceId;
@@ -208,7 +213,7 @@ public class OpenDeviceFactoryImpl implements DeviceFactory {
                         .setBoardSn(deviceSysinfo.getDeviceSn()).setNfcSn(deviceSysinfo.getNfcSn()).setAddress(dv.getPlaceName());
                 Boolean b = R.feignCheckData(alipayDeviceService.nfcDeviceActive(activeDeviceDTO));
                 if (b) {
-                    throw new RuntimeException("NFC设备激活失败");
+                    throw new RuntimeException("NFC设备激活失败!");
                 }
             }
             //过滤需要付费的设备
@@ -231,7 +236,17 @@ public class OpenDeviceFactoryImpl implements DeviceFactory {
 
     @Override
     public R restActive(MercMiniDeviceDto.RestActive restActive) {
-        deviceChargingService.removeById(restActive.getDeviceId());
+        Long deviceId = restActive.getDeviceId();
+        String nfcSn = restActive.getNfcSn();
+        //nfc解绑重置
+        if (StrUtil.isNotEmpty(nfcSn)) {
+            String loginId = AuthorizeUtils.getLoginId(String.class);
+            ResetDeviceDTO resetParams = new ResetDeviceDTO().setOperatorId(loginId).setOperatorName(loginId).setRemark("设备激活重置").setTerminalId(String.valueOf(deviceId));
+            alipayDeviceService.nfcDeviceReset(resetParams);
+            R.feignCheckData(alipayDeviceService.nfcDeviceReset(resetParams));
+            deviceSysinfoMapper.updateById(new DeviceSysinfo().setDeviceId(deviceId).setNfcSn(StrUtil.EMPTY));
+        }
+        deviceChargingService.removeById(deviceId);
         deviceAlgorithmChargingService.remove(new LambdaQueryWrapper<DeviceAlgorithmCharging>()
                 .eq(DeviceAlgorithmCharging::getDeviceId, restActive.getDeviceId())
         );
@@ -240,6 +255,7 @@ public class OpenDeviceFactoryImpl implements DeviceFactory {
                 .set(DeviceInfo::getActiveTime, null)
                 .eq(DeviceInfo::getDeviceId, restActive.getDeviceId())
         );
+
         return R.ok();
     }
 

+ 3 - 0
device-api-service/src/main/resources/mapper/DeviceInfoMapper.xml

@@ -273,6 +273,9 @@
                 </otherwise>
             </choose>
         </if>
+        <if test="queryPage.isHaveNfc != null">
+            and sysinfo.is_have_alipay_npad= #{queryPage.isHaveNfc}
+        </if>
         <if test="queryPage.keyword != null and queryPage.keyword != ''">
             and CONCAT(IFNULL(info.device_name, ''), IFNULL(info.device_id, '')) LIKE
             CONCAT('%',#{queryPage.keyword},'%')

+ 25 - 1
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -26,6 +26,7 @@ import java.util.List;
 @Data
 @Accessors(chain = true)
 public class DeviceInfoDto {
+
     /**
      * 删除线路\点位时时指定 传入 wherePlaceLineId\wherePlaceId
      */
@@ -39,6 +40,27 @@ public class DeviceInfoDto {
      */
     public final static String CLEAR = "clear";
 
+    @Data
+    @Accessors(chain = true)
+    public static class NfcVol {
+        @NotBlank(message = "设备编号不可为空")
+        @ApiModelProperty(value = "设备编号", required = true)
+        private String deviceId;
+
+        @NotBlank(message = "值不可为空")
+        @ApiModelProperty(value = " 音量:0~15 (最小颗粒为1)", required = true)
+        private String value;
+    }
+
+    @Data
+    @Accessors(chain = true)
+    public static class NfcVolQuery {
+        @NotBlank(message = "设备编号不可为空")
+        @ApiModelProperty(value = "设备编号", required = true)
+        private String deviceId;
+
+    }
+
 
     @Data
     @Accessors(chain = true)
@@ -236,7 +258,7 @@ public class DeviceInfoDto {
 
         @ApiModelProperty("算法ID")
         private Long algorithmId;
-        
+
         @ApiModelProperty("货道数量")
         private Integer aisleNum;
 
@@ -524,6 +546,8 @@ public class DeviceInfoDto {
         @ApiModelProperty("是否查询故障设备")
         private Boolean fault;
 
+        @ApiModelProperty("是否有nfc")
+        private Boolean isHaveNfc;
 
         @ApiModelProperty("是否导出当前页")
         private Boolean exportPage = true;

+ 2 - 0
device-api/src/main/java/com/xy/dto/MercMiniDeviceDto.java

@@ -87,6 +87,8 @@ public class MercMiniDeviceDto {
         @NotNull(message = "deviceId不能为空")
         @ApiModelProperty("设备id")
         private Long deviceId;
+        @ApiModelProperty("nfcSN")
+        private String nfcSn;
 
     }