From 1f27b82b5de1bfb7767c2fc0b8bbc37eb3acfa77 Mon Sep 17 00:00:00 2001
From: ZY <zc857179121@qq.com>
Date: 星期二, 13 五月 2025 18:01:19 +0800
Subject: [PATCH] 单据对接
---
src/main/java/com/zy/asrs/service/impl/ReportToThirdServiceImpl.java | 135 +++++++++++++++++++++++++++-----------------
1 files changed, 83 insertions(+), 52 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/ReportToThirdServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/ReportToThirdServiceImpl.java
index dc7520a..4fa99bf 100644
--- a/src/main/java/com/zy/asrs/service/impl/ReportToThirdServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/ReportToThirdServiceImpl.java
@@ -10,14 +10,21 @@
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.common.utils.Synchro;
+import com.zy.nc.SendUtil;
+import com.zy.nc.entity.NccSaleXsfhmxWms;
+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.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
@Service
@Slf4j
@@ -42,62 +49,86 @@
@Override
public void report(Order order, List<OrderDetl> orderDetls, DocType docType) {
Boolean http = false;
- switch (order.getDocType().toString()) {
- case "閿�鍞彂璐�":
- http = http("", docType.getDocName(), nyncIp + port, saveRefDelivery);
- if (Cools.isEmpty(order.getShipCode()) || order.getShipCode().equalsIgnoreCase("1")) {
-
- }
- break;
- case "浜ф垚鍝佸叆搴�":
- break;
- case "杈呮枡閲囪喘鍏ュ簱":
- break;
- case "杈呮枡鍙婃垚鍝佽浆搴�":
- break;
- case "鑷姩鍖呰鍏ュ簱":
- break;
- case "鍐呴儴璋冩嫧":
- break;
- default:
- break;
- }
- if (http) {
- // 淇敼璁㈠崟鐘舵�� 4.瀹屾垚 ===>> 6.宸蹭笂鎶�
- if (!orderService.updateSettle(order.getId(), 6L, null)) {
- throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇紝璇疯仈绯荤鐞嗗憳");
+ NcResultMessage response = null;
+ try {
+ switch (order.getDocType().toString()) {
+ case "35":
+ //缁勮瀵硅薄鏁版嵁
+ Map<String, Object> data = new HashMap<String, Object>();
+ SaleOutHeadVO saleOutHeadVO = new SaleOutHeadVO();
+ saleOutHeadVO.setPk_org("FYT");
+ saleOutHeadVO.setCwarehouseid("6101");
+ SaleOutBodyVO saleOutBodyVO = null;
+ List<SaleOutBodyVO> saleOutBodyVOList = new ArrayList<>();
+ for (OrderDetl orderDetl : orderDetls) {
+ saleOutBodyVO = new SaleOutBodyVO();
+ String remark = orderDetl.getRemark();
+ if (!Cools.isEmpty(remark)) {
+ NccSaleXsfhmxWms nccSaleXsfhmxWms = JSONObject.parseObject(remark, NccSaleXsfhmxWms.class);
+ Synchro.Copy(nccSaleXsfhmxWms, saleOutBodyVO);
+ saleOutBodyVO.setCsourcetype("4331-01");
+ saleOutBodyVO.setCsourcebillbid(nccSaleXsfhmxWms.getCdeliverybid());
+ saleOutBodyVO.setCsourcebillhid(nccSaleXsfhmxWms.getCdeliveryid());
+ }
+ saleOutBodyVO.setNnum(orderDetl.getQty());
+ saleOutBodyVOList.add(saleOutBodyVO);
+ }
+ saleOutHeadVO.setVdef2("");
+ saleOutHeadVO.setVdef3("");
+ saleOutHeadVO.setVdef4("");
+ saleOutHeadVO.setVdef7("");
+ saleOutHeadVO.setVdef8("");
+ saleOutHeadVO.setVdef13("");
+ saleOutHeadVO.setVdef14("");
+ data.put("SaleOutHeadVO", saleOutHeadVO);
+ data.put("SaleOutBodyVO", saleOutBodyVOList);
+ //鍙戦�佽姹�
+ 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 "浜ф垚鍝佸叆搴�":
+ break;
+ case "杈呮枡閲囪喘鍏ュ簱":
+ break;
+ case "杈呮枡鍙婃垚鍝佽浆搴�":
+ break;
+ case "鑷姩鍖呰鍏ュ簱":
+ break;
+ case "鍐呴儴璋冩嫧":
+ break;
+ default:
+ break;
}
+ if (http) {
+ // 淇敼璁㈠崟鐘舵�� 4.瀹屾垚 ===>> 6.宸蹭笂鎶�
+ if (!orderService.updateSettle(order.getId(), 6L, null)) {
+ throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇紝璇疯仈绯荤鐞嗗憳");
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ 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("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", url + path, JSON.toJSONString(data), response);
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- apiLogService.save(
- docType,
- url + path,
- null,
- "127.0.0.1",
- JSON.toJSONString(data),
- response,
- success
- );
- }
+ apiLogService.save(
+ docType,
+ url + path,
+ null,
+ "127.0.0.1",
+ JSON.toJSONString(data),
+ response,
+ success
+ );
return false;
}
}
--
Gitblit v1.9.1