zhoushihao
2025-07-09 a3c4e24bf090430e1a0a207d44478ca61926248a
1、fixbug:卧式理片笼出片异常
2、钢化版图显示
6个文件已修改
200 ■■■■■ 已修改文件
hangzhoumesParent/common/servicebase/src/main/java/com/mes/temperingglass/mapper/TemperingGlassInfoMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/common/servicebase/src/main/java/com/mes/temperingglass/service/TemperingGlassInfoService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/common/servicebase/src/main/java/com/mes/temperingglass/service/impl/TemperingGlassInfoServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/common/servicebase/src/main/resources/mapper/TemperingGlassInfoMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java 137 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hangzhoumesParent/common/servicebase/src/main/java/com/mes/temperingglass/mapper/TemperingGlassInfoMapper.java
@@ -44,4 +44,6 @@
            "WHERE\n" +
            "\tCONVERT ( DATE, create_time ) = CONVERT ( DATE, getdate( ) )")
    List<PieChartVO> queryPieChart();
    List<TemperingGlassInfo> queryEngineerAndLayoutId();
}
hangzhoumesParent/common/servicebase/src/main/java/com/mes/temperingglass/service/TemperingGlassInfoService.java
@@ -79,4 +79,6 @@
     * @return
     */
    List<PieChartVO> queryPieChart();
    List<TemperingGlassInfo> queryEngineerAndLayoutId();
}
hangzhoumesParent/common/servicebase/src/main/java/com/mes/temperingglass/service/impl/TemperingGlassInfoServiceImpl.java
@@ -207,4 +207,9 @@
    public List<PieChartVO> queryPieChart() {
        return baseMapper.queryPieChart();
    }
    @Override
    public List<TemperingGlassInfo> queryEngineerAndLayoutId() {
        return baseMapper.queryEngineerAndLayoutId();
    }
}
hangzhoumesParent/common/servicebase/src/main/resources/mapper/TemperingGlassInfoMapper.xml
@@ -1,6 +1,11 @@
<?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.temperingglass.mapper.TemperingGlassInfoMapper">
    <resultMap id="baseMap" type="com.mes.temperingglass.entity.TemperingGlassInfo">
        <result column="engineer_id" property="engineerId"/>
        <result column="tempering_layout_id" property="temperingLayoutId"/>
    </resultMap>
    <insert id="saveBatch">
        INSERT INTO tempering_glass_info (glass_id, flow_card_id, glass_type, width, height, thickness, films_id,
        ishorizontal, tempering_layout_id,
@@ -12,5 +17,12 @@
            #{item.angle}, #{item.state}, #{item.slot}, #{item.engineerId}, 0)
        </foreach>
    </insert>
    <select id="queryEngineerAndLayoutId" resultMap="baseMap">
        select top 3 engineer_id,tempering_layout_id
        from tempering_glass_info
        where state = 1 and deleted = 0
        group by engineer_id, tempering_layout_id
        order by min(id) desc
    </select>
</mapper>
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java
@@ -117,13 +117,14 @@
    public void startOneOpcTask() throws Exception {
        S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class);
        S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class);
        S7DataWLExtra s7DataWLExtraTwo = s7SerializerWLTwo.read(S7DataWLExtra.class);
        log.info("一线卧理: {}", s7DataWLOne);
        //获取第二条线路的卧式理片笼状态
        Boolean twoInkageEntity = s7DataWLTwo.getDeviceState();
        //默认只跑一台卧式理片,两条线路都可以走
        int cellFlag = 1;
        //如果两条线都启动则只能跑一条线
        if (twoInkageEntity != null && !twoInkageEntity) {
        if (!twoInkageEntity && !Const.OUT_DISABLE.equals(s7DataWLExtraTwo.getD06SlotState())) {
            cellFlag = 2;
        }
        startOneOpcTaskChild(s7DataWLOne, 1, cellFlag);
@@ -133,10 +134,11 @@
    public void startTwoOpcTask() throws Exception {
        S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class);
        S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class);
        S7DataWLExtra s7DataWLExtraTwo = s7SerializerWLTwo.read(S7DataWLExtra.class);
        log.info("二线卧理: {}", s7DataWLTwo);
        Boolean oneInkageEntity = s7DataWLOne.getDeviceState();
        int cellFlag = 1;
        if (oneInkageEntity != null && !oneInkageEntity) {
        if (!oneInkageEntity  && !Const.OUT_DISABLE.equals(s7DataWLExtraTwo.getD06SlotState())) {
            cellFlag = 2;
        }
        startOneOpcTaskChild(s7DataWLTwo, 2, cellFlag);
@@ -173,15 +175,15 @@
            //进片任务
            log.info("设备:{}状态:{}", device, request);
            log.info("进片任务:进片玻璃id为:{}", task.getGlassIdIn());
            intoTask(task, "", device);
            intoTask(task, device);
        } else if (request == 2 && taskRunning == 0) {
            //出片任务
            outTask(task, "", device, cellFlag);
            outTask(task, device, cellFlag);
        } else if (request == 3 && taskRunning == 0) {
            //直通任务
            log.info("设备:{}状态:{}", device, request);
            if (!outTask(task, "", device, cellFlag)) {
                intoTask(task, "", device);
            if (!outTask(task, device, cellFlag)) {
                intoTask(task, device);
            }
        } else if (request == 4) {
            log.info("设备:{}状态:{}", device, request);
@@ -218,7 +220,7 @@
    }
    @Scheduled(fixedDelay = 1000)
    public void edgTwoOpcTask() throws Exception {
    public void edgTwoOpcTask() {
        S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class);
        String glassId = s7DataWLTwo.getGlassId();
        log.info("2号线玻璃id{},历史id{}", glassId, glassIdTwo);
@@ -229,7 +231,7 @@
        edgTaskChild(glassId, 2);
    }
    private void edgTaskChild(String glassId, int cell) throws Exception {
    private void edgTaskChild(String glassId, int cell) {
        ratio = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_RATIO);
        GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId).last("limit 1"));
        if (glassInfo == null) {
@@ -270,9 +272,9 @@
        }
    }
    private boolean intoTask(S7DataWL task, String tableName, int deviceId) {
    private boolean intoTask(S7DataWL task, int deviceId) {
        Date startDate = new Date();
        log.info("开始执行进片任务,任务信息为:{},表名为:{},设备id:{},开始时间:{}", task, tableName, deviceId, startDate);
        log.info("开始执行进片任务,任务信息为:{},设备id:{},开始时间:{}", task, deviceId, startDate);
        //获取玻璃的基本信息
        GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, task.getGlassIdIn()));
        if (null == glassInfo) {
@@ -338,7 +340,7 @@
        return Boolean.TRUE;
    }
    private boolean outTask(S7DataWL task, String tableName, int deviceId, int cellFlag) throws Exception {
    private boolean outTask(S7DataWL task, int deviceId, int cellFlag) {
        Date startDate = new Date();
        //获取对应的设备状态信息
        S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class);
@@ -359,15 +361,14 @@
        // 3:二号线一对多的情况下,获取一号线磨边前片台C08的状态,C08非禁用时,一号线将按照D06片台状态觉得出片
        if (cellFlag == 2) {
            if (deviceId == 1) {
                twoOutState = twoOutState & d06OutState;
            } else {
                oneOutState = oneOutState & d06OutState;
            }
        }
        log.info("开始执行出片/直通任务,任务信息为:{},表名为:{},设备id:{},开始时间:{},一号线状态:{},二号线状态:{}",
                task, tableName, deviceId, startDate, oneOutState, twoOutState);
        log.info("开始执行出片/直通任务,任务信息为:{},设备id:{},开始时间:{},一号线状态:{},二号线状态:{}",
                task, deviceId, startDate, oneOutState, twoOutState);
        //获取当前需要走那条线
        int cell = 0;
        if (cellFlag == 1) {
@@ -381,22 +382,18 @@
                cell = Const.TWO_OUT_TARGET_POSITION;
            }
        }
        if (Const.OUT_FREE.equals(oneOutState) && Const.OUT_FREE.equals(twoOutState)) {
            if (cellFlag == 2) {
                if (!outChildTask(task, tableName, deviceId, cell, startDate)) {
            if (!outChildTask(task, deviceId, cell, startDate)) {
                    cell = cell == Const.ONE_OUT_TARGET_POSITION ? Const.TWO_OUT_TARGET_POSITION : Const.ONE_OUT_TARGET_POSITION;
                    return outChildTask(task, tableName, deviceId, cell, startDate);
                return outChildTask(task, deviceId, cell, startDate);
                }
            } else {
                return outChildTask(task, tableName, deviceId, cell, startDate);
            }
        } else {
            return outChildTask(task, tableName, deviceId, cell, startDate);
            return outChildTask(task, deviceId, cell, startDate);
        }
        return Boolean.TRUE;
    }
    private boolean outChildTask(S7DataWL task, String tableName, int deviceId, int cell, Date startDate) {
    private boolean outChildTask(S7DataWL task, int deviceId, int cell, Date startDate) {
        EdgStorageCageDetails edgStorageCageDetails = null;
        //笼内是版图相差是否超过阈值
@@ -534,7 +531,6 @@
        task.setStartCell(edgStorageCageDetails.getSlot());
        task.setTaskRunning(taskType);
        task.setEndCell(cell);
//        edgStorageDeviceTaskService.updateTaskMessage(tableName, task);
        if (deviceId == 1) {
            s7SerializerWLOne.write(
                    S7DataWL.builder()
hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java
@@ -1,11 +1,10 @@
package com.mes.job;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer;
import com.kangaroohy.milo.model.ReadWriteEntity;
import com.mes.common.config.Const;
import com.mes.damage.service.DamageService;
import com.mes.largenscreen.entity.PieChartVO;
@@ -24,6 +23,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
 * @author SNG-010
@@ -33,7 +33,7 @@
public class PlcTemperingGlassTask {
    @Autowired
    private TemperingGlassInfoService temperingAgoService;
    private TemperingGlassInfoService temperingGlassInfoService;
    @Autowired
    private DamageService damageService;
@@ -41,65 +41,45 @@
    @Qualifier("s7SerializerGHTwo")
    private S7Serializer s7SerializerGHTwo;
    /**
     * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成)
     * fixedDelay : 上一个调用结束后再次调用的延时
     */
    private List<TemperingGlassInfo> selectWaitingGlassByOpc() {
        //获取等待进炉中的玻璃信息
        try {
            S7DataGHTwo s7DataGHTwo = s7SerializerGHTwo.read(S7DataGHTwo.class);
            String engineerEntity = s7DataGHTwo.getF09EngineerId();
            Integer temperingLayoutIdEntity = s7DataGHTwo.getF09TemperingLayoutId();
            if (null == engineerEntity || null == temperingLayoutIdEntity) {
                engineerEntity = s7DataGHTwo.getF08EngineerId();
                temperingLayoutIdEntity = s7DataGHTwo.getF08TemperingLayoutId();
                if (null == engineerEntity || null == temperingLayoutIdEntity) {
                    log.info("获取参数异常,结束本次任务");
                    return new ArrayList<>();
                }
            }
            return temperingAgoService.list(new LambdaQueryWrapper<TemperingGlassInfo>()
                    .eq(TemperingGlassInfo::getEngineerId, engineerEntity)
                    .eq(TemperingGlassInfo::getTemperingLayoutId, temperingLayoutIdEntity));
        } catch (Exception e) {
            log.info("获取钢化参数异常:{}", e);
            return new ArrayList<>();
        }
    }
    @Scheduled(fixedDelay = 1000)
    public void temperingGlassHome() {
        JSONObject jsonObject = new JSONObject();
        //正在等待进片的玻璃
        List<TemperingGlassInfo> waitingGlass = selectWaitingGlassByOpc();
        if (waitingGlass != null) {
        List<TemperingGlassInfo> waitingGlass = new ArrayList<>();
        try {
            waitingGlass = selectWaitingGlassByOpc();
            if (CollectionUtil.isNotEmpty(waitingGlass)) {
            jsonObject.append("waitingGlass", waitingGlass);
        }
        } catch (Exception e) {
            log.info("钢化前获取异常:{}", e.getMessage());
        }
        try {
            List<TemperingGlassInfo> intoGlass = selectIntoGlass(waitingGlass);
            if (CollectionUtil.isNotEmpty(intoGlass)) {
                for (int i = 0; i < intoGlass.size(); i++) {
                    String jsonName = "intoGlass";
                    if (i != 0) {
                        jsonName = jsonName + i;
                    }
                    jsonObject.append(jsonName, temperingGlassInfoService.list(new LambdaQueryWrapper<TemperingGlassInfo>()
                            .eq(TemperingGlassInfo::getEngineerId, intoGlass.get(i).getEngineerId())
                            .eq(TemperingGlassInfo::getTemperingLayoutId, intoGlass.get(i).getTemperingLayoutId())));
                }
        //获取整在炉中的两个版图id
        List<TemperingGlassInfo> layoutId = temperingAgoService.selectLayoutId();
        //进炉中的玻璃
        if (!layoutId.isEmpty()) {
            List<TemperingGlassInfo> intoGlass = temperingAgoService.selectIntoGlass(layoutId.get(0));
            jsonObject.append("intoGlass", intoGlass);
            //进炉中的第二个版图
            if (layoutId.size() > 1) {
                List<TemperingGlassInfo> intoGlass2 = temperingAgoService.selectIntoGlass(layoutId.get(1));
                jsonObject.append("intoGlass2", intoGlass2);
            }
        } catch (Exception e) {
            log.info("钢化前获取异常:{}", e.getMessage());
        }
        try {
        //出炉后的玻璃
        List<TemperingGlassInfo> outGlass = temperingAgoService.selectOutGlass();
        if (outGlass != null) {
            List<TemperingGlassInfo> outGlass = temperingGlassInfoService.selectOutGlass();
            if (CollectionUtil.isNotEmpty(outGlass)) {
            jsonObject.append("outGlass", outGlass);
        }
        //过旋转台钢化后的玻璃
        List<TemperingGlassInfo> overGlass = temperingAgoService.selectOverGlass();
        if (outGlass != null) {
            jsonObject.append("overGlass", overGlass);
        } catch (Exception e) {
            log.info("钢化前获取异常:{}", e.getMessage());
        }
@@ -119,7 +99,7 @@
    public void temperingIsRun() {
        JSONObject jsonObject = new JSONObject();
        //正在进行的任务
        List<TemperingGlassInfo> temperingTaskType = temperingAgoService.selectTaskType();
        List<TemperingGlassInfo> temperingTaskType = temperingGlassInfoService.selectTaskType();
        jsonObject.append("temperingTaskType", temperingTaskType);
@@ -142,14 +122,14 @@
        //大屏钢化信息
        Date startOfToday = new Date(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli());
        Integer putGlass = temperingAgoService.count(
        Integer putGlass = temperingGlassInfoService.count(
                new QueryWrapper<TemperingGlassInfo>()
                        .eq("state", Const.TEMPERING_NEW)
                        .gt("create_time", startOfToday)
        );
        jsonObject.append("temperingTaskType", putGlass);
        //大屏钢化信息
        List<TemperingGlassInfo> temperingGlassInfoList = temperingAgoService.list(
        List<TemperingGlassInfo> temperingGlassInfoList = temperingGlassInfoService.list(
                new QueryWrapper<TemperingGlassInfo>()
                        .select("engineer_id", "tempering_layout_id")
                        .eq("state", Const.TEMPERING_START)
@@ -158,7 +138,7 @@
        );
        jsonObject.append("temperingGlassInfoList", temperingGlassInfoList.size());
        //大屏钢化信息
        List<TemperingGlassInfo> temperingGlassInfoInList = temperingAgoService.list(
        List<TemperingGlassInfo> temperingGlassInfoInList = temperingGlassInfoService.list(
                new LambdaQueryWrapper<TemperingGlassInfo>()
                        .select(TemperingGlassInfo::getEngineerId, TemperingGlassInfo::getTemperingLayoutId) // 选择要去重的字段
                        .eq(TemperingGlassInfo::getState, Const.TEMPERING_DROP)
@@ -166,7 +146,7 @@
        );
        jsonObject.append("temperingGlassInfoInList", temperingGlassInfoInList.size());
        //钢化饼图数据
        List<PieChartVO> pieChartVOS = temperingAgoService.queryPieChart();
        List<PieChartVO> pieChartVOS = temperingGlassInfoService.queryPieChart();
        jsonObject.append("pieChartVOS", pieChartVOS);
        ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("largenScreen");
        if (sendwServer != null) {
@@ -185,4 +165,53 @@
        }
    }
    /**
     * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成)
     * fixedDelay : 上一个调用结束后再次调用的延时
     */
    private List<TemperingGlassInfo> selectWaitingGlassByOpc() {
        //获取等待进炉中的玻璃信息
        try {
            S7DataGHTwo s7DataGHTwo = s7SerializerGHTwo.read(S7DataGHTwo.class);
            String engineerEntity = s7DataGHTwo.getF09EngineerId();
            Integer temperingLayoutIdEntity = s7DataGHTwo.getF09TemperingLayoutId();
            if (null == engineerEntity || null == temperingLayoutIdEntity) {
                engineerEntity = s7DataGHTwo.getF08EngineerId();
                temperingLayoutIdEntity = s7DataGHTwo.getF08TemperingLayoutId();
                if (null == engineerEntity || null == temperingLayoutIdEntity) {
                    log.info("获取参数异常,结束本次任务");
                    return new ArrayList<>();
                }
            }
            return temperingGlassInfoService.list(new LambdaQueryWrapper<TemperingGlassInfo>()
                    .eq(TemperingGlassInfo::getEngineerId, engineerEntity)
                    .eq(TemperingGlassInfo::getTemperingLayoutId, temperingLayoutIdEntity));
        } catch (Exception e) {
            log.info("获取钢化参数异常:{}", e);
            return new ArrayList<>();
        }
    }
    /**
     * 获取正在钢化的版图信息:获取3炉已经摆好的玻璃小片,排除正在摆的
     *
     * @param list
     * @return
     */
    private List<TemperingGlassInfo> selectIntoGlass(List<TemperingGlassInfo> list) {
        List<TemperingGlassInfo> temperingGlassInfoList = temperingGlassInfoService.queryEngineerAndLayoutId();
        log.info("钢化中获取到的数据为{}", temperingGlassInfoList);
        if (CollectionUtil.isEmpty(temperingGlassInfoList)) {
            return new ArrayList<>();
        }
        if (CollectionUtil.isEmpty(list)) {
            return temperingGlassInfoList;
        } else {
            String engineerId = list.get(0).getEngineerId();
            int temperingLayoutId = list.get(0).getTemperingLayoutId();
            List<TemperingGlassInfo> tempList = temperingGlassInfoList.stream().filter(e -> !(e.getEngineerId().equals(engineerId) && temperingLayoutId == e.getTemperingLayoutId())).collect(Collectors.toList());
            return tempList;
        }
    }
}