|
@@ -0,0 +1,104 @@
|
|
|
+package com.gyee.runeconomy.service.monitor;
|
|
|
+
|
|
|
+/*
|
|
|
+@author 谢生杰
|
|
|
+@date 2023/5/10-16:09
|
|
|
+*/
|
|
|
+
|
|
|
+import com.gyee.common.contant.ContantXk;
|
|
|
+import com.gyee.common.model.PointData;
|
|
|
+import com.gyee.common.util.DoubleUtils;
|
|
|
+import com.gyee.runeconomy.init.CacheContext;
|
|
|
+import com.gyee.runeconomy.model.auto.ProBasicEquipment;
|
|
|
+import com.gyee.runeconomy.model.auto.ProBasicEquipmentPoint;
|
|
|
+import com.gyee.runeconomy.model.auto.ProBasicSquare;
|
|
|
+import com.gyee.runeconomy.model.vo.LandformsVo;
|
|
|
+import com.gyee.runeconomy.util.StringUtils;
|
|
|
+import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class LandformsService {
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IEdosUtil edosUtil;
|
|
|
+
|
|
|
+ public List<LandformsVo> data(String foreignkeyid) throws Exception {
|
|
|
+ List<LandformsVo> resultList = new ArrayList<>();
|
|
|
+ Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
|
|
|
+
|
|
|
+ Map<String, List<ProBasicEquipment>> pjwtmap = CacheContext.pjwtmap;
|
|
|
+
|
|
|
+ Map<String, List<ProBasicEquipment>> sqwtmap = CacheContext.sqwtmap;
|
|
|
+ List<ProBasicEquipment> equipments = null;
|
|
|
+
|
|
|
+ if (foreignkeyid.endsWith("AG")){
|
|
|
+ equipments = sqwtmap.get(foreignkeyid);
|
|
|
+ if (StringUtils.isNotEmpty(equipments)){
|
|
|
+ List<String> wtstring = new ArrayList<>();
|
|
|
+ equipments.stream().forEach(wt->{
|
|
|
+ Map<String, ProBasicEquipmentPoint> equipmentPointMap = wtpAimap.get(wt.getId());
|
|
|
+// ProBasicEquipmentPoint powerPoint = equipmentPointMap.get(ContantXk.CJ_SSGL);
|
|
|
+// ProBasicEquipmentPoint speedPoint = equipmentPointMap.get(ContantXk.CJ_SSFS);
|
|
|
+ ProBasicEquipmentPoint sbztPoint = equipmentPointMap.get(ContantXk.SBZT);
|
|
|
+// wtstring.add(powerPoint.getNemCode());
|
|
|
+// wtstring.add(speedPoint.getNemCode());
|
|
|
+ wtstring.add(sbztPoint.getNemCode());
|
|
|
+ });
|
|
|
+ List<PointData> realData = edosUtil.getRealData(wtstring);
|
|
|
+ int index = 1;
|
|
|
+ for (int i=0;i<equipments.size();i++){
|
|
|
+ LandformsVo vo = new LandformsVo();
|
|
|
+ vo.setForeignkeyid(foreignkeyid);
|
|
|
+ vo.setWtid(equipments.get(i).getId());
|
|
|
+ vo.setWtname(equipments.get(i).getAname());
|
|
|
+// vo.setPower(DoubleUtils.keepPrecision(realData.get(i*index).getPointValueInDouble(),2));
|
|
|
+// vo.setSpeed(DoubleUtils.keepPrecision(realData.get(i*index+1).getPointValueInDouble(),2));
|
|
|
+ vo.setStatus((int) realData.get(i*index).getPointValueInDouble());
|
|
|
+ resultList.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (foreignkeyid.endsWith("EG")){
|
|
|
+ equipments = pjwtmap.get(foreignkeyid);
|
|
|
+ if (StringUtils.isNotEmpty(equipments)){
|
|
|
+ List<String> wtstring = new ArrayList<>();
|
|
|
+ equipments.stream().forEach(wt->{
|
|
|
+ Map<String, ProBasicEquipmentPoint> equipmentPointMap = wtpAimap.get(wt.getId());
|
|
|
+ ProBasicEquipmentPoint powerPoint = equipmentPointMap.get(ContantXk.CJ_SSGL);
|
|
|
+ ProBasicEquipmentPoint speedPoint = equipmentPointMap.get(ContantXk.CJ_SSFS);
|
|
|
+ ProBasicEquipmentPoint sbztPoint = equipmentPointMap.get(ContantXk.SBZT);
|
|
|
+ wtstring.add(powerPoint.getNemCode());
|
|
|
+ wtstring.add(speedPoint.getNemCode());
|
|
|
+ wtstring.add(sbztPoint.getNemCode());
|
|
|
+ });
|
|
|
+ List<PointData> realData = edosUtil.getRealData(wtstring);
|
|
|
+ int index = 3;
|
|
|
+ for (int i=0;i<equipments.size();i++){
|
|
|
+ LandformsVo vo = new LandformsVo();
|
|
|
+ vo.setForeignkeyid(foreignkeyid);
|
|
|
+ vo.setWtid(equipments.get(i).getId());
|
|
|
+ vo.setWtname(equipments.get(i).getAname());
|
|
|
+ vo.setPower(DoubleUtils.keepPrecision(realData.get(i*index).getPointValueInDouble(),2));
|
|
|
+ vo.setSpeed(DoubleUtils.keepPrecision(realData.get(i*index+1).getPointValueInDouble(),2));
|
|
|
+ vo.setStatus((int) realData.get(i*index+2).getPointValueInDouble());
|
|
|
+ resultList.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ProBasicSquare> sqByPj(String pjid) {
|
|
|
+ List<ProBasicSquare> sqls = CacheContext.sqls;
|
|
|
+ return sqls.stream().filter(s->s.getProjectId().equals(pjid)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+}
|