自动化立体仓库 - WMS系统
1
ZY
2025-03-29 c65db22f67af8018ae7105ea00d8743e42835e13
src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
@@ -1,5 +1,6 @@
package com.zy.asrs.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.BaseRes;
import com.core.common.Cools;
@@ -24,9 +25,7 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -77,8 +76,7 @@
        DocType docType = docTypeService.selectOrAdd(param.getOrderType(), Boolean.TRUE);
        Date now = new Date();
        // 单据主档
        order = new Order(
                String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
        order = new Order(String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                param.getOrderNo(),    // 订单编号
                DateUtils.convert(now),    // 单据日期
                docType.getDocId(),    // 单据类型
@@ -156,8 +154,7 @@
        }
// 生成调拨单
        if (docType.getDocId().intValue() == 32) {
            order = new Order(
                    String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
            order = new Order(String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                    "DB" + param.getOrderNo(),    // 订单编号
                    DateUtils.convert(now),    // 单据日期
                    33L,    // 单据类型
@@ -254,7 +251,7 @@
                if (order.getSettle() == 4L) {
                    // 修改订单状态 4.完成 ===>> 6.已上报
                    if (!orderService.updateSettle(order.getId(), 6L, null)) {
                        throw new CoolException("服务器内部错误,请联系管理员");
                        throw new CoolException("订单状态修改(4-6)失败");
                    }
                }
            }
@@ -273,7 +270,7 @@
                }
                // 修改订单状态 4.完成 ===>> 6.已上报
                if (!orderService.updateSettle(order.getId(), 6L, null)) {
                    throw new CoolException("服务器内部错误,请联系管理员");
                    throw new CoolException("订单状态修改(4-6)失败");
                }
            }
        }
@@ -294,8 +291,7 @@
        DocType docType = docTypeService.selectOrAdd(param.getOrderType(), Boolean.FALSE);
        Date now = new Date();
        // 单据主档
        order = new Order(
                String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
        order = new Order(String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                param.getOrderNo(),    // 订单编号
                DateUtils.convert(now),    // 单据日期
                docType.getDocId(),    // 单据类型
@@ -369,8 +365,7 @@
            }
        }
        if (docType.getDocId().intValue() == 32) {
            order = new Order(
                    String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
            order = new Order(String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                    "DB" + param.getOrderNo(),    // 订单编号
                    DateUtils.convert(now),    // 单据日期
                    33L,    // 单据类型
@@ -465,7 +460,7 @@
                if (order.getSettle() == 4L) {
                    // 修改订单状态 4.完成 ===>> 6.已上报
                    if (!orderService.updateSettle(order.getId(), 6L, null)) {
                        throw new CoolException("服务器内部错误,请联系管理员");
                        throw new CoolException("订单状态修改(4-6)失败");
                    }
                }
            }
@@ -484,7 +479,7 @@
                }
                // 修改订单状态 4.完成 ===>> 6.已上报
                if (!orderService.updateSettle(order.getId(), 6L, null)) {
                    throw new CoolException("服务器内部错误,请联系管理员");
                    throw new CoolException("订单状态修改(4-6)失败");
                }
            }
        }
@@ -509,8 +504,7 @@
            throw new CoolException(param.getBarcode() + "重复提交");
        }
        Date now = new Date();
        pack = new Pack(
                param.getBarcode(),    // 条码[非空]
        pack = new Pack(param.getBarcode(),    // 条码[非空]
                analyse.getMatnr(),    // 物料号
                analyse.getBarcode(),    // 序列码
                1L,    // 订单状态
@@ -522,7 +516,7 @@
                null    // 备注
        );
        if (!packService.insert(pack)) {
            throw new CoolException("服务器内部错误,请联系管理员");
            throw new CoolException("打包失败");
        }
        Mat mat = matService.selectByMatnr(analyse.getMatnr());
@@ -537,8 +531,7 @@
                    Tag top = tagService.getTop();
                    NodeUtils nodeUtils = new NodeUtils();
                    nodeUtils.executePath(top.getId());
                    priTag = new Tag(
                            null,    // 编号
                    priTag = new Tag(null,    // 编号
                            param.getGroupCode(),    // 名称
                            top.getId(),    // 父级
                            top.getName(),    // 父级名称
@@ -559,7 +552,7 @@
                            null    // 备注
                    );
                    if (tagMapper.insert(priTag) == 0) {
                        throw new CoolException("服务器内部错误,请联系管理员");
                        throw new CoolException("分类添加失败");
                    }
                }
                // 二级分类
@@ -567,8 +560,7 @@
                if (secTag == null) {
                    NodeUtils nodeUtils = new NodeUtils();
                    nodeUtils.executePath(priTag.getId());
                    secTag = new Tag(
                            null,    // 编号
                    secTag = new Tag(null,    // 编号
                            param.getGroupName(),    // 名称
                            priTag.getId(),    // 父级
                            priTag.getName(),    // 父级名称
@@ -589,7 +581,7 @@
                            null    // 备注
                    );
                    if (tagMapper.insert(secTag) == 0) {
                        throw new CoolException("服务器内部错误,请联系管理员");
                        throw new CoolException("分类添加失败");
                    }
                }
                tagId = secTag.getId();
@@ -605,7 +597,7 @@
            mat.setCreateTime(now);
            mat.setUpdateTime(now);
            if (!matService.insert(mat)) {
                throw new CoolException("服务器内部错误,请联系管理员");
                throw new CoolException("物料添加失败");
            } else {
                log.info("打包上线添加新物料[物料号:{}]", mat.getMatnr());
            }
@@ -655,6 +647,7 @@
        mat.setBeBatch(Cools.eq("true", param.getBInvBatch()) ? 1 : 0);
        mat.setStatus(param.getStates());
        mat.setModel(param.getIGroupType());//0:无换算 1:固定换算 2:浮动换算      不是0的都得传  默认为0
        mat.setCreateBy(9999L);//9999表示erp下发
        mat.setCreateTime(date);
        mat.setUpdateBy(9999L);//9999表示erp下发
@@ -664,9 +657,7 @@
    }
    public void callApiLogSave(Mat mat, String tableName, String response, Boolean bool) {
        apiLogService.save("ERP下发商品信息", tableName, "null", "10.10.10.1",
                "物料编码:" + mat.getMatnr() + "、物料名称:" + mat.getMaktx() + "、规格:" + mat.getSpecs() + "、备注:" + mat.getMemo(),
                response, bool);
        apiLogService.save("ERP下发商品信息", tableName, "null", "10.10.10.1", "物料编码:" + mat.getMatnr() + "、物料名称:" + mat.getMaktx() + "、规格:" + mat.getSpecs() + "、备注:" + mat.getMemo(), response, bool);
    }
@@ -683,8 +674,7 @@
            throw new CoolException("条码长度不是8位===>>" + param.getBarcode());
        }
        // 判断是否有相同条码的数据
        if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
                eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) {
        if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) {
            callApiLogSaveMES(param, null, param.getBarcode() + "数据正在进行入库", false);
            throw new CoolException(param.getBarcode() + "数据正在进行入库");
        }
@@ -745,17 +735,11 @@
    public void callApiLogSaveMES(CombParam combParam, CombParam.CombMat combMat, String response, Boolean bool) {
        if (Cools.isEmpty(combParam)) {
            apiLogService.save("MES下发入库通知单", "/open/asrs/comb/v1", "null", "10.10.10.1",
                    "",
                    response, bool);
            apiLogService.save("MES下发入库通知单", "/open/asrs/comb/v1", "null", "10.10.10.1", "", response, bool);
        } else if (Cools.isEmpty(combMat)) {
            apiLogService.save("MES下发入库通知单", "/open/asrs/comb/v1", "null", "10.10.10.1",
                    "托盘码:" + combParam.getBarcode(),
                    response, bool);
            apiLogService.save("MES下发入库通知单", "/open/asrs/comb/v1", "null", "10.10.10.1", "托盘码:" + combParam.getBarcode(), response, bool);
        } else {
            apiLogService.save("MES下发入库通知单", "/open/asrs/comb/v1", "null", "10.10.10.1",
                    "托盘码:" + combParam.getBarcode() + "、物料编号:" + combMat.getMatnr() + "、数量:" + combMat.getAnfme(),
                    response, bool);
            apiLogService.save("MES下发入库通知单", "/open/asrs/comb/v1", "null", "10.10.10.1", "托盘码:" + combParam.getBarcode() + "、物料编号:" + combMat.getMatnr() + "、数量:" + combMat.getAnfme(), response, bool);
        }
    }
@@ -870,6 +854,12 @@
            throw new CoolException("单据参数为空或者单据详情为空,无法生成单据信息");
        }
        if ("银座生产退料申请单".equalsIgnoreCase(docName)) {
            if (Cools.isEmpty(param.getBackOrderNo())){
                throw new CoolException("退料单的退料编号backOrderNo不能为空");
            }
        }
        Order orderOld = null;
        if (!Cools.isEmpty(orderService.selectByNo(param.getCPOID()))) {
@@ -901,6 +891,11 @@
        }
        Date now = new Date();
        Order order = orderMapping(param, now, pakin, docName);
        Set<String> set = new HashSet<>();
        for (OrderSyncParam.OrderDetl child : param.getChildren()) {
            set.add(child.getCDefine22());
        }
        order.setTel(JSON.toJSONString(set));
        orderService.insert(order);
        param.getChildren().forEach(od -> {
            OrderDetl orderDetl = orderDetlMapping(order, od, now);
@@ -999,9 +994,12 @@
        order.setDefNumber(param.get操作系统号());
        order.setCreateBy(9999L);
        order.setCreateTime(now);
        order.setUpdateBy(9999L);
        order.setUpdateTime(now);
        order.setSalesman(param.getBackOrderNo());
        order.setUpstreamcode(param.getUpstreamcode());
        //订单状态
        order.setSettle(1L);
        //状态
@@ -1035,8 +1033,13 @@
        od.setAnfme(odParam.getIQuantity());
        //销售订单号
        od.setThreeCode(odParam.getCDefine22());
        od.setDevNo(odParam.getDevNo());
        //自由项
        od.setBatch(Cools.isEmpty(odParam.getBatch()) ? "" : odParam.getBatch() + "__" + (Cools.isEmpty(odParam.getBFree1()) ? "" : odParam.getBFree1()));
        if (!Cools.isEmpty(odParam.getBatch()) || !Cools.isEmpty(odParam.getBFree1())) {
            od.setBrand((Cools.isEmpty(odParam.getBatch()) ? "" : odParam.getBatch()) + "__" + (Cools.isEmpty(odParam.getBFree1()) ? "" : odParam.getBFree1()));
        }
        od.setWeight(odParam.getINum());
        od.setVolume(odParam.getIinvexchrate());
        //IDs
        od.setSku(odParam.getId());
@@ -1045,6 +1048,7 @@
        od.setSource(order.getDocType().intValue());
        od.setStatus(1);
        od.setQty(0.0D);
        od.setReportQty(0.0D);
        od.setCreateBy(9999L);
        od.setCreateTime(now);
        od.setUpdateBy(9999L);
@@ -1063,14 +1067,11 @@
    public void callApiLogSave(MatInfoParam matParam, String tableName, String response, Boolean bool) {
        apiLogService.save("ERP下发商品信息", tableName, "null", "10.10.10.1",
                "物料编码:" + matParam.getCinvcode() + "、物料名称:" + matParam.getCinvname() + "、规格:" + matParam.getCInvStd() + "、备注:" + matParam.getMemo(),
                response, bool);
        apiLogService.save("ERP下发商品信息", tableName, "null", "10.10.10.1", "物料编码:" + matParam.getCinvcode() + "、物料名称:" + matParam.getCinvname() + "、规格:" + matParam.getCInvStd() + "、备注:" + matParam.getMemo(), response, bool);
    }
    public void callApiLogSave(OrderSyncParam param, String tableName, String response, Boolean bool) {
        apiLogService.save("ERP订单同步", tableName, "null", "10.10.10.1",
                param.toString(), response, bool);
        apiLogService.save("ERP订单同步", tableName, "null", "10.10.10.1", param.toString(), response, bool);
    }
    public static void main(String[] args) {