java.lang.ClassCastException: java.math.BigDecimal

qq_26878045 2015-07-26 09:01:24
if (issueDataList == null) {
if ("0".equals(qmsReportCommonForm.getReportTypeValue())) {
issueYearFrom = Integer.parseInt(qmsReportCommonForm
.getIssueYearFrom());
issueMonthFrom = Integer.parseInt(qmsReportCommonForm
.getIssueMonthFrom());
issueMonthTo = Integer.parseInt(qmsReportCommonForm
.getIssueMonthTo());
issueYearTo = issueMonthTo + 1 > 12 ? Integer
.parseInt(qmsReportCommonForm.getIssueYearTo()) + 1
: Integer.parseInt(qmsReportCommonForm
.getIssueYearTo());
issueMonthTo = issueMonthTo + 1 > 12 ? 1
: issueMonthTo + 1;
} else if ("2".equals(qmsReportCommonForm
.getReportTypeValue())) {
issueMonthTo = Integer.parseInt(qmsReportCommonForm
.getYearFaultMonth());
issueYearTo = issueMonthTo + 1 > 12 ? Integer
.parseInt(qmsReportCommonForm
.getYearFaultYear()) + 1 : Integer
.parseInt(qmsReportCommonForm
.getYearFaultYear());
issueYearFrom = issueYearTo - 1;
issueMonthFrom = issueMonthTo + 1 > 12 ? 1
: issueMonthTo + 1;
issueMonthTo = issueMonthTo + 1 > 12 ? 1
: issueMonthTo + 1;
}
cas = session
.connection()
.prepareCall(
"{call barprod.qms_report_data_generator.generate_issue_data(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
cas.registerOutParameter(1, Types.VARCHAR);
cas.registerOutParameter(2, Types.VARCHAR);
// 产品线
cas.setString(3, qmsReportCommonForm.getProductLineCode());
// 理货时间段
cas.setString(4, String.valueOf(issueYearFrom)
+ (issueMonthFrom < 10 ? "0" + issueMonthFrom
: issueMonthFrom));
cas.setString(5, String.valueOf(issueYearTo)
+ (issueMonthTo < 10 ? "0" + issueMonthTo
: issueMonthTo));
// 省
cas.setString(6, qmsReportCommonForm.getProvince());
// 市
cas.setString(7, qmsReportCommonForm.getCity());
// 客户群
cas.setString(8, qmsReportCommonForm
.getCustomerIndustryClass());
// 制造商
cas.setString(9, qmsReportCommonForm.getManufacturerCode());
// 编码集合
cas.setString(10, inventoryItemIdStr);
// 理货类别
cas.setString(11, qmsReportCommonForm.getSalesTypeSimple());
// 组织ID
cas.setObject(12, userBean.getOrganizationId(),
Types.DECIMAL);
// 原厂
cas.setObject(13, qmsReportCommonForm.getVendorId(),
Types.DECIMAL);
// 退回业务类型
cas.setString(14, returnDataComeFrom.substring(0,
returnDataComeFrom.length() - 1));
// 退回来源类型
cas.setString(15, returnComeFrom.substring(0,
returnComeFrom.length() - 1));
cas.executeQuery();
if (cas.getString(1) != null
&& !"0".equals(cas.getString(1))) {
throw new Exception(cas.getString(2));
}
}
sql.append("barprod.qms_report_issue_data_temp");

问题出在这两行:
cas.setObject(12, userBean.getOrganizationId(),
Types.DECIMAL);
cas.setObject(13, qmsReportCommonForm.getVendorId(),
Types.DECIMAL);
OrganizationId以及VendorId都定义的long类型,后台表中是number类型字段,存储过程中是传入的也是number类型的字段,但是执行到此处时报java.lang.ClassCastException: java.math.BigDecimal 错误。


以及函数:
public boolean writeIssueSheet() {
boolean returnValue = true;
try {
if (newSheetFlag == true) {
if (wbook != null) {
wbook.write();
wbook.close();
wbook = null;
WritingSheetFlag = false;
}
wbook = Workbook
.createWorkbook(new File(outDir
+ fileName.replaceAll(VAR, ISSUE_VAR
+ (sheetNum + 1))));
row = 0;
col = 0;
if ("1".equals(qmsReportCommonForm.getReportTypeValue())) {
wsheet = wbook.createSheet(TFISSUE, sheetNum);
} else {
wsheet = wbook
.createSheet(ISSUE + (sheetNum + 1), sheetNum);
}
newSheetFlag = false;
for (Iterator it = this.excelShowFieldTitleListArray.get(0)
.iterator(); it.hasNext();) {
wsheet.addCell(new Label(col++, 0, (String) it.next()));
}
} else {
wsheet = wbook.getSheet(ISSUE + (sheetNum + 1));
hasTicket = true;
}
while (WritingSheetFlag && !hasTicket) {
Thread.sleep(SHEEP_TIME);
}
WritingSheetFlag = true;
for (Iterator it = issueDataList.iterator(); it.hasNext();) {
row++;
col = 0;

Object[] o = (Object[]) it.next();
while (col < this.excelShowFieldTitleListArray.get(0).size()) {
wsheet.addCell(new Label(col++, row, (String) o[col-1])); //col=28列是报错
}
}
} catch (Exception e) {
returnValue = false;
this.setErrorMsg(e.toString());
logger
.error("QmsReportGeneratorService.writeIssueSheet errors.",
e);
}

问题出在下面这行:
wsheet.addCell(new Label(col++, row, (String) o[col-1])); //col=28列时报java.lang.ClassCastException: java.math.BigDecimal 错误。
哪位大侠帮忙看下是怎么回事呢?
...全文
76 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
cas.setObject(12, userBean.getOrganizationId(), Types.DECIMAL); cas.setObject(13, qmsReportCommonForm.getVendorId(), Types.DECIMAL); 你把类型看看有其他的没 应该是types.bigint来和long 对应 bigdecimal做精度运算的 具体对应类型: http://www.cnblogs.com/shishm/archive/2012/01/30/2332142.html 代码最好贴在代码器里。要不别人不方便。
回复
scmod 2015-07-27
(String) o[col-1]这东西在28时候输出来看下是个啥?
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2015-07-26 09:01
社区公告
暂无公告