fix:修复空指针报错问题

This commit is contained in:
2025-02-13 15:17:02 +08:00
parent b62b1dabe9
commit a72c4e3f8d
5 changed files with 69 additions and 34 deletions

View File

@@ -423,6 +423,12 @@ public class InBoxManageServiceImpl implements InBoxManageService {
param.put("height", boxDao.getBox_high()); param.put("height", boxDao.getBox_high());
param.put("containerType", boxDao.getVehicle_type()); param.put("containerType", boxDao.getVehicle_type());
String type = whereJson.getString("bill_type"); String type = whereJson.getString("bill_type");
if (StrUtil.isEmpty(type)) {
throw new BadRequestException("入库类型不能为空!");
}
if (type.length() < 4) {
throw new BadRequestException("入库类型字段长度不能少于4!");
}
param.put("barcode", whereJson.getString("box_no") + "-" + type.substring(3, 4)); param.put("barcode", whereJson.getString("box_no") + "-" + type.substring(3, 4));
//根据木箱高度,判断入库仓位的高度 //根据木箱高度,判断入库仓位的高度

View File

@@ -16,6 +16,7 @@ package org.nl.modules.common.utils;/*
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.poi.excel.BigExcelWriter; import cn.hutool.poi.excel.BigExcelWriter;
import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelUtil;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
@@ -203,9 +204,12 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
* 导出excel * 导出excel
*/ */
public static void downloadExcel(List<Map<String, Object>> list, HttpServletResponse response) throws IOException { public static void downloadExcel(List<Map<String, Object>> list, HttpServletResponse response) throws IOException {
ServletOutputStream out = null;
BigExcelWriter writer;
try {
String tempPath = SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx"; String tempPath = SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx";
File file = new File(tempPath); File file = new File(tempPath);
BigExcelWriter writer = ExcelUtil.getBigWriter(file); writer = ExcelUtil.getBigWriter(file);
// 一次性写出内容,使用默认样式,强制输出标题 // 一次性写出内容,使用默认样式,强制输出标题
writer.write(list, true); writer.write(list, true);
SXSSFSheet sheet = (SXSSFSheet) writer.getSheet(); SXSSFSheet sheet = (SXSSFSheet) writer.getSheet();
@@ -217,13 +221,18 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
//test.xls是弹出下载对话框的文件名不能为中文中文请自行编码 //test.xls是弹出下载对话框的文件名不能为中文中文请自行编码
response.setHeader("Content-Disposition", "attachment;filename=file.xlsx"); response.setHeader("Content-Disposition", "attachment;filename=file.xlsx");
ServletOutputStream out = response.getOutputStream(); out = response.getOutputStream();
// 终止后删除临时文件 // 终止后删除临时文件
file.deleteOnExit(); file.deleteOnExit();
writer.flush(out, true); writer.flush(out, true);
} finally {
//此处记得关闭输出Servlet流 //此处记得关闭输出Servlet流
if (ObjectUtil.isNotEmpty(out)) {
IoUtil.close(out); IoUtil.close(out);
} }
}
}
public static String getFileType(String type) { public static String getFileType(String type) {
String documents = "txt doc pdf ppt pps xlsx xls docx"; String documents = "txt doc pdf ppt pps xlsx xls docx";

View File

@@ -67,6 +67,9 @@ public class FaultDeviceServiceImpl implements FaultDeviceService {
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
if (ObjectUtil.isNotEmpty(device_code)) { if (ObjectUtil.isNotEmpty(device_code)) {
JSONObject device_jo = WQLObject.getWQLObject("EM_BI_MonitorDevice").query("device_code = '" + device_code + "'").uniqueResult(0); JSONObject device_jo = WQLObject.getWQLObject("EM_BI_MonitorDevice").query("device_code = '" + device_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(device_jo)){
throw new BadRequestException("未查询到设备号为["+device_code+"]的设备信息!");
}
param.put("device_code", device_code); param.put("device_code", device_code);
param.put("product_area", device_jo.getString("product_area")); param.put("product_area", device_jo.getString("product_area"));
} else { } else {

View File

@@ -192,10 +192,17 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
JSONObject task = WQLObject.getWQLObject("SCH_BASE_Task") JSONObject task = WQLObject.getWQLObject("SCH_BASE_Task")
.query("task_id = '" + task_id + "'") .query("task_id = '" + task_id + "'")
.uniqueResult(0); .uniqueResult(0);
if (ObjectUtil.isEmpty(task)){
throw new BadRequestException("未找到任务标识为:" + task_id + "的任务!");
}
if (StrUtil.isNotEmpty(row.getString("car_no"))) { if (StrUtil.isNotEmpty(row.getString("car_no"))) {
WQLObject.getWQLObject("SCH_BASE_Task") WQLObject.getWQLObject("SCH_BASE_Task")
.update(MapOf.of("car_no",row.getString("car_no")),"task_id = '" + task_id + "'"); .update(MapOf.of("car_no",row.getString("car_no")),"task_id = '" + task_id + "'");
} }
String handleClassName = task.getString("handle_class");
if (StrUtil.isEmpty(handleClassName)) {
throw new BadRequestException("当前任务的处理类未找到!");
}
AbstractAcsTask abstractTask = (AbstractAcsTask)SpringContextHolder.getBean(Class.forName(task.getString("handle_class"))); AbstractAcsTask abstractTask = (AbstractAcsTask)SpringContextHolder.getBean(Class.forName(task.getString("handle_class")));
abstractTask.updateTaskStatus(task,Task_Status_Convers.get(row.getString("task_status"))); abstractTask.updateTaskStatus(task,Task_Status_Convers.get(row.getString("task_status")));
} else { } else {
@@ -2089,7 +2096,14 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
WQLObject veExtTab = WQLObject.getWQLObject("md_pb_storagevehicleext"); WQLObject veExtTab = WQLObject.getWQLObject("md_pb_storagevehicleext");
// 6-退货入库 // 6-退货入库
String materialBarcode = whereJson.getString("material_barcode"); String materialBarcode = whereJson.getString("material_barcode");
if(StrUtil.isEmpty(materialBarcode)){
throw new BadRequestException("当前木箱号不能为空!");
}
String[] box_arr = materialBarcode.split("-"); String[] box_arr = materialBarcode.split("-");
if (box_arr.length < 2) {
// 处理分割结果不足的情况
throw new BadRequestException("当前木箱号数据异常!"+box_arr.toString());
}
//获取当前的入库类型 //获取当前的入库类型
whereJson.put("bill_type", "000" + box_arr[1]); whereJson.put("bill_type", "000" + box_arr[1]);
whereJson.put("box_no", box_arr[0]); whereJson.put("box_no", box_arr[0]);

View File

@@ -97,6 +97,9 @@ public class VirtualOutServiceImpl implements VirtualOutService {
if (ObjectUtil.isNotEmpty(whereJson.getString("box_no"))) { if (ObjectUtil.isNotEmpty(whereJson.getString("box_no"))) {
JSONObject jsonSub = WQL.getWO("PDA_VIRTUALOUT").addParam("flag", "4").addParam("box_no", whereJson.getString("box_no")).process().uniqueResult(0); JSONObject jsonSub = WQL.getWO("PDA_VIRTUALOUT").addParam("flag", "4").addParam("box_no", whereJson.getString("box_no")).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonSub)){
throw new BadRequestException("未查询到设木箱号为["+whereJson.getString("box_no")+"]的子卷包装关系信息!");
}
jo.put("net_weight_num", ObjectUtil.isNotEmpty(jsonSub) ? NumberUtil.round(jsonSub.getString("net_weight_num"), 3) : "0"); jo.put("net_weight_num", ObjectUtil.isNotEmpty(jsonSub) ? NumberUtil.round(jsonSub.getString("net_weight_num"), 3) : "0");
} else { } else {