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
package org.jeecg.modules.lims.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.jeecg.modules.lims.entity.LimsAppointment;
import org.jeecg.modules.lims.entity.LimsAppointmentAudit;
import org.jeecg.modules.lims.entity.LimsInstrument;
import org.jeecg.modules.lims.entity.LimsUsageRecord;
import org.jeecg.modules.lims.mapper.LimsAppointmentAuditMapper;
import org.jeecg.modules.lims.mapper.LimsAppointmentMapper;
import org.jeecg.modules.lims.mapper.LimsInstrumentMapper;
import org.jeecg.modules.lims.mapper.LimsUsageRecordMapper;
import org.jeecg.modules.lims.service.ILimsInstrumentService;
import org.jeecg.modules.lims.service.ILimsUsageRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * @Description: 仪器
 * @Author: jeecg-boot
 * @Date:   2022-11-07
 * @Version: V1.0
 */
@Service
public class LimsInstrumentServiceImpl extends ServiceImpl<LimsInstrumentMapper, LimsInstrument> implements ILimsInstrumentService {
    @Autowired
    private LimsUsageRecordMapper usageRecordMapper;
    @Autowired
    private LimsInstrumentMapper instrumentMapper;
    @Autowired
    private LimsAppointmentAuditMapper auditMapper;
    @Autowired
    private LimsAppointmentMapper appointmentMapper;
    @Override
    public void resetInspection() {
        LambdaUpdateWrapper<LimsInstrument> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(LimsInstrument::getInspection, 0);
        baseMapper.update(null, updateWrapper);
    }
 
    @Override
    @Transactional
    public void resetInstrument() {
        QueryWrapper<LimsUsageRecord> usageRecordQueryWrapper = new QueryWrapper<>();
        //查询正在运行的设备
        usageRecordQueryWrapper.lambda().eq(LimsUsageRecord::getStatus,1);
        List<LimsUsageRecord> limsUsageRecords = usageRecordMapper.selectList(usageRecordQueryWrapper);
        if(limsUsageRecords!=null && limsUsageRecords.size() > 0){
 
            List<String> instrumentIds  = limsUsageRecords.stream().map(LimsUsageRecord::getInstrument).collect(Collectors.toList());
            //更新设备表
            if(instrumentIds.size()>0){
                QueryWrapper<LimsInstrument> instrumentQueryWrapper = new QueryWrapper<>();
                instrumentQueryWrapper.lambda().in(LimsInstrument::getId,instrumentIds);
                List<LimsInstrument> instrumentList = instrumentMapper.selectList(instrumentQueryWrapper);
                instrumentList.stream().forEach(item -> {
                    item.setUsed("0");
                    item.setUpdateBy(item.getCreateBy());
                    item.setUpdateTime(new Date());
                    instrumentMapper.updateById(item);
                });
            }
 
            //更新使用记录表
            limsUsageRecords.stream().forEach(item->{
                item.setUpdateBy(item.getCreateBy());
                item.setUpdateTime(new Date());
                item.setStatus(2);
                usageRecordMapper.updateById(item);
            });
 
 
        }
 
 
 
    }
 
    @Override
    public void resetAudit() {
        //1.当天未审批设置为超时状态
        QueryWrapper<LimsAppointmentAudit> auditQueryWrapper = new QueryWrapper<>();
        auditQueryWrapper.lambda().eq(LimsAppointmentAudit::getStatus,"0");
        List<LimsAppointmentAudit> limsAppointmentAudits = auditMapper.selectList(auditQueryWrapper);
        limsAppointmentAudits.stream().forEach(item->{
            item.setStatus("3");
            auditMapper.updateById(item);
 
            //2.设置预约为取消
            String appoId = item.getAppoId();
            LimsAppointment appointment = appointmentMapper.selectById(appoId);
            appointment.setStatus("2");
            appointmentMapper.updateById(appointment);
 
        });
 
    }
}