ZengTao
2025-05-20 dbbf0c051ef05480a0becee07974b80e32b1cb8f
hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java
@@ -8,6 +8,7 @@
import com.kangaroohy.milo.model.ReadWriteEntity;
import com.kangaroohy.milo.service.MiloService;
import com.mes.common.config.Const;
import com.mes.common.config.ConstSysConfig;
import com.mes.damage.service.DamageService;
import com.mes.edgglasstask.entity.EdgGlassTaskInfo;
import com.mes.edgglasstask.service.EdgGlassTaskInfoService;
@@ -21,11 +22,11 @@
import com.mes.opctask.entity.EdgStorageDeviceTaskHistory;
import com.mes.opctask.service.EdgStorageDeviceTaskHistoryService;
import com.mes.opctask.service.EdgStorageDeviceTaskService;
import com.mes.sysconfig.service.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
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;
@@ -64,35 +65,35 @@
    EdgStorageDeviceTaskHistoryService edgStorageDeviceTaskHistoryService;
    @Resource
    DamageService damageService;
    @Resource
    SysConfigService sysConfigService;
    @Value("${mes.glassGap}")
    private int glassGap;
    @Value("${mes.threshold}")
    //    @Value("${mes.threshold}")
    private int threshold;
    @Value("${mes.cellLength}")
    //    @Value("${mes.cellLength}")
    private int cellLength;
    @Value("${mes.ratio}")
    //    @Value("${mes.ratio}")
    private int ratio;
    @Value("${mes.min.one.firstLength}")
    //    @Value("${mes.min.one.firstLength}")
    private int minOneFirstLength;
    @Value("${mes.min.one.secondLength}")
    //
//    @Value("${mes.min.one.secondLength}")
    private int minOneSecondLength;
    @Value("${mes.min.two.firstLength}")
    //
//    @Value("${mes.min.two.firstLength}")
    private int minTwoFirstLength;
    @Value("${mes.min.two.secondLength}")
    //
//    @Value("${mes.min.two.secondLength}")
    private int minTwoSecondLength;
    @Value("${mes.max.firstLength}")
    //
//    @Value("${mes.max.firstLength}")
    private int maxTwoFirstLength;
    @Value("${mes.max.secondLength}")
    //
//    @Value("${mes.max.secondLength}")
    private int maxTwoSecondLength;
    @Value("${mes.maxThickness}")
    //
//    @Value("${mes.maxThickness}")
    private int maxThickness;
    private String glassInIdOne = "";
@@ -124,6 +125,17 @@
    }
    private void startOneOpcTaskChild(String tableName, int device, int cellFlag) throws Exception {
        threshold = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_THRESHOLD);
        cellLength = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_CELL_LENGTH);
        ratio = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_RATIO);
        minOneFirstLength = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_MIN_ONE_FIRST_LENGTH);
        minOneSecondLength = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_MIN_ONE_SECOND_LENGTH);
        minTwoFirstLength = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_MIN_TWO_FIRST_LENGTH);
        minTwoSecondLength = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_MIN_TWO_SECOND_LENGTH);
        maxTwoFirstLength = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_MAX_FIRST_LENGTH);
        maxTwoSecondLength = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_MAX_SECOND_LENGTH);
        maxThickness = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_MAX_THICKNESS);
        EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(tableName);
        if (task == null) {
            log.info("任务表基础数据录入失败,请检查数据是否录入成功");
@@ -200,6 +212,7 @@
    }
    private void edgTaskChild(String glassId, int cell) throws Exception {
        ratio = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_RATIO);
        GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId).last("limit 1"));
        if (glassInfo == null) {
            log.info("对列表中的玻璃id错误,请检查数据,玻璃id:{}", glassId);
@@ -210,11 +223,11 @@
//        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".mesControl", true));
        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".glassId", Integer.parseInt(toEndingId)));
        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".toEdingId", Integer.parseInt(toEndingId)));
        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".width", (int) Math.max(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10)));
        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".height", (int) Math.min(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10)));
        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".width", (int) Math.max(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio)));
        list.add(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".height", (int) Math.min(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio)));
        miloService.writeToOpcUa(list);
        miloService.writeToOpcWord(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".thickness", (int) glassInfo.getThickness() * 10));
        miloService.writeToOpcWord(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".thickness", (int) glassInfo.getThickness() * ratio));
        //修改磨边对列中的磨边线路及状态
        edgGlassTaskInfoService.update(new LambdaUpdateWrapper<EdgGlassTaskInfo>()
                .set(EdgGlassTaskInfo::getLine, cell)
@@ -715,27 +728,6 @@
        taskHistory.setTaskState(Const.RAW_GLASS_TASK_NEW);
        taskHistory.setDeviceId(deviceId);
        edgStorageDeviceTaskHistoryService.save(taskHistory);
        return Boolean.TRUE;
    }
    public boolean updateCellRemainWidth(int slot, int device, EdgStorageDeviceTaskHistory taskHistory) {
        List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(new LambdaQueryWrapper<EdgStorageCageDetails>().eq(EdgStorageCageDetails::getSlot, slot)
                .eq(EdgStorageCageDetails::getState, Const.GLASS_STATE_IN));
        int remainWidth = cellLength;
        if (CollectionUtil.isNotEmpty(list)) {
            if (2 == taskHistory.getTaskType()) {
                remainWidth = 0;
            } else {
                for (EdgStorageCageDetails item : list) {
                    remainWidth = remainWidth - glassGap - (int) Math.max(item.getWidth(), item.getHeight());
                }
                if (remainWidth <= 0) {
                    remainWidth = 0;
                }
            }
        }
        edgStorageCageService.update(new LambdaUpdateWrapper<EdgStorageCage>().
                set(EdgStorageCage::getRemainWidth, remainWidth).eq(EdgStorageCage::getSlot, slot).eq(EdgStorageCage::getDeviceId, device));
        return Boolean.TRUE;
    }