| | |
| | | package com.mes.temperingglass.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.mapper.BigStorageCageDetailsMapper; |
| | | import com.mes.bigstorage.mapper.BigStorageCageMapper; |
| | | import com.mes.bigstoragetask.entity.BigStorageCageOutTask; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.mapper.TemperingGlassInfoMapper; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author zhoush |
| | | * @since 2024-03-27 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class TemperingGlassInfoServiceImpl extends ServiceImpl<TemperingGlassInfoMapper, TemperingGlassInfo> implements TemperingGlassInfoService { |
| | | |
| | | @Resource |
| | | private BigStorageCageDetailsMapper bigStorageCageDetailsMapper; |
| | | @Resource |
| | | private BigStorageCageMapper bigStorageCageMapper; |
| | | |
| | | @Override |
| | | public void addOutTask(List<TemperingGlassInfo> temperingGlassInfoList) { |
| | | double carwidth=5000; |
| | | double gay=50; |
| | | double carWidth=5000; |
| | | double gap=50; |
| | | //写入任务到任务表 |
| | | for (TemperingGlassInfo temperingGlassInfo:temperingGlassInfoList |
| | | ) { |
| | | if((carwidth-gay-temperingGlassInfo.getWidth())>0){ |
| | | //添加任务到任务表 |
| | | }else{ |
| | | log.info("1、当出片车宽度大于玻璃宽度时"); |
| | | if((carWidth-temperingGlassInfo.getWidth())>0){ |
| | | carWidth-=temperingGlassInfo.getWidth()+gap; |
| | | log.info("2、添加钢化小片表信息到任务表"); |
| | | temperingGlassInfo.setState(-1); |
| | | baseMapper.updateById(temperingGlassInfo); |
| | | log.info("3、修改钢化小片表任务状态"); |
| | | BigStorageCageOutTask bigStorageCageOutTask = new BigStorageCageOutTask(); |
| | | bigStorageCageOutTask.setId(temperingGlassInfo.getId()); |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<TemperingGlassInfo> SelectTemperingGlassInfo() { |
| | | return null; |
| | | public boolean saveBatch(List<TemperingGlassInfo> list) { |
| | | return baseMapper.saveBatch(list); |
| | | } |
| | | |
| | | //调度 |
| | | @Override |
| | | public void schedulingTask() { |
| | | QueryWrapper<BigStorageCageDetails> detailsWrapper1 = Wrappers.query(); |
| | | detailsWrapper1.select("tempering_layout_id", "count(distinct slot)") |
| | | .groupBy("tempering_layout_id"); |
| | | List<Map<String, Object>> temperingLayoutIdList = bigStorageCageDetailsMapper.selectMaps(detailsWrapper1); |
| | | |
| | | boolean key = false; |
| | | for (Map<String, Object> row : temperingLayoutIdList) { |
| | | for (Map.Entry<String, Object> entry : row.entrySet()) { |
| | | String temperingId = entry.getKey(); |
| | | int temperingNo = Integer.parseInt(entry.getValue().toString()); |
| | | if(temperingNo>8){ |
| | | QueryWrapper<BigStorageCageDetails> detailsWrapper2 = Wrappers.query(); |
| | | detailsWrapper2.select("tempering_layout_id", "slot") |
| | | .select("max(tempering_feed_sequence) as max_sequence", "min(tempering_feed_sequence) as min_sequence") |
| | | .groupBy("tempering_layout_id", "slot") |
| | | .orderByAsc("tempering_layout_id") |
| | | .orderByDesc("min_sequence"); |
| | | |
| | | List<Map<String, Object>> result = bigStorageCageDetailsMapper.selectMaps(detailsWrapper2); |
| | | for (Map<String, Object> rows : result) { |
| | | // 获取每行的值 |
| | | Object temperingLayoutId = rows.get("tempering_layout_id"); |
| | | int slot = Integer.parseInt(rows.get("slot").toString()); |
| | | int maxSequence = Integer.parseInt(rows.get("max_sequence").toString()); |
| | | int minSequence = Integer.parseInt(rows.get("min_sequence").toString()); |
| | | |
| | | LambdaQueryWrapper<BigStorageCage> bigStorageCageWrapper=new LambdaQueryWrapper<>(); |
| | | bigStorageCageWrapper.eq(BigStorageCage::getSlot,slot); |
| | | BigStorageCage bigStorageCage=bigStorageCageMapper.selectOne(bigStorageCageWrapper); |
| | | Integer remainWidth=5000-bigStorageCage.getRemainWidth(); |
| | | |
| | | BigStorageCage bigStorageCages=bigStorageCageMapper.selectJoinOne(BigStorageCage.class, new MPJLambdaWrapper<BigStorageCage>() |
| | | .selectAll(BigStorageCage.class) |
| | | .leftJoin(BigStorageCageDetails.class, on -> on |
| | | .eq(BigStorageCage::getDeviceId, BigStorageCageDetails::getDeviceId) |
| | | .eq(BigStorageCage::getSlot, BigStorageCageDetails::getSlot)) |
| | | .gt(BigStorageCage::getRemainWidth,remainWidth) |
| | | .eq(BigStorageCageDetails::getTemperingLayoutId,temperingLayoutId) |
| | | .eq(BigStorageCageDetails::getTemperingFeedSequence,minSequence-1) |
| | | ); |
| | | |
| | | if(bigStorageCages.getSlot()!=null){ |
| | | LambdaQueryWrapper<BigStorageCageDetails> bigStorageCageDetailsWrapper=new LambdaQueryWrapper<>(); |
| | | bigStorageCageDetailsWrapper |
| | | .eq(BigStorageCageDetails::getSlot,slot) |
| | | .orderByDesc(BigStorageCageDetails::getTemperingFeedSequence); |
| | | List<BigStorageCageDetails> bigStorageCageDetailsList=bigStorageCageDetailsMapper.selectList(bigStorageCageDetailsWrapper); |
| | | for (BigStorageCageDetails bigStorageCageDetails:bigStorageCageDetailsList |
| | | ) { |
| | | BigStorageCageOutTask bigStorageCageOutTask=new BigStorageCageOutTask(); |
| | | bigStorageCageOutTask.setTaskState(-3); |
| | | bigStorageCageOutTask.setStartSlot(slot); |
| | | bigStorageCageOutTask.setEndSlot(bigStorageCages.getSlot()); |
| | | } |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |