自动化立体仓库 - WMS系统
#
1
昨天 8257d89c461f6553d66fad1e5e3df3d172a00924
src/main/java/com/zy/asrs/controller/OpenController.java
@@ -11,6 +11,7 @@
import com.zy.common.web.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@@ -403,6 +404,9 @@
        } catch (Exception e){
            return R.error("单据编号[order_id]以 "+sign_arm_sku+" 与 "+sign_arm_order+" 作为拆分标记拆分失败!!!");
        }
        if (param.getArm_no()>4){
            return R.ok().add(true);
        }
        boolean taskArmWorkOrderSign = openService.TaskArmWorkOrderSign(param);
        return R.ok().add(taskArmWorkOrderSign);
@@ -413,7 +417,7 @@
     * AGV上报接收
     */
    @PostMapping("/agv/task/v1/agvCallback")
    @AppAuth(memo = "AGV上报接收")
//    @AppAuth(memo = "AGV上报接收")
    public synchronized R TaskAgvReport(@RequestHeader(required = false) String appkey,
                                        @RequestBody TaskAgvReportParam param,
                                        HttpServletRequest request) {
@@ -439,16 +443,126 @@
            return R.error("WMS任务号[reqCode]不能为空");
        }
        String taskCode = param.getTaskCode();
        String[] split = taskCode.split("-");
        param.setTaskNo(Integer.parseInt(split[0]));
//        if (Cools.isEmpty(param.getTimestamp())) {
//            return R.error("RGV任务号[timestamp]不能为空");
//        }
        if (taskCode == null || !taskCode.matches("^\\d+-.*$")) {
            throw new CoolException("taskCode 格式错误,需为 数字-xxx,例如 123-ABC");
        }
        param.setTaskNo(Integer.parseInt(taskCode.substring(0, taskCode.indexOf("-"))));
        boolean taskAgvReport = openService.TaskAgvReport(param);
        if (taskAgvReport){
            agvBindAndBin(String.valueOf(param.getTaskNo()));
            return R.ok();
        }
        return R.error("任务号不存在");
    }
    /**
     * PDA创建AGV任务
     */
    @PostMapping("/agv/task/v1/createTask")
    @AppAuth(memo = "PDA创建AGV任务")
    public synchronized R TaskAgvCreate(@RequestHeader(required = false) String appkey,
                                        @RequestBody TaskAgvCreateParam param,
                                        HttpServletRequest request) {
        auth(appkey, param, request);
        if (Cools.isEmpty(param)) {
            return R.parse(BaseRes.PARAM);
        }
        boolean taskAgvCreate = openService.taskAgvCreate(param);
        if (taskAgvCreate){
            return R.ok();
        }
        return R.error("任务号不存在");
    }
    /**
     * PDA获取AGV库位
     */
    @PostMapping("/agv/loc/v1/getLocList")
    @AppAuth(memo = "PDA检索AGV库位")
    public synchronized R GetAgvLocList(@RequestHeader(required = false) String appkey,
                                        @RequestBody AgvLocListParam param,
                                        HttpServletRequest request) {
        auth(appkey, param, request);
        List<AgvLocListDetlParam> list = openService.getAgvLocList(param);
        if (!list.isEmpty()) {
            return R.ok(list);
        }
        return R.error("库位不存在或无明细");
    }
    /**
     * PDA绑定解绑
     */
    @PostMapping("/agv/bindCtnrAndBin/v1")
    @AppAuth(memo = "PDA绑定与解绑")
    public synchronized R bindCtnrAndBin(@RequestHeader(required = false) String appkey,
                                        @RequestBody bindCtnrAndBinParam param,
                                        HttpServletRequest request) {
        auth(appkey, param, request);
        if (Cools.isEmpty(param)) {
            return R.parse(BaseRes.PARAM);
        }
        boolean bindCtnrAndBin = openService.bindCtnrAndBin(param);
        if (bindCtnrAndBin) {
            return R.ok();
        }
        return R.error("库位不存在或无明细");
    }
    /**
     * AGV申请过光栅
     */
    @PostMapping("/agv/arm/grating/v1/agvCallback")
    @AppAuth(memo = "AGV申请过光栅")
    public synchronized R agvGrating(@RequestHeader(required = false) String appkey,
                                         @RequestBody AgvGoTheArnParam param,
                                         HttpServletRequest request) {
//        auth(appkey, param, request);
        if (Cools.isEmpty(param)) {
            return R.parse(BaseRes.PARAM);
        }
        if (Cools.isEmpty(param.getCurrentPositionCode())) {
            return R.error("位置[currentPositionCode]不能为空");
        }
        boolean bindCtnrAndBin = true;
        List<ArmAgvGratingParam> armList = param.getArmNo();
        if (armList.isEmpty()){
            return R.error("库位不存在或无明细");
        }
        for (ArmAgvGratingParam arm : armList){
            if (bindCtnrAndBin){
                bindCtnrAndBin = openService.agvApplicationPassedTheGrating(arm);
//                System.out.println("请求通过光栅"+armNo);
            }
        }
        if (bindCtnrAndBin) {
            asyncProcessAfterValidation(param);
            return new R(0,"成功");
        }
        return R.error("库位不存在或无明细");
    }
    @Async
    public void agvBindAndBin(String taskNo) {
        try {
            Thread.sleep(500);
            openService.agvBindAndBin(taskNo);
        } catch (Exception e) {
            log.error("异步处理AGV光栅后续逻辑失败", e);
        }
    }
    @Async
    public void asyncProcessAfterValidation(AgvGoTheArnParam param) {
        try {
            Thread.sleep(500);
            openService.agvApplicationPassedTheGrating(param);
        } catch (Exception e) {
            log.error("异步处理AGV光栅后续逻辑失败", e);
        }
    }
}