Переглянути джерело

对接信产采购公告发布接口

tags/24080901
WendyYang 9 місяці тому
джерело
коміт
1353564027
4 змінених файлів з 170 додано та 3 видалено
  1. +18
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/MhApiClient.java
  2. +109
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhPurchaseNoticeDTO.java
  3. +39
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java
  4. +4
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/enumerization/PurchaseScopeEnum.java

+ 18
- 0
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<List<MhUnitDTO>> queryUnits() {
String requestUrl = mhApiHost + UNIT_URL;
@@ -97,6 +100,21 @@ public class MhApiClient {
}, false);
}

public void publishPurchaseNotice(List<MhPurchaseNoticeDTO> notices) {
if (environmentUtil.isDevEnv()) {
return;
}
String requestUrl = mhApiHost + PURCHASE_NOTICE;
String retBody = HttpUtil.post(requestUrl, JSONUtil.toJsonStr(notices));
MhRetDTO<Object> retObj = JSONUtil.toBean(retBody,
new TypeReference<MhRetDTO<Object>>() {
}, false);
if (!retObj.isOk()) {
log.error("采购公告发布失败:{}", retBody);
throw BizException.wrap("采购公告发布失败");
}
}

public boolean sendZwddWorkNotice(MhZwddWorkNoticeDTO notice) {
notice.setClientId(zwddWorkNoticeClientId);
notice.setClientSecret(zwddWorkNoticeClientSecret);


+ 109
- 0
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;

/**
* <p>
* 采购公告发布实体
* </p>
*
* @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;

}

+ 39
- 3
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<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)


+ 4
- 0
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);
}

}

Завантаження…
Відмінити
Зберегти