zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
package org.jeecg.modules.lims.testing.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.modules.lims.testing.dto.LimsTestingBatchDTO;
import org.jeecg.modules.lims.testing.entity.*;
import org.jeecg.modules.lims.testing.service.*;
import org.jeecg.modules.lims.testing.vo.LimsTestingBatchVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
 
/**
 * @Description: lims_testing_batch
 * @Author: jeecg-boot
 * @Date: 2023-05-11
 * @Version: V1.0
 */
@Api(tags = "lims_testing_batch")
@RestController
@RequestMapping("/lims/testing/batch")
@Slf4j
public class LimsTestingBatchController extends JeecgController<LimsTestingBatch, ILimsTestingBatchService> {
    @Autowired
    private ILimsTestingBatchService limsTestingBatchService;
    @Autowired
    private ILimsBatchSampleService limsBatchSampleService;
    @Autowired
    private ILimsTestingProductService limsTestingProductService;
    @Autowired
    private ILimsTestingStandardService limsTestingStandardService;
    @Autowired
    private ILimsItemTargetService limsItemTargetService;
    @Autowired
    private ILimsBatchResultService limsBatchResultService;
    @Autowired
    private ILimsTestingStandCondService limsTestingStandCondService;
    @Autowired
    private ILimsBatchDetailService limsBatchDetailService;
    @Autowired
    private ILimsTestingItemService itemService;
    @Autowired
    private ILimsTestingTypeService typService;
    @Autowired
    private ILimsTestingCategoryService categoryService;
 
    /**
     * 分页列表查询
     *
     * @param limsTestingBatch
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "lims_testing_batch-分页列表查询")
    @ApiOperation(value = "lims_testing_batch-分页列表查询", notes = "lims_testing_batch-分页列表查询")
    @GetMapping(value = "/list")
    public Result<?> queryPageList(LimsTestingBatch limsTestingBatch,
                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                   HttpServletRequest req) {
        QueryWrapper<LimsTestingBatch> queryWrapper = QueryGenerator.initQueryWrapper(limsTestingBatch, req.getParameterMap());
        Page<LimsTestingBatch> page = new Page<LimsTestingBatch>(pageNo, pageSize);
        Page<LimsTestingBatchVo> page2 = new Page<LimsTestingBatchVo>(pageNo, pageSize);
        IPage<LimsTestingBatch> pageList = limsTestingBatchService.page(page, queryWrapper);
        comp(pageList, page2);
        return Result.OK(page2);
    }
 
    private void comp(IPage<LimsTestingBatch> pageList, Page<LimsTestingBatchVo> page) {
        List<LimsTestingBatchVo> collect = pageList.getRecords().stream().map(item -> {
            LimsTestingBatchVo vo = new LimsTestingBatchVo();
            BeanUtils.copyProperties(item, vo);
            //产品名称
            LimsTestingProduct product = limsTestingProductService.getById(item.getProdId());
            if (product != null) {
                vo.setProdName(product.getName());
            }
            LimsTestingStandard stand = limsTestingStandardService.getById(item.getStandardId());
            if (stand != null) {
                vo.setStandName(stand.getName());
            }
            //计算每个批次的完成进度
            QueryWrapper<LimsBatchDetail> detailQueryWrapper = new QueryWrapper<>();
            detailQueryWrapper.lambda().eq(LimsBatchDetail::getBatchId, item.getId());
            List<LimsBatchDetail> detailList = limsBatchDetailService.list(detailQueryWrapper);
            vo.setProgress(0d);
            if (detailList.size() > 0) {
                //已完成检验数据
                List<LimsBatchDetail> finishDetailList = detailList.stream().filter(detail -> detail.getValue() != null).collect(Collectors.toList());
                vo.setBatchDetailTotal(detailList.size());
                vo.setBatchDetailFinish(finishDetailList.size());
                if (finishDetailList.size() > 0) {
                    double progress = finishDetailList.size() / 1.0 / detailList.size();
                    progress = progress * 100;
                    DecimalFormat decimalFormat = new DecimalFormat("#.0");
                    String pro = decimalFormat.format(progress);
                    vo.setProgress(Double.parseDouble(pro));
                }
            }
 
            return vo;
        }).collect(Collectors.toList());
        BeanUtils.copyProperties(pageList, page);
        page.setRecords(collect);
 
 
    }
 
    /**
     * 添加
     *
     * @param limsTestingBatch
     * @return
     */
    @AutoLog(value = "lims_testing_batch-添加")
    @ApiOperation(value = "lims_testing_batch-添加", notes = "lims_testing_batch-添加")
    @PostMapping(value = "/add")
    @Transactional
    public Result<?> add(@RequestBody LimsTestingBatchDTO limsTestingBatch) {
 
        //添加批次后需要生成样本信息
        limsTestingBatch.setBatchDate(new Date());
        QueryWrapper<LimsTestingStandard> queryWrapper = new QueryWrapper<>();
        //查询产品发布技术标准发布的
        queryWrapper.lambda().eq(LimsTestingStandard::getProdId, limsTestingBatch.getProdId())
                .eq(LimsTestingStandard::getStatus, 1).orderByDesc(LimsTestingStandard::getCreateTime);
        //查询产品的技术标准
        List<LimsTestingStandard> standList = limsTestingStandardService.list(queryWrapper);
        if (!standList.isEmpty() && standList.size() > 0) {
            String standId = standList.get(0).getId();
            limsTestingBatch.setStandardId(standId);
        } else {
            return Result.error("当前产品没有发布技术标准,请维护后重试!");
        }
        //1.生成批次
        limsTestingBatchService.save(limsTestingBatch);
 
        //2.生成样本数据
        generateSimpleData(limsTestingBatch);
        //3.生成检测记录汇总结果
        Integer integer = generateInspectRecord(limsTestingBatch);
        if (integer == -1) {
            return Result.error("当前产品未设置鉴定项目,请维护技术标准后重试!");
        }
        //4.生成检测明细
        generateInspectDetail(limsTestingBatch);
 
        return Result.OK("添加成功!");
    }
 
    //生成样本数据
    private void generateSimpleData(LimsTestingBatchDTO limsTestingBatch) {
        List<LimsTestingBatchDTO.ChannelInfo> channelInfoList = limsTestingBatch.getChannelInfoList();
        if (channelInfoList.isEmpty()) return;
        AtomicInteger sampleSum = new AtomicInteger();
        channelInfoList.stream().forEach(item -> {
            String channels = item.getChannels();
            Integer sampleNum = item.getSampleNum();
            //通道 和 样本数 为空时跳过
            if (StringUtils.isEmpty(channels) || sampleNum == null) {
                return;
            }
            String[] channelArray = channels.split(",");
            //通道数
            for (int i = 0; i < channelArray.length; i++) {
                String channel = channelArray[i];
                //样本数
                for (int j = 0; j < sampleNum; j++) {
                    sampleSum.getAndIncrement();
                    LimsBatchSample sample = new LimsBatchSample();
                    sample.setBatchId(limsTestingBatch.getId());
                    sample.setModelId(item.getModelId());
                    sample.setChannel(channel);
                    sample.setProdId(limsTestingBatch.getProdId());
                    sample.setCode(item.getModelCode()  + "-s" + (j + 1) + "-c" + channel);
 
                    limsBatchSampleService.save(sample);
                }
            }
 
 
        });
        //生成样本后更新统计数据
        limsTestingBatch.setSampleNum(sampleSum.get());
        limsTestingBatchService.updateById(limsTestingBatch);
    }
 
    //生成检验记录
    private Integer generateInspectRecord(LimsTestingBatchDTO limsTestingBatch) {
        String standardId = limsTestingBatch.getStandardId();
        QueryWrapper<LimsItemTarget> itemTargetQueryWrapper = new QueryWrapper<>();
        itemTargetQueryWrapper.lambda().eq(LimsItemTarget::getStandardId, standardId);
        itemTargetQueryWrapper.lambda().eq(LimsItemTarget::getEnabled,1);
        List<LimsItemTarget> targetList = limsItemTargetService.list(itemTargetQueryWrapper);
        Map<String, List<LimsItemTarget>> typGroupMap = targetList.stream().collect(Collectors.groupingBy(LimsItemTarget::getTypeId));
        Map<String, List<LimsItemTarget>> itmGroupMap = targetList.stream().collect(Collectors.groupingBy(LimsItemTarget::getItemId));
        if (itmGroupMap.isEmpty()) {
            return -1;
        }
        //根据typ分组
        typGroupMap.forEach((typ, value) -> {
            LimsBatchResult result = new LimsBatchResult();
            result.setBatchId(limsTestingBatch.getId());
            result.setTestingCat(value.get(0).getCategoryId());
            result.setTestingType(typ);
 
            LimsTestingCategory category = categoryService.getById(result.getTestingCat());
            LimsTestingType t = typService.getById(result.getTestingType());
            double sort = category.getSort() * 100 + t.getSort() * 1;
            result.setSort(sort);
            limsBatchResultService.save(result);
        });
 
        return 1;
 
    }
 
    /**
     * 生成检验明细
     */
    private void generateInspectDetail(LimsTestingBatchDTO limsTestingBatch) {
       /* //1.查询批次检测项目
        String standardId = limsTestingBatch.getStandardId();
        QueryWrapper<LimsItemTarget> itemTargetQueryWrapper = new QueryWrapper<>();
        itemTargetQueryWrapper.lambda().eq(LimsItemTarget::getStandardId, standardId);
        List<LimsItemTarget> targetList = limsItemTargetService.list(itemTargetQueryWrapper);
        Map<String, List<LimsItemTarget>> typGroupMap = targetList.stream().collect(Collectors.groupingBy(LimsItemTarget::getTypeId));
 
        //2.查询批次所有样本
        QueryWrapper<LimsBatchSample> sampleQueryWrapper = new QueryWrapper<>();
        sampleQueryWrapper.lambda().eq(LimsBatchSample::getBatchId,limsTestingBatch.getId());
        List<LimsBatchSample> sampleList = limsBatchSampleService.list(sampleQueryWrapper);
 
 
        //遍历技术标准下鉴定类别-type(查询各type的检测条件)
        typGroupMap.forEach((type,list)->{
            //查询批次下技术标准所有检测条件
            QueryWrapper<LimsTestingStandCond> condQueryWrapper = new QueryWrapper<>();
            condQueryWrapper.lambda().eq(LimsTestingStandCond::getTypeId,type);
            List<LimsTestingStandCond> conds = limsTestingStandCondService.list(condQueryWrapper);
            //如果没有检验条件,则添加一行检验数据
            if(conds ==null || conds.size() < 1) {
                LimsTestingStandCond cond = new LimsTestingStandCond();
                cond.setCond("-");
                conds.add(cond);
            }
 
            for (int i = 0; i <conds.size() ; i++) {
                LimsTestingStandCond cond = conds.get(i);
 
                for (int j = 0; j < sampleList.size(); j++) {
 
                }
 
            }
 
        });
*/
 
        //1.查询 批次检验结果记录
        QueryWrapper<LimsBatchResult> resultQueryWrapper = new QueryWrapper<>();
        resultQueryWrapper.lambda().eq(LimsBatchResult::getBatchId, limsTestingBatch.getId());
        List<LimsBatchResult> resultList = limsBatchResultService.list(resultQueryWrapper);
        Map<String, String> resultMap = resultList.stream().collect(Collectors.toMap(LimsBatchResult::getTestingType, LimsBatchResult::getId));
 
 
        //2.通过type 查询item
        List<String> typList = resultList.stream().map(LimsBatchResult::getTestingType).collect(Collectors.toList());
 
        //3.根据typ查询需检验的所有鉴定项
        QueryWrapper<LimsItemTarget> targetQueryWrapper = new QueryWrapper<>();
        targetQueryWrapper.lambda().eq(LimsItemTarget::getStandardId, limsTestingBatch.getStandardId());
        targetQueryWrapper.lambda().in(LimsItemTarget::getTypeId, typList.toArray());
        targetQueryWrapper.lambda().eq(LimsItemTarget::getEnabled, 1);
        List<LimsItemTarget> targetList = limsItemTargetService.list(targetQueryWrapper);
        List<String> typeIds = new ArrayList<>();
        List<String> itemIds = new ArrayList<>();
 
        //4.根据type分类item
        Map<String, List<LimsItemTarget>> typGroupMap = targetList.stream().collect(Collectors.groupingBy(LimsItemTarget::getTypeId));
 
        //5.查询type的测试条件
        Map<String, List<LimsTestingStandCond>> typCondMap1 = new HashMap<>();
        Map<String, List<LimsTestingStandCond>> typCondMap2 = new HashMap<>();
        typGroupMap.forEach((typ, itmList) -> {
            //保存typid和itemid 供生成破坏性使用
            typeIds.add(typ);
            List<String> itmIds = itmList.stream().filter(item->item.getEnabled()!=null && item.getEnabled()==1).map(LimsItemTarget::getItemId).collect(Collectors.toList());
            itemIds.addAll(itmIds);
            //保存typid和itemid 供生成破坏性使用
            QueryWrapper<LimsTestingStandCond> condQueryWrapper1 = new QueryWrapper<>();
            condQueryWrapper1.lambda().eq(LimsTestingStandCond::getStandardId, limsTestingBatch.getStandardId());
            condQueryWrapper1.lambda().eq(LimsTestingStandCond::getTypeId, typ);
            //测试电压
            condQueryWrapper1.lambda().eq(LimsTestingStandCond::getType, 1);
            List<LimsTestingStandCond> typCondList1 = limsTestingStandCondService.list(condQueryWrapper1);
            if (typCondList1 == null || typCondList1.size() < 1) {
                LimsTestingStandCond cond = new LimsTestingStandCond();
                cond.setCond("-");
                typCondList1.add(cond);
            }
            typCondMap1.put(typ, typCondList1);
            //测试温度
            QueryWrapper<LimsTestingStandCond> condQueryWrapper2 = new QueryWrapper<>();
            condQueryWrapper2.lambda().eq(LimsTestingStandCond::getStandardId, limsTestingBatch.getStandardId());
            condQueryWrapper2.lambda().eq(LimsTestingStandCond::getTypeId, typ);
            condQueryWrapper2.lambda().eq(LimsTestingStandCond::getType, 2);
            List<LimsTestingStandCond> typCondList2 = limsTestingStandCondService.list(condQueryWrapper2);
            if (typCondList2 == null || typCondList2.size() < 1) {
                LimsTestingStandCond cond = new LimsTestingStandCond();
                cond.setCond("-");
                typCondList2.add(cond);
            }
            typCondMap2.put(typ, typCondList2);
 
 
        });
        //6.查询批次所有样本
        QueryWrapper<LimsBatchSample> sampleQueryWrapper = new QueryWrapper<>();
        sampleQueryWrapper.lambda().eq(LimsBatchSample::getBatchId, limsTestingBatch.getId());
        List<LimsBatchSample> sampleList = limsBatchSampleService.list(sampleQueryWrapper);
 
        List<LimsBatchDetail> saveList = new ArrayList<>();
        //组装数据
        targetList.stream().forEach(itm -> {
            String typeId = itm.getTypeId();
            //查询typ是否破坏性实验
            LimsTestingType typ = typService.getById(typeId);
            sampleList.forEach(sample -> {
 
                //测试电压
                List<LimsTestingStandCond> conds1 = typCondMap1.get(typeId);
                //测试温度
                List<LimsTestingStandCond> conds2 = typCondMap2.get(typeId);
 
                conds1.forEach(cond1 -> {
                    conds2.forEach(cond2 -> {
                        LimsBatchDetail detail = new LimsBatchDetail();
                        detail.setResultId(resultMap.get(typeId));
                        detail.setSampleId(sample.getId());
                        detail.setItemId(itm.getItemId());
                        detail.setCond(cond1.getCond());
                        detail.setCond2(cond2.getCond());
                        detail.setBatchId(limsTestingBatch.getId());
                        //limsBatchDetailService.save(detail);
                        saveList.add(detail);
 
                    });
                });
 
            });
        });
        //10 补充破坏性实验需要数据
        //10.1 查询所有typ项
        QueryWrapper<LimsTestingType> typeQueryWrapper = new QueryWrapper<>();
        typeQueryWrapper.lambda().in(LimsTestingType::getId,typeIds);
        List<LimsTestingType> tList = typService.list(typeQueryWrapper);
 
        //10.2 根据typ查询所有itm并筛选出常规项
        QueryWrapper<LimsTestingItem> itemQueryWrapper = new QueryWrapper<>();
        itemQueryWrapper.lambda().in(LimsTestingItem::getId,itemIds);
        itemQueryWrapper.lambda().eq(LimsTestingItem::getGengeral,1);
        itemQueryWrapper.lambda().eq(LimsTestingItem::getEnabled,1);
        List<LimsTestingItem> itmGengeralList = itemService.list(itemQueryWrapper);
 
        tList.forEach(typ->{
            if(typ.getDestructive()==null || typ.getDestructive()==0) return;
            sampleList.forEach(sample -> {
                itmGengeralList.forEach(itm->{
                    //fix 破坏性实验不需要添加条件
//                //测试电压
//                List<LimsTestingStandCond> conds1 = typCondMap1.get(itm.getTypeId());
//                //测试温度
//                List<LimsTestingStandCond> conds2 = typCondMap2.get(itm.getTypeId());
//
//                conds1.forEach(cond1 -> {
//                    conds2.forEach(cond2 -> {
 
                            LimsBatchDetail detail2 = new LimsBatchDetail();
                            detail2.setResultId(resultMap.get(typ.getId()));
                            detail2.setSampleId(sample.getId());
                            detail2.setItemId(itm.getId());
                            detail2.setCond("-");
                            detail2.setCond2("-");
                            detail2.setBatchId(limsTestingBatch.getId());
                            detail2.setDestroy(1);
                            detail2.setRemark(typ.getName()+"破坏性实验检测项");
                            detail2.setTid(typ.getId());
                            saveList.add(detail2);
                            //limsBatchDetailService.save(detail2);
 
                            LimsBatchDetail detail3 = new LimsBatchDetail();
                            detail3.setResultId(resultMap.get(typ.getId()));
                            detail3.setSampleId(sample.getId());
                            detail3.setItemId(itm.getId());
                            detail3.setCond("-");
                            detail3.setCond2("-");
                            detail3.setDestroy(2);
                            detail3.setRemark(typ.getName()+"破坏性实验检测项");
                            detail3.setBatchId(limsTestingBatch.getId());
                            detail3.setTid(typ.getId());
                            //limsBatchDetailService.save(detail3);
                            saveList.add(detail3);
                        });
 
//                    });
//                });
            });
 
 
        });
        limsBatchDetailService.saveBatch(saveList);
    }
 
    /**
     * 编辑
     *
     * @param limsTestingBatch
     * @return
     */
    @AutoLog(value = "lims_testing_batch-编辑")
    @ApiOperation(value = "lims_testing_batch-编辑", notes = "lims_testing_batch-编辑")
    @PutMapping(value = "/edit")
 
    public Result<?> edit(@RequestBody LimsTestingBatch limsTestingBatch) {
        limsTestingBatchService.updateById(limsTestingBatch);
        return Result.OK("编辑成功!");
    }
 
    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "lims_testing_batch-通过id删除")
    @ApiOperation(value = "lims_testing_batch-通过id删除", notes = "lims_testing_batch-通过id删除")
    @DeleteMapping(value = "/delete")
    @Transactional
    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
        limsTestingBatchService.removeById(id);
        //删除批次时还需删除批次下生成的数据
        //1.删除批次检验结果记录
        QueryWrapper<LimsBatchResult> resultQueryWrapper = new QueryWrapper<>();
        resultQueryWrapper.lambda().eq(LimsBatchResult::getBatchId, id);
        limsBatchResultService.remove(resultQueryWrapper);
        //2.删除批次检验结果记录明细
        QueryWrapper<LimsBatchDetail> detailQueryWrapper = new QueryWrapper<>();
        detailQueryWrapper.lambda().eq(LimsBatchDetail::getBatchId, id);
        limsBatchDetailService.remove(detailQueryWrapper);
        //3.删除批次下生成样本数据
        QueryWrapper<LimsBatchSample> sampleQueryWrapper = new QueryWrapper<>();
        sampleQueryWrapper.lambda().eq(LimsBatchSample::getBatchId, id);
        limsBatchSampleService.remove(sampleQueryWrapper);
        return Result.OK("删除成功!");
    }
 
    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "lims_testing_batch-批量删除")
    @ApiOperation(value = "lims_testing_batch-批量删除", notes = "lims_testing_batch-批量删除")
    @DeleteMapping(value = "/deleteBatch")
    @Transactional
    public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
        List<String> idList = Arrays.asList(ids.split(","));
        this.limsTestingBatchService.removeByIds(idList);
        //删除批次时还需删除批次下生成的数据
        //1.删除批次检验结果记录
        QueryWrapper<LimsBatchResult> resultQueryWrapper = new QueryWrapper<>();
        resultQueryWrapper.lambda().in(LimsBatchResult::getBatchId, idList);
        limsBatchResultService.remove(resultQueryWrapper);
        //2.删除批次检验结果记录明细
        QueryWrapper<LimsBatchDetail> detailQueryWrapper = new QueryWrapper<>();
        detailQueryWrapper.lambda().in(LimsBatchDetail::getBatchId, idList);
        limsBatchDetailService.remove(detailQueryWrapper);
        //3.删除批次下生成样本数据
        QueryWrapper<LimsBatchSample> sampleQueryWrapper = new QueryWrapper<>();
        sampleQueryWrapper.lambda().in(LimsBatchSample::getBatchId, idList);
        limsBatchSampleService.remove(sampleQueryWrapper);
        return Result.OK("批量删除成功!");
    }
 
    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    @AutoLog(value = "lims_testing_batch-通过id查询")
    @ApiOperation(value = "lims_testing_batch-通过id查询", notes = "lims_testing_batch-通过id查询")
    @GetMapping(value = "/queryById")
    public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
        LimsTestingBatch limsTestingBatch = limsTestingBatchService.getById(id);
        if (limsTestingBatch == null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(limsTestingBatch);
    }
 
    /**
     * 导出excel
     *
     * @param request
     * @param limsTestingBatch
     */
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, LimsTestingBatch limsTestingBatch) {
        return super.exportXls(request, limsTestingBatch, LimsTestingBatch.class, "lims_testing_batch");
    }
 
    /**
     * 通过excel导入数据
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, LimsTestingBatch.class);
    }
 
}