Commit 0a5f4bb4 authored by 李灿灿's avatar 李灿灿

订单回复推ekp,附件推送送删除

parent 65badb9c
...@@ -57,7 +57,7 @@ public class EkpOrderUtil { ...@@ -57,7 +57,7 @@ public class EkpOrderUtil {
wholeForm.add("fdModelId", ekpProperties.getOrderFdModelId()); wholeForm.add("fdModelId", ekpProperties.getOrderFdModelId());
wholeForm.add("fdFlowId", ekpProperties.getOrderFdFlowId()); wholeForm.add("fdFlowId", ekpProperties.getOrderFdFlowId());
wholeForm.add("formValues", formValues); wholeForm.add("formValues", formValues);
System.out.println("wholeForm:" + wholeForm); log.info("wholeForm:" + wholeForm);
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
//如果EKP对该接口启用了Basic认证,那么客户端需要加入 //如果EKP对该接口启用了Basic认证,那么客户端需要加入
//addAuth(headers,"yourAccount"+":"+"yourPassword");是VO,则使用APPLICATION_JSON //addAuth(headers,"yourAccount"+":"+"yourPassword");是VO,则使用APPLICATION_JSON
...@@ -75,7 +75,7 @@ public class EkpOrderUtil { ...@@ -75,7 +75,7 @@ public class EkpOrderUtil {
return body; return body;
} }
}catch (Exception e){ }catch (Exception e){
log.info(e); log.error(e);
return null; return null;
} }
} }
...@@ -90,6 +90,7 @@ public class EkpOrderUtil { ...@@ -90,6 +90,7 @@ public class EkpOrderUtil {
public String sendReplyToEKP(EkpOrderReplyParam param, MultipartFile[] multipartFiles){ public String sendReplyToEKP(EkpOrderReplyParam param, MultipartFile[] multipartFiles){
log.info("推送EKP开始--订单回复信息"); log.info("推送EKP开始--订单回复信息");
RestTemplate yourRestTemplate = new RestTemplate(); RestTemplate yourRestTemplate = new RestTemplate();
List<AttachmentForm> fileList = createAllAttach(multipartFiles);
try{ try{
String formValues = new ObjectMapper().writeValueAsString(param); String formValues = new ObjectMapper().writeValueAsString(param);
//指向EKP的接口url //指向EKP的接口url
...@@ -101,11 +102,9 @@ public class EkpOrderUtil { ...@@ -101,11 +102,9 @@ public class EkpOrderUtil {
wholeForm.add("fdModelId", ekpProperties.getReplyFdModelId()); wholeForm.add("fdModelId", ekpProperties.getReplyFdModelId());
wholeForm.add("fdFlowId", ekpProperties.getReplyFdFlowId()); wholeForm.add("fdFlowId", ekpProperties.getReplyFdFlowId());
wholeForm.add("formValues", formValues); wholeForm.add("formValues", formValues);
wholeForm.add("attachmentForms", fileList);
//注意附件列表的key是一样的 log.info("wholeForm:" + wholeForm);
wholeForm.add("attachmentForms",createAllAttach(multipartFiles));
System.out.println("wholeForm:" + wholeForm);
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
//如果EKP对该接口启用了Basic认证,那么客户端需要加入 //如果EKP对该接口启用了Basic认证,那么客户端需要加入
//addAuth(headers,"yourAccount"+":"+"yourPassword");是VO,则使用APPLICATION_JSON //addAuth(headers,"yourAccount"+":"+"yourPassword");是VO,则使用APPLICATION_JSON
...@@ -123,8 +122,15 @@ public class EkpOrderUtil { ...@@ -123,8 +122,15 @@ public class EkpOrderUtil {
return body; return body;
} }
}catch (Exception e){ }catch (Exception e){
log.info(e); log.error(e);
return null; return null;
}finally {
//将产生的临时附件删除,这里的fileList没值得话是[],不会是null,如果是null需要做判空处理
fileList.stream().forEach(e -> {
FileDataSource dataSource = (FileDataSource)e.getFdAttachment().getDataSource();
boolean delete = dataSource.getFile().delete();
log.info("临时附件删除结果:",delete);
});
} }
} }
...@@ -135,20 +141,24 @@ public class EkpOrderUtil { ...@@ -135,20 +141,24 @@ public class EkpOrderUtil {
* @param multipartFiles * @param multipartFiles
* @return {@link List<AttachmentForm>} * @return {@link List<AttachmentForm>}
*/ */
public List<AttachmentForm> createAllAttach(MultipartFile[] multipartFiles) throws Exception { public List<AttachmentForm> createAllAttach(MultipartFile[] multipartFiles){
List<AttachmentForm> attForms = new ArrayList<>(); List<AttachmentForm> attForms = new ArrayList<>();
if (ArrayUtils.isNotEmpty(multipartFiles)){ if (ArrayUtils.isNotEmpty(multipartFiles)){
for (MultipartFile multipartFile : multipartFiles) { try {
AttachmentForm attForm = new AttachmentForm(); for (MultipartFile multipartFile : multipartFiles) {
//设置附件关键字,表单模式下为附件控件的id AttachmentForm attForm = new AttachmentForm();
attForm.setFdKey(ekpProperties.getReplyAttachKey()); //设置附件关键字,注意附件列表的key是一样的
attForm.setFdFileName(multipartFile.getOriginalFilename()); attForm.setFdKey(ekpProperties.getReplyAttachKey());
File file = new File("G:\\tmp\\" + multipartFile.getOriginalFilename()); attForm.setFdFileName(multipartFile.getOriginalFilename());
FileUtils.copyInputStreamToFile(multipartFile.getInputStream(), file); File file = new File(multipartFile.getOriginalFilename());
DataSource dataSource = new FileDataSource(file); FileUtils.copyInputStreamToFile(multipartFile.getInputStream(), file);
DataHandler dataHandler = new DataHandler(dataSource); DataSource dataSource = new FileDataSource(file);
attForm.setFdAttachment(dataHandler); DataHandler dataHandler = new DataHandler(dataSource);
attForms.add(attForm); attForm.setFdAttachment(dataHandler);
attForms.add(attForm);
}
}catch (Exception e){
log.error("createAllAttach--->error:",e);
} }
} }
return attForms; return attForms;
......
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