From 1a78ba1b06078ad7604ee5cb95aa9d42d7e66561 Mon Sep 17 00:00:00 2001 From: lsh <lsh@163.com> Date: 星期六, 19 十月 2024 15:20:39 +0800 Subject: [PATCH] * --- src/main/java/com/zy/asrs/controller/RgvController.java | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 100 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/RgvController.java b/src/main/java/com/zy/asrs/controller/RgvController.java index e50d1dc..7376efc 100644 --- a/src/main/java/com/zy/asrs/controller/RgvController.java +++ b/src/main/java/com/zy/asrs/controller/RgvController.java @@ -5,34 +5,39 @@ import com.core.common.R; import com.core.exception.CoolException; import com.zy.asrs.domain.enums.RgvStatusType; +import com.zy.asrs.domain.param.EnergyGatheringRingParam; import com.zy.asrs.domain.param.RgvOperatorParam; +import com.zy.asrs.domain.param.RingThroughParam; import com.zy.asrs.domain.vo.*; import com.zy.asrs.entity.*; import com.zy.asrs.mapper.BasRgvErrMapper; +import com.zy.asrs.service.BasDevpPositionService; import com.zy.asrs.service.BasRgvService; -import com.zy.asrs.service.LocMastService; import com.zy.asrs.service.WrkMastService; import com.zy.asrs.service.impl.MainServiceImpl; -import com.zy.asrs.utils.VersionUtils; +import com.zy.asrs.utils.NumUtils; +import com.zy.asrs.utils.Utils; import com.zy.core.cache.MessageQueue; import com.zy.core.cache.OutputQueue; import com.zy.core.cache.SlaveConnection; import com.zy.core.enums.RgvModeType; import com.zy.core.enums.RgvTaskModeType; import com.zy.core.enums.SlaveType; +import com.zy.core.model.DevpSlave; import com.zy.core.model.RgvSlave; import com.zy.core.model.Task; import com.zy.core.model.command.RgvCommand; import com.zy.core.model.protocol.RgvProtocol; import com.zy.core.properties.SlaveProperties; import com.zy.core.thread.RgvThread; +import com.zy.core.thread.SiemensDevpThread; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.rmi.CORBA.Util; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -58,7 +63,7 @@ @Autowired private MainServiceImpl mainService; @Autowired - private LocMastService locMastService; + private BasDevpPositionService basDevpPositionService; @PostMapping("/table/rgv/state") @ManagerAuth(memo = "RGV淇℃伅琛�") @@ -88,7 +93,7 @@ vo.setWalkPos(rgvProtocol.getWalkPos()==1?"涓嶅湪瀹氫綅":"鍦ㄥ畾浣�"); vo.setWorkNo2(rgvProtocol.getTaskNo2()); // 宸ヤ綅2浠诲姟鍙� vo.setStatus2(rgvProtocol.getStatusType2().desc); // 宸ヤ綅2鐘舵�� - vo.setLoading2(rgvProtocol.getLoaded2()==1?"鏈夌墿":"鏃犵墿"); // 宸ヤ綅2鏈夌墿 + vo.setLoading2(rgvProtocol.getLoaded2()==0?"鏃犵墿":"鏈夌墿"); // 宸ヤ綅2鏈夌墿 vo.setWarnCode(String.valueOf(rgvProtocol.getAlarm())); if (rgvProtocol.getAlarm() > 0) { @@ -110,7 +115,7 @@ vo.setRgvNo(basRgv.getRgvNo()); // RGV鍙� list.add(vo); // 鑾峰彇RGV淇℃伅 - RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Crn, basRgv.getRgvNo()); + RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basRgv.getRgvNo()); if (rgvThread == null) { continue; } @@ -119,7 +124,7 @@ continue; } - vo.setWorkNo1(rgvProtocol.getTaskNo1()); // 浠诲姟鍙� + vo.setWorkNo(rgvProtocol.getTaskNo1()); // 浠诲姟鍙� if (rgvProtocol.getTaskNo1()>0) { WrkMast wrkMast = wrkMastService.selectById(rgvProtocol.getTaskNo1()); if (wrkMast != null) { @@ -145,23 +150,11 @@ StringBuilder str = new StringBuilder(); String s; int i = 0; - while((s = OutputQueue.CRN.poll()) != null && i <=10) { + while((s = OutputQueue.RGV.poll()) != null && i <=10) { str.append("\n").append(s); i++; } return R.ok().add(str.toString()); - } - - @GetMapping("/demo/status") - public R demoStatus(){ - List<Map<String, Object>> res = new ArrayList<>(); - for (RgvSlave rgvSlave : slaveProperties.getRgv()) { - Map<String, Object> map = new HashMap<>(); - map.put("rgvNo", rgvSlave.getId()); - map.put("demo", rgvSlave.getDemo()); - res.add(map); - } - return R.ok().add(res); } /****************************************************************/ @@ -333,4 +326,91 @@ return false; } + @PostMapping("/ring/through/rgv/position/data") +// @ManagerAuth(memo = "鐜┛浣嶇疆淇℃伅") + public R ringThroughRgv(){ + List<RingThroughParam> result = new ArrayList<>(); + for (RgvSlave rgv : slaveProperties.getRgv()) { +// for (int i = 1;i<2;i++) { +// // 鑾峰彇RGV淇℃伅 + RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgv.getId()); + if (rgvThread == null) { + continue; + } + RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); + if (rgvProtocol == null) { + continue; + } + RingThroughParam ringThroughParam = new RingThroughParam(); + + ringThroughParam.setIndex(rgv.getId()); +// ringThroughParam.setIndex(i); +// double[] doubles = Utils.RingThroughXY2(1737000.0, NumUtils.GetRandomIntInRange(183)); + double[] doubles = Utils.RingThroughXYRgv(1737000.0, 1737000.0-rgvProtocol.RgvPos.doubleValue()); +// double[] doubles = Utils.RingThroughXY2(183.0, 100*i ); + + ringThroughParam.setValueX(doubles[0]-2.94); + ringThroughParam.setValueY(doubles[1]-2.94); + ringThroughParam.setModeColor(rgvProtocol.modeType.color); + ringThroughParam.setStatusColor(rgvProtocol.statusType.color); + result.add(ringThroughParam); + } + return R.ok().add(result); + } + + @PostMapping("/ring/through/dev/position/data") +// @ManagerAuth(memo = "绔欑偣淇℃伅") + public R ringThroughDev(){ + List<RingThroughParam> result = new ArrayList<>(); + List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<>()); + for (BasDevpPosition basDevpPosition : basDevpPositions){ + RingThroughParam ringThroughParam = new RingThroughParam(); + ringThroughParam.setIndex(basDevpPosition.getDevNo()); + double[] doubles = Utils.RingThroughXYSta(1737000.0, 1737000.0-basDevpPosition.getPlcPosition()); + ringThroughParam.setValueX(doubles[0]>50? doubles[0]+6:doubles[0]-1); + ringThroughParam.setValueY(doubles[1]>50? doubles[1]+6:doubles[1]-1); + result.add(ringThroughParam); + } + return R.ok().add(result); + } + + @PostMapping("/ring/through/track/position/data") +// @ManagerAuth(memo = "杞ㄩ亾PLC鐘舵�佷俊鎭�") + public R wnergyGatheringRingParamTrack(){ + List<EnergyGatheringRingParam> result = new ArrayList<>(); + try{ + for (DevpSlave devp : slaveProperties.getDevp()) { + if (devp.getId()!=1){ + break; + } + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + if (devpThread.isResult()){ + if (true){ + EnergyGatheringRingParam energyGatheringRingParam = new EnergyGatheringRingParam(); + energyGatheringRingParam.setTrackColor("rgba(0, 230, 118, 0.5)"); + energyGatheringRingParam.setRadiationColor("rgba(0, 230, 118, 0.5)"); + result.add(energyGatheringRingParam); + } else { + EnergyGatheringRingParam energyGatheringRingParam = new EnergyGatheringRingParam(); + energyGatheringRingParam.setTrackColor("rgba(0, 230, 118, 0.5)"); + energyGatheringRingParam.setRadiationColor("rgba(0, 230, 118, 0.5)"); + result.add(energyGatheringRingParam); + } + } + } + if (result.isEmpty()){ + EnergyGatheringRingParam energyGatheringRingParam = new EnergyGatheringRingParam(); + energyGatheringRingParam.setTrackColor("rgba(0, 0, 0, 81)"); + energyGatheringRingParam.setRadiationColor("rgba(0, 0, 0, 81)"); + result.add(energyGatheringRingParam); + } + } catch (Exception e){ + EnergyGatheringRingParam energyGatheringRingParam = new EnergyGatheringRingParam(); + energyGatheringRingParam.setTrackColor("rgba(0, 0, 0, 81)"); + energyGatheringRingParam.setRadiationColor("rgba(0, 0, 0, 81)"); + result.add(energyGatheringRingParam); + } + return R.ok().add(result); + } + } \ No newline at end of file -- Gitblit v1.9.1