|
@@ -1,10 +1,20 @@
|
|
package cn.iocoder.yudao.module.pms.controller.admin;
|
|
package cn.iocoder.yudao.module.pms.controller.admin;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
import cn.iocoder.yudao.module.pms.service.IotDeviceService;
|
|
import cn.iocoder.yudao.module.pms.service.IotDeviceService;
|
|
|
|
+import cn.iocoder.yudao.module.pms.util.IotDeviceConvert;
|
|
|
|
+import cn.iocoder.yudao.module.supplier.dal.dataobject.product.SupplierDO;
|
|
|
|
+import cn.iocoder.yudao.module.supplier.service.product.SupplierService;
|
|
|
|
+import cn.iocoder.yudao.module.system.convert.user.UserConvert;
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
|
+import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -29,6 +39,7 @@ 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 static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
|
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
|
|
|
|
|
|
|
|
@Tag(name = "管理后台 - 设备台账")
|
|
@Tag(name = "管理后台 - 设备台账")
|
|
@@ -39,6 +50,12 @@ public class IotDeviceController {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private IotDeviceService iotDeviceService;
|
|
private IotDeviceService iotDeviceService;
|
|
|
|
+ @Resource
|
|
|
|
+ private DeptService deptService;
|
|
|
|
+ @Resource
|
|
|
|
+ private DictDataService dictDataService;
|
|
|
|
+ @Resource
|
|
|
|
+ private SupplierService supplierService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
@Operation(summary = "创建设备台账")
|
|
@Operation(summary = "创建设备台账")
|
|
@@ -70,7 +87,15 @@ public class IotDeviceController {
|
|
@PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
|
|
@PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
|
|
public CommonResult<IotDeviceRespVO> getIotDevice(@RequestParam("id") Long id) {
|
|
public CommonResult<IotDeviceRespVO> getIotDevice(@RequestParam("id") Long id) {
|
|
IotDeviceDO iotDevice = iotDeviceService.getIotDevice(id);
|
|
IotDeviceDO iotDevice = iotDeviceService.getIotDevice(id);
|
|
- return success(BeanUtils.toBean(iotDevice, IotDeviceRespVO.class));
|
|
|
|
|
|
+ IotDeviceRespVO iotDeviceRespVO = new IotDeviceRespVO();
|
|
|
|
+ BeanUtils.copyProperties(iotDevice, iotDeviceRespVO);
|
|
|
|
+ DictDataDO dictData = dictDataService.getDictData(iotDevice.getBrand());
|
|
|
|
+ iotDeviceRespVO.setBrandName(Objects.nonNull(dictData)?dictData.getLabel():"");
|
|
|
|
+ SupplierDO supplierDO = supplierService.get(iotDevice.getSupplierId());
|
|
|
|
+ iotDeviceRespVO.setSupplierName(Objects.nonNull(supplierDO)?supplierDO.getName():"");
|
|
|
|
+ SupplierDO supplierDO1 = supplierService.get(iotDevice.getManufacturerId());
|
|
|
|
+ iotDeviceRespVO.setZzName(Objects.nonNull(supplierDO1)?supplierDO1.getName():"");
|
|
|
|
+ return success(iotDeviceRespVO);
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/page")
|
|
@GetMapping("/page")
|
|
@@ -78,7 +103,14 @@ public class IotDeviceController {
|
|
@PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
|
|
@PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
|
|
public CommonResult<PageResult<IotDeviceRespVO>> getIotDevicePage(@Valid IotDevicePageReqVO pageReqVO) {
|
|
public CommonResult<PageResult<IotDeviceRespVO>> getIotDevicePage(@Valid IotDevicePageReqVO pageReqVO) {
|
|
PageResult<IotDeviceDO> pageResult = iotDeviceService.getIotDevicePage(pageReqVO);
|
|
PageResult<IotDeviceDO> pageResult = iotDeviceService.getIotDevicePage(pageReqVO);
|
|
- return success(BeanUtils.toBean(pageResult, IotDeviceRespVO.class));
|
|
|
|
|
|
+ if (CollUtil.isEmpty(pageResult.getList())) {
|
|
|
|
+ return success(new PageResult<>(pageResult.getTotal()));
|
|
|
|
+ }
|
|
|
|
+ Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
|
|
|
+ convertList(pageResult.getList(), IotDeviceDO::getOrgId));
|
|
|
|
+ return success(new PageResult<>(IotDeviceConvert.INSTANCE.convertList(pageResult.getList(), deptMap),
|
|
|
|
+ pageResult.getTotal()));
|
|
|
|
+ //return success(BeanUtils.toBean(pageResult, IotDeviceRespVO.class));
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|
|
@GetMapping("/export-excel")
|