Compare commits

...

2 Commits

Author SHA1 Message Date
wangna0328 75dd5815d2 制度代码最终版 2025-08-04 22:17:46 +08:00
wangna0328 6ceda40d18 恢复如初,但发现其他bug 2025-08-04 19:32:38 +08:00
10 changed files with 85 additions and 36 deletions

View File

@ -42,7 +42,7 @@ public class RegulationEntity extends AuditableEntity implements Serializable {
@ExcelProperty("制度类型") @ExcelProperty("制度类型")
@ApiModelProperty("制度类型") @ApiModelProperty("制度类型")
@TableField("regulation_type") @TableField("regulation_type")
private String regulationType; private String type;
@ExcelProperty("制度状态") @ExcelProperty("制度状态")
@ApiModelProperty("制度状态DRAFT-草案APPROVED-已公示PUBLISHED-已发布ARCHIVED-已归档") @ApiModelProperty("制度状态DRAFT-草案APPROVED-已公示PUBLISHED-已发布ARCHIVED-已归档")
@ -96,4 +96,8 @@ public class RegulationEntity extends AuditableEntity implements Serializable {
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty("创建人姓名") @ApiModelProperty("创建人姓名")
private String createByName; private String createByName;
@TableField(exist = false)
@ApiModelProperty("制度类型")
private String regulationType;
} }

View File

@ -33,10 +33,10 @@ public class RegulationTypeEntity extends AuditableEntity implements Serializabl
@TableField("type_name") @TableField("type_name")
private String typeName; private String typeName;
@ExcelProperty("状态") @ExcelProperty("是否启用")
@ApiModelProperty("状态ENABLED-启用DISABLED-禁用") @ApiModelProperty("是否启用1-启用0-禁用)")
@TableField("status") @TableField("is_enabled")
private String status; private String isEnabled;
@ExcelProperty("排序顺序") @ExcelProperty("排序顺序")
@ApiModelProperty("排序顺序") @ApiModelProperty("排序顺序")
@ -55,5 +55,5 @@ public class RegulationTypeEntity extends AuditableEntity implements Serializabl
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty("创建人姓名") @ApiModelProperty("创建人姓名")
private String createByName; private String createrName;
} }

View File

@ -21,11 +21,15 @@ public interface RegulationMapper extends BaseMapper<RegulationEntity> {
* @param type 类型 * @param type 类型
* @param title 提案标题 * @param title 提案标题
* @param proposer 提案人 * @param proposer 提案人
* @param confirmStatus 确认状态
* @param userId 当前用户ID
* @return 分页结果 * @return 分页结果
*/ */
Page<RegulationEntity> selectRegulationListWithCreator(Page<RegulationEntity> page, Page<RegulationEntity> selectRegulationListWithCreator(Page<RegulationEntity> page,
@Param("status") String status, @Param("status") String status,
@Param("type") String type, @Param("type") String type,
@Param("title") String title, @Param("title") String title,
@Param("proposer") String proposer); @Param("proposer") String proposer,
@Param("confirmStatus") String confirmStatus,
@Param("userId") String userId);
} }

View File

@ -19,9 +19,10 @@ public interface RegulationService extends IService<RegulationEntity> {
* @param type 类型 * @param type 类型
* @param title 提案标题 * @param title 提案标题
* @param proposer 提案人 * @param proposer 提案人
* @param confirmStatus 确认状态
* @return 结果 * @return 结果
*/ */
Result getRegulationList(Integer page, Integer pageSize, String status, String type, String title, String proposer); Result getRegulationList(Integer page, Integer pageSize, String status, String type, String title, String proposer, String confirmStatus);
/** /**
* 创建制度提案 * 创建制度提案

View File

@ -16,7 +16,7 @@ public interface RegulationTypeService extends IService<RegulationTypeEntity> {
* @param page 页码 * @param page 页码
* @param size 页大小 * @param size 页大小
* @param typeName 类型名称 * @param typeName 类型名称
* @param status 状态 * @param status 是否启用1-启用0-禁用
* @param remark 备注 * @param remark 备注
* @return 结果 * @return 结果
*/ */

View File

@ -68,28 +68,13 @@ public class RegulationServiceImpl extends ServiceImpl<RegulationMapper, Regulat
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Result getRegulationList(Integer page, Integer pageSize, String status, String type, String title, String proposer) { public Result getRegulationList(Integer page, Integer pageSize, String status, String type, String title, String proposer, String confirmStatus) {
try { try {
Page<RegulationEntity> pageParam = new Page<>(page, pageSize); Page<RegulationEntity> pageParam = new Page<>(page, pageSize);
String userId = StpUtil.getLoginIdAsString();
// 使用关联查询获取创建人姓名 // 使用关联查询获取创建人姓名和确认状态
Page<RegulationEntity> result = this.baseMapper.selectRegulationListWithCreator(pageParam, status, type, title, proposer); Page<RegulationEntity> result = this.baseMapper.selectRegulationListWithCreator(pageParam, status, type, title, proposer, confirmStatus, userId);
// 如果是获取已发布的制度需要添加确认状态
if (status != null && "PUBLISHED".equals(status)) {
String userId = StpUtil.getLoginIdAsString();
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); return Result.ok(result);
} catch (Exception e) { } catch (Exception e) {
@ -203,6 +188,11 @@ public class RegulationServiceImpl extends ServiceImpl<RegulationMapper, Regulat
} }
} }
// 设置制度类型名称
if (regulation.getType() != null && !regulation.getType().isEmpty()) {
regulation.setRegulationType(regulation.getType());
}
return Result.ok(regulation); return Result.ok(regulation);
} catch (Exception e) { } catch (Exception e) {
return Result.error("获取制度详情失败:" + e.getMessage()); return Result.error("获取制度详情失败:" + e.getMessage());

View File

@ -109,7 +109,7 @@ public class RegulationTypeServiceImpl extends ServiceImpl<RegulationTypeMapper,
// 检查制度表中是否有使用此类型的记录包括所有状态 // 检查制度表中是否有使用此类型的记录包括所有状态
long regulationCount = regulationMapper.selectCount( long regulationCount = regulationMapper.selectCount(
new LambdaQueryWrapper<RegulationEntity>() new LambdaQueryWrapper<RegulationEntity>()
.eq(RegulationEntity::getRegulationType, typeName) .eq(RegulationEntity::getType, typeName)
.eq(RegulationEntity::getDelFlag, "0") .eq(RegulationEntity::getDelFlag, "0")
); );
// 如果有制度使用此类型则不允许删除 // 如果有制度使用此类型则不允许删除

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dite.znpt.mapper.RegulationMapper">
<!-- 分页查询制度列表(包含创建人姓名和制度类型名称) -->
<select id="selectRegulationListWithCreator" resultType="com.dite.znpt.domain.entity.RegulationEntity">
SELECT
r.*,
u.name as createByName,
rt.type_name as regulationType,
CASE
WHEN rc.status IS NOT NULL THEN rc.status
ELSE 'PENDING'
END as confirmStatus
FROM regulation r
LEFT JOIN user u ON r.create_by COLLATE utf8mb4_general_ci = u.user_id COLLATE utf8mb4_general_ci
LEFT JOIN regulation_type rt ON r.regulation_type = rt.type_name
LEFT JOIN regulation_confirmation rc ON r.regulation_id = rc.regulation_id
AND rc.confirmer_id = #{userId}
AND rc.del_flag = '0'
<where>
r.del_flag = '0'
<if test="status != null and status != ''">
AND r.status = #{status}
</if>
<if test="type != null and type != ''">
AND r.regulation_type = #{type}
</if>
<if test="title != null and title != ''">
AND r.title LIKE CONCAT('%', #{title}, '%')
</if>
<if test="proposer != null and proposer != ''">
AND u.name LIKE CONCAT('%', #{proposer}, '%')
</if>
<if test="confirmStatus != null and confirmStatus != ''">
<choose>
<when test="confirmStatus == 'CONFIRMED'">
AND rc.status = 'CONFIRMED'
</when>
<when test="confirmStatus == 'PENDING'">
AND rc.status IS NULL
</when>
</choose>
</if>
</where>
ORDER BY r.create_time DESC
</select>
</mapper>

View File

@ -3,24 +3,24 @@
<mapper namespace="com.dite.znpt.mapper.RegulationTypeMapper"> <mapper namespace="com.dite.znpt.mapper.RegulationTypeMapper">
<sql id="Base_Column_List"> <sql id="Base_Column_List">
rt.type_id, rt.type_name, rt.status, rt.sort_order, rt.remark, rt.del_flag, rt.type_id, rt.type_name, rt.is_enabled, rt.sort_order, rt.remark, rt.del_flag,
rt.create_by, rt.create_time, rt.update_by, rt.update_time rt.create_by, rt.create_time, rt.update_by, rt.update_time
</sql> </sql>
<select id="selectRegulationTypeListWithCreator" resultType="com.dite.znpt.domain.entity.RegulationTypeEntity"> <select id="selectRegulationTypeListWithCreator" resultType="com.dite.znpt.domain.entity.RegulationTypeEntity">
SELECT SELECT
rt.type_id, rt.type_name, rt.status, rt.sort_order, rt.remark, rt.del_flag, rt.type_id, rt.type_name, rt.is_enabled, rt.sort_order, rt.remark, rt.del_flag,
rt.create_by, rt.create_time, rt.update_by, rt.update_time, rt.create_by, rt.create_time, rt.update_by, rt.update_time,
u.name as createByName u.name as createrName
FROM regulation_type rt FROM regulation_type rt
LEFT JOIN user u ON rt.create_by = u.user_id LEFT JOIN user u ON rt.create_by COLLATE utf8mb4_general_ci = u.user_id COLLATE utf8mb4_general_ci
<where> <where>
rt.del_flag = '0' rt.del_flag = '0'
<if test="typeName != null and typeName != ''"> <if test="typeName != null and typeName != ''">
AND rt.type_name LIKE concat('%', #{typeName}, '%') AND rt.type_name LIKE concat('%', #{typeName}, '%')
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
AND rt.status = #{status} AND rt.is_enabled = #{status}
</if> </if>
<if test="remark != null and remark != ''"> <if test="remark != null and remark != ''">
AND rt.remark LIKE concat('%', #{remark}, '%') AND rt.remark LIKE concat('%', #{remark}, '%')

View File

@ -28,8 +28,9 @@ public class RegulationController {
@RequestParam(required = false) String status, @RequestParam(required = false) String status,
@RequestParam(required = false) String type, @RequestParam(required = false) String type,
@RequestParam(required = false) String title, @RequestParam(required = false) String title,
@RequestParam(required = false) String proposer) { @RequestParam(required = false) String proposer,
return regulationService.getRegulationList(page, size, status, type, title, proposer); @RequestParam(required = false) String confirmStatus) {
return regulationService.getRegulationList(page, size, status, type, title, proposer, confirmStatus);
} }
@ApiOperation(value = "创建制度提案", httpMethod = "POST") @ApiOperation(value = "创建制度提案", httpMethod = "POST")