Search in sources :

Example 1 with SqlQuery

use of cn.cerc.jdb.mysql.SqlQuery in project summer-bean by cn-cerc.

the class BookOptions method getAccInitYearMonth.

public static String getAccInitYearMonth(IHandle handle) {
    String result;
    String paramKey = AccInitYearMonth;
    // String result = getOption(owner, paramKey, "201301";
    try (MemoryBuffer buff = new MemoryBuffer(BufferType.getVineOptions, handle.getCorpNo(), paramKey)) {
        if (buff.isNull() || buff.getString("Value_").equals("")) {
            BuildQuery f = new BuildQuery(handle);
            String corpNo = handle.getCorpNo();
            f.add("select * from %s ", SystemTable.get(SystemTable.getBookOptions));
            f.byField("CorpNo_", corpNo);
            f.byField("Code_", paramKey);
            SqlQuery ds = f.open();
            if (!ds.eof()) {
                result = ds.getString("Value_");
                if ("".equals(result)) {
                    result = getBookCreateDate(handle).getYearMonth();
                    ds.edit();
                    ds.setField("Value_", result);
                    ds.post();
                }
            } else {
                result = getBookCreateDate(handle).getYearMonth();
                BookOptions app = new BookOptions(handle);
                app.appendToCorpOption(corpNo, paramKey, result);
            }
            buff.setField("Value_", result);
        }
        result = buff.getString("Value_");
    }
    // 做返回值复查
    if (result == null || "".equals(result))
        throw new RuntimeException("期初年月未设置,请先到系统参数中设置好后再进行此作业!");
    return result;
}
Also used : SqlQuery(cn.cerc.jdb.mysql.SqlQuery) BuildQuery(cn.cerc.jdb.mysql.BuildQuery)

Example 2 with SqlQuery

use of cn.cerc.jdb.mysql.SqlQuery in project summer-bean by cn-cerc.

the class BookOptions method appendToCorpOption.

// 增加账套参数
public void appendToCorpOption(String corpNo, String paramKey, String def) {
    SqlQuery cdsTmp = new SqlQuery(handle);
    cdsTmp.add("select * from %s where CorpNo_=N'%s' and Code_='%s' ", SystemTable.get(SystemTable.getBookOptions), corpNo, paramKey);
    cdsTmp.open();
    if (!cdsTmp.eof())
        return;
    String paramName = getParamName(paramKey);
    cdsTmp.append();
    cdsTmp.setField("CorpNo_", corpNo);
    cdsTmp.setField("Code_", paramKey);
    cdsTmp.setField("Name_", paramName);
    cdsTmp.setField("Value_", def);
    cdsTmp.setField("UpdateKey_", cn.cerc.jdb.other.utils.newGuid());
    cdsTmp.post();
}
Also used : SqlQuery(cn.cerc.jdb.mysql.SqlQuery)

Example 3 with SqlQuery

use of cn.cerc.jdb.mysql.SqlQuery in project summer-bean by cn-cerc.

the class Memory_UserInfo method get.

public static MemoryBuffer get(IHandle sess, String usercode) {
    MemoryBuffer buff = new MemoryBuffer(BufferType.getAccount, usercode);
    if (buff.isNull()) {
        SqlQuery ds = new SqlQuery(sess);
        ds.add("select a.Code_,a.Enabled_,a.Name_,a.SuperUser_,a.DiyRole_,a.RoleCode_,oi.Type_,a.ImageUrl_ ");
        ds.add("from %s a ", SystemTable.get(SystemTable.getUserInfo));
        ds.add("inner join %s oi on a.CorpNo_=oi.CorpNo_ ", SystemTable.get(SystemTable.getBookInfo));
        ds.add("where a.Code_='%s'", usercode);
        ds.open();
        if (ds.eof())
            throw new RuntimeException(String.format("用户代码 %s 不存在!", usercode));
        Record record = ds.getCurrent();
        buff.setField("Name_", record.getString("Name_"));
        buff.setField("Enabled_", record.getInt("Enabled_"));
        buff.setField("SuperUser_", record.getBoolean("SuperUser_"));
        buff.setField("ImageUrl_", record.getString("ImageUrl_"));
        if (record.getBoolean("DiyRole_"))
            buff.setField("RoleCode_", record.getString("Code_"));
        else
            buff.setField("RoleCode_", record.getString("RoleCode_"));
        buff.setField("CorpType_", "" + record.getInt("Type_") + ",");
    } else {
        count++;
    }
    return buff;
}
Also used : SqlQuery(cn.cerc.jdb.mysql.SqlQuery) Record(cn.cerc.jdb.core.Record)

Example 4 with SqlQuery

use of cn.cerc.jdb.mysql.SqlQuery in project summer-bean by cn-cerc.

the class UserList method getPriceValue.

private Map<String, Integer> getPriceValue(String userCode) {
    Map<String, Integer> value = new HashMap<>();
    value.put(UserOptions.ShowInUP, 0);
    value.put(UserOptions.ShowOutUP, 0);
    value.put(UserOptions.ShowWholesaleUP, 0);
    value.put(UserOptions.ShowBottomUP, 0);
    SqlQuery ds = new SqlQuery(handle);
    ds.add("select Code_,Value_ from %s ", SystemTable.get(SystemTable.getUserOptions));
    ds.add("where UserCode_='%s' and (Code_='%s' or Code_='%s' or Code_='%s' or Code_='%s')", userCode, UserOptions.ShowInUP, UserOptions.ShowOutUP, UserOptions.ShowWholesaleUP, UserOptions.ShowBottomUP);
    ds.open();
    while (ds.fetch()) value.put(ds.getString("Code_"), ds.getInt("Value_"));
    return value;
}
Also used : SqlQuery(cn.cerc.jdb.mysql.SqlQuery) HashMap(java.util.HashMap)

Example 5 with SqlQuery

use of cn.cerc.jdb.mysql.SqlQuery in project summer-bean by cn-cerc.

the class UserList method init.

private void init() {
    if (buff.size() > 0)
        return;
    // 从缓存中读取
    Gson gson = new GsonBuilder().enableComplexMapKeySerialization().create();
    IMemcache cache = Application.getMemcache();
    String data = (String) cache.get(buffKey);
    if (data != null && !"".equals(data)) {
        Type type = new TypeToken<Map<String, UserRecord>>() {
        }.getType();
        Map<String, UserRecord> items = gson.fromJson(data, type);
        for (String key : items.keySet()) {
            buff.put(key, items.get(key));
        }
        log.debug(this.getClass().getName() + " 缓存成功!");
        return;
    }
    // 从数据库中读取
    SqlQuery ds = new SqlQuery(handle);
    ds.add("select ID_,CorpNo_,Code_,Name_,QQ_,Mobile_,SuperUser_,");
    ds.add("LastRemindDate_,EmailAddress_,RoleCode_,ProxyUsers_,Enabled_,DiyRole_ ");
    ds.add("from %s ", SystemTable.get(SystemTable.getUserInfo));
    ds.add("where CorpNo_='%s'", handle.getCorpNo());
    ds.open();
    while (ds.fetch()) {
        String key = ds.getString("Code_");
        UserRecord value = new UserRecord();
        value.setId(ds.getString("ID_"));
        value.setCorpNo(ds.getString("CorpNo_"));
        value.setCode(ds.getString("Code_"));
        value.setName(ds.getString("Name_"));
        Map<String, Integer> priceValue = getPriceValue(ds.getString("Code_"));
        value.setShowInUP(priceValue.get(UserOptions.ShowInUP));
        value.setShowOutUP(priceValue.get(UserOptions.ShowOutUP));
        value.setShowWholesaleUP(priceValue.get(UserOptions.ShowWholesaleUP));
        value.setShowBottomUP(priceValue.get(UserOptions.ShowBottomUP));
        value.setQq(ds.getString("QQ_"));
        value.setMobile(ds.getString("Mobile_"));
        value.setAdmin(ds.getBoolean("SuperUser_"));
        value.setLastRemindDate(ds.getDateTime("LastRemindDate_").getDate());
        value.setEmail(ds.getString("EmailAddress_"));
        if (ds.getBoolean("DiyRole_"))
            value.setRoleCode(ds.getString("Code_"));
        else
            value.setRoleCode(ds.getString("RoleCode_"));
        value.setProxyUsers(ds.getString("ProxyUsers_"));
        value.setEnabled(ds.getBoolean("Enabled_"));
        buff.put(key, value);
    }
    // 存入到缓存中
    cache.set(buffKey, gson.toJson(buff));
    log.debug(this.getClass().getName() + " 缓存初始化!");
}
Also used : IMemcache(cn.cerc.jdb.cache.IMemcache) Type(java.lang.reflect.Type) SqlQuery(cn.cerc.jdb.mysql.SqlQuery) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

SqlQuery (cn.cerc.jdb.mysql.SqlQuery)38 Record (cn.cerc.jdb.core.Record)15 Webfunc (cn.cerc.jbean.core.Webfunc)4 MemoryBuffer (cn.cerc.jbean.other.MemoryBuffer)3 BuildQuery (cn.cerc.jdb.mysql.BuildQuery)3 CustomHandle (cn.cerc.jbean.core.CustomHandle)2 IMemcache (cn.cerc.jdb.cache.IMemcache)2 JPushRecord (cn.cerc.jmis.message.JPushRecord)2 MessageRecord (cn.cerc.jmis.message.MessageRecord)2 HashMap (java.util.HashMap)2 LocalService (cn.cerc.jbean.client.LocalService)1 DataValidateException (cn.cerc.jbean.core.DataValidateException)1 ServerConfig (cn.cerc.jbean.core.ServerConfig)1 ServiceException (cn.cerc.jbean.core.ServiceException)1 UserNotFindException (cn.cerc.jbean.other.UserNotFindException)1 StubHandle (cn.cerc.jbean.rds.StubHandle)1 DataSet (cn.cerc.jdb.core.DataSet)1 SqlSession (cn.cerc.jdb.mysql.SqlSession)1 Transaction (cn.cerc.jdb.mysql.Transaction)1 Gson (com.google.gson.Gson)1