Browse Source

人员证书处理

Zimo 22 giờ trước cách đây
mục cha
commit
49ac6ec6fc

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/cert/IotMeasureCertController.java

@@ -161,7 +161,7 @@ public class IotMeasureCertController {
         IotMeasureCertPageReqVO reqVO = new IotMeasureCertPageReqVO();
         reqVO.setExpired(true);
         long expired = iotMeasureCertMapper.selectCountByDeptAndExpireAndWarn(reqVO, ids);
-        reqVO.setExpired(false);
+        reqVO.setExpired(null);
         reqVO.setAlertWarn(true);
         //90天预警
         long warn = iotMeasureCertMapper.selectCountByDeptAndExpireAndWarn(reqVO, ids);

+ 127 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/cert/QhseOrgCertController.java

@@ -0,0 +1,127 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.cert;
+
+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.cert.vo.QhseOrgCertPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.cert.vo.QhseOrgCertRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.cert.vo.QhseOrgCertSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.cert.QhseOrgCertDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.cert.QhseOrgCertMapper;
+import cn.iocoder.yudao.module.pms.service.qhse.cert.QhseOrgCertService;
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
+import com.google.common.collect.ImmutableMap;
+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.beans.factory.annotation.Autowired;
+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.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+
+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-org-cert")
+@Validated
+public class QhseOrgCertController {
+
+    @Resource
+    private QhseOrgCertService qhseOrgCertService;
+    @Autowired
+    private DeptService deptService;
+    @Autowired
+    private QhseOrgCertMapper qhseOrgCertMapper;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建QHSE组织证书管理")
+    @PreAuthorize("@ss.hasPermission('rq:qhse-org-cert:create')")
+    public CommonResult<Long> createQhseOrgCert(@Valid @RequestBody QhseOrgCertSaveReqVO createReqVO) {
+        return success(qhseOrgCertService.createQhseOrgCert(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新QHSE组织证书管理")
+    @PreAuthorize("@ss.hasPermission('rq:qhse-org-cert:update')")
+    public CommonResult<Boolean> updateQhseOrgCert(@Valid @RequestBody QhseOrgCertSaveReqVO updateReqVO) {
+        qhseOrgCertService.updateQhseOrgCert(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除QHSE组织证书管理")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('rq:qhse-org-cert:delete')")
+    public CommonResult<Boolean> deleteQhseOrgCert(@RequestParam("id") Long id) {
+        qhseOrgCertService.deleteQhseOrgCert(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得QHSE组织证书管理")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('rq:qhse-org-cert:query')")
+    public CommonResult<QhseOrgCertRespVO> getQhseOrgCert(@RequestParam("id") Long id) {
+        QhseOrgCertDO qhseOrgCert = qhseOrgCertService.getQhseOrgCert(id);
+        return success(BeanUtils.toBean(qhseOrgCert, QhseOrgCertRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得QHSE组织证书管理分页")
+    @PreAuthorize("@ss.hasPermission('rq:qhse-org-cert:query')")
+    public CommonResult<PageResult<QhseOrgCertRespVO>> getQhseOrgCertPage(@Valid QhseOrgCertPageReqVO pageReqVO) {
+        PageResult<QhseOrgCertDO> pageResult = qhseOrgCertService.getQhseOrgCertPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, QhseOrgCertRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出QHSE组织证书管理 Excel")
+    @PreAuthorize("@ss.hasPermission('rq:qhse-org-cert:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportQhseOrgCertExcel(@Valid QhseOrgCertPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<QhseOrgCertDO> list = qhseOrgCertService.getQhseOrgCertPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "QHSE组织证书管理.xls", "数据", QhseOrgCertRespVO.class,
+                        BeanUtils.toBean(list, QhseOrgCertRespVO.class));
+    }
+
+
+    @GetMapping("/stat")
+    @Operation(summary = "QHSE资质证书统计")
+    public CommonResult<ImmutableMap> generateNum(Long deptId) {
+        Set<Long> ids = new HashSet<>();
+        if (Objects.nonNull(deptId)) {
+            ids = deptService.getChildDeptIdListFromCache(deptId);
+            ids.add(deptId);
+        }
+        //到期
+        QhseOrgCertPageReqVO reqVO = new QhseOrgCertPageReqVO();
+        reqVO.setExpired(true);
+        long expired = qhseOrgCertMapper.selectCountByDeptAndExpireAndWarn(reqVO, ids);
+        reqVO.setExpired(false);
+        reqVO.setAlertWarn(true);
+        //90天预警
+        long warn = qhseOrgCertMapper.selectCountByDeptAndExpireAndWarn(reqVO, ids);
+        reqVO.setExpired(null);
+        reqVO.setAlertWarn(null);
+        Long total = qhseOrgCertMapper.selectCountByDeptAndExpireAndWarn(reqVO, ids);
+        return success(ImmutableMap.of("expired", expired, "warn", warn,"total", total));
+    }
+}

+ 64 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/cert/vo/QhseOrgCertPageReqVO.java

@@ -0,0 +1,64 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.cert.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 = "管理后台 - QHSE组织证书管理分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class QhseOrgCertPageReqVO extends PageParam {
+
+    @Schema(description = "证书类别")
+    private String classify;
+
+    @Schema(description = "证书所属公司/个人")
+    private String certBelong;
+
+    @Schema(description = "证书颁发机构")
+    private String certOrg;
+
+    @Schema(description = "证书标准")
+    private String certStandard;
+
+    @Schema(description = "证书颁发时间")
+    private LocalDateTime certIssue;
+
+    @Schema(description = "证书有效期")
+    private LocalDateTime certExpire;
+
+    @Schema(description = "到期前提醒")
+    private Integer noticeBefore;
+
+    @Schema(description = "证书图片上传")
+    private String certPic;
+
+    @Schema(description = "备注", example = "随便")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "部门id", example = "9367")
+    private Long deptId;
+
+    @Schema(description = "用户id", example = "763")
+    private Long userId;
+
+    @Schema(description = "是否到期")
+    private Boolean expired;
+
+    @Schema(description = "证件名称", example = "张三")
+    private String certName;
+
+    @Schema(description = "是否预警")
+    private Boolean alertWarn;
+
+}

+ 79 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/cert/vo/QhseOrgCertRespVO.java

@@ -0,0 +1,79 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.cert.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 = "管理后台 - QHSE组织证书管理 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class QhseOrgCertRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31014")
+    @ExcelProperty("主键id")
+    private Long id;
+
+    @Schema(description = "证书类别")
+    @ExcelProperty("证书类别")
+    private String classify;
+
+    @Schema(description = "证书所属公司/个人")
+    @ExcelProperty("证书所属公司/个人")
+    private String certBelong;
+
+    @Schema(description = "证书颁发机构")
+    @ExcelProperty("证书颁发机构")
+    private String certOrg;
+
+    @Schema(description = "证书标准")
+    @ExcelProperty("证书标准")
+    private String certStandard;
+
+    @Schema(description = "证书颁发时间")
+    @ExcelProperty("证书颁发时间")
+    private LocalDateTime certIssue;
+
+    @Schema(description = "证书有效期")
+    @ExcelProperty("证书有效期")
+    private LocalDateTime certExpire;
+
+    @Schema(description = "到期前提醒")
+    @ExcelProperty("到期前提醒")
+    private Integer noticeBefore;
+
+    @Schema(description = "证书图片上传")
+    @ExcelProperty("证书图片上传")
+    private String certPic;
+
+    @Schema(description = "备注", example = "随便")
+    @ExcelProperty("备注")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "部门id", example = "9367")
+    @ExcelProperty("部门id")
+    private Long deptId;
+
+    @Schema(description = "用户id", example = "763")
+    @ExcelProperty("用户id")
+    private Long userId;
+
+    @Schema(description = "是否到期")
+    @ExcelProperty("是否到期")
+    private Boolean expired;
+
+    @Schema(description = "证件名称", example = "张三")
+    @ExcelProperty("证件名称")
+    private String certName;
+
+    @Schema(description = "是否预警")
+    @ExcelProperty("是否预警")
+    private Boolean alertWarn;
+
+}

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

@@ -0,0 +1,57 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.cert.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - QHSE组织证书管理新增/修改 Request VO")
+@Data
+public class QhseOrgCertSaveReqVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31014")
+    private Long id;
+
+    @Schema(description = "证书类别")
+    private String classify;
+
+    @Schema(description = "证书所属公司/个人")
+    private String certBelong;
+
+    @Schema(description = "证书颁发机构")
+    private String certOrg;
+
+    @Schema(description = "证书标准")
+    private String certStandard;
+
+    @Schema(description = "证书颁发时间")
+    private LocalDateTime certIssue;
+
+    @Schema(description = "证书有效期")
+    private LocalDateTime certExpire;
+
+    @Schema(description = "到期前提醒")
+    private Integer noticeBefore;
+
+    @Schema(description = "证书图片上传")
+    private String certPic;
+
+    @Schema(description = "备注", example = "随便")
+    private String remark;
+
+    @Schema(description = "部门id", example = "9367")
+    private Long deptId;
+
+    @Schema(description = "用户id", example = "763")
+    private Long userId;
+
+    @Schema(description = "是否到期")
+    private Boolean expired;
+
+    @Schema(description = "证件名称", example = "张三")
+    private String certName;
+
+    @Schema(description = "是否预警")
+    private Boolean alertWarn;
+
+}

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/measure/IotMeasureBookController.java

@@ -164,7 +164,7 @@ public class IotMeasureBookController {
         reqVO.setExpired(true);
         reqVO.setAlertWarn(null);
         long expired = iotMeasureBookMapper.selectCountByDeptAndExpireAndWarn(reqVO, ids);
-        reqVO.setExpired(false);
+        reqVO.setExpired(null);
         reqVO.setAlertWarn(true);
         //90天预警
         long warn = iotMeasureBookMapper.selectCountByDeptAndExpireAndWarn(reqVO, ids);

+ 88 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/cert/QhseOrgCertDO.java

@@ -0,0 +1,88 @@
+package cn.iocoder.yudao.module.pms.dal.dataobject.qhse.cert;
+
+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_org_cert")
+@KeySequence("rq_qhse_org_cert_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class QhseOrgCertDO extends BaseDO {
+
+    /**
+     * 主键id
+     */
+    @TableId
+    private Long id;
+    /**
+     * 证书类别
+     */
+    private String classify;
+    /**
+     * 证书所属公司/个人
+     */
+    private String certBelong;
+    /**
+     * 证书颁发机构
+     */
+    private String certOrg;
+    /**
+     * 证书标准
+     */
+    private String certStandard;
+    /**
+     * 证书颁发时间
+     */
+    private LocalDateTime certIssue;
+    /**
+     * 证书有效期
+     */
+    private LocalDateTime certExpire;
+    /**
+     * 到期前提醒
+     */
+    private Integer noticeBefore;
+    /**
+     * 证书图片上传
+     */
+    private String certPic;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 部门id
+     */
+    private Long deptId;
+    /**
+     * 用户id
+     */
+    private Long userId;
+    /**
+     * 是否到期
+     */
+    private Boolean expired;
+    /**
+     * 证件名称
+     */
+    private String certName;
+    /**
+     * 是否预警
+     */
+    private Boolean alertWarn;
+
+}

+ 47 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/qhse/cert/QhseOrgCertMapper.java

@@ -0,0 +1,47 @@
+package cn.iocoder.yudao.module.pms.dal.mysql.qhse.cert;
+
+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.cert.vo.QhseOrgCertPageReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.cert.QhseOrgCertDO;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.Set;
+
+/**
+ * QHSE组织证书管理 Mapper
+ *
+ * @author 超级管理员
+ */
+@Mapper
+public interface QhseOrgCertMapper extends BaseMapperX<QhseOrgCertDO> {
+
+    default PageResult<QhseOrgCertDO> selectPage(QhseOrgCertPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<QhseOrgCertDO>()
+                .eqIfPresent(QhseOrgCertDO::getClassify, reqVO.getClassify())
+                .eqIfPresent(QhseOrgCertDO::getCertBelong, reqVO.getCertBelong())
+                .eqIfPresent(QhseOrgCertDO::getCertOrg, reqVO.getCertOrg())
+                .eqIfPresent(QhseOrgCertDO::getCertStandard, reqVO.getCertStandard())
+                .eqIfPresent(QhseOrgCertDO::getCertIssue, reqVO.getCertIssue())
+                .eqIfPresent(QhseOrgCertDO::getCertExpire, reqVO.getCertExpire())
+                .eqIfPresent(QhseOrgCertDO::getNoticeBefore, reqVO.getNoticeBefore())
+                .eqIfPresent(QhseOrgCertDO::getCertPic, reqVO.getCertPic())
+                .eqIfPresent(QhseOrgCertDO::getRemark, reqVO.getRemark())
+                .betweenIfPresent(QhseOrgCertDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(QhseOrgCertDO::getDeptId, reqVO.getDeptId())
+                .eqIfPresent(QhseOrgCertDO::getUserId, reqVO.getUserId())
+                .eqIfPresent(QhseOrgCertDO::getExpired, reqVO.getExpired())
+                .likeIfPresent(QhseOrgCertDO::getCertName, reqVO.getCertName())
+                .eqIfPresent(QhseOrgCertDO::getAlertWarn, reqVO.getAlertWarn())
+                .orderByDesc(QhseOrgCertDO::getId));
+    }
+
+    default Long selectCountByDeptAndExpireAndWarn(QhseOrgCertPageReqVO reqVO, Set<Long> ids) {
+        return selectCount(new LambdaQueryWrapperX<QhseOrgCertDO>()
+                .eqIfPresent(QhseOrgCertDO::getExpired, reqVO.getExpired())
+                .eqIfPresent(QhseOrgCertDO::getAlertWarn, reqVO.getAlertWarn())
+                .inIfPresent(QhseOrgCertDO::getDeptId, ids)
+                .betweenIfPresent(QhseOrgCertDO::getCreateTime, reqVO.getCreateTime()));
+    }
+}

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

@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.module.pms.service.qhse.cert;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.cert.vo.QhseOrgCertPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.cert.vo.QhseOrgCertSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.cert.QhseOrgCertDO;
+
+import javax.validation.Valid;
+
+/**
+ * QHSE组织证书管理 Service 接口
+ *
+ * @author 超级管理员
+ */
+public interface QhseOrgCertService {
+
+    /**
+     * 创建QHSE组织证书管理
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createQhseOrgCert(@Valid QhseOrgCertSaveReqVO createReqVO);
+
+    /**
+     * 更新QHSE组织证书管理
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateQhseOrgCert(@Valid QhseOrgCertSaveReqVO updateReqVO);
+
+    /**
+     * 删除QHSE组织证书管理
+     *
+     * @param id 编号
+     */
+    void deleteQhseOrgCert(Long id);
+
+    /**
+     * 获得QHSE组织证书管理
+     *
+     * @param id 编号
+     * @return QHSE组织证书管理
+     */
+    QhseOrgCertDO getQhseOrgCert(Long id);
+
+    /**
+     * 获得QHSE组织证书管理分页
+     *
+     * @param pageReqVO 分页查询
+     * @return QHSE组织证书管理分页
+     */
+    PageResult<QhseOrgCertDO> getQhseOrgCertPage(QhseOrgCertPageReqVO pageReqVO);
+
+}

+ 99 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/cert/QhseOrgCertServiceImpl.java

@@ -0,0 +1,99 @@
+package cn.iocoder.yudao.module.pms.service.qhse.cert;
+
+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.cert.vo.QhseOrgCertPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.cert.vo.QhseOrgCertSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.cert.QhseOrgCertDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.cert.QhseOrgCertMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+
+import java.time.LocalDateTime;
+import java.time.temporal.ChronoUnit;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+
+/**
+ * QHSE组织证书管理 Service 实现类
+ *
+ * @author 超级管理员
+ */
+@Service
+@Validated
+public class QhseOrgCertServiceImpl implements QhseOrgCertService {
+
+    @Resource
+    private QhseOrgCertMapper qhseOrgCertMapper;
+
+    @Override
+    public Long createQhseOrgCert(QhseOrgCertSaveReqVO createReqVO) {
+        // 插入
+        QhseOrgCertDO qhseOrgCert = BeanUtils.toBean(createReqVO, QhseOrgCertDO.class);
+        qhseOrgCert.setDeleted(false);
+        qhseOrgCert.setAlertWarn(false);
+        qhseOrgCert.setExpired(false);
+        LocalDateTime certExpire = qhseOrgCert.getCertExpire();
+        //证书已过期的话,更新expired为true
+        if (certExpire.isBefore(LocalDateTime.now())) {
+            //证书已过期的话,更新expired为true
+            qhseOrgCert.setExpired(true);
+        } else  {
+            if (ChronoUnit.DAYS.between(LocalDateTime.now(), certExpire) < 60) {
+                qhseOrgCert.setAlertWarn(true);//设置为60天预警过期
+            }
+            qhseOrgCert.setExpired(false);
+        }
+        qhseOrgCertMapper.insert(qhseOrgCert);
+        // 返回
+        return qhseOrgCert.getId();
+    }
+
+    @Override
+    public void updateQhseOrgCert(QhseOrgCertSaveReqVO updateReqVO) {
+        // 校验存在
+        validateQhseOrgCertExists(updateReqVO.getId());
+        // 更新
+        QhseOrgCertDO updateObj = BeanUtils.toBean(updateReqVO, QhseOrgCertDO.class);
+        LocalDateTime certExpire = updateObj.getCertExpire();
+        //证书已过期的话,更新expired为true
+        if (certExpire.isBefore(LocalDateTime.now())) {
+            //证书已过期的话,更新expired为true
+            updateObj.setExpired(true);
+        } else  {
+            if (ChronoUnit.DAYS.between(LocalDateTime.now(), certExpire) < 60) {
+                updateObj.setAlertWarn(true);//设置为60天预警过期
+            }
+            updateObj.setExpired(false);
+        }
+        qhseOrgCertMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteQhseOrgCert(Long id) {
+        // 校验存在
+        validateQhseOrgCertExists(id);
+        // 删除
+        qhseOrgCertMapper.deleteById(id);
+    }
+
+    private void validateQhseOrgCertExists(Long id) {
+        if (qhseOrgCertMapper.selectById(id) == null) {
+            throw exception(new ErrorCode(1, "不存在"));
+        }
+    }
+
+    @Override
+    public QhseOrgCertDO getQhseOrgCert(Long id) {
+        return qhseOrgCertMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<QhseOrgCertDO> getQhseOrgCertPage(QhseOrgCertPageReqVO pageReqVO) {
+        return qhseOrgCertMapper.selectPage(pageReqVO);
+    }
+
+}