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 implements AnyProcReportDetService { @Override public List listByReportId(String reportId) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("report_id", reportId) .orderByAsc("sort"); List 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 tMap) { List list = baseDao.selectList(getDateWrapper(tMap)); if (CollectionUtils.isEmpty(list)){ return; } baseDao.migration(list); baseDao.delete(getDateWrapper(tMap)); } public QueryWrapper getDateWrapper(Map params) { String startDate = DateUtils.format(params.get("startdate"),DateUtils.DATE_TIME_PATTERN); String endDate = DateUtils.format(params.get("enddate"),DateUtils.DATE_TIME_PATTERN); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.ge(StringUtils.isNotBlank(startDate), "create_date", startDate); wrapper.le(StringUtils.isNotBlank(endDate), "create_date", endDate); return wrapper; } }