Search in sources :

Example 21 with Record

use of cn.cerc.jdb.core.Record in project summer-bean by cn-cerc.

the class BOMTemplate method output.

@Override
public void output(WritableSheet sheet) throws RowsExceededException, WriteException {
    // 输出列头
    Record head = this.getDataSet().getHead();
    if (heads != null) {
        for (int lineNo = 0; lineNo < heads.size(); lineNo++) {
            Column column = heads.get(lineNo);
            int row = this.getRow() + lineNo;
            Label item1 = new Label(0, row, column.getName());
            sheet.addCell(item1);
            column.setRecord(head);
            writeColumn(sheet, 1, row, column);
        }
        // 设置新的起点行号
        this.setRow(this.getRow() + heads.size());
    }
    // 输出原来的表格
    super.output(sheet);
    this.setRow(this.getHeads().size() + this.getDataSet().size() + 2);
    sheet.addCell(new Label(0, this.getRow(), "材料清单:"));
    this.setRow(this.getRow() + 1);
    this.getColumns().clear();
    this.getColumns().addAll(materials);
    this.setDataSet(materialDataSet);
    // 输出原来的表格
    super.output(sheet);
    this.setRow(this.getRow() + materialDataSet.size() + 2);
    sheet.addCell(new Label(0, this.getRow(), "制成清单:"));
    this.setRow(this.getRow() + 1);
    this.getColumns().clear();
    this.getColumns().addAll(makes);
    this.setDataSet(makeDataSet);
    // 输出原来的表格
    super.output(sheet);
}
Also used : Label(jxl.write.Label) Record(cn.cerc.jdb.core.Record)

Example 22 with Record

use of cn.cerc.jdb.core.Record in project summer-bean by cn-cerc.

the class BatchFormTemplate method output.

@Override
public void output(WritableSheet sheet) throws RowsExceededException, WriteException {
    int newRow = 0;
    for (DataSet dataSet : items) {
        this.setDataSet(dataSet);
        this.setFooter((template, sheet1) -> {
            Record footer = new Record();
            for (Record item : dataSet) {
                footer.setField("合计数量", footer.getDouble("合计数量") + item.getDouble("Num_"));
                footer.setField("合计金额", footer.getDouble("合计金额") + item.getDouble("OriAmount_"));
            }
            int row = template.getRow();
            for (String field : footer.getItems().keySet()) {
                row++;
                Object val = footer.getItems().get(field);
                sheet1.addCell(new Label(0, row, field));
                sheet1.addCell(new Label(1, row, Double.toString(utils.roundTo((Double) val, -2))));
            }
        });
        // 输出原来的表格
        super.output(sheet);
        newRow += this.getHeads().size() + dataSet.size() + 6;
        this.setRow(newRow);
    }
}
Also used : DataSet(cn.cerc.jdb.core.DataSet) Label(jxl.write.Label) Record(cn.cerc.jdb.core.Record)

Example 23 with Record

use of cn.cerc.jdb.core.Record in project summer-bean by cn-cerc.

the class ComplexColumn method getValue.

@Override
public String getValue() {
    Record record = this.getRecord();
    StringBuffer buff = new StringBuffer();
    for (String field : fields) {
        if (record.hasValue(field)) {
            if (buff.length() > 0)
                buff.append(",");
            buff.append(record.getString(field));
        }
    }
    return buff.toString();
}
Also used : Record(cn.cerc.jdb.core.Record)

Example 24 with Record

use of cn.cerc.jdb.core.Record in project summer-bean by cn-cerc.

the class ImportFile method init.

public int init() throws UnsupportedEncodingException {
    dataSet = new DataSet();
    // 处理文件上传
    DiskFileItemFactory factory = new DiskFileItemFactory();
    // 设置最大缓存
    factory.setSizeThreshold(5 * 1024);
    ServletFileUpload upload = new ServletFileUpload(factory);
    try {
        uploadFiles = upload.parseRequest(request);
    } catch (FileUploadException e) {
        // e.printStackTrace();
        uploadFiles = null;
        return 0;
    }
    if (uploadFiles != null) {
        for (int i = 0; i < uploadFiles.size(); i++) {
            FileItem fileItem = uploadFiles.get(i);
            if (fileItem.isFormField()) {
                // 普通数据
                String val = new String(fileItem.getString().getBytes("ISO-8859-1"), "UTF-8");
                dataSet.getHead().setField(fileItem.getFieldName(), val);
            } else {
                // 文件数据
                if (fileItem.getSize() > 0) {
                    Record rs = dataSet.append().getCurrent();
                    rs.setField("_FieldNo", i);
                    rs.setField("_FieldName", fileItem.getFieldName());
                    rs.setField("_ContentType", fileItem.getContentType());
                    rs.setField("_FileName", fileItem.getName());
                    rs.setField("_FileSize", fileItem.getSize());
                }
            }
        }
    }
    dataSet.first();
    return dataSet.size();
}
Also used : FileItem(org.apache.commons.fileupload.FileItem) ServletFileUpload(org.apache.commons.fileupload.servlet.ServletFileUpload) DataSet(cn.cerc.jdb.core.DataSet) Record(cn.cerc.jdb.core.Record) DiskFileItemFactory(org.apache.commons.fileupload.disk.DiskFileItemFactory) FileUploadException(org.apache.commons.fileupload.FileUploadException)

Example 25 with Record

use of cn.cerc.jdb.core.Record in project summer-bean by cn-cerc.

the class CustomHandle method init.

@Override
public boolean init(String corpNo, String userCode, String clientCode) {
    String token = GuidFixStr(cn.cerc.jdb.other.utils.newGuid());
    this.setProperty(Application.token, token);
    this.setProperty(Application.bookNo, corpNo);
    this.setProperty(Application.userCode, userCode);
    this.setProperty(Application.clientIP, clientCode);
    LocalService svr = new LocalService(this, "AppSessionRestore.byUserCode");
    if (!svr.exec("userCode", userCode)) {
        throw new RuntimeException(new UserNotFindException(userCode));
    }
    Record headOut = svr.getDataOut().getHead();
    this.setProperty(Application.userId, headOut.getString("UserID_"));
    this.setProperty(Application.loginTime, headOut.getDateTime("LoginTime_"));
    this.setProperty(Application.roleCode, headOut.getString("RoleCode_"));
    this.setProperty(Application.ProxyUsers, headOut.getString("ProxyUsers_"));
    this.setProperty(Application.userName, headOut.getString("UserName_"));
    this.setProperty(Application.deviceLanguage, headOut.getString("Language_"));
    try (MemoryBuffer buff = new MemoryBuffer(BufferType.getSessionBase, token)) {
        buff.setField("LoginTime_", headOut.getDateTime("LoginTime_"));
        buff.setField("UserID_", headOut.getString("UserID_"));
        buff.setField("UserCode_", userCode);
        buff.setField("CorpNo_", corpNo);
        buff.setField("UserName_", headOut.getString("UserName_"));
        buff.setField("RoleCode_", headOut.getString("RoleCode_"));
        buff.setField("ProxyUsers_", headOut.getString("ProxyUsers_"));
        buff.setField("Language_", headOut.getString("Language_"));
        buff.setField("exists", true);
    }
    return true;
}
Also used : MemoryBuffer(cn.cerc.jbean.other.MemoryBuffer) UserNotFindException(cn.cerc.jbean.other.UserNotFindException) Record(cn.cerc.jdb.core.Record) LocalService(cn.cerc.jbean.client.LocalService)

Aggregations

Record (cn.cerc.jdb.core.Record)53 SqlQuery (cn.cerc.jdb.mysql.SqlQuery)15 LocalService (cn.cerc.jbean.client.LocalService)9 Webfunc (cn.cerc.jbean.core.Webfunc)4 DataSet (cn.cerc.jdb.core.DataSet)4 Ignore (org.junit.Ignore)4 Test (org.junit.Test)4 MemoryBuffer (cn.cerc.jbean.other.MemoryBuffer)3 StubHandle (cn.cerc.jbean.rds.StubHandle)3 IMemcache (cn.cerc.jdb.cache.IMemcache)3 MessageRecord (cn.cerc.jmis.message.MessageRecord)3 UrlRecord (cn.cerc.jpage.core.UrlRecord)3 Label (jxl.write.Label)3 CustomHandle (cn.cerc.jbean.core.CustomHandle)2 IService (cn.cerc.jbean.core.IService)2 IStatus (cn.cerc.jbean.core.IStatus)2 UserNotFindException (cn.cerc.jbean.other.UserNotFindException)2 QueueQuery (cn.cerc.jdb.queue.QueueQuery)2 Column (cn.cerc.jexport.excel.Column)2 JPushRecord (cn.cerc.jmis.message.JPushRecord)2