|
@@ -1,11 +1,22 @@
|
|
|
package com.bizmatics.service.impl;
|
|
|
|
|
|
-import com.bizmatics.model.PlatformArea;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.bizmatics.common.core.bean.CommonPage;
|
|
|
+import com.bizmatics.model.*;
|
|
|
+import com.bizmatics.model.vo.DeviceVo;
|
|
|
+import com.bizmatics.model.vo.PlatformAreaVo;
|
|
|
+import com.bizmatics.model.vo.SiteDeviceList;
|
|
|
import com.bizmatics.persistence.mapper.PlatformAreaMapper;
|
|
|
import com.bizmatics.service.PlatformAreaService;
|
|
|
import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 服务实现类
|
|
@@ -17,6 +28,17 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class PlatformAreaServiceImpl extends AbstractCrudService<PlatformAreaMapper, PlatformArea> implements PlatformAreaService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SiteServiceImpl siteService;
|
|
|
+ @Autowired
|
|
|
+ private DeviceServiceImpl deviceService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DeviceStatusServiceImpl deviceStatusService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DeviceAttributeServiceImpl deviceAttributeService;
|
|
|
+
|
|
|
@Override
|
|
|
public void platformAreaAdd(PlatformArea platformArea){
|
|
|
platformArea.setEnable(1);
|
|
@@ -28,7 +50,74 @@ public class PlatformAreaServiceImpl extends AbstractCrudService<PlatformAreaMap
|
|
|
this.updateById(platformArea);
|
|
|
}
|
|
|
|
|
|
- public void platformAreaList(){
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> platformAreaList(int id){
|
|
|
+ LambdaQueryWrapper<PlatformArea> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PlatformArea::getEnable, 1).eq(PlatformArea::getId, id);
|
|
|
+ List<PlatformArea> platformAreaList = this.list(queryWrapper);
|
|
|
+ PlatformArea platformArea = (PlatformArea)platformAreaList.get(0);
|
|
|
+ LambdaQueryWrapper<Site> siteQueryWrapper = Wrappers.lambdaQuery();
|
|
|
+ siteQueryWrapper.eq(Site::getStationAreaId,platformArea.getId()).eq(Site::getEnable, 1);
|
|
|
+ List<Site> siteList = siteService.list(siteQueryWrapper);
|
|
|
+ int siteCount = siteList.size();
|
|
|
+ LambdaQueryWrapper<Device> deviceQueryWrapper = Wrappers.lambdaQuery();
|
|
|
+ deviceQueryWrapper.in(Device::getSiteId,siteList).eq(Device::getEnable, 1);
|
|
|
+ int deviceCount = deviceService.count(deviceQueryWrapper);
|
|
|
+ PlatformAreaVo platformAreaVo = new PlatformAreaVo();
|
|
|
+ platformAreaVo.setPlatformAreaName(platformArea.getPlatformAreaName());
|
|
|
+ platformAreaVo.setPlatformAreaAddress(platformArea.getPlatformAreaAddress());
|
|
|
+ platformAreaVo.setPlatformAreaCode(platformArea.getPlatformAreaCode());
|
|
|
+ platformAreaVo.setSiteCount(siteCount);
|
|
|
+ platformAreaVo.setDeviceCount(deviceCount);
|
|
|
+ platformAreaVo.setSite(siteList);
|
|
|
+ return (List<Map<String, Object>>) platformAreaVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PlatformAreaVo> platformAreaListOne(String platformAreaName){
|
|
|
+ List<PlatformAreaVo> PlatformAreaVoSite = baseMapper.siteCount(platformAreaName);
|
|
|
+ List<PlatformAreaVo> PlatformAreaVoDevice =baseMapper.deviceCount(platformAreaName);
|
|
|
+ for (int i = 0; i < PlatformAreaVoSite.size(); i++) {
|
|
|
+ PlatformAreaVo one =(PlatformAreaVo)PlatformAreaVoSite.get(i);
|
|
|
+ for (int j = 0; j < PlatformAreaVoSite.size(); j++) {
|
|
|
+ PlatformAreaVo two =(PlatformAreaVo)PlatformAreaVoDevice.get(j);
|
|
|
+ if (one.getId()==two.getId()){
|
|
|
+ one.setDeviceCount(two.getDeviceCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return PlatformAreaVoSite;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void platformAreaDel(int id){
|
|
|
+ PlatformArea platformArea = new PlatformArea();
|
|
|
+ platformArea.setId(id);
|
|
|
+ platformArea.setEnable(0);
|
|
|
+ this.updateById(platformArea);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SiteDeviceList> siteDeviceList(int stationAreaId){
|
|
|
+ List<SiteDeviceList> siteDeviceList = baseMapper.deviceList(stationAreaId);
|
|
|
+ return siteDeviceList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void siteDeviceUpdate (DeviceVo deviceVo){
|
|
|
+ deviceService.updateById(deviceVo.getDevice());
|
|
|
+ deviceAttributeService.updateById(deviceVo.getDeviceAttribute());
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void siteDeviceDel(int deviceId,int deviceAttributeId){
|
|
|
+ Device device = new Device();
|
|
|
+ DeviceAttribute deviceAttribute = new DeviceAttribute();
|
|
|
+ device.setId(deviceId);
|
|
|
+ device.setEnable(0);
|
|
|
+ deviceAttribute.setId(deviceAttributeId);
|
|
|
+ deviceAttribute.setEnable(0);
|
|
|
+ deviceService.updateById(device);
|
|
|
+ deviceAttributeService.updateById(deviceAttribute);
|
|
|
}
|
|
|
}
|