| | |
| | | package com.mes.uppattenusage.service.impl; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | 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.github.yulichang.base.MPJBaseServiceImpl; |
| | | import com.github.yulichang.query.MPJQueryWrapper; |
| | | import com.mes.engineering.entity.Engineering; |
| | | import com.mes.engineering.service.EngineeringService; |
| | | import com.mes.pp.entity.OptimizeProject; |
| | | import com.mes.pp.mapper.OptimizeProjectMapper; |
| | | import com.mes.uppattenusage.entity.OptimizeUpPattenUsage; |
| | | import com.mes.uppattenusage.entity.UpPattenUsage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.uppattenusage.mapper.UpPattenUsageMapper; |
| | | import com.mes.uppattenusage.service.UpPattenUsageService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-04-07 |
| | | * @since 2024-04-18 |
| | | */ |
| | | @Service |
| | | public class UpPattenUsageServiceImpl extends ServiceImpl<UpPattenUsageMapper, UpPattenUsage> implements UpPattenUsageService { |
| | | @Slf4j |
| | | public class UpPattenUsageServiceImpl extends MPJBaseServiceImpl<UpPattenUsageMapper, UpPattenUsage> implements UpPattenUsageService { |
| | | |
| | | @Autowired |
| | | OptimizeProjectMapper optimizeProjectMapper; |
| | | @Autowired |
| | | EngineeringService engineeringService; |
| | | @Override |
| | | public List<UpPattenUsage> prioritylist() { |
| | | //获取正在上片的任务id |
| | | Engineering engineering= engineeringService.selectInitiate(1); |
| | | //log.info("将参数传入到查询类里{}",engineering); |
| | | if(engineering!=null){ |
| | | LambdaQueryWrapper<UpPattenUsage> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(UpPattenUsage::getEngineeringId,engineering.getEngineerId()); |
| | | return this.list(wrapper); |
| | | }else { |
| | | return null; |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<UpPattenUsage> selectUpPattenUsage(UpPattenUsage upPattenUsage) { |
| | | LambdaQueryWrapper<UpPattenUsage> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(UpPattenUsage::getEngineeringId,upPattenUsage.getEngineeringId()); |
| | | return this.list(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | @DS("pp") |
| | | public List<UpPattenUsage> selectSaveUpPattenUsage(String engineeringId) { |
| | | |
| | | List<OptimizeUpPattenUsage> upPattenUsageList = null; |
| | | if (engineeringId != null) { |
| | | upPattenUsageList = optimizeProjectMapper.selectJoinList(OptimizeUpPattenUsage.class, new MPJQueryWrapper<OptimizeProject>() |
| | | .select("t.project_no,t.glass_type,b.o_width as width,b.o_height as height ,REGEXP_REPLACE(t.glass_thickness,'\\D','')as glass_thickness,b.stock_id") |
| | | .leftJoin("optimize_layout b on t.project_no=b.project_no") |
| | | .eq("b.project_no", engineeringId)); |
| | | } |
| | | // 创建一个 List 用于保存映射后的实体对象 |
| | | List<UpPattenUsage> resultList = new ArrayList<>(); |
| | | |
| | | // 遍历查询结果中的每个 Map 对象 |
| | | if (upPattenUsageList != null) { |
| | | for (OptimizeUpPattenUsage map : upPattenUsageList) { |
| | | // 创建一个新的 OptimizeProject 对象 |
| | | UpPattenUsage optimizeProject = new UpPattenUsage(); |
| | | // 将 Map 中的每个键值对映射到 OptimizeProject 对象的相应字段上 |
| | | optimizeProject.setEngineeringId(map.getProjectNo()); |
| | | optimizeProject.setFilmsId( map.getGlassType()); |
| | | optimizeProject.setWidth(map.getWidth()); |
| | | optimizeProject.setHeight( map.getHeight()); |
| | | optimizeProject.setThickness(map.getGlassThickness()); |
| | | optimizeProject.setLayoutSequence( map.getStockId()); |
| | | optimizeProject.setState(0); |
| | | // 将映射后的对象添加到结果列表中 |
| | | resultList.add(optimizeProject); |
| | | } |
| | | } |
| | | log.info("查询出上片顺序集合保存到实体类{}",resultList); |
| | | return resultList; |
| | | } |
| | | |
| | | @Override |
| | | public void saveUpPattenUsage(List<UpPattenUsage> upPattenUsage) { |
| | | this.saveBatch(upPattenUsage); |
| | | //保存原片使用详情表 |
| | | } |
| | | |
| | | @Override |
| | | public void updateUpPattenUsageState(UpPattenUsage upPattenUsage, Integer state) { |
| | | upPattenUsage.setState(state); |
| | | boolean updateSuccess=this.updateById(upPattenUsage); |
| | | log.info("更新状态{}",updateSuccess); |
| | | //更新状态 |
| | | } |
| | | |
| | | @Override |
| | | public UpPattenUsage selectedEngineering(String engineeringId) { |
| | | QueryWrapper<UpPattenUsage>wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("engineering_id",engineeringId) |
| | | .last("limit 1"); |
| | | return this.getOne(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public UpPattenUsage selectOverTask() { |
| | | QueryWrapper<UpPattenUsage>wrapper = new QueryWrapper<>(); |
| | | wrapper.gt("state",0) |
| | | .lt("state",99) |
| | | .last("limit 1"); |
| | | return this.getOne(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | //获取最后一块玻璃 |
| | | public UpPattenUsage selectSequence(UpPattenUsage upPattenUsage) { |
| | | QueryWrapper<UpPattenUsage>wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("engineering_id",upPattenUsage.getEngineeringId()) |
| | | .orderByDesc("layout_sequence") |
| | | .last("limit 1"); |
| | | return this.getOne(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateGlassState(UpPattenUsage upPattenUsage) { |
| | | UpdateWrapper<UpPattenUsage> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id",upPattenUsage.getId()) |
| | | .set("state",upPattenUsage.getState()); |
| | | return this.update(updateWrapper); |
| | | } |
| | | |
| | | |
| | | } |