org.jeecgframework.core.util.ApplicationContextUtil Java Examples

The following examples show how to use org.jeecgframework.core.util.ApplicationContextUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TSFillRuleServiceImpl.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
* 执行JAVA增强
*/
private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
	if(StringUtil.isNotEmpty(cgJavaValue)){
	Object obj = null;
	try {
		if("class".equals(cgJavaType)){
			//因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
			obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
		}else if("spring".equals(cgJavaType)){
			obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
		}
		if(obj instanceof CgformEnhanceJavaInter){
			CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
			javaInter.execute("t_s_fill_rule",data);
		}
	} catch (Exception e) {
		e.printStackTrace();
		throw new Exception("执行JAVA增强出现异常!");
	} 
}
}
 
Example #2
Source File: MultiUploadServiceImpl.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
* 执行JAVA增强
*/
private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
	if(StringUtil.isNotEmpty(cgJavaValue)){
	Object obj = null;
	try {
		if("class".equals(cgJavaType)){
			//因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
			obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
		}else if("spring".equals(cgJavaType)){
			obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
		}
		if(obj instanceof CgformEnhanceJavaInter){
			CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
			javaInter.execute("multi_upload",data);
		}
	} catch (Exception e) {
		e.printStackTrace();
		throw new Exception("执行JAVA增强出现异常!");
	} 
}
}
 
Example #3
Source File: DataGridTag.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
 * 描述:组装菜单按钮操作权限
 * dateGridUrl:url
 * operationCode:操作码
 * optList: 操作列表
 * @version 1.0
 */
private void installOperationCode(DataGridUrl dataGridUrl,String operationCode,List optList){
	if(ResourceUtil.getSessionUser().getUserName().equals("admin")|| !Globals.BUTTON_AUTHORITY_CHECK){
		optList.add(dataGridUrl);
	}else if(!oConvertUtils.isEmpty(operationCode)){
		Set<String> operationCodes = (Set<String>) super.pageContext.getRequest().getAttribute(Globals.OPERATIONCODES);
		if (null!=operationCodes) {
			List<String> operationCodesStr = new ArrayList<String>();
			for (String MyoperationCode : operationCodes) {
				if (oConvertUtils.isEmpty(MyoperationCode))
					break;
				systemService = ApplicationContextUtil.getContext().getBean(
							SystemService.class);
				TSOperation operation = systemService.getEntity(TSOperation.class, MyoperationCode);
				operationCodesStr.add(operation.getOperationcode());
			}
			if (!operationCodesStr.contains(operationCode)){
				optList.add(dataGridUrl);
			}
		}
	}else {
		optList.add(dataGridUrl);
	}
}
 
Example #4
Source File: HasPermissionTag.java    From jeecg with Apache License 2.0 6 votes vote down vote up
public boolean showTagBody(String code) {
if(ResourceUtil.getSessionUser().getUserName().equals("admin")|| !Globals.BUTTON_AUTHORITY_CHECK){
	return false;
}else{
	//权限判断;
	Set<String> operationCodeIds = (Set<String>) super.pageContext.getRequest().getAttribute(Globals.OPERATIONCODES);
	systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
	if (null!=operationCodeIds) {
		for (String operationCodeId : operationCodeIds) {
			if (oConvertUtils.isEmpty(operationCodeId))
				break;
			TSOperation operation = systemService.getEntity(TSOperation.class, operationCodeId);
			if (operation!=null && operation.getOperationcode().equals(code)){
				return true;
			}
		}
	}else{
		//包含权限规则修改,查询不到配置则不显示;
		return true;

	}
}
      return false;
  }
 
Example #5
Source File: MenuButtonsTag.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
 * 获取操作按钮的的code
 * @return
 */
private List<String> getOperationcodes(){
	//权限判断
	List<String> list = new ArrayList<String>();
	Set<String> operationCodeIds = (Set<String>) super.pageContext.getRequest().getAttribute(Globals.OPERATIONCODES);
	systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
	if (null!=operationCodeIds) {
		for (String operationCodeId : operationCodeIds) {
			if (oConvertUtils.isEmpty(operationCodeId))
				continue;
			TSOperation operation = systemService.getEntity(TSOperation.class, operationCodeId);
			if(operation!=null){
				list.add(operation.getOperationcode());
			}
		}
	}
	return list;
}
 
Example #6
Source File: TSCompanyPositionServiceImpl.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
* 执行JAVA增强
*/
private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
	if(StringUtil.isNotEmpty(cgJavaValue)){
	Object obj = null;
	try {
		if("class".equals(cgJavaType)){
			//因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
			obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
		}else if("spring".equals(cgJavaType)){
			obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
		}
		if(obj instanceof CgformEnhanceJavaInter){
			CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
			javaInter.execute("t_s_company_position",data);
		}
	} catch (Exception e) {
		e.printStackTrace();
		throw new Exception("执行JAVA增强出现异常!");
	} 
}
}
 
Example #7
Source File: TSInterfaceServiceImpl.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
 * 执行JAVA增强
 */
private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
	if(StringUtil.isNotEmpty(cgJavaValue)){
		Object obj = null;
		try {
			if("class".equals(cgJavaType)){
				//因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
				obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
			}else if("spring".equals(cgJavaType)){
				obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
			}
			if(obj instanceof CgformEnhanceJavaInter){
				CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
				javaInter.execute("t_s_interface",data);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception("执行JAVA增强出现异常!");
		} 
	}
}
 
Example #8
Source File: InterroleServiceImpl.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
* 执行JAVA增强
*/
private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
	if(StringUtil.isNotEmpty(cgJavaValue)){
	Object obj = null;
	try {
		if("class".equals(cgJavaType)){
			//因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
			obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
		}else if("spring".equals(cgJavaType)){
			obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
		}
		if(obj instanceof CgformEnhanceJavaInter){
			CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
			javaInter.execute("t_s_interrole",data);
		}
	} catch (Exception e) {
		e.printStackTrace();
		throw new Exception("执行JAVA增强出现异常!");
	} 
}
}
 
Example #9
Source File: TsBlackListServiceImpl.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
* 执行JAVA增强
*/
private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
	if(StringUtil.isNotEmpty(cgJavaValue)){
	Object obj = null;
	try {
		if("class".equals(cgJavaType)){
			//因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
			obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
		}else if("spring".equals(cgJavaType)){
			obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
		}
		if(obj instanceof CgformEnhanceJavaInter){
			CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
			javaInter.execute("ts_black_list",data);
		}
	} catch (Exception e) {
		e.printStackTrace();
		throw new Exception("执行JAVA增强出现异常!");
	} 
}
}
 
Example #10
Source File: FillRuleUtil.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param ruleCode ruleCode
 * @return 
 */
public static Object executeRule(String ruleCode){
	if(StringUtil.isEmpty(ruleCode))return null;
	Object obj=null;
	try {
		TSFillRuleServiceI ruleServiceI = ApplicationContextUtil.getContext().getBean(TSFillRuleServiceI.class);
		TSFillRuleEntity ruleEntity = ruleServiceI.findUniqueByProperty(TSFillRuleEntity.class, "ruleCode", ruleCode);
		if(ruleEntity!=null){
			IFillRuleHandler ruleHandler = (IFillRuleHandler) Class.forName(ruleEntity.getRuleClass()).newInstance();
			obj=ruleHandler.execute(ruleEntity.getRuleParam());
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return obj;
}
 
Example #11
Source File: CgformEnhanceJavaServiceImpl.java    From jeecg with Apache License 2.0 6 votes vote down vote up
@Override
public boolean checkClassOrSpringBeanIsExist(CgformEnhanceJavaEntity cgformEnhanceJavaEntity) {
	String cgJavaType = cgformEnhanceJavaEntity.getCgJavaType();
	String cgJavaValue = cgformEnhanceJavaEntity.getCgJavaValue();

	if(StringUtil.isNotEmpty(cgJavaValue)){
		try {
			if("class".equals(cgJavaType)){
				Class clazz = Class.forName(cgJavaValue);
				if(clazz==null || clazz.newInstance()==null)
					return false;
			}
			
			if("spring".equals(cgJavaType)){
				Object obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
				if(obj==null)
					return false;
			}
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

	return true;
}
 
Example #12
Source File: DaZhuanPanService.java    From jeewx with Apache License 2.0 6 votes vote down vote up
@Override
public String excute(String content, TextMessageResp defaultMessage,
		HttpServletRequest request) {
	WeixinAccountServiceI weixinAccountService = (WeixinAccountServiceI) ApplicationContextUtil.getContext().getBean("weixinAccountService");
	String accountid = weixinAccountService.findByToUsername(defaultMessage.getFromUserName()).getId();
	ResourceBundle bundler = ResourceBundle.getBundle("sysConfig");
	List<Article> articleList = new ArrayList<Article>();
	Article article = new Article();
	article.setTitle("大转盘");
	article.setDescription("大转盘抽奖咯");
	article.setPicUrl(bundler.getString("domain")
					+ "/plug-in/weixin/images/activity-lottery-1.png");
	article.setUrl(bundler.getString("domain")
			+ "/zpController.do?goZhuanpan&accountid="+accountid+"&openId="+defaultMessage.getToUserName());
	articleList.add(article);
	NewsMessageResp newsMessage = new NewsMessageResp();
	newsMessage.setToUserName(defaultMessage.getToUserName());
	newsMessage.setFromUserName(defaultMessage.getFromUserName());
	newsMessage.setCreateTime(new Date().getTime());
	newsMessage.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_NEWS);
	newsMessage.setArticleCount(articleList.size());
	newsMessage.setArticles(articleList);
	return MessageUtil.newsMessageToXml(newsMessage);
}
 
Example #13
Source File: GuagualeService.java    From jeewx with Apache License 2.0 6 votes vote down vote up
@Override
public String excute(String content, TextMessageResp defaultMessage,
		HttpServletRequest request) {
	WeixinAccountServiceI weixinAccountService = (WeixinAccountServiceI) ApplicationContextUtil.getContext().getBean("weixinAccountService");
	String accountid = weixinAccountService.findByToUsername(defaultMessage.getFromUserName()).getId();
	ResourceBundle bundler = ResourceBundle.getBundle("sysConfig");
	List<Article> articleList = new ArrayList<Article>();
	Article article = new Article();
	article.setTitle("刮刮乐");
	article.setDescription("刮刮乐咯");
	article
			.setPicUrl(bundler.getString("domain")
					+ "/plug-in/weixin/images/ggl/card.png");
	article.setUrl(bundler.getString("domain")
			+ "/zpController.do?goGglNew&accountid="+accountid+"&openId="+defaultMessage.getToUserName());
	articleList.add(article);
	NewsMessageResp newsMessage = new NewsMessageResp();
	newsMessage.setToUserName(defaultMessage.getToUserName());
	newsMessage.setFromUserName(defaultMessage.getFromUserName());
	newsMessage.setCreateTime(new Date().getTime());
	newsMessage.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_NEWS);
	newsMessage.setArticleCount(articleList.size());
	newsMessage.setArticles(articleList);
	return MessageUtil.newsMessageToXml(newsMessage);
}
 
Example #14
Source File: CmsService.java    From jeewx with Apache License 2.0 6 votes vote down vote up
public String excute(String content, TextMessageResp defaultMessage,
		HttpServletRequest request) {
	WeixinAccountServiceI weixinAccountService =(WeixinAccountServiceI)ApplicationContextUtil.getContext().getBean("weixinAccountService");
	ResourceBundle bundler = ResourceBundle.getBundle("sysConfig");
	List<Article> articleList = new ArrayList<Article>();
	Article article = new Article();
	article.setTitle("微网站");
	article.setDescription("");
	article.setPicUrl(bundler.getString("domain")+ "/webpage/weixin/cms/images/index.jpg");
	// 此userid后期需要通过高级接口获取到微信帐号,此处先以加密后的ID为参数进行传递
	String accountid = weixinAccountService.findByToUsername(defaultMessage.getFromUserName()).getId();
	article.setUrl(bundler.getString("domain")+ "/cmsController.do?goPage&page=index&accountid="+ accountid + "&userid="+ defaultMessage.getToUserName());
	articleList.add(article);
	NewsMessageResp newsMessage = new NewsMessageResp();
	newsMessage.setToUserName(defaultMessage.getToUserName());
	newsMessage.setFromUserName(defaultMessage.getFromUserName());
	newsMessage.setCreateTime(new Date().getTime());
	newsMessage.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_NEWS);
	newsMessage.setArticleCount(articleList.size());
	newsMessage.setArticles(articleList);
	return MessageUtil.newsMessageToXml(newsMessage);
}
 
Example #15
Source File: CmsArticleDataCollect.java    From jeewx with Apache License 2.0 6 votes vote down vote up
@Override
public void collect(Map<String, String> params) {
	CmsArticleServiceI cmsArticleService = (CmsArticleServiceI) ApplicationContextUtil.getContext().getBean("cmsArticleService");
	
	String articleid = params.get("articleid") != null ? params.get("articleid").toString() : "-";
	CmsArticleEntity cmsArticleEntity = cmsArticleService.getCmsArticleEntity(articleid);
	if (cmsArticleEntity != null) {
		CmsDataContent.put(CmsConstant.CMS_DATA_MAP_ARTICLE, cmsArticleEntity);
		CmsDataContent.put(CmsConstant.CMS_DATA_STR_TITLE, cmsArticleEntity.getTitle());
	}else{
		CmsDataContent.put(CmsConstant.CMS_DATA_MAP_ARTICLE, new CmsArticleEntity());
		CmsDataContent.put(CmsConstant.CMS_DATA_STR_TITLE, "文章明细");
	}
	String res = CmsConstant.CMS_ROOT_PATH + "/" + params.get(CmsConstant.CMS_STYLE_NAME);
	//资源路径
	CmsDataContent.put(CmsConstant.BASE, res);
}
 
Example #16
Source File: DictSelectTag.java    From jeewx with Apache License 2.0 5 votes vote down vote up
/**
 * 查询自定义数据字典
 * 
 * @作者:Alexander
 */
private List<Map<String, Object>> queryDic() {
	String sql = "select " + dictField + " as field," + dictText
			+ " as text from " + dictTable;
	systemService = ApplicationContextUtil.getContext().getBean(
			SystemService.class);
	List<Map<String, Object>> list = systemService.findForJdbc(sql);
	return list;
}
 
Example #17
Source File: InterfaceUtil.java    From jeecg with Apache License 2.0 5 votes vote down vote up
/**
 * 获取接口权限
 * @param request
 * @param interfaceEnum
 * @return
 */
public static InterfaceRuleDto getInterfaceRuleDto(HttpServletRequest request,InterfaceEnum interfaceEnum){
	//获取用户id
	String userName = (String) request.getAttribute(JwtConstants.CURRENT_USER_NAME);//= "interfaceuser";//
	logger.info(interfaceEnum.toString()+"--------"+userName);
	//根据用户账号和接口编码查询用户的接口权限
	TSInterfaceServiceI interfaceService=ApplicationContextUtil.getContext().getBean(TSInterfaceServiceI.class);
	InterfaceRuleDto interfaceRuleDto = interfaceService.getInterfaceRuleByUserNameAndCode(userName,interfaceEnum);
	System.out.println(interfaceRuleDto);
	logger.info(interfaceEnum.toString()+"--------"+interfaceRuleDto);
	return interfaceRuleDto;
}
 
Example #18
Source File: DictSelectTag.java    From jeecg with Apache License 2.0 5 votes vote down vote up
/**
 * 查询自定义数据字典
 * 
 * @作者:Alexander
 */
private List<Map<String, Object>> queryDic() {
	String sql = "select " + dictField + " as field," + dictText
			+ " as text from " + dictTable;

       if(dictCondition!=null){
           sql+=" "+dictCondition+" ";
       }

	systemService = ApplicationContextUtil.getContext().getBean(
			SystemService.class);
	List<Map<String, Object>> list = systemService.findForJdbc(sql);
	return list;
}
 
Example #19
Source File: DataGridTag.java    From jeecg with Apache License 2.0 5 votes vote down vote up
public String getNoAuthOperButton(){
	StringBuffer sb = new StringBuffer();
	if(ResourceUtil.getSessionUser().getUserName().equals("admin")|| !Globals.BUTTON_AUTHORITY_CHECK){
	}else{
		Set<String> operationCodes = (Set<String>) super.pageContext.getRequest().getAttribute(Globals.OPERATIONCODES);
		if (null!=operationCodes) {
			for (String MyoperationCode : operationCodes) {
				if (oConvertUtils.isEmpty(MyoperationCode))
					break;
				systemService = ApplicationContextUtil.getContext().getBean(
							SystemService.class);
				TSOperation operation = systemService.getEntity(TSOperation.class, MyoperationCode);
				if (operation.getOperationcode().startsWith(".") || operation.getOperationcode().startsWith("#")){
					if (operation.getOperationType().intValue()==Globals.OPERATION_TYPE_HIDE){
						//out.append("$(\""+name+"\").find(\"#"+operation.getOperationcode().replaceAll(" ", "")+"\").hide();");
						sb.append("$(\""+operation.getOperationcode().replaceAll(" ", "")+"\").hide();");
					}else {
						//out.append("$(\""+name+"\").find(\"#"+operation.getOperationcode().replaceAll(" ", "")+"\").find(\":input\").attr(\"disabled\",\"disabled\");");
						sb.append("$(\""+operation.getOperationcode().replaceAll(" ", "")+"\").attr(\"disabled\",\"disabled\");");
						sb.append("$(\""+operation.getOperationcode().replaceAll(" ", "")+"\").find(\":input\").attr(\"disabled\",\"disabled\");");
					}
				}
			}
		}
		
	}
	//org.jeecgframework.core.util.LogUtil.info("----getNoAuthOperButton-------"+sb.toString());
	return sb.toString(); 
}
 
Example #20
Source File: QueryGenerator.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 获取系统数据库类型
 */
private static String getDbType(){
	if(oConvertUtils.isNotEmpty(DB_TYPE)){
		return DB_TYPE;
	}
	try {
		ISysBaseAPI sysBaseAPI = ApplicationContextUtil.getContext().getBean(ISysBaseAPI.class);
		DB_TYPE = sysBaseAPI.getDatabaseType();
		return DB_TYPE;
	} catch (Exception e) {
		e.printStackTrace();
	}
	return DB_TYPE;
}
 
Example #21
Source File: CmsPhotoDataCollect.java    From jeewx with Apache License 2.0 5 votes vote down vote up
@Override
public void collect(Map<String, String> params) {
	WeixinPhotoAlbumServiceI weixinPhotoAlbumService = (WeixinPhotoAlbumServiceI) ApplicationContextUtil.getContext().getBean("weixinPhotoAlbumService");
	String id = params.get("id");
	WeixinPhotoAlbumEntity weixinPhotoAlbum = weixinPhotoAlbumService.getEntity(WeixinPhotoAlbumEntity.class, id);
	List<WeixinPhotoEntity> photos = weixinPhotoAlbum.getPhotos();

	//相片列表
	CmsDataContent.put(CmsConstant.CMS_DATA_LIST_PHOTO, photos);
	//资源模板先用default 待以后模板功能做好,统一动态传入
	String res = CmsConstant.CMS_PHOTO_ROOT_PATH + "/" + CmsConstant.CMS_PHOTO_DEFAULT_STYLE;
	//资源路径
	CmsDataContent.put(CmsConstant.BASE, res);
}
 
Example #22
Source File: QueryGenerator.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 获取系统数据库类型
 */
private static String getDbType(){
	if(oConvertUtils.isNotEmpty(DB_TYPE)){
		return DB_TYPE;
	}
	try {
		ISysBaseAPI sysBaseAPI = ApplicationContextUtil.getContext().getBean(ISysBaseAPI.class);
		DB_TYPE = sysBaseAPI.getDatabaseType();
		return DB_TYPE;
	} catch (Exception e) {
		e.printStackTrace();
	}
	return DB_TYPE;
}
 
Example #23
Source File: ComponentTools.java    From jeecg with Apache License 2.0 5 votes vote down vote up
public List<Map<String, Object>> getTableDictData(DataGridColumn col){
	String[] dic = col.getDictionary().split(",");
	String sql;
	if(!StringUtil.isEmpty(col.getDictCondition())){
		sql = "select " + dic[1] + " as field," + dic[2]+ " as text from " + dic[0]+" "+col.getDictCondition();
	}else{
		sql = "select " + dic[1] + " as field," + dic[2]+ " as text from " + dic[0];
	}
	systemService = ApplicationContextUtil.getContext().getBean(
			SystemService.class);
	List<Map<String, Object>> list = systemService.findForJdbc(sql);
	return list;
}
 
Example #24
Source File: ExportBase.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
/**
 * 注解到导出对象的转换
 * 
 * @param targetId
 * @param field
 * @param excelEntity
 * @param excel
 * @param pojoClass
 * @throws Exception
 */
private void getExcelField(String targetId, Field field, ExcelExportEntity excelEntity, Excel excel, Class<?> pojoClass) throws Exception {
	excelEntity.setName(getExcelName(excel.name(), targetId));
	excelEntity.setWidth(excel.width());
	excelEntity.setHeight(excel.height());
	excelEntity.setNeedMerge(excel.needMerge());
	excelEntity.setMergeVertical(excel.mergeVertical());
	excelEntity.setMergeRely(excel.mergeRely());
	excelEntity.setReplace(excel.replace());
	if(StringUtils.isNotEmpty(excel.dicCode())){
		EasypoiDictServiceI jeecgDictService = null;
		try {
			jeecgDictService = ApplicationContextUtil.getContext().getBean(EasypoiDictServiceI.class);
		} catch (Exception e) {
		}
		if(jeecgDictService!=null){
			 String[] dictReplace = jeecgDictService.queryDict(excel.dictTable(), excel.dicCode(), excel.dicText());
			 if(excelEntity.getReplace()!=null && dictReplace!=null && dictReplace.length!=0){
				 excelEntity.setReplace(dictReplace);
			 }
		}
	}
	excelEntity.setOrderNum(getCellOrder(excel.orderNum(), targetId));
	excelEntity.setWrap(excel.isWrap());
	excelEntity.setExportImageType(excel.imageType());
	excelEntity.setSuffix(excel.suffix());
	excelEntity.setDatabaseFormat(excel.databaseFormat());
	excelEntity.setFormat(StringUtils.isNotEmpty(excel.exportFormat()) ? excel.exportFormat() : excel.format());
	excelEntity.setStatistics(excel.isStatistics());
	String fieldname = field.getName();
	excelEntity.setMethod(PoiPublicUtil.getMethod(fieldname, pojoClass));
}
 
Example #25
Source File: JeecgTag.java    From jeecg with Apache License 2.0 5 votes vote down vote up
/**
 * 获取缓存
 * @return
 */
public StringBuffer getTagCache(){
	CacheServiceI cacheService = ApplicationContextUtil.getContext().getBean(CacheServiceI.class);
	if(CgAutoListConstant.SYS_MODE_DEV.equalsIgnoreCase(TempletContext._sysMode)){
		return null;
	}
	log.debug("-----TagCache-----toString()-----"+toString());
	return (StringBuffer) cacheService.get(CacheServiceI.TAG_CACHE, toString());
}
 
Example #26
Source File: GroovyParse.java    From jeewx with Apache License 2.0 5 votes vote down vote up
/**
 * 公式解析计算
 */
public static Object formulaParse(String formula, Map<String, Object> map) {
	ApplicationContext context = ApplicationContextUtil.getContext();
	GroovyScriptEngine groovyScriptEngine = context.getBean(GroovyScriptEngine.class);
	Object value = groovyScriptEngine.executeObject(formula, map);
	return value;
}
 
Example #27
Source File: ExcelExportUtil.java    From jeewx with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param targetId
 * @param field
 * @param excelEntity
 * @param excel
 * @param pojoClass
 * @throws Exception
 */
public static void getExcelField(String targetId, Field field,
		ExcelExportEntity excelEntity, Excel excel, Class<?> pojoClass)
		throws Exception {
	excelEntity.setName(getExcelName(excel.exportName(), targetId));
	excelEntity.setWidth(excel.exportFieldWidth());
	excelEntity.setHeight(excel.exportFieldHeight());
	excelEntity.setNeedMerge(excel.needMerge());
	excelEntity.setOrderNum(getCellOrder(excel.orderNum(),targetId));
	excelEntity.setWrap(excel.isWrap());
	excelEntity.setExportImageType(excel.imageType());
	excelEntity.setExportFormat(StringUtils.isNotEmpty(excel.exportFormat())?
			excel.exportFormat():excel.imExFormat());
	String fieldname = field.getName();
	excelEntity.setGetMethod(ExcelPublicUtil.getMethod(fieldname, pojoClass));
	if (excel.exportConvertSign() == 1||excel.imExConvert()==1) {
		StringBuffer getConvertMethodName = new StringBuffer("convertGet");
		getConvertMethodName
				.append(fieldname.substring(0, 1).toUpperCase());
		getConvertMethodName.append(fieldname.substring(1));
		Method getConvertMethod = pojoClass.getMethod(
				getConvertMethodName.toString(), new Class[] {});
		excelEntity.setGetMethod(getConvertMethod);
		
		if(StringUtils.isNotEmpty(excel.dicCode())){
			SystemService systemService = ApplicationContextUtil.getContext().getBean(SystemService.class);
		    List<DictEntity> dictList = systemService.queryDict(excel.dictTable(), excel.dicCode(), excel.dicText());
			Map<String,String> dictMap = new HashMap<String,String>();
		    for (DictEntity dictEntity : dictList) {
		    	dictMap.put(dictEntity.getTypecode(), dictEntity.getTypename());
			}
			excelEntity.setDictMap(dictMap);
		}
	}
}
 
Example #28
Source File: CgFormBuildController.java    From jeecg with Apache License 2.0 5 votes vote down vote up
/**
 * 获取url指定模板
 * @param templateName
 * @param templateType
 * @param dataMap
 * @return
 */
private String getUrlTemplate(String templateName,TemplateUtil.TemplateType templateType,Map dataMap){
	String content=null;
	CgformTemplateEntity entity=cgformTemplateService.findByCode(templateName);
	if(entity!=null){
		FreemarkerHelper viewEngine = new FreemarkerHelper();
		dataMap.put("DictData", ApplicationContextUtil.getContext().getBean("dictDataTag"));
		content = viewEngine.parseTemplate(TemplateUtil.getTempletPath(entity,0, templateType), dataMap);
	}
	return content;
}
 
Example #29
Source File: WeixinPhotoService.java    From jeewx with Apache License 2.0 5 votes vote down vote up
@Override
	public String excute(String content, TextMessageResp defaultMessage,
			HttpServletRequest request) {
		WeixinAccountServiceI weixinAccountService = (WeixinAccountServiceI) ApplicationContextUtil.getContext().getBean("weixinAccountService");
		WeixinAccountEntity account = weixinAccountService.getEntity(WeixinAccountEntity.class,defaultMessage.getFromUserName() );
		// 此userid后期需要通过高级接口获取到微信帐号,此处先以加密后的ID为参数进行传递
		String accountid = weixinAccountService.findByToUsername(defaultMessage.getFromUserName()).getId();
//		String sellerid = "";
//		if(account!=null){
//			sellerid = account.getUserName();
//		}
		ResourceBundle bundler = ResourceBundle.getBundle("sysConfig");
		List<Article> articleList = new ArrayList<Article>();
		Article article = new Article();
		article.setTitle("微相册");
		article.setDescription("");
		article.setPicUrl(bundler.getString("domain")+ "/template/photo/default/images/albums_head.jpg");
		// 此userid后期需要通过高级接口获取到微信帐号,此处先以加密后的ID为参数进行传递
		article.setUrl(bundler.getString("domain")+ "/cmsController.do?goPage&page=photoAlbum&accountid="+ accountid + "&userid="
				+ defaultMessage.getToUserName());
		articleList.add(article);
		NewsMessageResp newsMessage = new NewsMessageResp();
		newsMessage.setToUserName(defaultMessage.getToUserName());
		newsMessage.setFromUserName(defaultMessage.getFromUserName());
		newsMessage.setCreateTime(new Date().getTime());
		newsMessage.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_NEWS);
		newsMessage.setArticleCount(articleList.size());
		newsMessage.setArticles(articleList);
		return MessageUtil.newsMessageToXml(newsMessage);
	}
 
Example #30
Source File: CmsMenuDataCollect.java    From jeewx with Apache License 2.0 5 votes vote down vote up
@Override
public void collect(Map<String, String> params) {
	CmsArticleServiceI cmsArticleService = (CmsArticleServiceI) ApplicationContextUtil.getContext().getBean("cmsArticleService");
	CmsMenuServiceI cmsMenuService =  (CmsMenuServiceI) ApplicationContextUtil.getContext().getBean("cmsMenuService");
	
	String menuid = params.get("id") != null ? params.get("id").toString(): "-";
	CmsMenuEntity menuEntity = cmsMenuService.getEntity(CmsMenuEntity.class, menuid);
	CmsArticleEntity cmsArticleEntity = null;
	if (menuEntity != null) {
		//------------------------------------------------------------------
		Map p = new HashMap();
		p.put("columnid", menuEntity.getId());
		List<CmsArticleEntity> list = cmsArticleService.listByMap(p);
		//判断Menu类型
		if("02".equals(menuEntity.getType())){
			//单文章类型,则加载排序第一条文章
			if(list!=null&&list.size()>0){
				 cmsArticleEntity = list.get(0);
			}
		} else {
			CmsDataContent.put(CmsConstant.CMS_DATA_LIST_ARTICLE, list);
		}
		Map valueMap = new HashMap();
		MyBeanUtils.copyBean2Map(valueMap, menuEntity);
		if(cmsArticleEntity==null)cmsArticleEntity = new CmsArticleEntity();
		valueMap.put("article", cmsArticleEntity);
		//------------------------------------------------------------------
		CmsDataContent.put(CmsConstant.CMS_DATA_MAP_MENU, valueMap);
		CmsDataContent.put(CmsConstant.CMS_DATA_STR_TITLE, menuEntity.getName());
	} else {
		CmsDataContent.put(CmsConstant.CMS_DATA_MAP_MENU, new CmsMenuEntity());
		CmsDataContent.put(CmsConstant.CMS_DATA_STR_TITLE, "信息列表");
	}
	String res = CmsConstant.CMS_ROOT_PATH + "/" + params.get(CmsConstant.CMS_STYLE_NAME);
	//资源路径
	CmsDataContent.put(CmsConstant.BASE, res);
}