Commit ef2fa6c5 LN

优先使用json中的数据

1 个父辈 c5914b57
......@@ -87,7 +87,7 @@ public class LanguageMsgService {
try {
String jsonStr = FileUtil.readUtf8String(file);
List<LanguageMsg> languageMsgs = JsonUtil.toList(jsonStr, LanguageMsg.class);
msgListUpload(file.getName(),languageMsgs,false);
msgListUpload(file.getName(),languageMsgs,true);
} catch (Exception ex) {
log.info("autoImportCsvFile 读取文件" + fileName + "错误:" + ex.toString());
}
......@@ -101,34 +101,34 @@ public class LanguageMsgService {
}
public void autoImportCsvFile() {
// String filePath = getResourcesPath();
String filePath = "D:\\resources";
File file = new File(filePath); //需要获取的文件的路径
List<LanguageInfo> languageInfoList = dataCache.getLanguageList();
if (file.exists() && file.isDirectory()) {
String[] fileNameLists = file.list(); //存储文件名的String数组
File[] filePathLists = file.listFiles(); //存储文件路径的String数组
for (int i = 0; i < filePathLists.length; i++) {
//只读取后缀名为csv的
if (filePathLists[i].isFile()) {
String fileName = filePathLists[i].getName();
if (fileName.endsWith(".csv")) {
try {
List<LanguageMsg> msgList = readCsvFile(filePathLists[i].getAbsolutePath(), languageInfoList);
if (msgList.size() > 0) {
msgListUpload(fileName, msgList, false);
}
} catch (Exception ex) {
log.info("autoImportCsvFile 读取文件" + fileName + "错误:" + ex.toString());
}
}
}
}
}
}
// public void autoImportCsvFile() {
//// String filePath = getResourcesPath();
// String filePath = "D:\\resources";
// File file = new File(filePath); //需要获取的文件的路径
// List<LanguageInfo> languageInfoList = dataCache.getLanguageList();
// if (file.exists() && file.isDirectory()) {
// String[] fileNameLists = file.list(); //存储文件名的String数组
// File[] filePathLists = file.listFiles(); //存储文件路径的String数组
//
//
// for (int i = 0; i < filePathLists.length; i++) {
// //只读取后缀名为csv的
// if (filePathLists[i].isFile()) {
// String fileName = filePathLists[i].getName();
// if (fileName.endsWith(".csv")) {
// try {
// List<LanguageMsg> msgList = readCsvFile(filePathLists[i].getAbsolutePath(), languageInfoList);
// if (msgList.size() > 0) {
// msgListUpload(fileName, msgList, false);
// }
// } catch (Exception ex) {
// log.info("autoImportCsvFile 读取文件" + fileName + "错误:" + ex.toString());
// }
// }
// }
// }
// }
// }
public void autoImportResources() {
Map<String, Map<String, String>> lanMsgMap = new HashMap<>();
......@@ -340,7 +340,7 @@ public class LanguageMsgService {
String oldValue = oldMsg.getContent(lanType);
String newValue = msg.getContent(lanType);
if (ObjectUtil.isNotEmpty(newValue)) {
if (isNeedUpdate || ObjectUtil.isEmpty(oldValue)) {
if (ObjectUtil.isEmpty(oldValue)||(isNeedUpdate &&(!newValue.equals(oldValue))) ) {
oldMsg.setContent(lanType, newValue);
isUpdate = true;
//内容默认更改为中文
......
......@@ -91,11 +91,11 @@ public class MessageUtils {
private void initLanguageMsgList() {
msgMap = messageService.loadMsgMap();
//自动导入JSON内容
messageService.autoImportJsonFile();
//只新增不修改
messageService.autoImportResources();
//自动导入JSON内容
messageService.autoImportJsonFile();
if (msgMap.size() > 0) {
return;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!