|
@@ -1,14 +1,22 @@
|
|
|
package org.jeecg.modules.equipmentStatus.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import org.jeecg.modules.collectdata.entity.Collectdata;
|
|
|
+import org.jeecg.modules.collectdata.service.ICollectdataService;
|
|
|
import org.jeecg.modules.equipmentStatus.entity.EquipmentStatus;
|
|
|
import org.jeecg.modules.equipmentStatus.mapper.EquipmentStatusMapper;
|
|
|
import org.jeecg.modules.equipmentStatus.service.IEquipmentStatusService;
|
|
|
+import org.jeecg.modules.tpmEquipment.mapper.TpmEquipmentMapper;
|
|
|
+import org.jeecg.modules.tpmEquipmentTree.entity.TpmEquipmentTree;
|
|
|
+import org.jeecg.modules.tpmparams.entity.TpmParams;
|
|
|
+import org.jeecg.modules.tpmparams.mapper.TpmParamsMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 设备状态定义
|
|
@@ -21,6 +29,12 @@ public class EquipmentStatusServiceImpl extends ServiceImpl<EquipmentStatusMappe
|
|
|
|
|
|
@Autowired
|
|
|
EquipmentStatusMapper equipmentStatusMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TpmParamsMapper paramsMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ICollectdataService collectdataService;
|
|
|
/**
|
|
|
* 获取设备当天的总用电量
|
|
|
* @param day 日期
|
|
@@ -31,4 +45,37 @@ public class EquipmentStatusServiceImpl extends ServiceImpl<EquipmentStatusMappe
|
|
|
return equipmentStatusMapper.getEquipmentElectricity(day);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取设备状态信息
|
|
|
+ * @param day 日期
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<EquipmentStatus> listStatus(String day) {
|
|
|
+ List<EquipmentStatus> statusList = equipmentStatusMapper.listStatus(day);
|
|
|
+ if (statusList == null || statusList.size() < 1) {
|
|
|
+ return statusList;
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<TpmParams> queryWrapper = new QueryWrapper(new TpmParams());
|
|
|
+ queryWrapper.orderByAsc("id");
|
|
|
+ List<TpmParams> paramsList = paramsMapper.selectList(queryWrapper);
|
|
|
+ if (paramsList == null || paramsList.size() < 1) {
|
|
|
+ return statusList;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Collectdata> collectdataList = collectdataService.getLatestDataPerGroup();
|
|
|
+
|
|
|
+ for (int i = 0; i < statusList.size(); i++) {
|
|
|
+ String equipmentcode = statusList.get(i).getEquipmentcode();
|
|
|
+ statusList.get(i).setParamsList(paramsList.stream().filter(p -> p.getEquipmentcode().equals(equipmentcode))
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ List<Collectdata> subdataList = collectdataList.stream().filter(p -> p.getEquipmentcode().equals(equipmentcode))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Collectdata collectdata = subdataList == null || subdataList.size() < 1 ? null : subdataList.get(0);
|
|
|
+ statusList.get(i).setLastdata(collectdata);
|
|
|
+ }
|
|
|
+
|
|
|
+ return statusList;
|
|
|
+ }
|
|
|
}
|