【fix sonar】 OrgCodeRule.java文件

This commit is contained in:
tianwenbo
2023-03-06 17:49:09 +08:00
parent 12974a7ba8
commit 7eb32dd653
@@ -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<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
LambdaQueryWrapper<SysDepart> query1 = new LambdaQueryWrapper<SysDepart>();
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<>();
LambdaQueryWrapper<SysDepart> query1 = new LambdaQueryWrapper<>();
// 创建一个List集合,存储查询返回的所有SysDepart对象
List<SysDepart> departList = new ArrayList<>();
List<SysDepart> 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 { //处理有同级部门的情况