空值异常抛出

This commit is contained in:
lyd
2022-11-03 10:27:56 +08:00
parent 1ae43cd2ed
commit 08d2581ef7

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import org.nl.exception.BadRequestException;
import org.nl.utils.SecurityUtils;
import org.nl.wms.st.basedata.service.KilnService;
import org.nl.wql.WQL;
@@ -52,6 +53,7 @@ public class KilnServiceImpl implements KilnService {
String ivt_qty = jsonObject.getString("ivt_qty");
String is_full = jsonObject.getString("is_full");
String area_type = jsonObject.getString("area_type"); //01入窑02出窑
String struct_id = jsonObject.getString("struct_id");
String workprocedure_id = null;
// wql表结构
WQLObject structIvtTab = WQLObject.getWQLObject("ST_IVT_StructIvt");
@@ -74,64 +76,62 @@ public class KilnServiceImpl implements KilnService {
// 判断状态
if (point_status.equals("00")) { // 空位
// 删除仓位库存
structIvtTab.delete("struct_id = '" + jsonObject.getString("struct_id") + "'");
if (ObjectUtil.isNotEmpty(vehicleGroupObj)) // 组盘不为空则删除组盘信息以及设置载具编码为空
vehicleGroupTab.delete(vehicleGroupObj);
if (ObjectUtil.isNotEmpty(struct_id)) structIvtTab.delete("struct_id = '" + struct_id + "'");
// 组盘不为空则删除组盘信息以及设置载具编码为空
if (ObjectUtil.isNotEmpty(vehicleGroupObj)) vehicleGroupTab.delete(vehicleGroupObj);
vehicle_code = null;
} else if (point_status.equals("01")) { // 空载具
// 删除组盘
if (ObjectUtil.isNotEmpty(vehicleGroupObj))
vehicleGroupTab.delete(vehicleGroupObj);
if (ObjectUtil.isNotEmpty(vehicleGroupObj)) vehicleGroupTab.delete(vehicleGroupObj);
// 删除仓位库存
structIvtTab.delete("struct_id = '" + jsonObject.getString("struct_id") + "'");
} else {
if (ObjectUtil.isNotEmpty(struct_id)) structIvtTab.delete("struct_id = '" + struct_id + "'");
} else { // 有箱有料
if (ObjectUtil.isEmpty(vehicle_code)) throw new BadRequestException("载具编码不能为空");
if (ObjectUtil.isEmpty(material_id)) throw new BadRequestException("物料不能为空");
if (ObjectUtil.isEmpty(ivt_qty)) throw new BadRequestException("库存数不能为空");
if (area_type.equals("01")) { // 入窑缓存库那边是压制,出窑是烧制
workprocedure_id = workProcedureTab.query("workprocedure_code = '02'").uniqueResult(0).getString("workprocedure_id");
JSONObject workprocedureObj = workProcedureTab.query("workprocedure_code = '02'").uniqueResult(0);
if (ObjectUtil.isEmpty(workprocedureObj)) throw new BadRequestException("没有压制工序");
workprocedure_id = workprocedureObj.getString("workprocedure_id");
} else {
workprocedure_id = workProcedureTab.query("workprocedure_code = '03'").uniqueResult(0).getString("workprocedure_id");
JSONObject workprocedureObj = workProcedureTab.query("workprocedure_code = '03'").uniqueResult(0);
if (ObjectUtil.isEmpty(workprocedureObj)) throw new BadRequestException("没有烧制工序");
workprocedure_id = workprocedureObj.getString("workprocedure_id");
}
if (ObjectUtil.isEmpty(stockrecordId)) { // 仓位库存id为空就插入
JSONObject structIvt = new JSONObject();
structIvt.put("stockrecord_id", IdUtil.getSnowflake(1, 1).nextId());
structIvt.put("struct_id", jsonObject.getString("struct_id"));
if (ObjectUtil.isNotEmpty(vehicle_code))
structIvt.put("vehicle_code", vehicle_code);
structIvt.put("vehicle_code", vehicle_code);
structIvt.put("workprocedure_id", workprocedure_id);
if (ObjectUtil.isNotEmpty(material_id))
structIvt.put("material_id", material_id);
structIvt.put("material_id", material_id);
structIvt.put("producetask_id", jsonObject.getString("producetask_id"));
if (ObjectUtil.isNotEmpty(jsonObject.getString("ivt_qty"))) {
structIvt.put("canuse_qty", ivt_qty);
structIvt.put("ivt_qty", ivt_qty);
}
structIvt.put("canuse_qty", ivt_qty);
structIvt.put("ivt_qty", ivt_qty);
structIvt.put("frozen_qty", 0);
structIvt.put("warehousing_qty", 0);
structIvt.put("is_full", is_full);
// 入窑静置时间为物料上的静置时间,出窑则不要
if (area_type.equals("02")) {
structIvt.put("stewing_time", "0");
} else if (ObjectUtil.isNotEmpty(materialObj)) {
} else {
structIvt.put("stewing_time", materialObj.getString("stewing_time"));
}
structIvt.put("instorage_time", DateUtil.now());
structIvtTab.insert(structIvt);
} else { // 不为空就修改
JSONObject structIvt = structIvtTab.query("stockrecord_id = '" + stockrecordId + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(vehicle_code))
structIvt.put("vehicle_code", vehicle_code);
if (ObjectUtil.isNotEmpty(material_id))
structIvt.put("material_id", material_id);
structIvt.put("vehicle_code", vehicle_code);
structIvt.put("material_id", material_id);
structIvt.put("producetask_id", jsonObject.getString("producetask_id"));
structIvt.put("workprocedure_id", workprocedure_id);
if (ObjectUtil.isNotEmpty(ivt_qty)) {
structIvt.put("canuse_qty", ivt_qty);
structIvt.put("ivt_qty", ivt_qty);
}
structIvt.put("canuse_qty", ivt_qty);
structIvt.put("ivt_qty", ivt_qty);
// 入窑静置时间为物料上的静置时间,出窑则不要
if (area_type.equals("02")) {
structIvt.put("stewing_time", "0");
} else if (ObjectUtil.isNotEmpty(materialObj)) {
} else {
structIvt.put("stewing_time", materialObj.getString("stewing_time"));
}
structIvt.put("is_full", is_full);
@@ -145,12 +145,10 @@ public class KilnServiceImpl implements KilnService {
vehicleGroup.put("group_id", IdUtil.getSnowflake(1, 1).nextId());
vehicleGroup.put("vehicle_code", vehicle_code);
vehicleGroup.put("is_autopackage", 1);
if (ObjectUtil.isNotEmpty(materialObj)) {
vehicleGroup.put("material_id", materialObj.getString("material_id"));
vehicleGroup.put("material_code", materialObj.getString("material_code"));
vehicleGroup.put("material_name", materialObj.getString("material_name"));
vehicleGroup.put("material_spec", materialObj.getString("material_spec"));
}
vehicleGroup.put("material_id", materialObj.getString("material_id"));
vehicleGroup.put("material_code", materialObj.getString("material_code"));
vehicleGroup.put("material_name", materialObj.getString("material_name"));
vehicleGroup.put("material_spec", materialObj.getString("material_spec"));
vehicleGroup.put("task_id", IdUtil.simpleUUID());
vehicleGroup.put("create_id", currentUserId);
vehicleGroup.put("create_name", nickName);
@@ -167,6 +165,7 @@ public class KilnServiceImpl implements KilnService {
}
// 点位修改
JSONObject point = pointTab.query("point_id = '" + jsonObject.getString("point_id") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(point)) throw new BadRequestException("被删除或无权限,操作失败!");
point.put("point_status", point_status);
point.put("lock_type", jsonObject.getString("lock_type"));
point.put("vehicle_code", vehicle_code);