puzhibing
6 天以前 082bddee7df8a05ca95f473ec2643701d41a5213
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
package com.ruoyi.web.controller.api;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.domain.BaseModel;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.system.dto.TConfirmBreedingAndPreservationDTO;
import com.ruoyi.system.mapper.TProjectTeamMapper;
import com.ruoyi.system.model.*;
 
import java.util.ArrayList;
import java.util.List;
 
 
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.TBreedingAndPreservationDTO;
import com.ruoyi.system.dto.TTrainLibraryDTO;
import com.ruoyi.system.query.TBreedingAndPreservationQuery;
import com.ruoyi.system.query.TPedigreeChartConfirmQuery;
import com.ruoyi.system.query.TPedigreeChartQuery;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.TBreedingAndPreservationDetailVO;
import com.ruoyi.system.vo.TBreedingAndPreservationVO;
import com.ruoyi.system.vo.TPedigreeChartVO;
import com.ruoyi.system.vo.TProjectTeamVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Random;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 菌种选育保藏记录 前端控制器
 * </p>
 *
 * @author 无关风月
 * @since 2025-04-12
 */
@RestController
@RequestMapping("")
@Api(tags = "菌种选育保藏记录")
public class TBreedingAndPreservationController {
    @Resource
    private TBreedingAndPreservationService breedingAndPreservationService;
    @Resource
    private TCulturePreservationService culturePreservationService;
    @Resource
    private TObservationOfPetriDishesService observationOfPetriDishesService;
    @Resource
    private TVaccinationSlopeService vaccinationSlopeService;
    @Resource
    private TSeparationOfCultureDishesService separationOfCultureDishesService;
    @Resource
    private TokenService tokenService;
    @Resource
    private ISysUserService sysUserService;
 
    /**
     * 菌种选育保藏记录分页列表
     */
    //@PreAuthorize("@ss.hasPermi('system:breedingAndPreservation:list')")
    @ApiOperation(value = "菌种选育保藏记录-获取菌种选育保藏记录分页列表",response = TBreedingAndPreservationQuery.class)
    @PostMapping(value = "/api/t-breeding-and-preservation/pageList")
    public R<PageInfo<TBreedingAndPreservationVO>> pageList(@RequestBody String param) {
 
        TBreedingAndPreservationQuery query = JSON.parseObject(param, TBreedingAndPreservationQuery.class);
        SysUser sysUser = sysUserService.selectUserById(tokenService.getLoginUser().getUserId());
        if (sysUser.getRoleType().equals("2")){
            List<String> allProjectIds = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getUserId, tokenService.getLoginUser().getUserId())
                    .list().stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList());
            if (!allProjectIds.isEmpty()){                List<String> projectIds = projectTeamService.lambdaQuery().in(TProjectTeam::getId, allProjectIds)
                    .list().stream().map(TProjectTeam::getId).collect(Collectors.toList());
 
                if (projectIds.isEmpty()){
                    return R.ok(new PageInfo<>());
                }
                query.setProjectIds(projectIds);
            }else {
                return R.ok(new PageInfo<>());
            }
        }else if (!sysUser.getRoleType().equals("1")){
            if (query.getProjectIds() == null || query.getProjectIds().isEmpty()){
                List<String> allProjectIds = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getUserId, tokenService.getLoginUser().getUserId())
                        .list().stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList());
                if (!allProjectIds.isEmpty()){
                    List<String> projectIds = projectTeamService.lambdaQuery().in(TProjectTeam::getId, allProjectIds)
                            .eq(TProjectTeam::getStatus, 1).list().stream().map(TProjectTeam::getId).collect(Collectors.toList());
 
                    if (projectIds.isEmpty()){
                        return R.ok(new PageInfo<>());
                    }
                    query.setProjectIds(projectIds);
                }else {
                    return R.ok(new PageInfo<>());
                }
            }
        }
 
        return R.ok(breedingAndPreservationService.pageList(query));
    }
    /**
     * 新增菌种库
     */
    //@PreAuthorize("@ss.hasPermi('system:breedingAndPreservation:add')")
    @Log(title = "菌种选育保藏记录-新增选育保藏记录", businessType = BusinessType.INSERT)
    @ApiOperation(value = "菌种选育保藏记录-新增选育保藏记录",response = TBreedingAndPreservationDTO.class)
    @PostMapping(value = "/api/t-breeding-and-preservation/add")
    public R<Boolean> add(@RequestBody String param) {
        if (tokenService.getLoginUser()==null){
            return R.fail(401,"登陆失效");
        }
        TBreedingAndPreservationDTO dto = JSON.parseObject(param,TBreedingAndPreservationDTO.class);
        if (dto.getStatus()==1){
            return R.fail("有菌种待确认,无法提交");
        }
 
        if (dto.getStatus()==3){
            dto.setIsDraft(1);
        }
        List<String> projectIds = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getUserId, tokenService.getLoginUser().getUserId())
                .list().stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList());
        if (!projectIds.isEmpty()){
            TProjectTeam projectTeam = projectTeamService.lambdaQuery().in(TProjectTeam::getId, projectIds)
                    .eq(TProjectTeam::getStatus, 1)
                    .orderByDesc(BaseModel::getCreateTime)
                    .last("limit 1").one();
            dto.setProjectId(projectTeam.getId());
        }
        breedingAndPreservationService.save(dto);
        List<TSeparationOfCultureDishes> separationOfCultureDishesList = dto.getSeparationOfCultureDishesList();
        for (TSeparationOfCultureDishes tSeparationOfCultureDishes : separationOfCultureDishesList) {
            tSeparationOfCultureDishes.setBreedingPreserveId(dto.getId());
        }
        separationOfCultureDishesService.saveBatch(separationOfCultureDishesList);
        List<TObservationOfPetriDishes> observationOfPetriDishes = dto.getObservationOfPetriDishes();
        for (TObservationOfPetriDishes tSeparationOfCultureDishes : observationOfPetriDishes) {
            tSeparationOfCultureDishes.setBreedingPreserveId(dto.getId());
        }
        observationOfPetriDishesService.saveBatch(observationOfPetriDishes);
        List<TVaccinationSlope> vaccinationSlopes = dto.getVaccinationSlopes();
        for (TVaccinationSlope tSeparationOfCultureDishes : vaccinationSlopes) {
            tSeparationOfCultureDishes.setHandleId(tokenService.getLoginUser().getUserId()+"");
            tSeparationOfCultureDishes.setHandleTime(LocalDateTime.now());
            tSeparationOfCultureDishes.setBreedingPreserveId(dto.getId());
        }
        vaccinationSlopeService.saveBatch(vaccinationSlopes);
        List<TCulturePreservation> culturePreservations = dto.getCulturePreservations();
        for (TCulturePreservation tSeparationOfCultureDishes : culturePreservations) {
            tSeparationOfCultureDishes.setHandleId(tokenService.getLoginUser().getUserId()+"");
            tSeparationOfCultureDishes.setHandleTime(LocalDateTime.now());
            tSeparationOfCultureDishes.setBreedingPreserveId(dto.getId());
        }
        culturePreservationService.saveBatch(culturePreservations);
        if (dto.getStatus()!=null&&dto.getStatus()==2){
            notifyProjectEngineers(dto.getProjectId(), dto.getId(), 5);
        }
        return R.ok();
    }
    @Resource
    private TProjectTeamService projectTeamService;
    @Resource
    private TProjectTeamStaffService projectTeamStaffService;
    @Resource
    private TNoticeService noticeService;
    @Log(title = "菌种选育保藏记录-编辑选育保藏记录", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "菌种选育保藏记录-编辑选育保藏记录",response = TBreedingAndPreservationDTO.class)
    @PostMapping(value = "/api/t-breeding-and-preservation/update")
    public R<Boolean> update(@RequestBody String param) {
        if (tokenService.getLoginUser()==null){
            return R.fail(401,"登陆失效");
        }
        TBreedingAndPreservationDTO dto = JSON.parseObject(param,TBreedingAndPreservationDTO.class);
        if (dto.getStatus()==3){
            dto.setIsDraft(1);
        }else{
            dto.setIsDraft(0);
        }
        TBreedingAndPreservation breedingAndPreservationServiceById = breedingAndPreservationService.getById(dto.getId());
        if (breedingAndPreservationServiceById == null) {
            return R.fail("记录不存在");
        }
        if (breedingAndPreservationServiceById.getStatus()==1){
            return R.fail("该记录已提交,不可编辑!");
        }
        SysUser currentUser = sysUserService.selectUserById(tokenService.getLoginUser().getUserId());
        if ("3".equals(currentUser.getRoleType())) {
            return R.fail("菌种工程师只能进行入库确认,不能编辑记录");
        }
        List<TVaccinationSlope> vaccinationSlopes = dto.getVaccinationSlopes();
        List<TCulturePreservation> culturePreservations = dto.getCulturePreservations();
        if (vaccinationSlopes == null || culturePreservations == null) {
            return R.fail("接种斜面记录和菌种保藏记录不能为空");
        }
        if (dto.getStatus() != null && dto.getStatus() == 1) {
            if (breedingAndPreservationServiceById.getStatus() == null
                    || breedingAndPreservationServiceById.getStatus() != 2) {
                return R.fail("请先同步给保藏人并完成入库确认");
            }
            boolean slopeUnconfirmed = vaccinationSlopes.stream().anyMatch(item ->
                    !StringUtils.hasLength(item.getPreserveId()) || !StringUtils.hasLength(item.getPreserveSignature()));
            boolean preservationUnconfirmed = culturePreservations.stream().anyMatch(item ->
                    !StringUtils.hasLength(item.getPreserveId()) || !StringUtils.hasLength(item.getPreserveSignature()));
            if (slopeUnconfirmed || preservationUnconfirmed) {
                return R.fail("存在未确认的接种斜面或菌种保藏记录,不能提交");
            }
        }
        breedingAndPreservationService.updateById(dto);
        List<TSeparationOfCultureDishes> separationOfCultureDishesList = dto.getSeparationOfCultureDishesList();
        for (TSeparationOfCultureDishes tSeparationOfCultureDishes : separationOfCultureDishesList) {
            tSeparationOfCultureDishes.setBreedingPreserveId(dto.getId());
        }
        separationOfCultureDishesService.remove(new LambdaQueryWrapper<TSeparationOfCultureDishes>().eq(TSeparationOfCultureDishes::getBreedingPreserveId, dto.getId()));
        separationOfCultureDishesService.saveBatch(separationOfCultureDishesList);
        List<TObservationOfPetriDishes> observationOfPetriDishes = dto.getObservationOfPetriDishes();
        for (TObservationOfPetriDishes observationOfPetriDish : observationOfPetriDishes) {
            observationOfPetriDish.setBreedingPreserveId(dto.getId());
        }
        observationOfPetriDishesService.remove(new LambdaQueryWrapper<TObservationOfPetriDishes>().eq(TObservationOfPetriDishes::getBreedingPreserveId, dto.getId()));
        observationOfPetriDishesService.saveBatch(observationOfPetriDishes);
        for (TVaccinationSlope vaccinationSlope : vaccinationSlopes) {
            vaccinationSlope.setBreedingPreserveId(dto.getId());
        }
        vaccinationSlopeService.remove(new LambdaQueryWrapper<TVaccinationSlope>().eq(TVaccinationSlope::getBreedingPreserveId, dto.getId()));
        vaccinationSlopeService.saveBatch(vaccinationSlopes);
        for (TCulturePreservation tSeparationOfCultureDishes : culturePreservations) {
 
            tSeparationOfCultureDishes.setBreedingPreserveId(dto.getId());
        }
        culturePreservationService.remove(new LambdaQueryWrapper<TCulturePreservation>().eq(TCulturePreservation::getBreedingPreserveId, dto.getId()));
        for (TCulturePreservation culturePreservation : culturePreservations) {
            culturePreservation.setBreedingPreserveId(dto.getId());
        }
        culturePreservationService.saveBatch(culturePreservations);
        if (dto.getStatus()==2){
            notifyProjectEngineers(dto.getProjectId(), dto.getId(), 6);
        }
        return R.ok();
    }
 
    private void notifyProjectEngineers(String projectId, String dataId, int noticeType) {
        List<TProjectTeamStaff> engineers = projectTeamStaffService.lambdaQuery()
                .eq(TProjectTeamStaff::getTeamId, projectId)
                .eq(TProjectTeamStaff::getRoleType, 3)
                .list();
        for (TProjectTeamStaff engineer : engineers) {
            TNotice notice = new TNotice();
            notice.setUserId(engineer.getUserId());
            notice.setCommitId(tokenService.getLoginUser().getUserId() + "");
            notice.setStatus(1);
            notice.setNoticeContent("您有【1】条【菌种选育保藏记录】等待签字入库确认;");
            notice.setDataId(dataId);
            notice.setNoticeType(noticeType);
            noticeService.save(notice);
        }
    }
 
    @Log(title = "接种斜面记录确认入库", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "接种斜面记录确认入库",response = TConfirmBreedingAndPreservationDTO.class)
    @PostMapping(value = "/api/t-breeding-and-preservation/vaccinationSlopesConfirm")
    public R<Boolean> vaccinationSlopesConfirm(@RequestBody String param) {
        if (tokenService.getLoginUser() == null) {
            return R.fail(401, "登陆失效");
        }
        Long userId = tokenService.getLoginUser().getUserId();
 
        TConfirmBreedingAndPreservationDTO dto = JSON.parseObject(param,TConfirmBreedingAndPreservationDTO.class);
        TVaccinationSlope vaccinationSlope = vaccinationSlopeService.getById(dto.getId());
        if (vaccinationSlope == null) {
            return R.fail("接种斜面记录不存在");
        }
        R<Boolean> validation = validatePreservationConfirmation(vaccinationSlope.getBreedingPreserveId(), userId,
                vaccinationSlope.getPreserveSignature());
        if (validation != null) {
            return validation;
        }
        vaccinationSlope.setPreserveId(userId+"");
        vaccinationSlope.setPreserveTime(LocalDateTime.now());
        vaccinationSlope.setPreserveSignature(dto.getPreserveSignature());
        vaccinationSlopeService.updateById(vaccinationSlope);
        return R.ok();
    }
    @Log(title = "菌种保藏记录确认入库", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "菌种保藏记录确认入库",response = TConfirmBreedingAndPreservationDTO.class)
    @PostMapping(value = "/api/t-breeding-and-preservation/culturePreservationsConfirm")
    public R<Boolean> culturePreservationsConfirm(@RequestBody String param) {
        if (tokenService.getLoginUser() == null) {
            return R.fail(401, "登陆失效");
        }
        Long userId = tokenService.getLoginUser().getUserId();
        TConfirmBreedingAndPreservationDTO dto = JSON.parseObject(param,TConfirmBreedingAndPreservationDTO.class);
        TCulturePreservation culturePreservation = culturePreservationService.getById(dto.getId());
        if (culturePreservation == null) {
            return R.fail("菌种保藏记录不存在");
        }
        R<Boolean> validation = validatePreservationConfirmation(culturePreservation.getBreedingPreserveId(), userId,
                culturePreservation.getPreserveSignature());
        if (validation != null) {
            return validation;
        }
        culturePreservation.setPreserveId(userId+"");
        culturePreservation.setPreserveTime(LocalDateTime.now());
        culturePreservation.setPreserveSignature(dto.getPreserveSignature());
        culturePreservationService.updateById(culturePreservation);
        return R.ok();
    }
 
    @Resource
    private TProjectTeamMapper tProjectTeamMapper;
 
    private R<Boolean> validatePreservationConfirmation(String breedingPreserveId, Long userId,
                                                        String existingSignature) {
        if (StringUtils.hasLength(existingSignature)) {
            return R.fail("该记录已经确认,不能重复签字");
        }
        TBreedingAndPreservation record = breedingAndPreservationService.getById(breedingPreserveId);
        if (record == null || record.getStatus() == null || record.getStatus() != 2) {
            return R.fail("仅已同步且未提交的记录可以确认入库");
        }
        boolean isProjectEngineer = projectTeamStaffService.lambdaQuery()
                .eq(TProjectTeamStaff::getTeamId, record.getProjectId())
                .eq(TProjectTeamStaff::getUserId, userId)
                .count() > 0;
 
        SysUser sysUser = sysUserService.selectUserById(userId);
 
        if (isProjectEngineer) {
            if (!sysUser.getRoleType().equals("3")) {
                return R.fail("仅当前项目的菌种工程师可以确认入库");
            }
        }
        return null;
    }
 
    //@PreAuthorize("@ss.hasPermi('system:breedingAndPreservation:detail')")
    @ApiOperation(value = "选育保藏记录详情")
    @GetMapping(value = "/open/t-breeding-and-preservation/getDetailById")
    public R<TBreedingAndPreservationDetailVO> getDetailById(@RequestParam String id) {
        if (!StringUtils.hasText(id)) {
            return R.fail("记录ID不能为空");
        }
        TBreedingAndPreservation breedingAndPreservation = breedingAndPreservationService.getById(id);
        if (breedingAndPreservation == null) {
            return R.fail("菌种选育保藏记录不存在或已删除");
        }
        List<SysUser> sysUsers = sysUserService.selectAllList();
        TBreedingAndPreservationDetailVO res = new TBreedingAndPreservationDetailVO();
        BeanUtils.copyProperties(breedingAndPreservation, res);
        List<TSeparationOfCultureDishes> separationOfCultureDishesList = separationOfCultureDishesService.lambdaQuery().eq(TSeparationOfCultureDishes::getBreedingPreserveId, id).list();
        List<TObservationOfPetriDishes> observationOfPetriDishes = observationOfPetriDishesService.lambdaQuery().eq(TObservationOfPetriDishes::getBreedingPreserveId, id).list();
        List<TVaccinationSlope> vaccinationSlopes = vaccinationSlopeService.lambdaQuery().eq(TVaccinationSlope::getBreedingPreserveId, id).list();
        List<TCulturePreservation> culturePreservations = culturePreservationService.lambdaQuery().eq(TCulturePreservation::getBreedingPreserveId, id).list();
        for (TCulturePreservation culturePreservation : culturePreservations) {
            SysUser sysUser = findUserById(sysUsers, culturePreservation.getHandleId());
            if (sysUser!=null){
                culturePreservation.setHandleName(sysUser.getNickName());
            }
        }
        for (TVaccinationSlope vaccinationSlope : vaccinationSlopes) {
            SysUser sysUser = findUserById(sysUsers, vaccinationSlope.getHandleId());
            if (sysUser!=null){
                vaccinationSlope.setHandleName(sysUser.getNickName());
            }
        }
 
        if (com.ruoyi.common.utils.StringUtils.isNotEmpty(breedingAndPreservation.getProjectId())) {
            TProjectTeam tProjectTeam = tProjectTeamMapper.selectById(breedingAndPreservation.getProjectId());
            if (tProjectTeam != null) {
                List<TProjectTeamStaff> list = projectTeamStaffService.lambdaQuery().eq(TProjectTeamStaff::getTeamId, tProjectTeam.getId()).list();
                StringBuilder staffNames = new StringBuilder();
                for (TProjectTeamStaff tProjectTeamStaff : list) {
                    SysUser sysUser = sysUserService.selectUserById(Long.valueOf(tProjectTeamStaff.getUserId()));
                    if (sysUser!=null){
                        staffNames.append(sysUser.getNickName()).append(",");
                    }
                }
                if (StringUtils.hasLength(staffNames.toString())){
                    tProjectTeam.setStaff(staffNames.substring(0, staffNames.toString().length() - 1));
                }
 
                List<TProjectTeam> tProjectTeamList = new ArrayList<>();
                tProjectTeamList.add(tProjectTeam);
                res.setTProjectTeamList(tProjectTeamList);
            }
        }
 
        res.setSeparationOfCultureDishesList(separationOfCultureDishesList);
        res.setObservationOfPetriDishes(observationOfPetriDishes);
        res.setVaccinationSlopes(vaccinationSlopes);
        res.setCulturePreservations(culturePreservations);
        return R.ok(res);
    }
 
    private SysUser findUserById(List<SysUser> sysUsers, String userId) {
        if (!StringUtils.hasText(userId)) {
            return null;
        }
        try {
            Long parsedUserId = Long.valueOf(userId);
            return sysUsers.stream()
                    .filter(user -> user.getUserId() != null && user.getUserId().equals(parsedUserId))
                    .findFirst()
                    .orElse(null);
        } catch (NumberFormatException exception) {
            return null;
        }
    }
//
//    @Log(title = "培养皿分离记录删除", businessType = BusinessType.DELETE)
//    @ApiOperation(value = "培养皿分离记录删除")
//    @DeleteMapping(value = "/open/t_project_team/deleteSeparationOfCultureDishes")
//    public R<Boolean> deleteSeparationOfCultureDishes(@RequestParam String id) {
//        return R.ok(separationOfCultureDishesService.removeById(id));
//    }
//    @Log(title = "培养皿生物学形态观察记录", businessType = BusinessType.DELETE)
//    @ApiOperation(value = "培养皿生物学形态观察记录删除")
//    @DeleteMapping(value = "/open/t_project_team/deleteObservationOfPetriDishes")
//    public R<Boolean> deleteObservationOfPetriDishes(@RequestParam String id) {
//
//        return R.ok(observationOfPetriDishesService.removeById(id));
//    }
//    @Log(title = "接种斜面记录删除", businessType = BusinessType.DELETE)
//    @ApiOperation(value = "接种斜面记录删除")
//    @DeleteMapping(value = "/open/t_project_team/deleteVaccinationSlope")
//    public R<Boolean> deleteVaccinationSlope(@RequestParam String id) {
//        TVaccinationSlope byId = vaccinationSlopeService.getById(id);
//        if (byId.getPreserveSignature()!=null){
//            return R.fail("菌种保藏人签字确认之后,不可删除");
//        }
//        return R.ok(vaccinationSlopeService.removeById(id));
//    }
//    @Log(title = "菌种保藏记录删除", businessType = BusinessType.DELETE)
//    @ApiOperation(value = "菌种保藏记录删除")
//    @DeleteMapping(value = "/open/t_project_team/deleteCulturePreservation")
//    public R<Boolean> deleteCulturePreservation(@RequestParam String id) {
//        TCulturePreservation byId = culturePreservationService.getById(id);
//        if (byId.getPreserveSignature()!=null){
//            return R.fail("菌种保藏人签字确认之后,不可删除");
//        }
//        return R.ok(culturePreservationService.removeById(id));
//    }
    @Log(title = "菌种保藏记录删除", businessType = BusinessType.DELETE)
    @ApiOperation(value = "菌种保藏记录删除")
    @DeleteMapping(value = "/open/t_project_team/deleteBreedingAndPreservation")
    public R<Boolean> deleteCulturePreservation(@RequestParam String id) {
        TBreedingAndPreservation record = breedingAndPreservationService.getById(id);
        if (record == null) {
            return R.fail("记录不存在");
        }
        if (record.getStatus() != null && record.getStatus() == 1) {
            return R.fail("该记录已提交,不可删除");
        }
        return R.ok(breedingAndPreservationService.removeById(id));
    }
}