隐患规则
This commit is contained in:
@ -1,26 +1,27 @@
|
||||
package org.dromara.safety.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.safety.domain.vo.HazardRuleVo;
|
||||
import org.dromara.safety.domain.bo.HazardRuleBo;
|
||||
import org.dromara.safety.service.IHazardRuleService;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.safety.domain.bo.HazardRuleBo;
|
||||
import org.dromara.safety.domain.vo.HazardRuleVo;
|
||||
import org.dromara.safety.service.IHazardRuleService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 隐患分级通知规则
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package org.dromara.safety.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@ -22,6 +24,7 @@ public class HazardRuleNotifyObject implements Serializable {
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private Long ruleId;
|
||||
|
||||
/**
|
||||
|
||||
@ -10,6 +10,9 @@ import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.safety.domain.HazardRule;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 隐患分级通知规则业务对象 hazard_rule
|
||||
*
|
||||
@ -21,6 +24,9 @@ import org.dromara.safety.domain.HazardRule;
|
||||
@AutoMapper(target = HazardRule.class, reverseConvertGenerate = false)
|
||||
public class HazardRuleBo extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1523915364119852788L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ -72,7 +78,6 @@ public class HazardRuleBo extends BaseEntity {
|
||||
/**
|
||||
* 额外设置
|
||||
*/
|
||||
@NotBlank(message = "额外设置不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String extraSetting;
|
||||
|
||||
/**
|
||||
@ -80,4 +85,10 @@ public class HazardRuleBo extends BaseEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 通知对象
|
||||
*/
|
||||
@NotNull(message = "通知对象不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private List<HazardRuleNotifyObjectBo> notifyObjects;
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,8 @@
|
||||
package org.dromara.safety.domain.bo;
|
||||
|
||||
import org.dromara.safety.domain.HazardRuleNotifyObject;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 隐患规则通知对象业务对象 hazard_rule_notify_object
|
||||
@ -16,27 +11,18 @@ import jakarta.validation.constraints.*;
|
||||
* @date 2025-12-03
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = HazardRuleNotifyObject.class, reverseConvertGenerate = false)
|
||||
public class HazardRuleNotifyObjectBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
@NotNull(message = "规则ID不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long ruleId;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HazardRuleNotifyObjectBo {
|
||||
|
||||
/**
|
||||
* 通知ID
|
||||
*/
|
||||
@NotNull(message = "通知ID不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long notifyId;
|
||||
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
@NotBlank(message = "通知类型不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String notifyType;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -36,11 +36,15 @@ public class HazardRuleNotifyObjectVo implements Serializable {
|
||||
@ExcelProperty(value = "通知ID")
|
||||
private Long notifyId;
|
||||
|
||||
/**
|
||||
* 通知名称
|
||||
*/
|
||||
private String notifyName;
|
||||
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
@ExcelProperty(value = "通知类型")
|
||||
private String notifyType;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import org.dromara.safety.domain.HazardRule;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -89,5 +90,9 @@ public class HazardRuleVo implements Serializable {
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 通知对象
|
||||
*/
|
||||
List<HazardRuleNotifyObjectVo> notifyObjects;
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
package org.dromara.safety.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.safety.domain.HazardRuleNotifyObject;
|
||||
import org.dromara.safety.domain.bo.HazardRuleNotifyObjectBo;
|
||||
import org.dromara.safety.domain.vo.HazardRuleNotifyObjectVo;
|
||||
import org.dromara.safety.domain.vo.HazardRuleVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -19,52 +16,25 @@ import java.util.List;
|
||||
public interface IHazardRuleNotifyObjectService extends IService<HazardRuleNotifyObject> {
|
||||
|
||||
/**
|
||||
* 查询隐患规则通知对象
|
||||
* 根据规则查询通知对象
|
||||
*
|
||||
* @param ruleId 主键
|
||||
* @return 隐患规则通知对象
|
||||
* @param ruleId 规则id
|
||||
* @return 通知对象
|
||||
*/
|
||||
HazardRuleNotifyObjectVo queryById(Long ruleId);
|
||||
List<HazardRuleNotifyObjectVo> queryVoByRule(Long ruleId);
|
||||
|
||||
/**
|
||||
* 分页查询隐患规则通知对象列表
|
||||
* 根据对象列表查询对象列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 隐患规则通知对象分页列表
|
||||
* @param objectList 对象列表
|
||||
* @return 对象列表
|
||||
*/
|
||||
TableDataInfo<HazardRuleNotifyObjectVo> queryPageList(HazardRuleNotifyObjectBo bo, PageQuery pageQuery);
|
||||
List<HazardRuleNotifyObjectVo> queryVo(List<HazardRuleNotifyObject> objectList);
|
||||
|
||||
/**
|
||||
* 查询符合条件的隐患规则通知对象列表
|
||||
* 补充数据
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 隐患规则通知对象列表
|
||||
* @param voList 规则列表
|
||||
*/
|
||||
List<HazardRuleNotifyObjectVo> queryList(HazardRuleNotifyObjectBo bo);
|
||||
|
||||
/**
|
||||
* 新增隐患规则通知对象
|
||||
*
|
||||
* @param bo 隐患规则通知对象
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(HazardRuleNotifyObjectBo bo);
|
||||
|
||||
/**
|
||||
* 修改隐患规则通知对象
|
||||
*
|
||||
* @param bo 隐患规则通知对象
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(HazardRuleNotifyObjectBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除隐患规则通知对象信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
void supplementDataByRule(List<HazardRuleVo> voList);
|
||||
}
|
||||
|
||||
@ -1,24 +1,21 @@
|
||||
package org.dromara.safety.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.safety.domain.HazardRuleNotifyObject;
|
||||
import org.dromara.safety.domain.bo.HazardRuleNotifyObjectBo;
|
||||
import org.dromara.safety.domain.vo.HazardRuleNotifyObjectVo;
|
||||
import org.dromara.safety.domain.vo.HazardRuleVo;
|
||||
import org.dromara.safety.mapper.HazardRuleNotifyObjectMapper;
|
||||
import org.dromara.safety.service.IHazardRuleNotifyObjectService;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 隐患规则通知对象Service业务层处理
|
||||
@ -31,101 +28,81 @@ import java.util.Map;
|
||||
public class HazardRuleNotifyObjectServiceImpl extends ServiceImpl<HazardRuleNotifyObjectMapper, HazardRuleNotifyObject>
|
||||
implements IHazardRuleNotifyObjectService {
|
||||
|
||||
private final ISysUserService userService;
|
||||
|
||||
/**
|
||||
* 查询隐患规则通知对象
|
||||
* 根据规则查询通知对象
|
||||
*
|
||||
* @param ruleId 主键
|
||||
* @return 隐患规则通知对象
|
||||
* @param ruleId 规则id
|
||||
* @return 通知对象
|
||||
*/
|
||||
@Override
|
||||
public HazardRuleNotifyObjectVo queryById(Long ruleId) {
|
||||
return baseMapper.selectVoById(ruleId);
|
||||
public List<HazardRuleNotifyObjectVo> queryVoByRule(Long ruleId) {
|
||||
List<HazardRuleNotifyObject> objectList = this.lambdaQuery()
|
||||
.eq(HazardRuleNotifyObject::getRuleId, ruleId)
|
||||
.list();
|
||||
return this.queryVo(objectList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询隐患规则通知对象列表
|
||||
* 根据对象列表查询对象列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 隐患规则通知对象分页列表
|
||||
* @param objectList 对象列表
|
||||
* @return 对象列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<HazardRuleNotifyObjectVo> queryPageList(HazardRuleNotifyObjectBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<HazardRuleNotifyObject> lqw = buildQueryWrapper(bo);
|
||||
Page<HazardRuleNotifyObjectVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
public List<HazardRuleNotifyObjectVo> queryVo(List<HazardRuleNotifyObject> objectList) {
|
||||
List<HazardRuleNotifyObjectVo> voList = new ArrayList<>();
|
||||
Map<String, List<HazardRuleNotifyObject>> map = objectList.stream()
|
||||
.collect(Collectors.groupingBy(HazardRuleNotifyObject::getNotifyType));
|
||||
for (Map.Entry<String, List<HazardRuleNotifyObject>> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
List<HazardRuleNotifyObject> value = entry.getValue();
|
||||
switch (key) {
|
||||
case "1": {
|
||||
List<Long> userIds = value.stream()
|
||||
.map(HazardRuleNotifyObject::getNotifyId)
|
||||
.toList();
|
||||
List<SysUserVo> userVos = userService.selectUserByIds(userIds, null);
|
||||
Map<Long, String> userNameMap = userVos.stream()
|
||||
.collect(Collectors.toMap(SysUserVo::getUserId, SysUserVo::getNickName, (k, v) -> k));
|
||||
List<HazardRuleNotifyObjectVo> vos = value.stream().map(v -> {
|
||||
HazardRuleNotifyObjectVo vo = new HazardRuleNotifyObjectVo();
|
||||
vo.setRuleId(v.getRuleId());
|
||||
vo.setNotifyId(v.getNotifyId());
|
||||
vo.setNotifyName(userNameMap.getOrDefault(v.getNotifyId(), ""));
|
||||
vo.setNotifyType(key);
|
||||
return vo;
|
||||
}).toList();
|
||||
voList.addAll(vos);
|
||||
}
|
||||
case null, default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return voList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的隐患规则通知对象列表
|
||||
* 补充数据
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 隐患规则通知对象列表
|
||||
* @param voList 规则列表
|
||||
*/
|
||||
@Override
|
||||
public List<HazardRuleNotifyObjectVo> queryList(HazardRuleNotifyObjectBo bo) {
|
||||
LambdaQueryWrapper<HazardRuleNotifyObject> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
public void supplementDataByRule(List<HazardRuleVo> voList) {
|
||||
if (CollUtil.isEmpty(voList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<HazardRuleNotifyObject> buildQueryWrapper(HazardRuleNotifyObjectBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<HazardRuleNotifyObject> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getRuleId() != null, HazardRuleNotifyObject::getRuleId, bo.getRuleId());
|
||||
lqw.eq(bo.getNotifyId() != null, HazardRuleNotifyObject::getNotifyId, bo.getNotifyId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getNotifyType()), HazardRuleNotifyObject::getNotifyType, bo.getNotifyType());
|
||||
return lqw;
|
||||
List<Long> ruleIds = voList.stream().map(HazardRuleVo::getId).toList();
|
||||
List<HazardRuleNotifyObject> objectList = this.lambdaQuery()
|
||||
.in(HazardRuleNotifyObject::getRuleId, ruleIds)
|
||||
.list();
|
||||
List<HazardRuleNotifyObjectVo> objectVos = this.queryVo(objectList);
|
||||
Map<Long, List<HazardRuleNotifyObjectVo>> map = objectVos.stream()
|
||||
.collect(Collectors.groupingBy(HazardRuleNotifyObjectVo::getRuleId));
|
||||
for (HazardRuleVo vo : voList) {
|
||||
List<HazardRuleNotifyObjectVo> vos = map.get(vo.getId());
|
||||
vo.setNotifyObjects(vos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增隐患规则通知对象
|
||||
*
|
||||
* @param bo 隐患规则通知对象
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(HazardRuleNotifyObjectBo bo) {
|
||||
HazardRuleNotifyObject add = MapstructUtils.convert(bo, HazardRuleNotifyObject.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setRuleId(add.getRuleId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改隐患规则通知对象
|
||||
*
|
||||
* @param bo 隐患规则通知对象
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(HazardRuleNotifyObjectBo bo) {
|
||||
HazardRuleNotifyObject update = MapstructUtils.convert(bo, HazardRuleNotifyObject.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(HazardRuleNotifyObject entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除隐患规则通知对象信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,20 +5,26 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.safety.domain.HazardRule;
|
||||
import org.dromara.safety.domain.HazardRuleNotifyObject;
|
||||
import org.dromara.safety.domain.bo.HazardRuleBo;
|
||||
import org.dromara.safety.domain.bo.HazardRuleNotifyObjectBo;
|
||||
import org.dromara.safety.domain.vo.HazardRuleNotifyObjectVo;
|
||||
import org.dromara.safety.domain.vo.HazardRuleVo;
|
||||
import org.dromara.safety.mapper.HazardRuleMapper;
|
||||
import org.dromara.safety.service.IHazardRuleNotifyObjectService;
|
||||
import org.dromara.safety.service.IHazardRuleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 隐患分级通知规则Service业务层处理
|
||||
@ -31,6 +37,8 @@ import java.util.Map;
|
||||
public class HazardRuleServiceImpl extends ServiceImpl<HazardRuleMapper, HazardRule>
|
||||
implements IHazardRuleService {
|
||||
|
||||
private final IHazardRuleNotifyObjectService hazardRuleNotifyObjectService;
|
||||
|
||||
/**
|
||||
* 查询隐患分级通知规则
|
||||
*
|
||||
@ -39,7 +47,10 @@ public class HazardRuleServiceImpl extends ServiceImpl<HazardRuleMapper, HazardR
|
||||
*/
|
||||
@Override
|
||||
public HazardRuleVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
HazardRuleVo hazardRuleVo = baseMapper.selectVoById(id);
|
||||
List<HazardRuleNotifyObjectVo> objectVos = hazardRuleNotifyObjectService.queryVoByRule(id);
|
||||
hazardRuleVo.setNotifyObjects(objectVos);
|
||||
return hazardRuleVo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,6 +64,7 @@ public class HazardRuleServiceImpl extends ServiceImpl<HazardRuleMapper, HazardR
|
||||
public TableDataInfo<HazardRuleVo> queryPageList(HazardRuleBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<HazardRule> lqw = buildQueryWrapper(bo);
|
||||
Page<HazardRuleVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
hazardRuleNotifyObjectService.supplementDataByRule(result.getRecords());
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@ -69,7 +81,6 @@ public class HazardRuleServiceImpl extends ServiceImpl<HazardRuleMapper, HazardR
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<HazardRule> buildQueryWrapper(HazardRuleBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<HazardRule> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByDesc(HazardRule::getId);
|
||||
lqw.eq(bo.getProjectId() != null, HazardRule::getProjectId, bo.getProjectId());
|
||||
@ -90,12 +101,25 @@ public class HazardRuleServiceImpl extends ServiceImpl<HazardRuleMapper, HazardR
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(HazardRuleBo bo) {
|
||||
HazardRule add = MapstructUtils.convert(bo, HazardRule.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
List<HazardRuleNotifyObjectBo> notifyObjects = bo.getNotifyObjects();
|
||||
List<HazardRuleNotifyObject> objectList = notifyObjects.stream().map(item -> {
|
||||
HazardRuleNotifyObject notifyObject = new HazardRuleNotifyObject();
|
||||
notifyObject.setRuleId(add.getId());
|
||||
notifyObject.setNotifyId(item.getNotifyId());
|
||||
notifyObject.setNotifyType(item.getNotifyType());
|
||||
return notifyObject;
|
||||
}).toList();
|
||||
boolean b = hazardRuleNotifyObjectService.saveBatch(objectList);
|
||||
if (!b) {
|
||||
throw new ServiceException("数据库操作失败", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
@ -107,10 +131,37 @@ public class HazardRuleServiceImpl extends ServiceImpl<HazardRuleMapper, HazardR
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(HazardRuleBo bo) {
|
||||
HazardRule oldRule = this.getById(bo.getId());
|
||||
if (oldRule == null) {
|
||||
throw new ServiceException("数据不存在", HttpStatus.ERROR);
|
||||
}
|
||||
HazardRule update = MapstructUtils.convert(bo, HazardRule.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
boolean b = baseMapper.updateById(update) > 0;
|
||||
if (b) {
|
||||
// 旧通知对象
|
||||
boolean remove = hazardRuleNotifyObjectService.remove(new LambdaQueryWrapper<HazardRuleNotifyObject>()
|
||||
.eq(HazardRuleNotifyObject::getRuleId, bo.getId()));
|
||||
if (!remove) {
|
||||
throw new ServiceException("数据库操作失败", HttpStatus.ERROR);
|
||||
}
|
||||
// 新通知对象
|
||||
List<HazardRuleNotifyObjectBo> notifyObjects = bo.getNotifyObjects();
|
||||
List<HazardRuleNotifyObject> objectList = notifyObjects.stream().map(item -> {
|
||||
HazardRuleNotifyObject notifyObject = new HazardRuleNotifyObject();
|
||||
notifyObject.setRuleId(bo.getId());
|
||||
notifyObject.setNotifyId(item.getNotifyId());
|
||||
notifyObject.setNotifyType(item.getNotifyType());
|
||||
return notifyObject;
|
||||
}).toList();
|
||||
boolean b1 = hazardRuleNotifyObjectService.saveBatch(objectList);
|
||||
if (!b1) {
|
||||
throw new ServiceException("数据库操作失败", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2006,21 +2006,67 @@ CREATE TABLE hazard_rule_notify_object
|
||||
) comment '隐患规则通知对象';
|
||||
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1996139632219136001, '隐患分级通知规则', '1996118434672001025', '1', 'rule', 'safety/rule/index', 1, 0, 'C', '0', '0', 'safety:rule:list', '#', 103, 1, sysdate(), null, null, '隐患分级通知规则菜单');
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
|
||||
status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values (1996139632219136001, '隐患分级通知规则', '1996118434672001025', '1', 'rule', 'safety/rule/index', 1, 0, 'C',
|
||||
'0', '0', 'safety:rule:list', '#', 103, 1, sysdate(), null, null, '隐患分级通知规则菜单');
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1996139632219136002, '隐患分级通知规则查询', 1996139632219136001, '1', '#', '', 1, 0, 'F', '0', '0', 'safety:rule:query', '#', 103, 1, sysdate(), null, null, '');
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
|
||||
status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values (1996139632219136002, '隐患分级通知规则查询', 1996139632219136001, '1', '#', '', 1, 0, 'F', '0', '0',
|
||||
'safety:rule:query', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1996139632219136003, '隐患分级通知规则新增', 1996139632219136001, '2', '#', '', 1, 0, 'F', '0', '0', 'safety:rule:add', '#', 103, 1, sysdate(), null, null, '');
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
|
||||
status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values (1996139632219136003, '隐患分级通知规则新增', 1996139632219136001, '2', '#', '', 1, 0, 'F', '0', '0',
|
||||
'safety:rule:add', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1996139632219136004, '隐患分级通知规则修改', 1996139632219136001, '3', '#', '', 1, 0, 'F', '0', '0', 'safety:rule:edit', '#', 103, 1, sysdate(), null, null, '');
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
|
||||
status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values (1996139632219136004, '隐患分级通知规则修改', 1996139632219136001, '3', '#', '', 1, 0, 'F', '0', '0',
|
||||
'safety:rule:edit', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1996139632219136005, '隐患分级通知规则删除', 1996139632219136001, '4', '#', '', 1, 0, 'F', '0', '0', 'safety:rule:remove', '#', 103, 1, sysdate(), null, null, '');
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
|
||||
status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values (1996139632219136005, '隐患分级通知规则删除', 1996139632219136001, '4', '#', '', 1, 0, 'F', '0', '0',
|
||||
'safety:rule:remove', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1996139632219136006, '隐患分级通知规则导出', 1996139632219136001, '5', '#', '', 1, 0, 'F', '0', '0', 'safety:rule:export', '#', 103, 1, sysdate(), null, null, '');
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
|
||||
status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values (1996139632219136006, '隐患分级通知规则导出', 1996139632219136001, '5', '#', '', 1, 0, 'F', '0', '0',
|
||||
'safety:rule:export', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
|
||||
-- 隐患整改情况表
|
||||
create table hazard_hidden_danger_rectify
|
||||
(
|
||||
`id` bigint not null auto_increment comment '主键',
|
||||
hidden_danger_id bigint not null comment '关联隐患ID',
|
||||
rectify_times int not null comment '整改次数',
|
||||
|
||||
rectify_desc text null comment '整改说明',
|
||||
rectify_files varchar(1000) null comment '整改凭证附件',
|
||||
rectify_finish_time datetime null comment '完成整改时间',
|
||||
|
||||
review_user_id bigint null comment '复查人ID',
|
||||
review_opinion text null comment '复查意见',
|
||||
review_files varchar(1000) null comment '复查凭证附件',
|
||||
review_time datetime null comment '复查时间',
|
||||
|
||||
review_status char not null default '0' comment '复查状态 0-待复查 1-复查通过 2-复查不通过',
|
||||
`remark` varchar(512) null comment '备注',
|
||||
`create_by` bigint null comment '创建者',
|
||||
`update_by` bigint null comment '更新者',
|
||||
`create_dept` bigint null comment '创建部门',
|
||||
`create_time` datetime default CURRENT_TIMESTAMP null comment '创建时间',
|
||||
`update_time` datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
index `idx_hidden_danger_id` (`hidden_danger_id` asc) using btree comment '关联隐患ID',
|
||||
)
|
||||
comment '隐患整改情况表' row_format = DYNAMIC;
|
||||
|
||||
-- 索引
|
||||
|
||||
create index idx_rectify_times
|
||||
on hazard_hidden_danger_rectify (hidden_danger_id, rectify_times);
|
||||
|
||||
Reference in New Issue
Block a user