Commit 19995d59 authored by fangxinjiang's avatar fangxinjiang

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

parent 23b97fb4
package com.yifu.cloud.plus.v1.yifu.order.controller;
import com.alibaba.fastjson.JSONObject;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
......@@ -14,7 +13,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -22,11 +20,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.annotation.Resource;
import javax.json.Json;
import java.io.File;
import java.io.IOException;
/**
......
......@@ -122,8 +122,6 @@ public interface TOrderService extends IService<TOrder> {
void receiveOrderFileAsc(InputStream inputStream, String orderNo, String fileName, String originalFileName);
R<String> syncFileFromEkp(String orderNo, String attIds,String id);
/**
* 订单作废
*
......
......@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainListVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo;
......@@ -30,6 +29,7 @@ import com.yifu.cloud.plus.v1.yifu.order.service.TOrderEnclosureService;
import com.yifu.cloud.plus.v1.yifu.order.service.TOrderHandlerService;
import com.yifu.cloud.plus.v1.yifu.order.service.TOrderReplyService;
import com.yifu.cloud.plus.v1.yifu.order.service.TOrderService;
import com.yifu.cloud.plus.v1.yifu.order.util.EkpOrderFileAsyncTask;
import com.yifu.cloud.plus.v1.yifu.order.util.EkpOrderFileTask;
import com.yifu.cloud.plus.v1.yifu.order.util.ValidityUtil;
import com.yifu.cloud.plus.v1.yifu.order.vo.*;
......@@ -39,7 +39,7 @@ import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
......@@ -78,6 +78,8 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
private DaprUpmsProperties daprUpmsProperties;
@Resource
private TOrderFileSyncLogMapper orderFileSyncLogMapper;
@Autowired
private EkpOrderFileAsyncTask ekpOrderFileAsyncTask;
/**
* 订单列表分页查询
......@@ -752,32 +754,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
return R.ok();
}
/**
* @Author fxj
* @Description 同步项目订单附件 (EKP=>HRO)
* @Date 15:59 2024/11/15
* @Param
* @return
**/
@Async
@Override
public R<String> syncFileFromEkp(String orderNo, String attIds,String id) {
if (StringUtils.isEmpty(orderNo)){
return R.failed(OrderConstants.ORDER_NO_IS_EMPTY);
}
if (StringUtils.isEmpty(attIds)){
return R.failed(OrderConstants.ENCLOSURE_ID_IS_EMPTY);
}
String res = ekpOrderUtil.syncFileFromEkp(orderNo,attIds);
if (!Common.isNotNull(res)){
// 记录到数据库 失败的部分可在前端列表重试
this.saveFileSyncLog(orderNo,attIds,null,id);
}else {
// 记录到数据库 失败的部分可在前端列表重试
this.saveFileSyncLog(orderNo,attIds,res,id);
}
return R.ok(OrderConstants.OPERATE_SUCCESS);
}
/**
* @Author fxj
* @Description 记录及更新附件同步信息
......@@ -818,7 +795,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
if (Common.isEmpty(log)){
return R.failed(CommonConstants.NO_DATA_TO_HANDLE);
}
syncFileFromEkp(log.getOrderNo(),log.getAttIds(),id);
ekpOrderFileAsyncTask.syncFileFromEkp(log.getOrderNo(),log.getAttIds(),id);
return R.ok();
}
}
package com.yifu.cloud.plus.v1.yifu.order.util;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.ekp.util.EkpOrderUtil;
import com.yifu.cloud.plus.v1.yifu.order.constants.OrderConstants;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrderFileSyncLog;
import com.yifu.cloud.plus.v1.yifu.order.mapper.TOrderFileSyncLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
/**
* @Author fxj
* @Date 2023/6/25
* @Description
* @Version 1.0
*/
@Slf4j
@Component
public class EkpOrderFileAsyncTask {
@Resource
private EkpOrderUtil ekpOrderUtil;
@Resource
private TOrderFileSyncLogMapper orderFileSyncLogMapper;
/**
* @Author fxj
* @Description 同步项目订单附件 (EKP=>HRO)
* @Date 15:59 2024/11/15
* @Param
* @return
**/
@Async
public R<String> syncFileFromEkp(String orderNo, String attIds, String id) {
if (StringUtils.isEmpty(orderNo)){
return R.failed(OrderConstants.ORDER_NO_IS_EMPTY);
}
if (StringUtils.isEmpty(attIds)){
return R.failed(OrderConstants.ENCLOSURE_ID_IS_EMPTY);
}
String res = ekpOrderUtil.syncFileFromEkp(orderNo,attIds);
if (!Common.isNotNull(res)){
// 记录到数据库 失败的部分可在前端列表重试
this.saveFileSyncLog(orderNo,attIds,null,id);
}else {
// 记录到数据库 失败的部分可在前端列表重试
this.saveFileSyncLog(orderNo,attIds,res,id);
}
return R.ok(OrderConstants.OPERATE_SUCCESS);
}
/**
* @Author fxj
* @Description 记录及更新附件同步信息
* @Date 17:45 2024/11/15
* @Param
* @return
**/
private void saveFileSyncLog(String orderNo,String attIds,String msg,String id){
TOrderFileSyncLog log = new TOrderFileSyncLog();
if (Common.isNotNull(id)){
log.setId(id);
if (Common.isEmpty(msg)){
log.setReason(CommonConstants.EMPTY_STRING);
log.setFlag(CommonConstants.ZERO_STRING);
}else {
log.setReason(msg);
}
log.setUpdateTime(LocalDateTime.now());
orderFileSyncLogMapper.updateById(log);
}else {
log.setOrderNo(orderNo);
log.setAttIds(attIds);
log.setCreateTime(LocalDateTime.now());
log.setReason(msg);
log.setFlag(CommonConstants.ONE_STRING);
orderFileSyncLogMapper.insert(log);
}
}
}
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