| | |
| | | package com.mes.downglassinfo.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.downglassinfo.entity.DownGlassInfo; |
| | | import com.mes.downglassinfo.entity.DownGlassTask; |
| | | import com.mes.downglassinfo.mapper.DownGlassInfoMapper; |
| | | import com.mes.downglassinfo.service.DownGlassInfoService; |
| | | import com.mes.downglassinfo.service.DownGlassTaskService; |
| | | import com.mes.downworkstation.entity.DownWorkstation; |
| | | import com.mes.downworkstation.mapper.DownWorkstationMapper; |
| | | import com.mes.downworkstation.service.DownWorkstationService; |
| | | import com.mes.downworkstation.service.DownWorkstationTaskService; |
| | | import com.mes.tools.WebSocketServer; |
| | | import com.mes.downstorage.entity.DownStorageCageDetails; |
| | | import com.mes.downstorage.service.DownStorageCageDetailsService; |
| | | import com.mes.downworkstation.entity.dto.DownGlassInfoDTO; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.job.DownLoadCacheGlassTask; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | |
| | | @Service |
| | | public class DownGlassInfoServiceImpl extends ServiceImpl<DownGlassInfoMapper, DownGlassInfo> implements DownGlassInfoService { |
| | | |
| | | // 根据流程卡号查询最大序号 |
| | | @Autowired |
| | | DownLoadCacheGlassTask downLoadCacheGlassTask; |
| | | |
| | | @Autowired |
| | | DownStorageCageDetailsService downStorageCageDetailsService; |
| | | |
| | | /** |
| | | * 根据流程卡号查询最大序号 |
| | | */ |
| | | @Override |
| | | public Integer getMaxSequenceByFlowCardId(String flowCardId) { |
| | | public Integer getMaxSequenceByFlowCardId(String flowCardId, int layer) { |
| | | LambdaQueryWrapper<DownGlassInfo> lambdaQueryWrapper = Wrappers.lambdaQuery(); |
| | | lambdaQueryWrapper.eq(DownGlassInfo::getFlowCardId, flowCardId) |
| | | .eq(DownGlassInfo::getLayer, layer) |
| | | .select(DownGlassInfo::getSequence) |
| | | .orderByDesc(DownGlassInfo::getSequence) |
| | | .last("LIMIT 1"); |
| | |
| | | return downGlassInfo != null ? downGlassInfo.getSequence() : 0; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void insertDownGlassInfo(DownGlassInfo downGlassInfo) { |
| | | |
| | | |
| | | |
| | | baseMapper.insert(downGlassInfo); |
| | | } |
| | | |
| | | @Override |
| | | public DownGlassInfoDTO queryDownGlassMaxLayer(String flowCardId) { |
| | | return baseMapper.queryDownGlassMaxLayer(flowCardId); |
| | | } |
| | | |
| | | @Override |
| | | public Integer queryMaxSequence(String flowCardId, int layer) { |
| | | return baseMapper.queryMaxSequence(flowCardId, layer); |
| | | } |
| | | |
| | | @Override |
| | | public List<DownGlassInfoDTO> queryWorkStationIsIn(Boolean isDownload) { |
| | | return baseMapper.queryWorkStationIsIn(isDownload); |
| | | } |
| | | |
| | | @Override |
| | | public boolean generateOutGlassTask(String glassId) { |
| | | //更新卧式理片笼内玻璃状态 |
| | | downStorageCageDetailsService.update(new LambdaUpdateWrapper<DownStorageCageDetails>() |
| | | .set(DownStorageCageDetails::getState, Const.GLASS_STATE_OUT).eq(DownStorageCageDetails::getGlassId, glassId)); |
| | | DownStorageCageDetails details = downStorageCageDetailsService.getOne(new LambdaQueryWrapper<DownStorageCageDetails>() |
| | | .eq(DownStorageCageDetails::getGlassId, glassId)); |
| | | //生成下片信息 |
| | | DownGlassInfo downGlassInfo = new DownGlassInfo(); |
| | | BeanUtils.copyProperties(details, downGlassInfo); |
| | | //获取当前流程卡最大片序 |
| | | downGlassInfo.setSequence(this.getMaxSequenceByFlowCardId(details.getFlowCardId(), details.getLayer()) + 1); |
| | | this.save(downGlassInfo); |
| | | //生成任务信息 并向plc发送出片任务 |
| | | GlassInfo glassInfo = new GlassInfo(); |
| | | BeanUtils.copyProperties(details, glassInfo); |
| | | return downLoadCacheGlassTask.initDownGlassTask(glassInfo, details.getSlot(), Const.G13_WORK_STATION, 2); |
| | | } |
| | | } |