1、fixbug:进片任务异常后仍会向plc发任务
2、中空大理片玻璃配对按照流程卡+订单序号配对,弃用之前由玻璃尺寸匹配的情况
3、中空大理片出片规则调整适用性:获取多条中空线的仅空闲的状态,去任务表按更新时间倒序获取第一条任务(最近最不活跃的线路)。获取任务为空,则按照所有线路获取更新时间倒序第一条任务(最近最不活跃的线路)。
3个文件已修改
126 ■■■■■ 已修改文件
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/HollowGlassRelationInfoService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/HollowGlassRelationInfoService.java
@@ -1,7 +1,6 @@
package com.mes.hollow.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mes.common.config.ConstSysConfig;
import com.mes.hollow.entity.HollowGlassRelationInfo;
import com.mes.hollow.entity.dto.FlowCardGlassInfoDTO;
import com.mes.hollow.entity.dto.HollowBigStorageDTO;
@@ -24,7 +23,7 @@
     *
     * @return
     */
    HollowBigStorageDTO queryHollowTargetSlot(String flowCardId, double width, double height, int totalLayer, int layer);
    HollowBigStorageDTO queryHollowTargetSlot(String flowCardId, Integer glassType, double width, double height, int totalLayer, int layer);
    /**
     * 生成中空玻璃信息
@@ -43,6 +42,7 @@
    /**
     * 按照厚度获取玻璃间隙
     *
     * @param thickness
     * @return
     */
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java
@@ -68,12 +68,11 @@
//    private Integer outCarMaxSize;
    @Override
    public HollowBigStorageDTO queryHollowTargetSlot(String flowCardId, double width, double height, int totalLayer, int layer) {
    public HollowBigStorageDTO queryHollowTargetSlot(String flowCardId, Integer glassType, double width, double height, int totalLayer, int layer) {
        //按照玻璃信息获取关系表中对应的大理片笼格子号
        HollowGlassRelationInfo relationInfoOne = hollowGlassRelationInfoService.getOne(new LambdaQueryWrapper<HollowGlassRelationInfo>()
                .eq(HollowGlassRelationInfo::getFlowCardId, flowCardId)
                .eq(HollowGlassRelationInfo::getWidth, width)
                .eq(HollowGlassRelationInfo::getHeight, height)
                .eq(HollowGlassRelationInfo::getOrderSort, glassType)
                .eq(HollowGlassRelationInfo::getTotalLayer, totalLayer)
                .eq(HollowGlassRelationInfo::getLayer, layer)
                .eq(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_NEW)
@@ -95,8 +94,7 @@
            //虚拟位置表没有本工程下的所有玻璃虚拟信息,按照玻璃id生成本工程下所有玻璃的虚拟信息
            relationInfoOne = this.getOne(new LambdaQueryWrapper<HollowGlassRelationInfo>()
                    .eq(HollowGlassRelationInfo::getFlowCardId, flowCardId)
                    .eq(HollowGlassRelationInfo::getWidth, width)
                    .eq(HollowGlassRelationInfo::getHeight, height)
                    .eq(HollowGlassRelationInfo::getOrderSort, glassType)
                    .eq(HollowGlassRelationInfo::getTotalLayer, totalLayer)
                    .eq(HollowGlassRelationInfo::getLayer, layer)
                    .eq(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_NEW)
@@ -330,7 +328,7 @@
                }
                List<FlowCardGlassInfoDTO> flowCardInfoList = hollowBigStorageCageDetailsService.hollowIsAll(e, cageDetails.getTotalLayer(), Boolean.FALSE);
                log.info("获取到的流程卡信息为:{}", flowCardInfoList);
                if(CollectionUtil.isNotEmpty(flowCardInfoList)){
                if (CollectionUtil.isNotEmpty(flowCardInfoList)) {
                    hollowAllFlowCardVO.setFlowCardGlassInfoDTOList(flowCardInfoList);
                    pairTotalCount.addAndGet(flowCardInfoList.get(0).getPairCount());
                }
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java
@@ -104,9 +104,6 @@
    private static final String BIG_STORAGE_CAGE_IN_TWO_TASK = "big_storage_cage_in_two_task";
    private static final String BIG_STORAGE_CAGE_OUT_TWO_TASK = "big_storage_cage_out_two_task";
    private static final List<Integer> ONE_LINE_FIRST = Arrays.asList(930, 931, 932);
    private static final List<Integer> TWO_LINE_FIRST = Arrays.asList(931, 930, 932);
    private Integer lastTimeLine = -1;
    /**
     * 直通格子
     */
@@ -117,27 +114,27 @@
    private RedisUtil redisUtil;
    @Scheduled(fixedDelay = 1000)
    public void inBigStorageTask() throws Exception {
    public void inBigStorageTask() {
        S7DataZKDLPOne s7DataZKDLPOne = s7SerializerZKDLPOne.read(S7DataZKDLPOne.class);
        log.info("进片任务读取s7DataZKDLPOne:{}", s7DataZKDLPOne);
        Boolean inkageEntity = s7DataZKDLPOne.getMesControl();
        if (true != inkageEntity) {
        if (!inkageEntity) {
            log.info("当前为非联机状态,结束进片任务");
            return;
        }
        String requestEntity = s7DataZKDLPOne.getRequestMes().toString();
        if (!"1".equals(requestEntity)) {
        Integer requestEntity = s7DataZKDLPOne.getRequestMes();
        if (1 != requestEntity) {
            log.info("当前未收到进片请求,结束进片任务");
            return;
        }
        String mesReplyEntity = s7DataZKDLPOne.getMesReply().toString();
        if ("1".equals(mesReplyEntity)) {
        Integer mesReplyEntity = s7DataZKDLPOne.getMesReply();
        if (1 != mesReplyEntity) {
            log.info("有正在执行的任务,结束进片任务");
            return;
        }
        List<BigStorageCageTask> inTaskList = new ArrayList();
        String fromOpcUa = s7DataZKDLPOne.getFrom1().toString();
        Integer from = s7DataZKDLPOne.getFrom1();
        List<String> glassIdList = new ArrayList<>();
        List<String> requestWords = s7DataZKDLPOne.getIds();
        for (int i = 1; i <= 6; i++) {
@@ -145,7 +142,7 @@
            if (null != requestWord && !requestWord.isEmpty()) {
                BigStorageCageTask task = new BigStorageCageTask();
                task.setGlassId(requestWord);
                task.setStartSlot(Integer.parseInt(fromOpcUa));
                task.setStartSlot(from);
                inTaskList.add(task);
                glassIdList.add(requestWord);
                continue;
@@ -245,7 +242,7 @@
            if (slotMaxHeight > Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) && glassInfoList.get(0).getThickness() < slotMaxthickness) {
                for (BigStorageCageTask task : inTaskList) {
                    GlassInfo info = glassListMap.get(task.getGlassId()).get(0);
                    HollowBigStorageDTO bigStorageDTO = hollowGlassRelationInfoService.queryHollowTargetSlot(info.getFlowCardId(),
                    HollowBigStorageDTO bigStorageDTO = hollowGlassRelationInfoService.queryHollowTargetSlot(info.getFlowCardId(),info.getGlassType()
                            info.getWidth(), info.getHeight(), info.getTotalLayer(), info.getLayer());
//            临时更新格子的剩余尺寸:防止相邻玻璃进同一格子造成剩余尺寸不足,玻璃越界的情况,任务完成后再次更新大理片笼表剩余宽度(按照笼内玻璃数量更新大理片笼剩余尺寸)
                    hollowBigStorageCageService.update(new LambdaUpdateWrapper<HollowBigStorageCage>()
@@ -307,6 +304,9 @@
            }
        } catch (Exception exception) {
            log.info("进片任务执行中发生异常:{}", exception);
            hollowBigStorageCageDetailsService.update(new LambdaUpdateWrapper<HollowBigStorageCageDetails>()
                    .set(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_TAKE)
                    .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_NEW));
            hollowGlassRelationInfoService.update(new LambdaUpdateWrapper<HollowGlassRelationInfo>()
                    .set(HollowGlassRelationInfo::getGlassId, null)
                    .set(HollowGlassRelationInfo::getTemperingLayoutId, null)
@@ -315,6 +315,7 @@
                    .set(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_NEW)
                    .eq(HollowGlassRelationInfo::getState, Const.HOLLOW_RELATION_OCCUPY)
            );
            return;
        }
        //历史数据入库
        hollowBigStorageCageHistoryTaskService.saveBatch(historyTasks);
@@ -355,32 +356,30 @@
        S7DataZKDLPTwo s7DataZKDLPTwo = s7SerializerZKDLPTwo.read(S7DataZKDLPTwo.class);
        log.info("出片任务读取s7DataZKDLPTwo:{}", s7DataZKDLPTwo);
        Boolean inkageEntity = s7DataZKDLPTwo.getMesControl();
        if (true != inkageEntity) {
        if (!inkageEntity) {
            log.info("当前为非联机状态,结束进片任务");
            return;
        }
        String requestEntity = s7DataZKDLPTwo.getRequestMes().toString();
        if (!"1".equals(requestEntity)) {
        Integer requestEntity = s7DataZKDLPTwo.getRequestMes();
        if (1 != requestEntity) {
            log.info("当前未收到出片请求,结束出片任务");
            return;
        }
        //获取出片任务表
        List<BigStorageCageTask> outTaskList = getOutTaskList(s7DataZKDLPTwo);
        if (CollectionUtil.isNotEmpty(outTaskList)) {
            log.info("有正在执行的出片任务,结束本次出片任务");
            return;
        }
        //获取所有空闲的线路信息
        List<Integer> freeLineList = new ArrayList<>();
        //获取空闲且领取任务的数据信息,没有任务直接走玻璃调度
        HashMap<Integer, Boolean> map = new HashMap<>();
        Boolean oneState = Boolean.FALSE;
        Boolean twoState = Boolean.FALSE;
        Boolean threeState = Boolean.FALSE;
        try {
            if (CMJ1ModbusTcp.checkConnected()) {
                oneState = CMJ1ModbusTcp.readUInt16(42027 - 40001) != 0;
                map.put(930, oneState);
                Boolean oneState = CMJ1ModbusTcp.readUInt16(42027 - 40001) != 0;
                if (oneState) {
                    freeLineList.add(930);
                }
            }
        } catch (Exception e) {
            //nothing
@@ -389,54 +388,30 @@
        try {
            S7DataZKExtra s7DataZKExtra = s7SerializerZKQ2.read(S7DataZKExtra.class);
            log.info("中空额外读取{}", s7DataZKExtra);
            twoState = s7DataZKExtra.getIsFree();
            threeState = s7DataZKExtra.getIsFree03();
            map.put(931, twoState);
            map.put(932, threeState);
            Boolean twoState = s7DataZKExtra.getIsFree();
            Boolean threeState = s7DataZKExtra.getIsFree03();
            if (twoState) {
                freeLineList.add(931);
            }
            if (threeState) {
                freeLineList.add(932);
            }
        } catch (Exception e) {
            //nothing
            log.info("二/三线线空闲状态获取异常");
        }
        HollowGlassOutRelationInfo hollowGlassOutRelationInfo = null;
        int cell = -1;
        if (oneState && twoState || !(oneState || twoState)) {
            //获取上一次的任务信息线路
            List<Integer> resultList = lastTimeLine == 930 ? TWO_LINE_FIRST : ONE_LINE_FIRST;
            for (int i : resultList) {
                if (null == hollowGlassOutRelationInfo) {
                    cell = i;
                    hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
                            .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                                    .eq(HollowGlassOutRelationInfo::getCell, cell)
                                    .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
                            );
                }
            }
        } else {
            for (int i : ONE_LINE_FIRST) {
                if (null == hollowGlassOutRelationInfo) {
                    Boolean freeFlag = map.get(i);
                    cell = i;
                    if (freeFlag) {
                        hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
                                .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                                        .eq(HollowGlassOutRelationInfo::getCell, cell)
                                        .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
                                );
                    }
                }
            }
            for (int i : ONE_LINE_FIRST) {
                if (null == hollowGlassOutRelationInfo) {
                    cell = i;
                    hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
                            .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                                    .eq(HollowGlassOutRelationInfo::getCell, cell)
                                    .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
                            );
                }
            }
        HollowGlassOutRelationInfo hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
                .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                        .in(HollowGlassOutRelationInfo::getCell, freeLineList)
                        .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
                        .orderByAsc(HollowGlassOutRelationInfo::getUpdateTime).last("limit 1")
                );
        if (hollowGlassOutRelationInfo == null) {
            hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
                    .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                            .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
                            .orderByAsc(HollowGlassOutRelationInfo::getUpdateTime).last("limit 1")
                    );
        }
        if (null != hollowGlassOutRelationInfo) {
@@ -445,7 +420,7 @@
//            获取当前中空任务未完成出片的玻璃信息
            List<HollowGlassQueueInfo> unFinishHollowQueueList = hollowGlassQueueInfoService.list(new LambdaQueryWrapper<HollowGlassQueueInfo>()
                    .eq(HollowGlassQueueInfo::getFlowCardId, hollowGlassOutRelationInfo.getFlowCardId())
                    .eq(HollowGlassQueueInfo::getCell, cell)
                    .eq(HollowGlassQueueInfo::getCell, hollowGlassOutRelationInfo.getCell())
                    .eq(HollowGlassQueueInfo::getState, Const.TEMPERING_NEW)
                    .orderByAsc(HollowGlassQueueInfo::getHollowSequence));
            if (CollectionUtil.isNotEmpty(unFinishHollowQueueList)) {
@@ -1073,7 +1048,6 @@
            s7DataZKDLPTwo = new S7DataZKDLPTwo();
            s7DataZKDLPTwo.setMesReply(1);
            s7SerializerZKDLPTwo.write(s7DataZKDLPTwo);
            lastTimeLine = targetSlot;
        } catch (Exception e) {
            e.printStackTrace();
        }