package com.mes.glassinfo.service.impl; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.yulichang.base.MPJBaseServiceImpl; import com.github.yulichang.query.MPJQueryWrapper; import com.mes.engineering.entity.Engineering; import com.mes.glassinfo.entity.GlassInfo; import com.mes.glassinfo.entity.OptimizeGlassinfo; import com.mes.glassinfo.entity.dto.HollowGlassInfoDTO; import com.mes.glassinfo.mapper.GlassInfoMapper; import com.mes.glassinfo.service.GlassInfoService; import com.mes.pp.entity.OptimizeProject; import com.mes.pp.mapper.OptimizeProjectMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; /** *

* 服务实现类 *

* * @author wu * @since 2024-04-29 */ @Service @Slf4j public class GlassInfoServiceImpl extends MPJBaseServiceImpl implements GlassInfoService { @Resource OptimizeProjectMapper optimizeProjectMapper; @Override @DS("pp") public List selectGlassInfo(Engineering engineeringId) { List optimizeGlassinfos = null; if (engineeringId != null) { optimizeGlassinfos = optimizeProjectMapper.selectJoinList(OptimizeGlassinfo.class, new MPJQueryWrapper() .select("b.process_id,t.glass_type,b.o_width,b.o_height,t.glass_thickness,b.order_sort,b.p_width,b.p_height,b.layer," + "d.layers_number AS total_layer, b.stock_id,b.heat_layout_id,b.heat_layout_sort, b.x_axis,b.y_axis," + "c.x_axis as x_axis_heat,c.y_axis as y_axis_heat,b.project_no,b.glass_id,c.rotate_angle,d.merge as combine ,b.mark_icon") .leftJoin("optimize_detail b on t.project_no=b.project_no") .leftJoin("optimize_heat_detail c on c.project_no=t.project_no and b.heat_layout_id=c.layout_id and b.heat_layout_sort=c.sort") .leftJoin("flow_card d on d.process_id=b.process_id and d.technology_number=b.layer and d.order_number=b.order_sort ") //.eq("t.state",100) .eq("t.project_no", engineeringId.getEngineerId())); } // 创建一个 List 用于保存映射后的实体对象 List resultList = new ArrayList<>(); if (optimizeGlassinfos != null) { for (OptimizeGlassinfo map : optimizeGlassinfos) { // 创建一个新的 OptimizeGlassinfo 对象 GlassInfo glassInfo = new GlassInfo(); // 将 Map 中的每个键值对映射到 OptimizeGlassinfo 对象的相应字段上 glassInfo.setEngineerId(map.getProjectNo()); glassInfo.setFlowCardId(map.getProcessId()); glassInfo.setFilmsid(map.getGlassType()); //订单序号 glassInfo.setGlassType(map.getOrderSort()); //订单宽 glassInfo.setWidth(map.getOWidth()); //订单高 glassInfo.setHeight(map.getOHeight()); glassInfo.setEdgWidth(map.getPWidth()); glassInfo.setEdgHeight(map.getPHeight()); glassInfo.setThickness(map.getGlassThickness()); glassInfo.setLayer(map.getLayer()); glassInfo.setTotalLayer(map.getTotalLayer()); glassInfo.setPatternSequence(map.getStockId()); glassInfo.setXAxis(map.getXAxis()); glassInfo.setYAxis(map.getYAxis()); //钢化版图id glassInfo.setTemperingLayoutId(map.getHeatLayoutId()); //钢化版图顺序 glassInfo.setTemperingFeedSequence(map.getHeatLayoutSort()); glassInfo.setXCoordinate(map.getXAxisHeat()); glassInfo.setYCoordinate(map.getYAxisHeat()); glassInfo.setAngle(map.getRotateAngle()); glassInfo.setGlassId(map.getGlassId()); glassInfo.setCombine(map.getCombine()); glassInfo.setMarkIcon(map.getMarkIcon()); glassInfo.setFilmRemove(engineeringId.getFilmRemove()); // 将映射后的对象添加到结果列表中 resultList.add(glassInfo); } } log.info("查询出glassinfo的数据{}:", resultList); log.info("查询出glassinfopro的数据{}:", optimizeGlassinfos); return resultList; } @Override public void saveGlassInfo(List glassinfo) { this.saveBatch(glassinfo); } @Override public int getGlassInfoCountByFlowCardId(String flowCardId, int layer) { if (layer == 0) { return baseMapper.selectCount(new QueryWrapper().lambda() .eq(GlassInfo::getFlowCardId, flowCardId)); } else { return baseMapper.selectCount(new QueryWrapper().lambda() .eq(GlassInfo::getFlowCardId, flowCardId) .eq(GlassInfo::getLayer, layer)); } } @Override public List> getFlowCardId() { // 第二个查询:查询 OptimizeProject 表,根据 GlassInfo 的 engineerId 和 state 进行筛选 List optimizeProjects = optimizeProjectMapper.selectList( new QueryWrapper() .ne("state", 300) ); // 提取 engineerId 列表 List engineerIds = optimizeProjects.stream() .map(OptimizeProject::getProjectNo) .collect(Collectors.toList()); // 第一个查询:查询 GlassInfo 表并按 flow_card_id 分组,同时筛选出在 engineerIds 列表中的记录 List glassInfos = baseMapper.selectList( new QueryWrapper() .in("engineer_id", engineerIds) .groupBy("flow_card_id") .groupBy("layer") ); // 转换为 List> List> result = glassInfos.stream() .map(glassInfo -> { Map map = new HashMap<>(); map.put("flow_card_id", glassInfo.getFlowCardId() + " | " + glassInfo.getLayer()); // 如果还有其他字段需要添加到 map 中,在这里继续添加 return map; }) .collect(Collectors.toList()); log.info("result666: {}", result); return result; } @Override public List listBySize(String engineerId) { return baseMapper.listBySize(engineerId); } @Override public void deleteTask(String engineerId) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("engineer_id", engineerId); baseMapper.delete(queryWrapper); } @Override public List selectEdgGlassInfo(String engineeringId) { List glassInfos = null; if (engineeringId != null) { glassInfos = baseMapper.selectJoinList(GlassInfo.class, new MPJQueryWrapper() .select("t.engineer_id,t.glass_id,t.tempering_layout_id,t.tempering_feed_sequence,t.width,t.height,t.thickness,t.filmsid,t.flow_card_id") .leftJoin("edg_storage_cage_details b on t.engineer_id=b.engineer_id and t.glass_id=b.glass_id") .isNull("b.glass_id") .eq("t.engineer_id", engineeringId)); } return glassInfos; } }