11 小时以前 2b8f88856e90e530ddbfce88aea107a0ec894d5d
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
82
83
84
85
86
87
88
package cn.iocoder.yudao.module.srm.controller.admin.tender;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.srm.controller.admin.tender.vo.*;
import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierDO;
import cn.iocoder.yudao.module.srm.service.supplier.SrmSupplierService;
import cn.iocoder.yudao.module.srm.service.tender.SrmBidEvaluationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@Tag(name = "管理后台 - SRM 评标管理")
@RestController
@RequestMapping("/srm/bid-evaluation")
@Validated
public class SrmBidEvaluationController {
 
    @Resource
    private SrmBidEvaluationService bidEvaluationService;
 
    @Resource
    private SrmSupplierService supplierService;
 
    @PostMapping("/create")
    @Operation(summary = "创建评标记录")
    @PreAuthorize("@ss.hasPermission('srm:bid-evaluation:create')")
    public CommonResult<Long> createEvaluation(@Valid @RequestBody SrmBidEvaluationSaveReqVO createReqVO) {
        return success(bidEvaluationService.createEvaluation(createReqVO));
    }
 
    @GetMapping("/list-by-project")
    @Operation(summary = "按招标项目获取评标列表")
    @PreAuthorize("@ss.hasPermission('srm:bid-evaluation:query')")
    public CommonResult<List<SrmBidEvaluationRespVO>> getEvaluationList(@RequestParam("tenderProjectId") Long tenderProjectId) {
        List<SrmBidEvaluationRespVO> list = BeanUtils.toBean(bidEvaluationService.getEvaluationList(tenderProjectId), SrmBidEvaluationRespVO.class);
        enrichEvaluationSupplierNames(list);
        return success(list);
    }
 
    private void enrichEvaluationSupplierNames(List<SrmBidEvaluationRespVO> list) {
        if (list == null || list.isEmpty()) return;
        Set<Long> supplierIds = CollectionUtils.convertSet(list, SrmBidEvaluationRespVO::getSupplierId);
        Map<Long, SrmSupplierDO> supplierMap = supplierService.getSupplierMap(supplierIds);
        list.forEach(vo -> {
            SrmSupplierDO supplier = supplierMap.get(vo.getSupplierId());
            if (supplier != null) {
                vo.setSupplierName(supplier.getName());
            }
        });
    }
 
    @PutMapping("/calculate-ranking")
    @Operation(summary = "计算排名")
    @PreAuthorize("@ss.hasPermission('srm:bid-evaluation:update')")
    public CommonResult<Boolean> calculateRanking(@RequestParam("tenderProjectId") Long tenderProjectId) {
        bidEvaluationService.calculateRanking(tenderProjectId);
        return success(true);
    }
 
    // ========== 开标 ==========
 
    @PostMapping("/bid-open/create")
    @Operation(summary = "开标")
    @PreAuthorize("@ss.hasPermission('srm:bid-open:create')")
    public CommonResult<Long> createBidOpen(@RequestParam("tenderProjectId") Long tenderProjectId) {
        return success(bidEvaluationService.createBidOpen(tenderProjectId));
    }
 
    @GetMapping("/bid-open/get")
    @Operation(summary = "获取开标记录")
    @PreAuthorize("@ss.hasPermission('srm:bid-open:query')")
    public CommonResult<SrmBidOpenRespVO> getBidOpen(@RequestParam("id") Long id) {
        return success(BeanUtils.toBean(bidEvaluationService.getBidOpen(id), SrmBidOpenRespVO.class));
    }
 
}