#
cpT
8 天以前 463b9e4b68b8ab62a11c6985081fd5d62692cc79
src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
@@ -15,6 +15,7 @@
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.NotifyUtils;
import com.zy.asrs.utils.Utils;
import com.zy.common.entity.FindCrnNoResult;
import com.zy.common.model.StartupDto;
import com.zy.common.service.CommonService;
import com.zy.common.utils.RedisUtil;
@@ -341,6 +342,22 @@
        }
        Integer station = inStationObjModel.getDualCrnExecuteStation();
        if (station == 1) {
            List<Integer> basList = basDualCrnp.getDisableStationOneBays$();
            if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) {
                //禁止放货列,申请重新分配
                reassignTaskLocNo(wrkMast, inStationObjModel);
                return false;
            }
        }else {
            List<Integer> basList = basDualCrnp.getDisableStationTwoBays$();
            if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) {
                //禁止放货列,申请重新分配
                reassignTaskLocNo(wrkMast, inStationObjModel);
                return false;
            }
        }
        String sourceLocNo = Utils.getLocNo(inStationObjModel.getDeviceRow(), inStationObjModel.getDeviceBay(), inStationObjModel.getDeviceLev());
        List<DualCrnCommand> commandList = new ArrayList<>();
@@ -387,7 +404,25 @@
            return false;
        }
        List<StationObjModel> enableUseStationList = new ArrayList<>();
        for (StationObjModel stationObjModel : outStationList) {
            if (!stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
                continue;
            }
            if(stationObjModel.getDualCrnExecuteStation().equals(station)) {
                enableUseStationList.add(stationObjModel);
            }
            StationObjModel dualCrnSlaveStation = stationObjModel.getDualCrnSlaveStation();
            if(dualCrnSlaveStation != null) {
                if (dualCrnSlaveStation.getDualCrnExecuteStation().equals(station)) {
                    enableUseStationList.add(stationObjModel);
                }
            }
        }
        for (StationObjModel stationObjModel : enableUseStationList) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
            if (stationThread == null) {
                continue;
@@ -591,15 +626,34 @@
            } else if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts) {
                updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts;
                notifyUtils.notify(String.valueOf(SlaveType.DualCrn), basDualCrnp.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_OUT_TASK_COMPLETE, null);
                List<StationObjModel> outStationList = basDualCrnp.getOutStationList$();
                if(outStationList.isEmpty()){
                    News.info("双工位堆垛机:{} 出库站点未设置", basDualCrnp.getCrnNo());
                    return;
                }
                StationObjModel outStationObjModel = null;
                for (StationObjModel stationObjModel : outStationList) {
                    if (stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
                        outStationObjModel = stationObjModel;
                        break;
                    }
                }
                if (outStationObjModel == null) {
                    News.info("双工位堆垛机:{} 未找到匹配的任务出库站", basDualCrnp.getCrnNo());
                    return;
                }
                if (station == 1) {
                    redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                }else {
                    redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel.getDualCrnSlaveStation(), SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                }
                if(mainProcessPlugin.contains("Fake")) {
                    //生成仿真站点数据
                    List<StationObjModel> outStationList = basDualCrnp.getOutStationList$();
                    if(outStationList.isEmpty()){
                        News.info("双工位堆垛机:{} 出库站点未设置", basDualCrnp.getCrnNo());
                        return;
                    }
                    for (StationObjModel stationObjModel : outStationList) {
                        if (!stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
                            continue;
@@ -780,4 +834,70 @@
        return 0;
    }
    private boolean reassignTaskLocNo(WrkMast wrkMast, StationObjModel stationObjModel) {
        StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
        if (stationThread == null) {
            return false;
        }
        Map<Integer, StationProtocol> stationProtocolMap = stationThread.getStatusMap();
        StationProtocol stationProtocol = stationProtocolMap.get(stationObjModel.getStationId());
        if (stationProtocol == null) {
            return false;
        }
        String response = wmsOperateUtils.applyReassignTaskLocNo(wrkMast.getWrkNo(), stationObjModel.getStationId());
        if (response == null) {
            News.taskError(wrkMast.getWrkNo(), "请求WMS重新分配入库库位接口失败,接口未响应!!!response:{}", response);
            return false;
        }
        JSONObject jsonObject = JSON.parseObject(response);
        if (jsonObject.getInteger("code").equals(200)) {
            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
            String sourceLocNo = wrkMast.getLocNo();
            String locNo = dto.getLocNo();
            LocMast sourceLocMast = locMastService.queryByLoc(sourceLocNo);
            if (sourceLocMast == null) {
                News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 源库位信息不存在", sourceLocNo);
                return false;
            }
            if (!sourceLocMast.getLocSts().equals("S")) {
                News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 源库位状态不处于入库预约", sourceLocNo);
                return false;
            }
            LocMast locMast = locMastService.queryByLoc(locNo);
            if (locMast == null) {
                News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 目标库位信息不存在", locNo);
                return false;
            }
            if (!locMast.getLocSts().equals("O")) {
                News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 目标库位状态不处于空库位", locNo);
                return false;
            }
            //更新源库位
            sourceLocMast.setLocSts("O");
            sourceLocMast.setModiTime(new Date());
            locMastService.updateById(sourceLocMast);
            //更新目标库位
            locMast.setLocSts("S");
            locMast.setModiTime(new Date());
            locMastService.updateById(locMast);
            //更新工作档数据
            wrkMast.setLocNo(locNo);
            wrkMastService.updateById(wrkMast);
            return true;
        } else {
            News.error("请求WMS更换双工位库位接口失败!!!response:{}", response);
        }
        return false;
    }
}