nc对接修改添加通宇

This commit is contained in:
hjx
2026-01-13 17:26:59 +08:00
parent 8924757467
commit 931d63a5da
2 changed files with 167 additions and 10 deletions
@@ -475,6 +475,7 @@ public class TmsOrder implements Serializable {
@ApiModelProperty(value = "已收运费") @ApiModelProperty(value = "已收运费")
private BigDecimal collectedFreight; private BigDecimal collectedFreight;
@ApiModelProperty(value = "未收运费") @ApiModelProperty(value = "未收运费")
private BigDecimal uncollectedFreight; private BigDecimal uncollectedFreight;
@ApiModelProperty(value = "少收运费") @ApiModelProperty(value = "少收运费")
@@ -49,11 +49,18 @@ import org.apache.http.util.EntityUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller; import javax.xml.bind.Marshaller;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter; import java.io.StringWriter;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.NClob; import java.sql.NClob;
@@ -535,7 +542,7 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
reconciliation.setSynchronousStatus(1); reconciliation.setSynchronousStatus(1);
reconciliation.setSynchronousTime(new Date()); reconciliation.setSynchronousTime(new Date());
reconciliation.setNcId("ys"+String.valueOf(reconciliation.getReconciliationId())); reconciliation.setNcId("ys"+String.valueOf(reconciliation.getReconciliationId()));
reconciliationMapper.updateById(reconciliation); //reconciliationMapper.updateById(reconciliation);
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url); HttpPost httpPost = new HttpPost(url);
StringEntity postingString = new StringEntity(xmlString, "UTF-8"); StringEntity postingString = new StringEntity(xmlString, "UTF-8");
@@ -545,6 +552,42 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
CloseableHttpResponse response = httpClient.execute(httpPost); CloseableHttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity()); String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString); System.out.println(responseString);
ncLog.setResponeBody(responseString);
// 创建DOM解析器
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(responseString)));
// 获取根元素
Element root = document.getDocumentElement();
// 获取ufinterface元素的属性
String billtype = root.getAttribute("billtype");
String filename = root.getAttribute("filename");
System.out.println("billtype: " + billtype);
System.out.println("filename: " + filename);
// 获取sendresult节点
NodeList sendResultList = root.getElementsByTagName("sendresult");
if (sendResultList.getLength() > 0) {
Element sendResult = (Element) sendResultList.item(0);
// 获取子元素内容
String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent();
String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent();
String content = sendResult.getElementsByTagName("content").item(0).getTextContent();
System.out.println("bdocid: " + bdocid);
System.out.println("resultcode: " + resultcode);
System.out.println("content: " + content);
if(resultcode.equals("1")){
reconciliation.setSynchronousStatus(1);
}else{
reconciliation.setSynchronousStatus(2);
}
}
ncLogMapper.updateById(ncLog);
reconciliationMapper.updateById(reconciliation);
response.close(); response.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@@ -565,15 +608,20 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
R<TmsTransportNote> ajaxResult1=wlhyServiceFeign.selectByOrderNum(tmsOrder.getGoodsNumber()); R<TmsTransportNote> ajaxResult1=wlhyServiceFeign.selectByOrderNum(tmsOrder.getGoodsNumber());
if(ajaxResult1.getCode()==200){ if(ajaxResult1.getCode()==200){
TmsTransportNote tmsTransportNote= ajaxResult1.getData(); TmsTransportNote tmsTransportNote= ajaxResult1.getData();
if(ObjectUtil.isNotNull(tmsTransportNote.getIsPaper())){ if(ObjectUtil.isNotNull(tmsTransportNote)){
date=tmsTransportNote.getConfirmReceiptTime(); if(ObjectUtil.isNotNull(tmsTransportNote.getIsPaper())){
if(null==date){ date=tmsTransportNote.getConfirmReceiptTime();
date=new Date(); if(null==date){
date=new Date();
}
dateString = sdf.format(date);
}else{
throw new ServiceException("运单还没签收, 先签收");
} }
dateString = sdf.format(date);
}else{ }else{
throw new ServiceException("运单还没签收, 先签收"); throw new ServiceException("未查询到关联运单, 请核对");
} }
} }
/* if(null==reconciliation.getSettlementPartyId()){ /* if(null==reconciliation.getSettlementPartyId()){
throw new ServiceException("没有结算方,请核对"); throw new ServiceException("没有结算方,请核对");
@@ -677,7 +725,7 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
reconciliation.setSynchronousStatus(1); reconciliation.setSynchronousStatus(1);
reconciliation.setSynchronousTime(new Date()); reconciliation.setSynchronousTime(new Date());
reconciliation.setNcId("ys"+String.valueOf(reconciliation.getReconciliationId())); reconciliation.setNcId("ys"+String.valueOf(reconciliation.getReconciliationId()));
reconciliationMapper.updateById(reconciliation); //reconciliationMapper.updateById(reconciliation);
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url); HttpPost httpPost = new HttpPost(url);
StringEntity postingString = new StringEntity(xmlString, "UTF-8"); StringEntity postingString = new StringEntity(xmlString, "UTF-8");
@@ -687,6 +735,42 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
CloseableHttpResponse response = httpClient.execute(httpPost); CloseableHttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity()); String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString); System.out.println(responseString);
ncLog.setResponeBody(responseString);
// 创建DOM解析器
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(responseString)));
// 获取根元素
Element root = document.getDocumentElement();
// 获取ufinterface元素的属性
String billtype = root.getAttribute("billtype");
String filename = root.getAttribute("filename");
System.out.println("billtype: " + billtype);
System.out.println("filename: " + filename);
// 获取sendresult节点
NodeList sendResultList = root.getElementsByTagName("sendresult");
if (sendResultList.getLength() > 0) {
Element sendResult = (Element) sendResultList.item(0);
// 获取子元素内容
String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent();
String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent();
String content = sendResult.getElementsByTagName("content").item(0).getTextContent();
System.out.println("bdocid: " + bdocid);
System.out.println("resultcode: " + resultcode);
System.out.println("content: " + content);
if(resultcode.equals("1")){
reconciliation.setSynchronousStatus(1);
}else{
reconciliation.setSynchronousStatus(2);
}
}
ncLogMapper.updateById(ncLog);
reconciliationMapper.updateById(reconciliation);
response.close(); response.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@@ -836,7 +920,7 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
reconciliation.setSkSynchronousStatus(1); reconciliation.setSkSynchronousStatus(1);
reconciliation.setSkSynchronousTime(new Date()); reconciliation.setSkSynchronousTime(new Date());
reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getReconciliationId())); reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getReconciliationId()));
reconciliationMapper.updateById(reconciliation); //reconciliationMapper.updateById(reconciliation);
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url); HttpPost httpPost = new HttpPost(url);
StringEntity postingString = new StringEntity(xmlString, "UTF-8"); StringEntity postingString = new StringEntity(xmlString, "UTF-8");
@@ -846,6 +930,42 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
CloseableHttpResponse response = httpClient.execute(httpPost); CloseableHttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity()); String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString); System.out.println(responseString);
ncLog.setResponeBody(responseString);
// 创建DOM解析器
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(responseString)));
// 获取根元素
Element root = document.getDocumentElement();
// 获取ufinterface元素的属性
String billtype = root.getAttribute("billtype");
String filename = root.getAttribute("filename");
System.out.println("billtype: " + billtype);
System.out.println("filename: " + filename);
// 获取sendresult节点
NodeList sendResultList = root.getElementsByTagName("sendresult");
if (sendResultList.getLength() > 0) {
Element sendResult = (Element) sendResultList.item(0);
// 获取子元素内容
String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent();
String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent();
String content = sendResult.getElementsByTagName("content").item(0).getTextContent();
System.out.println("bdocid: " + bdocid);
System.out.println("resultcode: " + resultcode);
System.out.println("content: " + content);
if(resultcode.equals("1")){
reconciliation.setSkSynchronousStatus(1);
}else{
reconciliation.setSkSynchronousStatus(2);
}
}
ncLogMapper.updateById(ncLog);
reconciliationMapper.updateById(reconciliation);
response.close(); response.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@@ -955,7 +1075,7 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
reconciliation.setSkSynchronousStatus(1); reconciliation.setSkSynchronousStatus(1);
reconciliation.setSkSynchronousTime(new Date()); reconciliation.setSkSynchronousTime(new Date());
reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getReconciliationId())); reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getReconciliationId()));
reconciliationMapper.updateById(reconciliation); //reconciliationMapper.updateById(reconciliation);
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url); HttpPost httpPost = new HttpPost(url);
StringEntity postingString = new StringEntity(xmlString, "UTF-8"); StringEntity postingString = new StringEntity(xmlString, "UTF-8");
@@ -965,6 +1085,42 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
CloseableHttpResponse response = httpClient.execute(httpPost); CloseableHttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity()); String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString); System.out.println(responseString);
ncLog.setResponeBody(responseString);
// 创建DOM解析器
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(responseString)));
// 获取根元素
Element root = document.getDocumentElement();
// 获取ufinterface元素的属性
String billtype = root.getAttribute("billtype");
String filename = root.getAttribute("filename");
System.out.println("billtype: " + billtype);
System.out.println("filename: " + filename);
// 获取sendresult节点
NodeList sendResultList = root.getElementsByTagName("sendresult");
if (sendResultList.getLength() > 0) {
Element sendResult = (Element) sendResultList.item(0);
// 获取子元素内容
String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent();
String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent();
String content = sendResult.getElementsByTagName("content").item(0).getTextContent();
System.out.println("bdocid: " + bdocid);
System.out.println("resultcode: " + resultcode);
System.out.println("content: " + content);
if(resultcode.equals("1")){
reconciliation.setSkSynchronousStatus(1);
}else{
reconciliation.setSkSynchronousStatus(2);
}
}
ncLogMapper.updateById(ncLog);
reconciliationMapper.updateById(reconciliation);
response.close(); response.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();