Commit 657398a6 LN

锡膏管理图标修改。资源不同type的code可以重复。

1 个父辈 4b7908d5
......@@ -205,11 +205,11 @@ public class DataInitManager {
menus.addAll(createMenus(msd,msdManage,msdData,msdSetting));
Menu solderPaste = Menu.CreatePMenu("锡膏管理", 20, "solderPaste", 2, "MSD");
Menu solderPasteKanban = new Menu(new ArrayList<Menu>(), 1, "solderPasteKanban", "设备概览", 1, "solderPasteKanban", "neolight/solderPasteKanban/index", "", 0, "MSDManager");
Menu solderPasteManage = new Menu(new ArrayList<Menu>(), 1, "solderPasteManage", "库存", 1, "solderPasteManage", "neolight/solderPasteManage/index", "", 0, "MSDManager");
Menu solderPasteData = new Menu(new ArrayList<Menu>(), 1, "solderPasteData", "追溯性", 1, "solderPasteData", "neolight/solderPasteData/index", "", 0, "MSDData");
Menu solderPasteSetting = new Menu(new ArrayList<Menu>(), 1, "solderPasteSetting", "设置", 1, "solderPasteSetting", "neolight/solderPasteSetting/index", "", 0, "MSDSet");
Menu solderPaste = Menu.CreatePMenu("锡膏管理", 20, "solderPaste", 2, "sMana");
Menu solderPasteKanban = new Menu(new ArrayList<Menu>(), 1, "solderPasteKanban", "设备概览", 1, "solderPasteKanban", "neolight/solderPasteKanban/index", "", 0, "sKanban");
Menu solderPasteManage = new Menu(new ArrayList<Menu>(), 1, "solderPasteManage", "库存", 1, "solderPasteManage", "neolight/solderPasteManage/index", "", 0, "solder");
Menu solderPasteData = new Menu(new ArrayList<Menu>(), 1, "solderPasteData", "追溯性", 1, "solderPasteData", "neolight/solderPasteData/index", "", 0, "sData");
Menu solderPasteSetting = new Menu(new ArrayList<Menu>(), 1, "solderPasteSetting", "设置", 1, "solderPasteSetting", "neolight/solderPasteSetting/index", "", 0, "system");
menus.addAll(createMenus(solderPaste,solderPasteKanban,solderPasteManage,solderPasteData,solderPasteSetting));
//物料管理:元器件管理,条形码管理
......
......@@ -3,11 +3,8 @@ package com.neotel.smfcore.core.language.rest;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.csv.CsvReader;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.Md5Utls;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.language.rest.bean.dto.LanguageMsgDto;
......@@ -21,12 +18,10 @@ import com.neotel.smfcore.core.language.service.po.LanguageMsg;
import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.bean.FileProperties;
import com.neotel.smfcore.security.service.po.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.mapstruct.ap.shaded.freemarker.ext.beans.HashAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Criteria;
......@@ -93,14 +88,14 @@ public class LanguageMsgController {
String lanType = getLanTypeByFileName(uploadFile.getOriginalFilename());
if (smfclientType.contains(fileType)) {
//客户端js文件处理
Map<String, String> proMap = readJsFile(file);
Map<String, String> proMap = MessageUtils.readJsFile(file);
resultMsg = ResourceUpload(uploadFile.getOriginalFilename(), proMap, lanType, "smfclient");
} else if (smfcoreType.contains(fileType)) {
Map<String, String> proMap = MessageUtils.ReadPropertiesFile(file);
Map<String, String> proMap = MessageUtils.readPropertiesFile(file);
resultMsg = ResourceUpload(uploadFile.getOriginalFilename(), proMap, lanType, "");
}
if(csvType.equals(fileType)){
List<LanguageMsg> list=CsvFileRead(file.getAbsolutePath());
List<LanguageMsg> list=MessageUtils.readCsvFile(file.getAbsolutePath(),dataCache.getLanguageList());
msgListUpload(list);
}
return ResultBean.newOkResult(resultMsg);
......@@ -232,6 +227,7 @@ public class LanguageMsgController {
return list;
}
@ApiOperation("客户端提交资源列表:只增加不修改")
@PostMapping(value = "/resource")
@AnonymousAccess
......@@ -317,7 +313,7 @@ public class LanguageMsgController {
proMap.keySet()) {
String msgStr = proMap.get(key);
LanguageMsg msg = MessageUtils.getMsg(key);
LanguageMsg msg = MessageUtils.getMsg(type,key);
//导入时只能新增不能修改
if (msg == null) {
msg = new LanguageMsg(key, msgStr,type);
......@@ -353,124 +349,6 @@ public class LanguageMsgController {
return "ok";
}
private Map<String,String> readJsFile(File file){
Map<String,String> map=new HashMap<>();
try (FileInputStream fis = new FileInputStream(file.getPath());
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
BufferedReader br = new BufferedReader(isr)
) {
String line;
//网友推荐更加简洁的写法
int lineIndex=-1;
String currNodeName="";
while ((line = br.readLine()) != null) {
lineIndex++;
// if(lineIndex==0){
// continue;
// }
if(ObjectUtil.isEmpty(line)){
continue;
}
if (line.contains("{")){
if(line.contains("=")){
currNodeName="";
}else{
int dendIndex=line.indexOf(':');
String lineNode=line.substring(0,dendIndex).trim();
if(ObjectUtil.isEmpty(currNodeName)){
currNodeName=lineNode;
}else{
//节点名称+
currNodeName=currNodeName+"."+lineNode;
}
}
}else if(line.contains("}")){
//节点名称-
if(currNodeName.contains(".")){
int endIndex=currNodeName.lastIndexOf(".");
currNodeName=currNodeName.substring(0,endIndex );
}else{
currNodeName="";
}
}
else if(line .contains(":")){
if(line.endsWith(",")){
line=line.substring(0,line.length()-1);
}
String[] array=line.replace("'","").replace("\"","").split(":");
if(array.length==2){
String linekey=array[0].trim();
String lineValue=array[1].trim();
map.put(currNodeName+"."+linekey,lineValue);
}
}
}
} catch (IOException e) {
log.error("readJsFile 出错:"+e.toString());
e.printStackTrace();
}
return map;
}
private List<LanguageMsg> CsvFileRead(String fileURL ) throws Exception{
CsvReader csvRead = CsvReader.newReader(fileURL,"编号","code");
int codeIndex = csvRead.getCsvIndex("编号","code");
int typeIndex = csvRead.getCsvIndex("类型","type");
int msgIndex = csvRead.getCsvIndex("内容","msg");
Map<String,Integer> lanCodeIndex=new HashMap<>() ;
List<LanguageInfo> languageInfos=dataCache.getLanguageList();
for (LanguageInfo lan:languageInfos
) {
int lanIndex = csvRead.getCsvIndex(lan.getLanCode(),lan.getLanName());
if(lanIndex>=0){
lanCodeIndex.put(lan.getLanCode(),lanIndex);
}
}
int row = 1;
int newRowCount = 0;
int updateRowCount = 0;
String msg="";
List<LanguageMsg> list=new ArrayList<>();
while(csvRead.readRecord()) {
row++;
String[] lineValues = csvRead.getValues();
LanguageMsg languageMsg=new LanguageMsg();
String code = lineValues[codeIndex];
String type = lineValues[typeIndex];
String msgStr = lineValues[msgIndex];
if (code.isEmpty() || type.isEmpty() || msgStr.isEmpty()) {
log.warn("第" + row + "行中有空白内容,此行忽略");
continue;
}
languageMsg.setMsg(msgStr);
languageMsg.setCode(code);
languageMsg.setType(type);
for (String lan :
lanCodeIndex.keySet()) {
int lanIndex=lanCodeIndex.get(lan);
String lanMsg=lineValues[lanIndex];
if(!lanMsg.isEmpty()){
languageMsg.setContent(lan,lanMsg);
}
}
list.add(languageMsg);
}
return list;
}
private void msgListUpload( List<LanguageMsg> msgList) {
List<LanguageMsg> newLanguageList = new ArrayList<>();
......@@ -501,7 +379,7 @@ public class LanguageMsgController {
//判断是否是新增
LanguageMsg oldMsg=MessageUtils.getMsg(msg.getCode());
LanguageMsg oldMsg=MessageUtils.getMsg(msg.getType(), msg.getCode());
if(oldMsg==null){
newLanguageList.add(msg);
}
......
......@@ -89,19 +89,19 @@ public class LanguageMsgManagerImpl implements ILanguageMsgManager {
@Override
public LanguageMsg saveMsg(LanguageMsg resources) {
if (resources.getCode() == null) {
if ( ObjectUtil.isEmpty(resources.getCode() )) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"});
}
if (resources.getMsg() == null) {
if (ObjectUtil.isEmpty(resources.getMsg() )) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"msg"});
}
if (resources.getType() == null) {
if (ObjectUtil.isEmpty(resources.getType() )) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"type"});
}
if (resources.getContentList() == null) {
if (ObjectUtil.isEmpty(resources.getContentList() )) {
resources.setContentList(new ArrayList<>());
}
Criteria c = Criteria.where("code").is(resources.getCode());
Criteria c = Criteria.where("code").is(resources.getCode()).and("type").is(resources.getType());
String logName = "新增资源:";
if (resources.getId() != null) {
logName = "修改资源:";
......@@ -109,7 +109,7 @@ public class LanguageMsgManagerImpl implements ILanguageMsgManager {
} //code不能重复
LanguageMsg result = languageMsgDao.findOne(new Query(c));
if (result != null) {
throw new ValidateException("smfcore.resourcesExist", "资源[" + resources.getCode() + "]已存在");
throw new ValidateException("smfcore.resourcesExist", "资源[{0}][{1}]已存在",new String[]{resources.getType(),resources.getCode()});
}
Query query = new Query(c);
......
......@@ -116,7 +116,9 @@ public class DevicesStatusUtil {
public static Map<String,String> getAndRemoveOp(String cid){
Map<String, String> opMap = storageOpMap.get(cid);
if(opMap!=null){
opMap.remove(cid);
}
return opMap;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!