Zimo 1 месяц назад
Родитель
Сommit
93b7311183

+ 94 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/law/QhseLawController.java

@@ -0,0 +1,94 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.law;
+
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo.QhseLawPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo.QhseLawRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo.QhseLawSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.law.QhseLawDO;
+import cn.iocoder.yudao.module.pms.service.qhse.law.QhseLawService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.io.IOException;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+
+@Tag(name = "管理后台 - QHSE法规及行业标准")
+@RestController
+@RequestMapping("/rq/qhse-law")
+@Validated
+public class QhseLawController {
+
+    @Resource
+    private QhseLawService qhseLawService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建QHSE法规及行业标准")
+    @PreAuthorize("@ss.hasPermission('rq:qhse-law:create')")
+    public CommonResult<Long> createQhseLaw(@Valid @RequestBody QhseLawSaveReqVO createReqVO) {
+        return success(qhseLawService.createQhseLaw(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新QHSE法规及行业标准")
+    @PreAuthorize("@ss.hasPermission('rq:qhse-law:update')")
+    public CommonResult<Boolean> updateQhseLaw(@Valid @RequestBody QhseLawSaveReqVO updateReqVO) {
+        qhseLawService.updateQhseLaw(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除QHSE法规及行业标准")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('rq:qhse-law:delete')")
+    public CommonResult<Boolean> deleteQhseLaw(@RequestParam("id") Long id) {
+        qhseLawService.deleteQhseLaw(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得QHSE法规及行业标准")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('rq:qhse-law:query')")
+    public CommonResult<QhseLawRespVO> getQhseLaw(@RequestParam("id") Long id) {
+        QhseLawDO qhseLaw = qhseLawService.getQhseLaw(id);
+        return success(BeanUtils.toBean(qhseLaw, QhseLawRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得QHSE法规及行业标准分页")
+    @PreAuthorize("@ss.hasPermission('rq:qhse-law:query')")
+    public CommonResult<PageResult<QhseLawRespVO>> getQhseLawPage(@Valid QhseLawPageReqVO pageReqVO) {
+        PageResult<QhseLawDO> pageResult = qhseLawService.getQhseLawPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, QhseLawRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出QHSE法规及行业标准 Excel")
+    @PreAuthorize("@ss.hasPermission('rq:qhse-law:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportQhseLawExcel(@Valid QhseLawPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<QhseLawDO> list = qhseLawService.getQhseLawPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "QHSE法规及行业标准.xls", "数据", QhseLawRespVO.class,
+                        BeanUtils.toBean(list, QhseLawRespVO.class));
+    }
+
+}

+ 57 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/law/vo/QhseLawPageReqVO.java

@@ -0,0 +1,57 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+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 = "管理后台 - QHSE法规及行业标准分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class QhseLawPageReqVO extends PageParam {
+
+    @Schema(description = "类型", example = "1")
+    private String type;
+
+    @Schema(description = "法规名称", example = "芋艿")
+    private String name;
+
+    @Schema(description = "发布日期")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] publishDate;
+
+    @Schema(description = "最新修订日期")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] effectiveDate;
+
+    @Schema(description = "发布部门")
+    private String publishDept;
+
+    @Schema(description = "文件编号")
+    private String fileNo;
+
+    @Schema(description = "部门id", example = "7158")
+    private Long deptId;
+
+    @Schema(description = "最新修订日期")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] newDate;
+
+    @Schema(description = "适用条款")
+    private String applicableTerm;
+
+    @Schema(description = "备注", example = "你猜")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

+ 63 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/law/vo/QhseLawRespVO.java

@@ -0,0 +1,63 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - QHSE法规及行业标准 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class QhseLawRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "8392")
+    @ExcelProperty("主键id")
+    private Long id;
+
+    @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    @ExcelProperty("类型")
+    private String type;
+
+    @Schema(description = "法规名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
+    @ExcelProperty("法规名称")
+    private String name;
+
+    @Schema(description = "发布日期")
+    @ExcelProperty("发布日期")
+    private LocalDateTime publishDate;
+
+    @Schema(description = "最新修订日期")
+    @ExcelProperty("最新修订日期")
+    private LocalDateTime effectiveDate;
+
+    @Schema(description = "发布部门")
+    @ExcelProperty("发布部门")
+    private String publishDept;
+
+    @Schema(description = "文件编号")
+    @ExcelProperty("文件编号")
+    private String fileNo;
+
+    @Schema(description = "部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "7158")
+    @ExcelProperty("部门id")
+    private Long deptId;
+
+    @Schema(description = "最新修订日期", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("最新修订日期")
+    private LocalDateTime newDate;
+
+    @Schema(description = "适用条款")
+    @ExcelProperty("适用条款")
+    private String applicableTerm;
+
+    @Schema(description = "备注", example = "你猜")
+    @ExcelProperty("备注")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+}

+ 51 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/law/vo/QhseLawSaveReqVO.java

@@ -0,0 +1,51 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - QHSE法规及行业标准新增/修改 Request VO")
+@Data
+public class QhseLawSaveReqVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "8392")
+    private Long id;
+
+    @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    @NotEmpty(message = "类型不能为空")
+    private String type;
+
+    @Schema(description = "法规名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
+    @NotEmpty(message = "法规名称不能为空")
+    private String name;
+
+    @Schema(description = "发布日期")
+    private LocalDateTime publishDate;
+
+    @Schema(description = "最新修订日期")
+    private LocalDateTime effectiveDate;
+
+    @Schema(description = "发布部门")
+    private String publishDept;
+
+    @Schema(description = "文件编号")
+    private String fileNo;
+
+    @Schema(description = "部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "7158")
+    @NotNull(message = "部门id不能为空")
+    private Long deptId;
+
+    @Schema(description = "最新修订日期", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "最新修订日期不能为空")
+    private LocalDateTime newDate;
+
+    @Schema(description = "适用条款")
+    private String applicableTerm;
+
+    @Schema(description = "备注", example = "你猜")
+    private String remark;
+
+}

+ 72 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/law/QhseLawDO.java

@@ -0,0 +1,72 @@
+package cn.iocoder.yudao.module.pms.dal.dataobject.qhse.law;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+import java.time.LocalDateTime;
+
+/**
+ * QHSE法规及行业标准 DO
+ *
+ * @author 超级管理员
+ */
+@TableName("rq_qhse_law")
+@KeySequence("rq_qhse_law_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class QhseLawDO extends BaseDO {
+
+    /**
+     * 主键id
+     */
+    @TableId
+    private Long id;
+    /**
+     * 类型
+     */
+    private String type;
+    /**
+     * 法规名称
+     */
+    private String name;
+    /**
+     * 发布日期
+     */
+    private LocalDateTime publishDate;
+    /**
+     * 最新修订日期
+     */
+    private LocalDateTime effectiveDate;
+    /**
+     * 发布部门
+     */
+    private String publishDept;
+    /**
+     * 文件编号
+     */
+    private String fileNo;
+    /**
+     * 部门id
+     */
+    private Long deptId;
+    /**
+     * 最新修订日期
+     */
+    private LocalDateTime newDate;
+    /**
+     * 适用条款
+     */
+    private String applicableTerm;
+    /**
+     * 备注
+     */
+    private String remark;
+
+}

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/report/QhseMonthReportDO.java

@@ -30,6 +30,9 @@ public class QhseMonthReportDO extends BaseDO {
      * 月报名称
      */
     private String title;
+    /**
+     * 年月
+     */
     private String yearMonths;
     /**
      * 部门id

+ 34 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/qhse/law/QhseLawMapper.java

@@ -0,0 +1,34 @@
+package cn.iocoder.yudao.module.pms.dal.mysql.qhse.law;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo.QhseLawPageReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.law.QhseLawDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * QHSE法规及行业标准 Mapper
+ *
+ * @author 超级管理员
+ */
+@Mapper
+public interface QhseLawMapper extends BaseMapperX<QhseLawDO> {
+
+    default PageResult<QhseLawDO> selectPage(QhseLawPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<QhseLawDO>()
+                .eqIfPresent(QhseLawDO::getType, reqVO.getType())
+                .likeIfPresent(QhseLawDO::getName, reqVO.getName())
+                .betweenIfPresent(QhseLawDO::getPublishDate, reqVO.getPublishDate())
+                .betweenIfPresent(QhseLawDO::getEffectiveDate, reqVO.getEffectiveDate())
+                .eqIfPresent(QhseLawDO::getPublishDept, reqVO.getPublishDept())
+                .eqIfPresent(QhseLawDO::getFileNo, reqVO.getFileNo())
+                .eqIfPresent(QhseLawDO::getDeptId, reqVO.getDeptId())
+                .betweenIfPresent(QhseLawDO::getNewDate, reqVO.getNewDate())
+                .eqIfPresent(QhseLawDO::getApplicableTerm, reqVO.getApplicableTerm())
+                .eqIfPresent(QhseLawDO::getRemark, reqVO.getRemark())
+                .betweenIfPresent(QhseLawDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(QhseLawDO::getId));
+    }
+
+}

+ 55 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/law/QhseLawService.java

@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.module.pms.service.qhse.law;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo.QhseLawPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo.QhseLawSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.law.QhseLawDO;
+
+import javax.validation.Valid;
+
+/**
+ * QHSE法规及行业标准 Service 接口
+ *
+ * @author 超级管理员
+ */
+public interface QhseLawService {
+
+    /**
+     * 创建QHSE法规及行业标准
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createQhseLaw(@Valid QhseLawSaveReqVO createReqVO);
+
+    /**
+     * 更新QHSE法规及行业标准
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateQhseLaw(@Valid QhseLawSaveReqVO updateReqVO);
+
+    /**
+     * 删除QHSE法规及行业标准
+     *
+     * @param id 编号
+     */
+    void deleteQhseLaw(Long id);
+
+    /**
+     * 获得QHSE法规及行业标准
+     *
+     * @param id 编号
+     * @return QHSE法规及行业标准
+     */
+    QhseLawDO getQhseLaw(Long id);
+
+    /**
+     * 获得QHSE法规及行业标准分页
+     *
+     * @param pageReqVO 分页查询
+     * @return QHSE法规及行业标准分页
+     */
+    PageResult<QhseLawDO> getQhseLawPage(QhseLawPageReqVO pageReqVO);
+
+}

+ 72 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/law/QhseLawServiceImpl.java

@@ -0,0 +1,72 @@
+package cn.iocoder.yudao.module.pms.service.qhse.law;
+
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo.QhseLawPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.law.vo.QhseLawSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.law.QhseLawDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.law.QhseLawMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+
+/**
+ * QHSE法规及行业标准 Service 实现类
+ *
+ * @author 超级管理员
+ */
+@Service
+@Validated
+public class QhseLawServiceImpl implements QhseLawService {
+
+    @Resource
+    private QhseLawMapper qhseLawMapper;
+
+    @Override
+    public Long createQhseLaw(QhseLawSaveReqVO createReqVO) {
+        // 插入
+        QhseLawDO qhseLaw = BeanUtils.toBean(createReqVO, QhseLawDO.class);
+        qhseLaw.setDeleted(false);
+        qhseLawMapper.insert(qhseLaw);
+        // 返回
+        return qhseLaw.getId();
+    }
+
+    @Override
+    public void updateQhseLaw(QhseLawSaveReqVO updateReqVO) {
+        // 校验存在
+        validateQhseLawExists(updateReqVO.getId());
+        // 更新
+        QhseLawDO updateObj = BeanUtils.toBean(updateReqVO, QhseLawDO.class);
+        qhseLawMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteQhseLaw(Long id) {
+        // 校验存在
+        validateQhseLawExists(id);
+        // 删除
+        qhseLawMapper.deleteById(id);
+    }
+
+    private void validateQhseLawExists(Long id) {
+        if (qhseLawMapper.selectById(id) == null) {
+            throw exception(new ErrorCode(1, "不存在"));
+        }
+    }
+
+    @Override
+    public QhseLawDO getQhseLaw(Long id) {
+        return qhseLawMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<QhseLawDO> getQhseLawPage(QhseLawPageReqVO pageReqVO) {
+        return qhseLawMapper.selectPage(pageReqVO);
+    }
+
+}