From 7eb32dd6538fa181416711f035d92fab4c0bae02 Mon Sep 17 00:00:00 2001 From: tianwenbo Date: Mon, 6 Mar 2023 17:49:09 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90fix=20sonar=E3=80=91=20OrgCodeRule.jav?= =?UTF-8?q?a=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jero/modules/system/rule/OrgCodeRule.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/rule/OrgCodeRule.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/rule/OrgCodeRule.java index bef8b84c..b233363d 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/rule/OrgCodeRule.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/rule/OrgCodeRule.java @@ -2,14 +2,13 @@ package com.jero.modules.system.rule; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import io.netty.util.internal.StringUtil; import com.jero.common.handler.IFillRuleHandler; import com.jero.common.util.SpringContextUtils; import com.jero.common.util.YouBianCodeUtil; import com.jero.modules.system.entity.SysDepart; import com.jero.modules.system.service.ISysDepartService; +import io.netty.util.internal.StringUtil; -import java.util.ArrayList; import java.util.List; /** @@ -23,10 +22,10 @@ public class OrgCodeRule implements IFillRuleHandler { public Object execute(JSONObject params, JSONObject formData) { ISysDepartService sysDepartService = (ISysDepartService) SpringContextUtils.getBean("sysDepartServiceImpl"); - LambdaQueryWrapper query = new LambdaQueryWrapper(); - LambdaQueryWrapper query1 = new LambdaQueryWrapper(); + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + LambdaQueryWrapper query1 = new LambdaQueryWrapper<>(); // 创建一个List集合,存储查询返回的所有SysDepart对象 - List departList = new ArrayList<>(); + List departList ; String[] strArray = new String[2]; //定义部门类型 String orgType = ""; @@ -52,7 +51,7 @@ public class OrgCodeRule implements IFillRuleHandler { query1.eq(SysDepart::getParentId, "").or().isNull(SysDepart::getParentId); query1.orderByDesc(SysDepart::getOrgCode); departList = sysDepartService.list(query1); - if (departList == null || departList.size() == 0) { + if (departList == null || departList.isEmpty()) { strArray[0] = YouBianCodeUtil.getNextYouBianCode(null); strArray[1] = "1"; return strArray; @@ -76,7 +75,7 @@ public class OrgCodeRule implements IFillRuleHandler { // 根据父级部门类型算出当前部门的类型 orgType = String.valueOf(Integer.valueOf(depart.getOrgType()) + 1); // 处理同级部门为null的情况 - if (parentList == null || parentList.size() == 0) { + if (parentList == null || parentList.isEmpty()) { // 直接生成当前的部门编码并返回 newOrgCode = YouBianCodeUtil.getSubYouBianCode(parentCode, null); } else { //处理有同级部门的情况