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

@@ -104,13 +104,13 @@ public class InBoxManageServiceImpl implements InBoxManageService {
.eq("task_type", "010702")
.eq("is_delete", "0")
.lt("task_status", TaskStatusEnum.FINISHED.getCode()));
if (count>0){
throw new BadRequestException("当前木箱入库任务已存在"+ boxNo);
if (count > 0) {
throw new BadRequestException("当前木箱入库任务已存在" + boxNo);
}
//查询仓库是否存在相同木箱
JSONArray stIvtStructattr = WQLObject.getWQLObject("st_ivt_structattr").query("storagevehicle_code = '" + boxNo + "'").getResultJSONArray(0);
if (stIvtStructattr!=null && stIvtStructattr.size()>0){
throw new BadRequestException("当前木箱已经存在库中"+stIvtStructattr.getJSONObject(0).getString("struct_code"));
if (stIvtStructattr != null && stIvtStructattr.size() > 0) {
throw new BadRequestException("当前木箱已经存在库中" + stIvtStructattr.getJSONObject(0).getString("struct_code"));
}
// 查询木箱信息
BstIvtBoxinfo boxDao = iBstIvtBoxinfoService.getOne(
@@ -201,10 +201,10 @@ public class InBoxManageServiceImpl implements InBoxManageService {
throw new BadRequestException("扫描的木箱个数和选择的木箱层数不一致!");
}
Set<String> collect = Arrays.stream(split).collect(Collectors.toSet());
if (collect.size()!=split.length){
if (collect.size() != split.length) {
throw new BadRequestException("扫描的木箱条码不能相同");
}
if (split.length>3){
if (split.length > 3) {
throw new BadRequestException("堆叠木箱最大不能超过3层");
}
// 校验是否有相同木箱号
@@ -218,8 +218,8 @@ public class InBoxManageServiceImpl implements InBoxManageService {
//查询仓库是否存在相同木箱
for (String boxSn : split) {
JSONArray stIvtStructattr = WQLObject.getWQLObject("st_ivt_structattr").query("storagevehicle_code = '" + boxSn + "'").getResultJSONArray(0);
if (stIvtStructattr!=null && stIvtStructattr.size()>0){
throw new BadRequestException("当前木箱已经存在库中"+stIvtStructattr.getJSONObject(0).getString("struct_code"));
if (stIvtStructattr != null && stIvtStructattr.size() > 0) {
throw new BadRequestException("当前木箱已经存在库中" + stIvtStructattr.getJSONObject(0).getString("struct_code"));
}
}
@@ -349,13 +349,13 @@ public class InBoxManageServiceImpl implements InBoxManageService {
// 手工入库
if (whereJson.getString("bill_type").equals(IOSEnum.IN_TYPE.code("手工入库"))) {
if (!ifFirst) {
throw new BadRequestException("此木箱【"+whereJson.getString("box_no")+"】未入过库,请选择【生产入库】!");
throw new BadRequestException("此木箱【" + whereJson.getString("box_no") + "】未入过库,请选择【生产入库】!");
}
}
if (whereJson.getString("bill_type").equals(IOSEnum.IN_TYPE.code("生产入库"))) {
if (ifFirst) {
throw new BadRequestException("此木箱【"+whereJson.getString("box_no")+"】已入过库,请选择【手工入库】!");
throw new BadRequestException("此木箱【" + whereJson.getString("box_no") + "】已入过库,请选择【手工入库】!");
}
}
}
@@ -368,15 +368,15 @@ public class InBoxManageServiceImpl implements InBoxManageService {
JSONObject param = new JSONObject();
param.put("pcsn", "");
WQLObject.getWQLObject("md_pb_storagevehicleext")
.update(param,"pcsn = '"+whereJson.getString("box_no")+"'");
.update(param, "pcsn = '" + whereJson.getString("box_no") + "'");
}
// 更新子卷包装关系创建人
JSONObject param2 = new JSONObject();
param2.put("create_id",SecurityUtils.getCurrentUserId());
param2.put("create_name",SecurityUtils.getCurrentNickName());
param2.put("create_id", SecurityUtils.getCurrentUserId());
param2.put("create_name", SecurityUtils.getCurrentNickName());
WQLObject.getWQLObject("pdm_bi_subpackagerelation")
.update(param2,"package_box_sn = '"+whereJson.getString("box_no")+"'");
.update(param2, "package_box_sn = '" + whereJson.getString("box_no") + "'");
/*
* 查询mes木箱信息插入木箱信息表
@@ -423,6 +423,12 @@ public class InBoxManageServiceImpl implements InBoxManageService {
param.put("height", boxDao.getBox_high());
param.put("containerType", boxDao.getVehicle_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));
//根据木箱高度,判断入库仓位的高度

View File

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

View File

@@ -67,6 +67,9 @@ public class FaultDeviceServiceImpl implements FaultDeviceService {
JSONObject param = new JSONObject();
if (ObjectUtil.isNotEmpty(device_code)) {
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("product_area", device_jo.getString("product_area"));
} else {

View File

@@ -192,10 +192,17 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
JSONObject task = WQLObject.getWQLObject("SCH_BASE_Task")
.query("task_id = '" + task_id + "'")
.uniqueResult(0);
if (ObjectUtil.isEmpty(task)){
throw new BadRequestException("未找到任务标识为:" + task_id + "的任务!");
}
if (StrUtil.isNotEmpty(row.getString("car_no"))) {
WQLObject.getWQLObject("SCH_BASE_Task")
.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")));
abstractTask.updateTaskStatus(task,Task_Status_Convers.get(row.getString("task_status")));
} else {
@@ -2089,7 +2096,14 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
WQLObject veExtTab = WQLObject.getWQLObject("md_pb_storagevehicleext");
// 6-退货入库
String materialBarcode = whereJson.getString("material_barcode");
if(StrUtil.isEmpty(materialBarcode)){
throw new BadRequestException("当前木箱号不能为空!");
}
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("box_no", box_arr[0]);

View File

@@ -97,6 +97,9 @@ public class VirtualOutServiceImpl implements VirtualOutService {
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);
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");
} else {