From 32a905fbf1daeac74cbd573e5b841709c44955c2 Mon Sep 17 00:00:00 2001 From: ZY <zc857179121@qq.com> Date: 星期四, 08 五月 2025 17:01:27 +0800 Subject: [PATCH] 代码编写 --- src/main/java/com/zy/asrs/service/impl/ReportToThirdServiceImpl.java | 116 ++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 64 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..d01e15d 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,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,62 +46,70 @@ @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 "閿�鍞彂璐�": + //缁勮瀵硅薄鏁版嵁 + 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 "浜ф垚鍝佸叆搴�": + 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) { + 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