Commit dc876985 authored by fangxinjiang's avatar fangxinjiang

项目订单附件上传优化-fxj

parent f16dbd62
......@@ -20,10 +20,6 @@ public class EkpOrderProperties {
* 接口url
*/
String url;
/**
* 接口url
*/
String url2;
/**
* 订单modelId
......
package com.yifu.cloud.plus.v1.yifu.ekp.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.ekp.config.EkpOrderProperties;
import com.yifu.cloud.plus.v1.yifu.ekp.constant.EkpConstants;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpOrderParam;
......@@ -13,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.*;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
......@@ -29,6 +34,7 @@ import java.util.List;
*/
@Log4j2
@EnableConfigurationProperties(EkpOrderProperties.class)
@Component
public class EkpOrderUtil {
@Autowired
private EkpOrderProperties ekpProperties;
......@@ -145,16 +151,20 @@ public class EkpOrderUtil {
* @Date 15:10 2024/11/15
* @Param
* @return
**/
**/
@Async
public String syncFileFromEkp(String orderNo, String attIds){
log.info("同步项目订单附件信息");
RestTemplate yourRestTemplate = new RestTemplate();
String formValues = "{}";
try{
//指向EKP的接口url
//把ModelingAppModelParameterAddForm转换成MultiValueMap
MultiValueMap<String,Object> wholeForm = new LinkedMultiValueMap<>();
wholeForm.add("orderNo", orderNo);
wholeForm.add("attIds", attIds);
wholeForm.add("fileFlag", CommonConstants.ZERO_STRING);
wholeForm.add("formValues", formValues);
HttpHeaders headers = new HttpHeaders();
//如果EKP对该接口启用了Basic认证,那么客户端需要加入
//addAuth(headers,"yourAccount"+":"+"yourPassword");是VO,则使用APPLICATION_JSON
......@@ -162,7 +172,8 @@ public class EkpOrderUtil {
//必须设置上传类型,如果入参是字符串,使用MediaType.TEXT_PLAIN;如果
HttpEntity<MultiValueMap<String,Object>> entity = new HttpEntity<MultiValueMap<String,Object>>(wholeForm,headers);
//有返回值的情况 VO可以替换成具体的JavaBean
ResponseEntity<String> obj = yourRestTemplate.exchange(ekpProperties.getUrl2(), HttpMethod.POST, entity, String.class);
ResponseEntity<String> obj = yourRestTemplate.exchange(ekpProperties.getUrl(), HttpMethod.POST, entity, String.class);
log.error("附件同步结果:"+ JSONObject.toJSONString(obj));
String body = obj.getBody();
if (StringUtils.isBlank(body)){
log.error(EkpConstants.SEND_FAILED);
......@@ -176,5 +187,4 @@ public class EkpOrderUtil {
return "项目订单附件同步异常:"+e.getMessage();
}
}
}
#ekporder.url=http://192.168.0.228:8080/api/sys-modeling/appModelRestService/addModel
ekporder.url=http://36.7.147.29:27007/api/sys-modeling/appModelRestService/addModel
ekporder.url2=http://36.7.147.29:27007/api/sys-modeling/appModelRestService/updateOrderFileInfo
ekporder.url=http://127.0.0.1:8080/api/sys-modeling/appModelRestService/addModel
ekporder.orderFdModelId=182f1b7ffe2e96f975564e44e559847d
ekporder.orderFdFlowId=182f1c098ce991ca96bc927408792beb
ekporder.replyFdModelId=182f1bb35bb2156fb9a02904bc88dd8a
......
......@@ -548,7 +548,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
order.setDeptId(settleDomain.getId());
}
boolean save = this.save(order);
//异步处理附件信息同步
//异步处理附件信息同步 fxj 2024-11-22 17:46
if (Common.isNotNull(vo.getAttIds())){
this.syncFileFromEkp(order.getOrderNo(),vo.getAttIds());
}
......@@ -572,7 +572,6 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
ekpOrderFileTask.receiveOrderFileAsc(multipartFile.getInputStream(),vo.getOrderNo(),fileName,multipartFile.getOriginalFilename());
}
}
return R.ok(OrderConstants.OPERATE_SUCCESS);
}
......@@ -764,7 +763,6 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
* @Param
* @return
**/
@Async
@Override
public R<String> syncFileFromEkp(String orderNo, String attIds) {
if (StringUtils.isEmpty(orderNo)){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment