maven
2025-10-21 3240968279b2960b05071db0ac4e950955a69dfd
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
package com.ruoyi.procurementrecord.service.impl;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.excel.ExcelUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.procurementrecord.dto.ProcurementPageDto;
import com.ruoyi.procurementrecord.mapper.ProcurementPriceManagementMapper;
import com.ruoyi.procurementrecord.pojo.ProcurementPriceManagement;
import com.ruoyi.procurementrecord.service.ProcurementPriceManagementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
/**
 * @author :yys
 * @date : 2025/9/17 15:07
 */
@Service
@Slf4j
public class ProcurementPriceManagementServiceImpl extends ServiceImpl<ProcurementPriceManagementMapper, ProcurementPriceManagement> implements ProcurementPriceManagementService {
 
 
    @Autowired
    private ProcurementPriceManagementMapper procurementPriceManagementMapper;
 
 
    @Override
    public IPage<ProcurementPriceManagement> listPage(Page page, ProcurementPriceManagement procurementPriceManagement) {
        IPage<ProcurementPriceManagement> result = procurementPriceManagementMapper.listPage(page, procurementPriceManagement);
        // 根据生效时间,失效时间判断状态 有效,待生效,已过期
        for (ProcurementPriceManagement record : result.getRecords()) {
            if (record.getEffectiveTime() != null) {
                if (record.getEffectiveTime().getTime() <= System.currentTimeMillis()) {
                    record.setStatus("active");
                }
            }
            if (record.getEffectiveTime() != null) {
                if (record.getEffectiveTime().getTime() > System.currentTimeMillis()) {
                    record.setStatus("pending");
                }
            }
            if (record.getExpireTime() != null) {
                if (record.getExpireTime().getTime() <= System.currentTimeMillis()) {
                    record.setStatus("expired");
                }
            }
        }
        return result;
    }
 
    @Override
    public void export(HttpServletResponse response) {
        List<ProcurementPriceManagement> procurementPriceManagements = procurementPriceManagementMapper.selectList(null);
        for (ProcurementPriceManagement procurementPriceManagement : procurementPriceManagements) {
            if (procurementPriceManagement.getEffectiveTime() != null) {
                if (procurementPriceManagement.getEffectiveTime().getTime() <= System.currentTimeMillis()) {
                    procurementPriceManagement.setStatus("有效");
                }
            }
            if (procurementPriceManagement.getEffectiveTime() != null) {
                if (procurementPriceManagement.getEffectiveTime().getTime() > System.currentTimeMillis()) {
                    procurementPriceManagement.setStatus("待生效");
                }
            }
            if (procurementPriceManagement.getExpireTime() != null) {
                if (procurementPriceManagement.getExpireTime().getTime() <= System.currentTimeMillis()) {
                    procurementPriceManagement.setStatus("已过期");
                }
            }
        }
        ExcelUtil<ProcurementPriceManagement> util = new ExcelUtil<ProcurementPriceManagement>(ProcurementPriceManagement.class);
        util.exportExcel(response, procurementPriceManagements, "采购价格管理");}
}