Search in sources :

Example 6 with IMemcache

use of cn.cerc.jdb.cache.IMemcache in project summer-mis by cn-cerc.

the class MemoryBookInfo method clear.

public static void clear(String corpNo) {
    IMemcache buff = Application.getMemcache();
    buff.delete(getBuffKey(corpNo));
}
Also used : IMemcache(cn.cerc.jdb.cache.IMemcache)

Example 7 with IMemcache

use of cn.cerc.jdb.cache.IMemcache in project summer-mis by cn-cerc.

the class ProcessService method runTask.

private void runTask(IHandle handle) {
    // 同一秒内,不允许执行2个及以上任务
    String str = TDateTime.Now().getTime();
    if (str.equals(lock))
        return;
    if (taskApp == null)
        taskApp = new FileSystemXmlApplicationContext(taskFile);
    lock = str;
    for (String beanId : taskApp.getBeanDefinitionNames()) {
        AbstractTask task = getTask(handle, beanId);
        try {
            String curTime = TDateTime.Now().getTime().substring(0, 5);
            if (!"".equals(task.getTime()) && !task.getTime().equals(curTime))
                continue;
            int timeOut = task.getInterval();
            String buffKey = String.format("%d.%s.%s", BufferType.getObject.ordinal(), this.getClass().getName(), task.getClass().getName());
            IMemcache buff = Application.getMemcache();
            if (buff.get(buffKey) != null)
                continue;
            // 标识为已执行
            buff.set(buffKey, "ok", timeOut);
            if (task.getInterval() > 1)
                log.info("execute " + task.getClass().getName());
            task.execute();
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage());
        }
    }
}
Also used : FileSystemXmlApplicationContext(org.springframework.context.support.FileSystemXmlApplicationContext) IMemcache(cn.cerc.jdb.cache.IMemcache)

Example 8 with IMemcache

use of cn.cerc.jdb.cache.IMemcache in project summer-mis by cn-cerc.

the class SvrUserMessages method appendRecord.

/**
 * @return 增加一条新的消息记录
 */
public boolean appendRecord() {
    Record headIn = getDataIn().getHead();
    String corpNo = headIn.getString("corpNo");
    String userCode = headIn.getString("userCode");
    String subject = headIn.getString("subject");
    String content = headIn.getString("content");
    int process = headIn.getInt("process");
    int level = headIn.getInt("level");
    // 若为异步任务消息请求
    if (level == MessageLevel.Service.ordinal()) {
        // 若已存在同一公司别同一种回算请求在排队或者执行中,则不重复插入回算请求
        SqlQuery ds2 = new SqlQuery(handle);
        ds2.setMaximum(1);
        ds2.add("select UID_ from %s ", SystemTable.get(SystemTable.getUserMessages));
        ds2.add("where CorpNo_='%s' ", corpNo);
        ds2.add("and Subject_='%s' ", subject);
        ds2.add("and Level_=4 and (Process_ = 1 or Process_=2)");
        ds2.open();
        if (ds2.size() > 0) {
            // 返回消息的编号
            getDataOut().getHead().setField("msgId", ds2.getBigInteger("UID_"));
            return true;
        }
    }
    SqlQuery cdsMsg = new SqlQuery(this);
    cdsMsg.add("select * from %s", SystemTable.get(SystemTable.getUserMessages));
    cdsMsg.setMaximum(0);
    cdsMsg.open();
    // 保存到数据库
    cdsMsg.append();
    cdsMsg.setField("CorpNo_", corpNo);
    cdsMsg.setField("UserCode_", userCode);
    cdsMsg.setField("Level_", level);
    cdsMsg.setField("Subject_", subject);
    if (content.length() > 0)
        cdsMsg.setField("Content_", content.toString());
    cdsMsg.setField("AppUser_", handle.getUserCode());
    cdsMsg.setField("AppDate_", TDateTime.Now());
    // 日志类消息默认为已读
    cdsMsg.setField("Status_", level == MessageLevel.Logger.ordinal() ? 1 : 0);
    cdsMsg.setField("Process_", process);
    cdsMsg.setField("Final_", false);
    cdsMsg.post();
    // 清除缓存
    IMemcache buff = Application.getMemcache();
    String buffKey = String.format("%d.%s.%s.%s", BufferType.getObject.ordinal(), MessageRecord.class, corpNo, userCode);
    buff.delete(buffKey);
    // 返回消息的编号
    getDataOut().getHead().setField("msgId", cdsMsg.getBigInteger("UID_"));
    return true;
}
Also used : IMemcache(cn.cerc.jdb.cache.IMemcache) SqlQuery(cn.cerc.jdb.mysql.SqlQuery) Record(cn.cerc.jdb.core.Record) MessageRecord(cn.cerc.jmis.message.MessageRecord) JPushRecord(cn.cerc.jmis.message.JPushRecord)

Aggregations

IMemcache (cn.cerc.jdb.cache.IMemcache)8 Record (cn.cerc.jdb.core.Record)3 SqlQuery (cn.cerc.jdb.mysql.SqlQuery)2 Gson (com.google.gson.Gson)2 LocalService (cn.cerc.jbean.client.LocalService)1 IService (cn.cerc.jbean.core.IService)1 IStatus (cn.cerc.jbean.core.IStatus)1 JPushRecord (cn.cerc.jmis.message.JPushRecord)1 MessageRecord (cn.cerc.jmis.message.MessageRecord)1 GsonBuilder (com.google.gson.GsonBuilder)1 Type (java.lang.reflect.Type)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 FileSystemXmlApplicationContext (org.springframework.context.support.FileSystemXmlApplicationContext)1