无关风月
2025-06-20 b6657187eec92ccd148fc3f4d1db97ec8849e240
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
package com.ruoyi.web.controller.api;
 
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.BaseModel;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.*;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TPedigreeChartConfirmQuery;
import com.ruoyi.system.query.TPedigreeChartDetailQuery;
import com.ruoyi.system.query.TPedigreeChartQuery;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.TPedigreeChartConfirmVO;
import com.ruoyi.system.vo.TPedigreeChartDetailVO;
import com.ruoyi.system.vo.TPedigreeChartVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.C;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 谱系图 前端控制器
 * </p>
 *
 * @author 无关风月
 * @since 2025-04-12
 */
@RestController
@RequestMapping("")
@Api(tags = "谱系图管理")
public class TPedigreeChartController {
    @Resource
    private TPedigreeChartDetailService pedigreeChartDetailService;
    @Resource
    private TPedigreeChartService pedigreeChartService;
    @Resource
    private TokenService tokenService;
 
 
 
 
 
    /**
     * 获取谱系图分页列表
     */
    //@PreAuthorize("@ss.hasPermi('system:pedigreeChart:list')")
    @ApiOperation(value = "谱系图-获取谱系图分页列表",response = TPedigreeChartQuery.class)
    @PostMapping(value = "/api/t-pedigree-chart/pageList")
    public R<PageInfo<TPedigreeChartVO>> pageList(@RequestBody String param) {
        TPedigreeChartQuery query = JSON.parseObject(param, TPedigreeChartQuery.class);
        return R.ok(pedigreeChartService.pageList(query));
    }
 
 
    /**
     * 谱系图-新增谱系图、新增谱系图
     */
    //@PreAuthorize("@ss.hasPermi('system:pedigreeChart:addProgenitor')")
    @Log(title = "谱系图-新增谱系图-新增谱系图", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增谱系图-新增谱系图",response = TPedigreeChartParentAllDTO.class)
    @PostMapping(value = "/api/t-pedigree-chart/addProgenitor")
    public R<Boolean> addProgenitorAll(@RequestBody String param) {
        LoginUser loginUser = tokenService.getLoginUser();
        if (loginUser==null){
            return R.fail("登录失效");
        }
        TPedigreeChartParentAllDTO dto = JSON.parseObject(param, TPedigreeChartParentAllDTO.class);
        TPedigreeChart parent = dto.getParent();
        if (!dto.getOne().isEmpty()){
            String one1Json = JSON.toJSONString(dto.getOne().get(0));
            parent.setJson(one1Json);
        }
        pedigreeChartService.save(parent);
        if (!dto.getOne().isEmpty()){
            TPedigreeChartParentOneDTO one = dto.getOne().get(0);
            one.setParentId("0");
            one.setType(1);
            one.setStatus(one.getStatus());
            one.setStorageTime(LocalDateTime.now());
            one.setPedigreeChartId(parent.getId());
            one.setVaccinateId(loginUser.getUserId()+"");
            one.setVaccinateSignature(one.getVaccinateSignature());
            one.setVaccinateTime(LocalDateTime.now());
            one.setId(null);
            pedigreeChartDetailService.save(one);
            List<TPedigreeChartParentOneCountDTO> countList = one.getChildren();
 
            if (!countList.isEmpty()){
                TPedigreeChartParentOneCountDTO count = countList.get(0);
                count.setParentId(one.getId());
                count.setType(2);
                    count.setStatus(1);
                count.setPedigreeChartId(parent.getId());
                count.setId(null);
 
                pedigreeChartDetailService.save(count);
                if (count.getChildren()!=null){
                    for (TPedigreeChartParentTwoDTO tPedigreeChartParentTwoDTO : count.getChildren()) {
                        tPedigreeChartParentTwoDTO.setParentId(one.getId());
                        tPedigreeChartParentTwoDTO.setPedigreeChartId(parent.getId());
                        tPedigreeChartParentTwoDTO.setType(1);
                        if (tPedigreeChartParentTwoDTO.getStatus()==null){
                            tPedigreeChartParentTwoDTO.setStatus(1);
                        }
                        tPedigreeChartParentTwoDTO.setVaccinateId(loginUser.getUserId()+"");
                        tPedigreeChartParentTwoDTO.setVaccinateSignature(tPedigreeChartParentTwoDTO.getVaccinateSignature());
                        tPedigreeChartParentTwoDTO.setVaccinateTime(LocalDateTime.now());
                        tPedigreeChartParentTwoDTO.setStorageTime(LocalDateTime.now());
                        tPedigreeChartParentTwoDTO.setParentId(count.getId());
                        tPedigreeChartParentTwoDTO.setPedigreeChartId(parent.getId());
                        tPedigreeChartParentTwoDTO.setId(null);
 
                        pedigreeChartDetailService.save(tPedigreeChartParentTwoDTO);
                        List<TPedigreeChartParentTwoCountDTO> count1List = tPedigreeChartParentTwoDTO.getChildren();
                        if (!count1List.isEmpty()){
                            // 传代数
                            TPedigreeChartParentTwoCountDTO count1 = count1List.get(0);
                            count1.setType(2);
                            count1.setParentId(tPedigreeChartParentTwoDTO.getId());
                            count1.setPedigreeChartId(parent.getId());
                            count1.setStatus(1);
                            count1.setId(null);
                            pedigreeChartDetailService.save(count1);
                            if (count1.getChildren()!=null){
                                for (TPedigreeChartParentThreeDTO tPedigreeChartParentThreeDTO : count1.getChildren()) {
                                    tPedigreeChartParentThreeDTO.setParentId(count1.getId());
                                    tPedigreeChartParentThreeDTO.setPedigreeChartId(parent.getId());
                                    tPedigreeChartParentThreeDTO.setType(1);
                                    if (tPedigreeChartParentThreeDTO.getStatus()==null){
                                        tPedigreeChartParentThreeDTO.setStatus(1);
                                    }
                                    tPedigreeChartParentTwoDTO.setVaccinateId(loginUser.getUserId()+"");
                                    tPedigreeChartParentTwoDTO.setVaccinateSignature(tPedigreeChartParentTwoDTO.getVaccinateSignature());
                                    tPedigreeChartParentTwoDTO.setVaccinateTime(LocalDateTime.now());
                                    tPedigreeChartParentThreeDTO.setStorageTime(LocalDateTime.now());
                                    tPedigreeChartParentThreeDTO.setPedigreeChartId(parent.getId());
                                    tPedigreeChartParentThreeDTO.setId(null);
                                    pedigreeChartDetailService.save(tPedigreeChartParentThreeDTO);
                                }
                            }
                        }
                    }
                }
            }
            String one1Json = JSON.toJSONString(one);
            parent.setJson(one1Json);
            pedigreeChartService.updateById(parent);
            // 新增消息
            TNotice tNotice = new TNotice();
            List<String> collect = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getUserId, tokenService.getLoginUser().getUserId())
                    .eq(TProjectTeamStaff::getRoleType, 2)
                    .list().stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList());
            if (!collect.isEmpty()){
                TProjectTeam team = projectTeamService.lambdaQuery().in(TProjectTeam::getId, collect)
                        .eq(TProjectTeam::getStatus, 1)
                        .orderByDesc(BaseModel::getCreateTime).last("limit 1").one();
                TProjectTeamStaff one1 = projectTeamStaffService.lambdaQuery()
                        .eq(TProjectTeamStaff::getTeamId, team.getId()).eq(TProjectTeamStaff::getRoleType, 2).one();
                tNotice.setCommitId(tokenService.getLoginUser().getUserId()+"");
                tNotice.setUserId(one1.getUserId());
                tNotice.setStatus(1);
                tNotice.setNoticeContent("菌种实验员新增【1】条【菌种传代生产谱系图】操作,等待您签字确认;");
                tNotice.setDataId(parent.getId());
                tNotice.setNoticeType(4);
                noticeService.save(tNotice);
            }
 
        }
        return R.ok();
    }
    @Resource
    private TProjectTeamService projectTeamService;
    @Resource
    private TProjectTeamStaffService projectTeamStaffService;
    @Resource
    private TNoticeService noticeService;
    /**
     */
    //@PreAuthorize("@ss.hasPermi('system:pedigreeChart:addProgenitor')")
    @Log(title = "谱系图-编辑谱系图-编辑谱系图", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "编辑谱系图-编辑谱系图",response = TPedigreeChartParentAllDTO.class)
    @PostMapping(value = "/api/t-pedigree-chart/editProgenitor")
    public R<Boolean> editProgenitor(@RequestBody String param) {
        LoginUser loginUser = tokenService.getLoginUser();
        if (loginUser==null){
            return R.fail("登录失效");
        }
        TPedigreeChartParentAllDTO dto = JSON.parseObject(param, TPedigreeChartParentAllDTO.class);
        TPedigreeChart parent = dto.getParent();
        if (!dto.getOne().isEmpty()){
            String one1Json = JSON.toJSONString(dto.getOne().get(0));
            parent.setJson(one1Json);
        }
        pedigreeChartService.updateById(parent);
//        pedigreeChartDetailService.remove(new LambdaQueryWrapper<TPedigreeChartDetail>()
//                .eq(TPedigreeChartDetail::getPedigreeChartId,  dto.getParent().getId()));
//        if (!dto.getOne().isEmpty()){
//            TPedigreeChartParentOneDTO one = dto.getOne().get(0);
//            one.setParentId("0");
//            one.setType(1);
//            one.setStatus(1);
//            one.setPedigreeChartId(parent.getId());
//            pedigreeChartDetailService.save(one);
//            List<TPedigreeChartParentOneCountDTO> countList = one.getChildren();
//            if (!countList.isEmpty()){
//                TPedigreeChartParentOneCountDTO count = countList.get(0);
//                count.setParentId(one.getId());
//                count.setType(2);
//                count.setStatus(1);
//                count.setPedigreeChartId(parent.getId());
//                pedigreeChartDetailService.save(count);
//                if (count.getChildren()!=null){
//                    for (TPedigreeChartParentTwoDTO tPedigreeChartParentTwoDTO : count.getChildren()) {
//                        tPedigreeChartParentTwoDTO.setParentId(one.getId());
//                        tPedigreeChartParentTwoDTO.setPedigreeChartId(parent.getId());
//                        tPedigreeChartParentTwoDTO.setType(1);
//                        tPedigreeChartParentTwoDTO.setStatus(1);
//                        tPedigreeChartParentTwoDTO.setParentId(count.getId());
//                        tPedigreeChartParentTwoDTO.setPedigreeChartId(parent.getId());
//                        pedigreeChartDetailService.save(tPedigreeChartParentTwoDTO);
//                        List<TPedigreeChartParentTwoCountDTO> count1List = tPedigreeChartParentTwoDTO.getChildren();
//                        if (!count1List.isEmpty()){
//                            TPedigreeChartParentTwoCountDTO count1 = count1List.get(0);
//                            count1.setType(2);
//                            count1.setParentId(tPedigreeChartParentTwoDTO.getId());
//                            count1.setPedigreeChartId(parent.getId());
//                            count1.setStatus(1);
//                            pedigreeChartDetailService.save(count1);
//                            if (count1.getChildren()!=null){
//                                for (TPedigreeChartParentThreeDTO tPedigreeChartParentThreeDTO : count1.getChildren()) {
//                                    tPedigreeChartParentThreeDTO.setParentId(count1.getId());
//                                    tPedigreeChartParentThreeDTO.setPedigreeChartId(parent.getId());
//                                    tPedigreeChartParentThreeDTO.setType(1);
//                                    tPedigreeChartParentThreeDTO.setStatus(1);
//                                    tPedigreeChartParentThreeDTO.setParentId(tPedigreeChartParentTwoDTO.getId());
//                                    tPedigreeChartParentThreeDTO.setPedigreeChartId(parent.getId());
//                                    pedigreeChartDetailService.save(tPedigreeChartParentThreeDTO);
//                                }
//                            }
//                        }
//                    }
//                }
//
//            }
 
//        }
        return R.ok();
    }
    @Log(title = "谱系图-谱系图-删除谱系图", businessType = BusinessType.DELETE)
    @ApiOperation(value = "谱系图-删除谱系图")
    @DeleteMapping(value = "/open/t-pedigree-chart/deleteProgenitor")
    public R<Boolean> deleteProgenitor(@RequestParam String id) {
        pedigreeChartService.removeById(id);
        return R.ok();
    }
    @Log(title = "谱系图-谱系图-删除菌种传代项", businessType = BusinessType.DELETE)
    @ApiOperation(value = "谱系图-删除菌种传代项",response = TPedigreeChartParentDTO.class)
    @DeleteMapping(value = "/open/t-pedigree-chart/deleteProgenitorChild")
    public R<Boolean> deleteProgenitorChild(@RequestParam String id) {
         pedigreeChartDetailService.removeById(id);
        return R.ok();
    }
    @Log(title = "谱系图-谱系图-编辑菌种传代/传代数项", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "谱系图-编辑菌种传代/传代数项",response = TPedigreeChartParentDTO.class)
    @PostMapping(value = "/api/t-pedigree-chart/updateChild")
    public R<Boolean> updateChild(@RequestBody String param) {
        TPedigreeChartDetailUpdateDTO dto = JSON.parseObject(param, TPedigreeChartDetailUpdateDTO.class);
        pedigreeChartDetailService.updateById(dto);
        return R.ok();
    }
 
 
 
    /**
     * 谱系图-祖代新增菌种传代项
     */
    //@PreAuthorize("@ss.hasPermi('system:pedigreeChart:addChild')")
    @Log(title = "谱系图-祖代/母代新增菌种传代项", businessType = BusinessType.INSERT)
    @ApiOperation(value = "祖代/母代新增菌种传代项",response = TPedigreeChartDetailDTO.class)
    @PostMapping(value = "/api/t-pedigree-chart/addProgenitorChild")
    public R<Boolean> addProgenitorChild(@RequestBody String param) {
        LoginUser loginUser = tokenService.getLoginUser();
        if (loginUser==null){
            return R.fail("登录失效");
        }
        TPedigreeChartDetailDTO dto = JSON.parseObject(param, TPedigreeChartDetailDTO.class);
        if (dto.getParentId().equals("0")){
            // 新增祖代
            dto.setParentId("0");
            pedigreeChartDetailService.save(dto);
        }else{
            String parentId = dto.getParentId();
            TPedigreeChartDetail parent = pedigreeChartDetailService.getById(parentId);
            Long count = pedigreeChartDetailService.lambdaQuery().eq(TPedigreeChartDetail::getParentId, parentId).count();
            if (count>=parent.getGenerationCount()){
                return R.fail("该谱系图已满");
            }
            String pedigreeChartId = pedigreeChartDetailService.getById(parentId).getPedigreeChartId();
            TPedigreeChart pedigreeChart = pedigreeChartService.getById(pedigreeChartId);
            TPedigreeChartDetail tPedigreeChartDetail = new TPedigreeChartDetail();
            BeanUtils.copyProperties(dto,tPedigreeChartDetail);
            tPedigreeChartDetail.setStrainSource(dto.getStrainSource());
            tPedigreeChartDetail.setParentId(parentId);
            tPedigreeChartDetail.setPedigreeChartId(pedigreeChartId);
            tPedigreeChartDetail.setStatus(dto.getStatus());
            tPedigreeChartDetail.setStorageTime(LocalDateTime.now());
            tPedigreeChartDetail.setRemark(dto.getRemark());
            tPedigreeChartDetail.setType(1);
            tPedigreeChartDetail.setPedigreeChartId(pedigreeChart.getId());
            tPedigreeChartDetail.setVaccinateId(loginUser.getUserId()+"");
            tPedigreeChartDetail.setVaccinateTime(LocalDateTime.now());
            if (dto.getStatus()  ==2){
                tPedigreeChartDetail.setDiscardTime(LocalDateTime.now());
            }
            tPedigreeChartDetail.setVaccinateSignature(dto.getVaccinateSignature());
            pedigreeChartDetailService.save(tPedigreeChartDetail);
        }
 
        return R.ok();
    }
 
    /**
     * 获取谱系图详情待入库菌种分页列表
     */
    @ApiOperation(value = "谱系图-获取谱系图详情待入库菌种分页列表",response = TPedigreeChartDetailQuery.class)
    @PostMapping(value = "/api/t-pedigree-chart/pageListDetail")
    public R<PageInfo<TPedigreeChartDetailVO>> pageListDetail(@RequestBody String param) {
        TPedigreeChartDetailQuery query = JSON.parseObject(param, TPedigreeChartDetailQuery.class);
        return R.ok(pedigreeChartService.pageListDetail(query));
    }
    /**
     * 谱系图-菌种传代生产谱系图详情
     */
    //@PreAuthorize("@ss.hasPermi('system:pedigreeChart:detailInfo')")
    @ApiOperation(value = "谱系图-谱系图详情")
    @GetMapping(value = "/open/t-pedigree-chart/getDetailInfoById")
    public R<TPedigreeChart> getDetailInfoById(@RequestParam String id) {
        List<TPedigreeChartParentOneDTO> tPedigreeChartParentOneDTOS = new ArrayList<>();
        TPedigreeChart pedigreeChart = pedigreeChartService.getById(id);
        List<TPedigreeChartDetail> details = pedigreeChartDetailService.lambdaQuery().eq(TPedigreeChartDetail::getPedigreeChartId, id).list();
        TPedigreeChartParentAllDetailDTO tPedigreeChartParentAllDetailDTO = new TPedigreeChartParentAllDetailDTO();
        // 祖代
        TPedigreeChartDetail pedigreeChartDetail = details.stream().filter(e -> e.getParentId().equals("0")
        && e.getType()==1).findFirst().orElse(null);
        if (pedigreeChartDetail!=null){
            // 祖代/母代
            TPedigreeChartParentOneDTO tPedigreeChartParentOneDTO = new TPedigreeChartParentOneDTO();
            BeanUtils.copyProperties(pedigreeChartDetail,tPedigreeChartParentOneDTO);
            TPedigreeChartDetail pedigreeChartDetail1 = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentOneDTO.getId())
                    && e.getType() == 2).findFirst().orElse(null);
            // 传代计划数
            if (pedigreeChartDetail1!=null){
                TPedigreeChartParentOneCountDTO tPedigreeChartParentOneCountDTO = new TPedigreeChartParentOneCountDTO();
                List<TPedigreeChartParentOneCountDTO> tPedigreeChartParentOneCountDTOS = new ArrayList<>();
 
                BeanUtils.copyProperties(pedigreeChartDetail1,tPedigreeChartParentOneCountDTO);
                tPedigreeChartParentOneCountDTO.setParent(pedigreeChartDetail);
                // 祖代母代传代数
                List<TPedigreeChartDetail> collect = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentOneCountDTO.getId())
                        && e.getType() == 1).collect(Collectors.toList());
                List<TPedigreeChartParentTwoDTO> tPedigreeChartParentTwoDTOS = new ArrayList<>();
                List<TPedigreeChartParentThreeDTO> tPedigreeChartParentThreeDTOS = new ArrayList<>();
                for (TPedigreeChartDetail tPedigreeChartDetail : collect) {
                    TPedigreeChartParentTwoDTO tPedigreeChartParentTwoDTO = new TPedigreeChartParentTwoDTO();
                    BeanUtils.copyProperties(tPedigreeChartDetail,tPedigreeChartParentTwoDTO);
                    tPedigreeChartParentTwoDTO.setParent(pedigreeChartDetail1);
                    TPedigreeChartDetail pedigreeChartDetail2 = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentTwoDTO.getId())
                            && e.getType() == 2).findFirst().orElse(null);
                    if (pedigreeChartDetail2!=null){
                        ArrayList<TPedigreeChartParentTwoCountDTO> tPedigreeChartParentTwoCountDTOS = new ArrayList<>();
                        TPedigreeChartParentTwoCountDTO tPedigreeChartParentTwoCountDTO = new TPedigreeChartParentTwoCountDTO();
                        BeanUtils.copyProperties(pedigreeChartDetail2,tPedigreeChartParentTwoCountDTO);
                        List<TPedigreeChartDetail> collect1 = details.stream().filter(e -> e.getParentId().equals(tPedigreeChartParentTwoCountDTO.getId())
                                && e.getType() == 1).collect(Collectors.toList());
                        for (TPedigreeChartDetail chartDetail : collect1) {
                            TPedigreeChartParentThreeDTO tPedigreeChartParentThreeDTO = new TPedigreeChartParentThreeDTO();
                            BeanUtils.copyProperties(chartDetail,tPedigreeChartParentThreeDTO);
                            tPedigreeChartParentThreeDTO.setParent(pedigreeChartDetail2);
                            tPedigreeChartParentThreeDTOS.add(tPedigreeChartParentThreeDTO);
                        }
                        tPedigreeChartParentTwoCountDTO.setChildren(tPedigreeChartParentThreeDTOS);
                        tPedigreeChartParentTwoCountDTOS.add(tPedigreeChartParentTwoCountDTO);
                        tPedigreeChartParentTwoDTO.setChildren(tPedigreeChartParentTwoCountDTOS);
                    }
                    tPedigreeChartParentTwoDTOS.add(tPedigreeChartParentTwoDTO);
                }
                tPedigreeChartParentOneCountDTO.setChildren(tPedigreeChartParentTwoDTOS);
                tPedigreeChartParentOneCountDTOS.add(tPedigreeChartParentOneCountDTO);
                tPedigreeChartParentOneDTO.setChildren(tPedigreeChartParentOneCountDTOS);
            }
            tPedigreeChartParentOneDTOS.add(tPedigreeChartParentOneDTO);
            tPedigreeChartParentAllDetailDTO.setOne(tPedigreeChartParentOneDTOS);
        }
        pedigreeChart.setPedigreeChartParentAllDetailDTO(tPedigreeChartParentAllDetailDTO);
        return R.ok(pedigreeChart);
    }
    /**
     * 谱系图-菌种传代生产谱系图详情-菌种详情
     */
    //@PreAuthorize("@ss.hasPermi('system:pedigreeChart:strainInfo')")
    @ApiOperation(value = "谱系图-菌种传代生产谱系图详情-菌种详情")
    @GetMapping(value = "/api/t-pedigree-chart/strainInfo")
    public R strainInfo(@RequestParam String id) {
        TPedigreeChartDetail tPedigreeChartDetail = pedigreeChartDetailService.getById(id);
        if (!tPedigreeChartDetail.getParentId().equals("0")){
            TPedigreeChartDetail tPedigreeChartDetail1 = pedigreeChartDetailService.getById(tPedigreeChartDetail.getParentId());
            tPedigreeChartDetail.setParent(tPedigreeChartDetail1);
        }
        return R.ok(tPedigreeChartDetail);
    }
    /**
     * 谱系图-设置传代数
     */
    //@PreAuthorize("@ss.hasPermi('system:pedigreeChart:updateCount')")
    @ApiOperation(value = "谱系图-设置传代数",response = TPedigreeChartDetailCountDTO.class)
    @PostMapping(value = "/api/t-pedigree-chart/updateCount")
    public R<Boolean> updateCount(@RequestBody String param) {
        TPedigreeChartDetailCountDTO dto = JSON.parseObject(param, TPedigreeChartDetailCountDTO.class);
        TPedigreeChartDetail pedigreeChartDetail1 = new TPedigreeChartDetail();
        pedigreeChartDetail1.setParentId(dto.getParentId());
        pedigreeChartDetail1.setVaccinateId(tokenService.getLoginUser().getUserId()+"");
        pedigreeChartDetail1.setVaccinateTime(LocalDateTime.now());
        pedigreeChartDetail1.setVaccinateSignature(dto.getVaccinateSignature());
        TPedigreeChartDetail byId = pedigreeChartDetailService.getById(dto.getParentId());
        pedigreeChartDetail1.setGenerationCount(dto.getGenerationCount());
        pedigreeChartDetail1.setPedigreeChartId(byId.getPedigreeChartId());
        pedigreeChartDetail1.setType(2);
        pedigreeChartDetailService.save(pedigreeChartDetail1);
        return R.ok();
    }
 
    /**
     * 谱系图-菌种工程师确认入库
     */
    //@PreAuthorize("@ss.hasPermi('system:pedigreeChart:confirm')")
    @ApiOperation(value = "谱系图-菌种工程师确认入库",response = TTrainLibraryDetailConfirmDto.class)
    @Log(title = "谱系图-菌种工程师确认入库", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/api/t-pedigree-chart/confirm")
    public R<Boolean> confirm(@RequestBody String param) {
        if (tokenService.getLoginUser()==null){
            return R.fail("登录失效");
        }
        TTrainLibraryDetailConfirmDto dto = JSON.parseObject(param, TTrainLibraryDetailConfirmDto.class);
        TPedigreeChartDetail pedigreeChartDetail = pedigreeChartDetailService.getById(dto.getId());
        pedigreeChartDetail.setPreserveId(String.valueOf(tokenService.getLoginUser().getUserId()));
        pedigreeChartDetail.setPreserveSignature(dto.getPreserveSignature());
        pedigreeChartDetail.setConfirmTime(LocalDateTime.now());
        pedigreeChartDetailService.updateById(pedigreeChartDetail);
        return R.ok();
    }
    /**
     * 谱系图-代确认入库菌种列表
     */
    //@PreAuthorize("@ss.hasPermi('system:pedigreeChart:listConfirm')")
//    @ApiOperation(value = "谱系图-代确认入库菌种列表",response = TPedigreeChartConfirmQuery.class)
//    @GetMapping(value = "/api/t-pedigree-chart/listConfirm")
//    public R<PageInfo<TPedigreeChartConfirmVO>> listConfirm(@RequestBody String param) {
//        TPedigreeChartConfirmQuery query = JSON.parseObject(param, TPedigreeChartConfirmQuery.class);
//        return R.ok(pedigreeChartService.listConfirm(query));
//    }
}