hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowGlassRelationInfoServiceImpl.java
@@ -15,7 +15,9 @@ import com.mes.hollow.entity.HollowBigStorageCageDetails; import com.mes.hollow.entity.HollowGlassOutRelationInfo; import com.mes.hollow.entity.HollowGlassRelationInfo; import com.mes.hollow.entity.dto.*; import com.mes.hollow.entity.dto.FlowCardGlassInfoDTO; import com.mes.hollow.entity.dto.HollowBigStorageDTO; import com.mes.hollow.entity.dto.LackDetailsDTO; import com.mes.hollow.entity.vo.HollowAllFlowCardVO; import com.mes.hollow.entity.vo.HollowBigStorageDetailsQueryVO; import com.mes.hollow.mapper.HollowGlassRelationInfoMapper; @@ -112,11 +114,24 @@ if (null == relationInfoOne) { throw new RuntimeException("相关流程卡未找到对应的组号信息,玻璃流程卡:" + flowCardId + ",序号:" + glassType + ",总层数:" + totalLayer + ",层数:" + layer); } Integer slotMaxHeight = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_MAX_HEIGHT); Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_WIDTH); HollowBigStorageCage storageCage = null; if (Math.min(width, height) > slotMaxHeight) { storageCage = hollowBigStorageCageService.getOne(new LambdaQueryWrapper<HollowBigStorageCage>() .eq(HollowBigStorageCage::getEnableState, Const.SLOT_ON).eq(HollowBigStorageCage::getRemainWidth, slotWidth) .eq(HollowBigStorageCage::getDeviceId, 5) .orderByAsc(HollowBigStorageCage::getMaxThickness).last("limit 1")); HollowBigStorageDTO storageDTO = new HollowBigStorageDTO(); BeanUtils.copyProperties(storageCage, storageDTO); BeanUtils.copyProperties(relationInfoOne, storageDTO); return storageDTO; } //详情表内获取本组是否已经有玻璃在笼子内(0表示提前占用) int taskCount = hollowGlassOutRelationInfoService.count(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)); HollowBigStorageCage storageCage = null; //如果不存在则选择笼内未用的新格子 if (taskCount > 0) { storageCage = hollowBigStorageCageService.getOne(new LambdaQueryWrapper<HollowBigStorageCage>() hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollowqueue/mapper/HollowGlassQueueInfoMapper.java
@@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.mes.hollowqueue.entity.HollowGlassQueueInfo; import java.util.List; /** * (HollowGlassQueueInfo)表数据库访问层 * @@ -11,5 +13,11 @@ */ public interface HollowGlassQueueInfoMapper extends BaseMapper<HollowGlassQueueInfo> { /** * 查询需要仅卧转立的玻璃小片 * * @return */ List<String> queryNeedInCarGlass(); } hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollowqueue/service/HollowGlassQueueInfoService.java
@@ -18,5 +18,7 @@ List<HollowGlassQueueInfo> queryHollowGlassQueueInfoByLine(int cell); void confirmBorder(HollowGlassQueueInfo hollowGlassQueueInfo); List<String> queryNeedInCarGlass(); } hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/hollowqueue/service/impl/HollowGlassQueueInfoServiceImpl.java
@@ -4,10 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mes.common.config.Const; import com.mes.damage.entity.Damage; import com.mes.damage.service.DamageService; import com.mes.hollow.entity.HollowGlassOutRelationInfo; import com.mes.hollow.service.HollowGlassOutRelationInfoService; import com.mes.hollowqueue.entity.HollowGlassQueueInfo; import com.mes.hollowqueue.mapper.HollowGlassQueueInfoMapper; @@ -19,7 +17,6 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; /** * (HollowGlassQueueInfo)表服务实现类 @@ -108,5 +105,10 @@ } } @Override public List<String> queryNeedInCarGlass() { return baseMapper.queryNeedInCarGlass(); } } hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java
@@ -228,7 +228,7 @@ Integer slotMaxThickness = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_MAX_THICKNESS); //按照玻璃厚度分组,判断剩余格子是否可以存放 Map<Double, Long> thickCountMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getThickness, Collectors.counting())); if (glassInfoList.get(0).getThickness() < slotMaxThickness) { // if (glassInfoList.get(0).getThickness() < slotMaxThickness) { for (Map.Entry<Double, Long> entry : thickCountMap.entrySet()) { int count = hollowBigStorageCageService.count(new LambdaQueryWrapper<HollowBigStorageCage>() .eq(HollowBigStorageCage::getEnableState, Const.SLOT_ON).eq(HollowBigStorageCage::getRemainWidth, slotWidth) @@ -243,23 +243,23 @@ return; } } } // } //超大尺寸 Integer slotMaxHeight = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_MAX_HEIGHT); Integer slotMaxthickness = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_MAX_THICKNESS); if (slotMaxHeight < Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) || glassInfoList.get(0).getThickness() >= slotMaxthickness) { int count = hollowBigStorageCageDetailsService.count(new LambdaQueryWrapper<HollowBigStorageCageDetails>() .eq(HollowBigStorageCageDetails::getSlot, THROUGH_SLOT) .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); if (count > 0) { log.info("直通片台存在玻璃,结束本次进片"); //向plc发送报警:直通片台存在玻璃,无法继续直通 s7DataZKDLPOne = new S7DataZKDLPOne(); s7DataZKDLPOne.setAlramSignal(64); s7SerializerZKDLPOne.write(s7DataZKDLPOne); return; } } // Integer slotMaxHeight = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_MAX_HEIGHT); // Integer slotMaxthickness = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_SLOT_MAX_THICKNESS); // if (slotMaxHeight < Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) || glassInfoList.get(0).getThickness() >= slotMaxthickness) { // int count = hollowBigStorageCageDetailsService.count(new LambdaQueryWrapper<HollowBigStorageCageDetails>() // .eq(HollowBigStorageCageDetails::getSlot, THROUGH_SLOT) // .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); // if (count > 0) { // log.info("直通片台存在玻璃,结束本次进片"); // //向plc发送报警:直通片台存在玻璃,无法继续直通 // s7DataZKDLPOne = new S7DataZKDLPOne(); // s7DataZKDLPOne.setAlramSignal(64); // s7SerializerZKDLPOne.write(s7DataZKDLPOne); // return; // } // } log.info("将钢化小片表内的状态改为钢化结束,玻璃id有:{}", glassIdList); //修改钢化任务表中的状态 @@ -278,8 +278,9 @@ Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_GLASS_GAP); log.info("开始计算目标格子,玻璃id有:{}", inTaskList); if (slotMaxHeight > Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) && glassInfoList.get(0).getThickness() < slotMaxthickness) { // if (slotMaxHeight > Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) && glassInfoList.get(0).getThickness() < slotMaxthickness) { for (BigStorageCageTask task : inTaskList) { if (from == 910) { GlassInfo info = glassListMap.get(task.getGlassId()).get(0); HollowBigStorageDTO bigStorageDTO = null; try { @@ -347,9 +348,8 @@ .eq(HollowGlassRelationInfo::getSlotSequence, bigStorageDTO.getSlotSequence()) .eq(HollowGlassRelationInfo::getHollowSequence, bigStorageDTO.getHollowSequence()) ); } } else { BigStorageCageTask task = inTaskList.get(0); task.setTargetSlot(THROUGH_SLOT); //存放历史任务 HollowBigStorageCageHistoryTask historyTask = new HollowBigStorageCageHistoryTask(); @@ -370,6 +370,7 @@ cageDetails.setFilmsId(info.getFilmsid()); cageDetails.setId(null); hollowBigStorageCageDetailsService.save(cageDetails); } } //历史数据入库 @@ -852,6 +853,28 @@ } @Scheduled(fixedDelay = 1000) public void inCarTask() { //读取协议数据 S7DataZKDLPTwo s7DataZKDLPTwo = s7SerializerZKDLPTwo.read(S7DataZKDLPTwo.class); //汇报字为1 启动字为1是 清除所有任务信息 //启动字和汇报字是否均为0 List<String> glassIdList = hollowGlassQueueInfoService.queryNeedInCarGlass(); if (CollectionUtil.isEmpty(glassIdList)) { return; } List<HollowBigStorageCageDetails> list = hollowBigStorageCageDetailsService.list(new LambdaQueryWrapper<HollowBigStorageCageDetails>() .eq(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN) .in(HollowBigStorageCageDetails::getDeviceId, 5) .in(HollowBigStorageCageDetails::getGlassId, glassIdList)); if (CollectionUtil.isEmpty(list)) { return; } //todo:生成进进片大车任务 } private void dealDamageInTask(List<BigStorageCageTask> damageTaskList) { // 获取进片任务表中状态为破损的数据 log.info("破损的玻璃信息有:{}", damageTaskList); hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowGlassQueueInfoMapper.xml
New file @@ -0,0 +1,24 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.mes.hollowqueue.mapper.HollowGlassQueueInfoMapper"> <select id="queryNeedInCarGlass" resultType="java.lang.String"> WITH queue_temp AS ( SELECT slot, glass_id, LEAST(width, height) AS height, relation_id, ROW_NUMBER() OVER ( PARTITION BY cell ORDER BY hollow_sequence ) AS rn FROM `hollow_glass_queue_info` WHERE state = - 1 ), glass_id_temp AS (SELECT * FROM queue_temp WHERE rn = 1), task_temp AS (SELECT * FROM glass_id_temp t INNER JOIN hollow_glass_out_relation_info t1 ON t.relation_id = t1.id WHERE t1.state = 1) SELECT glass_id FROM task_temp WHERE height > 2500 </select> </mapper>