自动化立体仓库 - WCS系统
Junjie
2024-11-22 a2d6371396f74e4fb30a4c79e91c6b371a77d0b5
src/main/java/com/zy/asrs/controller/MonitorController.java
@@ -12,6 +12,7 @@
import com.zy.common.service.CommonService;
import com.zy.core.CrnThread;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.ShuttleProtocolStatusType;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.LedSlave;
import com.zy.core.model.LiftSlave;
@@ -26,10 +27,7 @@
import com.zy.core.thread.NyShuttleThread;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -319,10 +317,20 @@
            if (shuttleProtocol == null) {
                continue;
            }
            HashMap<String, Object> map = new HashMap<>();
            if (shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.OFFLINE)) {
                if (System.currentTimeMillis() - shuttleProtocol.getLastOnlineTime() > 1000 * 60 * 5) {
                    //离线超过五分钟
                    //设备离线中
                    map.put("deviceNo", shuttleProtocol.getShuttleNo());//设备号-小车号
                    map.put("errorMsg", "设备离线");//异常信息
                    map.put("device", "四向车");//异常信息
                    list.add(map);
                }
            }
            if (shuttleProtocol.getErrState() == 1) {
                //故障中
                HashMap<String, Object> map = new HashMap<>();
                map.put("deviceNo", shuttleProtocol.getShuttleNo());//设备号-小车号
                map.put("errorMsg", shuttleProtocol.getErrCode$());//异常信息
                map.put("device", "四向车");//异常信息
@@ -359,6 +367,10 @@
                    buffer.append("超重");
                }
                if (liftProtocol.getErrorCode() > 0) {
                    buffer.append(liftProtocol.getErrCode$());
                }
                HashMap<String, Object> map = new HashMap<>();
                map.put("deviceNo", liftProtocol.getLiftNo());//设备号-提升机号
                map.put("errorMsg", buffer.toString());//异常信息
@@ -385,6 +397,29 @@
        return R.ok().add(map);
    }
    /**
     * 获取设备运行异常统计
     */
    @GetMapping("/deviceRunErrorStatistic/{type}")
    public R deviceRunErrorStatistic(@PathVariable("type") String type) {
        int time = 1;//默认1天
        if (type.equals("day")) {
            time = 1;
        } else if (type.equals("week")) {
            time = 7;
        } else if (type.equals("month")) {
            time = 30;
        }
        //获取提升机运行异常数据
        List<Map<String, Object>> liftList = basLiftOptMapper.selectRunErrorStatistic(time);
        //获取小车运行异常数据
        List<Map<String, Object>> shuttleList = basShuttleOptMapper.selectRunErrorStatistic(time);
        HashMap<String, Object> map = new HashMap<>();
        map.put("lift", liftList);
        map.put("shuttle", shuttleList);
        return R.ok().add(map);
    }