rev:1.子卷包装关系字段维护2.入库查询报表字段维护3.处理成品报表部分字段没有值4.空托盘出库任务只生成一个,任务结束后在生成下一个

This commit is contained in:
2023-08-21 15:09:49 +08:00
parent b1a54910c1
commit 7c9209b5aa
4 changed files with 192 additions and 161 deletions

View File

@@ -340,6 +340,18 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
b、没有则优先找空的巷道按空位置顺序分配
3、任务下发判断巷道的任务类型只能为空盘入库或者无任务类型
* */
// 查询此点位是否有正在进行的任务,如果有则不生成任务
JSONObject jsonTask = WQLObject.getWQLObject("sch_base_task")
.query("point_code2 = '" + device_code + "' and is_delete = '0' and task_status <> '07'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonTask)) {
result.put("status", HttpStatus.OK.value());
result.put("message", "此点位已生成任务,请等待任务结束!");
log.info("apply返回参数---------------------------------------------" + result.toString());
return result;
}
JSONArray empArr = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "22").process().getResultJSONArray(0);
JSONObject struct_jo = new JSONObject();

View File

@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils;
@@ -29,11 +30,14 @@ import org.nl.wms.sch.tasks.InTask;
import org.nl.wms.st.inbill.service.RawAssistIStorService;
import org.nl.wms.st.inbill.service.StorPublicService;
import org.nl.wms.st.inbill.service.impl.InbillServiceImpl;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
/**
* @author zhouz
@@ -53,6 +57,8 @@ public class ProductInstorServiceImpl implements ProductInstorService {
private final CutConveyorTask cutConveyorTask;
private final RedissonClient redissonClient;
@Override
public JSONObject boxQuery(JSONObject whereJson) {
String box_no = whereJson.getString("box_no");
@@ -91,6 +97,7 @@ public class ProductInstorServiceImpl implements ProductInstorService {
@Override
@Transactional(rollbackFor = Exception.class)
@SneakyThrows
public JSONObject confirm(JSONObject whereJson) {
String box_no = whereJson.getString("box_no");
//1-报废入库2-生产入库3-退货入库4-拆分入库
@@ -117,170 +124,182 @@ public class ProductInstorServiceImpl implements ProductInstorService {
JSONObject mst_jo = new JSONObject();
mst_jo.put("tableData", box_rows);
mst_jo.put("biz_date", DateUtil.now());
if (option.equals("1")) {
mst_jo.put("bill_type", "0003");
}
if (option.equals("2")) {
mst_jo.put("bill_type", "0001");
}
if (option.equals("3")) {
mst_jo.put("bill_type", "0002");
}
if (option.equals("4")) {
mst_jo.put("bill_type", "0005");
}
HashMap box_map = box_rows.get(0);
Object sub_type = box_map.get("sub_type");
if (ObjectUtil.isNotEmpty(sub_type)){
if (sub_type.equals("1")){
//如果为返检的包装关系则变为返检入库
mst_jo.put("bill_type", "0006");
}
}
//查询成品库仓库
JSONObject stor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("is_delete = '0' AND is_used = '1' AND is_productstore = '1'").uniqueResult(0);
mst_jo.put("stor_id", stor.getString("stor_id"));
mst_jo.put("stor_code", stor.getString("stor_code"));
mst_jo.put("stor_name", stor.getString("stor_name"));
mst_jo.put("detail_count", box_rows.size());
mst_jo.put("total_qty", "0");
mst_jo.put("bill_status", "10"); // 生成
String iostorinv_id = "";
//查询该木箱是否存在未完成的入库单
JSONObject box_mst_jo = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "26").addParam("box_no", box_no).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(box_mst_jo)) {
iostorinv_id = box_mst_jo.getString("iostorinv_id");
} else {
iostorinv_id = rawAssistIStorService.insertDtl(mst_jo);
}
//判断是否虚拟
if (!is_virtual.equals("1")) {
//判断是该包装计划是否存在长宽高
JSONObject sub_jo = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_SN = '" + box_no + "'").uniqueResult(0);
Double box_length = sub_jo.getDoubleValue("box_length");
Double box_width = sub_jo.getDoubleValue("box_width");
Double box_high = sub_jo.getDoubleValue("box_high");
// 木箱长、宽、高不能为0
if (box_length <= 0 || box_width <= 0 || box_high <= 0) {
throw new BadRequestException("该木箱没有长宽高信息,无法入库,请到子卷包装关系中维护!");
}
// 木箱尺寸长度低于950的不入立体库长度大于1385的立体库无法入库
String length_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("box_length_up").getValue();
String length_down = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("box_length_down").getValue();
String with_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("box_with_up").getValue();
String high_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("box_high_up").getValue();
Double box_length_up = Double.valueOf(length_up); // 木箱长度上限
Double box_length_down = Double.valueOf(length_down); // 木箱长度下限
Double box_with_up = Double.valueOf(with_up); // 木箱宽度上限
Double box_high_up = Double.valueOf(high_up); // 木箱高度上限
if (!(box_length_down <= box_length && box_length <= box_length_up)) {
throw new BadRequestException("无法入立体库,木箱超长;当前木箱长度为:"+box_length);
}
if (!(box_width <= box_with_up)) {
throw new BadRequestException("无法入立体库,木箱超宽;当前木箱宽度为:"+box_width);
}
if (!(box_high <= box_high_up)) {
throw new BadRequestException("无法入立体库,木箱超高;当前木箱高度为:"+box_high);
}
JSONObject point_jo = WQLObject.getWQLObject("sch_base_point").query("point_code = '" + point_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(point_jo)) {
throw new BadRequestException("未查询到对应的点位!");
} else {
if (point_jo.getString("is_used").equals("0")) {
throw new BadRequestException("该点位已经被禁用!");
RLock lock = redissonClient.getLock("pda_ioIn:" + option);
boolean tryLock = lock.tryLock(5, TimeUnit.SECONDS);
try {
if (tryLock) {
if (option.equals("1")) {
mst_jo.put("bill_type", "0003");
}
if (point_jo.getString("is_delete").equals("1")) {
throw new BadRequestException("该点位已经被删除!");
if (option.equals("2")) {
mst_jo.put("bill_type", "0001");
}
if (!point_jo.getString("region_code").equals("NBJ01")) {
throw new BadRequestException("请扫描内包间入库点位!");
if (option.equals("3")) {
mst_jo.put("bill_type", "0002");
}
}
//创建二楼去一楼的任务
JSONObject form = new JSONObject();
form.put("point_code1", point_code);
form.put("point_code2", "NTB01");
form.put("vehicle_code", box_no);
form.put("task_type", "010507");
cutConveyorTask.createTask(form);
} else {
JSONArray now_dis_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "18").addParam("box_no", map.get("box_no")).process().getResultJSONArray(0);
if (now_dis_rows.size() > 0) {
throw new BadRequestException("该木箱已经分配过货位,无法继续分配!");
}
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
//直接分配虚拟区货位,并确认
JSONObject struct = WQL.getWO("PDA_ST_01").addParam("flag", "3").addParam("stor_id", stor.getString("stor_id")).process().uniqueResult(0);
HashMap<String, String> dis_map = new HashMap();
dis_map.put("sect_id", struct.getString("sect_id"));
dis_map.put("sect_code", struct.getString("sect_code"));
dis_map.put("sect_name", struct.getString("sect_name"));
dis_map.put("struct_id", struct.getString("struct_id"));
dis_map.put("struct_code", struct.getString("struct_code"));
dis_map.put("struct_name", struct.getString("struct_name"));
dis_map.put("work_status", "01");
dis_map.put("task_id", task_id);
//更新该木箱明细对应的分配
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(dis_map, "iostorinv_id = '" + iostorinv_id + "' AND box_no = '" + box_no + "'");
//修改库存
//直接取出入库分配表的库存
mst_jo = WQLObject.getWQLObject("ST_IVT_IOStorInv").query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
JSONArray dis_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinv_id = '" + iostorinv_id + "' AND box_no = '" + map.get("box_no") + "'").getResultJSONArray(0);
for (int i = 0; i < dis_rows.size(); i++) {
JSONObject dis_jo = dis_rows.getJSONObject(i);
JSONObject i_form = new JSONObject();
i_form.put("struct_id", dis_jo.getString("struct_id"));
i_form.put("material_id", dis_jo.getString("material_id"));
i_form.put("pcsn", dis_jo.getString("pcsn"));
i_form.put("change_qty", dis_jo.getString("plan_qty"));
i_form.put("bill_type_scode", mst_jo.getString("bill_type"));
i_form.put("quality_scode", "01");
i_form.put("inv_id", mst_jo.getString("iostorinv_id"));
i_form.put("bill_code", mst_jo.getString("bill_code"));
i_form.put("bill_table", "ST_IVT_IOStorInv");
i_form.put("qty_unit_id", dis_jo.getString("qty_unit_id"));
i_form.put("qty_unit_name", dis_jo.getString("qty_unit_name"));
storPublicService.IOStor(i_form, "31");
//更新明细表状态
JSONObject dtl_jo = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").query("iostorinvdtl_id = '" + dis_jo.getString("iostorinvdtl_id") + "'").uniqueResult(0);
if (dtl_jo.getDoubleValue("unassign_qty") == 0) {
//判断该明细下是否还存在未分配货位的分配明细
JSONArray disdiv_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinvdtl_id = '" + dis_jo.getString("iostorinvdtl_id") + "' AND (struct_id = '' OR struct_id is null) AND (point_id = '' OR point_id is null)").getResultJSONArray(0);
if (disdiv_rows.size() == 0) {
dtl_jo.put("bill_status", "40");
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").update(dtl_jo);
//判断主表下的明细是否都为40
JSONArray dtl_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").query("iostorinv_id = '" + dis_jo.getString("iostorinv_id") + "' AND bill_status < '40'").getResultJSONArray(0);
if (dtl_rows.size() == 0) {
mst_jo.put("bill_status", "40");
mst_jo.put("dis_optid", currentUserId);
mst_jo.put("dis_optname", nickName);
mst_jo.put("dis_time", DateUtil.now());
WQLObject.getWQLObject("ST_IVT_IOStorInv").update(mst_jo);
}
if (option.equals("4")) {
mst_jo.put("bill_type", "0005");
}
HashMap box_map = box_rows.get(0);
Object sub_type = box_map.get("sub_type");
if (ObjectUtil.isNotEmpty(sub_type)){
if (sub_type.equals("1")){
//如果为返检的包装关系则变为返检入库
mst_jo.put("bill_type", "0006");
}
}
//查询成品库仓库
JSONObject stor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("is_delete = '0' AND is_used = '1' AND is_productstore = '1'").uniqueResult(0);
mst_jo.put("stor_id", stor.getString("stor_id"));
mst_jo.put("stor_code", stor.getString("stor_code"));
mst_jo.put("stor_name", stor.getString("stor_name"));
mst_jo.put("detail_count", box_rows.size());
mst_jo.put("total_qty", "0");
mst_jo.put("bill_status", "10"); // 生成
String iostorinv_id = "";
//查询该木箱是否存在未完成的入库单
JSONObject box_mst_jo = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "26").addParam("box_no", box_no).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(box_mst_jo)) {
iostorinv_id = box_mst_jo.getString("iostorinv_id");
} else {
iostorinv_id = rawAssistIStorService.insertDtl(mst_jo);
}
//判断是否虚拟
if (!is_virtual.equals("1")) {
//判断是该包装计划是否存在长宽高
JSONObject sub_jo = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_SN = '" + box_no + "'").uniqueResult(0);
Double box_length = sub_jo.getDoubleValue("box_length");
Double box_width = sub_jo.getDoubleValue("box_width");
Double box_high = sub_jo.getDoubleValue("box_high");
// 木箱长、宽、高不能为0
if (box_length <= 0 || box_width <= 0 || box_high <= 0) {
throw new BadRequestException("该木箱没有长宽高信息,无法入库,请到子卷包装关系中维护!");
}
// 木箱尺寸长度低于950的不入立体库长度大于1385的立体库无法入库
String length_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("box_length_up").getValue();
String length_down = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("box_length_down").getValue();
String with_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("box_with_up").getValue();
String high_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("box_high_up").getValue();
Double box_length_up = Double.valueOf(length_up); // 木箱长度上限
Double box_length_down = Double.valueOf(length_down); // 木箱长度下限
Double box_with_up = Double.valueOf(with_up); // 木箱宽度上限
Double box_high_up = Double.valueOf(high_up); // 木箱高度上限
if (!(box_length_down <= box_length && box_length <= box_length_up)) {
throw new BadRequestException("无法入立体库,木箱超长;当前木箱长度为:"+box_length);
}
if (!(box_width <= box_with_up)) {
throw new BadRequestException("无法入立体库,木箱超宽;当前木箱宽度为:"+box_width);
}
if (!(box_high <= box_high_up)) {
throw new BadRequestException("无法入立体库,木箱超高;当前木箱高度为:"+box_high);
}
JSONObject point_jo = WQLObject.getWQLObject("sch_base_point").query("point_code = '" + point_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(point_jo)) {
throw new BadRequestException("未查询到对应的点位!");
} else {
if (point_jo.getString("is_used").equals("0")) {
throw new BadRequestException("该点位已经被禁用!");
}
if (point_jo.getString("is_delete").equals("1")) {
throw new BadRequestException("该点位已经被删除!");
}
if (!point_jo.getString("region_code").equals("NBJ01")) {
throw new BadRequestException("请扫描内包间入库点位!");
}
}
//创建二楼去一楼的任务
JSONObject form = new JSONObject();
form.put("point_code1", point_code);
form.put("point_code2", "NTB01");
form.put("vehicle_code", box_no);
form.put("task_type", "010507");
cutConveyorTask.createTask(form);
} else {
JSONArray now_dis_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "18").addParam("box_no", map.get("box_no")).process().getResultJSONArray(0);
if (now_dis_rows.size() > 0) {
throw new BadRequestException("该木箱已经分配过货位,无法继续分配!");
}
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
//直接分配虚拟区货位,并确认
JSONObject struct = WQL.getWO("PDA_ST_01").addParam("flag", "3").addParam("stor_id", stor.getString("stor_id")).process().uniqueResult(0);
HashMap<String, String> dis_map = new HashMap();
dis_map.put("sect_id", struct.getString("sect_id"));
dis_map.put("sect_code", struct.getString("sect_code"));
dis_map.put("sect_name", struct.getString("sect_name"));
dis_map.put("struct_id", struct.getString("struct_id"));
dis_map.put("struct_code", struct.getString("struct_code"));
dis_map.put("struct_name", struct.getString("struct_name"));
dis_map.put("work_status", "01");
dis_map.put("task_id", task_id);
//更新该木箱明细对应的分配
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(dis_map, "iostorinv_id = '" + iostorinv_id + "' AND box_no = '" + box_no + "'");
//修改库存
//直接取出入库分配表的库存
mst_jo = WQLObject.getWQLObject("ST_IVT_IOStorInv").query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
JSONArray dis_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinv_id = '" + iostorinv_id + "' AND box_no = '" + map.get("box_no") + "'").getResultJSONArray(0);
for (int i = 0; i < dis_rows.size(); i++) {
JSONObject dis_jo = dis_rows.getJSONObject(i);
JSONObject i_form = new JSONObject();
i_form.put("struct_id", dis_jo.getString("struct_id"));
i_form.put("material_id", dis_jo.getString("material_id"));
i_form.put("pcsn", dis_jo.getString("pcsn"));
i_form.put("change_qty", dis_jo.getString("plan_qty"));
i_form.put("bill_type_scode", mst_jo.getString("bill_type"));
i_form.put("quality_scode", "01");
i_form.put("inv_id", mst_jo.getString("iostorinv_id"));
i_form.put("bill_code", mst_jo.getString("bill_code"));
i_form.put("bill_table", "ST_IVT_IOStorInv");
i_form.put("qty_unit_id", dis_jo.getString("qty_unit_id"));
i_form.put("qty_unit_name", dis_jo.getString("qty_unit_name"));
storPublicService.IOStor(i_form, "31");
//更新明细表状态
JSONObject dtl_jo = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").query("iostorinvdtl_id = '" + dis_jo.getString("iostorinvdtl_id") + "'").uniqueResult(0);
if (dtl_jo.getDoubleValue("unassign_qty") == 0) {
//判断该明细下是否还存在未分配货位的分配明细
JSONArray disdiv_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinvdtl_id = '" + dis_jo.getString("iostorinvdtl_id") + "' AND (struct_id = '' OR struct_id is null) AND (point_id = '' OR point_id is null)").getResultJSONArray(0);
if (disdiv_rows.size() == 0) {
dtl_jo.put("bill_status", "40");
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").update(dtl_jo);
//判断主表下的明细是否都为40
JSONArray dtl_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").query("iostorinv_id = '" + dis_jo.getString("iostorinv_id") + "' AND bill_status < '40'").getResultJSONArray(0);
if (dtl_rows.size() == 0) {
mst_jo.put("bill_status", "40");
mst_jo.put("dis_optid", currentUserId);
mst_jo.put("dis_optname", nickName);
mst_jo.put("dis_time", DateUtil.now());
WQLObject.getWQLObject("ST_IVT_IOStorInv").update(mst_jo);
}
}
}
}
//调用入库分配确认方法
InbillServiceImpl inbillService = SpringContextHolder.getBean(InbillServiceImpl.class);
JSONObject dis_form = new JSONObject();
dis_form.put("task_id", task_id);
inbillService.confirmDis(dis_form);
}
}
//调用入库分配确认方法
InbillServiceImpl inbillService = SpringContextHolder.getBean(InbillServiceImpl.class);
JSONObject dis_form = new JSONObject();
dis_form.put("task_id", task_id);
inbillService.confirmDis(dis_form);
} finally {
if (tryLock) {
lock.unlock();
}
}
JSONObject jo = new JSONObject();
jo.put("message", "确认成功!");

View File

@@ -243,7 +243,7 @@ public class InBillQueryServiceImpl implements InBillQueryService {
mp.put("班次", json.getString("classes"));
mp.put("库区", json.getString("sect_name"));
mp.put("客户编码", json.getString("customer_name"));
mp.put("客户订单", json.getString("sale_order_name"));
mp.put("销售订单及行", json.getString("sale_order_name"));
mp.put("生产日期", json.getString("date_of_production").replace("-","/"));
mp.put("箱号", json.getString("box_no"));
mp.put("生产批号", (json.getString("confirm_time").substring(0,10)).replace("-","").trim());