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