Эх сурвалжийг харах

调用设备基础信息、设备维护记录、设备状态、设备类别的增删改查

zlm 7 сар өмнө
parent
commit
d3af9443f4

+ 114 - 0
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/base/EquipmentBaseController.java

@@ -0,0 +1,114 @@
+package com.zksy.web.controller.base;
+
+
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zksy.base.domain.EquipmentBase;
+import com.zksy.base.service.EquipmentBaseService;
+import com.zksy.common.annotation.Anonymous;
+import com.zksy.common.annotation.Log;
+import com.zksy.common.core.domain.AjaxResult;
+import com.zksy.common.enums.BusinessType;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 设备基础信息
+ */
+@Slf4j
+@RestController
+@RequestMapping("/EquipmentBase")
+public class EquipmentBaseController {
+
+    @Autowired
+    private EquipmentBaseService service;
+
+    @GetMapping("/getById/{id}")
+    @ApiOperation(value = "设备基础信息搜索getById")
+    @Anonymous
+    public AjaxResult getById(@PathVariable String id) {
+        EquipmentBase equipmentBase = service.getById(id);
+        if(equipmentBase==null){
+            return AjaxResult.error("该设备信息不存在");
+        }
+        return AjaxResult.success(equipmentBase);
+    }
+
+    //TODO 待优化
+    @Anonymous
+    @GetMapping("/findByPage")
+    @ApiOperation(value = "设备基础信息分页")
+    public Page findByPage(long pageNum, long pageSize,
+                           @RequestParam(required = false)String equipmentCode,
+                           @RequestParam(required = false)String equipmentName,
+                           @RequestParam(required = false)String equipmentModel,
+                           @RequestParam(required = false)String manufacturer) throws Exception {
+        return service.findByPage(pageNum, pageSize, equipmentCode,equipmentName,equipmentModel,manufacturer);
+    }
+
+    @Anonymous
+    @GetMapping("/getList")
+    @ApiOperation(value = "查询所有设备基础信息")
+    public AjaxResult getList() throws Exception {
+        return AjaxResult.success(service.list());
+    }
+
+    @Anonymous
+    @PostMapping("/save")
+    @ApiOperation(value = "新增设备基础信息")
+    @Log(title = "新增设备基础信息", businessType = BusinessType.INSERT)
+    public AjaxResult save(@RequestBody EquipmentBase entity) {
+        boolean saved = service.saveWithCheck(entity);
+        return saved ? AjaxResult.success("新增成功",saved)
+                : AjaxResult.error("新增失败",saved);
+    }
+
+    @Anonymous
+    @PostMapping("/saveBatch")
+    @ApiOperation(value = "设备基础信息批量新增")
+    @Log(title = "批量新增设备基础信息", businessType = BusinessType.INSERT)
+    public AjaxResult saveBatch(@RequestBody List<EquipmentBase> entityList) {
+        // 基础校验:列表不能为空
+        if (CollectionUtils.isEmpty(entityList)) {
+            return AjaxResult.error("批量新增失败:设备列表不能为空");
+        }
+
+        boolean saved = service.saveBatchWithCheck(entityList);
+        return saved ? AjaxResult.success("新增成功",saved)
+                : AjaxResult.error("新增失败",saved);
+    }
+
+    @Anonymous
+    @PutMapping("/updateById")
+    @ApiOperation(value = "设备基础信息修改")
+    @Log(title = "修改设备基础信息", businessType = BusinessType.UPDATE)
+    public AjaxResult updateById(@RequestBody EquipmentBase entity) {
+        boolean updated = service.updateWithCheck(entity);
+        return updated ? AjaxResult.success("修改成功",updated)
+                : AjaxResult.error("修改失败",updated);
+    }
+
+    @Anonymous
+    @DeleteMapping("/deleteById")
+    @ApiOperation(value = "设备基础信息删除")
+    @Log(title = "删除设备基础信息", businessType = BusinessType.DELETE)
+    public AjaxResult deleteById(String id) {
+        boolean deleted = service.removeWithCheck(id);
+        return deleted ? AjaxResult.success("删除成功",deleted)
+                : AjaxResult.error("删除失败",deleted);
+    }
+
+    @Anonymous
+    @DeleteMapping("/deleteBatchById")
+    @ApiOperation(value = "设备基础信息批量删除")
+    @Log(title = "设备基础信息批量删除", businessType = BusinessType.DELETE)
+    public AjaxResult deleteBatchById(@RequestParam List<String> ids) {
+        boolean deleted = service.removeBatchWithCheck(ids);
+        return deleted ? AjaxResult.success("删除成功",deleted)
+                : AjaxResult.error("删除失败",deleted);
+    }
+}

+ 104 - 0
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/base/EquipmentMaintainController.java

@@ -0,0 +1,104 @@
+package com.zksy.web.controller.base;
+
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zksy.base.domain.EquipmentMaintain;
+import com.zksy.base.service.EquipmentMaintainService;
+import com.zksy.common.annotation.Log;
+import com.zksy.common.core.domain.AjaxResult;
+import com.zksy.common.enums.BusinessType;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 设备维护记录
+ */
+@Slf4j
+@RestController
+@RequestMapping("/EquipmentMaintain")
+public class EquipmentMaintainController {
+
+    @Autowired
+    private EquipmentMaintainService service;
+
+    @GetMapping("/getById/{id}")
+    @ApiOperation(value = "设备维护记录搜索getById")
+    public AjaxResult getById(@PathVariable String id) {
+        EquipmentMaintain equipmentMaintain = service.getById(id);
+        if(equipmentMaintain==null){
+            return AjaxResult.error("该设备维护记录不存在");
+        }
+        return AjaxResult.success(equipmentMaintain);
+    }
+
+    //TODO 查询条件待完善
+    @GetMapping("/findByPage")
+    @ApiOperation(value = "设备维护记录分页")
+    public Page findByPage(long pageNum, long pageSize,
+                           @RequestParam(required = false)String maintainId,
+                           @RequestParam(required = false)String equipmentId,
+                           @RequestParam(required = false)String maintainType,
+                           @RequestParam(required = false)String maintainPerson) throws Exception {
+        return service.findByPage(pageNum, pageSize, maintainId,equipmentId,maintainType,maintainPerson);
+    }
+
+    @GetMapping("/getList")
+    @ApiOperation(value = "查询所有设备维护记录")
+    public AjaxResult getList() throws Exception {
+        return AjaxResult.success(service.list());
+    }
+
+    @PostMapping("/save")
+    @ApiOperation(value = "新增设备维护记录")
+    @Log(title = "新增设备维护记录", businessType = BusinessType.INSERT)
+    public AjaxResult save(@RequestBody EquipmentMaintain entity) {
+        boolean saved = service.saveWithCheck(entity);
+        return saved ? AjaxResult.success("新增成功",saved)
+                : AjaxResult.error("新增失败",saved);
+    }
+
+    @PostMapping("/saveBatch")
+    @ApiOperation(value = "设备维护记录批量新增")
+    @Log(title = "批量新增设备维护记录", businessType = BusinessType.INSERT)
+    public AjaxResult saveBatch(@RequestBody List<EquipmentMaintain> entityList) {
+        // 基础校验:列表不能为空
+        if (CollectionUtils.isEmpty(entityList)) {
+            return AjaxResult.error("批量新增失败:设备维护记录列表不能为空");
+        }
+
+        boolean saved = service.saveBatchWithCheck(entityList);
+        return saved ? AjaxResult.success("新增成功",saved)
+                : AjaxResult.error("新增失败",saved);
+    }
+
+    @PutMapping("/updateById")
+    @ApiOperation(value = "设备维护记录修改")
+    @Log(title = "修改设备维护记录", businessType = BusinessType.UPDATE)
+    public AjaxResult updateById(@RequestBody EquipmentMaintain entity) {
+        boolean updated = service.updateWithCheck(entity);
+        return updated ? AjaxResult.success("修改成功",updated)
+                : AjaxResult.error("修改失败",updated);
+    }
+
+    @DeleteMapping("/deleteById")
+    @ApiOperation(value = "设备维护记录删除")
+    @Log(title = "删除设备维护记录", businessType = BusinessType.DELETE)
+    public AjaxResult deleteById(String id) {
+        boolean deleted = service.removeById(id);
+        return deleted ? AjaxResult.success("删除成功",deleted)
+                : AjaxResult.error("删除失败",deleted);
+    }
+
+    @DeleteMapping("/deleteBatchById")
+    @ApiOperation(value = "设备维护记录批量删除")
+    @Log(title = "设备维护记录批量删除", businessType = BusinessType.DELETE)
+    public AjaxResult deleteBatchById(@RequestParam List<String> ids) {
+        boolean deleted = service.removeByIds(ids);
+        return deleted ? AjaxResult.success("删除成功",deleted)
+                : AjaxResult.error("删除失败",deleted);
+    }
+}

+ 105 - 0
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/base/EquipmentStatusController.java

@@ -0,0 +1,105 @@
+package com.zksy.web.controller.base;
+
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zksy.base.domain.EquipmentStatus;
+import com.zksy.base.service.EquipmentStatusService;
+import com.zksy.common.annotation.Log;
+import com.zksy.common.core.domain.AjaxResult;
+import com.zksy.common.enums.BusinessType;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 设备状态
+ */
+@Slf4j
+@RestController
+@RequestMapping("/EquipmentStatus")
+public class EquipmentStatusController {
+
+    @Autowired
+    private EquipmentStatusService service;
+
+    @GetMapping("/getById/{id}")
+    @ApiOperation(value = "设备状态搜索getById")
+    public AjaxResult getById(@PathVariable String id) {
+        EquipmentStatus equipmentStatus = service.getById(id);
+        if(equipmentStatus==null){
+            return AjaxResult.error("该设备状态不存在");
+        }
+        return AjaxResult.success(equipmentStatus);
+    }
+
+    @GetMapping("/findByPage")
+    @ApiOperation(value = "设备状态分页")
+    public Page findByPage(long pageNum, long pageSize,
+                           @RequestParam(required = false) String statusId,
+                           @RequestParam(required = false) String equipmentId,
+                           @RequestParam(required = false) Integer currentStatus,
+                           @RequestParam(required = false) Integer alarmStatus,
+                           @RequestParam(required = false) Integer onlineStatus,
+                           @RequestParam(required = false) Long userId) throws Exception {
+        return service.findByPage(pageNum, pageSize, statusId,equipmentId,currentStatus,alarmStatus,onlineStatus,userId);
+    }
+
+    @GetMapping("/getList")
+    @ApiOperation(value = "查询所有设备状态")
+    public AjaxResult getList() throws Exception {
+        return AjaxResult.success(service.list());
+    }
+
+    @PostMapping("/save")
+    @ApiOperation(value = "新增设备状态")
+    @Log(title = "新增设备状态", businessType = BusinessType.INSERT)
+    public AjaxResult save(@RequestBody EquipmentStatus entity) {
+        boolean saved = service.saveWithCheck(entity);
+        return saved ? AjaxResult.success("新增成功",saved)
+                : AjaxResult.error("新增失败",saved);
+    }
+
+    @PostMapping("/saveBatch")
+    @ApiOperation(value = "设备状态批量新增")
+    @Log(title = "批量新增设备状态", businessType = BusinessType.INSERT)
+    public AjaxResult saveBatch(@RequestBody List<EquipmentStatus> entityList) {
+        // 基础校验:列表不能为空
+        if (CollectionUtils.isEmpty(entityList)) {
+            return AjaxResult.error("批量新增失败:设备状态列表不能为空");
+        }
+
+        boolean saved = service.saveBatchWithCheck(entityList);
+        return saved ? AjaxResult.success("新增成功",saved)
+                : AjaxResult.error("新增失败",saved);
+    }
+
+    @PutMapping("/updateById")
+    @ApiOperation(value = "设备状态修改")
+    @Log(title = "修改设备状态", businessType = BusinessType.UPDATE)
+    public AjaxResult updateById(@RequestBody EquipmentStatus entity) {
+        boolean updated = service.updateWithCheck(entity);
+        return updated ? AjaxResult.success("修改成功",updated)
+                : AjaxResult.error("修改失败",updated);
+    }
+
+    @DeleteMapping("/deleteById")
+    @ApiOperation(value = "设备状态删除")
+    @Log(title = "删除设备状态", businessType = BusinessType.DELETE)
+    public AjaxResult deleteById(String id) {
+        boolean deleted = service.removeById(id);
+        return deleted ? AjaxResult.success("删除成功",deleted)
+                : AjaxResult.error("删除失败",deleted);
+    }
+
+    @DeleteMapping("/deleteBatchById")
+    @ApiOperation(value = "设备状态批量删除")
+    @Log(title = "设备状态批量删除", businessType = BusinessType.DELETE)
+    public AjaxResult deleteBatchById(@RequestParam List<String> ids) {
+        boolean deleted = service.removeByIds(ids);
+        return deleted ? AjaxResult.success("删除成功",deleted)
+                : AjaxResult.error("删除失败",deleted);
+    }
+}

+ 99 - 0
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/base/EquipmentTypeController.java

@@ -0,0 +1,99 @@
+package com.zksy.web.controller.base;
+
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zksy.base.domain.EquipmentType;
+import com.zksy.base.service.EquipmentTypeService;
+import com.zksy.common.annotation.Log;
+import com.zksy.common.core.domain.AjaxResult;
+import com.zksy.common.enums.BusinessType;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Slf4j
+@RestController
+@RequestMapping("/EquipmentType")
+public class EquipmentTypeController {
+
+    @Autowired
+    private EquipmentTypeService service;
+
+    @GetMapping("/getById/{id}")
+    @ApiOperation(value = "设备类别搜索getById")
+    public AjaxResult getById(@PathVariable String id) {
+        EquipmentType equipmentType = service.getById(id);
+        if(equipmentType==null){
+            return AjaxResult.error("该设备类别不存在");
+        }
+        return AjaxResult.success(equipmentType);
+    }
+
+    @GetMapping("/findByPage")
+    @ApiOperation(value = "设备类别分页")
+    public Page findByPage(long pageNum, long pageSize,
+                           @RequestParam(required = false)String typeId,
+                           @RequestParam(required = false)String typeName,
+                           @RequestParam(required = false)String parentTypeId) throws Exception {
+        return service.findByPage(pageNum, pageSize, typeId,typeName,parentTypeId);
+    }
+
+    @GetMapping("/getList")
+    @ApiOperation(value = "查询所有设备类别")
+    public AjaxResult getList() throws Exception {
+        return AjaxResult.success(service.list());
+    }
+
+    @PostMapping("/save")
+    @ApiOperation(value = "新增设备类别")
+    @Log(title = "新增设备类别", businessType = BusinessType.INSERT)
+    public AjaxResult save(@RequestBody EquipmentType entity) {
+        boolean saved = service.saveWithCheck(entity);
+        return saved ? AjaxResult.success("新增成功",saved)
+                : AjaxResult.error("新增失败",saved);
+    }
+
+    @PostMapping("/saveBatch")
+    @ApiOperation(value = "设备类别批量新增")
+    @Log(title = "批量新增设备类别", businessType = BusinessType.INSERT)
+    public AjaxResult saveBatch(@RequestBody List<EquipmentType> entityList) {
+        // 基础校验:列表不能为空
+        if (CollectionUtils.isEmpty(entityList)) {
+            return AjaxResult.error("批量新增失败:设备类别列表不能为空");
+        }
+
+        boolean saved = service.saveBatchWithCheck(entityList);
+        return saved ? AjaxResult.success("新增成功",saved)
+                : AjaxResult.error("新增失败",saved);
+    }
+
+    @PutMapping("/updateById")
+    @ApiOperation(value = "设备类别修改")
+    @Log(title = "修改设备类别", businessType = BusinessType.UPDATE)
+    public AjaxResult updateById(@RequestBody EquipmentType entity) {
+        boolean updated = service.updateWithCheck(entity);
+        return updated ? AjaxResult.success("修改成功",updated)
+                : AjaxResult.error("修改失败",updated);
+    }
+
+    @DeleteMapping("/deleteById")
+    @ApiOperation(value = "设备类别删除")
+    @Log(title = "删除设备类别", businessType = BusinessType.DELETE)
+    public AjaxResult deleteById(String id) {
+        boolean deleted = service.removeWithCheck(id);
+        return deleted ? AjaxResult.success("删除成功",deleted)
+                : AjaxResult.error("删除失败",deleted);
+    }
+
+    @DeleteMapping("/deleteBatchById")
+    @ApiOperation(value = "设备类别批量删除")
+    @Log(title = "设备类别批量删除", businessType = BusinessType.DELETE)
+    public AjaxResult deleteBatchById(@RequestParam List<String> ids) {
+        boolean deleted = service.removeBatchWithCheck(ids);
+        return deleted ? AjaxResult.success("删除成功",deleted)
+                : AjaxResult.error("删除失败",deleted);
+    }
+}