自动化立体仓库 - WCS系统
*
lsh
2024-10-17 c2116cdee584c009b7ffb1c89b062e35873b8885
src/main/java/com/zy/asrs/controller/RgvController.java
@@ -5,6 +5,7 @@
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.*;
@@ -13,6 +14,7 @@
import com.zy.asrs.service.BasRgvService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.service.impl.MainServiceImpl;
import com.zy.asrs.utils.NumUtils;
import com.zy.asrs.utils.Utils;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
@@ -20,12 +22,14 @@
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.PostMapping;
@@ -319,56 +323,40 @@
        return false;
    }
    @PostMapping("/console/rgv/site/data")
    @ManagerAuth(memo = "小车实时位置")
    public R scaleLatestData(){
        List<Map> result = new ArrayList<>();
        for (RgvSlave rgv : slaveProperties.getRgv()) {
            // 获取RGV信息
            RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgv.getId());
            if (rgvThread == null) {
                throw new CoolException("RGV不在线");
            }
            RgvProtocol rgvProtocol = rgvThread.getRgvProtocol();
            if (rgvProtocol == null) {
                throw new CoolException("RGV不在线");
            }
            Map<String, Object> rgvMap = new HashMap<>();
            rgvMap.put("title", rgvProtocol.getRgvPosI());
            rgvMap.put("id", rgvProtocol.getRgvNo());
            result.add(rgvMap);
        }
        return R.ok().add(result);
    }
    @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<10;i++) {
        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;
//            }
            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.RingThroughXY(183.0, 100.0*i);
            ringThroughParam.setValueX(doubles[0]);
            ringThroughParam.setValueY(doubles[1]);
            ringThroughParam.setIndex(rgv.getId());
//            ringThroughParam.setIndex(i);
//            double[] doubles = Utils.RingThroughXY2(1737000.0, NumUtils.GetRandomIntInRange(183));
            double[] doubles = Utils.RingThroughXY2(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 = "环穿位置信息")
//    @ManagerAuth(memo = "站点信息")
    public R ringThroughDev(){
        List<RingThroughParam> result = new ArrayList<>();
//        for (RgvSlave rgv : slaveProperties.getRgv()) {
@@ -386,12 +374,48 @@
//            ringThroughParam.setIndex(rgv.getId());
            ringThroughParam.setIndex(i);
            double[] doubles = Utils.RingThroughXY(183.0, 103.0*i);
            ringThroughParam.setValueX(doubles[0]);
            ringThroughParam.setValueY(doubles[1]);
            double[] doubles = Utils.RingThroughXY2(183.0, 100*i );
            ringThroughParam.setValueX(doubles[0]+2.94);
            ringThroughParam.setValueY(doubles[1]+2.94);
            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()) {
                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);
    }
}