|
@@ -10,14 +10,13 @@ import com.winhc.task.util.CsvToXlsxUtil;
|
|
|
import com.winhc.task.util.ZipUtils;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
import static com.winhc.task.common.Constant.*;
|
|
|
import static com.winhc.task.util.CsvToXlsxUtil.jsonToXLSxNewCompany;
|
|
@@ -33,14 +32,32 @@ public class TransToExcelNewCompany {
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
+
|
|
|
+
|
|
|
+ //全部任务
|
|
|
+ run();
|
|
|
+ //映射跑
|
|
|
+ //mapping_run();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void mapping_run() {
|
|
|
+ Stream.of("company", "company_double_random_check_info", "company_staff",
|
|
|
+ "company_abnormal_info",
|
|
|
+ "cancellation_announcement", "company_change", "company_punishment_info",
|
|
|
+ "company_holder", "company_check_info", "company_illegal_info", "company_judicial_assistance", "company_equity_info")
|
|
|
+ .forEach(tn -> {
|
|
|
+ String outXlsxPath = "D:\\tmp\\mapping\\" + tn + ".xlsx";
|
|
|
+ String objectNamePath = "anshuo/mapping/" + tn + ".json";
|
|
|
+ toTrans2(outXlsxPath, objectNamePath, tn);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void run() throws FileNotFoundException {
|
|
|
String ds = getYesterday_ymd();
|
|
|
- //ds = "20221114";
|
|
|
String outPathPre = "D:\\tmp\\data\\" + ds + "\\";
|
|
|
File file = new File(outPathPre);
|
|
|
//如果文件夹不存在则会创建
|
|
|
if (!file.exists()) file.mkdirs();
|
|
|
- //单个变更维度
|
|
|
- //toTrans(ds,"company_equity_info");
|
|
|
//新公司
|
|
|
newCompanyToExcel(outPathPre, ds);
|
|
|
//变更
|
|
@@ -48,7 +65,6 @@ public class TransToExcelNewCompany {
|
|
|
//压缩文件
|
|
|
FileOutputStream outZipPath = new FileOutputStream(new File("D:\\tmp\\data\\" + ds + ".zip"));
|
|
|
ZipUtils.toZip("D:\\tmp\\data\\" + ds, outZipPath, true);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public static void changeToExcel(String outPathPre, String ds) {
|
|
@@ -59,7 +75,7 @@ public class TransToExcelNewCompany {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private static void toTrans(String outPathPre, String ds, String tn) {
|
|
|
+ public static void toTrans(String outPathPre, String ds, String tn) {
|
|
|
Map<String, CompanyChangeArgs> exportArgs = CompanyChangeArgs.EXPORT_ARGS;
|
|
|
CompanyChangeArgs args = exportArgs.get(tn);
|
|
|
Function<JSONObject, JSONObject> handles = args.getHandles();
|
|
@@ -67,9 +83,21 @@ public class TransToExcelNewCompany {
|
|
|
.map(Collections::singletonList)
|
|
|
.collect(Collectors.toList());
|
|
|
String objectName = "anshuo/dim_change/" + ds + "/" + tn + ".json";
|
|
|
- //String outPath = "D:\\tmp\\data\\change_" + tn + ".xlsx";
|
|
|
String outPath = outPathPre + "change_" + tn + ".xlsx";
|
|
|
- jsonToXLSxChange(tn, outPath, objectName, company_head_list, args.getClazz(), handles);
|
|
|
+ Set<String> excludeColumnFiledNames = new HashSet<>();
|
|
|
+ excludeColumnFiledNames.add("old_name");
|
|
|
+ jsonToXLSxChange(tn, outPath, objectName, company_head_list, args.getClazz(), handles, excludeColumnFiledNames);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void toTrans2(String outPath, String objectNamePath, String tn) {
|
|
|
+ Map<String, CompanyChangeArgs> exportArgs = CompanyChangeArgs.EXPORT_ARGS;
|
|
|
+ CompanyChangeArgs args = exportArgs.get(tn);
|
|
|
+ Function<JSONObject, JSONObject> handles = args.getHandles();
|
|
|
+ String head = "原始名称@" + args.getHead();
|
|
|
+ List<List<String>> company_head_list = Arrays.stream(head.split("@"))
|
|
|
+ .map(Collections::singletonList)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ jsonToXLSxChange(tn, outPath, objectNamePath, company_head_list, args.getClazz(), handles, null);
|
|
|
}
|
|
|
|
|
|
public static void newCompanyToExcel(String outPathPre, String ds) {
|
|
@@ -88,7 +116,9 @@ public class TransToExcelNewCompany {
|
|
|
|
|
|
String objectName = "anshuo/new_company/" + ds + "/new_company.json";
|
|
|
|
|
|
- jsonToXLSxNewCompany(outPathPre, objectName, company_head_list, holder_head_list, staff_head_list);
|
|
|
+ Set<String> excludeColumnFiledNames = new HashSet<>();
|
|
|
+ excludeColumnFiledNames.add("old_name");
|
|
|
+ jsonToXLSxNewCompany(outPathPre, objectName, company_head_list, holder_head_list, staff_head_list, excludeColumnFiledNames);
|
|
|
}
|
|
|
}
|
|
|
|