Commit 7765eff1 authored by ZWT's avatar ZWT

feat(吉林演示): 松原

1.修改系统首页大屏总览接口,增加区分组织机构逻辑,完成接口冒烟测试;
2.修改系统首页获取井场列表接口,增加区分组织机构逻辑,完成接口冒烟测试;
3.修改系统首页井场功能下钻后提示报错问题,修改用电功率数据获取逻辑,修复报错问题;
4.修改输电线路分页列表查询接口,增加查询条件,在查询父线路列表时只查询10千伏线路,修改线上接口文档同时完成接口冒烟测试;
5.修改系统首页井场实时监控接口,增加区分组织机构逻辑,完成接口冒烟测试;
6.修改系统首页用能分析接口,增加区分组织机构逻辑,完成接口冒烟测试;
7.修改系统首页井场用能分析(双坐标轴)接口,增加区分组织机构逻辑,完成接口冒烟测试;
8.修改系统首页累积用电接口,增加区分组织机构逻辑,完成接口冒烟测试;
9.修改系统首页光伏实时监控接口,增加区分组织机构逻辑,完成接口冒烟测试;
10.修改系统首页井场效果评价接口,增加区分组织机构逻辑,完成接口冒烟测试;
11.修改系统首页先导实验井间开制度接口,增加区分组织机构逻辑,完成接口冒烟测试;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 580ed807
package pps.core.auth;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
......@@ -346,7 +346,7 @@ public class HttpRequestClient {
.addHeader(HttpHeaders.AUTHORIZATION, auth.getAuth())
.addHeader("Accept", ContentType.APPLICATION_JSON.toString())
.addHeader("Content-type", ContentType.APPLICATION_JSON.toString());
if (StringUtils.isNotBlank(json)) {
if (CharSequenceUtil.isNotBlank(json)) {
reqBuilder.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON));
}
try {
......
package pps.core.common.utils;
import org.apache.commons.lang3.StringUtils;
import cn.hutool.core.text.CharSequenceUtil;
import java.util.regex.Pattern;
......@@ -25,7 +25,7 @@ public class PatternUtil {
* 字符串脱敏模糊处理
*/
public static String desensitization(String str) {
if (StringUtils.isBlank(str)) {
if (CharSequenceUtil.isBlank(str)) {
return str;
}
//先判断手机号
......@@ -46,7 +46,7 @@ public class PatternUtil {
public static boolean easyCheckIdCard(String IdCard) {
//字符串为空或者不符合简单的18位校验返回false
String regex = "^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$";
if (StringUtils.isBlank(IdCard) || !Pattern.matches(regex, IdCard)) {
if (CharSequenceUtil.isBlank(IdCard) || !Pattern.matches(regex, IdCard)) {
return false;
}
return true;
......@@ -68,7 +68,7 @@ public class PatternUtil {
//邮箱加*号
public static String reStr(String str) {
if (StringUtils.isBlank(str)) {
if (CharSequenceUtil.isBlank(str)) {
return str;
}
String name = str;
......
package pps.core.system.cache;
import cn.hutool.core.text.CharSequenceUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import pps.core.common.utils.CounterBuilder;
import xstartup.annotation.XText;
import xstartup.base.XContext;
......@@ -124,7 +124,7 @@ public class SysDictionaryCache implements XCacheObject, XCacheLife {
public static void delete(XContext context, String alias, String dicId) {
List<SysDictionaryCache> list = Tool.get(Tool.class).list(context, alias, SysDictionaryCache.class);
if (ObjectUtils.isNotEmpty(list)) {
list = list.stream().filter((SysDictionaryCache b) -> !StringUtils.equals(b.getId(), dicId))
list = list.stream().filter((SysDictionaryCache b) -> !CharSequenceUtil.equals(b.getId(), dicId))
.collect(Collectors.toList());
}
CounterBuilder.globalCounterBuilder.addCounter("deleteCache");
......
......@@ -5,7 +5,6 @@ import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import pps.core.common.utils.ManifestComponentInfoHelper;
import pps.core.system.cache.SysDictionaryCache;
import pps.core.system.entity.SysDictionaryEnt;
......@@ -47,7 +46,7 @@ public class PpsCoreSystemModule extends XModule {
List<SysDictionaryEnt> sysDictionarys = dictionaryMapper.selectList(new LambdaQueryWrapper<SysDictionaryEnt>()
.isNotNull(SysDictionaryEnt::getAlias).gt(SysDictionaryEnt::getEndTime, DateUtil.date())
);
sysDictionarys = sysDictionarys.stream().filter(p -> !StringUtils.equals("", p.getAlias())).collect(Collectors.toList());
sysDictionarys = sysDictionarys.stream().filter(p -> !CharSequenceUtil.equals("", p.getAlias())).collect(Collectors.toList());
for (SysDictionaryEnt dictObj : sysDictionarys) {
List<SysDictionaryCache> list = new ArrayList<>();
SysDictionaryCache dictMap = new SysDictionaryCache();
......@@ -72,7 +71,7 @@ public class PpsCoreSystemModule extends XModule {
if (ObjectUtils.isNotEmpty(sysDictionaryChilds)) {
SysDictionaryCache dict = iterator.next();
for (SysDictionaryEnt dictChild : sysDictionaryChilds) {
if (StringUtils.equals(dict.getId(), dictChild.getPid())) {
if (CharSequenceUtil.equals(dict.getId(), dictChild.getPid())) {
List<SysDictionaryCache> sysDictionaryList = dictCashMap.get(aliasObj);
SysDictionaryCache dictMap = new SysDictionaryCache();
XCopyUtils.copyObject(dictChild, dictMap);
......
package pps.core.system.provider.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.base.Splitter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import pps.cloud.system.service.SysOrganizationCloudService;
import pps.cloud.system.service.SystemDictionaryService;
import pps.cloud.system.service.SystemUserRoleRelService;
......@@ -114,7 +113,7 @@ public class PpsUserSessionInjectProviderImpl implements XSessionInjectProvider
set.addAll(Arrays.asList(split));
}
}
if (!CollectionUtils.isEmpty(set)) {
if (CollUtil.isNotEmpty(set)) {
SystemDictionaryService dictService = context.getBean(SystemDictionaryService.class);
CreateSysDictionaryInput mediaTypesInput = new CreateSysDictionaryInput();
mediaTypesInput.setAlias("MEDIUM_TYPE");
......@@ -192,7 +191,7 @@ public class PpsUserSessionInjectProviderImpl implements XSessionInjectProvider
List<String> roleList = roleRelResult.getResult().stream().map(GetSysUserRoleRelOutput::getRoleId).collect(Collectors.toList());
String value = LoginConfig.adminRoles.findValue(context);
session.setDevops(0);
if (StringUtils.isNotBlank(value)) {
if (CharSequenceUtil.isNotBlank(value)) {
roleList.stream().filter(value::contains).findFirst().ifPresent(role -> session.setDevops(1));
}
}
......@@ -208,7 +207,7 @@ public class PpsUserSessionInjectProviderImpl implements XSessionInjectProvider
List<String> roleList = roleRelResult.getResult().stream().map(GetSysUserRoleRelOutput::getRoleId).collect(Collectors.toList());
String value = LoginConfig.adminRoles.findValue(context);
if (StringUtils.isNotBlank(value)) {
if (CharSequenceUtil.isNotBlank(value)) {
roleList.stream().filter(value::contains).findFirst().ifPresent(role -> session.setIsSuperAdmin(BusinessConstant.ONE));
}
......
......@@ -35,7 +35,7 @@ import java.util.List;
public class SysAreaService {
@XText("查询地区树")
@XApiPost
@XApiPost(anonymous = true)
public XListResult<GetSysAreaViewOutputTree> getSysAreaTree(XContext context, GetSysAreaInput input) {
//先从缓存中获取
List<SysAreaCache> sysAreaCaches = SysAreaCache.list(context, BusinessConstant.SYS_AREA_CACHE);
......@@ -73,7 +73,7 @@ public class SysAreaService {
XCopyUtils.copyObject(input, record);
List<SysAreaView> areaViews = mapper.selectListAll(record);
List<GetSysAreaViewOutputTree> list = XCopyUtils.copyNewList(areaViews, GetSysAreaViewOutputTree.class);
List<GetSysAreaViewOutputTree> trees = new ArrayList<>();
List<GetSysAreaViewOutputTree> trees = new ArrayList<>(list.size());
for (GetSysAreaViewOutputTree tree : list) {
if (tree.getLev().equals(0)) {
trees.add(tree);
......@@ -81,7 +81,7 @@ public class SysAreaService {
//子集
for (GetSysAreaViewOutputTree it : list) {
if (tree.getId().equals(it.getParentId())) {
if (tree.getChildren() == null) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(it);
......@@ -167,7 +167,7 @@ public class SysAreaService {
SysAreaView record = new SysAreaView();
XCopyUtils.copyObject(input, record);
SysAreaView view = mapper.selectOne(record);
if (view == null) {
if (ObjectUtil.isNull(view)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysAreaViewOutput output = new GetSysAreaViewOutput();
......
package pps.core.system.service;
import com.alibaba.csp.sentinel.util.StringUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.util.CollectionUtils;
import pps.core.common.session.PpsUserSession;
import pps.core.system.entity.SysAuthOuScopeEnt;
import pps.core.system.entity.SysAuthOuScopeView;
......@@ -43,19 +43,19 @@ public class SysAuthOuScopeService {
SysAuthOuScopeMapper sysAuthOuScopeMapper = context.getBean(SysAuthOuScopeMapper.class);
SysAuthOuScopeViewMapper sysAuthOuScopeViewMapper = context.getBean(SysAuthOuScopeViewMapper.class);
//删除原关系
QueryWrapper<SysAuthOuScopeEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysAuthOuScopeEnt::getUserId, input.getUserId());
List<SysAuthOuScopeEnt> sysAuthOuScopeEnts = sysAuthOuScopeMapper.selectList(queryWrapper);
List<SysAuthOuScopeEnt> sysAuthOuScopeEnts = sysAuthOuScopeMapper.selectList(new QueryWrapper<SysAuthOuScopeEnt>()
.lambda()
.eq(SysAuthOuScopeEnt::getUserId, input.getUserId()));
List<SysAuthOuScopeEnt> deleteList = new ArrayList<>();
//查询已存在的组织机构和功能
if (!CollectionUtils.isEmpty(sysAuthOuScopeEnts)) {
if (CollUtil.isNotEmpty(sysAuthOuScopeEnts)) {
for (SysAuthOuScopeEnt scopeEnt : sysAuthOuScopeEnts) {
List<String> ouIds = input.getOuIds();
for (String ouId : ouIds) {
List<String> menuIds = input.getMenuIds();
for (String menuId : menuIds) {
if (scopeEnt != null) {
if (ouId.equals(scopeEnt.getOuId()) && menuId.equals(scopeEnt.getMenuId())) {
if (ObjectUtil.isNotNull(scopeEnt)) {
if (CharSequenceUtil.equals(ouId, scopeEnt.getOuId()) && CharSequenceUtil.equals(menuId, scopeEnt.getMenuId())) {
deleteList.add(scopeEnt);
}
}
......@@ -63,11 +63,12 @@ public class SysAuthOuScopeService {
}
}
}
if (!CollectionUtils.isEmpty(deleteList)) {
if (CollUtil.isNotEmpty(deleteList)) {
List<String> collect = deleteList.stream().map(SysAuthOuScopeEnt::getId).collect(Collectors.toList());
sysAuthOuScopeMapper.deleteBatchIds(collect);
}
//创建新关系
PpsUserSession session = context.getSession(PpsUserSession.class);
List<SysAuthOuScopeView> viewList = new ArrayList<>();
List<String> ouIds = input.getOuIds();
for (String ouId : ouIds) {
......@@ -78,14 +79,13 @@ public class SysAuthOuScopeService {
entity.setOuId(ouId);
entity.setUserId(input.getUserId());
entity.setId(UUID.randomUUID().toString());
PpsUserSession session = context.getSession(PpsUserSession.class);
entity.setCreateById(session.getId());
entity.setCreateByName(session.getUserName());
entity.setCreateTime(new Date());
viewList.add(entity);
}
}
if (!CollectionUtils.isEmpty(viewList)) {
if (CollUtil.isNotEmpty(viewList)) {
sysAuthOuScopeViewMapper.batchInsert(viewList);
}
//返回执行成功的结果,事务提交
......@@ -96,16 +96,17 @@ public class SysAuthOuScopeService {
@XText("批量删除")
@XApiPost
public XServiceResult batchDeleteSysAuthOuScope(XContext context, BatchDeleteSysAuthOuScopeInput input) {
SysAuthOuScopeMapper mapper = context.getBean(SysAuthOuScopeMapper.class);
List<String> idList = input.getIdList();
if (!ObjectUtils.isEmpty(idList)) {
idList = idList.stream().filter(item -> !StringUtil.isBlank(item)).collect(Collectors.toList());
if (ObjectUtil.isNotNull(idList)) {
idList = idList.stream()
.filter(CharSequenceUtil::isNotBlank)
.collect(Collectors.toList());
}
if (ObjectUtils.isEmpty(idList)) {
if (CollUtil.isEmpty(idList)) {
return XServiceResult.error(context, XError.NotFound);
}
int i = mapper.deleteBatchIds(idList);
context.getLogger().debug("批量删除:{}", i);
SysAuthOuScopeMapper mapper = context.getBean(SysAuthOuScopeMapper.class);
mapper.deleteBatchIds(idList);
return XServiceResult.OK;
}
......
package pps.core.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import pps.core.system.cache.SysDictionaryCache;
import pps.core.system.entity.SysDictionaryEnt;
import pps.core.system.entity.SysDictionaryView;
......@@ -23,7 +25,6 @@ import xstartup.base.XContext;
import xstartup.base.data.CustomQueryInput;
import xstartup.base.data.XPageInput;
import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XStringUtils;
import xstartup.data.XListResult;
import xstartup.data.XPageResult;
import xstartup.data.XServiceResult;
......@@ -48,10 +49,10 @@ public class SysDictionaryService {
SysDictionaryMapper mapper = context.getBean(SysDictionaryMapper.class);
//如果输入的 alias 为空,查询新增项的上级alias
String alias;
if (StringUtils.isNotBlank(input.getAlias())) {
if (CharSequenceUtil.isNotBlank(input.getAlias())) {
alias = input.getAlias();
List<SysDictionaryCache> list1 = SysDictionaryCache.list(context, alias);
if (ObjectUtils.isNotEmpty(list1)) {
if (CollUtil.isNotEmpty(list1)) {
return XServiceResult.error(200, "字典标识已存在!");
}
} else {
......@@ -63,55 +64,61 @@ public class SysDictionaryService {
} else {
//缓存不存在数据库查询
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysDictionaryEnt::getDicKey, input.getDicKey())
queryWrapper.lambda()
.eq(SysDictionaryEnt::getDicKey, input.getDicKey())
.gt(SysDictionaryEnt::getEndTime, new Date());
if (StringUtils.isNotBlank(input.getPid())) {
if (CharSequenceUtil.isNotBlank(input.getPid())) {
queryWrapper.lambda().eq(SysDictionaryEnt::getPid, input.getPid());
} else {
queryWrapper.lambda().eq(SysDictionaryEnt::getPid, "1");
}
SysDictionaryEnt ent = mapper.selectOne(queryWrapper);
if (ent != null) {
if (ObjectUtil.isNotNull(ent)) {
return XServiceResult.error(200, "字典编码已存在!");
}
}
SysDictionaryEnt entity = new SysDictionaryEnt();
String dicId = UUID.randomUUID().toString();
XCopyUtils.copyObject(input, entity);
if (StringUtils.equals("1", input.getPid())) {
if (StringUtils.isBlank(input.getAlias())) {
if (CharSequenceUtil.equals("1", input.getPid())) {
if (CharSequenceUtil.isBlank(input.getAlias())) {
return XServiceResult.error(200, "新增一级字典,字典标识不能为空!");
}
entity.setPid("1");
entity.setDicPath(null);
} else {
QueryWrapper<SysDictionaryEnt> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(SysDictionaryEnt::getId, input.getPid());
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(wrapper);
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getId, input.getPid()));
//查看有没有dicPath,如果没有说明是一级,直接dicPath=/父级id
if (ObjectUtils.isNotEmpty(sysDictionaryEnt)) {
if (StringUtils.isNotBlank(sysDictionaryEnt.getDicPath())) {
if (ObjectUtil.isNotNull(sysDictionaryEnt)) {
if (CharSequenceUtil.isNotBlank(sysDictionaryEnt.getDicPath())) {
entity.setDicPath(sysDictionaryEnt.getDicPath() + "/" + sysDictionaryEnt.getId());
} else {
entity.setDicPath("/" + sysDictionaryEnt.getId());
}
}
}
if (input.getSort() == null) {
if (ObjectUtil.isNull(input.getSort())) {
QueryWrapper<SysDictionaryEnt> queryMaxSortEntity = new QueryWrapper<>();
queryMaxSortEntity.lambda().gt(SysDictionaryEnt::getEndTime, new Date());
if (StringUtils.isBlank(input.getPid())) {
queryMaxSortEntity.lambda().eq(SysDictionaryEnt::getPid, "1")
.isNotNull(SysDictionaryEnt::getSort).orderByDesc(SysDictionaryEnt::getSort);
if (CharSequenceUtil.isBlank(input.getPid())) {
queryMaxSortEntity.lambda()
.eq(SysDictionaryEnt::getPid, "1")
.isNotNull(SysDictionaryEnt::getSort)
.orderByDesc(SysDictionaryEnt::getSort);
} else {
queryMaxSortEntity.lambda().eq(SysDictionaryEnt::getPid, input.getPid());
queryMaxSortEntity.lambda()
.eq(SysDictionaryEnt::getPid, input.getPid());
}
//查询最大的sort值
queryMaxSortEntity.lambda().isNotNull(SysDictionaryEnt::getSort).orderByDesc(SysDictionaryEnt::getSort);
queryMaxSortEntity.lambda()
.isNotNull(SysDictionaryEnt::getSort)
.orderByDesc(SysDictionaryEnt::getSort);
List<SysDictionaryEnt> sysDictionarys = mapper.selectList(queryMaxSortEntity);
if (ObjectUtils.isNotEmpty(sysDictionarys)) {
if (CollUtil.isNotEmpty(sysDictionarys)) {
SysDictionaryEnt sysDictionaryEnt1 = sysDictionarys.get(0);
if (sysDictionaryEnt1.getSort() != null) {
if (ObjectUtil.isNotNull(sysDictionaryEnt1.getSort())) {
entity.setSort(sysDictionaryEnt1.getSort() + 1);
} else {
entity.setSort(1);
......@@ -122,23 +129,24 @@ public class SysDictionaryService {
}
entity.setEffectTime(new Date());
entity.setId(dicId);
// entity.setcr(context.getSession(PpsUserSession.class).getId());
entity.setCreateName(context.getUser().getName());
entity.setCreateTime(new Date());
mapper.insert(entity);
//更新字典缓存
if (entity.getEndTime() != null) {
if (ObjectUtil.isNotNull(entity.getEndTime())) {
long l = entity.getEndTime().getTime() - System.currentTimeMillis();
if (l > 0) {
SysDictionaryCache.deleteCache(context, alias);
QueryWrapper<SysDictionaryEnt> queryAlias = new QueryWrapper<>();
queryAlias.lambda().eq(SysDictionaryEnt::getAlias, alias).gt(SysDictionaryEnt::getEndTime, new Date());
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(queryAlias);
if (ObjectUtils.isNotEmpty(sysDictionaryEnt)) {
QueryWrapper<SysDictionaryEnt> queryAll = new QueryWrapper<>();
queryAll.lambda().eq(SysDictionaryEnt::getPid, sysDictionaryEnt.getId()).gt(SysDictionaryEnt::getEndTime, new Date());
List<SysDictionaryEnt> sysDictionaryEnts = mapper.selectList(queryAll);
if (ObjectUtils.isNotEmpty(sysDictionaryEnts)) {
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getAlias, alias)
.gt(SysDictionaryEnt::getEndTime, new Date()));
if (ObjectUtil.isNotNull(sysDictionaryEnt)) {
List<SysDictionaryEnt> sysDictionaryEnts = mapper.selectList(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getPid, sysDictionaryEnt.getId())
.gt(SysDictionaryEnt::getEndTime, new Date()));
if (CollUtil.isNotEmpty(sysDictionaryEnts)) {
sysDictionaryEnts.add(entity);
}
sysDictionaryEnts.add(sysDictionaryEnt);
......@@ -155,12 +163,12 @@ public class SysDictionaryService {
public String selectSysDictionaryAlias(XContext context, String pid) {
SysDictionaryMapper mapper = context.getBean(SysDictionaryMapper.class);
String alias = "";
while (StringUtils.isBlank(alias)) {
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysDictionaryEnt::getId, pid);
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(queryWrapper);
if (ObjectUtils.isNotEmpty(sysDictionaryEnt)) {
if (StringUtils.isNotBlank(sysDictionaryEnt.getAlias())) {
while (CharSequenceUtil.isBlank(alias)) {
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getId, pid));
if (ObjectUtil.isNotNull(sysDictionaryEnt)) {
if (CharSequenceUtil.isNotBlank(sysDictionaryEnt.getAlias())) {
alias = sysDictionaryEnt.getAlias();
} else {
pid = sysDictionaryEnt.getPid();
......@@ -178,13 +186,13 @@ public class SysDictionaryService {
SysDictionaryMapper mapper = context.getBean(SysDictionaryMapper.class);
//如果输入的alias为空,查询新增项的上级alias
String alias;
if (StringUtils.isNotBlank(input.getAlias())) {
if (CharSequenceUtil.isNotBlank(input.getAlias())) {
alias = input.getAlias();
List<SysDictionaryCache> list1 = SysDictionaryCache.list(context, alias);
if (ObjectUtils.isNotEmpty(list1)) {
if (CollUtil.isNotEmpty(list1)) {
boolean flag = true;
for (SysDictionaryCache cash : list1) {
if (StringUtils.equals(cash.getId(), input.getId()) && StringUtils.equals(alias, cash.getAlias())) {
if (CharSequenceUtil.equals(cash.getId(), input.getId()) && CharSequenceUtil.equals(alias, cash.getAlias())) {
flag = false;
}
}
......@@ -197,10 +205,10 @@ public class SysDictionaryService {
boolean exist = SysDictionaryCache.exist(context, alias, input.getDicKey());
if (exist) {
List<SysDictionaryCache> list1 = SysDictionaryCache.list(context, alias);
if (ObjectUtils.isNotEmpty(list1)) {
if (CollUtil.isNotEmpty(list1)) {
boolean flag = true;
for (SysDictionaryCache cash : list1) {
if (StringUtils.equals(cash.getId(), input.getId())) {
if (CharSequenceUtil.equals(cash.getId(), input.getId())) {
flag = false;
}
}
......@@ -211,10 +219,10 @@ public class SysDictionaryService {
}
}
//查询需要修改的
QueryWrapper<SysDictionaryEnt> queryEntity = new QueryWrapper<>();
queryEntity.lambda().eq(SysDictionaryEnt::getId, input.getId());
SysDictionaryEnt entity = mapper.selectOne(queryEntity);
if (entity == null) {
SysDictionaryEnt entity = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -225,10 +233,10 @@ public class SysDictionaryService {
List<SysDictionaryCache> list = SysDictionaryCache.list(context, alias);
List<SysDictionaryCache> items = new ArrayList<>();
for (SysDictionaryCache dict : list) {
if (StringUtils.equals(entity.getId(), dict.getId())) {
if (CharSequenceUtil.equals(entity.getId(), dict.getId())) {
SysDictionaryCache.delete(context, alias, entity.getId());
//更新字典缓存
if (entity.getEndTime() != null) {
if (ObjectUtil.isNotNull(entity.getEndTime())) {
long l = entity.getEndTime().getTime() - new Date().getTime();
if (l > 0) {
SysDictionaryCache sysDictionaryCache = new SysDictionaryCache();
......@@ -248,17 +256,17 @@ public class SysDictionaryService {
@XApiPost
public XServiceResult deleteSysDictionary(XContext context, DeleteSysDictionaryInput input) {
SysDictionaryMapper mapper = context.getBean(SysDictionaryMapper.class);
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysDictionaryEnt::getId, input.getId());
SysDictionaryEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysDictionaryEnt entity = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
SysDictionaryEnt sysDictionaryEnt = new SysDictionaryEnt();
sysDictionaryEnt.setId(entity.getId());
sysDictionaryEnt.setEndTime(new Date());
mapper.updateById(sysDictionaryEnt);
if (StringUtils.isBlank(entity.getAlias())) {
if (CharSequenceUtil.isBlank(entity.getAlias())) {
String alias = selectSysDictionaryAlias(context, entity.getPid());
SysDictionaryCache.delete(context, alias, entity.getId());
} else {
......@@ -271,10 +279,10 @@ public class SysDictionaryService {
@XApiPost
public XSingleResult<GetSysDictionaryOutput> getSysDictionary(XContext context, GetSysDictionaryInput input) {
SysDictionaryMapper mapper = context.getBean(SysDictionaryMapper.class);
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysDictionaryEnt::getId, input.getId());
SysDictionaryEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysDictionaryEnt entity = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysDictionaryOutput output = new GetSysDictionaryOutput();
......@@ -289,25 +297,26 @@ public class SysDictionaryService {
SysDictionaryViewMapper viewMapper = context.getBean(SysDictionaryViewMapper.class);
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().gt(SysDictionaryEnt::getEndTime, new Date());
if (StringUtils.isNotBlank(input.getId())) {
if (CharSequenceUtil.isNotBlank(input.getId())) {
queryWrapper.lambda().eq(SysDictionaryEnt::getId, input.getId());
}
if (StringUtils.isNotBlank(input.getParentId())) {
if (CharSequenceUtil.isNotBlank(input.getParentId())) {
queryWrapper.lambda().eq(SysDictionaryEnt::getPid, input.getParentId());
if (StringUtils.equals("1", input.getParentId())) {
QueryWrapper<SysDictionaryEnt> query = new QueryWrapper();
if (StringUtils.isNotBlank(input.getCode())) {
if (CharSequenceUtil.equals("1", input.getParentId())) {
QueryWrapper<SysDictionaryEnt> query = new QueryWrapper<>();
if (CharSequenceUtil.isNotBlank(input.getCode())) {
query.lambda().like(SysDictionaryEnt::getDicKey, input.getCode());
}
if (StringUtils.isNotBlank(input.getDicName())) {
if (CharSequenceUtil.isNotBlank(input.getDicName())) {
query.lambda().like(SysDictionaryEnt::getDicName, input.getDicName());
}
List<SysDictionaryEnt> sysDictionaryEnts = mapper.selectList(query);
if (ObjectUtils.isNotEmpty(sysDictionaryEnts)) {
List<String> collect = sysDictionaryEnts.stream().map(p -> {
if (StringUtils.isNotBlank(p.getDicPath())) {
if (CollUtil.isNotEmpty(sysDictionaryEnts)) {
List<String> collect = sysDictionaryEnts.stream()
.map(p -> {
if (CharSequenceUtil.isNotBlank(p.getDicPath())) {
String[] split = p.getDicPath().split("/");
if (ObjectUtils.isNotEmpty(split) && split.length > 1) {
if (ArrayUtil.isNotEmpty(split)) {
return split[1];
} else {
return null;
......@@ -315,7 +324,8 @@ public class SysDictionaryService {
} else {
return p.getId();
}
}).distinct().collect(Collectors.toList());
}).distinct()
.collect(Collectors.toList());
queryWrapper.lambda().in(SysDictionaryEnt::getId, collect);
} else {
return XPageResult.success(Collections.emptyList(), 1, 1, 0);
......@@ -325,14 +335,14 @@ public class SysDictionaryService {
input.setLimit(2000);
}
}
if (input.getDicType() != null) {
if (ObjectUtil.isNotNull(input.getDicType())) {
queryWrapper.lambda().eq(SysDictionaryEnt::getDicType, input.getDicType());
}
queryWrapper.lambda().orderByAsc(SysDictionaryEnt::getSort);
XPageResult<QuerySysDictionaryOutput> query = XMapperHelper.query(mapper, input, queryWrapper, QuerySysDictionaryOutput.class);
List<QuerySysDictionaryOutput> items = query.getResult().getItems();
if (items != null && !items.isEmpty()) {
List<String> ids = items.stream().map(p -> p.getId()).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(items)) {
List<String> ids = items.stream().map(QuerySysDictionaryOutput::getId).distinct().collect(Collectors.toList());
SysDictionaryView sysDictionaryView = new SysDictionaryView();
StringBuilder idsStr = new StringBuilder();
for (int i = 0; i < ids.size(); i++) {
......@@ -347,10 +357,10 @@ public class SysDictionaryService {
List<SysDictionaryView> sysDictionaryViews = viewMapper.selectListsByParentIds(sysDictionaryView);
int i = 0;
for (QuerySysDictionaryOutput out : items) {
if (sysDictionaryViews != null && !sysDictionaryViews.isEmpty()) {
if (CollUtil.isNotEmpty(sysDictionaryViews)) {
boolean flag = false;
for (SysDictionaryView view : sysDictionaryViews) {
if (StringUtils.equals(out.getId(), view.getPid())) {
if (CharSequenceUtil.equals(out.getId(), view.getPid())) {
flag = true;
break;
}
......@@ -372,13 +382,13 @@ public class SysDictionaryService {
@XText("分页条件查询字典")
@XApiPost
public XPageResult<QuerySysDictionaryOutput> querySysDictionaryOn(XContext context, QuerySysDictionaryInput input) {
if (XStringUtils.isNotEmpty(input.getCode()) || XStringUtils.isNotEmpty(input.getDicName())) {
if (CharSequenceUtil.isAllNotBlank(input.getCode(), input.getDicName())) {
SysDictionaryViewMapper mapper = context.getBean(SysDictionaryViewMapper.class);
SysDictionaryView view = new SysDictionaryView();
if (StringUtils.isNotBlank(input.getCode())) {
if (CharSequenceUtil.isNotBlank(input.getCode())) {
view.setDicKey(input.getCode());
}
if (StringUtils.isNotBlank(input.getDicName())) {
if (CharSequenceUtil.isNotBlank(input.getDicName())) {
view.setDicName(input.getDicName());
}
List<SysDictionaryView> viewList = mapper.selectTreeList(view);
......@@ -392,16 +402,16 @@ public class SysDictionaryService {
if (tree.getSort() == null)
tree.setSort(0);
tree.setChildren(null);
if (tree.getPid() == null || "".equals(tree.getPid()) || "1".equals(tree.getPid())) {
if (CharSequenceUtil.isBlank(tree.getPid()) || "1".equals(tree.getPid())) {
trees.add(tree);
tree.setXh(++i + "");
}
//子集
int j = 0;
for (QuerySysDictionaryOutput it : list) {
if (tree.getId().equals(it.getPid())) {
if (tree.getChildren() == null) {
tree.setChildren(new ArrayList<>());
if (CharSequenceUtil.equals(tree.getId(), it.getPid())) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(Collections.emptyList());
}
it.setXh(++j + "");
tree.set_showChildren(true);
......@@ -410,7 +420,7 @@ public class SysDictionaryService {
tree.setBeDefault(1);
}
}
if (tree.getChildren() != null && tree.getChildren().size() > 1) {
if (CollUtil.isNotEmpty(tree.getChildren())) {
List<QuerySysDictionaryOutput> children = tree.getChildren();
children = children.stream().sorted(Comparator.comparing(QuerySysDictionaryOutput::getXh)).collect(Collectors.toList());
tree.setChildren(children);
......@@ -424,25 +434,25 @@ public class SysDictionaryService {
SysDictionaryViewMapper viewMapper = context.getBean(SysDictionaryViewMapper.class);
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().gt(SysDictionaryEnt::getEndTime, new Date());
if (StringUtils.isNotBlank(input.getId())) {
if (CharSequenceUtil.isNotBlank(input.getId())) {
queryWrapper.lambda().eq(SysDictionaryEnt::getId, input.getId());
}
if (StringUtils.isNotBlank(input.getParentId())) {
if (CharSequenceUtil.isNotBlank(input.getParentId())) {
queryWrapper.lambda().eq(SysDictionaryEnt::getPid, input.getParentId());
if (StringUtils.equals("1", input.getParentId())) {
if (CharSequenceUtil.equals("1", input.getParentId())) {
QueryWrapper<SysDictionaryEnt> query = new QueryWrapper<>();
if (StringUtils.isNotBlank(input.getCode())) {
if (CharSequenceUtil.isNotBlank(input.getCode())) {
query.lambda().like(SysDictionaryEnt::getDicKey, input.getCode());
}
if (StringUtils.isNotBlank(input.getDicName())) {
if (CharSequenceUtil.isNotBlank(input.getDicName())) {
query.lambda().like(SysDictionaryEnt::getDicName, input.getDicName());
}
List<SysDictionaryEnt> sysDictionaryEnts = mapper.selectList(query);
if (ObjectUtils.isNotEmpty(sysDictionaryEnts)) {
if (CollUtil.isNotEmpty(sysDictionaryEnts)) {
List<String> collect = sysDictionaryEnts.stream().map(p -> {
if (StringUtils.isNotBlank(p.getDicPath())) {
if (CharSequenceUtil.isNotBlank(p.getDicPath())) {
String[] split = p.getDicPath().split("/");
if (ObjectUtils.isNotEmpty(split) && split.length > 1) {
if (ArrayUtil.isNotEmpty(split)) {
return split[1];
} else {
return null;
......@@ -450,7 +460,8 @@ public class SysDictionaryService {
} else {
return p.getId();
}
}).distinct().collect(Collectors.toList());
}).distinct()
.collect(Collectors.toList());
queryWrapper.lambda().in(SysDictionaryEnt::getId, collect);
} else {
return XPageResult.success(Collections.emptyList(), 1, 1, 0);
......@@ -460,15 +471,17 @@ public class SysDictionaryService {
input.setLimit(2000);
}
}
if (input.getDicType() != null) {
if (ObjectUtil.isNotNull(input.getDicType())) {
queryWrapper.lambda().eq(SysDictionaryEnt::getDicType, input.getDicType());
}
queryWrapper.lambda().orderByAsc(SysDictionaryEnt::getSort);
XPageResult<QuerySysDictionaryOutput> query = XMapperHelper.query(mapper, input, queryWrapper, QuerySysDictionaryOutput.class);
List<QuerySysDictionaryOutput> items = query.getResult().getItems();
if (items != null && !items.isEmpty()) {
List<String> ids = items.stream().map(QuerySysDictionaryOutput::getId
).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(items)) {
List<String> ids = items.stream()
.map(QuerySysDictionaryOutput::getId)
.distinct()
.collect(Collectors.toList());
SysDictionaryView sysDictionaryView = new SysDictionaryView();
StringBuilder idsStr = new StringBuilder();
for (int i = 0; i < ids.size(); i++) {
......@@ -483,10 +496,10 @@ public class SysDictionaryService {
List<SysDictionaryView> sysDictionaryViews = viewMapper.selectListsByParentIds(sysDictionaryView);
int i = 0;
for (QuerySysDictionaryOutput out : items) {
if (sysDictionaryViews != null && !sysDictionaryViews.isEmpty()) {
if (CollUtil.isNotEmpty(sysDictionaryViews)) {
boolean flag = false;
for (SysDictionaryView view : sysDictionaryViews) {
if (StringUtils.equals(out.getId(), view.getPid())) {
if (CharSequenceUtil.equals(out.getId(), view.getPid())) {
flag = true;
break;
}
......@@ -510,32 +523,32 @@ public class SysDictionaryService {
@XApiPost
public XListResult<QuerySysDictionaryOutput> getSysDictionaryTree(XContext context, QuerySysDictionaryInput input) {
SysDictionaryViewMapper mapper = context.getBean(SysDictionaryViewMapper.class);
if (XStringUtils.isEmpty(input.getCode()) && XStringUtils.isEmpty(input.getDicName()))
if (CharSequenceUtil.isAllNotEmpty(input.getCode(), input.getDicName()))
return XListResult.error(500, "请输入查询参数");
SysDictionaryView view = new SysDictionaryView();
if (StringUtils.isNotBlank(input.getCode())) {
if (CharSequenceUtil.isNotBlank(input.getCode())) {
view.setDicKey(input.getCode());
}
if (StringUtils.isNotBlank(input.getDicName())) {
if (CharSequenceUtil.isNotBlank(input.getDicName())) {
view.setDicName(input.getDicName());
}
List<SysDictionaryView> viewList = mapper.selectTreeList(view);
List<QuerySysDictionaryOutput> list = XCopyUtils.copyNewList(viewList, QuerySysDictionaryOutput.class);
List<QuerySysDictionaryOutput> trees = new ArrayList<>();
for (QuerySysDictionaryOutput tree : list) {
if (tree.getPid() == null || "".equals(tree.getPid()) || "1".equals(tree.getPid())) {
if (CharSequenceUtil.isBlank(tree.getPid()) || "1".equals(tree.getPid())) {
trees.add(tree);
}
//子集
for (QuerySysDictionaryOutput it : list) {
if (tree.getId().equals(it.getPid())) {
if (tree.getChildren() == null) {
tree.setChildren(new ArrayList<>());
if (CharSequenceUtil.equals(tree.getId(), it.getPid())) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(Collections.emptyList());
}
tree.getChildren().add(it);
}
}
if (tree.getChildren() != null && tree.getChildren().size() > 1) {
if (CollUtil.isNotEmpty(tree.getChildren())) {
List<QuerySysDictionaryOutput> children = tree.getChildren();
children = children.stream().sorted(Comparator.comparing(QuerySysDictionaryOutput::getSort)).collect(Collectors.toList());
tree.setChildren(children);
......@@ -557,7 +570,7 @@ public class SysDictionaryService {
SysDictionaryView record = new SysDictionaryView();
XCopyUtils.copyObject(input, record);
SysDictionaryView view = mapper.selectOne(record);
if (view == null) {
if (ObjectUtil.isNull(view)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysDictionaryViewOutput output = new GetSysDictionaryViewOutput();
......@@ -597,18 +610,20 @@ public class SysDictionaryService {
SysOrganizationDictionaryMapper orgDicmapper = context.getBean(SysOrganizationDictionaryMapper.class);
SysOrganizationRelMapper orgRelMapper = context.getBean(SysOrganizationRelMapper.class);
List<SysDictionaryCache> list = SysDictionaryCache.list(context, input.getAlias());
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysDictionaryEnt::getAlias, input.getAlias()).gt(SysDictionaryEnt::getEndTime, new Date());
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(queryWrapper);
list = list.stream().filter((SysDictionaryCache dic) -> StringUtils.equals(dic.getPid(), sysDictionaryEnt.getId()))
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getAlias, input.getAlias())
.gt(SysDictionaryEnt::getEndTime, new Date()));
list = list.stream().filter((SysDictionaryCache dic) -> CharSequenceUtil.equals(dic.getPid(), sysDictionaryEnt.getId()))
.collect(Collectors.toList());
if (ObjectUtils.isEmpty(list)) {
if (CollUtil.isEmpty(list)) {
list = SysDictionaryCache.list(context, input.getAlias());
//查询alias字典
QueryWrapper<SysDictionaryEnt> query = new QueryWrapper<>();
query.lambda().eq(SysDictionaryEnt::getAlias, input.getAlias()).gt(SysDictionaryEnt::getEndTime, new Date());
SysDictionaryEnt sysDictionary = mapper.selectOne(query);
if (ObjectUtils.isNotEmpty(sysDictionary)) {
SysDictionaryEnt sysDictionary = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getAlias, input.getAlias())
.gt(SysDictionaryEnt::getEndTime, new Date()));
if (ObjectUtil.isNotNull(sysDictionary)) {
list = new ArrayList<>();
SysDictionaryCache.set(context, input.getAlias(), list);
SysDictionaryCache sysDictionaryCache = new SysDictionaryCache();
......@@ -617,24 +632,25 @@ public class SysDictionaryService {
//查询alias字典下级字典项
QueryWrapper<SysDictionaryEnt> queryItems = new QueryWrapper<>();
//如果字典项在单位属性字典配置了,需要查询单位属性字典
if (ObjectUtils.isNotEmpty(sysDictionary.getIsOrg()) && sysDictionary.getIsOrg() == 1) {
if (ObjectUtil.isNotNull(sysDictionary.getIsOrg()) && sysDictionary.getIsOrg() == 1) {
//查询当前登录人的组织机构层级路径
QueryWrapper<SysOrganizationRelEnt> queryOrgRel = new QueryWrapper<>();
queryOrgRel.lambda().eq(SysOrganizationRelEnt::getOuId, input.getOuId())
.gt(SysOrganizationRelEnt::getEndTime, new Date());
SysOrganizationRelEnt sysOrganizationRelEnt = orgRelMapper.selectOne(queryOrgRel);
SysOrganizationRelEnt sysOrganizationRelEnt = orgRelMapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.eq(SysOrganizationRelEnt::getOuId, input.getOuId())
.gt(SysOrganizationRelEnt::getEndTime, new Date()));
//根据字典id查询
QueryWrapper<SysOrganizationDictionaryEnt> queryOrgDic = new QueryWrapper<>();
queryOrgDic.lambda().eq(SysOrganizationDictionaryEnt::getParentDicCode, sysDictionary.getId())
.gt(SysOrganizationDictionaryEnt::getEndTime, new Date());
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(queryOrgDic);
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(new QueryWrapper<SysOrganizationDictionaryEnt>()
.lambda()
.eq(SysOrganizationDictionaryEnt::getParentDicCode, sysDictionary.getId())
.gt(SysOrganizationDictionaryEnt::getEndTime, new Date()));
String ouIdPath = sysOrganizationRelEnt.getOuIdPath();
String ouId = sysOrganizationRelEnt.getOuId();
if (StringUtils.isNotBlank(ouIdPath)) {
List<String> dicIds = sysOrganizationDictionaryEnts.stream().map(p -> {
if (ouIdPath.contains(p.getOuId()) && p.getUseLowerLevel() == 1) {
if (CharSequenceUtil.isNotBlank(ouIdPath)) {
List<String> dicIds = sysOrganizationDictionaryEnts.stream()
.map(p -> {
if (CharSequenceUtil.contains(ouIdPath, p.getOuId()) && p.getUseLowerLevel() == 1) {
return p.getDicCode();
} else if (ouId.contains(p.getOuId())) {
} else if (CharSequenceUtil.contains(ouId, p.getOuId())) {
return p.getDicCode();
} else {
return "1";
......@@ -645,8 +661,8 @@ public class SysDictionaryService {
}
queryItems.lambda().eq(SysDictionaryEnt::getPid, sysDictionaryCache.getId()).gt(SysDictionaryEnt::getEndTime, new Date());
List<SysDictionaryEnt> sysDictionaryList = mapper.selectList(queryItems);
if (ObjectUtils.isNotEmpty(sysDictionaryList)) {
if (ObjectUtils.isNotEmpty(list)) {
if (CollUtil.isNotEmpty(sysDictionaryList)) {
if (CollUtil.isNotEmpty(list)) {
for (SysDictionaryEnt ent : sysDictionaryList) {
SysDictionaryCache cache = new SysDictionaryCache();
XCopyUtils.copyObject(ent, cache);
......@@ -654,7 +670,7 @@ public class SysDictionaryService {
}
}
sysDictionaryList.sort((o1, o2) -> {
if (ObjectUtils.isNotEmpty(o1.getSort()) && ObjectUtils.isNotEmpty(o2.getSort())) {
if (ObjectUtil.isAllNotEmpty(o1.getSort(), o2.getSort())) {
return o1.getSort() - o2.getSort();
} else {
return 0;
......@@ -665,24 +681,24 @@ public class SysDictionaryService {
}
}
}
if (ObjectUtils.isNotEmpty(sysDictionaryEnt.getIsOrg()) && sysDictionaryEnt.getIsOrg() == 1) {
if (ObjectUtil.isNotNull(sysDictionaryEnt.getIsOrg()) && sysDictionaryEnt.getIsOrg() == 1) {
//查询当前登录人的组织机构层级路径
QueryWrapper<SysOrganizationRelEnt> queryOrgRel = new QueryWrapper<>();
queryOrgRel.lambda().eq(SysOrganizationRelEnt::getOuId, input.getOuId())
.gt(SysOrganizationRelEnt::getEndTime, new Date());
SysOrganizationRelEnt sysOrganizationRelEnt = orgRelMapper.selectOne(queryOrgRel);
SysOrganizationRelEnt sysOrganizationRelEnt = orgRelMapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.eq(SysOrganizationRelEnt::getOuId, input.getOuId())
.gt(SysOrganizationRelEnt::getEndTime, new Date()));
//根据字典id查询
QueryWrapper<SysOrganizationDictionaryEnt> queryOrgDic = new QueryWrapper<>();
queryOrgDic.lambda().eq(SysOrganizationDictionaryEnt::getParentDicCode, sysDictionaryEnt.getId())
.gt(SysOrganizationDictionaryEnt::getEndTime, new Date());
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(queryOrgDic);
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(new QueryWrapper<SysOrganizationDictionaryEnt>()
.lambda()
.eq(SysOrganizationDictionaryEnt::getParentDicCode, sysDictionaryEnt.getId())
.gt(SysOrganizationDictionaryEnt::getEndTime, new Date()));
String ouIdPath = sysOrganizationRelEnt.getOuIdPath();
String ouId = sysOrganizationRelEnt.getOuId();
if (StringUtils.isNotBlank(ouIdPath)) {
if (CharSequenceUtil.isNotBlank(ouIdPath)) {
List<String> dicIds = sysOrganizationDictionaryEnts.stream().map(p -> {
if (ouIdPath.contains(p.getOuId()) && p.getUseLowerLevel() == 1) {
if (CharSequenceUtil.contains(ouIdPath, p.getOuId()) && p.getUseLowerLevel() == 1) {
return p.getDicCode();
} else if (ouId.contains(p.getOuId())) {
} else if (CharSequenceUtil.contains(ouId, p.getOuId())) {
return p.getDicCode();
} else {
return "1";
......@@ -692,7 +708,7 @@ public class SysDictionaryService {
}
}
list.sort((o1, o2) -> {
if (ObjectUtils.isNotEmpty(o1.getSort()) && ObjectUtils.isNotEmpty(o2.getSort())) {
if (ObjectUtil.isAllNotEmpty(o1.getSort(), o2.getSort())) {
return o1.getSort() - o2.getSort();
} else {
return 0;
......@@ -718,14 +734,14 @@ public class SysDictionaryService {
//子集
for (QuerySysDictionaryViewOutput it : outputs) {
if (tree.getId().equals(it.getParentSysDictionaryId())) {
if (tree.getChildren() == null) {
tree.setChildren(new ArrayList<>());
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(Collections.emptyList());
}
tree.getChildren().add(it);
}
}
}
trees.stream().sorted(Comparator.comparing(QuerySysDictionaryViewOutput::getSort)).collect(Collectors.toList());
trees.sort(Comparator.comparing(QuerySysDictionaryViewOutput::getSort));
return XListResult.success(trees);
}
......@@ -734,7 +750,8 @@ public class SysDictionaryService {
public XServiceResult updateBasePipelinePath(XContext context, UpdateSysDictionaryInput input) {
SysDictionaryMapper mapper = context.getBean(SysDictionaryMapper.class);
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().and(wrapper -> wrapper.eq(SysDictionaryEnt::getPid, "1").or().eq(SysDictionaryEnt::getPid, null)
queryWrapper.lambda()
.and(wrapper -> wrapper.eq(SysDictionaryEnt::getPid, "1").or().eq(SysDictionaryEnt::getPid, null)
.or().eq(SysDictionaryEnt::getPid, "2").or().eq(SysDictionaryEnt::getPid, "20"));
XPageInput page = new XPageInput();
page.setPage(1);
......@@ -747,25 +764,27 @@ public class SysDictionaryService {
public XServiceResult updateBasePipelineParentPath(XContext context, List<SysDictionaryEnt> dics) {
SysDictionaryMapper mapper = context.getBean(SysDictionaryMapper.class);
List<String> list = dics.stream().map(SysDictionaryEnt::getId
).distinct().collect(Collectors.toList());
while (ObjectUtils.isNotEmpty(list)) {
List<String> list = dics.stream()
.map(SysDictionaryEnt::getId)
.distinct()
.collect(Collectors.toList());
while (CollUtil.isNotEmpty(list)) {
//更新二级字典parentPath
QueryWrapper<SysDictionaryEnt> wrapper = new QueryWrapper<>();
wrapper.lambda().in(SysDictionaryEnt::getPid, list);
List<SysDictionaryEnt> sysDictionaryEnts = mapper.selectList(wrapper);
if (ObjectUtils.isNotEmpty(sysDictionaryEnts)) {
List<SysDictionaryEnt> sysDictionaryEnts = mapper.selectList(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.in(SysDictionaryEnt::getPid, list));
if (CollUtil.isNotEmpty(sysDictionaryEnts)) {
for (SysDictionaryEnt entity : sysDictionaryEnts) {
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().in(SysDictionaryEnt::getId, entity.getPid());
SysDictionaryEnt pdic = mapper.selectOne(queryWrapper);
String parentPath = pdic.getDicPath() == null ? "/" + pdic.getId() : pdic.getDicPath() + "/" + pdic.getId();
// String parentPath = entity.getDicPath() == null || entity.getDicPath() == "null" ? "/" + entity.getPid() : entity.getDicPath() + "/" + childDic.getId();
entity.setDicPath(parentPath);
SysDictionaryEnt pdic = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.in(SysDictionaryEnt::getId, entity.getPid()));
entity.setDicPath(CharSequenceUtil.isBlank(pdic.getDicPath()) ? "/" + pdic.getId() : pdic.getDicPath() + "/" + pdic.getId());
mapper.updateById(entity);
}
list = sysDictionaryEnts.stream().map(SysDictionaryEnt::getId
).distinct().collect(Collectors.toList());
list = sysDictionaryEnts.stream()
.map(SysDictionaryEnt::getId)
.distinct()
.collect(Collectors.toList());
} else {
list = null;
}
......@@ -779,12 +798,12 @@ public class SysDictionaryService {
SysDictionaryMapper mapper = context.getBean(SysDictionaryMapper.class);
QueryWrapper<SysDictionaryEnt> query = new QueryWrapper<>();
//查询当前字典项
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysDictionaryEnt::getId, input.getId());
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(queryWrapper);
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getId, input.getId()));
//查询上一个或者下一个字典项
query.lambda().eq(SysDictionaryEnt::getPid, sysDictionaryEnt.getPid());
if (StringUtils.equals("up", input.getSortFlag())) {
if (CharSequenceUtil.equals("up", input.getSortFlag())) {
query.lambda().lt(SysDictionaryEnt::getSort, sysDictionaryEnt.getSort())
.orderByDesc(SysDictionaryEnt::getSort);
} else {
......@@ -793,7 +812,7 @@ public class SysDictionaryService {
}
List<SysDictionaryEnt> sysDictionaryEnts = mapper.selectList(query);
Integer sort;
if (ObjectUtils.isNotEmpty(sysDictionaryEnts)) {
if (CollUtil.isNotEmpty(sysDictionaryEnts)) {
SysDictionaryEnt sysDictionaryEnt1 = sysDictionaryEnts.get(0);
//交换排序值
sort = sysDictionaryEnt1.getSort();
......@@ -814,18 +833,19 @@ public class SysDictionaryService {
SysDictionaryMapper mapper = context.getBean(SysDictionaryMapper.class);
SysOrganizationDictionaryMapper orgDicmapper = context.getBean(SysOrganizationDictionaryMapper.class);
List<SysDictionaryCache> list = SysDictionaryCache.list(context, RULE_NUMBER_ALIAS);
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysDictionaryEnt::getAlias, RULE_NUMBER_ALIAS);
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(queryWrapper);
list = list.stream().filter((SysDictionaryCache dic) -> StringUtils.equals(dic.getPid(), sysDictionaryEnt.getId()))
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getAlias, RULE_NUMBER_ALIAS));
list = list.stream().filter(dic -> CharSequenceUtil.equals(dic.getPid(), sysDictionaryEnt.getId()))
.collect(Collectors.toList());
if (ObjectUtils.isEmpty(list)) {
if (CollUtil.isEmpty(list)) {
list = SysDictionaryCache.list(context, RULE_NUMBER_ALIAS);
//查询alias字典
QueryWrapper<SysDictionaryEnt> query = new QueryWrapper<>();
query.lambda().eq(SysDictionaryEnt::getAlias, RULE_NUMBER_ALIAS).gt(SysDictionaryEnt::getEndTime, new Date());
SysDictionaryEnt sysDictionary = mapper.selectOne(query);
if (ObjectUtils.isNotEmpty(sysDictionary)) {
SysDictionaryEnt sysDictionary = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getAlias, RULE_NUMBER_ALIAS)
.gt(SysDictionaryEnt::getEndTime, new Date()));
if (ObjectUtil.isNotNull(sysDictionary)) {
list = new ArrayList<>();
SysDictionaryCache.set(context, RULE_NUMBER_ALIAS, list);
SysDictionaryCache sysDictionaryCache = new SysDictionaryCache();
......@@ -833,19 +853,20 @@ public class SysDictionaryService {
list.add(sysDictionaryCache);
//查询alias字典下级字典项
QueryWrapper<SysDictionaryEnt> queryItems = new QueryWrapper<>();
if (ObjectUtils.isNotEmpty(sysDictionary.getIsOrg()) && sysDictionary.getIsOrg() == 1) {
QueryWrapper<SysOrganizationDictionaryEnt> queryOrgDic = new QueryWrapper<>();
queryOrgDic.lambda().eq(SysOrganizationDictionaryEnt::getOuId, RULE_NUMBER_ALIAS)
.eq(SysOrganizationDictionaryEnt::getParentDicCode, sysDictionary.getId()).gt(SysOrganizationDictionaryEnt::getEndTime, new Date());
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(queryOrgDic);
if (ObjectUtil.isNotNull(sysDictionary.getIsOrg()) && sysDictionary.getIsOrg() == 1) {
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(new QueryWrapper<SysOrganizationDictionaryEnt>()
.lambda()
.eq(SysOrganizationDictionaryEnt::getOuId, RULE_NUMBER_ALIAS)
.eq(SysOrganizationDictionaryEnt::getParentDicCode, sysDictionary.getId())
.gt(SysOrganizationDictionaryEnt::getEndTime, new Date()));
List<String> dicIds = sysOrganizationDictionaryEnts.stream().map(SysOrganizationDictionaryEnt::getDicCode
).collect(Collectors.toList());
queryItems.lambda().in(SysDictionaryEnt::getId, dicIds);
}
queryItems.lambda().eq(SysDictionaryEnt::getPid, sysDictionaryCache.getId()).gt(SysDictionaryEnt::getEndTime, new Date());
List<SysDictionaryEnt> sysDictionaryList = mapper.selectList(queryItems);
if (ObjectUtils.isNotEmpty(sysDictionaryList)) {
if (ObjectUtils.isNotEmpty(list)) {
if (CollUtil.isNotEmpty(sysDictionaryList)) {
if (CollUtil.isNotEmpty(list)) {
for (SysDictionaryEnt ent : sysDictionaryList) {
SysDictionaryCache cache = new SysDictionaryCache();
XCopyUtils.copyObject(ent, cache);
......@@ -853,7 +874,7 @@ public class SysDictionaryService {
}
}
list.sort((o1, o2) -> {
if (ObjectUtils.isNotEmpty(o1.getSort()) && ObjectUtils.isNotEmpty(o2.getSort())) {
if (ObjectUtil.isAllNotEmpty(o1.getSort(), o2.getSort())) {
return o1.getSort() - o2.getSort();
} else {
return o1.getId().compareTo(o2.getId());
......@@ -865,17 +886,17 @@ public class SysDictionaryService {
}
}
}
if (ObjectUtils.isNotEmpty(sysDictionaryEnt.getIsOrg()) && sysDictionaryEnt.getIsOrg() == 1) {
QueryWrapper<SysOrganizationDictionaryEnt> queryOrgDic = new QueryWrapper<>();
queryOrgDic.lambda().eq(SysOrganizationDictionaryEnt::getOuId, sysDictionaryEnt.getId())
.eq(SysOrganizationDictionaryEnt::getParentDicCode, sysDictionaryEnt.getId()).gt(SysOrganizationDictionaryEnt::getEndTime, new Date());
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(queryOrgDic);
List<String> dicIds = sysOrganizationDictionaryEnts.stream().map(SysOrganizationDictionaryEnt::getDicCode
).collect(Collectors.toList());
if (ObjectUtil.isNotNull(sysDictionaryEnt.getIsOrg()) && sysDictionaryEnt.getIsOrg().equals(1)) {
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(new QueryWrapper<SysOrganizationDictionaryEnt>()
.lambda()
.eq(SysOrganizationDictionaryEnt::getOuId, sysDictionaryEnt.getId())
.eq(SysOrganizationDictionaryEnt::getParentDicCode, sysDictionaryEnt.getId())
.gt(SysOrganizationDictionaryEnt::getEndTime, new Date()));
List<String> dicIds = sysOrganizationDictionaryEnts.stream().map(SysOrganizationDictionaryEnt::getDicCode).collect(Collectors.toList());
list = list.stream().filter(i -> dicIds.contains(i.getId())).collect(Collectors.toList());
}
list.sort((o1, o2) -> {
if (ObjectUtils.isNotEmpty(o1.getSort()) && ObjectUtils.isNotEmpty(o2.getSort())) {
if (ObjectUtil.isAllNotEmpty(o1.getSort(), o2.getSort())) {
return o1.getSort() - o2.getSort();
} else {
return 0;
......@@ -894,9 +915,9 @@ public class SysDictionaryService {
@XApiPost
public XServiceResult createRuleNumber(XContext context, CreateRuleNumberInput input) throws ParseException {
SysDictionaryMapper mapper = context.getBean(SysDictionaryMapper.class);
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysDictionaryEnt::getAlias, "rule_number");
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(queryWrapper);
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.eq(SysDictionaryEnt::getAlias, "rule_number"));
SysDictionaryEnt newEnt = new SysDictionaryEnt();
newEnt.setPid(sysDictionaryEnt.getId());
newEnt.setDicName(input.getDicName());
......
package pps.core.system.service;
import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import pps.cloud.system.service.SystemDictionaryService;
import pps.cloud.system.service.data.sys_dictionary.*;
import pps.core.system.cache.SysDictionaryCache;
......@@ -36,7 +36,7 @@ public class SysDictionaryServiceImpl implements SystemDictionaryService {
QueryWrapper<SysDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysDictionaryEnt::getAlias, input.getAlias());
SysDictionaryEnt sysDictionaryEnt = mapper.selectOne(queryWrapper);
list = list.stream().filter((SysDictionaryCache dic) -> StringUtils.equals(dic.getPid(), sysDictionaryEnt.getId()) && !StringUtils.equals(dic.getAlias(), input.getAlias()))
list = list.stream().filter((SysDictionaryCache dic) -> CharSequenceUtil.equals(dic.getPid(), sysDictionaryEnt.getId()) && !CharSequenceUtil.equals(dic.getAlias(), input.getAlias()))
.collect(Collectors.toList());
if (ObjectUtils.isEmpty(list)) {
list = new ArrayList<>();
......@@ -64,7 +64,7 @@ public class SysDictionaryServiceImpl implements SystemDictionaryService {
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(queryOrgDic);
String ouIdPath = sysOrganizationRelEnt.getOuIdPath();
String ouId = sysOrganizationRelEnt.getOuId();
if (StringUtils.isNotBlank(ouIdPath)) {
if (CharSequenceUtil.isNotBlank(ouIdPath)) {
List<String> dicIds = sysOrganizationDictionaryEnts.stream().map(p -> {
if (ouIdPath.contains(p.getOuId()) && p.getUseLowerLevel() == 1) {
return p.getDicCode();
......@@ -112,7 +112,7 @@ public class SysDictionaryServiceImpl implements SystemDictionaryService {
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = orgDicmapper.selectList(queryOrgDic);
String ouIdPath = sysOrganizationRelEnt.getOuIdPath();
String ouId = sysOrganizationRelEnt.getOuId();
if (StringUtils.isNotBlank(ouIdPath)) {
if (CharSequenceUtil.isNotBlank(ouIdPath)) {
List<String> dicIds = sysOrganizationDictionaryEnts.stream().map(p -> {
if (ouIdPath.contains(p.getOuId()) && p.getUseLowerLevel() == 1) {
return p.getDicCode();
......
package pps.core.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.util.CollectionUtils;
import pps.cloud.system.service.SystemDictionaryService;
import pps.cloud.system.service.data.sys_dictionary.CreateSysDictionaryInput;
import pps.cloud.system.service.data.sys_dictionary.QuerySysDictionaryViewOutput;
......@@ -51,7 +53,7 @@ public class SysMenuService {
Integer isSuperAdmin = session.getIsSuperAdmin();
List<SysMenuView> viewList;
//普通角色且用户所属ou和查看的角色所属ou一样时返回当前用户可操作的菜单
if (BusinessConstant.ZERO.equals(isSuperAdmin) && session.getOuId().equals(input.getOuId())) {
if (BusinessConstant.ZERO.equals(isSuperAdmin) && CharSequenceUtil.equals(session.getOuId(), input.getOuId())) {
record.setUserId(session.getId());
viewList = mapper.selectSysMenuListByUserId(record);
} else {
......@@ -62,67 +64,48 @@ public class SysMenuService {
CreateSysDictionaryInput mediaTypesInput = new CreateSysDictionaryInput();
mediaTypesInput.setAlias("MEDIUM_TYPE");
XListResult<QuerySysDictionaryViewOutput> mediaTypes = dictService.querySysDictionarysByAlias(context, mediaTypesInput);
CreateSysDictionaryInput businessTypeInput = new CreateSysDictionaryInput();
businessTypeInput.setAlias("business_type");
XListResult<QuerySysDictionaryViewOutput> businessTypes = dictService.querySysDictionarysByAlias(context, businessTypeInput);
for (QuerySysMenuOutputTree tree : list) {
//业务类型
if (XStringUtils.isNotEmpty(tree.getMenuType())) {
List<QuerySysDictionaryViewOutput> items = businessTypes.getResult();
for (QuerySysDictionaryViewOutput item : items) {
if (tree.getMenuType().equals(item.getDicKey())) {
tree.setBusinessTypeName(item.getDicName());
}
}
if (tree.getBusinessTypeName() == null) {
tree.setBusinessTypeName(tree.getMenuType());
}
}
//介质类型
if (XStringUtils.isNotEmpty(tree.getMediaType())) {
if (mediaTypes.getResult() != null) {
List<QuerySysDictionaryViewOutput> items = mediaTypes.getResult();
String[] split = tree.getMediaType().split(",");
if (CharSequenceUtil.isNotBlank(tree.getMediaType())) {
if (CollUtil.isNotEmpty(mediaTypes.getResult())) {
StringBuilder buffer = new StringBuilder();
for (String mediaType : split) {
for (QuerySysDictionaryViewOutput item : items) {
if (mediaType.equals(item.getDicKey())) {
buffer.append(",");
buffer.append(item.getDicName());
for (String mediaType : CharSequenceUtil.splitToArray(tree.getMediaType(), ',')) {
for (QuerySysDictionaryViewOutput item : mediaTypes.getResult()) {
if (CharSequenceUtil.equals(mediaType, item.getDicKey())) {
buffer.append(",").append(item.getDicName());
}
}
}
if (buffer.length() > 0) {
String mediaTypeName = buffer.substring(1);
tree.setMediaTypeName(mediaTypeName);
tree.setMediaTypeName(buffer.substring(1));
}
}
if (tree.getMediaTypeName() == null) {
if (CharSequenceUtil.isBlank(tree.getMediaTypeName())) {
tree.setMediaTypeName(tree.getMediaType());
}
}
}
List<QuerySysMenuOutputTree> trees = new ArrayList<>();
List<QuerySysMenuOutputTree> trees = new ArrayList<>(list.size());
for (QuerySysMenuOutputTree tree : list) {
if (tree.getParentMenuId() == null || "".equals(tree.getParentMenuId())) {
if (CharSequenceUtil.isBlank(tree.getParentMenuId())) {
trees.add(tree);
}
//子集
for (QuerySysMenuOutputTree it : list) {
if (tree.getId().equals(it.getParentMenuId())) {
if (tree.getChildren() == null) {
if (CharSequenceUtil.equals(tree.getId(), it.getParentMenuId())) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(it);
}
}
if (tree.getChildren() != null && tree.getChildren().size() > 1) {
if (CollUtil.isNotEmpty(tree.getChildren())) {
List<QuerySysMenuOutputTree> children = tree.getChildren();
children = children.stream().sorted(Comparator.comparing(QuerySysMenuOutputTree::getSort)).collect(Collectors.toList());
children.sort(Comparator.comparing(QuerySysMenuOutputTree::getSort));
tree.setChildren(children);
}
}
trees = trees.stream().sorted(Comparator.comparing(QuerySysMenuOutputTree::getSort)).collect(Collectors.toList());
trees.sort(Comparator.comparing(QuerySysMenuOutputTree::getSort));
return XListResult.success(trees);
}
......@@ -144,67 +127,52 @@ public class SysMenuService {
CreateSysDictionaryInput mediaTypesInput = new CreateSysDictionaryInput();
mediaTypesInput.setAlias("MEDIUM_TYPE");
XListResult<QuerySysDictionaryViewOutput> mediaTypes = dictService.querySysDictionarysByAlias(context, mediaTypesInput);
CreateSysDictionaryInput businessTypeInput = new CreateSysDictionaryInput();
businessTypeInput.setAlias("business_type");
XListResult<QuerySysDictionaryViewOutput> businessTypes = dictService.querySysDictionarysByAlias(context, businessTypeInput);
for (QuerySysMenuOutputTree tree : list) {
//业务类型
if (XStringUtils.isNotEmpty(tree.getMenuType())) {
List<QuerySysDictionaryViewOutput> items = businessTypes.getResult();
for (QuerySysDictionaryViewOutput item : items) {
if (tree.getMenuType().equals(item.getDicKey())) {
tree.setBusinessTypeName(item.getDicName());
}
}
if (tree.getBusinessTypeName() == null) {
if (CharSequenceUtil.isNotBlank(tree.getMenuType())) {
if (CharSequenceUtil.isBlank(tree.getBusinessTypeName())) {
tree.setBusinessTypeName(tree.getMenuType());
}
}
//介质类型
if (XStringUtils.isNotEmpty(tree.getMediaType())) {
if (mediaTypes.getResult() != null) {
List<QuerySysDictionaryViewOutput> items = mediaTypes.getResult();
String[] split = tree.getMediaType().split(",");
if (CollUtil.isNotEmpty(mediaTypes.getResult())) {
StringBuilder buffer = new StringBuilder();
for (String mediaType : split) {
for (QuerySysDictionaryViewOutput item : items) {
if (mediaType.equals(item.getDicKey())) {
buffer.append(",");
buffer.append(item.getDicName());
for (String mediaType : CharSequenceUtil.splitToArray(tree.getMediaType(), ',')) {
for (QuerySysDictionaryViewOutput item : mediaTypes.getResult()) {
if (CharSequenceUtil.equals(mediaType, item.getDicKey())) {
buffer.append(",").append(item.getDicName());
}
}
}
if (buffer.length() > 0) {
String mediaTypeName = buffer.substring(1);
tree.setMediaTypeName(mediaTypeName);
tree.setMediaTypeName(buffer.substring(1));
}
}
if (tree.getMediaTypeName() == null) {
if (CharSequenceUtil.isBlank(tree.getMediaTypeName())) {
tree.setMediaTypeName(tree.getMediaType());
}
}
}
List<QuerySysMenuOutputTree> trees = new ArrayList<>();
List<QuerySysMenuOutputTree> trees = new ArrayList<>(list.size());
for (QuerySysMenuOutputTree tree : list) {
if (tree.getParentMenuId() == null || "".equals(tree.getParentMenuId())) {
if (CharSequenceUtil.isBlank(tree.getParentMenuId())) {
trees.add(tree);
}
//子集
for (QuerySysMenuOutputTree it : list) {
if (tree.getId().equals(it.getParentMenuId())) {
if (tree.getChildren() == null) {
if (CharSequenceUtil.equals(tree.getId(), it.getParentMenuId())) {
if (CollUtil.isEmpty(tree.getChildren())) {
//初始化集合
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(it);
}
}
if (tree.getChildren() != null && tree.getChildren().size() > 1) {
if (CollUtil.isNotEmpty(tree.getChildren())) {
List<QuerySysMenuOutputTree> children = tree.getChildren();
children = children.stream().sorted(Comparator.comparing(QuerySysMenuOutputTree::getSort)).collect(Collectors.toList());
children.sort(Comparator.comparing(QuerySysMenuOutputTree::getSort));
tree.setChildren(children);
}
}
trees = trees.stream().sorted(Comparator.comparing(QuerySysMenuOutputTree::getSort)).collect(Collectors.toList());
trees.sort(Comparator.comparing(QuerySysMenuOutputTree::getSort));
return XListResult.success(trees);
}
......@@ -216,7 +184,7 @@ public class SysMenuService {
SysMenuView record = new SysMenuView();
XCopyUtils.copyObject(input, record);
List<SysMenuView> viewList;
if (XStringUtils.isNotEmpty(record.getMenuName())) {
if (CharSequenceUtil.isNotBlank(record.getMenuName())) {
viewList = mapper.selectSysMenuListByMenuName(record);
} else {
viewList = mapper.selectSysMenuList(record);
......@@ -226,67 +194,48 @@ public class SysMenuService {
CreateSysDictionaryInput mediaTypesInput = new CreateSysDictionaryInput();
mediaTypesInput.setAlias("MEDIUM_TYPE");
XListResult<QuerySysDictionaryViewOutput> mediaTypes = dictService.querySysDictionarysByAlias(context, mediaTypesInput);
CreateSysDictionaryInput businessTypeInput = new CreateSysDictionaryInput();
businessTypeInput.setAlias("business_type");
XListResult<QuerySysDictionaryViewOutput> businessTypes = dictService.querySysDictionarysByAlias(context, businessTypeInput);
for (QuerySysMenuOutputTree tree : list) {
//业务类型
if (XStringUtils.isNotEmpty(tree.getMenuType())) {
List<QuerySysDictionaryViewOutput> items = businessTypes.getResult();
for (QuerySysDictionaryViewOutput item : items) {
if (tree.getMenuType().equals(item.getDicKey())) {
tree.setBusinessTypeName(item.getDicName());
}
}
if (tree.getBusinessTypeName() == null) {
tree.setBusinessTypeName(tree.getMenuType());
}
}
//介质类型
if (XStringUtils.isNotEmpty(tree.getMediaType())) {
if (mediaTypes.getResult() != null) {
List<QuerySysDictionaryViewOutput> items = mediaTypes.getResult();
String[] split = tree.getMediaType().split(",");
if (CharSequenceUtil.isNotBlank(tree.getMediaType())) {
if (CollUtil.isNotEmpty(mediaTypes.getResult())) {
StringBuilder buffer = new StringBuilder();
for (String mediaType : split) {
for (QuerySysDictionaryViewOutput item : items) {
for (String mediaType : CharSequenceUtil.splitToArray(tree.getMediaType(), ',')) {
for (QuerySysDictionaryViewOutput item : mediaTypes.getResult()) {
if (mediaType.equals(item.getDicKey())) {
buffer.append(",");
buffer.append(item.getDicName());
buffer.append(",").append(item.getDicName());
}
}
}
if (buffer.length() > 0) {
String mediaTypeName = buffer.substring(1);
tree.setMediaTypeName(mediaTypeName);
tree.setMediaTypeName(buffer.substring(1));
}
}
if (tree.getMediaTypeName() == null) {
if (CharSequenceUtil.isBlank(tree.getMediaTypeName())) {
tree.setMediaTypeName(tree.getMediaType());
}
}
}
List<QuerySysMenuOutputTree> trees = new ArrayList<>();
for (QuerySysMenuOutputTree tree : list) {
if (tree.getParentMenuId() == null || "".equals(tree.getParentMenuId())) {
if (CharSequenceUtil.isBlank(tree.getParentMenuId())) {
trees.add(tree);
}
//子集
for (QuerySysMenuOutputTree it : list) {
if (tree.getId().equals(it.getParentMenuId())) {
if (tree.getChildren() == null) {
if (CharSequenceUtil.equals(tree.getId(), it.getParentMenuId())) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(it);
}
}
if (tree.getChildren() != null && tree.getChildren().size() > 1) {
if (CollUtil.isNotEmpty(tree.getChildren())) {
List<QuerySysMenuOutputTree> children = tree.getChildren();
children = children.stream().sorted(Comparator.comparing(QuerySysMenuOutputTree::getSort)).collect(Collectors.toList());
children.sort(Comparator.comparing(QuerySysMenuOutputTree::getSort));
tree.setChildren(children);
}
}
trees = trees.stream().sorted(Comparator.comparing(QuerySysMenuOutputTree::getSort)).collect(Collectors.toList());
trees.sort(Comparator.comparing(QuerySysMenuOutputTree::getSort));
return XListResult.success(trees);
}
......@@ -302,7 +251,7 @@ public class SysMenuService {
public XListResult<QuerySysMenuOutputTree> getSysMenuListTree(XContext context, GetSysMenuInput input) {
SysMenuMapper mapper = context.getBean(SysMenuMapper.class);
QueryWrapper<SysMenuEnt> queryWrapper = new QueryWrapper<>();
if (XStringUtils.isNotEmpty(input.getParentMenuId())) {
if (CharSequenceUtil.isNotBlank(input.getParentMenuId())) {
queryWrapper.lambda().eq(SysMenuEnt::getParentMenuId, input.getParentMenuId());
} else {
queryWrapper.lambda().and(wrapper -> wrapper.isNull(SysMenuEnt::getParentMenuId).or().eq(SysMenuEnt::getParentMenuId, ""));
......@@ -314,42 +263,23 @@ public class SysMenuService {
CreateSysDictionaryInput mediaTypesInput = new CreateSysDictionaryInput();
mediaTypesInput.setAlias("MEDIUM_TYPE");
XListResult<QuerySysDictionaryViewOutput> mediaTypes = dictService.querySysDictionarysByAlias(context, mediaTypesInput);
CreateSysDictionaryInput businessTypeInput = new CreateSysDictionaryInput();
businessTypeInput.setAlias("business_type");
XListResult<QuerySysDictionaryViewOutput> businessTypes = dictService.querySysDictionarysByAlias(context, businessTypeInput);
for (QuerySysMenuOutputTree tree : list) {
//业务类型
if (XStringUtils.isNotEmpty(tree.getMenuType())) {
List<QuerySysDictionaryViewOutput> items = businessTypes.getResult();
for (QuerySysDictionaryViewOutput item : items) {
if (tree.getMenuType().equals(item.getDicKey())) {
tree.setBusinessTypeName(item.getDicName());
}
}
if (tree.getBusinessTypeName() == null) {
tree.setBusinessTypeName(tree.getMenuType());
}
}
//介质类型
if (XStringUtils.isNotEmpty(tree.getMediaType())) {
if (mediaTypes.getResult() != null) {
List<QuerySysDictionaryViewOutput> items = mediaTypes.getResult();
String[] split = tree.getMediaType().split(",");
if (CharSequenceUtil.isNotBlank(tree.getMediaType())) {
if (CollUtil.isNotEmpty(mediaTypes.getResult())) {
StringBuilder buffer = new StringBuilder();
for (String mediaType : split) {
for (QuerySysDictionaryViewOutput item : items) {
if (mediaType.equals(item.getDicKey())) {
buffer.append(",");
buffer.append(item.getDicName());
for (String mediaType : CharSequenceUtil.splitToArray(tree.getMediaType(), ',')) {
for (QuerySysDictionaryViewOutput item : mediaTypes.getResult()) {
if (CharSequenceUtil.equals(mediaType, item.getDicKey())) {
buffer.append(",").append(item.getDicName());
}
}
}
if (buffer.length() > 0) {
String mediaTypeName = buffer.substring(1);
tree.setMediaTypeName(mediaTypeName);
tree.setMediaTypeName(buffer.substring(1));
}
}
if (tree.getMediaTypeName() == null) {
if (CharSequenceUtil.isBlank(tree.getMediaTypeName())) {
tree.setMediaTypeName(tree.getMediaType());
}
}
......@@ -360,12 +290,12 @@ public class SysMenuService {
List<SysMenuView> childList = viewMapper.selectCountByParentMenuIds(parentIds);
Map<String, List<SysMenuView>> groupChildList = childList.stream().collect(Collectors.groupingBy(SysMenuView::getParentMenuId));
list.forEach(item -> {
if (groupChildList.get(item.getId()) == null) {
if (!groupChildList.containsKey(item.getId())) {
item.setChildren(null);
item.setIsHasChildren(0);
}
});
list = list.stream().sorted(Comparator.comparing(QuerySysMenuOutputTree::getSort)).collect(Collectors.toList());
list.sort(Comparator.comparing(QuerySysMenuOutputTree::getSort));
return XListResult.success(list);
}
......@@ -380,67 +310,51 @@ public class SysMenuService {
CreateSysDictionaryInput mediaTypesInput = new CreateSysDictionaryInput();
mediaTypesInput.setAlias("MEDIUM_TYPE");
XListResult<QuerySysDictionaryViewOutput> mediaTypes = dictService.querySysDictionarysByAlias(context, mediaTypesInput);
CreateSysDictionaryInput businessTypeInput = new CreateSysDictionaryInput();
businessTypeInput.setAlias("business_type");
XListResult<QuerySysDictionaryViewOutput> businessTypes = dictService.querySysDictionarysByAlias(context, businessTypeInput);
for (QuerySysMenuOutputTree tree : list) {
//业务类型
if (XStringUtils.isNotEmpty(tree.getMenuType())) {
List<QuerySysDictionaryViewOutput> items = businessTypes.getResult();
for (QuerySysDictionaryViewOutput item : items) {
if (tree.getMenuType().equals(item.getDicKey())) {
tree.setBusinessTypeName(item.getDicName());
}
}
if (tree.getBusinessTypeName() == null) {
if (CharSequenceUtil.isNotBlank(tree.getMenuType())) {
if (CharSequenceUtil.isBlank(tree.getBusinessTypeName())) {
tree.setBusinessTypeName(tree.getMenuType());
}
}
//介质类型
if (XStringUtils.isNotEmpty(tree.getMediaType())) {
if (mediaTypes.getResult() != null) {
List<QuerySysDictionaryViewOutput> items = mediaTypes.getResult();
String[] split = tree.getMediaType().split(",");
if (CollUtil.isNotEmpty(mediaTypes.getResult())) {
StringBuilder buffer = new StringBuilder();
for (String mediaType : split) {
for (QuerySysDictionaryViewOutput item : items) {
for (String mediaType : CharSequenceUtil.splitToArray(tree.getMediaType(), ',')) {
for (QuerySysDictionaryViewOutput item : mediaTypes.getResult()) {
if (mediaType.equals(item.getDicKey())) {
buffer.append(",");
buffer.append(item.getDicName());
buffer.append(",").append(item.getDicName());
}
}
}
if (buffer.length() > 0) {
String mediaTypeName = buffer.substring(1);
tree.setMediaTypeName(mediaTypeName);
tree.setMediaTypeName(buffer.substring(1));
}
}
if (tree.getMediaTypeName() == null) {
if (CharSequenceUtil.isBlank(tree.getMediaTypeName())) {
tree.setMediaTypeName(tree.getMediaType());
}
}
}
List<QuerySysMenuOutputTree> trees = new ArrayList<>();
List<QuerySysMenuOutputTree> trees = new ArrayList<>(list.size());
for (QuerySysMenuOutputTree tree : list) {
if (tree.getParentMenuId() == null || "".equals(tree.getParentMenuId())) {
if (CharSequenceUtil.isBlank(tree.getParentMenuId())) {
trees.add(tree);
}
//子集
for (QuerySysMenuOutputTree it : list) {
if (tree.getId().equals(it.getParentMenuId())) {
if (tree.getChildren() == null) {
if (CharSequenceUtil.equals(tree.getId(), it.getParentMenuId())) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(it);
}
}
if (tree.getChildren() != null && tree.getChildren().size() > 1) {
if (CollUtil.isNotEmpty(tree.getChildren())) {
List<QuerySysMenuOutputTree> children = tree.getChildren();
children = children.stream().sorted(Comparator.comparing(QuerySysMenuOutputTree::getSort)).collect(Collectors.toList());
children.sort(Comparator.comparing(QuerySysMenuOutputTree::getSort));
tree.setChildren(children);
}
}
trees = trees.stream().sorted(Comparator.comparing(QuerySysMenuOutputTree::getSort)).collect(Collectors.toList());
trees.sort(Comparator.comparing(QuerySysMenuOutputTree::getSort));
return XListResult.success(trees);
}
......@@ -449,17 +363,17 @@ public class SysMenuService {
public XServiceResult updateSysMenuSort(XContext context, UpdateSysMenuInput input) throws XServiceException {
return XTransactionHelper.begin(context, () -> {
SysMenuMapper mapper = context.getBean(SysMenuMapper.class);
QueryWrapper<SysMenuEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysMenuEnt::getId, input.getId());
SysMenuEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysMenuEnt entity = mapper.selectOne(new QueryWrapper<SysMenuEnt>()
.lambda()
.eq(SysMenuEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
Integer entitySort = entity.getSort();
QueryWrapper<SysMenuEnt> neighborQueryWrapper = new QueryWrapper<>();
neighborQueryWrapper.lambda().eq(SysMenuEnt::getParentMenuId, entity.getParentMenuId());
//判断是上移还是下移
if (input.getSortFlag().equals("up")) {
if (CharSequenceUtil.equals(input.getSortFlag(), "up")) {
//sort-=1;
neighborQueryWrapper.lambda().le(SysMenuEnt::getSort, entitySort);
neighborQueryWrapper.lambda().orderByDesc(SysMenuEnt::getSort);
......@@ -470,15 +384,15 @@ public class SysMenuService {
}
List<SysMenuEnt> sysMenuEnts = mapper.selectList(neighborQueryWrapper);
PpsUserSession session = context.getSession(PpsUserSession.class);
if (!CollectionUtils.isEmpty(sysMenuEnts) && sysMenuEnts.size() > 1) {
if (CollUtil.isNotEmpty(sysMenuEnts)) {
SysMenuEnt neighborEnt = sysMenuEnts.get(1);
Integer neighborEntSort = neighborEnt.getSort();
if (input.getSortFlag().equals("up")) {
if (neighborEntSort != null && neighborEntSort.equals(entitySort)) {
if (CharSequenceUtil.equals(input.getSortFlag(), "up")) {
if (ObjectUtil.isNotNull(neighborEntSort) && neighborEntSort.equals(entitySort)) {
neighborEntSort -= 1;
}
} else {
if (neighborEntSort != null && neighborEntSort.equals(entitySort)) {
if (ObjectUtil.isNotNull(neighborEntSort) && neighborEntSort.equals(entitySort)) {
neighborEntSort += 1;
}
}
......@@ -516,33 +430,31 @@ public class SysMenuService {
SysMenuViewMapper viewMapper = context.getBean(SysMenuViewMapper.class);
SysMenuEnt entity = new SysMenuEnt();
XCopyUtils.copyObject(input, entity);
if (entity.getSort() == null) {
if (ObjectUtil.isNull(entity.getSort())) {
SysMenuView relView = viewMapper.selectMaxSort(entity.getParentMenuId());
if (relView != null) {
Integer sort = relView.getSort();
entity.setSort(++sort);
if (ObjectUtil.isNotNull(relView)) {
entity.setSort(relView.getSort() + 1);
} else {
entity.setSort(1);
}
} else {
QueryWrapper<SysMenuEnt> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(SysMenuEnt::getParentMenuId, entity.getParentMenuId());
wrapper.lambda().ge(SysMenuEnt::getSort, entity.getSort());
List<SysMenuEnt> sysMenuEnts = mapper.selectList(wrapper);
if (!CollectionUtils.isEmpty(sysMenuEnts)) {
List<SysMenuEnt> sysMenuEnts = mapper.selectList(new QueryWrapper<SysMenuEnt>()
.lambda()
.eq(SysMenuEnt::getParentMenuId, entity.getParentMenuId())
.ge(SysMenuEnt::getSort, entity.getSort()));
if (CollUtil.isNotEmpty(sysMenuEnts)) {
sysMenuEnts.forEach(sysMenuEnt -> {
Integer sort = sysMenuEnt.getSort();
sysMenuEnt.setSort(++sort);
sysMenuEnt.setSort(sysMenuEnt.getSort() + 1);
mapper.updateById(sysMenuEnt);
});
}
}
if (entity.getParentMenuId() == null || "".equals(entity.getParentMenuId())) {
if (CharSequenceUtil.isBlank(entity.getParentMenuId())) {
entity.setLevel("1");
}
entity.setCreateTime(new Date());
PpsUserSession session = context.getSession(PpsUserSession.class);
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
entity.setCreateById(session.getId());
entity.setCreateByName(session.getUserName());
}
......@@ -560,9 +472,8 @@ public class SysMenuService {
SysMenuViewMapper viewMapper = context.getBean(SysMenuViewMapper.class);
SysMenuView relView = viewMapper.selectMaxSort(input.getParentMenuId());
QuerySysMenuInput output = new QuerySysMenuInput();
if (relView != null) {
Integer sort1 = relView.getSort();
output.setSort(++sort1);
if (ObjectUtil.isNotNull(relView)) {
output.setSort(relView.getSort() + 1);
} else {
output.setSort(1);
}
......@@ -575,16 +486,16 @@ public class SysMenuService {
return XTransactionHelper.begin(context, () -> {
SysMenuMapper mapper = context.getBean(SysMenuMapper.class);
SysMenuViewMapper viewMapper = context.getBean(SysMenuViewMapper.class);
QueryWrapper<SysMenuEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysMenuEnt::getId, input.getId());
SysMenuEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysMenuEnt entity = mapper.selectOne(new QueryWrapper<SysMenuEnt>()
.lambda()
.eq(SysMenuEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
entity.setModifyTime(new Date());
PpsUserSession session = context.getSession(PpsUserSession.class);
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
entity.setModifyById(session.getId());
entity.setModifyByName(session.getUserName());
}
......@@ -607,16 +518,16 @@ public class SysMenuService {
public XServiceResult deleteSysMenu(XContext context, DeleteSysMenuInput input) throws XServiceException {
return XTransactionHelper.begin(context, () -> {
SysMenuMapper mapper = context.getBean(SysMenuMapper.class);
QueryWrapper<SysMenuEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysMenuEnt::getId, input.getId());
SysMenuEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysMenuEnt entity = mapper.selectOne(new QueryWrapper<SysMenuEnt>()
.lambda()
.eq(SysMenuEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysMenuEnt::getParentMenuId, entity.getId());
List<SysMenuEnt> sysMenuEnts = mapper.selectList(queryWrapper);
if (CollectionUtils.isEmpty(sysMenuEnts)) {
List<SysMenuEnt> sysMenuEnts = mapper.selectList(new QueryWrapper<SysMenuEnt>()
.lambda()
.eq(SysMenuEnt::getParentMenuId, entity.getId()));
if (CollUtil.isEmpty(sysMenuEnts)) {
mapper.deleteById(entity);
} else {
return XServiceResult.error(context, MenuError.NotDelete);
......@@ -629,10 +540,10 @@ public class SysMenuService {
@XApiGet
public XSingleResult<GetSysMenuOutput> getSysMenu(XContext context, GetSysMenuInput input) {
SysMenuMapper mapper = context.getBean(SysMenuMapper.class);
QueryWrapper<SysMenuEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysMenuEnt::getId, input.getId());
SysMenuEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysMenuEnt entity = mapper.selectOne(new QueryWrapper<SysMenuEnt>()
.lambda()
.eq(SysMenuEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysMenuOutput output = new GetSysMenuOutput();
......@@ -674,7 +585,7 @@ public class SysMenuService {
SysMenuView record = new SysMenuView();
XCopyUtils.copyObject(input, record);
SysMenuView view = mapper.selectOne(record);
if (view == null) {
if (ObjectUtil.isNull(view)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysMenuViewOutput output = new GetSysMenuViewOutput();
......
package pps.core.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.util.CollectionUtils;
import pps.cloud.system.service.SysOrganizationCloudService;
import pps.cloud.system.service.data.sys_organization.*;
import pps.core.common.constant.BusinessConstant;
......@@ -13,7 +13,6 @@ import xstartup.annotation.XService;
import xstartup.annotation.XText;
import xstartup.base.XContext;
import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XStringUtils;
import xstartup.data.XListResult;
import xstartup.data.XSingleResult;
......@@ -29,9 +28,9 @@ public class SysOrganizationCloudServiceImpl implements SysOrganizationCloudServ
@Override
public XSingleResult<GetSysOrganizationViewOutput> getSysOrganizationById(XContext context, GetSysOrganizationViewInput input) {
SysOrganizationMapper mapper = context.getBean(SysOrganizationMapper.class);
QueryWrapper<SysOrganizationEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysOrganizationEnt::getId, input.getId());
SysOrganizationEnt ent = mapper.selectOne(queryWrapper);
SysOrganizationEnt ent = mapper.selectOne(new QueryWrapper<SysOrganizationEnt>()
.lambda()
.eq(SysOrganizationEnt::getId, input.getId()));
GetSysOrganizationViewOutput output = new GetSysOrganizationViewOutput();
XCopyUtils.copyObject(ent, output);
return XSingleResult.success(output);
......@@ -42,26 +41,26 @@ public class SysOrganizationCloudServiceImpl implements SysOrganizationCloudServ
SysUserOrganizationRelMapper mapper = context.getBean(SysUserOrganizationRelMapper.class);
SysOrganizationMapper sysOrganizationMapper = context.getBean(SysOrganizationMapper.class);
SysOrganizationRelMapper sysOrganizationRelMapper = context.getBean(SysOrganizationRelMapper.class);
QueryWrapper<SysUserOrganizationRelEnt> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(SysUserOrganizationRelEnt::getUserId, input.getUserId())
List<SysUserOrganizationRelEnt> relEnts = mapper.selectList(new QueryWrapper<SysUserOrganizationRelEnt>()
.lambda()
.eq(SysUserOrganizationRelEnt::getUserId, input.getUserId())
.le(SysUserOrganizationRelEnt::getEffectTime, new Date())
.ge(SysUserOrganizationRelEnt::getEndTime, new Date());
List<SysUserOrganizationRelEnt> relEnts = mapper.selectList(wrapper);
.ge(SysUserOrganizationRelEnt::getEndTime, new Date()));
GetSysOrganizationViewOutput output = new GetSysOrganizationViewOutput();
if (CollUtil.isNotEmpty(relEnts)) {
if (XStringUtils.isNotEmpty(relEnts.get(0).getOuId())) {
QueryWrapper<SysOrganizationEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysOrganizationEnt::getId, relEnts.get(0).getOuId())
.eq(SysOrganizationEnt::getIsDeleted, 1);
SysOrganizationEnt sysOrganizationEnt = sysOrganizationMapper.selectOne(queryWrapper);
if (CharSequenceUtil.isNotBlank(relEnts.get(0).getOuId())) {
SysOrganizationEnt sysOrganizationEnt = sysOrganizationMapper.selectOne(new QueryWrapper<SysOrganizationEnt>()
.lambda()
.eq(SysOrganizationEnt::getId, relEnts.get(0).getOuId())
.eq(SysOrganizationEnt::getIsDeleted, 1));
XCopyUtils.copyObject(sysOrganizationEnt, output);
output.setOuId(relEnts.get(0).getOuId());
QueryWrapper<SysOrganizationRelEnt> qw = new QueryWrapper<>();
qw.lambda().eq(SysOrganizationRelEnt::getOuId, relEnts.get(0).getOuId())
List<SysOrganizationRelEnt> sysOrganizationRelEnts = sysOrganizationRelMapper.selectList(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.eq(SysOrganizationRelEnt::getOuId, relEnts.get(0).getOuId())
.le(SysOrganizationRelEnt::getEffectTime, new Date())
.ge(SysOrganizationRelEnt::getEndTime, new Date());
List<SysOrganizationRelEnt> sysOrganizationRelEnts = sysOrganizationRelMapper.selectList(qw);
if (!CollectionUtils.isEmpty(sysOrganizationRelEnts)) {
.ge(SysOrganizationRelEnt::getEndTime, new Date()));
if (CollUtil.isNotEmpty(sysOrganizationRelEnts)) {
output.setOuPath(sysOrganizationRelEnts.get(0).getOuIdPath());
}
}
......
package pps.core.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import pps.cloud.system.service.data.sys_dictionary.QuerySysDictionaryViewOutput;
import pps.core.common.session.PpsUserSession;
import pps.core.system.entity.SysDictionaryEnt;
......@@ -56,32 +58,12 @@ public class SysOrganizationDictionaryService {
try {
endTime = sm.parse("9990-12-31 23:59:59");
} catch (ParseException e) {
e.printStackTrace();
}
QueryWrapper<SysOrganizationDictionaryEnt> query = new QueryWrapper<>();
query.lambda().eq(SysOrganizationDictionaryEnt::getOuId, input.getOuId()).gt(SysOrganizationDictionaryEnt::getEndTime, new Date());
List<SysOrganizationDictionaryEnt> list = mapper.selectList(query);
/*List<SysOrganizationDictionaryEnt> delList = new ArrayList<>();
List<SysDictionaryView> dataList = new ArrayList<>();
if (input.getItems() != null && input.getItems().size() > 0){
List<SysDictionaryView> items = input.getItems();
if (ObjectUtils.isNotEmpty(list)) {
for (SysOrganizationDictionaryEnt obj : list) {
boolean flag = true;
for (SysDictionaryView view : items) {
if(StringUtils.equals(view.getUid(),obj.getId()) || StringUtils.isEmpty(view.getUid())){
flag = false;
dataList.add(view);
}
}
if(flag){
delList.add(obj);
}
context.getLogger().error(e);
}
}else{
dataList = input.getItems();
}
}*/
List<SysOrganizationDictionaryEnt> list = mapper.selectList(new QueryWrapper<SysOrganizationDictionaryEnt>()
.lambda()
.eq(SysOrganizationDictionaryEnt::getOuId, input.getOuId())
.gt(SysOrganizationDictionaryEnt::getEndTime, new Date()));
for (SysOrganizationDictionaryEnt obj : list) {
obj.setEndTime(new Date());
obj.setModifyById(session.getId());
......@@ -90,7 +72,7 @@ public class SysOrganizationDictionaryService {
mapper.updateById(obj);
}
List<SysDictionaryView> dataList = input.getItems();
if (dataList != null && !dataList.isEmpty()) {
if (CollUtil.isNotEmpty(dataList)) {
for (SysDictionaryView view : dataList) {
SysOrganizationDictionaryEnt entity = new SysOrganizationDictionaryEnt();
entity.setOuId(input.getOuId());
......@@ -104,7 +86,7 @@ public class SysOrganizationDictionaryService {
entity.setUseLowerLevel(view.getUseLowerLevel());
entity.setId(UUID.randomUUID().toString());
mapper.insert(entity);
if (StringUtils.isNotBlank(view.getPid())) {
if (CharSequenceUtil.isNotBlank(view.getPid())) {
SysDictionaryEnt dictionaryEnt = new SysDictionaryEnt();
dictionaryEnt.setId(view.getPid());
dictionaryEnt.setIsOrg(1);
......@@ -120,10 +102,10 @@ public class SysOrganizationDictionaryService {
@XApiPost
public XServiceResult updateSysOrganizationDictionary(XContext context, UpdateSysOrganizationDictionaryInput input) {
SysOrganizationDictionaryMapper mapper = context.getBean(SysOrganizationDictionaryMapper.class);
QueryWrapper<SysOrganizationDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysOrganizationDictionaryEnt::getId, input.getId());
SysOrganizationDictionaryEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysOrganizationDictionaryEnt entity = mapper.selectOne(new QueryWrapper<SysOrganizationDictionaryEnt>()
.lambda()
.eq(SysOrganizationDictionaryEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -134,9 +116,6 @@ public class SysOrganizationDictionaryService {
@XText("删除组织机构字典")
@XApiPost
public XServiceResult deleteSysOrganizationDictionary(XContext context, DeleteSysOrganizationDictionaryInput input) {
SysOrganizationDictionaryMapper mapper = context.getBean(SysOrganizationDictionaryMapper.class);
SysDictionaryMapper dicMapper = context.getBean(SysDictionaryMapper.class);
PpsUserSession session = context.getSession(PpsUserSession.class);
SysDictionaryViewMapper dicViewMapper = context.getBean(SysDictionaryViewMapper.class);
SysDictionaryView view = new SysDictionaryView();
view.setDicPath(input.getId());
......@@ -145,9 +124,11 @@ public class SysOrganizationDictionaryService {
).distinct().collect(Collectors.toList());
QueryWrapper<SysOrganizationDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().in(SysOrganizationDictionaryEnt::getDicCode, dicIds);
if (StringUtils.isNotBlank(input.getOuId())) {
if (CharSequenceUtil.isNotBlank(input.getOuId())) {
queryWrapper.lambda().eq(SysOrganizationDictionaryEnt::getOuId, input.getOuId());
}
SysOrganizationDictionaryMapper mapper = context.getBean(SysOrganizationDictionaryMapper.class);
PpsUserSession session = context.getSession(PpsUserSession.class);
List<SysOrganizationDictionaryEnt> sysOrganizationDictionaryEnts = mapper.selectList(queryWrapper);
if (ObjectUtils.isNotEmpty(sysOrganizationDictionaryEnts)) {
for (SysOrganizationDictionaryEnt ent : sysOrganizationDictionaryEnts) {
......@@ -159,7 +140,7 @@ public class SysOrganizationDictionaryService {
}
}
//查询单位属性表是否还有字典,如果没有删除字典表中标记
// List<SysOrganizationDictionaryEnt> sysDics = mapper.selectList(queryWrapper);
SysDictionaryMapper dicMapper = context.getBean(SysDictionaryMapper.class);
if (ObjectUtils.isNotEmpty(sysDictionaryViews)) {
for (SysDictionaryView dicView : sysDictionaryViews) {
SysDictionaryEnt ent = new SysDictionaryEnt();
......@@ -177,10 +158,10 @@ public class SysOrganizationDictionaryService {
@XApiPost
public XSingleResult<GetSysOrganizationDictionaryOutput> getSysOrganizationDictionary(XContext context, GetSysOrganizationDictionaryInput input) {
SysOrganizationDictionaryMapper mapper = context.getBean(SysOrganizationDictionaryMapper.class);
QueryWrapper<SysOrganizationDictionaryEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysOrganizationDictionaryEnt::getId, input.getId());
SysOrganizationDictionaryEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysOrganizationDictionaryEnt entity = mapper.selectOne(new QueryWrapper<SysOrganizationDictionaryEnt>()
.lambda()
.eq(SysOrganizationDictionaryEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysOrganizationDictionaryOutput output = new GetSysOrganizationDictionaryOutput();
......@@ -210,7 +191,7 @@ public class SysOrganizationDictionaryService {
SysOrganizationDictionaryView record = new SysOrganizationDictionaryView();
XCopyUtils.copyObject(input, record);
SysOrganizationDictionaryView view = mapper.selectOne(record);
if (view == null) {
if (ObjectUtil.isNull(view)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysOrganizationDictionaryViewOutput output = new GetSysOrganizationDictionaryViewOutput();
......@@ -236,7 +217,6 @@ public class SysOrganizationDictionaryService {
//1、根据组织机构id查询字典id(dictCode)
//2、parentId为1:根据字典code查询所有字典,返回dictPath,整合id列表(把所有字典id拆开放在集合里),然后id++dicName过滤数据,返回第一级id
//3、parentId不为1:根据pid+dicName查询下级数据
SysDictionaryMapper dictionaryMapper = context.getBean(SysDictionaryMapper.class);
SysDictionaryViewMapper dictionaryViewMapper = context.getBean(SysDictionaryViewMapper.class);
List<QuerySysDictionaryViewOutput> outputs = new ArrayList<>();
List<SysDictionaryView> dictionaryViews;
......@@ -245,7 +225,7 @@ public class SysOrganizationDictionaryService {
pageInfo.setPageNum(input.getPage());
pageInfo.setPageSize(input.getLimit());
DateTime date = DateUtil.date();
if (StringUtils.equals(input.getParentId(), "1")) {
if (CharSequenceUtil.equals(input.getParentId(), "1")) {
SysDictionaryView recordView = XCopyUtils.copyNewObject(input, SysDictionaryView.class);
int start = (input.getPage() - 1) * input.getLimit();
recordView.setStartRow(start);
......@@ -260,20 +240,21 @@ public class SysOrganizationDictionaryService {
recordView.setEndTimeStr(date.toString());
dictionaryViews = dictionaryViewMapper.selectChildListByCondition(recordView);
}
SysDictionaryMapper dictionaryMapper = context.getBean(SysDictionaryMapper.class);
if (ObjectUtils.isNotEmpty(dictionaryViews)) {
List<String> pidList = dictionaryViews.stream().map(SysDictionaryView::getId
).distinct().collect(Collectors.toList());
QueryWrapper<SysDictionaryEnt> queryDict = new QueryWrapper<>();
queryDict.lambda().in(SysDictionaryEnt::getPid, pidList);
List<SysDictionaryEnt> sysDictionaryList = dictionaryMapper.selectList(queryDict);
List<SysDictionaryEnt> sysDictionaryList = dictionaryMapper.selectList(new QueryWrapper<SysDictionaryEnt>()
.lambda()
.in(SysDictionaryEnt::getPid, pidList));
pageInfo.setList(dictionaryViews);
outputs = XCopyUtils.copyNewList(pageInfo.getList(), QuerySysDictionaryViewOutput.class);
int i = 0;
for (QuerySysDictionaryViewOutput out : outputs) {
if (sysDictionaryList != null && !sysDictionaryList.isEmpty()) {
if (CollUtil.isNotEmpty(sysDictionaryList)) {
boolean flag = false;
for (SysDictionaryEnt obj : sysDictionaryList) {
if (StringUtils.equals(out.getId(), obj.getPid())) {
if (CharSequenceUtil.equals(out.getId(), obj.getPid())) {
flag = true;
break;
}
......@@ -286,7 +267,7 @@ public class SysOrganizationDictionaryService {
//添加子节点是否打开的标志
out.setChildren(null);
}
if (!StringUtils.equals(input.getParentId(), "1")) {
if (!CharSequenceUtil.equals(input.getParentId(), "1")) {
out.setChildren(null);
}
out.setOrderId(i);
......@@ -301,10 +282,10 @@ public class SysOrganizationDictionaryService {
public XListResult<SysOrganizationDictionaryEnt> querySysOrganizationDictionarys(XContext context, String ouId, String pid) {
SysOrganizationDictionaryMapper mapper = context.getBean(SysOrganizationDictionaryMapper.class);
QueryWrapper<SysOrganizationDictionaryEnt> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotBlank(ouId)) {
if (CharSequenceUtil.isNotBlank(ouId)) {
queryWrapper.lambda().like(SysOrganizationDictionaryEnt::getOuId, ouId);
}
if (StringUtils.isNotBlank(pid)) {
if (CharSequenceUtil.isNotBlank(pid)) {
queryWrapper.lambda().like(SysOrganizationDictionaryEnt::getParentDicCode, pid);
}
queryWrapper.lambda().gt(SysOrganizationDictionaryEnt::getEndTime, new Date());
......
package pps.core.system.service;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
......@@ -18,7 +20,6 @@ import xstartup.annotation.XText;
import xstartup.base.XContext;
import xstartup.base.data.CustomQueryInput;
import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XStringUtils;
import xstartup.data.XListResult;
import xstartup.data.XPageResult;
import xstartup.data.XServiceResult;
......@@ -47,12 +48,12 @@ public class SysOrganizationPropertyService {
mediaTypesInput.setAlias("MEDIUM_TYPE");
XListResult<QuerySysDictionaryViewOutput> mediaTypes = dictService.querySysDictionarysByAlias(context, mediaTypesInput);
List<QuerySysDictionaryViewOutput> mediaTypesResult = mediaTypes.getResult();
if (XStringUtils.isEmpty(input.getOuId())) {
if (CharSequenceUtil.isBlank(input.getOuId())) {
PpsUserSession session = context.getSession(PpsUserSession.class);
if (BusinessConstant.ZERO.equals(session.getIsSuperAdmin())) {
queryWrapper.lambda().eq(SysOrganizationPropertyEnt::getOuId, session.getOuId())
.le(true, SysOrganizationPropertyEnt::getEffectTime, date)
.ge(true, SysOrganizationPropertyEnt::getEndTime, date);
.le(SysOrganizationPropertyEnt::getEffectTime, date)
.ge(SysOrganizationPropertyEnt::getEndTime, date);
} else {
List<GetSysOrganizationPropertyOutput> list = new ArrayList<>();
for (QuerySysDictionaryViewOutput viewOutput : mediaTypesResult) {
......@@ -65,8 +66,8 @@ public class SysOrganizationPropertyService {
}
} else {
queryWrapper.lambda().eq(SysOrganizationPropertyEnt::getOuId, input.getOuId())
.le(true, SysOrganizationPropertyEnt::getEffectTime, date)
.ge(true, SysOrganizationPropertyEnt::getEndTime, date);
.le(SysOrganizationPropertyEnt::getEffectTime, date)
.ge(SysOrganizationPropertyEnt::getEndTime, date);
}
List<SysOrganizationPropertyEnt> propertyEnts = mapper.selectList(queryWrapper);
List<GetSysOrganizationPropertyOutput> outputs = XCopyUtils.copyNewList(propertyEnts, GetSysOrganizationPropertyOutput.class);
......@@ -107,10 +108,10 @@ public class SysOrganizationPropertyService {
@XApiPost
public XServiceResult updateSysOrganizationProperty(XContext context, UpdateSysOrganizationPropertyInput input) {
SysOrganizationPropertyMapper mapper = context.getBean(SysOrganizationPropertyMapper.class);
QueryWrapper<SysOrganizationPropertyEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysOrganizationPropertyEnt::getId, input.getId());
SysOrganizationPropertyEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysOrganizationPropertyEnt entity = mapper.selectOne(new QueryWrapper<SysOrganizationPropertyEnt>()
.lambda()
.eq(SysOrganizationPropertyEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -121,10 +122,10 @@ public class SysOrganizationPropertyService {
@XApiPost
public XServiceResult deleteSysOrganizationProperty(XContext context, DeleteSysOrganizationPropertyInput input) {
SysOrganizationPropertyMapper mapper = context.getBean(SysOrganizationPropertyMapper.class);
QueryWrapper<SysOrganizationPropertyEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysOrganizationPropertyEnt::getId, input.getId());
SysOrganizationPropertyEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysOrganizationPropertyEnt entity = mapper.selectOne(new QueryWrapper<SysOrganizationPropertyEnt>()
.lambda()
.eq(SysOrganizationPropertyEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
mapper.deleteById(entity);
......
package pps.core.system.service;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
......@@ -37,10 +38,10 @@ public class SysOrganizationRelService {
@XApiPost
public XServiceResult deleteSysOrganizationRel(XContext context, DeleteSysOrganizationRelInput input) {
SysOrganizationRelMapper mapper = context.getBean(SysOrganizationRelMapper.class);
QueryWrapper<SysOrganizationRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysOrganizationRelEnt::getId, input.getId());
SysOrganizationRelEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysOrganizationRelEnt entity = mapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.eq(SysOrganizationRelEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
mapper.deleteById(entity);
......@@ -50,10 +51,10 @@ public class SysOrganizationRelService {
@XApiGet
public XSingleResult<GetSysOrganizationRelOutput> getSysOrganizationRel(XContext context, GetSysOrganizationRelInput input) {
SysOrganizationRelMapper mapper = context.getBean(SysOrganizationRelMapper.class);
QueryWrapper<SysOrganizationRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysOrganizationRelEnt::getId, input.getId());
SysOrganizationRelEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysOrganizationRelEnt entity = mapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.eq(SysOrganizationRelEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysOrganizationRelOutput output = new GetSysOrganizationRelOutput();
......@@ -95,7 +96,7 @@ public class SysOrganizationRelService {
SysOrganizationRelView record = new SysOrganizationRelView();
XCopyUtils.copyObject(input, record);
SysOrganizationRelView view = mapper.selectOne(record);
if (view == null) {
if (ObjectUtil.isNull(view)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysOrganizationRelViewOutput output = new GetSysOrganizationRelViewOutput();
......
package pps.core.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import pps.cloud.base.service.BaseBaseStationService;
import pps.cloud.base.service.data.BaseOuIdInput;
import pps.cloud.base.service.data.QueryBaseStationInput;
......@@ -33,7 +33,6 @@ import xstartup.annotation.XText;
import xstartup.base.XContext;
import xstartup.base.exception.XServiceException;
import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XDateUtils;
import xstartup.base.util.XStringUtils;
import xstartup.data.XListResult;
import xstartup.data.XPageResult;
......@@ -63,9 +62,9 @@ public class SysOrganizationService {
stationInput.setStationName(input.getOuName());
XListResult<QueryBaseStationOutput> listResult = stationService.selectStationAllByStationName(context, stationInput);
List<QueryBaseStationOutput> stationLikeList = listResult.getResult();
if (!CollectionUtils.isEmpty(stationLikeList)) {
if (CollUtil.isNotEmpty(stationLikeList)) {
for (QueryBaseStationOutput baseStationView : stationLikeList) {
if (XStringUtils.isNotEmpty(baseStationView.getOuId())) {
if (CharSequenceUtil.isNotBlank(baseStationView.getOuId())) {
ouIds.add(baseStationView.getOuId());
}
}
......@@ -84,20 +83,20 @@ public class SysOrganizationService {
for (QuerySysOrganizationViewOutputTree tree : list) {
//如果是超级管理员查所以组织机构
if (BusinessConstant.ONE.equals(isSuperAdmin)) {
if (tree.getParentOuId().equals("00000000-0000-0000-0000-000000000000")) {
if (CharSequenceUtil.equals(tree.getParentOuId(), "00000000-0000-0000-0000-000000000000")) {
trees.add(tree);
}
} else {
if (tree.getId().equals(session.getOuId())) {
if (CharSequenceUtil.equals(tree.getId(), session.getOuId())) {
trees.add(tree);
}
}
//子集
for (QuerySysOrganizationViewOutputTree it : list) {
if (OuLevelConstant.CHANG_ZHAN.getCode().equals(it.getOuLevel()) && !CollectionUtils.isEmpty(stationLikeList)) {
List<QuerySysOrganizationViewOutputTree> stationList = new ArrayList<>();
if (CharSequenceUtil.equals(OuLevelConstant.CHANG_ZHAN.getCode(), it.getOuLevel()) && CollUtil.isNotEmpty(stationLikeList)) {
List<QuerySysOrganizationViewOutputTree> stationList = new ArrayList<>(stationLikeList.size());
for (QueryBaseStationOutput baseStationView : stationLikeList) {
if (it.getId().equals(baseStationView.getOuId())) {
if (CharSequenceUtil.equals(it.getId(), baseStationView.getOuId())) {
QuerySysOrganizationViewOutputTree outputTree = new QuerySysOrganizationViewOutputTree();
outputTree.setId(baseStationView.getId());
outputTree.setOuName(baseStationView.getStationName());
......@@ -107,52 +106,45 @@ public class SysOrganizationService {
}
it.setChildren(stationList);
}
if (tree.getId().equals(it.getParentOuId())) {
if (tree.getChildren() == null) {
if (CharSequenceUtil.equals(tree.getId(), it.getParentOuId())) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(it);
}
}
if (tree.getChildren() != null && tree.getChildren().size() > 1) {
if (CollUtil.isNotEmpty(tree.getChildren())) {
List<QuerySysOrganizationViewOutputTree> children = tree.getChildren();
children.forEach(outputTree -> {
if (outputTree.getSort() == null) {
if (ObjectUtil.isNull(outputTree.getSort())) {
outputTree.setSort(999);
}
});
children = children.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort)).collect(Collectors.toList());
children.sort(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort));
tree.setChildren(children);
}
}
trees.forEach(outputTree -> {
if (outputTree.getSort() == null) {
if (ObjectUtil.isNull(outputTree.getSort())) {
outputTree.setSort(999);
}
});
trees = trees.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort)).collect(Collectors.toList());
trees.sort(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort));
return XListResult.success(trees);
}
@XText("根据父级id查询儿子级--最后一级查的是场站")
@XApiPost
public XListResult<GetSysOrganizationViewOutput> selectOuInfoOrStationByParentOuId(XContext context, GetSysOrganizationRelInput input) {
SysOrganizationViewMapper mapper = context.getBean(SysOrganizationViewMapper.class);
SysOrganizationView record = new SysOrganizationView();
XCopyUtils.copyObject(input, record);
record.setEndTime(new Date());
record.setIsDeleted(BusinessConstant.ONE);
PpsUserSession session = context.getSession(PpsUserSession.class);
Integer isSuperAdmin = session.getIsSuperAdmin();
List<SysOrganizationView> viewList = new ArrayList<>();
if (XStringUtils.isNotEmpty(input.getOuLevel()) && OuLevelConstant.CHANG_ZHAN.getCode().equals(input.getOuLevel())) {
if (XStringUtils.isNotEmpty(input.getParentOuId())) {
if (CharSequenceUtil.isNotBlank(input.getOuLevel()) && CharSequenceUtil.equals(OuLevelConstant.CHANG_ZHAN.getCode(), input.getOuLevel())) {
if (CharSequenceUtil.isNotBlank(input.getParentOuId())) {
BaseBaseStationService stationService = context.getBean(BaseBaseStationService.class);
BaseOuIdInput ouIdInput = new BaseOuIdInput();
ouIdInput.setOuId(input.getParentOuId());
XListResult<QueryBaseStationOutput> viewsResult = stationService.selectStationListByOuId(context, ouIdInput);
List<QueryBaseStationOutput> stationViews = viewsResult.getResult();
if (CollectionUtils.isEmpty(stationViews)) {
if (CollUtil.isEmpty(stationViews)) {
return XListResult.success(Collections.emptyList());
}
for (QueryBaseStationOutput stationView : stationViews) {
......@@ -166,9 +158,16 @@ public class SysOrganizationService {
return XListResult.success(outputs);
}
}
if (XStringUtils.isEmpty(input.getParentOuId())) {
PpsUserSession session = context.getSession(PpsUserSession.class);
Integer isSuperAdmin = session.getIsSuperAdmin();
SysOrganizationViewMapper mapper = context.getBean(SysOrganizationViewMapper.class);
SysOrganizationView record = new SysOrganizationView();
XCopyUtils.copyObject(input, record);
record.setEndTime(new Date());
record.setIsDeleted(BusinessConstant.ONE);
if (CharSequenceUtil.isNotBlank(input.getParentOuId())) {
//如果是超级管理员查所以组织机构
if (BusinessConstant.ONE.equals(isSuperAdmin) || OuLevelConstant.YOU_QI_DIAO_KONG_ZHONG_XIN.getCode().equals(session.getOwnerOrgLevel())) {
if (BusinessConstant.ONE.equals(isSuperAdmin) || CharSequenceUtil.equals(OuLevelConstant.YOU_QI_DIAO_KONG_ZHONG_XIN.getCode(), session.getOwnerOrgLevel())) {
record.setParentOuId("00000000-0000-0000-0000-000000000000");
viewList = mapper.selectOuSonByParentOuId(record);
} else {
......@@ -185,16 +184,17 @@ public class SysOrganizationService {
@XText("根据用户id查询地区公司")
@XApiPost
public XListResult<GetSysOrganizationViewOutput> selectRegionFirmByUserId(XContext context, SelectRegionFirmInput input) {
String ouId = input.getOuId();
if (CharSequenceUtil.isBlank(input.getOuId())) {
PpsUserSession session = context.getSession(PpsUserSession.class);
SysOrganizationMapper bean = context.getBean(SysOrganizationMapper.class);
QueryWrapper<SysOrganizationEnt> wrapper = new QueryWrapper<>();
String ouId = session.getOuId();
if (StringUtils.isNotBlank(input.getOuId())) {
ouId = input.getOuId();
ouId = session.getOuId();
}
wrapper.lambda().eq(SysOrganizationEnt::getId, ouId).eq(SysOrganizationEnt::getIsDeleted, BusinessConstant.ONE);
SysOrganizationEnt ou = bean.selectOne(wrapper);
if (ou == null) {
SysOrganizationMapper bean = context.getBean(SysOrganizationMapper.class);
SysOrganizationEnt ou = bean.selectOne(new QueryWrapper<SysOrganizationEnt>()
.lambda()
.eq(SysOrganizationEnt::getId, ouId)
.eq(SysOrganizationEnt::getIsDeleted, BusinessConstant.ONE));
if (ObjectUtil.isNull(ou)) {
return XListResult.success(Collections.emptyList());
}
List<GetSysOrganizationViewOutput> outputs = new ArrayList<>();
......@@ -206,11 +206,12 @@ public class SysOrganizationService {
view.setOuLevel(OuLevelConstant.YOU_QI_DIAO_KONG_ZHONG_XIN.getCode());
SysOrganizationView organization = viewMapper.getSysOrganizationByOuLevelAndOuId(view);
if (OuLevelConstant.ZHUAN_YE_GONG_SI.getCode().equals(ou.getOuLevel()) || organization != null && OuLevelConstant.YOU_QI_DIAO_KONG_ZHONG_XIN.getCode().equals(organization.getOuLevel())) {
wrapper = new QueryWrapper<>();
wrapper.lambda().eq(SysOrganizationEnt::getOuLevel, OuLevelConstant.DI_QU_GONG_SI.getCode())
List<SysOrganizationEnt> organizationEnts = bean.selectList(new QueryWrapper<SysOrganizationEnt>()
.lambda()
.eq(SysOrganizationEnt::getOuLevel, OuLevelConstant.DI_QU_GONG_SI.getCode())
.eq(SysOrganizationEnt::getIsDeleted, BusinessConstant.ONE)
.orderBy(true, true, SysOrganizationEnt::getId);
List<SysOrganizationEnt> organizationEnts = bean.selectList(wrapper);
.orderByAsc(SysOrganizationEnt::getId)
);
outputs = XCopyUtils.copyNewList(organizationEnts, GetSysOrganizationViewOutput.class);
} else {
view = new SysOrganizationView();
......@@ -245,117 +246,117 @@ public class SysOrganizationService {
trees.add(tree);
}
} else {
if (tree.getId().equals(session.getOuId())) {
if (CharSequenceUtil.equals(tree.getId(), session.getOuId())) {
trees.add(tree);
}
}
//子集
for (QuerySysOrganizationViewOutputTree it : list) {
if (tree.getId().equals(it.getParentOuId())) {
if (tree.getChildren() == null) {
if (CharSequenceUtil.equals(tree.getId(), it.getParentOuId())) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(it);
}
}
if (tree.getChildren() != null && tree.getChildren().size() > 1) {
if (CollUtil.isNotEmpty(tree.getChildren())) {
List<QuerySysOrganizationViewOutputTree> children = tree.getChildren();
children.forEach(outputTree -> {
if (outputTree.getSort() == null) {
if (ObjectUtil.isNull(outputTree.getSort())) {
outputTree.setSort(999);
}
});
children = children.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort)).collect(Collectors.toList());
children.sort(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort));
tree.setChildren(children);
}
}
trees.forEach(outputTree -> {
if (outputTree.getSort() == null) {
if (ObjectUtil.isNull(outputTree.getSort())) {
outputTree.setSort(999);
}
});
trees = trees.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort)).collect(Collectors.toList());
trees.sort(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort));
return XListResult.success(trees);
}
@XText("根据条件组织机构树")
@XApiPost
public XListResult<QuerySysOrganizationViewOutputTree> getOuTreeByCondition(XContext context, GetOuInfoByConditionInput input) {
SysOrganizationViewMapper mapper = context.getBean(SysOrganizationViewMapper.class);
SysOrganizationView record = new SysOrganizationView();
XCopyUtils.copyObject(input, record);
record.setIsDeleted(BusinessConstant.ONE);
record.setEndTime(new Date());
List<SysOrganizationView> viewList = mapper.selectOuTreeByOuName(record);
List<QuerySysOrganizationViewOutputTree> list = XCopyUtils.copyNewList(viewList, QuerySysOrganizationViewOutputTree.class);
List<QuerySysOrganizationViewOutputTree> trees = new ArrayList<>();
String rootId = null;
String ouId = null;
if (input.getShowAll() != null && input.getShowAll()) {
if (ObjectUtil.isNotNull(input.getShowAll()) && input.getShowAll()) {
rootId = "00000000-0000-0000-0000-000000000000";
} else {
PpsUserSession session = context.getSession(PpsUserSession.class);
ouId = session.getOuId();
}
SysOrganizationViewMapper mapper = context.getBean(SysOrganizationViewMapper.class);
SysOrganizationView record = new SysOrganizationView();
XCopyUtils.copyObject(input, record);
record.setIsDeleted(BusinessConstant.ONE);
record.setEndTime(new Date());
List<SysOrganizationView> viewList = mapper.selectOuTreeByOuName(record);
List<QuerySysOrganizationViewOutputTree> list = XCopyUtils.copyNewList(viewList, QuerySysOrganizationViewOutputTree.class);
for (QuerySysOrganizationViewOutputTree tree : list) {
if (rootId != null) {
if (tree.getParentOuId().equals(rootId)) {
if (CharSequenceUtil.isNotBlank(rootId)) {
if (CharSequenceUtil.equals(tree.getParentOuId(), rootId)) {
trees.add(tree);
}
} else {
if (tree.getId().equals(ouId)) {
if (CharSequenceUtil.equals(tree.getId(), ouId)) {
trees.add(tree);
}
}
//子集
for (QuerySysOrganizationViewOutputTree it : list) {
if (tree.getId().equals(it.getParentOuId())) {
if (tree.getChildren() == null) {
if (CharSequenceUtil.equals(tree.getId(), it.getParentOuId())) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(it);
}
}
if (tree.getChildren() != null && tree.getChildren().size() > 1) {
if (CollUtil.isNotEmpty(tree.getChildren())) {
List<QuerySysOrganizationViewOutputTree> children = tree.getChildren();
children.forEach(outputTree -> {
if (outputTree.getSort() == null) {
if (ObjectUtil.isNull(outputTree.getSort())) {
outputTree.setSort(999);
}
});
children = children.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort)).collect(Collectors.toList());
children.sort(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort));
tree.setChildren(children);
}
}
trees.forEach(outputTree -> {
if (outputTree.getSort() == null) {
if (ObjectUtil.isNull(outputTree.getSort())) {
outputTree.setSort(999);
}
});
trees = trees.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort)).collect(Collectors.toList());
trees.sort(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort));
return XListResult.success(trees);
}
@XText("根据条件查询组织机构")
@XApiPost
public XListResult<GetSysOrganizationViewOutput> getOuInfoByCondition(XContext context, GetOuInfoByConditionInput input) {
SysOrganizationViewMapper mapper = context.getBean(SysOrganizationViewMapper.class);
SysOrganizationView record = new SysOrganizationView();
XCopyUtils.copyObject(input, record);
record.setEndTime(new Date());
record.setIsDeleted(BusinessConstant.ONE);
String rootId = null;
String ouId = null;
if (input.getShowAll() != null && input.getShowAll()) {
if (ObjectUtil.isNotNull(input.getShowAll()) && input.getShowAll()) {
rootId = "00000000-0000-0000-0000-000000000000";
} else {
PpsUserSession session = context.getSession(PpsUserSession.class);
ouId = session.getOuId();
}
List<SysOrganizationView> viewList;
if (XStringUtils.isEmpty(input.getParentOuId())) {
SysOrganizationViewMapper mapper = context.getBean(SysOrganizationViewMapper.class);
SysOrganizationView record = new SysOrganizationView();
XCopyUtils.copyObject(input, record);
record.setEndTime(new Date());
record.setIsDeleted(BusinessConstant.ONE);
if (CharSequenceUtil.isBlank(input.getParentOuId())) {
//如果是超级管理员查所以组织机构
if (rootId != null) {
if (CharSequenceUtil.isNotBlank(rootId)) {
record.setParentOuId(rootId);
viewList = mapper.selectOuSonByParentOuId(record);
} else {
......@@ -376,10 +377,10 @@ public class SysOrganizationService {
SysOrganizationView record = new SysOrganizationView();
XCopyUtils.copyObject(input, record);
record.setIsDeleted(BusinessConstant.ONE);
List<SysOrganizationView> viewList;
if (CharSequenceUtil.isBlank(input.getParentOuId())) {
PpsUserSession session = context.getSession(PpsUserSession.class);
Integer isSuperAdmin = session.getIsSuperAdmin();
List<SysOrganizationView> viewList;
if (XStringUtils.isEmpty(input.getParentOuId())) {
//如果是超级管理员查所以组织机构
if (BusinessConstant.ONE.equals(isSuperAdmin)) {
record.setParentOuId("00000000-0000-0000-0000-000000000000");
......@@ -410,7 +411,7 @@ public class SysOrganizationService {
public XListResult<DynamicQuerySysOrganizationOutput> querySysOrganizationList(XContext context, DynamicQuerySysOrganizationInput input) {
SysOrganizationViewMapper mapper = context.getBean(SysOrganizationViewMapper.class);
SysOrganizationView view;
if (StringUtils.isAllBlank(input.getId(), input.getParentOuId(), input.getOuName())) {
if (CharSequenceUtil.isAllBlank(input.getId(), input.getParentOuId(), input.getOuName())) {
//如果条件都为空,则从登录信息获取条件
view = new SysOrganizationView();
PpsUserSession session = context.getSession(PpsUserSession.class);
......@@ -466,25 +467,30 @@ public class SysOrganizationService {
@XText("根据父级id查询儿子级-特殊")
@XApiPost
public XListResult<GetSysOrganizationViewOutput> selectSpecailOuInfoByParentOuId(XContext context, GetSysOrganizationRelInput input) {
SysOrganizationViewMapper mapper = context.getBean(SysOrganizationViewMapper.class);
SysOrganizationView record = new SysOrganizationView();
XCopyUtils.copyObject(input, record);
record.setEndTime(new Date());
record.setIsDeleted(BusinessConstant.ONE);
PpsUserSession session = context.getSession(PpsUserSession.class);
Integer isSuperAdmin = session.getIsSuperAdmin();
List<SysOrganizationView> viewList;
SysDictionaryViewMapper dictionaryViewMapper = context.getBean(SysDictionaryViewMapper.class);
SysDictionaryView dictionaryView = new SysDictionaryView();
dictionaryView.setAlias("sys_inform_org");
boolean isSpecial = false;
List<SysDictionaryView> dictionaryViews = dictionaryViewMapper.selectListsByAlias(dictionaryView);
if (!CollectionUtils.isEmpty(dictionaryViews)) {
SysDictionaryView isExit = dictionaryViews.stream().filter(item -> XDateUtils.compare(item.getEndTime(), new Date()) >= 0 && item.getRemark().equals(session.getOuId())).findFirst().orElse(null);
if (isExit != null)
PpsUserSession session = context.getSession(PpsUserSession.class);
if (CollUtil.isNotEmpty(dictionaryViews)) {
SysDictionaryView isExit = dictionaryViews.stream()
.filter(item ->
DateUtil.compare(item.getEndTime(), new Date()) >= 0
&& CharSequenceUtil.equals(item.getRemark(), session.getOuId()))
.findFirst()
.orElse(null);
if (ObjectUtil.isNotNull(isExit))
isSpecial = true;
}
SysOrganizationViewMapper mapper = context.getBean(SysOrganizationViewMapper.class);
SysOrganizationView record = new SysOrganizationView();
XCopyUtils.copyObject(input, record);
record.setEndTime(new Date());
record.setIsDeleted(BusinessConstant.ONE);
List<SysOrganizationView> viewList;
if (XStringUtils.isEmpty(input.getParentOuId())) {
Integer isSuperAdmin = session.getIsSuperAdmin();
//如果是超级管理员查所以组织机构
if (BusinessConstant.ONE.equals(isSuperAdmin) || isSpecial) {
record.setParentOuId("00000000-0000-0000-0000-000000000000");
......@@ -512,35 +518,35 @@ public class SysOrganizationService {
List<QuerySysOrganizationViewOutputTree> list = XCopyUtils.copyNewList(viewList, QuerySysOrganizationViewOutputTree.class);
List<QuerySysOrganizationViewOutputTree> trees = new ArrayList<>();
for (QuerySysOrganizationViewOutputTree tree : list) {
if (tree.getId().equals(session.getOuId())) {
if (CharSequenceUtil.equals(tree.getId(), session.getOuId())) {
trees.add(tree);
}
//子集
for (QuerySysOrganizationViewOutputTree it : list) {
if (tree.getId().equals(it.getParentOuId())) {
if (tree.getChildren() == null) {
if (CharSequenceUtil.equals(tree.getId(), it.getParentOuId())) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(it);
}
}
if (tree.getChildren() != null && tree.getChildren().size() > 1) {
if (CollUtil.isNotEmpty(tree.getChildren())) {
List<QuerySysOrganizationViewOutputTree> children = tree.getChildren();
children.forEach(outputTree -> {
if (outputTree.getSort() == null) {
if (ObjectUtil.isNull(outputTree.getSort())) {
outputTree.setSort(999);
}
});
children = children.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort)).collect(Collectors.toList());
children.sort(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort));
tree.setChildren(children);
}
}
trees.forEach(outputTree -> {
if (outputTree.getSort() == null) {
if (ObjectUtil.isNull(outputTree.getSort())) {
outputTree.setSort(999);
}
});
trees = trees.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort)).collect(Collectors.toList());
trees.sort(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort));
return XListResult.success(trees);
}
......@@ -550,7 +556,7 @@ public class SysOrganizationService {
//先从缓存中获取
List<SysOrganizationCache> sysOrganizationCaches = SysOrganizationCache.list(context, BusinessConstant.SYS_ORGANIZATION_CACHE);
//缓存不存在从数据库获取
if (CollectionUtils.isEmpty(sysOrganizationCaches)) {
if (CollUtil.isEmpty(sysOrganizationCaches)) {
List<SysOrganizationCache> caches = selectSysOrganizationTree(context, input);
List<QuerySysOrganizationViewOutputTree> resultTree = XCopyUtils.copyNewList(caches, QuerySysOrganizationViewOutputTree.class);
return XListResult.success(resultTree);
......@@ -569,35 +575,35 @@ public class SysOrganizationService {
List<QuerySysOrganizationViewOutputTree> list = XCopyUtils.copyNewList(viewList, QuerySysOrganizationViewOutputTree.class);
List<QuerySysOrganizationViewOutputTree> trees = new ArrayList<>();
for (QuerySysOrganizationViewOutputTree tree : list) {
if (tree.getParentOuId().equals("00000000-0000-0000-0000-000000000000")) {
if (CharSequenceUtil.equals(tree.getParentOuId(), "00000000-0000-0000-0000-000000000000")) {
trees.add(tree);
}
//子集
for (QuerySysOrganizationViewOutputTree it : list) {
if (tree.getId().equals(it.getParentOuId())) {
if (tree.getChildren() == null) {
if (CharSequenceUtil.equals(tree.getId(), it.getParentOuId())) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(it);
}
}
if (tree.getChildren() != null && tree.getChildren().size() > 1) {
if (CollUtil.isNotEmpty(tree.getChildren())) {
List<QuerySysOrganizationViewOutputTree> children = tree.getChildren();
children.forEach(outputTree -> {
if (outputTree.getSort() == null) {
if (ObjectUtil.isNull(outputTree.getSort())) {
outputTree.setSort(999);
}
});
children = children.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort)).collect(Collectors.toList());
children.sort(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort));
tree.setChildren(children);
}
}
trees.forEach(outputTree -> {
if (outputTree.getSort() == null) {
if (ObjectUtil.isNull(outputTree.getSort())) {
outputTree.setSort(999);
}
});
trees = trees.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort)).collect(Collectors.toList());
trees.sort(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort));
List<SysOrganizationCache> caches = XCopyUtils.copyNewList(trees, SysOrganizationCache.class);
//放入redis缓存中
SysOrganizationCache.set(context, BusinessConstant.SYS_ORGANIZATION_CACHE, caches);
......@@ -614,65 +620,65 @@ public class SysOrganizationService {
List<SysOrganizationView> viewList = mapper.selectOrganizationByParentOuIdOrOuId(record);
List<QuerySysOrganizationViewOutputTree> list = XCopyUtils.copyNewList(viewList, QuerySysOrganizationViewOutputTree.class);
List<QuerySysOrganizationViewOutputTree> trees = new ArrayList<>();
if ("00000000-0000-0000-0000-000000000000".equals(input.getId())) {
if (CharSequenceUtil.equals("00000000-0000-0000-0000-000000000000", input.getId())) {
trees.add(list.get(0));
} else {
for (QuerySysOrganizationViewOutputTree tree : list) {
if (tree.getId().equals(input.getId())) {
if (CharSequenceUtil.equals(tree.getId(), input.getId())) {
trees.add(tree);
}
//子集
for (QuerySysOrganizationViewOutputTree it : list) {
if (tree.getId().equals(it.getParentOuId())) {
if (tree.getChildren() == null) {
if (CharSequenceUtil.equals(tree.getId(), it.getParentOuId())) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(it);
}
}
if (tree.getChildren() != null && tree.getChildren().size() > 1) {
if (CollUtil.isNotEmpty(tree.getChildren())) {
List<QuerySysOrganizationViewOutputTree> children = tree.getChildren();
children.forEach(outputTree -> {
if (outputTree.getSort() == null) {
if (ObjectUtil.isNull(outputTree.getSort())) {
outputTree.setSort(999);
}
});
children = children.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort)).collect(Collectors.toList());
children.sort(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort));
tree.setChildren(children);
}
}
}
trees.forEach(outputTree -> {
if (outputTree.getSort() == null) {
if (ObjectUtil.isNull(outputTree.getSort())) {
outputTree.setSort(999);
}
});
trees = trees.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort)).collect(Collectors.toList());
trees.sort(Comparator.comparing(QuerySysOrganizationViewOutputTree::getSort));
return XListResult.success(trees);
}
@XText("查询组织机构列表")
@XApiPost
public XPageResult<QuerySysOrganizationViewOutput> querySysOrganizationViewPage(XContext context, QuerySysOrganizationViewInput input) {
SysOrganizationViewMapper mapper = context.getBean(SysOrganizationViewMapper.class);
SystemDictionaryService dictService = context.getBean(SystemDictionaryService.class);
SysOrganizationView record = new SysOrganizationView();
XCopyUtils.copyObject(input, record);
PageHelper.startPage(input.getPage(), input.getLimit());
record.setIsDeleted(BusinessConstant.ONE);
record.setEndTime(new Date());
SysOrganizationViewMapper mapper = context.getBean(SysOrganizationViewMapper.class);
List<SysOrganizationView> list = mapper.selectSysOrganizationList(record);
if (!CollectionUtils.isEmpty(list)) {
if (CollUtil.isNotEmpty(list)) {
List<String> parentIds = list.stream().map(SysOrganizationView::getId).collect(Collectors.toList());
List<SysOrganizationView> childList = mapper.selectCountByParentOuIds(parentIds, new Date());
Map<String, List<SysOrganizationView>> groupChildList = childList.stream().collect(Collectors.groupingBy(SysOrganizationView::getParentOuId));
list.forEach(item -> {
if (groupChildList.get(item.getId()) != null)
if (groupChildList.containsKey(item.getId()))
item.setIsHasChildren(1);
else
item.setIsHasChildren(0);
});
}
SystemDictionaryService dictService = context.getBean(SystemDictionaryService.class);
//单位级别
CreateSysDictionaryInput unitLevelInput = new CreateSysDictionaryInput();
unitLevelInput.setAlias("UNIT_LEVEL");
......@@ -687,30 +693,26 @@ public class SysOrganizationService {
XListResult<QuerySysDictionaryViewOutput> countrys = dictService.querySysDictionarysByAlias(context, countryInput);
for (SysOrganizationView view : list) {
//单位级别
if (view.getOuLevel() != null) {
if (unitLevel.getResult() != null) {
List<QuerySysDictionaryViewOutput> items = unitLevel.getResult();
for (QuerySysDictionaryViewOutput item : items) {
if (view.getOuLevel().equals(item.getDicKey())) {
if (CharSequenceUtil.isNotBlank(view.getOuLevel())) {
if (CollUtil.isNotEmpty(unitLevel.getResult())) {
for (QuerySysDictionaryViewOutput item : unitLevel.getResult()) {
if (CharSequenceUtil.equals(view.getOuLevel(), item.getDicKey())) {
view.setLevelDicName(item.getDicName());
}
}
}
if (view.getLevelDicName() == null) {
if (CharSequenceUtil.isNotBlank(view.getLevelDicName())) {
view.setLevelDicName(view.getOuLevel());
}
}
//介质类型
if (view.getMediaType() != null) {
if (mediaTypes.getResult() != null) {
List<QuerySysDictionaryViewOutput> items = mediaTypes.getResult();
String[] split = view.getMediaType().split(",");
if (CharSequenceUtil.isNotBlank(view.getMediaType())) {
if (CollUtil.isNotEmpty(mediaTypes.getResult())) {
StringBuilder buffer = new StringBuilder();
for (String mediaType : split) {
for (QuerySysDictionaryViewOutput item : items) {
for (String mediaType : CharSequenceUtil.splitToArray(view.getMediaType(), ',')) {
for (QuerySysDictionaryViewOutput item : mediaTypes.getResult()) {
if (mediaType.equals(item.getDicKey())) {
buffer.append(",");
buffer.append(item.getDicName());
buffer.append(",").append(item.getDicName());
}
}
}
......@@ -719,28 +721,27 @@ public class SysOrganizationService {
view.setPropertyName(mediaTypeName);
}
}
if (view.getPropertyName() == null) {
if (CharSequenceUtil.isBlank(view.getPropertyName())) {
view.setPropertyName(view.getMediaType());
}
}
//国家
if (view.getCountry() != null) {
if (countrys.getResult() != null) {
List<QuerySysDictionaryViewOutput> items = countrys.getResult();
for (QuerySysDictionaryViewOutput item : items) {
if (view.getCountry().equals(item.getDicKey())) {
if (CharSequenceUtil.isNotBlank(view.getCountry())) {
if (CollUtil.isNotEmpty(countrys.getResult())) {
for (QuerySysDictionaryViewOutput item : countrys.getResult()) {
if (CharSequenceUtil.equals(view.getCountry(), item.getDicKey())) {
view.setCountryName(item.getDicName());
}
}
}
if (view.getCountryName() == null) {
if (CharSequenceUtil.isBlank(view.getCountryName())) {
view.setCountryName(view.getCountry());
}
}
}
PageInfo<SysOrganizationView> pageInfo = new PageInfo<>(list);
List<QuerySysOrganizationViewOutput> outputs = XCopyUtils.copyNewList(pageInfo.getList(), QuerySysOrganizationViewOutput.class);
outputs = outputs.stream().sorted(Comparator.comparing(QuerySysOrganizationViewOutput::getSort)).collect(Collectors.toList());
outputs.sort(Comparator.comparing(QuerySysOrganizationViewOutput::getSort));
return XPageResult.success(outputs, input, pageInfo.getTotal());
}
......@@ -764,7 +765,7 @@ public class SysOrganizationService {
PageHelper.startPage(input.getPage(), input.getLimit());
record.setIsDeleted(BusinessConstant.ONE);
List<SysOrganizationView> list = mapper.selectSysOrganizationList(record);
if (CollUtil.isEmpty(list) && StringUtils.isNotBlank(record.getId())) {
if (CollUtil.isEmpty(list) && CharSequenceUtil.isNotBlank(record.getId())) {
SysOrganizationView owner = mapper.selectOne(record);
List<SysOrganizationView> parentList = mapper.selectOrganizationBySubOuIds(Collections.singletonList(record.getId()));
if (CollUtil.isNotEmpty(parentList)) {
......@@ -787,10 +788,10 @@ public class SysOrganizationService {
Map<String, List<SysOrganizationView>> groupChildList = childList.stream()
.collect(Collectors.groupingBy(SysOrganizationView::getParentOuId));
for (SysOrganizationView view : list) {
if (Objects.isNull(view.getSort())) {
if (ObjectUtil.isNull(view.getSort())) {
view.setSort(0);
}
if (Objects.nonNull(groupChildList.get(view.getId()))) {
if (ObjectUtil.isNotNull(groupChildList.get(view.getId()))) {
view.setIsHasChildren(1);
} else {
view.setIsHasChildren(0);
......@@ -798,7 +799,7 @@ public class SysOrganizationService {
//单位级别
if (CollUtil.isNotEmpty(unitLevel.getResult())) {
view.setLevelDicName(unitLevel.getResult().stream()
.filter(row -> StringUtils.equals(row.getDicKey(), view.getOuLevel()))
.filter(row -> CharSequenceUtil.equals(row.getDicKey(), view.getOuLevel()))
.map(QuerySysDictionaryViewOutput::getDicName)
.findAny()
.orElse(null));
......@@ -816,21 +817,20 @@ public class SysOrganizationService {
return XTransactionHelper.begin(context, () -> {
SysOrganizationRelMapper mapper = context.getBean(SysOrganizationRelMapper.class);
Date date = new Date();
QueryWrapper<SysOrganizationRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysOrganizationRelEnt::getOuId, input.getId());
queryWrapper.lambda().le(true, SysOrganizationRelEnt::getEffectTime, date);
queryWrapper.lambda().ge(true, SysOrganizationRelEnt::getEndTime, date);
SysOrganizationRelEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysOrganizationRelEnt entity = mapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>()
.lambda().eq(SysOrganizationRelEnt::getOuId, input.getId())
.le(SysOrganizationRelEnt::getEffectTime, date)
.ge(SysOrganizationRelEnt::getEndTime, date));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
Integer entitySort = entity.getSort();
QueryWrapper<SysOrganizationRelEnt> sortQueryWrapper = new QueryWrapper<>();
sortQueryWrapper.lambda().eq(SysOrganizationRelEnt::getParentOuId, entity.getParentOuId());
sortQueryWrapper.lambda().le(true, SysOrganizationRelEnt::getEffectTime, date);
sortQueryWrapper.lambda().ge(true, SysOrganizationRelEnt::getEndTime, date);
sortQueryWrapper.lambda().le(SysOrganizationRelEnt::getEffectTime, date);
sortQueryWrapper.lambda().ge(SysOrganizationRelEnt::getEndTime, date);
//判断是上移还是下移
if (input.getSortFlag().equals("up")) {
if (CharSequenceUtil.equals(input.getSortFlag(), "up")) {
//sort-=1;
sortQueryWrapper.lambda().le(SysOrganizationRelEnt::getSort, entitySort);
sortQueryWrapper.lambda().orderByDesc(SysOrganizationRelEnt::getSort);
......@@ -841,15 +841,15 @@ public class SysOrganizationService {
}
List<SysOrganizationRelEnt> relEnts = mapper.selectList(sortQueryWrapper);
PpsUserSession session = context.getSession(PpsUserSession.class);
if (!CollectionUtils.isEmpty(relEnts) && relEnts.size() > 1) {
if (CollUtil.isNotEmpty(relEnts)) {
SysOrganizationRelEnt relEnt = relEnts.get(1);
Integer relEntSort = relEnt.getSort();
if (input.getSortFlag().equals("up")) {
if (relEntSort != null && relEntSort.equals(entitySort)) {
if (CharSequenceUtil.equals(input.getSortFlag(), "up")) {
if (ObjectUtil.isNotNull(relEntSort) && relEntSort.equals(entitySort)) {
relEntSort -= 1;
}
} else {
if (relEntSort != null && relEntSort.equals(entitySort)) {
if (ObjectUtil.isNotNull(relEntSort) && relEntSort.equals(entitySort)) {
relEntSort += 1;
}
}
......@@ -886,22 +886,22 @@ public class SysOrganizationService {
entity.setIsDeleted(BusinessConstant.ONE);
entity.setCreateTime(date);
PpsUserSession session = context.getSession(PpsUserSession.class);
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
entity.setCreateById(session.getId());
entity.setCreateByName(session.getUserName());
}
mapper.insert(entity);
//先修改父级为有子集状态
if (input.getParentOuId() != null) {
QueryWrapper<SysOrganizationRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().le(true, SysOrganizationRelEnt::getEffectTime, new Date());
queryWrapper.lambda().ge(true, SysOrganizationRelEnt::getEndTime, new Date());
queryWrapper.lambda().eq(SysOrganizationRelEnt::getOuId, input.getParentOuId());
SysOrganizationRelEnt parent = relMapper.selectOne(queryWrapper);
if (parent != null) {
if (ObjectUtil.isNotNull(input.getParentOuId())) {
SysOrganizationRelEnt parent = relMapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.le(SysOrganizationRelEnt::getEffectTime, new Date())
.ge(SysOrganizationRelEnt::getEndTime, new Date())
.eq(SysOrganizationRelEnt::getOuId, input.getParentOuId()));
if (ObjectUtil.isNotNull(parent)) {
parent.setIsHasChildren(BusinessConstant.ONE);
parent.setModifyTime(new Date());
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
parent.setModifyById(session.getId());
parent.setModifyByName(session.getUserName());
}
......@@ -925,9 +925,8 @@ public class SysOrganizationService {
SysOrganizationRelViewMapper relViewMapper = context.getBean(SysOrganizationRelViewMapper.class);
SysOrganizationRelView relView = relViewMapper.selectMaxSort(input.getParentOuId());
QuerySysOrganizationRelInput output = new QuerySysOrganizationRelInput();
if (relView != null) {
Integer sort1 = relView.getSort();
output.setSort(++sort1);
if (ObjectUtil.isNotNull(relView)) {
output.setSort(relView.getSort() + 1);
} else {
output.setSort(1);
}
......@@ -944,54 +943,52 @@ public class SysOrganizationService {
QueryWrapper<SysOrganizationEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysOrganizationEnt::getId, input.getId());
SysOrganizationEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
if (ObjectUtil.isNotNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
Date date = new Date();
entity.setModifyTime(date);
PpsUserSession session = context.getSession(PpsUserSession.class);
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
entity.setModifyById(session.getId());
entity.setModifyByName(session.getUserName());
}
mapper.updateById(entity);
//修改组织机构关系表
QueryWrapper<SysOrganizationRelEnt> relQueryWrapper = new QueryWrapper<>();
relQueryWrapper.lambda().eq(SysOrganizationRelEnt::getOuId, input.getId());
relQueryWrapper.lambda().le(SysOrganizationRelEnt::getEffectTime, new Date());
relQueryWrapper.lambda().ge(SysOrganizationRelEnt::getEndTime, new Date());
SysOrganizationRelEnt relEntity = relMapper.selectOne(relQueryWrapper);
if (relEntity == null) {
SysOrganizationRelEnt relEntity = relMapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.eq(SysOrganizationRelEnt::getOuId, input.getId())
.le(SysOrganizationRelEnt::getEffectTime, new Date())
.ge(SysOrganizationRelEnt::getEndTime, new Date()));
if (ObjectUtil.isNull(relEntity)) {
throw new XServiceException("数据有误!");
}
try {
//先修改原父级为无子集状态
if (input.getParentOuId() != null && !input.getParentOuId().equals(relEntity.getParentOuId())) {
QueryWrapper<SysOrganizationRelEnt> originalParentWrapper = new QueryWrapper<>();
originalParentWrapper.lambda().le(SysOrganizationRelEnt::getEffectTime, new Date());
originalParentWrapper.lambda().ge(SysOrganizationRelEnt::getEndTime, new Date());
originalParentWrapper.lambda().eq(SysOrganizationRelEnt::getOuId, relEntity.getParentOuId());
SysOrganizationRelEnt originalParent = relMapper.selectOne(originalParentWrapper);
if (originalParent != null) {
if (CharSequenceUtil.isNotBlank(input.getParentOuId()) && !CharSequenceUtil.equals(input.getParentOuId(), relEntity.getParentOuId())) {
SysOrganizationRelEnt originalParent = relMapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>().lambda().le(SysOrganizationRelEnt::getEffectTime, new Date())
.ge(SysOrganizationRelEnt::getEndTime, new Date())
.eq(SysOrganizationRelEnt::getOuId, relEntity.getParentOuId()));
if (ObjectUtil.isNotNull(originalParent)) {
originalParent.setIsHasChildren(BusinessConstant.ZERO);
originalParent.setModifyTime(new Date());
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
originalParent.setModifyById(session.getId());
originalParent.setModifyByName(session.getUserName());
}
relMapper.updateById(originalParent);
}
//修改新父级为有子集状态
QueryWrapper<SysOrganizationRelEnt> nowParentWrapper = new QueryWrapper<>();
nowParentWrapper.lambda().eq(SysOrganizationRelEnt::getOuId, input.getParentOuId());
nowParentWrapper.lambda().le(SysOrganizationRelEnt::getEffectTime, new Date());
nowParentWrapper.lambda().ge(SysOrganizationRelEnt::getEndTime, new Date());
SysOrganizationRelEnt nowParent = relMapper.selectOne(nowParentWrapper);
if (nowParent != null) {
SysOrganizationRelEnt nowParent = relMapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.eq(SysOrganizationRelEnt::getOuId, input.getParentOuId())
.le(SysOrganizationRelEnt::getEffectTime, new Date())
.ge(SysOrganizationRelEnt::getEndTime, new Date()));
if (ObjectUtil.isNotNull(nowParent)) {
nowParent.setIsHasChildren(BusinessConstant.ONE);
nowParent.setModifyTime(new Date());
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
nowParent.setModifyById(session.getId());
nowParent.setModifyByName(session.getUserName());
}
......@@ -1003,63 +1000,28 @@ public class SysOrganizationService {
}
relEntity.setSort(input.getSort());
relEntity.setModifyTime(date);
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
relEntity.setModifyById(session.getId());
relEntity.setModifyByName(session.getUserName());
}
relMapper.updateById(relEntity);
//修改组织机构属性表
QueryWrapper<SysOrganizationPropertyEnt> propertyQueryWrapper = new QueryWrapper<>();
propertyQueryWrapper.lambda().eq(SysOrganizationPropertyEnt::getOuId, input.getId())
List<SysOrganizationPropertyEnt> propertyEntitys = propertyMapper.selectList(new QueryWrapper<SysOrganizationPropertyEnt>()
.lambda()
.eq(SysOrganizationPropertyEnt::getOuId, input.getId())
.le(SysOrganizationPropertyEnt::getEffectTime, new Date())
.ge(SysOrganizationPropertyEnt::getEndTime, new Date());
List<SysOrganizationPropertyEnt> propertyEntitys = propertyMapper.selectList(propertyQueryWrapper);
.ge(SysOrganizationPropertyEnt::getEndTime, new Date()));
//组织机构属性数据全部改为失效
propertyEntitys.forEach(sysOrganizationPropertyEnt -> {
sysOrganizationPropertyEnt.setEndTime(date);
sysOrganizationPropertyEnt.setModifyTime(date);
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
sysOrganizationPropertyEnt.setModifyById(session.getId());
sysOrganizationPropertyEnt.setModifyByName(session.getUserName());
}
propertyMapper.updateById(sysOrganizationPropertyEnt);
});
insertSysOrganizationProperty(context, date, input.getId(), "GAS", session);
// if (XStringUtils.isNotEmpty(input.getMediaType())){
// String[] split = input.getMediaType().split(",");
// StringBuilder builder = new StringBuilder();
// for (String mediaType : split) {
// //用来判断库中是否存在选中的介质类型
// int record=0;
// for (SysOrganizationPropertyEnt propertyEntity : propertyEntitys) {
// //如果页面和库中的介质类型相等的话改为有效
// if (mediaType.equals(propertyEntity.getPropertyValue())){
// record+=1;
// //介质类型
// //propertyEntity.setPropertyValue(input.getMediumType());
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// String datetime="9999-12-31";
// try {
// propertyEntity.setEndTime(sdf.parse(datetime));
// } catch (ParseException e) {
// e.printStackTrace();
// }
// propertyMapper.updateById(propertyEntity);
// }
// }
// if (record ==0){
// builder.append(",");
// builder.append(mediaType);
//
// }
// }
// if (builder.length()>0){
// //新增组织机构属性表
// String mediaType = builder.substring(1);
//
// }
// }
} catch (Exception e) {
throw new XServiceException(e);
}
......@@ -1076,23 +1038,23 @@ public class SysOrganizationService {
return XTransactionHelper.begin(context, () -> {
SysOrganizationMapper mapper = context.getBean(SysOrganizationMapper.class);
SysUserOrganizationRelMapper userOuRelMapper = context.getBean(SysUserOrganizationRelMapper.class);
QueryWrapper<SysOrganizationEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysOrganizationEnt::getId, input.getId());
SysOrganizationEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysOrganizationEnt entity = mapper.selectOne(new QueryWrapper<SysOrganizationEnt>()
.lambda()
.eq(SysOrganizationEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
QueryWrapper<SysUserOrganizationRelEnt> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(SysUserOrganizationRelEnt::getOuId, entity.getId())
List<SysUserOrganizationRelEnt> relEnts = userOuRelMapper.selectList(new QueryWrapper<SysUserOrganizationRelEnt>()
.lambda()
.eq(SysUserOrganizationRelEnt::getOuId, entity.getId())
.le(true, SysUserOrganizationRelEnt::getEffectTime, new Date())
.ge(true, SysUserOrganizationRelEnt::getEndTime, new Date());
List<SysUserOrganizationRelEnt> relEnts = userOuRelMapper.selectList(wrapper);
if (!CollectionUtils.isEmpty(relEnts)) {
.ge(true, SysUserOrganizationRelEnt::getEndTime, new Date()));
if (CollUtil.isNotEmpty(relEnts)) {
return XServiceResult.error(200, "当前组织机构下已绑定人员禁止删除!");
}
entity.setModifyTime(new Date());
PpsUserSession session = context.getSession(PpsUserSession.class);
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
entity.setModifyById(session.getId());
entity.setModifyByName(session.getUserName());
}
......@@ -1100,15 +1062,15 @@ public class SysOrganizationService {
mapper.updateById(entity);
//组织机构关系表修改为失效状态
SysOrganizationRelMapper relmapper = context.getBean(SysOrganizationRelMapper.class);
QueryWrapper<SysOrganizationRelEnt> relWrapper = new QueryWrapper<>();
relWrapper.lambda().eq(SysOrganizationRelEnt::getOuId, input.getId());
relWrapper.lambda().le(true, SysOrganizationRelEnt::getEffectTime, new Date());
relWrapper.lambda().ge(true, SysOrganizationRelEnt::getEndTime, new Date());
SysOrganizationRelEnt relEnt = relmapper.selectOne(relWrapper);
SysOrganizationRelEnt relEnt = relmapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.eq(SysOrganizationRelEnt::getOuId, input.getId())
.le(true, SysOrganizationRelEnt::getEffectTime, new Date())
.ge(true, SysOrganizationRelEnt::getEndTime, new Date()));
try {
relEnt.setEndTime(new Date());
relEnt.setModifyTime(new Date());
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
relEnt.setModifyById(session.getId());
relEnt.setModifyByName(session.getUserName());
}
......@@ -1118,15 +1080,15 @@ public class SysOrganizationService {
}
//组织机构属性表修改为失效状态
SysOrganizationPropertyMapper propertyMapper = context.getBean(SysOrganizationPropertyMapper.class);
QueryWrapper<SysOrganizationPropertyEnt> propertyWrapper = new QueryWrapper<>();
propertyWrapper.lambda().eq(SysOrganizationPropertyEnt::getOuId, input.getId());
propertyWrapper.lambda().le(true, SysOrganizationPropertyEnt::getEffectTime, new Date());
propertyWrapper.lambda().ge(true, SysOrganizationPropertyEnt::getEndTime, new Date());
List<SysOrganizationPropertyEnt> propertyEnts = propertyMapper.selectList(propertyWrapper);
List<SysOrganizationPropertyEnt> propertyEnts = propertyMapper.selectList(new QueryWrapper<SysOrganizationPropertyEnt>()
.lambda()
.eq(SysOrganizationPropertyEnt::getOuId, input.getId())
.le(SysOrganizationPropertyEnt::getEffectTime, new Date())
.ge(SysOrganizationPropertyEnt::getEndTime, new Date()));
propertyEnts.forEach(propertyEnt -> {
propertyEnt.setEndTime(new Date());
propertyEnt.setModifyTime(new Date());
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
propertyEnt.setModifyById(session.getId());
propertyEnt.setModifyByName(session.getUserName());
}
......@@ -1143,9 +1105,8 @@ public class SysOrganizationService {
public void insertSysOrganizationProperty(XContext context, Date date, String uuid, String mediaTypes, PpsUserSession session) {
//新增组织机构属性表
SysOrganizationPropertyMapper propertyMapper = context.getBean(SysOrganizationPropertyMapper.class);
String[] split = mediaTypes.split(",");
List<SysOrganizationPropertyEnt> list = new ArrayList<>();
for (String mediumType : split) {
for (String mediumType : CharSequenceUtil.splitToArray(mediaTypes, ',')) {
SysOrganizationPropertyEnt propertyEnt = new SysOrganizationPropertyEnt();
propertyEnt.setId(UUID.randomUUID().toString());
propertyEnt.setOuId(uuid);
......@@ -1156,16 +1117,16 @@ public class SysOrganizationService {
try {
propertyEnt.setEndTime(sdf.parse(datetime));
} catch (ParseException e) {
e.printStackTrace();
context.getLogger().error(e);
}
propertyEnt.setCreateTime(date);
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
propertyEnt.setCreateById(session.getId());
propertyEnt.setCreateByName(session.getUserName());
}
list.add(propertyEnt);
}
if (!CollectionUtils.isEmpty(list)) {
if (CollUtil.isNotEmpty(list)) {
list.forEach(propertyMapper::insert);
}
}
......@@ -1179,25 +1140,22 @@ public class SysOrganizationService {
relEnt.setId(UUID.randomUUID().toString());
relEnt.setOuId(ouId);
relEnt.setParentOuId(parentOuId);
QueryWrapper<SysOrganizationRelEnt> relWrapper = new QueryWrapper<>();
relWrapper.lambda().eq(SysOrganizationRelEnt::getOuId, parentOuId)
SysOrganizationRelEnt relEnt1 = relMapper.selectOne(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.eq(SysOrganizationRelEnt::getOuId, parentOuId)
.le(SysOrganizationRelEnt::getEffectTime, date)
.ge(true, SysOrganizationRelEnt::getEndTime, date);
SysOrganizationRelEnt relEnt1 = relMapper.selectOne(relWrapper);
if (relEnt1 == null) {
.ge(true, SysOrganizationRelEnt::getEndTime, date));
if (ObjectUtil.isNull(relEnt1)) {
relEnt.setOuIdPath(ouId);
} else {
String ouIdPath = relEnt1.getOuIdPath();
ouIdPath = ouIdPath + "/" + ouId;
relEnt.setOuIdPath(ouIdPath);
relEnt.setLevels(relEnt1.getLevels() == null ? 1 : relEnt1.getLevels() + 1);
relEnt.setOuIdPath(relEnt1.getOuIdPath() + "/" + ouId);
relEnt.setLevels(ObjectUtil.isNull(relEnt1.getLevels()) ? 1 : relEnt1.getLevels() + 1);
}
//如果用户不填写序号需要取表中最大的序号然后+1作为当前数据的序号
if (sort == null) {
if (ObjectUtil.isNull(sort)) {
SysOrganizationRelView relView = relViewMapper.selectMaxSort(parentOuId);
if (relView != null) {
Integer sort1 = relView.getSort();
relEnt.setSort(++sort1);
if (ObjectUtil.isNotNull(relView)) {
relEnt.setSort(relView.getSort() + 1);
} else {
relEnt.setSort(1);
}
......@@ -1210,10 +1168,10 @@ public class SysOrganizationService {
try {
relEnt.setEndTime(sdf.parse(datetime));
} catch (ParseException e) {
e.printStackTrace();
context.getLogger().error(e);
}
relEnt.setCreateTime(date);
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
relEnt.setCreateById(session.getId());
relEnt.setCreateByName(session.getUserName());
}
......@@ -1224,10 +1182,10 @@ public class SysOrganizationService {
public void updateSysOrganizationChildRel(XContext context, Date date, SysOrganizationRelEnt relEnt, PpsUserSession session) {
SysOrganizationRelMapper relMapper = context.getBean(SysOrganizationRelMapper.class);
QueryWrapper<SysOrganizationRelEnt> relWrapper = new QueryWrapper<>();
relWrapper.lambda().like(SysOrganizationRelEnt::getOuIdPath, relEnt.getOuId() + "/");
List<SysOrganizationRelEnt> childList = relMapper.selectList(relWrapper);
if (!CollectionUtils.isEmpty(childList)) {
List<SysOrganizationRelEnt> childList = relMapper.selectList(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.like(SysOrganizationRelEnt::getOuIdPath, relEnt.getOuId() + "/"));
if (CollUtil.isNotEmpty(childList)) {
childList.forEach(item -> {
int index = item.getOuIdPath().indexOf(relEnt.getOuId());
item.setOuIdPath(relEnt.getOuIdPath() + item.getOuIdPath().substring(index + relEnt.getOuId().length()));
......@@ -1245,24 +1203,24 @@ public class SysOrganizationService {
public XListResult<GetOuListTreeOutput> getOuListWithSelfAndAuth(XContext context, GetOuListWithSelfAndAuthInput input) {
PpsUserSession session = context.getSession(PpsUserSession.class);
String ouId = session.getOuId();
if (StringUtils.isBlank(ouId)) return XListResult.success();
if (CharSequenceUtil.isBlank(ouId)) return XListResult.success();
//根据组织机构id获取所有的子级组织机构
List<GetOuListTreeOutput> ouList = this.getAllOuListByOuId(context, ouId);
if (CollectionUtils.isEmpty(ouList)) return XListResult.success();
if (StringUtils.isBlank(input.getMenuId())) {
if (CollUtil.isEmpty(ouList)) return XListResult.success();
if (CharSequenceUtil.isBlank(input.getMenuId())) {
return XListResult.success(this.createOuTree(ouList));
}
//获取用户授权的组织机构
Map<String, List<SysOrganization>> pageOrgMap = session.getPageOrgMap();
if (pageOrgMap != null) {
if (CollUtil.isNotEmpty(pageOrgMap)) {
//获取当前用户在指定菜单下被授权的组织机构
List<SysOrganization> authList = pageOrgMap.get(input.getMenuId());
if (!CollectionUtils.isEmpty(authList)) {
if (CollUtil.isNotEmpty(authList)) {
List<String> authOutIds = new ArrayList<>();
for (SysOrganization auth : authList) {
boolean isAdd = true;
for (GetOuListTreeOutput ou : ouList) {
if (ou.getOuId().equals(auth.getOuId())) {
if (CharSequenceUtil.equals(ou.getOuId(), auth.getOuId())) {
isAdd = false;
break;
}
......@@ -1271,7 +1229,7 @@ public class SysOrganizationService {
authOutIds.add(auth.getOuId());
}
}
if (!authOutIds.isEmpty()) {
if (CollUtil.isNotEmpty(authOutIds)) {
List<GetOuListTreeOutput> resultAuthList = this.getOuListByOuIds(context, authOutIds);
ouList.addAll(resultAuthList);
}
......@@ -1290,7 +1248,7 @@ public class SysOrganizationService {
view.setIsDeleted(1);
view.setId(ouId);
List<SysOrganizationView> list = mapper.selectAllListByOuId(view);
if (!list.isEmpty()) {
if (CollUtil.isNotEmpty(list)) {
for (SysOrganizationView item : list) {
GetOuListTreeOutput out = new GetOuListTreeOutput();
out.setId(item.getId());
......@@ -1309,10 +1267,10 @@ public class SysOrganizationService {
*/
private List<GetOuListTreeOutput> getOuListByOuIds(XContext context, List<String> ouIds) {
List<GetOuListTreeOutput> outputs = new ArrayList<>();
if (CollectionUtils.isEmpty(ouIds)) return outputs;
if (CollUtil.isEmpty(ouIds)) return outputs;
SysOrganizationViewMapper mapper = context.getBean(SysOrganizationViewMapper.class);
List<SysOrganizationView> list = mapper.selectListByOuIds(ouIds);
if (!list.isEmpty()) {
if (CollUtil.isNotEmpty(list)) {
for (SysOrganizationView item : list) {
GetOuListTreeOutput out = new GetOuListTreeOutput();
out.setId(item.getId());
......@@ -1328,19 +1286,19 @@ public class SysOrganizationService {
public List<GetOuListTreeOutput> createOuTree(List<GetOuListTreeOutput> list) {
List<GetOuListTreeOutput> treeList = new ArrayList<>();
if (!list.isEmpty()) {
if (CollUtil.isNotEmpty(list)) {
for (GetOuListTreeOutput tree : list) {
boolean isHaveParent = false;
for (GetOuListTreeOutput item : list) {
//子集
if (tree.getOuId().equals(item.getParentOuId())) {
if (tree.getChildren() == null) {
if (CharSequenceUtil.equals(tree.getOuId(), item.getParentOuId())) {
if (CollUtil.isEmpty(tree.getChildren())) {
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(item);
}
//父集
if (tree.getParentOuId().equals(item.getOuId())) {
if (CharSequenceUtil.equals(tree.getParentOuId(), item.getOuId())) {
isHaveParent = true;
}
}
......
package pps.core.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.util.CollectionUtils;
import pps.core.common.session.PpsUserSession;
import pps.core.system.entity.SysRoleMenuAuthEnt;
import pps.core.system.entity.SysRoleMenuAuthView;
......@@ -42,33 +43,29 @@ public class SysRoleMenuAuthService {
return XTransactionHelper.begin(context, () -> {
//删除原关系
SysRoleMenuAuthMapper mapper = context.getBean(SysRoleMenuAuthMapper.class);
QueryWrapper<SysRoleMenuAuthEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysRoleMenuAuthEnt::getRoleId, input.getRoleId());
PageHelper.startPage(1, 1000);
List<SysRoleMenuAuthEnt> sysUserRoleRelEnts = mapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(sysUserRoleRelEnts)) {
List<String> collect = sysUserRoleRelEnts.stream().map(SysRoleMenuAuthEnt::getId).collect(Collectors.toList());
mapper.deleteBatchIds(collect);
List<SysRoleMenuAuthEnt> sysUserRoleRelEnts = mapper.selectList(new QueryWrapper<SysRoleMenuAuthEnt>()
.lambda()
.eq(SysRoleMenuAuthEnt::getRoleId, input.getRoleId()));
if (CollUtil.isNotEmpty(sysUserRoleRelEnts)) {
mapper.deleteBatchIds(sysUserRoleRelEnts.stream().map(SysRoleMenuAuthEnt::getId).collect(Collectors.toList()));
}
//创建新关系
PpsUserSession session = context.getSession(PpsUserSession.class);
SysRoleMenuAuthViewMapper viewMapper = context.getBean(SysRoleMenuAuthViewMapper.class);
List<String> menuIdList = input.getMenuIds();
Date now = new Date();
List<SysRoleMenuAuthView> viewList = new ArrayList<>();
for (String menuId : menuIdList) {
for (String menuId : input.getMenuIds()) {
SysRoleMenuAuthView entity = new SysRoleMenuAuthView();
entity.setId(UUID.randomUUID().toString());
entity.setMenuId(menuId);
entity.setRoleId(input.getRoleId());
PpsUserSession session = context.getSession(PpsUserSession.class);
if (session != null) {
entity.setCreateById(session.getId());
entity.setCreateByName(session.getUserName());
}
entity.setCreateTime(now);
viewList.add(entity);
}
if (!CollectionUtils.isEmpty(viewList)) {
if (CollUtil.isNotEmpty(viewList)) {
viewMapper.batchInsert(viewList);
}
//返回执行成功的结果,事务提交
......@@ -94,7 +91,7 @@ public class SysRoleMenuAuthService {
QueryWrapper<SysRoleMenuAuthEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysRoleMenuAuthEnt::getId, input.getId());
SysRoleMenuAuthEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -105,10 +102,10 @@ public class SysRoleMenuAuthService {
@XApiPost
public XServiceResult deleteSysRoleMenuAuth(XContext context, DeleteSysRoleMenuAuthInput input) {
SysRoleMenuAuthMapper mapper = context.getBean(SysRoleMenuAuthMapper.class);
QueryWrapper<SysRoleMenuAuthEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysRoleMenuAuthEnt::getId, input.getId());
SysRoleMenuAuthEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysRoleMenuAuthEnt entity = mapper.selectOne(new QueryWrapper<SysRoleMenuAuthEnt>()
.lambda()
.eq(SysRoleMenuAuthEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
mapper.deleteById(entity);
......@@ -118,10 +115,10 @@ public class SysRoleMenuAuthService {
@XApiGet
public XSingleResult<GetSysRoleMenuAuthOutput> getSysRoleMenuAuth(XContext context, GetSysRoleMenuAuthInput input) {
SysRoleMenuAuthMapper mapper = context.getBean(SysRoleMenuAuthMapper.class);
QueryWrapper<SysRoleMenuAuthEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysRoleMenuAuthEnt::getId, input.getId());
SysRoleMenuAuthEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysRoleMenuAuthEnt entity = mapper.selectOne(new QueryWrapper<SysRoleMenuAuthEnt>()
.lambda()
.eq(SysRoleMenuAuthEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysRoleMenuAuthOutput output = new GetSysRoleMenuAuthOutput();
......@@ -157,7 +154,7 @@ public class SysRoleMenuAuthService {
SysRoleMenuAuthView record = new SysRoleMenuAuthView();
XCopyUtils.copyObject(input, record);
SysRoleMenuAuthView view = mapper.selectOne(record);
if (view == null) {
if (ObjectUtil.isNull(view)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysRoleMenuAuthViewOutput output = new GetSysRoleMenuAuthViewOutput();
......
package pps.core.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import pps.cloud.system.service.SystemDictionaryService;
import pps.cloud.system.service.data.sys_dictionary.CreateSysDictionaryInput;
import pps.cloud.system.service.data.sys_dictionary.QuerySysDictionaryViewOutput;
......@@ -19,7 +20,6 @@ import xstartup.annotation.XText;
import xstartup.base.XContext;
import xstartup.base.exception.XServiceException;
import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XStringUtils;
import xstartup.data.XListResult;
import xstartup.data.XPageResult;
import xstartup.data.XServiceResult;
......@@ -27,7 +27,10 @@ import xstartup.error.XError;
import xstartup.feature.api.annotation.XApiPost;
import xstartup.helper.XTransactionHelper;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@XText("角色管理")
......@@ -45,11 +48,11 @@ public class SysRoleService {
PpsUserSession session = context.getSession(PpsUserSession.class);
//如果不是超级管理员只查询当前用户的组织机构下的角色以及上级可继承的角色
if (BusinessConstant.ZERO.equals(session.getIsSuperAdmin())) {
if (XStringUtils.isEmpty(input.getOuId())) {
if (CharSequenceUtil.isBlank(input.getOuId())) {
record.setOuId(session.getOuId());
input.setOuId(session.getOuId());
}
if (XStringUtils.isEmpty(input.getMediaType())) {
if (CharSequenceUtil.isBlank(input.getMediaType())) {
mediaTypeList.add("ALL");
//普通角色只查询所属企业的介质类型
SysOrganizationPropertyViewMapper mapper = context.getBean(SysOrganizationPropertyViewMapper.class);
......@@ -57,7 +60,7 @@ public class SysRoleService {
propertyView.setOuId(session.getOuId());
propertyView.setEndTime(new Date());
List<SysOrganizationPropertyView> propertyViews = mapper.selectList(propertyView);
if (!CollectionUtils.isEmpty(propertyViews)) {
if (CollUtil.isNotEmpty(propertyViews)) {
for (SysOrganizationPropertyView propertyEnt : propertyViews) {
mediaTypeList.add(propertyEnt.getPropertyValue());
}
......@@ -68,29 +71,29 @@ public class SysRoleService {
List<SysRoleView> list = viewMapper.selectSysRoleListByOuId(record);
long total;
//查询上级可继承的角色
if (XStringUtils.isNotEmpty(input.getOuId())) {
if (CharSequenceUtil.isNotBlank(input.getOuId())) {
Date date = new Date();
SysOrganizationRelMapper organizationRelMapper = context.getBean(SysOrganizationRelMapper.class);
QueryWrapper<SysOrganizationRelEnt> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(SysOrganizationRelEnt::getOuId, input.getOuId())
.le(true, SysOrganizationRelEnt::getEffectTime, date)
.ge(true, SysOrganizationRelEnt::getEndTime, date);
List<SysOrganizationRelEnt> ouRelEnts = organizationRelMapper.selectList(wrapper);
if (!CollectionUtils.isEmpty(ouRelEnts)) {
List<SysOrganizationRelEnt> ouRelEnts = organizationRelMapper.selectList(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.eq(SysOrganizationRelEnt::getOuId, input.getOuId())
.le(SysOrganizationRelEnt::getEffectTime, date)
.ge(SysOrganizationRelEnt::getEndTime, date));
if (CollUtil.isNotEmpty(ouRelEnts)) {
SysOrganizationRelEnt relEnt = ouRelEnts.get(0);
String ouIdPath = relEnt.getOuIdPath();
if (XStringUtils.isNotEmpty(ouIdPath)) {
String[] split = ouIdPath.split("/");
List<String> ouIds = Arrays.asList(split);
ouIds = ouIds.stream().filter(id -> !id.equals(input.getOuId())).collect(Collectors.toList());
if (CharSequenceUtil.isNotBlank(ouIdPath)) {
List<String> ouIds = CharSequenceUtil.split(ouIdPath, '/').stream()
.filter(id -> !CharSequenceUtil.equals(id, input.getOuId()))
.collect(Collectors.toList());
record.setOuIds(ouIds);
//下级单位是否可继承:0->否;1->是;
if (!ouIds.isEmpty()) {
if (XStringUtils.isNotEmpty(input.getMediaType())) {
if (CollUtil.isNotEmpty(ouIds)) {
if (CharSequenceUtil.isNotBlank(input.getMediaType())) {
record.setMediaType(input.getMediaType());
} else {
if (BusinessConstant.ZERO.equals(session.getIsSuperAdmin())) {
if (!CollectionUtils.isEmpty(mediaTypeList)) {
if (CollUtil.isNotEmpty(mediaTypeList)) {
record.setMediaTypes(mediaTypeList);
}
}
......@@ -104,7 +107,7 @@ public class SysRoleService {
}
List<String> ouIds = new ArrayList<>();
for (SysRoleView roleView : list) {
if (XStringUtils.isNotEmpty(roleView.getOuId())) {
if (CharSequenceUtil.isNotBlank(roleView.getOuId())) {
ouIds.add(roleView.getOuId());
}
}
......@@ -114,13 +117,13 @@ public class SysRoleService {
XListResult<QuerySysDictionaryViewOutput> mediaTypes = dictService.querySysDictionarysByAlias(context, mediaTypesInput);
Date date = new Date();
List<SysOrganizationRelEnt> ouRelEnts = new ArrayList<>();
if (!CollectionUtils.isEmpty(ouIds)) {
if (CollUtil.isNotEmpty(ouIds)) {
SysOrganizationRelMapper organizationRelMapper = context.getBean(SysOrganizationRelMapper.class);
QueryWrapper<SysOrganizationRelEnt> wrapper = new QueryWrapper<>();
wrapper.lambda().in(SysOrganizationRelEnt::getOuId, ouIds)
.le(true, SysOrganizationRelEnt::getEffectTime, date)
.ge(true, SysOrganizationRelEnt::getEndTime, date);
ouRelEnts = organizationRelMapper.selectList(wrapper);
ouRelEnts = organizationRelMapper.selectList(new QueryWrapper<SysOrganizationRelEnt>()
.lambda()
.in(SysOrganizationRelEnt::getOuId, ouIds)
.le(SysOrganizationRelEnt::getEffectTime, date)
.ge(SysOrganizationRelEnt::getEndTime, date));
}
total = list.size();
Integer page = input.getPage() - 1;
......@@ -131,41 +134,36 @@ public class SysRoleService {
}
List<QuerySysRoleViewOutput> outputs = XCopyUtils.copyNewList(list, QuerySysRoleViewOutput.class);
for (QuerySysRoleViewOutput view : outputs) {
if (!CollectionUtils.isEmpty(ouRelEnts)) {
if (CollUtil.isNotEmpty(ouRelEnts)) {
for (SysOrganizationRelEnt ouRelEnt : ouRelEnts) {
if (ouRelEnt.getOuId().equals(view.getOuId())) {
if (CharSequenceUtil.equals(ouRelEnt.getOuId(), view.getOuId())) {
view.setParentOuId(ouRelEnt.getParentOuId());
}
}
}
//查询系统管理员角色,如果true的话不可以删除
String value = LoginConfig.adminRoles.findValue(context);
if (StringUtils.isNotBlank(value) && value.contains(view.getId())) {
if (CharSequenceUtil.isNotBlank(value) && CharSequenceUtil.contains(value, view.getId())) {
view.setSysAdmin(true);
} else {
view.setSysAdmin(false);
}
//介质类型
if (view.getMediaType() != null) {
if (mediaTypes.getResult() != null) {
List<QuerySysDictionaryViewOutput> items = mediaTypes.getResult();
String[] split = view.getMediaType().split(",");
if (CharSequenceUtil.isNotBlank(view.getMediaType())) {
if (CollUtil.isNotEmpty(mediaTypes.getResult())) {
StringBuilder buffer = new StringBuilder();
for (String mediaType : split) {
for (QuerySysDictionaryViewOutput item : items) {
for (String mediaType : CharSequenceUtil.splitToArray(view.getMediaType(), ',')) {
for (QuerySysDictionaryViewOutput item : mediaTypes.getResult()) {
if (mediaType.equals(item.getDicKey())) {
buffer.append(",");
buffer.append(item.getDicName());
buffer.append(",").append(item.getDicName());
}
}
}
if (buffer.length() > 0) {
String mediaTypeName = buffer.substring(1);
view.setMediaTypeName(mediaTypeName);
view.setMediaTypeName(buffer.substring(1));
}
}
if (view.getMediaTypeName() == null) {
if (CharSequenceUtil.isBlank(view.getMediaTypeName())) {
view.setMediaTypeName(view.getMediaType());
}
}
......@@ -181,11 +179,11 @@ public class SysRoleService {
SysRoleMapper mapper = context.getBean(SysRoleMapper.class);
QueryWrapper<SysRoleEnt> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(SysRoleEnt::getRoleName, input.getRoleName());
if (XStringUtils.isNotEmpty(input.getOuId())) {
if (CharSequenceUtil.isNotBlank(input.getOuId())) {
wrapper.lambda().eq(SysRoleEnt::getOuId, input.getOuId());
}
List<SysRoleEnt> sysRoleEnts = mapper.selectList(wrapper);
if (!CollectionUtils.isEmpty(sysRoleEnts)) {
if (CollUtil.isNotEmpty(sysRoleEnts)) {
return XServiceResult.error(200, "角色名称已存在!");
}
XCopyUtils.copyObject(input, entity);
......@@ -196,7 +194,7 @@ public class SysRoleService {
entity.setCreateByName(session.getUserName());
entity.setCreateById(session.getId());
//用户不选的话需要绑定为当前操作员的组织机构
if (XStringUtils.isEmpty(entity.getOuId())) {
if (CharSequenceUtil.isBlank(entity.getOuId())) {
entity.setOuId(session.getOuId());
}
try {
......@@ -214,20 +212,20 @@ public class SysRoleService {
public XServiceResult updateSysRole(XContext context, UpdateSysRoleInput input) throws XServiceException {
return XTransactionHelper.begin(context, () -> {
SysRoleMapper mapper = context.getBean(SysRoleMapper.class);
QueryWrapper<SysRoleEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysRoleEnt::getId, input.getId());
SysRoleEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysRoleEnt entity = mapper.selectOne(new QueryWrapper<SysRoleEnt>()
.lambda()
.eq(SysRoleEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
if (!entity.getRoleName().equals(input.getRoleName())) {
if (!CharSequenceUtil.equals(entity.getRoleName(), input.getRoleName())) {
QueryWrapper<SysRoleEnt> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(SysRoleEnt::getRoleName, input.getRoleName());
if (XStringUtils.isNotEmpty(input.getOuId())) {
if (CharSequenceUtil.isNotBlank(input.getOuId())) {
wrapper.lambda().eq(SysRoleEnt::getOuId, input.getOuId());
}
List<SysRoleEnt> sysRoleEnts = mapper.selectList(wrapper);
if (!CollectionUtils.isEmpty(sysRoleEnts)) {
if (CollUtil.isNotEmpty(sysRoleEnts)) {
return XServiceResult.error(200, "角色名称已存在!");
}
}
......@@ -248,20 +246,20 @@ public class SysRoleService {
return XTransactionHelper.begin(context, () -> {
SysRoleMapper mapper = context.getBean(SysRoleMapper.class);
SysUserRoleRelMapper relMapper = context.getBean(SysUserRoleRelMapper.class);
QueryWrapper<SysRoleEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysRoleEnt::getId, input.getId());
SysRoleEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysRoleEnt entity = mapper.selectOne(new QueryWrapper<SysRoleEnt>()
.lambda()
.eq(SysRoleEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
String value = LoginConfig.adminRoles.findValue(context);
if (StringUtils.isNotBlank(value) && value.contains(entity.getId())) {
if (CharSequenceUtil.isNotBlank(value) && CharSequenceUtil.contains(value, entity.getId())) {
return XServiceResult.error(200, "此角色是管理员角色,请勿删除!");
}
QueryWrapper<SysUserRoleRelEnt> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(SysUserRoleRelEnt::getRoleId, entity.getId());
List<SysUserRoleRelEnt> relEnts = relMapper.selectList(wrapper);
if (!CollectionUtils.isEmpty(relEnts)) {
List<SysUserRoleRelEnt> relEnts = relMapper.selectList(new QueryWrapper<SysUserRoleRelEnt>()
.lambda()
.eq(SysUserRoleRelEnt::getRoleId, entity.getId()));
if (CollUtil.isNotEmpty(relEnts)) {
List<String> collect = relEnts.stream().map(SysUserRoleRelEnt::getId).collect(Collectors.toList());
relMapper.deleteBatchIds(collect);
}
......@@ -277,7 +275,7 @@ public class SysRoleService {
SysRoleViewMapper viewMapper = context.getBean(SysRoleViewMapper.class);
SysRoleView record = new SysRoleView();
XCopyUtils.copyObject(input, record);
if (input.getShowAll() != null && input.getShowAll()) {
if (ObjectUtil.isNotNull(input.getShowAll()) && input.getShowAll()) {
record.setOuId(null);
}
PageHelper.startPage(input.getPage(), input.getLimit());
......
package pps.core.system.service;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
......@@ -37,10 +38,10 @@ public class SysUserGroupRoleRelService {
@XApiPost
public XServiceResult updateSysUserGroupRoleRel(XContext context, UpdateSysUserGroupRoleRelInput input) {
SysUserGroupRoleRelMapper mapper = context.getBean(SysUserGroupRoleRelMapper.class);
QueryWrapper<SysUserGroupRoleRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserGroupRoleRelEnt::getId, input.getId());
SysUserGroupRoleRelEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysUserGroupRoleRelEnt entity = mapper.selectOne(new QueryWrapper<SysUserGroupRoleRelEnt>()
.lambda()
.eq(SysUserGroupRoleRelEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -51,10 +52,10 @@ public class SysUserGroupRoleRelService {
@XApiPost
public XServiceResult deleteSysUserGroupRoleRel(XContext context, DeleteSysUserGroupRoleRelInput input) {
SysUserGroupRoleRelMapper mapper = context.getBean(SysUserGroupRoleRelMapper.class);
QueryWrapper<SysUserGroupRoleRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserGroupRoleRelEnt::getId, input.getId());
SysUserGroupRoleRelEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysUserGroupRoleRelEnt entity = mapper.selectOne(new QueryWrapper<SysUserGroupRoleRelEnt>()
.lambda()
.eq(SysUserGroupRoleRelEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
mapper.deleteById(entity);
......@@ -64,10 +65,10 @@ public class SysUserGroupRoleRelService {
@XApiPost
public XSingleResult<GetSysUserGroupRoleRelOutput> getSysUserGroupRoleRel(XContext context, GetSysUserGroupRoleRelInput input) {
SysUserGroupRoleRelMapper mapper = context.getBean(SysUserGroupRoleRelMapper.class);
QueryWrapper<SysUserGroupRoleRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserGroupRoleRelEnt::getId, input.getId());
SysUserGroupRoleRelEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysUserGroupRoleRelEnt entity = mapper.selectOne(new QueryWrapper<SysUserGroupRoleRelEnt>()
.lambda().
eq(SysUserGroupRoleRelEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysUserGroupRoleRelOutput output = new GetSysUserGroupRoleRelOutput();
......@@ -103,7 +104,7 @@ public class SysUserGroupRoleRelService {
SysUserGroupRoleRelView record = new SysUserGroupRoleRelView();
XCopyUtils.copyObject(input, record);
SysUserGroupRoleRelView view = mapper.selectOne(record);
if (view == null) {
if (ObjectUtil.isNull(view)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysUserGroupRoleRelViewOutput output = new GetSysUserGroupRoleRelViewOutput();
......
package pps.core.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import pps.core.system.entity.*;
import pps.core.system.mapper.*;
import pps.core.system.service.data.sys_auth_ou_scope.CreateSysAuthOuScopeInput;
......@@ -57,13 +57,12 @@ public class SysUserGroupService {
SysUserGroupRoleRelMapper userGroupWithRole = context.getBean(SysUserGroupRoleRelMapper.class);
SysUserGroupRoleRelViewMapper viewUserGroupWithRole = context.getBean(SysUserGroupRoleRelViewMapper.class);
//删除原关系
QueryWrapper<SysUserGroupRoleRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserGroupRoleRelEnt::getUserGroupId, input.getUserGroupId());
PageHelper.startPage(1, 1000);
List<SysUserGroupRoleRelEnt> sysUserGroupRoleRelEnts = userGroupWithRole.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(sysUserGroupRoleRelEnts)) {
List<String> collect = sysUserGroupRoleRelEnts.stream().map(SysUserGroupRoleRelEnt::getId).collect(Collectors.toList());
userGroupWithRole.deleteBatchIds(collect);
List<SysUserGroupRoleRelEnt> sysUserGroupRoleRelEnts = userGroupWithRole.selectList(new QueryWrapper<SysUserGroupRoleRelEnt>()
.lambda()
.eq(SysUserGroupRoleRelEnt::getUserGroupId, input.getUserGroupId()));
if (CollUtil.isNotEmpty(sysUserGroupRoleRelEnts)) {
userGroupWithRole.deleteBatchIds(sysUserGroupRoleRelEnts.stream().map(SysUserGroupRoleRelEnt::getId).collect(Collectors.toList()));
}
//创建新关系
List<String> items = input.getItems();
......@@ -78,7 +77,7 @@ public class SysUserGroupService {
entity.setCreateTime(now);
viewList.add(entity);
}
if (ObjectUtils.isNotEmpty(viewList)) {
if (CollUtil.isNotEmpty(viewList)) {
viewUserGroupWithRole.batchInsert(viewList);
}
return XServiceResult.OK;
......@@ -92,13 +91,12 @@ public class SysUserGroupService {
SysAuthOuScopeMapper userGroupWithRole = context.getBean(SysAuthOuScopeMapper.class);
SysAuthOuScopeViewMapper viewUserGroupWithRole = context.getBean(SysAuthOuScopeViewMapper.class);
//删除原关系
QueryWrapper<SysAuthOuScopeEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysAuthOuScopeEnt::getUserGroupId, input.getUserGroupId());
PageHelper.startPage(1, 1000);
List<SysAuthOuScopeEnt> sysAuthOuScopeEnts = userGroupWithRole.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(sysAuthOuScopeEnts)) {
List<String> collect = sysAuthOuScopeEnts.stream().map(SysAuthOuScopeEnt::getId).collect(Collectors.toList());
userGroupWithRole.deleteBatchIds(collect);
List<SysAuthOuScopeEnt> sysAuthOuScopeEnts = userGroupWithRole.selectList(new QueryWrapper<SysAuthOuScopeEnt>()
.lambda()
.eq(SysAuthOuScopeEnt::getUserGroupId, input.getUserGroupId()));
if (CollUtil.isNotEmpty(sysAuthOuScopeEnts)) {
userGroupWithRole.deleteBatchIds(sysAuthOuScopeEnts.stream().map(SysAuthOuScopeEnt::getId).collect(Collectors.toList()));
}
//创建新关系
List<SysAuthOuScopeView> viewList = new ArrayList<>();
......@@ -117,7 +115,7 @@ public class SysUserGroupService {
viewList.add(entity);
}
}
if (ObjectUtils.isNotEmpty(viewList)) {
if (CollUtil.isNotEmpty(viewList)) {
viewUserGroupWithRole.batchInsert(viewList);
}
return XServiceResult.OK;
......@@ -131,13 +129,12 @@ public class SysUserGroupService {
SysUserWithUserGroupRelMapper userGroupWithRole = context.getBean(SysUserWithUserGroupRelMapper.class);
SysUserWithUserGroupRelViewMapper userWithUserGroupRelViewMapper = context.getBean(SysUserWithUserGroupRelViewMapper.class);
//删除原关系
QueryWrapper<SysUserWithUserGroupRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserWithUserGroupRelEnt::getUserGroupId, input.getUserGroupId());
PageHelper.startPage(1, 1000);
List<SysUserWithUserGroupRelEnt> sysAuthOuScopeEnts = userGroupWithRole.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(sysAuthOuScopeEnts)) {
List<String> collect = sysAuthOuScopeEnts.stream().map(SysUserWithUserGroupRelEnt::getId).collect(Collectors.toList());
userGroupWithRole.deleteBatchIds(collect);
List<SysUserWithUserGroupRelEnt> sysAuthOuScopeEnts = userGroupWithRole.selectList(new QueryWrapper<SysUserWithUserGroupRelEnt>()
.lambda()
.eq(SysUserWithUserGroupRelEnt::getUserGroupId, input.getUserGroupId()));
if (CollUtil.isNotEmpty(sysAuthOuScopeEnts)) {
userGroupWithRole.deleteBatchIds(sysAuthOuScopeEnts.stream().map(SysUserWithUserGroupRelEnt::getId).collect(Collectors.toList()));
}
//创建新关系
List<SysUserWithUserGroupRelView> items = input.getItems();
......@@ -152,7 +149,7 @@ public class SysUserGroupService {
entity.setCreateTime(now);
viewList.add(entity);
}
if (ObjectUtils.isNotEmpty(viewList)) {
if (CollUtil.isNotEmpty(viewList)) {
userWithUserGroupRelViewMapper.batchInsert(viewList);
}
return XServiceResult.OK;
......@@ -163,10 +160,10 @@ public class SysUserGroupService {
@XApiPost
public XServiceResult updateSysUserGroup(XContext context, UpdateSysUserGroupInput input) {
SysUserGroupMapper mapper = context.getBean(SysUserGroupMapper.class);
QueryWrapper<SysUserGroupEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserGroupEnt::getId, input.getId());
SysUserGroupEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysUserGroupEnt entity = mapper.selectOne(new QueryWrapper<SysUserGroupEnt>()
.lambda()
.eq(SysUserGroupEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -179,39 +176,39 @@ public class SysUserGroupService {
public XServiceResult deleteSysUserGroup(XContext context, DeleteSysUserGroupInput input) {
return XTransactionHelper.begin(context, () -> {
SysUserGroupMapper mapper = context.getBean(SysUserGroupMapper.class);
SysUserGroupRoleRelMapper groupRoleMapper = context.getBean(SysUserGroupRoleRelMapper.class);
SysAuthOuScopeMapper groupMenuMapper = context.getBean(SysAuthOuScopeMapper.class);
SysUserWithUserGroupRelMapper groupUserMapper = context.getBean(SysUserWithUserGroupRelMapper.class);
QueryWrapper<SysUserGroupEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserGroupEnt::getId, input.getId());
SysUserGroupEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysUserGroupEnt entity = mapper.selectOne(new QueryWrapper<SysUserGroupEnt>()
.lambda()
.eq(SysUserGroupEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
mapper.deleteById(entity);
//删除角色用户组信息
QueryWrapper<SysUserGroupRoleRelEnt> roleWrapper = new QueryWrapper<>();
roleWrapper.lambda().eq(SysUserGroupRoleRelEnt::getUserGroupId, entity.getId());
List<SysUserGroupRoleRelEnt> sysUserGroupEnts = groupRoleMapper.selectList(roleWrapper);
if (sysUserGroupEnts != null && !sysUserGroupEnts.isEmpty()) {
SysUserGroupRoleRelMapper groupRoleMapper = context.getBean(SysUserGroupRoleRelMapper.class);
List<SysUserGroupRoleRelEnt> sysUserGroupEnts = groupRoleMapper.selectList(new QueryWrapper<SysUserGroupRoleRelEnt>()
.lambda()
.eq(SysUserGroupRoleRelEnt::getUserGroupId, entity.getId()));
if (CollUtil.isNotEmpty(sysUserGroupEnts)) {
for (SysUserGroupRoleRelEnt obj : sysUserGroupEnts) {
mapper.deleteById(obj);
}
}
//删除菜单用户组信息
QueryWrapper<SysAuthOuScopeEnt> menuWrapper = new QueryWrapper<>();
menuWrapper.lambda().eq(SysAuthOuScopeEnt::getUserGroupId, entity.getId());
List<SysAuthOuScopeEnt> menuGroupEnts = groupMenuMapper.selectList(menuWrapper);
if (menuGroupEnts != null && !menuGroupEnts.isEmpty()) {
SysAuthOuScopeMapper groupMenuMapper = context.getBean(SysAuthOuScopeMapper.class);
List<SysAuthOuScopeEnt> menuGroupEnts = groupMenuMapper.selectList(new QueryWrapper<SysAuthOuScopeEnt>()
.lambda()
.eq(SysAuthOuScopeEnt::getUserGroupId, entity.getId()));
if (CollUtil.isNotEmpty(menuGroupEnts)) {
for (SysAuthOuScopeEnt obj : menuGroupEnts) {
groupMenuMapper.deleteById(obj);
}
}
//删除用户用户组信息
QueryWrapper<SysUserWithUserGroupRelEnt> userWrapper = new QueryWrapper<>();
userWrapper.lambda().eq(SysUserWithUserGroupRelEnt::getUserGroupId, entity.getId());
List<SysUserWithUserGroupRelEnt> userGroupEnts = groupUserMapper.selectList(userWrapper);
if (userGroupEnts != null && !userGroupEnts.isEmpty()) {
SysUserWithUserGroupRelMapper groupUserMapper = context.getBean(SysUserWithUserGroupRelMapper.class);
List<SysUserWithUserGroupRelEnt> userGroupEnts = groupUserMapper.selectList(new QueryWrapper<SysUserWithUserGroupRelEnt>()
.lambda()
.eq(SysUserWithUserGroupRelEnt::getUserGroupId, entity.getId()));
if (CollUtil.isNotEmpty(userGroupEnts)) {
for (SysUserWithUserGroupRelEnt obj : userGroupEnts) {
groupUserMapper.deleteById(obj);
}
......@@ -224,10 +221,10 @@ public class SysUserGroupService {
@XApiPost
public XSingleResult<GetSysUserGroupOutput> getSysUserGroup(XContext context, GetSysUserGroupInput input) {
SysUserGroupMapper mapper = context.getBean(SysUserGroupMapper.class);
QueryWrapper<SysUserGroupEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserGroupEnt::getId, input.getId());
SysUserGroupEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysUserGroupEnt entity = mapper.selectOne(new QueryWrapper<SysUserGroupEnt>()
.lambda()
.eq(SysUserGroupEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysUserGroupOutput output = new GetSysUserGroupOutput();
......@@ -240,10 +237,10 @@ public class SysUserGroupService {
public XPageResult<QuerySysUserGroupOutput> querySysUserGroup(XContext context, QuerySysUserGroupInput input) {
SysUserGroupMapper mapper = context.getBean(SysUserGroupMapper.class);
QueryWrapper<SysUserGroupEnt> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotBlank(input.getUserGroupName())) {
if (CharSequenceUtil.isNotBlank(input.getUserGroupName())) {
queryWrapper.lambda().like(SysUserGroupEnt::getUserGroupName, input.getUserGroupName());
}
if (StringUtils.isNotBlank(input.getOuId())) {
if (CharSequenceUtil.isNotBlank(input.getOuId())) {
queryWrapper.lambda().like(SysUserGroupEnt::getOuId, input.getOuId());
}
return XMapperHelper.query(mapper, input, queryWrapper, QuerySysUserGroupOutput.class);
......@@ -261,7 +258,7 @@ public class SysUserGroupService {
SysUserGroupView record = new SysUserGroupView();
XCopyUtils.copyObject(input, record);
SysUserGroupView view = mapper.selectOne(record);
if (view == null) {
if (ObjectUtil.isNull(view)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysUserGroupViewOutput output = new GetSysUserGroupViewOutput();
......
package pps.core.system.service;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
......@@ -36,10 +37,10 @@ public class SysUserOrganizationRelService {
@XApiPost
public XServiceResult updateSysUserOrganizationRel(XContext context, UpdateSysUserOrganizationRelInput input) {
SysUserOrganizationRelMapper mapper = context.getBean(SysUserOrganizationRelMapper.class);
QueryWrapper<SysUserOrganizationRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserOrganizationRelEnt::getId, input.getId());
SysUserOrganizationRelEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysUserOrganizationRelEnt entity = mapper.selectOne(new QueryWrapper<SysUserOrganizationRelEnt>()
.lambda()
.eq(SysUserOrganizationRelEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
XCopyUtils.copyObject(input, entity);
......@@ -50,10 +51,10 @@ public class SysUserOrganizationRelService {
@XApiPost
public XServiceResult deleteSysUserOrganizationRel(XContext context, DeleteSysUserOrganizationRelInput input) {
SysUserOrganizationRelMapper mapper = context.getBean(SysUserOrganizationRelMapper.class);
QueryWrapper<SysUserOrganizationRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserOrganizationRelEnt::getId, input.getId());
SysUserOrganizationRelEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysUserOrganizationRelEnt entity = mapper.selectOne(new QueryWrapper<SysUserOrganizationRelEnt>()
.lambda()
.eq(SysUserOrganizationRelEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
mapper.deleteById(entity);
......@@ -66,7 +67,7 @@ public class SysUserOrganizationRelService {
QueryWrapper<SysUserOrganizationRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserOrganizationRelEnt::getId, input.getId());
SysUserOrganizationRelEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
if (ObjectUtil.isNull(entity)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysUserOrganizationRelOutput output = new GetSysUserOrganizationRelOutput();
......@@ -102,7 +103,7 @@ public class SysUserOrganizationRelService {
SysUserOrganizationRelView record = new SysUserOrganizationRelView();
XCopyUtils.copyObject(input, record);
SysUserOrganizationRelView view = mapper.selectOne(record);
if (view == null) {
if (ObjectUtil.isNull(view)) {
return XSingleResult.error(context, XError.NotFound);
}
GetSysUserOrganizationRelViewOutput output = new GetSysUserOrganizationRelViewOutput();
......
package pps.core.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.util.CollectionUtils;
import pps.core.common.constant.BusinessConstant;
import pps.core.common.session.PpsUserSession;
import pps.core.system.entity.SysOrganizationView;
......@@ -18,7 +19,6 @@ import xstartup.annotation.XText;
import xstartup.base.XContext;
import xstartup.base.exception.XServiceException;
import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XStringUtils;
import xstartup.data.XListResult;
import xstartup.data.XPageResult;
import xstartup.data.XServiceResult;
......@@ -42,30 +42,29 @@ public class SysUserRoleRelService {
return XTransactionHelper.begin(context, () -> {
//删除原关系
SysUserRoleRelMapper mapper = context.getBean(SysUserRoleRelMapper.class);
QueryWrapper<SysUserRoleRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserRoleRelEnt::getUserId, input.getUserId());
List<SysUserRoleRelEnt> sysUserRoleRelEnts = mapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(sysUserRoleRelEnts)) {
List<String> collect = sysUserRoleRelEnts.stream().map(SysUserRoleRelEnt::getId).collect(Collectors.toList());
mapper.deleteBatchIds(collect);
List<SysUserRoleRelEnt> sysUserRoleRelEnts = mapper.selectList(new QueryWrapper<SysUserRoleRelEnt>()
.lambda()
.eq(SysUserRoleRelEnt::getUserId, input.getUserId()));
if (CollUtil.isNotEmpty(sysUserRoleRelEnts)) {
mapper.deleteBatchIds(sysUserRoleRelEnts.stream().map(SysUserRoleRelEnt::getId).collect(Collectors.toList()));
}
//创建新关系
SysUserRoleRelViewMapper viewMapper = context.getBean(SysUserRoleRelViewMapper.class);
List<String> roleIdList = input.getRoleIdList();
Date now = new Date();
List<SysUserRoleRelView> viewList = new ArrayList<>();
PpsUserSession session = context.getSession(PpsUserSession.class);
for (String roleId : roleIdList) {
SysUserRoleRelView entity = new SysUserRoleRelView();
entity.setId(UUID.randomUUID().toString());
entity.setUserId(input.getUserId());
entity.setRoleId(roleId);
PpsUserSession session = context.getSession(PpsUserSession.class);
entity.setCreateById(session.getId());
entity.setCreateByName(session.getUserName());
entity.setCreateTime(now);
viewList.add(entity);
}
if (!CollectionUtils.isEmpty(viewList)) {
if (CollUtil.isNotEmpty(viewList)) {
viewMapper.batchInsert(viewList);
}
//返回执行成功的结果,事务提交
......@@ -80,41 +79,40 @@ public class SysUserRoleRelService {
return XTransactionHelper.begin(context, () -> {
//查询原关系
SysUserRoleRelMapper mapper = context.getBean(SysUserRoleRelMapper.class);
QueryWrapper<SysUserRoleRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserRoleRelEnt::getRoleId, input.getRoleId());
List<String> userIds = input.getUserIdList().stream().map(SysUserRoleRelEnt::getId).collect(Collectors.toList());
queryWrapper.lambda().in(SysUserRoleRelEnt::getUserId, userIds);
List<SysUserRoleRelEnt> sysUserRoleRelEnts = mapper.selectList(queryWrapper);
List<SysUserRoleRelEnt> sysUserRoleRelEnts = mapper.selectList(new QueryWrapper<SysUserRoleRelEnt>()
.lambda()
.eq(SysUserRoleRelEnt::getRoleId, input.getRoleId())
.in(SysUserRoleRelEnt::getUserId, input.getUserIdList().stream()
.map(SysUserRoleRelEnt::getId).collect(Collectors.toList())));
//创建新关系
SysUserRoleRelViewMapper viewMapper = context.getBean(SysUserRoleRelViewMapper.class);
List<SysUserRoleRelEnt> userIdList = input.getUserIdList();
Date now = new Date();
List<SysUserRoleRelView> viewList = new ArrayList<>();
List<SysUserRoleRelEnt> entList = new ArrayList<>();
PpsUserSession session = context.getSession(PpsUserSession.class);
for (SysUserRoleRelEnt user : userIdList) {
SysUserRoleRelView entity = new SysUserRoleRelView();
entity.setId(UUID.randomUUID().toString());
entity.setUserId(user.getId());
entity.setRoleId(input.getRoleId());
PpsUserSession session = context.getSession(PpsUserSession.class);
entity.setCreateById(session.getId());
entity.setCreateByName(session.getUserName());
entity.setCreateTime(now);
viewList.add(entity);
//同一个用户添加多次删除调旧的
for (SysUserRoleRelEnt roleRelEnt : sysUserRoleRelEnts) {
if (roleRelEnt.getUserId().equals(user.getId())) {
if (CharSequenceUtil.equals(roleRelEnt.getUserId(), user.getId())) {
entList.add(roleRelEnt);
break;
}
}
}
if (!CollectionUtils.isEmpty(viewList)) {
if (CollUtil.isNotEmpty(viewList)) {
viewMapper.batchInsert(viewList);
}
if (!CollectionUtils.isEmpty(entList)) {
List<String> collect = entList.stream().map(SysUserRoleRelEnt::getId).collect(Collectors.toList());
mapper.deleteBatchIds(collect);
if (CollUtil.isNotEmpty(entList)) {
mapper.deleteBatchIds(entList.stream().map(SysUserRoleRelEnt::getId).collect(Collectors.toList()));
}
//返回执行成功的结果,事务提交
return XServiceResult.OK;
......@@ -139,11 +137,9 @@ public class SysUserRoleRelService {
SysUserRoleRelView record = new SysUserRoleRelView();
XCopyUtils.copyObject(input, record);
PageHelper.startPage(input.getPage(), input.getLimit());
PpsUserSession session = context.getSession(PpsUserSession.class);
Integer isSuperAdmin = session.getIsSuperAdmin();
List<SysUserRoleRelView> list;
record.setEndTime(new Date());
if (XStringUtils.isNotEmpty(input.getOuId())) {
if (CharSequenceUtil.isNotBlank(input.getOuId())) {
List<String> ouIds = new ArrayList<>();
ouIds.add(input.getOuId());
record.setOuIds(ouIds);
......@@ -152,6 +148,8 @@ public class SysUserRoleRelService {
List<QuerySysUserRoleRelViewOutput> outputs = XCopyUtils.copyNewList(pageInfo.getList(), QuerySysUserRoleRelViewOutput.class);
return XPageResult.success(outputs, input, pageInfo.getTotal());
}
PpsUserSession session = context.getSession(PpsUserSession.class);
Integer isSuperAdmin = session.getIsSuperAdmin();
if (BusinessConstant.ZERO.equals(isSuperAdmin)) {
//查询当前用户所属组织机构的子级
SysOrganizationViewMapper sysOrganizationViewMapper = context.getBean(SysOrganizationViewMapper.class);
......@@ -161,7 +159,7 @@ public class SysUserRoleRelService {
sysOrganizationView.setParentOuId(session.getOuId());
List<SysOrganizationView> viewList = sysOrganizationViewMapper.selectOuSonByParentOuId(sysOrganizationView);
List<String> ouIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(viewList)) {
if (CollUtil.isNotEmpty(viewList)) {
for (SysOrganizationView organizationView : viewList) {
ouIds.add(organizationView.getId());
}
......@@ -182,12 +180,11 @@ public class SysUserRoleRelService {
public XServiceResult deleteSysUserRoleRel(XContext context, DeleteSysUserRoleRelOutput input) throws XServiceException {
return XTransactionHelper.begin(context, () -> {
SysUserRoleRelMapper mapper = context.getBean(SysUserRoleRelMapper.class);
QueryWrapper<SysUserRoleRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().in(SysUserRoleRelEnt::getId, input.getIds());
List<SysUserRoleRelEnt> relEnts = mapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(relEnts)) {
List<String> collect = relEnts.stream().map(SysUserRoleRelEnt::getId).collect(Collectors.toList());
mapper.deleteBatchIds(collect);
List<SysUserRoleRelEnt> relEnts = mapper.selectList(new QueryWrapper<SysUserRoleRelEnt>()
.lambda()
.in(SysUserRoleRelEnt::getId, input.getIds()));
if (CollUtil.isNotEmpty(relEnts)) {
mapper.deleteBatchIds(relEnts.stream().map(SysUserRoleRelEnt::getId).collect(Collectors.toList()));
}
//返回执行成功的结果,事务提交
return XServiceResult.OK;
......
......@@ -26,9 +26,9 @@ public class SysUserRoleRelServiceImpl implements SystemUserRoleRelService {
@XText("获取用户角色")
public XListResult<GetSysUserRoleRelOutput> getSysRoleByUserId(XContext context, GetSysUserRoleRelInput input) {
SysUserRoleRelMapper mapper = context.getBean(SysUserRoleRelMapper.class);
QueryWrapper<SysUserRoleRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserRoleRelEnt::getUserId, input.getUserId());
List<SysUserRoleRelEnt> list = mapper.selectList(queryWrapper);
List<SysUserRoleRelEnt> list = mapper.selectList(new QueryWrapper<SysUserRoleRelEnt>()
.lambda()
.eq(SysUserRoleRelEnt::getUserId, input.getUserId()));
List<GetSysUserRoleRelOutput> outputs = XCopyUtils.copyNewList(list, GetSysUserRoleRelOutput.class);
return XListResult.success(outputs);
}
......
package pps.core.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.Strings;
import org.springframework.util.CollectionUtils;
import pps.core.common.constant.BusinessConstant;
import pps.core.common.session.PpsUserSession;
import pps.core.system.entity.*;
......@@ -17,7 +17,6 @@ import xstartup.annotation.XText;
import xstartup.base.XContext;
import xstartup.base.exception.XServiceException;
import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XStringUtils;
import xstartup.data.XPageResult;
import xstartup.data.XServiceResult;
import xstartup.error.XError;
......@@ -47,12 +46,12 @@ public class SysUserService {
record.setEndTime(new Date());
PpsUserSession session = context.getSession(PpsUserSession.class);
if (BusinessConstant.ZERO.equals(session.getIsSuperAdmin())) {
if (XStringUtils.isEmpty(input.getOuId())) {
if (CharSequenceUtil.isBlank(input.getOuId())) {
record.setOuId(session.getOuId());
}
}
if (input.getHasOuId() != null && input.getHasOuId() == 0) {
record.setHasOuId(input.getHasOuId() + "");
if (ObjectUtil.isNotNull(input.getHasOuId()) && input.getHasOuId().equals(0)) {
record.setHasOuId(input.getHasOuId().toString());
list = mapper.selectSysUserListByNoOuId(record);
} else
list = mapper.selectSysUserListByOuId(record);
......@@ -62,9 +61,10 @@ public class SysUserService {
output.setPhone(UserInfoUtil.desensitization(output.getPhone()));
output.setIdentifyNo(UserInfoUtil.desensitization(output.getIdentifyNo()));
output.setEmail(UserInfoUtil.desensitization(output.getEmail()));
if (output.getStatus() == null)
if (ObjectUtil.isNull(output.getStatus())) {
output.setStatus(0);
}
}
return XPageResult.success(outputs, input, pageInfo.getTotal());
}
......@@ -77,28 +77,28 @@ public class SysUserService {
QueryWrapper<SysUserEnt> isExitQueryWrapper = new QueryWrapper<>();
isExitQueryWrapper.lambda().eq(SysUserEnt::getLoginName, input.getLoginName());
List<SysUserEnt> isExit = mapper.selectList(isExitQueryWrapper);
if (!CollectionUtils.isEmpty(isExit)) {
if (CollUtil.isNotEmpty(isExit)) {
return XServiceResult.error(993, "登录账户已存在!");
}
//查询是否存在有相同的Iam登录名,如果存在,提示错误信息
if (XStringUtils.isNotEmpty(input.getIamLoginName())) {
if (CharSequenceUtil.isNotBlank(input.getIamLoginName())) {
isExitQueryWrapper.clear();
isExitQueryWrapper.lambda().eq(SysUserEnt::getIamLoginName, input.getIamLoginName());
List<SysUserEnt> isIamExit = mapper.selectList(isExitQueryWrapper);
if (!CollectionUtils.isEmpty(isIamExit)) {
if (CollUtil.isNotEmpty(isIamExit)) {
return XServiceResult.error(993, "Iam登录账户已存在!");
}
}
SysUserEnt entity = new SysUserEnt();
XCopyUtils.copyObject(input, entity);
if (XStringUtils.isEmpty(input.getPassword())) {
if (CharSequenceUtil.isNotBlank(input.getPassword())) {
return XServiceResult.error(993, "请输入密码!");
}
entity.setPassword(input.getPassword());
String uuid = UUID.randomUUID().toString();
entity.setId(uuid);
PpsUserSession session = context.getSession(PpsUserSession.class);
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
entity.setCreateById(session.getId());
entity.setCreateByName(session.getUserName());
}
......@@ -130,9 +130,9 @@ public class SysUserService {
try {
relEnt.setEndTime(sdf.parse(datetime));
} catch (ParseException e) {
e.printStackTrace();
context.getLogger().error(e);
}
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
relEnt.setCreateById(session.getId());
relEnt.setCreateByName(session.getUserName());
}
......@@ -151,48 +151,48 @@ public class SysUserService {
QueryWrapper<SysUserEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserEnt::getId, input.getId());
SysUserEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
//查询是否存在相同的登录名,如果存在,提示错误信息
queryWrapper.clear();
queryWrapper.lambda().eq(SysUserEnt::getLoginName, input.getLoginName());
List<SysUserEnt> isExit = mapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(isExit) && (isExit.size() > 1 || !isExit.get(0).getId().equals(input.getId()))) {
if (CollUtil.isNotEmpty(isExit) && (isExit.size() > 1 || !CharSequenceUtil.equals(isExit.get(0).getId(), input.getId()))) {
return XServiceResult.error(993, "登录账户已存在!");
}
//查询是否存在有相同的Iam登录名,如果存在,提示错误信息
if (XStringUtils.isNotEmpty(input.getIamLoginName())) {
if (CharSequenceUtil.isNotBlank(input.getIamLoginName())) {
queryWrapper.clear();
queryWrapper.lambda().eq(SysUserEnt::getIamLoginName, input.getIamLoginName());
List<SysUserEnt> isIamExit = mapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(isIamExit) && (isIamExit.size() > 1 || !isIamExit.get(0).getId().equals(input.getId()))) {
if (CollUtil.isNotEmpty(isIamExit) && (isIamExit.size() > 1 || !CharSequenceUtil.equals(isIamExit.get(0).getId(), input.getId()))) {
return XServiceResult.error(993, "Iam登录账户已存在!");
}
}
XCopyUtils.copyObject(input, entity);
if (StringUtils.isNotBlank(entity.getPassword())) {
//String password = MD5Util.encryptPassword(AESUtil.decrypt(input.getPassword()));
if (CharSequenceUtil.isNotBlank(entity.getPassword())) {
entity.setPassword(input.getPassword());
}
entity.setModifyTime(new Date());
PpsUserSession session = context.getSession(PpsUserSession.class);
if (session != null) {
if (ObjectUtil.isNotNull(session)) {
entity.setModifyById(session.getId());
entity.setModifyByName(session.getUserName());
}
//加密敏感信息
if (StringUtils.isNotBlank(input.getPhone()) && !input.getPhone().contains("*")) {
if (CharSequenceUtil.isNotBlank(input.getPhone()) && !CharSequenceUtil.contains(input.getPhone(), '*')) {
entity.setPhone(UserInfoUtil.encrypt(input.getPhone()));
} else {
entity.setPhone(null);
}
if (StringUtils.isNotBlank(input.getIdentifyNo()) && !input.getIdentifyNo().contains("*")) {
if (CharSequenceUtil.isNotBlank(input.getIdentifyNo()) && !CharSequenceUtil.contains(input.getIdentifyNo(), '*')) {
entity.setIdentifyNo(UserInfoUtil.encrypt(input.getIdentifyNo()));
} else {
entity.setIdentifyNo(null);
}
if (StringUtils.isNotBlank(input.getEmail()) && !input.getEmail().contains("*")) {
if (CharSequenceUtil.isNotBlank(input.getEmail()) && !CharSequenceUtil.contains(input.getEmail(), '*')) {
entity.setEmail(UserInfoUtil.encrypt(input.getEmail()));
} else {
entity.setEmail(null);
......@@ -210,10 +210,10 @@ public class SysUserService {
public XServiceResult updateSysUserStatus(XContext context, UpdateSysUserInput input) throws XServiceException {
return XTransactionHelper.begin(context, () -> {
SysUserMapper mapper = context.getBean(SysUserMapper.class);
QueryWrapper<SysUserEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserEnt::getId, input.getId());
SysUserEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysUserEnt entity = mapper.selectOne(new QueryWrapper<SysUserEnt>()
.lambda()
.eq(SysUserEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
entity.setStatus(input.getStatus());
......@@ -222,40 +222,38 @@ public class SysUserService {
entity.setModifyById(session.getId());
entity.setModifyByName(session.getUserName());
mapper.updateById(entity);
if (input.getStatus() == 0) {
if (ObjectUtil.isNotNull(input.getStatus()) && input.getStatus().equals(0)) {
//删除登录日志错误信息
SysUserLoginLogMapper userLoginLogMapper = context.getBean(SysUserLoginLogMapper.class);
QueryWrapper<SysUserLoginLogEnt> queryLogWrapper = new QueryWrapper<>();
queryLogWrapper.lambda().eq(SysUserLoginLogEnt::getLoginName, entity.getLoginName());
userLoginLogMapper.delete(queryLogWrapper);
userLoginLogMapper.delete(new QueryWrapper<SysUserLoginLogEnt>()
.lambda()
.eq(SysUserLoginLogEnt::getLoginName, entity.getLoginName()));
}
//返回执行成功的结果,事务提交
return XServiceResult.OK;
});
}
public XServiceResult updateSysUserOrganizationRel(XContext context, String userId, String ouId, PpsUserSession session, String flag) throws XServiceException {
return XTransactionHelper.begin(context, () -> {
public void updateSysUserOrganizationRel(XContext context, String userId, String ouId, PpsUserSession session, String flag) throws XServiceException {
XTransactionHelper.begin(context, () -> {
//修改用户和组织机构关系为失效
SysUserOrganizationRelMapper relMapper = context.getBean(SysUserOrganizationRelMapper.class);
Date date = new Date();
QueryWrapper<SysUserOrganizationRelEnt> userOuQueryWrapper = new QueryWrapper<>();
userOuQueryWrapper.lambda().eq(SysUserOrganizationRelEnt::getUserId, userId);
userOuQueryWrapper.lambda().le(true, SysUserOrganizationRelEnt::getEffectTime, date);
userOuQueryWrapper.lambda().ge(true, SysUserOrganizationRelEnt::getEndTime, date);
SysUserOrganizationRelEnt relEntity = relMapper.selectOne(userOuQueryWrapper);
if (relEntity == null) {
SysUserOrganizationRelEnt relEntity = relMapper.selectOne(new QueryWrapper<SysUserOrganizationRelEnt>()
.lambda()
.eq(SysUserOrganizationRelEnt::getUserId, userId)
.le(SysUserOrganizationRelEnt::getEffectTime, date)
.ge(SysUserOrganizationRelEnt::getEndTime, date));
if (ObjectUtil.isNull(relEntity)) {
return XServiceResult.error(context, XError.NotFound);
}
//如果是修改就新增一条,删除的话不需要新增
if ("update".equals(flag)) {
if (CharSequenceUtil.equals("update", flag)) {
//如果不相等改为失效
if (!relEntity.getOuId().equals(ouId)) {
if (!CharSequenceUtil.equals(relEntity.getOuId(), ouId)) {
relEntity.setEndTime(date);
if (session != null) {
relEntity.setModifyById(session.getId());
relEntity.setModifyByName(session.getUserName());
}
relEntity.setModifyTime(date);
relMapper.updateById(relEntity);
//新增一条记录
......@@ -263,10 +261,8 @@ public class SysUserService {
}
} else {
relEntity.setEndTime(date);
if (session != null) {
relEntity.setModifyById(session.getId());
relEntity.setModifyByName(session.getUserName());
}
relEntity.setModifyTime(date);
relMapper.updateById(relEntity);
}
......@@ -280,10 +276,10 @@ public class SysUserService {
public XServiceResult deleteSysUser(XContext context, DeleteSysUserInput input) throws XServiceException {
return XTransactionHelper.begin(context, () -> {
SysUserMapper mapper = context.getBean(SysUserMapper.class);
QueryWrapper<SysUserEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserEnt::getId, input.getId());
SysUserEnt entity = mapper.selectOne(queryWrapper);
if (entity == null) {
SysUserEnt entity = mapper.selectOne(new QueryWrapper<SysUserEnt>()
.lambda()
.eq(SysUserEnt::getId, input.getId()));
if (ObjectUtil.isNull(entity)) {
return XServiceResult.error(context, XError.NotFound);
}
mapper.deleteById(entity);
......@@ -301,25 +297,27 @@ public class SysUserService {
SysUserView record = new SysUserView();
XCopyUtils.copyObject(input, record);
record.setEndTime(new Date());
if (Strings.isBlank(record.getOuId())) {
if (CharSequenceUtil.isBlank(record.getOuId())) {
SysOrganizationViewMapper organizationViewMapper = context.getBean(SysOrganizationViewMapper.class);
SysOrganizationView sysOrganizationView = new SysOrganizationView();
sysOrganizationView.setEndTime(new Date());
sysOrganizationView.setIsDeleted(BusinessConstant.ONE);
PpsUserSession session = context.getSession(PpsUserSession.class);
List<SysOrganizationView> viewList;
if (input.getShowAll() == null || !input.getShowAll()) {
if (ObjectUtil.isNull(input.getShowAll()) || !input.getShowAll()) {
sysOrganizationView.setId(session.getOuId());
viewList = organizationViewMapper.selectOuByOuId(sysOrganizationView);
if (viewList.isEmpty()) return XPageResult.success(Collections.emptyList(), input, 0);
List<String> ouIds = viewList.stream().map(SysOrganizationView::getId).collect(Collectors.toList());
record.setOuIds(ouIds);
if (CollUtil.isEmpty(viewList)) {
return XPageResult.success(Collections.emptyList(), input, 0);
}
record.setOuIds(viewList.stream()
.map(SysOrganizationView::getId)
.collect(Collectors.toList()));
}
}
PageHelper.startPage(input.getPage(), input.getLimit());
List<SysUserView> list = mapper.selectSysUserListByOuId(record);
PageInfo<SysUserView> pageInfo = new PageInfo<>(list);
List<QuerySysUserViewOutput> outputs = XCopyUtils.copyNewList(pageInfo.getList(), QuerySysUserViewOutput.class);
return XPageResult.success(outputs, input, pageInfo.getTotal());
return XPageResult.success(XCopyUtils.copyNewList(pageInfo.getList(), QuerySysUserViewOutput.class), input, pageInfo.getTotal());
}
}
package pps.core.system.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import pps.core.common.session.PpsUserSession;
import pps.core.system.entity.SysUserWithUserGroupRelEnt;
import pps.core.system.entity.SysUserWithUserGroupRelView;
......@@ -47,16 +47,15 @@ public class SysUserWithUserGroupRelService {
SysUserWithUserGroupRelViewMapper userWithUserGroupRelViewMapper = context.getBean(SysUserWithUserGroupRelViewMapper.class);
//删除原关系
QueryWrapper<SysUserWithUserGroupRelEnt> queryWrapper = new QueryWrapper<>();
if (StringUtils.equals("1", input.getType())) {
if (CharSequenceUtil.equals("1", input.getType())) {
queryWrapper.lambda().eq(SysUserWithUserGroupRelEnt::getUserGroupId, input.getUserGroupId());
} else {
queryWrapper.lambda().eq(SysUserWithUserGroupRelEnt::getUserId, input.getUserId());
}
PageHelper.startPage(1, 1000);
List<SysUserWithUserGroupRelEnt> sysAuthOuScopeEnts = userGroupWithRole.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(sysAuthOuScopeEnts)) {
List<String> collect = sysAuthOuScopeEnts.stream().map(SysUserWithUserGroupRelEnt::getId).collect(Collectors.toList());
userGroupWithRole.deleteBatchIds(collect);
if (CollUtil.isNotEmpty(sysAuthOuScopeEnts)) {
userGroupWithRole.deleteBatchIds(sysAuthOuScopeEnts.stream().map(SysUserWithUserGroupRelEnt::getId).collect(Collectors.toList()));
}
//创建新关系
Date now = new Date();
......@@ -64,7 +63,7 @@ public class SysUserWithUserGroupRelService {
List<SysUserWithUserGroupRelView> viewList = new ArrayList<>();
for (String groupId : groupIdList) {
SysUserWithUserGroupRelView entity = new SysUserWithUserGroupRelView();
if (StringUtils.equals("1", input.getType())) {
if (CharSequenceUtil.equals("1", input.getType())) {
entity.setUserId(groupId);
entity.setUserGroupId(input.getUserGroupId());
} else {
......@@ -78,7 +77,7 @@ public class SysUserWithUserGroupRelService {
entity.setCreateTime(now);
viewList.add(entity);
}
if (!CollectionUtils.isEmpty(viewList)) {
if (CollUtil.isNotEmpty(viewList)) {
userWithUserGroupRelViewMapper.batchInsert(viewList);
}
return XServiceResult.OK;
......@@ -88,13 +87,12 @@ public class SysUserWithUserGroupRelService {
public XServiceResult createSysUserWithUserGroupRel(XContext context, CreateSysUserWithUserGroupRelInput input) {
//删除原关系
SysUserWithUserGroupRelMapper delMapper = context.getBean(SysUserWithUserGroupRelMapper.class);
QueryWrapper<SysUserWithUserGroupRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserWithUserGroupRelEnt::getUserId, input.getUserId());
PageHelper.startPage(1, 1000);
List<SysUserWithUserGroupRelEnt> sysUserGroupEnts = delMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(sysUserGroupEnts)) {
List<String> collect = sysUserGroupEnts.stream().map(SysUserWithUserGroupRelEnt::getId).collect(Collectors.toList());
delMapper.deleteBatchIds(collect);
List<SysUserWithUserGroupRelEnt> sysUserGroupEnts = delMapper.selectList(new QueryWrapper<SysUserWithUserGroupRelEnt>()
.lambda()
.eq(SysUserWithUserGroupRelEnt::getUserId, input.getUserId()));
if (CollUtil.isNotEmpty(sysUserGroupEnts)) {
delMapper.deleteBatchIds(sysUserGroupEnts.stream().map(SysUserWithUserGroupRelEnt::getId).collect(Collectors.toList()));
}
SysUserWithUserGroupRelMapper mapper = context.getBean(SysUserWithUserGroupRelMapper.class);
List<SysUserWithUserGroupRelEnt> list = new ArrayList<>();
......@@ -113,13 +111,12 @@ public class SysUserWithUserGroupRelService {
public XServiceResult createSysUserGroupWithUserRel(XContext context, CreateSysUserGroupWithUserRelInput input) {
//删除原关系
SysUserWithUserGroupRelMapper delMapper = context.getBean(SysUserWithUserGroupRelMapper.class);
QueryWrapper<SysUserWithUserGroupRelEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysUserWithUserGroupRelEnt::getUserGroupId, input.getUserGroupId());
PageHelper.startPage(1, 1000);
List<SysUserWithUserGroupRelEnt> sysUserGroupEnts = delMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(sysUserGroupEnts)) {
List<String> collect = sysUserGroupEnts.stream().map(SysUserWithUserGroupRelEnt::getId).collect(Collectors.toList());
delMapper.deleteBatchIds(collect);
List<SysUserWithUserGroupRelEnt> sysUserGroupEnts = delMapper.selectList(new QueryWrapper<SysUserWithUserGroupRelEnt>()
.lambda()
.eq(SysUserWithUserGroupRelEnt::getUserGroupId, input.getUserGroupId()));
if (CollUtil.isNotEmpty(sysUserGroupEnts)) {
delMapper.deleteBatchIds(sysUserGroupEnts.stream().map(SysUserWithUserGroupRelEnt::getId).collect(Collectors.toList()));
}
SysUserWithUserGroupRelMapper mapper = context.getBean(SysUserWithUserGroupRelMapper.class);
List<SysUserWithUserGroupRelEnt> list = new ArrayList<>();
......
package pps.core.system.service;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang3.StringUtils;
import pps.cloud.system.service.SystemAreaService;
import pps.cloud.system.service.data.sys_area.GetSysAreaInput;
import pps.cloud.system.service.data.sys_area.GetSysAreaOutput;
......@@ -20,7 +21,6 @@ import xstartup.data.XSingleResult;
import xstartup.feature.api.annotation.XApiPost;
import java.util.List;
import java.util.Objects;
@XService
public class SystemAreaServiceImpl implements SystemAreaService {
......@@ -48,9 +48,9 @@ public class SystemAreaServiceImpl implements SystemAreaService {
Integer parentId = input.getParentId();
SysAreaMapper mapper = context.getBean(SysAreaMapper.class);
SysAreaEnt sysAreaEnt = mapper.selectOne(new LambdaQueryWrapper<SysAreaEnt>()
.eq(Objects.nonNull(id), SysAreaEnt::getId, id)
.eq(Objects.nonNull(parentId), SysAreaEnt::getParentId, parentId)
.eq(StringUtils.isNotEmpty(name), SysAreaEnt::getName, name)
.eq(ObjectUtil.isNotNull(id), SysAreaEnt::getId, id)
.eq(ObjectUtil.isNotNull(parentId), SysAreaEnt::getParentId, parentId)
.eq(CharSequenceUtil.isNotBlank(name), SysAreaEnt::getName, name)
.last(BusinessConstant.LAST_LIMIT)
);
return XSingleResult.success(XCopyUtils.copyNewObject(sysAreaEnt, GetSysAreaOutput.class));
......
package pps.core.system.utils;
import org.apache.commons.lang3.StringUtils;
import cn.hutool.core.text.CharSequenceUtil;
import pps.core.common.utils.PatternUtil;
import pps.core.common.utils.RSAUtil;
import pps.core.system.config.LoginConfig;
......@@ -18,7 +18,7 @@ public class UserInfoUtil {
//敏感信息rsa加密
public static String encrypt(String str) {
if (StringUtils.isBlank(str)) {
if (CharSequenceUtil.isBlank(str)) {
return str;
}
XContext context = XServiceContext.build(UserInfoUtil.class);
......@@ -29,7 +29,7 @@ public class UserInfoUtil {
//敏感信息rsa解密
public static String decrypt(String str) {
if (StringUtils.isBlank(str)) {
if (CharSequenceUtil.isBlank(str)) {
return str;
}
XContext context = XServiceContext.build(UserInfoUtil.class);
......
package pps.core.base.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.util.CollectionUtils;
import pps.core.base.entity.BaseDataEnt;
import pps.core.base.entity.BaseDataImportLogEnt;
import pps.core.base.entity.BaseDataView;
......@@ -337,7 +337,7 @@ public class BaseDataService {
BaseDataImportLogEnt ent = logMapper.selectOne(logEntQueryWrapper);
if (ent == null)
return XServiceResult.OK;
if (!CollectionUtils.isEmpty(input.getKeyNames())) {
if (CollUtil.isNotEmpty(input.getKeyNames())) {
for (String keyName : input.getKeyNames()) {
CalcBaseDataInput calcBaseDataInput = new CalcBaseDataInput("", keyName, input.getLineId(), "train_val", XDateUtils.getString(ent.getBeginDate()), XDateUtils.getString(ent.getEndDate()));
doTrainData(context, calcBaseDataInput);
......
package pps.core.base.service;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import org.springframework.util.CollectionUtils;
import pps.core.base.entity.BaseLineAttenuationRateEnt;
import pps.core.base.entity.BaseLineAttenuationRateView;
import pps.core.base.entity.BaseProjectInfoEnt;
......@@ -66,7 +66,7 @@ public class BaseProjectInfoService {
entity.setIsDeleted(0);
mapper.insert(entity);
List<BaseLineAttenuationRateView> list = new ArrayList<>();
if (!CollectionUtils.isEmpty(input.getList())) {
if (CollUtil.isNotEmpty(input.getList())) {
BaseLineAttenuationRateViewMapper rateMapper = context.getBean(BaseLineAttenuationRateViewMapper.class);
for (CreateBaseLineAttenuationRateInput rateInput : input.getList()) {
BaseLineAttenuationRateView ent = XCopyUtils.copyNewObject(rateInput, BaseLineAttenuationRateView.class);
......@@ -107,7 +107,7 @@ public class BaseProjectInfoService {
queryRateWrapper.lambda().eq(BaseLineAttenuationRateEnt::getType, 1);
rateMapper.delete(queryRateWrapper);
List<BaseLineAttenuationRateView> list = new ArrayList<>();
if (!CollectionUtils.isEmpty(input.getList())) {
if (CollUtil.isNotEmpty(input.getList())) {
BaseLineAttenuationRateViewMapper rateViewMapper = context.getBean(BaseLineAttenuationRateViewMapper.class);
for (CreateBaseLineAttenuationRateInput rateInput : input.getList()) {
BaseLineAttenuationRateView ent = XCopyUtils.copyNewObject(rateInput, BaseLineAttenuationRateView.class);
......@@ -157,7 +157,7 @@ public class BaseProjectInfoService {
queryRateWrapper.lambda().eq(BaseLineAttenuationRateEnt::getLineId, entity.getId());
queryRateWrapper.lambda().eq(BaseLineAttenuationRateEnt::getType, 1);
List<BaseLineAttenuationRateEnt> list = rateMapper.selectList(queryRateWrapper);
if (!CollectionUtils.isEmpty(list)) {
if (CollUtil.isNotEmpty(list)) {
List<CreateBaseLineAttenuationRateInput> rateInputs = XCopyUtils.copyNewList(list, CreateBaseLineAttenuationRateInput.class);
output.setList(rateInputs);
}
......
package pps.core.base.service;
import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import pps.core.base.entity.SysPageInfoEnt;
import pps.core.base.mapper.SysPageInfoMapper;
import pps.core.base.service.data.sys_page_info.*;
......@@ -54,13 +54,13 @@ public class SysPageInfoService {
if (entity == null) {
return XServiceResult.error(context, XError.NotFound);
}
if (StringUtils.isNotBlank(input.getPageContext())) {
if (CharSequenceUtil.isNotBlank(input.getPageContext())) {
entity.setPageContext(input.getPageContext());
}
if (StringUtils.isNotBlank(input.getPageName())) {
if (CharSequenceUtil.isNotBlank(input.getPageName())) {
entity.setPageName(input.getPageName());
}
if (StringUtils.isNotBlank(input.getPageRemark())) {
if (CharSequenceUtil.isNotBlank(input.getPageRemark())) {
entity.setPageRemark(input.getPageRemark());
}
entity.setModifyTime(new Date());
......@@ -104,10 +104,10 @@ public class SysPageInfoService {
public XPageResult<QuerySysPageInfoOutput> querySysPageInfo(XContext context, QuerySysPageInfoInput input) {
SysPageInfoMapper mapper = context.getBean(SysPageInfoMapper.class);
QueryWrapper<SysPageInfoEnt> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotBlank(input.getPageId())) {
if (CharSequenceUtil.isNotBlank(input.getPageId())) {
queryWrapper.lambda().eq(SysPageInfoEnt::getPageId, input.getPageId());
}
if (StringUtils.isNotBlank(input.getPageName())) {
if (CharSequenceUtil.isNotBlank(input.getPageName())) {
queryWrapper.lambda().like(SysPageInfoEnt::getPageName, input.getPageName());
}
if (ObjectUtils.isNotEmpty(input.getReleaseState())) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment