diff --git a/java/cloud/schedule/src/main/java/cn/toesbieya/jxc/schedule/task/StatisticTask.java b/java/cloud/schedule/src/main/java/cn/toesbieya/jxc/schedule/task/StatisticTask.java index 5e0e4d5..baa3dc3 100644 --- a/java/cloud/schedule/src/main/java/cn/toesbieya/jxc/schedule/task/StatisticTask.java +++ b/java/cloud/schedule/src/main/java/cn/toesbieya/jxc/schedule/task/StatisticTask.java @@ -106,7 +106,7 @@ public class StatisticTask implements CommandLineRunner { mapper.insertProfitTotal(statProfitTotal); - if (purchaseProfitGoods.size() > 0) { + if (!purchaseProfitGoods.isEmpty()) { mapper.insertProfitGoodsBatch(purchaseProfitGoods); } } diff --git a/java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/CustomerService.java b/java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/CustomerService.java index 4b78be7..629b052 100644 --- a/java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/CustomerService.java +++ b/java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/CustomerService.java @@ -73,7 +73,7 @@ public class CustomerService { }); //获取关联的行政区域的名称 - List regions = regionIds.size() > 0 ? regionMapper.selectBatchIds(regionIds) : Collections.emptyList(); + List regions = regionIds.isEmpty() ? Collections.emptyList() : regionMapper.selectBatchIds(regionIds); list.forEach(customerVo -> { SysRegion matched = Util.find(regions, item -> customerVo.getRegion().equals(item.getId())); diff --git a/java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/SupplierService.java b/java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/SupplierService.java index 01ea622..6c948a2 100644 --- a/java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/SupplierService.java +++ b/java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/SupplierService.java @@ -74,7 +74,7 @@ public class SupplierService { }); //获取关联的行政区域的名称 - List regions = regionIds.size() > 0 ? regionMapper.selectBatchIds(regionIds) : Collections.emptyList(); + List regions = regionIds.isEmpty() ? Collections.emptyList() : regionMapper.selectBatchIds(regionIds); list.forEach(supplierVo -> { SysRegion matched = Util.find(regions, item -> supplierVo.getRegion().equals(item.getId())); if (matched != null) { diff --git a/java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/UserService.java b/java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/UserService.java index 5da0404..626829d 100644 --- a/java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/UserService.java +++ b/java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/UserService.java @@ -2,6 +2,7 @@ package cn.toesbieya.jxc.system.service; import cn.toesbieya.jxc.common.model.entity.SysRole; import cn.toesbieya.jxc.common.model.entity.SysUser; +import cn.toesbieya.jxc.common.model.vo.DepartmentVo; import cn.toesbieya.jxc.common.model.vo.Result; import cn.toesbieya.jxc.common.model.vo.UserVo; import cn.toesbieya.jxc.common.util.Util; @@ -30,6 +31,8 @@ public class UserService { private SysUserMapper userMapper; @Resource private SysRoleMapper roleMapper; + @Resource + private DepartmentService departmentService; public PageResult search(UserSearch vo) { Integer id = vo.getId(); @@ -56,35 +59,49 @@ public class UserService { int userNum = users.size(); - //当前在线的用户id - Set onlineUserIds = WebSocketUtil.getOnlineUserIds(); - //传递给前端的结果集 List result = new ArrayList<>(userNum); + //当前在线的用户id + Set onlineUserIds = WebSocketUtil.getOnlineUserIds(); + //查询得到的用户的角色id Set userRoleIds = new HashSet<>(userNum); + //查询得到的用户的部门id + Set userDeptIds = new HashSet<>(userNum); users.forEach(user -> { result.add(new UserVo(user)); Integer rid = user.getRole(); + Integer deptId = user.getDept(); if (rid != null) userRoleIds.add(rid); + if (deptId != null) userDeptIds.add(deptId); }); - List roles = userRoleIds.size() > 0 ? roleMapper.selectBatchIds(userRoleIds) : Collections.emptyList(); + List roles = userRoleIds.isEmpty() ? Collections.emptyList() : roleMapper.selectBatchIds(userRoleIds); + List depts = userDeptIds.isEmpty() ? Collections.emptyList() : departmentService.getAll(); result.forEach(userVo -> { //设置在线情况 userVo.setOnline(Util.some(onlineUserIds, i -> userVo.getId().equals(i))); - Integer userRoleId = userVo.getRole(); - if (userRoleId != null) { - //设置用户的角色名称 - SysRole matched = Util.find(roles, i -> i.getId().equals(userRoleId)); + //设置用户的角色名称 + Integer roleId = userVo.getRole(); + if (roleId != null) { + SysRole matched = Util.find(roles, i -> i.getId().equals(roleId)); if (matched != null) { userVo.setRoleName(matched.getName()); } } + + //设置部门名称 + Integer deptId = userVo.getDept(); + if (deptId != null) { + DepartmentVo matched = Util.find(depts, i -> i.getId().equals(deptId)); + if (matched != null) { + userVo.setDeptName(matched.getFullname()); + } + } }); return new PageResult<>(pageResult.getTotal(), result); @@ -162,6 +179,7 @@ public class UserService { return rows > 0 ? Result.success() : Result.fail("重置失败,未匹配到用户"); } + //用户名重复时返回true private boolean isNameExist(String name, Integer id) { Integer num = userMapper.selectCount( Wrappers.lambdaQuery(SysUser.class) diff --git a/java/cloud/web/web-modules/system/src/main/resources/mapper/SysDepartment.xml b/java/cloud/web/web-modules/system/src/main/resources/mapper/SysDepartment.xml index 7739f7c..43b75c8 100644 --- a/java/cloud/web/web-modules/system/src/main/resources/mapper/SysDepartment.xml +++ b/java/cloud/web/web-modules/system/src/main/resources/mapper/SysDepartment.xml @@ -15,7 +15,7 @@ where c.pid = t.id ) select * - from t; + from t \ No newline at end of file diff --git a/java/local/src/main/java/cn/toesbieya/jxc/schedule/StatisticTask.java b/java/local/src/main/java/cn/toesbieya/jxc/schedule/StatisticTask.java index 621567d..c50b83a 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/schedule/StatisticTask.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/schedule/StatisticTask.java @@ -106,7 +106,7 @@ public class StatisticTask { mapper.insertProfitTotal(statProfitTotal); - if (purchaseProfitGoods.size() > 0) { + if (!purchaseProfitGoods.isEmpty()) { mapper.insertProfitGoodsBatch(purchaseProfitGoods); } } diff --git a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysCustomerService.java b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysCustomerService.java index 9e85a0c..9b97807 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysCustomerService.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysCustomerService.java @@ -74,7 +74,7 @@ public class SysCustomerService { }); //获取关联的行政区域的名称 - List regions = regionIds.size() > 0 ? regionMapper.selectBatchIds(regionIds) : Collections.emptyList(); + List regions = regionIds.isEmpty() ? Collections.emptyList():regionMapper.selectBatchIds(regionIds); list.forEach(customerVo -> { SysRegion matched = Util.find(regions, item -> customerVo.getRegion().equals(item.getId())); diff --git a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysSupplierService.java b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysSupplierService.java index eb7ac7c..2e9044f 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysSupplierService.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysSupplierService.java @@ -74,7 +74,7 @@ public class SysSupplierService { }); //获取关联的行政区域的名称 - List regions = regionIds.size() > 0 ? regionMapper.selectBatchIds(regionIds) : Collections.emptyList(); + List regions = regionIds.isEmpty() ? Collections.emptyList() : regionMapper.selectBatchIds(regionIds); list.forEach(supplierVo -> { SysRegion matched = Util.find(regions, item -> supplierVo.getRegion().equals(item.getId())); if (matched != null) { @@ -88,7 +88,7 @@ public class SysSupplierService { @UserAction("'添加供应商:'+ #supplier.name") public Result add(SysSupplier supplier) { if (isNameExist(supplier.getName(), null)) { - return Result.fail(String.format("添加失败,供应商【%s】已存在",supplier.getName())); + return Result.fail(String.format("添加失败,供应商【%s】已存在", supplier.getName())); } int rows = supplierMapper.insert(supplier); return rows > 0 ? Result.success("添加成功") : Result.fail("添加失败"); @@ -100,7 +100,7 @@ public class SysSupplierService { String name = supplier.getName(); if (isNameExist(name, id)) { - return Result.fail(String.format("修改失败,供应商【%s】已存在",name)); + return Result.fail(String.format("修改失败,供应商【%s】已存在", name)); } supplierMapper.update( diff --git a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysUserService.java b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysUserService.java index 2509be7..0d02bb1 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysUserService.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysUserService.java @@ -5,6 +5,7 @@ import cn.toesbieya.jxc.mapper.SysRoleMapper; import cn.toesbieya.jxc.mapper.SysUserMapper; import cn.toesbieya.jxc.model.entity.SysRole; import cn.toesbieya.jxc.model.entity.SysUser; +import cn.toesbieya.jxc.model.vo.DepartmentVo; import cn.toesbieya.jxc.model.vo.Result; import cn.toesbieya.jxc.model.vo.UserVo; import cn.toesbieya.jxc.model.vo.result.PageResult; @@ -30,6 +31,8 @@ public class SysUserService { private SysUserMapper userMapper; @Resource private SysRoleMapper roleMapper; + @Resource + private SysDepartmentService departmentService; public PageResult search(UserSearch vo) { Integer id = vo.getId(); @@ -56,35 +59,49 @@ public class SysUserService { int userNum = users.size(); - //当前在线的用户id - Set onlineUserIds = WebSocketUtil.getOnlineUserIds(); - //传递给前端的结果集 List result = new ArrayList<>(userNum); + //当前在线的用户id + Set onlineUserIds = WebSocketUtil.getOnlineUserIds(); + //查询得到的用户的角色id Set userRoleIds = new HashSet<>(userNum); + //查询得到的用户的部门id + Set userDeptIds = new HashSet<>(userNum); users.forEach(user -> { result.add(new UserVo(user)); Integer rid = user.getRole(); + Integer deptId = user.getDept(); if (rid != null) userRoleIds.add(rid); + if (deptId != null) userDeptIds.add(deptId); }); - List roles = userRoleIds.size() > 0 ? roleMapper.selectBatchIds(userRoleIds) : Collections.emptyList(); + List roles = userRoleIds.isEmpty() ? Collections.emptyList() : roleMapper.selectBatchIds(userRoleIds); + List depts = userDeptIds.isEmpty() ? Collections.emptyList() : departmentService.getAll(); result.forEach(userVo -> { //设置在线情况 userVo.setOnline(Util.some(onlineUserIds, i -> userVo.getId().equals(i))); - Integer userRoleId = userVo.getRole(); - if (userRoleId != null) { - //设置用户的角色名称 - SysRole matched = Util.find(roles, i -> i.getId().equals(userRoleId)); + //设置用户的角色名称 + Integer roleId = userVo.getRole(); + if (roleId != null) { + SysRole matched = Util.find(roles, i -> i.getId().equals(roleId)); if (matched != null) { userVo.setRoleName(matched.getName()); } } + + //设置部门名称 + Integer deptId = userVo.getDept(); + if (deptId != null) { + DepartmentVo matched = Util.find(depts, i -> i.getId().equals(deptId)); + if (matched != null) { + userVo.setDeptName(matched.getFullname()); + } + } }); return new PageResult<>(pageResult.getTotal(), result); @@ -162,6 +179,7 @@ public class SysUserService { return rows > 0 ? Result.success() : Result.fail("重置失败,未匹配到用户"); } + //用户名重复时返回true private boolean isNameExist(String name, Integer id) { Integer num = userMapper.selectCount( Wrappers.lambdaQuery(SysUser.class) diff --git a/java/local/src/main/resources/mapper/SysDepartment.xml b/java/local/src/main/resources/mapper/SysDepartment.xml index 6e4a16f..ede5259 100644 --- a/java/local/src/main/resources/mapper/SysDepartment.xml +++ b/java/local/src/main/resources/mapper/SysDepartment.xml @@ -15,7 +15,7 @@ where c.pid = t.id ) select * - from t; + from t \ No newline at end of file