春风项目四线(合箱线、总装线)
wujian
2024-07-12 d2daac02fbc20980162799fc7bf6b1ca59f5686a
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package com.jcdm.main.da.tileMatchRules.service.impl;
 
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
 
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.StrUtil;
import com.jcdm.common.utils.DateUtils;
import com.jcdm.main.da.passingStationCollection.domain.ProductNewPassStation;
import com.jcdm.main.da.passingStationCollection.service.ProductNewPassStationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jcdm.main.da.tileMatchRules.mapper.DaTileMatchRulesMapper;
import com.jcdm.main.da.tileMatchRules.domain.DaTileMatchRules;
import com.jcdm.main.da.tileMatchRules.service.IDaTileMatchRulesService;
 
import javax.annotation.Resource;
 
/**
 * 配瓦规则Service业务层处理
 * 
 * @author jiang
 * @date 2024-01-24
 */
@Service
public class DaTileMatchRulesServiceImpl implements IDaTileMatchRulesService 
{
    @Autowired
    private DaTileMatchRulesMapper daTileMatchRulesMapper;
 
    @Resource
    private ProductNewPassStationService productNewPassStationService;
 
    /**
     * 查询配瓦规则
     * 
     * @param id 配瓦规则主键
     * @return 配瓦规则
     */
    @Override
    public DaTileMatchRules selectDaTileMatchRulesById(Long id)
    {
        return daTileMatchRulesMapper.selectDaTileMatchRulesById(id);
    }
 
    /**
     * 查询配瓦规则列表
     * 
     * @param daTileMatchRules 配瓦规则
     * @return 配瓦规则
     */
    @Override
    public List<DaTileMatchRules> selectDaTileMatchRulesList(DaTileMatchRules daTileMatchRules)
    {
        return daTileMatchRulesMapper.selectDaTileMatchRulesList(daTileMatchRules);
    }
 
    /**
     * 新增配瓦规则
     * 
     * @param daTileMatchRules 配瓦规则
     * @return 结果
     */
    @Override
    public int insertDaTileMatchRules(DaTileMatchRules daTileMatchRules)
    {
        daTileMatchRules.setCreateTime(DateUtils.getNowDate());
        return daTileMatchRulesMapper.insertDaTileMatchRules(daTileMatchRules);
    }
 
    /**
     * 修改配瓦规则
     * 
     * @param daTileMatchRules 配瓦规则
     * @return 结果
     */
    @Override
    public int updateDaTileMatchRules(DaTileMatchRules daTileMatchRules)
    {
        daTileMatchRules.setUpdateTime(DateUtils.getNowDate());
        return daTileMatchRulesMapper.updateDaTileMatchRules(daTileMatchRules);
    }
 
    /**
     * 批量删除配瓦规则
     * 
     * @param ids 需要删除的配瓦规则主键
     * @return 结果
     */
    @Override
    public int deleteDaTileMatchRulesByIds(Long[] ids)
    {
        return daTileMatchRulesMapper.deleteDaTileMatchRulesByIds(ids);
    }
 
    /**
     * 删除配瓦规则信息
     * 
     * @param id 配瓦规则主键
     * @return 结果
     */
    @Override
    public int deleteDaTileMatchRulesById(Long id)
    {
        return daTileMatchRulesMapper.deleteDaTileMatchRulesById(id);
    }
 
    @Override
    public List<DaTileMatchRules> checkData(String SNCode, String XT, String CZ) {
        List<DaTileMatchRules> resultList =new ArrayList<>();
        ProductNewPassStation productNewPassStation = new ProductNewPassStation();
        productNewPassStation.setSfcCode(SNCode);
        List<ProductNewPassStation> passStationList = productNewPassStationService.getProductPassStationList(productNewPassStation);
        if (CollUtil.isNotEmpty(passStationList)){
            ProductNewPassStation passStation = passStationList.get(0);
            String productType = passStation.getProductType();
            DaTileMatchRules daTileMatchRules = new DaTileMatchRules();
            daTileMatchRules.setProductSeries(productType);
            daTileMatchRules.setScanObject1("箱体");
            daTileMatchRules.setScanObject2("曲轴");
            List<DaTileMatchRules> daTileMatchRulesList = this.selectDaTileMatchRulesList(daTileMatchRules);
            if (StrUtil.isNotBlank(XT) && StrUtil.isNotBlank(CZ)){
                ArrayList<String> xtList = ListUtil.toList(XT.split(";"));
                ArrayList<String> czList = new ArrayList<>();
                String s2 = "";
                if (CZ.contains(";")){
                    czList = ListUtil.toList(CZ.split(";"));
                    if (CollUtil.isNotEmpty(czList) && czList.size()>2){
                        s2 = czList.get(2);
                    }
                } else if (CZ.contains(",")){
                    czList = ListUtil.toList(CZ.split(","));
                    if (CollUtil.isNotEmpty(czList) && czList.size()>1){
                        s2 = czList.get(1);
                    }
                }
                if (CollUtil.isNotEmpty(xtList) && xtList.size()>1 &&
                        StrUtil.isNotBlank(s2)){
                    String s1 = xtList.get(1);
                    if ("380".equals(productType)){
                        for (int i = 1; i < 5; i++){
                            char[] charArray1 = s1.toCharArray();
                            String axisValue;
                            String neckValue;
                            if (charArray1.length >= 7){
                                axisValue = String.valueOf(charArray1[i]);
                            } else {
                                axisValue = "";
                            }
                            char[] charArray2 = s2.toCharArray();
                            if (charArray2.length >= 8){
                                neckValue = String.valueOf(charArray2[i]);
                            } else {
                                neckValue = "";
                            }
                            Integer position = i+1;
                            List<DaTileMatchRules> collect = daTileMatchRulesList.stream().filter(x -> position.equals(x.getAxisParameterNoPosition())
                                    && position.equals(x.getNeckParameterPosition())
                                    && x.getAxisValue().equals(axisValue)
                                    && x.getNeckValue().equals(neckValue)).collect(Collectors.toList());
                            if (CollUtil.isNotEmpty(collect)){
                                DaTileMatchRules daTileMatchRules1 = collect.get(0);
                                resultList.add(daTileMatchRules1);
                            }
                        }
 
                    }
                }
 
            }
        }
        return resultList;
    }
}