wangfei
2024-08-23 051613aa73be3e75af5a6dfdb86a722bcb5af094
hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/TemperingTask.java
@@ -5,8 +5,6 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mes.common.S7object;
import com.mes.common.config.Const;
import com.mes.damage.entity.Damage;
import com.mes.damage.service.DamageService;
import com.mes.device.PlcParameterObject;
import com.mes.temperingglass.entity.TemperingGlassInfo;
import com.mes.temperingglass.service.TemperingGlassInfoService;
@@ -35,10 +33,6 @@
    @Autowired
    private TemperingGlassInfoService temporaryGlassInfoService;
    @Autowired
    private DamageService damageService;
    private static final String ALONE_STATE = "0";
@@ -60,10 +54,6 @@
        List<Object> temperRecordIdListObj = temporalRecordService.listObjs(new QueryWrapper<TemperingRecord>().select("distinct tempering_layout_id"));
        List<String> temperRecordIdList = temperRecordIdListObj.stream().map(String::valueOf).collect(Collectors.toList());
        if (CollectionUtils.isEmpty(temperRecordIdList)) {
            log.info("当前系统没有需要钢化的玻璃信息");
            return;
        }
        List<TemperingGlassInfo> list = temporaryGlassInfoService.list(new LambdaQueryWrapper<TemperingGlassInfo>()
                .eq(TemperingGlassInfo::getState, Const.TEMPERING_START).notIn(TemperingGlassInfo::getTemperingLayoutId, temperRecordIdList));
        if (CollectionUtils.isEmpty(list)) {
@@ -86,31 +76,5 @@
    @Scheduled(fixedDelay = 1000)
    public void temperingGlassAfter() {
    }
    @Scheduled(fixedDelay = 1000)
    public void dealDamageTask() {
        Date startDate = new Date();
        log.info("钢化破损玻璃清除任务开始执行时间:{}", startDate);
        List<TemperingGlassInfo> temperingGlassInfoList = temporaryGlassInfoService.list(new LambdaQueryWrapper<TemperingGlassInfo>().in(TemperingGlassInfo::getState, Const.GLASS_STATE_DAMAGE_TAKE));
        if (CollectionUtils.isNotEmpty(temperingGlassInfoList)) {
            //获取破损/拿走玻璃id
            List<String> glassList = temperingGlassInfoList.stream().map(TemperingGlassInfo::getGlassId).collect(Collectors.toList());
            //将任务表中的数据删除
            temporaryGlassInfoService.remove(new LambdaQueryWrapper<TemperingGlassInfo>().in(TemperingGlassInfo::getGlassId, glassList));
            List<Damage> damageList = temperingGlassInfoList.stream().map(e -> {
                Damage damage = new Damage();
                damage.setGlassId(e.getGlassId());
                damage.setLine(Const.TEMPERING_OUT_TARGET_POSITION);
                damage.setWorkingProcedure("钢化");
                damage.setRemark("钢化");
                damage.setStatus(0);
                damage.setType(e.getState());
                return damage;
            }).collect(Collectors.toList());
            damageService.batchInsertDamage(damageList);
        }
        Date endDate = new Date();
        log.info("本次任务结束时间:{},共耗时:{}ms", endDate, endDate.getTime() - startDate.getTime());
    }
}