|
@@ -13,7 +13,9 @@ import com.bizmatics.common.core.util.FileUtils;
|
|
import com.bizmatics.common.core.util.StringUtils;
|
|
import com.bizmatics.common.core.util.StringUtils;
|
|
import com.bizmatics.common.spring.util.GlobalUtils;
|
|
import com.bizmatics.common.spring.util.GlobalUtils;
|
|
import com.bizmatics.model.*;
|
|
import com.bizmatics.model.*;
|
|
|
|
+import com.bizmatics.persistence.mapper.DeviceMapper;
|
|
import com.bizmatics.persistence.mapper.RtAnalogDataMapper;
|
|
import com.bizmatics.persistence.mapper.RtAnalogDataMapper;
|
|
|
|
+import com.bizmatics.persistence.mapper.SiteMapper;
|
|
import com.bizmatics.service.RtAnalogDataService;
|
|
import com.bizmatics.service.RtAnalogDataService;
|
|
import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
import com.bizmatics.service.SiteService;
|
|
import com.bizmatics.service.SiteService;
|
|
@@ -34,6 +36,7 @@ import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -49,36 +52,40 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
|
|
@Autowired
|
|
@Autowired
|
|
private UserSiteService userSiteService;
|
|
private UserSiteService userSiteService;
|
|
@Autowired
|
|
@Autowired
|
|
- private SiteService siteService;
|
|
|
|
|
|
+ private DeviceMapper deviceMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public RadCountVO selectCount() {
|
|
public RadCountVO selectCount() {
|
|
Integer userId = SessionLocal.getUserId();
|
|
Integer userId = SessionLocal.getUserId();
|
|
- List<UserSite> userSites = userSiteService.list(Wrappers.lambdaQuery(UserSite.class).eq(UserSite::getUserId, userId));
|
|
|
|
AtomicReference<Integer> heavyLoad = new AtomicReference<>(0);
|
|
AtomicReference<Integer> heavyLoad = new AtomicReference<>(0);
|
|
AtomicReference<Integer> easyLoad = new AtomicReference<>(0);
|
|
AtomicReference<Integer> easyLoad = new AtomicReference<>(0);
|
|
AtomicReference<Integer> norMalLoad = new AtomicReference<>(0);
|
|
AtomicReference<Integer> norMalLoad = new AtomicReference<>(0);
|
|
- userSites.forEach(userSite -> {
|
|
|
|
- Site site = siteService.getOne(Wrappers.lambdaQuery(Site.class).eq(Site::getId, userSite.getId()));
|
|
|
|
- Double aDouble = baseMapper.selectTotalLoad(userId, site.getId());
|
|
|
|
- String installedCapacity = site.getInstalledCapacity();
|
|
|
|
- double installedCapacityDouble = 0.00;
|
|
|
|
- if (StringUtils.isNotBlank(installedCapacity)){
|
|
|
|
- installedCapacityDouble = Double.parseDouble(installedCapacity);
|
|
|
|
- if (installedCapacityDouble > 0){
|
|
|
|
- Arith.div(aDouble,installedCapacityDouble);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (installedCapacityDouble < 0.4){
|
|
|
|
- easyLoad.getAndSet(easyLoad.get() + 1);
|
|
|
|
- }else if (installedCapacityDouble >= 0.4 && installedCapacityDouble <= 0.8){
|
|
|
|
- norMalLoad.getAndSet(norMalLoad.get() + 1);
|
|
|
|
- }else {
|
|
|
|
- heavyLoad.getAndSet(heavyLoad.get() + 1);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- int count = userSites.size();
|
|
|
|
|
|
+ List<Device> deviceList = deviceMapper.list(userId, null, null, null, null, null);
|
|
|
|
+ List<RtAnalogData> list = baseMapper.list(userId);
|
|
|
|
+ for (Device device:deviceList) {
|
|
|
|
+ list.stream()
|
|
|
|
+ .filter(rtAnalogData -> device.getDeviceCode().equals(rtAnalogData.getDeviceName())).findAny()
|
|
|
|
+ .ifPresent(rtAnalogData -> {
|
|
|
|
+ String installedCapacity = device.getInstalledCapacity();
|
|
|
|
+ double installedCapacityDouble = 0.00;
|
|
|
|
+ if (StringUtils.isNotBlank(installedCapacity)){
|
|
|
|
+ installedCapacityDouble = Double.parseDouble(installedCapacity);
|
|
|
|
+ if (installedCapacityDouble > 0){
|
|
|
|
+ installedCapacityDouble = Arith.div(rtAnalogData.getP(),installedCapacityDouble);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (installedCapacityDouble < 0.4){
|
|
|
|
+ easyLoad.getAndSet(easyLoad.get() + 1);
|
|
|
|
+ }else if (installedCapacityDouble >= 0.4 && installedCapacityDouble <= 0.8){
|
|
|
|
+ norMalLoad.getAndSet(norMalLoad.get() + 1);
|
|
|
|
+ }else {
|
|
|
|
+ heavyLoad.getAndSet(heavyLoad.get() + 1);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ int count = deviceList.size();
|
|
RadCountVO radCountVO = new RadCountVO();
|
|
RadCountVO radCountVO = new RadCountVO();
|
|
radCountVO.setHeavyLoad(Arith.div(heavyLoad.get(),count));
|
|
radCountVO.setHeavyLoad(Arith.div(heavyLoad.get(),count));
|
|
radCountVO.setEasyLoad(Arith.div(easyLoad.get(),count));
|
|
radCountVO.setEasyLoad(Arith.div(easyLoad.get(),count));
|