|  |  |  | @ -1,23 +1,21 @@ | 
		
	
		
			
				|  |  |  |  | package cn.estsh.i3plus.core.apiservice.mq; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.core.api.iservice.base.ISystemInitService; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.core.api.iservice.busi.ISysLocaleLanguageService; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.core.api.iservice.busi.ISysLocaleResourceService; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.platform.common.tool.TimeTool; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.core.api.iservice.busi.ISysMenuService; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.platform.common.tool.JsonUtilTool; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.platform.bean.SysLocaleLanguage; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.platform.bean.SysLocaleResource; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.platform.bean.SysMenu; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.impp.framework.boot.auth.AuthUtil; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.impp.framework.boot.util.LocaleUtils; | 
		
	
		
			
				|  |  |  |  | import com.rabbitmq.client.Channel; | 
		
	
		
			
				|  |  |  |  | import org.apache.commons.lang3.StringUtils; | 
		
	
		
			
				|  |  |  |  | import org.slf4j.Logger; | 
		
	
		
			
				|  |  |  |  | import org.slf4j.LoggerFactory; | 
		
	
		
			
				|  |  |  |  | import org.springframework.amqp.core.Message; | 
		
	
		
			
				|  |  |  |  | import org.springframework.amqp.rabbit.annotation.RabbitListener; | 
		
	
		
			
				|  |  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
		
	
		
			
				|  |  |  |  | import org.springframework.stereotype.Component; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | import java.io.IOException; | 
		
	
		
			
				|  |  |  |  | import java.util.ArrayList; | 
		
	
		
			
				|  |  |  |  | import java.util.List; | 
		
	
		
			
				|  |  |  |  | import java.util.Map; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 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 | 
		
	
		
			
				|  |  |  |  |  * @Modify: | 
		
	
		
			
				|  |  |  |  |  **/ | 
		
	
		
			
				|  |  |  |  | //@Component
 | 
		
	
		
			
				|  |  |  |  | @Component | 
		
	
		
			
				|  |  |  |  | public class SysLocalResourceQueue { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     private static final Logger LOGGER = LoggerFactory.getLogger(SysLocalResourceQueue.class); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Autowired | 
		
	
		
			
				|  |  |  |  |     private ISysLocaleResourceService localeResourceService; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Autowired | 
		
	
		
			
				|  |  |  |  |     private ISysLocaleLanguageService localeLanguageService; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Autowired | 
		
	
		
			
				|  |  |  |  |     private ISystemInitService systemInitService; | 
		
	
		
			
				|  |  |  |  |     private ISysMenuService sysMenuService; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     /** | 
		
	
		
			
				|  |  |  |  |      * 语言反向国际化实现 | 
		
	
	
		
			
				
					|  |  |  | @ -49,55 +41,28 @@ public class SysLocalResourceQueue { | 
		
	
		
			
				|  |  |  |  |      * <br/>   根据信息创建不同语言的国际化信息。 | 
		
	
		
			
				|  |  |  |  |      * <br/>        当存在的时候不做任何操作,不存的时候创建全部语言的资源信息 | 
		
	
		
			
				|  |  |  |  |      * </per> | 
		
	
		
			
				|  |  |  |  |      * @param resourceKey | 
		
	
		
			
				|  |  |  |  |      * @param channel | 
		
	
		
			
				|  |  |  |  |      * @param message | 
		
	
		
			
				|  |  |  |  |      */ | 
		
	
		
			
				|  |  |  |  |     @RabbitListener(queues = QUEUE_IMPP_RESOURCE) | 
		
	
		
			
				|  |  |  |  |     public void processImppMessage(String resourceKey, Channel channel, Message message) { | 
		
	
		
			
				|  |  |  |  |     public void processImppMessage(String missResourceStr, Channel channel, Message message) { | 
		
	
		
			
				|  |  |  |  |         try { | 
		
	
		
			
				|  |  |  |  |             if(StringUtils.isNotBlank(resourceKey)){ | 
		
	
		
			
				|  |  |  |  |                 List<SysLocaleLanguage> list = localeLanguageService.listSysLocaleLanguage(); | 
		
	
		
			
				|  |  |  |  |                 if(list != null && list.size() > 0){ | 
		
	
		
			
				|  |  |  |  |                     List<SysLocaleResource> resourceList = localeResourceService.findSysLocaleResourceByResKey(resourceKey); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |                     List<SysLocaleResource> saveResource = new ArrayList<>(list.size()); | 
		
	
		
			
				|  |  |  |  |                     SysLocaleResource resource = null; | 
		
	
		
			
				|  |  |  |  |                     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); | 
		
	
		
			
				|  |  |  |  |                         } | 
		
	
		
			
				|  |  |  |  |             Map<String, String> missResource = JsonUtilTool.decode(missResourceStr, Map.class); | 
		
	
		
			
				|  |  |  |  |             if (missResource != null && !missResource.isEmpty()) { | 
		
	
		
			
				|  |  |  |  |                 Map.Entry<String, String> entry = missResource.entrySet().iterator().next(); | 
		
	
		
			
				|  |  |  |  |                 SysMenu sysMenu = sysMenuService.getSysMenuByCode(entry.getValue()); | 
		
	
		
			
				|  |  |  |  |                 CommonEnumUtil.SOFT_TYPE softType = CommonEnumUtil.SOFT_TYPE.valueOf(sysMenu.getSoftType()); | 
		
	
		
			
				|  |  |  |  |                 if(softType == null){ | 
		
	
		
			
				|  |  |  |  |                     softType = CommonEnumUtil.SOFT_TYPE.IMPP; | 
		
	
		
			
				|  |  |  |  |                 } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |                     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){ | 
		
	
		
			
				|  |  |  |  |             e.printStackTrace(); | 
		
	
		
			
				|  |  |  |  |             LOGGER.error("缺失资源保存异常:{}", missResourceStr, e); | 
		
	
		
			
				|  |  |  |  |         }finally { | 
		
	
		
			
				|  |  |  |  |             try { | 
		
	
		
			
				|  |  |  |  |                 channel.basicAck(message.getMessageProperties().getDeliveryTag(),false); | 
		
	
	
		
			
				
					|  |  |  | 
 |