自动化立体仓库 - 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);
@@ -439,13 +443,14 @@
            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("任务号不存在");
@@ -480,9 +485,7 @@
                                        HttpServletRequest request) {
        auth(appkey, param, request);
        if (Cools.isEmpty(param)) {
            return R.parse(BaseRes.PARAM);
        }
        List<AgvLocListDetlParam> list = openService.getAgvLocList(param);
        if (!list.isEmpty()) {
            return R.ok(list);
@@ -509,4 +512,57 @@
        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);
        }
    }
}