@@ -1,6 +1,7 @@ | |||
package com.hz.pm.api.external; | |||
import cn.hutool.core.date.LocalDateTimeUtil; | |||
import cn.hutool.core.io.resource.ClassPathResource; | |||
import cn.hutool.core.lang.TypeReference; | |||
import cn.hutool.http.HttpUtil; | |||
import cn.hutool.json.JSONObject; | |||
@@ -15,7 +16,6 @@ import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.stereotype.Component; | |||
import java.time.LocalDateTime; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER; | |||
@@ -128,65 +128,13 @@ public class MhApiClient { | |||
return Boolean.FALSE; | |||
} | |||
static final String DICT_RET_JSON = "{\n" + | |||
" \"code\": 200,\n" + | |||
" \"msg\": \"success\",\n" + | |||
" \"data\": [\n" + | |||
" {\n" + | |||
" \"id\": \"035931f1fdb698cdf0d4cb7a04154a34\",\n" + | |||
" \"dictSort\": 0,\n" + | |||
" \"dictLabel\": \"竞争性切磋\",\n" + | |||
" \"dictValue\": \"JZXQC\",\n" + | |||
" \"dictType\": \"buy_way\",\n" + | |||
" \"dictId\": \"6f578f6f717a5d5bb0bf63a9b0870239\",\n" + | |||
" \"isDefault\": \"N\",\n" + | |||
" \"status\": \"0\",\n" + | |||
" \"remark\": null,\n" + | |||
" \"createTime\": \"2024-01-3021:21:40\",\n" + | |||
" \"updateTime\": null,\n" + | |||
" \"createBy\": \"7b40b2e2d396930d4f8567fd3d47a39e\",\n" + | |||
" \"updateBy\": \"\"\n" + | |||
" },\n" + | |||
" {\n" + | |||
" \"id\": \"1b66784a1af14660186d5e3e40dec96b\",\n" + | |||
" \"dictSort\": 0,\n" + | |||
" \"dictLabel\": \"询价\",\n" + | |||
" \"dictValue\": \"XJ\",\n" + | |||
" \"dictType\": \"buy_way\",\n" + | |||
" \"dictId\": \"6f578f6f717a5d5bb0bf63a9b0870239\",\n" + | |||
" \"isDefault\": \"N\",\n" + | |||
" \"status\": \"0\",\n" + | |||
" \"remark\": null,\n" + | |||
" \"createTime\": \"2024-01-3021:22:04\",\n" + | |||
" \"updateTime\": null,\n" + | |||
" \"createBy\": \"7b40b2e2d396930d4f8567fd3d47a39e\",\n" + | |||
" \"updateBy\": \"\"\n" + | |||
" },\n" + | |||
" {\n" + | |||
" \"id\": \"fc5d7c2cb97b15db54e3f6265df9e5f1\",\n" + | |||
" \"dictSort\": 0,\n" + | |||
" \"dictLabel\": \"邀请招标\",\n" + | |||
" \"dictValue\": \"YQZB\",\n" + | |||
" \"dictType\": \"buy_way\",\n" + | |||
" \"dictId\": \"6f578f6f717a5d5bb0bf63a9b0870239\",\n" + | |||
" \"isDefault\": \"N\",\n" + | |||
" \"status\": \"0\",\n" + | |||
" \"remark\": null,\n" + | |||
" \"createTime\": \"2024-01-3021:18:39\",\n" + | |||
" \"updateTime\": null,\n" + | |||
" \"createBy\": \"7b40b2e2d396930d4f8567fd3d47a39e\",\n" + | |||
" \"updateBy\": \"\"\n" + | |||
" }\n" + | |||
" ]\n" + | |||
"}"; | |||
public List<MhDictDTO> dictListByType(MhDictType dictType) { | |||
String retBody; | |||
if (!environmentUtil.isDevEnv()) { | |||
String url = mhApiHost + DICT_URL; | |||
retBody = HttpUtil.get(url + "?dictType=" + dictType); | |||
} else { | |||
retBody = DICT_RET_JSON; | |||
retBody = new ClassPathResource("/response/ret-purchase-method.json").readUtf8Str(); | |||
} | |||
MhRetDTO<List<MhDictDTO>> retObj = JSONUtil.toBean(retBody, | |||
new TypeReference<MhRetDTO<List<MhDictDTO>>>() { | |||
@@ -205,7 +153,7 @@ public class MhApiClient { | |||
String url = mhApiHost + PURCHASE_NOTICE_GET; | |||
retBody = HttpUtil.get(url + "?unitId=" + unitId); | |||
} else { | |||
return Collections.emptyList(); | |||
retBody = new ClassPathResource("/response/ret-purchase-intention.json").readUtf8Str(); | |||
} | |||
MhRetDTO<List<MhPurchaseIntentionDTO>> retObj = JSONUtil.toBean(retBody, | |||
new TypeReference<MhRetDTO<List<MhPurchaseIntentionDTO>>>() { | |||
@@ -218,5 +166,4 @@ public class MhApiClient { | |||
} | |||
} | |||
} |
@@ -4,6 +4,7 @@ import com.hz.pm.api.common.util.ExcelDownUtil; | |||
import com.hz.pm.api.projectdeclared.manage.PurchaseManage; | |||
import com.hz.pm.api.projectdeclared.model.dto.PurchaseSaveDTO; | |||
import com.hz.pm.api.projectdeclared.model.req.*; | |||
import com.hz.pm.api.projectdeclared.model.req.SubmitPurchaseNoticeReq.PurchaseNoticeTenderDTO; | |||
import com.hz.pm.api.projectdeclared.model.vo.PurchaseVO; | |||
import com.hz.pm.api.projectdeclared.model.vo.TestValidListVO; | |||
import com.hz.pm.api.projectdeclared.model.vo.XcfhxApplyListVO; | |||
@@ -121,4 +122,10 @@ public class PurchaseController { | |||
return purchaseManage.pageXcfhxApply(req); | |||
} | |||
@GetMapping("/purchaseIntention/{unitId}") | |||
@ApiOperation("获取采购意向") | |||
public List<PurchaseNoticeTenderDTO> listPurchaseIntention(@PathVariable Long unitId) { | |||
return purchaseManage.listPurchaseIntention(unitId); | |||
} | |||
} |
@@ -2,6 +2,7 @@ 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.io.FileUtil; | |||
import cn.hutool.core.lang.Assert; | |||
import cn.hutool.core.util.StrUtil; | |||
@@ -29,6 +30,7 @@ import com.hz.pm.api.datascope.model.DataScopeDTO; | |||
import com.hz.pm.api.datascope.utils.DataScopeUtil; | |||
import com.hz.pm.api.external.MhApiClient; | |||
import com.hz.pm.api.external.MhFileClient; | |||
import com.hz.pm.api.external.model.dto.MhPurchaseIntentionDTO; | |||
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; | |||
@@ -87,6 +89,7 @@ import org.springframework.transaction.annotation.Transactional; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.io.IOException; | |||
import java.math.BigDecimal; | |||
import java.math.RoundingMode; | |||
import java.time.LocalDateTime; | |||
import java.time.format.DateTimeFormatter; | |||
import java.util.*; | |||
@@ -408,6 +411,8 @@ public class PurchaseManage { | |||
tmpFile.deleteOnExit(); | |||
return fileId; | |||
}).collect(Collectors.joining(",")); | |||
PurchaseScopeEnum scope = PurchaseScopeEnum.getByCode(w.getPurchaseScope()) | |||
.orElseThrow(() -> BizException.wrap("采购范围无效")); | |||
return MhPurchaseNoticeDTO.builder() | |||
.bidOpenTime(DateUtil.date(w.getBidStartTime()).toJdkDate()) | |||
.endTime(DateUtil.date(w.getBidEndTime()).toJdkDate()) | |||
@@ -415,7 +420,7 @@ public class PurchaseManage { | |||
.budgetMoney(w.getBidBudget().multiply(BigDecimal.valueOf(10000))) | |||
.buyItem(w.getBidName()) | |||
.buyFile(fileIds) | |||
.buyScope(PurchaseScopeEnum.PUBLIC.eq(w.getPurchaseScope()) ? "Y" : "N") | |||
.buyScope(scope.getMhCode()) | |||
.buyWay(w.getPurchaseMethod()) | |||
.buyUnitName(w.getPurchaseUnit()) | |||
.createUnit(w.getPurchaseUnitId().intValue()) | |||
@@ -752,4 +757,28 @@ public class PurchaseManage { | |||
return PageVo.of(data, page.getTotal()); | |||
} | |||
public List<PurchaseNoticeTenderDTO> listPurchaseIntention(Long unitId) { | |||
List<MhPurchaseIntentionDTO> intentions = mhApiClient.listPurchaseNotice(unitId); | |||
if (intentions.isEmpty()) { | |||
return Collections.emptyList(); | |||
} | |||
return intentions.stream().map(w -> { | |||
PurchaseScopeEnum scope = PurchaseScopeEnum.getByMhCode(w.getBuyScope()) | |||
.orElseThrow(() -> BizException.wrap("采购范围无效")); | |||
PurchaseNoticeTenderDTO item = new PurchaseNoticeTenderDTO(); | |||
item.setBidName(w.getBuyItem()); | |||
item.setBidBudget(BigDecimal.valueOf(w.getBudgetMoney()) | |||
.divide(BigDecimal.valueOf(10000), RoundingMode.HALF_UP)); | |||
item.setPurchaseMethod(w.getBuyWay()); | |||
item.setPurchaseContact(w.getLinkUser()); | |||
item.setPurchasePhone(w.getLinkPhone()); | |||
item.setPurchaseConnectAddress(w.getDetailAddress()); | |||
BizUtils.notNull(w.getBidOpenTime(), t -> item.setBidStartTime(LocalDateTimeUtil.of(t))); | |||
BizUtils.notNull(w.getEndTime(), t -> item.setBidEndTime(LocalDateTimeUtil.of(t))); | |||
item.setPurchaseRemark(w.getBuyDesc()); | |||
item.setPurchaseScope(scope.getCode()); | |||
return item; | |||
}).collect(Collectors.toList()); | |||
} | |||
} |
@@ -3,6 +3,9 @@ package com.hz.pm.api.projectdeclared.model.enumerization; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Getter; | |||
import java.util.Arrays; | |||
import java.util.Optional; | |||
/** | |||
* <p> | |||
* PurchaseScopeEnum | |||
@@ -15,14 +18,27 @@ import lombok.Getter; | |||
@AllArgsConstructor | |||
public enum PurchaseScopeEnum { | |||
PUBLIC(1, "公开采购"), | |||
PRIVATE(2, "非公开采购"); | |||
PUBLIC(1, "公开采购", "Y"), | |||
PRIVATE(2, "非公开采购", "N"); | |||
private final Integer code; | |||
private final String val; | |||
private final String mhCode; | |||
public boolean eq(Integer code) { | |||
return this.code.equals(code); | |||
} | |||
public static Optional<PurchaseScopeEnum> getByMhCode(String mhCode) { | |||
return Arrays.stream(values()) | |||
.filter(w -> w.getMhCode().equals(mhCode)) | |||
.findFirst(); | |||
} | |||
public static Optional<PurchaseScopeEnum> getByCode(Integer code) { | |||
return Arrays.stream(values()) | |||
.filter(w -> w.getCode().equals(code)) | |||
.findFirst(); | |||
} | |||
} |
@@ -0,0 +1,101 @@ | |||
{ | |||
"code": 200, | |||
"msg": "success", | |||
"data": [ | |||
{ | |||
"id": "035931f1fdb698cdf0d4cb7a04154a34", | |||
"dictSort": 0, | |||
"dictLabel": "竞争性切磋", | |||
"dictValue": "JZXQC", | |||
"dictType": "buy_way", | |||
"dictId": "6f578f6f717a5d5bb0bf63a9b0870239", | |||
"isDefault": "N", | |||
"status": "0", | |||
"remark": null, | |||
"createTime": "2024-01-3021:21:40", | |||
"updateTime": null, | |||
"createBy": "7b40b2e2d396930d4f8567fd3d47a39e", | |||
"updateBy": "" | |||
}, | |||
{ | |||
"id": "1b66784a1af14660186d5e3e40dec96b", | |||
"dictSort": 0, | |||
"dictLabel": "询价", | |||
"dictValue": "XJ", | |||
"dictType": "buy_way", | |||
"dictId": "6f578f6f717a5d5bb0bf63a9b0870239", | |||
"isDefault": "N", | |||
"status": "0", | |||
"remark": null, | |||
"createTime": "2024-01-3021:22:04", | |||
"updateTime": null, | |||
"createBy": "7b40b2e2d396930d4f8567fd3d47a39e", | |||
"updateBy": "" | |||
}, | |||
{ | |||
"id": "fc5d7c2cb97b15db54e3f6265df9e5f1", | |||
"dictSort": 0, | |||
"dictLabel": "邀请招标", | |||
"dictValue": "YQZB", | |||
"dictType": "buy_way", | |||
"dictId": "6f578f6f717a5d5bb0bf63a9b0870239", | |||
"isDefault": "N", | |||
"status": "0", | |||
"remark": null, | |||
"createTime": "2024-01-3021:18:39", | |||
"updateTime": null, | |||
"createBy": "7b40b2e2d396930d4f8567fd3d47a39e", | |||
"updateBy": "" | |||
} | |||
] | |||
} |