package com.iailab.module.pms.coalquality.modules.analysis.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.iailab.framework.common.constant.Constant;
|
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.framework.tenant.core.aop.TenantIgnore;
|
import com.iailab.iems.common.utils.SerialNumUtils;
|
import com.iailab.module.pms.coalquality.modules.analysis.dao.CoalWashCurvesDao;
|
import com.iailab.module.pms.coalquality.modules.analysis.dto.CoalWashCurvesDTO;
|
import com.iailab.module.pms.coalquality.modules.analysis.dto.CoalWashCurvesDetDTO;
|
import com.iailab.module.pms.coalquality.modules.analysis.entity.CoalWashCurvesEntity;
|
import com.iailab.module.pms.coalquality.modules.analysis.service.CoalWashCurvesDetService;
|
import com.iailab.module.pms.coalquality.modules.analysis.service.CoalWashCurvesService;
|
import com.iailab.module.pms.coalquality.modules.analysis.vo.WashCurvesPageReqVO;
|
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.text.DecimalFormat;
|
import java.util.*;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2023年01月16日 15:58:00
|
*/
|
@Service
|
public class CoalWashCurvesServiceImpl extends BaseServiceImpl<CoalWashCurvesDao, CoalWashCurvesEntity>
|
implements CoalWashCurvesService {
|
@Autowired
|
private CoalWashCurvesDetService coalWashCurvesDetService;
|
|
private DecimalFormat df = new DecimalFormat("00");
|
|
@Autowired
|
private SerialNumUtils serialNumUtils;
|
|
private String BUSINESS_CODE = "CoalWashCurves";
|
|
@Override
|
@TenantIgnore
|
public PageResult<CoalWashCurvesDTO> page(WashCurvesPageReqVO washCurvesPageReqVO) {
|
PageResult<CoalWashCurvesEntity> page = baseDao.selectPage(washCurvesPageReqVO);
|
|
return BeanUtils.toBean(page, CoalWashCurvesDTO.class);
|
}
|
|
@Override
|
public CoalWashCurvesDTO get(String id) {
|
CoalWashCurvesEntity entity = baseDao.selectById(id);
|
CoalWashCurvesDTO dto = ConvertUtils.sourceToTarget(entity, CoalWashCurvesDTO.class);
|
Map<String, Object> parmas = new HashMap<>(1);
|
parmas.put("curvesId", dto.getId());
|
List<CoalWashCurvesDetDTO> detList = coalWashCurvesDetService.queryList(parmas);
|
dto.setDetList(detList);
|
return dto;
|
}
|
|
@Override
|
public CoalWashCurvesDTO getLastByMz(String mz) {
|
// if (StringUtils.isBlank(mz)) {
|
// return new CoalWashCurvesDTO();
|
// }
|
QueryWrapper<CoalWashCurvesEntity> wrapper = new QueryWrapper<>();
|
wrapper.eq(StringUtils.isNotBlank(mz), "mz", mz).orderByDesc(Constant.CREATE_DATE).last("limit 0, 1");
|
List<CoalWashCurvesEntity> list = baseDao.selectList(wrapper);
|
if (CollectionUtils.isEmpty(list)) {
|
return null;
|
}
|
|
CoalWashCurvesEntity entity = list.get(0);
|
CoalWashCurvesDTO dto = ConvertUtils.sourceToTarget(entity, CoalWashCurvesDTO.class);
|
Map<String, Object> parmas = new HashMap<>(1);
|
parmas.put("curvesId", dto.getId());
|
List<CoalWashCurvesDetDTO> detList = coalWashCurvesDetService.queryList(parmas);
|
dto.setDetList(detList);
|
return dto;
|
}
|
|
@Override
|
public CoalWashCurvesDTO getByMzAndRq(String mz, String syrq) {
|
// if (StringUtils.isBlank(mz)) {
|
// return new CoalWashCurvesDTO();
|
// }
|
QueryWrapper<CoalWashCurvesEntity> wrapper = new QueryWrapper<>();
|
wrapper.eq(StringUtils.isNotBlank(mz), "mz", mz)
|
.eq(StringUtils.isNotBlank(syrq),"syrq",syrq);
|
List<CoalWashCurvesEntity> list = baseDao.selectList(wrapper);
|
if (CollectionUtils.isEmpty(list)) {
|
return null;
|
}
|
|
CoalWashCurvesEntity entity = list.get(0);
|
CoalWashCurvesDTO dto = ConvertUtils.sourceToTarget(entity, CoalWashCurvesDTO.class);
|
Map<String, Object> parmas = new HashMap<>(1);
|
parmas.put("curvesId", dto.getId());
|
List<CoalWashCurvesDetDTO> detList = coalWashCurvesDetService.queryList(parmas);
|
dto.setDetList(detList);
|
return dto;
|
}
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void save(CoalWashCurvesDTO dto) {
|
// String a = serialNumUtils.getByBusiness( BUSINESS_CODE,4);
|
dto.setCode(dto.getNy().replace("-", "") );
|
CoalWashCurvesEntity entity = ConvertUtils.sourceToTarget(dto, CoalWashCurvesEntity.class);
|
entity.setId(UUID.randomUUID().toString());
|
entity.setCreateDate(new Date());
|
// entity.setCreator(SecurityUser.getUserId().toString());
|
insert(entity);
|
|
List<CoalWashCurvesDetDTO> detList = dto.getDetList();
|
// if (!CollectionUtils.isEmpty(detList)) {
|
// for (int i = 0; i < detList.size(); i++) {
|
// detList.get(i).setCode(entity.getCode() + df.format(i + 1));
|
// detList.get(i).setCurvesId(entity.getId());
|
// }
|
// coalWashCurvesDetService.saveList(detList);
|
// }
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void update(CoalWashCurvesDTO dto) {
|
CoalWashCurvesEntity entity = ConvertUtils.sourceToTarget(dto, CoalWashCurvesEntity.class);
|
entity.setUpdateDate(new Date());
|
// entity.setUpdater(SecurityUser.getUserId().toString());
|
updateById(entity);
|
|
List<CoalWashCurvesDetDTO> detList = dto.getDetList();
|
// if (!CollectionUtils.isEmpty(detList)) {
|
// detList.forEach(item -> {
|
// item.setCurvesId(entity.getId());
|
// });
|
// coalWashCurvesDetService.updateList(detList);
|
// }
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void delete(String[] ids) {
|
baseDao.deleteByIds(Arrays.asList(ids));
|
// coalWashCurvesDetService.deleteByCurvesIds(Arrays.asList(ids));
|
}
|
|
}
|