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 = "付款方名称") @ApiModelProperty(value = "付款方名称")
private String payer; private String payer;
@ApiModelProperty("客户编码nc")
private String customerCodeNc;
@ApiModelProperty("制单人编码nc") @ApiModelProperty("制单人编码nc")
private String makerCodeNc; private String makerCodeNc;
@@ -540,4 +538,23 @@ public class TmsOrder implements Serializable {
@ApiModelProperty("合同编号") @ApiModelProperty("合同编号")
private String contractNo; 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; private ApprovalDocumentMapper approvalDocumentMapper;
@Autowired @Autowired
private ApprovalDocumentDomainService approvalDocumentDomainService; private ApprovalDocumentDomainService approvalDocumentDomainService;
//nc测试环境地址
private String url="http://10.0.0.212/service/XChangeServlet?account=NKNC&groupcode=CNK"; 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()); reconciliationDTO.setInnerNumber(reconciliation.getInnerNumber());
R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO); R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO);
String makerCodeNc=""; String makerCodeNc="";
if(result.getCode()==200){ if(reconciliation.getOrganizationName().contains("南歧")){
List<TmsOrder> list=result.getData(); if(result.getCode()==200){
if(ObjectUtil.isNotNull(list)){ List<TmsOrder> list=result.getData();
for(TmsOrder tmsOrder:list){ if(ObjectUtil.isNotNull(list)){
R<TmsTransportNote> ajaxResult1=wlhyServiceFeign.selectByOrderNum(tmsOrder.getGoodsNumber()); for(TmsOrder tmsOrder:list){
if(ajaxResult1.getCode()==200){ R<TmsTransportNote> ajaxResult1=wlhyServiceFeign.selectByOrderNum(tmsOrder.getGoodsNumber());
TmsTransportNote tmsTransportNote= ajaxResult1.getData(); if(ajaxResult1.getCode()==200){
if(ObjectUtil.isNotNull(tmsTransportNote.getIsPaper())){ TmsTransportNote tmsTransportNote= ajaxResult1.getData();
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{
throw new ServiceException("运单还没签收, 先签收");
} }
}
/* if(null==reconciliation.getSettlementPartyId()){ /* if(null==reconciliation.getSettlementPartyId()){
throw new ServiceException("没有结算方,请核对"); throw new ServiceException("没有结算方,请核对");
}*/ }*/
@@ -440,120 +445,261 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getCustomsCodeNc())) { if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getCustomsCodeNc())) {
throw new ServiceException("请先维护制单员编码"); throw new ServiceException("请先维护制单员编码");
}*/ }*/
makerCodeNc=tmsOrder.getMakerCodeNc(); makerCodeNc=tmsOrder.getMakerCodeNc();
Ysitem item=new Ysitem(); Ysitem item=new Ysitem();
item.setSo_deptid("NG040104"); item.setSo_deptid("NG040104");
item.setPk_deptid("NG040104"); item.setPk_deptid("NG040104");
item.setPk_psndoc(tmsOrder.getSalesmanCodeNc()); item.setPk_psndoc(tmsOrder.getSalesmanCodeNc());
item.setCustomer(tmsOrder.getCustomerCodeNc()); item.setCustomer(tmsOrder.getCustomerCodeNc());
item.setObjtype("0"); item.setObjtype("0");
item.setDirection("1"); item.setDirection("1");
item.setScomment(tmsOrder.getAppointShipper()); item.setScomment(tmsOrder.getAppointShipper());
// item.setPk_currtype("CNY"); // item.setPk_currtype("CNY");
item.setPk_currtype(tmsOrder.getSettlementCurrency()); item.setPk_currtype(tmsOrder.getSettlementCurrency());
item.setPurchaseorder(tmsOrder.getGoodsNumber()); item.setPurchaseorder(tmsOrder.getGoodsNumber());
item.setTaxrate("0"); item.setTaxrate("0");
item.setQuantity_de("0"); item.setQuantity_de("0");
item.setMoney_de(String.valueOf(tmsOrder.getDeliveryFreight())); item.setMoney_de(String.valueOf(tmsOrder.getDeliveryFreight()));
item.setMoney_bal(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 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); BigDecimal notax_de=tmsOrder.getDeliveryFreight().subtract(tax_de);
item.setNotax_de(String.valueOf(notax_de)); item.setNotax_de(String.valueOf(notax_de));
item.setLocal_tax_de(String.valueOf(notax_de)); item.setLocal_tax_de(String.valueOf(notax_de));
item.setTax_de(String.valueOf(tax_de)); item.setTax_de(String.valueOf(tax_de));
item.setPrice(String.valueOf(tmsOrder.getDeliveryFreight())); item.setPrice(String.valueOf(tmsOrder.getDeliveryFreight()));
item.setTaxprice(String.valueOf(tmsOrder.getDeliveryFreight())); item.setTaxprice(String.valueOf(tmsOrder.getDeliveryFreight()));
item.setDef75("T10"); item.setDef75("T10");
item.setInvoiceno(""); item.setInvoiceno("");
ysitemList.add(item); ysitemList.add(item);
} }
Ysbodys bodys=new Ysbodys(); Ysbodys bodys=new Ysbodys();
bodys.setItem(ysitemList); bodys.setItem(ysitemList);
Ysbillhead billhead=new Ysbillhead(); Ysbillhead billhead=new Ysbillhead();
billhead.setPk_group("CNK"); billhead.setPk_group("CNK");
billhead.setPk_org("NG0401"); billhead.setPk_org("NG0401");
billhead.setSett_org("NG0401"); billhead.setSett_org("NG0401");
billhead.setCreationtime(dateString); billhead.setCreationtime(dateString);
billhead.setCreator(makerCodeNc); billhead.setCreator(makerCodeNc);
billhead.setPk_billtype("F0"); billhead.setPk_billtype("F0");
billhead.setPk_tradetype("D0"); billhead.setPk_tradetype("D0");
billhead.setBillclass("ys"); billhead.setBillclass("ys");
billhead.setIsinit("N"); billhead.setIsinit("N");
date=reconciliation.getCreateTime(); date=reconciliation.getCreateTime();
dateString = sdf.format(date); dateString = sdf.format(date);
billhead.setBilldate(dateString); billhead.setBilldate(dateString);
billhead.setSyscode("0"); billhead.setSyscode("0");
billhead.setBillno(""); billhead.setBillno("");
billhead.setDef59(""); billhead.setDef59("");
billhead.setSrc_syscode("0"); billhead.setSrc_syscode("0");
billhead.setBillstatus("0"); billhead.setBillstatus("0");
billhead.setBillmaker(makerCodeNc); billhead.setBillmaker(makerCodeNc);
billhead.setPk_busitype(""); billhead.setPk_busitype("");
billhead.setBillyear(sdf1.format(date)); billhead.setBillyear(sdf1.format(date));
billhead.setBillperiod(sdf2.format(date)); billhead.setBillperiod(sdf2.format(date));
billhead.setEffectstatus("0"); billhead.setEffectstatus("0");
billhead.setDef28("nqyw"); billhead.setDef28("nqyw");
billhead.setDef29(reconciliation.getInnerNumber()); billhead.setDef29(reconciliation.getInnerNumber());
billhead.setBodys(bodys); billhead.setBodys(bodys);
Ysbill bill=new Ysbill(); Ysbill bill=new Ysbill();
bill.setId("ys"+String.valueOf(reconciliation.getReconciliationId())); bill.setId("ys"+String.valueOf(reconciliation.getReconciliationId()));
bill.setBillhead(billhead); bill.setBillhead(billhead);
Ysufinterface ufinterface=new Ysufinterface(); Ysufinterface ufinterface=new Ysufinterface();
ufinterface.setAccount("NKNC"); ufinterface.setAccount("NKNC");
ufinterface.setBilltype("F0"); ufinterface.setBilltype("F0");
ufinterface.setBusinessunitcode(""); ufinterface.setBusinessunitcode("");
ufinterface.setFilename(""); ufinterface.setFilename("");
ufinterface.setIsexchange("Y"); ufinterface.setIsexchange("Y");
ufinterface.setOrgcode("NG0401"); ufinterface.setOrgcode("NG0401");
ufinterface.setReceiver("NG0401"); ufinterface.setReceiver("NG0401");
ufinterface.setReplace("Y"); ufinterface.setReplace("Y");
ufinterface.setRoottag(""); ufinterface.setRoottag("");
ufinterface.setSender("nqyw"); ufinterface.setSender("nqyw");
ufinterface.setBill(bill); ufinterface.setBill(bill);
JAXBContext jaxbContext = JAXBContext.newInstance(Ysufinterface.class); JAXBContext jaxbContext = JAXBContext.newInstance(Ysufinterface.class);
Marshaller marshaller = jaxbContext.createMarshaller(); Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
marshaller.marshal(ufinterface, sw); marshaller.marshal(ufinterface, sw);
String xmlString = sw.toString(); // 这是要发送的XML字符串 String xmlString = sw.toString(); // 这是要发送的XML字符串
System.out.println(xmlString); System.out.println(xmlString);
NcLog ncLog=new NcLog(); NcLog ncLog=new NcLog();
ncLog.setOrderId(reconciliation.getReconciliationId()); ncLog.setOrderId(reconciliation.getReconciliationId());
ncLog.setRequestBody(xmlString); ncLog.setRequestBody(xmlString);
ncLog.setResponeBody(""); ncLog.setResponeBody("");
ncLog.setType(0L); ncLog.setType(0L);
ncLog.setOrganizationId(reconciliation.getOrganizationId()); ncLog.setOrganizationId(reconciliation.getOrganizationId());
ncLog.setOrganizationName(reconciliation.getOrganizationName()); ncLog.setOrganizationName(reconciliation.getOrganizationName());
ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId());
ncLogMapper.insert(ncLog); ncLogMapper.insert(ncLog);
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");
httpPost.setEntity(postingString); httpPost.setEntity(postingString);
httpPost.setHeader("Content-type", "application/xml"); 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 { try {
httpClient.close(); CloseableHttpResponse response = httpClient.execute(httpPost);
} catch (IOException e) { String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString);
response.close();
} catch (Exception e) {
e.printStackTrace(); 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) { } catch (JAXBException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -591,37 +737,29 @@ public class ReconciliationImpl extends ServiceImpl<ReconciliationMapper, Reconc
throw new ServiceException("没有结算方,请核对"); throw new ServiceException("没有结算方,请核对");
}*/ }*/
String makerCodeNc=""; String makerCodeNc="";
R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO); if(reconciliation.getOrganizationName().contains("南歧")){
if(result.getCode()==200){ R<List<TmsOrder>> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO);
List<TmsOrder> list=result.getData(); if(result.getCode()==200){
if(ObjectUtil.isNotNull(list)){ List<TmsOrder> list=result.getData();
for(TmsOrder tmsOrder:list){ if(ObjectUtil.isNotNull(list)){
/* if (org.apache.commons.lang.StringUtils.isBlank(tmsOrder.getSalesmanCodeNc())) { for(TmsOrder tmsOrder:list){
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("请先维护制单员编码");
}*/
makerCodeNc=tmsOrder.getMakerCodeNc(); makerCodeNc=tmsOrder.getMakerCodeNc();
makerCodeNc="xiangna"; makerCodeNc="xiangna";
SKitem item=new SKitem(); SKitem item=new SKitem();
item.setSo_deptid("NG040104"); item.setSo_deptid("NG040104");
item.setPk_deptid("NG040104"); item.setPk_deptid("NG040104");
item.setCheckdirection("ar"); item.setCheckdirection("ar");
item.setPk_psndoc(tmsOrder.getSalesmanCodeNc()); item.setPk_psndoc(tmsOrder.getSalesmanCodeNc());
item.setCustomer(tmsOrder.getCustomerCodeNc()); item.setCustomer(tmsOrder.getCustomerCodeNc());
item.setPurchaseorder(tmsOrder.getGoodsNumber()); item.setPurchaseorder(tmsOrder.getGoodsNumber());
item.setObjtype("0"); item.setObjtype("0");
item.setDirection("1"); item.setDirection("1");
item.setScomment(tmsOrder.getAppointShipper()); item.setScomment(tmsOrder.getAppointShipper());
item.setPk_currtype(tmsOrder.getSettlementCurrency()); item.setPk_currtype(tmsOrder.getSettlementCurrency());
item.setMoney_cr(String.valueOf(tmsOrder.getCollectedFreight())); item.setMoney_cr(String.valueOf(tmsOrder.getCollectedFreight()));
item.setMoney_bal(String.valueOf(tmsOrder.getCollectedFreight())); item.setMoney_bal(String.valueOf(tmsOrder.getCollectedFreight()));
ysitemList.add(item); ysitemList.add(item);
/* AjaxResult ajaxResult=userServiceFeign.getShipperSummaryData(Long.valueOf(reconciliation.getSettlementPartyId())); /* AjaxResult ajaxResult=userServiceFeign.getShipperSummaryData(Long.valueOf(reconciliation.getSettlementPartyId()));
if(ajaxResult.get("code").toString().equals("200")){ if(ajaxResult.get("code").toString().equals("200")){
Object userShipperPo= ajaxResult.get("data"); 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) { } catch (JAXBException e) {
e.printStackTrace(); e.printStackTrace();
} }