package com.iailab.module.any.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.iailab.framework.common.service.impl.BaseServiceImpl;
|
import com.iailab.framework.common.util.object.ConvertUtils;
|
import com.iailab.common.utils.DateUtils;
|
import com.iailab.module.any.dao.AnyProcReportDetDao;
|
import com.iailab.module.any.dto.AnyProcReportDetDTO;
|
import com.iailab.module.any.entity.AnyProcReportDetEntity;
|
import com.iailab.module.any.service.AnyProcReportDetService;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Service;
|
import org.springframework.util.CollectionUtils;
|
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.UUID;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2024年06月25日
|
*/
|
@Service
|
public class AnyProcReportDetServiceImpl extends BaseServiceImpl<AnyProcReportDetDao, AnyProcReportDetEntity> implements AnyProcReportDetService {
|
|
@Override
|
public List<AnyProcReportDetDTO> listByReportId(String reportId) {
|
QueryWrapper<AnyProcReportDetEntity> wrapper = new QueryWrapper<>();
|
wrapper.eq("report_id", reportId)
|
.orderByAsc("sort");
|
List<AnyProcReportDetEntity> list = baseDao.selectList(wrapper);
|
return ConvertUtils.sourceToTarget(list, AnyProcReportDetDTO.class);
|
}
|
|
@Override
|
public void save(AnyProcReportDetDTO dto) {
|
AnyProcReportDetEntity entity = ConvertUtils.sourceToTarget(dto, AnyProcReportDetEntity.class);
|
entity.setId(UUID.randomUUID().toString());
|
entity.setCreateDate(new Date());
|
insert(entity);
|
}
|
|
@Override
|
public void migrationProcReportDet(Map<String, Date> tMap) {
|
List<AnyProcReportDetEntity> list = baseDao.selectList(getDateWrapper(tMap));
|
if (CollectionUtils.isEmpty(list)){
|
return;
|
}
|
baseDao.migration(list);
|
baseDao.delete(getDateWrapper(tMap));
|
}
|
|
public QueryWrapper<AnyProcReportDetEntity> getDateWrapper(Map<String, Date> params) {
|
String startDate = DateUtils.format(params.get("startdate"),DateUtils.DATE_TIME_PATTERN);
|
String endDate = DateUtils.format(params.get("enddate"),DateUtils.DATE_TIME_PATTERN);
|
|
QueryWrapper<AnyProcReportDetEntity> wrapper = new QueryWrapper<>();
|
wrapper.ge(StringUtils.isNotBlank(startDate), "create_date", startDate);
|
wrapper.le(StringUtils.isNotBlank(endDate), "create_date", endDate);
|
return wrapper;
|
}
|
}
|