|
|
@@ -0,0 +1,98 @@
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.measure;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookRespVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure.IotMeasureBookDO;
|
|
|
+import cn.iocoder.yudao.module.pms.service.qhse.measure.IotMeasureBookService;
|
|
|
+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 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 = "管理后台 - 计量器具台账")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/rq/iot-measure-book")
|
|
|
+@Validated
|
|
|
+public class IotMeasureBookController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IotMeasureBookService iotMeasureBookService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建计量器具台账")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-measure-book:create')")
|
|
|
+ public CommonResult<Long> createIotMeasureBook(@Valid @RequestBody IotMeasureBookSaveReqVO createReqVO) {
|
|
|
+ return success(iotMeasureBookService.createIotMeasureBook(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新计量器具台账")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-measure-book:update')")
|
|
|
+ public CommonResult<Boolean> updateIotMeasureBook(@Valid @RequestBody IotMeasureBookSaveReqVO updateReqVO) {
|
|
|
+ iotMeasureBookService.updateIotMeasureBook(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除计量器具台账")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-measure-book:delete')")
|
|
|
+ public CommonResult<Boolean> deleteIotMeasureBook(@RequestParam("id") Long id) {
|
|
|
+ iotMeasureBookService.deleteIotMeasureBook(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得计量器具台账")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-measure-book:query')")
|
|
|
+ public CommonResult<IotMeasureBookRespVO> getIotMeasureBook(@RequestParam("id") Long id) {
|
|
|
+ IotMeasureBookDO iotMeasureBook = iotMeasureBookService.getIotMeasureBook(id);
|
|
|
+ return success(BeanUtils.toBean(iotMeasureBook, IotMeasureBookRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得计量器具台账分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-measure-book:query')")
|
|
|
+ public CommonResult<PageResult<IotMeasureBookRespVO>> getIotMeasureBookPage(@Valid IotMeasureBookPageReqVO pageReqVO) {
|
|
|
+ PageResult<IotMeasureBookDO> pageResult = iotMeasureBookService.getIotMeasureBookPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, IotMeasureBookRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出计量器具台账 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-measure-book:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportIotMeasureBookExcel(@Valid IotMeasureBookPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<IotMeasureBookDO> list = iotMeasureBookService.getIotMeasureBookPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "计量器具台账.xls", "数据", IotMeasureBookRespVO.class,
|
|
|
+ BeanUtils.toBean(list, IotMeasureBookRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|