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;
/**
*
* 服务实现类
*
*
* @author 江苏鵷雏网络科技有限公司
* @since 2023-08-09
*/
@Service
public class PlanServiceImpl implements PlanService {
@Resource
private PlanMapper planMapper;
/**
* 查询检验计划
*
* @return
*/
@Override
public List selectAllPlan(String device, Date beginTime, Date endTime, String user) {
//获取数据库数据
List planVos = planMapper.selectAllPlan(device, beginTime, endTime, user);
//添加计划工期和检验进度
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;
}
}