UI-Project/src/views/UnLoadGlass/loadmachinerack.vue
@@ -202,7 +202,7 @@ initWebSocket(); onMounted(fetchTableData); setInterval(fetchTableData, 2000) // setInterval(fetchTableData, 2000) const open = () => { ElMessageBox.confirm( hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/common/Plcdownglass.java
New file @@ -0,0 +1,74 @@ package com.mes.common; import cn.hutool.json.JSONObject; import com.mes.device.PlcParameterObject; import com.mes.downglassinfo.entity.DownGlassTask; import com.mes.downglassinfo.service.DownGlassTaskService; import com.mes.downstorage.entity.DownStorageCageDetails; import com.mes.downstorage.mapper.DownStorageCageDetailsMapper; import com.mes.downstorage.service.DownStorageCageService; import com.mes.downworkstation.service.DownWorkstationService; import com.mes.glassinfo.entity.GlassInfo; import com.mes.glassinfo.service.GlassInfoService; import com.mes.tools.WebSocketServer; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import java.util.List; @Slf4j public class Plcdownglass extends Thread { public static final String RESULT_IN = "1"; public static final String RESULT_OUT = "2"; public static final String RESULT_IN_OUT = "3"; @Autowired private DownStorageCageService downStorageCageService; @Autowired private DownWorkstationService downWorkstationService; @Override public void run() { while (this != null) { JSONObject jsonObject = new JSONObject(); try { Thread.sleep(100); String result = S7control.getinstance().ReadWord("DB14.0", 1).get(0) + ""; String number = S7control.getinstance().ReadWord("DB14.2", 1).get(0) + ""; // 进片请求 if (RESULT_IN.equals(result)) { downStorageCageService.processInto(number); } // 出片请求 else if (RESULT_OUT.equals(result)) { downStorageCageService.processOut(); } // 进出片请求 else if (RESULT_IN_OUT.equals(result)) { // 先出后进 if (!downStorageCageService.processOut()) { downStorageCageService.processInto(number); } } downWorkstationService.insertdownglassinfo(); } catch (Exception e) { e.printStackTrace(); } } } } hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/common/Plchome.java
@@ -28,15 +28,7 @@ try { i++; Thread.sleep(100); DownGlassLogic plcService = plcServiceSupplier.get(); //当下片任务表状态为1时候将数据插入到下片玻璃信息表 plcService.insertdownglassinfo(); //当机械手任务表中状态为1 更新已经落架数量,并且把下片任务表的那条记录删掉 工位表流程卡绑定了架子 plcService.downWorkstation(); } catch (InterruptedException e) { hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/DownGlassTaskService.java
@@ -23,5 +23,5 @@ DownGlassTask selectLastOutCacheInfo(String endCell); Integer insertCacheTask(Long id, String start, String end, String type, double width, double height, String filmsId, double thickness, String flowCardId); Integer insertCacheTask(DownGlassTask downGlassTask); } hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/impl/DownGlassInfoServiceImpl.java
@@ -3,9 +3,18 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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 org.springframework.stereotype.Service; import java.util.List; @Service public class DownGlassInfoServiceImpl extends ServiceImpl<DownGlassInfoMapper, DownGlassInfo> implements DownGlassInfoService { @@ -30,4 +39,8 @@ } } hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downglassinfo/service/impl/DownGlassTaskServiceImpl.java
@@ -58,17 +58,17 @@ } @Override public Integer insertCacheTask(Long id, String start, String end, String type, double width, double height, String filmsId, double thickness, String flowCardId) { public Integer insertCacheTask(DownGlassTask downGlassTask) { DownGlassTask glassInfo = new DownGlassTask(); glassInfo.setId(id); glassInfo.setStartCell(start); glassInfo.setEndCell(end); glassInfo.setTaskType(type); glassInfo.setWidth(width); glassInfo.setHeight(height); glassInfo.setFilmsid(filmsId); glassInfo.setThickness(thickness); glassInfo.setFlowCardId(flowCardId); glassInfo.setId(downGlassTask.getId()); glassInfo.setStartCell(downGlassTask.getStartCell()); glassInfo.setEndCell(downGlassTask.getEndCell()); glassInfo.setTaskType(downGlassTask.getTaskType()); glassInfo.setWidth(downGlassTask.getWidth()); glassInfo.setHeight(downGlassTask.getHeight()); glassInfo.setFilmsid(downGlassTask.getFilmsid()); glassInfo.setThickness(downGlassTask.getThickness()); glassInfo.setFlowCardId(downGlassTask.getFlowCardId()); glassInfo.setTaskStauts(0); // 默认任务状态为0 int rows = baseMapper.insert(glassInfo); hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/DownGlassCacheLogic.java
File was deleted hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/DownStorageCageDetailsService.java
@@ -1,6 +1,7 @@ package com.mes.downstorage.service; import com.mes.downstorage.entity.DownStorageCageDetails; import com.mes.glassinfo.entity.GlassInfo; import java.util.List; import java.util.Map; @@ -11,4 +12,6 @@ //修改理片笼内信息 boolean updatedownStorageCageDetails(DownStorageCageDetails details); } hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/DownStorageCageService.java
@@ -26,4 +26,8 @@ List<DownStorageCageDetails> getIsExistIntoCacheByLayout(Integer tempering_layout_id, double width); List<DownStorageCageDetails> getIsExistIntoCacheByflowcardid(String flowcardid, double width); List<DownStorageCageDetails> IsExistIntoCacheByflowcardid(String flowcardid, double width); boolean processInto(String Number); boolean processOut(); } hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageDetailsServiceImpl.java
@@ -11,6 +11,7 @@ import com.mes.downstorage.mapper.DownStorageCageDetailsMapper; import com.mes.downstorage.mapper.DownStorageCageMapper; import com.mes.downstorage.service.DownStorageCageDetailsService; import com.mes.glassinfo.entity.GlassInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -29,17 +30,12 @@ } @Override //修改理片笼内信息 功能:对笼内栅格玻璃 【添加/删除/更换】 public boolean updatedownStorageCageDetails(DownStorageCageDetails details){ baseMapper.updateById(details); return true; } hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageServiceImpl.java
@@ -1,11 +1,20 @@ package com.mes.downstorage.service.impl; import com.github.yulichang.query.MPJQueryWrapper; 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.DownStorageCageService; import com.mes.glassinfo.entity.GlassInfo; import com.mes.glassinfo.service.GlassInfoService; import com.mes.tools.WebSocketServer; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,6 +35,13 @@ public class DownStorageCageServiceImpl extends ServiceImpl<DownStorageCageMapper, DownStorageCage> implements DownStorageCageService { @Autowired private DownStorageCageMapper downStorageCageMapper; @Autowired private GlassInfoService glassInfoService; @Autowired private DownStorageCageService downStorageCageService; @Autowired private DownGlassTaskService downGlassTaskService; @Override public List<Map> gettask(){ downStorageCageMapper.selectList(null); @@ -206,6 +222,176 @@ @Override public boolean processInto(String Number) { glassInfoService = WebSocketServer.applicationContext.getBean(GlassInfoService.class); downStorageCageService = WebSocketServer.applicationContext.getBean(DownStorageCageService.class); //按id查询玻璃信息表里的玻璃 GlassInfo GlassInfo = glassInfoService.selectGlassId(Number); PlcParameterObject plcmes = PLCAutoMes.PlcMesObject; //存在此玻璃编号 if (GlassInfo != null) { //同找到同流程卡附近空格 List<DownStorageCageDetails> list = downStorageCageService.getIsExistIntoCacheByflowcardid(GlassInfo.getFlowcardId(), GlassInfo.getWidth()); 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 = new DownGlassTask(); downGlassTask.setId(GlassInfo.getId()); // 设置玻璃ID downGlassTask.setStartCell("0"); downGlassTask.setTaskType("1"); downGlassTask.setEndCell(item.getSlot()+""); downGlassTask.setWidth(GlassInfo.getWidth()); // 设置玻璃宽度 downGlassTask.setHeight(GlassInfo.getHeight()); // 设置玻璃高度 downGlassTask.setFilmsid(GlassInfo.getFilmsid()+""); // 设置膜ID downGlassTask.setThickness(GlassInfo.getThickness()); // 设置玻璃厚度 downGlassTask.setFlowCardId(GlassInfo.getFlowcardId()); // 设置流程卡号 downGlassTaskService.insertCacheTask(downGlassTask); S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), (short) 1); //完成后插入小片数据到缓存表 return true; } } else { // ID编号不存在 不处理/回复PLC 进行报警提示 } //返回结果 return false; } /** * 理片 出 * @return */ // @Override public boolean processOut() { // 查询任务 PlcParameterObject plcmes = PLCAutoMes.PlcMesObject; List<DownStorageCageDetails> list = downStorageCageService.getCacheOut(1, 5); List<DownStorageCageDetails> list2 = downStorageCageService.getCacheOut(6, 10); List<DownStorageCageDetails> list3 = downStorageCageService.getCacheOut(1, 10); //自动绑定架子 // 优先 超出尺寸优先人工出片 人工处理 if (!list3.isEmpty()) { DownStorageCageDetails item3 = list3.get(0); if (item3.getHeight() >= 1 && item3.getWidth() >= 1) { String endcell = "13"; String SendEndcell = "1"; // selectInfo.insertCacheTask(item3.getGlassId() + "", "0", endcell, "2", item3.getWidth(), item3.getHeight(), item3.getFilmsid(), item3.getThickness(), item3.getFlowCardId()); DownGlassTask downGlassTask = new DownGlassTask(); downGlassTask.setId(item3.getId()); // 设置玻璃ID downGlassTask.setStartCell("0"); downGlassTask.setEndCell(endcell); downGlassTask.setTaskType("2"); downGlassTask.setWidth(item3.getWidth()); // 设置玻璃宽度 downGlassTask.setHeight(item3.getHeight()); // 设置玻璃高度 downGlassTask.setFilmsid(item3.getFilmsid()+""); // 设置膜ID downGlassTask.setThickness(item3.getThickness()); // 设置玻璃厚度 downGlassTask.setFlowCardId(item3.getFlowCardId()); // 设置流程卡号 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 (!list3.isEmpty()) { DownStorageCageDetails item3 = list3.get(0); String endcell = "11"; String SendEndcell = "1"; // selectInfo.insertCacheTask(item3.getGlassId() + "", "0", endcell, "2", item3.getWidth(), item3.getHeight(), item3.getFilmsid(), item3.getThickness(), item3.getFlowCardId()); DownGlassTask downGlassTask = new DownGlassTask(); downGlassTask.setId(item3.getId()); // 设置玻璃ID downGlassTask.setStartCell("0"); downGlassTask.setEndCell(endcell); downGlassTask.setTaskType("2"); downGlassTask.setWidth(item3.getWidth()); // 设置玻璃宽度 downGlassTask.setHeight(item3.getHeight()); // 设置玻璃高度 downGlassTask.setFilmsid(item3.getFilmsid()+""); // 设置膜ID downGlassTask.setThickness(item3.getThickness()); // 设置玻璃厚度 downGlassTask.setFlowCardId(item3.getFlowCardId()); // 设置流程卡号 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 //selectInfo.insertCacheTask(item.getGlassId() + "", "0", "06", "2", item.getWidth(), item.getHeight(), item.getFilmsid(), item.getThickness(), item.getFlowCardId()); DownGlassTask downGlassTask = new DownGlassTask(); downGlassTask.setId(item.getId()); // 设置玻璃ID downGlassTask.setStartCell("0"); downGlassTask.setEndCell("06"); downGlassTask.setTaskType("2"); downGlassTask.setWidth(item.getWidth()); // 设置玻璃宽度 downGlassTask.setHeight(item.getHeight()); // 设置玻璃高度 downGlassTask.setFilmsid(item.getFilmsid()+""); // 设置膜ID downGlassTask.setThickness(item.getThickness()); // 设置玻璃厚度 downGlassTask.setFlowCardId(item.getFlowCardId()); // 设置流程卡号 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 // selectInfo.insertCacheTask(item2.getGlassId() + "", "0", "11", "2", item2.getWidth(), item2.getHeight(), item2.getFilmsid(), item2.getThickness(), item2.getFlowCardId()); DownGlassTask downGlassTask = new DownGlassTask(); downGlassTask.setId(item2.getId()); // 设置玻璃ID downGlassTask.setStartCell("0"); downGlassTask.setEndCell("11"); downGlassTask.setTaskType("2"); downGlassTask.setWidth(item2.getWidth()); // 设置玻璃宽度 downGlassTask.setHeight(item2.getHeight()); // 设置玻璃高度 downGlassTask.setFilmsid(item2.getFilmsid()+""); // 设置膜ID downGlassTask.setThickness(item2.getThickness()); // 设置玻璃厚度 downGlassTask.setFlowCardId(item2.getFlowCardId()); // 设置流程卡号 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; } hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downworkstation/service/DownGlassLogic.java
File was deleted hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downworkstation/service/DownWorkstationService.java
@@ -27,6 +27,6 @@ int updateFlowCardIdAndCount(String flowCardId, int glassInfoCount, int workstationId); void insertdownglassinfo(); } hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downworkstation/service/impl/DownWorkstationServiceImpl.java
@@ -3,12 +3,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mes.downglassinfo.entity.DownGlassInfo; import com.mes.downglassinfo.entity.DownGlassTask; import com.mes.downglassinfo.service.DownGlassInfoService; import com.mes.downglassinfo.service.DownGlassTaskService; import com.mes.downworkstation.entity.DownWorkstation; import com.mes.downworkstation.entity.DownWorkstationTask; import com.mes.downworkstation.mapper.DownWorkstationMapper; import com.mes.downworkstation.mapper.DownWorkstationTaskMapper; import com.mes.downworkstation.service.DownWorkstationService; import com.mes.downworkstation.service.DownWorkstationTaskService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -21,9 +25,17 @@ @Autowired private DownWorkstationMapper downWorkstationMapper; @Autowired private DownWorkstationTaskMapper downWorkstationTaskMapper; @Autowired private DownGlassInfoService downGlassInfoService; @Autowired private DownGlassTaskService downGlassTaskService; @Autowired private DownWorkstationService downWorkstationService; @Autowired private DownWorkstationTaskService downWorkstationTaskService; // @Override // public List<DownWorkstation> gettwoDownWorkstations() { @@ -126,4 +138,80 @@ @Override public void insertdownglassinfo() { List<DownGlassTask> taskdownGlassInf = downGlassTaskService.getUnloadingTaskState(); // if (taskdownGlassInf != null && !taskdownGlassInf.isEmpty()) { // for (DownGlassTask downGlassInfo : taskdownGlassInf) { // 创建新的 DownGlassInfo 对象并设置相关属性 DownGlassInfo newdownGlassInfo = new DownGlassInfo(); newdownGlassInfo.setFlowCardId(downGlassInfo.getFlowCardId()); Integer maxSequence = downGlassInfoService.getMaxSequenceByFlowCardId(downGlassInfo.getFlowCardId()); // 初始化顺序字段值 int sequence = maxSequence != null ? maxSequence + 1 : 1; newdownGlassInfo.setWidth(downGlassInfo.getWidth()); newdownGlassInfo.setHeight(downGlassInfo.getHeight()); newdownGlassInfo.setThickness(downGlassInfo.getThickness()); newdownGlassInfo.setFilmsid(downGlassInfo.getFilmsid()); // 设置顺序字段值 newdownGlassInfo.setSequence(sequence); // 插入数据到下片玻璃信息表 downGlassInfoService.insertDownGlassInfo(newdownGlassInfo); //插入数据到机械手任务表 downWorkstationTaskService.insertdownWorkstationtask(newdownGlassInfo); //更新下片任务表状态为0 downGlassTaskService.updateTaskStateToZero(downGlassInfo.getId()); sequence++; // 递增顺序字段值 } } try { //查询下片工位表中架子是否绑定了流程卡号 工位表和任务表中状态为1的流程卡号和已落架数量 List<DownWorkstation> taskdownWorkstation = downWorkstationMapper.selectdownWorkstationstate(); if (taskdownWorkstation != null && !taskdownWorkstation.isEmpty()) { //,如果已经绑定则更新已落架数量,并且删除下片任务表中的记录 for (DownWorkstation downWorkstation : taskdownWorkstation) { //更新下片工位表中已落架数量 downWorkstationService.updateracksnumber(downWorkstation.getFlowCardId(), downWorkstation.getRacksnumber() + 1); //更新机械任务表中状态为0 downWorkstationTaskService.updateTaskStateToZero(downWorkstation.getId()); //删除下片任务表中的记录 downGlassTaskService.deleteTask(downWorkstation.getId()); } } } catch (Exception e) { // 打印异常信息 e.printStackTrace(); // 或者可以进行其他异常处理,比如记录日志或者返回特定的错误信息 } } }