| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveOrUpdatePropertyCompanyDistrict(PropertyCompanyDistrictEntity propertyCompanyDistrict) throws Exception { |
| | | IUserService bean = SpringUtil.getBean(IUserService.class); |
| | | User user = bean.getOne(Wrappers.<User>lambdaQuery().eq(User::getId, propertyCompanyDistrict.getPrincipal())); |
| | | if (StringUtils.isNotBlank(user.getRoleId())) { |
| | | if (!user.getRoleId().contains("1747504028253229058")) { |
| | | user.setRoleId(user.getRoleId() + ",1747504028253229058"); |
| | | } |
| | | } else { |
| | | user.setRoleId("1747504028253229058"); |
| | | } |
| | | // IUserService bean = SpringUtil.getBean(IUserService.class); |
| | | // User user = bean.getOne(Wrappers.<User>lambdaQuery().eq(User::getId, propertyCompanyDistrict.getPrincipal())); |
| | | // if (StringUtils.isNotBlank(user.getRoleId())) { |
| | | // if (!user.getRoleId().contains("1747504028253229058")) { |
| | | // user.setRoleId(user.getRoleId() + ",1747504028253229058"); |
| | | // } |
| | | // } else { |
| | | // user.setRoleId("1747504028253229058"); |
| | | // } |
| | | if (null != propertyCompanyDistrict.getId()) { |
| | | bean.updateById(user); |
| | | // bean.updateById(user); |
| | | return updateById(propertyCompanyDistrict) && submitPropertyDistrictUser(propertyCompanyDistrict); |
| | | } else { |
| | | long count = count(Wrappers.<PropertyCompanyDistrictEntity>lambdaQuery() |
| | |
| | | if (count > 0) { |
| | | throw new Exception("您已有该小区的合同,请勿重复添加!"); |
| | | } |
| | | bean.updateById(user); |
| | | // bean.updateById(user); |
| | | return save(propertyCompanyDistrict) && submitPropertyDistrictUser(propertyCompanyDistrict); |
| | | } |
| | | } |
| | |
| | | */ |
| | | private boolean submitPropertyDistrictUser(PropertyCompanyDistrictEntity propertyCompanyDistrict) { |
| | | List<Long> userIdList = Func.toLongList(propertyCompanyDistrict.getUserId()); |
| | | List<Long> arrayList = new ArrayList<Long>(userIdList); |
| | | // 把项目经理也加到物业用户关联表 |
| | | userIdList.add(Long.valueOf(propertyCompanyDistrict.getPrincipal())); |
| | | arrayList.add(Long.valueOf(propertyCompanyDistrict.getPrincipal())); |
| | | List<PropertyDistrictUserEntity> propertyDistrictUserEntityList = new ArrayList<>(); |
| | | userIdList.forEach(userId -> { |
| | | arrayList.forEach(userId -> { |
| | | PropertyDistrictUserEntity propertyDistrictUserEntity = new PropertyDistrictUserEntity(); |
| | | propertyDistrictUserEntity.setUserId(userId); |
| | | propertyDistrictUserEntity.setPropertyCompanyDistrictId(propertyCompanyDistrict.getId()); |
| | |
| | | <result column="has_children" property="hasChildren"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> |
| | | <resultMap id="treeNodeResultMap" type="org.springblade.modules.system.vo.DeptVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="title" property="title"/> |
| | | <result column="value" property="value"/> |
| | | <result column="key" property="key"/> |
| | | <result column="has_children" property="hasChildren"/> |
| | | </resultMap> |
| | | |
| | |
| | | </select> |
| | | |
| | | <select id="tree" resultMap="treeNodeResultMap"> |
| | | |
| | | <if test="param2!=null"> |
| | | SELECT |
| | | id, |
| | | dept_name AS title, |
| | | id AS "value", |
| | | id AS "key", |
| | | parent_id |
| | | FROM |
| | | ( SELECT * FROM blade_dept WHERE is_deleted = 0 AND tenant_id = #{param1} ORDER BY parent_id, id ) |
| | | org_query, |
| | | ( SELECT @id := #{param2} ) initialisation |
| | | WHERE |
| | | (FIND_IN_SET( parent_id, @id ) > 0 or FIND_IN_SET( id, @id ) > 0) |
| | | AND @id := CONCAT(@id,',',id) ORDER BY sort |
| | | </if> |
| | | |
| | | <if test="param2==null"> |
| | | select id, parent_id, dept_name as title, id as "value", id as "key" from blade_dept where is_deleted = 0 |
| | | <if test="param1!=null and param1!=''"> |
| | | and tenant_id = #{param1} |
| | | </if> |
| | | ORDER BY sort |
| | | </if> |
| | | |
| | | SELECT |
| | | a.id, |
| | | a.dept_name AS title, |
| | | a.parent_id, |
| | | b.id, |
| | | IF |
| | | ( b.id > 0, FALSE, TRUE ) disabled |
| | | FROM |
| | | blade_dept a |
| | | LEFT JOIN ( |
| | | SELECT |
| | | id, |
| | | dept_name AS title, |
| | | parent_id |
| | | FROM |
| | | ( SELECT * FROM blade_dept WHERE is_deleted = 0 AND tenant_id = #{param1} ORDER BY parent_id, id ) org_query, |
| | | ( SELECT @id := #{param2} ) initialisation |
| | | WHERE |
| | | ( FIND_IN_SET( parent_id, @id ) > 0 OR FIND_IN_SET( id, @id ) > 0 ) |
| | | AND @id := CONCAT( @id, ',', id ) |
| | | ORDER BY |
| | | sort |
| | | ) b ON a.id = b.id |
| | | WHERE |
| | | is_deleted = 0 |
| | | AND tenant_id = #{param1} ORDER BY a.sort |
| | | </select> |
| | | |
| | | <select id="lazyTree" resultMap="treeNodeResultMap"> |
| | |
| | | dept.id, |
| | | dept.parent_id, |
| | | dept.dept_name AS title, |
| | | dept.id AS "value", |
| | | dept.id AS "key", |
| | | ( |
| | | SELECT |
| | | CASE WHEN count(1) > 0 THEN 1 ELSE 0 END |
| | |
| | | |
| | | @Override |
| | | public List<DeptVO> tree(String tenantId) { |
| | | Long id = null; |
| | | Long id = 0L; |
| | | // 判断数据权限控制,非超管角色只可看到本级及以下数据 |
| | | // if (!AuthUtil.isAdministrator()) { |
| | | // Long deptId = Func.firstLong(AuthUtil.getDeptId()); |
| | | // Dept dept = SysCache.getDept(deptId); |
| | | // if (dept.getParentId() != 0) { |
| | | // parentId = dept.getParentId(); |
| | | // } |
| | | // List<DeptVO> merge = ForestNodeMerger.merge(baseMapper.tree(tenantId, parentId)); |
| | | // List<DeptVO> copy = BeanUtil.copy(merge, DeptVO.class); |
| | | // copy = copy.stream().filter(item -> AuthUtil.getDeptId().contains(item.getId().toString())).collect(Collectors.toList()); |
| | | // return copy; |
| | | // } |
| | | String userRole = AuthUtil.getUserRole(); |
| | | // 判断物业公司 |
| | | if (userRole.contains("wygly") || userRole.contains("wyxmjl")) { |
| | | // 获取当前用户的机构 |
| | | if (!AuthUtil.isAdmin()) { |
| | | id = Func.firstLong(AuthUtil.getDeptId()); |
| | | } |
| | | |
| | | return ForestNodeMerger.merge(baseMapper.tree(tenantId, id)); |
| | | List<DeptVO> tree = baseMapper.tree(tenantId, id); |
| | | if (AuthUtil.isAdmin()) { |
| | | for (DeptVO deptVO : tree) { |
| | | deptVO.setDisabled(false); |
| | | } |
| | | } |
| | | return ForestNodeMerger.merge(tree); |
| | | } |
| | | |
| | | @Override |
| | |
| | | */ |
| | | private String deptCategoryName; |
| | | |
| | | private Boolean disabled; |
| | | |
| | | } |