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);
|
|
});
|
|
}
|
}
|