“zhuo”
2023-08-10 390e54f20695b7f369fb50f584447d193543539d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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(String device, Date beginTime, Date endTime, String user) {
        //获取数据库数据
        List<PlanVo> 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;
    }
}