|
|
@@ -3,6 +3,7 @@ package com.ydtech.modules.admin.service.impl;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ydtech.modules.admin.dao.SysDeptMapper;
|
|
|
@@ -28,6 +29,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -95,7 +97,7 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
|
|
|
.in(SysPcAddress::getSource, Arrays.asList("1", "2"))
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getSource()), SysPcAddress::getSource, sysPcAddressDto.getSource())
|
|
|
- .eq(sysPcAddressDto.getStatus()!=null, SysPcAddress::getStatus, sysPcAddressDto.getStatus())
|
|
|
+ .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus())
|
|
|
.orderByDesc(SysPcAddress::getOperationTime));
|
|
|
|
|
|
return sysPcAddresses;
|
|
|
@@ -121,27 +123,27 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getCity()), SysPcAddress::getCity, sysPcAddressDto.getCity())
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
|
|
|
.in(SysPcAddress::getSource, Arrays.asList("1", "2"))
|
|
|
- .eq(sysPcAddressDto.getStatus()!=null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
|
|
|
+ .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
|
|
|
Long channelNum = sysPcAddressMapper.selectCount(new LambdaQueryWrapper<SysPcAddress>()
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getProvince()), SysPcAddress::getProvince, sysPcAddressDto.getProvince())
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getCity()), SysPcAddress::getCity, sysPcAddressDto.getCity())
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
|
|
|
.eq(SysPcAddress::getSource, 1)
|
|
|
- .eq(sysPcAddressDto.getStatus()!=null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
|
|
|
+ .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
|
|
|
Long proxyNum = sysPcAddressMapper.selectCount(new LambdaQueryWrapper<SysPcAddress>()
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getProvince()), SysPcAddress::getProvince, sysPcAddressDto.getProvince())
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getCity()), SysPcAddress::getCity, sysPcAddressDto.getCity())
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
|
|
|
.eq(SysPcAddress::getSource, 2)
|
|
|
- .eq(sysPcAddressDto.getStatus()!=null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
|
|
|
+ .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
|
|
|
|
|
|
Long onlineNum = sysPcAddressMapper.selectCount(new LambdaQueryWrapper<SysPcAddress>()
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getProvince()), SysPcAddress::getProvince, sysPcAddressDto.getProvince())
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getCity()), SysPcAddress::getCity, sysPcAddressDto.getCity())
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
|
|
|
.in(SysPcAddress::getSource, Arrays.asList("1", "2"))
|
|
|
- .eq(sysPcAddressDto.getStatus()==null,SysPcAddress::getStatus, 1)
|
|
|
- .eq(sysPcAddressDto.getStatus()!=null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
|
|
|
+ .eq(sysPcAddressDto.getStatus() == null, SysPcAddress::getStatus, 1)
|
|
|
+ .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
|
|
|
|
|
|
|
|
|
sysPcAddressNumVo.setAllNum(all);
|
|
|
@@ -162,7 +164,7 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getDistrict()), SysPcAddress::getDistrict, sysPcAddressDto.getDistrict())
|
|
|
.in(SysPcAddress::getSource, Arrays.asList("1", "2"))
|
|
|
.eq(StringUtils.isNotEmpty(sysPcAddressDto.getSource()), SysPcAddress::getSource, sysPcAddressDto.getSource())
|
|
|
- .eq(sysPcAddressDto.getStatus()!=null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
|
|
|
+ .eq(sysPcAddressDto.getStatus() != null, SysPcAddress::getStatus, sysPcAddressDto.getStatus()));
|
|
|
|
|
|
if (CollectionUtil.isEmpty(sysPcAddresses)) return regionInfoVos;
|
|
|
|
|
|
@@ -199,7 +201,7 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
|
|
|
wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getLat()), SysPcAddress::getLatitude, addressInfoDto.getLat());
|
|
|
wrapper.in(SysPcAddress::getSource, Arrays.asList("1", "2"));
|
|
|
wrapper.eq(StringUtils.isNotEmpty(addressInfoDto.getSource()), SysPcAddress::getSource, addressInfoDto.getSource());
|
|
|
- wrapper.eq(addressInfoDto.getStatus()!=null, SysPcAddress::getStatus, addressInfoDto.getStatus());
|
|
|
+ wrapper.eq(addressInfoDto.getStatus() != null, SysPcAddress::getStatus, addressInfoDto.getStatus());
|
|
|
wrapper.orderByDesc(SysPcAddress::getOperationTime);
|
|
|
|
|
|
Page<SysPcAddress> insOrdersPage = page(page, wrapper);
|
|
|
@@ -209,32 +211,82 @@ public class SysPcAddressServiceImpl extends ServiceImpl<SysPcAddressMapper, Sys
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PcAddressHistoryInfoVo getPcAddress(String dates) {
|
|
|
+ public PcAddressHistoryInfoVo getPcAddress(String startTime, String endTime, String source) {
|
|
|
PcAddressHistoryInfoVo pcAddressHistoryInfoVo = new PcAddressHistoryInfoVo();
|
|
|
- QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
|
|
|
- // 指定 COUNT(DISTINCT user_id) 查询
|
|
|
- queryWrapper.select("COUNT(DISTINCT user_id) AS total").likeRight(StringUtils.isNotEmpty(dates), "operation_time", dates)
|
|
|
- .in("source", Arrays.asList(1, 2));
|
|
|
- Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
|
|
|
- Long total = (Long) result.get("total");
|
|
|
- pcAddressHistoryInfoVo.setOnlineNum(total);
|
|
|
- if (StringUtils.isNullOrEmpty(dates)) {
|
|
|
- Date date = new Date();
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- dates = simpleDateFormat.format(date);
|
|
|
+ if (StringUtils.isEmpty(startTime) || startTime.equals(endTime)) {
|
|
|
+ if (StringUtils.isNullOrEmpty(startTime)) {
|
|
|
+ Date date = new Date();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ startTime = simpleDateFormat.format(date);
|
|
|
+ }
|
|
|
+ QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
|
|
|
+ // 指定 COUNT(DISTINCT user_id) 查询
|
|
|
+ queryWrapper.select("COUNT(DISTINCT user_id) AS total")
|
|
|
+ .likeRight(StringUtils.isNotEmpty(startTime), "operation_time", startTime)
|
|
|
+ .in("source", Arrays.asList(1, 2))
|
|
|
+ .eq(StringUtils.isNotEmpty(source),"source",source);
|
|
|
+ Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
|
|
|
+ Long total = (Long) result.get("total");
|
|
|
+ pcAddressHistoryInfoVo.setOnlineNum(total);
|
|
|
+
|
|
|
+ List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddress(startTime,source);
|
|
|
+ pcAddressHistoryInfoVo.setList(pcAddress);
|
|
|
+
|
|
|
+ List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressInfo(startTime,source);
|
|
|
+ System.out.println("********************" + sysPcAddressHistories.size());
|
|
|
+ pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ startTime = startTime + " 00:00:01";
|
|
|
+ endTime = endTime + " 23:59:59";
|
|
|
+ try {
|
|
|
+ Date parse = simpleDateFormat.parse(startTime);
|
|
|
+ Date parse1 = simpleDateFormat.parse(endTime);
|
|
|
+ startTime = simpleDateFormat.format(parse);
|
|
|
+ endTime = simpleDateFormat.format(parse1);
|
|
|
+
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ QueryWrapper<SysPcAddressHistory> queryWrapper = new QueryWrapper<>();
|
|
|
+ // 指定 COUNT(DISTINCT user_id) 查询
|
|
|
+ queryWrapper.select("COUNT(DISTINCT user_id) AS total").between("operation_time", startTime, endTime)
|
|
|
+ .in("source", Arrays.asList(1, 2)).eq(StringUtils.isNotEmpty(source),"source",source);
|
|
|
+ Map<String, Object> result = sysPcAddressHistoryService.getMap(queryWrapper);
|
|
|
+ Long total = (Long) result.get("total");
|
|
|
+ pcAddressHistoryInfoVo.setOnlineNum(total);
|
|
|
+
|
|
|
+ List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddressSection(startTime, endTime,source);
|
|
|
+
|
|
|
+ pcAddressHistoryInfoVo.setList(pcAddress);
|
|
|
+
|
|
|
+ List<SysPcAddressHistory> sysPcAddressHistories = sysPcAddressHistoryMapper.getPcAddressHistory(startTime, endTime,source);
|
|
|
+ System.out.println("********************" + sysPcAddressHistories.size());
|
|
|
+ pcAddressHistoryInfoVo.setPcAddressList(sysPcAddressHistories);
|
|
|
}
|
|
|
- List<PcAddressHistoryTimeVo> pcAddress = sysPcAddressHistoryMapper.getPcAddress(dates);
|
|
|
- pcAddressHistoryInfoVo.setList(pcAddress);
|
|
|
|
|
|
return pcAddressHistoryInfoVo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<SysPcAddress> getOnlinePeople() {
|
|
|
- return sysPcAddressMapper.selectList(new LambdaQueryWrapper<SysPcAddress>().eq(SysPcAddress::getStatus,1));
|
|
|
+ return sysPcAddressMapper.selectList(new LambdaQueryWrapper<SysPcAddress>().eq(SysPcAddress::getStatus, 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BasePageResult<SysPcAddressHistory> queryPcAddressHistoryInfo(PcAddressInfoDto addressInfoDto) {
|
|
|
+ Page page = new Page(addressInfoDto.getPageNum(), addressInfoDto.getPageSize());
|
|
|
+
|
|
|
+ IPage<SysPcAddressHistory> sysPcAddressHistoryIPage=sysPcAddressHistoryMapper.queryAddressHistory(page,addressInfoDto);
|
|
|
+
|
|
|
+ return new BasePageResult<>(addressInfoDto.getPageNum(), addressInfoDto.getPageSize(), sysPcAddressHistoryIPage.getTotal(), sysPcAddressHistoryIPage.getPages(),
|
|
|
+ sysPcAddressHistoryIPage.getRecords());
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|