Commit 9e572191 authored by 李灿灿's avatar 李灿灿

Merge branch 'feature-licancan' into 'develop'

Feature licancan

See merge request fangxinjiang/yifu!227
parents 3add8e96 b2cb2f2b
......@@ -2,7 +2,6 @@ package com.yifu.cloud.plus.v1.yifu.ekp.util;
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.AttachmentForm;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpOrderParam;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpOrderReplyParam;
import io.micrometer.core.instrument.util.StringUtils;
......@@ -12,15 +11,13 @@ import org.apache.commons.lang.ArrayUtils;
import org.codehaus.jackson.map.ObjectMapper;
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.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
......@@ -90,7 +87,7 @@ public class EkpOrderUtil {
public String sendReplyToEKP(EkpOrderReplyParam param, MultipartFile[] multipartFiles){
log.info("推送EKP开始--订单回复信息");
RestTemplate yourRestTemplate = new RestTemplate();
List<AttachmentForm> fileList = createAllAttach(multipartFiles);
List<File> fileList = new ArrayList<>();
try{
String formValues = new ObjectMapper().writeValueAsString(param);
//指向EKP的接口url
......@@ -102,7 +99,17 @@ public class EkpOrderUtil {
wholeForm.add("fdModelId", ekpProperties.getReplyFdModelId());
wholeForm.add("fdFlowId", ekpProperties.getReplyFdFlowId());
wholeForm.add("formValues", formValues);
wholeForm.add("attachmentForms", fileList);
if (ArrayUtils.isNotEmpty(multipartFiles)){
for (int i = 0; i < multipartFiles.length; i++) {
String fileName = multipartFiles[i].getOriginalFilename();
File file = new File(fileName);
FileUtils.copyInputStreamToFile(multipartFiles[i].getInputStream(), file);
wholeForm.add("attachmentForms["+i+"].fdKey", ekpProperties.getReplyAttachKey());
wholeForm.add("attachmentForms["+i+"].fdFileName", multipartFiles[i].getOriginalFilename());
wholeForm.add("attachmentForms["+i+"].fdAttachment", new FileSystemResource(file));
fileList.add(file);
}
}
log.info("wholeForm:" + wholeForm);
HttpHeaders headers = new HttpHeaders();
......@@ -127,42 +134,11 @@ public class EkpOrderUtil {
}finally {
//将产生的临时附件删除,这里的fileList没值得话是[],不会是null,如果是null需要做判空处理
fileList.stream().forEach(e -> {
FileDataSource dataSource = (FileDataSource)e.getFdAttachment().getDataSource();
boolean delete = dataSource.getFile().delete();
log.info("临时附件删除结果:",delete);
boolean delete = e.delete();
log.info("临时附件删除结果:{}",delete);
});
}
}
/**
* 处理成ekp要的附件格式
*
* @author licancan
* @param multipartFiles
* @return {@link List<AttachmentForm>}
*/
public List<AttachmentForm> createAllAttach(MultipartFile[] multipartFiles){
List<AttachmentForm> attForms = new ArrayList<>();
if (ArrayUtils.isNotEmpty(multipartFiles)){
try {
for (MultipartFile multipartFile : multipartFiles) {
AttachmentForm attForm = new AttachmentForm();
//设置附件关键字,注意附件列表的key是一样的
attForm.setFdKey(ekpProperties.getReplyAttachKey());
attForm.setFdFileName(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;
}
}
package com.yifu.cloud.plus.v1.yifu.ekp.vo;
import lombok.Data;
import javax.activation.DataHandler;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlMimeType;
/**
* @author licancan
* @description ekp附件类
* @date 2022-08-31 17:02:49
*/
@XmlAccessorType(XmlAccessType.FIELD)
@Data
public class AttachmentForm {
private String fdKey;
private String fdFileName;
@XmlMimeType("application/octet-stream")
private DataHandler fdAttachment;
}
......@@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
......@@ -57,6 +58,7 @@ public class OrderController {
*/
@Operation(summary = "订单列表不分页查询", description = "订单列表不分页查询")
@GetMapping("/getOrderList")
@PreAuthorize("@pms.hasPermission('order:order_getOrderList')")
public R<List<OrderListVO>> getOrderList(OrderListParam param) {
return R.ok(tOrderService.getOrderList(param));
}
......@@ -71,6 +73,7 @@ public class OrderController {
*/
@GetMapping("/handleOrder")
@Operation(summary = "变更订单状态", description = "变更订单状态")
//@PreAuthorize("@pms.hasPermission('order:order_handleOrder')")
public R<String> handleOrder(@RequestParam String id,@RequestParam Integer status) {
return tOrderService.handleOrder(id,status);
}
......@@ -84,7 +87,8 @@ public class OrderController {
*/
@Operation(summary = "通过id查询详情", description = "通过id查询详情")
@GetMapping("/{id}")
public R<OrderDetailVO> getInsuranceDetailById(@PathVariable("id") String id) {
//@PreAuthorize("@pms.hasPermission('order:order_getOrderDetailById')")
public R<OrderDetailVO> getOrderDetailById(@PathVariable("id") String id) {
return tOrderService.getOrderDetailById(id);
}
......@@ -114,6 +118,7 @@ public class OrderController {
*/
@Schema(description = "添加回复")
@PostMapping(value = "/uploadReplyEnclosure")
@PreAuthorize("@pms.hasPermission('order:order_uploadReplyEnclosure')")
public R uploadReplyEnclosure(@RequestBody MultipartFile[] file, String filePath, String replyContent,String orderNo) throws IOException {
return tOrderService.uploadReplyEnclosure(file, filePath,replyContent,orderNo);
}
......
......@@ -129,7 +129,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
EkpOrderParam param = new EkpOrderParam();
param.setFd_3b0b02a93e9cda(byId.getOrderNo());
param.setFd_3b0b02a34a0134(getOrderStatus(status));
//ekpOrderUtil.sendOrderToEKP(param);
ekpOrderUtil.sendOrderToEKP(param);
return R.ok(OrderConstants.OPERATE_SUCCESS);
}
......@@ -275,7 +275,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
param.setFd_3ac904badcaa06(user.getUsername());
param.setFd_3ac904b8590598(reply.getCreateTime().toString());
param.setFd_3ac904c7798e5c(replyContent);
//ekpOrderUtil.sendReplyToEKP(param,file);
ekpOrderUtil.sendReplyToEKP(param,file);
if (save && ArrayUtils.isNotEmpty(file)){
for (MultipartFile multipartFile : file) {
String fileName = System.currentTimeMillis() + "_" + multipartFile.getOriginalFilename();
......
......@@ -39,8 +39,8 @@ security:
- /v3/api-docs
- /actuator/**
- /swagger-ui/**
- /ekp/order/receiveOrder
- /ekp/order/receiveOrderReply
# - /ekp/order/receiveOrder
# - /ekp/order/receiveOrderReply
......
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