package com.zy.acs.manager.manager.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.zy.acs.manager.manager.entity.Code; import com.zy.acs.manager.manager.entity.Jam; import com.zy.acs.manager.manager.enums.JamStateType; import com.zy.acs.manager.manager.mapper.JamMapper; import com.zy.acs.manager.manager.service.CodeService; import com.zy.acs.manager.manager.service.JamService; import com.zy.acs.framework.common.Cools; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; @Slf4j @Service("jamService") public class JamServiceImpl extends ServiceImpl implements JamService { @Autowired private CodeService codeService; @Override public Jam getJam(Long agvId, Long jamCode, Long jamSeg) { List jams = this.list(new LambdaQueryWrapper() .eq(Jam::getJamAgv, agvId) .eq(Jam::getJamCode, jamCode) .eq(Jam::getJamSeg, jamSeg) .eq(Jam::getState, JamStateType.RUNNING.toString()) ); if (!Cools.isEmpty(jams)) { return jams.stream().findFirst().orElse(null); } return null; } @Override public Boolean checkIfFinish(Long avoAgv, String currCodeData) { if (Cools.isEmpty(avoAgv, currCodeData)) { return null; } Date now = new Date(); Code code = codeService.selectByData(currCodeData); List jams = this.list(new LambdaQueryWrapper() .eq(Jam::getAvoAgv, avoAgv) .eq(Jam::getAvoCode, code.getId()) .eq(Jam::getState, JamStateType.RUNNING.toString()) ); for (Jam jam : jams) { jam.setEndTime(now); jam.setUpdateTime(now); jam.setState(JamStateType.FINISH.toString()); if (!this.updateById(jam)) { log.error("{}编号阻塞记录完成修改失败!!!", jam.getUuid()); } } return null; } }