|
@@ -1,20 +1,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;
|
|
|
-import javax.validation.constraints.*;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
-import com.ruoyi.common.annotation.RepeatSubmit;
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
+import com.ruoyi.common.annotation.RepeatSubmit;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.validate.AddGroup;
|
|
@@ -22,12 +11,32 @@ import com.ruoyi.common.core.validate.EditGroup;
|
|
|
import com.ruoyi.common.core.validate.QueryGroup;
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
-import com.ruoyi.zhdd.domain.vo.SingleDeviceVo;
|
|
|
import com.ruoyi.zhdd.domain.bo.SingleDeviceBo;
|
|
|
+import com.ruoyi.zhdd.domain.vo.SingleDeviceVo;
|
|
|
+import com.ruoyi.zhdd.service.IDhService;
|
|
|
import com.ruoyi.zhdd.service.ISingleDeviceService;
|
|
|
-import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+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.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.constraints.NotEmpty;
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 单兵数据信息Controller
|
|
@@ -43,6 +52,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
public class SingleDeviceController extends BaseController {
|
|
|
|
|
|
private final ISingleDeviceService iSingleDeviceService;
|
|
|
+ private final IDhService dhService;
|
|
|
|
|
|
/**
|
|
|
* 查询单兵数据信息列表
|
|
@@ -50,7 +60,24 @@ public class SingleDeviceController extends BaseController {
|
|
|
@ApiOperation("查询单兵数据信息列表")
|
|
|
@GetMapping("/list")
|
|
|
public AjaxResult<Map<String, SingleDeviceVo>> list(@Validated(QueryGroup.class) SingleDeviceBo bo) {
|
|
|
+ bo.setDataSource(3);
|
|
|
List<SingleDeviceVo> singleDeviceVos = iSingleDeviceService.queryList(bo);
|
|
|
+ // 查询大华设备的在离线
|
|
|
+ JSONArray ecsArr = dhService.querySingleStat();
|
|
|
+ if (ecsArr.size() > 0) {
|
|
|
+ Map<String, JSONObject> collect2 = ecsArr.stream().collect(Collectors.toMap(i -> {
|
|
|
+ JSONObject a = (JSONObject) i;
|
|
|
+ return a.getStr("deviceCode");
|
|
|
+ }, object -> (JSONObject) object));
|
|
|
+ for (SingleDeviceVo singleDeviceVo : singleDeviceVos) {
|
|
|
+ JSONObject jsonObject = collect2.get(singleDeviceVo.getDeviceCode());
|
|
|
+ if (jsonObject != null) {
|
|
|
+ singleDeviceVo.setStat(jsonObject.getStr("stat"));
|
|
|
+ } else {
|
|
|
+ singleDeviceVo.setStat("offline");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
Map<String, SingleDeviceVo> collect = singleDeviceVos.stream().collect(Collectors.toMap(SingleDeviceVo::getDeviceCode, a -> a));
|
|
|
return AjaxResult.success(collect);
|
|
|
}
|
|
@@ -74,7 +101,7 @@ public class SingleDeviceController extends BaseController {
|
|
|
@PreAuthorize("@ss.hasPermi('zhdd:singleDevice:query')")
|
|
|
@GetMapping("/{userId}")
|
|
|
public AjaxResult<SingleDeviceVo> getInfo(@NotNull(message = "主键不能为空")
|
|
|
- @PathVariable("userId") String userId) {
|
|
|
+ @PathVariable("userId") String userId) {
|
|
|
return AjaxResult.success(iSingleDeviceService.queryById(userId));
|
|
|
}
|
|
|
|
|
@@ -107,10 +134,10 @@ public class SingleDeviceController extends BaseController {
|
|
|
*/
|
|
|
@ApiOperation("删除单兵数据信息")
|
|
|
@PreAuthorize("@ss.hasPermi('zhdd:singleDevice:remove')")
|
|
|
- @Log(title = "单兵数据信息" , businessType = BusinessType.DELETE)
|
|
|
+ @Log(title = "单兵数据信息", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{userIds}")
|
|
|
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
|
|
|
- @PathVariable String[] userIds) {
|
|
|
+ @PathVariable String[] userIds) {
|
|
|
return toAjax(iSingleDeviceService.deleteWithValidByIds(Arrays.asList(userIds), true) ? 1 : 0);
|
|
|
}
|
|
|
}
|