自动化立体仓库 - WMS系统
skyouc
1 天以前 44bc5cf48fa23a1bf5fcefedce1b4686033b245a
src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java
@@ -2,29 +2,43 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
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.Order;
import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.service.ApiLogService;
import com.zy.asrs.service.DocTypeService;
import com.zy.asrs.service.OrderDetlService;
import com.zy.asrs.service.OrderService;
import com.zy.api.entity.OrderItemsParam;
import com.zy.api.entity.OutOrderParams;
import com.zy.api.entity.PubOrderParams;
import com.zy.api.entity.ReportOrderParam;
import com.zy.api.entity.ReportOrderParams;
import com.zy.api.entity.StockAdjustParams;
import com.zy.api.entity.StockUpOrderParams;
import com.zy.api.entity.dto.XSR;
import com.zy.api.service.KopenApiService;
import com.zy.asrs.entity.*;
import com.zy.asrs.enums.OrderTypeEnum;
import com.zy.asrs.service.*;
import com.zy.asrs.service.impl.CheckOrderDetlServiceImpl;
import com.zy.asrs.task.AbstractHandler;
import com.zy.asrs.task.core.ReturnT;
import com.zy.asrs.utils.OrderInAndOutUtil;
import com.zy.asrs.utils.Utils;
import com.zy.common.constant.MesConstant;
import com.zy.common.model.DetlDto;
import com.zy.common.model.MesPakinParam;
import com.zy.common.model.MesPakoutParam;
import com.zy.common.utils.HttpHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
 * Created by vincent on 2020/7/7
@@ -32,6 +46,8 @@
@Slf4j
@Service
public class OrderSyncHandler extends AbstractHandler<String> {
    private final CheckOrderDetlServiceImpl checkOrderDetlService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
@@ -43,113 +59,498 @@
    private ApiLogService apiLogService;
    @Autowired
    private DocTypeService docTypeService;
    @Autowired
    private OrderPakinService orderPakinService;
    @Autowired
    private OrderDetlPakinService orderDetlPakinService;
    @Autowired
    private KopenApiService kopenApiService;
    @Autowired
    private MatService matService;
    OrderSyncHandler(CheckOrderDetlServiceImpl checkOrderDetlService) {
        this.checkOrderDetlService = checkOrderDetlService;
    }
    @Transactional
    public ReturnT<String> start(Order order) {
    public ReturnT<String> startOrderIssuedOnceMore(Order order) {
        DocType docType = docTypeService.selectById(order.getDocType());
        if (null == docType) {
            return SUCCESS;
        }
        Order order1 = OrderInAndOutUtil.selectByNo(order.getPakinPakoutStatus$(), order.getOrderNo());
        if (!Cools.isEmpty(order1)) {
            return FAIL.setMsg("请等待...订单执行档案正在转历史档案!!!");
        }
        List<OrderDetl> orderDetls = OrderInAndOutUtil.selectByOrderId(order.getPakinPakoutStatus$(), order.getId());
        if (!Cools.isEmpty(orderDetls) || !orderDetls.isEmpty()) {
            return FAIL.setMsg("请等待...订单执行明细档案正在转历史档案!!!");
        }
        // 单据明细档
        List<OrderDetl> orderDetlList = orderDetlService.selectByOrderId(order.getId());
        for (OrderDetl orderDetl : orderDetlList) {
            if (orderDetl.getQty().equals(0D)) {
                continue;
            }
            orderDetl.setWorkQty(orderDetl.getQty());
            orderDetl.setAnfme(orderDetl.getAnfme() - orderDetl.getQty());
            orderDetl.setQty(0D);
            orderDetlService.updateById(orderDetl);
        }
        // 修改订单状态 99.再次作业 ===>> 1.待作业
        if (!orderService.updateSettle(order.getId(), 1L, null)) {
            throw new CoolException("服务器内部错误,请联系管理员");
        }
        return SUCCESS;
    }
    @Transactional(rollbackFor = Exception.class)
    public ReturnT<String> startOrderIssued(Order order) {
        DocType docType = docTypeService.selectById(order.getDocType());
        if (null == docType) {
            return SUCCESS;
        }
        List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId());
        // 入库完成上报
        if (docType.getPakin() == 1) {
            MesPakinParam pakinParam = new MesPakinParam();
            pakinParam.setPakinTime(DateUtils.convert(order.getUpdateTime()));
            pakinParam.setLgortFrom("5008");
            pakinParam.setLgortTo("5006");
            for (OrderDetl orderDetl : orderDetls) {
                String serial = Cools.isEmpty(orderDetl.getBatch()) ? "" : orderDetl.getBatch();
                pakinParam.getList().add(new MesPakinParam.Detl(orderDetl.getMatnr() + (Cools.isEmpty(serial) ? "" : "-" + serial), orderDetl.getAnfme()));
            }
            String response = "";
            boolean success = false;
            try {
                response = new HttpHandler.Builder()
                        .setUri(MesConstant.URL)
                        .setPath(MesConstant.PAKIN_URL)
                        .setJson(JSON.toJSONString(pakinParam))
                        .build()
                        .doPost();
                JSONObject jsonObject = JSON.parseObject(response);
                if (jsonObject.getInteger("code").equals(200)) {
                    success = true;
                    // 修改订单状态 4.完成 ===>> 6.已上报
                    if (!orderService.updateSettle(order.getId(), 6L, null)) {
                        throw new CoolException("服务器内部错误,请联系管理员");
                    }
                } else {
                    log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL+MesConstant.PAKIN_URL, JSON.toJSONString(pakinParam), response);
                    throw new CoolException("上报mes系统失败");
                }
            } catch (Exception e) {
                log.error("fail", e);
//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return FAIL.setMsg(e.getMessage());
            } finally {
                try {
                    // 保存接口日志
                    apiLogService.save(
                            "成品库入库上报",
                            MesConstant.URL + MesConstant.PAKIN_URL,
                            null,
                            "127.0.0.1",
                            JSON.toJSONString(pakinParam),
                            response,
                            success
                    );
                } catch (Exception e) { log.error("", e); }
        OrderInAndOutUtil.insertOrder(order.getPakinPakoutStatus$(), order);
        // 单据明细档
        List<DetlDto> list = new ArrayList<>();
        List<OrderDetl> orderDetlList = new ArrayList<>();
        for (OrderDetl detail : orderDetls) {
            DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getBrand(), detail.getStandby1(),
                    detail.getStandby2(), detail.getStandby3(),
                    detail.getBoxType1(), detail.getBoxType2(), detail.getBoxType3(), detail.getAnfme(),
                    detail.getThreeCode());
            if (DetlDto.has(list, dto)) {
                DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch(), dto.getBrand(), dto.getStandby1(),
                        dto.getStandby2(), dto.getStandby3(), dto.getBoxType1(), dto.getBoxType2(), dto.getBoxType3());
                assert detlDto != null;
                detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme());
                OrderDetl orderDetl = OrderDetl.find(orderDetlList, dto.getMatnr(), dto.getBatch(), dto.getBrand(),
                        dto.getStandby1(), dto.getStandby2(), dto.getStandby3(), dto.getBoxType1(), dto.getBoxType2(),
                        dto.getBoxType3());
                assert orderDetl != null;
                orderDetl.setAnfme(orderDetl.getAnfme() + detail.getAnfme());
            } else {
                list.add(dto);
                orderDetlList.add(detail);
            }
        }
        // 出库完成上报
        if (docType.getPakout() == 1) {
            MesPakoutParam pakoutParam = new MesPakoutParam();
            pakoutParam.setPakoutTime(DateUtils.convert(order.getUpdateTime()));    // todo:luxiaotao
            pakoutParam.setLgortFrom("5008");   // todo:luxiaotao
            pakoutParam.setLgortTo("5006");   // todo:luxiaotao
            for (OrderDetl orderDetl : orderDetls) {
                String serial = Cools.isEmpty(orderDetl.getBatch()) ? "" : orderDetl.getBatch();
                pakoutParam.getList().add(new MesPakoutParam.Detl(orderDetl.getMatnr() + (Cools.isEmpty(serial) ? "" : "-" + serial), orderDetl.getAnfme()));
            }
            String response = "";
            boolean success = false;
            try {
                response = new HttpHandler.Builder()
                        .setUri(MesConstant.URL)
                        .setPath(MesConstant.PAKOUT_URL)    // todo:luxiaotao
                        .setJson(JSON.toJSONString(pakoutParam))
                        .build()
                        .doPost();
                JSONObject jsonObject = JSON.parseObject(response);
                if (jsonObject.getInteger("code").equals(200)) {
                    success = true;
                    // 修改订单状态 4.完成 ===>> 6.已上报
                    if (!orderService.updateSettle(order.getId(), 6L, null)) {
                        throw new CoolException("服务器内部错误,请联系管理员");
                    }
                } else {
                    log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL+MesConstant.PAKOUT_URL, JSON.toJSONString(pakoutParam), response);
                    throw new CoolException("上报mes系统失败");
                }
            } catch (Exception e) {
                log.error("fail", e);
//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return FAIL.setMsg(e.getMessage());
            } finally {
        for (OrderDetl orderDetl : orderDetlList) {
            orderDetl.setWorkQty(0D);
            OrderInAndOutUtil.insertOrderDetl(order.getPakinPakoutStatus$(), order, orderDetl);
            // 小松:如果下发备货派工单,则生成备货出库+备货入库
            if (order.getDocType().equals(OrderTypeEnum.TRANSFER.type.longValue())) {
                try {
                    // 保存接口日志
                    apiLogService.save(
                            "成品库出库上报",
                            MesConstant.URL + MesConstant.PAKOUT_URL,
                            null,
                            "127.0.0.1",
                            JSON.toJSONString(pakoutParam),
                            response,
                            success
                    );
                } catch (Exception e) { log.error("", e); }
                    ifTransfetInsertStockIn(order, orderDetl);
                } catch (Exception e) {
                    throw new CoolException(e.getMessage());
                }
            }
        }
        // 修改订单状态 1.未作业 ===>> 2.作业中
        if (!orderService.updateSettle(order.getId(), 2L, null)) {
            throw new CoolException("服务器内部错误,请联系管理员");
        }
        return SUCCESS;
    }
    @Transactional(rollbackFor = Exception.class)
    public void ifTransfetInsertStockIn(Order order, OrderDetl orderDetl) {
        OrderPakin orderPakin = new OrderPakin();
        BeanUtils.copyProperties(order, orderPakin);
        orderPakin.setDocType(OrderTypeEnum.STOCK_IN.type.longValue());
        if (!orderPakinService.insert(orderPakin)) {
            throw new CoolException("插入备货入库单失败");
        }
        OrderDetlPakin orderDetlPakin = new OrderDetlPakin();
        BeanUtils.copyProperties(orderDetl, orderDetlPakin);
        orderDetlPakin.setOrderId(orderPakin.getId());
        if (!orderDetlPakinService.insert(orderDetlPakin)) {
            throw new CoolException("插入备货入库单失败");
        }
    }
    @Transactional
    public ReturnT<String> startOrderInAndOutUtil(Order order) {
        // 小松:轮训到备货派工单是查询备货入库单是否完成
        if (order.getDocType().equals(OrderTypeEnum.STOCK_IN.type.longValue())) {
            return SUCCESS;
        }
        if (order.getDocType().equals(OrderTypeEnum.TRANSFER.type.longValue())) {
            OrderPakin orderPakin = orderPakinService.selectByNo(order.getOrderNo());
            if (null != orderPakin) {
                if (!orderPakin.getSettle().equals(4L)) {
                    return SUCCESS;
                }
            }
        }
        DocType docType = docTypeService.selectById(order.getDocType());
        if (null == docType) {
            return SUCCESS;
        }
        Order orderSou = orderService.selectByNo(order.getOrderNo());
        if (!orderSou.getSettle().equals(2L)) {
            return FAIL.setMsg("订单状态不正确,请联系管理员");
        }
        List<OrderDetl> orderDetlList = orderDetlService.selectByOrderId(orderSou.getId());
        List<OrderDetl> orderDetls = OrderInAndOutUtil.selectByOrderId(order.getPakinPakoutStatus$(), order.getId());
        for (OrderDetl orderDetlSou : orderDetlList) {
            for (OrderDetl orderDetl : orderDetls) {
                if (orderDetl.getQty().equals(0D)) {
                    continue;
                }
                if (orderDetlSou.beSimilar(orderDetl)) {
                    double v = orderDetlSou.getAnfme() - orderDetlSou.getQty();
                    if (v < orderDetl.getQty() || orderDetl.getQty().equals(v)) {
                        orderDetlSou.setQty(orderDetlSou.getAnfme());
                        orderDetl.setQty(orderDetl.getQty() - v);
                        break;
                    } else {
                        orderDetlSou.setQty(orderDetlSou.getQty() + orderDetl.getQty());
                        orderDetl.setQty(0D);
                    }
                }
            }
        }
        for (OrderDetl orderDetlSou : orderDetlList) {
            orderDetlService.updateById(orderDetlSou);
        }
        // 修改订单状态 2.作业中 ===>> 4.待上报
        if (!orderService.updateSettle(orderSou.getId(), 4L, null)) {
            throw new CoolException("服务器内部错误,请联系管理员");
        }
        // 修改订单状态 4.完成 ===>> 6.结束
        OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(), order.getId(), 6L, null);
        return SUCCESS;
    }
    /**
     * 单据上报
     *
     * @param order
     * @return com.zy.asrs.task.core.ReturnT<java.lang.String>
     * @author Ryan
     * @date 2025/12/15 16:14
     */
    @Transactional
    public ReturnT<String> startOrderReport(Order order) {
        DocType docType = docTypeService.selectById(order.getDocType());
        if (null == docType) {
            return SUCCESS;
        }
        long settle = 6L;
        List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId());
        if (Integer.valueOf(docType.getDocId() + "").equals(OrderTypeEnum.PICKING.type)) {
            // 上架派工单完成
            ReportOrderParam orderParam = new ReportOrderParam();
            orderParam.setCompany_id(order.getCstmrName())
                    .setWms_id(order.getId() + "")
                    .setOrder_no(order.getOrderNo())
                    .setType(order.getDocType() + "")
                    .setInv_no(order.getNumber())
                    .setPm_tktid(order.getItemName())
                    .setUpdate_time(Utils.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss"))
                    .setTarget_location("");
            List<ReportOrderParams> reportOrderParams = new ArrayList<>();
            orderDetls.forEach(detl -> {
                Mat material = matService.selectByMatnr(detl.getMatnr());
                if (Objects.isNull(material)) {
                    throw new CoolException("物料不存在");
                }
                ReportOrderParams itemParam = new ReportOrderParams();
                // BS Code
                itemParam.setTotal_serial(detl.getThreeCode())
                        // 上报时,默认产品类型是null
                        .setPro_type(material.getProType())
                        // 上报时,默认产品编码
                        .setPro_komcode(detl.getMatnr())
                        // 上报时,默认产品id是供应商编码
                        .setPro_id(detl.getSuppCode())
                        // 上报时,默认来源位置是null
                        .setLocation_no(null)
                        // 上报时,默认目标位置是null
                        .setLocation_type(null)
                        // 上报时,默认上报时间是更新时间
                        .setSj_date(order.getUpdateBy().toString())
                        // 上报时,默认上报人是更新人
                        .setSj_emp(order.getUpdateBy$())
                        // 上报时,默认上报数量是订单数量
                        .setPick_qty(detl.getQty().intValue())
                        // 上报时,默认损坏数量是0
                        .setDamage_qty(0)
                        // 上报时,默认差异数量是0
                        .setDiff_qty(0);
                reportOrderParams.add(itemParam);
            });
            orderParam.setDetails(reportOrderParams);
            XSR response = null;
            boolean success = false;
            try {
                response = kopenApiService.getInDispatchResult(orderParam);
                // if (true) {
                // success = true;
                // // 修改订单状态 4.完成 ===>> 6.已上报
                // if (!orderService.updateSettle(order.getId(), settle, null)) {
                // throw new CoolException("服务器内部错误,请联系管理员");
                // }
                // } else {
                // log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL +
                // MesConstant.PAKIN_URL, JSON.toJSONString(pakinParam), response);
                // throw new CoolException("上报mes系统失败");
                // }
            } catch (Exception e) {
                log.error("fail", e);
                // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return FAIL.setMsg(e.getMessage());
            } finally {
                try {
                    // 保存接口日志
                    apiLogService.save(
                            "上架派工单完成上报",
                            MesConstant.URL + MesConstant.IN_DISPATCH_RESULT,
                            null,
                            "127.0.0.1",
                            JSON.toJSONString(orderParam),
                            JSON.toJSONString(response),
                            success);
                } catch (Exception e) {
                    log.error("", e);
                }
            }
        } else if (Integer.valueOf(docType.getDocId() + "").equals(OrderTypeEnum.TRANSFER.type)) {
            // 备货派工单(出库)
            ReportOrderParam orderParam = new ReportOrderParam();
            orderParam.setCompany_id(order.getCstmrName())
                    .setWms_id(order.getId() + "")
                    .setOrder_no(order.getOrderNo())
                    .setType(order.getDocType() + "")
                    .setInv_no(order.getNumber())
                    .setPm_tktid(order.getItemName())
                    .setUpdate_time(Utils.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss"))
                    .setTarget_location("");
            List<ReportOrderParams> reportOrderParams = new ArrayList<>();
            orderDetls.forEach(detl -> {
                Mat material = matService.selectByMatnr(detl.getMatnr());
                if (Objects.isNull(material)) {
                    throw new CoolException("物料不存在");
                }
                ReportOrderParams itemParam = new ReportOrderParams();
                // BS Code
                itemParam.setTotal_serial(detl.getThreeCode())
                        // 上报时,默认产品类型是null
                        .setPro_type(material.getProType())
                        // 上报时,默认产品编码
                        .setPro_komcode(detl.getMatnr())
                        // 上报时,默认产品id是供应商编码
                        .setPro_id(detl.getSuppCode())
                        // 上报时,默认来源位置是null
                        .setLocation_no(null)
                        // 上报时,默认目标位置是null
                        .setLocation_type(null)
                        // 上报时,默认上报时间是更新时间
                        .setSj_date(order.getUpdateBy().toString())
                        // 上报时,默认上报人是更新人
                        .setSj_emp(order.getUpdateBy$())
                        // 上报时,默认上报数量是订单数量
                        .setPick_qty(detl.getQty().intValue())
                        // 上报时,默认损坏数量是0
                        .setDamage_qty(0)
                        // 上报时,默认差异数量是0
                        .setDiff_qty(0);
                reportOrderParams.add(itemParam);
            });
            orderParam.setDetails(reportOrderParams);
            XSR response = null;
            boolean success = false;
            try {
                // response = new HttpHandler.Builder()
                // .setUri(MesConstant.URL)
                // .setPath(MesConstant.PAKOUT_URL)
                // .setJson(JSON.toJSONString(pakoutParam))
                // .build()
                // .doPost();
                // JSONObject jsonObject = JSON.parseObject(response);
                // if (jsonObject.getInteger("code").equals(200)) {
                if (true) {
                    success = true;
                    // 修改订单状态 4.完成 ===>> 6.已上报
                    if (!orderService.updateSettle(order.getId(), settle, null)) {
                        throw new CoolException("服务器内部错误,请联系管理员");
                    }
                } else {
                    log.error("请求接口失败!!!url:{};request:{};response:{}",
                            MesConstant.URL + MesConstant.OUT_DISPATCH_RESULT,
                            JSON.toJSONString(orderParam), JSON.toJSONString(response));
                    throw new CoolException("上报KOPEN系统失败");
                }
            } catch (Exception e) {
                log.error("fail", e);
                return FAIL.setMsg(e.getMessage());
            } finally {
                try {
                    // 保存接口日志
                    apiLogService.save(
                            "备货派工单完成上报",
                            MesConstant.URL + MesConstant.OUT_DISPATCH_RESULT,
                            null,
                            "127.0.0.1",
                            JSON.toJSONString(orderParam),
                            JSON.toJSONString(response),
                            success);
                } catch (Exception e) {
                    log.error("", e);
                }
            }
        } else if (Integer.valueOf(docType.getDocId() + "").equals(OrderTypeEnum.STOCK.type)) {
            // 备货单反馈
            StockUpOrderParams stockUpOrderParams = new StockUpOrderParams();
            stockUpOrderParams.setCompany_id(order.getCstmrName())
                    .setWms_id(order.getId() + "")
                    .setDispatch_no(order.getNumber());
            OutOrderParams pubOrderParams = new OutOrderParams();
            pubOrderParams.setPick_no(order.getOrderNo())
                    .setOrder_no(order.getShipCode())
                    .setCus_id(order.getCstmrName())
                    .setCus_address(order.getTel());
            List<OrderItemsParam> reportOrderParams = new ArrayList<>();
            orderDetls.forEach(detl -> {
                Mat material = matService.selectByMatnr(detl.getMatnr());
                if (Objects.isNull(material)) {
                    throw new CoolException("物料不存在");
                }
                OrderItemsParam itemParam = new OrderItemsParam();
                // 上报时,默认产品类型是null
                itemParam.setPro_type(material.getProType());
                // 上报时,默认产品编码
                itemParam.setPro_komcode(material.getMatnr());
                // 上报时,默认产品id是供应商编码
                itemParam.setPro_id(detl.getSuppCode());
                // 上报时,默认上报时间是更新时间
                itemParam.setPick_qty(detl.getQty().intValue());
                reportOrderParams.add(itemParam);
            });
            pubOrderParams.setPartList(reportOrderParams);
            List<OutOrderParams> pubOrderParamsList = new ArrayList<>();
            pubOrderParamsList.add(pubOrderParams);
            // 设置派工单明细
            stockUpOrderParams.setDetails(pubOrderParamsList);
            stockUpOrderParams.setUpdate_time(order.getUpdateBy$());
            XSR response = null;
            boolean success = false;
            try {
                // response = new HttpHandler.Builder()
                // .setUri(MesConstant.URL)
                // .setPath(MesConstant.PAKOUT_URL)
                // .setJson(JSON.toJSONString(pakoutParam))
                // .build()
                // .doPost();
                // JSONObject jsonObject = JSON.parseObject(response);
                // if (jsonObject.getInteger("code").equals(200)) {
                if (true) {
                    success = true;
                    // 修改订单状态 4.完成 ===>> 6.已上报
                    if (!orderService.updateSettle(order.getId(), settle, null)) {
                        throw new CoolException("服务器内部错误,请联系管理员");
                    }
                } else {
                    log.error("请求接口失败!!!url:{};request:{};response:{}",
                            MesConstant.URL + MesConstant.OUT_DETAILS_RESULT,
                            JSON.toJSONString(stockUpOrderParams), JSON.toJSONString(response));
                    throw new CoolException("上报KOPEN系统失败");
                }
            } catch (Exception e) {
                log.error("fail", e);
                return FAIL.setMsg(e.getMessage());
            } finally {
                try {
                    // 保存接口日志
                    apiLogService.save(
                            "备货单完成上报",
                            MesConstant.URL + MesConstant.OUT_DETAILS_RESULT,
                            null,
                            "127.0.0.1",
                            JSON.toJSONString(stockUpOrderParams),
                            JSON.toJSONString(response),
                            success);
                } catch (Exception e) {
                    log.error("", e);
                }
            }
        }
        return SUCCESS;
    }
    /**
     * 损溢单完结上报
     *
     * @param order
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public ReturnT<String> startCheckOrderReport(CheckOrder order) {
        List<StockAdjustParams> adjustParams = new ArrayList<>();
        StockAdjustParams adjustParam = new StockAdjustParams();
        adjustParam.setCompany_id(order.getCstmrName())
                .setWms_id(order.getId() + "")
                .setType(0 + "")
                .setCompany_id(order.getCstmrName());
        adjustParam.setBsby_no(order.getNumber())
                .setResason("")
                .setReason_name("");
        List<CheckOrderDetl> detls = checkOrderDetlService
                .selectList(new EntityWrapper<CheckOrderDetl>().eq("order_id", order.getId()));
        if (Objects.isNull(detls) || detls.isEmpty()) {
            throw new CoolException("损溢单详情不存在");
        }
        List<OrderItemsParam> items = new ArrayList<>();
        detls.forEach(detl -> {
            Mat material = matService.selectByMatnr(detl.getMatnr());
            if (Objects.isNull(material)) {
                throw new CoolException("物料不存在");
            }
            OrderItemsParam itemParam = new OrderItemsParam();
            itemParam.setLocation_no(detl.getZpallet())
                    .setPro_komcode(material.getMatnr())
                    .setPro_id(detl.getSuppCode())
                    .setBsby_qty(detl.getDiffQty().intValue());
            items.add(itemParam);
        });
        adjustParam.setDetails(items);
        adjustParams.add(adjustParam);
        return SUCCESS;
        // TODO Auto-generated method stub
    }
}