xieshengjie 2 éve
szülő
commit
218ac7b3de

+ 64 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/monitor/LandformsController.java

@@ -0,0 +1,64 @@
+package com.gyee.runeconomy.controller.monitor;/*
+@author   谢生杰
+@date   2023/5/10-16:06
+*/
+
+import com.gyee.common.model.StringUtils;
+import com.gyee.runeconomy.dto.R;
+import com.gyee.runeconomy.dto.ResultMsg;
+import com.gyee.runeconomy.model.auto.ProBasicSquare;
+import com.gyee.runeconomy.model.vo.LandformsVo;
+import com.gyee.runeconomy.service.monitor.LandformsService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Controller
+@RequestMapping("/landforms")
+@Api(value = "地貌图",tags =  "地貌图")
+public class LandformsController {
+    @Resource
+    private LandformsService landformsService;
+
+    /**
+     * 地貌图数据
+     * @return
+     */
+    @GetMapping("/data")
+    @ResponseBody
+    @ApiOperation(value = "数据信息", notes = "数据信息")
+    public R data(@RequestParam(value = "foreignkeyid",required = true) String foreignkeyid) throws Exception {
+
+        List<LandformsVo> resultList = landformsService.data(foreignkeyid);
+        if (StringUtils.isNotNull(resultList)) {
+            return R.data(ResultMsg.ok(resultList));
+        }else{
+            return R.error(ResultMsg.error());
+        }
+    }
+
+
+    /**
+     * 根据期次查询阵区
+     * @return
+     */
+    @GetMapping("/sqByPj")
+    @ResponseBody
+    @ApiOperation(value = "根据期次查询阵区", notes = "根据期次查询阵区")
+    public R sqByPj(@RequestParam(value = "pjid",required = true) String pjid) throws Exception {
+
+        List<ProBasicSquare> resultList = landformsService.sqByPj(pjid);
+        if (StringUtils.isNotNull(resultList)) {
+            return R.data(ResultMsg.ok(resultList));
+        }else{
+            return R.error(ResultMsg.error());
+        }
+    }
+}

+ 18 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/model/vo/LandformsVo.java

@@ -0,0 +1,18 @@
+package com.gyee.runeconomy.model.vo;
+/*
+@author   谢生杰
+@date   2023/5/10-16:20
+*/
+
+import lombok.Data;
+
+@Data
+public class LandformsVo {
+
+    private String foreignkeyid;
+    private String wtid;
+    private String wtname;
+    private Integer status;
+    private Double power;
+    private Double speed;
+}

+ 104 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/monitor/LandformsService.java

@@ -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());
+    }
+}