|
@@ -10,11 +10,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ydtech.modules.admin.dao.SysDeptMapper;
|
|
import com.ydtech.modules.admin.dao.SysDeptMapper;
|
|
|
import com.ydtech.modules.admin.dao.SysGeographyPositionMapper;
|
|
import com.ydtech.modules.admin.dao.SysGeographyPositionMapper;
|
|
|
import com.ydtech.modules.admin.dao.SysGeographyPositionRecordMapper;
|
|
import com.ydtech.modules.admin.dao.SysGeographyPositionRecordMapper;
|
|
|
|
|
+import com.ydtech.modules.admin.dao.SysUserMapper;
|
|
|
import com.ydtech.modules.admin.model.SysDept;
|
|
import com.ydtech.modules.admin.model.SysDept;
|
|
|
import com.ydtech.modules.admin.model.SysGeographyPosition;
|
|
import com.ydtech.modules.admin.model.SysGeographyPosition;
|
|
|
import com.ydtech.modules.admin.model.SysGeographyPositionRecord;
|
|
import com.ydtech.modules.admin.model.SysGeographyPositionRecord;
|
|
|
import com.ydtech.modules.admin.model.SysUser;
|
|
import com.ydtech.modules.admin.model.SysUser;
|
|
|
import com.ydtech.modules.admin.model.dto.*;
|
|
import com.ydtech.modules.admin.model.dto.*;
|
|
|
|
|
+import com.ydtech.modules.admin.model.po.SysPcAddress;
|
|
|
import com.ydtech.modules.admin.model.vo.*;
|
|
import com.ydtech.modules.admin.model.vo.*;
|
|
|
import com.ydtech.modules.admin.service.GeoService;
|
|
import com.ydtech.modules.admin.service.GeoService;
|
|
|
import com.ydtech.modules.admin.service.SysGeographyPositionRecordService;
|
|
import com.ydtech.modules.admin.service.SysGeographyPositionRecordService;
|
|
@@ -45,6 +47,9 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private SysDeptMapper sysDeptMapper;
|
|
private SysDeptMapper sysDeptMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private SysUserMapper sysUserMapper;
|
|
|
@Resource
|
|
@Resource
|
|
|
private GeoService geoService;
|
|
private GeoService geoService;
|
|
|
|
|
|
|
@@ -54,40 +59,129 @@ public class SysGeographyPositionServiceImpl extends ServiceImpl<SysGeographyPos
|
|
|
@Override
|
|
@Override
|
|
|
public SysGeographyPositionVo queryPosition(SysGeographyPositionDto sysGeographyPositionDto) {
|
|
public SysGeographyPositionVo queryPosition(SysGeographyPositionDto sysGeographyPositionDto) {
|
|
|
SysGeographyPositionVo sysGeographyPositionVo = new SysGeographyPositionVo();
|
|
SysGeographyPositionVo sysGeographyPositionVo = new SysGeographyPositionVo();
|
|
|
|
|
+ // 类型:1。机构 2.用户
|
|
|
|
|
+ Integer type = sysGeographyPositionDto.getType();
|
|
|
|
|
+
|
|
|
|
|
+ if (type == 1) {
|
|
|
|
|
+ List<SysGeographyPosition> list = sysGeographyPositionMapper.selectList(new LambdaQueryWrapper<SysGeographyPosition>()
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getProvince()), SysGeographyPosition::getProvince, sysGeographyPositionDto.getProvince())
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getCity()), SysGeographyPosition::getCity, sysGeographyPositionDto.getCity())
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getDistrict()), SysGeographyPosition::getDistrict, sysGeographyPositionDto.getDistrict())
|
|
|
|
|
+ .in(SysGeographyPosition::getSource, Arrays.asList("1", "2"))
|
|
|
|
|
+ .likeRight(StringUtils.isNotEmpty(sysGeographyPositionDto.getQueryId()), SysGeographyPosition::getId, sysGeographyPositionDto.getQueryId())
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getSource()), SysGeographyPosition::getSource, sysGeographyPositionDto.getSource())
|
|
|
|
|
+ .eq(sysGeographyPositionDto.getStatus() != null, SysGeographyPosition::getStatus, sysGeographyPositionDto.getStatus())
|
|
|
|
|
+ .orderByDesc(SysGeographyPosition::getCreateTime));
|
|
|
|
|
+ if (list.size() == 0) return new SysGeographyPositionVo();
|
|
|
|
|
+
|
|
|
|
|
+ List<SysGeographyPositionInfoVo> sysGeographyPositionList = BeanUtil.copyToList(list, SysGeographyPositionInfoVo.class);
|
|
|
|
|
+ //填充机构名
|
|
|
|
|
+ for (SysGeographyPositionInfoVo sysGeographyPositionInfoVo : sysGeographyPositionList) {
|
|
|
|
|
+ SysUser sysUser = sysUserService.getById(sysGeographyPositionInfoVo.getId());
|
|
|
|
|
+ if (sysUser == null) continue;
|
|
|
|
|
+ sysGeographyPositionInfoVo.setLeaderName(sysUser.getLeaderName());
|
|
|
|
|
+ SysDept sysDept = sysDeptMapper.selectOne(new LambdaQueryWrapper<SysDept>()
|
|
|
|
|
+ .eq(SysDept::getId, sysUser.getDeptId()).eq(SysDept::getDelFlag, 0));
|
|
|
|
|
+ if (sysDept == null) continue;
|
|
|
|
|
+ String deptName = getDeptName(sysUser.getDeptId());
|
|
|
|
|
+// sysGeographyPositionInfoVo.setDeptName(sysDept.getName());
|
|
|
|
|
+ sysGeographyPositionInfoVo.setDeptName(deptName);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- List<SysGeographyPosition> list = sysGeographyPositionMapper.selectList(new LambdaQueryWrapper<SysGeographyPosition>()
|
|
|
|
|
- .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getProvince()), SysGeographyPosition::getProvince, sysGeographyPositionDto.getProvince())
|
|
|
|
|
- .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getCity()), SysGeographyPosition::getCity, sysGeographyPositionDto.getCity())
|
|
|
|
|
- .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getDistrict()), SysGeographyPosition::getDistrict, sysGeographyPositionDto.getDistrict())
|
|
|
|
|
- .in(SysGeographyPosition::getSource, Arrays.asList("1", "2"))
|
|
|
|
|
- .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getSource()), SysGeographyPosition::getSource, sysGeographyPositionDto.getSource())
|
|
|
|
|
- .eq(sysGeographyPositionDto.getStatus() != null, SysGeographyPosition::getStatus, sysGeographyPositionDto.getStatus())
|
|
|
|
|
- .orderByDesc(SysGeographyPosition::getCreateTime));
|
|
|
|
|
- if (list.size() == 0) return new SysGeographyPositionVo();
|
|
|
|
|
|
|
+ sysGeographyPositionVo.setList(sysGeographyPositionList);
|
|
|
|
|
+
|
|
|
|
|
+ }else if (type == 2){
|
|
|
|
|
+ List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
|
|
|
|
|
+ .eq(SysUser::getLeaderId, sysGeographyPositionDto.getQueryId()).ne(SysUser::getStatus, 0));
|
|
|
|
|
+ List<String> collect = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
|
|
|
|
|
+ List<String> ids = new ArrayList<>();
|
|
|
|
|
+ List<String> idList = queryList(collect, ids);
|
|
|
|
|
+ collect.addAll(idList);
|
|
|
|
|
+ if (collect.size() == 0) {
|
|
|
|
|
+ return sysGeographyPositionVo;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- List<SysGeographyPositionInfoVo> sysGeographyPositionList = BeanUtil.copyToList(list, SysGeographyPositionInfoVo.class);
|
|
|
|
|
- //填充机构名
|
|
|
|
|
- for (SysGeographyPositionInfoVo sysGeographyPositionInfoVo : sysGeographyPositionList) {
|
|
|
|
|
- SysUser sysUser = sysUserService.getById(sysGeographyPositionInfoVo.getId());
|
|
|
|
|
- if (sysUser == null) continue;
|
|
|
|
|
- sysGeographyPositionInfoVo.setLeaderName(sysUser.getLeaderName());
|
|
|
|
|
- SysDept sysDept = sysDeptMapper.selectOne(new LambdaQueryWrapper<SysDept>()
|
|
|
|
|
- .eq(SysDept::getId, sysUser.getDeptId()).eq(SysDept::getDelFlag, 0));
|
|
|
|
|
- if (sysDept == null) continue;
|
|
|
|
|
- String deptName = getDeptName(sysUser.getDeptId());
|
|
|
|
|
|
|
+ List<SysGeographyPosition> list = sysGeographyPositionMapper.selectList(new LambdaQueryWrapper<SysGeographyPosition>()
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getProvince()), SysGeographyPosition::getProvince, sysGeographyPositionDto.getProvince())
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getCity()), SysGeographyPosition::getCity, sysGeographyPositionDto.getCity())
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getDistrict()), SysGeographyPosition::getDistrict, sysGeographyPositionDto.getDistrict())
|
|
|
|
|
+ .in(SysGeographyPosition::getSource, Arrays.asList("1", "2"))
|
|
|
|
|
+ .in(CollectionUtil.isNotEmpty(collect), SysGeographyPosition::getId, collect)
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getSource()), SysGeographyPosition::getSource, sysGeographyPositionDto.getSource())
|
|
|
|
|
+ .eq(sysGeographyPositionDto.getStatus() != null, SysGeographyPosition::getStatus, sysGeographyPositionDto.getStatus())
|
|
|
|
|
+ .orderByDesc(SysGeographyPosition::getCreateTime));
|
|
|
|
|
+ if (list.size() == 0) return new SysGeographyPositionVo();
|
|
|
|
|
+
|
|
|
|
|
+ List<SysGeographyPositionInfoVo> sysGeographyPositionList = BeanUtil.copyToList(list, SysGeographyPositionInfoVo.class);
|
|
|
|
|
+ //填充机构名
|
|
|
|
|
+ for (SysGeographyPositionInfoVo sysGeographyPositionInfoVo : sysGeographyPositionList) {
|
|
|
|
|
+ SysUser sysUser = sysUserService.getById(sysGeographyPositionInfoVo.getId());
|
|
|
|
|
+ if (sysUser == null) continue;
|
|
|
|
|
+ sysGeographyPositionInfoVo.setLeaderName(sysUser.getLeaderName());
|
|
|
|
|
+ SysDept sysDept = sysDeptMapper.selectOne(new LambdaQueryWrapper<SysDept>()
|
|
|
|
|
+ .eq(SysDept::getId, sysUser.getDeptId()).eq(SysDept::getDelFlag, 0));
|
|
|
|
|
+ if (sysDept == null) continue;
|
|
|
|
|
+ String deptName = getDeptName(sysUser.getDeptId());
|
|
|
// sysGeographyPositionInfoVo.setDeptName(sysDept.getName());
|
|
// sysGeographyPositionInfoVo.setDeptName(sysDept.getName());
|
|
|
- sysGeographyPositionInfoVo.setDeptName(deptName);
|
|
|
|
|
|
|
+ sysGeographyPositionInfoVo.setDeptName(deptName);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ sysGeographyPositionVo.setList(sysGeographyPositionList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ }else {
|
|
|
|
|
+
|
|
|
|
|
+ List<SysGeographyPosition> list = sysGeographyPositionMapper.selectList(new LambdaQueryWrapper<SysGeographyPosition>()
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getProvince()), SysGeographyPosition::getProvince, sysGeographyPositionDto.getProvince())
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getCity()), SysGeographyPosition::getCity, sysGeographyPositionDto.getCity())
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getDistrict()), SysGeographyPosition::getDistrict, sysGeographyPositionDto.getDistrict())
|
|
|
|
|
+ .in(SysGeographyPosition::getSource, Arrays.asList("1", "2"))
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(sysGeographyPositionDto.getSource()), SysGeographyPosition::getSource, sysGeographyPositionDto.getSource())
|
|
|
|
|
+ .eq(sysGeographyPositionDto.getStatus() != null, SysGeographyPosition::getStatus, sysGeographyPositionDto.getStatus())
|
|
|
|
|
+ .orderByDesc(SysGeographyPosition::getCreateTime));
|
|
|
|
|
+ if (list.size() == 0) return new SysGeographyPositionVo();
|
|
|
|
|
+
|
|
|
|
|
+ List<SysGeographyPositionInfoVo> sysGeographyPositionList = BeanUtil.copyToList(list, SysGeographyPositionInfoVo.class);
|
|
|
|
|
+ //填充机构名
|
|
|
|
|
+ for (SysGeographyPositionInfoVo sysGeographyPositionInfoVo : sysGeographyPositionList) {
|
|
|
|
|
+ SysUser sysUser = sysUserService.getById(sysGeographyPositionInfoVo.getId());
|
|
|
|
|
+ if (sysUser == null) continue;
|
|
|
|
|
+ sysGeographyPositionInfoVo.setLeaderName(sysUser.getLeaderName());
|
|
|
|
|
+ SysDept sysDept = sysDeptMapper.selectOne(new LambdaQueryWrapper<SysDept>()
|
|
|
|
|
+ .eq(SysDept::getId, sysUser.getDeptId()).eq(SysDept::getDelFlag, 0));
|
|
|
|
|
+ if (sysDept == null) continue;
|
|
|
|
|
+ String deptName = getDeptName(sysUser.getDeptId());
|
|
|
|
|
+// sysGeographyPositionInfoVo.setDeptName(sysDept.getName());
|
|
|
|
|
+ sysGeographyPositionInfoVo.setDeptName(deptName);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ sysGeographyPositionVo.setList(sysGeographyPositionList);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- sysGeographyPositionVo.setList(sysGeographyPositionList);
|
|
|
|
|
- Long aLong = sysGeographyPositionMapper.selectCount(new LambdaQueryWrapper<SysGeographyPosition>().eq(SysGeographyPosition::getStatus, 1).in(SysGeographyPosition::getSource, Arrays.asList("1", "2")));
|
|
|
|
|
- sysGeographyPositionVo.setManNum(aLong);
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
return sysGeographyPositionVo;
|
|
return sysGeographyPositionVo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private List<String> queryList(List<String> collect, List<String> ids) {
|
|
|
|
|
+ if (collect.size() > 0) {
|
|
|
|
|
+ for (String id : collect) {
|
|
|
|
|
+ List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
|
|
|
|
|
+ .eq(SysUser::getLeaderId, id).ne(SysUser::getStatus, 0));
|
|
|
|
|
+ if (sysUsers.size() > 0) {
|
|
|
|
|
+ List<String> list = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList());
|
|
|
|
|
+ ids.addAll(list);
|
|
|
|
|
+ queryList(list, ids);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return ids;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private String getDeptName(String deptId) {
|
|
private String getDeptName(String deptId) {
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
SysDept sysDept = sysDeptMapper.selectOne(new LambdaQueryWrapper<SysDept>()
|
|
SysDept sysDept = sysDeptMapper.selectOne(new LambdaQueryWrapper<SysDept>()
|