nc对接修改添加通宇

This commit is contained in:
hjx
2026-01-13 14:16:24 +08:00
parent d7df2da828
commit 32d638730d
2 changed files with 513 additions and 237 deletions
@@ -523,8 +523,6 @@ public class TmsOrder implements Serializable {
@ApiModelProperty(value = "付款方名称")
private String payer;
@ApiModelProperty("客户编码nc")
private String customerCodeNc;
@ApiModelProperty("制单人编码nc")
private String makerCodeNc;
@@ -540,4 +538,23 @@ public class TmsOrder implements Serializable {
@ApiModelProperty("合同编号")
private String contractNo;
@ApiModelProperty("客户编码nc")
private String customerCodeNc;
@ApiModelProperty(value = "组织ID")
private String orgId;
@ApiModelProperty(value = "所属组织")
private String orgName;
@ApiModelProperty(value = "组织ID")
private Long organizationId;
@ApiModelProperty(value = "组织名称")
private String organizationName;
@ApiModelProperty(value = "上级组织ID")
private Long topOrganizationId;
}
@@ -89,7 +89,11 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
private ApprovalDocumentMapper approvalDocumentMapper;
@Autowired
private ApprovalDocumentDomainService approvalDocumentDomainService;
//nc测试环境地址
private String url="http://10.0.0.212/service/XChangeServlet?account=NKNC&groupcode=CNK";
//nc正式环境地址
//private String url="http://10.0.0.202/service/XChangeServlet?account=NKNC&groupcode=CNK";
/**
* 查询对账单列表
*/
@@ -411,23 +415,24 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
reconciliationDTO.setInnerNumber(reconciliation.getInnerNumber());
R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO);
String makerCodeNc="";
if(result.getCode()==200){
List<TmsOrder> list=result.getData();
if(ObjectUtil.isNotNull(list)){
for(TmsOrder tmsOrder:list){
R<TmsTransportNote> ajaxResult1=wlhyServiceFeign.selectByOrderNum(tmsOrder.getGoodsNumber());
if(ajaxResult1.getCode()==200){
TmsTransportNote tmsTransportNote= ajaxResult1.getData();
if(ObjectUtil.isNotNull(tmsTransportNote.getIsPaper())){
date=tmsTransportNote.getConfirmReceiptTime();
if(null==date){
date=new Date();
if(reconciliation.getOrganizationName().contains("南歧")){
if(result.getCode()==200){
List<TmsOrder> list=result.getData();
if(ObjectUtil.isNotNull(list)){
for(TmsOrder tmsOrder:list){
R<TmsTransportNote> ajaxResult1=wlhyServiceFeign.selectByOrderNum(tmsOrder.getGoodsNumber());
if(ajaxResult1.getCode()==200){
TmsTransportNote tmsTransportNote= ajaxResult1.getData();
if(ObjectUtil.isNotNull(tmsTransportNote.getIsPaper())){
date=tmsTransportNote.getConfirmReceiptTime();
if(null==date){
date=new Date();
}
dateString = sdf.format(date);
}else{
throw new ServiceException("运单还没签收, 先签收");
}
dateString = sdf.format(date);
}else{
throw new ServiceException("运单还没签收, 先签收");
}
}
/* if(null==reconciliation.getSettlementPartyId()){
throw new ServiceException("没有结算方,请核对");
}*/
@@ -440,120 +445,261 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getCustomsCodeNc())) {
throw new ServiceException("请先维护制单员编码");
}*/
makerCodeNc=tmsOrder.getMakerCodeNc();
Ysitem item=new Ysitem();
item.setSo_deptid("NG040104");
item.setPk_deptid("NG040104");
item.setPk_psndoc(tmsOrder.getSalesmanCodeNc());
item.setCustomer(tmsOrder.getCustomerCodeNc());
item.setObjtype("0");
item.setDirection("1");
item.setScomment(tmsOrder.getAppointShipper());
// item.setPk_currtype("CNY");
item.setPk_currtype(tmsOrder.getSettlementCurrency());
item.setPurchaseorder(tmsOrder.getGoodsNumber());
item.setTaxrate("0");
item.setQuantity_de("0");
item.setMoney_de(String.valueOf(tmsOrder.getDeliveryFreight()));
item.setMoney_bal(String.valueOf(tmsOrder.getDeliveryFreight()));
BigDecimal tax_de=tmsOrder.getDeliveryFreight().multiply(tmsOrder.getTaxRate().divide(BigDecimal.valueOf(100))).setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal notax_de=tmsOrder.getDeliveryFreight().subtract(tax_de);
item.setNotax_de(String.valueOf(notax_de));
item.setLocal_tax_de(String.valueOf(notax_de));
item.setTax_de(String.valueOf(tax_de));
item.setPrice(String.valueOf(tmsOrder.getDeliveryFreight()));
item.setTaxprice(String.valueOf(tmsOrder.getDeliveryFreight()));
item.setDef75("T10");
item.setInvoiceno("");
ysitemList.add(item);
}
Ysbodys bodys=new Ysbodys();
bodys.setItem(ysitemList);
Ysbillhead billhead=new Ysbillhead();
billhead.setPk_group("CNK");
billhead.setPk_org("NG0401");
billhead.setSett_org("NG0401");
billhead.setCreationtime(dateString);
billhead.setCreator(makerCodeNc);
billhead.setPk_billtype("F0");
billhead.setPk_tradetype("D0");
billhead.setBillclass("ys");
billhead.setIsinit("N");
date=reconciliation.getCreateTime();
dateString = sdf.format(date);
billhead.setBilldate(dateString);
billhead.setSyscode("0");
billhead.setBillno("");
billhead.setDef59("");
billhead.setSrc_syscode("0");
billhead.setBillstatus("0");
billhead.setBillmaker(makerCodeNc);
billhead.setPk_busitype("");
billhead.setBillyear(sdf1.format(date));
billhead.setBillperiod(sdf2.format(date));
billhead.setEffectstatus("0");
billhead.setDef28("nqyw");
billhead.setDef29(reconciliation.getInnerNumber());
billhead.setBodys(bodys);
Ysbill bill=new Ysbill();
bill.setId("ys"+String.valueOf(reconciliation.getReconciliationId()));
bill.setBillhead(billhead);
Ysufinterface ufinterface=new Ysufinterface();
ufinterface.setAccount("NKNC");
ufinterface.setBilltype("F0");
ufinterface.setBusinessunitcode("");
ufinterface.setFilename("");
ufinterface.setIsexchange("Y");
ufinterface.setOrgcode("NG0401");
ufinterface.setReceiver("NG0401");
ufinterface.setReplace("Y");
ufinterface.setRoottag("");
ufinterface.setSender("nqyw");
ufinterface.setBill(bill);
JAXBContext jaxbContext = JAXBContext.newInstance(Ysufinterface.class);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选
StringWriter sw = new StringWriter();
marshaller.marshal(ufinterface, sw);
String xmlString = sw.toString(); // 这是要发送的XML字符串
System.out.println(xmlString);
NcLog ncLog=new NcLog();
ncLog.setOrderId(reconciliation.getReconciliationId());
ncLog.setRequestBody(xmlString);
ncLog.setResponeBody("");
ncLog.setType(0L);
ncLog.setOrganizationId(reconciliation.getOrganizationId());
ncLog.setOrganizationName(reconciliation.getOrganizationName());
ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId());
ncLogMapper.insert(ncLog);
reconciliation.setSynchronousStatus(1);
reconciliation.setSynchronousTime(new Date());
reconciliation.setNcId("ys"+String.valueOf(reconciliation.getReconciliationId()));
reconciliationMapper.updateById(reconciliation);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
StringEntity postingString = new StringEntity(xmlString, "UTF-8");
httpPost.setEntity(postingString);
httpPost.setHeader("Content-type", "application/xml");
try {
CloseableHttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString);
response.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
makerCodeNc=tmsOrder.getMakerCodeNc();
Ysitem item=new Ysitem();
item.setSo_deptid("NG040104");
item.setPk_deptid("NG040104");
item.setPk_psndoc(tmsOrder.getSalesmanCodeNc());
item.setCustomer(tmsOrder.getCustomerCodeNc());
item.setObjtype("0");
item.setDirection("1");
item.setScomment(tmsOrder.getAppointShipper());
// item.setPk_currtype("CNY");
item.setPk_currtype(tmsOrder.getSettlementCurrency());
item.setPurchaseorder(tmsOrder.getGoodsNumber());
item.setTaxrate("0");
item.setQuantity_de("0");
item.setMoney_de(String.valueOf(tmsOrder.getDeliveryFreight()));
item.setMoney_bal(String.valueOf(tmsOrder.getDeliveryFreight()));
BigDecimal tax_de=tmsOrder.getDeliveryFreight().multiply(tmsOrder.getTaxRate().divide(BigDecimal.valueOf(100))).setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal notax_de=tmsOrder.getDeliveryFreight().subtract(tax_de);
item.setNotax_de(String.valueOf(notax_de));
item.setLocal_tax_de(String.valueOf(notax_de));
item.setTax_de(String.valueOf(tax_de));
item.setPrice(String.valueOf(tmsOrder.getDeliveryFreight()));
item.setTaxprice(String.valueOf(tmsOrder.getDeliveryFreight()));
item.setDef75("T10");
item.setInvoiceno("");
ysitemList.add(item);
}
Ysbodys bodys=new Ysbodys();
bodys.setItem(ysitemList);
Ysbillhead billhead=new Ysbillhead();
billhead.setPk_group("CNK");
billhead.setPk_org("NG0401");
billhead.setSett_org("NG0401");
billhead.setCreationtime(dateString);
billhead.setCreator(makerCodeNc);
billhead.setPk_billtype("F0");
billhead.setPk_tradetype("D0");
billhead.setBillclass("ys");
billhead.setIsinit("N");
date=reconciliation.getCreateTime();
dateString = sdf.format(date);
billhead.setBilldate(dateString);
billhead.setSyscode("0");
billhead.setBillno("");
billhead.setDef59("");
billhead.setSrc_syscode("0");
billhead.setBillstatus("0");
billhead.setBillmaker(makerCodeNc);
billhead.setPk_busitype("");
billhead.setBillyear(sdf1.format(date));
billhead.setBillperiod(sdf2.format(date));
billhead.setEffectstatus("0");
billhead.setDef28("nqyw");
billhead.setDef29(reconciliation.getInnerNumber());
billhead.setBodys(bodys);
Ysbill bill=new Ysbill();
bill.setId("ys"+String.valueOf(reconciliation.getReconciliationId()));
bill.setBillhead(billhead);
Ysufinterface ufinterface=new Ysufinterface();
ufinterface.setAccount("NKNC");
ufinterface.setBilltype("F0");
ufinterface.setBusinessunitcode("");
ufinterface.setFilename("");
ufinterface.setIsexchange("Y");
ufinterface.setOrgcode("NG0401");
ufinterface.setReceiver("NG0401");
ufinterface.setReplace("Y");
ufinterface.setRoottag("");
ufinterface.setSender("nqyw");
ufinterface.setBill(bill);
JAXBContext jaxbContext = JAXBContext.newInstance(Ysufinterface.class);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选
StringWriter sw = new StringWriter();
marshaller.marshal(ufinterface, sw);
String xmlString = sw.toString(); // 这是要发送的XML字符串
System.out.println(xmlString);
NcLog ncLog=new NcLog();
ncLog.setOrderId(reconciliation.getReconciliationId());
ncLog.setRequestBody(xmlString);
ncLog.setResponeBody("");
ncLog.setType(0L);
ncLog.setOrganizationId(reconciliation.getOrganizationId());
ncLog.setOrganizationName(reconciliation.getOrganizationName());
ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId());
ncLogMapper.insert(ncLog);
reconciliation.setSynchronousStatus(1);
reconciliation.setSynchronousTime(new Date());
reconciliation.setNcId("ys"+String.valueOf(reconciliation.getReconciliationId()));
reconciliationMapper.updateById(reconciliation);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
StringEntity postingString = new StringEntity(xmlString, "UTF-8");
httpPost.setEntity(postingString);
httpPost.setHeader("Content-type", "application/xml");
try {
httpClient.close();
} catch (IOException e) {
CloseableHttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString);
response.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}else if(reconciliation.getOrganizationName().contains("通宇")){
if(result.getCode()==200){
List<TmsOrder> list=result.getData();
if(ObjectUtil.isNotNull(list)){
for(TmsOrder tmsOrder:list){
R<TmsTransportNote> ajaxResult1=wlhyServiceFeign.selectByOrderNum(tmsOrder.getGoodsNumber());
if(ajaxResult1.getCode()==200){
TmsTransportNote tmsTransportNote= ajaxResult1.getData();
if(ObjectUtil.isNotNull(tmsTransportNote.getIsPaper())){
date=tmsTransportNote.getConfirmReceiptTime();
if(null==date){
date=new Date();
}
dateString = sdf.format(date);
}else{
throw new ServiceException("运单还没签收, 先签收");
}
}
/* if(null==reconciliation.getSettlementPartyId()){
throw new ServiceException("没有结算方,请核对");
}*/
/* if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getSalesmanCodeNc())) {
throw new ServiceException("请先维护业务员编码");
}
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getMakerCodeNc())) {
throw new ServiceException("请先维护制单员编码");
}
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getCustomsCodeNc())) {
throw new ServiceException("请先维护制单员编码");
}*/
makerCodeNc=tmsOrder.getMakerCodeNc();
Ysitem item=new Ysitem();
item.setSo_deptid("NG0408");
item.setPk_deptid("NG0408");
item.setPk_psndoc(tmsOrder.getSalesmanCodeNc());
item.setCustomer(tmsOrder.getCustomerCodeNc());
item.setObjtype("0");
item.setDirection("1");
item.setScomment(tmsOrder.getAppointShipper());
// item.setPk_currtype("CNY");
item.setPk_currtype(tmsOrder.getSettlementCurrency());
item.setPurchaseorder(tmsOrder.getGoodsNumber());
item.setTaxrate("0");
item.setQuantity_de("0");
item.setMoney_de(String.valueOf(tmsOrder.getDeliveryFreight()));
item.setMoney_bal(String.valueOf(tmsOrder.getDeliveryFreight()));
BigDecimal tax_de=tmsOrder.getDeliveryFreight().multiply(tmsOrder.getTaxRate().divide(BigDecimal.valueOf(100))).setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal notax_de=tmsOrder.getDeliveryFreight().subtract(tax_de);
item.setNotax_de(String.valueOf(notax_de));
item.setLocal_tax_de(String.valueOf(notax_de));
item.setTax_de(String.valueOf(tax_de));
item.setPrice(String.valueOf(tmsOrder.getDeliveryFreight()));
item.setTaxprice(String.valueOf(tmsOrder.getDeliveryFreight()));
item.setDef75("T10");
item.setInvoiceno("");
ysitemList.add(item);
}
Ysbodys bodys=new Ysbodys();
bodys.setItem(ysitemList);
Ysbillhead billhead=new Ysbillhead();
billhead.setPk_group("CNK");
billhead.setPk_org("NG04");
billhead.setSett_org("NG04");
billhead.setCreationtime(dateString);
billhead.setCreator(makerCodeNc);
billhead.setPk_billtype("F0");
billhead.setPk_tradetype("D0");
billhead.setBillclass("ys");
billhead.setIsinit("N");
date=reconciliation.getCreateTime();
dateString = sdf.format(date);
billhead.setBilldate(dateString);
billhead.setSyscode("0");
billhead.setBillno("");
billhead.setDef59("");
billhead.setSrc_syscode("0");
billhead.setBillstatus("0");
billhead.setBillmaker(makerCodeNc);
billhead.setPk_busitype("");
billhead.setBillyear(sdf1.format(date));
billhead.setBillperiod(sdf2.format(date));
billhead.setEffectstatus("0");
billhead.setDef28("nqyw");
billhead.setDef29(reconciliation.getInnerNumber());
billhead.setBodys(bodys);
Ysbill bill=new Ysbill();
bill.setId("ys"+String.valueOf(reconciliation.getReconciliationId()));
bill.setBillhead(billhead);
Ysufinterface ufinterface=new Ysufinterface();
ufinterface.setAccount("NKNC");
ufinterface.setBilltype("F0");
ufinterface.setBusinessunitcode("");
ufinterface.setFilename("");
ufinterface.setIsexchange("Y");
ufinterface.setOrgcode("NG04");
ufinterface.setReceiver("NG04");
ufinterface.setReplace("Y");
ufinterface.setRoottag("");
ufinterface.setSender("nqyw");
ufinterface.setBill(bill);
JAXBContext jaxbContext = JAXBContext.newInstance(Ysufinterface.class);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选
StringWriter sw = new StringWriter();
marshaller.marshal(ufinterface, sw);
String xmlString = sw.toString(); // 这是要发送的XML字符串
System.out.println(xmlString);
NcLog ncLog=new NcLog();
ncLog.setOrderId(reconciliation.getReconciliationId());
ncLog.setRequestBody(xmlString);
ncLog.setResponeBody("");
ncLog.setType(0L);
ncLog.setOrganizationId(reconciliation.getOrganizationId());
ncLog.setOrganizationName(reconciliation.getOrganizationName());
ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId());
ncLogMapper.insert(ncLog);
reconciliation.setSynchronousStatus(1);
reconciliation.setSynchronousTime(new Date());
reconciliation.setNcId("ys"+String.valueOf(reconciliation.getReconciliationId()));
reconciliationMapper.updateById(reconciliation);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
StringEntity postingString = new StringEntity(xmlString, "UTF-8");
httpPost.setEntity(postingString);
httpPost.setHeader("Content-type", "application/xml");
try {
CloseableHttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString);
response.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
} catch (JAXBException e) {
e.printStackTrace();
}
@@ -591,37 +737,29 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
throw new ServiceException("没有结算方,请核对");
}*/
String makerCodeNc="";
R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO);
if(result.getCode()==200){
List<TmsOrder> list=result.getData();
if(ObjectUtil.isNotNull(list)){
for(TmsOrder tmsOrder:list){
/* if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getSalesmanCodeNc())) {
throw new ServiceException("请先维护业务员编码");
}
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getMakerCodeNc())) {
throw new ServiceException("请先维护制单员编码");
}
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getCustomerCodeNc())) {
throw new ServiceException("请先维护制单员编码");
}*/
if(reconciliation.getOrganizationName().contains("南歧")){
R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO);
if(result.getCode()==200){
List<TmsOrder> list=result.getData();
if(ObjectUtil.isNotNull(list)){
for(TmsOrder tmsOrder:list){
makerCodeNc=tmsOrder.getMakerCodeNc();
makerCodeNc="xiangna";
SKitem item=new SKitem();
item.setSo_deptid("NG040104");
item.setPk_deptid("NG040104");
item.setCheckdirection("ar");
item.setPk_psndoc(tmsOrder.getSalesmanCodeNc());
item.setCustomer(tmsOrder.getCustomerCodeNc());
item.setPurchaseorder(tmsOrder.getGoodsNumber());
item.setObjtype("0");
item.setDirection("1");
item.setScomment(tmsOrder.getAppointShipper());
item.setPk_currtype(tmsOrder.getSettlementCurrency());
item.setMoney_cr(String.valueOf(tmsOrder.getCollectedFreight()));
item.setMoney_bal(String.valueOf(tmsOrder.getCollectedFreight()));
ysitemList.add(item);
makerCodeNc=tmsOrder.getMakerCodeNc();
makerCodeNc="xiangna";
SKitem item=new SKitem();
item.setSo_deptid("NG040104");
item.setPk_deptid("NG040104");
item.setCheckdirection("ar");
item.setPk_psndoc(tmsOrder.getSalesmanCodeNc());
item.setCustomer(tmsOrder.getCustomerCodeNc());
item.setPurchaseorder(tmsOrder.getGoodsNumber());
item.setObjtype("0");
item.setDirection("1");
item.setScomment(tmsOrder.getAppointShipper());
item.setPk_currtype(tmsOrder.getSettlementCurrency());
item.setMoney_cr(String.valueOf(tmsOrder.getCollectedFreight()));
item.setMoney_bal(String.valueOf(tmsOrder.getCollectedFreight()));
ysitemList.add(item);
/* AjaxResult ajaxResult=userServiceFeign.getShipperSummaryData(Long.valueOf(reconciliation.getSettlementPartyId()));
if(ajaxResult.get("code").toString().equals("200")){
Object userShipperPo= ajaxResult.get("data");
@@ -633,91 +771,212 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
}*/
}
}
}
SKbodys bodys=new SKbodys();
bodys.setItem(ysitemList);
SKbillhead billhead=new SKbillhead();
billhead.setPk_group("CNK");
billhead.setPk_org("NG0401");
billhead.setSett_org("NG0401");
billhead.setCreationtime(dateString);
billhead.setPk_billtype("F2");
billhead.setCreator(makerCodeNc);
billhead.setPk_tradetype("D2");
billhead.setBillclass("sk");
billhead.setBilldate(dateString);
billhead.setSyscode("0");
billhead.setBillno("");
billhead.setDef59("");
billhead.setSrc_syscode("0");
billhead.setBillstatus("0");
billhead.setBillmaker(makerCodeNc);
billhead.setPk_busitype("");
billhead.setBillyear(sdf1.format(date));
billhead.setBillperiod(sdf2.format(date));
billhead.setEffectstatus("0");
billhead.setDef28("nqyw");
billhead.setDef29(reconciliation.getInnerNumber());
billhead.setBodys(bodys);
SKbill bill=new SKbill();
bill.setId("sk"+String.valueOf(reconciliation.getReconciliationId()));
bill.setBillhead(billhead);
SKufinterface ufinterface=new SKufinterface();
ufinterface.setAccount("NKNC");
ufinterface.setBilltype("F2");
ufinterface.setBusinessunitcode("");
ufinterface.setFilename("");
ufinterface.setIsexchange("Y");
ufinterface.setOrgcode("NG0401");
ufinterface.setReceiver("NG0401");
ufinterface.setReplace("Y");
ufinterface.setRoottag("");
ufinterface.setSender("nqyw");
ufinterface.setBill(bill);
JAXBContext jaxbContext = null;
//String xmlString ="<ufinterface account=\"NKNC\" billtype=\"F0\" businessunitcode=\"\" filename=\"\" groupcode=\"CNK\" isexchange=\"Y\" orgcode=\"NG10\" receiver=\"NG10\" replace=\"Y\" roottag=\"\" sender=\"NKT_MY\">";
jaxbContext = JAXBContext.newInstance(SKufinterface.class);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选
StringWriter sw = new StringWriter();
marshaller.marshal(ufinterface, sw);
String xmlString = sw.toString(); // 这是要发送的XML字符串
System.out.println(xmlString);
NcLog ncLog=new NcLog();
ncLog.setOrderId(reconciliation.getReconciliationId());
ncLog.setRequestBody(xmlString);
ncLog.setResponeBody("");
ncLog.setType(1L);
ncLog.setOrganizationId(reconciliation.getOrganizationId());
ncLog.setOrganizationName(reconciliation.getOrganizationName());
ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId());
ncLogMapper.insert(ncLog);
reconciliation.setSkSynchronousStatus(1);
reconciliation.setSkSynchronousTime(new Date());
reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getReconciliationId()));
reconciliationMapper.updateById(reconciliation);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
StringEntity postingString = new StringEntity(xmlString, "UTF-8");
httpPost.setEntity(postingString);
httpPost.setHeader("Content-type", "application/xml");
try {
CloseableHttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString);
response.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}else if(reconciliation.getOrganizationName().contains("通宇")){
R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO);
if(result.getCode()==200){
List<TmsOrder> list=result.getData();
if(ObjectUtil.isNotNull(list)){
for(TmsOrder tmsOrder:list){
makerCodeNc=tmsOrder.getMakerCodeNc();
makerCodeNc="luoyx";
SKitem item=new SKitem();
item.setSo_deptid("NG0408");
item.setPk_deptid("NG0408");
item.setCheckdirection("ar");
item.setPk_psndoc(tmsOrder.getSalesmanCodeNc());
item.setCustomer(tmsOrder.getCustomerCodeNc());
item.setPurchaseorder(tmsOrder.getGoodsNumber());
item.setObjtype("0");
item.setDirection("1");
item.setScomment(tmsOrder.getAppointShipper());
item.setPk_currtype(tmsOrder.getSettlementCurrency());
item.setMoney_cr(String.valueOf(tmsOrder.getCollectedFreight()));
item.setMoney_bal(String.valueOf(tmsOrder.getCollectedFreight()));
ysitemList.add(item);
/* AjaxResult ajaxResult=userServiceFeign.getShipperSummaryData(Long.valueOf(reconciliation.getSettlementPartyId()));
if(ajaxResult.get("code").toString().equals("200")){
Object userShipperPo= ajaxResult.get("data");
JSONObject jsonObject = new JSONObject((Map) userShipperPo);
if(org.apache.commons.lang.StringUtils.isBlank(jsonObject.get("customerNcCode").toString())){
throw new ServiceException("请先维护客户编码");
}
}*/
}
}
}
SKbodys bodys=new SKbodys();
bodys.setItem(ysitemList);
SKbillhead billhead=new SKbillhead();
billhead.setPk_group("CNK");
billhead.setPk_org("NG04");
billhead.setSett_org("NG04");
billhead.setCreationtime(dateString);
billhead.setPk_billtype("F2");
billhead.setCreator(makerCodeNc);
billhead.setPk_tradetype("D2");
billhead.setBillclass("sk");
billhead.setBilldate(dateString);
billhead.setSyscode("0");
billhead.setBillno("");
billhead.setDef59("");
billhead.setSrc_syscode("0");
billhead.setBillstatus("0");
billhead.setBillmaker(makerCodeNc);
billhead.setPk_busitype("");
billhead.setBillyear(sdf1.format(date));
billhead.setBillperiod(sdf2.format(date));
billhead.setEffectstatus("0");
billhead.setDef28("nqyw");
billhead.setDef29(reconciliation.getInnerNumber());
billhead.setBodys(bodys);
SKbill bill=new SKbill();
bill.setId("sk"+String.valueOf(reconciliation.getReconciliationId()));
bill.setBillhead(billhead);
SKufinterface ufinterface=new SKufinterface();
ufinterface.setAccount("NKNC");
ufinterface.setBilltype("F2");
ufinterface.setBusinessunitcode("");
ufinterface.setFilename("");
ufinterface.setIsexchange("Y");
ufinterface.setOrgcode("NG04");
ufinterface.setReceiver("NG04");
ufinterface.setReplace("Y");
ufinterface.setRoottag("");
ufinterface.setSender("nqyw");
ufinterface.setBill(bill);
JAXBContext jaxbContext = null;
//String xmlString ="<ufinterface account=\"NKNC\" billtype=\"F0\" businessunitcode=\"\" filename=\"\" groupcode=\"CNK\" isexchange=\"Y\" orgcode=\"NG10\" receiver=\"NG10\" replace=\"Y\" roottag=\"\" sender=\"NKT_MY\">";
jaxbContext = JAXBContext.newInstance(SKufinterface.class);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选
StringWriter sw = new StringWriter();
marshaller.marshal(ufinterface, sw);
String xmlString = sw.toString(); // 这是要发送的XML字符串
System.out.println(xmlString);
NcLog ncLog=new NcLog();
ncLog.setOrderId(reconciliation.getReconciliationId());
ncLog.setRequestBody(xmlString);
ncLog.setResponeBody("");
ncLog.setType(1L);
ncLog.setOrganizationId(reconciliation.getOrganizationId());
ncLog.setOrganizationName(reconciliation.getOrganizationName());
ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId());
ncLogMapper.insert(ncLog);
reconciliation.setSkSynchronousStatus(1);
reconciliation.setSkSynchronousTime(new Date());
reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getReconciliationId()));
reconciliationMapper.updateById(reconciliation);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
StringEntity postingString = new StringEntity(xmlString, "UTF-8");
httpPost.setEntity(postingString);
httpPost.setHeader("Content-type", "application/xml");
try {
CloseableHttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString);
response.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
SKbodys bodys=new SKbodys();
bodys.setItem(ysitemList);
SKbillhead billhead=new SKbillhead();
billhead.setPk_group("CNK");
billhead.setPk_org("NG0401");
billhead.setSett_org("NG0401");
billhead.setCreationtime(dateString);
billhead.setPk_billtype("F2");
billhead.setCreator(makerCodeNc);
billhead.setPk_tradetype("D2");
billhead.setBillclass("sk");
billhead.setBilldate(dateString);
billhead.setSyscode("0");
billhead.setBillno("");
billhead.setDef59("");
billhead.setSrc_syscode("0");
billhead.setBillstatus("0");
billhead.setBillmaker(makerCodeNc);
billhead.setPk_busitype("");
billhead.setBillyear(sdf1.format(date));
billhead.setBillperiod(sdf2.format(date));
billhead.setEffectstatus("0");
billhead.setDef28("nqyw");
billhead.setDef29(reconciliation.getInnerNumber());
billhead.setBodys(bodys);
SKbill bill=new SKbill();
bill.setId("sk"+String.valueOf(reconciliation.getReconciliationId()));
bill.setBillhead(billhead);
SKufinterface ufinterface=new SKufinterface();
ufinterface.setAccount("NKNC");
ufinterface.setBilltype("F2");
ufinterface.setBusinessunitcode("");
ufinterface.setFilename("");
ufinterface.setIsexchange("Y");
ufinterface.setOrgcode("NG0401");
ufinterface.setReceiver("NG0401");
ufinterface.setReplace("Y");
ufinterface.setRoottag("");
ufinterface.setSender("nqyw");
ufinterface.setBill(bill);
JAXBContext jaxbContext = null;
//String xmlString ="<ufinterface account=\"NKNC\" billtype=\"F0\" businessunitcode=\"\" filename=\"\" groupcode=\"CNK\" isexchange=\"Y\" orgcode=\"NG10\" receiver=\"NG10\" replace=\"Y\" roottag=\"\" sender=\"NKT_MY\">";
jaxbContext = JAXBContext.newInstance(SKufinterface.class);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选
StringWriter sw = new StringWriter();
marshaller.marshal(ufinterface, sw);
String xmlString = sw.toString(); // 这是要发送的XML字符串
System.out.println(xmlString);
NcLog ncLog=new NcLog();
ncLog.setOrderId(reconciliation.getReconciliationId());
ncLog.setRequestBody(xmlString);
ncLog.setResponeBody("");
ncLog.setType(1L);
ncLog.setOrganizationId(reconciliation.getOrganizationId());
ncLog.setOrganizationName(reconciliation.getOrganizationName());
ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId());
ncLogMapper.insert(ncLog);
reconciliation.setSkSynchronousStatus(1);
reconciliation.setSkSynchronousTime(new Date());
reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getReconciliationId()));
reconciliationMapper.updateById(reconciliation);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
StringEntity postingString = new StringEntity(xmlString, "UTF-8");
httpPost.setEntity(postingString);
httpPost.setHeader("Content-type", "application/xml");
try {
CloseableHttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString);
response.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (JAXBException e) {
e.printStackTrace();
}