zc
2025-05-07 fcb71b8fc63f74cd00d3faa76c73f4c5566ee352
src/main/java/com/zy/asrs/controller/TVController.java
@@ -1,38 +1,28 @@
package com.zy.asrs.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Arith;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.domain.dto.AxisBean;
import com.zy.asrs.domain.dto.WorkChartAxis;
import com.zy.asrs.domain.dto.LocChartPie;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.BasShuttle;
import com.zy.asrs.domain.dto.WorkChartAxis;
import com.zy.asrs.entity.BasShuttleErr;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.mapper.ReportQueryMapper;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.BasShuttleErrService;
import com.zy.asrs.service.BasShuttleService;
import com.zy.asrs.service.WrkMastService;
import com.zy.common.model.MatDto;
import com.zy.common.model.SearchLocParam;
import com.zy.common.service.CommonService;
import com.zy.common.utils.HttpHandler;
import com.zy.common.utils.RedisUtil;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.LedSlave;
import com.zy.core.model.ShuttleSlave;
import com.zy.core.model.command.LedCommand;
import com.zy.core.model.protocol.ShuttleProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.LedThread;
import com.zy.core.thread.ShuttleThread;
import com.zy.core.thread.impl.NormalLedThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
@@ -40,13 +30,13 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by vincent on 2020/11/16
 */
@Slf4j
@RestController
@RequestMapping("/monitor")
public class TVController {
@@ -66,6 +56,9 @@
    private SlaveProperties slaveProperties;
    @Autowired
    private BasShuttleErrService basShuttleErrService;
    @Autowired
    private RedisUtil redisUtil;
    @Value("${asrs.wmsUrl}")
    private String wmsUrl;
@@ -225,94 +218,40 @@
     */
    @GetMapping("/led")
    public R monitorLed(@RequestParam("ledId") Integer ledId) {
        int dev_no = 1012;
        int dev_no1 = 1011;
        int dev_no2 = 1012;
        int dev_no3 = 1015;
        if (ledId == 1) {
            dev_no = 1012;
            dev_no1 = 1011;
            dev_no2 = 1012;
        } else if (ledId == 2) {
            dev_no = 1014;
            dev_no1 = 1013;
            dev_no2 = 1014;
            dev_no3 = 1015;
        } else if (ledId == 3) {
            dev_no = 1022;
            dev_no1 = 1021;
            dev_no2 = 1022;
            dev_no3 = 1023;
        } else if (ledId == 4) {
            dev_no = 1025;
            dev_no1 = 1024;
            dev_no2 = 1025;
            dev_no3 = 1026;
        }
        BasDevp basDevp = basDevpService.selectOne(new EntityWrapper<BasDevp>().eq("dev_no", dev_no));
        if (Cools.isEmpty(basDevp)) {
            return R.ok();
        Object o1 = redisUtil.get("LED_" + dev_no1);
        Object o2 = redisUtil.get("LED_" + dev_no2);
        Object o3 = redisUtil.get("LED_" + dev_no3);
        if (o1 != null) {
            //log.info("电视机显示1:{}", JSONObject.toJSONString(o1));
            return R.ok().add(o1);
        } else if (o2 != null) {
            //log.info("电视机显示2:{}", JSONObject.toJSONString(o2));
            return R.ok().add(o2);
        } else if (o3 != null) {
            //log.info("电视机显示3:{}", JSONObject.toJSONString(o3));
            return R.ok().add(o3);
        }
        WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wms_wrk_no", basDevp.getWrkNo()));
        if (Cools.isEmpty(wrkMast)) {
            return R.ok();
        }
        List<LedCommand> commands = new ArrayList<>();
        return R.ok();
        // 组装命令
        LedCommand ledCommand = new LedCommand();
        ledCommand.setWorkNo(wrkMast.getWmsWrkNo());
        ledCommand.setIoType(wrkMast.getIoType());
        // 出库模式
        switch (wrkMast.getIoType()) {
            case 1:
                ledCommand.setTitle("全板入库");
                break;
            case 10:
                ledCommand.setTitle("空板入库");
                break;
            case 101:
                ledCommand.setTitle("全板出库");
                break;
            case 103:
                ledCommand.setTitle("拣料出库");
                break;
            case 104:
                ledCommand.setTitle("并板出库");
                break;
            case 107:
                ledCommand.setTitle("盘点出库");
                break;
            case 110:
                ledCommand.setTitle("空板出库");
                ledCommand.setEmptyMk(true);
                break;
            case 53:
                ledCommand.setTitle("拣料入库");
                break;
            case 57:
                ledCommand.setTitle("盘点入库");
                break;
            case 54:
                ledCommand.setTitle("并板入库");
                break;
            default:
                break;
        }
        ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
        ledCommand.setLocNo(wrkMast.getLocNo());
        ledCommand.setStaNo(wrkMast.getStaNo());
        if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) {
            Map<String, Object> param = new HashMap<>();
            param.put("taskNo", wrkMast.getWmsWrkNo());
            param.put("sta", wrkMast.getStaNo());
            String response = null;
            try {
                response = new HttpHandler.Builder()
                        .setUri(wmsUrl)
                        .setPath("/rpc/led/getTask2")
                        .setJson(JSON.toJSONString(param))
                        .build()
                        .doPost();
            } catch (IOException e) {
                e.printStackTrace();
            }
            JSONObject jsonObject = JSON.parseObject(response);
            Integer code = jsonObject.getInteger("code");
            if (code.equals(200)) {
                String data = jsonObject.getString("data");
                List<LedCommand> wrkDetls = JSONArray.parseArray(data, LedCommand.class);
                commands.addAll(wrkDetls);
            }
        }
        return R.ok().add(commands);
    }
    /**
@@ -381,6 +320,9 @@
                continue;
            }
            HashMap<String, Object> map = new HashMap<>();
            if (Cools.isEmpty(shuttleProtocol.getErrorCode())) {
                continue;
            }
            int i = Integer.parseInt(shuttleProtocol.getErrorCode());
            if (i > 0) {
                BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(i);