自动化立体仓库 - WMS系统
#
whycq
2024-03-05 8003a29d3f510adfa971ea6ebd23af1ccd7316c1
src/main/java/com/zy/asrs/controller/BasShuttleController.java
@@ -1,5 +1,6 @@
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;
@@ -12,8 +13,10 @@
import com.core.common.BaseRes;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.common.utils.HttpHandler;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@@ -23,6 +26,9 @@
    @Autowired
    private BasShuttleService basShuttleService;
    @Value("${wcs-slave.url}")
    private String wcsUrl;
    @RequestMapping(value = "/basShuttle/{id}/auth")
    @ManagerAuth
@@ -122,4 +128,134 @@
        return R.ok();
    }
    @RequestMapping(value = "/basShuttle/command/list/auth")
    @ManagerAuth
    public R shuttleCommandQuery(@RequestParam Integer wrkNo) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("total", 0);
        hashMap.put("records", null);
        try {
            HashMap<String, Object> map = new HashMap<>();
            map.put("wrkNo", wrkNo);
            String response = new HttpHandler.Builder()
                    .setUri(wcsUrl)
                    .setPath("/shuttle/command/query")
                    .setParams(map)
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            Integer code = jsonObject.getInteger("code");
            if (code.equals(200)) {
                JSONObject data = jsonObject.getJSONObject("data");
                JSONObject assignCommand = data.getJSONObject("assignCommand");
                JSONArray commands = assignCommand.getJSONArray("commands");
                Integer commandStep = data.getInteger("commandStep");//当前步序
                for (int i = 0; i < commands.size(); i++) {
                    JSONObject object = commands.getJSONObject(i);
                    object.put("commandStep", commandStep);//当前步序
                    commands.set(i, object);
                }
                hashMap.put("total", commands.size());
                hashMap.put("records", commands);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
        return R.ok().add(hashMap);
    }
    //回退命令
    @RequestMapping(value = "/basShuttle/command/rollback/auth")
    @ManagerAuth
    public R shuttleCommandRollback(@RequestBody JSONObject param) {
        try {
            String response = new HttpHandler.Builder()
                    .setUri(wcsUrl)
                    .setPath("/shuttle/command/rollback")
                    .setParams(param)
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            Integer code = jsonObject.getInteger("code");
            if (code.equals(200)) {
                return R.ok();
            }
            return R.error();
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }
    //命令完成状态切换
    @RequestMapping(value = "/basShuttle/command/completeSwitch/auth")
    @ManagerAuth
    public R shuttleCommandCompleteSwitch(@RequestBody JSONObject param) {
        try {
            String response = new HttpHandler.Builder()
                    .setUri(wcsUrl)
                    .setPath("/shuttle/command/completeSwitch")
                    .setParams(param)
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            Integer code = jsonObject.getInteger("code");
            if (code.equals(200)) {
                return R.ok();
            }
            return R.error();
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }
    //重启任务(命令)
    @RequestMapping(value = "/basShuttle/command/restart/auth")
    @ManagerAuth
    public R shuttleCommandRestart(@RequestBody JSONObject param) {
        try {
            String response = new HttpHandler.Builder()
                    .setUri(wcsUrl)
                    .setPath("/shuttle/command/restart")
                    .setParams(param)
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            Integer code = jsonObject.getInteger("code");
            if (code.equals(200)) {
                return R.ok();
            }
            return R.error("重启失败");
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }
    //删除任务(命令)
    @RequestMapping(value = "/basShuttle/command/del/auth")
    @ManagerAuth
    public R shuttleCommandDel(@RequestBody JSONObject param) {
        try {
            String response = new HttpHandler.Builder()
                    .setUri(wcsUrl)
                    .setPath("/shuttle/command/del")
                    .setParams(param)
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            Integer code = jsonObject.getInteger("code");
            if (code.equals(200)) {
                return R.ok();
            }
            return R.error("删除失败");
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }
}