|
@@ -3,15 +3,22 @@ package com.ydtech.modules.admin.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.ydtech.modules.admin.dao.SysDeptMapper;
|
|
|
import com.ydtech.modules.admin.dao.SysPcAddressHistoryMapper;
|
|
import com.ydtech.modules.admin.dao.SysPcAddressHistoryMapper;
|
|
|
|
|
+import com.ydtech.modules.admin.model.SysDept;
|
|
|
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.dto.SysGeographyPositionPageDto;
|
|
import com.ydtech.modules.admin.model.dto.SysGeographyPositionPageDto;
|
|
|
import com.ydtech.modules.admin.model.po.SysPcAddressHistory;
|
|
import com.ydtech.modules.admin.model.po.SysPcAddressHistory;
|
|
|
import com.ydtech.modules.admin.service.SysPcAddressHistoryService;
|
|
import com.ydtech.modules.admin.service.SysPcAddressHistoryService;
|
|
|
|
|
+import com.ydtech.modules.admin.service.SysUserService;
|
|
|
import com.ydtech.modules.order.entity.BasePageResult;
|
|
import com.ydtech.modules.order.entity.BasePageResult;
|
|
|
import com.ydtech.utils.StringUtils;
|
|
import com.ydtech.utils.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @author Administrator
|
|
* @author Administrator
|
|
|
* @description 针对表【sys_pc_address_history(pc获取ip地址记录表)】的数据库操作Service实现
|
|
* @description 针对表【sys_pc_address_history(pc获取ip地址记录表)】的数据库操作Service实现
|
|
@@ -20,6 +27,12 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
@Service
|
|
|
public class SysPcAddressHistoryServiceImpl extends ServiceImpl<SysPcAddressHistoryMapper, SysPcAddressHistory>
|
|
public class SysPcAddressHistoryServiceImpl extends ServiceImpl<SysPcAddressHistoryMapper, SysPcAddressHistory>
|
|
|
implements SysPcAddressHistoryService {
|
|
implements SysPcAddressHistoryService {
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private SysUserService sysUserService;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private SysDeptMapper sysDeptMapper;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public BasePageResult<SysPcAddressHistory> queryPositionList(SysGeographyPositionPageDto sysGeographyPositionPageDto) {
|
|
public BasePageResult<SysPcAddressHistory> queryPositionList(SysGeographyPositionPageDto sysGeographyPositionPageDto) {
|
|
@@ -30,11 +43,97 @@ public class SysPcAddressHistoryServiceImpl extends ServiceImpl<SysPcAddressHist
|
|
|
wrapper.orderByDesc(SysPcAddressHistory::getOperationTime);
|
|
wrapper.orderByDesc(SysPcAddressHistory::getOperationTime);
|
|
|
|
|
|
|
|
Page<SysPcAddressHistory> insOrdersPage = page(page, wrapper);
|
|
Page<SysPcAddressHistory> insOrdersPage = page(page, wrapper);
|
|
|
|
|
+ List<SysPcAddressHistory> records = insOrdersPage.getRecords();
|
|
|
|
|
+ for (SysPcAddressHistory record : records) {
|
|
|
|
|
+ SysUser sysUser = sysUserService.getById(record.getUserId());
|
|
|
|
|
+ if (sysUser == null) continue;
|
|
|
|
|
+ record.setLeaderName(sysUser.getLeaderName());
|
|
|
|
|
+ String deptName = getDeptName(sysUser.getDeptId());
|
|
|
|
|
+ record.setDeptName(deptName);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return new BasePageResult<>(sysGeographyPositionPageDto.getPageNum(), page.getSize(), insOrdersPage.getTotal(), page.getPages(),
|
|
return new BasePageResult<>(sysGeographyPositionPageDto.getPageNum(), page.getSize(), insOrdersPage.getTotal(), page.getPages(),
|
|
|
insOrdersPage.getRecords());
|
|
insOrdersPage.getRecords());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private String getDeptName(String deptId) {
|
|
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
|
|
+ SysDept sysDept = sysDeptMapper.selectOne(new LambdaQueryWrapper<SysDept>()
|
|
|
|
|
+ .eq(SysDept::getId, deptId).eq(SysDept::getDelFlag, 0));
|
|
|
|
|
+ if (StringUtils.isEmpty(sysDept.getComlevel())) {
|
|
|
|
|
+ SysDept sysDept5 = sysDeptMapper.selectById(sysDept.getParentId());
|
|
|
|
|
+ if (sysDept5 == null) {
|
|
|
|
|
+ stringBuilder.append(sysDept.getName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ SysDept sysDept4 = sysDeptMapper.selectById(sysDept5.getParentId());
|
|
|
|
|
+ if (sysDept4 == null) {
|
|
|
|
|
+ stringBuilder.append(sysDept5.getName()).append("-").append(sysDept.getName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ SysDept sysDept3 = sysDeptMapper.selectById(sysDept4.getParentId());
|
|
|
|
|
+ if (sysDept3 == null) {
|
|
|
|
|
+ stringBuilder.append(sysDept4.getName())
|
|
|
|
|
+ .append("-").append(sysDept5.getName()).append("-").append(sysDept.getName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ SysDept sysDept2 = sysDeptMapper.selectById(sysDept3.getParentId());
|
|
|
|
|
+ if (sysDept2 == null) {
|
|
|
|
|
+ stringBuilder.append(sysDept3.getName()).append("-").append(sysDept4.getName())
|
|
|
|
|
+ .append("-").append(sysDept5.getName()).append("-").append(sysDept.getName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ stringBuilder.append(sysDept2.getName()).append("-").append(sysDept3.getName())
|
|
|
|
|
+ .append("-").append(sysDept4.getName()).append("-").append(sysDept5.getName()).append("-").append(sysDept.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (sysDept.getComlevel().equals("5")) {
|
|
|
|
|
+ SysDept sysDept4 = sysDeptMapper.selectById(sysDept.getParentId());
|
|
|
|
|
+ if (sysDept4 == null) {
|
|
|
|
|
+ stringBuilder.append(sysDept.getName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ SysDept sysDept3 = sysDeptMapper.selectById(sysDept4.getParentId());
|
|
|
|
|
+ if (sysDept3 == null) {
|
|
|
|
|
+ stringBuilder.append(sysDept4.getName()).append("-").append(sysDept.getName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ SysDept sysDept2 = sysDeptMapper.selectById(sysDept3.getParentId());
|
|
|
|
|
+ if (sysDept2 == null) {
|
|
|
|
|
+ stringBuilder.append(sysDept3.getName()).append("-").append(sysDept4.getName()).append("-").append(sysDept.getName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ stringBuilder.append(sysDept2.getName()).append("-").append(sysDept3.getName()).append("-").append(sysDept4.getName()).append("-").append(sysDept.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (sysDept.getComlevel().equals("4")) {
|
|
|
|
|
+ SysDept sysDept3 = sysDeptMapper.selectById(sysDept.getParentId());
|
|
|
|
|
+ if (sysDept3 == null) {
|
|
|
|
|
+ stringBuilder.append(sysDept.getName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ SysDept sysDept2 = sysDeptMapper.selectById(sysDept3.getParentId());
|
|
|
|
|
+ if (sysDept2 == null) {
|
|
|
|
|
+ stringBuilder.append(sysDept3.getName()).append("-").append(sysDept.getName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ stringBuilder.append(sysDept2.getName()).append("-").append(sysDept3.getName()).append("-").append(sysDept.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (sysDept.getComlevel().equals("3")) {
|
|
|
|
|
+ SysDept sysDept2 = sysDeptMapper.selectById(sysDept.getParentId());
|
|
|
|
|
+ if (sysDept2 == null) {
|
|
|
|
|
+ stringBuilder.append(sysDept.getName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ stringBuilder.append(sysDept2.getName()).append("-").append(sysDept.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } else if (sysDept.getComlevel().equals("2")) {
|
|
|
|
|
+ stringBuilder.append(sysDept.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ String s = stringBuilder.toString();
|
|
|
|
|
+ if (s.contains("总部-")) {
|
|
|
|
|
+ stringBuilder.replace(0, 3, "");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return stringBuilder.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|