自动化立体仓库 - WMS系统
ZY
2025-05-08 32a905fbf1daeac74cbd573e5b841709c44955c2
src/main/java/com/zy/asrs/service/impl/ReportToThirdServiceImpl.java
@@ -10,14 +10,18 @@
import com.zy.asrs.service.ApiLogService;
import com.zy.asrs.service.OrderService;
import com.zy.asrs.service.ReportToThirdService;
import com.zy.common.utils.HttpHandler;
import com.zy.nc.SendUtil;
import com.zy.nc.util.NcResultMessage;
import com.zy.nc.vo.SaleOutBodyVO;
import com.zy.nc.vo.SaleOutHeadVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
@@ -42,11 +46,29 @@
    @Override
    public void report(Order order, List<OrderDetl> orderDetls, DocType docType) {
        Boolean http = false;
        NcResultMessage response = null;
        try {
        switch (order.getDocType().toString()) {
            case "销售发货":
                http = http("", docType.getDocName(), nyncIp + port, saveRefDelivery);
                if (Cools.isEmpty(order.getShipCode()) || order.getShipCode().equalsIgnoreCase("1")) {
                    //组装对象数据
                    Map<String, Object> data = new HashMap<String, Object>();
                    SaleOutHeadVO saleOutHeadVO = new SaleOutHeadVO();
                    saleOutHeadVO.setPk_org("FYT");
                    saleOutHeadVO.setCwarehouseid("6101");
                    SaleOutBodyVO saleOutBodyVO = null;
                    for (OrderDetl orderDetl : orderDetls) {
                        saleOutBodyVO = new SaleOutBodyVO();
                        saleOutBodyVO.setCsourcebillhid("1001A1100000027XNSH2");
                        saleOutBodyVO.setCsourcebillbid("1001A1100000027YFC8U");
                        saleOutBodyVO.setCsourcetype("4331-01");
                    }
                    data.put("saleOutHeadVO", saleOutHeadVO);
                    data.put("saleOutBodyVO", saleOutBodyVO);
                    //发送请求
                    response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + port, saveRefDelivery, JSONObject.toJSONString(data));
                    if (!Cools.isEmpty(response) && response.isSuccess()) {
                        log.info("response:{}", response);
                        http = true;
                }
                break;
            case "产成品入库":
@@ -68,26 +90,17 @@
                throw new CoolException("服务器内部错误,请联系管理员");
            }
        }
        } catch (Exception e) {
            throw new CoolException("调用接口报错,请联系管理员");
        } finally {
            reportApiLog(response, order.getDocType$(), nyncIp, saveRefDelivery);
    }
    private Boolean http(Object data, String docType, String url, String path) {
    }
    private Boolean reportApiLog(Object data, String docType, String url, String path) {
        String response = "";
        boolean success = false;
        try {
            response = new HttpHandler.Builder()
                    .setUri(url)
                    .setPath(path)
                    .setJson(JSON.toJSONString(data))
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            if (jsonObject.getInteger("code").equals(1)) {
                return true;
            }
            log.error("请求接口失败!!!url:{};request:{};response:{}", url + path, JSON.toJSONString(data), response);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            apiLogService.save(
                    docType,
                    url + path,
@@ -97,7 +110,6 @@
                    response,
                    success
            );
        }
        return false;
    }
}