| | |
| | | package com.mes.job; |
| | | |
| | | import com.mes.tempering_record.service.TemperingRecordService; |
| | | import cn.smallbun.screw.core.util.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.mes.common.S7object; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.device.PlcParameterObject; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import com.mes.temperingrecord.entity.TemperingRecord; |
| | | import com.mes.temperingrecord.service.TemperingRecordService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/7/17 12:47 |
| | | * @Description: |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class TemperingTask { |
| | | |
| | | @Autowired |
| | | private TemperingRecordService temporalRecordService; |
| | | |
| | | @Autowired |
| | | private TemperingGlassInfoService temporaryGlassInfoService; |
| | | private static final String ALONE_STATE = "0"; |
| | | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void temperingGlassBefore() { |
| | | Date startDate = new Date(); |
| | | log.info("本次任务开始执行时间:{}", startDate); |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | String state = plcParameterObject.getPlcParameter("state").getValue(); |
| | | // 当前连线状态为 |
| | | if (ALONE_STATE.equals(state)) { |
| | | log.info("当前钢化炉连线模式为:{},不执行该任务", state); |
| | | return; |
| | | } |
| | | //将确认字置为0 |
| | | S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("confirmationWord").getAddress(), 0); |
| | | |
| | | //todo:获取钢化版图中状态为2的(进炉完成的玻璃信息) 且不存在钢化记录表内的 |
| | | List<Object> temperRecordIdListObj = temporalRecordService.listObjs(new QueryWrapper<TemperingRecord>().select("distinct tempering_layout_id")); |
| | | |
| | | List<String> temperRecordIdList = temperRecordIdListObj.stream().map(String::valueOf).collect(Collectors.toList()); |
| | | List<TemperingGlassInfo> list = temporaryGlassInfoService.list(new LambdaQueryWrapper<TemperingGlassInfo>() |
| | | .eq(TemperingGlassInfo::getState, Const.TEMPERING_START).notIn(TemperingGlassInfo::getTemperingLayoutId, temperRecordIdList)); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | log.info("当前系统没有需要钢化的玻璃信息"); |
| | | return; |
| | | } |
| | | List<Integer> temperingLayoutIdList = list.stream().map(TemperingGlassInfo::getTemperingLayoutId).distinct().collect(Collectors.toList()); |
| | | if (CollectionUtils.isNotEmpty(temperRecordIdList)) { |
| | | temperingLayoutIdList.removeAll(temperRecordIdList); |
| | | } |
| | | if (CollectionUtils.isEmpty(temperingLayoutIdList)) { |
| | | log.info("当前玻璃有正在钢化的任务"); |
| | | } |
| | | // 获取钢化下片表状态为2的玻璃信息 |
| | | |
| | | //完成任务将确认字置为1 |
| | | S7object.getinstance().plccontrol.writeWord(plcParameterObject.getPlcParameter("confirmationWord").getAddress(), 1); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |