New file |
| | |
| | | package com.mes.downglassinfo.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.downglassinfo.entity.DownGlassTask; |
| | | import com.mes.downglassinfo.mapper.DownGlassTaskMapper; |
| | | import com.mes.downglassinfo.service.DownGlassTaskService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-07 |
| | | */ |
| | | @Service |
| | | public class DownGlassTaskServiceImpl extends ServiceImpl<DownGlassTaskMapper, DownGlassTask> implements DownGlassTaskService { |
| | | |
| | | |
| | | @Override |
| | | public List<DownGlassTask> getUnloadingTaskState() { |
| | | QueryWrapper<DownGlassTask> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("task_stauts", 1); |
| | | return baseMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void updateTaskStateToZero(long id) { |
| | | UpdateWrapper<DownGlassTask> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.set("task_stauts", 0).eq("id", id); |
| | | baseMapper.update(new DownGlassTask(), updateWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteTask(String id) { |
| | | LambdaQueryWrapper<DownGlassTask> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(DownGlassTask::getFlowCardId, id); |
| | | |
| | | baseMapper.delete(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public DownGlassTask selectLastOutCacheInfo(String endCell) { |
| | | QueryWrapper<DownGlassTask> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("task_type", "2") |
| | | .eq("task_status", "2") |
| | | .eq("end_cell", endCell) |
| | | .last("LIMIT 1"); |
| | | |
| | | return baseMapper.selectOne(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public Integer insertCacheTask(DownGlassTask downGlassTask) { |
| | | // 查询数据库,检查主键值是否已经存在 |
| | | DownGlassTask existingTask = baseMapper.selectById(downGlassTask.getId()); |
| | | if (existingTask != null) { |
| | | // 如果已存在相同主键值的任务,则不进行插入操作,返回 null 或者抛出异常 |
| | | // 这里简单起见,直接返回 null |
| | | return null; |
| | | } |
| | | |
| | | // 如果主键值不存在,则进行插入操作 |
| | | DownGlassTask newDownGlassTask = new DownGlassTask(); |
| | | BeanUtils.copyProperties(downGlassTask, newDownGlassTask); |
| | | newDownGlassTask.setTaskStauts(0); // 默认任务状态为0 |
| | | |
| | | int rows = baseMapper.insert(newDownGlassTask); |
| | | return rows > 0 ? rows : null; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<DownGlassTask> selectInputTaskCache() { |
| | | return baseMapper.selectList(new QueryWrapper<DownGlassTask>().eq("task_status", 0).eq("task_type", 1)); |
| | | } |
| | | |
| | | /** |
| | | * 查询待出片任务 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DownGlassTask> selectOutTaskCache() { |
| | | return baseMapper.selectList(new QueryWrapper<DownGlassTask>().eq("task_status", 0).eq("task_type", 2)); |
| | | } |
| | | |
| | | |
| | | } |