自动化立体仓库 - WCS系统
#
Junjie
2023-10-25 7a3b50af32dce3c806a6e520043a714594f3acff
src/main/java/com/zy/asrs/controller/ConsoleController.java
@@ -41,6 +41,10 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.*;
/**
@@ -322,6 +326,50 @@
    }
    /**
     * 获取PLC2数据
     */
    @GetMapping("/plc2/auth")
    @ManagerAuth
    public R getMapFromPlc2() {
        try {
            String mapFilename = "plc2.json";
            String fileName = this.getClass().getClassLoader().getResource(mapFilename).getPath();//获取文件路径
            File file = new File(fileName);
            StringBuffer stringBuffer = new StringBuffer();
            if (file.isFile() && file.exists()) {
                InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "GBK");
                BufferedReader br = new BufferedReader(isr);
                String lineTxt = null;
                while ((lineTxt = br.readLine()) != null) {
                    stringBuffer.append(lineTxt);
                }
                br.close();
            }
            NavigateMapData navigateMapData = new NavigateMapData();
            //解析json地图数据
            ArrayList arrayList = JSON.parseObject(stringBuffer.toString(), ArrayList.class);
            List<List<MapNode>> lists = new ArrayList<>();
            //重建数据格式
            for (int i = 0; i < arrayList.size(); i++) {
                Object obj = arrayList.get(i);
                List<MapNode> list = JSON.parseArray(obj.toString(), MapNode.class);
                for (int j = 0; j < list.size(); j++) {
                    MapNode mapNode = list.get(j);
                    list.set(j, mapNode);
                }
                lists.add(list);
            }
            return R.ok().add(lists);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return R.error();
    }
    /**
     * 重置redis中的地图,将占用的库位全部解除
     */
    @GetMapping("/map/resetMap/auth")