Commit 0245e681 authored by 吴琼's avatar 吴琼

修改

parent 7a717dda
...@@ -273,7 +273,31 @@ ...@@ -273,7 +273,31 @@
<artifactId>jsch</artifactId> <artifactId>jsch</artifactId>
<version>0.1.54</version> <version>0.1.54</version>
</dependency> </dependency>
<!-- <dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<!--fastdfs-->
<!--<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
<version>1.25.2-RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>-->
<!-- <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId> <artifactId>spring-test</artifactId>
</dependency>--> </dependency>-->
......
...@@ -16,9 +16,12 @@ public interface TransactionReceiptRecordRepo extends JpaRepository<TransactionR ...@@ -16,9 +16,12 @@ public interface TransactionReceiptRecordRepo extends JpaRepository<TransactionR
@Query(value = "select count(1) from transaction_receipt_record where user_id =?1 and user_name =?2 and order_no =?3 ", nativeQuery = true) @Query(value = "select count(1) from transaction_receipt_record where user_id =?1 and user_name =?2 and order_no =?3 ", nativeQuery = true)
Long selectCountByUserIdAndOrderNo(Integer userId,String userName,String orderNo); Long selectCountByUserIdAndOrderNo(Integer userId,String userName,String orderNo);
@Query(value = "select * from transaction_receipt_record where import_status = ?1 ", nativeQuery = true) @Query(value = "select * from transaction_receipt_record where import_status = ?1", nativeQuery = true)
List<TransactionReceiptRecord> selectRecordsByImportStatus(Integer status); List<TransactionReceiptRecord> selectRecordsByImportStatus(Integer status);
@Query(value = "select * from transaction_receipt_record where import_status = ?1 and export_status !=2 ", nativeQuery = true)
List<TransactionReceiptRecord> selectRecordsByImportStatusAndExportStatus(Integer status);
@Query(value = "select count(1) from transaction_receipt_record where import_status =?1 ", nativeQuery = true) @Query(value = "select count(1) from transaction_receipt_record where import_status =?1 ", nativeQuery = true)
Long selectCountByImportStatus(Integer status); Long selectCountByImportStatus(Integer status);
......
...@@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
...@@ -58,7 +57,7 @@ public class TransactionReceiptRecordRest { ...@@ -58,7 +57,7 @@ public class TransactionReceiptRecordRest {
@RequestMapping("/orderQuery/importTransactionReceiptRecord") @RequestMapping("/orderQuery/importTransactionReceiptRecord")
@ResponseBody @ResponseBody
@Synchronized @Synchronized
public JsonResult importTransactionReceiptRecord(@RequestParam("file")MultipartFile file) { public JsonResult importTransactionReceiptRecord(@RequestParam("file") MultipartFile file) {
try{ try{
return transactionReceiptRecordService.importTransactionReceiptRecord(file); return transactionReceiptRecordService.importTransactionReceiptRecord(file);
}catch(IOException e){ }catch(IOException e){
...@@ -146,6 +145,7 @@ public class TransactionReceiptRecordRest { ...@@ -146,6 +145,7 @@ public class TransactionReceiptRecordRest {
//导出压缩包 //导出压缩包
@RequestMapping("/orderQuery/exportTransactionZipFile") @RequestMapping("/orderQuery/exportTransactionZipFile")
@ResponseBody @ResponseBody
@Synchronized
public JsonResult exportTransactionZipFile(HttpServletRequest request, HttpServletResponse response) throws Exception{ public JsonResult exportTransactionZipFile(HttpServletRequest request, HttpServletResponse response) throws Exception{
//try{ //try{
return transactionReceiptRecordService.exportZipFile(request,response); return transactionReceiptRecordService.exportZipFile(request,response);
......
package cn.quantgroup.customer.service;
import java.io.IOException;
import java.io.InputStream;
/**
* fastDFS 接入 http://confluence.quantgroup.cn/x/bMU5AQ
*
* @author jingfeng.guo
* @since 2019-08-24 17:04
*/
public interface IFastDFSService {
/**
* 上传文件
*
* @param fileInput
* @param fileSize
* @param fileExtName 扩展名
* @return
* @throws IOException
*/
String uploadFile(InputStream fileInput, Long fileSize, String fileExtName) throws IOException;
/**
* 上传文件
*
* @param bytes
* @param fileExtName
* @return
* @throws IOException
*/
String uploadFile(byte[] bytes, String fileExtName) throws IOException;
/**
* 文件上传, 下载url 再传
*
* @param url
* @param fileExtName
* @return
* @throws IOException
*/
String uploadFile(String url, String fileExtName) throws IOException;
/**
* 上传文件 base64
*
* @param base64String
* @param fileExtName
* @return
* @throws IOException
*/
String uploadFileOfBase64String(String base64String, String fileExtName) throws IOException;
/**
* 下载文件
*
* @param path
* @return
* @throws IOException
*/
byte[] downloadFile(String path) throws IOException;
}
package cn.quantgroup.customer.service.impl;
import cn.quantgroup.customer.service.IFastDFSService;
import com.github.tobato.fastdfs.domain.StorePath;
import com.github.tobato.fastdfs.proto.storage.DownloadByteArray;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* @author xing.yuan
*/
@Service
@Slf4j
public class FastDFSServiceImpl implements IFastDFSService {
@Resource
private FastFileStorageClient storageClient;
@Value("${fdfs.secret_key}")
private String secretKey;
@Value("${fdfs.domain}")
private String fastDfsHttp;
/**
* 文件上传
*
* @param fileInput
* @param fileSize
* @param fileExtName 扩展名
* @return
*/
@Override
public String uploadFile(InputStream fileInput, Long fileSize, String fileExtName) throws IOException {
StorePath storePath = null;
try {
storePath = storageClient.uploadFile(fileInput, fileSize, fileExtName, null);
} finally {
if (fileInput != null) {
try {
fileInput.close();
} catch (IOException e) {
}
}
}
if (storePath != null && StringUtils.isNotBlank(storePath.getFullPath())) {
return storePath.getFullPath();
} else {
throw new IOException("文件上传失败");
}
}
/**
* 文件上传
*
* @param bytes
* @param fileExtName 扩展名
* @return
*/
@Override
public String uploadFile(byte[] bytes, String fileExtName) throws IOException {
return uploadFile(new ByteArrayInputStream(bytes), (long) bytes.length, fileExtName);
}
/**
* 文件上传, 下载url 再传
*
* @param url
* @param fileExtName
* @return
* @throws IOException
*/
@Override
public String uploadFile(String url, String fileExtName) throws IOException {
InputStream in = null;
long size = 0;
HttpURLConnection conn = null;
try {
URL httpUrl = new URL(url);
conn = (HttpURLConnection) httpUrl.openConnection();
//设置超时间为3秒
conn.setConnectTimeout(3 * 1000);
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
in = conn.getInputStream();
size = in.available();
} catch (IOException e) {
log.warn("下载文件异常,url={},", url, e);
throw e;
}
log.info("准备上传文件; url={}, ", url);
try {
String path = uploadFile(in, size, fileExtName);
return path;
} finally {
if (conn != null) {
try {
conn.disconnect();
} catch (Exception e) {
}
}
}
}
/**
* 上传文件 base64
*
* @param base64String
* @param fileExtName
* @return
* @throws IOException
*/
@Override
public String uploadFileOfBase64String(String base64String, String fileExtName) throws IOException {
byte[] bytes = Base64.decodeBase64(base64String);
return uploadFile(bytes, fileExtName);
}
/**
* 下载文件
*
* @param path
* @return
*/
@Override
public byte[] downloadFile(String path) throws IOException {
if (StringUtils.isBlank(path)) {
return null;
}
String[] split = StringUtils.split(path, "/", 2);
if (split.length < 2) {
throw new IOException("路径不对");
}
byte[] bytes = storageClient.downloadFile(split[0], split[1], new DownloadByteArray() {
});
return bytes;
}
}
...@@ -9,6 +9,7 @@ import cn.quantgroup.customer.repo.TransactionReceiptRecordRepo; ...@@ -9,6 +9,7 @@ import cn.quantgroup.customer.repo.TransactionReceiptRecordRepo;
import cn.quantgroup.customer.rest.param.transactionreceipt.TransactionReceiptRecordQuery; import cn.quantgroup.customer.rest.param.transactionreceipt.TransactionReceiptRecordQuery;
import cn.quantgroup.customer.rest.vo.JsonResult; import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.rest.vo.transaction.*; import cn.quantgroup.customer.rest.vo.transaction.*;
import cn.quantgroup.customer.service.IFastDFSService;
import cn.quantgroup.customer.service.IFileService; import cn.quantgroup.customer.service.IFileService;
import cn.quantgroup.customer.service.ITransactionReceiptRecordService; import cn.quantgroup.customer.service.ITransactionReceiptRecordService;
import cn.quantgroup.customer.service.http.IHttpService; import cn.quantgroup.customer.service.http.IHttpService;
...@@ -262,8 +263,8 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -262,8 +263,8 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
public JsonResult exportZipFile(HttpServletRequest request, HttpServletResponse response) throws Exception { public JsonResult exportZipFile(HttpServletRequest request, HttpServletResponse response) throws Exception {
//调用电商接口获取对应数据 //调用电商接口获取对应数据
log.info("[TransactionReceiptRecordServiceImpl.exportZipFile begin]"); log.info("[TransactionReceiptRecordServiceImpl.exportZipFile begin]");
//查询需要导出的数据-导入成功的数据 //查询需要导出的数据-导入成功的数据,但未导出成功的数据
List<TransactionReceiptRecord> transactionReceiptRecordList= transactionReceiptRecordRepo.selectRecordsByImportStatus(1); List<TransactionReceiptRecord> transactionReceiptRecordList= transactionReceiptRecordRepo.selectRecordsByImportStatusAndExportStatus(1);
if(CollectionUtils.isEmpty(transactionReceiptRecordList)){ if(CollectionUtils.isEmpty(transactionReceiptRecordList)){
return JsonResult.buildErrorStateResult("没有可以导出得数据"); return JsonResult.buildErrorStateResult("没有可以导出得数据");
} }
......
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