|
|
@@ -0,0 +1,89 @@
|
|
|
+package org.dromara.riskctrl.controller;
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import jakarta.validation.constraints.NotNull;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.dromara.common.core.domain.R;
|
|
|
+import org.dromara.common.log.annotation.Log;
|
|
|
+import org.dromara.common.log.enums.BusinessType;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.web.core.BaseController;
|
|
|
+import org.dromara.riskctrl.domain.bo.SpecialEquipmentBo;
|
|
|
+import org.dromara.riskctrl.domain.vo.SpecialEquipmentVo;
|
|
|
+import org.dromara.riskctrl.service.ISpecialEquipmentService;
|
|
|
+import org.dromara.riskctrl.service.IEquipmentMaintenanceService;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 特种设备
|
|
|
+ *
|
|
|
+ * @author riskctrl
|
|
|
+ */
|
|
|
+@Validated
|
|
|
+@RequiredArgsConstructor
|
|
|
+@RestController
|
|
|
+@RequestMapping("/riskctrl/specialEquipment")
|
|
|
+public class SpecialEquipmentController extends BaseController {
|
|
|
+
|
|
|
+ private final ISpecialEquipmentService specialEquipmentService;
|
|
|
+ private final IEquipmentMaintenanceService equipmentMaintenanceService;
|
|
|
+
|
|
|
+ @SaCheckPermission("riskctrl:specialEquipment:list")
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo<SpecialEquipmentVo> list(SpecialEquipmentBo bo, PageQuery pageQuery) {
|
|
|
+ return specialEquipmentService.selectPageEquipmentList(bo, pageQuery);
|
|
|
+ }
|
|
|
+
|
|
|
+ @SaCheckPermission("riskctrl:specialEquipment:query")
|
|
|
+ @GetMapping(value = "/{equipmentId}")
|
|
|
+ public R<SpecialEquipmentVo> getInfo(@PathVariable @NotNull Long equipmentId) {
|
|
|
+ return R.ok(specialEquipmentService.selectEquipmentById(equipmentId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @SaCheckPermission("riskctrl:specialEquipment:add")
|
|
|
+ @Log(title = "特种设备", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping
|
|
|
+ public R<Void> add(@Validated @RequestBody SpecialEquipmentBo bo) {
|
|
|
+ return toAjax(specialEquipmentService.insertEquipment(bo));
|
|
|
+ }
|
|
|
+
|
|
|
+ @SaCheckPermission("riskctrl:specialEquipment:edit")
|
|
|
+ @Log(title = "特种设备", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ public R<Void> edit(@Validated @RequestBody SpecialEquipmentBo bo) {
|
|
|
+ return toAjax(specialEquipmentService.updateEquipment(bo));
|
|
|
+ }
|
|
|
+
|
|
|
+ @SaCheckPermission("riskctrl:specialEquipment:remove")
|
|
|
+ @Log(title = "特种设备", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{equipmentIds}")
|
|
|
+ public R<Void> remove(@PathVariable Long[] equipmentIds) {
|
|
|
+ return toAjax(specialEquipmentService.deleteEquipmentByIds(equipmentIds));
|
|
|
+ }
|
|
|
+
|
|
|
+ @SaCheckPermission("riskctrl:specialEquipment:list")
|
|
|
+ @GetMapping("/stats")
|
|
|
+ public R<Map<String, Object>> stats() {
|
|
|
+ Map<String, Object> equipStats = specialEquipmentService.selectEquipmentStats();
|
|
|
+ Map<String, Object> maintainStats = equipmentMaintenanceService.selectMaintenanceStats();
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
+ result.put("totalCount", equipStats.getOrDefault("total", 0));
|
|
|
+ result.put("normalCount", equipStats.getOrDefault("total", 0));
|
|
|
+ result.put("maintenanceCount", maintainStats.getOrDefault("pending", 0));
|
|
|
+ result.put("overdueCount", maintainStats.getOrDefault("completed", 0));
|
|
|
+ return R.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @SaCheckPermission("riskctrl:specialEquipment:list")
|
|
|
+ @GetMapping("/distribution")
|
|
|
+ public R<List<Map<String, Object>>> distribution() {
|
|
|
+ return R.ok(specialEquipmentService.selectTypeDistribution());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|