package com.gkhy.exam.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.gkhy.exam.common.api.CommonPage;
import com.gkhy.exam.common.api.CommonResult;
import com.gkhy.exam.common.constant.UserConstant;
import com.gkhy.exam.common.utils.PageUtils;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.system.domain.AnnualVerificationPlan;
import com.gkhy.exam.system.domain.CalibrationMonitoringEquipment;
import com.gkhy.exam.system.mapper.CalibrationMonitoringEquipmentMapper;
import com.gkhy.exam.system.service.CalibrationMonitoringEquipmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
/**
*
* 监测和测量设备校准确认表 服务实现类
*
*
* @author hh
* @since 2025-08-25 15:01:44
*/
@Service
public class CalibrationMonitoringEquipmentServiceImpl extends ServiceImpl implements CalibrationMonitoringEquipmentService {
@Autowired
private CalibrationMonitoringEquipmentMapper calibrationMonitoringEquipmentMapper;
@Override
public CommonPage selectCalibrationMonitoringEquipmentList(CalibrationMonitoringEquipment calibrationMonitoringEquipment) {
PageUtils.startPage();
List calibrationMonitoringEquipments = calibrationMonitoringEquipmentMapper.selectCalibrationMonitoringEquipmentList(calibrationMonitoringEquipment);
return CommonPage.restPage(calibrationMonitoringEquipments);
}
@Override
public CommonResult saveCalibrationMonitoringEquipment(CalibrationMonitoringEquipment calibrationMonitoringEquipment) {
int i = 0;
if (calibrationMonitoringEquipment.getId() == null){
calibrationMonitoringEquipment.setCreateBy(SecurityUtils.getUsername());
calibrationMonitoringEquipment.setCreateTime(LocalDateTime.now());
i = calibrationMonitoringEquipmentMapper.insert(calibrationMonitoringEquipment);
}else {
calibrationMonitoringEquipment.setUpdateTime(LocalDateTime.now());
calibrationMonitoringEquipment.setUpdateBy(SecurityUtils.getUsername());
i = calibrationMonitoringEquipmentMapper.updateById(calibrationMonitoringEquipment);
}
return i > 0 ? CommonResult.success() : CommonResult.failed();
}
@Override
public CommonResult deletedCalibrationMonitoringEquipment(Long id) {
int i = calibrationMonitoringEquipmentMapper.update(new CalibrationMonitoringEquipment(),
new LambdaUpdateWrapper().eq(CalibrationMonitoringEquipment::getId, id).set(CalibrationMonitoringEquipment::getDelFlag, UserConstant.DEPT_DISABLE)
.set(CalibrationMonitoringEquipment::getUpdateTime, LocalDateTime.now()).set(CalibrationMonitoringEquipment::getUpdateBy, SecurityUtils.getUsername())
);
return CommonResult.success();
}
}