#
zjj
2025-01-10 4c6ac55bbdfd2426274014047126da179bde367c
src/main/java/com/zy/asrs/controller/ConsoleController.java
@@ -17,6 +17,7 @@
import com.zy.asrs.mapper.BasCrnErrorMapper;
import com.zy.asrs.mapper.LocMastMapper;
import com.zy.asrs.mapper.ReportQueryMapper;
import com.zy.asrs.service.BasCrnpService;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.DeviceErrorService;
import com.zy.asrs.service.WrkMastService;
@@ -24,19 +25,25 @@
import com.zy.core.CrnThread;
import com.zy.core.DevpThread;
import com.zy.core.Slave;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.CrnModeType;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.CrnSlave;
import com.zy.core.model.DevpSlave;
import com.zy.core.model.RgvSlave;
import com.zy.core.model.Task;
import com.zy.core.model.command.CrnCommand;
import com.zy.core.model.protocol.CrnProtocol;
import com.zy.core.model.protocol.RgvProtocol;
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.properties.SystemProperties;
import com.zy.core.thread.BarcodeThread;
import com.zy.core.thread.ScaleThread;
import com.zy.core.thread.SiemensCrnThread;
import com.zy.core.thread.SiemensRgvThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -67,6 +74,60 @@
    private ReportQueryMapper reportQueryMapper;
    @Autowired
    private DeviceErrorService deviceErrorService;
    @Autowired
    private BasCrnpService basCrnpService;
    @PostMapping("/system/running/error")
    @ManagerAuth(memo = "系统运行状态")
    public R systemRunningError(){
        StringBuilder msg = new StringBuilder();
        for (CrnSlave crn : slaveProperties.getCrn()) {
            // 获取堆垛机信息
            CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
            if (crnThread == null) {
                continue;
            }
            CrnProtocol crnProtocol = crnThread.getCrnProtocol();
            if (crnProtocol == null) {
                continue;
            }
            if (crnProtocol.getStatus() == 99){
                msg.append("<span style=\"color: red\">").append(crn.getId()).append("号堆垛机报警<span><br>");
            }
        }
        for (RgvSlave rgv : slaveProperties.getRgv()) {
            // 获取堆垛机信息
            SiemensRgvThread rgvThread = (SiemensRgvThread) SlaveConnection.get(SlaveType.Rgv, rgv.getId());
            if (rgvThread == null) {
                continue;
            }
            RgvProtocol rgvProtocol = rgvThread.getRgvProtocol();
            if (rgvProtocol == null) {
                continue;
            }
            if (rgvProtocol.getAlarm() > 0){
                msg.append("<span style=\"color: red\">").append(rgv.getId()).append("号Rgv报警<span><br>");
            }
        }
        for (DevpSlave devp : slaveProperties.getDevp()) {
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
            Map<Integer, StaProtocol> station = devpThread.getStation();
            for(Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
                if (entry.getKey() == 302 || entry.getKey() == 303 || entry.getKey() == 304 || entry.getKey() == 305) {
                    if (!Cools.isEmpty(staPlcErr(entry))){
                        msg.append("<span style=\"color: red\">").append(staPlcErr(entry).get(0).getNo()).append("号提升机报警<span><br>");
                    }
                }
            }
        }
        if (!Cools.isEmpty(msg.toString())){
            return R.error().add(msg.toString());
        }
        return R.ok();
    }
    @PostMapping("/system/running/status")
    @ManagerAuth(memo = "系统运行状态")
@@ -115,6 +176,28 @@
            vo.setWorkNo(staProtocol.getWorkNo()); // 工作号
            vo.setSiteStatus(SiteStatusType.process(staProtocol));  // 状态
            vo.setNearbySta(staProtocol.getNearbySta());  //RGV位置
            vos.add(vo);
        }
        return R.ok().add(vos);
    }
    @PostMapping("/latest/data/hoist")
    @ManagerAuth(memo = "提升机实时数据")
    public R hoistLatestData(){
        List<HoistDataVo> vos = new ArrayList<>();
        Map<Integer, StaProtocol> stations = new HashMap<>();
        for (DevpSlave devp : slaveProperties.getDevp()) {
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
            if (null != devpThread) {
                stations.putAll(devpThread.getStation());
            }
        }
        for (Map.Entry<Integer, StaProtocol> entry : stations.entrySet()) {
            HoistDataVo vo = new HoistDataVo();
            StaProtocol staProtocol = entry.getValue();
            vo.setHoistId(String.valueOf(entry.getKey()));
            vo.setPlace(staProtocol.getPlace());
            vos.add(vo);
        }
        return R.ok().add(vos);
@@ -310,6 +393,11 @@
        CrnDetailVo vo = new CrnDetailVo();
        for (CrnSlave crnSlave : slaveProperties.getCrn()) {
            if (crnSlave.getId().equals(crnNo)) {
                BasCrnp basCrnp = basCrnpService.selectById(crnNo);
                if (basCrnp == null) {
                    return R.error("数据库维护异常");
                }
                SiemensCrnThread crnThread = (SiemensCrnThread) SlaveConnection.get(SlaveType.Crn, crnSlave.getId());
                CrnProtocol crnProtocol = crnThread.getCrnProtocol();
                vo.setCrnNo(crnNo);
@@ -334,6 +422,8 @@
                        vo.setError("");    // todo
                    }
                }
                vo.setInEnable(basCrnp.getInEnable());//可入
                vo.setOutEnable(basCrnp.getOutEnable());//可出
                return R.ok().add(vo);
            }
        }
@@ -445,4 +535,72 @@
        return R.ok(map);
    }
    public List<PlcErrorTableVo> staPlcErr(Map.Entry<Integer, StaProtocol> entry){
        List<PlcErrorTableVo> list = new ArrayList<>();
        StaProtocol staProtocol = entry.getValue();
        if (staProtocol.getBreakerErr()){
            PlcErrorTableVo vo = new PlcErrorTableVo();
            vo.setNo(entry.getKey());   //  序号
            vo.setPlcDesc("断路器故障");
            vo.setError("断路器故障");
            list.add(vo);
        }
        if (staProtocol.getInfraredErr()){
            PlcErrorTableVo vo = new PlcErrorTableVo();
            vo.setNo(entry.getKey());   //  序号
            vo.setPlcDesc("光电异常");
            vo.setError("光电异常");
            list.add(vo);
        }
        if (staProtocol.getOutTimeErr()){
            PlcErrorTableVo vo = new PlcErrorTableVo();
            vo.setNo(entry.getKey());   //  序号
            vo.setPlcDesc("运行超时");
            vo.setError("运行超时");
            list.add(vo);
        }
        if (staProtocol.getSeizeSeatErr()){
            PlcErrorTableVo vo = new PlcErrorTableVo();
            vo.setNo(entry.getKey());   //  序号
            vo.setPlcDesc("占位超时");
            vo.setError("占位超时");
            list.add(vo);
        }
        if (staProtocol.getWrkYgoodsN()){
            PlcErrorTableVo vo = new PlcErrorTableVo();
            vo.setNo(entry.getKey());   //  序号
            vo.setPlcDesc("有任务无货故障");
            vo.setError("有任务无货故障");
            list.add(vo);
        }
        if (staProtocol.getInverterErr()){
            PlcErrorTableVo vo = new PlcErrorTableVo();
            vo.setNo(entry.getKey());   //  序号
            vo.setPlcDesc("变频器故障");
            vo.setError("变频器故障");
            list.add(vo);
        }
        if (staProtocol.getContactErr()){
            PlcErrorTableVo vo = new PlcErrorTableVo();
            vo.setNo(entry.getKey());   //  序号
            vo.setPlcDesc("电机接触器故障");
            vo.setError("电机接触器故障");
            list.add(vo);
        }
        if (staProtocol.getUpcontactErr()){
            PlcErrorTableVo vo = new PlcErrorTableVo();
            vo.setNo(entry.getKey());   //  序号
            vo.setPlcDesc("顶升电机接触器故障");
            vo.setError("顶升电机接触器故障");
            list.add(vo);
        }
        return list;
    }
}