| | |
| | | package com.mes.downstorage.service.impl; |
| | | |
| | | import com.github.yulichang.query.MPJQueryWrapper; |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | | import com.mes.common.PLCAutoMes; |
| | | import com.mes.common.S7control; |
| | | 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 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> |
| | | * 服务实现类 |
| | |
| | | public class DownStorageCageServiceImpl extends ServiceImpl<DownStorageCageMapper, DownStorageCage> implements DownStorageCageService { |
| | | @Autowired |
| | | 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; |
| | | |
| | | |
| | | |
| | | @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; |
| | | // } |
| | | |
| | | 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<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 boolean processInto(String Number) { |
| | | |
| | | // 对获取的数据列表按照宽度进行排序 |
| | | 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); |
| | | //按id查询玻璃信息表里的玻璃 |
| | | GlassInfo GlassInfo = glassInfoService.selectGlassId(Number); |
| | | PlcParameterObject plcmes = PLCAutoMes.PlcMesObject; |
| | | //存在此玻璃编号 |
| | | if (GlassInfo != null) { |
| | | //同找到同流程卡附近空格 |
| | | List<DownStorageCageDetails> list = selectCacheEmpty(); |
| | | |
| | | |
| | | |
| | | // list<Map> list=selectCacheEmpty(); |
| | | // list<Map> = downStorageCageService.selectCacheEmpty(); |
| | | if (list.size() > 0) { |
| | | //存在空格 |
| | | //1.生成任务: 起始位置0 结束位置this.slot 任务类型 1 (进片任务) |
| | | //2.回复 1进片 |
| | | DownStorageCageDetails item = list.get(0); |
| | | |
| | | //selectInfo.insertCacheTask(GlassInfo.getId() + "", "0", item.getSlot() + "", "1", GlassInfo.getWidth(), GlassInfo.getHeight(), GlassInfo.getFilmsid(), GlassInfo.getThickness(), GlassInfo.getFlowcardId()); |
| | | |
| | | DownGlassTask downGlassTask = createDownGlassTask(GlassInfo,"0",item.getSlot()+"","1"); |
| | | |
| | | downGlassTaskService.insertCacheTask(downGlassTask); |
| | | |
| | | //S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), (short) 1); |
| | | |
| | | |
| | | //完成后插入小片数据到缓存表 |
| | | return true; |
| | | } |
| | | }); |
| | | |
| | | return map; |
| | | } else { |
| | | // ID编号不存在 不处理/回复PLC 进行报警提示 |
| | | } |
| | | //返回结果 |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 理片 出 |
| | | * @return |
| | | */ |
| | | // |
| | | @Override |
| | | public boolean processOut() { |
| | | // 查询任务 |
| | | |
| | | |
| | | PlcParameterObject plcmes = PLCAutoMes.PlcMesObject; |
| | | |
| | | List<DownStorageCageDetails> list = downStorageCageDetailsService.CacheOut(1, 5); |
| | | List<DownStorageCageDetails> list2 = downStorageCageDetailsService.CacheOut(6, 10); |
| | | List<DownStorageCageDetails> list3 = downStorageCageDetailsService.CacheOut(1, 10); |
| | | //自动绑定架子 |
| | | |
| | | |
| | | |
| | | |
| | | // 优先 超出尺寸优先人工出片 人工处理 |
| | | |
| | | if (!list3.isEmpty()) { |
| | | DownStorageCageDetails item3 = list3.get(0); |
| | | if (item3.getHeight() >= 1 && item3.getWidth() >= 1) { |
| | | |
| | | String endcell = "13"; |
| | | String SendEndcell = "1"; |
| | | |
| | | |
| | | |
| | | DownGlassTask downGlassTask =createDownGlassTask(item3,"0",endcell,"2"); |
| | | |
| | | downGlassTaskService.insertCacheTask(downGlassTask); |
| | | // S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell); |
| | | // S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | |
| | | //如果同时前后端都空闲 优先后端出片并且优先满架 |
| | | else if (!list2.isEmpty()&&!list3.isEmpty()) { |
| | | |
| | | DownStorageCageDetails item3 = list2.get(0); |
| | | String endcell = "11"; |
| | | String SendEndcell = "1"; |
| | | |
| | | DownGlassTask downGlassTask =createDownGlassTask(item3,"0",endcell,"2"); |
| | | downGlassTaskService.insertCacheTask(downGlassTask); |
| | | |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | |
| | | } |
| | | // 按照大小符合前端出片 |
| | | else if (!list.isEmpty()) { |
| | | DownStorageCageDetails item = list.get(0); |
| | | |
| | | // 出到 G06 |
| | | |
| | | |
| | | DownGlassTask downGlassTask =createDownGlassTask(item,"0","06","2"); |
| | | downGlassTaskService.insertCacheTask(downGlassTask); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "1"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | |
| | | // 按照大小符合后端出片 |
| | | } else if (!list2.isEmpty()) { |
| | | DownStorageCageDetails item2 = list2.get(0); |
| | | |
| | | // 出到 G11 |
| | | |
| | | DownGlassTask downGlassTask =createDownGlassTask(item2,"0","11","2"); |
| | | downGlassTaskService.insertCacheTask(downGlassTask); |
| | | |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | // 返回结果 |
| | | return false; |
| | | } |
| | | |
| | | |
| | | @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") |
| | | 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) |
| | | ); |
| | | 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; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |