自动化立体仓库 - WMS系统
IZCD4L12RTSW0VZ\Administrator
3 天以前 daa92640797e79b6ddf37fce330e8ccee25e88c6
src/main/java/com/zy/api/service/impl/KopenApiServiceImpl.java
@@ -1,5 +1,6 @@
package com.zy.api.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
@@ -83,6 +84,7 @@
     */
    @Override
    public XSR receiveOrders(List<PubOrderParams> orderParams, String type) {
        log.info("接收下发订单信息参数:{}", JSONObject.toJSONString(orderParams));
        orderParams.forEach(params -> {
            if (params.getType().equals(OrderWkType.getTypeVal(params.getType()))) {
                throw new CoolException("当前类型不是上架派工单!!");
@@ -102,6 +104,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public XSR getInDispatchResult(List<ReportOrderParam> params, Order order) {
        log.info("上架派工单反馈请求参数:{}", JSONObject.toJSONString(params));
        if (Objects.isNull(params)) {
            return XSR.error("参数不能为空!!");
        }
@@ -119,6 +122,7 @@
            }
            JSONObject jsonObject = JSONObject.parseObject(response);
            Integer code = jsonObject.getInteger("code");
            log.info("上架派工单返回结果:{}", JSONObject.toJSONString(response));
            if (!Objects.isNull(code) && code.equals(200)) {
                if (!Objects.isNull(order)) {
                    order.setReportOnce(5);
@@ -128,7 +132,7 @@
            } else {
                if (!Objects.isNull(order)) {
                    int reportOnce = order.getReportOnce();
                    reportOnce ++;
                    reportOnce++;
                    order.setReportOnce(reportOnce);
                    orderService.updateById(order);
                }
@@ -138,7 +142,7 @@
        } catch (Exception e) {
            if (!Objects.isNull(order)) {
                int reportOnce = order.getReportOnce();
                reportOnce ++;
                reportOnce++;
                order.setReportOnce(reportOnce);
                orderService.updateById(order);
            }
@@ -149,9 +153,10 @@
    /**
     * 获取自定义请求头
     *
     * @return java.util.Map<java.lang.String, java.lang.Object>
     * @author Ryan
     * @date 2025/12/29 9:11
     * @return java.util.Map<java.lang.String,java.lang.Object>
     */
    private Map<String, Object> getHeaderParam() {
        Map<String, Object> headerParam = new HashMap<>();
@@ -180,6 +185,8 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public XSR sendOutDispatch(List<PubOrderParams> pubOrderParams, String type) {
        log.info("备货指示派工单下发参数:{}", JSONObject.toJSONString(pubOrderParams));
        if (Objects.isNull(pubOrderParams) || pubOrderParams.isEmpty()) {
            return XSR.error("参数不能为空!!");
        }
@@ -254,6 +261,8 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public synchronized XSR basMatupdate(List<SyncMatParmas> params) {
        log.info("基础零件变更:{}", JSONArray.toJSONString(params));
        if (Objects.isNull(params) || params.isEmpty()) {
            return XSR.error("参数不能为空!!");
        }
@@ -264,7 +273,12 @@
            if (Objects.isNull(mats.getPro_type())) {
                throw new CoolException("零件类型不能为空!!");
            }
            Mat matnr = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", mats.getPro_komcode()));
            if (Objects.isNull(mats.getPro_id())) {
                throw new CoolException("供应商不能为空!!");
            }
            Mat matnr = matService.selectOne(new EntityWrapper<Mat>()
                    .eq("supp_code", mats.getPro_id())
                    .eq("matnr", mats.getPro_komcode()));
            if (!Objects.isNull(matnr)) {
                // 订单时间
                if (Utils.isValidFormat(mats.getUpdate_time(), "yyyy-MM-dd HH:mm:ss")) {
@@ -492,6 +506,8 @@
     */
    @Override
    public XSR getOutDetails(List<StockUpOrderParams> stockUpParams) {
        log.info("备货单下发参数:{}", JSONArray.toJSONString(stockUpParams));
        if (Objects.isNull(stockUpParams)) {
            return XSR.error("参数不能为空!!");
        }
@@ -550,22 +566,24 @@
            wrapper.eq("matnr", params.getPro_komcode());
        }
        Page<LocDetl> locDetls = locDetlService.selectPage(new Page<>(params.getCurr(), params.getLimit()),  wrapper);
        Page<LocDetl> locDetls = locDetlService.selectPage(new Page<>(params.getCurr(), params.getLimit()), wrapper);
        return XSR.ok(locDetls.getRecords());
    }
    /**
     * 零件损溢单下发
     *
     * @author Ryan
     * @date 2025/11/24 15:22
     *
     * @param params
     * @return com.core.common.R
     * @author Ryan
     * @date 2025/11/24 15:22
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public XSR sendStockAdjust(List<StockAdjustParams> params, Long userId) {
        log.info("零件损溢单下发参数:{}", JSONArray.toJSONString(params));
        if (Objects.isNull(params)) {
            return XSR.error("参数不能为空!!");
        }
@@ -578,11 +596,12 @@
    /**
     * 损溢单完结上报
     * @author Ryan
     * @date 2025/12/30 16:57
     *
     * @param params
     * @param order
     * @return com.zy.api.entity.dto.XSR
     * @author Ryan
     * @date 2025/12/30 16:57
     */
    @Override
    public XSR reportCheckOrder(List<StockAdjustParams> params, CheckOrder order) {
@@ -612,7 +631,7 @@
            } else {
                if (!Objects.isNull(order)) {
                    int reportOnce = order.getReportOnce();
                    reportOnce ++;
                    reportOnce++;
                    order.setReportOnce(reportOnce);
                    checkOrderService.updateById(order);
                }
@@ -634,6 +653,7 @@
    /**
     * 备货单反馈
     *
     * @param params
     * @param order
     * @return
@@ -666,7 +686,7 @@
            } else {
                if (!Objects.isNull(order)) {
                    int reportOnce = order.getReportOnce();
                    reportOnce ++;
                    reportOnce++;
                    order.setReportOnce(reportOnce);
                    orderService.updateById(order);
                }
@@ -676,7 +696,7 @@
        } catch (Exception e) {
            if (!Objects.isNull(order)) {
                int reportOnce = order.getReportOnce();
                reportOnce ++;
                reportOnce++;
                order.setReportOnce(reportOnce);
                orderService.updateById(order);
            }
@@ -685,9 +705,66 @@
        }
    }
    /** 生成新的零件损溢单
     * @param userId */
    @Transactional(rollbackFor = Exception.class)
    /**
     * 备货指示派工单反馈
     * @author Ryan
     * @date 2026/1/15 15:20
     * @param orderParams
     * @param order
     * @return com.zy.api.entity.dto.XSR
     */
    @Override
    public XSR reportOutDetailsResult(List<ReportOrderParam> orderParams, Order order) {
        if (Objects.isNull(orderParams)) {
            return XSR.error("参数不能为空!!");
        }
        String response = null;
        try {
            response = new HttpHandler.Builder()
                    .setUri(url + ":" + port)
                    .setPath(prefix + "/getOutDetailsResult")
                    .setJson(JSONObject.toJSONString(orderParams))
                    .build()
                    .doPost();
            if (Objects.isNull(response) || response.trim().isEmpty()) {
                return XSR.error("外网接口无响应!!");
            }
            JSONObject jsonObject = JSONObject.parseObject(response);
            Integer code = jsonObject.getInteger("code");
            if (!Objects.isNull(code) && code.equals(200)) {
                if (!Objects.isNull(order)) {
                    order.setReportOnce(5);
                    orderService.updateById(order);
                }
                return XSR.ok("入库单上报完成!!");
            } else {
                if (!Objects.isNull(order)) {
                    int reportOnce = order.getReportOnce();
                    reportOnce++;
                    order.setReportOnce(reportOnce);
                    orderService.updateById(order);
                }
                String msg = jsonObject.getString("message");
                return XSR.error(Objects.isNull(msg) ? "上报失败!!" : msg);
            }
        } catch (Exception e) {
            if (!Objects.isNull(order)) {
                int reportOnce = order.getReportOnce();
                reportOnce++;
                order.setReportOnce(reportOnce);
                orderService.updateById(order);
            }
            log.error(e.getMessage(), e);
            return XSR.error(e.getMessage());
        }
    }
    /**
     * 生成新的零件损溢单
     *
     * @param userId
     */
    @Transactional(rollbackFor = Exception.class)
    public void gentCheckOrders(StockAdjustParams params, Long userId) {
        if (Objects.isNull(params.getDetails()) || params.getDetails().isEmpty()) {
            throw new CoolException("订单明细不能为空!!");