2 커밋 7cd7b16132 ... ce3ae0ee3b

작성자 SHA1 메시지 날짜
  Zimo ce3ae0ee3b Merge remote-tracking branch 'origin/master' 9 시간 전
  Zimo 20992356e6 获取yanfan token 9 시간 전

+ 22 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/IotDeviceController.java

@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.pms.controller.admin;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjUtil;
+import cn.hutool.json.JSONObject;
 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
@@ -59,6 +60,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.client.RestTemplate;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
@@ -115,6 +117,8 @@ public class IotDeviceController {
     private IotDeviceMapper iotDeviceMapper;
     @Autowired
     private IotAlarmSettingMapper iotAlarmSettingMapper;
+    @Autowired
+    private RestTemplate restTemplate;
 
     @GetMapping(value = {"/company"})
     @Operation(summary = "获取设备属于哪个公司", description = "获取设备属于哪个公司")
@@ -811,4 +815,22 @@ public class IotDeviceController {
         List<ImmutableMap<String, ? extends Serializable>> collect = allDevices.stream().map(e -> ImmutableMap.of("id", e.getId(), "deviceName", e.getDeviceName(), "deviceCode", e.getDeviceCode())).collect(Collectors.toList());
         return success(collect);
     }
+
+    @Operation(summary = "获取延凡token")
+    @GetMapping("/yf/token")
+    public CommonResult<String> getYfToken() {
+        Map<String, Object> map = new HashMap<>();
+//        map.put("code", "12");
+        map.put("password", "123456");
+        map.put("sourceType", 1);
+        map.put("username", "yanfan");
+//        map.put("uuid", "5dc9dd7f2337451f8f708131166eabab");
+        JSONObject entries = restTemplate.postForObject("http://121.36.34.44/prod-api/login", map, JSONObject.class);
+        if (Objects.nonNull(entries)) {
+            if (Objects.nonNull(entries.get("token"))) {
+                return success(String.valueOf(entries.get("token")));
+            }
+        }
+        return success("");
+    }
 }