ZengTao
2024-07-15 bb37f664476c01aefd93dd9b8856851f11d4d3cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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.glassinfo.entity.GlassInfo;
import com.mes.glassinfo.entity.OptimizeGlassinfo;
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author wu
 * @since 2024-04-29
 */
@Service
@Slf4j
public class GlassInfoServiceImpl extends MPJBaseServiceImpl<GlassInfoMapper, GlassInfo> implements GlassInfoService {
    @Autowired
    OptimizeProjectMapper optimizeProjectMapper;
 
    @Override
    @DS("pp")
    public List<GlassInfo> selectGlassInfo(String engineeringId) {
        List<OptimizeGlassinfo> optimizeGlassinfos = null;
        if (engineeringId != null) {
            optimizeGlassinfos = optimizeProjectMapper.selectJoinList(OptimizeGlassinfo.class, new MPJQueryWrapper<OptimizeProject>()
                    .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, b.total_layer, b.stock_id,b.heat_layout_id,b.heat_layout_sort,c.x_axis,c.y_axis,b.project_no,b.glass_id,c.rotate_angle")
                    .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")
                    //.eq("t.state",100)
                    .eq("t.project_no", engineeringId));
        }
        //order_sort,o_width,o_height
        // 创建一个 List 用于保存映射后的实体对象
        List<GlassInfo> 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.setLayer(map.getLayer());
                glassInfo.setTotalLayer(map.getTotalLayer());
                glassInfo.setEdgHeight(map.getPHeight());
                glassInfo.setThickness(map.getGlassThickness());
                glassInfo.setPatternSequence(map.getStockId());//
                glassInfo.setTemperingLayoutId(map.getHeatLayoutId());//钢化版图id
                glassInfo.setTemperingFeedSequence(map.getHeatLayoutSort());//钢化版图顺序
                glassInfo.setXCoordinate(map.getXAxis());
                glassInfo.setYCoordinate(map.getYAxis());
                glassInfo.setAngle(map.getRotateAngle());
                glassInfo.setGlassId(map.getGlassId());
                // 将映射后的对象添加到结果列表中
                resultList.add(glassInfo);
            }
        }
        log.info("查询出glassinfo的数据{}:", resultList);
        log.info("查询出glassinfopro的数据{}:", optimizeGlassinfos);
        return resultList;
    }
 
    @Override
    public void saveGlassInfo(List<GlassInfo> glassinfo) {
        this.saveBatch(glassinfo);
    }
/*
 
    @Override
    public int getGlassInfoCountByFlowCardId(String flowCardId,int layer) {
        return baseMapper.selectCount(new QueryWrapper<GlassInfo>().lambda()
                .eq(GlassInfo::getFlowCardId, flowCardId)
                .eq(GlassInfo::getLayer, layer));
 
    }
 
 
    @Override
    public List<Map<String, Object>> getFlowCardId() {
        // 第二个查询:查询 OptimizeProject 表,根据 GlassInfo 的 engineerId 和 state 进行筛选
        List<OptimizeProject> optimizeProjects = optimizeProjectMapper.selectList(
                new QueryWrapper<OptimizeProject>()
                        .ne("state", 300)
        );
        // 提取 engineerId 列表
        List<String> engineerIds = optimizeProjects.stream()
                .map(OptimizeProject::getProjectNo)
                .collect(Collectors.toList());
 
        // 第一个查询:查询 GlassInfo 表并按 flow_card_id 分组,同时筛选出在 engineerIds 列表中的记录
        List<GlassInfo> glassInfos = baseMapper.selectList(
                new QueryWrapper<GlassInfo>()
                        .in("engineer_id", engineerIds)
                        .groupBy("flow_card_id")
                        .groupBy("layer")
        );
 
        // 转换为 List<Map<String, Object>>
        List<Map<String, Object>> result = glassInfos.stream()
                .map(glassInfo -> {
                    Map<String, Object> map = new HashMap<>();
                    map.put("flow_card_id", glassInfo.getFlowCardId()+" | "+glassInfo.getLayer());
                    // 如果还有其他字段需要添加到 map 中,在这里继续添加
                    return map;
                })
                .collect(Collectors.toList());
        log.info("result666: {}", result);
        return result;
    }*/
 
 
 
 
 
}