6 Commits

Author SHA1 Message Date
shih
b600436243 保养方案关联 2026-04-02 16:29:30 +08:00
shih
2108e2a1e2 设备类型维护,表单开发中增加设备类型下拉所需的接口增加、修改 2026-04-01 10:42:26 +08:00
shih
b3c8423239 应用管理权限问题修改 2026-03-30 12:22:03 +08:00
king
8b53722f90 报表系统 新增 定时任务 2026-03-30 11:27:38 +08:00
king
564e119bc3 Merge branch 'refs/heads/dev_js_20260325' 2026-03-27 09:11:01 +08:00
king
5c998db1ed 新增 定时任务 2026-03-26 17:49:34 +08:00
20 changed files with 678 additions and 1 deletions

View File

@@ -338,6 +338,21 @@ public class FrameWorkAdapter implements IlideeYunjiAdapter {
}
//回显设备类型
@TenantIgnore
@Override
public List<Map<String, Object>> getSblxViewList(List<Long> sblxIdList) {
SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper()
.select("id", "industry_name AS industryName")
.setTableName("dev_sblx")
.setWhere(where -> {
where.in("id", sblxIdList);
})
.build();
List<Map<String, Object>> dataList = sqlService.getDataListByPlus(wrapper);
return dataList;
}
//获取用户分页列表
@Override
public Object getUserPage(Integer pageNo, Integer pageSize, lideeYunJiUserParam param) {

View File

@@ -0,0 +1,55 @@
package com.lideeyunji.core.framework.config.job;
import com.lideeyunji.core.framework.mapper.OracleProcedureMapper;
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
import com.lideeyunji.tool.framework.quartz.core.handler.JobHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
/**
* Oracle 存储过程调用定时任务
* 用于定时调用 Oracle 存储过程进行数据处理
*/
@Slf4j
@Component("oracleProcedureJob")
public class OracleProcedureJob implements JobHandler {
@Resource
private OracleProcedureMapper oracleProcedureMapper;
@Override
public String execute(String param) throws Exception {
log.info("========== 开始执行 Oracle 存储过程定时任务,参数:{} ==========", param);
try {
callAllProcedure();
log.info("========== Oracle 存储过程定时任务执行成功 ==========");
return "Oracle 存储过程定时任务执行成功";
} catch (Exception e) {
log.error("========== Oracle 存储过程定时任务执行失败 ==========", e);
throw new RuntimeException("Oracle 存储过程调用失败:" + e.getMessage(), e);
}
}
/**
* 调用简单存储过程
*/
private void callAllProcedure() {
log.info("开始调用存储过程...");
Map<String, Object> params = new HashMap<>();
params.put("result", new Object()); // 用于接收输出参数
oracleProcedureMapper.callAllProcedure(lideeYunJiBaseConstant.DS_ORACLE_GRYYBI);
// 获取输出参数值
Object result = params.get("result");
log.info("存储过程执行结果:{}", result);
}
}

View File

@@ -0,0 +1,53 @@
package com.lideeyunji.core.framework.config.job;
import com.lideeyunji.core.framework.mapper.OracleProcedureMapper;
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
import com.lideeyunji.tool.framework.quartz.core.handler.JobHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* Oracle 存储过程调用定时任务 ,用于更新核心、高频的数据
* 用于定时调用 Oracle 存储过程进行数据处理
*/
@Slf4j
@Component("oracleProcedureUpdateCoreJob")
public class OracleProcedureUpdateCoreJob implements JobHandler {
@Resource
private OracleProcedureMapper oracleProcedureMapper;
@Override
public String execute(String param) throws Exception {
log.info("========== 开始执行 Oracle 存储过程定时任务 ,用于更新核心、高频的数据,参数:{} ==========", param);
try {
callUpdateCore();
log.info("========== Oracle 存储过程定时任务,用于更新核心、高频的数据 执行成功 ==========");
return "Oracle 存储过程定时任务,用于更新核心、高频的数据 执行成功";
} catch (Exception e) {
log.error("========== Oracle 存储过程定时任务,用于更新核心、高频的数据 执行失败 ==========", e);
throw new RuntimeException("Oracle 存储过程,用于更新核心、高频的数据 调用失败:" + e.getMessage(), e);
}
}
/**
* 调用简单存储过程
*/
private void callUpdateCore() {
log.info("开始调用存储过程...");
Map<String, Object> params = new HashMap<>();
params.put("result", new Object()); // 用于接收输出参数
oracleProcedureMapper.callUpdateCore(lideeYunJiBaseConstant.DS_ORACLE_GRYYBI);
// 获取输出参数值
Object result = params.get("result");
log.info("存储过程执行结果:{}", result);
}
}

View File

@@ -285,6 +285,10 @@ public class DbFormController extends BaseController {
String deptormatSql="(select name from system_dept where id ="+label+") as "+label;
fieldList.set(ind,deptormatSql);//子查询
break;
case "sblxSelect":
String sblxormatSql="(select industry_name from dev_sblx where id ="+label+") as "+label;
fieldList.set(ind,sblxormatSql);//子查询
break;
}
}
}
@@ -306,6 +310,7 @@ public class DbFormController extends BaseController {
List<String> dataList = labelParam.getDataList();
List<Long> userIdList = labelParam.getUserIdList();//用户id
List<Long> deptIdList = labelParam.getDeptIdList();//部门id
List<Long> sblxIdList = labelParam.getSblxIdList();//设备类型id
if (Func.isNotEmpty(dbformId)) { //自定义表
String mapKey = dbformId + "&" + label;
@@ -341,6 +346,10 @@ public class DbFormController extends BaseController {
List<Map<String, Object>> deptViewList = lideeYunJiAdapter.getDeptViewList(deptIdList);
resultMap.put("deptList", deptViewList);
}
if (Func.isNotEmpty(sblxIdList)) {//部门表回显
List<Map<String, Object>> sblxViewList = lideeYunJiAdapter.getSblxViewList(sblxIdList);
resultMap.put("sblxList", sblxViewList);
}
})).get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e.getMessage());

View File

@@ -34,7 +34,7 @@ public class ByglByjhLbPlugin implements AroundAdvicePlugin {
return;
}
for (Map<String, Object> record : records) {
String plan_id = lideeYunJiUtils.getMap2Str(record, "plan_id");
String plan_id = lideeYunJiUtils.getMap2Str(record, "id");
Map<String, Object> countByPlanId = byglByjhMapper.getCountByPlanId(plan_id);
record.put("plan_count",lideeYunJiUtils.getMap2Long(countByPlanId,"jhs"));
record.put("completed_count",lideeYunJiUtils.getMap2Long(countByPlanId,"wcs"));

View File

@@ -0,0 +1,37 @@
package com.lideeyunji.core.framework.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.lideeyunji.tool.framework.permission.core.annotation.DataPermission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
/**
* Oracle 存储过程调用 Mapper
*/
@Mapper
public interface OracleProcedureMapper {
/**
* 调用 Oracle 存储过程 - 示例
*
* @param dataSourceType 存储过程参数
* @return 执行结果
*/
@DS(value = "#dataSourceType")
@DataPermission(enable = false)
void callAllProcedure(@Param("dataSourceType") String dataSourceType);
/**
* 调用 Oracle 存储过程 - 示例
*
* @param dataSourceType 存储过程参数
* @return 执行结果
*/
@DS(value = "#dataSourceType")
@DataPermission(enable = false)
void callUpdateCore(@Param("dataSourceType") String dataSourceType);
}

View File

@@ -33,5 +33,8 @@ public class DictLabelParam {
@Schema(description = "部门id列表")
private List<Long> deptIdList;
@Schema(description = "设备类型id列表")
private List<Long> sblxIdList;
}

View File

@@ -0,0 +1,14 @@
<?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.lideeyunji.core.framework.mapper.OracleProcedureMapper">
<!-- 调用示例存储过程 -->
<select id="callAllProcedure" statementType="CALLABLE" >
{call P_ERP_DATA_NEW()}
</select>
<!-- 调用示例存储过程 -->
<select id="callUpdateCore" statementType="CALLABLE" >
{call P_ERP_DATA_FAST()}
</select>
</mapper>

View File

@@ -198,4 +198,13 @@ public interface ErrorCodeConstants {
// ========== 站内信发送 1-002-028-000 ==========
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "模板参数({})缺失");
// ========== 设备类型维护 1_002_029_000 ==========
ErrorCode SBLX_NAME_DUPLICATE = new ErrorCode(1_002_029_000, "已经存在该名字的设备类型");
ErrorCode SBLX_EXITS_CHILDREN = new ErrorCode(1_002_029_001, "存在子设备类型,无法删除");
ErrorCode SBLX_NOT_FOUND = new ErrorCode(1_002_029_002, "当前设备类型不存在");
ErrorCode SBLX_PARENT_ERROR = new ErrorCode(1_002_029_003, "不能设置自己为父设备类型");
ErrorCode SBLX_PARENT_NOT_EXITS = new ErrorCode(1_002_029_004,"父级设备类型不存在");
ErrorCode SBLX_PARENT_IS_CHILD = new ErrorCode(1_002_029_005, "不能设置自己的子设备类型为父设备类型");
}

View File

@@ -0,0 +1,85 @@
package com.lideeyunji.service.system.controller;
import com.lideeyunji.service.system.controller.vo.dept.dept.DeptRespVO;
import com.lideeyunji.service.system.controller.vo.dept.dept.DeptSimpleRespVO;
import com.lideeyunji.service.system.controller.vo.sblx.SblxListReqVO;
import com.lideeyunji.service.system.controller.vo.sblx.SblxRespVO;
import com.lideeyunji.service.system.controller.vo.sblx.SblxSaveReqVO;
import com.lideeyunji.service.system.controller.vo.sblx.SblxSimpleRespVO;
import com.lideeyunji.service.system.entity.SblxDO;
import com.lideeyunji.service.system.service.ISblxService;
import com.lideeyunji.tool.framework.common.pojo.CommonResult;
import com.lideeyunji.tool.framework.common.util.object.BeanUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import static com.lideeyunji.tool.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 设备类型")
@RestController
@RequestMapping("/system/sblx")
@Validated
public class SblxController {
@Resource
private ISblxService sblxService;
@PostMapping("create")
@Operation(tags = "设备类型管理",summary = "创建设备类型")
@PreAuthorize("@ss.hasPermission('system:sblx:create')")
public CommonResult<Long> createSblx(@Valid @RequestBody SblxSaveReqVO createReqVO) {
Long deptId = sblxService.createSblx(createReqVO);
return success(deptId);
}
@PutMapping("update")
@Operation(tags = "设备类型管理",summary = "更新设备类型")
@PreAuthorize("@ss.hasPermission('system:sblx:update')")
public CommonResult<Boolean> updateSblx(@Valid @RequestBody SblxSaveReqVO updateReqVO) {
sblxService.updateSblx(updateReqVO);
return success(true);
}
@DeleteMapping("delete")
@Operation(tags = "设备类型管理",summary = "删除设备类型")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:sblx:delete')")
public CommonResult<Boolean> deleteSblx(@RequestParam("id") Long id) {
sblxService.deleteSblx(id);
return success(true);
}
@GetMapping("/list")
@Operation(tags = "设备类型管理",summary = "获取设备类型列表")
@PreAuthorize("@ss.hasPermission('system:sblx:query')")
public CommonResult<List<SblxRespVO>> getSblxList(SblxListReqVO reqVO) {
List<SblxDO> list = sblxService.getSblxList(reqVO);
return success(BeanUtils.toBean(list, SblxRespVO.class));
}
@GetMapping(value = {"/list-all-simple", "/simple-list"})
@Operation(tags = "设备类型管理",summary = "获取设备类型精简信息列表", description = "主要用于前端的下拉选项")
public CommonResult<List<SblxSimpleRespVO>> getSimpleDeptList() {
List<SblxDO> list = sblxService.getSblxList(
new SblxListReqVO());
return success(BeanUtils.toBean(list, SblxSimpleRespVO.class));
}
@GetMapping("/get")
@Operation(tags = "设备类型管理",summary = "获得设备类型信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:sblx:query')")
public CommonResult<DeptRespVO> getDept(@RequestParam("id") Long id) {
SblxDO sblx = sblxService.getSblx(id);
return success(BeanUtils.toBean(sblx, DeptRespVO.class));
}
}

View File

@@ -0,0 +1,13 @@
package com.lideeyunji.service.system.controller.vo.sblx;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 设备类型列表 Request VO")
@Data
public class SblxListReqVO {
@Schema(description = "设备类型名称,模糊匹配" )
private String industryName;
}

View File

@@ -0,0 +1,30 @@
package com.lideeyunji.service.system.controller.vo.sblx;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 设备类型信息 Response VO")
@Data
public class SblxRespVO {
@Schema(description = "设备类型编号", example = "1024")
private Long id;
@Schema(description = "设备类型名称", requiredMode = Schema.RequiredMode.REQUIRED)
private String industryName;
@Schema(description = "设备类型编码", requiredMode = Schema.RequiredMode.REQUIRED)
private String industryCode;
@Schema(description = "父设备类型 ID", example = "1024")
private Long parentId;
@Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer sort;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,34 @@
package com.lideeyunji.service.system.controller.vo.sblx;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@Schema(description = "管理后台 - 设备类型创建/修改 Request VO")
@Data
public class SblxSaveReqVO {
@Schema(description = "设备类型id", example = "1024")
private Long id;
@Schema(description = "设备类型名称", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "设备类型名称不能为空")
@Size(max = 30, message = "设备类型名称长度不能超过 30 个字符")
private String industryName;
@Schema(description = "设备类型编码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "设备类型编码不能为空")
@Size(max = 30, message = "设备类型编码长度不能超过 30 个字符")
private String industryCode;
@Schema(description = "父设备类型 ID", example = "1024")
private Long parentId;
@Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "显示顺序不能为空")
private Integer sort;
}

View File

@@ -0,0 +1,23 @@
package com.lideeyunji.service.system.controller.vo.sblx;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Schema(description = "管理后台 - 设备类型精简信息 Response VO")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SblxSimpleRespVO {
@Schema(description = "设备类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
@Schema(description = "设备类型名称", requiredMode = Schema.RequiredMode.REQUIRED)
private String industryName;
@Schema(description = "父设备类型 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long parentId;
}

View File

@@ -0,0 +1,50 @@
package com.lideeyunji.service.system.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.lideeyunji.tool.framework.common.enums.CommonStatusEnum;
import com.lideeyunji.tool.framework.mybatis.core.dataobject.BaseDO;
import com.lideeyunji.tool.framework.tenant.core.db.TenantBaseDO;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 设备类型表
*
*/
@TableName("dev_sblx")
@Data
@EqualsAndHashCode(callSuper = true)
public class SblxDO extends BaseDO {
public static final Long PARENT_ID_ROOT = 0L;
/**
* 设备类型ID
*/
@TableId
private Long id;
/**
* 设备类型名称
*/
private String industryName;
/**
* 设备类型编码
*/
private String industryCode;
/**
* 父设备类型ID
*
* 关联 {@link #id}
*/
private Long parentId;
/**
* 显示顺序
*/
private Integer sort;
}

View File

@@ -0,0 +1,32 @@
package com.lideeyunji.service.system.mapper;
import com.lideeyunji.service.system.controller.vo.sblx.SblxListReqVO;
import com.lideeyunji.service.system.entity.SblxDO;
import com.lideeyunji.tool.framework.mybatis.core.mapper.BaseMapperX;
import com.lideeyunji.tool.framework.mybatis.core.query.LambdaQueryWrapperX;
import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
import java.util.List;
@Mapper
public interface SblxMapper extends BaseMapperX<SblxDO> {
default List<SblxDO> selectList(SblxListReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<SblxDO>()
.likeIfPresent(SblxDO::getIndustryName, reqVO.getIndustryName()));
}
default SblxDO selectByParentIdAndName(Long parentId, String name) {
return selectOne(SblxDO::getParentId, parentId, SblxDO::getIndustryName, name);
}
default Long selectCountByParentId(Long parentId) {
return selectCount(SblxDO::getParentId, parentId);
}
default List<SblxDO> selectListByParentId(Collection<Long> parentIds) {
return selectList(SblxDO::getParentId, parentIds);
}
}

View File

@@ -0,0 +1,54 @@
package com.lideeyunji.service.system.service;
import com.lideeyunji.service.system.controller.vo.sblx.SblxListReqVO;
import com.lideeyunji.service.system.controller.vo.sblx.SblxSaveReqVO;
import com.lideeyunji.service.system.entity.SblxDO;
import java.util.List;
/**
* 设备类型 Service 接口
*
*/
public interface ISblxService {
/**
* 创建设备类型
*
* @param createReqVO 设备类型信息
* @return id
*/
Long createSblx(SblxSaveReqVO createReqVO);
/**
* 更新设备类型信息
*
* @param updateReqVO 设备类型信息
*/
void updateSblx(SblxSaveReqVO updateReqVO);
/**
* 删除设备类型信息
*
* @param id
*/
void deleteSblx(Long id);
/**
* 获得设备类型信息
*
* @param id
* @return 设备类型信息
*/
SblxDO getSblx(Long id);
/**
* 筛选设备类型列表
*
* @param reqVO 筛选条件请求 VO
* @return 设备类型信息列表
*/
List<SblxDO> getSblxList(SblxListReqVO reqVO);
}

View File

@@ -161,6 +161,10 @@ public class OAuth2ClientServiceImpl implements IOAuth2ClientService {
}
if (!CollUtil.isEmpty(roleIds)) {
Set<Long> clientIds = clientPermissionService.getRoleClientListByRoleId(roleIds);
//修改 若无clientIds时直接返回空
if(CollUtil.isEmpty(clientIds)){
return new PageResult<>();
}
pageReqVO.setIds(clientIds);
}
return oAuth2ClientJoinMapper.selectPage(pageReqVO);

View File

@@ -0,0 +1,155 @@
package com.lideeyunji.service.system.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.annotations.VisibleForTesting;
import com.lideeyunji.service.system.controller.vo.sblx.SblxListReqVO;
import com.lideeyunji.service.system.controller.vo.sblx.SblxSaveReqVO;
import com.lideeyunji.service.system.entity.SblxDO;
import com.lideeyunji.service.system.mapper.SblxMapper;
import com.lideeyunji.service.system.service.ISblxService;
import com.lideeyunji.tool.framework.common.util.object.BeanUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import static com.lideeyunji.service.system.constant.ErrorCodeConstants.*;
import static com.lideeyunji.tool.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
* 设备类型 Service 实现类
*
*/
@Service
@Validated
@Slf4j
public class SblxServiceImpl implements ISblxService {
@Resource
private SblxMapper sblxMapper;
@Override
public Long createSblx(SblxSaveReqVO createReqVO) {
if (createReqVO.getParentId() == null) {
createReqVO.setParentId(SblxDO.PARENT_ID_ROOT);
}
// 校验父部门的有效性
validateParentDept(null, createReqVO.getParentId());
// 校验部门名的唯一性
validateDeptNameUnique(null, createReqVO.getParentId(), createReqVO.getIndustryName());
// 插入
SblxDO sblx = BeanUtils.toBean(createReqVO, SblxDO.class);
sblxMapper.insert(sblx);
return sblx.getId();
}
@Override
public void updateSblx(SblxSaveReqVO updateReqVO) {
if (updateReqVO.getParentId() == null) {
updateReqVO.setParentId(SblxDO.PARENT_ID_ROOT);
}
// 校验自己存在
validateDeptExists(updateReqVO.getId());
// 校验父部门的有效性
validateParentDept(updateReqVO.getId(), updateReqVO.getParentId());
// 校验部门名的唯一性
validateDeptNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getIndustryName());
// 更新
SblxDO updateObj = BeanUtils.toBean(updateReqVO, SblxDO.class);
sblxMapper.updateById(updateObj);
}
@Override
public void deleteSblx(Long id) {
// 校验是否存在
validateDeptExists(id);
// 校验是否有子部门
if (sblxMapper.selectCountByParentId(id) > 0) {
throw exception(SBLX_EXITS_CHILDREN);
}
// 删除部门
sblxMapper.deleteById(id);
}
@VisibleForTesting
void validateDeptExists(Long id) {
if (id == null) {
return;
}
SblxDO sblx = sblxMapper.selectById(id);
if (sblx == null) {
throw exception(SBLX_NOT_FOUND);
}
}
@VisibleForTesting
void validateParentDept(Long id, Long parentId) {
if (parentId == null || SblxDO.PARENT_ID_ROOT.equals(parentId)) {
return;
}
// 1. 不能设置自己为父部门
if (Objects.equals(id, parentId)) {
throw exception(SBLX_PARENT_ERROR);
}
// 2. 父部门不存在
SblxDO parentSblx = sblxMapper.selectById(parentId);
if (parentSblx == null) {
throw exception(SBLX_PARENT_NOT_EXITS);
}
// 3. 递归校验父部门,如果父部门是自己的子部门,则报错,避免形成环路
if (id == null) { // id 为空,说明新增,不需要考虑环路
return;
}
for (int i = 0; i < Short.MAX_VALUE; i++) {
// 3.1 校验环路
parentId = parentSblx.getParentId();
if (Objects.equals(id, parentId)) {
throw exception(SBLX_PARENT_IS_CHILD);
}
// 3.2 继续递归下一级父部门
if (parentId == null || SblxDO.PARENT_ID_ROOT.equals(parentId)) {
break;
}
parentSblx = sblxMapper.selectById(parentId);
if (parentSblx == null) {
break;
}
}
}
@VisibleForTesting
void validateDeptNameUnique(Long id, Long parentId, String name) {
SblxDO sblx = sblxMapper.selectByParentIdAndName(parentId, name);
if (sblx == null) {
return;
}
// 如果 id 为空,说明不用比较是否为相同 id 的部门
if (id == null) {
throw exception(SBLX_NAME_DUPLICATE);
}
if (ObjectUtil.notEqual(sblx.getId(), id)) {
throw exception(SBLX_NAME_DUPLICATE);
}
}
@Override
public SblxDO getSblx(Long id) {
return sblxMapper.selectById(id);
}
@Override
public List<SblxDO> getSblxList(SblxListReqVO reqVO) {
List<SblxDO> list = sblxMapper.selectList(reqVO);
list.sort(Comparator.comparing(SblxDO::getSort));
return list;
}
}

View File

@@ -60,6 +60,8 @@ public interface IlideeYunjiAdapter {
//回显部门
List<Map<String,Object>> getDeptViewList(List<Long> deptIdList);
//设备类型
List<Map<String,Object>> getSblxViewList(List<Long> sblxIdList);
//获取用户分页列表
Object getUserPage(Integer pageNo, Integer pageSize, lideeYunJiUserParam param);