package com.iailab.module.device.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.device.dao.DeviceHealthReportDataDao;
|
import com.iailab.module.device.dto.DeviceHealthReportDataDTO;
|
import com.iailab.module.device.entity.DeviceHealthReportDataEntity;
|
import com.iailab.module.device.service.DeviceHealthReportDataService;
|
import lombok.extern.slf4j.Slf4j;
|
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月28日
|
*/
|
@Slf4j
|
@Service
|
public class DeviceHealthReportDataServiceImpl extends BaseServiceImpl<DeviceHealthReportDataDao, DeviceHealthReportDataEntity>
|
implements DeviceHealthReportDataService {
|
|
|
@Override
|
public List<DeviceHealthReportDataDTO> listByReportId(String reportId) {
|
QueryWrapper<DeviceHealthReportDataEntity> wrapper = new QueryWrapper<>();
|
wrapper.eq("report_id", reportId)
|
.orderByAsc("sort");
|
List<DeviceHealthReportDataEntity> list = baseDao.selectList(wrapper);
|
return ConvertUtils.sourceToTarget(list, DeviceHealthReportDataDTO.class);
|
}
|
|
@Override
|
public void save(DeviceHealthReportDataDTO dto) {
|
DeviceHealthReportDataEntity entity = ConvertUtils.sourceToTarget(dto, DeviceHealthReportDataEntity.class);
|
entity.setId(UUID.randomUUID().toString());
|
entity.setCreateDate(new Date());
|
insert(entity);
|
}
|
|
@Override
|
public void migrationDeviceHealthReportData(Map<String, Date> tMap) {
|
List<DeviceHealthReportDataEntity> list = baseDao.selectList(getDateWrapper(tMap));
|
if (CollectionUtils.isEmpty(list)){
|
return;
|
}
|
baseDao.migration(list);
|
baseDao.delete(getDateWrapper(tMap));
|
}
|
|
public QueryWrapper<DeviceHealthReportDataEntity> 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<DeviceHealthReportDataEntity> wrapper = new QueryWrapper<>();
|
wrapper.ge(StringUtils.isNotBlank(startDate), "create_date", startDate);
|
wrapper.le(StringUtils.isNotBlank(endDate), "create_date", endDate);
|
return wrapper;
|
}
|
}
|