| | |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.engineering.entity.Engineering; |
| | | import com.mes.engineering.mapper.EngineeringMapper; |
| | | import com.mes.engineering.service.EngineeringService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.mapper.GlassInfoMapper; |
| | | import com.mes.pp.entity.OptimizeProject; |
| | | import com.mes.pp.mapper.OptimizeProjectMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | OptimizeProjectMapper optimizeProjectMapper; |
| | | @Autowired |
| | | private EngineeringMapper engineeringMapper; |
| | | @Autowired |
| | | private GlassInfoMapper glassInfoMapper; |
| | | |
| | | //开始/暂停任务 |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Engineering selectUpInitiate(Integer state, Integer equipmentId) { |
| | | return null; |
| | | public Engineering selectUpInitiate(String engineerId) { |
| | | QueryWrapper<Engineering> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("engineer_id", engineerId) |
| | | .last("limit 1"); |
| | | return engineeringMapper.selectOne(wrapper); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @DS("hangzhoumes") |
| | | public GlassInfo selectGlassinfoIsnull(String engineerId) { |
| | | QueryWrapper<GlassInfo> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("engineer_id", engineerId) |
| | | .last("limit 1"); |
| | | return glassInfoMapper.selectOne(wrapper); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @DS("northGlassMes") |
| | | public List<Engineering> selectTask() { |
| | | //查询可开始任务的工程 |
| | | QueryWrapper<Engineering> wrapper = new QueryWrapper<>(); |
| | | // wrapper.eq("state", 0); |
| | | wrapper.eq("state", 5); |
| | | return engineeringMapper.selectList(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public boolean pauseTask(String engineerId, Integer state) { |
| | | Engineering engineering = this.getBaseMapper().selectOne( |
| | | Wrappers.lambdaQuery(Engineering.class) |
| | | .eq(Engineering::getEngineerId, engineerId) |
| | | ); |
| | | |
| | | if (engineering == null) { |
| | | // 工程不存在,返回失败 |
| | | return false; |
| | | } |
| | | |
| | | // 2. 根据当前状态决定目标状态(1→5,5→1) |
| | | Integer targetState = engineering.getState() == 1 ? 5 : 1; |
| | | |
| | | //暂停正在进行工程 |
| | | LambdaUpdateChainWrapper<Engineering> pauseWrapper = new LambdaUpdateChainWrapper<>(this.getBaseMapper()); |
| | | pauseWrapper.set(Engineering::getState, state); |
| | | pauseWrapper.set(Engineering::getState, targetState); |
| | | pauseWrapper.eq(Engineering::getEngineerId, engineerId); |
| | | return pauseWrapper.update(); |
| | | } |