mitao
3 天以前 56efd0aa54e2c5cea81ff9b28855bca520dee475
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.ruoyi.system.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.system.mapper.ProjectMainMapper;
import com.ruoyi.system.model.ContractTemplate;
import com.ruoyi.system.model.ProjectMain;
import com.ruoyi.system.query.ProjectMainListQuery;
import com.ruoyi.system.query.ProjectPhaseListQuery;
import com.ruoyi.system.service.ProjectMainService;
import com.ruoyi.system.vo.ProjectMainListVO;
import com.ruoyi.system.vo.ProjectPhaseListVO;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
 
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.List;
 
/**
 * <p>
 * 项目主表 服务实现类
 * </p>
 *
 * @author WuGuanFengYue
 * @since 2025-10-16
 */
@Service
public class ProjectMainServiceImpl extends ServiceImpl<ProjectMainMapper, ProjectMain> implements ProjectMainService {
 
    @Override
    public PageInfo<ProjectMainListVO> pageList(ProjectMainListQuery query) {
        PageInfo<ProjectMainListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<ProjectMainListVO> list = this.baseMapper.pageList(query, pageInfo);
        pageInfo.setRecords(list);
        return pageInfo;
    }
 
    public static void main(String[] args) {
        LocalDate date1 = LocalDate.of(2023, 1, 10);
        LocalDate date2 = LocalDate.of(2023, 1, 1);
 
        long daysBetween = ChronoUnit.DAYS.between(date1, date2);
        System.out.println(daysBetween); // 输出: 9
    }
 
    @Override
    public PageInfo<ProjectPhaseListVO> pageListPhase(ProjectPhaseListQuery query) {
        PageInfo<ProjectPhaseListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<ProjectPhaseListVO> list = this.baseMapper.pageListPhase(query, pageInfo);
        for (ProjectPhaseListVO projectPhaseListVO : list) {
            LocalDate createTime = projectPhaseListVO.getCreateTime().toLocalDate();
            LocalDate settleTime = projectPhaseListVO.getSettleTime();
            if (createTime.isAfter(settleTime)){
                projectPhaseListVO.setSettleTimeRange(0);
            }else{
                long daysBetween = ChronoUnit.DAYS.between(createTime, settleTime)+1;
                projectPhaseListVO.setSettleTimeRange((int) daysBetween);
            }
            // 根据settleTime 赋值warningStatus,红灯:办结时限前一周橙灯:办结时限前15天 黄灯:办结时限前30天 绿灯:正常状态,未到办结事项预警时限或已办结
            if (StringUtils.hasLength(projectPhaseListVO.getFileUrl())){
                projectPhaseListVO.setWarningStatus(1);
            }else{
                if (projectPhaseListVO.getSettleTime().isBefore(LocalDate.now().plusDays(7))) {
                    projectPhaseListVO.setWarningStatus(4);
                } else if (projectPhaseListVO.getSettleTime().isBefore(LocalDate.now().plusDays(15))) {
                    projectPhaseListVO.setWarningStatus(3);
                } else if (projectPhaseListVO.getSettleTime().isBefore(LocalDate.now().plusDays(30))) {
                    projectPhaseListVO.setWarningStatus(2);
                } else {
                    projectPhaseListVO.setWarningStatus(1);
                }
            }
 
 
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
}