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

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

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