自动化立体仓库 - WMS系统
zhou zhou
2025-12-25 418a73bcee019e078307a1c2c255235de33d20ca
src/main/java/com/zy/asrs/task/handler/OrderPakinSyncHandler.java
@@ -5,16 +5,14 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.DocType;
import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.entity.OrderDetlPakin;
import com.zy.asrs.entity.OrderPakin;
import com.zy.asrs.entity.*;
import com.zy.asrs.service.ApiLogService;
import com.zy.asrs.service.DocTypeService;
import com.zy.asrs.service.OrderDetlPakinService;
import com.zy.asrs.service.OrderPakinService;
import com.zy.asrs.task.AbstractHandler;
import com.zy.asrs.task.core.ReturnT;
import com.zy.common.constant.ApiInterfaceConstant;
import com.zy.common.constant.MesConstant;
import com.zy.common.model.MesPakinParam;
import com.zy.common.utils.HttpHandler;
@@ -23,6 +21,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
@@ -51,20 +50,22 @@
            return FAIL.setMsg("未找到对应的单据类型:" + order.getOrderNo());
        }
        MesPakinParam pakinParam = new MesPakinParam();
        ErpReportDto param = new ErpReportDto();
        param.setOrderDetails(new ArrayList<>());
        List<OrderDetlPakin> orderDetls = orderDetlPakinService.selectByOrderId(order.getId());
        for (OrderDetlPakin orderDetl : orderDetls) {
            String serial = Cools.isEmpty(orderDetl.getBatch()) ? "" : orderDetl.getBatch();
            pakinParam.getList().add(new MesPakinParam.Detl(orderDetl.getMatnr() + (Cools.isEmpty(serial) ? "" : "-" + serial), orderDetl.getAnfme()));
            param.getOrderDetails().add(new ErpReportDto.DetlDto(orderDetl.getMatnr(),orderDetl.getQty()));
        }
        param.setOrderNo(order.getOrderNo());
        String response = "";
        boolean success = false;
        ReturnT<String> result = SUCCESS;
        try {
            response = new HttpHandler.Builder()
                    .setUri(MesConstant.URI)
                    .setPath(MesConstant.PAKIN_PATH)
                    .setJson(JSON.toJSONString(pakinParam))
                    .setUri(ApiInterfaceConstant.ERP_IP)
                    .setPath(ApiInterfaceConstant.PAKIN_PATH)
                    .setJson(JSON.toJSONString(param))
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
@@ -73,7 +74,7 @@
                orderPakinService.updateSettle(order.getId(), 6L, null);
                success = true;
            } else {
                log.error("入库完成上报erp失败!url:{};request:{};response:{}", MesConstant.URI + MesConstant.PAKIN_PATH, JSON.toJSONString(pakinParam), response);
                log.error("入库完成上报erp失败!url:{};request:{};response:{}", ApiInterfaceConstant.ERP_IP + ApiInterfaceConstant.PAKIN_PATH, JSON.toJSONString(param), response);
                throw new CoolException("入库完成上报erp失败");
            }
        } catch (Exception e) {
@@ -84,10 +85,10 @@
                // 保存接口日志
                apiLogService.save(
                        "入库完成上报",
                        MesConstant.URI + MesConstant.PAKIN_PATH,
                        ApiInterfaceConstant.ERP_IP + ApiInterfaceConstant.PAKIN_PATH,
                        null,
                        "127.0.0.1",
                        JSON.toJSONString(pakinParam),
                        JSON.toJSONString(param),
                        response,
                        success
                );