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.iems.common.utils.ConvertUtils;
|
import com.iailab.iems.common.utils.SerialNumUtils;
|
import com.iailab.module.pms.coalquality.modules.detection.dao.QualityDetectionDao;
|
import com.iailab.module.pms.coalquality.modules.detection.dto.QualityDetectionDTO;
|
import com.iailab.module.pms.coalquality.modules.detection.entity.QualityDetectionEntity;
|
import com.iailab.module.pms.coalquality.modules.detection.service.QualityDetectionService;
|
import com.iailab.module.pms.coalquality.modules.detection.vo.DetectionPageReqVO;
|
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 org.springframework.util.CollectionUtils;
|
|
import java.util.Arrays;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* 煤质检测
|
*
|
* @author PanZhibao
|
* @Description
|
* @createTime 2023年02月07日 13:15:00
|
*/
|
@Service
|
public class QualityDetectionServiceImpl extends BaseServiceImpl<QualityDetectionDao, QualityDetectionEntity>
|
implements QualityDetectionService {
|
|
@Autowired
|
private SerialNumUtils serialNumUtils;
|
|
private Map<String, String> prefixMap = new HashMap<>();
|
|
private String BUSINESS_CODE = "QualityDetection";
|
|
@Override
|
public PageResult<QualityDetectionDTO> page(DetectionPageReqVO reqVO) {
|
PageResult<QualityDetectionEntity> page = baseDao.selectPage(reqVO);
|
|
return BeanUtils.toBean(page, QualityDetectionDTO.class);
|
}
|
|
|
@Override
|
public QualityDetectionDTO get(String id) {
|
QualityDetectionEntity entity = baseDao.selectById(id);
|
|
return ConvertUtils.sourceToTarget(entity, QualityDetectionDTO.class);
|
}
|
|
@Override
|
public void save(QualityDetectionDTO dto) {
|
if (CollectionUtils.isEmpty(prefixMap)) {
|
prefixMap.put("ym", "10");
|
prefixMap.put("cpm", "20");
|
prefixMap.put("spm", "30");
|
}
|
QualityDetectionEntity entity = ConvertUtils.sourceToTarget(dto, QualityDetectionEntity.class);
|
entity.setCode(prefixMap.get(dto.getType()) + serialNumUtils.getByBusinessDate(BUSINESS_CODE + dto.getType(), dto.getRq(), 4));
|
entity.setCreateDate(new Date());
|
// entity.setCreator(SecurityUser.getUserId().toString());
|
insert(entity);
|
}
|
|
@Override
|
public void update(QualityDetectionDTO dto) {
|
QualityDetectionEntity entity = ConvertUtils.sourceToTarget(dto, QualityDetectionEntity.class);
|
entity.setUpdateDate(new Date());
|
// entity.setUpdater(SecurityUser.getUserId().toString());
|
updateById(entity);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void delete(String[] ids) {
|
baseDao.deleteByIds(Arrays.asList(ids));
|
}
|
|
@Override
|
public Long cheack(QualityDetectionDTO dto) {
|
String id = dto.getId();
|
String code = dto.getCode();
|
|
QueryWrapper<QualityDetectionEntity> queryWrapper = new QueryWrapper<>();
|
queryWrapper.ne(StringUtils.isNotBlank(id), "id", id);
|
queryWrapper.and(wrapper -> wrapper.eq("code", code));
|
return baseDao.selectCount(queryWrapper);
|
}
|
|
}
|