Commit 25f1ad20 authored by 郝彦辉's avatar 郝彦辉

添加Excel表格数据和black_list_new表里数据比对的工具/black_list/queryDateBack

参数说明:
filePath:原文件地址;titleNames:表格的头部标题,已逗号分隔;haveTitle:是否有标题列,默认true;queryType:查询类别,目前可以传idCard或phoneNo,name暂不支持
parent f6cd205e
Pipeline #77 failed with stages
...@@ -300,6 +300,26 @@ ...@@ -300,6 +300,26 @@
<artifactId>enoch-agent-spring-boot-starter</artifactId> <artifactId>enoch-agent-spring-boot-starter</artifactId>
</dependency> </dependency>
<!-- add by 2019.09.09 -->
<!--<dependency>
<groupId>jxl</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12.1</version>
</dependency>-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -38,6 +38,9 @@ public class Constant { ...@@ -38,6 +38,9 @@ public class Constant {
public static String XYQB_USER_QUERY_USER_DETAIL_BY_UUID_SQL = "select user_id from user a left join user_detail b on a.id=b.user_id where a.uuid = '%s'"; public static String XYQB_USER_QUERY_USER_DETAIL_BY_UUID_SQL = "select user_id from user a left join user_detail b on a.id=b.user_id where a.uuid = '%s'";
public static String BLACK_LIST_NEW_QUERY_BY_IDNO_SQL2 = "select * from black_list_new where id_no = '%s' and created_at < '%s' and status = true;";
public static String BLACK_LIST_NEW_QUERY_BY_PHONENO_SQL2 = "select * from black_list_new where phone_no = '%s' and created_at < '%s' and status = true;";
} }
public static class BATCH_TYPE { public static class BATCH_TYPE {
......
...@@ -22,4 +22,16 @@ public class BlackListQueryManagerController { ...@@ -22,4 +22,16 @@ public class BlackListQueryManagerController {
return iBlackListQueryManagerService.queryBlackList(uuid, name, phoneNo, idCard, type); return iBlackListQueryManagerService.queryBlackList(uuid, name, phoneNo, idCard, type);
} }
/**
* @描述
* @参数 [filePath:原文件地址; titleNames:表格的头部标题,已逗号分隔; haveTitle:是否有标题列,默认true; queryType:查询类别,目前可以传idCard或phoneNo,name暂不支持]
* @返回值 cn.quantgroup.qgblservice.response.GlobalResponse
* @创建人 yanhui.Hao
* @创建时间 2019.09.10
*/
@RequestMapping("/queryDateBack")
public GlobalResponse queryDateBack(String filePath,String titleNames, String haveTitle, String queryType){
return iBlackListQueryManagerService.queryDateBack(filePath,titleNames,haveTitle,queryType);
}
} }
...@@ -11,4 +11,7 @@ public interface IBlackListQueryManagerService { ...@@ -11,4 +11,7 @@ public interface IBlackListQueryManagerService {
public GlobalResponse queryBlackList(String uuid, String name, String phoneNo, String idCard, String type); public GlobalResponse queryBlackList(String uuid, String name, String phoneNo, String idCard, String type);
public void initChannelBlackListExpireConfig(); public void initChannelBlackListExpireConfig();
public GlobalResponse queryDateBack(String filePath, String titleNames,String haveTitle, String queryType);
} }
package cn.quantgroup.qgblservice.utils;
import java.io.*;
import java.util.List;
/**
* -----------------------------------------------------------------------------<br>
* 描述: <br>
* 作者: Haoyanhui <br>
* 时间:2019.09.09 22:34 <br>
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
*/
public class ReadOrWriteTxt {
/**传入txt路径读取txt文件
* @param txtPath
* @return 返回读取到的内容
*/
public static String readTxt(String txtPath) {
File file = new File(txtPath);
if(file.isFile() && file.exists()){
try {
FileInputStream fileInputStream = new FileInputStream(file);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
StringBuffer sb = new StringBuffer();
String text = null;
while((text = bufferedReader.readLine()) != null){
sb.append(text);
}
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
/**使用FileOutputStream来写入txt文件
* @param txtPath txt文件路径
* @param content 需要写入的文本
*/
public static void writeTxt(String txtPath,String content){
FileOutputStream fileOutputStream = null;
File file = new File(txtPath);
try {
if(file.exists()){
//判断文件是否存在,如果不存在就新建一个txt
file.createNewFile();
}
fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(content.getBytes());
fileOutputStream.flush();
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void writeTxt(String txtPath,List<String> contentList){
FileOutputStream fileOutputStream = null;
File file = new File(txtPath);
try {
if(file.exists()){
//判断文件是否存在,如果不存在就新建一个txt
file.createNewFile();
}
fileOutputStream = new FileOutputStream(file);
for(String content:contentList){
fileOutputStream.write(content.getBytes());
}
fileOutputStream.flush();
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
//String filePath = "D:\\JavaTeam\\shmf.txt";
String filePath = "/opt/web_app/shmf.txt";
String queryType = "aa";
String writeFilePath = "";
if(filePath.lastIndexOf("/")!=-1){//linux
writeFilePath = filePath.substring(0,filePath.lastIndexOf("/"))+"/"+queryType+".txt";
}else{//windows
writeFilePath = filePath.substring(0,filePath.lastIndexOf("\\"))+"\\"+queryType+".txt";
}
System.out.println(filePath);
System.out.println(writeFilePath);
}
}
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