From 13535640273e8db4669227598b13c213571003e9 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Tue, 26 Mar 2024 16:18:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E4=BF=A1=E4=BA=A7=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E5=85=AC=E5=91=8A=E5=8F=91=E5=B8=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hz/pm/api/external/MhApiClient.java | 18 ++++ .../external/model/dto/MhPurchaseNoticeDTO.java | 109 +++++++++++++++++++++ .../api/projectdeclared/manage/PurchaseManage.java | 42 +++++++- .../model/enumerization/PurchaseScopeEnum.java | 4 + 4 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhPurchaseNoticeDTO.java diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/MhApiClient.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/MhApiClient.java index 3456b27..920f0d3 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/MhApiClient.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/MhApiClient.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import java.time.LocalDateTime; import java.util.List; +import java.util.Objects; import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER; @@ -53,6 +54,8 @@ public class MhApiClient { private static final String DICT_URL = "/dict_data/listByType"; + private static final String PURCHASE_NOTICE = "/buy_notice/saveBuyNoticeList"; + public MhRetDTO> queryUnits() { String requestUrl = mhApiHost + UNIT_URL; @@ -97,6 +100,21 @@ public class MhApiClient { }, false); } + public void publishPurchaseNotice(List notices) { + if (environmentUtil.isDevEnv()) { + return; + } + String requestUrl = mhApiHost + PURCHASE_NOTICE; + String retBody = HttpUtil.post(requestUrl, JSONUtil.toJsonStr(notices)); + MhRetDTO retObj = JSONUtil.toBean(retBody, + new TypeReference>() { + }, false); + if (!retObj.isOk()) { + log.error("采购公告发布失败:{}", retBody); + throw BizException.wrap("采购公告发布失败"); + } + } + public boolean sendZwddWorkNotice(MhZwddWorkNoticeDTO notice) { notice.setClientId(zwddWorkNoticeClientId); notice.setClientSecret(zwddWorkNoticeClientSecret); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhPurchaseNoticeDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhPurchaseNoticeDTO.java new file mode 100644 index 0000000..ea5be0e --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhPurchaseNoticeDTO.java @@ -0,0 +1,109 @@ +package com.hz.pm.api.external.model.dto; + +import lombok.Builder; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + *

+ * 采购公告发布实体 + *

+ * + * @author WendyYang + * @since 15:42 2024/3/26 + */ +@Data +@Builder +public class MhPurchaseNoticeDTO { + /** + * 采购ID + */ + private String id; + /** + * 采购物品 + */ + private String buyItem; + /** + * 预算金额 + */ + private BigDecimal budgetMoney; + /** + * 采购方式 + */ + private String buyWay; + /** + * 开标时间 + */ + private Date bidOpenTime; + /** + * 结束时间 + */ + private Date endTime; + /** + * 详细地址 + */ + private String detailAddress; + /** + * 链接地址 + */ + private String linkAddress; + /** + * 采购描述 + */ + private String buyDesc; + /** + * 采购文件 + */ + private String buyFile; + /** + * 采购单位名称 + */ + private String buyUnitName; + /** + * 创建单位 + */ + private Integer createUnit; + /** + * 联系人 + */ + private String linkUser; + /** + * 联系电话 + */ + private String linkPhone; + /** + * 创建用户 + */ + private String createUser; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新用户 + */ + private String updateUser; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 发布状态:W暂存待发布/撤回,Y已发布 + */ + private String postStatus; + /** + * 查看次数 + */ + private int viewCount; + /** + * 采购范围:Y公开采购,N非公开采购 + */ + private String buyScope; + /** + * 类型:CGYS 采购意向、ZBGG 招标公告 + */ + private String type; + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java index f25deab..4d893e5 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java @@ -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 notices = new ArrayList<>(); List 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) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/enumerization/PurchaseScopeEnum.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/enumerization/PurchaseScopeEnum.java index 106b026..df22e45 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/enumerization/PurchaseScopeEnum.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/enumerization/PurchaseScopeEnum.java @@ -21,4 +21,8 @@ public enum PurchaseScopeEnum { private final Integer code; private final String val; + public boolean eq(Integer code) { + return this.code.equals(code); + } + }