All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fastchar.extjs.FastExtHelper Maven / Gradle / Ivy

Go to download

FastChar-ExtJs is a Java Web framework that uses extjs libraries.Quickly build a background management system

There is a newer version: 2.2.2
Show newest version
package com.fastchar.extjs;

import com.fastchar.core.FastChar;
import com.fastchar.extjs.core.menus.FastMenuInfo;
import com.fastchar.extjs.entity.ExtManagerEntity;
import com.fastchar.extjs.entity.ExtSystemNoticeEntity;
import com.fastchar.utils.FastDateUtils;
import com.fastchar.utils.FastStringUtils;

import java.util.List;

@SuppressWarnings("ResultOfMethodCallIgnored")
public class FastExtHelper {

    /**
     * 刷新ExtWeb数据,相对于重新初始化ExtWeb数据,包括重新加载fast-heads.html、fast-menus.xml数据等!
     * 刷新后,需要浏览器重新加载系统即可!
     */
    public static void refreshExtWeb() {
        try {
            FastChar.getConfig(FastExtConfig.class)
                    .getMergeJs().delete();
            FastChar.getObservable().notifyObservers("refreshHeads");
            FastChar.getObservable().notifyObservers("refreshMenus");
        } catch (Exception ignored) { }
    }


    /**
     * 添加系统待办事项
     *
     * @param title   标题
     * @param content 内容
     * @return 布尔值
     */
    public static void addWaitInfo(
            String title,
            String content) {
        addWaitInfo(null, null, title, content, null);
    }

    /**
     * 添加系统待办事项
     *
     * @param title      标题
     * @param content    内容
     * @param actionMenu 触发的菜单,多级以'@'符合分割
     * @return 布尔值
     */
    public static void addWaitInfo(
            String title,
            String content,
            String actionMenu) {
         addWaitInfo(null, null, title, content, actionMenu);
    }

    /**
     * 添加系统待办事项
     *
     * @param code       唯一编号
     * @param title      标题
     * @param content    内容
     * @param actionMenu 触发的菜单,多级以'@'符合分割
     * @return 布尔值
     */
    public static void addWaitInfo(
            String code,
            String title,
            String content,
            String actionMenu) {
        addWaitInfo(null, code, title, content, actionMenu);
    }

    /**
     * 添加系统待办事项
     *
     * @param parentLayerCode 权限编号
     * @param code            唯一编号
     * @param title           标题
     * @param content         内容
     * @param actionMenu      触发的菜单,多级以'@'符合分割
     * @return 布尔值
     */
    public static void addWaitInfo(
            String parentLayerCode,
            String code,
            String title,
            String content,
            String actionMenu) {

        FastMenuInfo menuInfo = null;
        if (FastStringUtils.isNotEmpty(actionMenu)) {
            String[] menuArray = actionMenu.split("@");
            FastMenuInfo menus = FastChar.getValues().get("menus");
            menuInfo = getMenu(menuArray, 0, menus);
        }
        String menuId = null;
        if (menuInfo != null) {
            menuId = menuInfo.getId();
        }

        List managers = ExtManagerEntity.getInstance().getManagerByNoticeTitle(title, menuId);
        for (ExtManagerEntity manager : managers) {
            ExtSystemNoticeEntity noticeEntity = ExtSystemNoticeEntity.newInstance();
            noticeEntity.setParentLayerCode(parentLayerCode);
            if (FastStringUtils.isEmpty(code)) {
                code = FastStringUtils.buildOnlyCode("NTC");
            }
            noticeEntity.set("noticeCode", code);
            noticeEntity.set("noticeTitle", title);
            noticeEntity.set("noticeContent", content);
            noticeEntity.set("noticeState", ExtSystemNoticeEntity.ExtSystemNoticeStateEnum.待处理.ordinal());
            if (menuInfo != null) {
                noticeEntity.set("noticeAction", "system.selectMenu('" + menuInfo.getId() + "')");
            }
            noticeEntity.setParentLayerCode(manager.getLayerValue());
            noticeEntity.set("managerId", manager.getId());
            noticeEntity.set("noticeDateTime", FastDateUtils.getDateString());
            noticeEntity.push("noticeCode", "managerId");
        }
    }


    /**
     * 标记已处理
     *
     * @param code 唯一编号
     */
    public static void doneWaitInfo(String code) {
        ExtSystemNoticeEntity.dao().updateWaitInfo(code);
    }


    private static FastMenuInfo getMenu(String[] menuLevels, int index, FastMenuInfo menus) {
        String menuName = menuLevels[index];
        for (FastMenuInfo child : menus.getChildren()) {
            if (child.getText().equals(menuName)) {
                if (menuLevels.length - 1 == index) {
                    return child;
                }
                return getMenu(menuLevels, index + 1, child);
            }
        }
        return null;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy