|
|
@ -1,5 +1,7 @@ |
|
|
|
package org.dromara.demo.service.impl; |
|
|
|
|
|
|
|
import io.micrometer.core.instrument.util.TimeUtils; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import org.dromara.common.core.utils.MapstructUtils; |
|
|
|
import org.dromara.common.core.utils.StringUtils; |
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|
|
@ -8,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.dromara.demo.service.IStationInfoService; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.dromara.demo.domain.bo.ZeroAdjustmentAnalysisBo; |
|
|
|
import org.dromara.demo.domain.vo.ZeroAdjustmentAnalysisVo; |
|
|
@ -15,9 +18,13 @@ import org.dromara.demo.domain.ZeroAdjustmentAnalysis; |
|
|
|
import org.dromara.demo.mapper.ZeroAdjustmentAnalysisMapper; |
|
|
|
import org.dromara.demo.service.IZeroAdjustmentAnalysisService; |
|
|
|
|
|
|
|
import java.time.Duration; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
/** |
|
|
|
* 校零校准分析Service业务层处理 |
|
|
@ -31,6 +38,8 @@ public class ZeroAdjustmentAnalysisServiceImpl implements IZeroAdjustmentAnalysi |
|
|
|
|
|
|
|
private final ZeroAdjustmentAnalysisMapper baseMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private IStationInfoService stationInfoService; |
|
|
|
/** |
|
|
|
* 查询校零校准分析 |
|
|
|
* |
|
|
@ -53,6 +62,20 @@ public class ZeroAdjustmentAnalysisServiceImpl implements IZeroAdjustmentAnalysi |
|
|
|
public TableDataInfo<ZeroAdjustmentAnalysisVo> queryPageList(ZeroAdjustmentAnalysisBo bo, PageQuery pageQuery) { |
|
|
|
LambdaQueryWrapper<ZeroAdjustmentAnalysis> lqw = buildQueryWrapper(bo); |
|
|
|
Page<ZeroAdjustmentAnalysisVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
|
|
|
List<ZeroAdjustmentAnalysisVo> records = result.getRecords(); |
|
|
|
for (ZeroAdjustmentAnalysisVo record : records) { |
|
|
|
// 获取目标时间
|
|
|
|
Date toZeroDate = record.getToZeroDate(); |
|
|
|
if (toZeroDate == null) { |
|
|
|
throw new IllegalArgumentException("目标时间不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
// 动态生成 duration
|
|
|
|
String duration = getTimeDifference(toZeroDate); |
|
|
|
// 如:"2701天20小时53分钟"
|
|
|
|
record.setDuration(duration); |
|
|
|
} |
|
|
|
result.setRecords(records); |
|
|
|
return TableDataInfo.build(result); |
|
|
|
} |
|
|
|
|
|
|
@ -83,6 +106,7 @@ public class ZeroAdjustmentAnalysisServiceImpl implements IZeroAdjustmentAnalysi |
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getMonitorPerson()), ZeroAdjustmentAnalysis::getMonitorPerson, bo.getMonitorPerson()); |
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getMonitorCompany()), ZeroAdjustmentAnalysis::getMonitorCompany, bo.getMonitorCompany()); |
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getInsider()), ZeroAdjustmentAnalysis::getInsider, bo.getInsider()); |
|
|
|
lqw.orderByDesc(ZeroAdjustmentAnalysis::getUpdateTime); |
|
|
|
return lqw; |
|
|
|
} |
|
|
|
|
|
|
@ -94,6 +118,20 @@ public class ZeroAdjustmentAnalysisServiceImpl implements IZeroAdjustmentAnalysi |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Boolean insertByBo(ZeroAdjustmentAnalysisBo bo) { |
|
|
|
String station = bo.getStation(); |
|
|
|
String area = stationInfoService.getAreaByStationName(station); |
|
|
|
bo.setArea(area); |
|
|
|
// 获取目标时间
|
|
|
|
Date toZeroDate = bo.getToZeroDate(); |
|
|
|
if (toZeroDate == null) { |
|
|
|
throw new IllegalArgumentException("目标时间不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
// 动态生成 duration
|
|
|
|
String duration = getTimeDifference(toZeroDate); |
|
|
|
// 如:"2701天20小时53分钟"
|
|
|
|
bo.setDuration(duration); |
|
|
|
bo.setInsider("张志虎"); |
|
|
|
ZeroAdjustmentAnalysis add = MapstructUtils.convert(bo, ZeroAdjustmentAnalysis.class); |
|
|
|
validEntityBeforeSave(add); |
|
|
|
boolean flag = baseMapper.insert(add) > 0; |
|
|
@ -103,6 +141,25 @@ public class ZeroAdjustmentAnalysisServiceImpl implements IZeroAdjustmentAnalysi |
|
|
|
return flag; |
|
|
|
} |
|
|
|
|
|
|
|
private String getTimeDifference(Date toDate) { |
|
|
|
LocalDateTime start = toDate.toInstant() |
|
|
|
.atZone(java.time.ZoneId.systemDefault()) |
|
|
|
.toLocalDateTime(); |
|
|
|
|
|
|
|
LocalDateTime end = LocalDateTime.now(); |
|
|
|
|
|
|
|
Duration duration = Duration.between(start, end); |
|
|
|
|
|
|
|
long days = duration.toDays(); |
|
|
|
long hours = TimeUnit.SECONDS.toHours(duration.getSeconds()) % 24; |
|
|
|
long minutes = TimeUnit.SECONDS.toMinutes(duration.getSeconds()) % 60; |
|
|
|
|
|
|
|
return String.format("%d天%d小时%d分钟", days, hours, minutes); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 修改校零校准分析 |
|
|
|
* |
|
|
|