wangfei
2025-04-21 09402133807b1e774e658a13ad365b2e6efca25b
hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/TemperingTask.java
@@ -5,9 +5,11 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mes.common.S7object;
import com.mes.common.config.Const;
import com.mes.common.config.ConstSysConfig;
import com.mes.damage.entity.Damage;
import com.mes.damage.service.DamageService;
import com.mes.device.PlcParameterObject;
import com.mes.sysconfig.service.SysConfigService;
import com.mes.sysdict.entity.SysDictData;
import com.mes.sysdict.service.SysDictDataService;
import com.mes.temperingglass.entity.TemperingGlassInfo;
@@ -18,8 +20,6 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
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;
import java.util.Comparator;
@@ -48,14 +48,13 @@
    @Autowired
    private SysDictDataService sysDictDataService;
    @Autowired
    private SysConfigService sysConfigService;
    private static final String ALONE_STATE = "0";
    @Value("${mes.width}")
    private Integer temperingWidth;
    @Value("${mes.height}")
    private Integer temperingHeight;
//    @Scheduled(fixedDelay = 1000)
    //    @Scheduled(fixedDelay = 1000)
    public void temperingGlassBefore() {
        Date startDate = new Date();
        log.info("本次任务开始执行时间:{}", startDate);
@@ -100,12 +99,14 @@
                .sorted(Comparator.comparing(TemperingGlassInfo::getTemperingFeedSequence)).collect(Collectors.toList());
        //按照膜系获取玻璃材质
        SysDictData glassTypeSysDictData = sysDictDataService.getOne(new QueryWrapper<SysDictData>()
                .eq(StringUtils.isNotBlank(temperingGlassList.get(0).getFilmsid()), "dict_label", temperingGlassList.get(0).getFilmsid()));
                .eq(StringUtils.isNotBlank(temperingGlassList.get(0).getFilmsId()), "dict_label", temperingGlassList.get(0).getFilmsId()));
        double sumArea = temperingGlassList.stream().mapToDouble(e -> e.getWidth() * e.getHeight()).sum();
        double maxArea = temperingGlassList.stream().mapToDouble(e -> e.getWidth() * e.getHeight()).max().orElse(0.0);
        double minArea = temperingGlassList.stream().mapToDouble(e -> e.getWidth() * e.getHeight()).min().orElse(0.0);
        double areaDifference = (10000 * (maxArea - minArea) / maxArea);
        Integer temperingHeight = sysConfigService.queryConfigValue(ConstSysConfig.TEMPERING_HEIGHT);
        Integer temperingWidth = sysConfigService.queryConfigValue(ConstSysConfig.TEMPERING_HEIGHT);
        double loadingRate = (int) (10000 * sumArea / (temperingHeight * temperingWidth));
        TemperingRecord temperingRecord = new TemperingRecord();
        temperingRecord.setEngineerId(maxGlassInfo.getEngineerId());
@@ -131,7 +132,7 @@
        log.info("本次任务结束时间:{},共耗时:{}ms", endDate, endDate.getTime() - startDate.getTime());
    }
    @Scheduled(fixedDelay = 1000)
//    @Scheduled(fixedDelay = 1000)
    public void temperingGlassAfter() {
        //暂不处理
    }