package com.iailab.module.pms.coalquality.modules.detection.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.iailab.framework.common.pojo.PageResult;
|
import com.iailab.framework.common.service.impl.BaseServiceImpl;
|
import com.iailab.framework.common.util.object.BeanUtils;
|
import com.iailab.framework.common.util.object.ConvertUtils;
|
import com.iailab.iems.common.utils.SerialNumUtils;
|
import com.iailab.module.pms.coalquality.modules.detection.dao.QualityMediumDao;
|
import com.iailab.module.pms.coalquality.modules.detection.dto.QualityMediumDTO;
|
import com.iailab.module.pms.coalquality.modules.detection.entity.QualityMediumEntity;
|
import com.iailab.module.pms.coalquality.modules.detection.service.QualityMediumService;
|
import com.iailab.module.pms.coalquality.modules.detection.vo.MediumPageReqVO;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.Arrays;
|
import java.util.Date;
|
|
/**
|
* 介质粉检测
|
*
|
* @author PanZhibao
|
* @Description
|
* @createTime 2023年02月07日 17:27:00
|
*/
|
@Slf4j
|
@Service
|
public class QualityMediumServiceImpl extends BaseServiceImpl<QualityMediumDao, QualityMediumEntity>
|
implements QualityMediumService {
|
|
@Autowired
|
private SerialNumUtils serialNumUtils;
|
|
|
private String BUSINESS_CODE = "QualityMedium";
|
|
@Override
|
public PageResult<QualityMediumDTO> page(MediumPageReqVO reqVO) {
|
PageResult<QualityMediumEntity> page = baseDao.selectPage(reqVO);
|
|
return BeanUtils.toBean(page, QualityMediumDTO.class);
|
}
|
|
@Override
|
public QualityMediumDTO get(String id) {
|
QualityMediumEntity entity = baseDao.selectById(id);
|
|
return ConvertUtils.sourceToTarget(entity, QualityMediumDTO.class);
|
}
|
|
@Override
|
public void save(QualityMediumDTO dto) {
|
dto.setCode(serialNumUtils.getByBusinessDate(BUSINESS_CODE, dto.getRq(), 4));
|
QualityMediumEntity entity = ConvertUtils.sourceToTarget(dto, QualityMediumEntity.class);
|
entity.setCreateDate(new Date());
|
// entity.setCreator(SecurityUser.getUserId().toString());
|
insert(entity);
|
}
|
|
@Override
|
public void update(QualityMediumDTO dto) {
|
QualityMediumEntity entity = ConvertUtils.sourceToTarget(dto, QualityMediumEntity.class);
|
entity.setUpdateDate(new Date());
|
// entity.setUpdater(SecurityUser.getUserId().toString());
|
updateById(entity);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void delete(String[] ids) {
|
baseDao.deleteBatchIds(Arrays.asList(ids));
|
}
|
|
@Override
|
public Long cheack(QualityMediumDTO dto) {
|
String id = dto.getId();
|
String code = dto.getCode();
|
|
QueryWrapper<QualityMediumEntity> queryWrapper = new QueryWrapper<>();
|
queryWrapper.ne(StringUtils.isNotBlank(id), "id", id);
|
queryWrapper.and(wrapper -> wrapper.eq("code", code));
|
return baseDao.selectCount(queryWrapper);
|
}
|
|
}
|