| | |
| | | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| | | 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.dal.dataobject.SrmTenderMaterialDO; |
| | | import cn.iocoder.yudao.module.srm.dal.mysql.SrmTenderMaterialMapper; |
| | | import cn.iocoder.yudao.module.srm.service.supplier.SrmSupplierService; |
| | | import cn.iocoder.yudao.module.srm.service.tender.SrmTenderBidService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | |
| | | |
| | | @Resource |
| | | private SrmSupplierService supplierService; |
| | | |
| | | @Resource |
| | | private SrmTenderMaterialMapper tenderMaterialMapper; |
| | | |
| | | // ========== 投标管理 ========== |
| | | |
| | |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/update-total") |
| | | @Operation(summary = "更新投标总金额") |
| | | @Parameter(name = "id", description = "投标ID", required = true) |
| | | @Parameter(name = "bidTotalAmount", description = "投标总金额(报价合计自动带出后可人工调整)") |
| | | @PreAuthorize("@ss.hasPermission('srm:tender-bid:update')") |
| | | public CommonResult<Boolean> updateBidTotal(@RequestParam("id") Long id, |
| | | @RequestParam(value = "bidTotalAmount", required = false) BigDecimal bidTotalAmount) { |
| | | tenderBidService.updateBidTotal(id, bidTotalAmount); |
| | | return success(true); |
| | | } |
| | | |
| | | // ========== 供应商报价 ========== |
| | | |
| | | @PostMapping("/quote/create") |
| | |
| | | @Operation(summary = "按投标获取报价列表") |
| | | @PreAuthorize("@ss.hasPermission('srm:supplier-quote:query')") |
| | | public CommonResult<List<SrmSupplierQuoteRespVO>> getQuoteListByBid(@RequestParam("bidId") Long bidId) { |
| | | return success(BeanUtils.toBean(tenderBidService.getQuoteList(bidId), SrmSupplierQuoteRespVO.class)); |
| | | List<SrmSupplierQuoteRespVO> list = BeanUtils.toBean(tenderBidService.getQuoteList(bidId), SrmSupplierQuoteRespVO.class); |
| | | enrichQuoteMaterialInfo(list); |
| | | return success(list); |
| | | } |
| | | |
| | | private void enrichQuoteMaterialInfo(List<SrmSupplierQuoteRespVO> list) { |
| | | if (list == null || list.isEmpty()) return; |
| | | Set<Long> materialIds = CollectionUtils.convertSet(list, SrmSupplierQuoteRespVO::getTenderMaterialId); |
| | | Map<Long, SrmTenderMaterialDO> materialMap = tenderMaterialMapper.selectBatchIds(materialIds).stream() |
| | | .collect(java.util.stream.Collectors.toMap(SrmTenderMaterialDO::getId, m -> m)); |
| | | list.forEach(vo -> { |
| | | SrmTenderMaterialDO material = materialMap.get(vo.getTenderMaterialId()); |
| | | if (material != null) { |
| | | vo.setTenderMaterialCode(material.getProductCode()); |
| | | vo.setTenderMaterialName(material.getProductName()); |
| | | vo.setMaterialName(material.getProductName()); |
| | | vo.setTenderMaterialSpec(material.getProductSpec()); |
| | | vo.setTenderMaterialUnit(material.getUnit()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // ========== 关联数据填充 ========== |