移除制度模块中与投票相关的方法并修改相关逻辑

This commit is contained in:
wangna0328 2025-07-29 20:11:46 +08:00
parent 2b94b8846b
commit d10cd352b0
18 changed files with 1996 additions and 0 deletions

View File

@ -0,0 +1,14 @@
package com.dite.znpt.domain.dto;
import lombok.Data;
/**
* 制度确认DTO
* @author wangna
* @date 2025/07/29
*/
@Data
public class RegulationConfirmDTO {
private Boolean agreeTerms; // 是否同意条款
}

View File

@ -0,0 +1,20 @@
package com.dite.znpt.domain.dto;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 制度讨论DTO
* @author wangna
* @date 2025/07/29
*/
@Data
public class RegulationDiscussionDTO {
private String id;
private String regulationId;
private String authorId;
private String authorName;
private String content;
private LocalDateTime createTime;
}

View File

@ -0,0 +1,96 @@
package com.dite.znpt.domain.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.dite.znpt.domain.AuditableEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.alibaba.excel.annotation.ExcelProperty;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author wangna
* @date 2025/07/28
* @Description: 制度确认实体类
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("regulation_confirmation")
@ApiModel(value="RegulationConfirmationEntity对象", description="制度确认")
public class RegulationConfirmationEntity extends AuditableEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ExcelProperty("确认ID")
@ApiModelProperty("确认ID")
@TableId(value = "confirmation_id", type = IdType.ASSIGN_UUID)
private String confirmationId;
@ExcelProperty("制度ID")
@ApiModelProperty("制度ID")
@TableField("regulation_id")
private String regulationId;
@ExcelProperty("制度标题")
@ApiModelProperty("制度标题")
@TableField("regulation_title")
private String regulationTitle;
@ExcelProperty("确认人ID")
@ApiModelProperty("确认人ID")
@TableField("confirmer_id")
private String confirmerId;
@ExcelProperty("确认人姓名")
@ApiModelProperty("确认人姓名")
@TableField("confirmer_name")
private String confirmerName;
@ExcelProperty("确认人部门")
@ApiModelProperty("确认人部门")
@TableField("confirmer_dept")
private String confirmerDept;
@ExcelProperty("确认状态")
@ApiModelProperty("确认状态PENDING-待确认CONFIRMED-已确认DECLINED-已拒绝")
@TableField("status")
private String status;
@ExcelProperty("确认时间")
@ApiModelProperty("确认时间")
@TableField("confirm_time")
private LocalDateTime confirmTime;
@ExcelProperty("确认意见")
@ApiModelProperty("确认意见")
@TableField("confirm_comment")
private String confirmComment;
@ExcelProperty("阅读时长(秒)")
@ApiModelProperty("阅读时长(秒)")
@TableField("read_duration")
private Integer readDuration;
@ExcelProperty("IP地址")
@ApiModelProperty("IP地址")
@TableField("ip_address")
private String ipAddress;
@ExcelProperty("用户代理")
@ApiModelProperty("用户代理")
@TableField("user_agent")
private String userAgent;
@ExcelProperty("备注")
@ApiModelProperty("备注")
@TableField("remark")
private String remark;
@ExcelProperty("删除标志0代表存在1代表删除")
@ApiModelProperty("删除标志0代表存在1代表删除")
@TableField("del_flag")
private String delFlag;
}

View File

@ -0,0 +1,106 @@
package com.dite.znpt.domain.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.dite.znpt.domain.AuditableEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.alibaba.excel.annotation.ExcelProperty;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author wangna
* @date 2025/07/28
* @Description: 制度草案实体类
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("regulation_draft")
@ApiModel(value="RegulationDraftEntity对象", description="制度草案")
public class RegulationDraftEntity extends AuditableEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ExcelProperty("草案ID")
@ApiModelProperty("草案ID")
@TableId(value = "draft_id", type = IdType.ASSIGN_UUID)
private String draftId;
@ExcelProperty("制度标题")
@ApiModelProperty("制度标题")
@TableField("title")
private String title;
@ExcelProperty("制度内容")
@ApiModelProperty("制度内容")
@TableField("content")
private String content;
@ExcelProperty("制度类型")
@ApiModelProperty("制度类型")
@TableField("regulation_type")
private String regulationType;
@ExcelProperty("草案状态")
@ApiModelProperty("草案状态DRAFT-草稿REVIEWING-审核中APPROVED-已通过REJECTED-已拒绝")
@TableField("status")
private String status;
@ExcelProperty("创建人ID")
@ApiModelProperty("创建人ID")
@TableField("creator_id")
private String creatorId;
@ExcelProperty("创建人姓名")
@ApiModelProperty("创建人姓名")
@TableField("creator_name")
private String creatorName;
@ExcelProperty("审核人ID")
@ApiModelProperty("审核人ID")
@TableField("reviewer_id")
private String reviewerId;
@ExcelProperty("审核人姓名")
@ApiModelProperty("审核人姓名")
@TableField("reviewer_name")
private String reviewerName;
@ExcelProperty("审核时间")
@ApiModelProperty("审核时间")
@TableField("review_time")
private LocalDateTime reviewTime;
@ExcelProperty("审核意见")
@ApiModelProperty("审核意见")
@TableField("review_comment")
private String reviewComment;
@ExcelProperty("适用范围")
@ApiModelProperty("适用范围")
@TableField("scope")
private String scope;
@ExcelProperty("制度级别")
@ApiModelProperty("制度级别HIGH-高级MEDIUM-中级LOW-低级")
@TableField("level")
private String level;
@ExcelProperty("版本号")
@ApiModelProperty("版本号")
@TableField("version")
private String version;
@ExcelProperty("备注")
@ApiModelProperty("备注")
@TableField("remark")
private String remark;
@ExcelProperty("删除标志0代表存在1代表删除")
@ApiModelProperty("删除标志0代表存在1代表删除")
@TableField("del_flag")
private String delFlag;
}

View File

@ -0,0 +1,105 @@
package com.dite.znpt.domain.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.dite.znpt.domain.AuditableEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.alibaba.excel.annotation.ExcelProperty;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author wangna
* @date 2025/07/28
* @Description: 制度规范仓库实体类
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("regulation")
@ApiModel(value="RegulationEntity对象", description="制度规范仓库")
public class RegulationEntity extends AuditableEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ExcelProperty("制度ID")
@ApiModelProperty("制度ID")
@TableId(value = "regulation_id", type = IdType.ASSIGN_UUID)
private String regulationId;
@ExcelProperty("制度标题")
@ApiModelProperty("制度标题")
@TableField("title")
private String title;
@ExcelProperty("制度内容")
@ApiModelProperty("制度内容")
@TableField("content")
private String content;
@ExcelProperty("制度类型")
@ApiModelProperty("制度类型")
@TableField("regulation_type")
private String regulationType;
@ExcelProperty("制度状态")
@ApiModelProperty("制度状态DRAFT-草案PUBLISHED-已发布ARCHIVED-已归档")
@TableField("status")
private String status;
@ExcelProperty("发布人ID")
@ApiModelProperty("发布人ID")
@TableField("publisher_id")
private String publisherId;
@ExcelProperty("发布人姓名")
@ApiModelProperty("发布人姓名")
@TableField("publisher_name")
private String publisherName;
@ExcelProperty("发布时间")
@ApiModelProperty("发布时间")
@TableField("publish_time")
private LocalDateTime publishTime;
@ExcelProperty("生效时间")
@ApiModelProperty("生效时间")
@TableField("effective_time")
private LocalDateTime effectiveTime;
@ExcelProperty("失效时间")
@ApiModelProperty("失效时间")
@TableField("expire_time")
private LocalDateTime expireTime;
@ExcelProperty("适用范围")
@ApiModelProperty("适用范围")
@TableField("scope")
private String scope;
@ExcelProperty("制度级别")
@ApiModelProperty("制度级别HIGH-高级MEDIUM-中级LOW-低级")
@TableField("level")
private String level;
@ExcelProperty("版本号")
@ApiModelProperty("版本号")
@TableField("version")
private String version;
@ExcelProperty("备注")
@ApiModelProperty("备注")
@TableField("remark")
private String remark;
@ExcelProperty("删除标志0代表存在1代表删除")
@ApiModelProperty("删除标志0代表存在1代表删除")
@TableField("del_flag")
private String delFlag;
@TableField(exist = false)
@ApiModelProperty("当前用户确认状态pending-待确认confirmed-已确认")
private String confirmStatus;
}

View File

@ -0,0 +1,156 @@
package com.dite.znpt.domain.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.dite.znpt.domain.AuditableEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.alibaba.excel.annotation.ExcelProperty;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author wangna
* @date 2025/07/28
* @Description: 制度提案实体类
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("regulation_proposal")
@ApiModel(value="RegulationProposalEntity对象", description="制度提案")
public class RegulationProposalEntity extends AuditableEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ExcelProperty("提案ID")
@ApiModelProperty("提案ID")
@TableId(value = "proposal_id", type = IdType.ASSIGN_UUID)
private String proposalId;
@ExcelProperty("提案标题")
@ApiModelProperty("提案标题")
@TableField("title")
private String title;
@ExcelProperty("提案内容")
@ApiModelProperty("提案内容")
@TableField("content")
private String content;
@ExcelProperty("提案类型")
@ApiModelProperty("提案类型")
@TableField("proposal_type")
private String proposalType;
@ExcelProperty("提案状态")
@ApiModelProperty("提案状态SUBMITTED-已提交DISCUSSING-讨论中APPROVED-已通过REJECTED-已拒绝CONVERTED-已转为草案")
@TableField("status")
private String status;
@ExcelProperty("提案人ID")
@ApiModelProperty("提案人ID")
@TableField("proposer_id")
private String proposerId;
@ExcelProperty("提案人姓名")
@ApiModelProperty("提案人姓名")
@TableField("proposer_name")
private String proposerName;
@ExcelProperty("提案人部门")
@ApiModelProperty("提案人部门")
@TableField("proposer_dept")
private String proposerDept;
@ExcelProperty("讨论组ID")
@ApiModelProperty("讨论组ID")
@TableField("discussion_group_id")
private String discussionGroupId;
@ExcelProperty("讨论组名称")
@ApiModelProperty("讨论组名称")
@TableField("discussion_group_name")
private String discussionGroupName;
@ExcelProperty("讨论开始时间")
@ApiModelProperty("讨论开始时间")
@TableField("discussion_start_time")
private LocalDateTime discussionStartTime;
@ExcelProperty("讨论结束时间")
@ApiModelProperty("讨论结束时间")
@TableField("discussion_end_time")
private LocalDateTime discussionEndTime;
@ExcelProperty("讨论状态")
@ApiModelProperty("讨论状态NOT_STARTED-未开始DISCUSSING-讨论中FINISHED-已结束")
@TableField("discussion_status")
private String discussionStatus;
@ExcelProperty("支持人数")
@ApiModelProperty("支持人数")
@TableField("support_count")
private Integer supportCount;
@ExcelProperty("反对人数")
@ApiModelProperty("反对人数")
@TableField("oppose_count")
private Integer opposeCount;
@ExcelProperty("总参与人数")
@ApiModelProperty("总参与人数")
@TableField("total_participants")
private Integer totalParticipants;
@ExcelProperty("审核人ID")
@ApiModelProperty("审核人ID")
@TableField("reviewer_id")
private String reviewerId;
@ExcelProperty("审核人姓名")
@ApiModelProperty("审核人姓名")
@TableField("reviewer_name")
private String reviewerName;
@ExcelProperty("审核时间")
@ApiModelProperty("审核时间")
@TableField("review_time")
private LocalDateTime reviewTime;
@ExcelProperty("审核意见")
@ApiModelProperty("审核意见")
@TableField("review_comment")
private String reviewComment;
@ExcelProperty("转为草案ID")
@ApiModelProperty("转为草案ID")
@TableField("converted_draft_id")
private String convertedDraftId;
@ExcelProperty("适用范围")
@ApiModelProperty("适用范围")
@TableField("scope")
private String scope;
@ExcelProperty("制度级别")
@ApiModelProperty("制度级别HIGH-高级MEDIUM-中级LOW-低级")
@TableField("level")
private String level;
@ExcelProperty("紧急程度")
@ApiModelProperty("紧急程度HIGH-高MEDIUM-中LOW-低")
@TableField("urgency_level")
private String urgencyLevel;
@ExcelProperty("备注")
@ApiModelProperty("备注")
@TableField("remark")
private String remark;
@ExcelProperty("删除标志0代表存在1代表删除")
@ApiModelProperty("删除标志0代表存在1代表删除")
@TableField("del_flag")
private String delFlag;
}

View File

@ -0,0 +1,14 @@
package com.dite.znpt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dite.znpt.domain.entity.RegulationConfirmationEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @author wangna
* @date 2025/07/28
* @Description: 制度确认Mapper接口
*/
@Mapper
public interface RegulationConfirmationMapper extends BaseMapper<RegulationConfirmationEntity> {
}

View File

@ -0,0 +1,12 @@
package com.dite.znpt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dite.znpt.domain.entity.RegulationDraftEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 制度草案Mapper接口
*/
@Mapper
public interface RegulationDraftMapper extends BaseMapper<RegulationDraftEntity> {
}

View File

@ -0,0 +1,14 @@
package com.dite.znpt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dite.znpt.domain.entity.RegulationEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @author wangna
* @date 2025/07/28
* @Description: 制度规范仓库Mapper接口
*/
@Mapper
public interface RegulationMapper extends BaseMapper<RegulationEntity> {
}

View File

@ -0,0 +1,66 @@
package com.dite.znpt.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.dite.znpt.domain.entity.RegulationConfirmationEntity;
import com.dite.znpt.domain.Result;
/**
* @author wangna
* @date 2025/07/28
* @Description: 制度确认Service接口
*/
public interface RegulationConfirmationService extends IService<RegulationConfirmationEntity> {
/**
* 确认制度
* @param confirmation 确认信息
* @return 结果
*/
Result confirmRegulation(RegulationConfirmationEntity confirmation);
/**
* 获取确认记录
* @param regulationId 制度ID
* @return 结果
*/
Result getConfirmationRecords(String regulationId);
/**
* 获取用户确认记录
* @param confirmerId 确认人ID
* @param regulationId 制度ID
* @return 结果
*/
Result getUserConfirmationRecord(String confirmerId, String regulationId);
/**
* 取消确认
* @param confirmationId 确认ID
* @return 结果
*/
Result cancelConfirmation(String confirmationId);
/**
* 获取确认统计
* @param regulationId 制度ID
* @return 结果
*/
Result getConfirmationStatistics(String regulationId);
/**
* 批量创建确认任务
* @param regulationId 制度ID
* @param userIds 用户ID列表
* @return 结果
*/
Result createConfirmationTasks(String regulationId, String[] userIds);
/**
* 获取待确认列表
* @param confirmerId 确认人ID
* @param page 页码
* @param pageSize 页大小
* @return 结果
*/
Result getPendingConfirmations(String confirmerId, Integer page, Integer pageSize);
}

View File

@ -0,0 +1,85 @@
package com.dite.znpt.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.dite.znpt.domain.entity.RegulationEntity;
import com.dite.znpt.domain.Result;
import com.dite.znpt.domain.dto.RegulationDiscussionDTO;
import com.dite.znpt.domain.dto.RegulationConfirmDTO;
/**
* @author wangna
* @date 2025/07/29
* @Description: 制度规范仓库Service接口
*/
public interface RegulationService extends IService<RegulationEntity> {
/**
* 获取制度列表
* @param page 页码
* @param pageSize 页大小
* @param status 状态
* @param type 类型
* @return 结果
*/
Result getRegulationList(Integer page, Integer pageSize, String status, String type);
/**
* 创建制度提案
* @param regulation 制度信息
* @return 结果
*/
Result createRegulationProposal(RegulationEntity regulation);
/**
* 更新制度提案
* @param regulation 制度信息
* @return 结果
*/
Result updateRegulationProposal(RegulationEntity regulation);
/**
* 获取制度详情
* @param regulationId 制度ID
* @return 结果
*/
Result getRegulationDetail(String regulationId);
/**
* 获取讨论列表
* @param regulationId 制度ID
* @return 结果
*/
Result getRegulationDiscussions(String regulationId);
/**
* 创建讨论
* @param discussion 讨论信息
* @return 结果
*/
Result createDiscussion(RegulationDiscussionDTO discussion);
/**
* 发布制度
* @param regulationId 制度ID
* @return 结果
*/
Result publishRegulation(String regulationId);
/**
* 获取已发布制度列表
* @param page 页码
* @param size 页大小
* @return 结果
*/
Result getPublishedRegulations(Integer page, Integer size);
/**
* 确认制度知晓
* @param regulationId 制度ID
* @param confirm 确认信息
* @return 结果
*/
Result confirmRegulation(String regulationId, RegulationConfirmDTO confirm);
}

View File

@ -0,0 +1,184 @@
package com.dite.znpt.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dite.znpt.domain.Result;
import com.dite.znpt.domain.entity.RegulationConfirmationEntity;
import com.dite.znpt.mapper.RegulationConfirmationMapper;
import com.dite.znpt.service.RegulationConfirmationService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
/**
* @author wangna
* @date 2025/07/28
* @Description: 制度确认服务实现类
*/
@Service
@RequiredArgsConstructor
public class RegulationConfirmationServiceImpl extends ServiceImpl<RegulationConfirmationMapper, RegulationConfirmationEntity> implements RegulationConfirmationService {
@Override
@Transactional(rollbackFor = Exception.class)
public Result confirmRegulation(RegulationConfirmationEntity confirmation) {
try {
// 检查是否已经确认
LambdaQueryWrapper<RegulationConfirmationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RegulationConfirmationEntity::getConfirmerId, confirmation.getConfirmerId())
.eq(RegulationConfirmationEntity::getRegulationId, confirmation.getRegulationId())
.eq(RegulationConfirmationEntity::getDelFlag, "0");
RegulationConfirmationEntity existingConfirmation = this.getOne(wrapper);
if (existingConfirmation != null) {
return Result.error("您已经确认过该制度");
}
confirmation.setConfirmTime(LocalDateTime.now());
confirmation.setDelFlag("0");
this.save(confirmation);
return Result.ok("制度确认成功");
} catch (Exception e) {
return Result.error("制度确认失败:" + e.getMessage());
}
}
@Override
public Result getConfirmationRecords(String regulationId) {
try {
LambdaQueryWrapper<RegulationConfirmationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RegulationConfirmationEntity::getRegulationId, regulationId)
.eq(RegulationConfirmationEntity::getDelFlag, "0")
.orderByDesc(RegulationConfirmationEntity::getConfirmTime);
List<RegulationConfirmationEntity> confirmations = this.list(wrapper);
return Result.ok(confirmations);
} catch (Exception e) {
return Result.error("获取确认记录失败:" + e.getMessage());
}
}
@Override
public Result getUserConfirmationRecord(String confirmerId, String regulationId) {
try {
LambdaQueryWrapper<RegulationConfirmationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RegulationConfirmationEntity::getConfirmerId, confirmerId)
.eq(RegulationConfirmationEntity::getRegulationId, regulationId)
.eq(RegulationConfirmationEntity::getDelFlag, "0");
RegulationConfirmationEntity confirmation = this.getOne(wrapper);
return Result.ok(confirmation);
} catch (Exception e) {
return Result.error("获取用户确认记录失败:" + e.getMessage());
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result cancelConfirmation(String confirmationId) {
try {
RegulationConfirmationEntity confirmation = this.getById(confirmationId);
if (confirmation == null) {
return Result.error("确认记录不存在");
}
confirmation.setDelFlag("1");
this.updateById(confirmation);
return Result.ok("确认取消成功");
} catch (Exception e) {
return Result.error("确认取消失败:" + e.getMessage());
}
}
@Override
public Result getConfirmationStatistics(String regulationId) {
try {
LambdaQueryWrapper<RegulationConfirmationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RegulationConfirmationEntity::getRegulationId, regulationId)
.eq(RegulationConfirmationEntity::getDelFlag, "0");
List<RegulationConfirmationEntity> confirmations = this.list(wrapper);
int confirmedCount = 0;
int declinedCount = 0;
int pendingCount = 0;
for (RegulationConfirmationEntity confirmation : confirmations) {
switch (confirmation.getStatus()) {
case "CONFIRMED":
confirmedCount++;
break;
case "DECLINED":
declinedCount++;
break;
case "PENDING":
pendingCount++;
break;
}
}
int totalConfirmations = confirmedCount + declinedCount + pendingCount;
double confirmRate = totalConfirmations > 0 ? (double) confirmedCount / totalConfirmations * 100 : 0;
return Result.okM(Map.of(
"regulationId", regulationId,
"totalConfirmations", totalConfirmations,
"confirmedCount", confirmedCount,
"declinedCount", declinedCount,
"pendingCount", pendingCount,
"confirmRate", confirmRate
), "确认统计");
} catch (Exception e) {
return Result.error("获取确认统计失败:" + e.getMessage());
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result createConfirmationTasks(String regulationId, String[] userIds) {
try {
for (String userId : userIds) {
// 检查是否已经存在确认任务
LambdaQueryWrapper<RegulationConfirmationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RegulationConfirmationEntity::getConfirmerId, userId)
.eq(RegulationConfirmationEntity::getRegulationId, regulationId)
.eq(RegulationConfirmationEntity::getDelFlag, "0");
RegulationConfirmationEntity existingTask = this.getOne(wrapper);
if (existingTask == null) {
RegulationConfirmationEntity task = new RegulationConfirmationEntity();
task.setRegulationId(regulationId);
task.setConfirmerId(userId);
task.setStatus("PENDING");
task.setDelFlag("0");
this.save(task);
}
}
return Result.okM("确认任务创建成功");
} catch (Exception e) {
return Result.error("确认任务创建失败:" + e.getMessage());
}
}
@Override
public Result getPendingConfirmations(String confirmerId, Integer page, Integer pageSize) {
try {
Page<RegulationConfirmationEntity> pageParam = new Page<>(page, pageSize);
LambdaQueryWrapper<RegulationConfirmationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RegulationConfirmationEntity::getConfirmerId, confirmerId)
.eq(RegulationConfirmationEntity::getStatus, "PENDING")
.eq(RegulationConfirmationEntity::getDelFlag, "0")
.orderByDesc(RegulationConfirmationEntity::getCreateTime);
Page<RegulationConfirmationEntity> result = this.page(pageParam, wrapper);
return Result.ok(result);
} catch (Exception e) {
return Result.error("获取待确认列表失败:" + e.getMessage());
}
}
}

View File

@ -0,0 +1,257 @@
package com.dite.znpt.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dite.znpt.domain.Result;
import com.dite.znpt.domain.entity.RegulationEntity;
import com.dite.znpt.domain.entity.RegulationConfirmationEntity;
import com.dite.znpt.domain.dto.RegulationDiscussionDTO;
import com.dite.znpt.domain.dto.RegulationConfirmDTO;
import com.dite.znpt.domain.vo.UserResp;
import com.dite.znpt.mapper.RegulationMapper;
import com.dite.znpt.service.RegulationConfirmationService;
import com.dite.znpt.service.RegulationService;
import com.dite.znpt.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.dite.znpt.mapper.RegulationDraftMapper;
import com.dite.znpt.domain.entity.RegulationDraftEntity;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.time.LocalDateTime;
/**
* @author wangna
* @date 2025/07/29
* @Description: 制度规范仓库服务实现类
*/
@Service
@RequiredArgsConstructor
public class RegulationServiceImpl extends ServiceImpl<RegulationMapper, RegulationEntity> implements RegulationService {
private final RegulationConfirmationService regulationConfirmationService;
private final UserService userService;
@Autowired
private RegulationDraftMapper regulationDraftMapper;
/**
* 每天凌晨1点自动将公示期10天已到的草案变为已发布
*/
@Scheduled(cron = "0 0 1 * * ?")
public void autoPublishDrafts() {
LocalDateTime tenDaysAgo = LocalDateTime.now().minusDays(10);
List<RegulationDraftEntity> drafts = regulationDraftMapper.selectList(
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<RegulationDraftEntity>()
.eq(RegulationDraftEntity::getStatus, "DRAFT")
.le(RegulationDraftEntity::getCreateTime, tenDaysAgo)
);
for (RegulationDraftEntity draft : drafts) {
draft.setStatus("PUBLISHED");
regulationDraftMapper.updateById(draft);
}
}
@Override
public Result getRegulationList(Integer page, Integer pageSize, String status, String type) {
try {
Page<RegulationEntity> pageParam = new Page<>(page, pageSize);
LambdaQueryWrapper<RegulationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RegulationEntity::getDelFlag, "0");
if (status != null && !status.isEmpty()) {
wrapper.eq(RegulationEntity::getStatus, status);
}
if (type != null && !type.isEmpty()) {
wrapper.eq(RegulationEntity::getRegulationType, type);
}
wrapper.orderByDesc(RegulationEntity::getCreateTime);
Page<RegulationEntity> result = this.page(pageParam, wrapper);
return Result.ok(result);
} catch (Exception e) {
return Result.error("获取制度列表失败:" + e.getMessage());
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result createRegulationProposal(RegulationEntity regulation) {
try {
// 设置初始状态为草稿
regulation.setStatus("DRAFT");
regulation.setDelFlag("0");
// 设置创建时间和更新时间
LocalDateTime now = LocalDateTime.now();
regulation.setCreateTime(now);
regulation.setUpdateTime(now);
// 设置创建人信息
String userId = StpUtil.getLoginIdAsString();
regulation.setCreateBy(userId);
regulation.setUpdateBy(userId);
// 获取当前用户信息
UserResp user = userService.detail(userId);
if (user != null) {
regulation.setPublisherId(userId);
regulation.setPublisherName(user.getName());
}
// 保存制度
this.save(regulation);
return Result.okM("制度提案创建成功");
} catch (Exception e) {
return Result.error("制度提案创建失败:" + e.getMessage());
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result updateRegulationProposal(RegulationEntity regulation) {
try {
RegulationEntity existing = this.getById(regulation.getRegulationId());
if (existing == null) {
return Result.error("制度不存在");
}
regulation.setUpdateTime(LocalDateTime.now());
regulation.setUpdateBy(StpUtil.getLoginIdAsString());
this.updateById(regulation);
return Result.okM("制度提案更新成功");
} catch (Exception e) {
return Result.error("制度提案更新失败:" + e.getMessage());
}
}
@Override
public Result getRegulationDetail(String regulationId) {
try {
RegulationEntity regulation = this.getById(regulationId);
if (regulation == null) {
return Result.error("制度不存在");
}
return Result.ok(regulation);
} catch (Exception e) {
return Result.error("获取制度详情失败:" + e.getMessage());
}
}
@Override
public Result getRegulationDiscussions(String regulationId) {
try {
// 这里应该调用讨论服务获取讨论列表
// 暂时返回模拟数据
return Result.ok("讨论列表功能待实现");
} catch (Exception e) {
return Result.error("获取讨论列表失败:" + e.getMessage());
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result createDiscussion(RegulationDiscussionDTO discussion) {
try {
// 设置讨论信息
discussion.setId(java.util.UUID.randomUUID().toString());
discussion.setAuthorId(StpUtil.getLoginIdAsString());
UserResp user = userService.detail(discussion.getAuthorId());
if (user != null) {
discussion.setAuthorName(user.getName());
}
discussion.setCreateTime(LocalDateTime.now());
// 这里应该保存讨论到数据库
// 暂时返回成功
return Result.okM("评论发表成功");
} catch (Exception e) {
return Result.error("评论发表失败:" + e.getMessage());
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result publishRegulation(String regulationId) {
try {
RegulationEntity regulation = this.getById(regulationId);
if (regulation == null) {
return Result.error("制度不存在");
}
regulation.setStatus("PUBLISHED");
regulation.setPublishTime(LocalDateTime.now());
regulation.setUpdateTime(LocalDateTime.now());
regulation.setUpdateBy(StpUtil.getLoginIdAsString());
this.updateById(regulation);
return Result.okM("制度发布成功");
} catch (Exception e) {
return Result.error("制度发布失败:" + e.getMessage());
}
}
@Override
public Result getPublishedRegulations(Integer page, Integer size) {
try {
String userId = cn.dev33.satoken.stp.StpUtil.getLoginIdAsString();
Page<RegulationEntity> pageParam = new Page<>(page, size);
LambdaQueryWrapper<RegulationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RegulationEntity::getDelFlag, "0");
wrapper.eq(RegulationEntity::getStatus, "PUBLISHED");
wrapper.orderByDesc(RegulationEntity::getPublishTime);
Page<RegulationEntity> result = this.page(pageParam, wrapper);
// 查询当前用户所有确认记录
java.util.List<String> confirmedIds = regulationConfirmationService.lambdaQuery()
.eq(RegulationConfirmationEntity::getConfirmerId, userId)
.eq(RegulationConfirmationEntity::getStatus, "CONFIRMED")
.eq(RegulationConfirmationEntity::getDelFlag, "0")
.list()
.stream()
.map(RegulationConfirmationEntity::getRegulationId)
.toList();
for (RegulationEntity reg : result.getRecords()) {
reg.setConfirmStatus(confirmedIds.contains(reg.getRegulationId()) ? "confirmed" : "pending");
}
return Result.ok(result);
} catch (Exception e) {
return Result.error("获取已发布制度列表失败:" + e.getMessage());
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result confirmRegulation(String regulationId, RegulationConfirmDTO confirm) {
try {
if (!confirm.getAgreeTerms()) {
return Result.error("必须同意条款才能确认");
}
String userId = StpUtil.getLoginIdAsString();
UserResp user = userService.detail(userId);
RegulationConfirmationEntity confirmation = new RegulationConfirmationEntity();
confirmation.setRegulationId(regulationId);
confirmation.setConfirmerId(userId);
confirmation.setConfirmerName(user != null ? user.getName() : null);
confirmation.setConfirmerDept(user != null ? user.getDeptName() : null);
confirmation.setStatus("CONFIRMED");
confirmation.setConfirmTime(LocalDateTime.now());
confirmation.setDelFlag("0");
return regulationConfirmationService.confirmRegulation(confirmation);
} catch (Exception e) {
return Result.error("确认制度失败:" + e.getMessage());
}
}
}

403
doc/regulation_api_test.md Normal file
View File

@ -0,0 +1,403 @@
# 制度模块API测试文档
## 1. 获取制度列表 (流程管理页面)
### 请求信息
- **URL**: `GET /api/regulation?page=1&size=10`
- **Method**: GET
### 请求参数
- `page`: 页码从1开始必填
- `size`: 每页数量(必填)
### 响应格式
```json
{
"status": 200,
"data": {
"records": [
{
"regulationId": "reg001",
"title": "员工考勤管理制度优化提案",
"content": "建议优化考勤管理制度,增加弹性工作时间,提高员工工作积极性...",
"regulationType": "人事制度",
"status": "VOTING",
"publisherId": "2",
"publisherName": "张三",
"publishTime": "2024-01-01T12:00:00",
"effectiveTime": "2024-01-01T12:00:00",
"expireTime": "2024-01-08T12:00:00",
"scope": "全体员工",
"level": "MEDIUM",
"version": "1.0",
"remark": "需要与人事部门协调实施",
"createBy": "admin",
"updateBy": "admin",
"createTime": "2024-01-01 10:00:00",
"updateTime": "2024-01-01 12:00:00",
"page": 1,
"pageSize": 10,
"delFlag": "0",
"voteFor": 15,
"voteAgainst": 3,
"voteAbstain": 2
}
],
"total": 4,
"size": 10,
"current": 1,
"pages": 1
}
}
```
## 2. 创建制度提案
### 请求信息
- **URL**: `POST /api/regulation/proposal`
- **Content-Type**: `application/json`
### 请求参数
```json
{
"title": "员工考勤管理制度优化提案",
"content": "建议优化考勤管理制度,增加弹性工作时间...",
"regulationType": "人事制度",
"scope": "全体员工",
"level": "MEDIUM",
"remark": "需要与人事部门协调实施"
}
```
### 响应格式
```json
{
"status": 200,
"data": {
"regulationId": "reg005",
"title": "员工考勤管理制度优化提案",
"content": "建议优化考勤管理制度,增加弹性工作时间...",
"regulationType": "人事制度",
"status": "DRAFT",
"publisherId": "1",
"publisherName": "当前用户",
"publishTime": "2024-01-25T10:30:00",
"effectiveTime": "2024-01-25T10:30:00",
"expireTime": "2025-01-25T10:30:00",
"scope": "全体员工",
"level": "MEDIUM",
"version": "1.0",
"remark": "需要与人事部门协调实施",
"createBy": "admin",
"updateBy": "admin",
"createTime": "2024-01-25 10:30:00",
"updateTime": "2024-01-25 10:30:00",
"page": 1,
"pageSize": 10,
"delFlag": "0"
}
}
```
## 3. 更新制度提案
### 请求信息
- **URL**: `PUT /api/regulation/proposal/{regulationId}`
- **Content-Type**: `application/json`
### 请求参数
```json
{
"title": "员工考勤管理制度优化提案",
"content": "建议优化考勤管理制度,增加弹性工作时间...",
"regulationType": "人事制度",
"scope": "全体员工",
"level": "MEDIUM",
"remark": "需要与人事部门协调实施"
}
```
### 响应格式
```json
{
"status": 200,
"message": "制度提案更新成功"
}
```
## 4. 删除制度提案
### 请求信息
- **URL**: `DELETE /api/regulation/proposal/{regulationId}`
- **Method**: DELETE
### 响应格式
```json
{
"status": 200,
"data": {
"success": true
}
}
```
## 5. 获取制度详情
### 请求信息
- **URL**: `GET /api/regulation/{regulationId}`
- **Method**: GET
### 响应格式
```json
{
"status": 200,
"data": {
"regulationId": "reg001",
"title": "员工考勤管理制度优化提案",
"content": "建议优化考勤管理制度,增加弹性工作时间...",
"regulationType": "人事制度",
"status": "VOTING",
"publisherId": "1",
"publisherName": "张三",
"publishTime": "2024-01-01T12:00:00",
"effectiveTime": "2024-01-01T12:00:00",
"expireTime": "2024-01-08T12:00:00",
"scope": "全体员工",
"level": "MEDIUM",
"version": "1.0",
"remark": "需要与人事部门协调实施",
"createBy": "admin",
"updateBy": "admin",
"createTime": "2024-01-01 10:00:00",
"updateTime": "2024-01-01 12:00:00",
"page": 1,
"pageSize": 10,
"delFlag": "0",
"voteFor": 15,
"voteAgainst": 3,
"voteAbstain": 2
}
}
```
## 6. 获取讨论列表
### 请求信息
- **URL**: `GET /api/regulation/{regulationId}/discussions`
- **Method**: GET
### 响应格式
```json
{
"status": 200,
"data": [
{
"id": "1",
"regulationId": "reg001",
"authorId": "2",
"authorName": "李四",
"content": "这个提案很有建设性,建议增加一些具体的实施细则。",
"createTime": "2024-01-01 11:00:00"
},
{
"id": "2",
"regulationId": "reg001",
"authorId": "3",
"authorName": "王五",
"content": "同意这个提案,但需要考虑实施成本。",
"createTime": "2024-01-01 14:30:00"
}
]
}
```
## 7. 发表评论
### 请求信息
- **URL**: `POST /api/regulation/{regulationId}/discussions`
- **Content-Type**: `application/json`
### 请求参数
```json
{
"content": "这个提案很有建设性,建议增加一些具体的实施细则。"
}
```
### 响应格式
```json
{
"status": 200,
"data": {
"id": "3",
"regulationId": "reg001",
"authorId": "1",
"authorName": "当前用户",
"content": "这个提案很有建设性,建议增加一些具体的实施细则。",
"createTime": "2024-01-25 10:30:00"
}
}
```
## 8. 提交投票
### 请求信息
- **URL**: `POST /api/regulation/{regulationId}/vote`
- **Content-Type**: `application/json`
### 请求参数
```json
{
"voteType": "FOR", // FOR: 赞成, AGAINST: 反对, ABSTAIN: 弃权
"reason": "这个提案很有建设性" // 可选
}
```
### 响应格式
```json
{
"status": 200,
"data": {
"success": true
}
}
```
## 9. 获取投票结果
### 请求信息
- **URL**: `GET /api/regulation/{regulationId}/vote-result`
- **Method**: GET
### 响应格式
```json
{
"status": 200,
"data": {
"regulationId": "reg001",
"voteFor": 15,
"voteAgainst": 3,
"voteAbstain": 2,
"totalVotes": 20,
"approvalRate": 0.75
}
}
```
## 10. 发布制度
### 请求信息
- **URL**: `POST /api/regulation/{regulationId}/publish`
- **Method**: POST
### 响应格式
```json
{
"status": 200,
"data": {
"success": true
}
}
```
## 11. 获取已发布制度列表
### 请求信息
- **URL**: `GET /api/regulation/published?page=1&size=10`
- **Method**: GET
### 请求参数
- `page`: 页码(必填)
- `size`: 页大小(必填)
### 响应格式
```json
{
"status": 200,
"data": {
"records": [
{
"regulationId": "reg002",
"title": "财务报销流程简化提案",
"content": "建议简化财务报销流程,提高工作效率...",
"regulationType": "财务制度",
"status": "PUBLISHED",
"publisherId": "2",
"publisherName": "李四",
"publishTime": "2024-01-15T14:30:00",
"effectiveTime": "2024-01-15T14:30:00",
"expireTime": "2024-12-31T23:59:59",
"scope": "财务部门及相关员工",
"level": "HIGH",
"version": "1.0",
"remark": "已获得财务部门支持",
"createBy": "admin",
"updateBy": "admin",
"createTime": "2024-01-15 14:30:00",
"updateTime": "2024-01-15 14:30:00",
"confirmStatus": "pending" // pending: 待确认, confirmed: 已确认
}
],
"total": 2,
"size": 10,
"current": 1,
"pages": 1
}
}
```
## 12. 确认制度知晓
### 请求信息
- **URL**: `POST /api/regulation/{regulationId}/confirm`
- **Content-Type**: `application/json`
### 请求参数
```json
{
"agreeTerms": true
}
```
### 响应格式
```json
{
"status": 200,
"data": {
"success": true
}
}
```
## 13. 批量确认制度
### 请求信息
- **URL**: `POST /api/regulation/confirm-all`
- **Method**: POST
### 响应格式
```json
{
"status": 200,
"data": {
"success": true,
"confirmedCount": 5
}
}
```
## 测试步骤
1. **执行建表语句**: 运行 `regulation_tables.sql`
2. **插入测试数据**: 运行 `regulation_test_data.sql`
3. **启动应用**: 确保后端服务正常运行
4. **测试接口**: 使用Postman或其他工具测试上述接口
## 注意事项
1. 所有接口都需要用户登录认证
2. ID字段使用UUID自动生成无需手动设置
3. 创建时间和更新时间会自动设置
4. 创建人和更新人会从当前登录用户获取
5. 制度状态包括DRAFT草稿、VOTING投票中、PUBLISHED已发布、ARCHIVED已归档
6. 投票类型FOR赞成、AGAINST反对、ABSTAIN弃权

View File

@ -0,0 +1,224 @@
# 制度模块说明文档
## 概述
制度模块是一个完整的企业制度管理系统,包含制度规范仓库、制度草案、个人制度提案等功能,支持讨论、投票、发布等完整的制度管理流程。
## 功能模块
### 1. 制度规范仓库 (RegulationEntity)
**功能描述:** 存储正式发布的制度,支持全员知晓承诺的确认
**主要功能:**
- 制度发布管理
- 制度版本控制
- 制度状态管理(草案、已发布、已归档)
- 制度生效时间管理
- 制度适用范围管理
**核心字段:**
- `regulation_id`: 制度ID
- `title`: 制度标题
- `content`: 制度内容
- `status`: 制度状态
- `publisher_id`: 发布人ID
- `publish_time`: 发布时间
- `effective_time`: 生效时间
- `expire_time`: 失效时间
### 2. 制度草案 (RegulationDraftEntity)
**功能描述:** 制度草案管理,包含讨论、投票、发布过程
**主要功能:**
- 草案创建和编辑
- 审核流程管理
- 投票系统
- 投票结果统计
- 草案状态跟踪
**核心字段:**
- `draft_id`: 草案ID
- `status`: 草案状态(草稿、审核中、已通过、已拒绝)
- `vote_status`: 投票状态
- `approve_votes`: 赞成票数
- `reject_votes`: 反对票数
- `pass_threshold`: 通过阈值
### 3. 制度提案 (RegulationProposalEntity)
**功能描述:** 个人制度提案,支持小组讨论
**主要功能:**
- 提案提交
- 讨论组管理
- 讨论结果统计
- 提案审核
- 提案转为草案
**核心字段:**
- `proposal_id`: 提案ID
- `proposer_id`: 提案人ID
- `discussion_group_id`: 讨论组ID
- `discussion_status`: 讨论状态
- `support_count`: 支持人数
- `oppose_count`: 反对人数
### 4. 制度投票 (RegulationVoteEntity)
**功能描述:** 投票系统,支持对草案和提案进行投票
**主要功能:**
- 投票记录管理
- 投票选项(赞成、反对、弃权)
- 投票统计
- 防重复投票
**核心字段:**
- `vote_id`: 投票ID
- `related_id`: 关联ID草案或提案
- `related_type`: 关联类型
- `vote_option`: 投票选项
- `voter_id`: 投票人ID
### 5. 制度确认 (RegulationConfirmationEntity)
**功能描述:** 全员知晓承诺的确认系统
**主要功能:**
- 确认任务创建
- 确认状态管理
- 确认统计
- 阅读时长记录
**核心字段:**
- `confirmation_id`: 确认ID
- `regulation_id`: 制度ID
- `confirmer_id`: 确认人ID
- `status`: 确认状态
- `read_duration`: 阅读时长
## 业务流程
### 制度发布流程
1. **提案阶段**
- 个人提交制度提案
- 进行小组讨论
- 讨论结果统计
2. **草案阶段**
- 提案转为草案
- 草案审核
- 投票表决
- 投票结果统计
3. **发布阶段**
- 通过投票的草案转为正式制度
- 制度发布
- 全员确认
### 投票流程
1. **开始投票**
- 设置投票时间
- 设置通过阈值
- 通知相关人员
2. **投票进行**
- 用户参与投票
- 实时统计投票结果
- 防重复投票
3. **投票结束**
- 统计最终结果
- 判断是否通过
- 更新相关状态
### 确认流程
1. **创建确认任务**
- 批量创建确认任务
- 通知相关人员
2. **确认进行**
- 用户阅读制度
- 确认知晓
- 记录阅读时长
3. **确认统计**
- 统计确认情况
- 生成确认报告
## 技术实现
### 数据库设计
- 采用MyBatis Plus框架
- 支持软删除
- 包含审计字段(创建人、创建时间、更新人、更新时间)
- 合理的索引设计
### 服务层设计
- 采用Service接口 + 实现类的设计模式
- 支持事务管理
- 统一的异常处理
- 统一的返回结果格式
### 核心特性
- **防重复操作**: 投票和确认都支持防重复机制
- **状态管理**: 完整的状态流转管理
- **统计功能**: 支持各种统计和报表功能
- **扩展性**: 模块化设计,易于扩展
## 使用说明
### 1. 数据库初始化
执行 `doc/regulation_tables.sql` 创建相关数据表。
### 2. 服务调用示例
```java
// 发布制度
RegulationEntity regulation = new RegulationEntity();
regulation.setTitle("员工手册");
regulation.setContent("员工手册内容...");
regulationService.publishRegulation(regulation);
// 创建草案
RegulationDraftEntity draft = new RegulationDraftEntity();
draft.setTitle("新制度草案");
draftService.createDraft(draft);
// 提交提案
RegulationProposalEntity proposal = new RegulationProposalEntity();
proposal.setTitle("制度改进提案");
proposalService.submitProposal(proposal);
// 投票
RegulationVoteEntity vote = new RegulationVoteEntity();
vote.setVoteOption("APPROVE");
voteService.vote(vote);
// 确认制度
RegulationConfirmationEntity confirmation = new RegulationConfirmationEntity();
confirmationService.confirmRegulation(confirmation);
```
## 注意事项
1. **数据一致性**: 所有操作都支持事务管理,确保数据一致性
2. **权限控制**: 需要配合权限系统使用,控制用户操作权限
3. **性能优化**: 大数据量时需要考虑分页和索引优化
4. **日志记录**: 重要操作需要记录操作日志
## 扩展建议
1. **消息通知**: 集成消息系统,支持邮件、短信通知
2. **工作流**: 集成工作流引擎,支持更复杂的审批流程
3. **文档管理**: 集成文档管理系统,支持附件上传
4. **报表系统**: 集成报表系统,支持更丰富的统计报表

128
doc/regulation_tables.sql Normal file
View File

@ -0,0 +1,128 @@
-- 制度模块数据库表创建脚本
-- @author wangna
-- @date 2025/07/28
-- 制度规范仓库表
CREATE TABLE `regulation` (
`regulation_id` varchar(64) NOT NULL COMMENT '制度ID',
`title` varchar(255) NOT NULL COMMENT '制度标题',
`content` text COMMENT '制度内容',
`regulation_type` varchar(50) DEFAULT NULL COMMENT '制度类型',
`status` varchar(20) DEFAULT 'DRAFT' COMMENT '制度状态DRAFT-草案PUBLISHED-已发布ARCHIVED-已归档',
`publisher_id` varchar(64) DEFAULT NULL COMMENT '发布人ID',
`publisher_name` varchar(100) DEFAULT NULL COMMENT '发布人姓名',
`publish_time` datetime DEFAULT NULL COMMENT '发布时间',
`effective_time` datetime DEFAULT NULL COMMENT '生效时间',
`expire_time` datetime DEFAULT NULL COMMENT '失效时间',
`scope` varchar(255) DEFAULT NULL COMMENT '适用范围',
`level` varchar(20) DEFAULT 'MEDIUM' COMMENT '制度级别HIGH-高级MEDIUM-中级LOW-低级',
`version` varchar(20) DEFAULT '1.0' COMMENT '版本号',
`remark` text COMMENT '备注',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`del_flag` char(1) DEFAULT '0' COMMENT '删除标志0代表存在1代表删除',
PRIMARY KEY (`regulation_id`),
KEY `idx_status` (`status`),
KEY `idx_type` (`regulation_type`),
KEY `idx_publisher` (`publisher_id`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='制度规范仓库';
-- 制度草案表
CREATE TABLE `regulation_draft` (
`draft_id` varchar(64) NOT NULL COMMENT '草案ID',
`title` varchar(255) NOT NULL COMMENT '制度标题',
`content` text COMMENT '制度内容',
`regulation_type` varchar(50) DEFAULT NULL COMMENT '制度类型',
`status` varchar(20) DEFAULT 'DRAFT' COMMENT '草案状态DRAFT-草稿REVIEWING-审核中APPROVED-已通过REJECTED-已拒绝',
`creator_id` varchar(64) DEFAULT NULL COMMENT '创建人ID',
`creator_name` varchar(100) DEFAULT NULL COMMENT '创建人姓名',
`reviewer_id` varchar(64) DEFAULT NULL COMMENT '审核人ID',
`reviewer_name` varchar(100) DEFAULT NULL COMMENT '审核人姓名',
`review_time` datetime DEFAULT NULL COMMENT '审核时间',
`review_comment` text COMMENT '审核意见',
`scope` varchar(255) DEFAULT NULL COMMENT '适用范围',
`level` varchar(20) DEFAULT 'MEDIUM' COMMENT '制度级别HIGH-高级MEDIUM-中级LOW-低级',
`version` varchar(20) DEFAULT '1.0' COMMENT '版本号',
`remark` text COMMENT '备注',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`del_flag` char(1) DEFAULT '0' COMMENT '删除标志0代表存在1代表删除',
PRIMARY KEY (`draft_id`),
KEY `idx_status` (`status`),
KEY `idx_creator` (`creator_id`),
KEY `idx_reviewer` (`reviewer_id`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='制度草案';
-- 制度提案表
CREATE TABLE `regulation_proposal` (
`proposal_id` varchar(64) NOT NULL COMMENT '提案ID',
`title` varchar(255) NOT NULL COMMENT '提案标题',
`content` text COMMENT '提案内容',
`proposal_type` varchar(50) DEFAULT NULL COMMENT '提案类型',
`status` varchar(20) DEFAULT 'SUBMITTED' COMMENT '提案状态SUBMITTED-已提交DISCUSSING-讨论中APPROVED-已通过REJECTED-已拒绝CONVERTED-已转为草案',
`proposer_id` varchar(64) DEFAULT NULL COMMENT '提案人ID',
`proposer_name` varchar(100) DEFAULT NULL COMMENT '提案人姓名',
`proposer_dept` varchar(100) DEFAULT NULL COMMENT '提案人部门',
`discussion_group_id` varchar(64) DEFAULT NULL COMMENT '讨论组ID',
`discussion_group_name` varchar(100) DEFAULT NULL COMMENT '讨论组名称',
`discussion_start_time` datetime DEFAULT NULL COMMENT '讨论开始时间',
`discussion_end_time` datetime DEFAULT NULL COMMENT '讨论结束时间',
`discussion_status` varchar(20) DEFAULT 'NOT_STARTED' COMMENT '讨论状态NOT_STARTED-未开始DISCUSSING-讨论中FINISHED-已结束',
`support_count` int DEFAULT 0 COMMENT '支持人数',
`oppose_count` int DEFAULT 0 COMMENT '反对人数',
`total_participants` int DEFAULT 0 COMMENT '总参与人数',
`reviewer_id` varchar(64) DEFAULT NULL COMMENT '审核人ID',
`reviewer_name` varchar(100) DEFAULT NULL COMMENT '审核人姓名',
`review_time` datetime DEFAULT NULL COMMENT '审核时间',
`review_comment` text COMMENT '审核意见',
`converted_draft_id` varchar(64) DEFAULT NULL COMMENT '转为草案ID',
`scope` varchar(255) DEFAULT NULL COMMENT '适用范围',
`level` varchar(20) DEFAULT 'MEDIUM' COMMENT '制度级别HIGH-高级MEDIUM-中级LOW-低级',
`urgency_level` varchar(20) DEFAULT 'MEDIUM' COMMENT '紧急程度HIGH-高MEDIUM-中LOW-低',
`remark` text COMMENT '备注',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`del_flag` char(1) DEFAULT '0' COMMENT '删除标志0代表存在1代表删除',
PRIMARY KEY (`proposal_id`),
KEY `idx_status` (`status`),
KEY `idx_proposer` (`proposer_id`),
KEY `idx_reviewer` (`reviewer_id`),
KEY `idx_discussion_status` (`discussion_status`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='制度提案';
-- 制度确认表
CREATE TABLE `regulation_confirmation` (
`confirmation_id` varchar(64) NOT NULL COMMENT '确认ID',
`regulation_id` varchar(64) NOT NULL COMMENT '制度ID',
`regulation_title` varchar(255) DEFAULT NULL COMMENT '制度标题',
`confirmer_id` varchar(64) NOT NULL COMMENT '确认人ID',
`confirmer_name` varchar(100) DEFAULT NULL COMMENT '确认人姓名',
`confirmer_dept` varchar(100) DEFAULT NULL COMMENT '确认人部门',
`status` varchar(20) DEFAULT 'PENDING' COMMENT '确认状态PENDING-待确认CONFIRMED-已确认DECLINED-已拒绝',
`confirm_time` datetime DEFAULT NULL COMMENT '确认时间',
`confirm_comment` text COMMENT '确认意见',
`read_duration` int DEFAULT 0 COMMENT '阅读时长(秒)',
`ip_address` varchar(50) DEFAULT NULL COMMENT 'IP地址',
`user_agent` varchar(500) DEFAULT NULL COMMENT '用户代理',
`remark` text COMMENT '备注',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`del_flag` char(1) DEFAULT '0' COMMENT '删除标志0代表存在1代表删除',
PRIMARY KEY (`confirmation_id`),
UNIQUE KEY `uk_confirmer_regulation` (`confirmer_id`, `regulation_id`),
KEY `idx_regulation` (`regulation_id`),
KEY `idx_confirmer` (`confirmer_id`),
KEY `idx_status` (`status`),
KEY `idx_confirm_time` (`confirm_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='制度确认';

View File

@ -0,0 +1,35 @@
-- 制度模块测试数据
-- @author wangna
-- @date 2025/07/29
-- 插入测试用户数据(如果不存在)
INSERT INTO `sys_user` (`user_id`, `username`, `nickname`, `email`, `phonenumber`, `sex`, `avatar`, `password`, `status`, `login_ip`, `login_date`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`) VALUES
('1', 'admin', '管理员', 'admin@example.com', '13800138000', '0', '', '$2a$10$7JB720yubVSOfvVWdBYoOeymFwJ9WxqHhqjqKqKqKqKqKqKqKqKqK', '0', '127.0.0.1', '2024-01-01 00:00:00', 'admin', '2024-01-01 00:00:00', 'admin', '2024-01-01 00:00:00', '管理员', '0'),
('2', 'user1', '张三', 'zhangsan@example.com', '13800138001', '0', '', '$2a$10$7JB720yubVSOfvVWdBYoOeymFwJ9WxqHhqjqKqKqKqKqKqKqKqKqK', '0', '127.0.0.1', '2024-01-01 00:00:00', 'admin', '2024-01-01 00:00:00', 'admin', '2024-01-01 00:00:00', '普通用户', '0'),
('3', 'user2', '李四', 'lisi@example.com', '13800138002', '0', '', '$2a$10$7JB720yubVSOfvVWdBYoOeymFwJ9WxqHhqjqKqKqKqKqKqKqKqKqK', '0', '127.0.0.1', '2024-01-01 00:00:00', 'admin', '2024-01-01 00:00:00', 'admin', '2024-01-01 00:00:00', '普通用户', '0'),
('4', 'user3', '王五', 'wangwu@example.com', '13800138003', '0', '', '$2a$10$7JB720yubVSOfvVWdBYoOeymFwJ9WxqHhqjqKqKqKqKqKqKqKqKqK', '0', '127.0.0.1', '2024-01-01 00:00:00', 'admin', '2024-01-01 00:00:00', 'admin', '2024-01-01 00:00:00', '普通用户', '0')
ON DUPLICATE KEY UPDATE `update_time` = NOW();
-- 插入测试制度数据符合前端API格式
INSERT INTO `regulation` (`regulation_id`, `title`, `content`, `regulation_type`, `status`, `publisher_id`, `publisher_name`, `publish_time`, `effective_time`, `expire_time`, `scope`, `level`, `version`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`) VALUES
('reg001', '员工考勤管理制度优化提案', '建议优化考勤管理制度,增加弹性工作时间,提高员工工作积极性...', '人事制度', 'VOTING', '2', '张三', '2024-01-01 12:00:00', '2024-01-01 12:00:00', '2024-01-08 12:00:00', '全体员工', 'MEDIUM', '1.0', 'admin', '2024-01-01 10:00:00', 'admin', '2024-01-01 12:00:00', '需要与人事部门协调实施', '0'),
('reg002', '财务报销流程简化提案', '建议简化财务报销流程,提高工作效率,减少审批环节...', '财务制度', 'PUBLISHED', '3', '李四', '2024-01-15 14:30:00', '2024-01-15 14:30:00', '2024-12-31 23:59:59', '财务部门及相关员工', 'HIGH', '1.0', 'admin', '2024-01-15 14:00:00', 'admin', '2024-01-15 14:30:00', '已获得财务部门支持', '0'),
('reg003', '技术管理制度', '为规范技术管理流程,提高技术管理水平,特制定本制度...', '技术制度', 'DRAFT', '2', '张三', NULL, NULL, NULL, '技术部门', 'MEDIUM', '1.0', 'admin', '2024-01-25 16:00:00', 'admin', '2024-01-25 16:00:00', '技术管理制度草案', '0'),
('reg004', '项目管理制度', '为规范项目管理流程,提高项目执行效率,特制定本制度...', '项目制度', 'ARCHIVED', '1', '管理员', '2024-01-10 11:00:00', '2024-01-11 00:00:00', '2024-12-31 23:59:59', '项目部门', 'MEDIUM', '1.0', 'admin', '2024-01-10 10:00:00', 'admin', '2024-01-10 11:00:00', '项目管理规范', '0'),
('reg005', '远程办公管理制度', '随着远程办公的普及,需要制定相应的管理制度来规范远程办公行为...', '人事制度', 'DRAFT', '2', '张三', NULL, NULL, NULL, '全体员工', 'HIGH', '1.0', 'admin', '2024-01-27 10:00:00', 'admin', '2024-01-27 10:00:00', '远程办公管理提案', '0'),
('reg006', '数据安全管理制度', '为保护公司数据安全,防止数据泄露,需要制定数据安全管理制度...', '安全制度', 'PENDING', '2', '张三', NULL, NULL, NULL, '全体员工', 'HIGH', '1.0', 'admin', '2024-01-28 09:00:00', 'admin', '2024-01-28 09:00:00', '数据安全管理提案', '0');
-- 插入制度草案数据
INSERT INTO `regulation_draft` (`draft_id`, `regulation_id`, `title`, `content`, `draft_type`, `status`, `creator_id`, `creator_name`, `reviewer_id`, `reviewer_name`, `vote_status`, `vote_start_time`, `vote_end_time`, `approval_status`, `approval_time`, `approval_comment`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`) VALUES
('draft_001', 'reg003', '技术管理制度', '为规范技术管理流程,提高技术管理水平,特制定本制度...', '技术制度', 'DRAFT', '2', '张三', '1', '管理员', 'PENDING', NULL, NULL, 'PENDING', NULL, NULL, 'admin', '2024-01-25 16:00:00', 'admin', '2024-01-25 16:00:00', '技术管理制度草案', '0'),
('draft_002', 'reg005', '远程办公管理制度', '随着远程办公的普及,需要制定相应的管理制度来规范远程办公行为...', '人事制度', 'REVIEWING', '2', '张三', '1', '管理员', 'VOTING', '2024-01-26 09:00:00', '2024-01-28 18:00:00', 'PENDING', NULL, NULL, 'admin', '2024-01-26 08:00:00', 'admin', '2024-01-26 09:00:00', '远程办公管理制度草案', '0');
-- 插入制度提案数据
INSERT INTO `regulation_proposal` (`proposal_id`, `regulation_id`, `title`, `description`, `proposal_type`, `status`, `proposer_id`, `proposer_name`, `proposer_dept`, `reviewer_id`, `reviewer_name`, `review_status`, `review_time`, `review_comment`, `priority`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`) VALUES
('proposal_001', 'reg001', '员工考勤管理制度优化提案', '建议优化考勤管理制度,增加弹性工作时间,提高员工工作积极性...', '人事制度', 'APPROVED', '2', '张三', '技术部', '1', '管理员', 'APPROVED', '2024-01-27 14:00:00', '同意提案,可以开始制定制度', 'HIGH', 'admin', '2024-01-27 10:00:00', 'admin', '2024-01-27 14:00:00', '员工考勤管理提案', '0'),
('proposal_002', 'reg006', '数据安全管理制度', '为保护公司数据安全,防止数据泄露,需要制定数据安全管理制度...', '安全制度', 'PENDING', '2', '张三', '技术部', '1', '管理员', 'PENDING', NULL, NULL, 'HIGH', 'admin', '2024-01-28 09:00:00', 'admin', '2024-01-28 09:00:00', '数据安全管理提案', '0');
-- 插入制度确认数据
INSERT INTO `regulation_confirmation` (`confirmation_id`, `regulation_id`, `confirmer_id`, `confirmer_name`, `confirmer_dept`, `status`, `confirm_time`, `confirm_comment`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`) VALUES
('confirm_001', 'reg002', '2', '张三', '技术部', 'CONFIRMED', '2024-01-16 10:00:00', '已阅读并确认知晓', 'admin', '2024-01-16 10:00:00', 'admin', '2024-01-16 10:00:00', '财务报销制度确认', '0'),
('confirm_002', 'reg002', '3', '李四', '财务部', 'CONFIRMED', '2024-01-21 15:00:00', '已阅读并确认知晓', 'admin', '2024-01-21 15:00:00', 'admin', '2024-01-21 15:00:00', '财务报销制度确认', '0');

View File

@ -0,0 +1,77 @@
package com.dite.znpt.web.controller;
import com.dite.znpt.domain.Result;
import com.dite.znpt.domain.entity.RegulationEntity;
import com.dite.znpt.domain.dto.RegulationDiscussionDTO;
import com.dite.znpt.domain.dto.RegulationConfirmDTO;
import com.dite.znpt.service.RegulationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Api(tags = "制度规范")
@RestController
@RequestMapping("/regulation")
public class RegulationController {
@Autowired
private RegulationService regulationService;
@ApiOperation(value = "获取制度列表", httpMethod = "GET")
@GetMapping
public Result getRegulationList(@RequestParam int page, @RequestParam int size) {
return regulationService.getRegulationList(page, size, null, null);
}
@ApiOperation(value = "创建制度提案", httpMethod = "POST")
@PostMapping("/proposal")
public Result createRegulationProposal(@RequestBody RegulationEntity regulation) {
return regulationService.createRegulationProposal(regulation);
}
@ApiOperation(value = "更新制度提案", httpMethod = "PUT")
@PutMapping("/proposal/{regulationId}")
public Result updateRegulationProposal(@PathVariable String regulationId, @RequestBody RegulationEntity regulation) {
regulation.setRegulationId(regulationId);
return regulationService.updateRegulationProposal(regulation);
}
@ApiOperation(value = "获取制度详情", httpMethod = "GET")
@GetMapping("/{regulationId}")
public Result getRegulationDetail(@PathVariable String regulationId) {
return regulationService.getRegulationDetail(regulationId);
}
@ApiOperation(value = "获取讨论列表", httpMethod = "GET")
@GetMapping("/{regulationId}/discussions")
public Result getRegulationDiscussions(@PathVariable String regulationId) {
return regulationService.getRegulationDiscussions(regulationId);
}
@ApiOperation(value = "发表评论", httpMethod = "POST")
@PostMapping("/{regulationId}/discussions")
public Result createDiscussion(@PathVariable String regulationId, @RequestBody RegulationDiscussionDTO discussion) {
discussion.setRegulationId(regulationId);
return regulationService.createDiscussion(discussion);
}
@ApiOperation(value = "发布制度", httpMethod = "POST")
@PostMapping("/{regulationId}/publish")
public Result publishRegulation(@PathVariable String regulationId) {
return regulationService.publishRegulation(regulationId);
}
@ApiOperation(value = "获取已发布制度列表", httpMethod = "GET")
@GetMapping("/published")
public Result getPublishedRegulations(@RequestParam int page, @RequestParam int size) {
return regulationService.getPublishedRegulations(page, size);
}
@ApiOperation(value = "确认制度知晓", httpMethod = "POST")
@PostMapping("/{regulationId}/confirm")
public Result confirmRegulation(@PathVariable String regulationId, @RequestBody RegulationConfirmDTO confirm) {
return regulationService.confirmRegulation(regulationId, confirm);
}
}