| | |
| | | package com.mes.downstorage.service.impl; |
| | | |
| | | import com.github.yulichang.query.MPJQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | |
| | | //import com.mes.device.PlcParameterObject; |
| | | import com.mes.downglassinfo.entity.DownGlassTask; |
| | | import com.mes.downglassinfo.service.DownGlassTaskService; |
| | | import com.mes.downstorage.entity.DownStorageCage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.downstorage.entity.DownStorageCageDetails; |
| | | import com.mes.downstorage.mapper.DownStorageCageDetailsMapper; |
| | | import com.mes.downstorage.mapper.DownStorageCageMapper; |
| | | import com.mes.downstorage.service.DownStorageCageDetailsService; |
| | | import com.mes.downstorage.service.DownStorageCageService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.pp.entity.OptimizeDetail; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | |
| | | @Slf4j |
| | | @Service |
| | | public class DownStorageCageServiceImpl extends ServiceImpl<DownStorageCageMapper, DownStorageCage> implements DownStorageCageService { |
| | | @Autowired |
| | | @Autowired(required = false) |
| | | private DownStorageCageMapper downStorageCageMapper; |
| | | @Override |
| | | public List<Map> gettask(){ |
| | | downStorageCageMapper.selectList(null); |
| | | // downStorageCageMapper.selectJoin(); |
| | | return null; |
| | | }; |
| | | |
| | | @Autowired |
| | | private GlassInfoService glassInfoService; |
| | | |
| | | @Autowired |
| | | private DownGlassTaskService downGlassTaskService; |
| | | @Autowired |
| | | private DownStorageCageDetailsService downStorageCageDetailsService; |
| | | @Autowired |
| | | private DownStorageCageDetailsMapper downStorageCageDetailsMapper; |
| | | |
| | | @Override |
| | | public List<Map> getCacheLeisure() { |
| | | log.info(" 查询笼子内空闲"); |
| | | List<Map> map = downStorageCageMapper.selectJoinList( |
| | | Map.class, new MPJQueryWrapper<DownStorageCageDetails>() |
| | | .select("escd.*") |
| | | .leftJoin("down_storage_cage_details escd on t.slot = escd.slot") |
| | | .isNull("escd.slot") |
| | | .orderByAsc("escd.slot") |
| | | ); |
| | | return map; |
| | | public DownGlassTask createDownGlassTask(GlassInfo glassInfo, String startCell, String endCell, String taskType) { |
| | | DownGlassTask downGlassTask = new DownGlassTask(); |
| | | |
| | | BeanUtils.copyProperties(glassInfo, downGlassTask); |
| | | |
| | | downGlassTask.setStartCell(startCell); |
| | | downGlassTask.setTaskType(taskType); |
| | | downGlassTask.setEndCell(endCell); |
| | | return downGlassTask; |
| | | } |
| | | |
| | | // @Override |
| | | // public List<Map> getCacheOut(int start, int end) { |
| | | // log.info(" 根据传入的工位查询符合按照顺序和大小出片的小片"); |
| | | // List<Map> map = downStorageCageMapper.selectJoinList( |
| | | // Map.class, new MPJQueryWrapper<DownStorageCageDetails>() |
| | | // .select("escd.*") |
| | | // .leftJoin("down_storage_cage_details escd on t.slot = escd.slot") |
| | | // .leftJoin("down_workstation dw on escd.flow_card_id = dw.flow_card_id") |
| | | // .isNotNull("escd.slot") |
| | | // .between("dw.workstation_id", start, end) |
| | | // .orderByAsc("escd.tempering_layout_id, escd.tempering_feed_sequence") |
| | | // ); |
| | | // return map; |
| | | // } |
| | | @Override |
| | | public DownGlassTask createDownGlassTask(DownStorageCageDetails glassInfo, String startCell, String endCell, String taskType) { |
| | | DownGlassTask downGlassTask = new DownGlassTask(); |
| | | |
| | | BeanUtils.copyProperties(glassInfo, downGlassTask); |
| | | downGlassTask.setStartCell(startCell); |
| | | downGlassTask.setTaskType(taskType); |
| | | downGlassTask.setEndCell(endCell); |
| | | return downGlassTask; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //找到空格子 |
| | | @Override |
| | | public List<DownStorageCageDetails> selectCacheEmpty() { |
| | | return baseMapper.selectJoinList(DownStorageCageDetails.class, |
| | | JoinWrappers.lambda(DownStorageCage.class) |
| | | .selectAll(DownStorageCage.class) |
| | | .select(DownStorageCageDetails::getWidth, DownStorageCageDetails::getHeight, DownStorageCageDetails::getGlassId) |
| | | .leftJoin(DownStorageCageDetails.class, on -> on |
| | | .eq(DownStorageCageDetails::getDeviceId, DownStorageCage::getDeviceId) |
| | | .eq(DownStorageCageDetails::getSlot, DownStorageCage::getSlot)) |
| | | .isNull(DownStorageCageDetails::getSlot) |
| | | ); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Map> getCacheOut(int start, int end) { |
| | | log.info("根据传入的工位查询符合按照顺序和大小出片的小片"); |
| | | List<Map> map = downStorageCageMapper.selectJoinList( |
| | | Map.class, new MPJQueryWrapper<DownStorageCageDetails>() |
| | | .select("escd.*") |
| | | .leftJoin("down_storage_cage_details escd on t.slot = escd.slot") |
| | | .leftJoin("down_workstation dw on escd.flow_card_id = dw.flow_card_id") |
| | | .isNotNull("escd.slot") |
| | | .between("dw.workstation_id", start, end) |
| | | .orderByAsc("escd.tempering_layout_id, escd.tempering_feed_sequence") |
| | | public List<Map<String, Object>> selectDownStorageCages() { |
| | | return baseMapper.selectJoinMaps(JoinWrappers.lambda(DownStorageCage.class) |
| | | .selectAll(DownStorageCage.class) |
| | | .selectAs(DownStorageCageDetails::getId, "esdId") |
| | | .select(DownStorageCageDetails::getGlassId, DownStorageCageDetails::getWidth, DownStorageCageDetails::getHeight, DownStorageCageDetails::getId) |
| | | .leftJoin(DownStorageCageDetails.class, on -> on |
| | | .eq(DownStorageCageDetails::getDeviceId, DownStorageCage::getDeviceId) |
| | | .eq(DownStorageCageDetails::getSlot, DownStorageCage::getSlot)) |
| | | ); |
| | | |
| | | // 对获取的数据列表按照宽度进行排序 |
| | | Collections.sort(map, new Comparator<Map>() { |
| | | @Override |
| | | public int compare(Map o1, Map o2) { |
| | | // 获取宽度并比较 |
| | | double width1 = (double) o1.get("width"); |
| | | double width2 = (double) o2.get("width"); |
| | | return Double.compare(width2, width1); |
| | | } |
| | | |
| | | /** |
| | | * 修改理片笼信息 功能:对笼内栅格玻璃 【启用/禁用】 |
| | | * |
| | | * @param downStorageCage |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateDownStorageCage(DownStorageCage downStorageCage) { |
| | | DownStorageCage downItem = baseMapper.selectById(downStorageCage.getId()); |
| | | downItem.setEnableState(downStorageCage.getEnableState()); |
| | | baseMapper.updateById(downItem); |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 修改理片笼信息 功能:对笼内栅格玻璃 【添加/删除/更换】 |
| | | * |
| | | * @param downStorageCageId |
| | | * @param downStorageCageDetails |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateDownStorageCageDetails(int downStorageCageId, DownStorageCageDetails downStorageCageDetails) { |
| | | DownStorageCage downItem = baseMapper.selectById(downStorageCageId); |
| | | log.info("正常" + downItem); |
| | | if (downStorageCageDetails != null) { |
| | | DownStorageCageDetails edgDItem = downStorageCageDetailsMapper.selectById(downStorageCageDetails.getId()); |
| | | //添加 |
| | | if (edgDItem != null) { |
| | | //只传格子 :移除玻璃 |
| | | DownStorageCageDetails newresult = downStorageCageDetailsMapper.selectById(downStorageCageDetails.getId()); |
| | | newresult.setSlot(downItem.getSlot()); |
| | | downStorageCageDetailsMapper.updateById(newresult); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | return map; |
| | | if (downItem != null) { |
| | | //移除 |
| | | DownStorageCageDetails result = downStorageCageDetailsMapper.selectOne(new MPJLambdaWrapper<DownStorageCageDetails>().eq(DownStorageCageDetails::getSlot, downStorageCageId)); |
| | | if (result != null) { |
| | | result.setSlot(0); |
| | | downStorageCageDetailsMapper.updateById(result); |
| | | } |
| | | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<Map> getCacheInfo() { |
| | | log.info(" 查询笼子内信息"); |
| | | List<Map> map = downStorageCageMapper.selectJoinList( |
| | | Map.class, new MPJQueryWrapper<DownStorageCageDetails>() |
| | | .select("escd.*") |
| | | .leftJoin("down_storage_cage_details escd on t.slot = escd.slot") |
| | | .orderByAsc("t.slot") |
| | | ); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map> getIsExistIntoCacheByLayoutAndSequence(Integer tempering_layout_id, Integer tempering_feed_sequence, double width) { |
| | | log.info(" 查询可进此片玻璃的栅格号 找到相同版图id并且大于前面的顺序的空格"); |
| | | |
| | | |
| | | List<Map> map = downStorageCageMapper.selectJoinList( |
| | | Map.class, new MPJQueryWrapper<DownStorageCageDetails>() |
| | | .select("escd.*") |
| | | .leftJoin("down_storage_cage_details escd on t.slot = escd.slot") |
| | | .isNotNull("escd.slot") |
| | | .eq("escd.tempering_layout_id", tempering_layout_id) |
| | | .lt("escd.tempering_feed_sequence", tempering_feed_sequence) |
| | | .gt("t.remain_width", width) |
| | | .orderByAsc("escd.tempering_feed_sequence") |
| | | ); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map> getIsExistIntoCacheByLayout(Integer tempering_layout_id, double width) { |
| | | List<Map> map = downStorageCageMapper.selectJoinList( |
| | | Map.class, new MPJQueryWrapper<DownStorageCageDetails>() |
| | | .select("escd.*") |
| | | .leftJoin("down_storage_cage_details escd on t.slot = escd.slot") |
| | | .isNotNull("escd.slot") |
| | | .lt("escd.tempering_layout_id", tempering_layout_id) |
| | | .gt("t.remain_width", width) |
| | | .orderByDesc("escd.tempering_layout_id, escd.tempering_feed_sequence") |
| | | ); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |