|
|
@@ -7,37 +7,42 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
-import com.xunmei.common.core.enums.OrgTypeEnum;
|
|
|
+import com.xunmei.common.core.domain.device.domain.SysMultiLayerDictionary;
|
|
|
import com.xunmei.common.core.exception.ServiceException;
|
|
|
import com.xunmei.common.core.utils.DateHelper;
|
|
|
import com.xunmei.common.core.utils.DateUtils;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
-import com.xunmei.system.api.RemoteMediatorService;
|
|
|
import com.xunmei.system.api.RemoteProtectionService;
|
|
|
import com.xunmei.system.api.domain.SysDevice;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import com.xunmei.system.api.dto.ProtectionDTO;
|
|
|
import com.xunmei.system.api.dto.SysDeviceInnerListDto;
|
|
|
import com.xunmei.system.api.vo.ProtectionVO;
|
|
|
+import com.xunmei.system.dto.SysDevicePageDto;
|
|
|
import com.xunmei.system.mapper.SysDeviceMapper;
|
|
|
import com.xunmei.system.mapper.SysOrgMapper;
|
|
|
import com.xunmei.system.service.ISysDeviceService;
|
|
|
+import com.xunmei.system.service.ISysMultiLayerDictionaryService;
|
|
|
import com.xunmei.system.service.ISysOrgService;
|
|
|
import com.xunmei.system.util.DeviceExport;
|
|
|
import com.xunmei.system.vo.area.AccessType;
|
|
|
import com.xunmei.system.vo.area.HostVO;
|
|
|
import com.xunmei.system.vo.area.VideoVO;
|
|
|
+import com.xunmei.system.vo.device.SysDevicePageVo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.net.URLEncoder;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 【请填写功能名称】Service业务层处理
|
|
|
@@ -56,77 +61,42 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
|
|
|
private SysOrgMapper sysOrgMapper;
|
|
|
@Autowired
|
|
|
private RemoteProtectionService remoteProtectionService;
|
|
|
- @Autowired
|
|
|
- private RemoteMediatorService remoteMediatorService;
|
|
|
+ @Resource
|
|
|
+ private ISysMultiLayerDictionaryService dictionaryService;
|
|
|
@Autowired
|
|
|
private RedisTemplate redisTemplate;
|
|
|
|
|
|
@Override
|
|
|
- public TableDataInfo<SysDevice> selectPage(SysDevice sysDevice) {
|
|
|
- //未删除
|
|
|
- sysDevice.setDelFlag("0");
|
|
|
- Page<SysDevice> page;
|
|
|
- //分页
|
|
|
- if (sysDevice.getPageNum() != null && sysDevice.getPageSize() != null) {
|
|
|
- page = new Page<>(sysDevice.getPageNum(), sysDevice.getPageSize());
|
|
|
- } else {
|
|
|
- page = new Page<>();
|
|
|
- }
|
|
|
- //查询条件
|
|
|
- String n = sysDevice.getDeviceName();
|
|
|
- sysDevice.setDeviceName(null);
|
|
|
- QueryWrapper<SysDevice> query = new QueryWrapper<>(sysDevice);
|
|
|
- if (null != n) {
|
|
|
- query.like("device_name", n);
|
|
|
- }
|
|
|
+ public TableDataInfo<SysDevicePageVo> selectPage(SysDevicePageDto req) {
|
|
|
+
|
|
|
//下穿
|
|
|
- if (sysDevice.getCheckSub()) {
|
|
|
- List<Long> ids = orgService.selectCheckSubOrgIdList(sysDevice.getOrgId());
|
|
|
- //清空前端传递的org_id
|
|
|
- sysDevice.setOrgId(null);
|
|
|
- //添加in条件
|
|
|
- query.in("org_id", ids);
|
|
|
- }
|
|
|
- //时间范围查询
|
|
|
- if (sysDevice.getParams().get("beginTime") != null && sysDevice.getParams().get("endTime") != null) {
|
|
|
- query.between("create_time", sysDevice.getParams().get("beginTime"), sysDevice.getParams().get("endTime"));
|
|
|
+ if (req.getCheckSub()) {
|
|
|
+ SysOrg org = orgService.getById(req.getOrgId());
|
|
|
+ req.setOrgPath(org.getPath());
|
|
|
}
|
|
|
+
|
|
|
//获取数据
|
|
|
- page = sysDeviceMapper.selectPage(page, query);
|
|
|
- if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(page.getRecords()) && page.getTotal() > 0) {
|
|
|
- if (sysDevice.getPageNum() != null && sysDevice.getPageSize() != null) {
|
|
|
- page = new Page<>(sysDevice.getPageNum() - 1, sysDevice.getPageSize());
|
|
|
- } else {
|
|
|
- page = new Page<>();
|
|
|
- }
|
|
|
- page = sysDeviceMapper.selectPage(page, query);
|
|
|
- }
|
|
|
- if (ObjectUtil.isNotEmpty(page.getRecords())) {
|
|
|
- List<Long> collect = page.getRecords().stream().map(SysDevice::getOrgId).collect(Collectors.toList());
|
|
|
- List<SysOrg> sysOrgs = orgService.selectByOrgIdList(collect);
|
|
|
- for (SysDevice record : page.getRecords()) {
|
|
|
- Optional<SysOrg> any = sysOrgs.stream().filter(r -> ObjectUtil.equal(r.getId(), record.getOrgId())).findAny();
|
|
|
- if (!any.isPresent()) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- SysOrg sysOrg = any.get();
|
|
|
- if (OrgTypeEnum.DIQU_HANG_SHE.getCode().toString().equals(sysOrg.getOrgType())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (OrgTypeEnum.HANG_SHE.getCode().toString().equals(sysOrg.getOrgType())) {
|
|
|
- record.setAffiliatedArea(sysOrg.getAffiliatedArea());
|
|
|
- continue;
|
|
|
- }
|
|
|
- record.setAffiliatedArea(sysOrg.getAffiliatedArea());
|
|
|
- record.setAffiliatedBank(sysOrg.getAffiliatedBank());
|
|
|
- }
|
|
|
- }
|
|
|
+ Page<SysDevicePageVo> page = sysDeviceMapper.selectPageData(req.getPageRequest(), req);
|
|
|
+ dealDictData(page.getRecords());
|
|
|
//抓换为TableDataInfo适配前端
|
|
|
return TableDataInfo.build(page);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void dealDictData(List<SysDevicePageVo> list) {
|
|
|
+ if (ObjectUtil.isEmpty(list)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<SysMultiLayerDictionary> dictionaryList = dictionaryService.list();
|
|
|
+ for (SysDevicePageVo vo : list) {
|
|
|
+ dictionaryList.stream().filter(r -> ObjectUtil.equal(vo.getAssetType(), r.getId().toString())).findFirst().ifPresent(r -> vo.setAssetType(r.getName()));
|
|
|
+ dictionaryList.stream().filter(r -> ObjectUtil.equal(vo.getDeviceType(), r.getId().toString())).findFirst().ifPresent(r -> vo.setDeviceType(r.getName()));
|
|
|
+ dictionaryList.stream().filter(r -> ObjectUtil.equal(vo.getDeviceBrand(), r.getId().toString())).findFirst().ifPresent(r -> vo.setDeviceBrand(r.getName()));
|
|
|
+ dictionaryList.stream().filter(r -> ObjectUtil.equal(vo.getDeviceModel(), r.getId().toString())).findFirst().ifPresent(r -> vo.setDeviceModel(r.getName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询列表
|
|
|
*
|
|
|
@@ -254,15 +224,20 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
|
|
|
/**
|
|
|
* 新增【请填写功能名称】
|
|
|
* 该方法只适合单个新增,批量导入时,会导致报警主机新增时数据报错
|
|
|
+ *
|
|
|
* @param sysDevice 【请填写功能名称】
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
public int insertSysDevice(SysDevice sysDevice) {
|
|
|
sysDevice.setCreateTime(DateUtils.getNowDate());
|
|
|
+ sysDevice.setUpdateTime(DateUtils.getNowDate());
|
|
|
sysDevice.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ sysDevice.setUpdateBy(SecurityUtils.getUsername());
|
|
|
SysOrg sysOrg = orgService.selectSysOrgById(sysDevice.getOrgId());
|
|
|
sysDevice.setOrgName(sysOrg.getShortName());
|
|
|
+ sysDevice.setOrgPath(sysOrg.getPath());
|
|
|
+ sysDevice.setOrgId(sysOrg.getId());
|
|
|
SysDevice sysDevice1 = this.checkName(sysDevice.getOrgId(), sysDevice.getDeviceName());
|
|
|
if (null != sysDevice1) {
|
|
|
throw new RuntimeException("设备名称重复");
|