|
@@ -1,15 +1,22 @@
|
|
|
package cn.iocoder.yudao.module.pms.controller.admin.devicegroup;
|
|
package cn.iocoder.yudao.module.pms.controller.admin.devicegroup;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.inspect.order.vo.IotInspectOrderRespVO;
|
|
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.ThingsModelDTO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.TableDataInfo;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.devicegroup.IotDeviceGroupDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.devicegroup.IotDeviceGroupDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.devicegroup.IotDeviceGroupDetailDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.devicegroup.IotDeviceGroupDetailDO;
|
|
|
-import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectOrderDetailDO;
|
|
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.tdparams.IotTdParamsDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.tdparams.IotTdParamsMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.service.IotDeviceService;
|
|
|
import cn.iocoder.yudao.module.pms.service.devicegroup.IotDeviceGroupDetailService;
|
|
import cn.iocoder.yudao.module.pms.service.devicegroup.IotDeviceGroupDetailService;
|
|
|
import cn.iocoder.yudao.module.pms.service.devicegroup.IotDeviceGroupService;
|
|
import cn.iocoder.yudao.module.pms.service.devicegroup.IotDeviceGroupService;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
@@ -19,7 +26,6 @@ import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
-import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
@@ -31,6 +37,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -51,6 +58,16 @@ public class IotDeviceGroupController {
|
|
|
private IotDeviceGroupDetailService iotDeviceGroupDetailService;
|
|
private IotDeviceGroupDetailService iotDeviceGroupDetailService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private DeptApi deptApi;
|
|
private DeptApi deptApi;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private StringRedisTemplate redisTemplate;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IotTdParamsMapper iotTdParamsMapper;
|
|
|
|
|
+ @Value("${yanfan.url}")
|
|
|
|
|
+ private String yanfanUrl;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IotDeviceService iotDeviceService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private RestTemplate restTemplate;
|
|
|
|
|
|
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建PMS成套")
|
|
@Operation(summary = "创建PMS成套")
|
|
@@ -140,4 +157,22 @@ public class IotDeviceGroupController {
|
|
|
return success(new PageResult<>(collect, deviceGroupList.getTotal()));
|
|
return success(new PageResult<>(collect, deviceGroupList.getTotal()));
|
|
|
// return success(deviceGroupList);
|
|
// return success(deviceGroupList);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/td/{id}")
|
|
|
|
|
+ @Operation(summary = "获得某设备的成套信息")
|
|
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device-group:query')")
|
|
|
|
|
+ public CommonResult<Map<String, Object>> getIotDeviceGroupDetail(@PathVariable("id") Long id) {
|
|
|
|
|
+ List<IotDeviceGroupDetailDO> details = iotDeviceGroupDetailService.getIotDeviceGroupDetailListByGroupId(id);
|
|
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
+ details.forEach(e ->{
|
|
|
|
|
+ IotDeviceDO iotDevice = iotDeviceService.getIotDevice(e.getDeviceId());
|
|
|
|
|
+ TableDataInfo tableDataInfo = restTemplate.getForObject(yanfanUrl + "/prod-api/iot/device/listThingsModel?deviceId="+iotDevice.getYfDeviceId()+"&pageNum=1&pageSize=200", TableDataInfo.class);
|
|
|
|
|
+ if (Objects.nonNull(tableDataInfo)) {
|
|
|
|
|
+ List<ThingsModelDTO> rows = JSON.parseArray(JSON.toJSONString(tableDataInfo.getRows()), ThingsModelDTO.class);
|
|
|
|
|
+ resultMap.put(e.getDeviceCode(), rows);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return success(resultMap);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|