package com.yuanchu.limslaboratory.service.impl;
|
|
import com.yuanchu.limslaboratory.mapper.PlanMapper;
|
import com.yuanchu.limslaboratory.pojo.vo.PlanVo;
|
import com.yuanchu.limslaboratory.service.PlanService;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* <p>
|
* 服务实现类
|
* </p>
|
*
|
* @author 江苏鵷雏网络科技有限公司
|
* @since 2023-08-09
|
*/
|
@Service
|
public class PlanServiceImpl implements PlanService {
|
|
@Resource
|
private PlanMapper planMapper;
|
|
/**
|
* 查询检验计划
|
*
|
* @return
|
*/
|
@Override
|
public List<PlanVo> selectAllPlan(Integer deviceId, Date beginTime, Date endTime, Integer userId) {
|
//获取数据库数据
|
List<PlanVo> planVos = planMapper.selectAllPlan(deviceId, beginTime, endTime, userId);
|
//添加计划工期和检验进度
|
planVos.forEach(planVo -> {
|
//添加检验进度
|
//判断是否是已完成
|
if (planVo.getState() != null) {
|
planVo.setProgress(100);
|
}
|
//判断是否是未分配
|
if (planVo.getCheckproject() == null) {
|
planVo.setProgress(0);
|
}
|
//判断是否是进行中
|
if (planVo.getState() == null && planVo.getCheckproject() != null) {
|
planVo.setProgress(50);
|
}
|
//添加计划工期
|
if (planVo.getFinishtime() != null && planVo.getStarttime() != null) {
|
long startTimeInMillis = planVo.getStarttime().getTime();
|
long endTimeInMillis = planVo.getFinishtime().getTime();
|
long durationInMillis = endTimeInMillis - startTimeInMillis;
|
long duration = durationInMillis / (1000 * 60 * 60);
|
planVo.setDuration(Integer.valueOf((int) duration));
|
}
|
});
|
return planVos;
|
}
|
}
|