Commit 58469088 LN

Merge remote-tracking branch 'origin/master'

2 个父辈 d63fcae4 b6b07855
...@@ -242,6 +242,12 @@ ...@@ -242,6 +242,12 @@
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>
<version>3.1.1</version> <version>3.1.1</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
......
...@@ -519,7 +519,8 @@ public class DeviceController { ...@@ -519,7 +519,8 @@ public class DeviceController {
if(!Strings.isNullOrEmpty(hSerial)){ if(!Strings.isNullOrEmpty(hSerial)){
for (DataLog queueTask : queueTasks) { for (DataLog queueTask : queueTasks) {
if(queueTask.isCheckOutTask() && !queueTask.isFinished()){ if(queueTask.isCheckOutTask() && !queueTask.isFinished()){
if(queueTask.getSourceName().equals(hSerial)){ String sourceName = queueTask.getSourceName();
if(sourceName != null && queueTask.getSourceName().equals(hSerial)){
//单号相同任务数量+1 //单号相同任务数量+1
outTaskCount = outTaskCount + 1; outTaskCount = outTaskCount + 1;
} }
......
...@@ -94,6 +94,21 @@ public class LanguageMsgController { ...@@ -94,6 +94,21 @@ public class LanguageMsgController {
return ResultBean.newOkResult(resultMsg); return ResultBean.newOkResult(resultMsg);
} }
@RequestMapping(value = "/getLanguageMsgList")
@AnonymousAccess
public List<LanguageMsg> getMsgList(String type) throws Exception {
List<LanguageMsg> results = new ArrayList<>();
Criteria criteria = Criteria.where("type").is(type);
Query query = Query.query(criteria);
List<LanguageMsg> list = languageMsgManager.findByQuery(query);
for (LanguageMsg languageMsg : list) {
if(!languageMsg.getCreateDate().equals(languageMsg.getUpdateDate())){
languageMsg.setId(null);//不需要返回ID
results.add(languageMsg);
}
}
return results;
}
@ApiOperation("导出资源文件") @ApiOperation("导出资源文件")
@GetMapping(value = "/download") @GetMapping(value = "/download")
......
...@@ -18,7 +18,8 @@ import java.util.Map; ...@@ -18,7 +18,8 @@ import java.util.Map;
@Data @Data
@Document @Document
public class LanguageMsg extends BasePo implements Serializable { public class
LanguageMsg extends BasePo implements Serializable {
public LanguageMsg(){ public LanguageMsg(){
......
...@@ -2,6 +2,8 @@ package com.neotel.smfcore.core.language.util; ...@@ -2,6 +2,8 @@ package com.neotel.smfcore.core.language.util;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.csv.CsvReader; import com.neotel.smfcore.common.csv.CsvReader;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.language.service.bean.Content; import com.neotel.smfcore.core.language.service.bean.Content;
import com.neotel.smfcore.core.language.service.bean.LanguageInfo; import com.neotel.smfcore.core.language.service.bean.LanguageInfo;
...@@ -9,7 +11,6 @@ import com.neotel.smfcore.core.language.service.nanager.ILanguageMsgManager; ...@@ -9,7 +11,6 @@ import com.neotel.smfcore.core.language.service.nanager.ILanguageMsgManager;
import com.neotel.smfcore.core.language.service.po.LanguageMsg; import com.neotel.smfcore.core.language.service.po.LanguageMsg;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -20,14 +21,14 @@ import java.util.*; ...@@ -20,14 +21,14 @@ import java.util.*;
@Service @Service
public class LanguageMsgService { public class LanguageMsgService {
private static MyMessageSource messageSource;
@Autowired @Autowired
ILanguageMsgManager languageMsgManager; ILanguageMsgManager languageMsgManager;
@Autowired @Autowired
DataCache dataCache; DataCache dataCache;
private static MyMessageSource messageSource;
public LanguageMsgService(MyMessageSource messageSource) { public LanguageMsgService(MyMessageSource messageSource) {
this.messageSource = messageSource; LanguageMsgService.messageSource = messageSource;
// if(messageSource instanceof ResourceBundleMessageSource){ // if(messageSource instanceof ResourceBundleMessageSource){
// //
// Map<String,String> map1=messageSource.getMessageMap(Locale.SIMPLIFIED_CHINESE); // Map<String,String> map1=messageSource.getMessageMap(Locale.SIMPLIFIED_CHINESE);
...@@ -37,31 +38,31 @@ public class LanguageMsgService { ...@@ -37,31 +38,31 @@ public class LanguageMsgService {
// Map<String,String> map5=messageSource.getMessageMap(new Locale("")); // Map<String,String> map5=messageSource.getMessageMap(new Locale(""));
// } // }
} }
public Map<String,Map<String, LanguageMsg>> loadMsgMap() {
int hasCount=1; public Map<String, Map<String, LanguageMsg>> loadMsgMap() {
Map<String,Map<String, LanguageMsg>> resourceMap=new HashMap<>();
int hasCount = 1;
Map<String, Map<String, LanguageMsg>> resourceMap = new HashMap<>();
List<LanguageMsg> msgs = languageMsgManager.findByQuery(new Query()); List<LanguageMsg> msgs = languageMsgManager.findByQuery(new Query());
for (LanguageMsg msg : for (LanguageMsg msg : msgs) {
msgs) { if (msg.getCode().startsWith("smfcode.") || msg.getType().equals("smfcode")) {
if(msg.getCode().startsWith("smfcode.")||msg.getType().equals("smfcode")){ String newCode = msg.getCode().replace("smfcode.", "smfcore.");
String newCode=msg.getCode().replace("smfcode.","smfcore.");
msg.setCode(newCode); msg.setCode(newCode);
msg.setType("smfcore"); msg.setType("smfcore");
languageMsgManager.save(msg); languageMsgManager.save(msg);
} }
Map<String, LanguageMsg> typeMap = resourceMap.get(msg.getType()); Map<String, LanguageMsg> typeMap = resourceMap.get(msg.getType());
if(typeMap==null){ if (typeMap == null) {
typeMap=new HashMap<>(); typeMap = new HashMap<>();
} }
if(typeMap.containsKey(msg.getCode())){ if (typeMap.containsKey(msg.getCode())) {
String delId=msg.getId(); String delId = msg.getId();
// log.info("资源创建时间["+typeMap.get(msg.getCode()).getCreateDate()+"]["+ msg.getCreateDate()+"]ID["+typeMap.get(msg.getCode()).getId()+"]["+ msg.getId()+"],code=["+msg.getCode()+"]已存在,["+hasCount+"]"); // log.info("资源创建时间["+typeMap.get(msg.getCode()).getCreateDate()+"]["+ msg.getCreateDate()+"]ID["+typeMap.get(msg.getCode()).getId()+"]["+ msg.getId()+"],code=["+msg.getCode()+"]已存在,["+hasCount+"]");
log.info("资源 ID["+typeMap.get(msg.getCode()).getId()+"]["+ msg.getId()+"],code=["+msg.getCode()+"]已存在,删除资源["+delId+"]["+hasCount+"]"); log.info("资源 ID[" + typeMap.get(msg.getCode()).getId() + "][" + msg.getId() + "],code=[" + msg.getCode() + "]已存在,删除资源[" + delId + "][" + hasCount + "]");
languageMsgManager.delete(msg); languageMsgManager.delete(msg);
hasCount++; hasCount++;
}else{ } else {
typeMap.put(msg.getCode(),msg); typeMap.put(msg.getCode(), msg);
resourceMap.put(msg.getType(), typeMap); resourceMap.put(msg.getType(), typeMap);
} }
} }
...@@ -69,24 +70,33 @@ public class LanguageMsgService { ...@@ -69,24 +70,33 @@ public class LanguageMsgService {
return resourceMap; return resourceMap;
} }
// public String getResourcesPath() { public void autoImportJsonFile() {
// String filePath = System.getProperty("user.dir"); String classesPath = this.getClass().getResource("/").getPath();
// log.info("user.dir=" + filePath); File classDir = new File(classesPath); //需要获取的文件的路径
// // "\\WEB-INF\\classes\\META-INF\\resources"; if (classDir.exists() && classDir.isDirectory()) {
//// user.dir=C:\Program Files\Apache Software Foundation\Tomcat 9.0 for (File file : classDir.listFiles()) {
//// C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\smf-core\WEB-INF\classes\META-INF\resources //只读取后缀名为json的
// if(filePath.toLowerCase().contains("tomcat")){ if (file.isFile()) {
// return filePath+"\\webapps\\smf-core\\WEB-INF\\classes\\META-INF\\resources"; String fileName = file.getName();
// }else{ if (fileName.endsWith(".json")) {
// return filePath + "\\src\\main\\resources"; try {
// } String jsonStr = FileUtil.readUtf8String(file);
// } List<LanguageMsg> languageMsgs = JsonUtil.toList(jsonStr, LanguageMsg.class);
msgListUpload(file.getName(),languageMsgs,false);
} catch (Exception ex) {
log.info("autoImportCsvFile 读取文件" + fileName + "错误:" + ex.toString());
}
}
}
}
}
}
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数组
...@@ -98,12 +108,12 @@ public class LanguageMsgService { ...@@ -98,12 +108,12 @@ public class LanguageMsgService {
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());
} }
} }
} }
...@@ -138,12 +148,10 @@ public class LanguageMsgService { ...@@ -138,12 +148,10 @@ public class LanguageMsgService {
List<LanguageMsg> languageMsgs = new ArrayList<>(); List<LanguageMsg> languageMsgs = new ArrayList<>();
for (String code : for (String code : defaultLanMap.keySet()) {
defaultLanMap.keySet()) {
String defMsg = defaultLanMap.get(code); String defMsg = defaultLanMap.get(code);
LanguageMsg msg = new LanguageMsg(code, defMsg, ""); LanguageMsg msg = new LanguageMsg(code, defMsg, "");
for (String lan : for (String lan : lanMsgMap.keySet()) {
lanMsgMap.keySet()) {
if (lanMsgMap.get(lan).containsKey(code)) { if (lanMsgMap.get(lan).containsKey(code)) {
String lanMsg = lanMsgMap.get(lan).get(code); String lanMsg = lanMsgMap.get(lan).get(code);
msg.setContent(lan, lanMsg); msg.setContent(lan, lanMsg);
...@@ -216,49 +224,44 @@ public class LanguageMsgService { ...@@ -216,49 +224,44 @@ public class LanguageMsgService {
// } // }
public List<String> getAllLanList() { public List<String> getAllLanList() {
List<LanguageInfo> lanList = dataCache.getLanguageList(); List<LanguageInfo> lanList = dataCache.getLanguageList();
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
for (LanguageInfo lan : lanList for (LanguageInfo lan : lanList) {
) {
list.add(lan.getLanCode()); list.add(lan.getLanCode());
} }
return list; return list;
} }
public String resourceUpload(String orgFileName, Map<String, String> proMap , String lanCode, String type) { public String resourceUpload(String orgFileName, Map<String, String> proMap, String lanCode, String type) {
List<LanguageMsg> newLanguageList = new ArrayList<>(); List<LanguageMsg> newLanguageList = new ArrayList<>();
List<LanguageMsg> updateLanguageList = new ArrayList<>(); List<LanguageMsg> updateLanguageList = new ArrayList<>();
if (proMap != null && proMap.size() > 0) { if (proMap != null && proMap.size() > 0) {
for (String key : for (String key : proMap.keySet()) {
proMap.keySet()) {
//如果Key爲空,直接返回 //如果Key爲空,直接返回
if(ObjectUtil.isEmpty(key)) if (ObjectUtil.isEmpty(key)) {
{
continue; continue;
} }
String msgStr = proMap.get(key); String msgStr = proMap.get(key);
LanguageMsg msg = MessageUtils.getMsg(type,key); LanguageMsg msg = MessageUtils.getMsg(type, key);
//导入时只能新增不能修改 //导入时只能新增不能修改
if (msg == null) { if (msg == null) {
msg = new LanguageMsg(key, msgStr,type); msg = new LanguageMsg(key, msgStr, type);
msg.setContent(lanCode, msgStr); msg.setContent(lanCode, msgStr);
newLanguageList.add(msg); newLanguageList.add(msg);
} else { } else {
String oldMsg = msg.getContent(lanCode); String oldMsg = msg.getContent(lanCode);
// if (!oldMsg.equals(msgStr)) { // if (!oldMsg.equals(msgStr)) {
if(ObjectUtil.isEmpty(oldMsg)){ if (ObjectUtil.isEmpty(oldMsg)) {
msg.setContent(lanCode, msgStr); msg.setContent(lanCode, msgStr);
//内容默认更改为中文 //内容默认更改为中文
if(lanCode.equals(MessageUtils.ZH_CN)){ if (lanCode.equals(MessageUtils.ZH_CN)) {
if(!msg.getMsg().equals(msgStr)){ if (!msg.getMsg().equals(msgStr)) {
msg.setMsg(msgStr); msg.setMsg(msgStr);
} }
} }
...@@ -272,41 +275,39 @@ public class LanguageMsgService { ...@@ -272,41 +275,39 @@ public class LanguageMsgService {
if (newLanguageList.size() > 0) { if (newLanguageList.size() > 0) {
languageMsgManager.insertAll(newLanguageList); languageMsgManager.insertAll(newLanguageList);
for (LanguageMsg msg : for (LanguageMsg msg : newLanguageList) {
newLanguageList) {
MessageUtils.updateMsg(msg); MessageUtils.updateMsg(msg);
} }
} }
if(updateLanguageList.size() >0||newLanguageList.size()>0){ if (updateLanguageList.size() > 0 || newLanguageList.size() > 0) {
log.info("导入资源[" + orgFileName + "]["+type+"]["+lanCode+"],共["+proMap.size()+"]条数据,共更新[" + updateLanguageList.size() + "]条资源,新增[" + newLanguageList.size() + "]条资源"); log.info("导入资源[" + orgFileName + "][" + type + "][" + lanCode + "],共[" + proMap.size() + "]条数据,共更新[" + updateLanguageList.size() + "]条资源,新增[" + newLanguageList.size() + "]条资源");
}else{ } else {
log.debug("导入资源[" + orgFileName + "]["+type+"]["+lanCode+"],共["+proMap.size()+"]条数据,共更新[" + updateLanguageList.size() + "]条资源,新增[" + newLanguageList.size() + "]条资源"); log.debug("导入资源[" + orgFileName + "][" + type + "][" + lanCode + "],共[" + proMap.size() + "]条数据,共更新[" + updateLanguageList.size() + "]条资源,新增[" + newLanguageList.size() + "]条资源");
} }
return "ok"; return "ok";
} }
public void msgListUpload(String fileName, List<LanguageMsg> msgList,boolean isNeedUpdate) { public void msgListUpload(String fileName, List<LanguageMsg> msgList, boolean isNeedUpdate) {
List<LanguageMsg> newLanguageList = new ArrayList<>(); List<LanguageMsg> newLanguageList = new ArrayList<>();
List<LanguageMsg> updateLanguageList = new ArrayList<>(); List<LanguageMsg> updateLanguageList = new ArrayList<>();
for (LanguageMsg msg : for (LanguageMsg msg : msgList) {
msgList) {
if(ObjectUtil.isEmpty(msg.getCode())) { if (ObjectUtil.isEmpty(msg.getCode())) {
//code不能为空 //code不能为空
continue; continue;
} }
if(ObjectUtil.isEmpty(msg.getMsg())){ if (ObjectUtil.isEmpty(msg.getMsg())) {
//内容不能为空 //内容不能为空
continue; continue;
} if(ObjectUtil.isEmpty(msg.getType())){ }
if (ObjectUtil.isEmpty(msg.getType())) {
//内容不能为空 //内容不能为空
continue; continue;
} }
List<Content> contentList = new ArrayList<>(); List<Content> contentList = new ArrayList<>();
for (Content con : for (Content con : msg.getContentList()) {
msg.getContentList()) {
if (ObjectUtil.isEmpty(con.getLanCode()) || ObjectUtil.isEmpty(con.getMsg())) { if (ObjectUtil.isEmpty(con.getLanCode()) || ObjectUtil.isEmpty(con.getMsg())) {
continue; continue;
} }
...@@ -315,19 +316,17 @@ public class LanguageMsgService { ...@@ -315,19 +316,17 @@ public class LanguageMsgService {
//判断是否是新增 //判断是否是新增
LanguageMsg oldMsg=MessageUtils.getMsg(msg.getType(), msg.getCode()); LanguageMsg oldMsg = MessageUtils.getMsg(msg.getType(), msg.getCode());
if(oldMsg==null){ if (oldMsg == null) {
newLanguageList.add(msg); newLanguageList.add(msg);
} } else {
else{ boolean isUpdate = false;
boolean isUpdate=false;
//只新增不修改 //只新增不修改
List<String> allLanList=getAllLanList(); List<String> allLanList = getAllLanList();
for (String lanType : for (String lanType : allLanList) {
allLanList) {
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 (isNeedUpdate || ObjectUtil.isEmpty(oldValue)) {
oldMsg.setContent(lanType, newValue); oldMsg.setContent(lanType, newValue);
isUpdate = true; isUpdate = true;
...@@ -341,7 +340,7 @@ public class LanguageMsgService { ...@@ -341,7 +340,7 @@ public class LanguageMsgService {
} }
} }
if(isUpdate){ if (isUpdate) {
updateLanguageList.add(oldMsg); updateLanguageList.add(oldMsg);
languageMsgManager.save(oldMsg); languageMsgManager.save(oldMsg);
MessageUtils.updateMsg(oldMsg); MessageUtils.updateMsg(oldMsg);
...@@ -351,26 +350,20 @@ public class LanguageMsgService { ...@@ -351,26 +350,20 @@ public class LanguageMsgService {
} }
if (newLanguageList.size() > 0) { if (newLanguageList.size() > 0) {
languageMsgManager.insertAll(newLanguageList); languageMsgManager.insertAll(newLanguageList);
for (LanguageMsg msg : for (LanguageMsg msg : newLanguageList) {
newLanguageList) {
MessageUtils.updateMsg(msg); MessageUtils.updateMsg(msg);
} }
} }
log.info("导入csv["+fileName+"]资源,共["+msgList.size()+"]条数据,共更新[" + updateLanguageList.size() + "]条资源,新增[" + newLanguageList.size() + "]条资源"); log.info("导入csv[" + fileName + "]资源,共[" + msgList.size() + "]条数据,共更新[" + updateLanguageList.size() + "]条资源,新增[" + newLanguageList.size() + "]条资源");
} }
public Map<String, String> readPropertiesFile(File file) { public Map<String, String> readPropertiesFile(File file) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
try (FileInputStream fis = new FileInputStream(file.getPath()); try (FileInputStream fis = new FileInputStream(file.getPath()); InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); BufferedReader br = new BufferedReader(isr)) {
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
BufferedReader br = new BufferedReader(isr)
) {
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
...@@ -389,31 +382,30 @@ public class LanguageMsgService { ...@@ -389,31 +382,30 @@ public class LanguageMsgService {
} }
public List<LanguageMsg> readCsvFile(String fileURL , List<LanguageInfo> languageInfos) throws Exception{ public List<LanguageMsg> readCsvFile(String fileURL, List<LanguageInfo> languageInfos) throws Exception {
CsvReader csvRead = CsvReader.newReader(fileURL,"编号","code"); CsvReader csvRead = CsvReader.newReader(fileURL, "编号", "code");
int codeIndex = csvRead.getCsvIndex("编号","code"); int codeIndex = csvRead.getCsvIndex("编号", "code");
int typeIndex = csvRead.getCsvIndex("类型","type"); int typeIndex = csvRead.getCsvIndex("类型", "type");
int msgIndex = csvRead.getCsvIndex("内容","msg"); int msgIndex = csvRead.getCsvIndex("内容", "msg");
Map<String,Integer> lanCodeIndex=new HashMap<>() ; Map<String, Integer> lanCodeIndex = new HashMap<>();
// List<LanguageInfo> languageInfos=dataCache.getLanguageList(); // List<LanguageInfo> languageInfos=dataCache.getLanguageList();
for (LanguageInfo lan:languageInfos for (LanguageInfo lan : languageInfos) {
) { int lanIndex = csvRead.getCsvIndex(lan.getLanCode(), lan.getLanName());
int lanIndex = csvRead.getCsvIndex(lan.getLanCode(),lan.getLanName()); if (lanIndex >= 0) {
if(lanIndex>=0){ lanCodeIndex.put(lan.getLanCode(), lanIndex);
lanCodeIndex.put(lan.getLanCode(),lanIndex);
} }
} }
int row = 1; int row = 1;
int newRowCount = 0; int newRowCount = 0;
int updateRowCount = 0; int updateRowCount = 0;
String msg=""; String msg = "";
List<LanguageMsg> list=new ArrayList<>(); List<LanguageMsg> list = new ArrayList<>();
while(csvRead.readRecord()) { while (csvRead.readRecord()) {
row++; row++;
String[] lineValues = csvRead.getValues(); String[] lineValues = csvRead.getValues();
LanguageMsg languageMsg=new LanguageMsg(); LanguageMsg languageMsg = new LanguageMsg();
String code = lineValues[codeIndex]; String code = lineValues[codeIndex];
String type = lineValues[typeIndex]; String type = lineValues[typeIndex];
String msgStr = lineValues[msgIndex]; String msgStr = lineValues[msgIndex];
...@@ -425,13 +417,12 @@ public class LanguageMsgService { ...@@ -425,13 +417,12 @@ public class LanguageMsgService {
languageMsg.setCode(code); languageMsg.setCode(code);
languageMsg.setType(type); languageMsg.setType(type);
for (String lan : for (String lan : lanCodeIndex.keySet()) {
lanCodeIndex.keySet()) { int lanIndex = lanCodeIndex.get(lan);
int lanIndex=lanCodeIndex.get(lan); if (lineValues.length > lanIndex) {
if(lineValues.length>lanIndex){ String lanMsg = lineValues[lanIndex];
String lanMsg=lineValues[lanIndex]; if (!lanMsg.isEmpty()) {
if(!lanMsg.isEmpty()){ languageMsg.setContent(lan, lanMsg);
languageMsg.setContent(lan,lanMsg);
} }
} }
} }
...@@ -442,17 +433,14 @@ public class LanguageMsgService { ...@@ -442,17 +433,14 @@ public class LanguageMsgService {
} }
public Map<String,String> readJsFile(File file){ public Map<String, String> readJsFile(File file) {
Map<String,String> map=new HashMap<>(); Map<String, String> map = new HashMap<>();
try (FileInputStream fis = new FileInputStream(file.getPath()); try (FileInputStream fis = new FileInputStream(file.getPath()); InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); BufferedReader br = new BufferedReader(isr)) {
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
BufferedReader br = new BufferedReader(isr)
) {
String line; String line;
//网友推荐更加简洁的写法 //网友推荐更加简洁的写法
int lineIndex=-1; int lineIndex = -1;
String currNodeName=""; String currNodeName = "";
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
lineIndex++; lineIndex++;
...@@ -460,49 +448,48 @@ public class LanguageMsgService { ...@@ -460,49 +448,48 @@ public class LanguageMsgService {
// continue; // continue;
// } // }
if(ObjectUtil.isEmpty(line)){ if (ObjectUtil.isEmpty(line)) {
continue; continue;
} }
if (line.contains("{")){ if (line.contains("{")) {
if(line.contains("=")){ if (line.contains("=")) {
currNodeName=""; currNodeName = "";
}else{ } else {
int dendIndex=line.indexOf(':'); int dendIndex = line.indexOf(':');
String lineNode=line.substring(0,dendIndex).trim(); String lineNode = line.substring(0, dendIndex).trim();
if(ObjectUtil.isEmpty(currNodeName)){ if (ObjectUtil.isEmpty(currNodeName)) {
currNodeName=lineNode; currNodeName = lineNode;
}else{ } else {
//节点名称+ //节点名称+
currNodeName=currNodeName+"."+lineNode; currNodeName = currNodeName + "." + lineNode;
} }
} }
}else if(line.contains("}")){ } else if (line.contains("}")) {
//节点名称- //节点名称-
if(currNodeName.contains(".")){ if (currNodeName.contains(".")) {
int endIndex=currNodeName.lastIndexOf("."); int endIndex = currNodeName.lastIndexOf(".");
currNodeName=currNodeName.substring(0,endIndex ); currNodeName = currNodeName.substring(0, endIndex);
}else{ } else {
currNodeName=""; currNodeName = "";
}
} }
else if(line .contains(":")){ } else if (line.contains(":")) {
if(line.endsWith(",")){ if (line.endsWith(",")) {
line=line.substring(0,line.length()-1); line = line.substring(0, line.length() - 1);
} }
String[] array=line.replace("'","").replace("\"","").split(":"); String[] array = line.replace("'", "").replace("\"", "").split(":");
if(array.length==2){ if (array.length == 2) {
String linekey=array[0].trim(); String linekey = array[0].trim();
String lineValue=array[1].trim(); String lineValue = array[1].trim();
map.put(currNodeName+"."+linekey,lineValue); map.put(currNodeName + "." + linekey, lineValue);
} }
} }
} }
} catch (IOException e) { } catch (IOException e) {
log.error("readJsFile 出错:"+e.toString()); log.error("readJsFile 出错:" + e.toString());
e.printStackTrace(); e.printStackTrace();
} }
return map; return map;
......
...@@ -92,8 +92,8 @@ public class MessageUtils { ...@@ -92,8 +92,8 @@ public class MessageUtils {
private void initLanguageMsgList() { private void initLanguageMsgList() {
msgMap = messageService.loadMsgMap(); msgMap = messageService.loadMsgMap();
//自动导入CSV内容,只新增不修改 //自动导入JSON内容
messageService.autoImportCsvFile(); messageService.autoImportJsonFile();
//只新增不修改 //只新增不修改
messageService.autoImportResources(); messageService.autoImportResources();
if (msgMap.size() > 0) { if (msgMap.size() > 0) {
......
...@@ -410,11 +410,15 @@ public class LiteOrderCache { ...@@ -410,11 +410,15 @@ public class LiteOrderCache {
if(!Strings.isNullOrEmpty(reelId)){ if(!Strings.isNullOrEmpty(reelId)){
//RI //RI
pos=storagePosManager.getByBarcode(reelId); pos=storagePosManager.getByBarcode(reelId);
if(pos != null){
if(excludePosIds.contains(pos.getId())) { if(excludePosIds.contains(pos.getId())) {
log.info("工单[" + orderNo + "]RI出库,任务数[" + taskReelCount + "]出库位置仓位【" + pos.getPosName() + "】RI=[" + pos.getBarcode().getBarcode() + "]已在操作队列中,跳过不处理"); log.info("工单[" + orderNo + "]RI出库,任务数[" + taskReelCount + "]出库位置仓位【" + pos.getPosName() + "】RI=[" + pos.getBarcode().getBarcode() + "]已在操作队列中,跳过不处理");
break; break;
} }
}else{ }else{
log.info("工单[" + orderNo + "]RI出库时,库存中未找到料盘["+reelId+"]");
}
}else{
//PN //PN
pos=storagePosManager.findPartNumberInStorages(availableStorageIds, partNumber, excludePosIds, checkoutType); pos=storagePosManager.findPartNumberInStorages(availableStorageIds, partNumber, excludePosIds, checkoutType);
} }
......
...@@ -194,13 +194,14 @@ public class TaskService { ...@@ -194,13 +194,14 @@ public class TaskService {
* 获取所有任务 * 获取所有任务
*/ */
public List<DataLog> getAllTasksByCid(String cid) { public List<DataLog> getAllTasksByCid(String cid) {
List<DataLog> resultTasks = new ArrayList<>();
List<DataLog> allTasks = getAllTasks(); List<DataLog> allTasks = getAllTasks();
for (DataLog task : allTasks) { for (DataLog task : allTasks) {
if(task.getCid().equals(cid)){ if(task.getCid().equals(cid)){
allTasks.add(task); resultTasks.add(task);
} }
} }
return allTasks; return resultTasks;
} }
/** /**
......
...@@ -188,7 +188,7 @@ public class Menu extends BasePo implements Serializable { ...@@ -188,7 +188,7 @@ public class Menu extends BasePo implements Serializable {
menu.setHidden(false); menu.setHidden(false);
menu.setComponentName(""); menu.setComponentName("");
menu.setIcon(icon); menu.setIcon(icon);
menu.setTitleKey(""); menu.setTitleKey(path);
menu.setParentMenu(parentMenu); menu.setParentMenu(parentMenu);
return menu; return menu;
} }
......
...@@ -2,7 +2,7 @@ server: ...@@ -2,7 +2,7 @@ server:
port: 8800 port: 8800
api: api:
name: Neotel name:
inCheckUrl: inCheckUrl:
outNotifyUrl: outNotifyUrl:
inNotifyUrl: inNotifyUrl:
......
package com.neotel.smfcore;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.JsonUtil;
import org.junit.jupiter.api.Test;
import org.springframework.util.FileCopyUtils;
import java.io.File;
import java.io.FileWriter;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ApplicationTests {
@Test
void contextLoads() {
saveLanguageFile("smfcore");
saveLanguageFile("smf");
}
private void saveLanguageFile(String type){
try {
String url = "http://192.168.1.243/smf-core/api/translation/getLanguageMsgList";
Map<String,Object> params = new HashMap<>();
params.put("type",type);
System.out.println("开始获取最新["+type+"]翻译资源...");
String jsonTxt = HttpHelper.postParam(url,params);
Map<String, Object> resultMap = JsonUtil.toMap(jsonTxt);
if(resultMap.get("status") != null){
System.out.println(jsonTxt);
return;
}
// String jsonTxt = type + "+++++";
String testClassDirPath = this.getClass().getResource("/").getPath();
File testClassDir = new File(testClassDirPath);
File projectDir = testClassDir.getParentFile().getParentFile();
String filename = type+".json";
File projectJsonFile = new File(projectDir,"src/main/resources/"+filename);
System.out.println("生成翻译资源文件到" + projectJsonFile.getAbsolutePath());
try(FileWriter fw = new FileWriter(projectJsonFile)){
fw.write(jsonTxt);
}
File targetJsonFile = new File(projectDir,"target/classes/"+filename);
if(targetJsonFile.exists()){
targetJsonFile.delete();
}
System.out.println("复制翻译资源文件到" + targetJsonFile.getAbsolutePath());
FileCopyUtils.copy(projectJsonFile,targetJsonFile);
} catch (Exception e) {
System.out.println("获取["+type+"]翻译资源出错"+e.getMessage());
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!