Jelajahi Sumber

add SingleDevice kafka

459242451@qq.com 3 tahun lalu
induk
melakukan
1f1e606d65

+ 7 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/SysGatewayUserTask.java

@@ -1,6 +1,8 @@
 package com.ruoyi.web.controller.task;
 
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
@@ -237,6 +239,11 @@ public class SysGatewayUserTask {
                     SingleDeviceBo singleDeviceBo = JSONUtil.toBean(Convert.toStr(gp), SingleDeviceBo.class);
                     // 根据deviceCod删除再新增
                     singleDeviceService.remove(Wrappers.<SingleDevice>lambdaQuery().eq(SingleDevice::getDeviceCode, singleDeviceBo.getDeviceCode()));
+                    String utcTime = singleDeviceBo.getTime();
+                    if (StrUtil.isNotBlank(utcTime)) {
+                        String concat = StrUtil.concat(true, utcTime.substring(0, 4), "-", utcTime.substring(4, 6), "-", utcTime.substring(6, 11), ":", utcTime.substring(11, 13), ":", utcTime.substring(13));
+                        singleDeviceBo.setTime(DateUtil.formatDateTime(DateUtil.parseUTC(concat)));
+                    }
                     singleDeviceService.insertByBo(singleDeviceBo);
                 }
             }

+ 6 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhdd/SingleDeviceController.java

@@ -2,7 +2,9 @@ package com.ruoyi.web.controller.zhdd;
 
 import java.util.List;
 import java.util.Arrays;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 import lombok.RequiredArgsConstructor;
 import javax.servlet.http.HttpServletResponse;
@@ -46,10 +48,11 @@ public class SingleDeviceController extends BaseController {
      * 查询单兵数据信息列表
      */
     @ApiOperation("查询单兵数据信息列表")
-    @PreAuthorize("@ss.hasPermi('zhdd:singleDevice:list')")
     @GetMapping("/list")
-    public AjaxResult<List<SingleDeviceVo>> list(@Validated(QueryGroup.class) SingleDeviceBo bo) {
-        return AjaxResult.success(iSingleDeviceService.queryList(bo));
+    public AjaxResult<Map<String, SingleDeviceVo>> list(@Validated(QueryGroup.class) SingleDeviceBo bo) {
+        List<SingleDeviceVo> singleDeviceVos = iSingleDeviceService.queryList(bo);
+        Map<String, SingleDeviceVo> collect = singleDeviceVos.stream().collect(Collectors.toMap(SingleDeviceVo::getDeviceCode, a -> a));
+        return AjaxResult.success(collect);
     }
 
     /**