hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/hollow/entity/vo/HollowGlassFormulaVO.java
New file @@ -0,0 +1,28 @@ package com.mes.hollow.entity.vo; import com.mes.hollow.entity.HollowFormulaDetails; import lombok.Data; /** * @Author : zhoush * @Date: 2024/12/30 15:34 * @Description: */ @Data public class HollowGlassFormulaVO extends HollowFormulaDetails { /** * 宽度 */ private double width; /** * 高度 */ private double height; /** * /*厚度 */ private Double thickness; } hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/hollow/mapper/HollowFormulaDetailsMapper.java
@@ -2,6 +2,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.mes.hollow.entity.HollowFormulaDetails; import com.mes.hollow.entity.vo.HollowGlassFormulaVO; import org.apache.ibatis.annotations.Param; /** * (HollowFormulaDetails)表数据库访问层 @@ -11,5 +13,6 @@ */ public interface HollowFormulaDetailsMapper extends BaseMapper<HollowFormulaDetails> { HollowGlassFormulaVO queryFormulaDetailsByGlassId(@Param("glassId") String glassId, @Param("flowCardId") String flowCardId, @Param("cell") Integer cell); } hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/hollow/service/HollowFormulaDetailsService.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.mes.hollow.entity.HollowFormulaDetails; import com.mes.hollow.entity.vo.HollowGlassFormulaVO; /** * (HollowFormulaDetails)表服务接口 @@ -11,5 +12,6 @@ */ public interface HollowFormulaDetailsService extends IService<HollowFormulaDetails> { HollowGlassFormulaVO queryFormulaDetailsByGlassId(String glassId, String flowCardId, Integer cell); } hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/hollow/service/impl/HollowFormulaDetailsServiceImpl.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mes.hollow.entity.HollowFormulaDetails; import com.mes.hollow.entity.vo.HollowGlassFormulaVO; import com.mes.hollow.mapper.HollowFormulaDetailsMapper; import com.mes.hollow.service.HollowFormulaDetailsService; import org.springframework.stereotype.Service; @@ -15,5 +16,9 @@ @Service public class HollowFormulaDetailsServiceImpl extends ServiceImpl<HollowFormulaDetailsMapper, HollowFormulaDetails> implements HollowFormulaDetailsService { @Override public HollowGlassFormulaVO queryFormulaDetailsByGlassId(String glassId, String flowCardId, Integer cell) { return baseMapper.queryFormulaDetailsByGlassId(glassId, flowCardId, cell); } } hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/job/OpcHollowRemoveTask.java
New file @@ -0,0 +1,125 @@ package com.mes.job; import com.kangaroohy.milo.model.ReadWriteEntity; import com.kangaroohy.milo.service.MiloService; import com.mes.hollow.entity.vo.HollowGlassFormulaVO; import com.mes.hollow.service.HollowFormulaDetailsService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; /** * @author SNG-015 */ @Component @Slf4j public class OpcHollowRemoveTask { @Resource private HollowFormulaDetailsService hollowFormulaDetailsService; @Resource private OpcPlcStorageCageHollowTask opcPlcStorageCageHollowTask; @Autowired(required = false) MiloService miloService; /** * 收到除膜机请求及玻璃id * * @throws Exception */ @Scheduled(fixedDelay = 1000) public void hollowRemoveTaskOne() throws Exception { hollowRemoveChildTask("CMJ1.CMJ1."); } @Scheduled(fixedDelay = 1000) public void hollowRemoveTaskTwo() throws Exception { hollowRemoveChildTask("CMJ2.CMJ2."); } private void hollowRemoveChildTask(String cell) throws Exception { ReadWriteEntity requestEntity = miloService.readFromOpcUa(cell + "mesControl"); if ("0".equals(requestEntity.getValue() + "")) { log.info("当前除膜机为单机状态"); return; } int request = Integer.parseInt(requestEntity.getValue() + ""); int flagRequest = request & 3; if (flagRequest != 3) { log.info("当前未收到请求玻璃id数据,结束任务"); return; } ReadWriteEntity glassIdEntity = miloService.readFromOpcUa(cell + "glassId"); if (StringUtils.isBlank(glassIdEntity.getValue() + "")) { log.info("当前未收到玻璃id数据,结束任务"); return; } //按照玻璃id获取对应的任务id HollowGlassFormulaVO detailsVO = hollowFormulaDetailsService.queryFormulaDetailsByGlassId(glassIdEntity.getValue() + "", null, null); if (null == detailsVO) { log.info("玻璃id不存在,请检查数据"); return; } //按照任务id获取对应的配方信息 List<ReadWriteEntity> list = new ArrayList<>(); if (detailsVO.getFilmRemove() != 0) { // 10111011 int sendId = request & 273; sendId = sendId + 4; list.add(opcPlcStorageCageHollowTask.generateReadWriteEntity(cell + "mesControl", sendId)); } else { // 先将对应的位置为0,获得请求的玻璃数据, 然后将对应位值 110111011 int sendId = request & 273; sendId = sendId + 4 + 64; list.add(opcPlcStorageCageHollowTask.generateReadWriteEntity(cell + "mesControl", sendId)); list.add(opcPlcStorageCageHollowTask.generateReadWriteEntity(cell + "glassTop", detailsVO.getTopRemove())); list.add(opcPlcStorageCageHollowTask.generateReadWriteEntity(cell + "glassBottom", detailsVO.getBottomRemove())); list.add(opcPlcStorageCageHollowTask.generateReadWriteEntity(cell + "glassLeft", detailsVO.getLeftRemove())); list.add(opcPlcStorageCageHollowTask.generateReadWriteEntity(cell + "glassRight", detailsVO.getRightRemove())); } list.add(opcPlcStorageCageHollowTask.generateReadWriteEntity(cell + "thickness", detailsVO.getThickness())); list.add(opcPlcStorageCageHollowTask.generateReadWriteEntity(cell + "firstLength", Math.max(detailsVO.getWidth(), detailsVO.getHeight()))); list.add(opcPlcStorageCageHollowTask.generateReadWriteEntity(cell + "secondLength", Math.min(detailsVO.getWidth(), detailsVO.getHeight()))); miloService.writeToOpcWord(list); return; } /** * 收到除膜机ID接收完成开始执行任务 * * @throws Exception */ @Scheduled(fixedDelay = 1000) public void finishHollowRemoveOneTask() throws Exception { finishHollowRemoveChildTask("CMJ1.CMJ1."); } @Scheduled(fixedDelay = 1000) public void finishHollowRemoveTwoTask() throws Exception { finishHollowRemoveChildTask("CMJ2.CMJ2."); } public void finishHollowRemoveChildTask(String cell) throws Exception { ReadWriteEntity requestEntity = miloService.readFromOpcUa(cell + "mesControl"); int request = Integer.parseInt(requestEntity.getValue() + ""); int flagRequest = request & 9; if (flagRequest != 9) { log.info("当前未收到除膜机ID接收完成信号,结束任务"); return; } //向电气发送清楚信号 int sendId = request & 251; List<ReadWriteEntity> list = new ArrayList<>(); list.add(opcPlcStorageCageHollowTask.generateReadWriteEntity(cell + "mesControl", sendId)); miloService.writeToOpcWord(list); } } hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java
@@ -917,17 +917,11 @@ } } private ReadWriteEntity generateReadWriteEntity(String identifier, Object value) { public ReadWriteEntity generateReadWriteEntity(String identifier, Object value) { return ReadWriteEntity.builder() .identifier(identifier) //Kep中是Long类型,即:Int32,Java中的int类型 .value(value) .build(); } // // private List<BigStorageCageTask> computeOutTaskList(List<BigStorageCageTask> taskList, int totalLayer, int target) { //// if (target == 931){} // if (taskList.get(0).get) // return null; // } } hangzhoumesParent/moduleService/howllowGlassModule/src/main/resources/mapper/HollowFormulaDetailsMapper.xml
New file @@ -0,0 +1,59 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.mes.hollow.mapper.HollowFormulaDetailsMapper"> <select id="1" resultType="com.mes.hollow.entity.HollowBigStorageCageDetails"> select max(sequence) as sequence, device_id, slot from hollow_big_storage_cage_details where (flow_card_id, total_layer, layer, virtual_slot) = (#{flowCardId}, #{totalLayer}, #{layer}, #{virtualSlot}) and state in (0, 100, 102, 103, 104) group by device_id, slot order by sequence </select> <select id="queryFormulaDetailsByGlassId" resultType="com.mes.hollow.entity.vo.HollowGlassFormulaVO"> select t3.id, t3.formula_name, case when t3.film_remove = 0 then 0 else ifnull(t2.film_remove, 0) end as film_remove, t3.top_remove, t3.bottom_remove, t3.left_remove, t3.right_remove, t3.frame_one, t3.frame_two, t3.frame_three, t3.frame_four, t3.seal_insert, t3.cas_one, t3.cas_two, t3.cas_three, t3.cas_four, t3.interval_frame_type, t3.interval_frame_width, t3.interval_frame_height, t2.width, t2.height, t2.thickness from hollow_glass_out_relation_info t inner join hollow_glass_queue_info t1 on t.id = t1.relation_id inner join glass_info t2 on t1.glass_id = t2.glass_id inner join hollow_formula_details t3 on t.formula_id = t3.id <where> t.state in (0,1,2) <if test="glassId != null and glassId !=''"> and t1.glass_id = #{glassId} </if> <if test="flowCardId != null and flowCardId !=''"> and t.flow_card_id = #{flowCardId} </if> <if test="cell != null and cell !=''"> and t.cell = #{cell} </if> </where> limit 1 </select> </mapper>