1.3K Star 6.1K Fork 2.9K

GVP季圣华 / 华夏ERP

 / 详情

单价为空时,导出excel 出现空指针异常

Backlog
Opened this issue  
2021-04-15 22:17

版本信息 2.3

库存图片 输入图片说明异常日志: 输入图片说明

代码库中没有修复,我尝试本地修复了一下 更改了com.jsh.erp.controller.DepotItemController这个类下面的exportExcel方法 如下:
@GetMapping(value = "/exportExcel")
public void exportExcel(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("depotId") Long depotId,
@RequestParam("monthTime") String monthTime,
@RequestParam("materialParam") String materialParam,
HttpServletRequest request, HttpServletResponse response) throws Exception {
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
String timeA = monthTime+"-01 00:00:00";
String timeB = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
try {
List dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
timeB, (currentPage-1)*pageSize, pageSize);
//存放数据json数组
String[] names = {"名称", "规格", "型号", "单位", "单价", "上月结存数量", "入库数量", "出库数量", "本月结存数量", "结存金额"};
String title = "库存报表";
List<String[]> objects = new ArrayList<String[]>();
if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) {
Long mId = diEx.getMId();
String[] objs = new String[10];
objs[0] = diEx.getMName();
objs[1] = diEx.getMStandard();
objs[2] = diEx.getMModel();
objs[3] = diEx.getMaterialUnit();
BigDecimal purchaseDecimal=diEx.getPurchaseDecimal();
objs[4] = ( purchaseDecimal== null ? "" :purchaseDecimal.toString());
objs[5] = depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId).toString();
objs[6] = depotItemService.getInNumByParam(depotId,mId,timeA,timeB,tenantId).toString();
objs[7] = depotItemService.getOutNumByParam(depotId,mId,timeA,timeB,tenantId).toString();
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,timeB,tenantId);
objs[8] = thisSum.toString();
objs[9] = ( purchaseDecimal== null ? "" :thisSum.multiply(purchaseDecimal).toString());
objects.add(objs);
}
}
File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
ExportExecUtil.showExec(file, file.getName() + "-" + monthTime, response);
} catch (Exception e) {
e.printStackTrace();
}
}
主要增加了 空指针判断 输入图片说明

Comments (0)

五千万 created任务
五千万 set related repository to 季圣华/华夏ERP
展开全部操作日志

Sign in to comment

状态
Assignees
Milestones
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
Branches
Planed to start   -   Planed to end
-
Top level
Priority
参与者(1)
Java
1
https://gitee.com/jishenghua/JSH_ERP.git
git@gitee.com:jishenghua/JSH_ERP.git
jishenghua
JSH_ERP
华夏ERP

Search