自动化立体仓库 - WMS系统
pang.jiabao
2025-09-22 9e53b59e30bba2149900aa2cc9f22ad0ab445edd
u8单据对接开发完成
10个文件已修改
4个文件已添加
913 ■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/OpenController.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/OrderDetl.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/U8Properties.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/param/MatSyncParam.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/param/OpenOrderPakinParam.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/param/OpenOrderPakoutParam.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/result/OrderRsult.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/OpenService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java 566 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/OrderServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/task/AutoReportingScheduler.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/task/handler/AutoReportingHandler.java 147 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/model/DetlDto.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/OpenController.java
@@ -34,7 +34,7 @@
    private OpenService openService;
    @PostMapping("/order/matSync/default/v1")
    @AppAuth(memo = "商品信息同步接口")
    @AppAuth(memo = "商品信息同步")
    public synchronized R syncMatInfo(@RequestHeader(required = false) String appkey,
                                      @RequestBody(required = false) MatSyncParam param,
                                      HttpServletRequest request){
@@ -67,6 +67,7 @@
     * 添加入库单
     */
    @PostMapping("/order/pakin/default/v1")
    @AppAuth(memo = "入库单下发")
    public synchronized R pakinOrderCreate(@RequestHeader(required = false) String appkey,
                                           @RequestBody OpenOrderPakinParam param,
                                           HttpServletRequest request) {
@@ -77,10 +78,13 @@
        if (Cools.isEmpty(param.getOrderNo())) {
            return R.error("单据编号[orderNo]不能为空");
        }
        if (Cools.isEmpty(param.getOptType())) {
            return R.error("操作类型[optType]不能为空");
        }
        if (Cools.isEmpty(param.getOrderType())) {
            return R.error("单据类型[orderType]不能为空");
        }
        if (Cools.isEmpty(param.getOrderDetails())) {
        if (!param.getOptType().equals("delete") && Cools.isEmpty(param.getOrderDetails())) {
            return R.error("单据明细[orderDetails]不能为空");
        }
        openService.pakinOrderCreate(param);
@@ -102,7 +106,7 @@
     * 添加出库单
     */
    @PostMapping("/order/pakout/default/v1")
    @AppAuth(memo = "添加订单出库")
    @AppAuth(memo = "出库单下发")
    public synchronized R pakoutOrderCreate(@RequestHeader(required = false) String appkey,
                                            @RequestBody OpenOrderPakoutParam param,
                                            HttpServletRequest request) {
@@ -110,19 +114,16 @@
        if (Cools.isEmpty(param)) {
            return R.parse(BaseRes.PARAM);
        }
        if (Cools.isEmpty(param.getLgort())) {
            return R.error("单据编号[lgort]不能为空");
        }
        if (!param.getLgort().equals("5006")) {
            return R.ok();
        }
        if (Cools.isEmpty(param.getOrderNo())) {
            return R.error("单据编号[orderNo]不能为空");
        }
        if (Cools.isEmpty(param.getOrderType())) {
            return R.error("单据类型[orderType]不能为空");
        }
        if (Cools.isEmpty(param.getOrderDetails())) {
        if (Cools.isEmpty(param.getOptType())) {
            return R.error("操作类型[optType]不能为空");
        }
        if (!param.getOptType().equals("delete") && Cools.isEmpty(param.getOrderDetails())) {
            return R.error("单据明细[orderDetails]不能为空");
        }
        openService.pakoutOrderCreate(param);
@@ -140,6 +141,14 @@
        return R.ok().add(openService.pakoutOrderComplete(param));
    }
    /**
     * 结果上报接口-测试
     */
    @PostMapping("/order/resultExport/default/v1")
    public synchronized R orderPakoutComplete(String param) {
       return new R(200,"操作成功");
    }
    /**
     * 库存统计
@@ -152,7 +161,7 @@
    }
    private void auth(String appkey, Object obj, HttpServletRequest request) {
        log.info("{}接口被访问;appkey:{};请求数据:{}", "open/sensorType/list/auth/v1", appkey, JSON.toJSONString(obj));
        log.info("{}接口被访问;appkey:{};请求数据:{}", request.getRequestURI(), appkey, JSON.toJSONString(obj));
        request.setAttribute("cache", obj);
        if (!auth) {
            return;
src/main/java/com/zy/asrs/entity/OrderDetl.java
@@ -132,7 +132,7 @@
    private String sku;
    /**
     * 单位量
     * 上报数量
     */
    @ApiModelProperty(value= "单位量")
    private Double units;
@@ -242,9 +242,9 @@
    private Integer source;
    /**
     * 要求检验 1: 是  0: 否
     * 是否上报 1: 是  0: 否   2: 等待上报
     */
    @ApiModelProperty(value= "要求检验 1: 是  0: 否  ")
    @ApiModelProperty(value= "是否上报 1: 是  0: 否   2: 等待上报")
    private Integer inspect;
    /**
src/main/java/com/zy/asrs/entity/U8Properties.java
New file
@@ -0,0 +1,23 @@
package com.zy.asrs.entity;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
 * @author pang.jiabao
 * @description 读取u8相关配置文件
 * @createDate 2025/9/19 10:26
 */
@Data
@Component
@ConfigurationProperties(prefix = "u8")
public class U8Properties {
    private String URL;
    private String sServer;
    private String sAccID;
    private String sUserID;
    private String sPassword;
    private String resultReportPath;
}
src/main/java/com/zy/asrs/entity/param/MatSyncParam.java
@@ -19,7 +19,14 @@
    public List<MatParam> matDetails;
    @Data
    public class MatParam{
    public static class MatParam{
        /**
         * 操作类型
         * add.新增,delete.删除,update.修改
         */
        private String optType;
        /**
         * 商品编号
         */
src/main/java/com/zy/asrs/entity/param/OpenOrderPakinParam.java
@@ -17,6 +17,9 @@
    private String orderTime;
    // 操作类型 add.新增,delete.删除
    private String optType;
    private List<DetlDto> orderDetails;
}
src/main/java/com/zy/asrs/entity/param/OpenOrderPakoutParam.java
@@ -21,6 +21,9 @@
    private String orderTime;
    // 操作类型 add.新增,delete.删除
    private String optType;
    private List<DetlDto> orderDetails;
    private String lgort;
src/main/java/com/zy/asrs/entity/result/OrderRsult.java
New file
@@ -0,0 +1,52 @@
package com.zy.asrs.entity.result;
import lombok.Data;
import java.util.List;
@Data
public class OrderRsult {
    public Login login;
    public String vouchName;
    public String commandType;
    public String verifier;
    public List<HeadTable> headTable;
    public List<BodyTable> bodyTable;
    @Data
    public static class Login {
        public String sAccID;
        public String sUserID;
        public String sPassword;
        public String sServer;
    }
    @Data
    public static class HeadTable {
        public String ctvcode;
        public String dtvdate;
        public String cmaker;
        public String vt_id;
        public String ciwhcode;
        public String cowhcode;
        public String cordcode;
        public String cirdcode;
        public String codepcode;
        public String cidepcode;
        public String wms_operator;
    }
    @Data
    public static class BodyTable {
        public String irowno;
        public String cinvcode;
        public String ctvbatch;
        public String itvquantity;
        public String cinposcode;
        public String coutposcode;
        public String itrsid;
        public String editprop;
        // 单据号
        public String orderNo;
    }
}
src/main/java/com/zy/asrs/service/OpenService.java
@@ -19,7 +19,7 @@
    List<OpenOrderCompeteResult> pakinOrderComplete(OpenOrderCompleteParam param);
    /**
     * 添加入库单
     * 添加出库单
     */
    void pakoutOrderCreate(OpenOrderPakoutParam param);
src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
@@ -52,85 +52,115 @@
    @Override
    @Transactional
    public void pakinOrderCreate(OpenOrderPakinParam param) {
        Order order = orderService.selectByNo(param.getOrderNo());
        if (!Cools.isEmpty(order)) {
            throw new CoolException(param.getOrderNo() + "单据已存在,请勿重复提交");
        }
        DocType docType = docTypeService.selectOrAdd(param.getOrderType(), Boolean.TRUE);
        Date now = new Date();
        // 单据主档
        order = new Order(
                String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                param.getOrderNo(),    // 订单编号
                DateUtils.convert(now),    // 单据日期
                docType.getDocId(),    // 单据类型
                null,    // 项目编号
                null,    //
                null,    // 调拨项目编号
                null,    // 初始票据号
                null,    // 票据号
                null,    // 客户编号
                null,    // 客户
                null,    // 联系方式
                null,    // 操作人员
                null,    // 合计金额
                null,    // 优惠率
                null,    // 优惠金额
                null,    // 销售或采购费用合计
                null,    // 实付金额
                null,    // 付款类型
                null,    // 业务员
                null,    // 结算天数
                null,    // 邮费支付类型
                null,    // 邮费
                null,    // 付款时间
                null,    // 发货时间
                null,    // 物流名称
                null,    // 物流单号
                1L,    // 订单状态
                1,    // 状态
                9527L,    // 添加人员
                now,    // 添加时间
                9527L,    // 修改人员
                now,    // 修改时间
                null    // 备注
        );
        if (!orderService.insert(order)) {
            throw new CoolException("生成单据主档失败,请联系管理员");
        }
        // 单据明细档
        List<DetlDto> list = new ArrayList<>();
        List<DetlDto> orderDetails = param.getOrderDetails();
        for (DetlDto detail : orderDetails) {
            DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme());
            if (DetlDto.has(list, dto)) {
                DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch());
                assert detlDto != null;
                detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme());
        String orderNo = param.getOrderNo();
        String orderType = param.getOrderType();
        String optType = param.getOptType();
        Order order = orderService.selectByNo(orderNo);
        if (optType.equals("add")) {
            if (!Cools.isEmpty(order)) {
                throw new CoolException(orderNo + "单据已存在,请勿重复提交");
            }
            DocType docType = docTypeService.selectOrAdd(orderType, Boolean.TRUE);
            Date now = new Date();
            // 单据主档
            order = new Order(
                    String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                    orderNo,    // 订单编号
                    DateUtils.convert(now),    // 单据日期
                    docType.getDocId(),    // 单据类型
                    null,    // 项目编号
                    null,    //
                    null,    // 调拨项目编号
                    null,    // 初始票据号
                    null,    // 票据号
                    null,    // 客户编号
                    null,    // 客户
                    null,    // 联系方式
                    null,    // 操作人员
                    null,    // 合计金额
                    null,    // 优惠率
                    null,    // 优惠金额
                    null,    // 销售或采购费用合计
                    null,    // 实付金额
                    null,    // 付款类型
                    null,    // 业务员
                    null,    // 结算天数
                    null,    // 邮费支付类型
                    null,    // 邮费
                    null,    // 付款时间
                    null,    // 发货时间
                    null,    // 物流名称
                    null,    // 物流单号
                    1L,    // 订单状态
                    1,    // 状态
                    9527L,    // 添加人员
                    now,    // 添加时间
                    9527L,    // 修改人员
                    now,    // 修改时间
                    null    // 备注
            );
            if (!orderService.insert(order)) {
                throw new CoolException("生成单据主档失败,orderNo:" + orderNo);
            }
            // 合并单据明细档
            List<DetlDto> list = new ArrayList<>();
            List<DetlDto> orderDetails = param.getOrderDetails();
            for (DetlDto detail : orderDetails) {
                DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme());
                if (DetlDto.has(list, dto)) {
                    DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch());
                    assert detlDto != null;
                    detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme());
                } else {
                    list.add(dto);
                }
            }
            // 插入明细
            for (DetlDto detlDto : list) {
                Mat mat = matService.selectByMatnr(detlDto.getMatnr());
                if (Cools.isEmpty(mat)) {
                    throw new CoolException(detlDto.getMatnr() + "编号商品检索失败,请先添加商品");
                }
                OrderDetl orderDetl = new OrderDetl();
                orderDetl.sync(mat);
                orderDetl.setBatch(detlDto.getBatch());
                orderDetl.setAnfme(detlDto.getAnfme());
                orderDetl.setOrderId(order.getId());
                orderDetl.setOrderNo(order.getOrderNo());
                orderDetl.setSku(detlDto.getSku()); // 单行号,u8明细id,上报需要
                orderDetl.setCreateBy(9527L);
                orderDetl.setCreateTime(now);
                orderDetl.setUpdateBy(9527L);
                orderDetl.setUpdateTime(now);
                orderDetl.setStatus(1);
                orderDetl.setQty(0.0D);
                if (!orderDetlService.insert(orderDetl)) {
                    throw new CoolException(orderNo+":生成单据明细失败:" + detlDto.getMatnr());
                }
            }
        } else if (optType.equals("delete")) {
            if (Cools.isEmpty(order)) {
                throw new CoolException(orderNo + "单据不存在!");
            }
            // 订单状态
            Long settle = order.getSettle();
            if (settle == 1) {
                // 删除订单明细
                orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id", order.getId()));
                // 删除订单主表
                orderService.delete(new EntityWrapper<Order>().eq("id", order.getId()));
            } else {
                list.add(dto);
                throw new CoolException(orderNo + ":订单已处理,无法取消");
            }
        }
        for (DetlDto detlDto : list) {
            Mat mat = matService.selectByMatnr(detlDto.getMatnr());
            if (Cools.isEmpty(mat)) {
                throw new CoolException(detlDto.getMatnr() + "编号商品检索失败,请先添加商品");
            }
            OrderDetl orderDetl = new OrderDetl();
            orderDetl.sync(mat);
            orderDetl.setBatch(detlDto.getBatch());
            orderDetl.setAnfme(detlDto.getAnfme());
            orderDetl.setOrderId(order.getId());
            orderDetl.setOrderNo(order.getOrderNo());
            orderDetl.setCreateBy(9527L);
            orderDetl.setCreateTime(now);
            orderDetl.setUpdateBy(9527L);
            orderDetl.setUpdateTime(now);
            orderDetl.setStatus(1);
            orderDetl.setQty(0.0D);
            if (!orderDetlService.insert(orderDetl)) {
                throw new CoolException("生成单据明细失败,请联系管理员");
            }
        } else {
            throw new CoolException(orderNo + ",操作类型不存在:" + optType);
        }
    }
@@ -183,89 +213,105 @@
    @Override
    @Transactional
    public void pakoutOrderCreate(OpenOrderPakoutParam param) {
        Order order = orderService.selectByNo(param.getOrderNo());
        // 如果单据不存在则添加;如果单据存在,作业中无法修改,反之则修改单据
        if (!Cools.isEmpty(order)) {
            if (order.getSettle() > 1L) {
                throw new CoolException(param.getOrderNo() + "正在出库,无法修改单据");
        String orderNo = param.getOrderNo();
        String optType = param.getOptType();
        String orderType = param.getOrderType();
        Order order = orderService.selectByNo(orderNo);
        if (optType.equals("add")) {
            DocType docType = docTypeService.selectOrAdd(orderType, Boolean.FALSE);
            Date now = new Date();
            // 单据主档
            order = new Order(
                    String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                    orderNo,    // 订单编号
                    DateUtils.convert(now),    // 单据日期
                    docType.getDocId(),    // 单据类型
                    null,    // 项目编号
                    null,    //
                    null,    // 调拨项目编号
                    null,    // 初始票据号
                    null,    // 票据号
                    null,    // 客户编号
                    null,    // 客户
                    null,    // 联系方式
                    null,    // 操作人员
                    null,    // 合计金额
                    null,    // 优惠率
                    null,    // 优惠金额
                    null,    // 销售或采购费用合计
                    null,    // 实付金额
                    null,    // 付款类型
                    null,    // 业务员
                    null,    // 结算天数
                    null,    // 邮费支付类型
                    null,    // 邮费
                    null,    // 付款时间
                    null,    // 发货时间
                    null,    // 物流名称
                    null,    // 物流单号
                    1L,    // 订单状态
                    1,    // 状态
                    9527L,    // 添加人员
                    now,    // 添加时间
                    9527L,    // 修改人员
                    now,    // 修改时间
                    null    // 备注
            );
            if (!orderService.insert(order)) {
                throw new CoolException("生成单据主档失败,orderNo:" + orderNo);
            }
            orderService.remove(order.getId());
        }
        DocType docType = docTypeService.selectOrAdd(param.getOrderType(), Boolean.FALSE);
        Date now = new Date();
        // 单据主档
        order = new Order(
                String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                param.getOrderNo(),    // 订单编号
                DateUtils.convert(now),    // 单据日期
                docType.getDocId(),    // 单据类型
                null,    // 项目编号
                null,    //
                null,    // 调拨项目编号
                null,    // 初始票据号
                null,    // 票据号
                null,    // 客户编号
                null,    // 客户
                null,    // 联系方式
                null,    // 操作人员
                null,    // 合计金额
                null,    // 优惠率
                null,    // 优惠金额
                null,    // 销售或采购费用合计
                null,    // 实付金额
                null,    // 付款类型
                null,    // 业务员
                null,    // 结算天数
                null,    // 邮费支付类型
                null,    // 邮费
                null,    // 付款时间
                null,    // 发货时间
                null,    // 物流名称
                null,    // 物流单号
                1L,    // 订单状态
                1,    // 状态
                9527L,    // 添加人员
                now,    // 添加时间
                9527L,    // 修改人员
                now,    // 修改时间
                null    // 备注
        );
        if (!orderService.insert(order)) {
            throw new CoolException("生成单据主档失败,请联系管理员");
        }
        // 单据明细档
        List<DetlDto> list = new ArrayList<>();
        List<DetlDto> orderDetails = param.getOrderDetails();
        for (DetlDto detail : orderDetails) {
            DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme());
            if (DetlDto.has(list, dto)) {
                DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch());
                assert detlDto != null;
                detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme());
            // 单据明细档
            List<DetlDto> list = new ArrayList<>();
            List<DetlDto> orderDetails = param.getOrderDetails();
            for (DetlDto detail : orderDetails) {
                DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme());
                if (DetlDto.has(list, dto)) {
                    DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch());
                    assert detlDto != null;
                    detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme());
                } else {
                    list.add(dto);
                }
            }
            for (DetlDto detlDto : list) {
                Mat mat = matService.selectByMatnr(detlDto.getMatnr());
                if (Cools.isEmpty(mat)) {
                    throw new CoolException(detlDto.getMatnr() + "编号商品检索失败,请先添加商品");
                }
                OrderDetl orderDetl = new OrderDetl();
                orderDetl.sync(mat);
                orderDetl.setBatch(detlDto.getBatch());
                orderDetl.setAnfme(detlDto.getAnfme());
                orderDetl.setOrderId(order.getId());
                orderDetl.setOrderNo(order.getOrderNo());
                orderDetl.setSku(detlDto.getSku()); // 单行号,u8明细id,上报需要
                orderDetl.setCreateBy(9527L);
                orderDetl.setCreateTime(now);
                orderDetl.setUpdateBy(9527L);
                orderDetl.setUpdateTime(now);
                orderDetl.setStatus(1);
                orderDetl.setQty(0.0D);
                if (!orderDetlService.insert(orderDetl)) {
                    throw new CoolException(orderNo + ":生成单据明细失败:" + detlDto.getMatnr());
                }
            }
        } else if (optType.equals("delete")) {
            if (Cools.isEmpty(order)) {
                throw new CoolException(orderNo + "单据不存在!");
            }
            // 订单状态
            Long settle = order.getSettle();
            if (settle == 1) {
                // 删除订单明细
                orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id", order.getId()));
                // 删除订单主表
                orderService.delete(new EntityWrapper<Order>().eq("id", order.getId()));
            } else {
                list.add(dto);
                throw new CoolException(orderNo + ":订单已处理,无法取消");
            }
        }
        for (DetlDto detlDto : list) {
            Mat mat = matService.selectByMatnr(detlDto.getMatnr());
            if (Cools.isEmpty(mat)) {
                throw new CoolException(detlDto.getMatnr() + "编号商品检索失败,请先添加商品");
            }
            OrderDetl orderDetl = new OrderDetl();
            orderDetl.sync(mat);
            orderDetl.setBatch(detlDto.getBatch());
            orderDetl.setAnfme(detlDto.getAnfme());
            orderDetl.setOrderId(order.getId());
            orderDetl.setOrderNo(order.getOrderNo());
            orderDetl.setCreateBy(9527L);
            orderDetl.setCreateTime(now);
            orderDetl.setUpdateBy(9527L);
            orderDetl.setUpdateTime(now);
            orderDetl.setStatus(1);
            orderDetl.setQty(0.0D);
            if (!orderDetlService.insert(orderDetl)) {
                throw new CoolException("生成单据明细失败,请联系管理员");
            }
        } else {
            throw new CoolException(orderNo + ",操作类型不存在:" + optType);
        }
    }
@@ -438,110 +484,126 @@
    @Override
    @Transactional
    public void syncMat(MatSyncParam param) {
        if (Cools.isEmpty(param.getMatDetails()) || param.getMatDetails().size() <=0 ) {
        if (Cools.isEmpty(param.getMatDetails()) || param.getMatDetails().size() <= 0) {
            throw new CoolException("商品数据为空");
        }
        for(MatSyncParam.MatParam matParam : param.getMatDetails()){
            if(Cools.isEmpty(matParam.getMatnr())){
                throw new CoolException("商品编码不能为空");
        Date now = new Date();
        for (MatSyncParam.MatParam matParam : param.getMatDetails()) {
            String logInfo = "optType:" + matParam.getOptType() + ",matnr:" + matParam.getMatnr() + ",maktx:" + matParam.getMaktx() + ",specs:" + matParam.getSpecs();
            if (Cools.isEmpty(matParam.getOptType(), matParam.getMatnr(), matParam.getMaktx())) {
                throw new CoolException("商品信息不能为空[" + logInfo + "]");
            }
            Date now = new Date();
            Mat mat = matService.selectByMatnr(matParam.getMatnr());
            if (mat == null) {
                mat = new Mat();
                // 分类
                Long tagId;
                // 一级分类
                if (!Cools.isEmpty(matParam.getGroupCode()) && !Cools.isEmpty(matParam.getGroupName())) {
                    Tag priTag = tagService.selectByName(matParam.getGroupCode(), 2);
                    if (priTag == null) {
                        Tag top = tagService.getTop();
                        NodeUtils nodeUtils = new NodeUtils();
                        nodeUtils.executePath(top.getId());
                        priTag = new Tag(
                                null,    // 编号
                                matParam.getGroupCode(),    // 名称
                                top.getId(),    // 父级
                                top.getName(),    // 父级名称
                                nodeUtils.path.toString(),    // 关联路径
                                nodeUtils.pathName.toString(),    // 关联路径名
                                0,    // 类型
                                null,    // 负责人
                                null,    // 图片
                                null,    // 简要描述
                                null,    // 数量
                                2,    // 等级
                                null,    // 排序
                                1,    // 状态
                                now,    // 添加时间
                                null,    // 添加人员
                                now,    // 修改时间
                                null,    // 修改人员
                                null    // 备注
                        );
                        if (tagMapper.insert(priTag) == 0) {
                            throw new CoolException("服务器内部错误,请联系管理员");
                        }
            switch (matParam.getOptType()) {
                case "add":
                    if (mat != null) {
                        throw new CoolException("商品信息已经存在[" + logInfo + "]");
                    }
                    // 二级分类
                    Tag secTag = tagService.selectByName(matParam.getGroupName(), 3);
                    if (secTag == null) {
                        NodeUtils nodeUtils = new NodeUtils();
                        nodeUtils.executePath(priTag.getId());
                        secTag = new Tag(
                                null,    // 编号
                                matParam.getGroupName(),    // 名称
                                priTag.getId(),    // 父级
                                priTag.getName(),    // 父级名称
                                nodeUtils.path.toString(),    // 关联路径
                                nodeUtils.pathName.toString(),    // 关联路径名
                                0,    // 类型
                                null,    // 负责人
                                null,    // 图片
                                null,    // 简要描述
                                null,    // 数量
                                3,    // 等级
                                null,    // 排序
                                1,    // 状态
                                now,    // 添加时间
                                null,    // 添加人员
                                now,    // 修改时间
                                null,    // 修改人员
                                null    // 备注
                        );
                        if (tagMapper.insert(secTag) == 0) {
                            throw new CoolException("服务器内部错误,请联系管理员");
                    mat = new Mat();
                    // 分类
                    Long tagId;
                    // 一级分类
                    if (!Cools.isEmpty(matParam.getGroupCode()) && !Cools.isEmpty(matParam.getGroupName())) {
                        Tag priTag = tagService.selectByName(matParam.getGroupCode(), 2);
                        if (priTag == null) {
                            Tag top = tagService.getTop();
                            NodeUtils nodeUtils = new NodeUtils();
                            nodeUtils.executePath(top.getId());
                            priTag = new Tag(
                                    null,    // 编号
                                    matParam.getGroupCode(),    // 名称
                                    top.getId(),    // 父级
                                    top.getName(),    // 父级名称
                                    nodeUtils.path.toString(),    // 关联路径
                                    nodeUtils.pathName.toString(),    // 关联路径名
                                    0,    // 类型
                                    null,    // 负责人
                                    null,    // 图片
                                    null,    // 简要描述
                                    null,    // 数量
                                    2,    // 等级
                                    null,    // 排序
                                    1,    // 状态
                                    now,    // 添加时间
                                    null,    // 添加人员
                                    now,    // 修改时间
                                    null,    // 修改人员
                                    null    // 备注
                            );
                            if (tagMapper.insert(priTag) == 0) {
                                throw new CoolException("服务器内部错误,请联系管理员");
                            }
                        }
                        // 二级分类
                        Tag secTag = tagService.selectByName(matParam.getGroupName(), 3);
                        if (secTag == null) {
                            NodeUtils nodeUtils = new NodeUtils();
                            nodeUtils.executePath(priTag.getId());
                            secTag = new Tag(
                                    null,    // 编号
                                    matParam.getGroupName(),    // 名称
                                    priTag.getId(),    // 父级
                                    priTag.getName(),    // 父级名称
                                    nodeUtils.path.toString(),    // 关联路径
                                    nodeUtils.pathName.toString(),    // 关联路径名
                                    0,    // 类型
                                    null,    // 负责人
                                    null,    // 图片
                                    null,    // 简要描述
                                    null,    // 数量
                                    3,    // 等级
                                    null,    // 排序
                                    1,    // 状态
                                    now,    // 添加时间
                                    null,    // 添加人员
                                    now,    // 修改时间
                                    null,    // 修改人员
                                    null    // 备注
                            );
                            if (tagMapper.insert(secTag) == 0) {
                                throw new CoolException("服务器内部错误,请联系管理员");
                            }
                        }
                        tagId = secTag.getId();
                    } else {
                        tagId = tagService.getTop().getId();
                    }
                    tagId = secTag.getId();
                } else {
                    tagId = tagService.getTop().getId();
                }
                mat.sync(param);
//            mat.setMatnr(param.getMatnr());
//            mat.setMaktx(param.getMaktx());
//            mat.setSpecs(param.getSpecs());
//            mat.setModel(param.getModel());
                mat.setTagId(tagId);
                mat.setStatus(1);
                mat.setCreateTime(now);
                mat.setUpdateTime(now);
                if (!matService.insert(mat)) {
                    throw new CoolException("服务器内部错误,请联系管理员");
                } else {
                    log.info("同步新物料[商品编号:{}]", mat.getMatnr());
                }
            } else {
                mat.sync(param);
                if (!matService.update(mat, new EntityWrapper<Mat>().eq("matnr",matParam.getMatnr()))) {
                    throw new CoolException("更新已存在商品信息失败,请联系管理员");
                }
                    mat.sync(matParam);
                    mat.setTagId(tagId);
                    mat.setStatus(1);
                    mat.setCreateTime(now);
                    mat.setUpdateTime(now);
                    if (!matService.insert(mat)) {
                        throw new CoolException("同步新物料错误[" + logInfo + "]");
                    } else {
                        log.info("同步新物料[{}]", logInfo);
                    }
                    break;
                case "delete":
                    if (mat == null) {
                        throw new CoolException("商品信息不存在[" + logInfo + "]");
                    }
                    if (matService.delete(new EntityWrapper<Mat>().eq("matnr", matParam.getMatnr()))) {
                        log.info("删除物料[{}]", logInfo);
                    } else {
                        throw new CoolException("删除已存在商品信息失败[" + logInfo + "]");
                    }
                    break;
                case "update":
                    if (mat == null) {
                        throw new CoolException("商品信息不存在[" + logInfo + "]");
                    }
                    mat.sync(matParam);
                    if (!matService.update(mat, new EntityWrapper<Mat>().eq("matnr", matParam.getMatnr()))) {
                        throw new CoolException("更新已存在商品信息失败[" + logInfo + "]");
                    } else {
                        log.info("更新物料[:{}]", logInfo);
                    }
                    break;
                default:
                    throw new CoolException("商品信息操作类型不存在[" + logInfo + "]");
            }
        }
    }
}
src/main/java/com/zy/asrs/service/impl/OrderServiceImpl.java
@@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Slf4j
@Service("orderService")
@@ -70,6 +71,16 @@
                break;
            }
        }
        //当该订单明细数量==完成数量且>上报数量,上报状态为 否 或者 是 时都改成等待上报,定时器轮询等待上报进行上报
        for (OrderDetl orderDetl : orderDetls) {
            if (Objects.equals(orderDetl.getAnfme(), orderDetl.getQty())&&
                    orderDetl.getQty()>orderDetl.getUnits()
                    &&orderDetl.getInspect()<2) {
                    orderDetl.setInspect(2);//等待上报
                    orderDetlService.updateById(orderDetl);
            }
        }
        if (complete) {
            if (!this.updateSettle(order.getId(), 4L, null)) {
                throw new CoolException("修改订单【orderNo = " + order.getOrderNo() + "】状态为已完成失败");
src/main/java/com/zy/asrs/task/AutoReportingScheduler.java
New file
@@ -0,0 +1,46 @@
package com.zy.asrs.task;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.service.OrderDetlService;
import com.zy.asrs.task.handler.AutoReportingHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
 * @author pang.jiabao
 * @description 订单明细完成,定时上报u8
 * @createDate 2025/9/19 9:50
 */
@Component
@Slf4j
public class AutoReportingScheduler {
    @Resource
    private OrderDetlService orderDetlService;
    @Resource
    private AutoReportingHandler autoReportingHandler;
    @Scheduled(cron = "0 0/10 * * * ? ")
//    @Scheduled(cron = "0/3 * * * * ? ")
    void execute() {
        List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("inspect", 2));
        if (Cools.isEmpty(orderDetls)) {
            return;
        }
        for (OrderDetl orderDetl : orderDetls) {
            try {
                autoReportingHandler.U8Reporting(orderDetl);
            } catch (Exception e) {
                log.error("订单明细上报异常,订单号:{},物料:{},异常描述", orderDetl.getOrderNo(), orderDetl.getMatnr());
                e.printStackTrace();
            }
        }
    }
}
src/main/java/com/zy/asrs/task/handler/AutoReportingHandler.java
New file
@@ -0,0 +1,147 @@
package com.zy.asrs.task.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.core.common.Cools;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.Order;
import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.entity.U8Properties;
import com.zy.asrs.entity.result.OrderRsult;
import com.zy.asrs.service.ApiLogService;
import com.zy.asrs.service.OrderDetlService;
import com.zy.asrs.service.OrderService;
import com.zy.common.utils.HttpHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Objects;
/**
 * @author pang.jiabao
 * @description 订单明细完成,定时上报u8
 * @createDate 2025/9/19 9:50
 */
@Slf4j
@Component
public class AutoReportingHandler {
    @Resource
    private U8Properties u8Properties;
    @Resource
    private OrderDetlService orderDetlService;
    @Resource
    private OrderService orderService;
    public void U8Reporting(OrderDetl orderDetl) {
        String orderNo = orderDetl.getOrderNo();
        Order order = orderService.selectByNo(orderNo);
        if (order == null) {
            throw new CoolException("没有找到该订单号:" + orderNo);
        }
        OrderRsult orderRsult = new OrderRsult();
        OrderRsult.Login login = new OrderRsult.Login();
        OrderRsult.HeadTable headTable = new OrderRsult.HeadTable();
        OrderRsult.BodyTable bodyTable = new OrderRsult.BodyTable();
        login.setSAccID(u8Properties.getSAccID()); //账套号    固定
        login.setSUserID(u8Properties.getSUserID());//U8登陆账号 固定
        login.setSPassword(u8Properties.getSPassword());//U8登陆密码 固定
        login.setSServer(u8Properties.getSServer());//U8服务器地址 固定
        orderRsult.setLogin(login);
        orderRsult.setVerifier("sys");//单据类型  固定
        orderRsult.setCommandType("关闭");//操作类型  固定
        orderRsult.setVouchName("");//审核人 填写则自动审核
        headTable.setCtvcode(orderNo);//调拨单号  默认
        //时间
        Date date = new Date();
        Format formatter = new SimpleDateFormat("yyyy-MM-dd");
        String format = formatter.format(date);
        headTable.setDtvdate(format);//单据日期
        headTable.setCmaker("sys");//制单人名称
        headTable.setVt_id("89");//模板号        默认
        headTable.setCiwhcode("1");//转入仓库编码
        headTable.setCowhcode("1");//转出仓库编码
        headTable.setCordcode("");//出库类别编码      默认
        headTable.setCirdcode("");//入库类别编码      默认
        headTable.setCodepcode("");//转出部门编码
        headTable.setCidepcode("");//转入部门编码
        bodyTable.setOrderNo(orderDetl.getOrderNo()); // 单据号
        bodyTable.setIrowno(orderDetl.getSku());//行号
        bodyTable.setCinvcode(orderDetl.getMatnr());//存货编码
        bodyTable.setCtvbatch(Cools.isEmpty(orderDetl.getBatch()) ? "" : orderDetl.getBatch());//批号(特殊说明)
        Double qty = orderDetl.getQty() - (Cools.isEmpty(orderDetl.getUnits()) ? 0 : orderDetl.getUnits());
        bodyTable.setItvquantity(String.valueOf(qty));//完成件数
        bodyTable.setCinposcode("1-1");//立库源货位
        bodyTable.setCoutposcode("");//目标货位
        bodyTable.setItrsid(orderDetl.getSku());//行主键
        bodyTable.setEditprop("A");//状态 A 新增
        ArrayList<OrderRsult.BodyTable> bodyTables = new ArrayList<>();
        bodyTables.add(bodyTable);
        orderRsult.setBodyTable(bodyTables);
        ArrayList<OrderRsult.HeadTable> headTables = new ArrayList<>();
        headTables.add(headTable);
        orderRsult.setHeadTable(headTables);
        String response = "";
        boolean success = false;
        try {
            response = new HttpHandler.Builder()
//                        .setHeaders(map)
                    .setUri(u8Properties.getURL())
                    .setPath(u8Properties.getResultReportPath())
                    .setJson(JSON.toJSONString(orderRsult))
                    .build()
                    .doPost();
            log.info("订单明细完成上报u8原始返回:{}", response);
            JSONObject jsonObject = JSON.parseObject(response);
            if (jsonObject.getInteger("code").equals(200)) {
                orderDetl.setUnits(qty + (Cools.isEmpty(orderDetl.getUnits()) ? 0 : orderDetl.getUnits()));
                if (Objects.equals(orderDetl.getQty(), orderDetl.getAnfme())) {
                    orderDetl.setInspect(1);
                }
                orderDetlService.updateById(orderDetl);
                success = true;
            } else {
                log.error("订单明细完成上报u8失败!!!url:{};request:{};response:{}", u8Properties.getURL() + "/" + u8Properties.getResultReportPath(), JSON.toJSONString(orderRsult), response);
            }
        } catch (Exception e) {
            response = e.getMessage();
            log.error("订单明细完成上报u8异常!!!url:{};request:{};response:{}", u8Properties.getURL() + "/" + u8Properties.getResultReportPath(), JSON.toJSONString(orderRsult), response);
        } finally {
            try {
                // 保存接口日志
                ApiLogService apiLogService = SpringUtils.getBean(ApiLogService.class);
                apiLogService.save(
                        "订单完成上报u8",
                        u8Properties.getURL() + "/" + u8Properties.getResultReportPath(),
                        "",
                        "127.0.0.1",
                        JSON.toJSONString(orderRsult),
                        response,
                        success
                );
            } catch (Exception e) {
                log.error("订单完成上报u8接口日志保存异常", e);
            }
        }
    }
}
src/main/java/com/zy/common/model/DetlDto.java
@@ -21,6 +21,11 @@
    private Double anfme;
    /**
     * 单行号,u8明细id
     */
    private String sku;
    public DetlDto() {
    }
src/main/resources/application.yml
@@ -71,6 +71,15 @@
comb:
  limit: 5000
u8:
  URL: http://127.0.0.1:8080/jsjwms
  sServer: 10.10.0.10
  sAccID: (default)@980
  sUserID: PW008
  sPassword: D#012332.
  # 订单明细结果上报地址
  resultReportPath: open/asrs/order/resultExport/default/v1
#erp对接
erp:
  #  开关