Ver Fonte

Merge remote-tracking branch 'origin/master'

zhangcl há 1 semana atrás
pai
commit
34ca382794

+ 98 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/danger/IotDangerSourceController.java

@@ -0,0 +1,98 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.danger;
+
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourcePageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourceRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourceSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.danger.IotDangerSourceDO;
+import cn.iocoder.yudao.module.pms.service.qhse.danger.IotDangerSourceService;
+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-danger-source")
+@Validated
+public class IotDangerSourceController {
+
+    @Resource
+    private IotDangerSourceService iotDangerSourceService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建危险源")
+    @PreAuthorize("@ss.hasPermission('rq:iot-danger-source:create')")
+    public CommonResult<Long> createIotDangerSource(@Valid @RequestBody IotDangerSourceSaveReqVO createReqVO) {
+        return success(iotDangerSourceService.createIotDangerSource(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新危险源")
+    @PreAuthorize("@ss.hasPermission('rq:iot-danger-source:update')")
+    public CommonResult<Boolean> updateIotDangerSource(@Valid @RequestBody IotDangerSourceSaveReqVO updateReqVO) {
+        iotDangerSourceService.updateIotDangerSource(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除危险源")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('rq:iot-danger-source:delete')")
+    public CommonResult<Boolean> deleteIotDangerSource(@RequestParam("id") Long id) {
+        iotDangerSourceService.deleteIotDangerSource(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得危险源")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('rq:iot-danger-source:query')")
+    public CommonResult<IotDangerSourceRespVO> getIotDangerSource(@RequestParam("id") Long id) {
+        IotDangerSourceDO iotDangerSource = iotDangerSourceService.getIotDangerSource(id);
+        return success(BeanUtils.toBean(iotDangerSource, IotDangerSourceRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得危险源分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-danger-source:query')")
+    public CommonResult<PageResult<IotDangerSourceRespVO>> getIotDangerSourcePage(@Valid IotDangerSourcePageReqVO pageReqVO) {
+        PageResult<IotDangerSourceDO> pageResult = iotDangerSourceService.getIotDangerSourcePage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, IotDangerSourceRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出危险源 Excel")
+    @PreAuthorize("@ss.hasPermission('rq:iot-danger-source:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportIotDangerSourceExcel(@Valid IotDangerSourcePageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<IotDangerSourceDO> list = iotDangerSourceService.getIotDangerSourcePage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "危险源.xls", "数据", IotDangerSourceRespVO.class,
+                        BeanUtils.toBean(list, IotDangerSourceRespVO.class));
+    }
+
+}

+ 49 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/danger/vo/IotDangerSourcePageReqVO.java

@@ -0,0 +1,49 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 危险源分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class IotDangerSourcePageReqVO extends PageParam {
+
+    @Schema(description = "区域/位置")
+    private String region;
+
+    @Schema(description = "危害因素描述", example = "你猜")
+    private String elementDescription;
+
+    @Schema(description = "可能导致的后果")
+    private String maybeResult;
+
+    @Schema(description = "风险评价可能性")
+    private String evalKn;
+
+    @Schema(description = "风险评价严重性")
+    private String evalYz;
+
+    @Schema(description = "风险评价风险值")
+    private String evalFxz;
+
+    @Schema(description = "风险等级")
+    private String riskGrade;
+
+    @Schema(description = "控制措施")
+    private String controlMethod;
+
+    @Schema(description = "备注", example = "随便")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

+ 59 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/danger/vo/IotDangerSourceRespVO.java

@@ -0,0 +1,59 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+import com.alibaba.excel.annotation.*;
+
+@Schema(description = "管理后台 - 危险源 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IotDangerSourceRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11742")
+    @ExcelProperty("主键id")
+    private Long id;
+
+    @Schema(description = "区域/位置", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("区域/位置")
+    private String region;
+
+    @Schema(description = "危害因素描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
+    @ExcelProperty("危害因素描述")
+    private String elementDescription;
+
+    @Schema(description = "可能导致的后果")
+    @ExcelProperty("可能导致的后果")
+    private String maybeResult;
+
+    @Schema(description = "风险评价可能性")
+    @ExcelProperty("风险评价可能性")
+    private String evalKn;
+
+    @Schema(description = "风险评价严重性")
+    @ExcelProperty("风险评价严重性")
+    private String evalYz;
+
+    @Schema(description = "风险评价风险值")
+    @ExcelProperty("风险评价风险值")
+    private String evalFxz;
+
+    @Schema(description = "风险等级", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("风险等级")
+    private String riskGrade;
+
+    @Schema(description = "控制措施")
+    @ExcelProperty("控制措施")
+    private String controlMethod;
+
+    @Schema(description = "备注", example = "随便")
+    @ExcelProperty("备注")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+}

+ 46 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/danger/vo/IotDangerSourceSaveReqVO.java

@@ -0,0 +1,46 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+
+import javax.validation.constraints.NotEmpty;
+import java.util.*;
+
+@Schema(description = "管理后台 - 危险源新增/修改 Request VO")
+@Data
+public class IotDangerSourceSaveReqVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11742")
+    private Long id;
+
+    @Schema(description = "区域/位置", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "区域/位置不能为空")
+    private String region;
+
+    @Schema(description = "危害因素描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
+    @NotEmpty(message = "危害因素描述不能为空")
+    private String elementDescription;
+
+    @Schema(description = "可能导致的后果")
+    private String maybeResult;
+
+    @Schema(description = "风险评价可能性")
+    private String evalKn;
+
+    @Schema(description = "风险评价严重性")
+    private String evalYz;
+
+    @Schema(description = "风险评价风险值")
+    private String evalFxz;
+
+    @Schema(description = "风险等级", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "风险等级不能为空")
+    private String riskGrade;
+
+    @Schema(description = "控制措施")
+    private String controlMethod;
+
+    @Schema(description = "备注", example = "随便")
+    private String remark;
+
+}

+ 67 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/danger/IotDangerSourceDO.java

@@ -0,0 +1,67 @@
+package cn.iocoder.yudao.module.pms.dal.dataobject.qhse.danger;
+
+import lombok.*;
+import java.util.*;
+import java.time.LocalDateTime;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 危险源 DO
+ *
+ * @author 超级管理员
+ */
+@TableName("rq_iot_danger_source")
+@KeySequence("rq_iot_danger_source_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class IotDangerSourceDO extends BaseDO {
+
+    /**
+     * 主键id
+     */
+    @TableId
+    private Long id;
+    /**
+     * 区域/位置
+     */
+    private String region;
+    /**
+     * 危害因素描述
+     */
+    private String elementDescription;
+    /**
+     * 可能导致的后果
+     */
+    private String maybeResult;
+    /**
+     * 风险评价可能性
+     */
+    private String evalKn;
+    /**
+     * 风险评价严重性
+     */
+    private String evalYz;
+    /**
+     * 风险评价风险值
+     */
+    private String evalFxz;
+    /**
+     * 风险等级
+     */
+    private String riskGrade;
+    /**
+     * 控制措施
+     */
+    private String controlMethod;
+    /**
+     * 备注
+     */
+    private String remark;
+
+}

+ 35 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/qhse/danger/IotDangerSourceMapper.java

@@ -0,0 +1,35 @@
+package cn.iocoder.yudao.module.pms.dal.mysql.qhse.danger;
+
+import java.util.*;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourcePageReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.danger.IotDangerSourceDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 危险源 Mapper
+ *
+ * @author 超级管理员
+ */
+@Mapper
+public interface IotDangerSourceMapper extends BaseMapperX<IotDangerSourceDO> {
+
+    default PageResult<IotDangerSourceDO> selectPage(IotDangerSourcePageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<IotDangerSourceDO>()
+                .eqIfPresent(IotDangerSourceDO::getRegion, reqVO.getRegion())
+                .eqIfPresent(IotDangerSourceDO::getElementDescription, reqVO.getElementDescription())
+                .eqIfPresent(IotDangerSourceDO::getMaybeResult, reqVO.getMaybeResult())
+                .eqIfPresent(IotDangerSourceDO::getEvalKn, reqVO.getEvalKn())
+                .eqIfPresent(IotDangerSourceDO::getEvalYz, reqVO.getEvalYz())
+                .eqIfPresent(IotDangerSourceDO::getEvalFxz, reqVO.getEvalFxz())
+                .eqIfPresent(IotDangerSourceDO::getRiskGrade, reqVO.getRiskGrade())
+                .eqIfPresent(IotDangerSourceDO::getControlMethod, reqVO.getControlMethod())
+                .eqIfPresent(IotDangerSourceDO::getRemark, reqVO.getRemark())
+                .betweenIfPresent(IotDangerSourceDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(IotDangerSourceDO::getId));
+    }
+
+}

+ 57 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/danger/IotDangerSourceService.java

@@ -0,0 +1,57 @@
+package cn.iocoder.yudao.module.pms.service.qhse.danger;
+
+import java.util.*;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourcePageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourceSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.danger.IotDangerSourceDO;
+
+import javax.validation.Valid;
+
+/**
+ * 危险源 Service 接口
+ *
+ * @author 超级管理员
+ */
+public interface IotDangerSourceService {
+
+    /**
+     * 创建危险源
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createIotDangerSource(@Valid IotDangerSourceSaveReqVO createReqVO);
+
+    /**
+     * 更新危险源
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateIotDangerSource(@Valid IotDangerSourceSaveReqVO updateReqVO);
+
+    /**
+     * 删除危险源
+     *
+     * @param id 编号
+     */
+    void deleteIotDangerSource(Long id);
+
+    /**
+     * 获得危险源
+     *
+     * @param id 编号
+     * @return 危险源
+     */
+    IotDangerSourceDO getIotDangerSource(Long id);
+
+    /**
+     * 获得危险源分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 危险源分页
+     */
+    PageResult<IotDangerSourceDO> getIotDangerSourcePage(IotDangerSourcePageReqVO pageReqVO);
+
+}

+ 77 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/danger/IotDangerSourceServiceImpl.java

@@ -0,0 +1,77 @@
+package cn.iocoder.yudao.module.pms.service.qhse.danger;
+
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourcePageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourceSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.danger.IotDangerSourceDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.danger.IotDangerSourceMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+
+
+import javax.annotation.Resource;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+
+/**
+ * 危险源 Service 实现类
+ *
+ * @author 超级管理员
+ */
+@Service
+@Validated
+public class IotDangerSourceServiceImpl implements IotDangerSourceService {
+
+    @Resource
+    private IotDangerSourceMapper iotDangerSourceMapper;
+
+    @Override
+    public Long createIotDangerSource(IotDangerSourceSaveReqVO createReqVO) {
+        // 插入
+        IotDangerSourceDO iotDangerSource = BeanUtils.toBean(createReqVO, IotDangerSourceDO.class);
+        iotDangerSource.setDeleted(false);
+        iotDangerSourceMapper.insert(iotDangerSource);
+        // 返回
+        return iotDangerSource.getId();
+    }
+
+    @Override
+    public void updateIotDangerSource(IotDangerSourceSaveReqVO updateReqVO) {
+        // 校验存在
+        validateIotDangerSourceExists(updateReqVO.getId());
+        // 更新
+        IotDangerSourceDO updateObj = BeanUtils.toBean(updateReqVO, IotDangerSourceDO.class);
+        iotDangerSourceMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteIotDangerSource(Long id) {
+        // 校验存在
+        validateIotDangerSourceExists(id);
+        // 删除
+        iotDangerSourceMapper.deleteById(id);
+    }
+
+    private void validateIotDangerSourceExists(Long id) {
+        if (iotDangerSourceMapper.selectById(id) == null) {
+            throw exception(new ErrorCode(222,"不存在"));
+        }
+    }
+
+    @Override
+    public IotDangerSourceDO getIotDangerSource(Long id) {
+        return iotDangerSourceMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<IotDangerSourceDO> getIotDangerSourcePage(IotDangerSourcePageReqVO pageReqVO) {
+        return iotDangerSourceMapper.selectPage(pageReqVO);
+    }
+
+}