hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/Const.java
@@ -6,6 +6,13 @@ * @Description: */ public class Const { //默认密码 public static final String DEFULT_PASSWORD = "123456"; //默认角色 public static final Long DEFULT_ROLE = 1L; //A09出片目标位置 public static final String A09_OUT_TARGET_POSITION = "2001"; //A09出片目标位置 public static final String A10_OUT_TARGET_POSITION = "2002"; } hangzhoumesParent/common/servicebase/src/main/java/com/mes/device/PlcParameterInfo.java
@@ -105,9 +105,10 @@ if (addressLength < 2) { return null; } if (addressLength == 2) { int wordindex = index; return stringdatas[0] + "." + wordindex; /* if (addressLength == 2) { return stringdatas[0] + "." + wordindex; } @@ -115,8 +116,8 @@ int wordindex = index; int newIndex = wordindex + 13; return stringdatas[0] + "." + wordindex + "-" + newIndex; } return null; }*/ // return null; } public int getPlcAddress() { hangzhoumesParent/common/servicebase/src/main/java/com/mes/device/PlcParameterObject.java
@@ -148,7 +148,10 @@ } if (plcParameterInfo.getAddressLength() == 2) { plcParameterInfo.setValue(String.valueOf(byte2short(valueList))); } else if (plcParameterInfo.getAddressLength() == 14) { } else if (plcParameterInfo.getAddressLength() == 4) { plcParameterInfo.setValue(String.valueOf(byte2int(valueList))); } else if (plcParameterInfo.getAddressLength() >10) { plcParameterInfo.setValue((byteToHexString(valueList))); } else { String valuestr = new String(valueList); @@ -186,9 +189,21 @@ return l; } /** * byte[]类型转short * * @param b byte[]类型值 */ public static short byte2int(byte[] b) { short l = 0; for (int i = 0; i < 4; i++) { l <<= 8; //<<=和我们的 +=是一样的,意思就是 l = l << 8 l |= (b[3-i] & 0xff); //和上面也是一样的 l = l | (b[i]&0xff) } return l; } public static String byteToHexString(byte[] bytes) { String str = new String(bytes, StandardCharsets.UTF_8); String str = new String(bytes, StandardCharsets.UTF_8).trim(); return str; } hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/AppRunnerConfig.java
@@ -1,6 +1,6 @@ package com.mes; import com.mes.common.PlcHomeEdg; import com.mes.common.S7object; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; @@ -17,7 +17,7 @@ public void run(ApplicationArguments args) throws Exception { // TODO Auto-generated method stub log.info("启动完成"); new PlcHomeEdg().start(); S7object.getinstance().start(); } } hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/CacheGlassModuleApplication.java
@@ -1,15 +1,12 @@ package com.mes; import com.mes.common.WebSocketServer; import lombok.extern.slf4j.Slf4j; import org.mybatis.spring.annotation.MapperScan; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.scheduling.annotation.EnableScheduling; import springfox.documentation.swagger2.annotations.EnableSwagger2; import com.mes.edgstoragecage.service.*; /** * @Author : zhoush @@ -21,14 +18,15 @@ @MapperScan("com.mes.*.mapper") @EnableDiscoveryClient @EnableSwagger2 @EnableScheduling public class CacheGlassModuleApplication { public static void main(String[] args) { try { SpringApplication springApplication = new SpringApplication(CacheGlassModuleApplication.class); ConfigurableApplicationContext applicationContext = springApplication.run(args); WebSocketServer.setApplicationContext(applicationContext); //SpringApplication.run(CacheGlassModuleApplication.class, args); // SpringApplication springApplication = new SpringApplication(CacheGlassModuleApplication.class); // ConfigurableApplicationContext applicationContext = springApplication.run(args); // WebSocketServer.setApplicationContext(applicationContext); SpringApplication.run(CacheGlassModuleApplication.class, args); } catch (Exception e) { log.error(e.getMessage()); } hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/InitUtil.java
File was deleted hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/JsonFile/PlcCacheGlass.json
File was deleted hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PLCAutoMes.java
File was deleted hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcBitInfo.java
File was deleted hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcBitObject.java
File was deleted hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcHomeEdg.java
@@ -1,6 +1,5 @@ package com.mes.common; import cn.hutool.core.date.DateTime; import cn.hutool.json.JSONObject; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.mes.edgstoragecage.entity.EdgStorageCage; @@ -17,10 +16,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.*; @Service @Slf4j @@ -91,7 +87,7 @@ taskCache.setStartCell(0); taskCache.setEndCell(edgStorageCage.getSlot()); taskCache.setTaskType(1); taskCache.setCreateTime(new DateTime()); taskCache.setCreateTime(new Date()); edgStorageCageDetailsMapper.updateById(edgStorageCageDetails); taskCacheService.insertTaskCache(taskCache); S7object.getinstance().plccontrol.WriteWord(mapParameter.get("MES_confirmation_word"), (short)1); @@ -129,7 +125,7 @@ taskCache.setStartCell(outEdgStorageCageDetails.getSlot()); taskCache.setEndCell(endcell); taskCache.setTaskType(2); taskCache.setCreateTime(new DateTime()); taskCache.setCreateTime(new Date()); taskCacheService.insertTaskCache(taskCache); S7object.getinstance().plccontrol.WriteWord(mapParameter.get("MES_confirmation_word"), (short)1); } @@ -153,18 +149,16 @@ } mapValue.put(key, value); } S7object.getinstance().plccontrol.WriteWord(S7object.getinstance().PlcMesObject.getPlcParameter("A06_request_word").getAddress(), (short)1); try { Thread.sleep(1000); taskCacheService = WebSocketServer.applicationContext.getBean(TaskCacheService.class); glassInfoService = WebSocketServer.applicationContext.getBean(GlassInfoService.class); edgStorageCageService = WebSocketServer.applicationContext.getBean(EdgStorageCageService.class); edgStorageCageDetailsMapper = WebSocketServer.applicationContext.getBean(EdgStorageCageDetailsMapper.class); // initialize();//初始化数据 if ("0".equals(mapValue.get("A06_request_word"))) { if ("0".equals(S7object.getinstance().PlcMesObject.getPlcParameter("A06_request_word"))) { //清除 S7object.getinstance().plccontrol.WriteWord(mapParameter.get("MES_confirmation_word"), (short) 0); } else if ("1".equals(mapValue.get("A06_request_word")) && "0".equals(mapValue.get("MES_confirmation_word"))) { } else if ("1".equals(S7object.getinstance().PlcMesObject.getPlcParameter("A06_request_word")) && "0".equals(S7object.getinstance().PlcMesObject.getPlcParameter("MES_confirmation_word"))) { inTo(); } else if ("2".equals(mapValue.get("A06_request_word")) && hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcParameterInfo.java
File was deleted hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcParameterObject.java
File was deleted hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/S7object.java
@@ -1,24 +1,34 @@ package com.mes.common; import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType; import com.mes.device.PlcParameterObject; import com.mes.tools.InitUtil; import com.mes.tools.S7control; /** * @Author : zhoush * @Date: 2024/4/9 15:13 * @Description: */ public class S7object { public class S7object extends Thread { public S7control plccontrol; // PLC通讯类实例 private EPlcType plcType = EPlcType.S1200; // 西门子PLC类型 private String ip = "192.168.10.1"; // plc ip地址 private int port = 102; // plc 端口号 public PlcParameterObject PlcMesObject; private static volatile S7object instance = null; private S7object() { if (plccontrol == null) { plccontrol = new S7control(plcType, ip, port, 0, 0); String PlcCacheGlass=S7object.class.getResource("/JsonFile/PlcCacheGlass.json").getPath(); //log.info(PLCAutoMes.class.getResource("").getPath()); PlcMesObject = InitUtil.initword(PlcCacheGlass); } } @@ -33,4 +43,20 @@ } return instance; } @Override public void run() { while (this != null) { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } byte[] getplcvlues= plccontrol.ReadByte(PlcMesObject.getPlcAddressBegin(),PlcMesObject.getPlcAddressLength()); PlcMesObject.setPlcParameterList(getplcvlues); } } } hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/edgstoragecage/service/impl/EdgStorageCageDetailsServiceImpl.java
@@ -1,10 +1,10 @@ package com.mes.edgstoragecage.service.impl; import cn.hutool.core.lang.Assert; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.github.yulichang.base.MPJBaseServiceImpl; import com.github.yulichang.query.MPJLambdaQueryWrapper; import com.github.yulichang.query.MPJQueryWrapper; import com.github.yulichang.toolkit.JoinWrappers; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.mes.edgstoragecage.entity.EdgStorageCage; @@ -16,13 +16,18 @@ import com.mes.pp.entity.OptimizeLayout; import com.mes.pp.mapper.OptimizeDetailMapper; import com.mes.taskcache.entity.TaskCache; import com.mes.taskcache.service.TaskCacheService; import com.mes.uppattenusage.entity.UpPattenUsage; import com.mes.uppattenusage.mapper.UpPattenUsageMapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; /** * <p> @@ -33,22 +38,30 @@ * @since 2024-04-07 */ @Service @Slf4j public class EdgStorageCageDetailsServiceImpl extends MPJBaseServiceImpl<EdgStorageCageDetailsMapper, EdgStorageCageDetails> implements EdgStorageCageDetailsService { @Autowired @Resource UpPattenUsageMapper upPattenUsageMapper; @Autowired OptimizeDetailMapper optimizeDetailMapper; @Autowired @Resource EdgStorageCageMapper edgStorageCageMapper; @Autowired TaskCacheService taskCacheService; /** * 识别 拿走:200/破损:201 * * @param glassId * @param ControlsId * @return */ @Override public boolean identWorn(String glassId, int ControlsId) { List<EdgStorageCageDetails> edgStorageCageDetails = baseMapper.selectList(new MPJLambdaQueryWrapper<EdgStorageCageDetails>().selectAll(EdgStorageCageDetails.class).eq(EdgStorageCageDetails::getGlassId,glassId)); if (edgStorageCageDetails.size() == 1) { @@ -70,6 +83,7 @@ /** * 获取 切割当前版图 * * @return */ @Override @@ -104,6 +118,7 @@ /** * 获取 工程下的当前版图 * * @param current * @return */ @@ -129,6 +144,7 @@ /** * 查询笼内版图差值范围内的 此尺寸玻璃 如无则按照 钢化版图序号 以及玻璃序号 * * @param glassId * @param poor * @return @@ -138,45 +154,61 @@ //1.去笼内查询此尺寸的玻璃 目前版图差值内的玻璃 是否有同尺寸的 //1.1 有同尺寸的 则生成同尺寸的任务 //1.2 无同尺寸的 则生成版图顺序最小的出片 EdgStorageCageDetails edgStorageCageDetails= baseMapper.selectOne(new MPJLambdaQueryWrapper<EdgStorageCageDetails>() log.info("按照玻璃id:{}获取玻璃信息", glassId); EdgStorageCageDetails oldEdgStorageCageDetails = null; if (StringUtils.isNotEmpty(glassId)) { oldEdgStorageCageDetails = baseMapper.selectOne(new MPJLambdaQueryWrapper<EdgStorageCageDetails>() .selectAll(EdgStorageCageDetails.class) .eq(EdgStorageCageDetails::getGlassId,glassId) ); List<EdgStorageCageDetails> listEdgStorageCageDetails= baseMapper.selectList(new LambdaQueryWrapper<EdgStorageCageDetails>() .lt(EdgStorageCageDetails::getState,200) .orderByAsc(EdgStorageCageDetails::getTemperingLayoutId,EdgStorageCageDetails::getTemperingFeedSequence) ); EdgStorageCageDetails minTemperingLayoutId=new EdgStorageCageDetails(); if(!listEdgStorageCageDetails.isEmpty()){ minTemperingLayoutId=listEdgStorageCageDetails.get(0); .eq(EdgStorageCageDetails::getGlassId, glassId)); } EdgStorageCageDetails result=new EdgStorageCageDetails(); if(edgStorageCageDetails!=null&&minTemperingLayoutId!=null){ result=edgStorageCageMapper.selectJoinOne(EdgStorageCageDetails.class,new MPJLambdaWrapper<EdgStorageCage>() LambdaQueryWrapper<TaskCache> wrapper = new LambdaQueryWrapper<TaskCache>().select(TaskCache::getGlassId).eq(TaskCache::getTaskType, "2"); List<TaskCache> taskCacheList = taskCacheService.list(wrapper); List<String> glassIds = taskCacheList.stream().map(TaskCache::getGlassId).collect(Collectors.toList()); log.info("获取笼内所有已出片的玻璃id信息:{}", glassIds); EdgStorageCageDetails minTemperingLayoutId = baseMapper.selectOne(new LambdaQueryWrapper<EdgStorageCageDetails>() .eq(EdgStorageCageDetails::getState, 100) .notIn(CollectionUtils.isNotEmpty(glassIds), EdgStorageCageDetails::getGlassId, glassIds) .orderByAsc(EdgStorageCageDetails::getTemperingLayoutId, EdgStorageCageDetails::getTemperingFeedSequence) .last("limit 1")); Assert.isTrue(minTemperingLayoutId != null, "笼内无符合要求的玻璃"); log.info("获取笼内最小版图id{}及版序为{}的玻璃信息{}", minTemperingLayoutId.getTemperingLayoutId(), minTemperingLayoutId.getTemperingFeedSequence(), minTemperingLayoutId); EdgStorageCageDetails outEdgStorageCageDetails = null; if (oldEdgStorageCageDetails != null && minTemperingLayoutId != null) { log.info("按照上一片已出玻璃宽度{},高度{},及版图id区间{}到{}获取出片任务玻璃信息", oldEdgStorageCageDetails.getWidth() , oldEdgStorageCageDetails.getHeight(), minTemperingLayoutId.getTemperingLayoutId(), minTemperingLayoutId.getTemperingLayoutId() + poor); outEdgStorageCageDetails = edgStorageCageMapper.selectJoinOne(EdgStorageCageDetails.class, new MPJLambdaWrapper<EdgStorageCage>() .selectAll(EdgStorageCageDetails.class) .leftJoin(EdgStorageCageDetails.class,on->on .eq(EdgStorageCageDetails::getDeviceId,EdgStorageCage::getDeviceId) .eq(EdgStorageCageDetails::getSlot,EdgStorageCage::getSlot)) .isNotNull(EdgStorageCageDetails::getSlot) .eq(EdgStorageCageDetails::getWidth,edgStorageCageDetails.getWidth()) .eq(EdgStorageCageDetails::getHeight,edgStorageCageDetails.getHeight()) .eq(EdgStorageCageDetails::getWidth, oldEdgStorageCageDetails.getWidth()) .eq(EdgStorageCageDetails::getHeight, oldEdgStorageCageDetails.getHeight()) .ge(EdgStorageCageDetails::getTemperingLayoutId,minTemperingLayoutId.getTemperingLayoutId()) .le(EdgStorageCageDetails::getTemperingLayoutId,minTemperingLayoutId.getTemperingLayoutId()+poor) .orderByAsc(EdgStorageCageDetails::getTemperingLayoutId,EdgStorageCageDetails::getTemperingFeedSequence) .last("limit 1") ); log.info("出片任务的玻璃信息:{}", outEdgStorageCageDetails); } if (result==null){ result=edgStorageCageMapper.selectJoinOne(EdgStorageCageDetails.class,new MPJLambdaWrapper<EdgStorageCage>() .selectAll(EdgStorageCageDetails.class) .leftJoin(EdgStorageCageDetails.class,on->on .eq(EdgStorageCageDetails::getDeviceId,EdgStorageCage::getDeviceId) .eq(EdgStorageCageDetails::getSlot,EdgStorageCage::getSlot)) .isNotNull(EdgStorageCageDetails::getSlot) .orderByAsc(EdgStorageCageDetails::getTemperingLayoutId,EdgStorageCageDetails::getTemperingFeedSequence) ); if (outEdgStorageCageDetails == null) { outEdgStorageCageDetails = minTemperingLayoutId; // outEdgStorageCageDetails = edgStorageCageMapper.selectJoinOne(EdgStorageCageDetails.class, new MPJLambdaWrapper<EdgStorageCage>() // .selectAll(EdgStorageCageDetails.class) // .leftJoin(EdgStorageCageDetails.class, on -> on // .eq(EdgStorageCageDetails::getDeviceId, EdgStorageCage::getDeviceId) // .eq(EdgStorageCageDetails::getSlot, EdgStorageCage::getSlot)) // .isNotNull(EdgStorageCageDetails::getSlot) // .orderByAsc(EdgStorageCageDetails::getTemperingLayoutId, EdgStorageCageDetails::getTemperingFeedSequence) // .last("limit 1") // ); } return result; return outEdgStorageCageDetails; } } hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/edgstoragecage/service/impl/EdgStorageCageServiceImpl.java
@@ -1,27 +1,21 @@ package com.mes.edgstoragecage.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.UpdateWrapper; import com.github.yulichang.base.MPJBaseServiceImpl; import com.github.yulichang.query.MPJLambdaQueryWrapper; import com.github.yulichang.query.MPJQueryWrapper; import com.github.yulichang.toolkit.JoinWrappers; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.mes.edgstoragecage.entity.EdgStorageCage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mes.edgstoragecage.entity.EdgStorageCageDetails; import com.mes.edgstoragecage.mapper.EdgStorageCageMapper; import com.mes.edgstoragecage.mapper.EdgStorageCageDetailsMapper; import com.mes.edgstoragecage.mapper.EdgStorageCageMapper; import com.mes.edgstoragecage.service.EdgStorageCageService; import com.mes.uppattenusage.entity.UpPattenUsage; import com.mes.uppattenusage.mapper.UpPattenUsageMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; import java.util.*; import java.util.stream.Collectors; /** * <p> @@ -49,24 +43,10 @@ return baseMapper.selectJoinList(EdgStorageCage.class,new MPJLambdaWrapper<EdgStorageCage>() .selectAll(EdgStorageCage.class) .leftJoin(EdgStorageCageDetails.class,on->on .eq(EdgStorageCageDetails::getDeviceId,EdgStorageCage::getDeviceId) .eq(EdgStorageCageDetails::getSlot,EdgStorageCage::getSlot)) .eq(EdgStorageCageDetails::getSlot,EdgStorageCage::getSlot) .eq(EdgStorageCageDetails::getState,"100")) .isNull(EdgStorageCageDetails::getSlot) ); // return baseMapper.selectJoinMaps(JoinWrappers.lambda(EdgStorageCage.class).selectAll(EdgStorageCage.class) // .select(EdgStorageCageDetails::getWidth, EdgStorageCageDetails::getHeight,EdgStorageCageDetails::getGlassId) // .leftJoin(EdgStorageCageDetails.class,on->on // .eq(EdgStorageCageDetails::getDeviceId,EdgStorageCage::getDeviceId) // .eq(EdgStorageCageDetails::getSlot,EdgStorageCage::getSlot)) // .isNull(EdgStorageCageDetails::getSlot) // ); // return baseMapper.selectJoinMaps(new MPJQueryWrapper<EdgStorageCage>().selectAll(EdgStorageCage.class) // .select("escd.glass_id","escd.flow_card_id","escd.width","escd.height") // .leftJoin("edg_storage_cage_details escd on t.device_id=escd.device_id and t.slot=escd.slot") // .isNull("escd.slot") // ); } /** hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java
New file @@ -0,0 +1,167 @@ package com.mes.job; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.Assert; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.mes.common.S7object; import com.mes.common.config.Const; import com.mes.device.PlcParameterObject; import com.mes.edgstoragecage.entity.EdgStorageCage; import com.mes.edgstoragecage.entity.EdgStorageCageDetails; import com.mes.edgstoragecage.service.EdgStorageCageDetailsService; import com.mes.edgstoragecage.service.EdgStorageCageService; import com.mes.glassinfo.entity.GlassInfo; import com.mes.glassinfo.service.GlassInfoService; import com.mes.taskcache.entity.TaskCache; import com.mes.taskcache.service.TaskCacheService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.util.Date; import java.util.List; /** * @Author : zhoush * @Date: 2024/5/8 8:17 * @Description: */ @Component @Slf4j public class CacheGlassTask { @Autowired TaskCacheService taskCacheService; @Autowired GlassInfoService glassInfoService; @Autowired EdgStorageCageService edgStorageCageService; @Autowired EdgStorageCageDetailsService edgStorageCageDetailsService; @Value("${mes.threshold}") private int threshold; @Scheduled(fixedDelay = 10000) public void plcHomeEdgTask() { PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; String taskRequestTypeValue = plcParameterObject.getPlcParameter("A06_request_word").getValue(); String glassIdeValue = plcParameterObject.getPlcParameter("A05_scanning_ID").getValue(); String confirmationWrodValue = plcParameterObject.getPlcParameter("MES_confirmation_word").getValue(); // 1为A09空闲,2为A10空闲,3为A09A10都空闲,0为A09A10都有玻璃 String outGlassstate = plcParameterObject.getPlcParameter("A09_glass_status").getValue(); String confirmationWrodAddress = plcParameterObject.getPlcParameter("MES_confirmation_word").getAddress(); if ("0".equals(taskRequestTypeValue)) { log.info("1、获取到的请求字为0,将确认字改为0"); S7object.getinstance().plccontrol.WriteWord(confirmationWrodAddress, (short) 0); return; } if (!"0".equals(confirmationWrodValue)) { log.info("1、获取到的请求字不为0,将确认字改为0"); S7object.getinstance().plccontrol.WriteWord(confirmationWrodAddress, (short) 0); return; } if ("1".equals(taskRequestTypeValue)) { log.info("2、进片请求,且确认字为0,执行进片任务"); inTo(glassIdeValue, confirmationWrodAddress); } else if ("2".equals(taskRequestTypeValue)) { //09空闲 :1 10空闲 :2 都空闲:3 其他0 log.info("2、出片请求,且确认字为0,执行进片任务"); outTo(Integer.parseInt(outGlassstate), confirmationWrodAddress); } else if ("3".equals(taskRequestTypeValue)) { log.info("2、进片和出片都空闲,执行出片任务"); if ("0".equals(outGlassstate)) { inTo(glassIdeValue, confirmationWrodAddress); } else { outTo(Integer.parseInt(outGlassstate), confirmationWrodAddress); } } } private void inTo(String glassId, String confirmationWrodAddress) { log.info("1、按照玻璃id:{}获取玻璃小片信息", glassId); GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId)); if (glassInfo == null) { log.info("2、此玻璃编号不存在"); return; } log.info("2、获取到的玻璃信息为{}", glassInfo); //添加进片任务 查找空格 List<EdgStorageCage> list = edgStorageCageService.selectCacheEmpty(); log.info("3、查询卧式理片笼里面的空格:{}", list); if (CollectionUtil.isEmpty(list)) { log.info("4、不存在空格"); return; } log.info("4、将玻璃信息插入卧式理片笼:{}", glassInfo); EdgStorageCageDetails details = new EdgStorageCageDetails(); BeanUtils.copyProperties(glassInfo, details); details.setState(100); Integer slot = list.get(0).getSlot(); Integer deviceId = list.get(0).getDeviceId(); log.info("5、获取空闲格子为:{},设备号为{}", slot, deviceId); details.setSlot(slot); details.setDeviceId(deviceId); edgStorageCageDetailsService.save(details); log.info("6、生成进片任务信息存入任务表"); TaskCache taskCache = new TaskCache(); taskCache.setGlassId(glassId); taskCache.setTaskStatus(0); taskCache.setStartCell(0); taskCache.setEndCell(slot); taskCache.setTaskType(1); taskCache.setCreateTime(new Date()); taskCacheService.insertTaskCache(taskCache); log.info("6、发送确认字"); S7object.getinstance().plccontrol.WriteWord(confirmationWrodAddress, (short) 1); } private void outTo(int line, String confirmationWrodAddress) { Assert.isTrue(line != 0, "A09、A10都有玻璃,无法出片"); log.info("1、出片任务出【{}】号线,备注(09空闲:1;10空闲:2;都空闲:3)", line); int endcell = 0; List<TaskCache> oldTaskCacheList; log.info("2、判断出片线路,获取最后该条线已出片的任务信息(备注:0待执行,1已执行),都空闲优先出A09线"); if (line == 2) { endcell = 2002; oldTaskCacheList = taskCacheService.selectLastOutCacheInfos(Const.A10_OUT_TARGET_POSITION); } else { endcell = 2001; oldTaskCacheList = taskCacheService.selectLastOutCacheInfos(Const.A09_OUT_TARGET_POSITION); } String glassId = ""; if (CollectionUtil.isNotEmpty(oldTaskCacheList)) { glassId = oldTaskCacheList.get(0).getGlassId(); } log.info("3、按照历史已出玻璃id{}和阈值{},拿出理片笼内的出片信息", glassId, threshold); EdgStorageCageDetails glassInfo = edgStorageCageDetailsService.selectConformGlass(glassId, threshold); if (glassInfo != null) { log.info("4、添加出片任务,玻璃id:{},任务类型:{},起始位置:{},结束位置:{}", glassInfo.getGlassId(), 2, glassInfo.getSlot(), endcell); TaskCache taskCache = new TaskCache(); taskCache.setGlassId(glassInfo.getGlassId()); taskCache.setTaskStatus(0); taskCache.setStartCell(glassInfo.getSlot()); taskCache.setEndCell(endcell); taskCache.setTaskType(2); taskCache.setCreateTime(new Date()); taskCacheService.insertTaskCache(taskCache); S7object.getinstance().plccontrol.WriteWord(confirmationWrodAddress, (short) 1); } } } hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/taskcache/entity/TaskCache.java
@@ -1,8 +1,9 @@ package com.mes.taskcache.entity; import cn.hutool.core.date.DateTime; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.util.Date; @Data //lombok 简写java代码 实体类的get与set @TableName("task_cache") @@ -12,6 +13,6 @@ private int endCell;//结束 private int taskType;//任务类型 private int taskStatus;//任务状态 private DateTime createTime;//任务状态 private Date createTime;//任务状态 } hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/taskcache/service/impl/TaskCacheServiceImpl.java
@@ -1,18 +1,10 @@ package com.mes.taskcache.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.yulichang.query.MPJLambdaQueryWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.mes.edgstoragecage.entity.EdgStorageCageDetails; import com.mes.edgstoragecage.mapper.EdgStorageCageDetailsMapper; import com.mes.glassinfo.entity.GlassInfo; import com.mes.glassinfo.mapper.GlassInfoMapper; import com.mes.taskcache.entity.TaskCache; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.mes.taskcache.entity.TaskCache; import com.mes.taskcache.mapper.TaskCacheMapper; import com.mes.taskcache.service.TaskCacheService; import com.mes.uppattenusage.entity.UpPattenUsage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @@ -98,7 +90,7 @@ */ @Override public List<TaskCache> selectLastOutCacheInfos(String line){ return baseMapper.selectList(new MPJLambdaWrapper<TaskCache>().selectAll(TaskCache.class).eq(TaskCache::getEndCell,line).eq(TaskCache::getTaskStatus,1).orderByDesc(TaskCache::getGlassId)); return baseMapper.selectList(new MPJLambdaWrapper<TaskCache>().selectAll(TaskCache.class).eq(TaskCache::getEndCell,line).eq(TaskCache::getTaskStatus,1).orderByDesc(TaskCache::getCreateTime)); // return baseMapper.selectList(new QueryWrapper<TaskCache>().eq("end_cell",line).eq("task_status",1).orderByDesc("ID")); } @@ -109,7 +101,7 @@ */ @Override public TaskCache selectLastOutCacheInfo(String line){ return baseMapper.selectOne(new MPJLambdaWrapper<TaskCache>().selectAll(TaskCache.class).eq(TaskCache::getEndCell,line).eq(TaskCache::getTaskStatus,1).orderByDesc(TaskCache::getGlassId)); return baseMapper.selectOne(new MPJLambdaWrapper<TaskCache>().selectAll(TaskCache.class).eq(TaskCache::getEndCell,line).eq(TaskCache::getTaskStatus,1).orderByDesc(TaskCache::getCreateTime)); } hangzhoumesParent/moduleService/CacheGlassModule/src/main/resources/JsonFile/PlcCacheGlass.json
New file @@ -0,0 +1,57 @@ { "plcAddressBegin":"DB11.0", "plcAddressLenght":"80", "dataType":"word", "parameteInfor":[ { "codeId": "A06_request_word", "addressIndex":"0", "addressLenght":"2", "ratio":"1", "unit":"m/min" }, { "codeId": "A05_scanning_ID", "addressIndex":"2", "addressLenght":"30", "ratio":"1", "unit":"" }, { "codeId": "MES_confirmation_word", "addressIndex":"38", "addressLenght":"2", "ratio":"1", "unit":"" }, { "codeId": "A09_glass_status", "addressIndex":"68", "addressLenght":"2", "ratio":"1", "unit":"" }, { "codeId": "A10_glass_status", "addressIndex":"70", "addressLenght":"2", "ratio":"1", "unit":"" }, { "codeId": "A09_prohibit_film_production", "addressIndex":"72", "addressLenght":"2", "ratio":"1", "unit":"" } , { "codeId": "A10_prohibit_film_production", "addressIndex":"74", "addressLenght":"2", "ratio":"1", "unit":"" } ] } hangzhoumesParent/moduleService/CacheGlassModule/src/main/resources/application.yml
@@ -10,3 +10,5 @@ mapper-locations: classpath*:mapper/*.xml configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl mes: threshold: 3