hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
@@ -7,6 +7,8 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.mes.common.S7object;
import com.mes.common.config.Const;
import com.mes.damage.entity.Damage;
import com.mes.damage.service.DamageService;
import com.mes.device.PlcParameterObject;
import com.mes.downglassinfo.entity.DownGlassInfo;
import com.mes.downglassinfo.entity.DownGlassTask;
@@ -54,9 +56,8 @@
    DownWorkstationService downWorkstationService;
    @Autowired
    DownGlassInfoService downGlassInfoService;
    @Value("${mes.threshold}")
    private Integer threshold;
    @Autowired
    DamageService damageService;
    @Value("${mes.throughWidth}")
    private Integer throughWidth;
@@ -126,6 +127,43 @@
        }
    }
    @Scheduled(fixedDelay = 300)
    public void plcShelfFull() {
        List<DownWorkstation> list = downGlassInfoService.queryWorkStationIsFull();
        if (CollectionUtils.isNotEmpty(list)) {
            S7control s7control = S7object.getinstance().plccontrol;
            PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject;
            s7control.writeWord(plcMesObject.getPlcParameter("alarm_signal").getAddress(), 1);
        }
    }
    @Scheduled(fixedDelay = 1000)
    public void dealDamageTask() {
        Date startDate = new Date();
        log.info("下片破损玻璃清除任务开始执行时间:{}", startDate);
        List<DownGlassTask> downGlassTaskList = downGlassTaskService.list(new LambdaQueryWrapper<DownGlassTask>()
                .in(DownGlassTask::getTaskType, Const.GLASS_CACHE_TYPE_OUT_ALL).in(DownGlassTask::getTaskStatus, Const.GLASS_STATE_DAMAGE_TAKE));
        if (CollectionUtils.isNotEmpty(downGlassTaskList)) {
            //获取破损/拿走玻璃id
            List<String> glassList = downGlassTaskList.stream().map(DownGlassTask::getGlassId).collect(Collectors.toList());
            //将任务表中的数据删除
            downGlassTaskService.remove(new LambdaQueryWrapper<DownGlassTask>().in(DownGlassTask::getTaskType, Const.GLASS_CACHE_TYPE_OUT_ALL).in(DownGlassTask::getGlassId, glassList));
            List<Damage> damageList = downGlassTaskList.stream().map(e -> {
                Damage damage = new Damage();
                damage.setGlassId(e.getGlassId());
                damage.setLine(Const.TEMPERING_OUT_TARGET_POSITION);
                damage.setWorkingProcedure("下片");
                damage.setRemark("下片");
                damage.setStatus(0);
                damage.setType(e.getTaskStatus());
                return damage;
            }).collect(Collectors.toList());
            damageService.batchInsertDamage(damageList);
        }
        Date endDate = new Date();
        log.info("本次任务结束时间:{},共耗时:{}ms", endDate, endDate.getTime() - startDate.getTime());
    }
    public void inTo(String glassId, String requestWord, String currentSlot) {
        log.info("1、按照玻璃id:{}获取玻璃小片信息,当前格子为:{}", glassId, currentSlot);
        //添加进片任务  查找空格
@@ -170,7 +208,7 @@
            }
            if (!checkFlag) {
                log.info("无空架子,获取已绑定架子的流程卡信息,查看玻璃信息是否可被对调");
                List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.FALSE);
                List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Const.WORK_STATION_ALL, Boolean.FALSE);
                log.info("获取架子上已绑定流程卡落架的数量及未落架的玻璃数据:{}", downGlassInfoDTOList);
                if (CollectionUtils.isEmpty(downGlassInfoDTOList)) {
                    log.info("已绑定流程卡均无未落架玻璃,请及时处理架子上的玻璃,清除流程卡,执行进片任务");
@@ -309,6 +347,7 @@
            }
        }
        List<Integer> workStationAll = Arrays.asList(1, 2, 3, 4, 5, 6);
        //获取非本次落架的架子信息
        List<Integer> offWorkStationList = workStationAll.stream().filter(e -> !workList.contains(e)).collect(Collectors.toList());
        List<DownStorageCageDetails> list = new ArrayList();
        //是否有空架子 true:有   false:无
@@ -387,12 +426,12 @@
        loop:
        if (StringUtils.isBlank(tempGlassId)) {
            //获取正在落架的绑定流程卡的信息(流程卡、层数、落架数量)
            List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.TRUE);
            //todo:落架玻璃数为0,即使绑定了流程卡,也无法找到对应的架子信息,只能重新绑定
            List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationFlowCard(workList);
            List<String> downGlassFlowList = downGlassInfoDTOList.stream().map(item -> item.getFlowCardId() + ":" + item.getLayer()).collect(Collectors.toList());
            if (CollectionUtils.isEmpty(downGlassFlowList)) {
                //架子都未绑定流程卡,出笼内子数量最多尺寸最大的玻璃id,无  则返回扫描扫到的玻璃id进行出片
                tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId, offWorkStationList);
                isNeedBind = Boolean.TRUE;
                break loop;
            }
@@ -456,6 +495,7 @@
                        if (CollectionUtils.isNotEmpty(downStorageCageDetails)) {
                            tempGlassId = downStorageCageDetails.get(0).getGlassId();
                            break;
                        }
                    }
                }
@@ -513,7 +553,7 @@
            endCell = workstation.getWorkstationId();
        }
        //更新落架玻璃数量
        if (endCell == 7) {
        if (endCell == Const.G13_WORK_STATION) {
            downWorkstationService.update(new UpdateWrapper<DownWorkstation>().eq("flow_card_id", downStorageCageDetails.getFlowCardId())
                    .eq("layer", downStorageCageDetails.getLayer()).setSql("other_number = other_number +1"));
        } else {
@@ -526,6 +566,8 @@
        BeanUtils.copyProperties(downStorageCageDetails, downGlassInfo);
        //落架片序
        downGlassInfo.setSequence(downGlassInfoService.queryMaxSequence(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer()));
        downGlassInfo.setWorkStationId(endCell);
        downGlassInfo.setGmtCreate(new Date());
        downGlassInfoService.save(downGlassInfo);
        //生成任务信息
        GlassInfo glassInfo = new GlassInfo();