|
@@ -2,14 +2,12 @@ package cn.iocoder.yudao.module.pms.controller.admin;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
-import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdeviceperson.vo.IotDevicePersonRelationSaveReqVO;
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorder.vo.IotMainWorkOrderRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.*;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotProductClassifyDO;
|
|
@@ -26,11 +24,8 @@ import cn.iocoder.yudao.module.pms.service.yanfan.YfDeviceService;
|
|
|
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.controller.admin.user.vo.user.UserSimpleRespVO;
|
|
|
-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 io.swagger.v3.oas.annotations.Operation;
|
|
@@ -181,18 +176,26 @@ public class IotDeviceController {
|
|
|
@Operation(summary = "获得设备关联责任人 分页")
|
|
|
@PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
|
|
|
public CommonResult<PageResult<IotDeviceRespVO>> responsiblePage(@Valid IotDevicePageReqVO pageReqVO) {
|
|
|
- PageResult<IotDeviceDO> pageResult = iotDeviceService.getIotDevicePage(pageReqVO);
|
|
|
+ // 只显示已经设置关联了责任人的设备
|
|
|
+ PageResult<IotDeviceRespVO> pageResult = iotDeviceService.personRelationDevices(pageReqVO);
|
|
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
|
|
return success(new PageResult<>(pageResult.getTotal()));
|
|
|
}
|
|
|
- // 查询设备关联的 负责人
|
|
|
- Map<Long, String> devicePersonNames = iotDevicePersonService.getIotDevicePerson(convertList(pageResult.getList(), IotDeviceDO::getId));
|
|
|
- Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
|
|
- convertList(pageResult.getList(), IotDeviceDO::getDeptId));
|
|
|
- // return success(new PageResult<>(IotDeviceConvert.INSTANCE.convertList(pageResult.getList(), deptMap), pageResult.getTotal()));
|
|
|
return success(new PageResult<>(buildDevicePersonsList(pageResult.getList()), pageResult.getTotal()));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/deviceDynamicsPage")
|
|
|
+ @Operation(summary = "获得设备动态 分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
|
|
|
+ public CommonResult<PageResult<IotDeviceRespVO>> responsiblePagedeviceDynamicsPage(@Valid IotDevicePageReqVO pageReqVO) {
|
|
|
+ // 只显示已经设置关联了责任人的设备
|
|
|
+ PageResult<IotDeviceDO> pageResult = iotDeviceService.getIotDevicePage(pageReqVO);
|
|
|
+ if (CollUtil.isEmpty(pageResult.getList())) {
|
|
|
+ return success(new PageResult<>(pageResult.getTotal()));
|
|
|
+ }
|
|
|
+ return success(new PageResult<>(buildDeviceDynamicsList(pageResult.getList()), pageResult.getTotal()));
|
|
|
+ }
|
|
|
+
|
|
|
@Autowired
|
|
|
private TDDeviceMapper deviceMapper;
|
|
|
|
|
@@ -254,7 +257,6 @@ public class IotDeviceController {
|
|
|
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
|
|
convertList(pageResult.getList(), IotDeviceRespVO::getDeptId));
|
|
|
// 拼接BOM节点信息
|
|
|
- // return success(new PageResult<>(buildDeviceAssociateBomList(pageResult.getList()), pageResult.getTotal()));
|
|
|
return success(new PageResult<>(IotDeviceConvert.INSTANCE.convertList1(pageResult.getList(), deptMap), pageResult.getTotal()));
|
|
|
}
|
|
|
|
|
@@ -285,11 +287,11 @@ public class IotDeviceController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 组装 设备-bom 关联关系对象
|
|
|
+ * 设备动态分布 设置关联查询信息
|
|
|
* @param devices
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<IotDeviceRespVO> buildDevicePersonsList(List<IotDeviceDO> devices) {
|
|
|
+ private List<IotDeviceRespVO> buildDeviceDynamicsList(List<IotDeviceDO> devices) {
|
|
|
if (CollUtil.isEmpty(devices)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
@@ -307,6 +309,29 @@ public class IotDeviceController {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 组装 设备-bom 关联关系对象
|
|
|
+ * @param devices
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<IotDeviceRespVO> buildDevicePersonsList(List<IotDeviceRespVO> devices) {
|
|
|
+ if (CollUtil.isEmpty(devices)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ // 设备部门信息
|
|
|
+ Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
|
|
+ convertList(devices, IotDeviceRespVO::getDeptId));
|
|
|
+ // 查询设备关联的 负责人
|
|
|
+ Map<Long, String> devicePersonNames = iotDevicePersonService.getIotDevicePerson(convertList(devices, IotDeviceRespVO::getId));
|
|
|
+ // 2. 拼接数据
|
|
|
+ return BeanUtils.toBean(devices, IotDeviceRespVO.class, (deviceVO) -> {
|
|
|
+ // 2.1 拼接部门信息
|
|
|
+ findAndThen(deptMap, deviceVO.getDeptId(), dept -> deviceVO.setDeptName(dept.getName()));
|
|
|
+ // 2.2 设备关联的负责人姓名
|
|
|
+ findAndThen(devicePersonNames, deviceVO.getId(), person -> deviceVO.setResponsibleNames(person));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/export-excel")
|
|
|
@Operation(summary = "导出设备台账 Excel")
|
|
|
@PreAuthorize("@ss.hasPermission('rq:iot-device:export')")
|