hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
@@ -20,6 +20,7 @@
import com.mes.downworkstation.service.DownWorkstationService;
import com.mes.glassinfo.entity.GlassInfo;
import com.mes.glassinfo.service.GlassInfoService;
import com.mes.tools.S7control;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
@@ -75,16 +76,18 @@
    public void plcHomeEdgTask() {
        PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject;
        String requestWord = plcParameterObject.getPlcParameter("RequestWord").getValue();
        String glassIdeValue = plcParameterObject.getPlcParameter("G04ID").getValue();
        String confirmationWrodValue = plcParameterObject.getPlcParameter("MES_confirmation_word").getValue();
        String glassIdeValue = plcParameterObject.getPlcParameter("requestID").getValue();
        //A08  A09表示线路相同  可做等价  无数据转int异常
        String out08Glassstate = plcParameterObject.getPlcParameter("A08_glass_status").getValue();
        String out10Glassstate = plcParameterObject.getPlcParameter("A10_glass_status").getValue();
        String confirmationWrodAddress = plcParameterObject.getPlcParameter("MES_confirmation_word").getAddress();
        String currentSlot = plcParameterObject.getPlcParameter("Current_slot").getValue();
        String out06Glassstate = plcParameterObject.getPlcParameter("glassStatus06").getValue();
        String out08Glassstate = plcParameterObject.getPlcParameter("glassStatus08").getValue();
        String out11Glassstate = plcParameterObject.getPlcParameter("glassStatus11").getValue();
        String out13Glassstate = plcParameterObject.getPlcParameter("glassStatus13").getValue();
        String confirmationWrodValue = plcParameterObject.getPlcParameter("confirmationWord").getValue();
        String confirmationWrodAddress = plcParameterObject.getPlcParameter("confirmationWord").getAddress();
        String currentSlot = plcParameterObject.getPlcParameter("currentCell").getValue();
        log.info("1、获取到的请求字为:{},获取到的扫描ID为:{},获取到的确认字为:{},获取到的出片状态分别为:A09:{}、A10:{},当前格子号为:{}",
                requestWord, glassIdeValue, confirmationWrodValue, out08Glassstate, out10Glassstate, currentSlot);
        log.info("1、获取到的请求字为:{},获取到的扫描ID为:{},获取到的确认字为:{},获取到的出片状态分别为:g06:{}、g08:{}、g11:{}、g13:{},当前格子号为:{}",
                requestWord, glassIdeValue, confirmationWrodValue, out06Glassstate, out08Glassstate, out11Glassstate, out13Glassstate, currentSlot);
        if ("0".equals(requestWord)) {
            if ("0".equals(confirmationWrodValue)) {
@@ -174,8 +177,8 @@
                    for (DownGlassInfoDTO e : downGlassInfoDTOList) {
                        List<GlassInfo> glassInfoList = e.getGlassInfoList();
                        for (GlassInfo item : glassInfoList) {
                            if (item.getWidth().equals(glassInfo.getWidth()) && item.getHeight().equals(glassInfo.getHeight())
                                    && item.getThickness().equals(glassInfo.getThickness()) && item.getFilmsid().equals(glassInfo.getFilmsid())) {
                            if (item.getWidth() == glassInfo.getWidth() && item.getHeight() == glassInfo.getHeight()
                                    && item.getThickness() == glassInfo.getThickness() && item.getFilmsid().equals(glassInfo.getFilmsid())) {
                                //玻璃是否为多层
                                checkFlag = multilayerCheck(item, Boolean.FALSE);
                                if (checkFlag) {
@@ -208,9 +211,6 @@
        downStorageCageDetailsService.save(downStorageCageDetails);
//        生成进片任务
        initDownGlassTask(glassInfo, 0, nearestEmpty.getSlot(), Const.GLASS_CACHE_TYPE_IN);
        //log.info("5、生成进片任务信息存入任务表是否完成:{}", taskCache);
//        S7object.getinstance().plccontrol.writeWord(confirmationWrodAddress, (short) 1);
//        log.info("6、发送确认字完成");
    }
    public Boolean outTo(String glassStatus06, String glassStatus11, String glassStatus13, String glassId) {
@@ -347,7 +347,7 @@
                    DownGlassInfo downGlassInfo = downGlassInfoService.getOne(new LambdaQueryWrapper<DownGlassInfo>()
                            .eq(DownGlassInfo::getFlowCardId, downGlassInfoDTO.getFlowCardId())
                            .eq(DownGlassInfo::getLayer, downGlassInfoDTO.getLayer()).eq(DownGlassInfo::getSequence, sequence));
                    if (null != downGlassInfoDTO && downGlassInfo.getWidth().equals(item.getWidth()) && downGlassInfo.getHeight().equals(item.getHeight())) {
                    if (null != downGlassInfoDTO && downGlassInfo.getWidth() == item.getWidth() && downGlassInfo.getHeight() == item.getHeight()) {
                        log.info("相同次序玻璃对应上,可执行进片任务");
                        //更新玻璃状态,生成出片任务
                        tempGlassId = item.getGlassId();
@@ -406,7 +406,7 @@
                    .eq(DownGlassInfo::getFlowCardId, downGlassInfoDTO.getFlowCardId())
                    .eq(DownGlassInfo::getLayer, downGlassInfoDTO.getLayer()).eq(DownGlassInfo::getSequence, sequence));
            log.info("拿当前版序获取玻璃信息{},按照次序判断当前玻璃是否尺寸对应的上(与数量最多的次序比较)。", downGlassInfo);
            if (null != downGlassInfoDTO && downGlassInfo.getWidth().equals(glassInfo.getWidth()) && downGlassInfo.getHeight().equals(glassInfo.getHeight())) {
            if (null != downGlassInfoDTO && downGlassInfo.getWidth() == glassInfo.getWidth() && downGlassInfo.getHeight() == glassInfo.getHeight()) {
                log.info("相同次序玻璃对应上,可执行进片任务");
                return Boolean.TRUE;
            } else {
@@ -419,7 +419,7 @@
        }
    }
    private Boolean generateDownGlassOutTask(String glassId, Integer taskType, Boolean isBind, DownStorageCageDetails cageDetails) {
    public Boolean generateDownGlassOutTask(String glassId, Integer taskType, Boolean isBind, DownStorageCageDetails cageDetails) {
        //按玻璃id获取玻璃信息
        DownStorageCageDetails downStorageCageDetails = null;
        if (glassId.equals(cageDetails.getGlassId())) {
@@ -468,18 +468,34 @@
        return initDownGlassTask(glassInfo, downStorageCageDetails.getSlot(), endCell, taskType);
    }
    private Boolean initDownGlassTask(GlassInfo glassInfo, Integer startCell, Integer endCell, Integer taskType) {
    public Boolean initDownGlassTask(GlassInfo glassInfo, Integer startCell, Integer endCell, Integer taskType) {
        log.info("玻璃{}生成进片任务", glassInfo.getGlassId());
        DownGlassTask downGlassTask = new DownGlassTask();
        downGlassTask.setStartCell(startCell);
        downGlassTask.setGlassId(glassInfo.getGlassId());
        downGlassTask.setEndCell(endCell);
        downGlassTask.setTaskType(taskType + "");
        downGlassTask.setWidth(glassInfo.getWidth().intValue());
        downGlassTask.setHeight(glassInfo.getHeight().intValue());
        downGlassTask.setWidth((int) glassInfo.getWidth());
        downGlassTask.setHeight((int) glassInfo.getHeight());
        downGlassTask.setFlowCardId(glassInfo.getFlowCardId());
        downGlassTask.setTaskStauts(0);
        downGlassTask.setCreateTime(new Date());
        return downGlassTaskService.save(downGlassTask);
        downGlassTaskService.save(downGlassTask);
        //向plc发送命令
        return sendMessageToPlc((int) glassInfo.getWidth(), (int) glassInfo.getHeight(), (int) glassInfo.getThickness(),
                startCell, endCell, taskType);
    }
    private Boolean sendMessageToPlc(int width, int height, int thickness, int startCell, int endCell, int taskType) {
        S7control s7control = S7object.getinstance().plccontrol;
        PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject;
        s7control.writeWord(plcMesObject.getPlcParameter("Glass_width").getAddress(), (short) width * 10);
        s7control.writeWord(plcMesObject.getPlcParameter("Glass_height").getAddress(), (short) height * 10);
        s7control.writeWord(plcMesObject.getPlcParameter("Glass_thickness").getAddress(), (short) thickness * 10);
        s7control.writeWord(plcMesObject.getPlcParameter("Start_cell").getAddress(), (short) startCell);
        s7control.writeWord(plcMesObject.getPlcParameter("End_cell").getAddress(), (short) endCell);
        s7control.writeWord(plcMesObject.getPlcParameter("task_type").getAddress(), (short) taskType);
        s7control.writeWord(plcMesObject.getPlcParameter("confirmationWord").getAddress(), (short) 1);
        return Boolean.TRUE;
    }
}