|
|
@@ -1,6 +1,8 @@ |
|
|
|
package com.hz.pm.api.projectdeclared.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil; |
|
|
|
import cn.hutool.core.lang.Assert; |
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
@@ -11,11 +13,15 @@ import com.hz.pm.api.common.statemachine.util.StateMachineUtil; |
|
|
|
import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; |
|
|
|
import com.hz.pm.api.common.util.ExcelDownUtil; |
|
|
|
import com.hz.pm.api.common.util.ExcelExportStyle; |
|
|
|
import com.hz.pm.api.external.MhApiClient; |
|
|
|
import com.hz.pm.api.external.model.dto.MhPurchaseNoticeDTO; |
|
|
|
import com.hz.pm.api.projectdeclared.model.dto.DeclaredProjectExportDTO; |
|
|
|
import com.hz.pm.api.projectdeclared.model.dto.PurchaseSaveDTO; |
|
|
|
import com.hz.pm.api.projectdeclared.model.entity.Contract; |
|
|
|
import com.hz.pm.api.projectdeclared.model.entity.Purchase; |
|
|
|
import com.hz.pm.api.projectdeclared.model.enumerization.PurchaseScopeEnum; |
|
|
|
import com.hz.pm.api.projectdeclared.model.req.SubmitPurchaseNoticeReq; |
|
|
|
import com.hz.pm.api.projectdeclared.model.req.SubmitPurchaseNoticeReq.PurchaseNoticeTenderDTO; |
|
|
|
import com.hz.pm.api.projectdeclared.model.req.SubmitPurchaseRecordReq; |
|
|
|
import com.hz.pm.api.projectdeclared.model.vo.PurchaseVO; |
|
|
|
import com.hz.pm.api.projectdeclared.service.IContractService; |
|
|
@@ -48,9 +54,7 @@ import java.io.IOException; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@@ -71,6 +75,7 @@ public class PurchaseManage { |
|
|
|
private final IPurchaseService purchaseService; |
|
|
|
private final TenderStateMachineUtil tenderStateMachineUtil; |
|
|
|
private final StateMachineUtil stateMachineUtil; |
|
|
|
private final MhApiClient mhApiClient; |
|
|
|
|
|
|
|
/** |
|
|
|
* 待采购的-项目列表 |
|
|
@@ -256,6 +261,7 @@ public class PurchaseManage { |
|
|
|
VUtils.isTrue(!ProjectStatusEnum.TO_BE_PURCHASED.eq(project.getStatus()) |
|
|
|
|| !ProjectStatusEnum.PROJECT_APPROVED.eq(project.getStage())) |
|
|
|
.throwMessage("提交失败,该项目不是待采购备案状态或者已立项阶段"); |
|
|
|
List<MhPurchaseNoticeDTO> notices = new ArrayList<>(); |
|
|
|
List<Purchase> purchases = req.getTenders().stream().map(w -> { |
|
|
|
Purchase purchase = new Purchase(); |
|
|
|
purchase.setPurchaseMethod(w.getPurchaseMethod()); |
|
|
@@ -279,11 +285,41 @@ public class PurchaseManage { |
|
|
|
purchase.setCreateBy(user.getUserIdStr()); |
|
|
|
} |
|
|
|
purchase.setStatus(TenderStatusEnum.TO_BE_SUBMIT_PURCHASE_INFO.getTenderStatus()); |
|
|
|
notices.add(buildPurchaseNotice(w, user)); |
|
|
|
return purchase; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
purchaseService.saveOrUpdateBatch(purchases); |
|
|
|
stateMachineUtil.pass(project); |
|
|
|
projectService.updateById(project); |
|
|
|
// 发布采购公告 |
|
|
|
mhApiClient.publishPurchaseNotice(notices); |
|
|
|
} |
|
|
|
|
|
|
|
private MhPurchaseNoticeDTO buildPurchaseNotice(PurchaseNoticeTenderDTO w, UserInfoDetails user) { |
|
|
|
Date now = new Date(); |
|
|
|
return MhPurchaseNoticeDTO.builder() |
|
|
|
.bidOpenTime(DateUtil.date(w.getBidStartTime()).toJdkDate()) |
|
|
|
.endTime(DateUtil.date(w.getBidEndTime()).toJdkDate()) |
|
|
|
.buyDesc(w.getPurchaseRemark()) |
|
|
|
.budgetMoney(w.getBidBudget()) |
|
|
|
.buyItem(w.getBidName()) |
|
|
|
.buyFile(w.getBidDoc()) |
|
|
|
.buyScope(PurchaseScopeEnum.PUBLIC.eq(w.getPurchaseScope()) ? "Y" : "N") |
|
|
|
.buyWay(w.getPurchaseMethod()) |
|
|
|
.buyUnitName(w.getPurchaseUnit()) |
|
|
|
.createUnit(w.getPurchaseUnitId().intValue()) |
|
|
|
.createTime(now) |
|
|
|
.updateTime(now) |
|
|
|
.createUser(user.getMhUserId()) |
|
|
|
.updateUser(user.getMhUserId()) |
|
|
|
// 招标采购 |
|
|
|
.type("ZBGG") |
|
|
|
.detailAddress(w.getPurchaseConnectAddress()) |
|
|
|
.linkAddress(w.getBidAddress()) |
|
|
|
.linkUser(w.getPurchaseContact()) |
|
|
|
.linkPhone(w.getPurchasePhone()) |
|
|
|
.postStatus("Y") |
|
|
|
.build(); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|