|
|
@ -1,23 +1,21 @@
|
|
|
|
package cn.estsh.i3plus.core.apiservice.mq;
|
|
|
|
package cn.estsh.i3plus.core.apiservice.mq;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.base.ISystemInitService;
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysMenuService;
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysLocaleLanguageService;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.JsonUtilTool;
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysLocaleResourceService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleLanguage;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysMenu;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleResource;
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.LocaleUtils;
|
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.amqp.core.Message;
|
|
|
|
import org.springframework.amqp.core.Message;
|
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static cn.estsh.i3plus.platform.common.util.PlatformConstWords.QUEUE_IMPP_RESOURCE;
|
|
|
|
import static cn.estsh.i3plus.platform.common.util.PlatformConstWords.QUEUE_IMPP_RESOURCE;
|
|
|
|
|
|
|
|
|
|
|
@ -29,19 +27,13 @@ import static cn.estsh.i3plus.platform.common.util.PlatformConstWords.QUEUE_IMPP
|
|
|
|
* @CreateDate : 19-8-23 下午3:12
|
|
|
|
* @CreateDate : 19-8-23 下午3:12
|
|
|
|
* @Modify:
|
|
|
|
* @Modify:
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
//@Component
|
|
|
|
@Component
|
|
|
|
public class SysLocalResourceQueue {
|
|
|
|
public class SysLocalResourceQueue {
|
|
|
|
|
|
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(SysLocalResourceQueue.class);
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(SysLocalResourceQueue.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ISysLocaleResourceService localeResourceService;
|
|
|
|
private ISysMenuService sysMenuService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ISysLocaleLanguageService localeLanguageService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ISystemInitService systemInitService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 语言反向国际化实现
|
|
|
|
* 语言反向国际化实现
|
|
|
@ -49,55 +41,28 @@ public class SysLocalResourceQueue {
|
|
|
|
* <br/> 根据信息创建不同语言的国际化信息。
|
|
|
|
* <br/> 根据信息创建不同语言的国际化信息。
|
|
|
|
* <br/> 当存在的时候不做任何操作,不存的时候创建全部语言的资源信息
|
|
|
|
* <br/> 当存在的时候不做任何操作,不存的时候创建全部语言的资源信息
|
|
|
|
* </per>
|
|
|
|
* </per>
|
|
|
|
* @param resourceKey
|
|
|
|
|
|
|
|
* @param channel
|
|
|
|
* @param channel
|
|
|
|
* @param message
|
|
|
|
* @param message
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@RabbitListener(queues = QUEUE_IMPP_RESOURCE)
|
|
|
|
@RabbitListener(queues = QUEUE_IMPP_RESOURCE)
|
|
|
|
public void processImppMessage(String resourceKey, Channel channel, Message message) {
|
|
|
|
public void processImppMessage(String missResourceStr, Channel channel, Message message) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if(StringUtils.isNotBlank(resourceKey)){
|
|
|
|
Map<String, String> missResource = JsonUtilTool.decode(missResourceStr, Map.class);
|
|
|
|
List<SysLocaleLanguage> list = localeLanguageService.listSysLocaleLanguage();
|
|
|
|
if (missResource != null && !missResource.isEmpty()) {
|
|
|
|
if(list != null && list.size() > 0){
|
|
|
|
Map.Entry<String, String> entry = missResource.entrySet().iterator().next();
|
|
|
|
List<SysLocaleResource> resourceList = localeResourceService.findSysLocaleResourceByResKey(resourceKey);
|
|
|
|
SysMenu sysMenu = sysMenuService.getSysMenuByCode(entry.getValue());
|
|
|
|
|
|
|
|
CommonEnumUtil.SOFT_TYPE softType = CommonEnumUtil.SOFT_TYPE.valueOf(sysMenu.getSoftType());
|
|
|
|
List<SysLocaleResource> saveResource = new ArrayList<>(list.size());
|
|
|
|
if(softType == null){
|
|
|
|
SysLocaleResource resource = null;
|
|
|
|
softType = CommonEnumUtil.SOFT_TYPE.IMPP;
|
|
|
|
for (SysLocaleLanguage language : list) {
|
|
|
|
|
|
|
|
resource = null;
|
|
|
|
|
|
|
|
if(resourceList != null && resourceList.size() > 0){
|
|
|
|
|
|
|
|
for (SysLocaleResource localeResource : resourceList) {
|
|
|
|
|
|
|
|
if(language.getLanguageCode() != null && language.getLanguageCode().equals(localeResource.getLanguageCode())){
|
|
|
|
|
|
|
|
resource = localeResource;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
resource = new SysLocaleResource();
|
|
|
|
|
|
|
|
resource.setLanguageCode(language.getLanguageCode());
|
|
|
|
|
|
|
|
resource.setLanguageNameRdd(language.getLanguageName());
|
|
|
|
|
|
|
|
resource.setIsSystem(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
|
|
|
resource.setResourceType(CommonEnumUtil.SYS_LOCALE_RESOURCE_TYPE.MISSING.getValue());
|
|
|
|
|
|
|
|
resource.setResourceValue(resourceKey);
|
|
|
|
|
|
|
|
resource.setResourceKey(resourceKey);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resource.setCreateDatetime(TimeTool.getNowTime(true));
|
|
|
|
|
|
|
|
resource.setModifyDatetime(TimeTool.getNowTime(true));
|
|
|
|
|
|
|
|
resource.setIsValid(CommonEnumUtil.IS_VAILD.VAILD.getValue()); //有效
|
|
|
|
|
|
|
|
resource.setIsDeleted(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); //未删除
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(resource != null){
|
|
|
|
|
|
|
|
saveResource.add(resource);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(saveResource != null && saveResource.size() > 0){
|
|
|
|
|
|
|
|
localeResourceService.saveSysLocaleResource(saveResource);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LocaleUtils.saveMissResource(entry.getKey(), AuthUtil.getSessionLanguage().toString(),
|
|
|
|
|
|
|
|
softType.getValue(),
|
|
|
|
|
|
|
|
CommonEnumUtil.SYS_LOCALE_RESOURCE_TYPE.MISSING.getValue(),
|
|
|
|
|
|
|
|
CommonEnumUtil.MiSS_RESOURCE_SOURCE.WEB.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
LOGGER.error("缺失资源保存异常:{}", missResourceStr, e);
|
|
|
|
}finally {
|
|
|
|
}finally {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
|
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
|
|
|