|
|
@@ -0,0 +1,123 @@
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin.devicegroup;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.inspect.order.vo.IotInspectOrderRespVO;
|
|
|
+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.inspect.IotInspectOrderDetailDO;
|
|
|
+import cn.iocoder.yudao.module.pms.service.devicegroup.IotDeviceGroupDetailService;
|
|
|
+import cn.iocoder.yudao.module.pms.service.devicegroup.IotDeviceGroupService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
+
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - PMS成套")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/rq/iot-device-group")
|
|
|
+@Validated
|
|
|
+public class IotDeviceGroupController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IotDeviceGroupService iotDeviceGroupService;
|
|
|
+ @Autowired
|
|
|
+ private IotDeviceGroupDetailService iotDeviceGroupDetailService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建PMS成套")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device-group:create')")
|
|
|
+ public CommonResult<Long> createIotDeviceGroup(@Valid @RequestBody IotDeviceGroupSaveReqVO createReqVO) {
|
|
|
+ return success(iotDeviceGroupService.createIotDeviceGroup(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新PMS成套")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device-group:update')")
|
|
|
+ public CommonResult<Boolean> updateIotDeviceGroup(@Valid @RequestBody IotDeviceGroupSaveReqVO updateReqVO) {
|
|
|
+ iotDeviceGroupService.updateIotDeviceGroup(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除PMS成套")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device-group:delete')")
|
|
|
+ public CommonResult<Boolean> deleteIotDeviceGroup(@RequestParam("id") Long id) {
|
|
|
+ iotDeviceGroupService.deleteIotDeviceGroup(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得PMS成套")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device-group:query')")
|
|
|
+ public CommonResult<IotDeviceGroupRespVO> getIotDeviceGroup(@RequestParam("id") Long id) {
|
|
|
+ IotDeviceGroupDO iotDeviceGroup = iotDeviceGroupService.getIotDeviceGroup(id);
|
|
|
+ IotDeviceGroupRespVO bean = BeanUtils.toBean(iotDeviceGroup, IotDeviceGroupRespVO.class);
|
|
|
+ List<IotDeviceGroupDetailDO> iotDeviceGroupDetailListByGroupId = iotDeviceGroupDetailService.getIotDeviceGroupDetailListByGroupId(iotDeviceGroup.getId());
|
|
|
+ bean.setDetails(iotDeviceGroupDetailListByGroupId);
|
|
|
+ return success(bean);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得PMS成套分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device-group:query')")
|
|
|
+ public CommonResult<PageResult<IotDeviceGroupRespVO>> getIotDeviceGroupPage(@Valid IotDeviceGroupPageReqVO pageReqVO) {
|
|
|
+ PageResult<IotDeviceGroupDO> pageResult = iotDeviceGroupService.getIotDeviceGroupPage(pageReqVO);
|
|
|
+ List<IotDeviceGroupRespVO> collect = pageResult.getList().stream().map(e -> {
|
|
|
+ IotDeviceGroupRespVO bean = BeanUtil.toBean(e, IotDeviceGroupRespVO.class);
|
|
|
+ List<IotDeviceGroupDetailDO> iotDeviceGroupDetailListByGroupId = iotDeviceGroupDetailService.getIotDeviceGroupDetailListByGroupId(e.getId());
|
|
|
+ bean.setDetails(iotDeviceGroupDetailListByGroupId);
|
|
|
+ return bean;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return success(new PageResult<>(collect, pageResult.getTotal()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出PMS成套 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device-group:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportIotDeviceGroupExcel(@Valid IotDeviceGroupPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<IotDeviceGroupDO> list = iotDeviceGroupService.getIotDeviceGroupPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "PMS成套.xls", "数据", IotDeviceGroupRespVO.class,
|
|
|
+ BeanUtils.toBean(list, IotDeviceGroupRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/device/group")
|
|
|
+ @Operation(summary = "获得某设备的成套信息")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-device-group:query')")
|
|
|
+ public CommonResult<PageResult<IotDeviceGroupDetailDO>> getDeviceGroup(@Valid IotDeviceGroupDetailPageReqVO reqVO) {
|
|
|
+ PageResult<IotDeviceGroupDetailDO> deviceGroupList = iotDeviceGroupService.getDeviceGroupList(reqVO);
|
|
|
+ return success(deviceGroupList);
|
|
|
+ }
|
|
|
+}
|