yangys
2024-11-02 27eb2df01ab873bc7f1451ff5865ed66b2876159
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
package com.qianwen.smartman.modules.smis.service.impl;
 
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.CRC32;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qianwen.core.log.exception.ServiceException;
import com.qianwen.core.mp.base.BaseServiceImpl;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.common.cache.cps.WorkstationCache;
import com.qianwen.smartman.common.enums.WcsDataTypeEnums;
import com.qianwen.smartman.common.utils.Lambda;
import com.qianwen.smartman.common.utils.MessageUtils;
import com.qianwen.smartman.modules.smis.convert.WorkstationWcsConvert;
import com.qianwen.smartman.modules.smis.entity.DmpVariables;
import com.qianwen.smartman.modules.smis.entity.WorkstationOfMachine;
import com.qianwen.smartman.modules.smis.entity.WorkstationWcs;
import com.qianwen.smartman.modules.smis.entity.WorkstationWcsUsage;
import com.qianwen.smartman.modules.smis.mapper.WorkstationWcsMapper;
import com.qianwen.smartman.modules.smis.service.IWorkstationOfMachineService;
import com.qianwen.smartman.modules.smis.service.IWorkstationService;
import com.qianwen.smartman.modules.smis.service.IWorkstationWcsService;
import com.qianwen.smartman.modules.smis.service.IWorkstationWcsUsageService;
import com.qianwen.smartman.modules.smis.vo.DmpVariablesVO;
import com.qianwen.smartman.modules.smis.vo.MachineDmpVariablesVO;
import com.qianwen.smartman.modules.smis.vo.WorkstationWcsSaveNewVO;
import com.qianwen.smartman.modules.smis.vo.WorkstationWcsSaveVO;
import com.qianwen.smartman.modules.smis.vo.WorkstationWcsVO;
import com.qianwen.smartman.modules.tdengine.service.IWorkstationDynamicCollectService;
 
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.HexUtil;
 
@Service
public class WorkstationWcsServiceImpl extends BaseServiceImpl<WorkstationWcsMapper, WorkstationWcs> implements IWorkstationWcsService {
    @Autowired
    private IWorkstationOfMachineService workstationOfMachineService;
    @Autowired
    @Lazy
    private IWorkstationService workstationService;
    //@Autowired
    //@Lazy
    //private IDmpVariablesService dmpVariablesService;
    @Autowired
    private IWorkstationDynamicCollectService dynamicCollectService;
    @Autowired
    @Lazy
    private IWorkstationWcsUsageService workstationWcsUsageService;
    private static final String SUFFIX = "_____0";
    /*
    @Transactional(rollbackFor = {Exception.class})
    public List<WorkstationWcsVO> updateBatch(List<WorkstationWcsSaveVO> workstationWcsSaveVOList) {
        List<WorkstationWcs> workstationWcsList = WorkstationWcsConvert.INSTANCE.convertVOToEntity(workstationWcsSaveVOList);
        List<Long> workstationWcsIdList = new ArrayList<>();
        List<WorkstationWcs> wcsList = new ArrayList<>();
        for (WorkstationWcs workstationWcs : workstationWcsList) {
            List<Long> ids = list(Wrappers.<WorkstationWcs>lambdaQuery()
                    .eq(Func.isNotEmpty(workstationWcs.getWorkstationId()), WorkstationWcs::getWorkstationId, workstationWcs.getWorkstationId())
                    .eq(WorkstationWcs::getCollectSettingItem, workstationWcs.getCollectSettingItem())
                    .eq(WorkstationWcs::getDataType, workstationWcs.getDataType())
                    .eq(WorkstationWcs::getDataItem, workstationWcs.getDataItem()))
                    .stream().map(WorkstationWcs::getId).collect(Collectors.toList());
            
            if (Func.isNotEmpty(ids)) {
                workstationWcsIdList.addAll(ids);
            } else {
                checkWorkstationWcs(workstationWcs);//检查数据是否存在
                setCrc(workstationWcs);
            }
            MachineDmpVariablesVO machineDmpVariablesVO = this.dmpVariablesService.listByWorkstationId(workstationWcs.getWorkstationId());
            List<DmpVariablesVO> dmpVariablesVOList = machineDmpVariablesVO.getDmpVariablesVOList();
            if (Func.isNotEmpty(dmpVariablesVOList)) {
                List<String> nameList = dmpVariablesVOList.stream().map((v0) -> {
                    return v0.getName();
                }).collect(Collectors.toList());
                if (nameList.contains(workstationWcs.getCollectSettingItem())) {
                    Map<String, Long> dmpNameToId = dmpVariablesVOList.stream().collect(Collectors.toMap((v0) -> {
                        return v0.getName();
                    }, (v0) -> {
                        return v0.getId();
                    }));
                    workstationWcs.setDmpVariablesId(dmpNameToId.get(workstationWcs.getCollectSettingItem()));
                    wcsList.add(workstationWcs);
                }
            }
        }
        removeByIds(workstationWcsIdList);
        saveBatch(wcsList);
        List<Long> workstationIds = wcsList.stream().map((v0) -> {
            return v0.getWorkstationId();
        }).collect(Collectors.toList());
        if (Func.isNotEmpty(workstationIds)) {
            WorkstationCache.clearDmpStatus(workstationIds);
            clearWorkstationParamTypeCacheByWorkstationId(workstationIds);
        }
        List<WorkstationWcsVO> convert = WorkstationWcsConvert.INSTANCE.convert(wcsList);
        wrapperVO(convert);
        return convert;
    }
    */
 
    /*
    @Override 
    @Transactional(rollbackFor = {Exception.class})
    public List<WorkstationWcsVO> insert(List<WorkstationWcsSaveVO> workstationWcsSaveVOList) {
        Long workstationId = workstationWcsSaveVOList.get(0).getWorkstationId();
        List<WorkstationWcsSaveVO> checkedVoList = workstationWcsSaveVOList.stream().filter((v0) -> {
            return v0.checkedItem();
        }).collect(Collectors.toList());
        validWorkstationExistsWcs(checkedVoList);
        List<DmpVariables> dmpVariablesList = validDmpName(workstationId, checkedVoList);
        List<WorkstationWcs> saveWorkstationWcsList = WorkstationWcsConvert.INSTANCE.convertVOToEntity(checkedVoList);
        
      //删除tdengine中的count_data_${workstationId}_${usageCode}和aggregate_count_data_${workstationId}_${usageCode},实际上这2个表不存在
        this.dynamicCollectService.removeTableUpdateWcs(saveWorkstationWcsList);
        
        //也是删除以上2个表,也是不存在的表
        this.dynamicCollectService.removeTableDeleteWcs(list(Lambda.eq(WorkstationWcs::getWorkstationId, workstationId)
                .notIn(Func.isNotEmpty(saveWorkstationWcsList), WorkstationWcs::getCollectSettingItem, saveWorkstationWcsList
                  .stream().map(WorkstationWcs::getCollectSettingItem)
                  .collect(Collectors.toList()))));
        
        deleteByWorkstationIdList(Collections.singletonList(workstationId));//删除workstation_wsc的老数据
        for (WorkstationWcs workstationWcs : saveWorkstationWcsList) {
            checkWorkstationWcs(workstationWcs);
            setCrc(workstationWcs);
        }
        List<WorkstationWcs> collect =  saveWorkstationWcsList.stream().filter(w -> {
            return Func.isNotEmpty(w.getDataItem());
        }).collect(Collectors.toList());
        saveOrUpdateBatch(collect);
        
        //下一步更新排序(idx)
        Map<Long, Integer> idToIdx = workstationWcsSaveVOList.stream().collect(Collectors.toMap((v0) -> {
            return v0.getDmpVariablesId();
        }, (v0) -> {
            return v0.getSort();
        }));
        dmpVariablesList.forEach(dmpVariables -> {
            dmpVariables.setIdx(idToIdx.get(dmpVariables.getId()));//更新索引序号
        });
        this.dmpVariablesService.updateBatchById(dmpVariablesList);
        
        //更新缓存
        List<Long> workstationIds = workstationWcsSaveVOList.stream().map((v0) -> {
            return v0.getWorkstationId();
        }).collect(Collectors.toList());
        WorkstationCache.clearDmpStatus(workstationIds);
        workstationIds.forEach(id -> {
            WorkstationCache.clearWorkstationWcs(String.valueOf(id));
        });
        clearWorkstationParamTypeCacheByWorkstationId(workstationIds);
        
        //返回所有数据的VO列表
        return WorkstationWcsConvert.INSTANCE.convert(saveWorkstationWcsList);
    }
    */
 
    private void validWorkstationExistsWcs(final List<WorkstationWcsSaveVO> workstationWcsSaveVOList) {
        boolean exist = (workstationWcsSaveVOList.stream().filter(it -> {
            return !it.getDataType().equals(WcsDataTypeEnums.WcsDataType.OTHER.getCode());
        }).filter(it2 -> {
            return it2.getUsageId() != null;
        }).collect(Collectors.groupingBy(it3 -> {
            return Long.valueOf(it3.getWorkstationId().longValue() + it3.getUsageId().longValue());
        }, Collectors.counting()))).values().stream().anyMatch(count -> {
            return count.longValue() > 1;
        });
        Assert.isTrue(!exist, MessageUtils.message("workstation.wcs.usage.id.already.exists", new Object[0]), new Object[0]);
    }
    /*
    private List<DmpVariables> validDmpName(Long workstationId, List<WorkstationWcsSaveVO> workstationWcsSaveVOList) {
        WorkstationOfMachine one = this.workstationOfMachineService.getWorkstationOfMachineByWorkstationId(workstationId);
        
        List<DmpVariables> dmpVariablesList = this.dmpVariablesService.list(Wrappers.<DmpVariables>lambdaQuery().eq(DmpVariables::getMachineId, one.getMachineId()));
        
        Map<Long, String> dmpIdToName = dmpVariablesList.stream().collect(Collectors.toMap((v0) -> {
            return v0.getId();
        }, (v0) -> {
            return v0.getName();
        }));
        List<String> collectItemList = workstationWcsSaveVOList.stream().map(w -> {
            return (String) dmpIdToName.get(w.getDmpVariablesId());
        }).collect(Collectors.toList());
        List<String> collectItemDistinctList = collectItemList.stream().distinct().collect(Collectors.toList());
        Assert.isTrue(collectItemList.size() == collectItemDistinctList.size(), MessageUtils.message("workstationWcs.collectItem.already.exists", new Object[0]), new Object[0]);
        return dmpVariablesList;
    }*/
 
    public void setCrc(WorkstationWcs workstationWcs) {
        byte[] bytes = workstationWcs.getDataItem().concat(SUFFIX).getBytes();
        CRC32 crc32 = new CRC32();
        crc32.update(bytes, 0, bytes.length);
        String dataItemCrc = HexUtil.toHex(crc32.getValue());
        workstationWcs.setDataItemCrc(dataItemCrc);
    }
 
    @Override 
    public WorkstationWcsVO updateSetting(WorkstationWcsSaveVO workstationWcsSaveVO) {
        WorkstationWcs workstationWcs = WorkstationWcsConvert.INSTANCE.convert(workstationWcsSaveVO);
        checkSetting(workstationWcs);
        updateById(workstationWcs);
        WorkstationWcsVO workstationWcsVO = WorkstationWcsConvert.INSTANCE.convertVO(workstationWcsSaveVO);
        wrapperVO(Collections.singletonList(workstationWcsVO));
        return workstationWcsVO;
    }
 
    @Override 
    public List<WorkstationWcsVO> listWcsSetting() {
        List<WorkstationWcs> list = list( Wrappers.<WorkstationWcs>lambdaQuery().isNull(WorkstationWcs::getWorkstationId));
        List<WorkstationWcsVO> convert = WorkstationWcsConvert.INSTANCE.convert(list);
        wrapperVO(convert);
        return convert;
    }
 
    @Override 
    @Transactional(rollbackFor = {Exception.class})
    public List<WorkstationWcsVO> saveSetting(List<WorkstationWcsSaveVO> workstationWcsSaveVOList) {
        List<WorkstationWcs> workstationWcsList = WorkstationWcsConvert.INSTANCE.convertVOToEntity(workstationWcsSaveVOList);
        workstationWcsList.forEach(this::checkSetting);
        saveOrUpdateBatch(workstationWcsList);
        List<WorkstationWcsVO> convert = WorkstationWcsConvert.INSTANCE.convert(workstationWcsList);
        wrapperVO(convert);
        return convert;
    }
 
    public void checkSetting(WorkstationWcs workstationWcs) {
        Long count = Long.valueOf(count(Wrappers.<WorkstationWcs>lambdaQuery()
                  .ne(Func.isNotEmpty(workstationWcs.getId()), WorkstationWcs::getId, workstationWcs.getId())
                  .eq(Func.isNotEmpty(workstationWcs.getWorkstationId()), WorkstationWcs::getWorkstationId, workstationWcs.getWorkstationId())
                  .isNull(Func.isEmpty(workstationWcs.getWorkstationId()), WorkstationWcs::getWorkstationId)
                  .eq(WorkstationWcs::getCollectSettingItem, workstationWcs.getCollectSettingItem())));
        
        /*
        Long count = Long.valueOf(count( Wrappers.lambdaQuery().ne(Func.isNotEmpty(workstationWcs.getId()), (v0) -> {
            return v0.getId();
        }, workstationWcs.getId()).eq(Func.isNotEmpty(workstationWcs.getWorkstationId()), (v0) -> {
            return v0.getWorkstationId();
        }, workstationWcs.getWorkstationId()).isNull(Func.isEmpty(workstationWcs.getWorkstationId()), (v0) -> {
            return v0.getWorkstationId();
        }).eq((v0) -> {
            return v0.getCollectSettingItem();
        }, workstationWcs.getCollectSettingItem())));*/
        if (count.longValue() > 0) {
            throw new ServiceException(MessageUtils.message("workstationWcs.collectItem.already.exists", new Object[0]));
        }
    }
 
    @Override 
    public Boolean deleteByWorkstationIdList(List<Long> workstationIdList) {
        remove(Wrappers.<WorkstationWcs>lambdaQuery().in(WorkstationWcs::getWorkstationId, workstationIdList));
        /*
        remove((Wrapper) Wrappers.lambdaQuery().in((v0) -> {
            return v0.getWorkstationId();
        }, workstationIdList));*/
        clearWorkstationParamTypeCacheByWorkstationId(workstationIdList);
        return true;
    }
 
    @Override 
    public List<WorkstationWcsVO> listWorkstationWcsByWorkstationId(Long workstationId) {
        List<WorkstationWcsVO> workstationWcsVOList = ((WorkstationWcsMapper) this.baseMapper).listWcs(workstationId);
        wrapperVO(workstationWcsVOList);
        return workstationWcsVOList;
    }
 
    private void wrapperVO(final List<WorkstationWcsVO> workstationWcsVOList) {
        workstationWcsVOList
        .forEach(it -> {
            it.setDataTypeDesc(WcsDataTypeEnums.WcsDataType.getNameByCode(it.getDataType()));
            
            //WorkstationWcsUsage usage = workstationWcsUsageService.getById(it.getUsageId());
            //it.setUsageName(usage.getUsageName());
            Optional.<Long>ofNullable(it.getUsageId()).map(usageId -> {
                WorkstationWcsUsage usage = workstationWcsUsageService.getById(usageId);
                return usage;
            }).ifPresent(usage2 -> {
                it.setUsageName(usage2.getUsageName());
            });
            //Optional.<Long>ofNullable(it.getUsageId()).map(this.workstationWcsUsageService::getById).ifPresent(());
          });
        /*
        workstationWcsVOList.forEach(it -> {
            it.setDataTypeDesc(WcsDataTypeEnums.WcsDataType.getNameByCode(it.getDataType()));
            Optional ofNullable = Optional.ofNullable(it.getUsageId());
            IWorkstationWcsUsageService iWorkstationWcsUsageService = this.workstationWcsUsageService;
            iWorkstationWcsUsageService.getClass();
            ofNullable.map((v1) -> {
                return r1.getById(v1);
            }).ifPresent(usage -> {
                it.setUsageName(usage.getUsageName());
            });
        });*/
    }
 
    @Override 
    public Boolean delete(List<Long> workstationWcsIdList) {
        List<WorkstationWcs> workstationWcs = listByIds(workstationWcsIdList);
        removeByIds(workstationWcsIdList);
        List<Long> workstationIds = workstationWcs.stream().map((v0) -> {
            return v0.getWorkstationId();
        }).collect(Collectors.toList());
        workstationIds.forEach(id -> {
            WorkstationCache.clearWorkstationWcs(String.valueOf(id));
        });
        clearWorkstationParamTypeCacheByWorkstationId(workstationIds);
        return null;
    }
 
    @Override 
    public void clearWorkstationParamTypeCacheByWorkstationId(List<Long> workstationIdList) {
        List<WorkstationOfMachine> workstationOfMachineList = this.workstationOfMachineService.list(Wrappers.<WorkstationOfMachine>lambdaQuery()
                .in(WorkstationOfMachine::getWorkstationId, workstationIdList));
        /*
        List<WorkstationOfMachine> workstationOfMachineList = this.workstationOfMachineService.list((Wrapper) Wrappers.lambdaQuery().in((v0) -> {
            return v0.getWorkstationId();
        }, workstationIdList));*/
        List<Long> machineIdList = workstationOfMachineList.stream().map((v0) -> {
            return v0.getMachineId();
        }).collect(Collectors.toList());
        for (Long id : machineIdList) {
            WorkstationCache.clearWorkstationParamTypeCache(String.valueOf(id));
        }
    }
 
    @Override 
    @Transactional(rollbackFor = {Exception.class})
    public List<WorkstationWcsVO> insertNew(List<WorkstationWcsSaveNewVO> workstationWcsSaveNewVOList, List<Long> workstationIdList) {
        List<WorkstationWcsSaveVO> workstationWcsSaveVOList = new ArrayList<>();
        workstationIdList.forEach(workstationId -> {
            List<WorkstationWcsVO> workstationWcsVOList = listWorkstationWcsByWorkstationId(workstationId);
            Map<String, Long> wcsCollectItemToId = workstationWcsVOList.stream().collect(Collectors.toMap((v0) -> {
                return v0.getCollectItemDesc();
            }, (v0) -> {
                return v0.getId();
            }));
            workstationWcsSaveNewVOList.forEach(workstationWcsSaveNewVO -> {
                if (wcsCollectItemToId.containsKey(workstationWcsSaveNewVO.getCollectSettingItem())) {
                    WorkstationWcsSaveVO workstationWcsSaveVO = WorkstationWcsSaveVO.builder().id((Long) wcsCollectItemToId.get(workstationWcsSaveNewVO.getCollectSettingItem())).workstationId(workstationId).collectSettingItem(workstationWcsSaveNewVO.getCollectSettingItem()).dataItem(workstationWcsSaveNewVO.getDataItem()).dataType(workstationWcsSaveNewVO.getDataType()).bigScreen(workstationWcsSaveNewVO.getBigScreen()).realTimeData(workstationWcsSaveNewVO.getRealTimeData()).processParameter(workstationWcsSaveNewVO.getProcessParameter()).usageId(Long.valueOf(Func.toLong(workstationWcsSaveNewVO.getUsageId()))).build();
                    workstationWcsSaveVOList.add(workstationWcsSaveVO);
                }
            });
        });
        List<WorkstationWcs> workstationWcsList = WorkstationWcsConvert.INSTANCE.convertVOToEntity(workstationWcsSaveVOList);
        workstationWcsList.forEach(this::setCrc);
        
        Stream<WorkstationWcsSaveVO> stream = workstationWcsSaveVOList.stream();        
        Stream<WorkstationWcsSaveVO> stream2 = list(Lambda.in(WorkstationWcs::getWorkstationId, workstationIdList)
                .notIn(WorkstationWcs::getId,workstationWcsList
                  .stream().map(WorkstationWcs::getId).collect(Collectors.toList()))
                .ne(WorkstationWcs::getDataType, WcsDataTypeEnums.WcsDataType.OTHER.getCode()))
              .stream().map(WorkstationWcsConvert.INSTANCE::convert);
        
        //Stream.concat(stream, stream2);
        validWorkstationExistsWcs(Stream.concat(stream, stream2).collect(Collectors.toList()));
        
        /*
        Stream<WorkstationWcsSaveVO> stream = workstationWcsSaveVOList.stream();
        Stream stream2 = list((Wrapper) ((ExtraLambdaQueryWrapper) Lambda.in((v0) -> {
            return v0.getWorkstationId();
        }, workstationIdList).notIn((v0) -> {
            return v0.getId();
        }, (Collection) workstationWcsList.stream().map((v0) -> {
            return v0.getId();
        }).collect(Collectors.toList()))).ne((v0) -> {
            return v0.getDataType();
        }, WcsDataTypeEnums.WcsDataType.OTHER.getCode())).stream();
        WorkstationWcsConvert workstationWcsConvert = WorkstationWcsConvert.INSTANCE;
        workstationWcsConvert.getClass();
        validWorkstationExistsWcs((List) Stream.concat(stream, stream2.map(this::convert)).collect(Collectors.toList()));
        */
        this.dynamicCollectService.removeTableUpdateWcs(workstationWcsList);
        updateBatchById(workstationWcsList);
        WorkstationCache.clearDmpStatus(workstationIdList);
        workstationIdList.forEach(id -> {
            WorkstationCache.clearWorkstationWcs(String.valueOf(id));
        });
        clearWorkstationParamTypeCacheByWorkstationId(workstationIdList);
        List<WorkstationWcsVO> convert = WorkstationWcsConvert.INSTANCE.convert(workstationWcsList);
        wrapperVO(convert);
        return convert;
    }
 
    @Override 
    public String isExists(List<WorkstationWcsSaveNewVO> workstationWcsSaveNewVOList, List<Long> workstationIdList) {
        Map<Long, String> workstationIdToName = this.workstationService.listByIds(workstationIdList).stream().collect(Collectors.toMap((v0) -> {
            return v0.getId();
        }, (v0) -> {
            return v0.getName();
        }));
        StringBuilder name = new StringBuilder("");
        Set<Long> idSet = new HashSet<>();
        for (Long workstationId : workstationIdList) {
            for (WorkstationWcsSaveNewVO w : workstationWcsSaveNewVOList) {
                Long count = Long.valueOf(count(Wrappers.<WorkstationWcs>lambdaQuery()
                        .eq(WorkstationWcs::getWorkstationId, workstationId).eq(WorkstationWcs::getDmpVariablesId, w.getDmpVariablesId())
                        .eq(WorkstationWcs::getDataType, w.getDataType()).eq(WorkstationWcs::getDataItem, w.getDataItem())));
                /*
                Long count = Long.valueOf(count((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> {
                    return v0.getWorkstationId();
                }, workstationId)).eq((v0) -> {
                    return v0.getDmpVariablesId();
                }, w.getDmpVariablesId())).eq((v0) -> {
                    return v0.getDataType();
                }, w.getDataType())).eq((v0) -> {
                    return v0.getDataItem();
                }, w.getDataItem())));*/
                if (count.longValue() > 0) {
                    idSet.add(workstationId);
                }
            }
        }
        idSet.forEach(id -> {
            name.append(",").append((String) workstationIdToName.get(id));
        });
        return Func.isNotEmpty(name) ? name.substring(1) : name.toString();
    }
 
    /***
     * 检查工况参数配置的数据类型dataType,和对应的数据是否存在
     * @param workstationWcs
     */
    private void checkWorkstationWcs(WorkstationWcs workstationWcs) {
        if (WcsDataTypeEnums.ONLY_ONE_LIST.contains(workstationWcs.getDataType())) {
            Long count = Long.valueOf(count(Wrappers.<WorkstationWcs>lambdaQuery()
                    .ne(Func.isNotEmpty(workstationWcs.getId()), WorkstationWcs::getId, workstationWcs.getId())
                    .eq(Func.isNotEmpty(workstationWcs.getWorkstationId()), WorkstationWcs::getWorkstationId, workstationWcs.getWorkstationId())
                    .isNotNull(Func.isNotEmpty(workstationWcs.getWorkstationId()), WorkstationWcs::getWorkstationId)
                    .eq(WorkstationWcs::getDataType, workstationWcs.getDataType())));
            if (count.longValue() > 0) {
                throw new ServiceException(MessageUtils.message("workstationWcs.dataType.already.exists", new Object[0]));
            }
        }
        Long count2 = Long.valueOf(count(Wrappers.<WorkstationWcs>lambdaQuery()
                .ne(Func.isNotEmpty(workstationWcs.getId()), WorkstationWcs::getId, workstationWcs.getId())
                .eq(Func.isNotEmpty(workstationWcs.getWorkstationId()), WorkstationWcs::getWorkstationId, workstationWcs.getWorkstationId())
                .isNotNull(Func.isNotEmpty(workstationWcs.getWorkstationId()), WorkstationWcs::getWorkstationId)
                .eq(WorkstationWcs::getDmpVariablesId, workstationWcs.getDmpVariablesId())));
        if (count2.longValue() > 0) {
            throw new ServiceException(MessageUtils.message("workstationWcs.collectItem.already.exists", new Object[0]));
        }
    }
}