Commit ef2fa6c5 LN

优先使用json中的数据

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