package com.yuanchu.limslaboratory.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.limslaboratory.mapper.UserMapper;
import com.yuanchu.limslaboratory.pojo.Instrument;
import com.yuanchu.limslaboratory.mapper.InstrumentMapper;
import com.yuanchu.limslaboratory.pojo.User;
import com.yuanchu.limslaboratory.service.InstrumentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.limslaboratory.utils.JsonUtil;
import com.yuanchu.limslaboratory.utils.MyUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
*
* 服务实现类
*
*
* @author 江苏鵷雏网络科技有限公司
* @since 2023-07-20
*/
@Service
public class InstrumentServiceImpl extends ServiceImpl implements InstrumentService {
@Resource
private InstrumentMapper instrumentMapper;
@Resource
private UserMapper userMapper;
@Override
public Integer addInstrumentInformation(Instrument instrument) {
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Instrument::getEquipmentCode, instrument.getEquipmentCode());
wrapper.eq(Instrument::getState, 1);
wrapper.select(Instrument::getEquipmentCode);
Instrument instrument1 = instrumentMapper.selectOne(wrapper);
if (ObjectUtils.isEmpty(instrument1)){
return instrumentMapper.insert(instrument);
}
return 0;
}
@Override
public Boolean deleteInstrumentInformation(String instrumentId) {
LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(Instrument::getId, instrumentId);
updateWrapper.set(Instrument::getState, 0);
int isUpdateSuccess = instrumentMapper.update(new Instrument(), updateWrapper);
return isUpdateSuccess > 0;
}
@Override
public IPage