|
|
|
|
@@ -1,59 +1,40 @@
|
|
|
|
|
package com.wb.domainserver.domain.gcone.ordr.dlivy.service;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.StringReader;
|
|
|
|
|
import java.io.StringWriter;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
|
import com.wb.domainserver.domain.admin.store.sopmal.vo.BOShopSetupVO;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.common.service.BOCommonService;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.goods.purchs.mapper.BOPurchsMapper;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.goods.purchs.vo.BOOrderLogVO;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.mbr.mlg.service.BOMlgService;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.mbr.mlg.vo.BOMlgVO;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ntcn.mssage.service.BOMssageService;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ordr.atmcrcpmny.vo.BOAtmcRcpmnyCnfirmVO;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ordr.dlivy.mapper.BODlivyMapper;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ordr.dlivy.vo.*;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ordr.ordr.mapper.BOOrdrMapper;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ordr.ordr.service.BOOrdrService;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ordr.ordr.vo.BOOrdrLogVO;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ordr.ordr.vo.BOOrdrShippingVO;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ordr.ordr.vo.BOOrdrVO;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ordr.pay.service.BOPayService;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ordr.pay.vo.BOPayVO;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ordr.rtngudrefnd.service.BORtngudrefndService;
|
|
|
|
|
import com.wb.domainserver.exception.WnbtRestException;
|
|
|
|
|
import com.wb.domainserver.exception.code.ErrorCode;
|
|
|
|
|
import com.wb.domainserver.util.dataaccess.DataMap;
|
|
|
|
|
import com.wb.domainserver.util.string.StringUtil;
|
|
|
|
|
import io.micrometer.common.util.StringUtils;
|
|
|
|
|
import jakarta.xml.bind.JAXBContext;
|
|
|
|
|
import jakarta.xml.bind.JAXBException;
|
|
|
|
|
import jakarta.xml.bind.Marshaller;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.wb.domainserver.domain.gcone.ordr.dlivy.mapper.BODlivyMapper;
|
|
|
|
|
import com.wb.domainserver.util.dataaccess.DataMap;
|
|
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.http.*;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
import org.w3c.dom.Document;
|
|
|
|
|
import org.w3c.dom.Element;
|
|
|
|
|
import org.w3c.dom.Node;
|
|
|
|
|
import org.w3c.dom.NodeList;
|
|
|
|
|
import org.xml.sax.InputSource;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
import javax.xml.parsers.DocumentBuilder;
|
|
|
|
|
import javax.xml.parsers.DocumentBuilderFactory;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
@@ -83,6 +64,9 @@ public class BODlivyService {
|
|
|
|
|
@Autowired
|
|
|
|
|
BORtngudrefndService boRtngudrefndService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private BOCommonService boCommonService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ####################################
|
|
|
|
|
출고 리스트 서비스 시작
|
|
|
|
|
@@ -494,6 +478,167 @@ public class BODlivyService {
|
|
|
|
|
return contents;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ACI Key 발급 API
|
|
|
|
|
* @param
|
|
|
|
|
* @return List<DataMap>
|
|
|
|
|
*/
|
|
|
|
|
public DataMap selectBOAciKey() throws WnbtRestException {
|
|
|
|
|
String apiKey = boCommonService.selectAciApiKey();
|
|
|
|
|
DataMap message = new DataMap();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
headers.set("USERID", "UNIHAN");
|
|
|
|
|
headers.set("APIKEY", apiKey);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
HttpEntity<String> apiRequest =
|
|
|
|
|
new HttpEntity<>("{}", headers);
|
|
|
|
|
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
ResponseEntity<String> response = restTemplate.exchange(
|
|
|
|
|
"https://acieshop.com/api/kr/pod/v1.5/",
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
apiRequest,
|
|
|
|
|
String.class
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
JsonNode jsonNode = objectMapper.readTree(response.getBody());
|
|
|
|
|
|
|
|
|
|
message.put("status", jsonNode.get("Status").asText());
|
|
|
|
|
message.put("aciKey", jsonNode.get("ACIKey").asText());
|
|
|
|
|
message.put("errMsg", jsonNode.get("ErrMsg").asText());
|
|
|
|
|
}catch (WnbtRestException wre){
|
|
|
|
|
log.error(wre.getMessage());
|
|
|
|
|
throw wre;
|
|
|
|
|
}catch (RuntimeException re){
|
|
|
|
|
log.error(re.getMessage());
|
|
|
|
|
throw new WnbtRestException(ErrorCode.INTERNAL_SERVER_ERROR);
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new WnbtRestException(ErrorCode.INTERNAL_SERVER_ERROR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 화물 추적 - 운송장 조회 API
|
|
|
|
|
* @param boDlivyVO
|
|
|
|
|
* @return List<DataMap>
|
|
|
|
|
*/
|
|
|
|
|
public DataMap updateBOAciDelivery(BODlivyVO boDlivyVO) throws WnbtRestException {
|
|
|
|
|
DataMap aciMap = selectBOAciKey();
|
|
|
|
|
String aciKey = String.valueOf(aciMap.get("aciKey"));
|
|
|
|
|
DataMap message = new DataMap();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
headers.set("USERID", "UNIHAN");
|
|
|
|
|
headers.set("ACIKey", aciKey);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> body = new HashMap<>();
|
|
|
|
|
body.put("BLNO", mapper.selectBOOrdrInvcnb(boDlivyVO));
|
|
|
|
|
|
|
|
|
|
HttpEntity<Map<String, Object>> apiRequest =
|
|
|
|
|
new HttpEntity<>(body, headers);
|
|
|
|
|
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
ResponseEntity<String> response = restTemplate.exchange(
|
|
|
|
|
"ex",
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
apiRequest,
|
|
|
|
|
String.class
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
JsonNode jsonNode = objectMapper.readTree(response.getBody());
|
|
|
|
|
|
|
|
|
|
message.put("status", jsonNode.get("Status").asText());
|
|
|
|
|
JsonNode podInfoNode = jsonNode.get("PODInfo");
|
|
|
|
|
if(!podInfoNode.isNull()) {
|
|
|
|
|
List<DataMap> podInfoList = new ArrayList<>();
|
|
|
|
|
for(JsonNode podInfoItem : podInfoNode) {
|
|
|
|
|
DataMap PODInfo = new DataMap();
|
|
|
|
|
PODInfo.put("blno", podInfoItem.get("BLNO").asText());
|
|
|
|
|
PODInfo.put("dateLocalwhin", podInfoItem.get("DATE_LOCALWHIN").asText());
|
|
|
|
|
PODInfo.put("dateLocaldeparture", podInfoItem.get("DATE_LOCALDEPARTURE").asText());
|
|
|
|
|
PODInfo.put("dateIcnarrival", podInfoItem.get("DATE_ICNARRIVAL").asText());
|
|
|
|
|
PODInfo.put("dateCustomes", podInfoItem.get("DATE_CUSTOMES").asText());
|
|
|
|
|
PODInfo.put("dateDelivery", podInfoItem.get("DATE_DELIVERY").asText());
|
|
|
|
|
PODInfo.put("recipient", podInfoItem.get("RECIPIENT").asText());
|
|
|
|
|
PODInfo.put("wta", podInfoItem.get("WTA").asText());
|
|
|
|
|
PODInfo.put("wtdan", podInfoItem.get("WTDAN").asText());
|
|
|
|
|
|
|
|
|
|
List<DataMap> volumeList = new ArrayList<>();
|
|
|
|
|
for(JsonNode volumeItem : podInfoItem.get("VOLUME")) {
|
|
|
|
|
DataMap volume = new DataMap();
|
|
|
|
|
volume.put("width", volumeItem.get("WIDTH").asText());
|
|
|
|
|
volume.put("length", volumeItem.get("LENGTH").asText());
|
|
|
|
|
volume.put("height", volumeItem.get("HEIGHT").asText());
|
|
|
|
|
|
|
|
|
|
volumeList.add(volume);
|
|
|
|
|
}
|
|
|
|
|
PODInfo.put("volume", volumeList);
|
|
|
|
|
|
|
|
|
|
List<List> customsList = new ArrayList<>();
|
|
|
|
|
for(JsonNode customsItem : podInfoItem.get("CUSTOMS")) {
|
|
|
|
|
List<DataMap> customDetail = new ArrayList<>();
|
|
|
|
|
for(JsonNode customItem : customsItem) {
|
|
|
|
|
DataMap Custom = new DataMap();
|
|
|
|
|
Custom.put("dateEvent", customItem.get("DATE_EVENT").asText());
|
|
|
|
|
Custom.put("traceStatus", customItem.get("TRACE_STATUS").asText());
|
|
|
|
|
|
|
|
|
|
customDetail.add(Custom);
|
|
|
|
|
}
|
|
|
|
|
customsList.add(customDetail);
|
|
|
|
|
}
|
|
|
|
|
PODInfo.put("customs", customsList);
|
|
|
|
|
|
|
|
|
|
List<DataMap> localPodList = new ArrayList<>();
|
|
|
|
|
for(JsonNode localPodItem : podInfoItem.get("LOCAL_POD")) {
|
|
|
|
|
DataMap localPod = new DataMap();
|
|
|
|
|
localPod.put("traceStatus", localPodItem.get("TRACE_STATUS").asText());
|
|
|
|
|
localPod.put("dateEvent", localPodItem.get("DATE_EVENT").asText());
|
|
|
|
|
localPod.put("position", localPodItem.get("POSITION").asText());
|
|
|
|
|
|
|
|
|
|
localPodList.add(localPod);
|
|
|
|
|
}
|
|
|
|
|
PODInfo.put("localPod", localPodList);
|
|
|
|
|
|
|
|
|
|
podInfoList.add(PODInfo);
|
|
|
|
|
}
|
|
|
|
|
message.put("podInfo", podInfoList);
|
|
|
|
|
} else {
|
|
|
|
|
message.put("errMsg", jsonNode.get("ErrMsg").asText());
|
|
|
|
|
}
|
|
|
|
|
}catch (WnbtRestException wre){
|
|
|
|
|
log.error(wre.getMessage());
|
|
|
|
|
throw wre;
|
|
|
|
|
}catch (RuntimeException re){
|
|
|
|
|
log.error(re.getMessage());
|
|
|
|
|
throw new WnbtRestException(ErrorCode.INTERNAL_SERVER_ERROR);
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new WnbtRestException(ErrorCode.INTERNAL_SERVER_ERROR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 송장번호 조회
|
|
|
|
|
* @param boDlivyVO
|
|
|
|
|
* @return List<DataMap>
|
|
|
|
|
*/
|
|
|
|
|
public String selectBOOrdrInvcnb(BODlivyVO boDlivyVO) throws WnbtRestException {
|
|
|
|
|
return mapper.selectBOOrdrInvcnb(boDlivyVO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|