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)) {
@@ -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) {
@@ -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,7 +468,7 @@
        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);
@@ -480,6 +480,22 @@
        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;
    }
}