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);
}
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);
}
}
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();
}
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();
}
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;
}
Aggregations