| | |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.modules.community.entity.CommunityEntity; |
| | | import org.springblade.modules.community.service.ICommunityService; |
| | | import org.springblade.modules.grid.entity.GridEntity; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.property.entity.PropertyCompanyEntity; |
| | | import org.springblade.modules.property.service.IPropertyCompanyService; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.entity.Region; |
| | | import org.springblade.modules.system.mapper.DeptMapper; |
| | |
| | | public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements IDeptService { |
| | | private static final String TENANT_ID = "tenantId"; |
| | | private static final String PARENT_ID = "parentId"; |
| | | |
| | | @Autowired |
| | | private IPropertyCompanyService propertyCompanyService; |
| | | // |
| | | // @Autowired |
| | | // private IPropertyCompanyService propertyCompanyService; |
| | | |
| | | @Autowired |
| | | private IRegionService regionService; |
| | |
| | | for (Long id : longs) { |
| | | // 查询当前机构信息 |
| | | DeptVO dept = baseMapper.getDeptById(id); |
| | | // 如果父机构为物业公司 |
| | | if (dept.getParentName().equals("物业公司")) { |
| | | // 删除 |
| | | propertyCompanyService.remove(Wrappers.<PropertyCompanyEntity>update().lambda().eq(PropertyCompanyEntity::getDeptId, id)); |
| | | } |
| | | } |
| | | return removeByIds(longs); |
| | | } |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void savePropertyCompany(Dept dept) { |
| | | // 查询物业公司是否存在 |
| | | QueryWrapper<PropertyCompanyEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted", 0) |
| | | .eq("dept_id", dept.getId()) |
| | | .eq("name", dept.getDeptName()); |
| | | PropertyCompanyEntity propertyCompanyEntity = propertyCompanyService.getOne(wrapper); |
| | | if (null != propertyCompanyEntity) { |
| | | // 修改 |
| | | propertyCompanyEntity.setDeptId(dept.getId()); |
| | | propertyCompanyEntity.setName(dept.getDeptName()); |
| | | // 往物业公司表中插入一条数据 |
| | | propertyCompanyService.updateById(propertyCompanyEntity); |
| | | } else { |
| | | // 新增 |
| | | PropertyCompanyEntity companyEntity = new PropertyCompanyEntity(); |
| | | companyEntity.setDeptId(dept.getId()); |
| | | companyEntity.setName(dept.getDeptName()); |
| | | // 往物业公司表中插入一条数据 |
| | | propertyCompanyService.save(companyEntity); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Object dataHandleCommunity() { |
| | | // 查询所有的社区 |
| | | QueryWrapper<Region> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("district_code","361102").eq("region_level",5); |
| | | List<Region> list = regionService.list(queryWrapper); |
| | | // 遍历 |
| | | for (Region region : list) { |
| | | // 查询是否已创建 |
| | | QueryWrapper<CommunityEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted", 0).eq("name", region.getName()); |
| | | CommunityEntity one = SpringUtil.getBean(ICommunityService.class).getOne(wrapper); |
| | | if (null == one) { |
| | | // 新增 |
| | | CommunityEntity communityEntity = new CommunityEntity(); |
| | | communityEntity.setStreetCode(region.getTownCode()); |
| | | communityEntity.setName(region.getName()); |
| | | communityEntity.setCode(region.getCode()); |
| | | // 新增 |
| | | SpringUtil.getBean(ICommunityService.class).save(communityEntity); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Object dataRegionGridCodeBindHandle() { |
| | | // 查询网格对应的机构信息(包含父级机构名称) |
| | | List<DeptVO> deptVOS = baseMapper.getGridDeptAndParentList(); |
| | | //遍历处理 |
| | | for (DeptVO deptVO : deptVOS) { |
| | | GridEntity gridEntity = SpringUtils.getBean(IGridService.class).getGridByNames(deptVO.getDeptName(), deptVO.getParentName()); |
| | | if (null != gridEntity) { |
| | | deptVO.setRegionCode(gridEntity.getGridCode()); |
| | | // 更新 |
| | | updateById(deptVO); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | |
| | | // 处理并返回 |
| | | return deptAndUserNodeTree; |
| | | } |
| | | |
| | | /** |
| | | * 数据处理(社区绑定)-- 处理社区(派出所下) |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Object dataHandleCommunityByPolice() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 查询对应的派出所 |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Dept getDeptByDeptIds(String deptId) { |
| | | return baseMapper.getDeptByDeptIds(deptId); |
| | | } |
| | | } |