@@ -101,9 +101,9 @@ public class MhApiClient { | |||||
} | } | ||||
public void publishPurchaseNotice(List<MhPurchaseNoticeDTO> notices) { | public void publishPurchaseNotice(List<MhPurchaseNoticeDTO> notices) { | ||||
if (environmentUtil.isDevEnv()) { | |||||
/*if (environmentUtil.isDevEnv()) { | |||||
return; | return; | ||||
} | |||||
}*/ | |||||
String requestUrl = mhApiHost + PURCHASE_NOTICE; | String requestUrl = mhApiHost + PURCHASE_NOTICE; | ||||
String retBody = HttpUtil.post(requestUrl, JSONUtil.toJsonStr(notices)); | String retBody = HttpUtil.post(requestUrl, JSONUtil.toJsonStr(notices)); | ||||
MhRetDTO<Object> retObj = JSONUtil.toBean(retBody, | MhRetDTO<Object> retObj = JSONUtil.toBean(retBody, | ||||
@@ -1,6 +1,9 @@ | |||||
package com.hz.pm.api.external; | package com.hz.pm.api.external; | ||||
import cn.hutool.core.io.FileUtil; | |||||
import cn.hutool.core.lang.TypeReference; | import cn.hutool.core.lang.TypeReference; | ||||
import cn.hutool.http.HttpRequest; | |||||
import cn.hutool.http.HttpResponse; | |||||
import cn.hutool.http.HttpUtil; | import cn.hutool.http.HttpUtil; | ||||
import cn.hutool.json.JSONUtil; | import cn.hutool.json.JSONUtil; | ||||
import com.hz.pm.api.external.model.dto.MhFileInfoDTO; | import com.hz.pm.api.external.model.dto.MhFileInfoDTO; | ||||
@@ -11,9 +14,11 @@ import lombok.extern.slf4j.Slf4j; | |||||
import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
import org.springframework.core.env.Environment; | import org.springframework.core.env.Environment; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import org.springframework.web.multipart.MultipartFile; | |||||
import javax.servlet.ServletOutputStream; | import javax.servlet.ServletOutputStream; | ||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
import java.io.File; | |||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -41,6 +46,9 @@ public class MhFileClient { | |||||
@Value("${mh.file.detail-url:}") | @Value("${mh.file.detail-url:}") | ||||
private String fileDetailUrl; | private String fileDetailUrl; | ||||
@Value("${mh.file.upload-url:}") | |||||
private String fileUploadUrl; | |||||
private boolean isProdEnv() { | private boolean isProdEnv() { | ||||
String[] profiles = environment.getActiveProfiles(); | String[] profiles = environment.getActiveProfiles(); | ||||
return Arrays.asList(profiles).contains("prod"); | return Arrays.asList(profiles).contains("prod"); | ||||
@@ -80,4 +88,17 @@ public class MhFileClient { | |||||
} | } | ||||
} | } | ||||
public String uploadFile(File file) { | |||||
HttpRequest request = HttpUtil.createPost(fileUploadUrl); | |||||
request.form("file", file); | |||||
try (HttpResponse response = request.execute()) { | |||||
MhRetDTO retObj = JSONUtil.toBean(response.body(), MhRetDTO.class); | |||||
if (retObj.isOk()) { | |||||
return retObj.getData().toString(); | |||||
} | |||||
log.error("文件上传失败:{}", retObj); | |||||
throw BizException.wrap("文件上传失败"); | |||||
} | |||||
} | |||||
} | } |
@@ -2,8 +2,11 @@ package com.hz.pm.api.projectdeclared.manage; | |||||
import cn.hutool.core.bean.BeanUtil; | import cn.hutool.core.bean.BeanUtil; | ||||
import cn.hutool.core.date.DateUtil; | 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.lang.Assert; | ||||
import cn.hutool.core.util.URLUtil; | |||||
import cn.hutool.http.HttpUtil; | |||||
import cn.hutool.json.JSONUtil; | |||||
import com.alibaba.excel.EasyExcel; | import com.alibaba.excel.EasyExcel; | ||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
@@ -14,6 +17,7 @@ import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; | |||||
import com.hz.pm.api.common.util.ExcelDownUtil; | import com.hz.pm.api.common.util.ExcelDownUtil; | ||||
import com.hz.pm.api.common.util.ExcelExportStyle; | import com.hz.pm.api.common.util.ExcelExportStyle; | ||||
import com.hz.pm.api.external.MhApiClient; | import com.hz.pm.api.external.MhApiClient; | ||||
import com.hz.pm.api.external.MhFileClient; | |||||
import com.hz.pm.api.external.model.dto.MhPurchaseNoticeDTO; | 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.DeclaredProjectExportDTO; | ||||
import com.hz.pm.api.projectdeclared.model.dto.PurchaseSaveDTO; | import com.hz.pm.api.projectdeclared.model.dto.PurchaseSaveDTO; | ||||
@@ -43,15 +47,24 @@ import com.ningdatech.basic.function.VUtils; | |||||
import com.ningdatech.basic.model.PageVo; | import com.ningdatech.basic.model.PageVo; | ||||
import com.ningdatech.basic.util.CollUtils; | import com.ningdatech.basic.util.CollUtils; | ||||
import com.ningdatech.basic.util.NdDateUtils; | import com.ningdatech.basic.util.NdDateUtils; | ||||
import com.ningdatech.file.entity.File; | |||||
import com.ningdatech.file.entity.vo.result.FileResultVO; | |||||
import com.ningdatech.file.service.FileService; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.beans.BeanUtils; | import org.springframework.beans.BeanUtils; | ||||
import org.springframework.mock.web.MockMultipartFile; | |||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
import org.springframework.web.multipart.MultipartFile; | |||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
import java.io.ByteArrayOutputStream; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
import java.net.URL; | |||||
import java.nio.file.Files; | |||||
import java.nio.file.Path; | |||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.time.format.DateTimeFormatter; | import java.time.format.DateTimeFormatter; | ||||
import java.util.*; | import java.util.*; | ||||
@@ -76,6 +89,8 @@ public class PurchaseManage { | |||||
private final TenderStateMachineUtil tenderStateMachineUtil; | private final TenderStateMachineUtil tenderStateMachineUtil; | ||||
private final StateMachineUtil stateMachineUtil; | private final StateMachineUtil stateMachineUtil; | ||||
private final MhApiClient mhApiClient; | private final MhApiClient mhApiClient; | ||||
private final MhFileClient mhFileClient; | |||||
private final FileService fileService; | |||||
/** | /** | ||||
* 待采购的-项目列表 | * 待采购的-项目列表 | ||||
@@ -297,13 +312,24 @@ public class PurchaseManage { | |||||
private MhPurchaseNoticeDTO buildPurchaseNotice(PurchaseNoticeTenderDTO w, UserInfoDetails user) { | private MhPurchaseNoticeDTO buildPurchaseNotice(PurchaseNoticeTenderDTO w, UserInfoDetails user) { | ||||
Date now = new Date(); | Date now = new Date(); | ||||
List<FileResultVO> bidFiles = JSONUtil.toList(w.getBidDoc(), FileResultVO.class); | |||||
List<File> files = fileService.listByIds(CollUtils.fieldSet(bidFiles, FileResultVO::getId)); | |||||
String fileIds = files.stream().map(file -> { | |||||
String fileUrl = fileService.findUrlByFile(file); | |||||
String filePath = FileUtil.getTmpDirPath() + file.getOriginalFileName(); | |||||
java.io.File tmpFile = new java.io.File(filePath); | |||||
HttpUtil.downloadFile(fileUrl, tmpFile); | |||||
String fileId = mhFileClient.uploadFile(tmpFile); | |||||
tmpFile.deleteOnExit(); | |||||
return fileId; | |||||
}).collect(Collectors.joining(",")); | |||||
return MhPurchaseNoticeDTO.builder() | return MhPurchaseNoticeDTO.builder() | ||||
.bidOpenTime(DateUtil.date(w.getBidStartTime()).toJdkDate()) | .bidOpenTime(DateUtil.date(w.getBidStartTime()).toJdkDate()) | ||||
.endTime(DateUtil.date(w.getBidEndTime()).toJdkDate()) | .endTime(DateUtil.date(w.getBidEndTime()).toJdkDate()) | ||||
.buyDesc(w.getPurchaseRemark()) | .buyDesc(w.getPurchaseRemark()) | ||||
.budgetMoney(w.getBidBudget().multiply(BigDecimal.valueOf(10000))) | .budgetMoney(w.getBidBudget().multiply(BigDecimal.valueOf(10000))) | ||||
.buyItem(w.getBidName()) | .buyItem(w.getBidName()) | ||||
.buyFile(w.getBidDoc()) | |||||
.buyFile(fileIds) | |||||
.buyScope(PurchaseScopeEnum.PUBLIC.eq(w.getPurchaseScope()) ? "Y" : "N") | .buyScope(PurchaseScopeEnum.PUBLIC.eq(w.getPurchaseScope()) ? "Y" : "N") | ||||
.buyWay(w.getPurchaseMethod()) | .buyWay(w.getPurchaseMethod()) | ||||
.buyUnitName(w.getPurchaseUnit()) | .buyUnitName(w.getPurchaseUnit()) | ||||
@@ -257,6 +257,8 @@ mh: | |||||
file: | file: | ||||
down-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/previewFileLogin | down-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/previewFileLogin | ||||
detail-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/ossfile/getFileInfoList | detail-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/ossfile/getFileInfoList | ||||
upload-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/uploadFileSkipLogin | |||||
auth-code: | auth-code: | ||||
secret-key: nqkmzqojg5j4eiypr3rb8s7nb4noa8b2 | secret-key: nqkmzqojg5j4eiypr3rb8s7nb4noa8b2 | ||||
agent-login: | agent-login: | ||||
@@ -255,6 +255,7 @@ mh: | |||||
file: | file: | ||||
detail-url: http://10.54.38.13:8081/mh-gateway/oss/ossfile/getFileInfoList | detail-url: http://10.54.38.13:8081/mh-gateway/oss/ossfile/getFileInfoList | ||||
down-url: http://10.54.38.13:8081/mh-gateway/oss/oss/downloadFileNotLogin | down-url: http://10.54.38.13:8081/mh-gateway/oss/oss/downloadFileNotLogin | ||||
upload-url: http://10.54.38.13:8081/mh-gateway/oss/oss/uploadFileSkipLogin | |||||
sync-mh-company: | sync-mh-company: | ||||
open: false | open: false | ||||
sync-mh-user: | sync-mh-user: | ||||
@@ -1,17 +1,26 @@ | |||||
package com.hz.pm.api.todocenter; | package com.hz.pm.api.todocenter; | ||||
import cn.hutool.json.JSONObject; | |||||
import cn.hutool.core.io.FileUtil; | |||||
import cn.hutool.http.HttpUtil; | |||||
import com.hz.pm.api.AppTests; | import com.hz.pm.api.AppTests; | ||||
import com.hz.pm.api.common.helper.UserInfoHelper; | |||||
import com.hz.pm.api.external.MhApiClient; | import com.hz.pm.api.external.MhApiClient; | ||||
import com.hz.pm.api.external.MhFileClient; | |||||
import com.hz.pm.api.external.model.dto.MhZwddWorkNoticeDTO; | import com.hz.pm.api.external.model.dto.MhZwddWorkNoticeDTO; | ||||
import com.hz.pm.api.external.todo.MHTodoClient; | import com.hz.pm.api.external.todo.MHTodoClient; | ||||
import com.hz.pm.api.external.todo.dto.MhTodoExtraParamDTO; | import com.hz.pm.api.external.todo.dto.MhTodoExtraParamDTO; | ||||
import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; | import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; | ||||
import com.hz.pm.api.user.security.model.UserFullInfoDTO; | import com.hz.pm.api.user.security.model.UserFullInfoDTO; | ||||
import com.ningdatech.basic.util.CollUtils; | |||||
import com.ningdatech.file.entity.File; | |||||
import com.ningdatech.file.entity.vo.result.FileResultVO; | |||||
import com.ningdatech.file.service.FileService; | |||||
import org.junit.Test; | import org.junit.Test; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import java.util.Arrays; | |||||
import java.util.List; | |||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
* MhApiClientTest | * MhApiClientTest | ||||
@@ -26,6 +35,10 @@ public class MhApiClientTest extends AppTests { | |||||
private MHTodoClient mhTodoClient; | private MHTodoClient mhTodoClient; | ||||
@Autowired | @Autowired | ||||
private MhApiClient mhApiClient; | private MhApiClient mhApiClient; | ||||
@Autowired | |||||
private MhFileClient mhFileClient; | |||||
@Autowired | |||||
private FileService fileService; | |||||
@Test | @Test | ||||
public void sendTodo() { | public void sendTodo() { | ||||
@@ -45,7 +58,7 @@ public class MhApiClientTest extends AppTests { | |||||
} | } | ||||
@Test | @Test | ||||
public void test(){ | |||||
public void test() { | |||||
MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder() | MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder() | ||||
.title(MHTodoTypeEnum.DECLARED_RECORD_AUDIT.getVal()) | .title(MHTodoTypeEnum.DECLARED_RECORD_AUDIT.getVal()) | ||||
.targetUser("ce44b47503147319fc3b5c826cb51fd2") | .targetUser("ce44b47503147319fc3b5c826cb51fd2") | ||||
@@ -257,6 +257,7 @@ mh: | |||||
file: | file: | ||||
down-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/previewFileLogin | down-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/previewFileLogin | ||||
detail-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/ossfile/getFileInfoList | detail-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/ossfile/getFileInfoList | ||||
upload-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/uploadFileSkipLogin | |||||
auth-code: | auth-code: | ||||
secret-key: nqkmzqojg5j4eiypr3rb8s7nb4noa8b2 | secret-key: nqkmzqojg5j4eiypr3rb8s7nb4noa8b2 | ||||
agent-login: | agent-login: | ||||