Explorar el Código

Merge branch 'master' into prod

李进 hace 1 año
padre
commit
427d29a98f

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

@@ -3,7 +3,6 @@ package com.xy.controller;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.xy.alipay.AliPay;
 import com.xy.annotate.RestMappingController;
 import com.xy.dto.DeviceBluetoothAuthDto;
 import com.xy.dto.DeviceInfoDto;
@@ -213,7 +212,6 @@ public class MercMiniDeviceController {
 
     @ApiOperation("运营状态修改")
     @PostMapping("modifyBusyStage")
-    @AliPay(AliPay.Type.BUSY_STATE)
     public R modifyBusyStage(@RequestBody @Validated MercMiniDeviceDto.BusySate busySate) {
         Long mercId = MercAuthUtils.getMercId();
         Long deviceId = busySate.getDeviceId();

+ 0 - 5
device-api-service/pom.xml

@@ -87,10 +87,5 @@
             <version>1.0</version>
             <scope>compile</scope>
         </dependency>
-        <dependency>
-            <groupId>com.xy</groupId>
-            <artifactId>xy-alipay</artifactId>
-            <version>1.0</version>
-        </dependency>
     </dependencies>
 </project>

+ 0 - 39
device-api-service/src/main/java/com/xy/alipay/AliPay.java

@@ -1,39 +0,0 @@
-package com.xy.alipay;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.lang.annotation.*;
-
-/**
- * 支付宝注解
- *
- * @author lijin
- */
-@Target({ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface AliPay {
-
-    /**
-     * 类型
-     *
-     * @return
-     */
-    Type value();
-
-
-    @Getter
-    @AllArgsConstructor
-    enum Type {
-
-        RESTART("重启设备"),
-
-        BUSY_STATE("修改运营状态")
-
-        ;
-
-        private String type;
-    }
-
-}

+ 0 - 141
device-api-service/src/main/java/com/xy/alipay/AliPayAspet.java

@@ -1,141 +0,0 @@
-package com.xy.alipay;
-
-import cn.hutool.json.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.xy.collections.list.JArrayList;
-import com.xy.collections.map.JMap;
-import com.xy.dto.CommandMqtt;
-import com.xy.dto.DeviceChangeStatusDTO;
-import com.xy.dto.MercMiniDeviceDto;
-import com.xy.entity.DeviceInfo;
-import com.xy.service.AlipayDeviceService;
-import com.xy.service.DeviceInfoServiceImpl;
-import com.xy.utils.AuthorizeUtils;
-import com.xy.utils.R;
-import com.xy.utils.enums.DictSonEnum;
-import lombok.AllArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Slf4j
-@Aspect
-@Component
-@AllArgsConstructor
-public class AliPayAspet {
-
-    private DeviceInfoServiceImpl deviceInfoService;
-
-    private AlipayDeviceService alipayDeviceService;
-
-    /**
-     * 支付宝设备
-     *
-     * @param joinPoint
-     * @param aliPay
-     * @return
-     * @throws Throwable
-     */
-    @Around("@annotation(aliPay)")
-    public Object timer(ProceedingJoinPoint joinPoint, AliPay aliPay) throws Throwable {
-        String type = aliPay.value().getType();
-        Object[] args = joinPoint.getArgs();
-        Object result = R.ok();
-        try {
-            boolean fal = before(type, args);
-            if (fal) {
-                result = joinPoint.proceed(args);
-            }
-        } catch (Exception e) {
-            throw e;
-        }
-        return result;
-    }
-
-    public boolean before(String type, Object[] args) {
-        boolean fal = true;
-        //重启设备
-        if (type.equals(AliPay.Type.RESTART.getType())) {
-            List<CommandMqtt> restart = restart(args);
-            if (restart.size() > 0) {
-                args[0] = restart;
-            } else {
-                fal = false;
-            }
-        }
-        //修改运营状态
-        if (type.equals(AliPay.Type.BUSY_STATE.getType())) {
-            fal = busyState(args);
-        }
-        return fal;
-    }
-
-    /**
-     * 重启设备
-     *
-     * @param args
-     */
-    private List<CommandMqtt> restart(Object[] args) {
-        List<CommandMqtt> result = new ArrayList<>();
-        List<CommandMqtt> commandMqtts = (List<CommandMqtt>) args[0];
-        //查询支付宝设备信息
-        List<DeviceInfo> deviceInfos = deviceInfoService.list(new LambdaQueryWrapper<DeviceInfo>()
-                .in(DeviceInfo::getDeviceId, new JArrayList<>(commandMqtts).comparing(CommandMqtt::getDeviceId).getProperty(CommandMqtt::getDeviceId))
-                .eq(DeviceInfo::getDeviceType, DictSonEnum.DEVICE_TYPE_5.getKey())
-        );
-        if (deviceInfos.size() == 0) {
-            return commandMqtts;
-        }
-        JMap<Long, DeviceInfo> deviceInfosJMaps = new JArrayList<>(deviceInfos).toMap(DeviceInfo::getDeviceId).cover();
-        commandMqtts.forEach(commandMqtt -> {
-            JSONObject templet = commandMqtt.getTemplet();
-            JSONObject data = templet.getJSONObject("data");
-            DeviceInfo deviceInfo = deviceInfosJMaps.get(commandMqtt.getDeviceId());
-            if (deviceInfo == null) {
-                result.add(commandMqtt);
-                return;
-            }
-            //发送支付宝设备重启请求
-            if (data.getStr("type").equals("app") && data.getStr("task").equals("restart")) {
-                alipayDeviceService.deviceReboot(deviceInfo.getDistrictId().toString());
-            }
-        });
-        return result;
-    }
-
-    /**
-     * 修改运营状态
-     *
-     * @param args
-     * @return
-     */
-    private boolean busyState(Object[] args) {
-        MercMiniDeviceDto.BusySate busySate = (MercMiniDeviceDto.BusySate) args[0];
-        //查询支付宝设备信息
-        DeviceInfo deviceInfo = deviceInfoService.getOne(new LambdaQueryWrapper<DeviceInfo>()
-                .eq(DeviceInfo::getDeviceId, busySate.getDeviceId())
-                .eq(DeviceInfo::getDeviceType, DictSonEnum.DEVICE_TYPE_5.getKey())
-        );
-        if (deviceInfo == null) {
-            return true;
-        }
-        Long deviceId = busySate.getDeviceId();
-        DeviceInfo updateDeviceInfo = new DeviceInfo()
-                .setDeviceId(deviceId)
-                .setBusyState(busySate.getBusyState())
-                .setFreezeStatus(busySate.getBusyState());
-        deviceInfoService.updateById(updateDeviceInfo);
-        //发送支付宝设备修改运营状态请求
-        DeviceChangeStatusDTO deviceChangeStatusDTO = new DeviceChangeStatusDTO()
-                .setTerminalId(String.valueOf(deviceId))
-                .setOperatorId(AuthorizeUtils.getLoginId(String.class))
-                .setStatus(busySate.getBusyState());
-        alipayDeviceService.changeStatus(deviceChangeStatusDTO);
-        return false;
-    }
-}

+ 0 - 2
device-api-service/src/main/java/com/xy/service/MqttServiceImpl.java

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xy.alipay.AliPay;
 import com.xy.annotate.Runners;
 import com.xy.annotate.Timer;
 import com.xy.collections.map.JHashMap;
@@ -126,7 +125,6 @@ public class MqttServiceImpl extends ServiceImpl<MqttCommandMapper, MqttCommand>
 
     @Override
     @ApiOperation("指令发送")
-    @AliPay(AliPay.Type.RESTART)
     public R<List<Tuple.Tuple3<Long, Long, Boolean>>> senCommand(List<CommandMqtt> commandMqtts) {
         //发送指令
         List<MqttDto> mqttDtos = new ArrayList<>();