自动化立体仓库 - WMS系统
pang.jiabao
1 天以前 b51e3b3d5bb721cec65952498d1c2c882d1a01d6
src/main/java/com/zy/asrs/controller/MesController.java
@@ -1,13 +1,19 @@
package com.zy.asrs.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.entity.BasStation;
import com.zy.asrs.entity.mes.*;
import com.zy.asrs.service.BasStationService;
import com.zy.asrs.service.MesService;
import com.zy.common.web.BaseController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@RestController
public class MesController extends BaseController {
@@ -28,9 +34,39 @@
    // 出库申请
    @PostMapping("/api/mes/outBoundOrder")
    public MesReturn outBoundOrder(@RequestBody MesInApply param){
        MesReturn mesReturn = new MesReturn();
        mesReturn.setSuccess(mesService.outBoundOrder(param) == 1 ? "1" : "2");
        // 终点为空,计算接驳位
        BasStation basStation = null;
        if (Cools.isEmpty(param.getNextStationId())) {
            List<BasStation> basStations = basStationService.selectList(new EntityWrapper<BasStation>().eq("loc_sts", "O"));
            if(basStations.isEmpty()) {
                mesReturn.setSuccess("2");
                mesReturn.setMessage("无空接驳位,请稍后再试!");
                return mesReturn;
            }
            // 接驳点
            basStation = basStations.get(0);
            param.setNextStationId(basStation.getDevNo());
            // 先更新接驳点状态
            basStation.setModiTime(new Date());
            basStation.setLocSts("S");
            basStation.setBarcode(param.getDjNo());
            basStationService.updateById(basStation);
        }
        int i = mesService.outBoundOrder(param);
        if(i == 1) {
            mesReturn.setSuccess("1");
        } else {
            // 释放接驳点
            if(basStation != null) {
                basStation.setModiTime(new Date());
                basStation.setLocSts("O");
                basStation.setBarcode("");
                basStationService.updateById(basStation);
            }
            mesReturn.setSuccess("2");
        }
        return mesReturn;
    }
@@ -66,11 +102,47 @@
        return mesService.allowOutStation(param);
    }
    // 下发运输任务
    @Resource
    private BasStationService basStationService;
    // 下发运输任务,mes调用下刀06(呼叫agv搬运)
    @PostMapping("/api/mes/submitTask")
    public JSONObject submitTask(@RequestBody TransTask param){
        // 终点为空,计算接驳位
        BasStation basStation = null;
        if (Cools.isEmpty(param.getNextStationId())) {
            List<BasStation> basStations = basStationService.selectList(new EntityWrapper<BasStation>().eq("loc_sts", "O"));
            if(basStations.isEmpty()) {
                JSONObject result = new JSONObject();
                result.put("taskno", param.getTaskno());
                result.put("Success", "2");
                result.put("Message", "无空接驳位,请稍后再试!");
                return result;
            }
            // 接驳点
            basStation = basStations.get(0);
            param.setNextStationId(basStation.getDevNo());
        return mesService.submitTask(param);
            // 先更新接驳点状态
            basStation.setModiTime(new Date());
            basStation.setLocSts("S");
            basStation.setBarcode(param.getDjNo());
            basStationService.updateById(basStation);
        }
        param.setAgvFactory(1); // 海康
        param.setNextStationId("A1");
        JSONObject sendAgvTask = mesService.submitTask(param);
        if (!"1".equals(sendAgvTask.getString("Success"))) {
            // 释放接驳点
            if(basStation != null) {
                basStation.setModiTime(new Date());
                basStation.setLocSts("O");
                basStation.setBarcode("");
                basStationService.updateById(basStation);
            }
        }
        return sendAgvTask;
    }
    // 接受成品刀可以入库二维码